mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Event } from '../models/event.model';
|
|
import { localstoreService } from './localstore.service'
|
|
import { AES, enc, SHA1 } from 'crypto-js'
|
|
import { EventList } from '../models/agenda/AgendaEventList';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
|
|
export class ToDayEventStorageService {
|
|
|
|
// main data
|
|
private _eventsList:EventList[] = []
|
|
// local storage keyName
|
|
private keyName: string;
|
|
|
|
constructor() {
|
|
|
|
this.keyName = (SHA1("ToDayEventStorageService"+ 'home/eventSource')).toString()
|
|
|
|
|
|
setTimeout(() => {
|
|
let restore = localstoreService.get(this.keyName, {})
|
|
this._eventsList = restore.eventsList || []
|
|
}, 10)
|
|
|
|
}
|
|
|
|
get eventsList() {
|
|
return this._eventsList || []
|
|
}
|
|
get count() {
|
|
return this._eventsList.length
|
|
}
|
|
|
|
|
|
reset(eventsList: EventList[]) {
|
|
this._eventsList = eventsList
|
|
this.save()
|
|
if(window['all-process-gabinete']) {
|
|
window['all-process-gabinete']()
|
|
}
|
|
}
|
|
|
|
private save() {
|
|
setTimeout(()=>{
|
|
localstoreService.set(this.keyName,{
|
|
eventsList :this._eventsList,
|
|
count: this._eventsList
|
|
})
|
|
}, 10)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export const ToDayEventStorage = new ToDayEventStorageService() |