diff --git a/src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts b/src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts
index d82b40569..e9a5c1d1e 100644
--- a/src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts
+++ b/src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts
@@ -206,13 +206,13 @@ export class ApproveEventModalPage implements OnInit {
try {
await this.processes.PostTaskAction(body).toPromise()
this.router.navigate(['/home/gabinete-digital/event-list']);
- this.toastService._successMessage()
+ this.toastService._successMessage('Evento enviado para revisão');
} catch (error) {
if(error.status == 0) {
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
} else {
- this.toastService._badRequest()
+ this.toastService._badRequest('Evento não enviado para revisão');
}
this.router.navigate(['/home/gabinete-digital/event-list']);
}
diff --git a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts
index 7a6558bdf..76b71e2bb 100644
--- a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts
+++ b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts
@@ -216,13 +216,14 @@ export class ApproveEventPage implements OnInit {
await this.processes.PostTaskAction(body).toPromise()
this.toastService._successMessage();
this.goBack();
+ this.toastService._successMessage('Evento Aprovar')
} catch (error) {
if(error.status == 0) {
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
} else {
- this.toastService._badRequest()
+ this.toastService._badRequest('Evento não aprovar')
}
}
finally {
@@ -266,14 +267,14 @@ export class ApproveEventPage implements OnInit {
this.offlineManager.storeRequestData('event-listRever', body);
});
- this.toastService._successMessage('Pedido enviado');
+ this.toastService._successMessage('Evento enviado para revisão');
this.goBack();
} catch (error) {
if(error.status == 0) {
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
} else {
- this.toastService._badRequest();
+ this.toastService._badRequest('Evento não enviado para revisão');
}
} finally {
loader.remove()
@@ -299,7 +300,7 @@ export class ApproveEventPage implements OnInit {
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
} else {
- this.toastService._badRequest()
+ this.toastService._badRequest('Evento não rejeitado')
}
}
finally {
@@ -379,13 +380,14 @@ export class ApproveEventPage implements OnInit {
await this.processes.PostTaskAction(body).toPromise();
this.toastService._successMessage();
this.goBack();
+ this.toastService._successMessage('Evento enviado para revisão');
} catch (error) {
- if(error.status == 0) {
- this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
- } else {
-
- this.toastService._badRequest();
- }
+ if(error.status == 0) {
+ this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
+ } else {
+
+ this.toastService._badRequest('Evento não enviado para revisão');
+ }
} finally {
loader.remove()
}
diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.ts b/src/app/pages/gabinete-digital/gabinete-digital.page.ts
index ab0b6f288..5e74dc460 100644
--- a/src/app/pages/gabinete-digital/gabinete-digital.page.ts
+++ b/src/app/pages/gabinete-digital/gabinete-digital.page.ts
@@ -166,6 +166,7 @@ export class GabineteDigitalPage implements OnInit {
}
this.LoadCounts();
+ this.updateAllProcess()
const pathname = window.location.pathname
this.router.events.forEach((event) => {
@@ -176,9 +177,11 @@ export class GabineteDigitalPage implements OnInit {
if(this.NotificationsService.active === false) {
this.checkRoutes();
this.LoadCounts();
+ this.updateAllProcess()
} else {
this.checkRoutes();
this.LoadCounts();
+ this.updateAllProcess()
}
}
})
@@ -786,7 +789,7 @@ export class GabineteDigitalPage implements OnInit {
if (event) {
setTimeout(() => {
- event.target.complete();
+ event?.target?.complete();
}, 2000);
}
else {
diff --git a/src/app/services/background.service.ts b/src/app/services/background.service.ts
index 505d8b1ca..ca5021972 100644
--- a/src/app/services/background.service.ts
+++ b/src/app/services/background.service.ts
@@ -35,7 +35,6 @@ export class BackgroundService {
e.funx()
}
})
- this.status = 'offline'
}
paint() {
diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts
index e30c875d3..820e63d57 100644
--- a/src/app/services/notifications.service.ts
+++ b/src/app/services/notifications.service.ts
@@ -12,7 +12,8 @@ import { EventTrigger } from '../services/eventTrigger.service';
import { SessionStore } from '../store/session.service';
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
import { notificationObject } from '../models/notifications';
-
+import { v4 as uuidv4 } from 'uuid'
+import { Capacitor } from '@capacitor/core';
@Injectable({
providedIn: 'root'
})
@@ -30,6 +31,7 @@ export class NotificationsService {
}} = {}
active = false
+ isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications');
constructor(
private http: HttpClient,
@@ -83,44 +85,53 @@ export class NotificationsService {
}
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
- }
- });
+ if(!this.isPushNotificationsAvailable) {
+ return false
+ }
+
+ PushNotifications.requestPermissions().then(result => {
+ if (result.receive === 'granted') {
+ // Register with Apple / Google to receive push via APNS/FCM
+ PushNotifications.register();
+ } else {
+ // Show some error
+ }
+ });
}
getAndpostToken(username) {
- if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
-
- } else {
- const geturl = environment.apiURL + 'notifications/token';
- PushNotifications.addListener('registration',
- (token: Token) => {
- const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
- const body = {
- UserId: SessionStore.user.UserId,
- TokenId: token.value,
- Status: 1,
- Service: 1
- };
+ if(!this.isPushNotificationsAvailable) {
+ return false
+ }
- this.http.post(`${geturl}`, body, { headers }).subscribe(data => {
- this.active = true
- console.log(data)
- }, (error) => {
- console.log(error)
- })
- }
- );
- }
+ const geturl = environment.apiURL + 'notifications/token';
+ PushNotifications.addListener('registration',
+ (token: Token) => {
+ const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
+ const body = {
+ UserId: SessionStore.user.UserId,
+ TokenId: token.value,
+ Status: 1,
+ Service: 1
+ };
+
+ this.http.post(`${geturl}`, body, { headers }).subscribe(data => {
+ this.active = true
+ console.log(data)
+ }, (error) => {
+ console.log(error)
+ })
+ }
+ );
+
}
registrationError() {
+ if(!this.isPushNotificationsAvailable) {
+ return false
+ }
+
PushNotifications.addListener('registrationError',
(error: any) => {
this.active = false
@@ -129,6 +140,10 @@ export class NotificationsService {
}
onReciveForeground() {
+ if(!this.isPushNotificationsAvailable) {
+ return false
+ }
+
console.log('foregrund');
PushNotifications.addListener('pushNotificationReceived',
(notification: PushNotificationSchema) => {
@@ -156,6 +171,10 @@ export class NotificationsService {
}
onReciveBackground() {
+ if(!this.isPushNotificationsAvailable) {
+ return false
+ }
+
console.log('fbackgrund');
PushNotifications.addListener('pushNotificationActionPerformed',
(notification: ActionPerformed) => {
diff --git a/src/app/shared/agenda/approve-event/approve-event.page.ts b/src/app/shared/agenda/approve-event/approve-event.page.ts
index 376173f5d..da1467b5a 100644
--- a/src/app/shared/agenda/approve-event/approve-event.page.ts
+++ b/src/app/shared/agenda/approve-event/approve-event.page.ts
@@ -87,9 +87,14 @@ export class ApproveEventPage implements OnInit {
try {
await this.processes.PostTaskAction(body).toPromise()
this.modalController.dismiss(serialNumber);
- this.toastService._successMessage()
+ this.toastService._successMessage('Evento aprovar')
} catch (error) {
- this.toastService._badRequest()
+ if(error.status == 0) {
+ this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
+ } else {
+
+ this.toastService._badRequest('Evento não aprovar')
+ }
} finally {
this.close()
loader.remove()
@@ -108,7 +113,13 @@ export class ApproveEventPage implements OnInit {
await this.processes.PostTaskAction(body).toPromise()
this.toastService._successMessage('Evento rejeitado')
} catch (error) {
- this.toastService._badRequest('Processo não efectuado')
+ if(error.status == 0) {
+ this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
+ } else {
+
+ this.toastService._badRequest('Evento não rejeitado')
+ }
+
} finally {
loader.remove()
this.close()
@@ -196,7 +207,7 @@ export class ApproveEventPage implements OnInit {
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
} else {
- this.toastService._badRequest();
+ this.toastService._badRequest('Evento não enviado para revisão');
}
} finally {
loader.remove()
diff --git a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts
index e832ab727..b21e9b2f7 100644
--- a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts
+++ b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts
@@ -42,7 +42,6 @@ export class EventsToApprovePage implements OnInit {
}
ngOnInit() {
- // console.log('ERROR LEGN',this.eventsMDGPRList.length)
this.segment = this.loggeduser.Profile;
this.LoadToApproveEvents();
@@ -127,7 +126,7 @@ export class EventsToApprovePage implements OnInit {
doRefresh(event) {
if (event) {
setTimeout(() => {
- event.target.complete();
+ event?.target?.complete();
}, 2000);
}
diff --git a/src/app/store/eventoaprovacao-store.service.ts b/src/app/store/eventoaprovacao-store.service.ts
index 5435e7fd9..78802a652 100644
--- a/src/app/store/eventoaprovacao-store.service.ts
+++ b/src/app/store/eventoaprovacao-store.service.ts
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { localstoreService } from './localstore.service'
import { AES, enc, SHA1 } from 'crypto-js'
+import { isArray } from 'ionic-angular/umd/util/util';
@Injectable({
providedIn: 'root'
@@ -24,8 +25,8 @@ export class EventoaprovacaoStoreService {
setTimeout(()=>{
- let restoreMd = localstoreService.get(this.keyNamemd, {})
- let restorePr = localstoreService.get(this.keyNamepr, {})
+ let restoreMd = localstoreService.get(this.keyNamemd, [])
+ let restorePr = localstoreService.get(this.keyNamepr, [])
this._listPr = restorePr.listPr || []
this._listMd = restoreMd.lisMd || []
@@ -36,8 +37,8 @@ export class EventoaprovacaoStoreService {
}
- get listpr() { return this._listPr }
- get listmd() { return this._listMd }
+ get listpr() { return this._listPr || [] }
+ get listmd() { return this._listMd || [] }
get count() { return this._count || 0 }
set count(value: number) {
@@ -55,20 +56,24 @@ export class EventoaprovacaoStoreService {
}
resetpr(eventsList: any) {
- this._listPr = eventsList
+ if(Array.isArray(eventsList)) {
+ this._listPr = eventsList
- this.countPr = this._listPr.length
- this.count = this.countPr + this.countMd
+ this.countPr = this._listPr.length
+ this.count = this.countPr + this.countMd
- this.savePr()
+ this.savePr()
+ }
}
resetmd(eventsList: any) {
- this._listMd = eventsList
+ if(Array.isArray(eventsList)) {
+ this._listMd = eventsList
- this.countMd = this._listMd.length
- this.count = this.countPr + this.countMd
- this.saveMd()
+ this.countMd = this._listMd.length
+ this.count = this.countPr + this.countMd
+ this.saveMd()
+ }
}
private saveMd() {
diff --git a/src/app/store/session.service.ts b/src/app/store/session.service.ts
index cf33bdcfb..cd9309ad3 100644
--- a/src/app/store/session.service.ts
+++ b/src/app/store/session.service.ts
@@ -149,6 +149,35 @@ class SessionService {
return initials;
}
+
+ clearPermission() {
+ this.permission = {
+ Agenda: {
+ access: false
+ },
+ Gabinete: {
+ access: false,
+ pr_tasks: false,
+ md_tasks: false,
+ aprove_event: false
+ },
+ Actions: {
+ access : false,
+ create : false,
+ delete : false,
+ edit : false,
+ createPost : false,
+ deletePost : false,
+ editPost : false
+ },
+ Chat: {
+ access: false
+ }
+ }
+ }
+
+ setPermission() {}
+
}
diff --git a/src/assets/firebase-messaging-sw.js b/src/assets/firebase-messaging-sw.js
index 627521a5c..fdd82b78c 100644
--- a/src/assets/firebase-messaging-sw.js
+++ b/src/assets/firebase-messaging-sw.js
@@ -1,11 +1,3 @@
- if ('serviceWorker' in navigator) {
- navigator.serviceWorker.register('./firebase-messaging-sw.js')
- .then(function(registration) {
- }).catch(function(err) {
- });
- }
-// Scripts for firebase and firebase messaging
-
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js');
@@ -36,4 +28,33 @@ messaging.onBackgroundMessage(function(payload) {
self.registration.showNotification(notificationTitle,
notificationOptions);
-});
\ No newline at end of file
+});
+
+
+self.addEventListener('install', function(event) {
+ self.skipWaiting();
+ console.log('Installed', event);
+});
+
+self.addEventListener('activate', function(event) {
+ console.log('Activated', event);
+});
+
+self.addEventListener('push', function(event) {
+
+ var uid = "EXISTS_IN_CORE.JS";
+ var token = "ALSO_EXISTS_IN_CORE.JS";
+
+ console.log("Push recieved - we need to know the uid and token here, from core.js");
+});
+
+self.addEventListener('message', function(event){
+ var data = JSON.parse(event.data);
+
+ console.log("SW Received Message:");
+ console.log(data);
+
+ self.userID = data.uid;
+ self.userToken = data.token;
+
+});
\ No newline at end of file
diff --git a/src/index.html b/src/index.html
index 09f31204c..dcc59a249 100644
--- a/src/index.html
+++ b/src/index.html
@@ -48,36 +48,6 @@
}
-->
-
-
diff --git a/version/git-version.ts b/version/git-version.ts
index b1c5c2daa..24fb5068d 100644
--- a/version/git-version.ts
+++ b/version/git-version.ts
@@ -1,12 +1,12 @@
export let versionData = {
- "shortSHA": "cddddf982",
- "SHA": "cddddf982b924dbca51d9deba781dc1182d4b2b5",
+ "shortSHA": "dcff11581",
+ "SHA": "dcff11581665a569e10ccab0aeaf1dc7f04d3d3a",
"branch": "no_bug_movemente",
"lastCommitAuthor": "'Eudes Inácio'",
- "lastCommitTime": "'Fri Feb 3 14:45:16 2023 +0100'",
- "lastCommitMessage": "merge with Peter changes",
- "lastCommitNumber": "4721",
+ "lastCommitTime": "'Mon Feb 6 09:44:43 2023 +0100'",
+ "lastCommitMessage": "Code refactore on pedido mobile",
+ "lastCommitNumber": "4722",
"change": "",
- "changeStatus": "On branch no_bug_movemente\nYour branch is behind 'origin/no_bug_movemente' by 2 commits, and can be fast-forwarded.\n (use \"git pull\" to update your local branch)\n\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts\n\tdeleted: www.rar",
+ "changeStatus": "On branch no_bug_movemente\nYour branch and 'origin/no_bug_movemente' have diverged,\nand have 1 and 2 different commits each, respectively.\n (use \"git pull\" to merge the remote branch into yours)\n\nAll conflicts fixed but you are still merging.\n (use \"git commit\" to conclude merge)\n\nChanges to be committed:\n\tmodified: .gitignore\n\tmodified: package-lock.json\n\tmodified: package.json\n\tmodified: src/app/home/home.page.ts\n\tmodified: src/app/pages/agenda/agenda.page.html\n\tmodified: src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts\n\tmodified: src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.ts\n\tmodified: src/app/services/background.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/shared/agenda/approve-event/approve-event.page.ts\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts\n\tmodified: src/app/store/eventoaprovacao-store.service.ts\n\tmodified: src/app/store/session.service.ts\n\tmodified: src/assets/firebase-messaging-sw.js\n\tmodified: src/index.html\n\tmodified: version/git-version.ts",
"changeAuthor": "eudes.inacio"
}
\ No newline at end of file