This is an automated email from the ASF dual-hosted git repository.

oleewere pushed a commit to branch branch-feature-AMBARI-22842
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit 7883bc522eac3da3f998258f91851693913d08ef
Author: Istvan Tobias <tobias.ist...@gmail.com>
AuthorDate: Sun Feb 11 23:57:41 2018 +0100

    AMBARI-22814 Add different options of component name display
---
 .../ambari-logsearch-web/src/app/app.module.ts     |  4 ++-
 .../classes/models/{node-item.ts => node-group.ts} | 15 ++++------
 .../src/app/classes/models/node-item.ts            |  3 ++
 .../service-logs-table.component.html              |  2 +-
 .../node-item.ts => pipes/component-label.ts}      | 26 ++++++++++-------
 .../src/app/services/http-client.service.ts        |  3 ++
 .../src/app/services/logs-container.service.ts     | 33 ++++++++++++++--------
 .../src/app/services/utils.service.ts              |  6 ++--
 8 files changed, 57 insertions(+), 35 deletions(-)

diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts 
b/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts
index 5a2b59d..1c85681 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts
@@ -101,6 +101,7 @@ import {LogIndexFilterComponent} from 
'@app/components/log-index-filter/log-inde
 
 import {TimeZoneAbbrPipe} from '@app/pipes/timezone-abbr.pipe';
 import {TimerSecondsPipe} from '@app/pipes/timer-seconds.pipe';
+import {ComponentLabelPipe} from "@app/pipes/component-label";
 
 export function HttpLoaderFactory(http: Http): TranslateHttpLoader {
   // adding 'static' parameter to step over mock data request
@@ -164,7 +165,8 @@ export function getXHRBackend(injector: Injector, browser: 
BrowserXhr, xsrf: XSR
     HistoryItemControlsComponent,
     LogIndexFilterComponent,
     TimeZoneAbbrPipe,
-    TimerSecondsPipe
+    TimerSecondsPipe,
+    ComponentLabelPipe
   ],
   imports: [
     BrowserModule,
diff --git 
a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts 
b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-group.ts
similarity index 76%
copy from 
ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts
copy to 
ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-group.ts
index ef5f772..d461b23 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-group.ts
@@ -16,15 +16,10 @@
  * limitations under the License.
  */
 
-import {CommonEntry} from '@app/classes/models/common-entry';
-
-export interface NodeItem {
+/**
+ * A simple interface for the component's groups (aka services)
+ */
+export interface NodeGroup {
   name: string;
-  type?: string;
-  value: string;
-  isParent: boolean;
-  isRoot: boolean;
-  childs?: NodeItem[];
-  logLevelCount?: CommonEntry[];
-  vNodeList?: CommonEntry[];
+  label?: string;
 }
diff --git 
a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts 
b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts
index ef5f772..ca10578 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts
@@ -17,11 +17,14 @@
  */
 
 import {CommonEntry} from '@app/classes/models/common-entry';
+import {NodeGroup} from "@app/classes/models/node-group";
 
 export interface NodeItem {
   name: string;
   type?: string;
   value: string;
+  label?: string;
+  group?: NodeGroup;
   isParent: boolean;
   isRoot: boolean;
   childs?: NodeItem[];
diff --git 
a/ambari-logsearch/ambari-logsearch-web/src/app/components/service-logs-table/service-logs-table.component.html
 
b/ambari-logsearch/ambari-logsearch-web/src/app/components/service-logs-table/service-logs-table.component.html
index 3110d9a..26ec1df 100644
--- 
a/ambari-logsearch/ambari-logsearch-web/src/app/components/service-logs-table/service-logs-table.component.html
+++ 
b/ambari-logsearch/ambari-logsearch-web/src/app/components/service-logs-table/service-logs-table.component.html
@@ -79,7 +79,7 @@
                 <log-level [logEntry]="log"></log-level>
               </td>
               <td *ngIf="isColumnDisplayed('type')" [ngClass]="'log-type'">
-                {{log.type}}
+                {{log.type | componentLabel | async}}
               </td>
               <ng-container *ngFor="let column of displayedColumns">
                 <td *ngIf="customStyledColumns.indexOf(column.value) === -1"
diff --git 
a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts 
b/ambari-logsearch/ambari-logsearch-web/src/app/pipes/component-label.ts
similarity index 59%
copy from 
ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts
copy to ambari-logsearch/ambari-logsearch-web/src/app/pipes/component-label.ts
index ef5f772..4a81abd 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/pipes/component-label.ts
@@ -16,15 +16,21 @@
  * limitations under the License.
  */
 
-import {CommonEntry} from '@app/classes/models/common-entry';
+import {Pipe, PipeTransform} from '@angular/core';
+import {ComponentsService} from "@app/services/storage/components.service";
+import {Observable} from "rxjs/Observable";
+
+@Pipe({
+  name: 'componentLabel'
+})
+export class ComponentLabelPipe implements PipeTransform {
+
+  constructor(private componentService: ComponentsService) {
+  }
+
+  transform(name: string): Observable<string> {
+    return this.componentService.findInCollection(component => component.name 
=== name)
+      .map(component => component ? component.label || component.name : name)
+  }
 
-export interface NodeItem {
-  name: string;
-  type?: string;
-  value: string;
-  isParent: boolean;
-  isRoot: boolean;
-  childs?: NodeItem[];
-  logLevelCount?: CommonEntry[];
-  vNodeList?: CommonEntry[];
 }
diff --git 
a/ambari-logsearch/ambari-logsearch-web/src/app/services/http-client.service.ts 
b/ambari-logsearch/ambari-logsearch-web/src/app/services/http-client.service.ts
index 52f4d5b..787eb57 100644
--- 
a/ambari-logsearch/ambari-logsearch-web/src/app/services/http-client.service.ts
+++ 
b/ambari-logsearch/ambari-logsearch-web/src/app/services/http-client.service.ts
@@ -73,6 +73,9 @@ export class HttpClientService extends Http {
     components: {
       url: 'service/logs/components/levels/counts'
     },
+    serviceComponentsName: {
+      url: 'service/logs/components'
+    },
     clusters: {
       url: 'service/logs/clusters'
     },
diff --git 
a/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-container.service.ts
 
b/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-container.service.ts
index 7664b3d..3c2493b 100644
--- 
a/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-container.service.ts
+++ 
b/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-container.service.ts
@@ -996,21 +996,32 @@ export class LogsContainerService {
     return request;
   }
 
-  loadComponents(): Observable<Response> {
-    const request = this.httpClient.get('components');
-    request.subscribe((response: Response): void => {
-      const jsonResponse = response.json(),
-        components = jsonResponse && jsonResponse.vNodeList.map((item): 
NodeItem => Object.assign(item, {
-            value: item.logLevelCount.reduce((currentValue: number, 
currentItem): number => {
-              return currentValue + Number(currentItem.value);
-            }, 0)
-          }));
+  loadComponents(): Observable<Response[]> {
+    const requestComponentsData:Observable<Response> = 
this.httpClient.get('components');
+    const requestComponentsName:Observable<Response> = 
this.httpClient.get('serviceComponentsName');
+    const requests = Observable.combineLatest(requestComponentsName, 
requestComponentsData);
+    requests.subscribe((responses:Response[]) => {
+      const componentsNames = responses[0].json();
+      const componentsData = responses[1].json();
+      const components = componentsData && 
componentsData.vNodeList.map((item): NodeItem => {
+        const component = componentsNames.metadata.find(component => 
component.name === item.name);
+        return Object.assign(item, {
+          label: component.label || item.name,
+          group: component && component.group && {
+            name: component.group,
+            label: componentsNames.groups[component.group]
+          },
+          value: item.logLevelCount.reduce((currentValue: number, 
currentItem): number => {
+            return currentValue + Number(currentItem.value);
+          }, 0)
+        });
+      });
       if (components) {
-        this.utils.pushUniqueValues(this.filters.components.options, 
components.map(this.utils.getListItemFromNode));
+        this.utils.pushUniqueValues(this.filters.components.options, 
components.map(node => this.utils.getListItemFromNode(node, true) ));
         this.componentsStorage.addInstances(components);
       }
     });
-    return request;
+    return requests;
   }
 
   loadHosts(): Observable<Response> {
diff --git 
a/ambari-logsearch/ambari-logsearch-web/src/app/services/utils.service.ts 
b/ambari-logsearch/ambari-logsearch-web/src/app/services/utils.service.ts
index c960cd1..eae8928 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/services/utils.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/utils.service.ts
@@ -122,11 +122,13 @@ export class UtilsService {
   /**
    * Get instance for dropdown list from NodeItem object
    * @param node {NodeItem}
+   * @param addGroup {boolean}
    * @returns {ListItem}
    */
-  getListItemFromNode(node: NodeItem): ListItem {
+  getListItemFromNode(node: NodeItem, addGroup: boolean = false): ListItem {
+    const group: string = addGroup && node.group ? `${node.group.label || 
node.group.name}: ` : '';
     return {
-      label: `${node.name} (${node.value})`,
+      label: `${group}${node.label || node.name} (${node.value})`,
       value: node.name
     };
   }

-- 
To stop receiving notification emails like this one, please contact
oleew...@apache.org.

Reply via email to