mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
add synchro
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user