diff --git a/.gitignore b/.gitignore index 2db2d43da..52265823b 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,8 @@ src/app/architect/ src/environments/environment.e2e.ts .env platforms_ -_platforms \ No newline at end of file +_platforms + + +src/app/store/notification.service.spec.ts +src/app/store/notification.service.ts \ No newline at end of file diff --git a/src/app/Rules/despacho.service.ts b/src/app/Rules/despacho.service.ts index f1387ac95..1d07c2698 100644 --- a/src/app/Rules/despacho.service.ts +++ b/src/app/Rules/despacho.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { customTask, fullTask } from '../models/dailyworktask.model'; +import { customTask, fullTask, fullTaskList } from '../models/dailyworktask.model'; import { AttachmentList } from '../models/Excludetask'; import { PermissionService } from '../OtherService/permission.service'; import { CustomTaskPipe } from '../pipes/custom-task.pipe'; @@ -189,7 +189,7 @@ export class DespachoService { } - async getList({updateStore = false}): Promise { + async getList({updateStore = false}): Promise | null { if (this.LoaderService.loading) { return this.despachoStore.list @@ -197,35 +197,32 @@ export class DespachoService { this.LoaderService.push({}) - let result: fullTask[] = [] + let result: fullTaskList[] = [] + let despachoList: customTask[] = []; try { result = await this.processes.GetTasksList("Despacho", false).toPromise(); + result = result.filter((data:fullTaskList) => data.workflowInstanceDataFields.Status == "Active") + result.forEach((element, index) => { + + let task: customTask = this.customTaskPipe.transform(element); + despachoList.push(task); + + }); + + despachoList = this.sortArrayISODate(despachoList).reverse(); + + if(updateStore) { + this.despachoStore.reset(despachoList); + } + } catch (error) { } finally { this.LoaderService.pop({}) - } - - - result = result.filter(data => data.workflowInstanceDataFields.Status == "Active") - - let despachoList: customTask[] = new Array(); - - result.forEach((element, index) => { - - let task: customTask = this.customTaskPipe.transform(element); - despachoList.push(task); - - }); - - despachoList = this.sortArrayISODate(despachoList).reverse(); - - if(updateStore) { - this.despachoStore.reset(despachoList); + return this.despachoStore.list } - return despachoList } sortArrayISODate(myArray: any) { diff --git a/src/app/guards/auth.guard.ts b/src/app/guards/auth.guard.ts index 1a39ff1f9..83859aead 100644 --- a/src/app/guards/auth.guard.ts +++ b/src/app/guards/auth.guard.ts @@ -17,7 +17,10 @@ export class AuthGuard implements CanActivate { route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { - if(window.location.pathname != '' && !SessionStore.exist) { + if(!SessionStore.user.Inactivity) { + this.router.navigate(['/inactivity']); + } + else if(window.location.pathname != '' && !SessionStore.exist) { this.router.navigate(['/']); return false } else { diff --git a/src/app/guards/inactivity.guard.ts b/src/app/guards/inactivity.guard.ts index 8d7c71dae..59e88cb68 100644 --- a/src/app/guards/inactivity.guard.ts +++ b/src/app/guards/inactivity.guard.ts @@ -16,12 +16,9 @@ export class InactivityGuard implements CanActivate { route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { - if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin) { - // alert('stay set pin') + if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin ) { return true - } else if(SessionStore.exist && !SessionStore.user.Inactivity) { - // alert('stay conform') return true } else { this.router.navigate(['/home/events']); diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index 2d33cb4e3..912061afe 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -6,32 +6,18 @@ import { Component, OnInit, NgZone } from '@angular/core'; import { Event } from '../models/event.model'; import { NotificationsService } from '../services/notifications.service'; import { WebNotificationsService } from '../services/webnotifications.service'; -import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular'; +import { AlertController, Platform } from '@ionic/angular'; import { Router, ActivatedRoute } from '@angular/router'; import { ToDayEventStorage } from '../store/to-day-event-storage.service'; import { DocumentCounterService } from 'src/app/OtherService/document-counter.service' import { PermissionService } from '../OtherService/permission.service'; import { TotalDocumentStore } from '../store/total-document.service'; -import { connection } from '../services/socket/synchro.service'; +import { synchro } from '../services/socket/synchro.service'; import { DespachoService } from '../Rules/despacho.service'; import { ExpedienteGdStore } from '../store/expedientegd-store.service'; import { InativityService } from '../services/inativity.service'; import { SessionStore } from '../store/session.service'; - - - -// import * as Sentry from "@sentry/browser"; -// import { Integrations } from "@sentry/tracing"; - -// Sentry.init({ -// dsn: "https://b374f7c7e09a49adb04197845ded60e9@o927946.ingest.sentry.io/5877459", -// integrations: [new Integrations.BrowserTracing()], - -// // Set tracesSampleRate to 1.0 to capture 100% -// // of transactions for performance monitoring. -// // We recommend adjusting this value in production -// tracesSampleRate: 1.0, -// }); +import { StorageService } from '../services/storage.service'; @Component({ selector: 'app-home', @@ -72,7 +58,7 @@ export class HomePage implements OnInit { postEvent: any; folderId: string; - connection = connection + synchro = synchro constructor( private zone: NgZone, @@ -85,7 +71,8 @@ export class HomePage implements OnInit { public p: PermissionService, public documentCounterService: DocumentCounterService, private despachoRule: DespachoService, - private inativityService: InativityService) { + private inativityService: InativityService, + private storageService: StorageService,) { this.router.events.subscribe((val) => { document.querySelectorAll('ion-modal').forEach((e: any) => e.remove()) @@ -93,8 +80,9 @@ export class HomePage implements OnInit { this.updateList() - + window['platform'] = platform window['inactivity/function'] = () => { + if(window.location.pathname != '/inactivity') { const pathname = window.location.pathname @@ -103,25 +91,18 @@ export class HomePage implements OnInit { } } + var myWorker = new Worker(new URL('./nice.worker.js', import.meta.url) ); - // if (typeof Worker !== 'undefined') { - // // Create a new - // const worker = new Worker(new URL('./nice.worker.ts', import.meta.url)); - // worker.onmessage = ({ data }) => { - // console.log(`page got message: ${data}`); - // }; - // worker.postMessage('hello'); - // } else { - // // Web workers are not supported in this environment. - // // You should add a fallback so that your program still executes correctly. - // } + myWorker.onmessage = function(oEvent) { + console.log('Worker said : ' + oEvent.data); + } + + myWorker.postMessage('ali'); } - refreshing() { - - } + refreshing() {} ngOnInit() { /* this.network.checkNetworkConnection; @@ -137,9 +118,6 @@ export class HomePage implements OnInit { } } - - - mobilefirstConnect() { if(window['WLAuthorizationManager']) { @@ -184,6 +162,10 @@ export class HomePage implements OnInit { } ) + synchro.registerCallback('Notification', (notification)=> { + console.log('notification====== £=======£==========£======', notification) + }, 'any') + } } diff --git a/src/app/home/nice.worker.js b/src/app/home/nice.worker.js new file mode 100644 index 000000000..ce71defff --- /dev/null +++ b/src/app/home/nice.worker.js @@ -0,0 +1,5 @@ +postMessage("I\'m working before postMessage(\'ali\')."); + +onmessage = function(oEvent) { + postMessage('Hi ' + oEvent.data); +}; \ No newline at end of file diff --git a/src/app/home/nice.worker.ts b/src/app/home/nice.worker.ts deleted file mode 100644 index c2275749d..000000000 --- a/src/app/home/nice.worker.ts +++ /dev/null @@ -1,6 +0,0 @@ -// / - -addEventListener('message', ({ data }) => { - const response = `worker response to ${data}`; - //postMessage(response); -}); diff --git a/src/app/modals/create-process/create-process.page.ts b/src/app/modals/create-process/create-process.page.ts index e9e23a859..2b27f0440 100644 --- a/src/app/modals/create-process/create-process.page.ts +++ b/src/app/modals/create-process/create-process.page.ts @@ -546,7 +546,7 @@ export class CreateProcessPage implements OnInit { taskParticipants: this.taskParticipants, taskParticipantsCc: this.taskParticipantsCc }, - cssClass: 'attendee', + cssClass: 'attendee modal-desktop', backdropDismiss: false }); diff --git a/src/app/modals/profile/profile.page.html b/src/app/modals/profile/profile.page.html index 7b55af5c7..326672ecc 100644 --- a/src/app/modals/profile/profile.page.html +++ b/src/app/modals/profile/profile.page.html @@ -28,7 +28,7 @@
- {{notificationdata.length}} novas notificações + {{notificationdata.length}} novas notificações diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts index bd503f4ac..ea97e3808 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -10,6 +10,7 @@ import { EditProfilePage } from './edit-profile/edit-profile.page'; import { JsonStore } from '../../services/jsonStore.service'; import { StorageService } from '../../services/storage.service'; import { NotificationsService } from '../../services/notifications.service'; +import { SessionStore } from 'src/app/store/session.service'; @Component({ selector: 'app-profile', @@ -65,6 +66,8 @@ export class ProfilePage implements OnInit { notImplemented() { } + asyncNotification(){} + async getNotificationData(){ this.storageservice.get("Notifications").then((value) => { console.log("Init get store", value) @@ -201,10 +204,10 @@ export class ProfilePage implements OnInit { } logout() { - window.localStorage.clear(); - + SessionStore.setInativity(false) + setTimeout(() => { - this.router.navigateByUrl('/', { replaceUrl: true }); + this.router.navigate(['/inactivity']); }, 100) } diff --git a/src/app/models/dailyworktask.model.ts b/src/app/models/dailyworktask.model.ts index c57ec15b1..778fff98a 100644 --- a/src/app/models/dailyworktask.model.ts +++ b/src/app/models/dailyworktask.model.ts @@ -67,6 +67,34 @@ export class fullTask { workflowName: string } +export interface fullTaskList { + serialNumber: string; + taskStartDate: string; + workflowDisplayName: string; + activityInstanceName: string; + totalDocuments: number; + workflowInstanceDataFields: { + Subject: string; + Sender: string; + FolderID: number; + DispatchDocId: number; + Status: string; + // all list + ViewerRequest?: any + Remetente?: any + Agenda?: any // event to approve + StartDate?: any // event to approve + EndDate?: any // event to approve + InstanceId?: string // event to approve + Location?: string // event to approve + IsAllDayEvent?: any // event to approve + // pedidos + DocIdDiferimento?: any + // pedidos deferimento // Despacho do Presidente da República + originator?: any + } +} + export class customFullTask { serialNumber: string; taskStartDate: string; diff --git a/src/app/models/event.model.ts b/src/app/models/event.model.ts index 2ce647677..dfa36d7d0 100644 --- a/src/app/models/event.model.ts +++ b/src/app/models/event.model.ts @@ -127,6 +127,7 @@ export interface EventToApproveEdit { MDEmail: string; IsAllDayEvent: boolean; Status: string; + Category: string EventType: string; IsRecurring: boolean; ParticipantsList: ParticipantsList[]; @@ -140,4 +141,59 @@ export interface EventToApproveEdit { InstanceId?: string; } -// ================================================================================ \ No newline at end of file +// // ================================================================================ +// export interface EventToApproveDetails { +// serialNumber: string; +// originator: { +// email: string; +// manager: string; +// displayName: string; +// fqn: string; +// username: string; +// }[] +// actions: string[]; +// activityInstanceName: string; +// workflowInstanceFolio: string; +// taskStartDate: string; +// workflowID: number; +// workflowInstanceID: number; +// workflowName: string; +// workflowDisplayName: string; +// formURL: string; +// workflowInstanceDataFields: { +// Body: string; +// Location: string; +// Subject: string; +// StartDate: string; +// EndDate: string; +// Participants: string; +// CC: string; +// Private: boolean; +// ReviewUserComment: string; +// MDName: string; +// MDEmail: string; +// OriginatorComments: string; +// Agenda: string; +// EventType: string; +// TimeZone: string; +// EventID: string; +// HasAttachments: boolean; +// ParticipantsList: { +// $type?: any; +// EmailAddress: string; +// Name: string; +// IsRequired: boolean; +// }[] +// EventOrganizer: string; +// CreatEvent: string; +// IsAllDayEvent: boolean; +// MDwxUserID: number; +// SerializedItem: string; +// DeserializedItem: string; +// Status: string; +// Message: string; +// InstanceId: string; +// } +// totalDocuments?: any; +// Documents?: any; +// } diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index f6ed35bdb..931a0390b 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -1,7 +1,6 @@ -import { Component, OnInit, ViewChild, Inject, LOCALE_ID, Input } from '@angular/core'; +import { Component, OnInit, ViewChild, Inject, LOCALE_ID } from '@angular/core'; import { CalendarComponent } from 'ionic2-calendar'; import { AlertController, ModalController } from '@ionic/angular'; -import { formatDate } from '@angular/common'; import { EventsService } from 'src/app/services/events.service'; import { Event } from '../../models/event.model'; import { Router, NavigationEnd } from '@angular/router'; diff --git a/src/app/pages/agenda/edit-event/edit-event.page.ts b/src/app/pages/agenda/edit-event/edit-event.page.ts index 346b38167..b6609a129 100644 --- a/src/app/pages/agenda/edit-event/edit-event.page.ts +++ b/src/app/pages/agenda/edit-event/edit-event.page.ts @@ -265,7 +265,7 @@ export class EditEventPage implements OnInit { taskParticipants: this.taskParticipants, taskParticipantsCc: this.taskParticipantsCc }, - cssClass: 'attendee', + cssClass: 'modal attendee modal-desktop', backdropDismiss: false }); @@ -279,8 +279,13 @@ export class EditEventPage implements OnInit { const newAttendees: EventPerson[] = data['taskParticipants']; const newAttendeesCC: EventPerson[] = data['taskParticipantsCc']; - this.setIntervenient(newAttendees); - this.setIntervenientCC(newAttendeesCC); + if(newAttendees.length) { + this.setIntervenient(newAttendees); + } + if(newAttendeesCC) { + this.setIntervenientCC(newAttendeesCC); + } + } }); } diff --git a/src/app/pages/agenda/new-event/new-event.page.ts b/src/app/pages/agenda/new-event/new-event.page.ts index 77d96de29..fb5d5d4e4 100644 --- a/src/app/pages/agenda/new-event/new-event.page.ts +++ b/src/app/pages/agenda/new-event/new-event.page.ts @@ -296,9 +296,9 @@ export class NewEventPage implements OnInit { const modal = await this.modalController.create({ component: AttendeesPageModal, componentProps: { - eventAttendees: this.postEvent.Attendees, adding: this.adding, - taskParticipants: this.taskParticipants + taskParticipants: this.taskParticipants, + taskParticipantsCc: this.taskParticipantsCc }, cssClass: 'attendee modal modal-desktop', backdropDismiss: false @@ -308,19 +308,27 @@ export class NewEventPage implements OnInit { modal.onDidDismiss().then((data) => { - if(data){ + if(data) { data = data['data']; + if(data) { - const newAttendees: EventPerson[] = data['taskParticipants']; - const newAttendeesCC: EventPerson[] = data['taskParticipantsCc']; + const newAttendees: EventPerson[] = data['taskParticipants']; + const newAttendeesCC: EventPerson[] = data['taskParticipantsCc']; + + if(newAttendees.length) { + this.setIntervenient(newAttendees); + } + if(newAttendeesCC) { + this.setIntervenientCC(newAttendeesCC); + } + + } - this.setIntervenient(newAttendees); - this.setIntervenientCC(newAttendeesCC); } }); } - setIntervenient(data){ + setIntervenient(data) { this.taskParticipants = data; this.postEvent.Attendees = data; } @@ -329,7 +337,7 @@ export class NewEventPage implements OnInit { this.taskParticipantsCc = data; } - addParticipants(){ + addParticipants() { this.adding = 'intervenient' this.openAttendees(); } diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index cf21ce7a9..2b6880152 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -5,7 +5,7 @@ import { ContactsPage } from 'src/app/pages/chat/messages/contacts/contacts.page import { AlertService } from 'src/app/services/alert.service'; import { AuthService } from 'src/app/services/auth.service'; import { ChatService } from 'src/app/services/chat.service'; -import { connection } from 'src/app/services/socket/synchro.service'; +import { synchro } from 'src/app/services/socket/synchro.service'; import { ToastService } from 'src/app/services/toast.service'; import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popover/chat-options-popover.page'; import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page'; @@ -33,7 +33,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { members:any; scrollingOnce:boolean = true; - connection = connection; + synchro = synchro; chatMessageStore = ChatMessageStore chatUserStorage = ChatUserStorage @@ -258,7 +258,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { if (res == 502) { // Connection timeout - // happens when the connection was pending for too long + // happens when the synchro was pending for too long // let's reconnect await this.serverLongPull(); } else if (res != 200) { diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.ts b/src/app/pages/gabinete-digital/gabinete-digital.page.ts index e19ec35ec..dccb3d085 100644 --- a/src/app/pages/gabinete-digital/gabinete-digital.page.ts +++ b/src/app/pages/gabinete-digital/gabinete-digital.page.ts @@ -461,7 +461,10 @@ export class GabineteDigitalPage implements OnInit, DoCheck { let despachos = await this.despachoRule.getList({updateStore: true}) - this.despachoStore.reset(despachos) + if(despachos) { + this.despachoStore.reset(despachos) + } + let pareceres = await this.processesbackend.GetTasksList("Pedido de Parecer", false).toPromise(); let pareceresPr = await this.processesbackend.GetTasksList("Pedido de Parecer do Presidente", false).toPromise(); diff --git a/src/app/pages/inactivity/inactivity.page.ts b/src/app/pages/inactivity/inactivity.page.ts index f573ce7fa..bcccf0249 100644 --- a/src/app/pages/inactivity/inactivity.page.ts +++ b/src/app/pages/inactivity/inactivity.page.ts @@ -79,10 +79,12 @@ export class InactivityPage implements OnInit { await this.authService.SetSession(attempt, this.userattempt); await this.authService.loginChat(this.userattempt); await this.getToken(); + SessionStore.setInativity(true) this.goback() } else { SessionStore.delete() + window.localStorage.clear(); await this.authService.SetSession(attempt, this.userattempt); } diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index eacaad6d2..ee388ca95 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -6,7 +6,6 @@ import { ToastService } from 'src/app/services/toast.service'; import { environment } from 'src/environments/environment'; import { AlertController } from '@ionic/angular'; import { NotificationsService } from 'src/app/services/notifications.service'; -import crypto from 'crypto-js' import { LocalstoreService } from 'src/app/store/localstore.service'; import { SessionStore } from 'src/app/store/session.service'; @@ -40,7 +39,6 @@ export class LoginPage implements OnInit { ngOnInit() { - let userData = this.sessionStore.user const loginPreference = userData?.LoginPreference diff --git a/src/app/services/network.service.ts b/src/app/services/network.service.ts deleted file mode 100644 index 78b32ba50..000000000 --- a/src/app/services/network.service.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Network } from '@ionic-native/network/ngx'; -import { Platform } from '@ionic/angular'; -import { fromEvent, merge, of, Observable } from 'rxjs'; -import { mapTo } from 'rxjs/operators'; - -@Injectable({ - providedIn: 'root' -}) -export class NetworkService { - - constructor( - private network: Network) { } - - checkNetworkConnection(){ - this.network.onConnect().subscribe((value) => { - - document.body.style.setProperty(`--color`, "#0782C9"); - - console.log('network connected!',value); - }); - } - - checkNetworkDisconnection(){ - this.network.onDisconnect().subscribe((value) => { - document.body.style.setProperty(`--color`, "#eeeb30"); - console.log('network was disconnected :-('),value; - - }); - } -} \ No newline at end of file diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index 57df9a5e7..6f7301aac 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -13,6 +13,7 @@ import { NavigationExtras,Router } from '@angular/router'; import { ToastService } from '../services/toast.service'; import { Optional } from '@angular/core'; import { JsonStore } from './jsonStore.service'; +import { synchro } from './socket/synchro.service'; @Injectable({ providedIn: 'root' @@ -39,15 +40,17 @@ export class NotificationsService { private toastService: ToastService, private zone: NgZone, private activeroute: ActivatedRoute, - private jsonstore: JsonStore) { + private jsonstore: JsonStore) { } + registerCallback(type: string, funx: Function, object: any = {} ) { + + this.callbacks.push({type, funx}) + if(!object.hasOwnProperty('desktop') && object['desktop'] != false) { + synchro.registerCallback('Notification',funx, type) + } + } - - registerCallback(type: string, funx: Function ) { - this.callbacks.push({type, funx}) - } - getTokenByUserIdAndId(user, userID) { const geturl = environment.apiURL + 'notifications/user/' + userID; @@ -168,9 +171,13 @@ export class NotificationsService { console.log('Push notification recived: failure ' + error.responseText); console.log(JSON.stringify(error)); } - ); + ) + } else { + console.log('not called') } - } + } else { + console.log('not called') + } } @@ -216,6 +223,9 @@ export class NotificationsService { console.log(message); var data = JSON.parse(message.payload); + + synchro.$send(data) + console.log('data.Service', data.Service); // module console.log('data.IdObject', data.IdObject); // Object id console.log('data.Object', data.Object); // details diff --git a/src/app/services/network.service.spec.ts b/src/app/services/object-query.service.spec.ts similarity index 50% rename from src/app/services/network.service.spec.ts rename to src/app/services/object-query.service.spec.ts index 2c8c63926..899a5ee75 100644 --- a/src/app/services/network.service.spec.ts +++ b/src/app/services/object-query.service.spec.ts @@ -1,16 +1,16 @@ import { TestBed } from '@angular/core/testing'; -import { NetworkService } from './network.service'; +import { ObjectQueryService } from './object-query.service'; -describe('NavigationService', () => { - let service: NetworkService; +describe('ObjectQueryService', () => { + let service: ObjectQueryService; beforeEach(() => { TestBed.configureTestingModule({}); - service = TestBed.inject(NetworkService); + service = TestBed.inject(ObjectQueryService); }); it('should be created', () => { expect(service).toBeTruthy(); }); -}); \ No newline at end of file +}); diff --git a/src/app/services/object-query.service.ts b/src/app/services/object-query.service.ts new file mode 100644 index 000000000..922ea0349 --- /dev/null +++ b/src/app/services/object-query.service.ts @@ -0,0 +1,60 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class ObjectQueryService { + + data : any[] = [] + save: Function = () =>{} + + constructor() {} + + Update(select:Function, update:Function, data: any[] = this.data ) { + + let changes = 0 + + data.forEach((e)=> { + if(select(e)) { + changes++ + update(e) + } + + }) + + if(changes != 0) { + this.save() + } + } + + select(select:Function, data: any[] = this.data ) { + return data.filter((e)=>{ + return select(e) + }) + } + + Delete(select:Function, data: any[] = this.data) { + + let changes = 0 + + data.forEach((e, index)=>{ + if(select(e)) { + if (index > -1) { + changes++ + data.splice(index, 1); + } + } + }) + + if(changes != 0) this.save() + } + + Insert(inert:any, data: any[] = this.data ) { + data.push(inert) + } + + print() { + console.log(this.data) + } + +} diff --git a/src/app/services/processes.service.ts b/src/app/services/processes.service.ts index eb640891e..f84e7e025 100644 --- a/src/app/services/processes.service.ts +++ b/src/app/services/processes.service.ts @@ -8,6 +8,7 @@ import { DocumentSetUpMeeting } from '../models/CallMeeting'; import { Excludetask } from '../models/Excludetask'; import { ExpedienteFullTask } from '../models/Expediente'; import { GetTasksListType } from '../models/GetTasksListType'; +import { fullTaskList } from '../models/dailyworktask.model'; @Injectable({ providedIn: 'root' @@ -24,7 +25,7 @@ export class ProcessesService { this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey); } - GetTasksList(processname: typeof GetTasksListType, onlycount:boolean): Observable + GetTasksList(processname: typeof GetTasksListType, onlycount:boolean): Observable { const geturl = environment.apiURL + 'tasks/List'; let params = new HttpParams(); @@ -37,7 +38,7 @@ export class ProcessesService { params: params }; - return this.http.get(`${geturl}`, options); + return this.http.get(`${geturl}`, options); } GetTaskListExpediente(onlycount1): Observable { diff --git a/src/app/services/socket/synchro.service.ts b/src/app/services/socket/synchro.service.ts index 70383bdb7..8d9d4fbf6 100644 --- a/src/app/services/socket/synchro.service.ts +++ b/src/app/services/socket/synchro.service.ts @@ -1,6 +1,8 @@ import { Injectable } from '@angular/core'; +import { SessionStore } from 'src/app/store/session.service'; import { v4 as uuidv4 } from 'uuid' import { BackgroundService } from '../background.service'; +import { environment } from 'src/environments/environment'; export interface wss{ @@ -17,7 +19,7 @@ export interface wss{ @Injectable({ providedIn: 'root' }) -export class SynchroService { +class SynchroService { [x: string]: any; private connection!: WebSocket; @@ -27,10 +29,12 @@ export class SynchroService { callback = function(){} private _connected = false; private BackgroundService = new BackgroundService() - private callBacks: { - type: 'Offline' | 'Online' + callBacks: { + type: 'Offline' | 'Online' | 'Onmessage' | 'Chat' | 'Notification' | 'Notifications' | '', + object?: string funx: Function }[] = [] + private msgQueue = [] constructor(){} @@ -55,10 +59,11 @@ export class SynchroService { this.url = `${wss.url}${wss.header.id}/${wss.header.jwt}/${wss.header.bluePrint}/${this.id}/` } - registerCallback(type: 'Offline' | 'Online', funx: Function) { + registerCallback(type: 'Offline' | 'Online' | 'Onmessage' | 'Chat' | 'Notifications' | 'Notification', funx: Function, object='') { this.callBacks.push({ type, - funx + funx, + object }) } @@ -85,22 +90,72 @@ export class SynchroService { console.log('open ======================= welcome to socket server') this._connected = true + // send all saved data due to internet connection + this.msgQueue.forEach((item, index, object) => { + this.$send(item); + object.splice(index, 1); + }) + } public $send(object: any) { - let message = { - message: '{"person.adress.country":"1Angola"}', - username: '', - idConnection: this.id + if(!this._connected) { // save data to send when back online + this.msgQueue.push(object) } - let sendData = JSON.stringify(Object.assign({}, message)); + let payload = { + message: JSON.stringify(object) || '{"person.adress.country":"1Angola"}', + username: SessionStore.user.FullName, + idConnection: this.id + } + + + let sendData = JSON.stringify(payload); + console.log(sendData) this.connection.send(sendData); } private onmessage = async (event: any)=> { + + + let data = JSON.parse(event.data) + let payload = JSON.parse(data.message) + payload.message = JSON.parse(payload.message) + const idConnection = payload.idConnection + const username = payload.username + + if(idConnection != this.id ) { + + if(window['platform'].is('desktop') || this.platform.is('mobileweb')) {} + else return false + if(environment.production) return false + + this.callBacks.forEach((e)=> { + + if(payload.message[0]) { + if(payload.message[0].Service && payload.message[0].Object && payload.message[0].IdObject) { + if(e.type == '' && !e.object) { + if(username == SessionStore.user.FullName) { + e.funx(payload.message, data) + } + } + + if(e.type == 'Notifications' ) { + e.funx(payload.message, data) + } + + } + } else if(payload.message.Service && payload.message.Object && payload.message.IdObject) { + if(e.type == 'Notification' && e.object == payload.message.Object || e.type == 'Notification' && e.object == 'any' ) { + e.funx(payload.message, data) + } + } + + }) + + } this.callback() } @@ -137,7 +192,8 @@ export class SynchroService { } -export const connection = new SynchroService() -connection.setUrl() -connection.connect() +export const synchro = new SynchroService() +synchro.setUrl() +synchro.connect() +window['synchro'] = synchro \ No newline at end of file diff --git a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.html b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.html index e78d25b29..22078a985 100644 --- a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.html +++ b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.html @@ -87,6 +87,48 @@ +
+
+
+ +
+
+ + + Reunião + Viagem + Conferência + Encontro + + + + + + + + Reunião + + + Viagem + + + Conferência + + + Encontro + + + + + +
+
+
+
diff --git a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts index 9d979c58b..0f85c7b4e 100644 --- a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts +++ b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts @@ -72,6 +72,7 @@ export class EditEventToApprovePage implements OnInit { workflowInstanceDataFields:{ Body: "", OccurrenceType: '', + Category: '', LastOccurrence: '', IsRecurring: false, ParticipantsList: [], @@ -146,7 +147,7 @@ export class EditEventToApprovePage implements OnInit { async getTask() { - this.processes.GetTask(this.serialNumber).subscribe( result =>{ + this.processes.GetTask(this.serialNumber).subscribe( (result) =>{ this.eventProcess = result this.restoreDatepickerData() @@ -302,6 +303,7 @@ export class EditEventToApprovePage implements OnInit { LastOccurrence: this.eventProcess.workflowInstanceDataFields.LastOccurrence, }, ParticipantsList: this.eventProcess.workflowInstanceDataFields.ParticipantsList, + Category: this.eventProcess.workflowInstanceDataFields.Category } try { diff --git a/src/app/shared/agenda/edit-event/edit-event.page.html b/src/app/shared/agenda/edit-event/edit-event.page.html index bea2a9c55..1c7c50fc6 100644 --- a/src/app/shared/agenda/edit-event/edit-event.page.html +++ b/src/app/shared/agenda/edit-event/edit-event.page.html @@ -55,7 +55,7 @@
- + 123123
diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index fe12f9d27..d3d9c75a3 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -8,7 +8,7 @@ import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popo import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page'; import { ContactsPage } from '../new-group/contacts/contacts.page'; import { Router } from '@angular/router'; -import { connection } from 'src/app/services/socket/synchro.service'; +import { synchro } from 'src/app/services/socket/synchro.service'; import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/chat-options-features.page'; import { ChatMessageStore } from 'src/app/store/chat/chat-message.service'; import { ChatUserStorage } from 'src/app/store/chat/chat-user.service'; @@ -39,7 +39,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy @Output() openNewEventPage:EventEmitter = new EventEmitter(); - connection = connection; + synchro = synchro; chatMessageStore = ChatMessageStore chatUserStorage = ChatUserStorage @@ -152,7 +152,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy sendMessage() { - this.connection.$send({}) + this.synchro.$send({}) let body = { "message": diff --git a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html index 2c3d99fac..b20c12395 100644 --- a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html +++ b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html @@ -68,6 +68,49 @@
+ +
+
+
+ +
+
+ + + Reunião + Viagem + Conferência + Encontro + + + + + + + + Reunião + + + Viagem + + + Conferência + + + Encontro + + + + + +
+
+
+
diff --git a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts index 2fe029dd4..49cc677c1 100644 --- a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts +++ b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts @@ -68,6 +68,7 @@ export class EditEventToApproveComponent implements OnInit { workflowInstanceDataFields:{ Body: "", OccurrenceType: '', + Category: '', LastOccurrence: '', ParticipantsList: [], Agenda: '', @@ -132,41 +133,42 @@ export class EditEventToApproveComponent implements OnInit { async getTask() { const result = await this.processes.GetTask(this.serialNumber).toPromise(); - console.log(result); + console.log(result); this.eventProcess = result + this.eventProcess.workflowInstanceDataFields.Category = result.workflowInstanceDataFields.EventType - this.startDate = new Date(this.eventProcess.workflowInstanceDataFields.StartDate); - this.endDate = new Date(this.eventProcess.workflowInstanceDataFields.EndDate); + this.startDate = new Date(this.eventProcess.workflowInstanceDataFields.StartDate); + this.endDate = new Date(this.eventProcess.workflowInstanceDataFields.EndDate); - // description - let body : any =this.eventProcess.workflowInstanceDataFields.Body.replace(/<[^>]+>/g, '') - this.eventProcess.workflowInstanceDataFields.Body = body - this.Location = this.eventProcess.workflowInstanceDataFields.Location + // description + let body : any =this.eventProcess.workflowInstanceDataFields.Body.replace(/<[^>]+>/g, '') + this.eventProcess.workflowInstanceDataFields.Body = body + this.Location = this.eventProcess.workflowInstanceDataFields.Location - this.InstanceId = this.eventProcess.workflowInstanceDataFields.InstanceId - try { - this.getAttachments() + this.InstanceId = this.eventProcess.workflowInstanceDataFields.InstanceId + try { + this.getAttachments() - } catch (error) { + } catch (error) { + } + + + if(this.eventProcess.workflowInstanceDataFields.IsRecurring == false) { + this.isRecurring = "Não se repete"; + } + else { + this.isRecurring = "Repete"; + } + + this.eventProcess.workflowInstanceDataFields.ParticipantsList.forEach(e => { + if(e.IsRequired) { + this.taskParticipants.push(e); + } else { + this.taskParticipantsCc.push(e); } - - - if(this.eventProcess.workflowInstanceDataFields.IsRecurring == false) { - this.isRecurring = "Não se repete"; - } - else { - this.isRecurring = "Repete"; - } - - this.eventProcess.workflowInstanceDataFields.ParticipantsList.forEach(e => { - if(e.IsRequired) { - this.taskParticipants.push(e); - } else { - this.taskParticipantsCc.push(e); - } - }) + }) /* }) */ } @@ -254,6 +256,7 @@ export class EditEventToApproveComponent implements OnInit { LastOccurrence: this.eventProcess.workflowInstanceDataFields.LastOccurrence, }, ParticipantsList: this.eventProcess.workflowInstanceDataFields.ParticipantsList, + Category: this.eventProcess.workflowInstanceDataFields.Category } console.log(event); @@ -307,14 +310,19 @@ export class EditEventToApproveComponent implements OnInit { modal.onDidDismiss().then((data) => { - if(data){ + if(data) { data = data['data']; const newAttendees: EventPerson[] = data['taskParticipants']; const newAttendeesCC: EventPerson[] = data['taskParticipantsCc']; - this.setIntervenient(newAttendees); - this.setIntervenientCC(newAttendeesCC); + if(newAttendees.length) { + this.setIntervenient(newAttendees); + } + if(newAttendeesCC) { + this.setIntervenientCC(newAttendeesCC); + } + } }); } else { diff --git a/src/app/shared/header/header.page.html b/src/app/shared/header/header.page.html index 789ba42ad..9bf6ef370 100644 --- a/src/app/shared/header/header.page.html +++ b/src/app/shared/header/header.page.html @@ -77,8 +77,14 @@
+ - {{profileLabel(loggeduser.Profile)}} + +
+ {{profileLabel(loggeduser.Profile)}} +
{{this.notificationLength}}
+
+
diff --git a/src/app/shared/header/header.page.ts b/src/app/shared/header/header.page.ts index c935f1c4b..c7aad3f17 100644 --- a/src/app/shared/header/header.page.ts +++ b/src/app/shared/header/header.page.ts @@ -7,6 +7,7 @@ import { ProfilePage } from 'src/app/modals/profile/profile.page'; import { StorageService } from '../../services/storage.service'; import { SessionStore } from 'src/app/store/session.service'; import { NotificationsService } from '../../services/notifications.service'; +import { environment } from 'src/environments/environment'; @Component({ selector: 'app-header', @@ -24,6 +25,8 @@ export class HeaderPage implements OnInit { notificationLength: 0; SessionStore = SessionStore + production = environment.production + constructor( private router: Router, private modalController: ModalController, @@ -46,8 +49,6 @@ export class HeaderPage implements OnInit { } else { this.UpdateNotificationCount(); } - - } @@ -154,7 +155,8 @@ export class HeaderPage implements OnInit { componentProps: { } }); - return await modal.present(); + await modal.present(); + } async dynamicSearch() { diff --git a/src/app/shared/headers/header-no-search/profile/profile.page.ts b/src/app/shared/headers/header-no-search/profile/profile.page.ts index cf56e9814..6a2a5029c 100644 --- a/src/app/shared/headers/header-no-search/profile/profile.page.ts +++ b/src/app/shared/headers/header-no-search/profile/profile.page.ts @@ -26,7 +26,7 @@ export class ProfileComponent implements OnInit { this.loggeduser = authService.ValidatedUser; - console.log(this.loggeduser.RoleDescription) + // console.log(this.loggeduser.RoleDescription) this.checkState() } diff --git a/src/app/store/despacho-store.service.ts b/src/app/store/despacho-store.service.ts index 9d3c9bb17..1cd097920 100644 --- a/src/app/store/despacho-store.service.ts +++ b/src/app/store/despacho-store.service.ts @@ -1,7 +1,8 @@ import { Injectable } from '@angular/core'; import { localstoreService } from './localstore.service' -import { AES, enc, SHA1 } from 'crypto-js' +import { SHA1 } from 'crypto-js' import { customTask } from '../models/dailyworktask.model'; +import { ObjectQueryService } from '../services/object-query.service'; @Injectable({ providedIn: 'root' @@ -14,20 +15,85 @@ export class DespachoStoreService { private keyName: string; private _count = 0 + ObjectQueryService = new ObjectQueryService() + constructor() { this.keyName = (SHA1(this.constructor.name+ 'home/eventSource')).toString() - - + window['ObjectQueryService'] = this.Query() + setTimeout(()=>{ let restore = localstoreService.get(this.keyName, {}) this._list = restore.list || [] this._count = parseInt(restore.count) || 0 }, 10) + + setTimeout(()=>{ + + // this.Query().Update( + // (select:customTask): boolean => select.Folio == 'Formação', + // (update:customTask) => update.Folio = 'Formação 5' + // ) + + // this.Query().Update( + // (select:customTask): boolean => select.Folio == 'Formação', + // (update:customTask) => { + // update.Folio = 'Formação 7'; + // update.DocumentURL = 'peter'; + // } + // ) + + // this.Query().Update( + // (select:customTask): boolean => select.Folio == 'Formação', + // (update:customTask): customTask => ({ + // CreateDate: '', + // DocId: 0, + // DocumentURL: '', + // DocumentsQty: '', + // FolderID: 0, + // Folio:' ', + // Remetente: '', + // Senders: '', + // SerialNumber: '', + // Status: '', + // WorkflowName: '', + // activityInstanceName: '' + // }) + // ) + + // this.Query().Delete( + // (select: customTask): boolean => select.DocId == 3 && select.DocId >= 1 + // ) + + }, 5000) + } - get list() { + Query() { + return { + Update: (select:Function, update:Function) => { + this.ObjectQueryService.Update(select, update, this._list ) + this.save({dynamicCount : true}) + }, + select: (select) => { + this.ObjectQueryService.select(select, this._list ) + this.save({dynamicCount : true}) + }, + Delete : (select) => { + this.ObjectQueryService.Delete(select, this._list ) + this.save({dynamicCount : true}) + }, + Insert: (insert: customTask | customTask[]) =>{ + this.ObjectQueryService.Insert(insert, this._list) + this.save({dynamicCount : true}) + } + } + } + + ObjectQuery() {} + + get list(): customTask[] { return this._list || [] } @@ -37,17 +103,20 @@ export class DespachoStoreService { set count(value: number) { this._count = value - this.save() + this.save({}) } reset(eventsList: any) { this._list = eventsList - - this.count = this._list.length - this.save() + this.save({dynamicCount:true}) } - private save() { + private save = ({dynamicCount = false})=> { + + if(dynamicCount) { + this._count = this._list.length + } + setTimeout(()=>{ localstoreService.set(this.keyName,{ list: this._list, diff --git a/src/app/store/session.service.ts b/src/app/store/session.service.ts index de3dc3fe5..d2e8f225e 100644 --- a/src/app/store/session.service.ts +++ b/src/app/store/session.service.ts @@ -13,7 +13,6 @@ class SessionService { private _user = new UserSession() // local storage keyName private keyName: string; - private _needTovalidateUser = false constructor() { @@ -53,7 +52,7 @@ class SessionService { return this._user.PIN == SHA1(pin).toString() } - needTovalidateUser() { + needToValidateUser() { return this._user.Inactivity } @@ -73,6 +72,7 @@ class SessionService { return false } return this._user.PIN.length >= 2 + } reset(user) { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 57c4335c5..c34c5fe3b 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -10,7 +10,7 @@ export const environment = { /* apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/', */ domain: 'gabinetedigital.local', //gabinetedigital.local defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto paulo.pinto@gabinetedigital.local - defaultuserpwd: 'tabteste@006' //tabteste@006 + defaultuserpwd: 'tabteste@006', //tabteste@006, }; /*