Fixed webapp build and error message.
[src/xds/xds-agent.git] / webapp / src / app / app.component.ts
1 import { Component, OnInit, OnDestroy } from '@angular/core';
2 import { TranslateService } from '@ngx-translate/core';
3 import { ConfigService, IConfig } from './services/config.service';
4
5 @Component({
6     selector: 'app-root',
7     templateUrl: 'app.component.html'
8 })
9
10 export class AppComponent implements OnInit, OnDestroy {
11     private defaultLanguage = 'en';
12     public isCollapsed = true;
13
14     constructor(private translate: TranslateService, private configSvr: ConfigService) {
15     }
16
17     ngOnInit() {
18         this.translate.addLangs(['en', 'fr']);
19         this.translate.setDefaultLang(this.defaultLanguage);
20
21         const browserLang = this.translate.getBrowserLang();
22         this.translate.use(browserLang.match(/en|fr/) ? browserLang : this.defaultLanguage);
23
24         this.configSvr.Conf$.subscribe((cfg: IConfig) => {
25             let lang: string;
26             switch (cfg.language) {
27                 case 'ENG':
28                     lang = 'en';
29                     break;
30                 case 'FRA':
31                     lang = 'fr';
32                     break;
33                 default:
34                     lang = this.defaultLanguage;
35             }
36             this.translate.use(lang);
37         });
38     }
39
40     ngOnDestroy(): void {
41         // this.aglIdentityService.loginResponse.unsubscribe();
42         // this.aglIdentityService.logoutResponse.unsubscribe();
43     }
44 }