You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2017/10/09 06:01:13 UTC

[15/50] [abbrv] ambari git commit: AMBARI-22128 Log Search UI: add event bars for Components list item. (ababiichuk)

AMBARI-22128 Log Search UI: add event bars for Components list item. (ababiichuk)


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

Branch: refs/heads/branch-feature-AMBARI-14714
Commit: 15cd1c598ba1285dcde8df47f72647f5c7fc29e7
Parents: 67396ba
Author: ababiichuk <ab...@hortonworks.com>
Authored: Wed Oct 4 14:08:37 2017 +0300
Committer: ababiichuk <ab...@hortonworks.com>
Committed: Wed Oct 4 14:08:37 2017 +0300

----------------------------------------------------------------------
 .../filters-panel/filters-panel.component.html  |  3 +-
 .../src/app/models/node.model.ts                |  3 +-
 .../src/app/models/store.model.ts               |  2 +-
 .../app/services/component-generator.service.ts | 23 ++++++++-
 .../src/app/services/filtering.service.spec.ts  | 27 ++++++++++
 .../src/app/services/filtering.service.ts       | 53 +++++++++++++-------
 .../src/app/services/http-client.service.ts     |  2 +-
 7 files changed, 90 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd1c59/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.html
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.html b/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.html
index fc3dac8..e0db997 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.html
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.html
@@ -39,7 +39,8 @@
                    additionalLabelComponentSetter="getDataForHostsNodeBar"></filter-button>
     <filter-button formControlName="components" label="{{filters.components.label | translate}}"
                    [iconClass]="filters.components.iconClass" [subItems]="filters.components.options"
-                   [isMultipleChoice]="true" [isRightAlign]="true"></filter-button>
+                   [isMultipleChoice]="true" [isRightAlign]="true"
+                   additionalLabelComponentSetter="getDataForComponentsNodeBar"></filter-button>
     <filter-button formControlName="levels" label="{{filters.levels.label | translate}}" [iconClass]="filters.levels.iconClass"
                    [subItems]="filters.levels.options" [isMultipleChoice]="true" [isRightAlign]="true"></filter-button>
     <menu-button *ngIf="!captureSeconds" label="{{'filter.capture' | translate}}" iconClass="fa fa-caret-right"

http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd1c59/ambari-logsearch/ambari-logsearch-web/src/app/models/node.model.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/models/node.model.ts b/ambari-logsearch/ambari-logsearch-web/src/app/models/node.model.ts
index 2891d142..b01421e 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/models/node.model.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/models/node.model.ts
@@ -25,5 +25,6 @@ export interface Node {
   isParent: boolean;
   isRoot: boolean;
   childs?: Node[];
-  logLevelCount: CommonEntry[];
+  logLevelCount?: CommonEntry[];
+  vNodeList?: CommonEntry[];
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd1c59/ambari-logsearch/ambari-logsearch-web/src/app/models/store.model.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/models/store.model.ts b/ambari-logsearch/ambari-logsearch-web/src/app/models/store.model.ts
index a6a084f..518e7cd 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/models/store.model.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/models/store.model.ts
@@ -53,7 +53,7 @@ export interface AppStore {
   userConfigs: UserConfig[];
   filters: Filter[];
   clusters: string[];
-  components: string[];
+  components: Node[];
   serviceLogsFields: ServiceLogField[];
   auditLogsFields: AuditLogField[];
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd1c59/ambari-logsearch/ambari-logsearch-web/src/app/services/component-generator.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/component-generator.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/component-generator.service.ts
index c49f40f..43755c0 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/services/component-generator.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/component-generator.service.ts
@@ -18,13 +18,14 @@
 
 import {Injectable, ComponentFactoryResolver, ViewContainerRef} from '@angular/core';
 import {HostsService} from '@app/services/storage/hosts.service';
+import {ComponentsService} from '@app/services/storage/components.service';
 import {LogsContainerService} from '@app/services/logs-container.service';
 import {NodeBarComponent} from '@app/components/node-bar/node-bar.component';
 
 @Injectable()
 export class ComponentGeneratorService {
 
-  constructor(private resolver: ComponentFactoryResolver, private hostsStorage: HostsService, private logsContainer: LogsContainerService) {
+  constructor(private resolver: ComponentFactoryResolver, private hostsStorage: HostsService, private componentsStorage: ComponentsService, private logsContainer: LogsContainerService) {
   }
 
   private createComponent(type: any, container: ViewContainerRef, properties?: any): void {
@@ -54,4 +55,24 @@ export class ComponentGeneratorService {
     });
   }
 
+  getDataForComponentsNodeBar(componentName: string, container: ViewContainerRef): void {
+    let data;
+    this.componentsStorage.getAll().subscribe(components => {
+      if (container && components && components.length) {
+        const selectedHost = components.find(host => host.name === componentName);
+        data = selectedHost.logLevelCount.map(event => {
+          return {
+            color: this.logsContainer.colors[event.name],
+            value: event.value
+          };
+        });
+        if (data.length) {
+          this.createComponent(NodeBarComponent, container, {
+            data
+          });
+        }
+      }
+    });
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd1c59/ambari-logsearch/ambari-logsearch-web/src/app/services/filtering.service.spec.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/filtering.service.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/filtering.service.spec.ts
index e3f731e..c4db041 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/services/filtering.service.spec.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/filtering.service.spec.ts
@@ -24,6 +24,8 @@ import {ComponentsService, components} from '@app/services/storage/components.se
 import {HostsService, hosts} from '@app/services/storage/hosts.service';
 import {UtilsService} from '@app/services/utils.service';
 import {HttpClientService} from '@app/services/http-client.service';
+import {ListItem} from '@app/classes/list-item.class';
+import {Node} from '@app/models/node.model';
 
 import {FilteringService} from './filtering.service';
 
@@ -64,4 +66,29 @@ describe('FilteringService', () => {
   it('should create service', inject([FilteringService], (service: FilteringService) => {
     expect(service).toBeTruthy();
   }));
+
+  describe('#getListItemFromString()', () => {
+    it('should convert string to ListItem', inject([FilteringService], (service: FilteringService) => {
+      const getListItemFromString: (name: string) => ListItem = service['getListItemFromString'];
+      expect(getListItemFromString('customName')).toEqual({
+        label: 'customName',
+        value: 'customName'
+      });
+    }));
+  });
+
+  describe('#getListItemFromNode()', () => {
+    it('should convert Node to ListItem', inject([FilteringService], (service: FilteringService) => {
+      const getListItemFromNode: (node: Node) => ListItem = service['getListItemFromNode'];
+      expect(getListItemFromNode({
+        name: 'customName',
+        value: '1',
+        isParent: true,
+        isRoot: true
+      })).toEqual({
+        label: 'customName (1)',
+        value: 'customName'
+      });
+    }));
+  });
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd1c59/ambari-logsearch/ambari-logsearch-web/src/app/services/filtering.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/filtering.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/filtering.service.ts
index 0fff75d..7fe6517 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/services/filtering.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/filtering.service.ts
@@ -18,12 +18,14 @@
 
 import {Injectable} from '@angular/core';
 import {FormControl, FormGroup} from '@angular/forms';
+import {Response} from '@angular/http';
 import {Subject} from 'rxjs/Subject';
 import {Observable} from 'rxjs/Observable';
 import 'rxjs/add/observable/timer';
 import 'rxjs/add/operator/takeUntil';
 import * as moment from 'moment-timezone';
 import {ListItem} from '@app/classes/list-item.class';
+import {Node} from '@app/models/node.model';
 import {AppSettingsService} from '@app/services/storage/app-settings.service';
 import {ClustersService} from '@app/services/storage/clusters.service';
 import {ComponentsService} from '@app/services/storage/components.service';
@@ -35,29 +37,41 @@ export class FilteringService {
 
   constructor(private httpClient: HttpClientService, private appSettings: AppSettingsService, private clustersStorage: ClustersService, private componentsStorage: ComponentsService, private hostsStorage: HostsService) {
     appSettings.getParameter('timeZone').subscribe(value => this.timeZone = value || this.defaultTimeZone);
-    clustersStorage.getAll().subscribe(clusters => {
-      this.filters.clusters.options = [...this.filters.clusters.options, ...clusters.map(this.getListItem)];
+    clustersStorage.getAll().subscribe((clusters: string[]): void => {
+      this.filters.clusters.options = [...this.filters.clusters.options, ...clusters.map(this.getListItemFromString)];
     });
-    componentsStorage.getAll().subscribe(components => {
-      this.filters.components.options = [...this.filters.components.options, ...components.map(this.getListItem)];
+    componentsStorage.getAll().subscribe((components: Node[]): void => {
+     this.filters.components.options = [...this.filters.components.options, ...components.map(this.getListItemFromNode)];
     });
-    hostsStorage.getAll().subscribe(hosts => {
-      this.filters.hosts.options = [...this.filters.hosts.options, ...hosts.map(host => {
-        return {
-          label: `${host.name} (${host.value})`,
-          value: host.name
-        };
-      })];
+    hostsStorage.getAll().subscribe((hosts: Node[]): void => {
+      this.filters.hosts.options = [...this.filters.hosts.options, ...hosts.map(this.getListItemFromNode)];
     });
   }
 
-  private getListItem(name: string): ListItem {
+  /**
+   * Get instance for dropdown list from string
+   * @param name {string}
+   * @returns {ListItem}
+   */
+  private getListItemFromString(name: string): ListItem {
     return {
       label: name,
       value: name
     };
   }
 
+  /**
+   * Get instance for dropdown list from Node object
+   * @param name {Node}
+   * @returns {ListItem}
+   */
+  private getListItemFromNode(node: Node): ListItem {
+    return {
+      label: `${node.name} (${node.value})`,
+      value: node.name
+    };
+  }
+
   private readonly defaultTimeZone = moment.tz.guess();
 
   private readonly paginationOptions = ['10', '25', '50', '100'];
@@ -423,7 +437,7 @@ export class FilteringService {
   }
 
   loadClusters(): void {
-    this.httpClient.get('clusters').subscribe(response => {
+    this.httpClient.get('clusters').subscribe((response: Response): void => {
       const clusterNames = response.json();
       if (clusterNames) {
         this.clustersStorage.addInstances(clusterNames);
@@ -432,18 +446,21 @@ export class FilteringService {
   }
 
   loadComponents(): void {
-    this.httpClient.get('components').subscribe(response => {
+    this.httpClient.get('components').subscribe((response: Response): void => {
       const jsonResponse = response.json(),
-        components = jsonResponse && jsonResponse.groupList;
+        components = jsonResponse && jsonResponse.vNodeList.map((item): Node => Object.assign(item, {
+            value: item.logLevelCount.reduce((currentValue: number, currentItem): number => {
+              return currentValue + Number(currentItem.value);
+            }, 0)
+          }));
       if (components) {
-        const componentNames = components.map(component => component.type);
-        this.componentsStorage.addInstances(componentNames);
+        this.componentsStorage.addInstances(components);
       }
     });
   }
 
   loadHosts(): void {
-    this.httpClient.get('hosts').subscribe(response => {
+    this.httpClient.get('hosts').subscribe((response: Response): void => {
       const jsonResponse = response.json(),
         hosts = jsonResponse && jsonResponse.vNodeList;
       if (hosts) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd1c59/ambari-logsearch/ambari-logsearch-web/src/app/services/http-client.service.ts
----------------------------------------------------------------------
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 44a5f6a..495f706 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
@@ -62,7 +62,7 @@ export class HttpClientService extends Http {
       params: opts => new ServiceLogsTruncatedQueryParams(opts)
     },
     components: {
-      url: 'service/logs/components'
+      url: 'service/logs/components/levels/counts'
     },
     clusters: {
       url: 'service/logs/clusters'