Skip to content

Commit

Permalink
Fixed the issue to fetch undefined.json
Browse files Browse the repository at this point in the history
  • Loading branch information
alvachien committed Apr 10, 2017
1 parent 98093f5 commit 838d1ba
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 29 deletions.
18 changes: 14 additions & 4 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,31 @@ export class AppComponent implements OnInit {
private _domSanitizer: DomSanitizer,
viewContainerRef: ViewContainerRef) {
if (environment.DebugLogging) {
console.log("Entering constructor of AppComponent");
console.log("ACHIHUI Log: Entering constructor of AppComponent");
}

let arlang: string[] = [];
for(let ap of this._uistatus.arLang)
arlang.push(ap.IsoName);
this._translateService.addLangs(arlang);
this._translateService.setDefaultLang(this._uistatus.curLang);
this._translateService.setDefaultLang(this._uistatus.curLang ? this._uistatus.curLang : "en");

this._uistatus.obsCurLanguage.subscribe(x => {
this._translateService.setDefaultLang(x);
if (environment.DebugLogging) {
console.log("ACHIHUI Log: Entering current language change in AppComponent: " + x);
}
if (x) {
this._translateService.use(x);
}
}, error => {
}, () => {
});

this._authService.authContent.subscribe(x => {
if (environment.DebugLogging) {
console.log("ACHIHUI Log: Entering subscribe of authContent in AppComponent");
}

this._uistatus.setIsLogin(x.isAuthorized);
});

Expand All @@ -55,7 +65,7 @@ export class AppComponent implements OnInit {

ngOnInit() {
if (environment.DebugLogging) {
console.log("Entering ngOnInit of AppComponent");
console.log("ACHIHUI Log: Entering ngOnInit of AppComponent");
}
}
}
14 changes: 4 additions & 10 deletions src/app/finance/finance.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class FinanceComponent implements OnInit {
private _translateService: TranslateService,
viewContainerRef: ViewContainerRef) {
if (environment.DebugLogging) {
console.log("Entering constructor of FinanceComponent");
console.log("ACHIHUI Log: Entering constructor of FinanceComponent");
}
this.arLanguages = new Array<AppLanguage>();

Expand All @@ -58,14 +58,6 @@ export class FinanceComponent implements OnInit {
this.arLanguages.push(ap);
arlang.push(ap.IsoName);
}
this._translateService.addLangs(arlang);
this._translateService.setDefaultLang(this._uistatus.curLang);

this._uistatus.obsCurLanguage.subscribe(x => {
this._translateService.setDefaultLang(x);
}, error => {
}, () => {
});

this._iconRegistry.addSvgIconInNamespace('assets', 'github',
this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/github.svg'));
Expand Down Expand Up @@ -160,6 +152,8 @@ export class FinanceComponent implements OnInit {
this.libraryMenuToggled = !this.libraryMenuToggled;
}
public onLanguageClick(lang: AppLanguage) : void {
this._uistatus.setCurrentLanguage(lang.IsoName);
if (lang.IsoName !== this._uistatus.curLang) {
this._uistatus.setCurrentLanguage(lang.IsoName);
}
}
}
2 changes: 1 addition & 1 deletion src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<td-navigation-drawer flex icon="event_seat" sidenavTitle="H.I.H." name="{{ titleLogin }}" (logout)="onLogout()">
<div td-sidenav-content *ngIf="!isLoggedIn">
<md-nav-list menu-items>
<a md-list-item (click)="onLogin()">{{"Login.Login" | translate }</a>
<a md-list-item (click)="onLogin()">{{"Login.Login" | translate }}</a>
</md-nav-list>
</div>
<div td-sidenav-content *ngIf="isLoggedIn">
Expand Down
10 changes: 6 additions & 4 deletions src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { UIStatusService } from '../services/uistatus.service';
import { AuthService } from '../services/auth.service';
import { AppLanguage } from '../model/common';
import { TranslateService } from '@ngx-translate/core';

@Component({
selector: 'hih-home',
Expand All @@ -23,7 +24,8 @@ export class HomeComponent implements OnInit {

constructor(
private _authService: AuthService,
private _uistatus: UIStatusService
private _uistatus: UIStatusService,
private _translateService: TranslateService
) {
this.arLanguages = new Array<AppLanguage>();

Expand Down Expand Up @@ -66,9 +68,7 @@ export class HomeComponent implements OnInit {
this._uistatus.obsFinanceRouteList.subscribe(x => {
this.financeRoutes = x;
}, error => {

}, () => {

});
this._uistatus.obsLibraryRouteList.subscribe(x => {
this.libraryRoutes = x;
Expand Down Expand Up @@ -107,6 +107,8 @@ export class HomeComponent implements OnInit {
}

public onLanguageClick(lang: AppLanguage) : void {
this._uistatus.setCurrentLanguage(lang.IsoName);
if (lang.IsoName !== this._uistatus.curLang) {
this._uistatus.setCurrentLanguage(lang.IsoName);
}
}
}
12 changes: 3 additions & 9 deletions src/app/learn/learn.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ export class LearnComponent implements OnInit {
arlang.push(ap.IsoName);
}

this._translateService.addLangs(arlang);
this._translateService.setDefaultLang(this._uistatus.curLang);
this._uistatus.obsCurLanguage.subscribe(x => {
this._translateService.setDefaultLang(x);
}, error => {
}, () => {
});

this._iconRegistry.addSvgIconInNamespace('assets', 'github',
this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/github.svg'));
this._iconRegistry.addSvgIconInNamespace('assets', 'angular',
Expand Down Expand Up @@ -161,6 +153,8 @@ export class LearnComponent implements OnInit {
this.libraryMenuToggled = !this.libraryMenuToggled;
}
public onLanguageClick(lang: AppLanguage) : void {
this._uistatus.setCurrentLanguage(lang.IsoName);
if (lang.IsoName !== this._uistatus.curLang) {
this._uistatus.setCurrentLanguage(lang.IsoName);
}
}
}
7 changes: 6 additions & 1 deletion src/app/services/uistatus.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,17 @@ export class UIStatusService {
if (environment.DebugLogging) {
console.log("ACHIHUI Log: Entering setFinanceSubModule of UIStatusService with " + financeSubMod);
}

this.financeSubModule = financeSubMod;
this.subjFinanceSubModule.next(this.financeSubModule);
}

public setCurrentLanguage(curlang: string): void {
if (curlang !== this.curLang) {
if (environment.DebugLogging) {
console.log("ACHIHUI Log: Entering setCurrentLanguage of UIStatusService with " + curlang);
}

if (curlang && curlang !== this.curLang) {
// Check whether the new value is valid
let bValid: boolean = false;
for(let ap of this.arLang) {
Expand Down

0 comments on commit 838d1ba

Please sign in to comment.