2021-10-21 14:15:50 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
2021-10-26 15:27:25 +01:00
|
|
|
import { StorageService } from 'src/app/services/storage.service';
|
2022-10-11 17:07:51 +01:00
|
|
|
import { localstoreService } from '../store/localstore.service';
|
|
|
|
|
import { AES, enc, SHA1 } from 'crypto-js'
|
2021-10-21 14:15:50 +01:00
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
|
|
|
|
export class ThemeService {
|
|
|
|
|
|
|
|
|
|
themes = [
|
|
|
|
|
'gov',
|
2021-10-27 15:10:55 +01:00
|
|
|
'default',
|
|
|
|
|
'tribunal'
|
2021-10-21 14:15:50 +01:00
|
|
|
]
|
|
|
|
|
|
2022-10-11 17:07:51 +01:00
|
|
|
currentTheme: 'gov' | 'default' | 'tribunal' = 'gov'
|
|
|
|
|
keyName: string
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private storageservice: StorageService
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
this.keyName = (SHA1(this.constructor.name)).toString()
|
|
|
|
|
let restore = localstoreService.get(this.keyName, {
|
|
|
|
|
theme: "gov"
|
|
|
|
|
})
|
2021-10-21 15:05:37 +01:00
|
|
|
|
2022-10-11 17:07:51 +01:00
|
|
|
this.setTheme(restore.theme)
|
|
|
|
|
|
|
|
|
|
}
|
2021-10-21 14:15:50 +01:00
|
|
|
|
2021-10-27 15:10:55 +01:00
|
|
|
setTheme(theme: 'gov' | 'default' | 'tribunal') {
|
2021-10-21 16:09:10 +01:00
|
|
|
|
2022-10-12 13:07:55 +01:00
|
|
|
if(this.themes.includes(theme)) {
|
|
|
|
|
document.body.classList.remove("gov");
|
|
|
|
|
document.body.classList.remove("default");
|
|
|
|
|
document.body.classList.remove("tribunal");
|
|
|
|
|
|
|
|
|
|
document.body.classList.add(theme);
|
|
|
|
|
this.currentTheme = theme;
|
|
|
|
|
|
|
|
|
|
localstoreService.set(this.keyName, {
|
|
|
|
|
theme: theme
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-11 17:07:51 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveTheme() {
|
2021-10-21 16:09:10 +01:00
|
|
|
|
|
|
|
|
}
|
2021-10-21 14:15:50 +01:00
|
|
|
|
2022-10-11 17:07:51 +01:00
|
|
|
}
|