From b38c7717cc1aff8c5a43ae930b61ab0a0cf60404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Sat, 29 Jan 2022 17:42:43 +0100 Subject: [PATCH 1/7] =?UTF-8?q?pull=20made=20and=20local=20notifica=C3=A7?= =?UTF-8?q?=C3=B5es=20get?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 5 +++++ package.json | 1 + 2 files changed, 6 insertions(+) diff --git a/package-lock.json b/package-lock.json index 153db057c..788e7ad97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2213,6 +2213,11 @@ "resolved": "https://registry.npmjs.org/@capacitor/keyboard/-/keyboard-1.1.3.tgz", "integrity": "sha512-WpD1f/3HH6IpADiRaFTDGdhrqYhZDikybXXhUdGAEEwHbErHt9zS5RQgbeROjGmkXcurVvQsalQ59YuKU0VzwA==" }, + "@capacitor/local-notifications": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@capacitor/local-notifications/-/local-notifications-1.1.0.tgz", + "integrity": "sha512-l6S9rBylxGPq/U+xpJzZcOL4l2s8I2Igq7uDTidR4imIxxX3bLRz9nDSQREWsbQkFx7ALFm/5Y8PJGz2C6qKPw==" + }, "@capacitor/network": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@capacitor/network/-/network-1.0.6.tgz", diff --git a/package.json b/package.json index 7f646e2e2..3a92ebd74 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "@capacitor/haptics": "^1.1.2", "@capacitor/ios": "3.3.0", "@capacitor/keyboard": "^1.1.2", + "@capacitor/local-notifications": "^1.1.0", "@capacitor/network": "^1.0.6", "@capacitor/push-notifications": "^1.0.7", "@capacitor/share": "^1.0.7", From 7a93a7d3403f5167c3e125d0c2cec1d0c1257b81 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Tue, 1 Feb 2022 23:14:36 +0100 Subject: [PATCH 2/7] =?UTF-8?q?Mudar=20meu=20Calend=C3=A1rio=20para=20"Cal?= =?UTF-8?q?end=C3=A1rio=20do=20MDGPR"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/agenda/agenda.page.html | 2 +- src/app/pages/agenda/new-event/new-event.page.html | 2 +- .../pages/gabinete-digital/event-list/event-list.page.html | 2 +- src/app/shared/agenda/event-list/event-list.page.html | 2 +- src/app/shared/agenda/new-event/new-event.page.html | 2 +- .../events-to-approve/events-to-approve.page.html | 2 +- .../event-list-event-list-module.js.download | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/pages/agenda/agenda.page.html b/src/app/pages/agenda/agenda.page.html index 8cfcd1062..bd507f0a3 100644 --- a/src/app/pages/agenda/agenda.page.html +++ b/src/app/pages/agenda/agenda.page.html @@ -228,7 +228,7 @@
-
Meu Calendário
+
Calendário do MDGPR
diff --git a/src/app/pages/agenda/new-event/new-event.page.html b/src/app/pages/agenda/new-event/new-event.page.html index efb0cdbe5..a6b2c38c0 100644 --- a/src/app/pages/agenda/new-event/new-event.page.html +++ b/src/app/pages/agenda/new-event/new-event.page.html @@ -32,7 +32,7 @@ Calendário do Presidente da República - Meu calendário + Calendário do MDGPR diff --git a/src/app/pages/gabinete-digital/event-list/event-list.page.html b/src/app/pages/gabinete-digital/event-list/event-list.page.html index 5d2d63013..2cad919fc 100644 --- a/src/app/pages/gabinete-digital/event-list/event-list.page.html +++ b/src/app/pages/gabinete-digital/event-list/event-list.page.html @@ -16,7 +16,7 @@ - Meu calendário + Calendário do MDGPR Presidente da República diff --git a/src/app/shared/agenda/event-list/event-list.page.html b/src/app/shared/agenda/event-list/event-list.page.html index 62932ed7d..fb67da1f3 100644 --- a/src/app/shared/agenda/event-list/event-list.page.html +++ b/src/app/shared/agenda/event-list/event-list.page.html @@ -11,7 +11,7 @@ - Meu calendário + Calendário do MDGPR Presidente da República diff --git a/src/app/shared/agenda/new-event/new-event.page.html b/src/app/shared/agenda/new-event/new-event.page.html index ba4135ca2..f5c683c3e 100644 --- a/src/app/shared/agenda/new-event/new-event.page.html +++ b/src/app/shared/agenda/new-event/new-event.page.html @@ -43,7 +43,7 @@ Calendário do Presidente da República - Meu calendário + Calendário do MDGPR diff --git a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html index eff4cab69..93d814d14 100644 --- a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html +++ b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html @@ -10,7 +10,7 @@ - Meu calendário + Calendário do MDGPR Presidente da República diff --git a/src/assets/images/Gabinete Digital_files/event-list-event-list-module.js.download b/src/assets/images/Gabinete Digital_files/event-list-event-list-module.js.download index 1af0ffb69..3c8624c49 100644 --- a/src/assets/images/Gabinete Digital_files/event-list-event-list-module.js.download +++ b/src/assets/images/Gabinete Digital_files/event-list-event-list-module.js.download @@ -9,7 +9,7 @@ "use strict"; __webpack_require__.r(__webpack_exports__); -/* harmony default export */ __webpack_exports__["default"] = ("\n \n \n \n \n Eventos para Aprovação\n \n \n \n \n Meu calendário\n \n \n Presidente da República\n \n \n \n\n\n\n
\n \n
\n \n \n \n
\n
\n

08:30

\n

12:30

\n
\n
\n

Luanda | Palácio Presidencial

\n

Reunião de Conselho de Ministros

\n
\n
\n
\n
\n
\n
\n\n
\n \n \n \n
\n
\n

08:30

\n

12:30

\n
\n
\n

Luanda | Palácio Presidencial

\n

Reunião de Conselho de Ministros

\n
\n
\n
\n
\n
\n
\n\n
\n"); +/* harmony default export */ __webpack_exports__["default"] = ("\n \n \n \n \n Eventos para Aprovação\n \n \n \n \n Calendário do MDGPR\n \n \n Presidente da República\n \n \n \n\n\n\n
\n \n
\n \n \n \n
\n
\n

08:30

\n

12:30

\n
\n
\n

Luanda | Palácio Presidencial

\n

Reunião de Conselho de Ministros

\n
\n
\n
\n
\n
\n
\n\n
\n \n \n \n
\n
\n

08:30

\n

12:30

\n
\n
\n

Luanda | Palácio Presidencial

\n

Reunião de Conselho de Ministros

\n
\n
\n
\n
\n
\n
\n\n
\n"); /***/ }), @@ -225,4 +225,4 @@ EventListPage = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([ /***/ }) }]); -//# sourceMappingURL=event-list-event-list-module.js.map \ No newline at end of file +//# sourceMappingURL=event-list-event-list-module.js.map From 964a4201c9acbb1858925146f61e5546ec199c2f Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Tue, 1 Feb 2022 23:24:02 +0100 Subject: [PATCH 3/7] remove duplicate header in publication detail page modal --- .../publication-detail/publication-detail.page.html | 1 - .../publication-detail/publication-detail.page.scss | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html index ed7fccafb..dd6e0bbb6 100644 --- a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html +++ b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html @@ -1,5 +1,4 @@ - diff --git a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.scss b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.scss index 2f9854000..1802e0968 100644 --- a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.scss +++ b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.scss @@ -1,9 +1,8 @@ :host{ - + } ion-content{ --background: transparent; - transform: translate3d(0, 5px, 0); --border-radius: 30px; } ion-footer{ @@ -89,4 +88,4 @@ .post-description{ margin: 0 auto; margin-bottom: 35px; -} \ No newline at end of file +} From aad07d834992f6185130b99a749806870b4a9b37 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Wed, 2 Feb 2022 10:01:37 +0100 Subject: [PATCH 4/7] fix undefined date at response from websocket api --- src/app/services/chat/room.service.ts | 19 ++++++++++--------- .../shared/chat/messages/messages.page.html | 2 +- .../popover/chat-popover/chat-popover.page.ts | 4 +++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index fb89ea961..42f80a4a2 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -84,20 +84,21 @@ export class RoomService { ChatMessage = this.fix_updatedAt(ChatMessage) console.log('recivemessage', ChatMessage) - const message = this.prepareMessage(ChatMessage) + if(message._updatedAt == undefined){ + message._updatedAt = new Date().getTime(); + } + this.lastMessage = message if (message.t == 'r') { this.name = message.msg } - this.calDateDuration(ChatMessage._updatedAt) + this.calDateDuration(message._updatedAt) this.messages.push(message) setTimeout(() => { this.scrollDown() }, 100) - //this.sortService.sortDate(this.messages, '') - if(SessionStore.user.RochetChatUser != ChatMessage.u.username) { this.NativeNotificationService.sendNotificationChat({ message: message.msg, @@ -182,7 +183,7 @@ export class RoomService { if(message._id == id) { messages.splice(index, 1) } - + }) this.storage.set('chatmsg' + this.id, messages).then((value) => { @@ -250,12 +251,12 @@ export class RoomService { open() { // this.typing(this.message) } - + leave(rid?) { this.WsChatService.leaveRoom(this.id) } - + isJson(str) { try { JSON.parse(str); @@ -341,10 +342,10 @@ export class RoomService { private fix_updatedAt(message) { if (message.result) { - console.log('FIX UPDATE ', message.result) + //console.log('FIX UPDATE ', message.result) message.result._updatedAt = message.result._updatedAt['$date'] } else { - // console.log('FIX UPDATE 11', message) + //console.log('FIX UPDATE 11', message) message._updatedAt = message._updatedAt['$date'] } return message diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 10a3032be..37c723586 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -68,7 +68,7 @@
{{msg.u.name}} - {{showDateDuration(msg._updatedAt)}} + {{showDateDuration(msg.duration)}}
diff --git a/src/app/shared/popover/chat-popover/chat-popover.page.ts b/src/app/shared/popover/chat-popover/chat-popover.page.ts index d15e5abdb..374f807ab 100644 --- a/src/app/shared/popover/chat-popover/chat-popover.page.ts +++ b/src/app/shared/popover/chat-popover/chat-popover.page.ts @@ -66,7 +66,9 @@ export class ChatPopoverPage implements OnInit { }); await modal.present(); modal.onDidDismiss().then((res)=>{ - this.leaveGroup(); + if(res.data == 'success'){ + this.leaveGroup(); + } }); } From 97acff4a7b834e574d257f47ad33eb01a0a1abad Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Wed, 2 Feb 2022 10:10:57 +0100 Subject: [PATCH 5/7] save --- src/app/services/functions/file.service.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/app/services/functions/file.service.ts b/src/app/services/functions/file.service.ts index 2f3313ab2..f864b398f 100644 --- a/src/app/services/functions/file.service.ts +++ b/src/app/services/functions/file.service.ts @@ -299,10 +299,10 @@ export class FileService { loader.remove(); this.toastService.badRequest("Não foi possível adicionar a fotografia!"); }); - + }); } - + }); } @@ -386,12 +386,6 @@ export class FileService { accept: ['image/apng', 'image/jpeg', 'image/png'] }) - - setInterval(() => { - console.log(input.value) - }, 550) - - input.onchange = async () => { //alert('Onchange AQUI') From 49146e61daa2428522201f1952f99b328dece898 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Wed, 2 Feb 2022 10:28:36 +0100 Subject: [PATCH 6/7] save --- .../services/chat/ws-chat-methods.service.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts index 4208e6ca7..f0d7af0d4 100644 --- a/src/app/services/chat/ws-chat-methods.service.ts +++ b/src/app/services/chat/ws-chat-methods.service.ts @@ -156,11 +156,11 @@ export class WsChatMethodsService { /** * @description when a new room is create, needs to subtribe in order to receive updates - * @param id - * @param roomData + * @param id + * @param roomData */ subscribeToRoomUpdate(id, roomData) { - + this.defaultSubtribe(id) this.prepareRoom(roomData); @@ -185,10 +185,10 @@ export class WsChatMethodsService { }) } - + /** - * @description create a representation of an room in these instance this.dm, this.group ... - * @param roomData + * @description create a representation of an room in these instance this.dm, this.group ... + * @param roomData */ prepareRoom(roomData) { let room:RoomService; @@ -236,12 +236,12 @@ export class WsChatMethodsService { * @param id user ID */ private getUserStatus(id?:string) { - + this.WsChatService.getUserStatus((d) => { const username = d.fields.args[0][1] const statusNum = d.fields.args[0][2] - + const statusText = this.statusNumberToText(statusNum) const user = this.getUserByName(username) @@ -260,8 +260,8 @@ export class WsChatMethodsService { /** * @description convert rocketchat statues num to readable string - * @param text - * @returns + * @param text + * @returns */ statusNumberToText(text) { if(text == '0') { @@ -277,7 +277,7 @@ export class WsChatMethodsService { return "busy" } } - + deleteMessage(id?) { return this.WsChatService.deleteMessage(id); From 7237d906530c130217629fce641fd7d9210b8f21 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Wed, 2 Feb 2022 11:57:11 +0100 Subject: [PATCH 7/7] - add method get user from room in ws api - Modified logout method --- src/app/modals/profile/profile.page.ts | 6 ++- src/app/services/auth.service.ts | 35 +++++++++++++---- .../services/chat/ws-chat-methods.service.ts | 4 ++ src/app/services/chat/ws-chat.service.ts | 39 ++++++++++++++++--- 4 files changed, 69 insertions(+), 15 deletions(-) diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts index 926fe61f9..aee2e76e3 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -214,11 +214,13 @@ export class ProfilePage implements OnInit { } logout() { - SessionStore.setInativity(false) + this.authService.logout() + + /* SessionStore.setInativity(false) SessionStore.setUrlBeforeInactivity(this.router.url) setTimeout(() => { this.router.navigateByUrl('/', { replaceUrl: true }); - }, 100) + }, 100) */ } diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index a508f72d2..f26ca9f5e 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -11,6 +11,7 @@ import { SessionStore } from '../store/session.service'; import { AESEncrypt } from '../services/aesencrypt.service'; import { CookieService } from 'ngx-cookie-service'; import { WsChatService } from 'src/app/services/chat/ws-chat.service'; +import { Router } from '@angular/router'; @Injectable({ providedIn: 'root' }) @@ -31,7 +32,8 @@ export class AuthService { public alertController: AlertController, private aesencrypt: AESEncrypt, private cookieService: CookieService, - private WsChatService: WsChatService) { + private WsChatService: WsChatService, + private router: Router,) { this.headers = new HttpHeaders(); @@ -101,12 +103,9 @@ export class AuthService { } } - logout() { - this.ValidatedUser = null; - } - //Login to rocketChat server async loginChat(user: UserForm) { + const expireDate = new Date(new Date().getTime() + 60*1000); let postData = { "user": user.username, "password": user.password, @@ -128,13 +127,14 @@ export class AuthService { }, 1) console.log('Login to Rocket chat OK'); - this.ValidatedUserChat = responseChat; - localStorage.setItem('userChat', JSON.stringify(responseChat)); this.storageService.store(AuthConnstants.AUTH, responseChat); - + + this.autologout(10000); + return true; + } else{ console.log('Network error'); @@ -143,6 +143,25 @@ export class AuthService { } } + autologout(expirationDate:number){ + setTimeout(()=>{ + this.logout(); + }, expirationDate) + } + + logout() { + + this.ValidatedUser = null; + localStorage.removeItem('userChat'); + + SessionStore.setInativity(false) + SessionStore.setUrlBeforeInactivity(this.router.url) + setTimeout(() => { + this.router.navigateByUrl('/', { replaceUrl: true }); + }, 100) + + } + //Get user data from RocketChat | global object getUserData(){ this.storageService.get(AuthConnstants.AUTH).then(res=>{ diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts index f0d7af0d4..7e458ed1f 100644 --- a/src/app/services/chat/ws-chat-methods.service.ts +++ b/src/app/services/chat/ws-chat-methods.service.ts @@ -361,5 +361,9 @@ export class WsChatMethodsService { this.users = user } + getUserOfRoom(roomId){ + return this.WsChatService.getUserOfRoom(roomId); + } + } diff --git a/src/app/services/chat/ws-chat.service.ts b/src/app/services/chat/ws-chat.service.ts index 3abc1ae4e..61cf2096f 100644 --- a/src/app/services/chat/ws-chat.service.ts +++ b/src/app/services/chat/ws-chat.service.ts @@ -119,6 +119,35 @@ export class WsChatService { }); } + getUserOfRoom(roomId) { + + const requestId = uuidv4() + + const message = { + "msg": "method", + "method": "getUsersOfRoom", + "id": requestId, + "params": [ + roomId, + false, + { + "limit": 100, + "skip": 0 + } ] + } + + this.ws.send({message, requestId}) + + return new Promise((resolve, reject) => { + this.ws.registerCallback({type:'Onmessage', funx:(message)=>{ + if(message.id == requestId) { // same request send + resolve(message) + return true + } + }}) + }); + } + logout() { this.isLogin = false this.ws.connected = false @@ -360,7 +389,7 @@ export class WsChatService { } }) } - + loadHistory(roomId, limit: number = 50) { @@ -593,7 +622,7 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) { }, onopen:()=> { this.ws.connected = true - + console.log('================== welcome to socket server =====================') this.ws.wsMsgQueue() @@ -602,13 +631,13 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) { for (const [key, value] of Object.entries(this.wsCallbacks)) { if(value.type== 'reConnect') { const dontRepeat = value.funx() - + if(dontRepeat) { delete this.wsCallbacks[key] } - + } - + } }