diff --git a/src/app/guards/login.guard.ts b/src/app/guards/login.guard.ts index 2987806a8..a8f1790f3 100644 --- a/src/app/guards/login.guard.ts +++ b/src/app/guards/login.guard.ts @@ -4,6 +4,7 @@ import { Observable } from 'rxjs'; import { SessionStore } from '../store/session.service'; import { Platform } from '@ionic/angular'; import { RouteService } from 'src/app/services/route.service' +import { FirstEnterService } from 'src/app/services/first-enter.service' @Injectable({ providedIn: 'root' @@ -12,7 +13,8 @@ export class LoginGuard implements CanActivate { constructor( private router:Router, private platform: Platform, - private RouteService: RouteService ) { + private RouteService: RouteService, + private FirstEnterService: FirstEnterService ) { } canActivate( @@ -24,7 +26,7 @@ export class LoginGuard implements CanActivate { if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) { // enter app - this.router.navigate(['/home/events']); + this.FirstEnterService.enter() return false } else if(SessionStore.exist && !SessionStore.user.Inactivity && SessionStore.user.LoginPreference == 'Pin' && SessionStore.forceToLoginWithForceToLogInWithPassword && this.platform.is('mobile')) { // login with password while has pin diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.ts b/src/app/pages/gabinete-digital/gabinete-digital.page.ts index abb3cb545..546ec76f1 100644 --- a/src/app/pages/gabinete-digital/gabinete-digital.page.ts +++ b/src/app/pages/gabinete-digital/gabinete-digital.page.ts @@ -106,7 +106,7 @@ export class GabineteDigitalPage implements OnInit { AllProcess = [] - workerList : Worker + // workerList : Worker @ViewChild(ExpedientsPage) expedientesPage: ExpedientsPage; @ViewChild(PendentesPage) pendentesListPage: PendentesPage; @@ -128,11 +128,11 @@ export class GabineteDigitalPage implements OnInit { public NotificationsService: NotificationsService ) { - this.workerList = new Worker(new URL('./list.worker.js', import.meta.url)); + // this.workerList = new Worker(new URL('./list.worker.js', import.meta.url)); - this.workerList.onmessage = (oEvent) => { - this.AllProcess = oEvent.data - } + // this.workerList.onmessage = (oEvent) => { + // this.AllProcess = oEvent.data + // } window.onresize = (event) => { // if not mobile remove all component @@ -197,70 +197,78 @@ export class GabineteDigitalPage implements OnInit { }); - this.NotificationsService.registerCallback( - 'despachos', - () => { - this.LoadCounts(); - console.log('refresh with notification') - } - ) - this.NotificationsService.registerCallback( - 'despachos-pr', - () => { - this.LoadCounts(); - console.log('refresh with notification') - } - ) - this.NotificationsService.registerCallback( - 'expediente', - () => { - this.LoadCounts(); - console.log('refresh with notification') - } - ) - this.NotificationsService.registerCallback( - 'gabinete-digital', - () => { - this.LoadCounts(); - console.log('refresh with notification') - } - ) - this.NotificationsService.registerCallback( - 'parecer', - () => { - this.LoadCounts(); - console.log('refresh with notification') - } - ) - this.NotificationsService.registerCallback( - 'deferimento', - () => { - this.LoadCounts(); - console.log('refresh with notification') - } - ) - this.NotificationsService.registerCallback( - 'diplomas-assinar', - () => { - this.LoadCounts(); - console.log('refresh with notification') - } - ) - this.NotificationsService.registerCallback( - 'diplomas', - () => { - this.LoadCounts(); - console.log('refresh with notification') - } - ) - this.NotificationsService.registerCallback( - 'expedientes-pr', - () => { - this.LoadCounts(); - console.log('refresh with notification') - } - ) + // this.NotificationsService.registerCallback({ + // type:'despachos', + // funx:() => { + // // this.loadCount(); + // console.log('refresh with notification') + // } + // }) + // this.NotificationsService.registerCallback({ + // type:'*', + // funx:() => { + // // this.LoadCounts(); + // console.log('refresh with notification *') + // } + // }) + + // this.NotificationsService.registerCallback({ + // type:'despachos-pr', + // funx:() => { + // // this.LoadCounts(); + // console.log('refresh with notification') + // } + // }) + // this.NotificationsService.registerCallback({ + // type:'expediente', + // funx: () => { + // this.LoadCounts(); + // console.log('refresh with notification') + // } + // }) + // this.NotificationsService.registerCallback({ + // type:'gabinete-digital', + // funx:() => { + // this.LoadCounts(); + // console.log('refresh with notification') + // } + // }) + // this.NotificationsService.registerCallback({ + // type:'parecer', + // funx: () => { + // this.LoadCounts(); + // console.log('refresh with notification') + // } + // }) + // this.NotificationsService.registerCallback({ + // type: 'deferimento', + // funx: () => { + // this.LoadCounts(); + // console.log('refresh with notification') + // } + // }) + // this.NotificationsService.registerCallback({ + // type: 'diplomas-assinar', + // funx: () => { + // this.LoadCounts(); + // console.log('refresh with notification') + // } + // }) + // this.NotificationsService.registerCallback({ + // type: 'diplomas', + // funx: () => { + // this.LoadCounts(); + // console.log('refresh with notification') + // } + // }) + // this.NotificationsService.registerCallback({ + // type: 'expedientes-pr', + // funx: () => { + // this.LoadCounts(); + // console.log('refresh with notification') + // } + // }) } @@ -578,7 +586,7 @@ export class GabineteDigitalPage implements OnInit { updateAllProcess() { this.AllProcess = this.expedientegbstore.list.concat(this.pedidosstore.listparecer).concat(this.pedidosstore.listdeferimento) .concat(this.despachoprstore.list).concat(this.eventoaprovacaostore.listmd).concat(this.eventoaprovacaostore.listpr).concat(this.despachoStore.list) - .concat(this.deplomasStore.diplomasParaAssinarList).concat(this.deplomasStore.diplomasAssinadoList).concat(this.deplomasStore.DiplomaGerarList) + .concat(this.deplomasStore.diplomasParaAssinarList).concat(this.deplomasStore.diplomasAssinadoList).concat(this.deplomasStore.DiplomaGerarList).concat(this.pendentesstore.list) // try{ // this.workerList.postMessage([ @@ -591,8 +599,6 @@ export class GabineteDigitalPage implements OnInit { // .concat(this.despachoprstore.list).concat(this.eventoaprovacaostore.listmd).concat(this.eventoaprovacaostore.listpr).concat(this.despachoStore.list) // .concat(this.deplomasStore.diplomasParaAssinarList).concat(this.deplomasStore.diplomasAssinadoList).concat(this.deplomasStore.DiplomaGerarList) // } - - } get getAllProcessCount() { diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index f6d7b6238..880e4506b 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -27,73 +27,59 @@ export class NotificationsService { folderId: string; DataArray = new Array(); - callbacks: { + + callbacks: {[key: string]: { type: notificationObject, funx: Function id: string - }[] = [] + }} = {} active = false constructor( private http: HttpClient, private storageService: StorageService, - private modalController: ModalController, public modalCtrl: AlertController, - private animationController: AnimationController, private platform: Platform, private router: Router, - private toastService: ToastService, private zone: NgZone, - private activeroute: ActivatedRoute, - private eventtrigger: EventTrigger, - private backgroundservice: BackgroundService, - /* private eventTriger: Events, */ - /* private fcm: FCM */) { + private eventtrigger: EventTrigger,) { } - registerCallback(type: notificationObject, 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) - } - return id; - } - - // registerCallback({type, funx, id = uuidv4()}:{ + // registerCallback({type, funx, id = uuidv4()} : { // type: notificationObject, // funx: Function // id?: string // }) { - - // this.callbacks.push({ type, funx, id }) - + // this.callbacks[id] = { funx, id, type} // return id; // } - private runNotificationCallback(notification) { - this.callbacks.forEach((data) => { - if(data.type == notification.data.IdObject) { - data.funx({notification}) - } else if (data.type == '*') { - } - }) - } + // private async runNotificationCallback(notification) { - deleteCallback(id) { - this.callbacks.forEach((e, index) => { - if (e.id == id) { - if (index > -1) { - this.callbacks.splice(index, 1); - } - } - }) + // for (const [key, value] of Object.entries(this.callbacks)) { + // if(value.type == notification.data.Object) { - } + // const dontRepeat = await value.funx(notification) + + // if(dontRepeat) { + // delete this.callbacks[key] + // } + + // } else if (value.type == '*') { + // const dontRepeat = await value.funx(notification) + + // if(dontRepeat) { + // delete this.callbacks[key] + // } + // } + + // } + + // } getTokenByUserIdAndId(user, userID) { // const geturl = environment.apiURL + 'notifications/user/' + userID; @@ -120,7 +106,7 @@ export class NotificationsService { PushNotifications.addListener('registration', (token: Token) => { - this.active = false + this.storageService.store(username, token.value); this.storageService.get(username).then(value => { @@ -135,6 +121,7 @@ export class NotificationsService { }; this.http.post(`${geturl}`, body, { headers }).subscribe(data => { + this.active = true //console.log(data) }, (error) => { //console.log(error) @@ -163,6 +150,7 @@ export class NotificationsService { onReciveForeground() { PushNotifications.addListener('pushNotificationReceived', (notification: PushNotificationSchema) => { + this.active = true console.log(notification) //this.DataArray.push(notification) //console.log(this.DataArray) @@ -176,7 +164,7 @@ export class NotificationsService { } }) - this.runNotificationCallback(notification) + // this.runNotificationCallback(notification) /* this.eventTriger.publish('notificatioRecive') */ this.eventtrigger.publishSomeData({ notification: "recive" @@ -188,6 +176,7 @@ export class NotificationsService { onReciveBackground() { PushNotifications.addListener('pushNotificationActionPerformed', (notification: ActionPerformed) => { + this.active = true console.log(notification) /* this.DataArray.push(notification.notification) @@ -196,7 +185,7 @@ export class NotificationsService { notification: "recive" }) */ this.notificatinsRoutes(notification) - this.runNotificationCallback(notification) + // this.runNotificationCallback(notification) } ); } diff --git a/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts b/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts index 768e4222a..20e77969e 100644 --- a/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts +++ b/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts @@ -76,7 +76,7 @@ export class AllProcessesPage implements OnInit { updateAllProcess() { this.AllProcess = this.expedientegbstore.list.concat(this.pedidosstore.listparecer).concat(this.pedidosstore.listdeferimento) .concat(this.despachoprstore.list).concat(this.eventoaprovacaostore.listmd).concat(this.eventoaprovacaostore.listpr).concat(this.despachoStore.list) - .concat(this.deplomasStore.diplomasParaAssinarList).concat(this.deplomasStore.diplomasAssinadoList).concat(this.deplomasStore.DiplomaGerarList) + .concat(this.deplomasStore.diplomasParaAssinarList).concat(this.deplomasStore.diplomasAssinadoList).concat(this.deplomasStore.DiplomaGerarList).concat(this.pendentesstore.list) } get getAllProcessCount() { diff --git a/tsconfig.worker.json b/tsconfig.worker.json new file mode 100644 index 000000000..39ec19374 --- /dev/null +++ b/tsconfig.worker.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/worker", + "lib": [ + "es2018", + "webworker" + ], + "types": [] + }, + "include": [ + "src/**/*.worker.ts" + ] + } \ No newline at end of file diff --git a/version/git-version.ts b/version/git-version.ts index 86109465c..cfce24cf5 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "e9de468b9", - "SHA": "e9de468b9b5dfd61c4b34a30e59de77c2a432953", + "shortSHA": "7b97a79e3", + "SHA": "7b97a79e3c16ea1794a9cb22c8c74f9d95affda8", "branch": "no_bug_movemente", "lastCommitAuthor": "'Eudes InĂ¡cio'", - "lastCommitTime": "'Thu Jan 19 09:51:21 2023 +0100'", - "lastCommitMessage": "pull of Peter changes", - "lastCommitNumber": "4657", + "lastCommitTime": "'Thu Jan 19 10:24:18 2023 +0100'", + "lastCommitMessage": "pull of peter changes 2", + "lastCommitNumber": "4660", "change": "", - "changeStatus": "On branch no_bug_movemente\nYour branch and 'origin/no_bug_movemente' have diverged,\nand have 3 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: src/app/shared/gabinete-digital/all-processes/all-processes.page.ts", + "changeStatus": "On branch no_bug_movemente\nYour branch and 'origin/no_bug_movemente' have diverged,\nand have 4 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: src/app/guards/login.guard.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.ts\n\tnew file: tsconfig.worker.json", "changeAuthor": "eudes.inacio" } \ No newline at end of file