AMBARI-21313 Log Search UI: implement service for string constants. (ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/72c7400d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/72c7400d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/72c7400d

Branch: refs/heads/trunk
Commit: 72c7400dcfed179524eed0a19747bb409130aaa8
Parents: 607c918
Author: ababiichuk <ababiic...@hortonworks.com>
Authored: Thu Jun 22 15:23:30 2017 +0300
Committer: ababiichuk <ababiic...@hortonworks.com>
Committed: Thu Jun 22 15:23:30 2017 +0300

----------------------------------------------------------------------
 .../ambari-logsearch-web-new/package.json       |  8 +++++---
 .../src/app/app.component.html                  |  4 +---
 .../src/app/app.component.ts                    |  7 ++++---
 .../src/app/app.module.ts                       | 21 +++++++++++++++++---
 .../app/login-form/login-form.component.html    | 12 +++++------
 .../src/assets/i18n/en.json                     |  8 ++++++++
 6 files changed, 42 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/72c7400d/ambari-logsearch/ambari-logsearch-web-new/package.json
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/package.json 
b/ambari-logsearch/ambari-logsearch-web-new/package.json
index feccace..bda2556 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/package.json
+++ b/ambari-logsearch/ambari-logsearch-web-new/package.json
@@ -19,13 +19,15 @@
     "@angular/platform-browser": "^4.0.0",
     "@angular/platform-browser-dynamic": "^4.0.0",
     "@angular/router": "^4.0.0",
+    "@ngx-translate/core": "^6.0.1",
+    "@ngx-translate/http-loader": "^0.0.3",
     "bootstrap": "^3.3.7",
     "core-js": "^2.4.1",
+    "font-awesome": "^4.7.0",
+    "jquery": "^1.12.4",
     "ngx-bootstrap": "^1.6.6",
     "rxjs": "^5.1.0",
-    "zone.js": "^0.8.4",
-    "jquery": "^1.12.4",
-    "font-awesome": "^4.7.0"
+    "zone.js": "^0.8.4"
   },
   "devDependencies": {
     "@angular/cli": "1.0.0",

http://git-wip-us.apache.org/repos/asf/ambari/blob/72c7400d/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.html
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.html 
b/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.html
index 3ba591e..8d9f6d0 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.html
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.html
@@ -15,7 +15,5 @@
   limitations under the License.
 -->
 
-<h1>
-  {{title}}
-</h1>
+<h1>{{'common.title' | translate}}</h1>
 <login-form *ngIf="!httpClient.isAuthorized"></login-form>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/72c7400d/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.ts 
b/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.ts
index 6f88af0..79cdc5d 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/app.component.ts
@@ -17,6 +17,7 @@
  */
 
 import {Component} from '@angular/core';
+import {TranslateService} from '@ngx-translate/core';
 import {HttpClientService} from './http-client.service';
 
 @Component({
@@ -27,12 +28,12 @@ import {HttpClientService} from './http-client.service';
 
 export class AppComponent {
 
-  constructor(private httpClient: HttpClientService) {
+  constructor(private httpClient: HttpClientService, private translate: 
TranslateService) {
+    translate.setDefaultLang('en');
+    translate.use('en');
   }
 
   ngOnInit() {
     this.httpClient.get('status');
   }
-
-  title = 'Ambari Log Search';
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/72c7400d/ambari-logsearch/ambari-logsearch-web-new/src/app/app.module.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/app.module.ts 
b/ambari-logsearch/ambari-logsearch-web-new/src/app/app.module.ts
index 39dc46f..2d132e2 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/app.module.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/app.module.ts
@@ -19,15 +19,21 @@
 import {BrowserModule} from '@angular/platform-browser';
 import {NgModule, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
 import {FormsModule} from '@angular/forms';
-import {HttpModule} from '@angular/http';
+import {HttpModule, Http} from '@angular/http';
 import {InMemoryWebApiModule} from 'angular-in-memory-web-api';
 import {mockApiDataService} from './mock-api-data.service'
 import {AlertModule} from 'ngx-bootstrap';
+import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
+import {TranslateHttpLoader} from '@ngx-translate/http-loader';
 import {HttpClientService} from './http-client.service';
 
 import {AppComponent} from './app.component';
 import {LoginFormComponent} from './login-form/login-form.component';
 
+export function HttpLoaderFactory(http: Http) {
+  return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
+}
+
 @NgModule({
   declarations: [
     AppComponent,
@@ -37,8 +43,17 @@ import {LoginFormComponent} from 
'./login-form/login-form.component';
     BrowserModule,
     FormsModule,
     HttpModule,
-    InMemoryWebApiModule.forRoot(mockApiDataService),
-    AlertModule.forRoot()
+    InMemoryWebApiModule.forRoot(mockApiDataService, {
+      passThruUnknownUrl: true
+    }),
+    AlertModule.forRoot(),
+    TranslateModule.forRoot({
+      loader: {
+        provide: TranslateLoader,
+        useFactory: HttpLoaderFactory,
+        deps: [Http]
+      }
+    })
   ],
   providers: [HttpClientService],
   bootstrap: [AppComponent],

http://git-wip-us.apache.org/repos/asf/ambari/blob/72c7400d/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.html
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.html
 
b/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.html
index 1cad6b3..4b7951a 100644
--- 
a/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.html
+++ 
b/ambari-logsearch/ambari-logsearch-web-new/src/app/login-form/login-form.component.html
@@ -16,18 +16,18 @@
 -->
 
 <div class="well col-md-4 col-md-offset-4 col-sm-offset-4">
-  <div class="alert alert-danger" *ngIf="isLoginAlertDisplayed">
-    <strong>Error!</strong> Invalid User credentials.<br>Please try again.
-  </div>
+  <div class="alert alert-danger" *ngIf="isLoginAlertDisplayed" 
[innerHTML]="'authorization.error' | translate"></div>
   <form #loginForm="ngForm" (ngSubmit)="login()">
     <div class="form-group">
-      <label for="username">Username</label>
+      <label for="username">{{'authorization.name' | translate}}</label>
       <input class="form-control" type="text" id="username" name="username" 
required [(ngModel)]="username">
     </div>
     <div class="form-group">
-      <label for="password">Password</label>
+      <label for="password">{{'authorization.password' | translate}}</label>
       <input class="form-control" type="password" id="password" 
name="password" required [(ngModel)]="password">
     </div>
-    <button class="btn btn-success" [disabled]="!loginForm.form.valid || 
isRequestInProgress">Sign In</button>
+    <button class="btn btn-success" [disabled]="!loginForm.form.valid || 
isRequestInProgress">
+      {{'authorization.signIn' | translate}}
+    </button>
   </form>
 </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/72c7400d/ambari-logsearch/ambari-logsearch-web-new/src/assets/i18n/en.json
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/assets/i18n/en.json 
b/ambari-logsearch/ambari-logsearch-web-new/src/assets/i18n/en.json
new file mode 100644
index 0000000..13c3805
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/assets/i18n/en.json
@@ -0,0 +1,8 @@
+{
+  "common.title": "Ambari Log Search",
+
+  "authorization.name": "Username",
+  "authorization.password": "Password",
+  "authorization.signIn": "Sign In",
+  "authorization.error": "<strong>Error!</strong> Invalid User 
credentials.<br>Please try again."
+}
\ No newline at end of file

Reply via email to