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( canActivate(
route: ActivatedRouteSnapshot, route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
console.log('hire!', state.url)
// if user not active // if user not active
if(!SessionStore.user.Inactivity) { if(!SessionStore.user.Inactivity) {
console.log(' goto login /')
this.router.navigate(['/']); this.router.navigate(['/']);
return false return false
} }
// if session doesn't exit // if session doesn't exit
else if(!SessionStore.exist) { else if(!SessionStore.exist) {
console.log(' goto /')
this.router.navigate(['/']); this.router.navigate(['/']);
return false return false
} else { } else {
if(this.p.userPermission(this.p.permissionList.Chat.access) == true) {
// this.authService.loginChat();
}
const pathname = state.url const pathname = state.url
if(pathname.startsWith('/home/agenda')) { if(pathname.startsWith('/home/agenda')) {
if(this.p.userPermission(this.p.permissionList.Agenda.access)) { if(this.p.userPermission(this.p.permissionList.Agenda.access)) {
return true; return true;
} else { } else {
@@ -48,7 +47,7 @@ export class AuthGuard implements CanActivate {
} }
} else if ( pathname.startsWith('/home/gabinete-digital')) { } else if ( pathname.startsWith('/home/gabinete-digital')) {
console.log('gabinete');
if(this.p.userPermission(this.p.permissionList.Gabinete.access)) { if(this.p.userPermission(this.p.permissionList.Gabinete.access)) {
return true; return true;
@@ -73,6 +72,7 @@ export class AuthGuard implements CanActivate {
} }
} else if (pathname.startsWith('/home/events')) { } else if (pathname.startsWith('/home/events')) {
if(SessionStore.user.OwnerCalendars.length >= 1 || this.p.userPermission([this.p.permissionList.Gabinete.access])) { if(SessionStore.user.OwnerCalendars.length >= 1 || this.p.userPermission([this.p.permissionList.Gabinete.access])) {
console.log('go /home/events')
return true return true
} else { } else {
this.router.navigate(['/login']); 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, route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { 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.platform.is('desktop') || this.platform.is('mobileweb')) {
if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ 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, route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { 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' ) { if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) {
console.log(' goto /home/events')
this.router.navigate(['/home/events']); this.router.navigate(['/home/events']);
return false return false
} else if(SessionStore.exist && !SessionStore.user.Inactivity && SessionStore.user.LoginPreference == 'Pin' && SessionStore.forceToLoginWithForceToLogInWithPassword && !this.platform.is('desktop') && !this.platform.is('mobileweb')) { } 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) { goto(url) {
this.router.navigate([url]) // this.router.navigateByUrl('/home/events', { replaceUrl: true });
this.router.navigate([url], { replaceUrl: true })
} }
refreshing() { } refreshing() { }
@@ -134,8 +135,8 @@ export class HomePage implements OnInit {
this.logDeviceInfo(); this.logDeviceInfo();
this.notificationsService.onReciveForeground(); // this.notificationsService.onReciveForeground();
this.notificationsService.onReciveBackground(); // this.notificationsService.onReciveBackground();
window.addEventListener('online', () => { window.addEventListener('online', () => {
// console.log('Became 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.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', IdObject, 'gabinete-digital']));
} }
this.notificationservice.tempClearArray(); // this.notificationservice.tempClearArray();
this.deleteNotification(index); this.deleteNotification(index);
this.eventtrigger.publishSomeData({ this.eventtrigger.publishSomeData({
notification: "deleted" notification: "deleted"
+3 -3
View File
@@ -797,8 +797,8 @@ export class AgendaPage implements OnInit {
this.listToPresent = this.CalendarStore.eventSource this.listToPresent = this.CalendarStore.eventSource
this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) 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.CalendarStore.eventSource)
console.log('this.TimelineMDList', this.TimelineMDList) // console.log('this.TimelineMDList', this.TimelineMDList)
this.myCal.update(); 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 }) 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(); this.myCal.update();
-113
View File
@@ -27,117 +27,4 @@
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar> <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> </ion-content>
+33 -33
View File
@@ -79,54 +79,54 @@ export class EventsPage implements OnInit {
private changeProfileService: ChangeProfileService, 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) { // window['zipPhoneCallback'] = function (zipphone) {
var frame = document.getElementById('home-iframe'); // var frame = document.getElementById('home-iframe');
if(frame) { // if(frame) {
frame['contentWindow']['postMessage']({call:'cookies', value: { cookies: {} }}); // frame['contentWindow']['postMessage']({call:'cookies', value: { cookies: {} }});
} // }
} // }
this.changeProfileService.registerCallback(() => { // this.changeProfileService.registerCallback(() => {
this.listToPresent = []; // this.listToPresent = [];
this.listToPresentexpediente = [] // this.listToPresentexpediente = []
}) // })
} }
ngOnInit() { ngOnInit() {
this.segment = "Combinada"; // this.segment = "Combinada";
this.profile = "mdgpr"; // this.profile = "mdgpr";
this.showGreeting(); // this.showGreeting();
this.router.events.forEach((event) => { // this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == '/home/events') { // if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents(); // this.RefreshEvents();
setTimeout(() => { // setTimeout(() => {
this.LoadList(); // this.LoadList();
}, 1500) // }, 1500)
} // }
}); // });
this.hideSearch(); // this.hideSearch();
this.backgroundservice.registerBackService('Online', () => { // this.backgroundservice.registerBackService('Online', () => {
this.showGreeting(); // this.showGreeting();
this.RefreshEvents(); // this.RefreshEvents();
this.LoadList(); // this.LoadList();
this.hideSearch(); // this.hideSearch();
}); // });
} }
+6 -4
View File
@@ -38,7 +38,7 @@ export class InactivityPage implements OnInit {
loop = false loop = false
ngOnInit() { ngOnInit() {
alert('pin')
} }
runloop() { runloop() {
@@ -101,6 +101,8 @@ export class InactivityPage implements OnInit {
} else { } else {
SessionStore.delete() SessionStore.delete()
window.localStorage.clear(); window.localStorage.clear();
SessionStore.setInativity(true)
await this.authService.SetSession(attempt, this.userattempt); await this.authService.SetSession(attempt, this.userattempt);
} }
@@ -117,9 +119,9 @@ export class InactivityPage implements OnInit {
} }
getToken() { getToken() {
this.notificatinsservice.requestPermissions(); // this.notificatinsservice.requestPermissions();
this.notificatinsservice.registrationError(); // this.notificatinsservice.registrationError();
this.notificatinsservice.getAndpostToken(this.username); // this.notificatinsservice.getAndpostToken(this.username);
} }
setCode(code: string) { 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 { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
import { ChatSystemService } from 'src/app/services/chat/chat-system.service'; import { ChatSystemService } from 'src/app/services/chat/chat-system.service';
import { ChatService } from 'src/app/services/chat.service'; import { ChatService } from 'src/app/services/chat.service';
import { Platform } from '@ionic/angular';
@Component({ @Component({
@@ -49,7 +51,8 @@ export class LoginPage implements OnInit {
public p: PermissionService, public p: PermissionService,
private RochetChatConnectorService: RochetChatConnectorService, private RochetChatConnectorService: RochetChatConnectorService,
public ChatSystemService: ChatSystemService, public ChatSystemService: ChatSystemService,
private ChatService: ChatService private ChatService: ChatService,
private platform: Platform,
) {} ) {}
ngOnInit() { ngOnInit() {
@@ -93,9 +96,9 @@ export class LoginPage implements OnInit {
} }
getToken() { getToken() {
this.notificatinsservice.requestPermissions(); // this.notificatinsservice.requestPermissions();
this.notificatinsservice.registrationError(); // this.notificatinsservice.registrationError();
this.notificatinsservice.getAndpostToken(this.username); // this.notificatinsservice.getAndpostToken(this.username);
} }
async Login() { async Login() {
@@ -157,7 +160,13 @@ export class LoginPage implements OnInit {
this.getToken(); 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{ else{
+3
View File
@@ -50,10 +50,13 @@ export class AuthService {
this.headers = new HttpHeaders(); this.headers = new HttpHeaders();
if (SessionStore.exist) { if (SessionStore.exist) {
SessionStore.setInativity(true)
if(this.p.userPermission(this.p.permissionList.Chat.access) == true ) { if(this.p.userPermission(this.p.permissionList.Chat.access) == true ) {
this.loginToChatWs() this.loginToChatWs()
} }
} }
+28 -28
View File
@@ -17,7 +17,7 @@ export class TimeService {
end = new Date(); end = new Date();
start = new Date(start); 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 totalMinutes = Math.floor(totalSeconds/60);
const totalHours = Math.floor(totalMinutes/60); const totalHours = Math.floor(totalMinutes/60);
const totalDays = Math.floor(totalHours/24); const totalDays = Math.floor(totalHours/24);
@@ -75,37 +75,37 @@ export class TimeService {
} }
countDownDateTimer(date:any, roomId:string){ countDownDateTimer(date:any, roomId:string){
let timer = setInterval(() =>{ // let timer = setInterval(() =>{
let difference = new Date(date).getTime() - new Date().getTime(); // let difference = new Date(date).getTime() - new Date().getTime();
let c_day = Math.floor(difference/(1000*60*60*24)); // 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_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60));
let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60)); // let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
let c_seconds = Math.floor((difference % (1000*60)) / 1000); // 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) { // if(difference < 0) {
clearInterval(timer); // clearInterval(timer);
this.countDownTime = "Expired"; // this.countDownTime = "Expired";
let body = { "roomId":roomId, } // let body = { "roomId":roomId, }
this.chatService.getRoomInfo(roomId).subscribe(room=>{ // this.chatService.getRoomInfo(roomId).subscribe(room=>{
this.room = room['room']; // this.room = room['room'];
if(this.room.t === 'p'){ // if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{ // this.chatService.deleteGroup(body).subscribe(res=>{
this.ChatSystemService.deleteRoom(roomId) // this.ChatSystemService.deleteRoom(roomId)
}); // });
} // }
else{ // else{
this.chatService.deleteChannel(body).subscribe(res=>{ // this.chatService.deleteChannel(body).subscribe(res=>{
this.ChatSystemService.deleteRoom(roomId) // this.ChatSystemService.deleteRoom(roomId)
}); // });
} // }
}); // });
} // }
}) // })
return this.countDownTime; // return this.countDownTime;
} }
addZero(i) { addZero(i) {
+127 -127
View File
@@ -14,7 +14,7 @@ import { BackgroundService } from './background.service';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { EventTrigger } from '../services/eventTrigger.service'; import { EventTrigger } from '../services/eventTrigger.service';
import { SessionStore } from '../store/session.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({ @Injectable({
providedIn: 'root' 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() // const id = uuidv4()
this.callbacks.push({ type, funx, id }) // this.callbacks.push({ type, funx, id })
if (!object.hasOwnProperty('desktop') && object['desktop'] != false) { // if (!object.hasOwnProperty('desktop') && object['desktop'] != false) {
this.backgroundservice.registerBackService('Notification', funx, type) // this.backgroundservice.registerBackService('Notification', funx, type)
} // }
return id; // return id;
} // }
deleteCallback(id) { // deleteCallback(id) {
this.callbacks.forEach((e, index) => { // this.callbacks.forEach((e, index) => {
if (e.id == id) { // if (e.id == id) {
if (index > -1) { // if (index > -1) {
this.callbacks.splice(index, 1); // this.callbacks.splice(index, 1);
} // }
} // }
}) // })
} // }
getTokenByUserIdAndId(user, userID) { // getTokenByUserIdAndId(user, userID) {
// const geturl = environment.apiURL + 'notifications/user/' + userID; // // const geturl = environment.apiURL + 'notifications/user/' + userID;
// return this.http.get<Tokenn[]>(`${geturl}`); // // return this.http.get<Tokenn[]>(`${geturl}`);
} // }
requestPermissions() { // requestPermissions() {
PushNotifications.requestPermissions().then(result => { // PushNotifications.requestPermissions().then(result => {
if (result.receive === 'granted') { // if (result.receive === 'granted') {
// Register with Apple / Google to receive push via APNS/FCM // // Register with Apple / Google to receive push via APNS/FCM
PushNotifications.register(); // PushNotifications.register();
} else { // } else {
// Show some error // // Show some error
} // }
}); // });
} // }
getAndpostToken(username) { // getAndpostToken(username) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) { // if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else { // } else {
const geturl = environment.apiURL + 'notifications/token'; // const geturl = environment.apiURL + 'notifications/token';
PushNotifications.addListener('registration', // PushNotifications.addListener('registration',
(token: Token) => { // (token: Token) => {
this.storageService.store(username, token.value); // this.storageService.store(username, token.value);
this.storageService.get(username).then(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 headers = { 'Authorization': SessionStore.user.BasicAuthKey };
const body = { // const body = {
UserId: res.UserId, // UserId: res.UserId,
TokenId: token.value, // TokenId: token.value,
Status: 1, // Status: 1,
Service: 1 // Service: 1
}; // };
this.http.post<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => { // this.http.post<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => {
}, (error) => { // }, (error) => {
}) // })
}); // });
}); // });
} // }
); // );
} // }
} // }
registrationError() { // registrationError() {
PushNotifications.addListener('registrationError', // PushNotifications.addListener('registrationError',
(error: any) => { // (error: any) => {
} // }
); // );
} // }
onReciveForeground() { // onReciveForeground() {
PushNotifications.addListener('pushNotificationReceived', // PushNotifications.addListener('pushNotificationReceived',
(notification: PushNotificationSchema) => { // (notification: PushNotificationSchema) => {
this.DataArray.push(notification) // this.DataArray.push(notification)
this.storageService.store("Notifications", this.DataArray) // this.storageService.store("Notifications", this.DataArray)
this.eventtrigger.publishSomeData({ // this.eventtrigger.publishSomeData({
notification: "recive" // notification: "recive"
}) // })
} // }
); // );
} // }
onReciveBackground() { // onReciveBackground() {
PushNotifications.addListener('pushNotificationActionPerformed', // PushNotifications.addListener('pushNotificationActionPerformed',
(notification: ActionPerformed) => { // (notification: ActionPerformed) => {
/* this.DataArray.push(notification.notification) // /* this.DataArray.push(notification.notification)
this.storageService.store("Notifications", this.DataArray) // this.storageService.store("Notifications", this.DataArray)
this.eventtrigger.publishSomeData({ // this.eventtrigger.publishSomeData({
notification: "recive" // notification: "recive"
}) */ // }) */
this.notificatinsRoutes(notification) // this.notificatinsRoutes(notification)
} // }
); // );
} // }
tempClearArray() { // tempClearArray() {
this.DataArray = new Array; // 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'])); // 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") { // 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'])); // 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") { // 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/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/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 })); // 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") { // 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'])); // 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") { // 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'])); // 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") { // 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'])); // 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") { // else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "accao") {
this.zone.run(() => this.router.navigate(['/home/publications', notification.notification.data.IdObject])); // this.zone.run(() => this.router.navigate(['/home/publications', notification.notification.data.IdObject]));
} // }
else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "publicacao") { // 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])); // 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") { // 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'])); // 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") { // 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'])); // 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") { // 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/expedientes-pr', notification.notification.data.IdObject, 'gabinete-digital']));
} // }
} // }
} }
+90 -90
View File
@@ -2,116 +2,116 @@
/* eslint-disable no-undef */ /* eslint-disable no-undef */
/* eslint-disable no-restricted-globals */ /* eslint-disable no-restricted-globals */
const regex = /{{\s*([^}]+)\s*}}/g; // const regex = /{{\s*([^}]+)\s*}}/g;
var _pushVaribales = ""; // var _pushVaribales = "";
function interpolate(messageData) { // function interpolate(messageData) {
return function interpolate(o) { // return function interpolate(o) {
return messageData.replace(regex, function (a, b) { // return messageData.replace(regex, function (a, b) {
var r = o[b]; // var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a; // return typeof r === 'string' || typeof r === 'number' ? r : a;
}); // });
} // }
} // }
function createTemplateMessage(messageData) { // function createTemplateMessage(messageData) {
if (Object.keys(_pushVaribales).length > 0 ) { // if (Object.keys(_pushVaribales).length > 0 ) {
var message = interpolate(messageData)(_pushVaribales); // var message = interpolate(messageData)(_pushVaribales);
return message; // return message;
} else { // } else {
return messageData; // return messageData;
} // }
} // }
function displayNotification(event) { // function displayNotification(event) {
var messageJson = event.data.text(); // var messageJson = event.data.text();
messageJson = JSON.parse(messageJson); // messageJson = JSON.parse(messageJson);
var title = messageJson.title ? messageJson.title : "New message"; // var title = messageJson.title ? messageJson.title : "New message";
var imageUrl = messageJson.iconUrl ? messageJson.iconUrl : "images/icon.png"; // var imageUrl = messageJson.iconUrl ? messageJson.iconUrl : "images/icon.png";
// var tagJson = messageJson.payload; // // var tagJson = messageJson.payload;
// var tag = tagJson.tag ? tagJson.tag : ""; // // var tag = tagJson.tag ? tagJson.tag : "";
var bodyAlert = messageJson.alert ? messageJson.alert : "Example message" // var bodyAlert = messageJson.alert ? messageJson.alert : "Example message"
var payloadData = messageJson.payload ? messageJson.payload : "Example message" // var payloadData = messageJson.payload ? messageJson.payload : "Example message"
let messageTemp; // let messageTemp;
if ((messageTemp = regex.exec(bodyAlert)) !== null) { // if ((messageTemp = regex.exec(bodyAlert)) !== null) {
bodyAlert = createTemplateMessage(bodyAlert); // bodyAlert = createTemplateMessage(bodyAlert);
} // }
self.registration.showNotification(title, { // self.registration.showNotification(title, {
body: bodyAlert, // body: bodyAlert,
icon: imageUrl, // icon: imageUrl,
data: payloadData, // data: payloadData,
// tag: tag // // tag: tag
}); // });
return Promise.resolve(); // return Promise.resolve();
} // }
function triggerSeenEvent(strMsg) { // function triggerSeenEvent(strMsg) {
send_message_to_all_clients("msgEventSeen:" + strMsg); // send_message_to_all_clients("msgEventSeen:" + strMsg);
} // }
function triggerOpenEvent(strMsg) { // function triggerOpenEvent(strMsg) {
send_message_to_all_clients("msgEventOpen:" + 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) { // function send_message_to_client(client, msg) {
return new Promise(function (resolve, reject) { // return new Promise(function (resolve, reject) {
var msg_chan = new MessageChannel(); // var msg_chan = new MessageChannel();
msg_chan.port1.onmessage = function (event) { // msg_chan.port1.onmessage = function (event) {
if (event.data.error) { // if (event.data.error) {
reject(event.data.error); // reject(event.data.error);
} else { // } else {
resolve(event.data); // resolve(event.data);
} // }
}; // };
client.postMessage(msg, [msg_chan.port2]); // client.postMessage(msg, [msg_chan.port2]);
}); // });
} // }
function send_message_to_all_clients(msg) { // function send_message_to_all_clients(msg) {
clients.matchAll().then(clients => { // clients.matchAll().then(clients => {
clients.forEach(client => { // clients.forEach(client => {
send_message_to_client(client, msg); // send_message_to_client(client, msg);
}) // })
}); // });
} // }
self.addEventListener('install', function (event) { // self.addEventListener('install', function (event) {
self.skipWaiting(); // self.skipWaiting();
//event.postMessage("SW Says 'Hello back!'"); // //event.postMessage("SW Says 'Hello back!'");
}); // });
self.addEventListener('message', function (event) { // self.addEventListener('message', function (event) {
replyPort = event.ports[0]; // replyPort = event.ports[0];
_pushVaribales = event.data; // _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; // let nidjson = event.notification.data;
event.notification.close(); // event.notification.close();
event.waitUntil(triggerOpenEvent(nidjson)); // 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/ibmmfpfanalytics.js"></script>
<script type="text/javascript" src="node_modules/ibm-mfp-web-sdk/ibmmfpf.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/ibmmfpf.js"></script>
<script src="node_modules/ibm-mfp-web-sdk/ibmmfpfanalytics.js"></script> --> <script src="node_modules/ibm-mfp-web-sdk/ibmmfpfanalytics.js"></script> -->
<!-- <script src="assets/js/index.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 src="assets/js/wldirectudpate.js"></script> -->
<!-- <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 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="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 --> <!-- add to homescreen for ios -->
<meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-capable" content="yes" />
@@ -65,7 +65,7 @@
<link rel="preconnect" href="https://fonts.gstatic.com"> <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/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" 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> <script>
Object.defineProperty(String.prototype, 'capitalize', { Object.defineProperty(String.prototype, 'capitalize', {