mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-01-04 16:48:49 +01:00
feat: demo version additions
This commit is contained in:
parent
8f0a950bcc
commit
713aff561e
35 changed files with 1406 additions and 40 deletions
|
|
@ -4,7 +4,12 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*/
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { withLatestFrom, filter } from 'rxjs/operators';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
|
||||
import { AnalyticsService } from './@core/utils/analytics.service';
|
||||
import { AbService } from './@core/utils/ab.service';
|
||||
import { SeoService } from './@core/utils/seo.service';
|
||||
|
||||
@Component({
|
||||
|
|
@ -13,11 +18,48 @@ import { SeoService } from './@core/utils/seo.service';
|
|||
})
|
||||
export class AppComponent implements OnInit {
|
||||
|
||||
constructor(private analytics: AnalyticsService, private seoService: SeoService) {
|
||||
themes = ['default', 'cosmic', 'corporate', 'dark'];
|
||||
|
||||
constructor(private analytics: AnalyticsService,
|
||||
private seoService: SeoService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private abService: AbService,
|
||||
private themeService: NbThemeService) {
|
||||
|
||||
this.themeService.onThemeChange()
|
||||
.subscribe((theme: any) => {
|
||||
this.analytics.trackEvent('changeTheme', theme.name);
|
||||
});
|
||||
|
||||
this.activatedRoute.queryParams
|
||||
.subscribe((params: any) => {
|
||||
if (params.theme && this.themes.includes(params.theme)) {
|
||||
this.themeService.changeTheme(params.theme);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
const variants = [
|
||||
AbService.VARIANT_THEME_CORPORATE,
|
||||
AbService.VARIANT_THEME_DEFAULT,
|
||||
AbService.VARIANT_THEME_COSMIC,
|
||||
AbService.VARIANT_THEME_DARK,
|
||||
];
|
||||
|
||||
this.analytics.trackPageViews();
|
||||
this.seoService.trackCanonicalChanges();
|
||||
this.abService.onAbEvent()
|
||||
.pipe(
|
||||
withLatestFrom(this.activatedRoute.queryParams),
|
||||
filter(([e, params]: [{ name: string }, any]) => !params.theme),
|
||||
)
|
||||
.subscribe(([e, params]: [{ name: string }, any]) => {
|
||||
const themeName = e.name.replace('theme-change-', '');
|
||||
if (variants.includes(e.name) && this.themes.includes(themeName)) {
|
||||
this.themeService.changeTheme(themeName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue