finalized desktop version and first try implementing mobile
This commit is contained in:
parent
fe25daeaca
commit
7f944081a0
18 changed files with 395 additions and 27 deletions
58
caesar-tauri-angular/src/app/services/storage.service.ts
Normal file
58
caesar-tauri-angular/src/app/services/storage.service.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class StorageService {
|
||||
|
||||
// ----------------- Session ------------------------
|
||||
// Ruft einen Wert aus dem sessionStorage ab
|
||||
getSessionEntry(key: string): any {
|
||||
const item = sessionStorage.getItem(key);
|
||||
return item ? JSON.parse(item) : null;
|
||||
}
|
||||
|
||||
public setSessionEntry(key: string, data: unknown): void {
|
||||
sessionStorage.setItem(key, JSON.stringify(data));
|
||||
}
|
||||
|
||||
public deleteSessionEntry(key: string): void {
|
||||
sessionStorage.removeItem(key);
|
||||
}
|
||||
|
||||
public clearSession(): void {
|
||||
sessionStorage.clear();
|
||||
}
|
||||
|
||||
public isSessionEmpty(): boolean {
|
||||
return sessionStorage.length === 0;
|
||||
}
|
||||
|
||||
// ----------------- Local ------------------------
|
||||
public setLocalEntry(key: string, data: unknown): void {
|
||||
localStorage.setItem(key, JSON.stringify(data));
|
||||
}
|
||||
|
||||
public getLocalEntry(key: string): any {
|
||||
const item = localStorage.getItem(key);
|
||||
return item ? JSON.parse(item) : null;
|
||||
}
|
||||
|
||||
public deleteLocalEntry(key: string): void {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
|
||||
public clearLocal(): void {
|
||||
localStorage.clear();
|
||||
}
|
||||
|
||||
public isLocalEmpty(): boolean {
|
||||
return localStorage.length === 0;
|
||||
}
|
||||
|
||||
// ----------------- General ------------------------
|
||||
public clearAll(): void {
|
||||
this.clearLocal();
|
||||
this.clearSession();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue