mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +00:00
Improve local storage and fix expediente task strature
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DespachosPageStoreService } from './despachos-page-store.service';
|
||||
|
||||
describe('DespachosPageStoreService', () => {
|
||||
let service: DespachosPageStoreService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(DespachosPageStoreService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,60 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { localstoreService } from './localstore.service'
|
||||
import { AES, enc, SHA1 } from 'crypto-js'
|
||||
import { customTask } from '../models/dailyworktask.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DespachosPageStoreService {
|
||||
|
||||
// main data
|
||||
private _list: [] = []
|
||||
// local storage keyName
|
||||
private keyName: string;
|
||||
private _count = 0
|
||||
|
||||
constructor() {
|
||||
|
||||
this.keyName = (SHA1(this.constructor.name)).toString()
|
||||
|
||||
|
||||
setTimeout(()=>{
|
||||
let restore = localstoreService.get(this.keyName, {})
|
||||
this._list = restore.list || []
|
||||
this._count = parseInt(restore.count) || 0
|
||||
}, 10)
|
||||
|
||||
}
|
||||
|
||||
get list(): customTask[] {
|
||||
return this._list || []
|
||||
}
|
||||
|
||||
get count() {
|
||||
return this._count
|
||||
}
|
||||
set count(value) {
|
||||
this._count = value
|
||||
this.save()
|
||||
}
|
||||
|
||||
reset(eventsList: any) {
|
||||
this._list = eventsList
|
||||
|
||||
this.count = this._list.length
|
||||
this.save()
|
||||
}
|
||||
|
||||
private save() {
|
||||
setTimeout(()=> {
|
||||
localstoreService.set(this.keyName,{
|
||||
list: this._list,
|
||||
count: this._count
|
||||
})
|
||||
}, 10)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const DespachoPageStore = new DespachosPageStoreService()
|
||||
@@ -1,16 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ExpedienteStorageServiceService } from './expediente-storage-service.service';
|
||||
|
||||
describe('ExpedienteStorageServiceService', () => {
|
||||
let service: ExpedienteStorageServiceService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ExpedienteStorageServiceService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,62 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Event } from '../models/event.model';
|
||||
import { localstoreService } from './localstore.service'
|
||||
import { AES, enc, SHA1 } from 'crypto-js'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
|
||||
// shared data used in home and gabinete
|
||||
class ExpedienteStorageServiceService {
|
||||
|
||||
// main data
|
||||
private _list: Event[] = []
|
||||
private _count = 0
|
||||
// local storage keyName
|
||||
private keyName: string;
|
||||
|
||||
constructor() {
|
||||
|
||||
this.keyName = (SHA1(this.constructor.name+ 'ExpedienteStorage/forAll')).toString()
|
||||
|
||||
setTimeout(()=>{
|
||||
let restore = localstoreService.get(this.keyName, [])
|
||||
this._list = restore.list || []
|
||||
this._count = restore.count || 0
|
||||
}, 10)
|
||||
|
||||
}
|
||||
|
||||
get list() {
|
||||
return this._list
|
||||
}
|
||||
|
||||
get count() {
|
||||
return this._count
|
||||
}
|
||||
set count(value: number) {
|
||||
this._count = value
|
||||
this.save()
|
||||
}
|
||||
|
||||
reset(list: any) {
|
||||
this._list = list
|
||||
|
||||
this.count = this._list.length
|
||||
this.save()
|
||||
}
|
||||
|
||||
private save() {
|
||||
setTimeout(()=>{
|
||||
localstoreService.set(this.keyName, {
|
||||
list: this._list,
|
||||
count: this._count
|
||||
})
|
||||
}, 10)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export const ExpedienteStorage = new ExpedienteStorageServiceService()
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { localstoreService } from './localstore.service'
|
||||
import { AES, enc, SHA1 } from 'crypto-js'
|
||||
import { ExpedienteTask } from '../models/dailyworktask.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -8,7 +9,7 @@ import { AES, enc, SHA1 } from 'crypto-js'
|
||||
export class ExpedientegdStoreService {
|
||||
|
||||
// main data
|
||||
private _list = []
|
||||
private _list: ExpedienteTask[] = []
|
||||
// local storage keyName
|
||||
private keyName: string;
|
||||
private _count = 0
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ExpedienteprStoreService } from './expedientepr-store.service';
|
||||
|
||||
describe('ExpedienteprStoreService', () => {
|
||||
let service: ExpedienteprStoreService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ExpedienteprStoreService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,54 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { localstoreService } from './localstore.service'
|
||||
import { AES, enc, SHA1 } from 'crypto-js'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ExpedienteprStoreService {
|
||||
// main data
|
||||
private _list: [] = []
|
||||
// local storage keyName
|
||||
private keyName: string;
|
||||
private _count = 0
|
||||
|
||||
constructor() {
|
||||
|
||||
this.keyName = (SHA1(this.constructor.name)).toString()
|
||||
|
||||
setTimeout(()=>{
|
||||
let restore = localstoreService.get(this.keyName, {})
|
||||
this._list = restore.list || []
|
||||
this._count = parseInt(restore.count) || 0
|
||||
}, 10)
|
||||
|
||||
}
|
||||
|
||||
get list() { return this._list || [] }
|
||||
|
||||
get count() { return this._count || 0 }
|
||||
set count(value: number) {
|
||||
this._count = value
|
||||
this.save()
|
||||
}
|
||||
|
||||
reset(eventsList: any) {
|
||||
this._list = eventsList
|
||||
|
||||
this.count = this._list.length
|
||||
this.save()
|
||||
}
|
||||
|
||||
private save() {
|
||||
setTimeout(()=>{
|
||||
localstoreService.set(this.keyName,{
|
||||
list: this._list,
|
||||
count: this._count
|
||||
})
|
||||
}, 10)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const ExpedienteprStore = new ExpedienteprStoreService()
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LoaderService } from './loader.service';
|
||||
|
||||
describe('LoaderService', () => {
|
||||
let service: LoaderService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(LoaderService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LoaderService {
|
||||
|
||||
private loadingList: {
|
||||
name: string
|
||||
}[] = []
|
||||
|
||||
constructor() { }
|
||||
|
||||
get loading(){
|
||||
return this.loadingList.length != 0
|
||||
}
|
||||
|
||||
push({name = ''}) {
|
||||
this.loadingList.push({
|
||||
name: name
|
||||
})
|
||||
}
|
||||
|
||||
pop({}) {
|
||||
this.loadingList.pop()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user