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..ea87df0d3 100644 --- a/src/app/guards/inactivity.guard.ts +++ b/src/app/guards/inactivity.guard.ts @@ -16,6 +16,8 @@ export class InactivityGuard implements CanActivate { route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + alert(SessionStore.exist +' '+SessionStore.user.Inactivity + ' '+ !SessionStore.hasPin) + if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin) { // alert('stay set pin') return true diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index 2d33cb4e3..2961bff97 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,7 +80,7 @@ export class HomePage implements OnInit { this.updateList() - + window['platform'] = platform window['inactivity/function'] = () => { if(window.location.pathname != '/inactivity') { @@ -103,25 +90,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 +117,6 @@ export class HomePage implements OnInit { } } - - - mobilefirstConnect() { if(window['WLAuthorizationManager']) { @@ -178,12 +155,16 @@ export class HomePage implements OnInit { updateList() { this.notificationsService.registerCallback( - 'despachos', + 'any', () => { this.despachoRule.getList({updateStore: true}) } ) + synchro.registerCallback('Notification', (DataArray)=> { + alert('nice') + }, '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/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 0764e07fc..f438c36fb 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -65,6 +65,8 @@ export class ProfilePage implements OnInit { notImplemented() { } + asyncNotification(){} + async getNotificationData(){ this.storageservice.get("Notifications").then((value) => { console.log("Init get store", value) 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/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/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/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/notifications.service.ts b/src/app/services/notifications.service.ts index 924242563..cdb2fafd7 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; @@ -216,6 +219,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/object-query.service.spec.ts b/src/app/services/object-query.service.spec.ts new file mode 100644 index 000000000..899a5ee75 --- /dev/null +++ b/src/app/services/object-query.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ObjectQueryService } from './object-query.service'; + +describe('ObjectQueryService', () => { + let service: ObjectQueryService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ObjectQueryService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); 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/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/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 19172c015..2ee6ef65d 100644 --- a/src/app/shared/header/header.page.ts +++ b/src/app/shared/header/header.page.ts @@ -6,6 +6,7 @@ import { LoginUserRespose } from 'src/app/models/user.model'; import { ProfilePage } from 'src/app/modals/profile/profile.page'; import { StorageService } from '../../services/storage.service'; import { SessionStore } from 'src/app/store/session.service'; +import { environment } from 'src/environments/environment'; @Component({ selector: 'app-header', @@ -23,6 +24,8 @@ export class HeaderPage implements OnInit { notificationLength: 0; SessionStore = SessionStore + production = environment.production + constructor( private router: Router, private modalController: ModalController, 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..9ea6d00f0 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 } 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, }; /*