This commit is contained in:
tiago.kayaya
2021-06-16 13:29:57 +01:00
parent 3435354f55
commit 16c8e27d34
6 changed files with 195 additions and 132 deletions
+16 -9
View File
@@ -347,7 +347,7 @@ export class AgendaPage implements OnInit {
get CalendarCurrentDay ():any { get CalendarCurrentDay ():any {
console.log(this.viewDate.getDate(), '0_0') /* console.log(this.viewDate.getDate(), '0_0') */
return this.viewDate.getDate() return this.viewDate.getDate()
} }
@@ -530,10 +530,10 @@ export class AgendaPage implements OnInit {
//Inicializa o array eventSource //Inicializa o array eventSource
//this.eventSource=[]; //this.eventSource=[];
if(this.profile == "mdgpr" && this.loggeduser.Profile == 'MDGPR' ) { if(this.loggeduser.Profile == 'MDGPR' ) {
let mdOficialEvents = await this.eventService.getAllPrOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise(); let mdOficialEvents = await this.eventService.getAllMdOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise();
let mdPessoalEvents = await this.eventService.getAllPrPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise(); let mdPessoalEvents = await this.eventService.getAllMdPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise();
// calendar // calendar
this.eventSource=[]; this.eventSource=[];
@@ -708,7 +708,7 @@ export class AgendaPage implements OnInit {
//Inicializa o array eventSource //Inicializa o array eventSource
this.eventsListOficial = []; this.eventsListOficial = [];
if(this.profile == "mdgpr" && this.loggeduser.Profile == 'MDGPR') { if(this.loggeduser.Profile == 'MDGPR') {
this.eventService.getAllMdOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).subscribe(res => { this.eventService.getAllMdOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).subscribe(res => {
this.eventSource=[]; this.eventSource=[];
this.eventsListOficial = res.filter(data => data.CalendarName == "Oficial"); this.eventsListOficial = res.filter(data => data.CalendarName == "Oficial");
@@ -742,7 +742,8 @@ export class AgendaPage implements OnInit {
this.timelineBoxCorrectHeight(500); this.timelineBoxCorrectHeight(500);
this.centralizeTimeline(500); this.centralizeTimeline(500);
}); });
} else { }
else {
let prOficialEvents= await this.eventService.getAllPrOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise(); let prOficialEvents= await this.eventService.getAllPrOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise();
this.eventSource=[]; this.eventSource=[];
this.eventsListOficial = prOficialEvents.filter(data => data.CalendarName == "Oficial"); this.eventsListOficial = prOficialEvents.filter(data => data.CalendarName == "Oficial");
@@ -779,7 +780,8 @@ export class AgendaPage implements OnInit {
break; break;
} }
} else { }
else {
//this.showTimelinePR = false; //this.showTimelinePR = false;
//this.showTimelineMD = false; //this.showTimelineMD = false;
@@ -789,8 +791,8 @@ export class AgendaPage implements OnInit {
if(this.loggeduser.Profile == 'MDGPR') { if(this.loggeduser.Profile == 'MDGPR') {
let mdOficialEvents = await this.eventService.getAllPrOficialEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).toPromise(); let mdOficialEvents = await this.eventService.getAllMdOficialEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).toPromise();
let mdPessoalEvents = await this.eventService.getAllPrPessoalEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).toPromise(); let mdPessoalEvents = await this.eventService.getAllMdPessoalEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).toPromise();
if(this.segment == 'Oficial') { if(this.segment == 'Oficial') {
this.eventsList = mdOficialEvents; this.eventsList = mdOficialEvents;
@@ -842,6 +844,9 @@ export class AgendaPage implements OnInit {
} }
else{
let prOficialEvents= await this.eventService.getAllPrOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise(); let prOficialEvents= await this.eventService.getAllPrOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise();
let prPessoalEvents= await this.eventService.getAllPrPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise(); let prPessoalEvents= await this.eventService.getAllPrPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise();
@@ -891,6 +896,8 @@ export class AgendaPage implements OnInit {
this.centralizeTimeline(500); this.centralizeTimeline(500);
} }
}
} }
} }
@@ -4,7 +4,9 @@ import { EventAttachment } from 'src/app/models/attachment.model';
import { EventBody } from 'src/app/models/eventbody.model'; import { EventBody } from 'src/app/models/eventbody.model';
import { EventPerson } from 'src/app/models/eventperson.model'; import { EventPerson } from 'src/app/models/eventperson.model';
import { SearchDocument } from 'src/app/models/search-document'; import { SearchDocument } from 'src/app/models/search-document';
import { User } from 'src/app/models/user.model';
import { AttachmentsService } from 'src/app/services/attachments.service'; import { AttachmentsService } from 'src/app/services/attachments.service';
import { AuthService } from 'src/app/services/auth.service';
import { EventsService } from 'src/app/services/events.service'; import { EventsService } from 'src/app/services/events.service';
import { ToastService } from 'src/app/services/toast.service'; import { ToastService } from 'src/app/services/toast.service';
import { BadRequestPage } from 'src/app/shared/popover/bad-request/bad-request.page'; import { BadRequestPage } from 'src/app/shared/popover/bad-request/bad-request.page';
@@ -36,6 +38,8 @@ export class NewEventPage implements OnInit {
documents:SearchDocument[] = []; documents:SearchDocument[] = [];
loggeduser: User;
constructor( constructor(
private modalController: ModalController, private modalController: ModalController,
private navParams: NavParams, private navParams: NavParams,
@@ -43,11 +47,13 @@ export class NewEventPage implements OnInit {
private attachmentsService: AttachmentsService, private attachmentsService: AttachmentsService,
private animationController: AnimationController, private animationController: AnimationController,
private toastService: ToastService, private toastService: ToastService,
userService: AuthService,
) { ) {
this.loggeduser = userService.ValidatedUser;
this.postEvent = new Event(); this.postEvent = new Event();
this.eventBody = { BodyType : "1", Text : ""}; this.eventBody = { BodyType : "1", Text : ""};
this.postEvent.Body = this.eventBody; this.postEvent.Body = this.eventBody;
this.profile = this.navParams.get('profile'); /* this.profile = this.navParams.get('profile'); */
this.selectedSegment = this.navParams.get('segment'); this.selectedSegment = this.navParams.get('segment');
this.selectedDate = this.navParams.get('eventSelectedDate'); this.selectedDate = this.navParams.get('eventSelectedDate');
@@ -126,14 +132,20 @@ export class NewEventPage implements OnInit {
this.postEvent.HasAttachments = true; this.postEvent.HasAttachments = true;
} }
let eventId: string; let eventId: any;
try { try {
if(this.profile=='mdgpr') { if(this.loggeduser.Profile == 'MDGPR') {
console.log(this.loggeduser.Profile);
eventId = await this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).toPromise(); eventId = await this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).toPromise();
console.log(eventId);
} }
else if(this.profile=='pr'){ else if(this.loggeduser.Profile == 'PR'){
console.log(this.loggeduser.Profile);
eventId = await this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).toPromise(); eventId = await this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).toPromise();
} }
@@ -170,74 +182,6 @@ export class NewEventPage implements OnInit {
} }
async successMessage(message?: any, callback?) {
var notification = document.createElement('div')
notification.id = 'notification'
notification.innerHTML = `
<div class="main-content width-100 pa-20">
<p class="message d-flex align-center">
<ion-icon slot="end" class="title-icon pr-10" src="/assets/images/nofitication-success.svg"></ion-icon>
<p class="text">{{ message }}</p>
</p>
</div>
`
document.body.append(notification)
notification.querySelector('.text').innerHTML = message || 'Processo efetuado'
setTimeout(()=>{
notification.remove()
},7000)
}
async badRequest(message?: string, callback?) {
const enterAnimation = (baseEl: any) => {
const backdropAnimation = this.animationController.create()
.addElement(baseEl.querySelector('ion-backdrop')!)
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
const wrapperAnimation = this.animationController.create()
.addElement(baseEl.querySelector('.modal-wrapper')!)
.keyframes([
{ offset: 0, opacity: '1', right: '-100%' },
{ offset: 1, opacity: '1', right: '0px' }
]);
return this.animationController.create()
.addElement(baseEl)
.easing('ease-out')
.duration(500)
.addAnimation([backdropAnimation, wrapperAnimation]);
}
const leaveAnimation = (baseEl: any) => {
return enterAnimation(baseEl).direction('reverse');
}
const modal = await this.modalController.create({
enterAnimation,
leaveAnimation,
component: BadRequestPage,
componentProps: {
message: message || 'Processo efetuado' ,
},
cssClass: 'notification-modal'
});
modal.present()
setTimeout(()=>{
if (callback) {
callback()
}
modal.dismiss()
},7000)
}
async openAttendees() { async openAttendees() {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
@@ -184,6 +184,9 @@ export class EventDetailModalPage implements OnInit {
this.attachamentsService.getAttachmentsById(this.pageId).subscribe(res => { this.attachamentsService.getAttachmentsById(this.pageId).subscribe(res => {
console.log(res); console.log(res);
},(error) => {
console.log(error);
}); });
} }
async viewDocument(documenturl:string) async viewDocument(documenturl:string)
+40 -4
View File
@@ -123,13 +123,49 @@ export class EventsPage implements OnInit {
let start = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); let start = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds();
let end = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" 23:59:59"; let end = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" 23:59:59";
switch (this.segment)
if(this.loggeduser.Profile == 'MDGPR'){
let mdOficialEvents = await this.eventService.getAllMdOficialEvents(start, end).toPromise();
let mdPessoalEvents = await this.eventService.getAllMdPessoalEvents(start, end).toPromise();
this.eventsList = mdOficialEvents.concat(mdPessoalEvents);
if(this.eventsList.length > 0){
this.currentEvent = this.eventsList[0].Subject;
this.currentHoursMinutes = this.eventsList[0].StartDate;
}
this.totalEvent = this.eventsList.length;
this.showLoader = false;
}
else{
let prOficialEvents= await this.eventService.getAllPrOficialEvents(start, end).toPromise();
let prPessoalEvents= await this.eventService.getAllPrPessoalEvents(start, end).toPromise();
this.eventsList = prOficialEvents.concat(prPessoalEvents);
console.log(this.eventsList);
console.log(this.eventsList);
if(this.eventsList.length > 0){
this.currentEvent = this.eventsList[0].Subject;
this.currentHoursMinutes = this.eventsList[0].StartDate;
}
this.totalEvent = this.eventsList.length;
this.showLoader = false;
}
/* switch (this.segment)
{ {
case "Combinada": case "Combinada":
if(this.loggeduser.Profile == 'MDGPR'){ if(this.loggeduser.Profile == 'MDGPR'){
let mdOficialEvents = await this.eventService.getAllPrOficialEvents(start, end).toPromise(); let mdOficialEvents = await this.eventService.getAllMdOficialEvents(start, end).toPromise();
let mdPessoalEvents = await this.eventService.getAllPrPessoalEvents(start, end).toPromise(); let mdPessoalEvents = await this.eventService.getAllMdPessoalEvents(start, end).toPromise();
this.eventsList = mdOficialEvents.concat(mdPessoalEvents); this.eventsList = mdOficialEvents.concat(mdPessoalEvents);
@@ -190,7 +226,7 @@ export class EventsPage implements OnInit {
}); });
} }
break; break;
} } */
} }
showGreeting(){ showGreeting(){
+104 -40
View File
@@ -16,8 +16,11 @@ export class EventsService {
loggeduser: User; loggeduser: User;
headers: HttpHeaders; headers: HttpHeaders;
headersOwnerOficial: HttpHeaders; headersPrOficial: HttpHeaders;
headersOwnerPessoal: HttpHeaders; headersPrPessoal: HttpHeaders;
headersMdOficial: HttpHeaders;
headersMdPessoal: HttpHeaders;
headersSharedOficial: HttpHeaders; headersSharedOficial: HttpHeaders;
headersSharedPessoal: HttpHeaders; headersSharedPessoal: HttpHeaders;
@@ -26,51 +29,75 @@ export class EventsService {
constructor(private http: HttpClient, user: AuthService) { constructor(private http: HttpClient, user: AuthService) {
this.loggeduser = user.ValidatedUser; this.loggeduser = user.ValidatedUser;
this.headersOwnerOficial = new HttpHeaders(); this.headersMdOficial = new HttpHeaders();
this.headersOwnerPessoal = new HttpHeaders(); this.headersMdPessoal = new HttpHeaders();
this.headersPrOficial = new HttpHeaders();
this.headersPrPessoal = new HttpHeaders();
this.headersSharedOficial = new HttpHeaders(); this.headersSharedOficial = new HttpHeaders();
this.headersSharedPessoal = new HttpHeaders(); this.headersSharedPessoal = new HttpHeaders();
if(this.loggeduser.Profile == 'MDGPR'){ if(this.loggeduser.Profile == 'MDGPR'){
this.headersOwnerOficial = this.headersOwnerOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersOwnerOficial = this.headersOwnerOficial.set('CalendarId', this.loggeduser.OwnerCalendars[0].CalendarId);
this.headersOwnerOficial = this.headersOwnerOficial.set('CalendarRoleId', this.loggeduser.OwnerCalendars[0].CalendarRoleId);
this.headersOwnerPessoal = this.headersOwnerPessoal.set('Authorization', this.loggeduser.BasicAuthKey); this.loggeduser.OwnerCalendars.forEach(calendar =>{
this.headersOwnerPessoal = this.headersOwnerPessoal.set('CalendarId', this.loggeduser.OwnerCalendars[1].CalendarId); if(calendar.CalendarName == 'Oficial'){
this.headersOwnerPessoal = this.headersOwnerPessoal.set('CalendarRoleId', this.loggeduser.OwnerCalendars[1].CalendarRoleId); this.headersMdOficial = this.headersMdOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersMdOficial = this.headersMdOficial.set('CalendarId', calendar.CalendarId);
this.headersMdOficial = this.headersMdOficial.set('CalendarRoleId', calendar.CalendarRoleId);
}
else if(calendar.CalendarName == 'Pessoal'){
this.headersMdPessoal = this.headersMdPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersMdPessoal = this.headersMdPessoal.set('CalendarId', calendar.CalendarId);
this.headersMdPessoal = this.headersMdPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
this.headersSharedOficial = this.headersSharedOficial.set('Authorization', this.loggeduser.BasicAuthKey); }
this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', this.loggeduser.SharedCalendars[0].CalendarId); });
this.headersSharedOficial = this.headersSharedOficial.set('CalendarRoleId', this.loggeduser.SharedCalendars[0].CalendarRoleId);
this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', this.loggeduser.BasicAuthKey); this.loggeduser.SharedCalendars.forEach(sharedCalendar =>{
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', this.loggeduser.SharedCalendars[1].CalendarId); if(sharedCalendar.CalendarName == 'Oficial'){
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', this.loggeduser.SharedCalendars[1].CalendarRoleId); this.headersSharedOficial = this.headersSharedOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', sharedCalendar.CalendarId);
this.headersSharedOficial = this.headersSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
}
else if(sharedCalendar.CalendarName == 'Pessoal'){
this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', sharedCalendar.CalendarId);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
}
});
} }
else if(this.loggeduser.Profile == 'PR'){ else if(this.loggeduser.Profile == 'PR'){
this.headersOwnerOficial = this.headersOwnerOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersOwnerOficial = this.headersOwnerOficial.set('CalendarId', this.loggeduser.OwnerCalendars[0].CalendarId);
this.headersOwnerOficial = this.headersOwnerOficial.set('CalendarRoleId', this.loggeduser.OwnerCalendars[0].CalendarRoleId);
this.headersOwnerPessoal = this.headersOwnerPessoal.set('Authorization', this.loggeduser.BasicAuthKey); this.loggeduser.OwnerCalendars.forEach(calendar =>{
this.headersOwnerPessoal = this.headersOwnerPessoal.set('CalendarId', this.loggeduser.OwnerCalendars[1].CalendarId); if(calendar.CalendarName == 'Oficial'){
this.headersOwnerPessoal = this.headersOwnerPessoal.set('CalendarRoleId', this.loggeduser.OwnerCalendars[1].CalendarRoleId); this.headersPrOficial = this.headersPrOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersPrOficial = this.headersPrOficial.set('CalendarId', calendar.CalendarId);
this.headersPrOficial = this.headersPrOficial.set('CalendarRoleId', calendar.CalendarRoleId);
}
else if(calendar.CalendarName == 'Pessoal'){
this.headersPrPessoal = this.headersPrPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersPrPessoal = this.headersPrPessoal.set('CalendarId', calendar.CalendarId);
this.headersPrPessoal = this.headersPrPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
}
});
} }
this.headers = new HttpHeaders(); this.headers = new HttpHeaders();
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey); this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
/* this.headers = this.headers.set('CalendarId', this.loggeduser.OwnerCalendars[0].CalendarId);
this.headers = this.headers.set('CalendarRoleId', this.loggeduser.OwnerCalendars[0].CalendarRoleId); */
} }
getAllEvents(startdate:string, enddate:string): Observable<Event[]>{ /* getAllEvents(startdate:string, enddate:string): Observable<Event[]>{
const geturl = environment.apiURL + 'calendar/GetAllEvents'; const geturl = environment.apiURL + 'calendar/GetAllEvents';
let params = new HttpParams(); let params = new HttpParams();
@@ -82,7 +109,7 @@ export class EventsService {
params: params params: params
}; };
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<Event[]>(`${geturl}`, options);
} } */
getAllPrOficialEvents(startdate:string, enddate:string): Observable<Event[]>{ getAllPrOficialEvents(startdate:string, enddate:string): Observable<Event[]>{
@@ -92,8 +119,17 @@ export class EventsService {
params = params.set("Start", startdate); params = params.set("Start", startdate);
params = params.set("End", enddate); params = params.set("End", enddate);
/* switch (this.loggeduser.Profile == 'MDGPR') {
case value:
break;
default:
break;
} */
let options = { let options = {
headers: this.headersOwnerOficial, headers: this.headersPrOficial,
params: params params: params
}; };
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<Event[]>(`${geturl}`, options);
@@ -107,7 +143,7 @@ export class EventsService {
params = params.set("End", enddate); params = params.set("End", enddate);
let options = { let options = {
headers: this.headersOwnerPessoal, headers: this.headersPrPessoal,
params: params params: params
}; };
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<Event[]>(`${geturl}`, options);
@@ -121,7 +157,7 @@ export class EventsService {
params = params.set("End", enddate); params = params.set("End", enddate);
let options = { let options = {
headers: this.headersOwnerOficial, headers: this.headersMdOficial,
params: params params: params
}; };
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<Event[]>(`${geturl}`, options);
@@ -135,7 +171,7 @@ export class EventsService {
params = params.set("End", enddate); params = params.set("End", enddate);
let options = { let options = {
headers: this.headersOwnerPessoal, headers: this.headersMdPessoal,
params: params params: params
}; };
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<Event[]>(`${geturl}`, options);
@@ -239,7 +275,7 @@ export class EventsService {
return this.http.put<Event>(`${puturl}`, event, options) return this.http.put<Event>(`${puturl}`, event, options)
} }
postEvent(event:Event, calendarName:string, sharedagenda:string) /* postEvent(event:Event, calendarName:string, sharedagenda:string)
{ {
const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PostEvent'); const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PostEvent');
let params = new HttpParams(); let params = new HttpParams();
@@ -252,7 +288,7 @@ export class EventsService {
}; };
return this.http.post<Event>(`${puturl}`, event, options) return this.http.post<Event>(`${puturl}`, event, options)
} } */
postEventMd(event:Event, calendarName:string) postEventMd(event:Event, calendarName:string)
{ {
@@ -261,11 +297,25 @@ export class EventsService {
params = params.set("CalendarName", calendarName); params = params.set("CalendarName", calendarName);
let options = { let options:any;
headers: this.headers, switch (calendarName) {
params: params case 'Oficial':
}; console.log(calendarName);
options = {
headers: this.headersMdOficial,
params: params
};
break;
case 'Pessoal':
console.log(calendarName);
options = {
headers: this.headersMdPessoal,
params: params
};
break;
}
console.log(options);
return this.http.post<string>(`${puturl}`, event, options) return this.http.post<string>(`${puturl}`, event, options)
} }
@@ -276,10 +326,24 @@ export class EventsService {
params = params.set("CalendarName", calendarName); params = params.set("CalendarName", calendarName);
let options = { let options:any;
headers: this.headers, switch (calendarName) {
params: params case 'Oficial':
}; console.log(calendarName);
options = {
headers: this.headersPrOficial,
params: params
};
break;
case 'Pessoal':
console.log(calendarName);
options = {
headers: this.headersPrPessoal,
params: params
};
break;
}
return this.http.post<string>(`${puturl}`, event, options) return this.http.post<string>(`${puturl}`, event, options)
} }
@@ -12,6 +12,8 @@ import { EventAttachment } from 'src/app/models/attachment.model';
import { BadRequestPage } from '../../popover/bad-request/bad-request.page'; import { BadRequestPage } from '../../popover/bad-request/bad-request.page';
import { SuccessMessagePage} from '../../popover/success-message/success-message.page'; import { SuccessMessagePage} from '../../popover/success-message/success-message.page';
import { ToastService } from 'src/app/services/toast.service'; import { ToastService } from 'src/app/services/toast.service';
import { User } from 'src/app/models/user.model';
import { AuthService } from 'src/app/services/auth.service';
@Component({ @Component({
@@ -45,14 +47,19 @@ export class NewEventPage implements OnInit {
minDate: string; minDate: string;
loggeduser: User;
constructor( constructor(
private modalController: ModalController, private modalController: ModalController,
private eventService: EventsService, private eventService: EventsService,
private attachmentsService: AttachmentsService, private attachmentsService: AttachmentsService,
private animationController: AnimationController, private animationController: AnimationController,
private toastService: ToastService private toastService: ToastService,
private userService: AuthService,
) {} ) {
this.loggeduser = userService.ValidatedUser;
}
ngOnInit() { ngOnInit() {
@@ -173,11 +180,11 @@ export class NewEventPage implements OnInit {
this.postEvent.HasAttachments = true; this.postEvent.HasAttachments = true;
} }
if(this.profile=='mdgpr') { if(this.loggeduser.Profile == 'MDGPR') {
this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe( this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe(
async (id) => { async (id) => {
const eventId: string = id; const eventId: any = id;
const DocumentToSave: EventAttachment[] = this.documents.map((e) => { const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
return { return {
@@ -215,11 +222,13 @@ export class NewEventPage implements OnInit {
this.toastService.badRequest('Evento não criado') this.toastService.badRequest('Evento não criado')
}); });
} }
else if(this.profile=='pr') { else if(this.loggeduser.Profile == 'PR') {
this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe( this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe(
(id) => { (id) => {
console.log(id);
const eventId: string = id;
const eventId: any = id;
const DocumentToSave: EventAttachment[] = this.documents.map((e) => { const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
return { return {