1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Saving settings mode to cookies

This commit is contained in:
Patrik J. Braun 2021-05-16 16:36:21 +02:00
parent 2fa1c8f87f
commit 01f858b092
3 changed files with 13 additions and 2 deletions

View File

@ -1,4 +1,5 @@
export class CookieNames {
public static lang = 'pigallery2-lang';
public static session = 'pigallery2-session';
public static advancedSettings = 'advanced-settings';
}

View File

@ -62,7 +62,8 @@
i18n-switch-on-text
switch-handle-width="100"
switch-label-width="20"
[(ngModel)]="simplifiedMode">
[(ngModel)]="simplifiedMode"
(ngModelChange)="modeToggle()">
</bSwitch>
</div>
</div>

View File

@ -7,6 +7,8 @@ import {NavigationService} from '../../model/navigation.service';
import {ISettingsComponent} from '../settings/_abstract/ISettingsComponent';
import {PageHelper} from '../../model/page.helper';
import {SettingsService} from '../settings/settings.service';
import {CookieNames} from '../../../../common/CookieNames';
import {CookieService} from 'ngx-cookie-service';
@Component({
selector: 'app-admin',
@ -22,7 +24,11 @@ export class AdminComponent implements OnInit, AfterViewInit {
constructor(private authService: AuthenticationService,
private navigation: NavigationService,
public notificationService: NotificationService,
public settingsService: SettingsService) {
public settingsService: SettingsService,
private cookieService: CookieService) {
if (this.cookieService.check(CookieNames.advancedSettings)) {
this.simplifiedMode = !(this.cookieService.get(CookieNames.advancedSettings) === 'true');
}
}
ngAfterViewInit(): void {
@ -55,6 +61,9 @@ export class AdminComponent implements OnInit, AfterViewInit {
return 'info';
}
modeToggle(): void {
this.cookieService.set(CookieNames.advancedSettings, this.simplifiedMode ? 'false' : 'true');
}
}