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 {
console.log(this.viewDate.getDate(), '0_0')
/* console.log(this.viewDate.getDate(), '0_0') */
return this.viewDate.getDate()
}
@@ -530,10 +530,10 @@ export class AgendaPage implements OnInit {
//Inicializa o array 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 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 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.getAllMdPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise();
// calendar
this.eventSource=[];
@@ -708,7 +708,7 @@ export class AgendaPage implements OnInit {
//Inicializa o array eventSource
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.eventSource=[];
this.eventsListOficial = res.filter(data => data.CalendarName == "Oficial");
@@ -742,7 +742,8 @@ export class AgendaPage implements OnInit {
this.timelineBoxCorrectHeight(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();
this.eventSource=[];
this.eventsListOficial = prOficialEvents.filter(data => data.CalendarName == "Oficial");
@@ -779,7 +780,8 @@ export class AgendaPage implements OnInit {
break;
}
} else {
}
else {
//this.showTimelinePR = false;
//this.showTimelineMD = false;
@@ -789,8 +791,8 @@ export class AgendaPage implements OnInit {
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 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 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.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') {
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 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();
@@ -890,6 +895,8 @@ export class AgendaPage implements OnInit {
this.timelineBoxCorrectHeight(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 { EventPerson } from 'src/app/models/eventperson.model';
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 { AuthService } from 'src/app/services/auth.service';
import { EventsService } from 'src/app/services/events.service';
import { ToastService } from 'src/app/services/toast.service';
import { BadRequestPage } from 'src/app/shared/popover/bad-request/bad-request.page';
@@ -36,6 +38,8 @@ export class NewEventPage implements OnInit {
documents:SearchDocument[] = [];
loggeduser: User;
constructor(
private modalController: ModalController,
private navParams: NavParams,
@@ -43,11 +47,13 @@ export class NewEventPage implements OnInit {
private attachmentsService: AttachmentsService,
private animationController: AnimationController,
private toastService: ToastService,
userService: AuthService,
) {
this.loggeduser = userService.ValidatedUser;
this.postEvent = new Event();
this.eventBody = { BodyType : "1", Text : ""};
this.postEvent.Body = this.eventBody;
this.profile = this.navParams.get('profile');
/* this.profile = this.navParams.get('profile'); */
this.selectedSegment = this.navParams.get('segment');
this.selectedDate = this.navParams.get('eventSelectedDate');
@@ -126,14 +132,20 @@ export class NewEventPage implements OnInit {
this.postEvent.HasAttachments = true;
}
let eventId: string;
let eventId: any;
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();
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();
}
@@ -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() {
const modal = await this.modalController.create({
@@ -184,6 +184,9 @@ export class EventDetailModalPage implements OnInit {
this.attachamentsService.getAttachmentsById(this.pageId).subscribe(res => {
console.log(res);
},(error) => {
console.log(error);
});
}
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 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":
if(this.loggeduser.Profile == 'MDGPR'){
let mdOficialEvents = await this.eventService.getAllPrOficialEvents(start, end).toPromise();
let mdPessoalEvents = await this.eventService.getAllPrPessoalEvents(start, end).toPromise();
let mdOficialEvents = await this.eventService.getAllMdOficialEvents(start, end).toPromise();
let mdPessoalEvents = await this.eventService.getAllMdPessoalEvents(start, end).toPromise();
this.eventsList = mdOficialEvents.concat(mdPessoalEvents);
@@ -190,7 +226,7 @@ export class EventsPage implements OnInit {
});
}
break;
}
} */
}
showGreeting(){
+105 -41
View File
@@ -16,8 +16,11 @@ export class EventsService {
loggeduser: User;
headers: HttpHeaders;
headersOwnerOficial: HttpHeaders;
headersOwnerPessoal: HttpHeaders;
headersPrOficial: HttpHeaders;
headersPrPessoal: HttpHeaders;
headersMdOficial: HttpHeaders;
headersMdPessoal: HttpHeaders;
headersSharedOficial: HttpHeaders;
headersSharedPessoal: HttpHeaders;
@@ -26,51 +29,75 @@ export class EventsService {
constructor(private http: HttpClient, user: AuthService) {
this.loggeduser = user.ValidatedUser;
this.headersOwnerOficial = new HttpHeaders();
this.headersOwnerPessoal = new HttpHeaders();
this.headersMdOficial = new HttpHeaders();
this.headersMdPessoal = new HttpHeaders();
this.headersPrOficial = new HttpHeaders();
this.headersPrPessoal = new HttpHeaders();
this.headersSharedOficial = new HttpHeaders();
this.headersSharedPessoal = new HttpHeaders();
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.loggeduser.OwnerCalendars.forEach(calendar =>{
if(calendar.CalendarName == 'Oficial'){
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.headersOwnerPessoal = this.headersOwnerPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersOwnerPessoal = this.headersOwnerPessoal.set('CalendarId', this.loggeduser.OwnerCalendars[1].CalendarId);
this.headersOwnerPessoal = this.headersOwnerPessoal.set('CalendarRoleId', this.loggeduser.OwnerCalendars[1].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.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', this.loggeduser.SharedCalendars[1].CalendarId);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', this.loggeduser.SharedCalendars[1].CalendarRoleId);
this.loggeduser.SharedCalendars.forEach(sharedCalendar =>{
if(sharedCalendar.CalendarName == 'Oficial'){
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'){
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.headersOwnerPessoal = this.headersOwnerPessoal.set('CalendarId', this.loggeduser.OwnerCalendars[1].CalendarId);
this.headersOwnerPessoal = this.headersOwnerPessoal.set('CalendarRoleId', this.loggeduser.OwnerCalendars[1].CalendarRoleId);
this.loggeduser.OwnerCalendars.forEach(calendar =>{
if(calendar.CalendarName == 'Oficial'){
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 = 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';
let params = new HttpParams();
@@ -82,7 +109,7 @@ export class EventsService {
params: params
};
return this.http.get<Event[]>(`${geturl}`, options);
}
} */
getAllPrOficialEvents(startdate:string, enddate:string): Observable<Event[]>{
@@ -91,9 +118,18 @@ export class EventsService {
params = params.set("Start", startdate);
params = params.set("End", enddate);
/* switch (this.loggeduser.Profile == 'MDGPR') {
case value:
break;
default:
break;
} */
let options = {
headers: this.headersOwnerOficial,
headers: this.headersPrOficial,
params: params
};
return this.http.get<Event[]>(`${geturl}`, options);
@@ -107,7 +143,7 @@ export class EventsService {
params = params.set("End", enddate);
let options = {
headers: this.headersOwnerPessoal,
headers: this.headersPrPessoal,
params: params
};
return this.http.get<Event[]>(`${geturl}`, options);
@@ -121,7 +157,7 @@ export class EventsService {
params = params.set("End", enddate);
let options = {
headers: this.headersOwnerOficial,
headers: this.headersMdOficial,
params: params
};
return this.http.get<Event[]>(`${geturl}`, options);
@@ -135,7 +171,7 @@ export class EventsService {
params = params.set("End", enddate);
let options = {
headers: this.headersOwnerPessoal,
headers: this.headersMdPessoal,
params: params
};
return this.http.get<Event[]>(`${geturl}`, options);
@@ -239,7 +275,7 @@ export class EventsService {
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');
let params = new HttpParams();
@@ -252,7 +288,7 @@ export class EventsService {
};
return this.http.post<Event>(`${puturl}`, event, options)
}
} */
postEventMd(event:Event, calendarName:string)
{
@@ -261,11 +297,25 @@ export class EventsService {
params = params.set("CalendarName", calendarName);
let options = {
headers: this.headers,
params: params
};
let options:any;
switch (calendarName) {
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)
}
@@ -276,10 +326,24 @@ export class EventsService {
params = params.set("CalendarName", calendarName);
let options = {
headers: this.headers,
params: params
};
let options:any;
switch (calendarName) {
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)
}
@@ -12,6 +12,8 @@ import { EventAttachment } from 'src/app/models/attachment.model';
import { BadRequestPage } from '../../popover/bad-request/bad-request.page';
import { SuccessMessagePage} from '../../popover/success-message/success-message.page';
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({
@@ -45,14 +47,19 @@ export class NewEventPage implements OnInit {
minDate: string;
loggeduser: User;
constructor(
private modalController: ModalController,
private eventService: EventsService,
private attachmentsService: AttachmentsService,
private animationController: AnimationController,
private toastService: ToastService
private toastService: ToastService,
private userService: AuthService,
) {}
) {
this.loggeduser = userService.ValidatedUser;
}
ngOnInit() {
@@ -173,11 +180,11 @@ export class NewEventPage implements OnInit {
this.postEvent.HasAttachments = true;
}
if(this.profile=='mdgpr') {
if(this.loggeduser.Profile == 'MDGPR') {
this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe(
async (id) => {
const eventId: string = id;
const eventId: any = id;
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
return {
@@ -215,11 +222,13 @@ export class NewEventPage implements OnInit {
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(
(id) => {
console.log(id);
const eventId: string = id;
const eventId: any = id;
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
return {