68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
import { PrimeNGConfig } from 'primeng/api';
|
|
import { AuthService } from './services/auth/auth.service';
|
|
import { SocketService } from './services/socket/socket.service';
|
|
import { ThemeService } from './services/theme/theme.service';
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
templateUrl: './app.component.html',
|
|
styleUrls: ['./app.component.scss']
|
|
})
|
|
export class AppComponent implements OnInit {
|
|
|
|
themeName!: string;
|
|
sidebarWidth!: string;
|
|
|
|
isLoggedIn: boolean = false;
|
|
|
|
constructor(
|
|
private authService: AuthService,
|
|
private themeService: ThemeService,
|
|
private socket: SocketService,
|
|
private translateService: TranslateService,
|
|
private config: PrimeNGConfig
|
|
) {
|
|
this.themeService.sidebarWidth$.subscribe(value => {
|
|
this.sidebarWidth = value;
|
|
});
|
|
this.themeService.themeName$.subscribe(value => {
|
|
this.themeName = value;
|
|
});
|
|
this.authService.isLoggedIn$.subscribe(value => {
|
|
this.isLoggedIn = value;
|
|
});
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
this.translateService.setDefaultLang('en');
|
|
|
|
this.themeService.loadTheme();
|
|
this.socket.startSocket();
|
|
}
|
|
|
|
loadLang(): void {
|
|
let lang = localStorage.getItem(`default_lang`);
|
|
if (!lang) {
|
|
lang = 'en';
|
|
this.setLang(lang);
|
|
}
|
|
this.translate(lang);
|
|
}
|
|
|
|
setLang(lang: string): void {
|
|
localStorage.setItem(`default_lang`, lang);
|
|
}
|
|
|
|
translate(lang: string) {
|
|
this.translateService.use(lang);
|
|
this.translateService.get('primeng').subscribe(res => this.config.setTranslation(res));
|
|
}
|
|
|
|
|
|
setSideWidth($event: any): void {
|
|
this.themeService.setSideWidth($event);
|
|
}
|
|
}
|