This commit is contained in:
Peter Maquiran
2023-02-03 19:37:47 +01:00
parent 065fc517ae
commit 6ff883c982
17 changed files with 871 additions and 169 deletions
+1
View File
@@ -78,3 +78,4 @@ www2020
android copy/
report.*
src/plugin/src/
_node_modules/
+699 -58
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -28,12 +28,14 @@
"@angular/cdk": "^11.2.13",
"@angular/common": "^12.1.2",
"@angular/core": "^12.1.2",
"@angular/fire": "^7.5.0",
"@angular/forms": "~12.1.2",
"@angular/localize": "^12.1.2",
"@angular/material": "^11.2.13",
"@angular/material-moment-adapter": "^12.0.5",
"@angular/platform-browser": "~12.1.2",
"@angular/platform-browser-dynamic": "~12.1.2",
"@angular/pwa": "^15.1.4",
"@angular/router": "~12.1.2",
"@awesome-cordova-plugins/core": "^5.40.0",
"@awesome-cordova-plugins/document-viewer": "^5.41.0",
+1
View File
@@ -100,6 +100,7 @@ export class HomePage implements OnInit {
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
document.querySelectorAll('popover-viewport').forEach((e: any) => e.remove())
document.querySelectorAll('.loading-blocker').forEach((e: any) => e.remove())
document.querySelectorAll('ion-popover').forEach((e: any) => e.remove())
});
window['platform'] = platform
@@ -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']);
}
@@ -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 {
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()
}
@@ -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 {
-1
View File
@@ -35,7 +35,6 @@ export class BackgroundService {
e.funx()
}
})
this.status = 'offline'
}
paint() {
+48 -30
View File
@@ -13,7 +13,7 @@ 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'
})
@@ -31,6 +31,7 @@ export class NotificationsService {
}} = {}
active = false
isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications');
constructor(
private http: HttpClient,
@@ -85,44 +86,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')) {
if(!this.isPushNotificationsAvailable) {
return false
}
} 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
};
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<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => {
this.active = true
console.log(data)
}, (error) => {
console.log(error)
})
}
);
this.http.post<Tokenn>(`${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
@@ -131,6 +141,10 @@ export class NotificationsService {
}
onReciveForeground() {
if(!this.isPushNotificationsAvailable) {
return false
}
console.log('foregrund');
PushNotifications.addListener('pushNotificationReceived',
(notification: PushNotificationSchema) => {
@@ -158,6 +172,10 @@ export class NotificationsService {
}
onReciveBackground() {
if(!this.isPushNotificationsAvailable) {
return false
}
console.log('fbackgrund');
PushNotifications.addListener('pushNotificationActionPerformed',
(notification: ActionPerformed) => {
@@ -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()
@@ -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);
}
+17 -12
View File
@@ -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() {
+29
View File
@@ -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() {}
}
+29 -8
View File
@@ -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');
@@ -37,3 +29,32 @@ messaging.onBackgroundMessage(function(payload) {
self.registration.showNotification(notificationTitle,
notificationOptions);
});
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;
});
+1 -1
View File
@@ -3,4 +3,4 @@ import { oaprProd } from './suport/oapr'
import { doneITProd } from './suport/doneIt'
export const environment: Environment = oaprProd;
export const environment: Environment = doneITProd;
-30
View File
@@ -48,36 +48,6 @@
}
</script> -->
<script>
if (navigator.serviceWorker) {
navigator.serviceWorker.register("assets/firebase-messaging-sw.js").then(function(reg) {
window.pushReg = reg;
if (reg.installing) {
console.info('Service worker installing');
} else if (reg.waiting) {
console.info('Service worker installed');
} else if (reg.active) {
console.info('Service worker active');
}
if (!(reg.showNotification)) {
console.info('Notifications aren\'t supported on service workers.');
}
// Check if push messaging is supported
if (!('PushManager' in window)) {
console.info("Push messaging isn't supported.");
}
if (Notification.permission === 'denied') {
console.info('The user has blocked notifications.');
}
}).catch(err => {
console.error(JSON.stringify(err));
});
} else {
console.info("Service workers aren't supported in this browser.");
}
</script>
<meta name="color-scheme" content="light dark" />
<meta name="viewport" content="viewport-fit=cover, width=device-width, height=device-hight, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
+7 -7
View File
@@ -1,12 +1,12 @@
export let versionData = {
"shortSHA": "5cef86553",
"SHA": "5cef86553525ac3ef5e20797b04f3e2c12119d82",
"shortSHA": "065fc517a",
"SHA": "065fc517aedb4f1a87f84ccf0a87b4331f373f67",
"branch": "no_bug_movemente",
"lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Thu Feb 2 18:44:19 2023 +0100'",
"lastCommitMessage": "fix pop",
"lastCommitNumber": "4718",
"change": "diff --git a/src/firebase-messaging-sw.js b/src/firebase-messaging-sw.js\ndeleted file mode 100644\nindex f2423c01d..000000000\n--- a/src/firebase-messaging-sw.js\n+++ /dev/null\n@@ -1,40 +0,0 @@\n- if ('serviceWorker' in navigator) {\n- navigator.serviceWorker.register('./firebase-messaging-sw.js')\n- .then(function(registration) {\n- }).catch(function(err) {\n- });\n- } \n-// Scripts for firebase and firebase messaging\n-\n-\n-/* importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js');\n-importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js');\n-\n-// Initialize the Firebase app in the service worker by passing the generated config\n-var firebaseConfig = {\n- apiKey: \"AIzaSyAAdHmTFznCMerdT99nrewJgISRvtxPqoY\",\n- authDomain: \"gabinete-digital-2020.firebaseapp.com\",\n- databaseURL: \"https://gabinete-digital-2020.firebaseio.com\",\n- projectId: \"gabinete-digital-2020\",\n- storageBucket: \"gabinete-digital-2020.appspot.com\",\n- messagingSenderId: \"800733765231\",\n- appId: \"1:800733765231:web:28e7792ab150006513779a\",\n- measurementId: \"G-8QN4BLZ8XK\"\n-};\n-\n-firebase.initializeApp(firebaseConfig);\n-\n-// Retrieve firebase messaging\n-const messaging = firebase.messaging();\n-\n-messaging.onBackgroundMessage(function(payload) {\n- console.log('Received background message ', payload);\n-\n- const notificationTitle = payload.notification.title;\n- const notificationOptions = {\n- body: payload.notification.body,\n- };\n-\n- self.registration.showNotification(notificationTitle,\n- notificationOptions);\n-}); */\n\\ No newline at end of file\ndiff --git a/src/index.html b/src/index.html\nindex dcc59a249..09f31204c 100644\n--- a/src/index.html\n+++ b/src/index.html\n@@ -48,6 +48,36 @@\n }\n </script> -->\n \n+ <script>\n+ if (navigator.serviceWorker) {\n+ navigator.serviceWorker.register(\"assets/firebase-messaging-sw.js\").then(function(reg) {\n+ window.pushReg = reg;\n+ if (reg.installing) {\n+ console.info('Service worker installing');\n+ } else if (reg.waiting) {\n+ console.info('Service worker installed');\n+ } else if (reg.active) {\n+ console.info('Service worker active');\n+ }\n+ if (!(reg.showNotification)) {\n+ console.info('Notifications aren\\'t supported on service workers.');\n+ }\n+ // Check if push messaging is supported\n+ if (!('PushManager' in window)) {\n+ console.info(\"Push messaging isn't supported.\");\n+ }\n+\n+ if (Notification.permission === 'denied') {\n+ console.info('The user has blocked notifications.');\n+ }\n+ }).catch(err => {\n+ console.error(JSON.stringify(err));\n+ });\n+ } else {\n+ console.info(\"Service workers aren't supported in this browser.\");\n+ }\n+ </script>\n+\n <meta name=\"color-scheme\" content=\"light dark\" />\n <meta name=\"viewport\" content=\"viewport-fit=cover, width=device-width, height=device-hight, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no\" />\n <meta name=\"format-detection\" content=\"telephone=no\" />\ndiff --git a/www.rar b/www.rar\nindex 546192517..5575a7494 100644\nBinary files a/www.rar and b/www.rar differ",
"changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.html\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.ts\n\tmodified: src/app/pages/gabinete-digital/diplomas-assinar/diplomas-assinar.page.scss\n\tmodified: src/app/pages/gabinete-digital/diplomas/diplomas.page.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.html\n\tmodified: src/app/shared/gabinete-digital/diplomas-assinar/diplomas-assinar.page.scss\n\tmodified: src/app/shared/gabinete-digital/diplomas-assinar/diplomas-assinar.page.ts\n\tmodified: src/app/shared/gabinete-digital/diplomas/diplomas.page.ts\n\tmodified: src/app/shared/popover/diplomas-gerar-options/diplomas-gerar-options.page.ts\n\nChanges not staged for commit:\n (use \"git add/rm <file>...\" to update what will be committed)\n (use \"git restore <file>...\" to discard changes in working directory)\n\tdeleted: src/firebase-messaging-sw.js\n\tmodified: src/index.html\n\tmodified: www.rar\n\nUntracked files:\n (use \"git add <file>...\" to include in what will be committed)\n\tsrc/assets/firebase-messaging-sw.js\n\tsrc/assets/js/firebase-app.js\n\tsrc/assets/js/firebase-messaging.js",
"lastCommitTime": "'Fri Feb 3 14:37:29 2023 +0100'",
"lastCommitMessage": "improve",
"lastCommitNumber": "4719",
"change": "",
"changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\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/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/environments/environment.prod.ts\n\tmodified: src/index.html",
"changeAuthor": "peter.maquiran"
}