diff --git a/capacitor.config.json b/capacitor.config.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/capacitor.config.json @@ -0,0 +1 @@ +{} diff --git a/nice.html b/nice.html deleted file mode 100644 index 1768917f4..000000000 --- a/nice.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - Document - - - - - - - \ No newline at end of file diff --git a/src/app/guards/inactivity.guard.ts b/src/app/guards/inactivity.guard.ts index 64fad8b0b..a3e56ca7f 100644 --- a/src/app/guards/inactivity.guard.ts +++ b/src/app/guards/inactivity.guard.ts @@ -17,12 +17,14 @@ export class InactivityGuard implements CanActivate { private router:Router, private platform: Platform, public permissionService: PermissionService, - ){} + private alertController: AlertController + ) {} canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { console.log(this.permissionList); if(this.permissionService.userPermission(this.permissionList.Agenda.access) || this.permissionService.userPermission(this.permissionList.Gabinete.access)){ @@ -33,7 +35,23 @@ export class InactivityGuard implements CanActivate { } else if(this.permissionService.userPermission(this.permissionList.Actions.access)){ this.router.navigate(['/home/publications']); + } else { + + this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Utilizador sem acesso a aplicação', + buttons: [{ + text: 'Ok', + handler: () => { + + } + }] + }).then( async (alertPopup) => { + await alertPopup.present(); + }) + } + return false } else if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin ) { return true @@ -41,6 +59,7 @@ export class InactivityGuard implements CanActivate { return true }//Mobile or Tablet without session else { + if(this.permissionService.userPermission(this.permissionList.Agenda.access) || this.permissionService.userPermission(this.permissionList.Gabinete.access)){ this.router.navigate(['/home/events']); } @@ -49,6 +68,19 @@ export class InactivityGuard implements CanActivate { } else if(this.permissionService.userPermission(this.permissionList.Actions.access)){ this.router.navigate(['/home/publications']); + } else { + this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Utilizador sem acesso a aplicação', + buttons: [{ + text: 'Ok', + handler: () => { + + } + }] + }).then( async (alertPopup)=>{ + await alertPopup.present(); + }) } return false } diff --git a/src/app/home/home.page.html b/src/app/home/home.page.html index d730cc84d..13403de01 100644 --- a/src/app/home/home.page.html +++ b/src/app/home/home.page.html @@ -1,6 +1,6 @@ - - + + diff --git a/src/app/models/agenda/AgendaEventList.ts b/src/app/models/agenda/AgendaEventList.ts index a40eba19b..1667eb464 100644 --- a/src/app/models/agenda/AgendaEventList.ts +++ b/src/app/models/agenda/AgendaEventList.ts @@ -7,6 +7,7 @@ export interface EventListStore { calendarName: "Oficial" |"Pessoal" profile: "md" | "pr", id: string + CalendarId: any } export interface EventList { diff --git a/src/app/models/user.model.ts b/src/app/models/user.model.ts index e7c5cbe56..24f420637 100644 --- a/src/app/models/user.model.ts +++ b/src/app/models/user.model.ts @@ -40,11 +40,13 @@ export class UserSession { Authorization: string; Email: string FullName: string + ManagerName: string OwnerCalendars: { CalendarId: string CalendarName: "Oficial" | "Pessoal"; CalendarRoleId: string; Id: number; + OwnerUserId: any }[] RoleDescription: string RoleID: number @@ -55,12 +57,13 @@ export class UserSession { Id: number; OwnerUserId: string; TypeShare: number; + CalendarToken: string; }[] UserName: string Password: string RochetChatUser: string RochetChatUserId: string - Profile: any; + Profile: 'PR' | 'MDGPR' | 'Consultant' | 'Department boss' | 'Assistant' | 'Director' | 'Deputy Director' | 'Secretariat' | 'Deputy Director' | 'General secretary' ; LoginPreference: 'None' | 'Password' | 'Pin' | null; PIN: string Inactivity: boolean diff --git a/src/app/pages/agenda/agenda.page.html b/src/app/pages/agenda/agenda.page.html index bd507f0a3..7a2f91fa7 100644 --- a/src/app/pages/agenda/agenda.page.html +++ b/src/app/pages/agenda/agenda.page.html @@ -93,14 +93,6 @@ -
@@ -110,12 +102,25 @@ + + +
+
+ {{ sessionStore.getInitials }} +
-
+ + - @@ -184,9 +189,7 @@
-
- -
+
@@ -228,11 +231,11 @@
-
Calendário do MDGPR
+
Calendário do MDGPR
-
Calendário do Presidente da República
+
Calendário do Presidente da República
@@ -248,6 +251,7 @@
+
@@ -290,7 +294,7 @@
-
+
diff --git a/src/app/pages/agenda/agenda.page.scss b/src/app/pages/agenda/agenda.page.scss index 39eab29b1..fc57c4e31 100644 --- a/src/app/pages/agenda/agenda.page.scss +++ b/src/app/pages/agenda/agenda.page.scss @@ -857,3 +857,26 @@ $font-size: 11pt; } } +.calendar-letters { + width: 36px; + height: 36px; + background-color: #f05d5e; + border-radius: 44px; + text-align: center; + align-items: center; + display: flex; + justify-content: center; + margin-top: -3px; + border: 1.5px solid black; + color: white; + .text{ + + } +} + + +.cal-reverse { + background: white !important; + color: black !important; + border-color: #f05d5e !important; +} \ No newline at end of file diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index 3e9ad13a3..91328044d 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -32,6 +32,7 @@ import { ChangeProfileService } from 'src/app/services/change-profile.service'; import { SqliteService } from 'src/app/services/sqlite.service'; import { BackgroundService } from 'src/app/services/background.service'; import { ThemeService } from 'src/app/services/theme.service' +import { SessionStore } from 'src/app/store/session.service'; @Component({ @@ -163,11 +164,13 @@ export class AgendaPage implements OnInit { listToPresent array = [] + sessionStore = SessionStore; + constructor( private alertCtrl: AlertController, @Inject(LOCALE_ID) private locale: string, private modalCtrl: ModalController, - private eventService: EventsService, + public eventService: EventsService, private router: Router, private sanitizer: DomSanitizer, authService: AuthService, @@ -192,16 +195,27 @@ export class AgendaPage implements OnInit { if (this.loggeduser.Profile == 'MDGPR') { this.mobileComponent.showEventList = true; this.profile = "mdgpr"; - } else { + } else if (this.loggeduser.Profile == 'PR') { this.profile = "pr"; + } else { + this.profile = "mdgpr"; } }) if (this.loggeduser.Profile == 'MDGPR') { this.mobileComponent.showEventList = true; this.profile = "mdgpr"; - } else { + } else if (this.loggeduser.Profile == 'PR') { this.profile = "pr"; + } else { + if(this.eventService.calendarOwnerIds.length >= 2) { + this.profile = "mdgpr"; + } else if (this.eventService.hasOwnCalendar) { + this.profile = "mdgpr"; + } else if (this.eventService.hasSharedCalendar) { + this.profile = "pr"; + } + } this.calendarHeight = "356px"; @@ -285,6 +299,7 @@ export class AgendaPage implements OnInit { /* console.log('Event clicked', event); */ //clear + console.log(event) this.setIntervenient([]); this.setIntervenientCC([]); @@ -529,8 +544,7 @@ export class AgendaPage implements OnInit { }).catch((error) => { this.getFromDB(); - }) - .finally(() => { + }).finally(() => { this.showLoader = false; }) @@ -560,9 +574,9 @@ export class AgendaPage implements OnInit { }).catch((error) => { this.getFromDB() }) - .finally(() => { - this.showLoader = false; - }) + .finally(() => { + this.showLoader = false; + }) } else if (this.loggeduser.Profile == 'PR') { @@ -597,6 +611,69 @@ export class AgendaPage implements OnInit { .finally(() => { this.showLoader = false; }) + } else if (this.loggeduser.Profile != 'PR' && this.loggeduser.Profile != 'MDGPR'){ + if(this.profile == "mdgpr") { + + this.eventService.getAllOwnEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then( + + (response: any) => { + console.log('ALL MD EVENTS', response); + + this.addEventToDB(response, "md"); + + // calendar + this.CalendarStore.removeRange(startTime, endTime, 'md') + + // loop + this.CalendarStore.pushEvent(response, 'md'); + + console.log('CALENDAR STORE', this.CalendarStore.eventSource) + this.listToPresent = this.CalendarStore.eventSource + this.trasnformData(response, 'md'); + + this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + + console.log('check list to present data', this.listToPresent); + this.myCal.update(); + this.myCal.loadEvents(); + + this.showLoader = false; + this.showTimeline = true; + + }).catch((error) => { + this.getFromDB(); + }).finally(() => { + this.showLoader = false; + }) + + } else if (this.profile == "pr" ) { + + this.eventService.genericGetAllSharedEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => { + this.addEventToDB(response, "pr"); + + this.CalendarStore.removeRange(startTime, endTime, 'pr') + // calendar + this.CalendarStore.pushEvent(response, 'pr'); + + this.listToPresent = this.CalendarStore.eventSource + + + this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + + console.log('check list to present data', this.listToPresent); + this.myCal.update(); + this.myCal.loadEvents(); + + this.showLoader = false; + this.showTimeline = true; + + }).catch((error) => { + this.getFromDB() + }).finally(() => { + this.showLoader = false; + }) + + } } } else { @@ -604,7 +681,6 @@ export class AgendaPage implements OnInit { let counter = 0; - // view MDGPR calendar with MDGPR profile if (this.loggeduser.Profile == 'MDGPR') { this.eventService.getAllMdEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => { @@ -635,13 +711,12 @@ export class AgendaPage implements OnInit { }).catch((error) => { this.getFromDB() + }).finally(() => { + counter++; + if (counter == 2) { + this.showLoader = false; + } }) - .finally(() => { - counter++; - if (counter == 2) { - this.showLoader = false; - } - }) this.eventService.getAllSharedEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => { @@ -673,15 +748,14 @@ export class AgendaPage implements OnInit { }).catch((error) => { this.getFromDB() - }) - .finally(() => { + }).finally(() => { counter++; - if (counter == 2) { - this.showLoader = false; - } - }) + if (counter == 2) { + this.showLoader = false; + } + }) - } else { + } else if(this.loggeduser.Profile == 'PR') { // view PR calendar with PR profile this.eventService.getAllPrEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => { @@ -719,12 +793,104 @@ export class AgendaPage implements OnInit { }).catch((error) => { this.getFromDB() + }).finally(() => { + if (counter == 1 || this.loggeduser.Profile == 'PR') { + this.showLoader = false; + } }) - .finally(() => { - if (counter == 1 || this.loggeduser.Profile == 'PR') { + + } else { + + if(this.loggeduser.OwnerCalendars.length != 0) { + + this.eventService.getAllOwnEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => { + + this.addEventToDB(response, "md"); + let eventsList = response; + + this.CalendarStore.removeRange(startTime, endTime, 'md') + + // loop + this.CalendarStore.pushEvent(eventsList, 'md'); + + this.listToPresent = this.CalendarStore.eventSource + + this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + + this.myCal.update(); + this.myCal.loadEvents(); + + this.showTimelineMD = true; + + counter++; + if (counter == 2) { + this.showLoader = false; + } + + + }).catch((error) => { + this.getFromDB() + }).finally(() => { + counter++; + if (counter == 2) { this.showLoader = false; } }) + } else { + counter++; + if (counter == 2) { + this.showLoader = false; + } + } + + console.log(this.loggeduser.SharedCalendars) + + if(this.loggeduser.SharedCalendars.length != 0) { + + + this.eventService.genericGetAllSharedEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => { + + this.addEventToDB(response, "pr"); + let eventsList = response; + + // clear the current month only + this.CalendarStore.removeRange(startTime, endTime, 'pr') + + + this.CalendarStore.pushEvent(eventsList, 'pr'); + this.listToPresent = this.CalendarStore.eventSource + + + this.TimelinePRList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + + console.log('check list to present data', this.listToPresent); + + this.myCal.update(); + this.myCal.loadEvents(); + + this.showTimelinePR = true; + + counter++; + + if (counter == 2 || this.loggeduser.Profile == 'PR') { + this.showLoader = false; + } + + }).catch((error) => { + this.getFromDB() + }) + .finally(() => { + counter++; + if (counter == 2) { + this.showLoader = false; + } + }) + } else { + counter++; + if (counter == 2) { + this.showLoader = false; + } + } } @@ -751,21 +917,25 @@ export class AgendaPage implements OnInit { //Deve ser removido para ficar só um method transform trasnformDataDB(response) { - console.log('Transform ', response) - response.forEach(element => { - let event = { - startTime: new Date(element.StartDate), - endTime: new Date(element.EndDate), - allDay: false, - event: element, - calendarName: element.CalendarName, - profile: element.Profile, - id: element.EventId, - } - this.array.push(event) - }); - this.listToPresent = this.array; - console.log('LIST TO PRESET', this.listToPresent) + + if(response) { + console.log('Transform ', response) + response.forEach(element => { + let event = { + startTime: new Date(element.StartDate), + endTime: new Date(element.EndDate), + allDay: false, + event: element, + calendarName: element.CalendarName, + profile: element.Profile, + id: element.EventId, + } + this.array.push(event) + }); + this.listToPresent = this.array; + console.log('LIST TO PRESET', this.listToPresent) + } + } addEventToDB(response, profile) { @@ -848,6 +1018,25 @@ export class AgendaPage implements OnInit { } + + getEventsFromDB () { + + new Promise((resolve, reject)=>{ + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + this.storage.get('agendaResponse').then((events) => { + resolve(events) + }) + } else { + this.sqliteservice.getAllEvents().then((events: any[]) => { + resolve(events) + + }) + } + }) + + + } + updateEventListBox() { if (window.innerWidth < 800) { @@ -866,6 +1055,14 @@ export class AgendaPage implements OnInit { } else if (this.loggeduser.Profile == 'PR') { this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + } else { + + if(this.profile == "pr") { + this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + } else if (this.profile == "mdgpr") { + this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + } + } break; @@ -875,9 +1072,15 @@ export class AgendaPage implements OnInit { this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) } - else { + else if(this.loggeduser.Profile == 'PR') { this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) this.TimelinePRList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + } else { + if(this.profile == "pr") { + this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + } else if (this.profile == "mdgpr") { + this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + } } break; @@ -886,15 +1089,22 @@ export class AgendaPage implements OnInit { if (this.profile == "mdgpr" && this.loggeduser.Profile == 'MDGPR') { this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, {segment: this.segment, selectedDate: this.eventSelectedDate}) - } else { + } else if(this.loggeduser.Profile == 'PR') { this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) this.TimelinePRList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + } else { + if(this.profile == "pr") { + this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + } else if (this.profile == "mdgpr") { + this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + } } break; } } else { + this.TimelinePRList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) diff --git a/src/app/pages/agenda/edit-event/edit-event.page.ts b/src/app/pages/agenda/edit-event/edit-event.page.ts index 18db101f0..4646d9b17 100644 --- a/src/app/pages/agenda/edit-event/edit-event.page.ts +++ b/src/app/pages/agenda/edit-event/edit-event.page.ts @@ -14,6 +14,8 @@ import { SearchPage } from '../../search/search.page'; import { ThemeService } from 'src/app/services/theme.service'; import { NgxMatDateFormats } from '@angular-material-components/datetime-picker'; import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker'; +import { SessionStore } from 'src/app/store/session.service'; + const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { parse: { @@ -79,6 +81,8 @@ export class EditEventPage implements OnInit { public stepMinutes = [1, 5, 10, 15, 20, 25]; public stepSeconds = [1, 5, 10, 15, 20, 25]; + sesseionStora = SessionStore + constructor( private modalController: ModalController, private navParams: NavParams, @@ -249,29 +253,57 @@ export class EditEventPage implements OnInit { this.postEvent.EventRecurrence.Type = this.selectedRecurringType; - this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => { + if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { + this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => { - if(this.initCalendarName != this.postEvent.CalendarName) { - - let body = { - "EventId": this.postEvent.EventId, - "CalendarDestinationName": this.postEvent.CalendarName, + if(this.initCalendarName != this.postEvent.CalendarName) { + + let body = { + "EventId": this.postEvent.EventId, + "CalendarDestinationName": this.postEvent.CalendarName, + } + try { + await this.eventsService.changeAgenda(body).toPromise(); + } catch (error) {} + finally { + this.goBack(); + } + } - try { - await this.eventsService.changeAgenda(body).toPromise(); - } catch (error) {} - finally { - this.goBack(); + + this.toastService.successMessage(); + + }, error => { + if(error.status != 0) + this.toastService.badRequest() + }); + } else { + this.eventsService.editEvent(this.postEvent, 2, 3, this.postEvent.CalendarId).subscribe(async () => { + + if(this.initCalendarName != this.postEvent.CalendarName) { + + let body = { + "EventId": this.postEvent.EventId, + "CalendarDestinationName": this.postEvent.CalendarName, + } + try { + await this.eventsService.changeAgenda(body).toPromise(); + } catch (error) {} + finally { + this.goBack(); + } + } + + this.toastService.successMessage(); + + }, error => { + if(error.status != 0) + this.toastService.badRequest() + }); + } - } - - this.toastService.successMessage(); - - }, error => { - if(error.status != 0) - this.toastService.badRequest() - }); + this.isEventEdited = true; diff --git a/src/app/pages/agenda/new-event/new-event.page.ts b/src/app/pages/agenda/new-event/new-event.page.ts index dd6468e00..20a5c7b13 100644 --- a/src/app/pages/agenda/new-event/new-event.page.ts +++ b/src/app/pages/agenda/new-event/new-event.page.ts @@ -14,7 +14,6 @@ import { AttendeesPageModal } from '../../events/attendees/attendees.page'; import { SearchPage } from '../../search/search.page'; import { ThemePalette } from '@angular/material/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { EventRecurrence } from 'src/app/models/agenda/eventrecurrence.model'; import { ThemeService } from 'src/app/services/theme.service'; import { NgxMatDateFormats } from '@angular-material-components/datetime-picker'; import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker'; @@ -129,7 +128,6 @@ export class NewEventPage implements OnInit { console.log(this.postEvent); console.log(this.selectedSegment); - this.getRecurrenceTypes(); if(this.selectedSegment != "Combinada"){ @@ -302,7 +300,7 @@ export class NewEventPage implements OnInit { - if(this.CalendarName == 'MDGPR') { + if(this.loggeduser.Profile == 'MDGPR') { console.log(this.loggeduser.Profile); console.log(this.postEvent); @@ -311,10 +309,12 @@ export class NewEventPage implements OnInit { console.log(eventId); } - else if(this.CalendarName == 'PR'){ + else if(this.loggeduser.Profile == 'PR') { console.log(this.loggeduser.Profile); eventId = await this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).toPromise(); + } else { + eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName).toPromise(); } const DocumentToSave: EventAttachment[] = this.documents.map((e) => { diff --git a/src/app/pages/agenda/view-event/view-event.page.ts b/src/app/pages/agenda/view-event/view-event.page.ts index 4c9c36f76..cf1ef745d 100644 --- a/src/app/pages/agenda/view-event/view-event.page.ts +++ b/src/app/pages/agenda/view-event/view-event.page.ts @@ -22,6 +22,8 @@ import { StorageService } from 'src/app/services/storage.service'; import { ThemeService } from 'src/app/services/theme.service' import { RouteService } from 'src/app/services/route.service'; import { Storage } from '@ionic/storage'; +import { SessionStore } from 'src/app/store/session.service'; +import { CalendarService } from 'src/app/store/calendar.service'; @Component({ @@ -55,7 +57,7 @@ export class ViewEventPage implements OnInit { header = true task: ExpedientTaskModalPageNavParamsTask; LoadedDocument: any = null; - + sesseionStora = SessionStore constructor( private modalController: ModalController, /* private navParams: NavParams, */ @@ -75,7 +77,8 @@ export class ViewEventPage implements OnInit { private storage: StorageService, public ThemeService: ThemeService, private RouteService: RouteService, - private ionicStorage: Storage + private ionicStorage: Storage, + private CalendarService: CalendarService ) { this.isEventEdited = false; this.loadedEvent = new Event(); @@ -96,13 +99,6 @@ export class ViewEventPage implements OnInit { } }); - /* this.activatedRoute.queryParams.subscribe(params => { - if(params["eventId"]) { - this.eventId = params["eventId"]; - console.log(params["eventId"]); - } - }); */ - } ngOnInit() { @@ -137,6 +133,23 @@ export class ViewEventPage implements OnInit { } + getEventsFromDB () { + + return new Promise((resolve, reject) => { + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + this.storage.get('agendaResponse').then((events) => { + resolve(events) + }) + } else { + this.sqliteservice.getAllEvents().then((events: any[]) => { + resolve(events) + + }) + } + }) + } + + close() { this.modalController.dismiss(this.isEventEdited); @@ -166,51 +179,108 @@ export class ViewEventPage implements OnInit { loadEvent() { const loader = this.toastService.loading(); - this.eventsService.getEvent(this.eventId).subscribe(res => { - this.loadedEvent = res; - this.addEventToDb(res); - console.log('Loaded one event', res) - /* this.today = new Date(res.StartDate); - this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */ - loader.remove() - }, (error) => { - - console.log('errorstatus ss',error.status) - - if (error.status === 0) { - this.getFromDb(); - } else { - this.toastService.badRequest('Este evento já não existe na sua agenda') + + if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { + this.eventsService.getEvent(this.eventId).subscribe(res => { + this.loadedEvent = res; + this.addEventToDb(res); + console.log('Loaded one event', res) + /* this.today = new Date(res.StartDate); + this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */ loader.remove() - this.modalController.dismiss('Eevent not Foud'); - this.RouteService.goBack(); + }, (error) => { + + console.log('errorstatus ss',error.status) + + if (error.status === 0) { + this.getFromDb(); + } else { + this.toastService.badRequest('Este evento já não existe na sua agenda') + loader.remove() + this.modalController.dismiss('Eevent not Foud'); + this.RouteService.goBack(); + } + loader.remove() + }); + } else { + + const event = this.CalendarService.eventSource.find((ele) => ele.id == this.eventId) + + // console.log('View event details', event) + + if(event?.CalendarId) { + this.eventsService.genericGetEvent(this.eventId, event.CalendarId).subscribe(res => { + this.loadedEvent = res; + this.addEventToDb(res); + console.log('Loaded one event', res) + /* this.today = new Date(res.StartDate); + this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */ + loader.remove() + }, (error) => { + + console.log('errorstatus ss',error.status) + + if (error.status === 0) { + this.getFromDb(); + } else { + this.toastService.badRequest('Este evento já não existe na sua agenda') + loader.remove() + this.modalController.dismiss('Eevent not Foud'); + this.RouteService.goBack(); + } + loader.remove() + }); } - loader.remove() - }); + + } + + + } deleteEvent() { const loader = this.toastService.loading() - this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => { - const alert = await this.alertController.create({ - cssClass: 'my-custom-class', - header: 'Evento removido', - buttons: ['OK'] + if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { + this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => { + const alert = await this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Evento removido', + buttons: ['OK'] + }); + + setTimeout(() => { + alert.dismiss(); + }, 1500); + this.goBack(); + this.toastService.successMessage('Evento apagado'); + }, () => { }, + () => { + loader.remove(); + }); + + } else { + + this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, this.loadedEvent.CalendarId).subscribe(async () => { + const alert = await this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Evento removido', + buttons: ['OK'] + }); + + setTimeout(() => { + alert.dismiss(); + }, 1500); + this.goBack(); + this.toastService.successMessage('Evento apagado'); + }, () => { }, + () => { + loader.remove(); }); - - setTimeout(() => { - alert.dismiss(); - }, 1500); - this.goBack(); - this.toastService.successMessage('Evento apagado'); - }, () => { }, - () => { - loader.remove(); - }); - - loader.remove(); + + + } } diff --git a/src/app/pages/chat/group-messages/group-messages.page.html b/src/app/pages/chat/group-messages/group-messages.page.html index 28b5366ad..719f24dcc 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.html +++ b/src/app/pages/chat/group-messages/group-messages.page.html @@ -65,6 +65,14 @@
{{msg.msg}} {{msg.msg}} + + + + + + + + {{last ? scrollToBottom() : ''}}
@@ -108,6 +116,12 @@
image + + + + + +
@@ -115,6 +129,7 @@ + @@ -138,6 +153,13 @@ {{msg.displayType}} + + + + + + +
diff --git a/src/app/pages/chat/group-messages/group-messages.page.scss b/src/app/pages/chat/group-messages/group-messages.page.scss index 65dbba56d..89849c416 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.scss +++ b/src/app/pages/chat/group-messages/group-messages.page.scss @@ -359,3 +359,31 @@ .typing ngx-letters-avatar { padding-right: 5px; } + + +.float-status{ + position: relative !important; + float: right; + display: flex; + align-items: self-end; +} + +.float-status-image{ + position: relative !important; + float: right; + display: flex; + align-items: self-end; + top: -15px; +} + +.float-status-webtrix { + position: relative !important; + top: 0px !important; + float: right; + display: flex; + align-items: self-end; +} + +.float-status-all { + font-size: 10pt !important; +} diff --git a/src/app/pages/chat/group-messages/group-messages.page.ts b/src/app/pages/chat/group-messages/group-messages.page.ts index 67151d38a..b17cbd288 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.ts +++ b/src/app/pages/chat/group-messages/group-messages.page.ts @@ -36,6 +36,7 @@ import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, Cur import { Filesystem, Directory, Encoding } from '@capacitor/filesystem'; import { DomSanitizer } from '@angular/platform-browser'; import { MessageService } from 'src/app/services/chat/message.service'; +import { AlertController } from '@ionic/angular'; import { File } from '@awesome-cordova-plugins/file/ngx'; import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx'; @@ -87,6 +88,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { durationDisplay = ''; duration = 0; showAvatar = true; + audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null constructor( private menu: MenuController, @@ -113,6 +115,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { private processesService: ProcessesService, private CameraService: CameraService, private sanitiser: DomSanitizer, + private alertController: AlertController, private file: File, private fileOpener: FileOpener, ) { @@ -165,9 +168,9 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { message: '', status: status, } - this.chatService.setUserStatus(body).subscribe(res => { - console.log(res); - }) + // this.chatService.setUserStatus(body).subscribe(res => { + // console.log(res); + // }) } deleteMessage(msgId: string) { @@ -374,15 +377,15 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { getRoomInfo() { this.showLoader = true; - this.chatService.getRoomInfo(this.roomId).subscribe(room => { - this.room = room['room']; - this.roomName = this.room.name.split('-').join(' '); - if (this.room.customFields.countDownDate) { - this.roomCountDownDate = this.timeService.countDownDateTimer(this.room.customFields.countDownDate, this.room._id); - } - this.getGroupContacts(this.room); - this.showLoader = false; - }); + // this.chatService.getRoomInfo(this.roomId).subscribe(room => { + // this.room = room['room']; + // this.roomName = this.room.name.split('-').join(' '); + // if (this.room.customFields.countDownDate) { + // this.roomCountDownDate = this.timeService.countDownDateTimer(this.room.customFields.countDownDate, this.room._id); + // } + // this.getGroupContacts(this.room); + // this.showLoader = false; + // }); } async getChatMembers() { diff --git a/src/app/pages/chat/messages/messages.page.html b/src/app/pages/chat/messages/messages.page.html index ccfe00101..67291ed03 100644 --- a/src/app/pages/chat/messages/messages.page.html +++ b/src/app/pages/chat/messages/messages.page.html @@ -46,11 +46,6 @@ -
{{msg.duration}}
- {{msg.msg}} - {{msg.msg}} + + + + + + + {{last ? scrollToBottom() : ''}}
@@ -80,6 +80,12 @@
image + + + + + +
@@ -118,6 +124,15 @@ {{msg.displayType}} + + + + + + + + +
diff --git a/src/app/pages/chat/messages/messages.page.scss b/src/app/pages/chat/messages/messages.page.scss index 3676b8be4..5283f4d58 100644 --- a/src/app/pages/chat/messages/messages.page.scss +++ b/src/app/pages/chat/messages/messages.page.scss @@ -328,3 +328,31 @@ button::-moz-focus-inner { padding: 0px; border: 0px; } + + +.float-status{ + position: relative !important; + float: right; + display: flex; + align-items: self-end; +} + +.float-status-image{ + position: relative !important; + float: right; + display: flex; + align-items: self-end; + top: -15px; +} + +.float-status-webtrix { + position: relative !important; + top: 0px !important; + float: right; + display: flex; + align-items: self-end; +} + +.float-status-all { + font-size: 10pt !important; +} diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 99a72a53a..4681ae195 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -1,6 +1,6 @@ import { AfterViewChecked, AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router' -import { GestureController, Gesture, ModalController, NavParams, PopoverController, Platform } from '@ionic/angular'; +import { GestureController, Gesture, ModalController, NavParams, PopoverController, Platform, AlertController } from '@ionic/angular'; import { map } from 'rxjs/operators'; import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page'; import { EventPerson } from 'src/app/models/eventperson.model'; @@ -41,7 +41,6 @@ import { Storage } from '@ionic/storage'; import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service'; import { Camera, CameraResultType, CameraSource } from '@capacitor/camera'; import { Plugins, Capacitor } from '@capacitor/core'; -import { MultipleDocumentsPicker } from '@awesome-cordova-plugins/multiple-document-picker/ngx'; import { DomSanitizer } from '@angular/platform-browser'; import { StringDecoder } from 'string_decoder'; import { File } from '@awesome-cordova-plugins/file/ngx'; @@ -109,6 +108,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { base64File: string; downloadProgess: number; + audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null + constructor( public popoverController: PopoverController, private modalController: ModalController, @@ -133,12 +134,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { private processesService: ProcessesService, private storage: Storage, private fileToBase64Service: FileToBase64Service, - private multipleDocumentsPicker: MultipleDocumentsPicker, private sant: DomSanitizer, - private file: File, - private fileOpener: FileOpener, + //private fileOpener: FileOpener, private sanitiser: DomSanitizer, - private document: DocumentViewer + private alertController: AlertController, + // private document: DocumentViewer ) { this.loggedUser = authService.ValidatedUserChat['data']; this.roomId = this.navParams.get('roomId'); @@ -148,7 +148,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { if (window.innerWidth > 701) { this.modalController.dismiss(); } - }; + } console.log(this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})); @@ -160,6 +160,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { this.scrollToBottomClicked() }, 150) + } ngOnInit() { @@ -956,27 +957,27 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { } openFile(pdfString, filename, type) { - const blob = this.b64toBlob(pdfString, type) - let pathFile = '' - const fileName = filename - const contentFile = blob - if (this.platform.is('ios')) { - pathFile = this.file.documentsDirectory - } else { - pathFile = this.file.externalRootDirectory - } - console.log(pdfString) - console.log(pathFile) - console.log(contentFile) - this.file - .writeFile(pathFile, fileName, contentFile, { replace: true }) - .then(success => { - this.fileOpener - .open(pathFile + fileName, type) - .then(() => console.log('File is opened')) - .catch(e => console.log('Error opening file', e)); - }) - .catch(e => console.log('Error writing file', e)) + // const blob = this.b64toBlob(pdfString, type) + // let pathFile = '' + // const fileName = filename + // const contentFile = blob + // if (this.platform.is('ios')) { + // pathFile = this.file.documentsDirectory + // } else { + // pathFile = this.file.externalRootDirectory + // } + // console.log(pdfString) + // console.log(pathFile) + // console.log(contentFile) + // this.file + // .writeFile(pathFile, fileName, contentFile, { replace: true }) + // .then(success => { + // this.fileOpener + // .open(pathFile + fileName, type) + // .then(() => console.log('File is opened')) + // .catch(e => console.log('Error opening file', e)); + // }) + // .catch(e => console.log('Error writing file', e)) } downloadFileFromBrowser(fileName: string, data: any): void { diff --git a/src/app/pages/inactivity/inactivity.page.ts b/src/app/pages/inactivity/inactivity.page.ts index 949aa90af..9802d08ac 100644 --- a/src/app/pages/inactivity/inactivity.page.ts +++ b/src/app/pages/inactivity/inactivity.page.ts @@ -185,7 +185,7 @@ export class InactivityPage implements OnInit { SessionStore.setInativity(true) this.goback() - setTimeout(()=>{ + setTimeout(() => { this.clearCode() }, 1000) @@ -201,16 +201,22 @@ export class InactivityPage implements OnInit { if(pathName) { this.router.navigate([pathName],{replaceUrl: true}); } else { - this.router.navigate(['/home/events'], {replaceUrl: true}); + + setTimeout(()=>{ + this.router.navigate(['/home/events'], {replaceUrl: true}); + }, 5000) + } } storePin() { - const code = this.code.join(''); - SessionStore.setPin(code); - this.router.navigate(['/home/events']); + setTimeout(()=>{ + const code = this.code.join(''); + SessionStore.setPin(code); + this.router.navigate(['/home/events']); + }, 5000) } diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index a3e93ff8c..4ed0d7480 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -138,8 +138,8 @@ export class LoginPage implements OnInit { } this.getToken(); - this.router.navigateByUrl('/pin', { replaceUrl: true }); + this.router.navigateByUrl('/pin', { replaceUrl: true }); } } else{ @@ -153,6 +153,8 @@ export class LoginPage implements OnInit { else { this.toastService._badRequest('Por favor, insira o seu nome de utilizador'); } + + } goback() { diff --git a/src/app/services/agenda/list-box.service.ts b/src/app/services/agenda/list-box.service.ts index 8070c3a21..1b324d3e3 100644 --- a/src/app/services/agenda/list-box.service.ts +++ b/src/app/services/agenda/list-box.service.ts @@ -199,7 +199,8 @@ export class ListBoxService { EndDate: event.event.EndDate, Location: event.event.Location, EventId: event.event.EventId, - CalendarName: event.event.CalendarName + CalendarName: event.event.CalendarName, + CalendarId: event.event.CalendarId }, Subject: event.event.Subject, startMany: false, diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 369bb85fe..4a8ecd238 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -55,8 +55,6 @@ export class AuthService { if (SessionStore.exist) { this.ValidatedUser = SessionStore.user - // console.log('login', SessionStore.user.RochetChatUser, SessionStore.user.Password) - if(this.p.userPermission(this.p.permissionList.Chat.access) == true ){ this.loginToChatWs() } @@ -101,9 +99,26 @@ export class AuthService { session.Profile = 'PR' } else if(session.RoleID == 100000011) { session.Profile = 'MDGPR' + } else if(session.RoleID == 99999872) { + session.Profile = 'Consultant' } - else{ - session.Profile = this.initialsService.getInitials(session.FullName); + else if(session.RoleID == 99999873) { + session.Profile = 'Assistant' + } + else if(session.RoleID == 99999874) { + session.Profile = 'Department boss' + } + else if(session.RoleID == 99999875) { + session.Profile = 'Director' + } + else if(session.RoleID == 99999876) { + session.Profile = 'Deputy Director' + } + else if(session.RoleID == 99999885) { + session.Profile = 'Secretariat' + } + else if(session.RoleID == 99999886) { + session.Profile = 'General secretary' } session.Password = user.password @@ -117,6 +132,8 @@ export class AuthService { return true; } + + this.initialsService.getInitials(session.FullName); } //Login to rocketChat server2 @@ -135,7 +152,7 @@ export class AuthService { let responseChat = await this.httpService.post('login', postData).toPromise(); if(responseChat) { - console.log('Login to Rocket chat OK', responseChat); + this.ValidatedUserChat = responseChat; localStorage.setItem('userChat', JSON.stringify(responseChat)); this.storageService.store(AuthConnstants.AUTH, responseChat); @@ -162,6 +179,10 @@ export class AuthService { SessionStore.user.RochetChatUserId = message.result.id SessionStore.save() + + // console.log('user session', SessionStore.user) + + this.WsChatService.setStatus('online') }).catch((message) => { @@ -215,7 +236,7 @@ export class AuthService { this.NfService.downloadFileMsg = async (message: MessageService, room?: RoomService) => { - console.log('FILE TYPE', message.file.type) + // console.log('FILE TYPE', message.file.type) let downloadFile = ""; if (message.file.type == "application/img") { const event: any = await this.AttachmentsService.downloadFile(message.file.guid).toPromise(); @@ -224,7 +245,7 @@ export class AuthService { if (event.type === HttpEventType.DownloadProgress) { //this.downloadProgess = Math.round((100 * event.loaded) / event.total); - console.log('FILE TYPE 33', message.file.type) + // console.log('FILE TYPE 33', message.file.type) return true } else if (event.type === HttpEventType.Response) { downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '')); @@ -236,7 +257,7 @@ export class AuthService { } await this.storage.set(message.file.guid, downloadFile).then(() => { - console.log('IMAGE SAVED') + // console.log('IMAGE SAVED') }); return true } @@ -279,8 +300,8 @@ export class AuthService { this.userData$.next(''); this.router.navigate(['']); }) */ - } + async presentAlert(message: string) { const alert = await this.alertController.create({ cssClass: 'my-custom-class', diff --git a/src/app/services/chat.service.ts b/src/app/services/chat.service.ts index e1a29b34b..5be562fd6 100644 --- a/src/app/services/chat.service.ts +++ b/src/app/services/chat.service.ts @@ -30,21 +30,25 @@ export class ChatService { private authService: AuthService, private storage: Storage, private storageService:StorageService, - public p:PermissionService - ) - { + public p: PermissionService) { + if(this.p.userPermission(this.p.permissionList.Chat.access)){ this.loggedUserChat = authService.ValidatedUserChat; this.headers = new HttpHeaders(); - this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId); - this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken); - this.options = { - headers: this.headers, - }; - } + + + if(this.p.userPermission(this.p.permissionList.Chat.access)) { + this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId); + this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken); + this.options = { + headers: this.headers, + }; + } } + } + getDocumentDetails(url:string){ let headersc = new HttpHeaders(); headersc = headersc.set('X-User-Id', this.loggedUserChat['data'].userId); diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts index 82dae5b98..8780bb626 100644 --- a/src/app/services/chat/ws-chat-methods.service.ts +++ b/src/app/services/chat/ws-chat-methods.service.ts @@ -162,9 +162,9 @@ export class WsChatMethodsService { } catch(e){} - setTimeout(()=>{ + setTimeout(() => { this.sortRoomList() - }, 1000) + }, 10000) } @@ -213,6 +213,11 @@ export class WsChatMethodsService { setTimeout(()=>{ this.sortRoomList() }, 1000) + + + setTimeout(()=>{ + this.sortRoomList() + }, 10000) this.loadingWholeList = false } diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts index c2fd4b9b6..24284550b 100644 --- a/src/app/services/events.service.ts +++ b/src/app/services/events.service.ts @@ -28,9 +28,21 @@ export class EventsService { headersMdOficial: HttpHeaders; headersMdPessoal: HttpHeaders; + headerOwnOficial: HttpHeaders; + headerOwnPessoal: HttpHeaders; + + headerSharedOficial: HttpHeaders; + headerSharedPessoal: HttpHeaders; + headersSharedOficial: HttpHeaders; headersSharedPessoal: HttpHeaders; + hasSharedCalendar = false + hasOwnCalendar = false + + + calendarOwnerIds = [] + constructor( private http: HttpClient, public user: AuthService, @@ -51,6 +63,13 @@ export class EventsService { this.headersSharedPessoal = new HttpHeaders(); + this.headerOwnOficial= new HttpHeaders(); + this.headerOwnPessoal= new HttpHeaders(); + + this.headerSharedOficial= new HttpHeaders(); + this.headerSharedPessoal= new HttpHeaders(); + + this.setHeader() this.changeProfileService.registerCallback(() => { this.loggeduser = this.user.ValidatedUser; @@ -61,10 +80,22 @@ export class EventsService { setHeader() { + this.hasSharedCalendar = false + this.hasOwnCalendar = false + + this.calendarOwnerIds = [] + if (this.loggeduser) { if (this.loggeduser.Profile == 'MDGPR') { this.loggeduser.OwnerCalendars.forEach(calendar => { + + if(!this.calendarOwnerIds.includes(calendar.OwnerUserId)) { + this.calendarOwnerIds.push(calendar.OwnerUserId) + } + + this.hasOwnCalendar = true + if (calendar.CalendarName == 'Oficial') { this.headersMdOficial = this.headersMdOficial.set('Authorization', this.loggeduser.BasicAuthKey); this.headersMdOficial = this.headersMdOficial.set('CalendarId', calendar.CalendarId); @@ -79,6 +110,13 @@ export class EventsService { }); this.loggeduser.SharedCalendars.forEach(sharedCalendar => { + + if(!this.calendarOwnerIds.includes(sharedCalendar.OwnerUserId)) { + this.calendarOwnerIds.push(sharedCalendar.OwnerUserId) + } + + this.hasSharedCalendar = true + if (sharedCalendar.CalendarName == 'Oficial') { this.headersSharedOficial = this.headersSharedOficial.set('Authorization', this.loggeduser.BasicAuthKey); this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', sharedCalendar.CalendarId); @@ -94,6 +132,13 @@ export class EventsService { else if (this.loggeduser.Profile == 'PR') { this.loggeduser.OwnerCalendars.forEach(calendar => { + + if(!this.calendarOwnerIds.includes(calendar.OwnerUserId)) { + this.calendarOwnerIds.push(calendar.OwnerUserId) + } + + this.hasOwnCalendar = true + if (calendar.CalendarName == 'Oficial') { this.headersPrOficial = this.headersPrOficial.set('Authorization', this.loggeduser.BasicAuthKey); this.headersPrOficial = this.headersPrOficial.set('CalendarId', calendar.CalendarId); @@ -106,6 +151,55 @@ export class EventsService { } }); + } else { + + + this.loggeduser.OwnerCalendars.forEach(calendar => { + + if(!this.calendarOwnerIds.includes(calendar.OwnerUserId)) { + this.calendarOwnerIds.push(calendar.OwnerUserId) + } + this.hasOwnCalendar = true + + if (calendar.CalendarName == 'Oficial') { + this.headerOwnOficial = this.headerOwnOficial.set('Authorization', this.loggeduser.BasicAuthKey); + this.headerOwnOficial = this.headerOwnOficial.set('CalendarId', calendar.CalendarId); + this.headerOwnOficial = this.headerOwnOficial.set('CalendarRoleId', calendar.CalendarRoleId); + this.headerOwnOficial = this.headerOwnOficial.set('CalendarName', calendar.CalendarName); + } + else if (calendar.CalendarName == 'Pessoal') { + this.headerOwnPessoal = this.headerOwnPessoal.set('Authorization', this.loggeduser.BasicAuthKey); + this.headerOwnPessoal =this.headerOwnPessoal.set('CalendarId', calendar.CalendarId); + this.headerOwnPessoal =this.headerOwnPessoal.set('CalendarRoleId', calendar.CalendarRoleId); + this.headerOwnPessoal = this.headerOwnPessoal.set('CalendarName', calendar.CalendarName); + } + }); + + + for (let sharedCalendar of this.loggeduser.SharedCalendars) { + + + if(!this.calendarOwnerIds.includes(sharedCalendar.OwnerUserId)) { + this.calendarOwnerIds.push(sharedCalendar.OwnerUserId) + } + + this.hasSharedCalendar = true + + if (sharedCalendar.CalendarName == 'Oficial') { + sharedCalendar.CalendarName + this.headerSharedOficial = this.headerSharedOficial.set('Authorization', 'Basic '+sharedCalendar.CalendarToken); + this.headerSharedOficial = this.headerSharedOficial.set('CalendarId', sharedCalendar.CalendarId); + this.headerSharedOficial = this.headerSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId); + this.headerSharedOficial = this.headerSharedOficial.set('CalendarName', sharedCalendar.CalendarName); + } + else if (sharedCalendar.CalendarName == 'Pessoal') { + this.headerSharedPessoal = this.headerSharedPessoal.set('Authorization', 'Basic '+sharedCalendar.CalendarToken); + this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarId', sharedCalendar.CalendarId); + this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId); + this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarName', sharedCalendar.CalendarName); + } + } + } this.headers = new HttpHeaders(); @@ -113,20 +207,6 @@ export class EventsService { } } - /* getAllEvents(startdate:string, enddate:string): Observable{ - const geturl = environment.apiURL + 'calendar/GetAllEvents'; - let params = new HttpParams(); - - params = params.set("StartDate", startdate); - params = params.set("EndDate", enddate); - - let options = { - headers: this.headers, - params: params - }; - return this.http.get(`${geturl}`, options); - } */ - getAllPrOficialEvents(startdate: string, enddate: string): Observable { let geturl = environment.apiURL + 'calendar/pr'; @@ -208,6 +288,93 @@ export class EventsService { }); } + + async getAllOwnEvents(startdate: string, enddate: string) { + let ownO = await this.getAllOwnOficialEvents(startdate, enddate).toPromise(); + let ownP = await this.getAllOwnPessoalEvents(startdate, enddate).toPromise(); + const resFinal = ownO.concat(ownP); + return new Promise(resolve => { + return resolve(resFinal) + }); + } + + getAllOwnOficialEvents(startdate: string, enddate: string): Observable { + let geturl = environment.apiURL + 'calendar/GetEvents'; + + let params = new HttpParams(); + + params = params.set("StartDate", startdate); + params = params.set("EndDate", enddate); + + + let options = { + headers: this.headerOwnOficial, + params: params + }; + return this.http.get(`${geturl}`, options); + } + + getAllOwnPessoalEvents(startdate: string, enddate: string): any { + let geturl = environment.apiURL + 'calendar/GetEvents'; + + let params = new HttpParams(); + + params = params.set("StartDate", startdate); + params = params.set("EndDate", enddate); + + let options = { + headers: this.headerOwnPessoal, + params: params + }; + return this.http.get(`${geturl}`, options) + } + + async genericGetAllSharedEvents(startdate: string, enddate: string) { + + let prO = await this.genericGetAllSharedOficialEvents(startdate, enddate).toPromise(); + let prP = await this.genericGetAllSharedPessoalEvents(startdate, enddate).toPromise(); + const resFinal = prO.concat(prP); + + return new Promise(resolve => { + return resolve(resFinal) + }); + } + + genericGetAllSharedOficialEvents(startdate: string, enddate: string): Observable { + let geturl = environment.apiURL + 'calendar/GetEvents'; + geturl = geturl.replace('/V4/', '/V5/') + + let params = new HttpParams(); + + params = params.set("StartDate", startdate); + params = params.set("EndDate", enddate); + + + + let options = { + headers: this.headerSharedOficial, + params: params + }; + + return this.http.get(`${geturl}`, options); + } + + genericGetAllSharedPessoalEvents(startdate: string, enddate: string): Observable { + let geturl = environment.apiURL + 'calendar/GetEvents'; + geturl = geturl.replace('/V4/', '/V5/') + + let params = new HttpParams(); + + params = params.set("StartDate", startdate); + params = params.set("EndDate", enddate); + + let options = { + headers: this.headerSharedPessoal, + params: params + }; + return this.http.get(`${geturl}`, options); + } + async getAllSharedEvents(startdate: string, enddate: string) { let prO = await this.getAllSharedOficialEvents(startdate, enddate).toPromise(); let prP = await this.getAllSharedPessoalEvents(startdate, enddate).toPromise(); @@ -293,6 +460,39 @@ export class EventsService { return this.http.get(`${geturl}`, options); } + + genericGetEvent(eventid: string, calendarId: string) { + let geturl = environment.apiURL + 'calendar/GetEvent'; + let params = new HttpParams(); + + params = params.set("EventId", eventid); + + const headers = [ + this.headerSharedOficial, + this.headerSharedPessoal, + this.headerOwnPessoal, + this.headerOwnOficial + ] + + const header = headers.find((header)=> { + return header?.get('CalendarId')?.includes(calendarId) + }) + + if(header) { + let options = { + headers: header, + params: params + } + + return this.http.get(`${geturl}`, options); + } else { + + } + + throw('error') + + } + putEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number, sharedagenda: string): Observable { const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PutEvent'); @@ -309,7 +509,7 @@ export class EventsService { return this.http.put(`${puturl}`, event, options) } - editEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number): Observable { + editEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number, CalendarId? ): Observable { let arrayReq = []; arrayReq.push(event); const puturl = environment.apiURL + 'calendar/PutEvent'; @@ -328,6 +528,20 @@ export class EventsService { } else if (this.loggeduser.Profile == 'PR') { this.headers = this.headersPrOficial; + } else { + + const headers = [ + this.headerSharedOficial, + this.headerSharedPessoal, + this.headerOwnPessoal, + this.headerOwnOficial + ] + + const header = headers.find((header)=> { + return header?.get('CalendarId')?.includes(CalendarId) + }) + + this.headers = header } } else { @@ -337,6 +551,20 @@ export class EventsService { else if (this.loggeduser.Profile == 'PR') { this.headers = this.headersPrPessoal; } + else { + const headers = [ + this.headerSharedOficial, + this.headerSharedPessoal, + this.headerOwnPessoal, + this.headerOwnOficial + ] + + const header = headers.find((header)=> { + return header?.get('CalendarId')?.includes(CalendarId) + }) + + this.headers = header + } } let options = { @@ -352,6 +580,7 @@ export class EventsService { }) ) } + changeAgenda(body: any) { const puturl = environment.apiURL + 'Calendar/MoveEvent'; @@ -361,21 +590,6 @@ export class EventsService { return this.http.post(`${puturl}`, body, options); } - /* postEvent(event:Event, calendarName:string, sharedagenda:string) - { - const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PostEvent'); - let params = new HttpParams(); - - params = params.set("CalendarName", calendarName); - - let options = { - headers: this.headers, - params: params - }; - - return this.http.post(`${puturl}`, event, options) - } */ - postEventMd(event: Event, calendarName: string) { const puturl = environment.apiURL + 'calendar/md'; let params = new HttpParams(); @@ -432,6 +646,58 @@ export class EventsService { return this.http.post(`${puturl}`, event, options) } + + + postEventGeneric(event: Event, calendarName: string) { + const puturl = environment.apiURL + 'Calendar/PostEvent'; + let params = new HttpParams(); + + params = params.set("CalendarName", calendarName); + + let options: any; + + + if(this.hasOwnCalendar) { + switch (calendarName) { + case 'Oficial': + options = { + headers: this.headerOwnOficial, + params: params + }; + break; + + case 'Pessoal': + + options = { + headers: this.headerOwnPessoal, + params: params + }; + break; + } + } else { + switch (calendarName) { + case 'Oficial': + options = { + headers: this.headerSharedOficial, + params: params + }; + break; + + case 'Pessoal': + + options = { + headers: this.headerSharedPessoal, + params: params + }; + break; + } + } + + + + return this.http.post(`${puturl}`, event, options) + } + deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) { let arrayReq = []; let Object = { @@ -488,6 +754,92 @@ export class EventsService { }) ) } + + + genericDeleteEvent(eventid: string, eventDeleteType: number, calendarName: string, calendarId: string) { + let arrayReq = []; + let Object = { + eventid: eventid, + eventDeleteType: eventDeleteType, + calendarName: calendarName + } + arrayReq.push(Object) + const puturl = environment.apiURL + 'calendar/DeleteEvent'; + let params = new HttpParams(); + + params = params.set("EventId", eventid); + // 0 for occurence and 1 for serie (delete all events) + params = params.set("eventDeleteType", eventDeleteType.toString()); + + let options; + + if(this.loggeduser.Profile == 'MDGPR') { + if (calendarName == 'Pessoal') { + options = { + headers: this.headersMdPessoal, + params: params + }; + } + else if (calendarName == 'Oficial') { + options = { + headers: this.headersMdOficial, + params: params + }; + } + } + else if (this.loggeduser.Profile == 'PR') { + if (calendarName == 'Pessoal') { + options = { + headers: this.headersPrPessoal, + params: params + }; + } + else if (calendarName == 'Oficial') { + options = { + headers: this.headersPrOficial, + params: params + }; + } + } + else { + const headers = [ + this.headerSharedOficial, + this.headerSharedPessoal, + this.headerOwnPessoal, + this.headerOwnOficial + ] + + const header = headers.find((header)=> { + return header?.get('CalendarId')?.includes(calendarId) + }) + + if (header) { + + + options = { + headers: header, + params: params + }; + + return this.http.delete(`${puturl}`, options).pipe( + catchError(err => { + console.log('Event edit saved offline') + this.offlinemanager.storeRequestData('eventDelete', arrayReq); + throw new Error(err); + }) + ) + } else { + + } + + throw('header not found') + + } + + + } + + postExpedientEvent(docId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) { const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/event'; let params = new HttpParams(); diff --git a/src/app/services/permission.service.ts b/src/app/services/permission.service.ts index b0ebcf48f..cbd725923 100644 --- a/src/app/services/permission.service.ts +++ b/src/app/services/permission.service.ts @@ -35,6 +35,23 @@ export class PermissionService { return false; } + userPermissionCount(args) { + if(!Array.isArray(args)) { + args = [args] + } + + let count = 0 + + for(let permission of (this.SessionStore.user.UserPermissions || [])) { + if (args.includes(permission)) { + count++; + } + } + + + return count; + } + role(args: any) { let UserRoleIsValid = this.userRole(args) diff --git a/src/app/shared/agenda/edit-event/edit-event.page.ts b/src/app/shared/agenda/edit-event/edit-event.page.ts index 0c25fa514..2265c0592 100644 --- a/src/app/shared/agenda/edit-event/edit-event.page.ts +++ b/src/app/shared/agenda/edit-event/edit-event.page.ts @@ -13,6 +13,7 @@ import { ToastService } from 'src/app/services/toast.service'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { ParticipantsPipe } from 'src/app/pipes/participants.pipe'; import { ThemeService } from 'src/app/services/theme.service' +import { SessionStore } from 'src/app/store/session.service'; @Component({ selector: 'app-edit-event', @@ -83,6 +84,7 @@ export class EditEventPage implements OnInit { public stepSeconds = [1, 5, 10, 15, 20, 25]; private participantsPipe = new ParticipantsPipe() + sesseionStora = SessionStore constructor( private modalController: ModalController, @@ -258,19 +260,37 @@ export class EditEventPage implements OnInit { this.showLoader = true; try { - await this.eventsService.editEvent(this.postEvent, 2, 3).toPromise() - if(this.initCalendarName != this.postEvent.CalendarName) { - let body = { - "EventId": this.postEvent.EventId, - "CalendarDestinationName": this.postEvent.CalendarName, + if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { + await this.eventsService.editEvent(this.postEvent, 2, 3).toPromise() + if(this.initCalendarName != this.postEvent.CalendarName) { + let body = { + "EventId": this.postEvent.EventId, + "CalendarDestinationName": this.postEvent.CalendarName, + } + + try { + await this.eventsService.changeAgenda(body).toPromise(); + } catch (e) {} } - - try { - await this.eventsService.changeAgenda(body).toPromise(); - } catch (e) {} + this.showLoader = false; + this.toastService.successMessage() + } else { + await this.eventsService.editEvent(this.postEvent, 2, 3, this.postEvent.CalendarId).toPromise() + if(this.initCalendarName != this.postEvent.CalendarName) { + let body = { + "EventId": this.postEvent.EventId, + "CalendarDestinationName": this.postEvent.CalendarName, + } + + try { + await this.eventsService.changeAgenda(body).toPromise(); + } catch (e) {} + } + this.showLoader = false; + this.toastService.successMessage() } - this.showLoader = false; - this.toastService.successMessage() + + } catch(error) { this.showLoader = false this.toastService.badRequest() diff --git a/src/app/shared/agenda/new-event/new-event.page.ts b/src/app/shared/agenda/new-event/new-event.page.ts index 612b59506..dd0935eef 100644 --- a/src/app/shared/agenda/new-event/new-event.page.ts +++ b/src/app/shared/agenda/new-event/new-event.page.ts @@ -413,7 +413,7 @@ export class NewEventPage implements OnInit { }); } - else if(this.CalendarName == 'PR') { + else if(this.loggeduser.Profile == 'PR') { console.log('PR - Aqui'); console.log(this.postEvent); this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe( @@ -448,6 +448,39 @@ export class NewEventPage implements OnInit { } this.toastService.successMessage('Evento criado') }); + } else { + this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName).subscribe( + (id) => { + console.log(id); + + const eventId: any = id; + + const DocumentToSave: EventAttachment[] = this.documents.map((e) => { + return { + SourceTitle: e.Assunto, + ParentId: eventId, + Source: '1', + SourceId: e.Id, + ApplicationId: e.ApplicationType.toString(), + Id: '', + Link: '', + SerialNumber: '' + }; + }); + + DocumentToSave.forEach((attachments, i) => { + this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) =>{ + if(DocumentToSave.length == (i+1)){ + this.afterSave(); + } + }); + }); + + if(DocumentToSave.length == 0){ + this.afterSave(); + } + this.toastService.successMessage('Evento criado') + }); } } diff --git a/src/app/shared/agenda/view-event/view-event.page.ts b/src/app/shared/agenda/view-event/view-event.page.ts index d321f7939..e28b060bb 100644 --- a/src/app/shared/agenda/view-event/view-event.page.ts +++ b/src/app/shared/agenda/view-event/view-event.page.ts @@ -14,6 +14,8 @@ import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expedient import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page'; import { ThemeService } from 'src/app/services/theme.service' import { RouteService } from 'src/app/services/route.service'; +import { CalendarService } from 'src/app/store/calendar.service'; +import { SessionStore } from 'src/app/store/session.service'; @Component({ @@ -23,7 +25,7 @@ import { RouteService } from 'src/app/services/route.service'; }) export class ViewEventPage implements OnInit { - loadedEvent: any; + loadedEvent: Event; isEventEdited: boolean; eventBody: EventBody; loadedAttachments:any; @@ -46,6 +48,7 @@ export class ViewEventPage implements OnInit { @Input() eventId: string; @Output() viewEventDetailDismiss = new EventEmitter(); + sesseionStora = SessionStore constructor( private eventsService: EventsService, @@ -55,7 +58,8 @@ export class ViewEventPage implements OnInit { private modalController: ModalController, public popoverController: PopoverController, private toastService: ToastService, - public ThemeService: ThemeService + public ThemeService: ThemeService, + private CalendarService: CalendarService ) { this.isEventEdited = false; this.loadedEvent = new Event(); @@ -97,24 +101,51 @@ export class ViewEventPage implements OnInit { loadEvent() { - this.eventsService.getEvent(this.eventId).subscribe(res => { - console.log(res); - this.loadedEvent = res; - this.today = new Date(res.StartDate); - this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); - }, (error)=> { + if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { + this.eventsService.getEvent(this.eventId).subscribe(res => { + console.log(res); + this.loadedEvent = res; + this.today = new Date(res.StartDate); + this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); + }, (error)=> { + + this.viewEventDetailDismiss.emit({ + type: 'close' + }) + + if(error.status == 0) { + this.toastService.badRequest('Não é possível visualizar este evento no modo offline') + } else { + this.toastService.badRequest('Este evento já não existe na sua agenda') + } + + }); + } else { - this.viewEventDetailDismiss.emit({ - type: 'close' - }) + const event = this.CalendarService.eventSource.find((ele) => ele.id == this.eventId) - if(error.status == 0) { - this.toastService.badRequest('Não é possível visualizar este evento no modo offline') - } else { - this.toastService.badRequest('Este evento já não existe na sua agenda') + + if(event?.CalendarId) { + + this.eventsService.genericGetEvent(this.eventId, event.CalendarId).subscribe(res => { + this.loadedEvent = res; + this.today = new Date(res.StartDate); + this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); + }, (error)=> { + + this.viewEventDetailDismiss.emit({ + type: 'close' + }) + + if(error.status == 0) { + this.toastService.badRequest('Não é possível visualizar este evento no modo offline') + } else { + this.toastService.badRequest('Este evento já não existe na sua agenda') + } + }); } - - }); + } + } async deleteEvent() { @@ -122,24 +153,52 @@ export class ViewEventPage implements OnInit { if (this.loadedEvent.IsRecurring) { const loader = this.toastService.loading() - this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => { - this.toastService.successMessage('Evento apagado'); - this.close(); - },()=>{}, - ()=>{ - loader.remove(); - }); + if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { + this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => { + this.toastService.successMessage('Evento apagado'); + this.close(); + },()=>{}, + ()=>{ + loader.remove(); + }); + } else { + + const event = this.CalendarService.eventSource.find((ele) => ele.id == this.eventId) + + if(event?.CalendarId) { + this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, event?.CalendarId).subscribe(async () => { + this.toastService.successMessage('Evento apagado'); + this.close(); + },()=>{}, + ()=>{ + loader.remove(); + }); + } + + } + } else { const loader = this.toastService.loading() + + if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { + this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => { + this.toastService.successMessage('Evento apagado'); + this.close(); + },()=>{}, + ()=>{ + loader.remove(); + }); + } else { + this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, this.loadedEvent.CalendarId).subscribe(async () => { + this.toastService.successMessage('Evento apagado'); + this.close(); + },()=>{}, + ()=>{ + loader.remove(); + }); + } - this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => { - this.toastService.successMessage('Evento apagado'); - this.close(); - },()=>{}, - ()=>{ - loader.remove(); - }); } } @@ -188,7 +247,7 @@ export class ViewEventPage implements OnInit { workflowInstanceDataFields: { FolderID: '', Subject: selectedDoc.SourceName, - SourceSecFsID: selectedDoc.ApplicationId || selectedDoc.ApplicationID, + SourceSecFsID: selectedDoc.ApplicationId || selectedDoc['ApplicationID'], SourceType: 'DOC', SourceID: selectedDoc.SourceId, DispatchNumber: '' @@ -254,7 +313,7 @@ export class ViewEventPage implements OnInit { taskAction: taskAction, task: this.task, seachDocuments: this.loadedEvent.Attachments[ this.dicIndex], - aplicationId: this.loadedEvent.Attachments[ this.dicIndex].ApplicationId || this.loadedEvent.Attachments[ this.dicIndex].ApplicationID + aplicationId: this.loadedEvent.Attachments[ this.dicIndex].ApplicationId || this.loadedEvent.Attachments[ this.dicIndex]['ApplicationID'] }, cssClass: classs, }); diff --git a/src/app/shared/chat/group-messages/group-messages.module.ts b/src/app/shared/chat/group-messages/group-messages.module.ts index bdbe70cc8..929170a0d 100644 --- a/src/app/shared/chat/group-messages/group-messages.module.ts +++ b/src/app/shared/chat/group-messages/group-messages.module.ts @@ -15,6 +15,7 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import {MatMenuModule} from '@angular/material/menu'; import { LettersAvatarModule } from "ngx-letters-avatar"; import { PipesModule } from 'src/app/pipes/pipes.module'; +import { SafehtmlPipe } from 'src/app/pipes/safehtml.pipe'; @NgModule({ imports: [ @@ -33,4 +34,4 @@ import { PipesModule } from 'src/app/pipes/pipes.module'; schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [GroupMessagesPage] }) -export class GroupMessagesPageModule {} +export class GroupMessagesPageModule {} \ No newline at end of file diff --git a/src/app/shared/chat/group-messages/group-messages.page.html b/src/app/shared/chat/group-messages/group-messages.page.html index 61ac8afd6..fafed23df 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.html +++ b/src/app/shared/chat/group-messages/group-messages.page.html @@ -56,6 +56,14 @@
{{msg.msg}} {{msg.msg}} + + + + + + + + {{last ? scrollToBottom() : ''}}
@@ -83,6 +91,13 @@ msg.attachments[0].image_url" (click)="openPreview(msg)"> image + + + + + + +
@@ -90,6 +105,7 @@ + @@ -113,6 +129,13 @@ {{msg.displayType}} + + + + + + +
diff --git a/src/app/shared/chat/group-messages/group-messages.page.scss b/src/app/shared/chat/group-messages/group-messages.page.scss index 9742565e9..8df9dee88 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.scss +++ b/src/app/shared/chat/group-messages/group-messages.page.scss @@ -293,3 +293,31 @@ .typing ngx-letters-avatar { padding-right: 5px; } + + +.float-status{ + position: relative !important; + float: right; + display: flex; + align-items: self-end; +} + +.float-status-image{ + position: relative !important; + float: right; + display: flex; + align-items: self-end; + top: -15px; +} + +.float-status-webtrix { + position: relative !important; + top: 0px !important; + float: right; + display: flex; + align-items: self-end; +} + +.float-status-all { + font-size: 10pt !important; +} diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index bf520382f..d3e9dab13 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -36,9 +36,11 @@ import { Camera, CameraResultType, CameraSource } from '@capacitor/camera'; import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, CurrentRecordingStatus } from 'capacitor-voice-recorder'; import { Filesystem, Directory, Encoding } from '@capacitor/filesystem'; import { DomSanitizer } from '@angular/platform-browser'; +import { AlertController, NavParams } from '@ionic/angular'; import { File } from '@awesome-cordova-plugins/file/ngx'; import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx'; + /* import * as pdfjsLib from 'pdfjs-dist'; if( pdfjsLib !== undefined ){ @@ -101,6 +103,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe durationDisplay = ''; duration = 0; + audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null + constructor( public wsChatMethodsService: WsChatMethodsService, private modalController: ModalController, @@ -123,10 +127,12 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe private CameraService: CameraService, private toastService: ToastService, private sanitiser: DomSanitizer, + private alertController: AlertController, private file: File, private platform: Platform, private fileOpener: FileOpener, + ) { console.log('OnCONSTRUCTOR'); this.loggedUserChat = authService.ValidatedUserChat['data']; diff --git a/src/app/shared/chat/messages/messages.module.ts b/src/app/shared/chat/messages/messages.module.ts index 574c55e8a..6cec6a4e2 100644 --- a/src/app/shared/chat/messages/messages.module.ts +++ b/src/app/shared/chat/messages/messages.module.ts @@ -13,6 +13,7 @@ import { MatButtonModule } from '@angular/material/button'; import {MatMenuModule} from '@angular/material/menu'; import { LettersAvatarModule } from "ngx-letters-avatar"; import { PipesModule } from 'src/app/pipes/pipes.module'; +import { SafehtmlPipe } from 'src/app/pipes/safehtml.pipe'; @NgModule({ imports: [ @@ -25,9 +26,8 @@ import { PipesModule } from 'src/app/pipes/pipes.module'; MatMenuModule, LettersAvatarModule, PipesModule, - ], exports: [MessagesPage], declarations: [MessagesPage] }) -export class MessagesPageModule {} +export class MessagesPageModule {} \ No newline at end of file diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 8fdd6e7a6..681881928 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -233,6 +233,7 @@