From f51bd246fcd5957dc7c471950b986e6901755df1 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Tue, 19 Sep 2023 10:21:23 +0100 Subject: [PATCH] fix ubgs --- .../create-process/create-process.page.ts | 16 +- src/app/modals/profile/profile.page.ts | 21 +- src/app/pages/chat/chat.page.html | 9 +- src/app/pages/chat/chat.page.ts | 12 +- .../group-contacts/group-contacts.page.ts | 56 ++--- .../pages/chat/new-group/new-group.page.ts | 31 ++- .../expedient-task-modal.page.ts | 52 ++--- .../new-action/new-action.page.html | 2 + .../new-action/new-action.page.ts | 10 +- src/app/services/chat/chat-system.service.ts | 51 ++--- src/app/services/chat/room.service.ts | 6 +- src/app/services/data.service.ts | 8 + .../notifications-ends-points.service.spec.ts | 16 ++ .../notifications-ends-points.service.ts | 40 ++++ .../notifications-store.service.spec.ts | 16 ++ .../notifications-store.service.ts | 9 + .../notifications-trigger.service.spec.ts | 16 ++ .../notifications-trigger.service.ts | 70 ++++++ .../notifications.service.spec.ts | 16 ++ .../notification/notifications.service.ts | 200 ++++++++++++++++++ src/app/services/notifications.service.ts | 54 +++-- src/app/services/task.service.ts | 102 ++++----- .../shared/chat/new-group/new-group.page.ts | 42 ++-- src/app/shared/header/header.page.html | 6 +- .../opts-expediente/opts-expediente.page.ts | 44 ++-- .../new-action/new-action.page.html | 7 +- .../publication/new-action/new-action.page.ts | 41 ++-- src/assets/images/icons-nav-agenda-active.svg | 46 ++++ src/global.scss | 16 +- 29 files changed, 754 insertions(+), 261 deletions(-) create mode 100644 src/app/services/notification/notifications-ends-points.service.spec.ts create mode 100644 src/app/services/notification/notifications-ends-points.service.ts create mode 100644 src/app/services/notification/notifications-store.service.spec.ts create mode 100644 src/app/services/notification/notifications-store.service.ts create mode 100644 src/app/services/notification/notifications-trigger.service.spec.ts create mode 100644 src/app/services/notification/notifications-trigger.service.ts create mode 100644 src/app/services/notification/notifications.service.spec.ts create mode 100644 src/app/services/notification/notifications.service.ts create mode 100644 src/assets/images/icons-nav-agenda-active.svg diff --git a/src/app/modals/create-process/create-process.page.ts b/src/app/modals/create-process/create-process.page.ts index 0806e1635..b5ba6a8f0 100644 --- a/src/app/modals/create-process/create-process.page.ts +++ b/src/app/modals/create-process/create-process.page.ts @@ -110,9 +110,9 @@ export class CreateProcessPage implements OnInit { console.log('this.fulltask', this.fulltask) - if(this.fulltask?.Documents) { - this.documents = this.fulltask.Documents - } + // if(this.fulltask?.Documents) { + // this.documents = this.fulltask.Documents + // } if (this.task.SerialNumber) { this.task.serialNumber = this.task.SerialNumber @@ -355,7 +355,7 @@ export class CreateProcessPage implements OnInit { DispatchFolder: this.dispatchFolder, AttachmentList: docs } - + try { if (this.task.activityInstanceName == 'Tarefa de Despacho' || this.task.activityInstanceName == 'Reexecutar Despacho') { // create parecer @@ -604,7 +604,7 @@ export class CreateProcessPage implements OnInit { backdropDismiss: false }); - + modal.onDidDismiss().then((data) => { if (data) { @@ -683,7 +683,7 @@ export class CreateProcessPage implements OnInit { backdropDismiss: false }); - + modal.onDidDismiss().then(res => { if (res['data'] == 'close') { this.modalController.dismiss(res['data']) @@ -742,7 +742,7 @@ export class CreateProcessPage implements OnInit { cssClass: classs, backdropDismiss: false }); - + modal.onDidDismiss().then((res) => { }, (error) => { @@ -770,7 +770,7 @@ export class CreateProcessPage implements OnInit { select: true } }); - + modal.onDidDismiss().then((res) => { if (res) { const data = res.data; diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts index ef5c39eb3..57ce30227 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -86,7 +86,7 @@ export class ProfilePage implements OnInit { this.getNotificationData(); - + this.getProfilpicture(); } @@ -259,7 +259,7 @@ export class ProfilePage implements OnInit { this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', IdObject, 'gabinete-digital'])); } else if (Service === "gabinete-digital" && Object === "diplomas-assinar") { - + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', IdObject, 'gabinete-digital'])); } else if (Service === "gabinete-digital" && Object === "diploma-revisao") { @@ -309,26 +309,26 @@ export class ProfilePage implements OnInit { else if (Service === "agenda" && Object === "event-list") { //this.zone.run(() => this.router.navigate(['/home/gabinete-digital/event-list/approve-event',IdObject, 'agenda'])); this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', IdObject, 'agenda'])); - + } else if (Service === "gabinete-digital" && Object === "despachos") { this.processesService.GetTask(IdObject).subscribe((task) => { this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', IdObject, 'gabinete-digital'], { replaceUrl: true })); }, (error) => { this.notificationdata[i].read = true; }) - - + + } else if (Service === "gabinete-digital" && Object === "parecer") { - + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', IdObject, 'gabinete-digital'])); } else if (Service === "gabinete-digital" && Object === "deferimento") { - + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', IdObject, 'gabinete-digital'])); } else if (Service === "gabinete-digital" && Object === "despachos-pr") { - + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', IdObject, 'gabinete-digital'])); } else if (Service === "accoes" && Object === "accao") { @@ -341,7 +341,7 @@ export class ProfilePage implements OnInit { this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', IdObject, 'gabinete-digital'])); } else if (Service === "gabinete-digital" && Object === "diplomas-assinar") { - + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', IdObject, 'gabinete-digital'])); } else if (Service === "gabinete-digital" && Object === "expedientes-pr") { @@ -383,13 +383,16 @@ export class ProfilePage implements OnInit { if (environment.production) { window.location.pathname = '/auth' + this.notificationService.DeletePostToken() } else { const pathBeforeGoOut = window.location.pathname this.router.navigateByUrl('/auth', { replaceUrl: true }); + this.notificationService.DeletePostToken() setTimeout(() => { if (this.logoutOut == false || pathBeforeGoOut == window.location.pathname) { window.location.pathname = '/auth' + this.notificationService.DeletePostToken() } else { } diff --git a/src/app/pages/chat/chat.page.html b/src/app/pages/chat/chat.page.html index f8dbc834c..68131be4b 100644 --- a/src/app/pages/chat/chat.page.html +++ b/src/app/pages/chat/chat.page.html @@ -1,6 +1,6 @@ - + @@ -41,7 +41,7 @@ - +
@@ -142,7 +142,7 @@
{{group.lastMessage.u.name}}: {{group.lastMessage.msg}}
{{group.userThatIsTyping}} está escrever ...
- +
@@ -231,9 +231,8 @@ [roomId]="roomId" (backToChat)="backToChat($event)" (closeAllDesktopComponents)="closeAllDesktopComponents()" - [style.display]="showNewGroup ? 'flex' : 'none'" *ngIf="showNewGroup" - class=" height-100 flex-column"> + class=" height-100 flex-column d-flex"> { this.ChatSystemService.subscribeToRoom() + this.RochetChatConnectorService.setStatus('online') },1000); /* const webSocketURL = environment.apiWsChatUrl; @@ -193,13 +194,13 @@ export class ChatPage implements OnInit { ws.addEventListener('open', () => { console.log('WebSocket connection opened'); }); - + ws.addEventListener('message', (event) => { const data = JSON.parse(event.data); // Handle incoming messages from the Rocket.Chat server. console.log('Received message:', data); }); - + ws.addEventListener('close', (event) => { console.log('WebSocket connection closed', event); // Optionally, attempt to reopen the connection when it's closed. @@ -209,8 +210,8 @@ export class ChatPage implements OnInit { }, 5000); // Reopen the connection after 5 seconds (adjust as needed). }); - this.RochetChatConnectorService.sendStreamNotifyRoom("26XgGhKghKN8fN6v8KvDfW9jrjhKhoAWhM", SessionStore.user.UserName, 'typing', true).catch((error) => console.error(error)); - + this.RochetChatConnectorService.sendStreamNotifyRoom("26XgGhKghKN8fN6v8KvDfW9jrjhKhoAWhM", SessionStore.user.UserName, 'typing', true).catch((error) => console.error(error)); + ws.addEventListener('error', (error) => { console.error('WebSocket error:', error); // Handle WebSocket errors here. @@ -365,6 +366,7 @@ export class ChatPage implements OnInit { } openNewGroupPage() { this.segment = 'Grupos'; + this.idSelected = ''; if (window.innerWidth < 701) { this.newGroup(); @@ -518,7 +520,7 @@ export class ChatPage implements OnInit { // }).catch((error) => { // console.error('storage getchatusers: ',error) // }) - // } + // } // // else { // // this.sqlservice.getAllChatRoom().then((rooms: any) => { // // // diff --git a/src/app/pages/chat/group-messages/group-contacts/group-contacts.page.ts b/src/app/pages/chat/group-messages/group-contacts/group-contacts.page.ts index e3d5078a3..eaeb0de34 100644 --- a/src/app/pages/chat/group-messages/group-contacts/group-contacts.page.ts +++ b/src/app/pages/chat/group-messages/group-contacts/group-contacts.page.ts @@ -36,7 +36,7 @@ export class GroupContactsPage implements OnInit { objectUserSingleStone = [] userContainer = {} - + constructor( private modalController: ModalController, private http: HttpClient, @@ -61,8 +61,8 @@ export class GroupContactsPage implements OnInit { // this.chatService.refreshtoken(); this.loadUsers(); // this.getMembers(); - - + + } loadUsers(){ @@ -98,10 +98,10 @@ export class GroupContactsPage implements OnInit { } else { 'not found' } - + } - - + + const userContainer = {} for(const user of this.objectUserSingleStone) { const firstLetter = user.name.charAt(0) @@ -111,11 +111,11 @@ export class GroupContactsPage implements OnInit { } else { userContainer[firstLetter].push(user) } - + } this.userContainer = userContainer - + this.showLoader = false; }); @@ -155,16 +155,16 @@ export class GroupContactsPage implements OnInit { "roomId": this.room._id, "userId": data._id, } - + if(this.room.t == "p"){ this.chatService.removeGroupMember(body).subscribe(res=>{ - + this.getMembers(); }); } else if(this.room.t == "c"){ this.chatService.removeChannelMember(body).subscribe(res=>{ - + this.getMembers(); }); } @@ -195,7 +195,7 @@ export class GroupContactsPage implements OnInit { }); const selectedUsers = this.users.filter( e => e?.isChecked == true) - + users.forEach( (user, index) => { if(user[index]) { console.log({user, index}) @@ -215,7 +215,7 @@ export class GroupContactsPage implements OnInit { let a = this.objectUserSingleStone.filter( e => e.name.toLowerCase().includes(this.textSearch.toLowerCase())) - + let b = {} for(const user of a) { const firstLetter = user.name.charAt(0) @@ -225,16 +225,16 @@ export class GroupContactsPage implements OnInit { } else { b[firstLetter].push(user) } - + } this.userContainer = b - + } clicked(){ - + } selectedContact(user:any) { @@ -244,18 +244,18 @@ export class GroupContactsPage implements OnInit { } else { user.isChecked = true } - + const userIndex = this.objectUserSingleStone.findIndex((e) => e._id == user._id) this.objectUserSingleStone[userIndex].isChecked = user.isChecked } addContacts(room:any){ - + this.selectedUserList = this.users.filter(function(contact) { return contact.isChecked == true; }); - + this.selectedUserList.forEach(user=>{ let body ={ "roomId":room._id, @@ -263,7 +263,7 @@ export class GroupContactsPage implements OnInit { } this.chatService.addUserToGroup(body).subscribe(res=>{ - + }); }); } @@ -271,12 +271,12 @@ export class GroupContactsPage implements OnInit { loading = false updateGroup(){ if(this.loading) { - return + return } - + this.loading = true console.log('this.room', this.room) - + this.chatService.getRoomInfo(this.room._id).subscribe(room=>{ this.room = room['room']; this.addContacts(this.room); @@ -288,8 +288,8 @@ export class GroupContactsPage implements OnInit { } async openGroupMessages(roomId:any){ - this.close(); - + + const modal = await this.modalController.create({ component: GroupMessagesPage, componentProps: { @@ -300,9 +300,11 @@ export class GroupContactsPage implements OnInit { }); - modal.onDidDismiss(); + modal.onDidDismiss().then(() => { + this.close(); + }); await modal.present(); - + } } diff --git a/src/app/pages/chat/new-group/new-group.page.ts b/src/app/pages/chat/new-group/new-group.page.ts index 0e713d049..91a5a6338 100644 --- a/src/app/pages/chat/new-group/new-group.page.ts +++ b/src/app/pages/chat/new-group/new-group.page.ts @@ -41,25 +41,24 @@ export class NewGroupPage implements OnInit { ngOnInit() { // this.chatService.refreshtoken(); // console.log(this.documents) - } - _ionChange(event){ + _ionChange(event) { this.showDuration = event.detail.checked; - if(event.detail.checked){ + if(event.detail.checked) { this.thedate = new Date(); } - else{ + else { this.thedate = ''; } } - close(){ + close() { this.modalController.dismiss(); } async createGroup(){ - + let name = this.groupName.split(' ').join('-'); //Take out all special characters in string name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); @@ -72,17 +71,15 @@ export class NewGroupPage implements OnInit { "countDownDate": this.thedate } res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields); - } else{ res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields); - } this.isGroupCreated = true; this.addContacts(res.result); this.ChatSystemService.getAllRooms(); - + setTimeout(() => { this.ChatSystemService.subscribeToRoomUpdate(res.result.rid, res.result); }, 10) @@ -90,23 +87,23 @@ export class NewGroupPage implements OnInit { if(res?.result?.rid) { - + this.ChatSystemService.getAllRooms(() => { if(!this.ChatSystemService.getGroupRoom(res.result.rid)) { this.createGroupWithAttachmentsCath(res) } else { setTimeout(()=> { - + this.createGroupWithAttachments(res) - + }, 500) } }, res.result.rid); - + } else { - + this.toastService._badRequest('Existe um grupo com este nome!'); } @@ -169,7 +166,7 @@ export class NewGroupPage implements OnInit { this.close(); let name = this.groupName.split(' ').join('-'); - + const modal = await this.modalController.create({ component: GroupContactsPage, @@ -206,7 +203,7 @@ export class NewGroupPage implements OnInit { text: 'Ok', cssClass: 'btn-cancel', handler:(value:any) => { - + let now = new Date(); this.thedate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + value.days.value, now.getHours() + value.hours.value, now.getMinutes() + value.minutes.value, now.getSeconds(), now.getMilliseconds()); @@ -215,7 +212,7 @@ export class NewGroupPage implements OnInit { value.hours.value, value.minutes.value, ] - + if(value.days.value != null && value.hours.value != null && value.minutes.value != null){ if(value.days.value > 0) { if(value.days.value == 1) { diff --git a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts index 66826fc22..2a0759dd9 100644 --- a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts @@ -120,30 +120,30 @@ export class ExpedientTaskModalPage implements OnInit { this.loggeduser = SessionStore.user; this.task = this.navParams.get('task'); - + this.SearchFolder = this.navParams.get('SearchFolder'); this.aplicationId = this.navParams.get('aplicationId') - this.document = this.navParams.get('document') + // this.document = this.navParams.get('document') this.taskType = this.navParams.get('taskAction'); - if(this.document) { - const doc: any = this.document + // if(this.document) { + // const doc: any = this.document - this.documents.push({ - ApplicationId: (doc.ApplicationType || doc.ApplicationId), - ApplicationType: (doc.ApplicationType || doc.ApplicationId), - SourceId: (doc.Id || doc.DocId || doc.SourceId), - Id: (doc.Id || doc.DocId || doc.SourceId), - EntidadeOrganicaNome: (doc.sender || doc.SourceName || doc. EntidadeOrganicaNome), - Sender: (doc.sender || doc.SourceName || doc. EntidadeOrganicaNome), - Data: (doc.DocDate || doc.Data), - DocDate: (doc.DocDate || doc.Data), - Assunto: doc.Assunto, - } as any) - } + // this.documents.push({ + // ApplicationId: (doc.ApplicationType || doc.ApplicationId), + // ApplicationType: (doc.ApplicationType || doc.ApplicationId), + // SourceId: (doc.Id || doc.DocId || doc.SourceId), + // Id: (doc.Id || doc.DocId || doc.SourceId), + // EntidadeOrganicaNome: (doc.sender || doc.SourceName || doc. EntidadeOrganicaNome), + // Sender: (doc.sender || doc.SourceName || doc. EntidadeOrganicaNome), + // Data: (doc.DocDate || doc.Data), + // DocDate: (doc.DocDate || doc.Data), + // Assunto: doc.Assunto, + // } as any) + // } const DocumentToSave = this.documents.map((e) => { @@ -181,7 +181,7 @@ export class ExpedientTaskModalPage implements OnInit { this.postData.DispatchFolder.Subject = this.task.workflowInstanceDataFields.Subject; this.profile = this.navParams.get('profile'); - + } async setAdding(type: "intervenient" | "CC") { @@ -199,9 +199,9 @@ export class ExpedientTaskModalPage implements OnInit { } onSelectedTypesChanged(ev:any) { - + if(ev.length > 1){ - + this.selectedTypes = ev.filter(data => data != '99999850'); } if(ev.length == 0){ @@ -216,7 +216,7 @@ export class ExpedientTaskModalPage implements OnInit { getSubjectType() { this.processes.GetSubjectType().subscribe(res=>{ - + this.subjectTypes = res; }); } @@ -233,7 +233,7 @@ export class ExpedientTaskModalPage implements OnInit { if(this.p.userPermission([this.p.permissionList.Gabinete.pr_tasks])) { return ['MDGPR'] } - + return null } @@ -368,7 +368,7 @@ export class ExpedientTaskModalPage implements OnInit { loader.remove() } - + break; case '1': // Parecer @@ -434,7 +434,7 @@ export class ExpedientTaskModalPage implements OnInit { loader.remove() } - + break; } } @@ -450,7 +450,7 @@ export class ExpedientTaskModalPage implements OnInit { DispatchFolder: this.dispatchFolder, AttachmentList: docs, } - + let action_despacho_pr = { "serialNumber": this.task.serialNumber, @@ -520,7 +520,7 @@ export class ExpedientTaskModalPage implements OnInit { getAttachments() { this.attachmentsService.getAttachmentsBySerial(this.task.serialNumber).subscribe(res=>{ this.loadedAttachments = res; - + }); } @@ -601,7 +601,7 @@ export class ExpedientTaskModalPage implements OnInit { } async viewExpedientDetail() { - + let classs; if( window.innerWidth <= 800){ diff --git a/src/app/pages/publications/new-action/new-action.page.html b/src/app/pages/publications/new-action/new-action.page.html index cb0a77275..b9615482c 100644 --- a/src/app/pages/publications/new-action/new-action.page.html +++ b/src/app/pages/publications/new-action/new-action.page.html @@ -44,6 +44,7 @@ [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" [touchUi]="touchUi" + [hideTime]="true" > @@ -74,6 +75,7 @@ [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" [touchUi]="touchUi" + [hideTime]="true" > diff --git a/src/app/pages/publications/new-action/new-action.page.ts b/src/app/pages/publications/new-action/new-action.page.ts index 4eb1a23f1..a166eae1a 100644 --- a/src/app/pages/publications/new-action/new-action.page.ts +++ b/src/app/pages/publications/new-action/new-action.page.ts @@ -14,7 +14,7 @@ const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { dateInput: "YYYY-MMMM-DD HH:mm" }, display: { - dateInput: "DD MMM YYYY H:mm", + dateInput: "DD MMM YYYY", monthYearLabel: "MMM YYYY", dateA11yLabel: "LL", monthYearA11yLabel: "MMMM YYYY" @@ -97,7 +97,7 @@ export class NewActionPage implements OnInit { }, 1000); segmentChanged(ev: any) { - + } get dateValid() { @@ -173,7 +173,7 @@ export class NewActionPage implements OnInit { date.setSeconds(0); if(minutes % 15 != 0) { - + if (minutes > 45) { date.setMinutes(60) } else if (minutes > 30) { @@ -184,7 +184,7 @@ export class NewActionPage implements OnInit { date.setMinutes(15) } - } + } return date } @@ -193,7 +193,7 @@ export class NewActionPage implements OnInit { const _date = new Date(date); const minutes = _date .getMinutes(); _date .setMinutes(minutes + 15) - return _date + return _date } } diff --git a/src/app/services/chat/chat-system.service.ts b/src/app/services/chat/chat-system.service.ts index c19f5ea02..af29c2a40 100644 --- a/src/app/services/chat/chat-system.service.ts +++ b/src/app/services/chat/chat-system.service.ts @@ -45,7 +45,7 @@ export class ChatSystemService { onRoomsLoad = new Subscribe({execute : false, deleteOnExecute: true}) - + constructor( private RochetChatConnectorService: RochetChatConnectorService, private storage: Storage, @@ -76,6 +76,7 @@ export class ChatSystemService { await this.chatService.refreshtoken(); await this.getUser(); + this.RochetChatConnectorService.setStatus('online') await this.getAllRooms(); this.subscribeToRoom(); // @@ -179,7 +180,7 @@ export class ChatSystemService { const rooms = await this.storage.get('Rooms'); if(rooms) { - for (let roomData of rooms.result.update) { + for (let roomData of rooms.result.update) { await this.prepareRoom(roomData); } } @@ -213,7 +214,7 @@ export class ChatSystemService { } try { await this.storage.remove('Rooms'); - } catch(e) {} + } catch(e) {} } let index = 0 @@ -224,7 +225,7 @@ export class ChatSystemService { const roomId = this.getRoomId(roomData); if(roomData.t == 'd') { - + let error = false let res; @@ -238,13 +239,13 @@ export class ChatSystemService { if(error) { res = await this.chatService.getMembers(roomId).toPromise(); } - - + + const members = res['members']; const users = members.filter(data => data.username != this.sessionStore.user.UserName); rooms.result.update[index]['members'] = members rooms.result.update[index]['membersExcludeMe'] = users - + await this.prepareRoom(roomData); } else { if (roomData.t === 'p') { @@ -257,19 +258,19 @@ export class ChatSystemService { await this.chatService.refreshtoken(); error = true } - + if(error) { res = await this.chatService.getGroupMembers(roomId).toPromise() } const members = res['members']; const users = members.filter(data => data.username != this.sessionStore.user.UserName); - + rooms.result.update[index]['members'] = members rooms.result.update[index]['membersExcludeMe'] = users - + await this.prepareRoom(roomData); - + } else { @@ -283,7 +284,7 @@ export class ChatSystemService { await this.chatService.refreshtoken(); error = true } - + if(error) { res = await this.chatService.getChannelMembers(roomId).toPromise() } @@ -291,19 +292,19 @@ export class ChatSystemService { const members = res['members']; const users = members.filter(data => data.username != this.sessionStore.user.UserName); - + rooms.result.update[index]['members'] = members rooms.result.update[index]['membersExcludeMe'] = users await this.prepareRoom(roomData); } - + } if(roomId == roomIdCallback) { callback() } - - + + index++; } } @@ -372,29 +373,29 @@ export class ChatSystemService { * @param id room id */ private defaultSubtribe(id: any) { - + const room = this.getRoomById(id); - + if(!room.subscribeAttempt) { room.subscribeAttempt = true; - + this.RochetChatConnectorService.streamRoomMessages(id).then((subscription) => { room.status.receive.message = true; }) - + this.RochetChatConnectorService.subStreamNotifyRoom(id, 'typing', false).then((subscription) => { room.status.receive.typing = true; // }) - + this.RochetChatConnectorService.subStreamNotifyRoom(id, 'readMessage', false).then((subscription) => { room.status.receive.readMessage = true; }) - + this.RochetChatConnectorService.streamNotifyRoomDeleteMessage(id).then((subscription) => { room.status.receive.deleteMessage = true; }) - } + } } @@ -485,7 +486,7 @@ export class ChatSystemService { this.delete.push(roomId) delete this.group[roomId]; - this._group = this._group.filter((e)=> e.id != roomId); + this._group = this._group.filter((e)=> e.id != roomId); } deleteRecently(roomId) { @@ -626,7 +627,7 @@ export class ChatSystemService { return 'Sem nome' } - + } else { return roomData.fname } diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 4e67a5e36..1b1849a1b 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -721,11 +721,11 @@ export class RoomService { formatDateToDDMMYYYY(dateStamp) { const date = new Date(dateStamp); - + const day = date.getDate().toString().padStart(2, '0'); const month = (date.getMonth() + 1).toString().padStart(2, '0'); // Month is zero-based const year = date.getFullYear(); - + return `${day}-${month}-${year}`; } @@ -780,6 +780,8 @@ export class RoomService { let currentDateMessage = new Date().toLocaleDateString() if(!this.labelDates.find( e => e == currentDateMessage)) { + this.labelDates.push(currentDateMessage) + const cloneMessage = new MessageServiceDateLabel() cloneMessage.ChatSystemService = this.ChatSystemService diff --git a/src/app/services/data.service.ts b/src/app/services/data.service.ts index d48da2bcc..9320c7adf 100644 --- a/src/app/services/data.service.ts +++ b/src/app/services/data.service.ts @@ -18,4 +18,12 @@ export class DataService { return this.data[name] } + delate(name: string) { + delete this.data[name] + } + + + clear() { + this.data = {} + } } diff --git a/src/app/services/notification/notifications-ends-points.service.spec.ts b/src/app/services/notification/notifications-ends-points.service.spec.ts new file mode 100644 index 000000000..312bbf7f3 --- /dev/null +++ b/src/app/services/notification/notifications-ends-points.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { NotificationsEndsPointsService } from './notifications-ends-points.service'; + +describe('NotificationsEndsPointsService', () => { + let service: NotificationsEndsPointsService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(NotificationsEndsPointsService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/notification/notifications-ends-points.service.ts b/src/app/services/notification/notifications-ends-points.service.ts new file mode 100644 index 000000000..4b218415a --- /dev/null +++ b/src/app/services/notification/notifications-ends-points.service.ts @@ -0,0 +1,40 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { SessionStore } from 'src/app/store/session.service'; +import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications'; +import { environment } from 'src/environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class NotificationsEndsPointsService { + + constructor( + private http: HttpClient, + ) { } + + + + postToken(token) { + const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; + const body = { + UserId: SessionStore.user.UserId, + TokenId: token, + Status: 1, + Service: 1 + }; + + return this.http.post(`${environment.apiURL}+ 'notifications/token'`, body, { headers }) + } + + + DeleteToken(token) { + + const geturl = environment.apiURL + `notifications/token?userId=${SessionStore.user.UserId}&tokenId=${token}`; + const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; + const body = {}; + + return this.http.delete(`${geturl}`, { headers, body }) + } + +} diff --git a/src/app/services/notification/notifications-store.service.spec.ts b/src/app/services/notification/notifications-store.service.spec.ts new file mode 100644 index 000000000..89c9f0edc --- /dev/null +++ b/src/app/services/notification/notifications-store.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { NotificationsStoreService } from './notifications-store.service'; + +describe('NotificationsStoreService', () => { + let service: NotificationsStoreService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(NotificationsStoreService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/notification/notifications-store.service.ts b/src/app/services/notification/notifications-store.service.ts new file mode 100644 index 000000000..b6914e848 --- /dev/null +++ b/src/app/services/notification/notifications-store.service.ts @@ -0,0 +1,9 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class NotificationsStoreService { + + constructor() { } +} diff --git a/src/app/services/notification/notifications-trigger.service.spec.ts b/src/app/services/notification/notifications-trigger.service.spec.ts new file mode 100644 index 000000000..bda029160 --- /dev/null +++ b/src/app/services/notification/notifications-trigger.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { NotificationsTriggerService } from './notifications-trigger.service'; + +describe('NotificationsTriggerService', () => { + let service: NotificationsTriggerService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(NotificationsTriggerService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/notification/notifications-trigger.service.ts b/src/app/services/notification/notifications-trigger.service.ts new file mode 100644 index 000000000..8867bc8bd --- /dev/null +++ b/src/app/services/notification/notifications-trigger.service.ts @@ -0,0 +1,70 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { SessionStore } from 'src/app/store/session.service'; +import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications'; +import { environment } from 'src/environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class NotificationsTriggerService { + + constructor( + private http: HttpClient, + ) { } + + + + + sendNotificationWithSend(userID, title, bodymsg, roomId) { + const geturl = environment.apiURL + `notifications/send`; + + const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; + const message = { + "Service": "chat", + "IdObject": roomId + } + let id = 437 + this.http.post(geturl + `?userId=${userID}&title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => { + + }, (error) => { + + }) + } + + + ChatSendMessageNotification(userID, title, bodymsg, roomId) { + const geturl = environment.apiURL + `notifications/sendbyUsername`; + + const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; + const message = { + "Service": "chat", + "IdObject": roomId + } + let id = 437 + this.http.post(geturl + `?username=${userID}&title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => { + // this.active = true + }, (error) => { + + }) + } + + ChatSendMessageNotificationGrup(usersID, title, bodymsg, roomId) { + const geturl = environment.apiURL + `notifications/sendByUsernames`; + + const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; + const message = { + "Users": usersID, + "NotificationData": { + "Service": "chat", + "IdObject": roomId + } + } + + this.http.post(geturl + `?title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => { + // this.active = true + }, (error) => { + + }) + } +} diff --git a/src/app/services/notification/notifications.service.spec.ts b/src/app/services/notification/notifications.service.spec.ts new file mode 100644 index 000000000..c939c4c3f --- /dev/null +++ b/src/app/services/notification/notifications.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { NotificationsService } from './notifications.service'; + +describe('NotificationsService', () => { + let service: NotificationsService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(NotificationsService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/notification/notifications.service.ts b/src/app/services/notification/notifications.service.ts new file mode 100644 index 000000000..3aff89bb7 --- /dev/null +++ b/src/app/services/notification/notifications.service.ts @@ -0,0 +1,200 @@ +import { Injectable, NgZone } from '@angular/core'; +import { AlertController, Platform } from '@ionic/angular'; +import { Capacitor } from '@capacitor/core'; +import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications'; +import { environment } from 'src/environments/environment'; +import { NotificationsEndsPointsService } from './notifications-ends-points.service' +import { AngularFireMessaging } from '@angular/fire/messaging'; +import { NavigationExtras, Router } from '@angular/router'; +@Injectable({ + providedIn: 'root' +}) +export class NotificationsService { + + isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications'); + active = false + + constructor( + private platform: Platform, + private NotificationsEndsPointsService: NotificationsEndsPointsService, + private afMessaging: AngularFireMessaging, + private router: Router, + private zone: NgZone, + ) { } + + + requestPermissions() { + + if (this.platform.is('mobile')) { + if (!this.isPushNotificationsAvailable) { + return false + } + PushNotifications.requestPermissions().then(result => { + if (result.receive === 'granted') { + // Register with Apple / Google to receive push via APNS/FCM + PushNotifications.register(); + } else { + // Show some error + } + }); + } else {} + } + + + getToken(): Promise { + return new Promise((resolve, reject) => { + if (this.platform.is('mobile')) { + if (!this.isPushNotificationsAvailable) { + return false + } + PushNotifications.addListener('registration', + (token: Token) => { + resolve(token.value) + } + ); + } else { + this.afMessaging.requestToken.subscribe( + (token) => { + resolve(token) + }, + (error) => { + console.error('Permission denied:', error); + } + ); + } + }) + } + + async registerToken(username) { + const token = await this.getToken() + + if (this.platform.is('mobile')) { + if (!this.isPushNotificationsAvailable) { + return false + } + + this.NotificationsEndsPointsService.postToken(token) + } else { + this.afMessaging.requestToken.subscribe( + (token) => { + // Save the token to your server for sending notifications + console.log('Permission granted! Token:', token); + this.NotificationsEndsPointsService.postToken(token) + }, + (error) => { + console.error('Permission denied:', error); + } + ); + } + } + + onReciveBackground() { + + if(this.platform.is('mobile')) { + if (!this.isPushNotificationsAvailable) { + return false + } + + PushNotifications.addListener('pushNotificationActionPerformed', + (notification: ActionPerformed) => { + this.active = true + console.log('NOtification Listener Backgroud', notification) + /* this.DataArray.push(notification.notification) + + this.storageService.store("Notifications", this.DataArray) + this.eventtrigger.publishSomeData({ + notification: "recive" + }) */ + this.notificatinsRoutes(notification) + // this.runNotificationCallback(notification) + } + ); + } else { + navigator.serviceWorker.onmessage = (event) => { + console.log('Mensagem recebida do Service Worker:', event.data.data); + let object = { + notification: event.data + } + + if (event.data.notificationClicked) { + console.log('Notificação push do Firebase clicada em segundo plano!'); + this.notificatinsRoutes(object) + } + }; + } + + } + + + registrationError() { + if (!this.isPushNotificationsAvailable) { + return false + } + + PushNotifications.addListener('registrationError', + (error: any) => { + this.active = false + } + ); + } + + + notificatinsRoutes = (notification) => { + + console.log('BACK BACK',notification) + + if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) { + + this.zone.run(() => this.router.navigate(['/home/agenda', notification.notification.data.IdObject, 'agenda'])); + } + else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes") { + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', notification.notification.data.IdObject, 'gabinete-digital'])); + } + else if (notification.notification.data.Service === "agenda" && notification.notification.data.Object === "event-list") { + //this.zone.run(() => this.router.navigate(['/home/gabinete-digital/event-list/approve-event',IdObject, 'agenda'])); + this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', notification.notification.data.IdObject, 'agenda'])); + + } else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos") { + + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', notification.notification.data.IdObject, 'gabinete-digital'], { replaceUrl: true })); + } + else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "parecer") { + + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital'])); + } + else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "deferimento") { + + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital'])); + } + else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos-pr") { + + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', notification.notification.data.IdObject, 'gabinete-digital'])); + } + else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "accao") { + this.zone.run(() => this.router.navigate(['/home/publications', notification.notification.data.IdObject])); + } + else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "publicacao") { + this.zone.run(() => this.router.navigate(['/home/publications/view-publications', notification.notification.data.FolderId, notification.data.IdObject])); + } + else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas") { + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.IdObject, 'gabinete-digital'])); + } + else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas-assinar") { + + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', notification.notification.data.IdObject, 'gabinete-digital'])); + } + + else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diploma-revisao") { + + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.IdObject, 'gabinete-digital'])); + } + + else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes-pr") { + this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.notification.data.IdObject, 'gabinete-digital'])); + } else if (notification.notification.data.Service === "chat") { + let navigationExtras: NavigationExtras = { queryParams: { "roomId": notification.notification.data.IdObject, } }; + this.zone.run(() => this.router.navigate(['/home/chat'], navigationExtras)); + } + + } +} diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index f868b7020..e2be3a0cb 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -34,6 +34,7 @@ export class NotificationsService { active = false isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications'); notificationReceived: EventEmitter = new EventEmitter(); + token = '' constructor( private http: HttpClient, @@ -81,6 +82,7 @@ export class NotificationsService { PushNotifications.addListener('registration', (token: Token) => { this.postToken(token.value, geturl) + this.token = token.value } ); } else { @@ -89,6 +91,7 @@ export class NotificationsService { // Save the token to your server for sending notifications console.log('Permission granted! Token:', token); this.postToken(token, geturl) + this.token = token }, (error) => { console.error('Permission denied:', error); @@ -98,6 +101,13 @@ export class NotificationsService { } + + DeletePostToken() { + const geturl = environment.apiURL + `notifications/token?userId=${SessionStore.user.UserId}&tokenId=${this.token}`; + + this.DeleteToken(geturl) + } + postToken(token, geturl) { const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; const body = { @@ -113,6 +123,19 @@ export class NotificationsService { }) } + + DeleteToken(geturl) { + const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; + const body = {}; + + this.http.delete(`${geturl}`, { headers, body }).subscribe(data => { + this.active = true + }, (error) => { + + }) + } + + registrationError() { if (!this.isPushNotificationsAvailable) { return false @@ -137,8 +160,8 @@ export class NotificationsService { this.active = true console.log('NOtification Listener', notification) this.storenotification(notification) - - + + } ); @@ -154,7 +177,7 @@ export class NotificationsService { } } - + storenotification(notification) { console.log('Store Notification ',notification) this.storageService.get("Notifications").then((store) => { @@ -168,21 +191,21 @@ export class NotificationsService { let exists = accumulator.find(item => { return item.id === current.id; }); - - if(!exists) { + + if(!exists) { accumulator = accumulator.concat(current); } return accumulator; }, []); - + console.log('Notification Result',result); this.storageService.store("Notifications", result).then(() => { this.eventtrigger.publishSomeData({ notification: "recive" }) }) - - + + } else { this.storageService.store("Notifications", store).then(() => { this.eventtrigger.publishSomeData({ @@ -190,11 +213,6 @@ export class NotificationsService { }) }) } - - - - - }).catch((error) => { if (!error) { this.storageService.store("Notifications", [notification]) @@ -208,13 +226,13 @@ export class NotificationsService { if (!this.isPushNotificationsAvailable) { return false } - + PushNotifications.addListener('pushNotificationActionPerformed', (notification: ActionPerformed) => { this.active = true console.log('NOtification Listener Backgroud', notification) /* this.DataArray.push(notification.notification) - + this.storageService.store("Notifications", this.DataArray) this.eventtrigger.publishSomeData({ notification: "recive" @@ -236,7 +254,7 @@ export class NotificationsService { } }; } - + } sendNotificationWithSend(userID, title, bodymsg, roomId) { @@ -254,7 +272,7 @@ export class NotificationsService { }) } - + ChatSendMessageNotification(userID, title, bodymsg, roomId) { const geturl = environment.apiURL + `notifications/sendbyUsername`; @@ -298,7 +316,7 @@ export class NotificationsService { notificatinsRoutes = (notification) => { -console.log('BACK BACK',notification) + console.log('BACK BACK',notification) if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) { diff --git a/src/app/services/task.service.ts b/src/app/services/task.service.ts index 06b4e286f..d4971285b 100644 --- a/src/app/services/task.service.ts +++ b/src/app/services/task.service.ts @@ -42,7 +42,7 @@ export class TaskService { deplomasStore = DeplomasStore SessionStore = SessionStore - + AllProcess = [] showLoader: boolean = false showLoaderNum: number = 0 @@ -57,8 +57,8 @@ export class TaskService { funx: Function id: string } - } = {} - + } = {} + constructor( private processesbackend: ProcessesService, @@ -95,7 +95,7 @@ export class TaskService { registerCallback({funx, id = uuidv4()}) { this.callbacks[id] = { funx, id} - + return { delete: ()=> { delete this.callbacks[id] @@ -132,7 +132,7 @@ export class TaskService { if(!isoDateString) { return false } - + const creationDate = new Date(isoDateString) return momentG(new Date(), 'dd MMMM yyyy') == momentG(new Date(creationDate), 'dd MMMM yyyy') } @@ -149,7 +149,7 @@ export class TaskService { } else if (attribute == 'OverdueTasks') { return this.overdueTask(item.Deadline || item.deadline) - + } return true } @@ -168,9 +168,9 @@ export class TaskService { sortArrayISODate(myArray: any): any[] { - return myArray.sort((a,b) => - Date.parse(b.CreateDate || b.taskStartDate || b.TaskStartDate || b.TaskReceiveDate || b.taskReceiveDate ) - - + return myArray.sort((a,b) => + Date.parse(b.CreateDate || b.taskStartDate || b.TaskStartDate || b.TaskReceiveDate || b.taskReceiveDate ) + - Date.parse(a.CreateDate || b.taskStartDate || b.TaskStartDate || a.TaskReceiveDate || a.taskReceiveDate )) } @@ -216,7 +216,7 @@ export class TaskService { await this.loadPendestes() await this.loadDiplomas() - + await this.loadEventosParaAprovacao() this.loadCount = true @@ -241,17 +241,17 @@ export class TaskService { try { let expedientes; expedientes = await this.processesbackend.GetTaskListExpediente(false).toPromise() - + expedientes = (expedientes || [] ).filter(data => data.workflowInstanceDataFields.Status == "" || data.workflowInstanceDataFields.Status == "Active") - + expedientes = expedientes.filter((item) => { return item.activityInstanceName != 'Retificar Expediente' }); - + expedientes = expedientes.map((element) => this.expedienteTaskPipe.transform(element)); expedientes = this.sortArrayISODate(expedientes).reverse() - + this.expedientegbstore.reset(expedientes); } catch (error) { @@ -268,15 +268,15 @@ export class TaskService { try { let pareceres = await this.processesbackend.GetTasksList("Pedido de Parecer", false).toPromise(); let pareceresPr = await this.processesbackend.GetTasksList("Pedido de Parecer do Presidente", false).toPromise(); - + let allParecer = pareceres.concat(pareceresPr); - + this.pedidosstore.countparecer = Object.keys(allParecer.filter(data => data.workflowInstanceDataFields.Status == "Active")).length; - + this.pedidosstore.resetparecer(allParecer.filter(data => data.workflowInstanceDataFields.Status == "Active").map((element) => { return this.customTaskPipe.transform(element) - })); - + })); + let deferimentos = await this.processesbackend.GetTasksList("Pedido de Deferimento", false).toPromise(); this.pedidosstore.countdeferimento = Object.keys(deferimentos.filter(data => data.workflowInstanceDataFields.Status == "Active")).length this.pedidosstore.resetdeferimento(deferimentos.filter(data => data.workflowInstanceDataFields.Status == "Active").map((element) => { @@ -292,7 +292,7 @@ export class TaskService { this.showLoaderNum++ try { - + let pendentes = await this.processesbackend.GetPendingTasks(false).toPromise(); this.pendentesstore.count = Object.keys(pendentes).length; @@ -304,7 +304,7 @@ export class TaskService { } this.showLoaderNum-- - + } @@ -313,7 +313,7 @@ export class TaskService { console.log('PR') // PR dont have event to approve /* if(this.SessionStore.user.Profile != 'PR') { */ - try { + try { for(let calendar of this.eventService.calendarNamesAry) { if(calendar == 'Meu calendario') { // color @@ -324,10 +324,10 @@ export class TaskService { } catch (error) { eventsList = []; } - + console.log(calendar, eventsList) this.eventoaprovacaostore.save(calendar, eventsList) - + } else { let allEvents = await this.processesbackend.eventsToApprove(calendar.OwnerUserId, 'againete page').toPromise() let eventsList @@ -336,13 +336,13 @@ export class TaskService { } catch(error) { eventsList = [] } - + console.log(calendar, eventsList) this.eventoaprovacaostore.save(calendar.OwnerUserId, eventsList) } } } catch (error) { - + } /* } */ @@ -357,64 +357,64 @@ export class TaskService { this.showLoaderNum++ try { - + let depachoAPI = await this.processesbackend.GetTasksList("Despacho do Presidente da República", false).toPromise(); - - + + if(SessionStore.user.Profile != 'PR') { - + let depacho: any = depachoAPI.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho"); depacho = depacho.filter(data => data.workflowInstanceDataFields.Status == "Active"); - + depacho = depacho.map((e)=> this.customTaskPipe.transform(e)) - + this.despachoprstore.reset(depacho) - + } else if(SessionStore.user.Profile == 'PR') { - + let depacho: any = depachoAPI.filter(data => data.activityInstanceName == "Concluir Despacho").filter(data => data.workflowInstanceDataFields.Status == "Active") depacho = depacho.map((e)=> this.customTaskPipe.transform(e)) this.despachoprstore.reset(depacho) - + } - - + + let gerarDiploma = depachoAPI.reverse().filter(data => data.activityInstanceName == "Gerar Diploma" || data.activityInstanceName == "Retificar Diploma"); let diplomasList = [] - + gerarDiploma.forEach(element => { let task: customTask = this.customTaskPipe.transform(element); diplomasList.push(task); }); - + diplomasList = diplomasList this.deplomasStore.resetDiplomaGerar(diplomasList); - - + + let diplomasValidar = depachoAPI.filter(data => data.activityInstanceName == "Revisar Diploma"); - + diplomasValidar = diplomasValidar.filter(data => data.activityInstanceName != "Tarefa de Despacho"); - - + + this.deplomasStore.resetDiplomasReview(diplomasValidar.map((element)=> { - + let date = new Date(element.taskStartDate); date.setMonth(date.getMonth() + 1); let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); - + return this.customTaskPipe.transform(element) })) - - + + let diplomasAssinar: any = depachoAPI.filter(data => data.activityInstanceName == "Assinar Diploma"); diplomasAssinar = diplomasAssinar.map((element) => this.expedienteTaskPipe.transform(element)) this.deplomasStore.resetDiplomasParaAssinar(diplomasAssinar) - + let diplomasAssinados: any = depachoAPI.filter(data => data.activityInstanceName == "Diploma Assinado"); diplomasAssinados = diplomasAssinados.map((element) => this.expedienteTaskPipe.transform(element)) this.deplomasStore.resetDiplomasAssinadoList(diplomasAssinados) } catch (error) {} - + this.showLoaderNum-- } @@ -471,7 +471,7 @@ export class TaskService { dynamicSearch({searchSubject, ordinance, list}) { if(searchSubject) { - + const AllProcess = list.filter((task) => { let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject subject = subject.toLowerCase(); diff --git a/src/app/shared/chat/new-group/new-group.page.ts b/src/app/shared/chat/new-group/new-group.page.ts index 7ef1a1890..ff091b870 100644 --- a/src/app/shared/chat/new-group/new-group.page.ts +++ b/src/app/shared/chat/new-group/new-group.page.ts @@ -37,8 +37,8 @@ export class NewGroupPage implements OnInit{ @Input() groupName:string; @Output() addGroupMessage:EventEmitter = new EventEmitter(); @Output() closeAllDesktopComponents:EventEmitter = new EventEmitter(); - @Output() backToChat:EventEmitter = new EventEmitter(); - + @Output() backToChat:EventEmitter = new EventEmitter(); + constructor( private pickerController: PickerController, @@ -57,23 +57,17 @@ export class NewGroupPage implements OnInit{ } ngOnInit() { - - console.log(this.dataService.get("task")) this.task = this.dataService.get("task"); this.event = this.dataService.get("event"); - console.log(this.task) - - this - - if(this.task) { + if(this.task && this.dataService.get("newGroup")) { this.link = this.dataService.get("link"); this.groupName = this.task.Folio; this.documents = this.dataService.get("documents"); this.dataService.set("newGroup", false); this.dataService.set("link", false); - } else if (this.event) { + } else if (this.event && this.dataService.get("newGroup")) { // this.link = this.dataService.get("link"); this.groupName = this.event.Subject; @@ -83,12 +77,14 @@ export class NewGroupPage implements OnInit{ this.dataService.set("newGroup", false); this.dataService.set("link", false); + } else { + this.dataService.clear(); } } _ionChange(event) { - + this.showDuration = event.detail.checked; if(event.detail.checked) { @@ -112,12 +108,12 @@ export class NewGroupPage implements OnInit{ this.viewContainerRef.clear(); this.closeAllDesktopComponents.emit(); } - + } } async createGroup() { - + let name = this.groupName.split(' ').join('-'); //Take out all special characters in string name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); @@ -132,12 +128,12 @@ export class NewGroupPage implements OnInit{ let customFields = { "countDownDate":this.thedate } - res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields); + res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields); } else { res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields); } - + loader.remove(); @@ -146,23 +142,23 @@ export class NewGroupPage implements OnInit{ if(res?.result?.rid) { this.addGroupMessage.emit(res.result.rid); - + this.ChatSystemService.getAllRooms(() => { if(!this.ChatSystemService.getGroupRoom(res.result.rid)) { this.createGroupWithAttachmentsCath(res) } else { setTimeout(()=> { - + this.createGroupWithAttachments(res) - + }, 500) } }, res.result.rid); - + } else { - + this.toastService._badRequest('Existe um grupo com este nome!'); } @@ -224,7 +220,7 @@ export class NewGroupPage implements OnInit{ this.close(); let name = this.groupName.split(' ').join('-'); - + const modal = await this.modalController.create({ component: GroupContactsPage, @@ -263,7 +259,7 @@ export class NewGroupPage implements OnInit{ text: 'Ok', cssClass: 'btn-cancel', handler:(value:any)=>{ - + let now = new Date(); this.thedate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + value.days.value, now.getHours() + value.hours.value, now.getMinutes() + value.minutes.value, now.getSeconds(), now.getMilliseconds()); @@ -272,7 +268,7 @@ export class NewGroupPage implements OnInit{ value.hours.value, value.minutes.value, ] - + if(value.days.value != null && value.hours.value != null && value.minutes.value != null){ if(value.days.value > 0){ if(value.days.value == 1){ diff --git a/src/app/shared/header/header.page.html b/src/app/shared/header/header.page.html index 1ab20e815..ce3de1a91 100644 --- a/src/app/shared/header/header.page.html +++ b/src/app/shared/header/header.page.html @@ -62,7 +62,7 @@
- +
@@ -226,7 +226,7 @@
- +
@@ -242,4 +242,4 @@
-
\ No newline at end of file +
diff --git a/src/app/shared/popover/opts-expediente/opts-expediente.page.ts b/src/app/shared/popover/opts-expediente/opts-expediente.page.ts index af5f8e6df..cbcad8e04 100644 --- a/src/app/shared/popover/opts-expediente/opts-expediente.page.ts +++ b/src/app/shared/popover/opts-expediente/opts-expediente.page.ts @@ -41,7 +41,7 @@ export class OptsExpedientePage implements OnInit { SessionStore = SessionStore; environment = environment - + constructor( private popoverController: PopoverController, private modalController: ModalController, @@ -58,7 +58,7 @@ export class OptsExpedientePage implements OnInit { public TaskService: TaskService, private dataService: DataService, ) { - + } ngOnInit() { @@ -66,12 +66,12 @@ export class OptsExpedientePage implements OnInit { } async openNewGroupPage() { - - this.dataService.set("newGroup", true); - this.dataService.set("task", this.task); - this.dataService.set("newGroupName", this.task.Folio); - this.dataService.set("documents", this.fulltask.Documents); - this.dataService.set("link", window.location.pathname); + + // this.dataService.set("newGroup", true); + // this.dataService.set("task", this.task); + // this.dataService.set("newGroupName", this.task.Folio); + // this.dataService.set("documents", this.fulltask.Documents); + // this.dataService.set("link", window.location.pathname); const modal = await this.modalController.create({ component: NewGroupPage, @@ -180,7 +180,7 @@ export class OptsExpedientePage implements OnInit { }); modal.onDidDismiss().then( async (res) => { - + if(res.data){ const DocumentToSave = res.data.documents.map((e) => { return { @@ -232,7 +232,7 @@ export class OptsExpedientePage implements OnInit { if(error.status == 0) { this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão') } else { - + this.toastService._badRequest() } } finally { @@ -249,7 +249,7 @@ export class OptsExpedientePage implements OnInit { if(error.status == 0) { this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão') } else { - + this.toastService._badRequest('Processo não encontrado') } }); @@ -266,7 +266,7 @@ export class OptsExpedientePage implements OnInit { "AttachmentList" :documents, } - + const loader = this.toastService.loading() @@ -313,7 +313,7 @@ export class OptsExpedientePage implements OnInit { async openExpedientActionsModal(taskAction: any, task: any) { - + this.close(); let classs; @@ -330,9 +330,9 @@ export class OptsExpedientePage implements OnInit { }, cssClass: classs, }); - + modal.onDidDismiss().then(async res=>{ - + let body = res['data']; if(res['data']){ const loader = this.toastService.loading() @@ -344,7 +344,7 @@ export class OptsExpedientePage implements OnInit { if(error.status == 0) { this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão') } else { - + this.toastService._badRequest('Processo não descartado') } } finally { @@ -352,7 +352,7 @@ export class OptsExpedientePage implements OnInit { } } else{ - + } }, (error) => { console.log(error) @@ -373,7 +373,7 @@ export class OptsExpedientePage implements OnInit { modal.onDidDismiss().then( async (res) => { - + if(body == 'descartar') { if(res['data']== 'Yes') { @@ -389,7 +389,7 @@ export class OptsExpedientePage implements OnInit { if(error.status == 0) { this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão') } else { - + this.toastService._badRequest('Processo não descartado') } } finally { @@ -415,7 +415,7 @@ export class OptsExpedientePage implements OnInit { if(error.status == 0) { this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão') } else { - + this.toastService._badRequest('Processo não descartado') } } finally { @@ -424,7 +424,7 @@ export class OptsExpedientePage implements OnInit { this.goBack(); } else if(res['data'] == 'No'){ - + const loader = this.toastService.loading() try { @@ -432,7 +432,7 @@ export class OptsExpedientePage implements OnInit { this.TaskService.loadExpedientes() this.toastService._successMessage(); this.goBack(); - } catch (error) { + } catch (error) { if(error.status == 0) { this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão') } else { diff --git a/src/app/shared/publication/new-action/new-action.page.html b/src/app/shared/publication/new-action/new-action.page.html index 28c97c75a..9b74f47a7 100644 --- a/src/app/shared/publication/new-action/new-action.page.html +++ b/src/app/shared/publication/new-action/new-action.page.html @@ -53,7 +53,8 @@ [showSeconds]="showSeconds" [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" - [touchUi]="touchUi"> + [hideTime]="true" + > @@ -89,7 +90,9 @@ [showSpinners]="showSpinners" [showSeconds]="showSeconds" [stepHour]="stepHour" [stepMinute]="stepMinute" - [stepSecond]="stepSecond"> + [stepSecond]="stepSecond" + [hideTime]="true" + >
diff --git a/src/app/shared/publication/new-action/new-action.page.ts b/src/app/shared/publication/new-action/new-action.page.ts index be3c1bc25..68eedee4e 100644 --- a/src/app/shared/publication/new-action/new-action.page.ts +++ b/src/app/shared/publication/new-action/new-action.page.ts @@ -5,12 +5,29 @@ import { PublicationFolder } from 'src/app/models/publicationfolder'; import { PublicationsService } from 'src/app/services/publications.service'; import { ToastService } from 'src/app/services/toast.service'; import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'; +import { NgxMatDateFormats } from '@angular-material-components/datetime-picker'; +import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker'; + +const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { + parse: { + dateInput: "YYYY-MMMM-DD HH:mm" + }, + display: { + dateInput: "DD MMM YYYY", + monthYearLabel: "MMM YYYY", + dateA11yLabel: "LL", + monthYearA11yLabel: "MMMM YYYY" + } +} @Component({ selector: 'app-new-action', templateUrl: './new-action.page.html', styleUrls: ['./new-action.page.scss'], + providers: [ + { provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMATS }, + ] }) export class NewActionPage implements OnInit { @@ -42,7 +59,7 @@ export class NewActionPage implements OnInit { ) { this.folder = new PublicationFolder(); - + this.setStartDate() this.setEndDate() } @@ -53,7 +70,7 @@ export class NewActionPage implements OnInit { } segmentChanged(ev: any) { - + } get dateValid() { @@ -103,10 +120,10 @@ export class NewActionPage implements OnInit { if(this.Form.invalid) { return false } else { - + } - + this.folder = { ProcessId: null, @@ -116,7 +133,7 @@ export class NewActionPage implements OnInit { DateEnd: this.folder.DateEnd, ActionType: this.segment, } - + const loader = this.toastService.loading() @@ -145,7 +162,7 @@ export class NewActionPage implements OnInit { date.setSeconds(0); if(minutes % 15 != 0) { - + if (minutes > 45) { date.setMinutes(60) } else if (minutes > 30) { @@ -156,18 +173,18 @@ export class NewActionPage implements OnInit { date.setMinutes(15) } - } + } return date } - + roundTimeQuarterHour() { let date = new Date(); const minutes = date.getMinutes(); date.setSeconds(0); if(minutes % 15 != 0) { - + if (minutes > 45) { date.setMinutes(60) } else if (minutes > 30) { @@ -178,7 +195,7 @@ export class NewActionPage implements OnInit { date.setMinutes(15) } - } + } return date } @@ -187,9 +204,9 @@ export class NewActionPage implements OnInit { const _date = new Date(date); const minutes = _date .getMinutes(); _date .setMinutes(minutes + 15) - return _date + return _date } - + setStartDate() { this.folder.DateBegin = this.roundTimeQuarterHour() diff --git a/src/assets/images/icons-nav-agenda-active.svg b/src/assets/images/icons-nav-agenda-active.svg new file mode 100644 index 000000000..c1a5e00b6 --- /dev/null +++ b/src/assets/images/icons-nav-agenda-active.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/global.scss b/src/global.scss index 0366517a9..9c38654b7 100644 --- a/src/global.scss +++ b/src/global.scss @@ -1475,12 +1475,19 @@ $font-size: rem(15); ngx-mat-datetime-content .actions { z-index: 1; position: relative; - top: -66px; + + button { + z-index: 11111111; + } +} + +ngx-mat-datetime-content .time-container { margin-bottom: -44px; button { z-index: 11111111; } + } @@ -1659,3 +1666,10 @@ h5, .buttons{ .welcome-text { margin-bottom: 15px; } + + +.image-prety { + border-color: transparent !important; + -o-object-fit: cover; + object-fit: cover; +}