diff --git a/src/app/guards/auth.guard.ts b/src/app/guards/auth.guard.ts index 17b0dd5af..e46b20548 100644 --- a/src/app/guards/auth.guard.ts +++ b/src/app/guards/auth.guard.ts @@ -21,25 +21,24 @@ export class AuthGuard implements CanActivate { canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + console.log('hire!', state.url) // if user not active if(!SessionStore.user.Inactivity) { + console.log(' goto login /') this.router.navigate(['/']); return false } // if session doesn't exit else if(!SessionStore.exist) { + console.log(' goto /') this.router.navigate(['/']); return false } else { - if(this.p.userPermission(this.p.permissionList.Chat.access) == true) { - // this.authService.loginChat(); - } const pathname = state.url if(pathname.startsWith('/home/agenda')) { - if(this.p.userPermission(this.p.permissionList.Agenda.access)) { return true; } else { @@ -48,7 +47,7 @@ export class AuthGuard implements CanActivate { } } else if ( pathname.startsWith('/home/gabinete-digital')) { - console.log('gabinete'); + if(this.p.userPermission(this.p.permissionList.Gabinete.access)) { return true; @@ -73,6 +72,7 @@ export class AuthGuard implements CanActivate { } } else if (pathname.startsWith('/home/events')) { if(SessionStore.user.OwnerCalendars.length >= 1 || this.p.userPermission([this.p.permissionList.Gabinete.access])) { + console.log('go /home/events') return true } else { this.router.navigate(['/login']); @@ -87,6 +87,9 @@ export class AuthGuard implements CanActivate { } } + + + return true } } diff --git a/src/app/guards/inactivity.guard.ts b/src/app/guards/inactivity.guard.ts index e4cd3f7a8..224c5e7ba 100644 --- a/src/app/guards/inactivity.guard.ts +++ b/src/app/guards/inactivity.guard.ts @@ -21,6 +21,7 @@ export class InactivityGuard implements CanActivate { route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + console.log('hire inactinity!', state.url) if (this.platform.is('desktop') || this.platform.is('mobileweb')) { if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ diff --git a/src/app/guards/login.guard.ts b/src/app/guards/login.guard.ts index d0a3836a4..fca22ebf0 100644 --- a/src/app/guards/login.guard.ts +++ b/src/app/guards/login.guard.ts @@ -19,7 +19,10 @@ export class LoginGuard implements CanActivate { route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + console.log('hire login!', state.url) + if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) { + console.log(' goto /home/events') this.router.navigate(['/home/events']); return false } else if(SessionStore.exist && !SessionStore.user.Inactivity && SessionStore.user.LoginPreference == 'Pin' && SessionStore.forceToLoginWithForceToLogInWithPassword && !this.platform.is('desktop') && !this.platform.is('mobileweb')) { diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index 50f5413bf..5fe102ea9 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -125,7 +125,8 @@ export class HomePage implements OnInit { } goto(url) { - this.router.navigate([url]) + // this.router.navigateByUrl('/home/events', { replaceUrl: true }); + this.router.navigate([url], { replaceUrl: true }) } refreshing() { } @@ -134,8 +135,8 @@ export class HomePage implements OnInit { this.logDeviceInfo(); - this.notificationsService.onReciveForeground(); - this.notificationsService.onReciveBackground(); + // this.notificationsService.onReciveForeground(); + // this.notificationsService.onReciveBackground(); window.addEventListener('online', () => { // console.log('Became online') diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts index 939a7b98e..0de056f9f 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -178,7 +178,7 @@ export class ProfilePage implements OnInit { this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', IdObject, 'gabinete-digital'])); } - this.notificationservice.tempClearArray(); + // this.notificationservice.tempClearArray(); this.deleteNotification(index); this.eventtrigger.publishSomeData({ notification: "deleted" diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index 4e2c33a10..9814a6372 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -797,8 +797,8 @@ export class AgendaPage implements OnInit { 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(this.CalendarStore.eventSource) - console.log('this.TimelineMDList', this.TimelineMDList) + // console.log(this.CalendarStore.eventSource) + // console.log('this.TimelineMDList', this.TimelineMDList) this.myCal.update(); @@ -847,7 +847,7 @@ export class AgendaPage implements OnInit { this.TimelinePRList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) - console.log('this.TimelinePRList', this.TimelinePRList) + // console.log('this.TimelinePRList', this.TimelinePRList) // this.myCal.update(); diff --git a/src/app/pages/events/events.page.html b/src/app/pages/events/events.page.html index d8f7fe964..d6cd0119a 100644 --- a/src/app/pages/events/events.page.html +++ b/src/app/pages/events/events.page.html @@ -27,117 +27,4 @@ -
-
-
-
- -
A sua Agenda
-
- -
-
- - - -
- -
-
{{event.StartDate | date: 'HH:mm'}}
-
{{event.EndDate | date: 'HH:mm'}}
- -
Todo
-
o dia
-
-
-
-
{{event.Location}}
-
-

{{event.Subject}}

-
-
-
-
- -
- -
-
- -
-
-
- -
CorrespondĂȘncia por ler
-
- -
-
- - -
-
-
{{task.taskStartDate | date: 'dd-MM-yyyy'}}
-
{{task.taskStartDate | date: 'HH:mm'}}
-
-
-
{{ task.Subject }}
-
{{ task.Senders }}
-
-
-
- -
-
-
-
- - diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts index 78c8864e2..d2fa65e96 100644 --- a/src/app/pages/events/events.page.ts +++ b/src/app/pages/events/events.page.ts @@ -79,54 +79,54 @@ export class EventsPage implements OnInit { private changeProfileService: ChangeProfileService, ) { - this.loggeduser = SessionStore.user; + // this.loggeduser = SessionStore.user; - this.platform.resize.subscribe(async () => { - // - // + // this.platform.resize.subscribe(async () => { + // // + // // - }); + // }); - window['zipPhoneCallback'] = function (zipphone) { - var frame = document.getElementById('home-iframe'); - if(frame) { - frame['contentWindow']['postMessage']({call:'cookies', value: { cookies: {} }}); - } - } + // window['zipPhoneCallback'] = function (zipphone) { + // var frame = document.getElementById('home-iframe'); + // if(frame) { + // frame['contentWindow']['postMessage']({call:'cookies', value: { cookies: {} }}); + // } + // } - this.changeProfileService.registerCallback(() => { + // this.changeProfileService.registerCallback(() => { - this.listToPresent = []; - this.listToPresentexpediente = [] - }) + // this.listToPresent = []; + // this.listToPresentexpediente = [] + // }) } ngOnInit() { - this.segment = "Combinada"; - this.profile = "mdgpr"; + // this.segment = "Combinada"; + // this.profile = "mdgpr"; - this.showGreeting(); + // this.showGreeting(); - this.router.events.forEach((event) => { - if (event instanceof NavigationEnd && event.url == '/home/events') { - this.RefreshEvents(); - setTimeout(() => { - this.LoadList(); - }, 1500) - } - }); - this.hideSearch(); + // this.router.events.forEach((event) => { + // if (event instanceof NavigationEnd && event.url == '/home/events') { + // this.RefreshEvents(); + // setTimeout(() => { + // this.LoadList(); + // }, 1500) + // } + // }); + // this.hideSearch(); - this.backgroundservice.registerBackService('Online', () => { - this.showGreeting(); - this.RefreshEvents(); - this.LoadList(); - this.hideSearch(); - }); + // this.backgroundservice.registerBackService('Online', () => { + // this.showGreeting(); + // this.RefreshEvents(); + // this.LoadList(); + // this.hideSearch(); + // }); } diff --git a/src/app/pages/inactivity/inactivity.page.ts b/src/app/pages/inactivity/inactivity.page.ts index c5cad1d7c..954cc101e 100644 --- a/src/app/pages/inactivity/inactivity.page.ts +++ b/src/app/pages/inactivity/inactivity.page.ts @@ -38,7 +38,7 @@ export class InactivityPage implements OnInit { loop = false ngOnInit() { - + alert('pin') } runloop() { @@ -101,6 +101,8 @@ export class InactivityPage implements OnInit { } else { SessionStore.delete() window.localStorage.clear(); + + SessionStore.setInativity(true) await this.authService.SetSession(attempt, this.userattempt); } @@ -117,9 +119,9 @@ export class InactivityPage implements OnInit { } getToken() { - this.notificatinsservice.requestPermissions(); - this.notificatinsservice.registrationError(); - this.notificatinsservice.getAndpostToken(this.username); + // this.notificatinsservice.requestPermissions(); + // this.notificatinsservice.registrationError(); + // this.notificatinsservice.getAndpostToken(this.username); } setCode(code: string) { diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index 8fd964e5f..7c8f64857 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -15,6 +15,8 @@ import { MessageModel, DeleteMessageModel } from '../../models/beast-orm'; import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'; import { ChatSystemService } from 'src/app/services/chat/chat-system.service'; import { ChatService } from 'src/app/services/chat.service'; +import { Platform } from '@ionic/angular'; + @Component({ @@ -49,7 +51,8 @@ export class LoginPage implements OnInit { public p: PermissionService, private RochetChatConnectorService: RochetChatConnectorService, public ChatSystemService: ChatSystemService, - private ChatService: ChatService + private ChatService: ChatService, + private platform: Platform, ) {} ngOnInit() { @@ -93,9 +96,9 @@ export class LoginPage implements OnInit { } getToken() { - this.notificatinsservice.requestPermissions(); - this.notificatinsservice.registrationError(); - this.notificatinsservice.getAndpostToken(this.username); + // this.notificatinsservice.requestPermissions(); + // this.notificatinsservice.registrationError(); + // this.notificatinsservice.getAndpostToken(this.username); } async Login() { @@ -157,7 +160,13 @@ export class LoginPage implements OnInit { this.getToken(); - this.router.navigateByUrl('/home/events', { replaceUrl: true }); + if(!this.platform.is('desktop') && !this.platform.is('mobileweb')) { + this.router.navigateByUrl('/pin', { replaceUrl: true }); + } else { + this.router.navigateByUrl('/home/events'); + } + + } } else{ diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 8b8ede159..4b5cf4e4d 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -50,10 +50,13 @@ export class AuthService { this.headers = new HttpHeaders(); if (SessionStore.exist) { + + SessionStore.setInativity(true) if(this.p.userPermission(this.p.permissionList.Chat.access) == true ) { this.loginToChatWs() } + } diff --git a/src/app/services/functions/time.service.ts b/src/app/services/functions/time.service.ts index 747ab7343..ce2ae0fb0 100644 --- a/src/app/services/functions/time.service.ts +++ b/src/app/services/functions/time.service.ts @@ -17,7 +17,7 @@ export class TimeService { end = new Date(); start = new Date(start); - const totalSeconds = Math.floor((end - (start))/1000);; + const totalSeconds = Math.floor((end - (start))/1000); const totalMinutes = Math.floor(totalSeconds/60); const totalHours = Math.floor(totalMinutes/60); const totalDays = Math.floor(totalHours/24); @@ -75,37 +75,37 @@ export class TimeService { } countDownDateTimer(date:any, roomId:string){ - let timer = setInterval(() =>{ - let difference = new Date(date).getTime() - new Date().getTime(); - let c_day = Math.floor(difference/(1000*60*60*24)); - let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60)); - let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60)); - let c_seconds = Math.floor((difference % (1000*60)) / 1000); + // let timer = setInterval(() =>{ + // let difference = new Date(date).getTime() - new Date().getTime(); + // let c_day = Math.floor(difference/(1000*60*60*24)); + // let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60)); + // let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60)); + // let c_seconds = Math.floor((difference % (1000*60)) / 1000); - this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ; + // this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ; - if(difference < 0) { - clearInterval(timer); - this.countDownTime = "Expired"; - let body = { "roomId":roomId, } - this.chatService.getRoomInfo(roomId).subscribe(room=>{ - this.room = room['room']; + // if(difference < 0) { + // clearInterval(timer); + // this.countDownTime = "Expired"; + // let body = { "roomId":roomId, } + // this.chatService.getRoomInfo(roomId).subscribe(room=>{ + // this.room = room['room']; - if(this.room.t === 'p'){ - this.chatService.deleteGroup(body).subscribe(res=>{ - this.ChatSystemService.deleteRoom(roomId) - }); - } - else{ + // if(this.room.t === 'p'){ + // this.chatService.deleteGroup(body).subscribe(res=>{ + // this.ChatSystemService.deleteRoom(roomId) + // }); + // } + // else{ - this.chatService.deleteChannel(body).subscribe(res=>{ - this.ChatSystemService.deleteRoom(roomId) - }); - } - }); - } - }) - return this.countDownTime; + // this.chatService.deleteChannel(body).subscribe(res=>{ + // this.ChatSystemService.deleteRoom(roomId) + // }); + // } + // }); + // } + // }) + // return this.countDownTime; } addZero(i) { diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index b23c936b7..db2fb701c 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -14,7 +14,7 @@ import { BackgroundService } from './background.service'; import { v4 as uuidv4 } from 'uuid'; import { EventTrigger } from '../services/eventTrigger.service'; import { SessionStore } from '../store/session.service'; -import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications'; +// import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications'; @Injectable({ providedIn: 'root' @@ -57,170 +57,170 @@ export class NotificationsService { } - registerCallback(type: string, funx: Function, object: any = {}) { + // registerCallback(type: string, funx: Function, object: any = {}) { - const id = uuidv4() - this.callbacks.push({ type, funx, id }) - if (!object.hasOwnProperty('desktop') && object['desktop'] != false) { - this.backgroundservice.registerBackService('Notification', funx, type) - } + // const id = uuidv4() + // this.callbacks.push({ type, funx, id }) + // if (!object.hasOwnProperty('desktop') && object['desktop'] != false) { + // this.backgroundservice.registerBackService('Notification', funx, type) + // } - return id; - } + // return id; + // } - deleteCallback(id) { - this.callbacks.forEach((e, index) => { - if (e.id == id) { - if (index > -1) { - this.callbacks.splice(index, 1); - } - } - }) + // deleteCallback(id) { + // this.callbacks.forEach((e, index) => { + // if (e.id == id) { + // if (index > -1) { + // this.callbacks.splice(index, 1); + // } + // } + // }) - } + // } - getTokenByUserIdAndId(user, userID) { - // const geturl = environment.apiURL + 'notifications/user/' + userID; + // getTokenByUserIdAndId(user, userID) { + // // const geturl = environment.apiURL + 'notifications/user/' + userID; - // return this.http.get(`${geturl}`); - } + // // return this.http.get(`${geturl}`); + // } - requestPermissions() { - PushNotifications.requestPermissions().then(result => { - if (result.receive === 'granted') { - // Register with Apple / Google to receive push via APNS/FCM - PushNotifications.register(); - } else { - // Show some error - } - }); - } + // requestPermissions() { + // PushNotifications.requestPermissions().then(result => { + // if (result.receive === 'granted') { + // // Register with Apple / Google to receive push via APNS/FCM + // PushNotifications.register(); + // } else { + // // Show some error + // } + // }); + // } - getAndpostToken(username) { - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + // getAndpostToken(username) { + // if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - } else { - const geturl = environment.apiURL + 'notifications/token'; - PushNotifications.addListener('registration', - (token: Token) => { + // } else { + // const geturl = environment.apiURL + 'notifications/token'; + // PushNotifications.addListener('registration', + // (token: Token) => { - this.storageService.store(username, token.value); - this.storageService.get(username).then(value => { + // this.storageService.store(username, token.value); + // this.storageService.get(username).then(value => { - this.storageService.get(AuthConnstants.USER).then(res => { + // this.storageService.get(AuthConnstants.USER).then(res => { - const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; - const body = { - UserId: res.UserId, - TokenId: token.value, - Status: 1, - Service: 1 - }; + // const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; + // const body = { + // UserId: res.UserId, + // TokenId: token.value, + // Status: 1, + // Service: 1 + // }; - this.http.post(`${geturl}`, body, { headers }).subscribe(data => { + // this.http.post(`${geturl}`, body, { headers }).subscribe(data => { - }, (error) => { + // }, (error) => { - }) - }); + // }) + // }); - }); - } - ); - } + // }); + // } + // ); + // } - } + // } - registrationError() { - PushNotifications.addListener('registrationError', - (error: any) => { + // registrationError() { + // PushNotifications.addListener('registrationError', + // (error: any) => { - } - ); - } + // } + // ); + // } - onReciveForeground() { - PushNotifications.addListener('pushNotificationReceived', - (notification: PushNotificationSchema) => { + // onReciveForeground() { + // PushNotifications.addListener('pushNotificationReceived', + // (notification: PushNotificationSchema) => { - this.DataArray.push(notification) + // this.DataArray.push(notification) - this.storageService.store("Notifications", this.DataArray) - this.eventtrigger.publishSomeData({ - notification: "recive" - }) - } - ); - } + // this.storageService.store("Notifications", this.DataArray) + // this.eventtrigger.publishSomeData({ + // notification: "recive" + // }) + // } + // ); + // } - onReciveBackground() { - PushNotifications.addListener('pushNotificationActionPerformed', - (notification: ActionPerformed) => { + // onReciveBackground() { + // PushNotifications.addListener('pushNotificationActionPerformed', + // (notification: ActionPerformed) => { - /* this.DataArray.push(notification.notification) + // /* this.DataArray.push(notification.notification) - this.storageService.store("Notifications", this.DataArray) - this.eventtrigger.publishSomeData({ - notification: "recive" - }) */ - this.notificatinsRoutes(notification) - } - ); - } + // this.storageService.store("Notifications", this.DataArray) + // this.eventtrigger.publishSomeData({ + // notification: "recive" + // }) */ + // this.notificatinsRoutes(notification) + // } + // ); + // } - tempClearArray() { - this.DataArray = new Array; - } + // tempClearArray() { + // this.DataArray = new Array; + // } - notificatinsRoutes = (notification) => { + // notificatinsRoutes = (notification) => { - if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) { + // 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 === "expediente") { - 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'])); + // 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 === "expediente") { + // 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") { + // } 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/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 === "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/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/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 === "expedientes-pr") { - this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.notification.data.IdObject, 'gabinete-digital'])); - } + // 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 === "expedientes-pr") { + // this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.notification.data.IdObject, 'gabinete-digital'])); + // } - } + // } } diff --git a/src/assets/MFPPushServiceWorker.js b/src/assets/MFPPushServiceWorker.js index a3e05af69..bb9b5ccde 100644 --- a/src/assets/MFPPushServiceWorker.js +++ b/src/assets/MFPPushServiceWorker.js @@ -2,116 +2,116 @@ /* eslint-disable no-undef */ /* eslint-disable no-restricted-globals */ -const regex = /{{\s*([^}]+)\s*}}/g; -var _pushVaribales = ""; +// const regex = /{{\s*([^}]+)\s*}}/g; +// var _pushVaribales = ""; -function interpolate(messageData) { - return function interpolate(o) { - return messageData.replace(regex, function (a, b) { - var r = o[b]; - return typeof r === 'string' || typeof r === 'number' ? r : a; - }); - } -} +// function interpolate(messageData) { +// return function interpolate(o) { +// return messageData.replace(regex, function (a, b) { +// var r = o[b]; +// return typeof r === 'string' || typeof r === 'number' ? r : a; +// }); +// } +// } -function createTemplateMessage(messageData) { - if (Object.keys(_pushVaribales).length > 0 ) { - var message = interpolate(messageData)(_pushVaribales); - return message; - } else { - return messageData; - } -} +// function createTemplateMessage(messageData) { +// if (Object.keys(_pushVaribales).length > 0 ) { +// var message = interpolate(messageData)(_pushVaribales); +// return message; +// } else { +// return messageData; +// } +// } -function displayNotification(event) { - var messageJson = event.data.text(); - messageJson = JSON.parse(messageJson); - var title = messageJson.title ? messageJson.title : "New message"; - var imageUrl = messageJson.iconUrl ? messageJson.iconUrl : "images/icon.png"; -// var tagJson = messageJson.payload; -// var tag = tagJson.tag ? tagJson.tag : ""; - var bodyAlert = messageJson.alert ? messageJson.alert : "Example message" - var payloadData = messageJson.payload ? messageJson.payload : "Example message" - let messageTemp; - if ((messageTemp = regex.exec(bodyAlert)) !== null) { - bodyAlert = createTemplateMessage(bodyAlert); - } - self.registration.showNotification(title, { - body: bodyAlert, - icon: imageUrl, - data: payloadData, -// tag: tag - }); - return Promise.resolve(); -} +// function displayNotification(event) { +// var messageJson = event.data.text(); +// messageJson = JSON.parse(messageJson); +// var title = messageJson.title ? messageJson.title : "New message"; +// var imageUrl = messageJson.iconUrl ? messageJson.iconUrl : "images/icon.png"; +// // var tagJson = messageJson.payload; +// // var tag = tagJson.tag ? tagJson.tag : ""; +// var bodyAlert = messageJson.alert ? messageJson.alert : "Example message" +// var payloadData = messageJson.payload ? messageJson.payload : "Example message" +// let messageTemp; +// if ((messageTemp = regex.exec(bodyAlert)) !== null) { +// bodyAlert = createTemplateMessage(bodyAlert); +// } +// self.registration.showNotification(title, { +// body: bodyAlert, +// icon: imageUrl, +// data: payloadData, +// // tag: tag +// }); +// return Promise.resolve(); +// } -function triggerSeenEvent(strMsg) { - send_message_to_all_clients("msgEventSeen:" + strMsg); -} +// function triggerSeenEvent(strMsg) { +// send_message_to_all_clients("msgEventSeen:" + strMsg); +// } -function triggerOpenEvent(strMsg) { - send_message_to_all_clients("msgEventOpen:" + strMsg); -} +// function triggerOpenEvent(strMsg) { +// send_message_to_all_clients("msgEventOpen:" + strMsg); +// } -function onPushNotificationReceived(event) { +// function onPushNotificationReceived(event) { - if (event.data) { +// if (event.data) { - } - event.waitUntil(displayNotification(event).then(() => triggerSeenEvent(event.data.text()))); -}; +// } +// event.waitUntil(displayNotification(event).then(() => triggerSeenEvent(event.data.text()))); +// }; -self.addEventListener('push', onPushNotificationReceived); +// self.addEventListener('push', onPushNotificationReceived); -function send_message_to_client(client, msg) { - return new Promise(function (resolve, reject) { - var msg_chan = new MessageChannel(); +// function send_message_to_client(client, msg) { +// return new Promise(function (resolve, reject) { +// var msg_chan = new MessageChannel(); - msg_chan.port1.onmessage = function (event) { - if (event.data.error) { - reject(event.data.error); - } else { - resolve(event.data); - } - }; +// msg_chan.port1.onmessage = function (event) { +// if (event.data.error) { +// reject(event.data.error); +// } else { +// resolve(event.data); +// } +// }; - client.postMessage(msg, [msg_chan.port2]); - }); -} +// client.postMessage(msg, [msg_chan.port2]); +// }); +// } -function send_message_to_all_clients(msg) { - clients.matchAll().then(clients => { - clients.forEach(client => { - send_message_to_client(client, msg); - }) - }); -} +// function send_message_to_all_clients(msg) { +// clients.matchAll().then(clients => { +// clients.forEach(client => { +// send_message_to_client(client, msg); +// }) +// }); +// } -self.addEventListener('install', function (event) { - self.skipWaiting(); +// self.addEventListener('install', function (event) { +// self.skipWaiting(); - //event.postMessage("SW Says 'Hello back!'"); -}); +// //event.postMessage("SW Says 'Hello back!'"); +// }); -self.addEventListener('message', function (event) { - replyPort = event.ports[0]; - _pushVaribales = event.data; -}); +// self.addEventListener('message', function (event) { +// replyPort = event.ports[0]; +// _pushVaribales = event.data; +// }); -self.addEventListener('activate', function (event) { +// self.addEventListener('activate', function (event) { - event.waitUntil(self.clients.claim()); -}); +// event.waitUntil(self.clients.claim()); +// }); -self.addEventListener('notificationclick', function (event) { +// self.addEventListener('notificationclick', function (event) { - let nidjson = event.notification.data; - event.notification.close(); - event.waitUntil(triggerOpenEvent(nidjson)); -}); +// let nidjson = event.notification.data; +// event.notification.close(); +// event.waitUntil(triggerOpenEvent(nidjson)); +// }); -self.addEventListener('pushsubscriptionchange', function () { +// self.addEventListener('pushsubscriptionchange', function () { - send_message_to_all_clients("updateRegistration:"); -}); \ No newline at end of file +// send_message_to_all_clients("updateRegistration:"); +// }); \ No newline at end of file diff --git a/src/index.html b/src/index.html index 63e7662dc..78ba7271c 100644 --- a/src/index.html +++ b/src/index.html @@ -9,12 +9,12 @@ - + - + @@ -65,7 +65,7 @@ - +