diff --git a/src/app/language.model.ts b/src/app/language.model.ts index cbe3cdd..eb737f4 100644 --- a/src/app/language.model.ts +++ b/src/app/language.model.ts @@ -1,4 +1,5 @@ export interface LanguageData { + _id: string; language: string; component: string; data?: any; diff --git a/src/app/language.service.ts b/src/app/language.service.ts index 2eed0a8..0739991 100644 --- a/src/app/language.service.ts +++ b/src/app/language.service.ts @@ -3,13 +3,22 @@ import { LanguageData } from './language.model'; import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http'; import { ConfigData } from './configdata'; +var Buffer = require('buffer/').Buffer; + @Injectable({ providedIn: 'root' }) export class LanguageService { - - private baseURL = 'http://localhost:8080/getlang'; +// +// URL for test using REST API to local MariaDB database +// private baseURL = 'http://localhost:8080/zgointl'; +// +// URL for test using REST API to local MongoDB database +// private baseURL = 'http://localhost:5000/zgointl'; +// +// URL for access MongoDB database from remote server + private baseURL = ConfigData.Be_URL + 'api/getlang'; public zgoLanguage: string = ''; @@ -20,7 +29,12 @@ export class LanguageService { // // Get default language from localStorage // - var def_zgoLanguage = localStorage.getItem('zgo_language'); + const def_zgoLanguage = localStorage.getItem('zgo_language'); + // + // Set authorizacion paramaters + // + const Auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64'); + const reqHeaders = new HttpHeaders().set('Authorization', Auth); if ( def_zgoLanguage == null ) { this.zgoLanguage = 'en-US'; @@ -29,10 +43,11 @@ export class LanguageService { this.zgoLanguage = def_zgoLanguage; } // - // Get View's text data from language database + // Get component's text data from language database // return this.http.get(this.baseURL + - '/?lang_id=' + this.zgoLanguage + - '&viewname=' + viewName); + '/?lang=' + this.zgoLanguage + + '&component=' + viewName, + { headers : reqHeaders }); } }