[ADF-3918] Fix translation issue (#4169)

This commit is contained in:
Eugenio Romano
2019-01-20 23:40:07 +00:00
committed by GitHub
parent 9a70852985
commit 348bee9c6f
22 changed files with 253 additions and 201 deletions

View File

@@ -38,6 +38,13 @@ export enum AppConfigValues {
LOGIN_ROUTE = 'loginRoute',
DISABLECSRF = 'disableCSRF'
}
export enum Status {
INIT = 'init',
LOADING = 'loading',
LOADED = 'loaded'
}
/* spellchecker: enable */
@Injectable({
@@ -55,7 +62,8 @@ export class AppConfigService {
alfrescoRepositoryName: 'alfresco-1'
};
private onLoadSubject: Subject<any>;
status: Status = Status.INIT;
protected onLoadSubject: Subject<any>;
onLoad: Observable<any>;
constructor(private http: HttpClient) {
@@ -128,19 +136,29 @@ export class AppConfigService {
* @returns Notification when loading is complete
*/
load(): Promise<any> {
return new Promise((resolve) => {
return new Promise(async (resolve) => {
const configUrl = `app.config.json?v=${Date.now()}`;
this.http.get(configUrl).subscribe(
(data: any) => {
this.config = Object.assign({}, this.config, data || {});
this.onLoadSubject.next(this.config);
if (this.status === Status.INIT) {
this.status = Status.LOADING;
await this.http.get(configUrl).subscribe(
(data: any) => {
this.status = Status.LOADED;
this.config = Object.assign({}, this.config, data || {});
this.onLoadSubject.next(this.config);
resolve(this.config);
},
() => {
resolve(this.config);
}
);
} else if (this.status === Status.LOADED) {
resolve(this.config);
} else if (this.status === Status.LOADING) {
this.onLoad.subscribe(() => {
resolve(this.config);
},
() => {
resolve(this.config);
}
);
});
}
});
}