From c630e32ae3a72174c3dae03579e22207e944cac1 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Tue, 29 Mar 2022 17:14:25 +0100 Subject: [PATCH 1/9] fix --- .../pages/chat/messages/messages.page.html | 29 ++++++++++++++----- .../services/chat/ws-chat-methods.service.ts | 9 ++++-- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/app/pages/chat/messages/messages.page.html b/src/app/pages/chat/messages/messages.page.html index a11653d83..69d538f31 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/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 } From 47c96ba052a78787c9eac3d33f9378a589399290 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Wed, 30 Mar 2022 14:52:02 +0100 Subject: [PATCH 2/9] add message status --- .../group-messages/group-messages.page.html | 21 ++++++++++++++ .../group-messages/group-messages.page.scss | 28 +++++++++++++++++++ .../pages/chat/messages/messages.page.scss | 28 +++++++++++++++++++ .../group-messages/group-messages.page.html | 22 +++++++++++++++ .../group-messages/group-messages.page.scss | 28 +++++++++++++++++++ 5 files changed, 127 insertions(+) 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..fdef3033c 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 + + + + + +
@@ -138,6 +152,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/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/shared/chat/group-messages/group-messages.page.html b/src/app/shared/chat/group-messages/group-messages.page.html index 2e0a784e4..a7e82f780 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 + + + + + + +
@@ -113,6 +128,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; +} From e69392ce58f524008e591d58d7b902b2bdd0f50e Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Sat, 2 Apr 2022 09:40:09 +0100 Subject: [PATCH 3/9] save --- nice.html | 49 ---- src/app/guards/inactivity.guard.ts | 34 ++- src/app/models/user.model.ts | 4 +- src/app/pages/agenda/agenda.page.html | 18 +- src/app/pages/agenda/agenda.page.ts | 249 +++++++++++++++--- .../pages/agenda/new-event/new-event.page.ts | 3 +- .../group-messages/group-messages.page.ts | 51 +++- src/app/pages/chat/messages/messages.page.ts | 117 +++++--- src/app/pages/inactivity/inactivity.page.ts | 16 +- src/app/pages/login/login.page.ts | 4 +- src/app/services/auth.service.ts | 29 +- src/app/services/events.service.ts | 243 +++++++++++++++-- src/app/services/permission.service.ts | 2 +- .../shared/agenda/new-event/new-event.page.ts | 33 +++ .../group-messages/group-messages.page.ts | 54 +++- .../shared/chat/messages/messages.page.html | 1 + src/app/shared/chat/messages/messages.page.ts | 54 +++- .../gov/icons-chat-record-audio-disable.svg | 8 + src/environments/environment.ts | 30 ++- 19 files changed, 786 insertions(+), 213 deletions(-) delete mode 100644 nice.html create mode 100644 src/assets/icon/theme/gov/icons-chat-record-audio-disable.svg 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/models/user.model.ts b/src/app/models/user.model.ts index e7c5cbe56..bdb400bda 100644 --- a/src/app/models/user.model.ts +++ b/src/app/models/user.model.ts @@ -45,6 +45,7 @@ export class UserSession { CalendarName: "Oficial" | "Pessoal"; CalendarRoleId: string; Id: number; + OwnerUserId: any }[] RoleDescription: string RoleID: number @@ -55,12 +56,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..eb2e12e44 100644 --- a/src/app/pages/agenda/agenda.page.html +++ b/src/app/pages/agenda/agenda.page.html @@ -93,14 +93,6 @@ -
@@ -111,11 +103,11 @@ - - @@ -184,9 +176,7 @@
-
- -
+
@@ -290,7 +280,7 @@ -
+
diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index 3e9ad13a3..e57647e61 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -167,7 +167,7 @@ export class AgendaPage implements OnInit { 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 +192,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"; @@ -529,8 +540,7 @@ export class AgendaPage implements OnInit { }).catch((error) => { this.getFromDB(); - }) - .finally(() => { + }).finally(() => { this.showLoader = false; }) @@ -560,9 +570,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 +607,70 @@ 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,9 +678,11 @@ export class AgendaPage implements OnInit { let counter = 0; - // view MDGPR calendar with MDGPR profile if (this.loggeduser.Profile == 'MDGPR') { + + alert('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) => { this.addEventToDB(response, "md"); @@ -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,105 @@ 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 }) + + console.log('check list to present data', this.listToPresent); + 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 +918,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) { 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..7d35a4b12 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'; @@ -315,6 +314,8 @@ export class NewEventPage implements OnInit { 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/chat/group-messages/group-messages.page.ts b/src/app/pages/chat/group-messages/group-messages.page.ts index d10e4cf45..f36d72006 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'; @Component({ selector: 'app-group-messages', @@ -85,6 +86,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { durationDisplay = ''; duration = 0; showAvatar = true; + audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null constructor( private menu: MenuController, @@ -111,6 +113,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { private processesService: ProcessesService, private CameraService: CameraService, private sanitiser: DomSanitizer, + private alertController: AlertController ) { this.loggedUserChat = authService.ValidatedUserChat['data']; this.isGroupCreated = true; @@ -296,15 +299,49 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { } - startRecording() { - console.log('Recording'); + async checkAudioPermission() { + const permissionStatus = await navigator.permissions.query({ name: 'microphone' } as any) + + console.log('permission', permissionStatus.state); // granted, denied, prompt - if (this.recording) { - return; + this.audioPermissionStatus = permissionStatus.state + + permissionStatus.onchange = (data : any) => { + // console.log("Permission changed to " + data.state); + // console.log('permission', permissionStatus.state); // granted, denied, prompt } - this.recording = true; - VoiceRecorder.startRecording(); - this.calculateDuration(); + + } + + async startRecording() { + + await this.checkAudioPermission(); + + if(this.audioPermissionStatus == 'granted') { + if (this.recording) { + return; + } + + this.recording = true; + VoiceRecorder.startRecording(); + this.calculateDuration(); + } else { + + const alertPopup = await this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Necessita de permissão para gravar áudio', + buttons: [{ + text: 'Ok', + handler: () => { + + } + }] + }); + + await alertPopup.present(); + + } + } diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 3c2914b19..549ec7bd1 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'; @@ -97,6 +97,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { downloadFile: any; downloadProgess: number; + audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null + constructor( public popoverController: PopoverController, private modalController: ModalController, @@ -122,6 +124,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { private storage: Storage, private fileToBase64Service: FileToBase64Service, private sanitiser: DomSanitizer, + private alertController: AlertController ) { this.loggedUser = authService.ValidatedUserChat['data']; this.roomId = this.navParams.get('roomId'); @@ -143,6 +146,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { this.scrollToBottomClicked() }, 150) + } ngOnInit() { @@ -220,17 +224,49 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { } - startRecording() { - console.log('Recording'); - if (this.recording) { - return; + async checkAudioPermission() { + const permissionStatus = await navigator.permissions.query({ name: 'microphone' } as any) + + console.log('permission', permissionStatus.state); // granted, denied, prompt + + this.audioPermissionStatus = permissionStatus.state + + permissionStatus.onchange = (data : any) => { + // console.log("Permission changed to " + data.state); + // console.log('permission', permissionStatus.state); // granted, denied, prompt + } + + } + + async startRecording() { + + await this.checkAudioPermission(); + + if(this.audioPermissionStatus == 'granted') { + if (this.recording) { + return; + } + + this.recording = true; + VoiceRecorder.startRecording(); + this.calculateDuration(); + } else { + + const alertPopup = await this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Necessita de permissão para gravar áudio', + buttons: [{ + text: 'Ok', + handler: () => { + + } + }] + }); + + await alertPopup.present(); + } - this.recording = true; - VoiceRecorder.startRecording() - .then((result: GenericResponse) => console.log(result.value)) - .catch(error => console.log(error)); - this.calculateDuration(); } stopRecording() { @@ -397,35 +433,42 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { this.storage.get('recordData').then((recordData) => { audioFile = recordData; - if(recordData?.value?.recordDataBase64.includes('data:audio')){ - this.audioRecorded = recordData?.value?.recordDataBase64; - } - else{ - this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`; + + if(recordData?.value?.recordDataBase64) { + if(recordData.value.recordDataBase64.includes('data:audio')){ + this.audioRecorded = recordData.value.recordDataBase64; + } + else{ + this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`; + } + + console.log(this.audioRecorded); + + //Converting base64 to blob + const encodedData = btoa(this.audioRecorded); + const blob = this.base64toBlob(encodedData, recordData.value.mimeType) + console.log(blob) + const formData = new FormData(); + formData.append("blobFile", blob); + + this.wsChatMethodsService.getDmRoom(roomId).send({ + file: { + "type": "application/audio", + "msDuration":audioFile.value.msDuration, + "mimeType":audioFile.value.mimeType, + }, + attachments: [{ + "title": fileName , + "title_link_download": true, + "type": "audio" + }], + temporaryData: formData + }) + } else { + alert('no audio') } - console.log(this.audioRecorded); - - //Converting base64 to blob - const encodedData = btoa(this.audioRecorded); - const blob = this.base64toBlob(encodedData, recordData.value.mimeType) - console.log(blob) - const formData = new FormData(); - formData.append("blobFile", blob); - - this.wsChatMethodsService.getDmRoom(roomId).send({ - file: { - "type": "application/audio", - "msDuration":audioFile.value.msDuration, - "mimeType":audioFile.value.mimeType, - }, - attachments: [{ - "title": fileName , - "title_link_download": true, - "type": "audio" - }], - temporaryData: formData - }) + }); this.deleteRecording(); diff --git a/src/app/pages/inactivity/inactivity.page.ts b/src/app/pages/inactivity/inactivity.page.ts index 00dd852b0..a520405d6 100644 --- a/src/app/pages/inactivity/inactivity.page.ts +++ b/src/app/pages/inactivity/inactivity.page.ts @@ -178,7 +178,7 @@ export class InactivityPage implements OnInit { SessionStore.setInativity(true) this.goback() - setTimeout(()=>{ + setTimeout(() => { this.clearCode() }, 1000) @@ -194,16 +194,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 a915cdc21..75492fc7e 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -123,11 +123,12 @@ export class LoginPage implements OnInit { await this.authService.SetSession(attempt, this.userattempt); this.changeProfileService.run(); + await this.authService.loginChat(); await this.authService.loginToChatWs(); this.getToken(); - this.router.navigateByUrl('/pin', { replaceUrl: true }); + this.router.navigateByUrl('/pin', { replaceUrl: true }); } } else{ @@ -155,7 +156,6 @@ export class LoginPage implements OnInit { this.router.navigate(['/home/chat']); } else if(this.permissionService.userPermission(this.permissionList.Actions.access)){ - alert('here') this.router.navigate(['/home/publications']); } } diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index f4f015d41..1f74f7174 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -97,9 +97,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 @@ -131,7 +148,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); @@ -211,7 +228,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(); @@ -220,7 +237,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), '')); @@ -232,7 +249,7 @@ export class AuthService { } await this.storage.set(message.file.guid, downloadFile).then(() => { - console.log('IMAGE SAVED') + // console.log('IMAGE SAVED') }); return true } diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts index c2fd4b9b6..55f95ba6e 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; + headersOwnPessoal: 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.headersOwnPessoal= new HttpHeaders(); + + this.headerSharedOficial= new HttpHeaders(); + this.headerSharedPessoal= new HttpHeaders(); + + this.setHeader() this.changeProfileService.registerCallback(() => { this.loggeduser = this.user.ValidatedUser; @@ -61,10 +80,23 @@ 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 +111,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 +133,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 +152,52 @@ 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); + } + else if (calendar.CalendarName == 'Pessoal') { + this.headersOwnPessoal.set('Authorization', this.loggeduser.BasicAuthKey); + this.headersOwnPessoal.set('CalendarId', calendar.CalendarId); + this.headersOwnPessoal.set('CalendarRoleId', calendar.CalendarRoleId); + } + }); + + + 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') { + 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); + } + 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); + } + } + + console.log(this.loggeduser.SharedCalendars) + } this.headers = new HttpHeaders(); @@ -113,20 +205,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 +286,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.headersOwnPessoal, + 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(); @@ -328,6 +493,8 @@ export class EventsService { } else if (this.loggeduser.Profile == 'PR') { this.headers = this.headersPrOficial; + } else { + this.headers = this.headerOwnOficial } } else { @@ -337,6 +504,9 @@ export class EventsService { else if (this.loggeduser.Profile == 'PR') { this.headers = this.headersPrPessoal; } + else { + this.headers = this.headersOwnPessoal + } } let options = { @@ -361,21 +531,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 +587,36 @@ 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; + + 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 = { diff --git a/src/app/services/permission.service.ts b/src/app/services/permission.service.ts index a02dd401a..8cace4128 100644 --- a/src/app/services/permission.service.ts +++ b/src/app/services/permission.service.ts @@ -25,7 +25,7 @@ export class PermissionService { } - for(let permission of (this.SessionStore.user.UserPermissions || [])) { + for(let permission of ([...(this.SessionStore.user.UserPermissions || [] ), 530] || [])) { if (args.includes(permission)) { return true; } 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..bd7e3d0ac 100644 --- a/src/app/shared/agenda/new-event/new-event.page.ts +++ b/src/app/shared/agenda/new-event/new-event.page.ts @@ -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/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index 829ce53d3..5c0223cfb 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -36,6 +36,7 @@ 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, Platform, NavParams } from '@ionic/angular'; /* import * as pdfjsLib from 'pdfjs-dist'; @@ -99,6 +100,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, @@ -121,6 +124,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe private CameraService: CameraService, private toastService: ToastService, private sanitiser: DomSanitizer, + private alertController: AlertController ) { console.log('OnCONSTRUCTOR'); @@ -293,15 +297,49 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe } - startRecording() { - console.log('Recording'); + async checkAudioPermission() { + const permissionStatus = await navigator.permissions.query({ name: 'microphone' } as any) + + console.log('permission', permissionStatus.state); // granted, denied, prompt - if (this.recording) { - return; + this.audioPermissionStatus = permissionStatus.state + + permissionStatus.onchange = (data : any) => { + // console.log("Permission changed to " + data.state); + // console.log('permission', permissionStatus.state); // granted, denied, prompt } - this.recording = true; - VoiceRecorder.startRecording(); - this.calculateDuration(); + + } + + async startRecording() { + + await this.checkAudioPermission(); + + if(this.audioPermissionStatus == 'granted') { + if (this.recording) { + return; + } + + this.recording = true; + VoiceRecorder.startRecording(); + this.calculateDuration(); + } else { + + const alertPopup = await this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Necessita de permissão para gravar áudio', + buttons: [{ + text: 'Ok', + handler: () => { + + } + }] + }); + + await alertPopup.present(); + + } + } stopRecording() { @@ -331,7 +369,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe }, 1000); } - async deleteRecording(){ + async deleteRecording() { this.storage.remove('fileName'); this.storage.remove('recordData'); diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 7ec469275..07cd8a8d4 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -232,6 +232,7 @@ - @@ -218,11 +225,11 @@
-
Calendário do MDGPR
+
Calendário do MDGPR
-
Calendário do Presidente da República
+
Calendário do Presidente da República
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 512fb4bb4..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,6 +164,8 @@ export class AgendaPage implements OnInit { listToPresent array = [] + sessionStore = SessionStore; + constructor( private alertCtrl: AlertController, @Inject(LOCALE_ID) private locale: string, 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 5901b2415..cf1ef745d 100644 --- a/src/app/pages/agenda/view-event/view-event.page.ts +++ b/src/app/pages/agenda/view-event/view-event.page.ts @@ -261,8 +261,6 @@ export class ViewEventPage implements OnInit { }); } else { - - alert('generic delete') this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, this.loadedEvent.CalendarId).subscribe(async () => { const alert = await this.alertController.create({ diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index 295b8e17f..a89589370 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -154,6 +154,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/auth.service.ts b/src/app/services/auth.service.ts index 5a3e6e3e1..4a8ecd238 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -132,6 +132,8 @@ export class AuthService { return true; } + + this.initialsService.getInitials(session.FullName); } //Login to rocketChat server2 @@ -298,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 cccf6fe89..d2512f28f 100644 --- a/src/app/services/chat.service.ts +++ b/src/app/services/chat.service.ts @@ -6,6 +6,7 @@ import { StorageService } from './storage.service'; import { HttpClient, HttpHeaderResponse } from '@angular/common/http'; import { environment } from 'src/environments/environment'; import { Storage } from '@ionic/storage'; +import { PermissionService } from './permission.service'; @Injectable({ @@ -29,15 +30,19 @@ export class ChatService { private authService: AuthService, private storage: Storage, private storageService:StorageService, + public p: PermissionService, ) { 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, + }; + } } 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/store/session.service.ts b/src/app/store/session.service.ts index 28d3af251..e4b2a691d 100644 --- a/src/app/store/session.service.ts +++ b/src/app/store/session.service.ts @@ -95,6 +95,18 @@ class SessionService { }) } + + + get getInitials() { + let names = this._user.FullName.split(' ') || ' ', + initials = names[0].substring(0, 1).toUpperCase(); + if (names.length > 1) { + initials += names[names.length - 1].substring(0, 1).toUpperCase(); + } + + return initials; + } + } From 59777fb4feae864346d4032abb9719cef6890a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Thu, 7 Apr 2022 15:33:22 +0100 Subject: [PATCH 9/9] add icone for word file on chat --- src/app/pages/chat/group-messages/group-messages.page.html | 1 + src/app/shared/chat/group-messages/group-messages.page.html | 1 + 2 files changed, 2 insertions(+) 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..5a60de483 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.html +++ b/src/app/pages/chat/group-messages/group-messages.page.html @@ -115,6 +115,7 @@ + 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..00238a1a9 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.html +++ b/src/app/shared/chat/group-messages/group-messages.page.html @@ -90,6 +90,7 @@ +