Files
doneit-web/src/app/store/deplomas.service.ts
T

172 lines
4.6 KiB
TypeScript
Raw Normal View History

2021-08-18 12:05:27 +01:00
import { Injectable } from '@angular/core';
import { localstoreService } from './localstore.service'
import { AES, enc, SHA1 } from 'crypto-js'
@Injectable({
providedIn: 'root'
})
export class DeplomasService {
private _diplomasAssinadoList = []
2021-08-24 16:32:10 +01:00
private _diplomasReviewList = []
2022-06-21 16:59:28 +01:00
private _diplomasGerarList = []
private _diplomasParaAssinar = []
2021-08-18 12:05:27 +01:00
private keyNameDiplomasAssinado: string;
2022-06-21 16:59:28 +01:00
private keyNameDiplomasParaAssinar: string;
private keyNameDiplomasGerar: string;
private keyNameDiplomasReview: string;
2021-08-18 12:05:27 +01:00
private _diplomasAssinadoListCount = 0
2021-08-24 16:32:10 +01:00
private _diplomasReviewCount = 0
2022-06-21 16:59:28 +01:00
private _diplomasGerarListCount = 0;
private _diplomasListCount = 0;
2021-08-18 12:05:27 +01:00
2022-06-21 16:59:28 +01:00
constructor() {
2021-08-18 12:05:27 +01:00
this.keyNameDiplomasAssinado = (SHA1(this.constructor.name+"diplomasAssinado")).toString()
2022-06-21 16:59:28 +01:00
this.keyNameDiplomasReview = (SHA1(this.constructor.name+"diplomasReview")).toString()
this.keyNameDiplomasGerar = (SHA1(this.constructor.name+"diplomasGerar")).toString()
this.keyNameDiplomasParaAssinar = (SHA1(this.constructor.name+"diplomasParaAsinar")).toString()
2021-08-18 12:05:27 +01:00
2022-06-21 16:59:28 +01:00
setTimeout(() => {
2021-08-18 12:05:27 +01:00
let restoreDiplomasAssinado = localstoreService.get(this.keyNameDiplomasAssinado, {})
2022-06-21 16:59:28 +01:00
let restoreDiplomasParaAssinar = localstoreService.get(this.keyNameDiplomasParaAssinar, {})
let restoreDiplomasReviewList = localstoreService.get(this.keyNameDiplomasReview, {})
let restoreDiplomasGerarList = localstoreService.get(this.keyNameDiplomasGerar, {})
2021-08-18 12:05:27 +01:00
this._diplomasAssinadoList = restoreDiplomasAssinado.list || []
this._diplomasAssinadoListCount = parseInt(restoreDiplomasAssinado.count) || 0
2022-06-21 16:59:28 +01:00
this._diplomasParaAssinar = restoreDiplomasParaAssinar.list || []
this._diplomasListCount = parseInt(restoreDiplomasParaAssinar.count) || 0
2021-08-24 16:32:10 +01:00
this._diplomasReviewList = restoreDiplomasReviewList.list || []
this._diplomasReviewCount = parseInt(restoreDiplomasReviewList.count) || 0
2022-06-21 16:59:28 +01:00
this._diplomasGerarList = restoreDiplomasGerarList.list || []
this._diplomasGerarListCount = parseInt(restoreDiplomasGerarList.count) || 0
2021-08-18 12:05:27 +01:00
}, 10)
}
2021-08-24 16:32:10 +01:00
get deplomasReviewCount() {
return this._diplomasReviewCount
}
set deplomasReviewCount(arg: number) {
this._diplomasReviewCount = arg
2021-08-25 15:23:30 +01:00
this.saveDiplomasReviewList()
2021-08-24 16:32:10 +01:00
}
get countDiplomasAssinadoListCount() {
2021-08-18 12:05:27 +01:00
return this._diplomasAssinadoListCount || 0
}
set countDiplomasListCount(value) {
this._diplomasAssinadoListCount = value
this.saveDiplomasAssinadoList()
}
2022-06-21 16:59:28 +01:00
get diplomasParaAssinartCount() {
2021-08-18 12:05:27 +01:00
return this._diplomasListCount || 0
}
2022-06-21 16:59:28 +01:00
set diplomasParaAssinarCount(value) {
this._diplomasParaAssinar = value
this.saveDiplomasParaAssinar()
2021-08-18 12:05:27 +01:00
}
2022-06-21 16:59:28 +01:00
// get list
get diplomasParaAssinarList() {
return this._diplomasParaAssinar
2021-08-18 12:05:27 +01:00
}
2021-08-24 16:32:10 +01:00
2022-06-21 16:59:28 +01:00
// get list
2021-08-18 12:05:27 +01:00
get diplomasAssinadoList() {
return this._diplomasAssinadoList
}
2022-06-21 16:59:28 +01:00
// get list
get diplomasReviewList() {
return this._diplomasReviewList
}
2022-06-22 15:59:21 +01:00
// get list
get DiplomaGerarList() {
return this._diplomasGerarList
}
2021-08-18 12:05:27 +01:00
resetDiplomasAssinadoList(value: any[]) {
this._diplomasAssinadoListCount = value.length
this._diplomasAssinadoList = value
this.saveDiplomasAssinadoList()
}
2022-06-21 16:59:28 +01:00
resetDiplomasParaAssinar(value: any[]) {
2021-08-18 12:05:27 +01:00
this._diplomasListCount = value.length
2022-06-21 16:59:28 +01:00
this._diplomasParaAssinar = value
this.saveDiplomasParaAssinar()
2021-08-18 12:05:27 +01:00
}
2021-08-24 16:32:10 +01:00
resetDiplomasReview(value: any[]) {
this._diplomasReviewList =value
this._diplomasReviewCount = value.length
this.saveDiplomasReviewList()
}
2022-06-21 16:59:28 +01:00
resetDiplomaGerar(value: any[]) {
this._diplomasGerarListCount = value.length
this._diplomasGerarList = value
this.savetDiplomaGerar()
}
2021-08-24 16:32:10 +01:00
private saveDiplomasReviewList () {
setTimeout(()=>{
2022-06-21 16:59:28 +01:00
localstoreService.set(this.keyNameDiplomasReview,{
2021-08-24 16:32:10 +01:00
list: this._diplomasReviewList,
count: this._diplomasReviewCount,
})
}, 10)
}
private saveDiplomasAssinadoList() {
2021-08-18 18:31:35 +01:00
2021-08-18 12:05:27 +01:00
setTimeout(()=>{
localstoreService.set(this.keyNameDiplomasAssinado,{
list: this._diplomasAssinadoList,
count: this._diplomasAssinadoListCount,
})
}, 10)
}
2022-06-21 16:59:28 +01:00
private saveDiplomasParaAssinar () {
2021-08-18 12:05:27 +01:00
setTimeout(()=>{
2022-06-21 16:59:28 +01:00
localstoreService.set(this.keyNameDiplomasParaAssinar,{
list: this._diplomasParaAssinar,
2021-08-18 12:05:27 +01:00
count: this._diplomasListCount,
})
}, 10)
}
2022-06-21 16:59:28 +01:00
private savetDiplomaGerar() {
setTimeout(()=>{
localstoreService.set(this.keyNameDiplomasGerar,{
list: this._diplomasGerarList,
count: this._diplomasGerarListCount,
})
}, 10)
}
2021-08-18 12:05:27 +01:00
}
export let DeplomasStore = new DeplomasService()