2021-08-18 18:31:35 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { localstoreService } from './localstore.service'
|
|
|
|
|
import { AES, enc, SHA1 } from 'crypto-js'
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
|
|
|
|
export class TotalDocumentService {
|
|
|
|
|
|
|
|
|
|
private _count = 0
|
|
|
|
|
// local storage keyName
|
|
|
|
|
private keyName: string;
|
|
|
|
|
|
|
|
|
|
constructor() {
|
2023-01-12 15:27:09 +01:00
|
|
|
this.keyName = (SHA1("TotalDocumentService")).toString()
|
2021-08-18 18:31:35 +01:00
|
|
|
|
|
|
|
|
setTimeout(()=> {
|
|
|
|
|
let restore = localstoreService.get(this.keyName, {})
|
|
|
|
|
this._count = restore.count || 0
|
|
|
|
|
}, 10)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get count() {
|
|
|
|
|
return this._count
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetCount(value) {
|
|
|
|
|
this._count = value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveCount() {
|
|
|
|
|
setTimeout(()=> {
|
|
|
|
|
localstoreService.set(this.keyName, {
|
|
|
|
|
count: this._count
|
|
|
|
|
})
|
|
|
|
|
}, 10)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export let TotalDocumentStore = new TotalDocumentService()
|