mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
97 lines
2.3 KiB
TypeScript
97 lines
2.3 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { localstoreService } from './localstore.service'
|
|
import { AES, enc, SHA1 } from 'crypto-js'
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class PedidosStoreService {
|
|
|
|
private _listParecer: Event[] = []
|
|
private _listDeferimento: Event[] = []
|
|
// local storage keyName
|
|
private keyNameparecer: string;
|
|
private keyNamedeferiemnto: string;
|
|
private _countparecer = 0
|
|
private _countDeferiemnto = 0
|
|
|
|
constructor() {
|
|
|
|
this.keyNameparecer = (SHA1("PedidosStoreService"+"parecer")).toString()
|
|
this.keyNamedeferiemnto = (SHA1("PedidosStoreService"+"deferimneto")).toString()
|
|
|
|
setTimeout(()=>{
|
|
let restoreParecer = localstoreService.get(this.keyNameparecer, {})
|
|
let restoreDeferimento = localstoreService.get(this.keyNamedeferiemnto, {})
|
|
|
|
this._listParecer = restoreDeferimento.listDeferimento || []
|
|
this._listDeferimento = restoreParecer.listParecer || []
|
|
this._countparecer = parseInt(restoreParecer.count) || 0
|
|
this._countDeferiemnto = parseInt(restoreDeferimento.count) || 0
|
|
|
|
}, 10)
|
|
|
|
}
|
|
|
|
get listparecer(): any[] {
|
|
return this._listParecer || []
|
|
}
|
|
|
|
get listdeferimento(): any[] {
|
|
return this._listDeferimento || []
|
|
}
|
|
|
|
get countparecer() {
|
|
return this._countparecer || 0
|
|
}
|
|
set countparecer(value: number) {
|
|
this._countparecer = value
|
|
this.saveParecer()
|
|
}
|
|
|
|
get countdeferimento() {
|
|
return this._countDeferiemnto || 0
|
|
}
|
|
set countdeferimento(value: number ) {
|
|
this._countDeferiemnto = value
|
|
this.saveDeferimento()
|
|
}
|
|
|
|
resetparecer(eventsList: any) {
|
|
this._listParecer = eventsList
|
|
|
|
this.countparecer = this._listParecer.length
|
|
this.saveDeferimento()
|
|
}
|
|
|
|
resetdeferimento(list: any) {
|
|
this._listDeferimento = list
|
|
|
|
this.countdeferimento =this._listDeferimento.length
|
|
this.saveParecer()
|
|
}
|
|
|
|
private saveParecer() {
|
|
setTimeout(()=>{
|
|
localstoreService.set(this.keyNameparecer,{
|
|
listParecer: this._listParecer,
|
|
count: this._countparecer,
|
|
})
|
|
}, 10)
|
|
|
|
}
|
|
|
|
private saveDeferimento() {
|
|
setTimeout(()=>{
|
|
localstoreService.set(this.keyNamedeferiemnto,{
|
|
listDeferimento: this._listParecer,
|
|
count: this._countDeferiemnto,
|
|
})
|
|
}, 10)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export const PedidosStore = new PedidosStoreService()
|