mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-18 00:10:14 +01:00
fix: sync theme select with value with theme service
This commit is contained in:
parent
77066ad20c
commit
28c29e088f
2 changed files with 12 additions and 3 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
</a>
|
</a>
|
||||||
<a class="logo" href="#" (click)="navigateHome()">ngx-<span>admin</span></a>
|
<a class="logo" href="#" (click)="navigateHome()">ngx-<span>admin</span></a>
|
||||||
</div>
|
</div>
|
||||||
<nb-select [(selected)]="currentTheme" (selectedChange)="toggleTheme()" status="primary">
|
<nb-select [selected]="currentTheme" (selectedChange)="changeTheme($event)" status="primary">
|
||||||
<nb-option *ngFor="let theme of themes" [value]="theme.value"> {{ theme.name }}</nb-option>
|
<nb-option *ngFor="let theme of themes" [value]="theme.value"> {{ theme.name }}</nb-option>
|
||||||
</nb-select>
|
</nb-select>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.currentTheme = this.themeService.currentTheme;
|
||||||
|
|
||||||
this.userService.getUsers()
|
this.userService.getUsers()
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$))
|
||||||
.subscribe((users: any) => this.user = users.nick);
|
.subscribe((users: any) => this.user = users.nick);
|
||||||
|
|
@ -60,6 +62,13 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
||||||
takeUntil(this.destroy$),
|
takeUntil(this.destroy$),
|
||||||
)
|
)
|
||||||
.subscribe((isLessThanXl: boolean) => this.userPictureOnly = isLessThanXl);
|
.subscribe((isLessThanXl: boolean) => this.userPictureOnly = isLessThanXl);
|
||||||
|
|
||||||
|
this.themeService.onThemeChange()
|
||||||
|
.pipe(
|
||||||
|
map(({ name }) => name),
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
)
|
||||||
|
.subscribe(themeName => this.currentTheme = themeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
|
@ -67,8 +76,8 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
||||||
this.destroy$.complete();
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleTheme() {
|
changeTheme(themeName: string) {
|
||||||
this.themeService.changeTheme(this.currentTheme);
|
this.themeService.changeTheme(themeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSidebar(): boolean {
|
toggleSidebar(): boolean {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue