This commit is contained in:
Peter Maquiran
2022-12-19 17:04:21 +01:00
parent 7543f319b8
commit 2b85796a5f
15 changed files with 325 additions and 416 deletions
+8 -5
View File
@@ -21,25 +21,24 @@ export class AuthGuard implements CanActivate {
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | 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
}
}
+1
View File
@@ -21,6 +21,7 @@ export class InactivityGuard implements CanActivate {
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | 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)){
+3
View File
@@ -19,7 +19,10 @@ export class LoginGuard implements CanActivate {
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | 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')) {
+4 -3
View File
@@ -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')
+1 -1
View File
@@ -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"
+3 -3
View File
@@ -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();
-113
View File
@@ -27,117 +27,4 @@
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
<div class="conteiner-box px-20 height-100" ng-swipe-up="swipe($event)">
<div *ngIf="p.userPermission([p.permissionList.Agenda.access])" class="schedule height-100">
<div class="schedule-header">
<div class="title">
<ion-icon class="icon" slot="end" src="assets/images/icons-default-agenda.svg" ></ion-icon>
<div class="text">A sua Agenda</div>
</div>
<button title="Ir para a sua Agenda" class="btn-no-color" [routerLink]="['/home/agenda']">
<ion-icon
*ngIf="ThemeService.currentTheme == 'default' "
class="icon-next"
slot="end"
src="assets/images/icons-arrow-circle-arrow-right.svg"
></ion-icon>
<ion-icon
*ngIf="ThemeService.currentTheme == 'gov' "
class="icon-next"
slot="end"
src="assets/images/theme/gov/icons-arrow-circle-arrow-right.svg"
></ion-icon>
<ion-icon
*ngIf="ThemeService.currentTheme == 'doneIt' "
class="icon-next"
slot="end"
src="assets/images/theme/doneIt/icons-arrow-circle-arrow-right.svg"
></ion-icon>
</button>
</div>
<div class="content overflow-y-auto flex-grow-1 height-100">
<ion-list>
<ion-item class="item-hover cursor-pointer" lines="none" *ngFor="let event of listToPresent"
(click)="goToEvent(event)"
>
<div class="d-flex content-{{loggeduser.Profile}}-{{event.CalendarName}}">
<div class="schedule-time">
<div *ngIf="!event.IsAllDayEvent" class="time-start">{{event.StartDate | date: 'HH:mm'}}</div>
<div *ngIf="!event.IsAllDayEvent" class="time-end">{{event.EndDate | date: 'HH:mm'}}</div>
<div *ngIf="event.IsAllDayEvent" class="time-start"> Todo </div>
<div *ngIf="event.IsAllDayEvent" class="time-end text-center"> o dia </div>
<div></div>
</div>
<div class="schedule-details">
<div class="location">{{event.Location}}</div>
<div class="description">
<p>{{event.Subject}}</p>
</div>
</div>
</div>
</ion-item>
</ion-list>
</div>
</div>
<div *ngIf="p.userPermission([p.permissionList.Gabinete.access])" class="schedule height-100">
<div class="schedule-header">
<div class="title">
<ion-icon class="icon" slot="end" src="assets/images/icons-correspondencias.svg"></ion-icon>
<div class="text">Correspondência por ler</div>
</div>
<button title="Ir para o Gabinete Digital" (click)="viewExpedientListPage()" class="btn-no-color cursor-pointer">
<ion-icon
*ngIf="ThemeService.currentTheme == 'default' "
class="icon-next"
slot="end"
src="assets/images/icons-arrow-circle-arrow-right.svg"
></ion-icon>
<ion-icon
*ngIf="ThemeService.currentTheme == 'gov' "
class="icon-next"
slot="end"
src="assets/images/theme/gov/icons-arrow-circle-arrow-right.svg"
></ion-icon>
<ion-icon
*ngIf="ThemeService.currentTheme == 'doneIt' "
class="icon-next"
slot="end"
src="assets/images/theme/doneIt/icons-arrow-circle-arrow-right.svg"
></ion-icon>
</button>
</div>
<div class="content overflow-y-auto flex-grow-1 height-100">
<ion-list>
<ion-item class="item-hover cursor-pointer" lines="none" *ngFor = "let task of listToPresentexpediente"
(click)="goToExpediente(task.SerialNumber)">
<div class="item-exp d-flex">
<div class="schedule-date">
<div class="time-end">{{task.taskStartDate | date: 'dd-MM-yyyy'}}</div>
<div class="time-start">{{task.taskStartDate | date: 'HH:mm'}}</div>
</div>
<div class="schedule-details pointer">
<div class="description">{{ task.Subject }}</div>
<div class="location">{{ task.Senders }}</div>
</div>
</div>
</ion-item>
</ion-list>
</div>
</div>
</div>
<!-- <iframe id="home-iframe" style="width: 100%;" src="/assets/www/pdfjs/web/viewer.html?file=/assets/www/pdfjs/web/compressed.tracemonkey-pldi-09.pdf.pdf"></iframe> -->
</ion-content>
+33 -33
View File
@@ -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();
// });
}
+6 -4
View File
@@ -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) {
+14 -5
View File
@@ -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{
+3
View File
@@ -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()
}
}
+28 -28
View File
@@ -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) {
+127 -127
View File
@@ -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<Tokenn[]>(`${geturl}`);
}
// // return this.http.get<Tokenn[]>(`${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<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => {
// this.http.post<Tokenn>(`${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']));
// }
}
// }
}
+90 -90
View File
@@ -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:");
});
// send_message_to_all_clients("updateRegistration:");
// });
+4 -4
View File
@@ -9,12 +9,12 @@
<!-- <script type="text/javascript" src="node_modules/ibm-mfp-web-sdk/ibmmfpfanalytics.js"></script>
<script type="text/javascript" src="node_modules/ibm-mfp-web-sdk/ibmmfpf.js"></script> -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.9.359/pdf.min.js" integrity="sha512-U5C477Z8VvmbYAoV4HDq17tf4wG6HXPC6/KM9+0/wEXQQ13gmKY2Zb0Z2vu0VNUWch4GlJ+Tl/dfoLOH4i2msw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.9.359/pdf.min.js" integrity="sha512-U5C477Z8VvmbYAoV4HDq17tf4wG6HXPC6/KM9+0/wEXQQ13gmKY2Zb0Z2vu0VNUWch4GlJ+Tl/dfoLOH4i2msw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> -->
<!-- <script src="node_modules/ibm-mfp-web-sdk/ibmmfpf.js"></script>
<script src="node_modules/ibm-mfp-web-sdk/ibmmfpfanalytics.js"></script> -->
<!-- <script src="assets/js/index.js"></script> -->
<link rel="manifest" href="assets/manifest.json">
<!-- <link rel="manifest" href="assets/manifest.json"> -->
<!-- <script src="assets/js/wldirectudpate.js"></script> -->
<!-- <script>
@@ -56,7 +56,7 @@
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="assets/icon/favicon.png" />
<link rel="manifest" href="assets/json/manifest.json">
<!-- <link rel="manifest" href="assets/json/manifest.json"> -->
<!-- add to homescreen for ios -->
<meta name="apple-mobile-web-app-capable" content="yes" />
@@ -65,7 +65,7 @@
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script type="module" src="./assets/js/index.js"></script>
<!-- <script type="module" src="./assets/js/index.js"></script> -->
<script>
Object.defineProperty(String.prototype, 'capitalize', {