aboutsummaryrefslogtreecommitdiffstats
path: root/webapp/src/app/app.component.ts
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-10 16:29:10 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-10 16:36:12 +0100
commitfb2f6b918beb0a994ad304bfd678ef0c5c562210 (patch)
tree21c64ee76658b2e68559891ba317cb893afd2d44 /webapp/src/app/app.component.ts
parentc51d5034d527578da70bdd41b9ce13f28455c598 (diff)
Moved Dashboad webapp on Angular 5 !
Webapp loading time decreased from 2.7s to 1.5sec ! Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'webapp/src/app/app.component.ts')
-rw-r--r--webapp/src/app/app.component.ts48
1 files changed, 28 insertions, 20 deletions
diff --git a/webapp/src/app/app.component.ts b/webapp/src/app/app.component.ts
index 40cfb24..0d1ce12 100644
--- a/webapp/src/app/app.component.ts
+++ b/webapp/src/app/app.component.ts
@@ -1,37 +1,45 @@
-import { Component, OnInit, OnDestroy } from "@angular/core";
-import { Router } from '@angular/router';
-//TODO import {TranslateService} from "ng2-translate";
+import { Component, OnInit, OnDestroy } from '@angular/core';
+import { TranslateService } from '@ngx-translate/core';
+import { ConfigService, IConfig } from './services/config.service';
@Component({
- selector: 'app',
- templateUrl: './app/app.component.html',
- styleUrls: ['./app/app.component.css']
+ selector: 'app-root',
+ templateUrl: 'app.component.html',
+ styleUrls: ['app.component.css']
})
export class AppComponent implements OnInit, OnDestroy {
+ private defaultLanguage = 'en';
+ public isCollapsed = true;
- isCollapsed: boolean = true;
-
- private defaultLanguage: string = 'en';
-
- // I initialize the app component.
- //TODO constructor(private translate: TranslateService) {
- constructor(public router: Router) {
+ constructor(private translate: TranslateService, private configSvr: ConfigService) {
}
ngOnInit() {
-
- /* TODO
- this.translate.addLangs(["en", "fr"]);
+ this.translate.addLangs(['en', 'fr']);
this.translate.setDefaultLang(this.defaultLanguage);
- let browserLang = this.translate.getBrowserLang();
+ const browserLang = this.translate.getBrowserLang();
this.translate.use(browserLang.match(/en|fr/) ? browserLang : this.defaultLanguage);
- */
+
+ this.configSvr.Conf$.subscribe((cfg: IConfig) => {
+ let lang: string;
+ switch (cfg.language) {
+ case 'ENG':
+ lang = 'en';
+ break;
+ case 'FRA':
+ lang = 'fr';
+ break;
+ default:
+ lang = this.defaultLanguage;
+ }
+ this.translate.use(lang);
+ });
}
ngOnDestroy(): void {
+ // this.aglIdentityService.loginResponse.unsubscribe();
+ // this.aglIdentityService.logoutResponse.unsubscribe();
}
-
-
}