You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2017/07/07 14:58:22 UTC
[35/36] ambari git commit: AMBARI-21429 Log Search UI: implement
dynamic loading of options for filters. (ababiichuk)
AMBARI-21429 Log Search UI: implement dynamic loading of options for filters. (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/39e1922b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/39e1922b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/39e1922b
Branch: refs/heads/branch-feature-logsearch-ui
Commit: 39e1922b23811943a25a4afdcba5021987aaee98
Parents: 80cdcf2
Author: ababiichuk <ab...@hortonworks.com>
Authored: Fri Jul 7 17:53:27 2017 +0300
Committer: ababiichuk <ab...@hortonworks.com>
Committed: Fri Jul 7 17:53:27 2017 +0300
----------------------------------------------------------------------
.../src/app/app.module.ts | 35 ++++------
.../src/app/components/app.component.spec.ts | 2 +-
.../filter-button.component.spec.ts | 8 ++-
.../filters-panel.component.spec.ts | 23 +++++-
.../filters-panel/filters-panel.component.ts | 32 ++++++++-
.../logs-list/logs-list.component.spec.ts | 8 ++-
.../components/logs-list/logs-list.component.ts | 28 ++++----
.../src/app/models/store.model.ts | 73 ++++++++++++--------
.../src/app/services/filtering.service.spec.ts | 10 ++-
.../src/app/services/filtering.service.ts | 59 +++++-----------
.../src/app/services/http-client.service.ts | 11 ++-
.../services/storage/app-settings.service.ts | 14 ++--
.../app/services/storage/app-state.service.ts | 14 ++--
.../app/services/storage/audit-logs.service.ts | 13 ++--
.../app/services/storage/bar-graphs.service.ts | 13 ++--
.../app/services/storage/clusters.service.ts | 32 +++++++++
.../app/services/storage/components.service.ts | 32 +++++++++
.../src/app/services/storage/filters.service.ts | 13 ++--
.../src/app/services/storage/graphs.service.ts | 13 ++--
.../src/app/services/storage/nodes.service.ts | 14 ++--
.../app/services/storage/reducers.service.ts | 48 +++++++++++++
.../services/storage/service-logs.service.ts | 13 ++--
.../services/storage/user-configs.service.ts | 13 ++--
.../src/assets/mock-data.ts | 25 ++++++-
24 files changed, 364 insertions(+), 182 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/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 65139db..72b5ad1 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
@@ -33,15 +33,18 @@ import {HttpClientService} from '@app/services/http-client.service';
import {ComponentActionsService} from '@app/services/component-actions.service';
import {FilteringService} from '@app/services/filtering.service';
-import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service';
-import {AppStateService, appState} from '@app/services/storage/app-state.service';
-import {AuditLogsService, auditLogs} from '@app/services/storage/audit-logs.service';
-import {ServiceLogsService, serviceLogs} from '@app/services/storage/service-logs.service';
-import {BarGraphsService, barGraphs} from '@app/services/storage/bar-graphs.service';
-import {GraphsService, graphs} from '@app/services/storage/graphs.service';
-import {NodesService, nodes} from '@app/services/storage/nodes.service';
-import {UserConfigsService, userConfigs} from '@app/services/storage/user-configs.service';
-import {FiltersService, filters} from '@app/services/storage/filters.service';
+import {AppSettingsService} from '@app/services/storage/app-settings.service';
+import {AppStateService} from '@app/services/storage/app-state.service';
+import {AuditLogsService} from '@app/services/storage/audit-logs.service';
+import {ServiceLogsService} from '@app/services/storage/service-logs.service';
+import {BarGraphsService} from '@app/services/storage/bar-graphs.service';
+import {GraphsService} from '@app/services/storage/graphs.service';
+import {NodesService} from '@app/services/storage/nodes.service';
+import {UserConfigsService} from '@app/services/storage/user-configs.service';
+import {FiltersService} from '@app/services/storage/filters.service';
+import {ClustersService} from '@app/services/storage/clusters.service';
+import {ComponentsService} from '@app/services/storage/components.service';
+import {reducer} from '@app/services/storage/reducers.service';
import {AppComponent} from '@app/components/app.component';
import {LoginFormComponent} from '@app/components/login-form/login-form.component';
@@ -104,17 +107,7 @@ export function getXHRBackend(injector: Injector, browser: BrowserXhr, xsrf: XSR
deps: [Http]
}
}),
- StoreModule.provideStore({
- appSettings: appSettings,
- appState: appState,
- auditLogs: auditLogs,
- serviceLogs: serviceLogs,
- barGraphs: barGraphs,
- graphs: graphs,
- nodes: nodes,
- userConfigs: userConfigs,
- filters: filters
- }),
+ StoreModule.provideStore(reducer),
MomentModule,
MomentTimezoneModule
],
@@ -131,6 +124,8 @@ export function getXHRBackend(injector: Injector, browser: BrowserXhr, xsrf: XSR
NodesService,
UserConfigsService,
FiltersService,
+ ClustersService,
+ ComponentsService,
{
provide: XHRBackend,
useFactory: getXHRBackend,
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/app.component.spec.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/app.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/app.component.spec.ts
index b1b691c..bc16ea4 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/app.component.spec.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/app.component.spec.ts
@@ -57,7 +57,7 @@ describe('AppComponent', () => {
{
provide: HttpClientService,
useValue: httpClient
- },
+ }
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filter-button/filter-button.component.spec.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filter-button/filter-button.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filter-button/filter-button.component.spec.ts
index 8828390..dda81e6 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filter-button/filter-button.component.spec.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filter-button/filter-button.component.spec.ts
@@ -24,6 +24,8 @@ import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {StoreModule} from '@ngrx/store';
import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service';
+import {ClustersService, clusters} from '@app/services/storage/clusters.service';
+import {ComponentsService, components} from '@app/services/storage/components.service';
import {ComponentActionsService} from '@app/services/component-actions.service';
import {FilteringService} from '@app/services/filtering.service';
@@ -42,7 +44,9 @@ describe('FilterButtonComponent', () => {
declarations: [FilterButtonComponent],
imports: [
StoreModule.provideStore({
- appSettings
+ appSettings,
+ clusters,
+ components
}),
TranslateModule.forRoot({
provide: TranslateLoader,
@@ -51,6 +55,8 @@ describe('FilterButtonComponent', () => {
})],
providers: [
AppSettingsService,
+ ClustersService,
+ ComponentsService,
ComponentActionsService,
FilteringService
],
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filters-panel/filters-panel.component.spec.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filters-panel/filters-panel.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filters-panel/filters-panel.component.spec.ts
index 8291572..1917f7f 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filters-panel/filters-panel.component.spec.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filters-panel/filters-panel.component.spec.ts
@@ -23,7 +23,10 @@ import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {StoreModule} from '@ngrx/store';
import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service';
+import {ClustersService, clusters} from '@app/services/storage/clusters.service';
+import {ComponentsService, components} from '@app/services/storage/components.service';
import {FilteringService} from '@app/services/filtering.service';
+import {HttpClientService} from '@app/services/http-client.service';
import {FiltersPanelComponent} from './filters-panel.component';
@@ -36,11 +39,21 @@ describe('FiltersPanelComponent', () => {
let fixture: ComponentFixture<FiltersPanelComponent>;
beforeEach(async(() => {
+ const httpClient = {
+ get: () => {
+ return {
+ subscribe: () => {
+ }
+ }
+ }
+ };
TestBed.configureTestingModule({
declarations: [FiltersPanelComponent],
imports: [
StoreModule.provideStore({
- appSettings
+ appSettings,
+ clusters,
+ components
}),
TranslateModule.forRoot({
provide: TranslateLoader,
@@ -50,7 +63,13 @@ describe('FiltersPanelComponent', () => {
],
providers: [
AppSettingsService,
- FilteringService
+ ClustersService,
+ ComponentsService,
+ FilteringService,
+ {
+ provide: HttpClientService,
+ useValue: httpClient
+ }
],
schemas: [NO_ERRORS_SCHEMA]
})
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filters-panel/filters-panel.component.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filters-panel/filters-panel.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filters-panel/filters-panel.component.ts
index 652b864..f42a2bb 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filters-panel/filters-panel.component.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/filters-panel/filters-panel.component.ts
@@ -19,6 +19,9 @@
import {Component} from '@angular/core';
import {FormControl, FormGroup} from '@angular/forms';
import {FilteringService} from '@app/services/filtering.service';
+import {HttpClientService} from '@app/services/http-client.service';
+import {ClustersService} from '@app/services/storage/clusters.service';
+import {ComponentsService} from '@app/services/storage/components.service';
@Component({
selector: 'filters-panel',
@@ -27,7 +30,9 @@ import {FilteringService} from '@app/services/filtering.service';
})
export class FiltersPanelComponent {
- constructor(private filtering: FilteringService) {
+ constructor(private filtering: FilteringService, private httpClient: HttpClientService, private clustersStorage: ClustersService, private componentsStorage: ComponentsService) {
+ this.loadClusters();
+ this.loadComponents();
}
get filters() {
@@ -35,11 +40,32 @@ export class FiltersPanelComponent {
}
private filtersFormItems = Object.keys(this.filters).reduce((currentObject, key) => {
- let item = {};
- item[key] = new FormControl();
+ const item = {
+ [key]: new FormControl()
+ };
return Object.assign(currentObject, item);
}, {});
+ private loadClusters(): void {
+ this.httpClient.get('clusters').subscribe(response => {
+ const clusterNames = response.json();
+ if (clusterNames) {
+ this.clustersStorage.addInstances(clusterNames);
+ }
+ });
+ }
+
+ private loadComponents(): void {
+ this.httpClient.get('components').subscribe(response => {
+ const jsonResponse = response.json(),
+ components = jsonResponse && jsonResponse.groupList;
+ if (components) {
+ const componentNames = components.map(component => component.type);
+ this.componentsStorage.addInstances(componentNames);
+ }
+ });
+ }
+
filtersForm = new FormGroup(this.filtersFormItems);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.spec.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.spec.ts
index ea3d780..ffcfb83 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.spec.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.spec.ts
@@ -23,6 +23,8 @@ import {MomentTimezoneModule} from 'angular-moment-timezone';
import {AuditLogsService, auditLogs} from '@app/services/storage/audit-logs.service';
import {ServiceLogsService, serviceLogs} from '@app/services/storage/service-logs.service';
import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service';
+import {ClustersService, clusters} from '@app/services/storage/clusters.service';
+import {ComponentsService, components} from '@app/services/storage/components.service';
import {HttpClientService} from '@app/services/http-client.service';
import {FilteringService} from '@app/services/filtering.service';
@@ -47,7 +49,9 @@ describe('LogsListComponent', () => {
StoreModule.provideStore({
auditLogs,
serviceLogs,
- appSettings
+ appSettings,
+ clusters,
+ components
}),
MomentModule,
MomentTimezoneModule
@@ -60,6 +64,8 @@ describe('LogsListComponent', () => {
AuditLogsService,
ServiceLogsService,
AppSettingsService,
+ ClustersService,
+ ComponentsService,
FilteringService
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.ts
index 5cfe4cc..bf80445 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/components/logs-list/logs-list.component.ts
@@ -49,17 +49,15 @@ export class LogsListComponent implements OnInit {
levels: ['level']
};
- logs = this.serviceLogsStorage.getAll().map(logs => {
- return logs.map(log => {
- return {
- type: log.type,
- level: log.level,
- className: log.level.toLowerCase(),
- message: log.log_message,
- time: log.logtime
- }
- });
- });
+ logs = this.serviceLogsStorage.getAll().map(logs => logs.map(log => {
+ return {
+ type: log.type,
+ level: log.level,
+ className: log.level.toLowerCase(),
+ message: log.log_message,
+ time: log.logtime
+ };
+ }));
get timeZone(): string {
return this.filtering.timeZone;
@@ -67,9 +65,13 @@ export class LogsListComponent implements OnInit {
private loadLogs(): void {
this.httpClient.get(this.logsArrayId, this.getParams()).subscribe(response => {
+ const jsonResponse = response.json(),
+ logs = jsonResponse && jsonResponse.logList;
this.serviceLogsStorage.clear();
- const logs = response.json().logList;
- this.serviceLogsStorage.addInstances(logs);
+ if (logs) {
+ const logs = response.json().logList;
+ this.serviceLogsStorage.addInstances(logs);
+ }
});
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/store.model.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/store.model.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/store.model.ts
index d5f8881..190ab7e 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/models/store.model.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/models/store.model.ts
@@ -29,10 +29,12 @@ import {UserConfig} from '@app/models/user-config.model';
import {Filter} from '@app/models/filter.model';
export const storeActions = {
- ADD: 'ADD',
- DELETE: 'DELETE',
- CLEAR: 'CLEAR',
- SET: 'SET'
+ 'ARRAY.ADD': 'ADD',
+ 'ARRAY.DELETE.PRIMITIVE': 'DELETE_PRIMITIVE',
+ 'ARRAY.DELETE.OBJECT': 'DELETE_OBJECT',
+ 'ARRAY.CLEAR': 'CLEAR',
+
+ 'OBJECT.SET': 'SET'
};
export interface AppStore {
@@ -45,6 +47,8 @@ export interface AppStore {
nodes: Node[];
userConfigs: UserConfig[];
filters: Filter[];
+ clusters: string[];
+ components: string[];
}
export class ModelService {
@@ -72,21 +76,28 @@ export class CollectionModelService extends ModelService {
addInstances(instances: any[]): void {
this.store.dispatch({
- type: storeActions.ADD,
+ type: `${storeActions['ARRAY.ADD']}_${this.modelName}`,
payload: instances
});
}
- deleteInstance(instance: any): void {
+ deleteObjectInstance(instance: any): void {
+ this.store.dispatch({
+ type: `${storeActions['ARRAY.DELETE.OBJECT']}_${this.modelName}`,
+ payload: instance
+ });
+ }
+
+ deletePrimitiveInstance(instance: any): void {
this.store.dispatch({
- type: storeActions.DELETE,
+ type: `${storeActions['ARRAY.DELETE.PRINITIVE']}_${this.modelName}`,
payload: instance
});
}
clear(): void {
this.store.dispatch({
- type: storeActions.CLEAR
+ type: `${storeActions['ARRAY.CLEAR']}_${this.modelName}`
});
}
@@ -106,33 +117,37 @@ export class ObjectModelService extends ModelService {
setParameters(params: any): void {
this.store.dispatch({
- type: storeActions.SET,
+ type: `${storeActions['OBJECT.SET']}_${this.modelName}`,
payload: params
});
}
}
-export function collectionReducer(state: any[] = [], action: Action): any {
- switch (action.type) {
- case storeActions.ADD:
- return [...state, ...action.payload];
- case storeActions.DELETE:
- return state.filter(instance => {
- return instance.id !== action.payload.id;
- });
- case storeActions.CLEAR:
- return [];
- default:
- return state;
- }
+export function getCollectionReducer(modelName: string, defaultState: any = []): any {
+ return (state: any = defaultState, action: Action) => {
+ switch (action.type) {
+ case `${storeActions['ARRAY.ADD']}_${modelName}`:
+ return [...state, ...action.payload];
+ case `${storeActions['ARRAY.DELETE.OBJECT']}_${modelName}`:
+ return state.filter(instance => instance.id !== action.payload.id);
+ case `${storeActions['ARRAY.DELETE.PRIMITIVE']}_${modelName}`:
+ return state.filter(item => item !== action.payload);
+ case `${storeActions['ARRAY.CLEAR']}_${modelName}`:
+ return [];
+ default:
+ return state;
+ }
+ };
}
-export function objectReducer(state: any = {}, action: Action): any {
- switch (action.type) {
- case storeActions.SET:
- return Object.assign({}, state, action.payload);
- default:
- return state;
- }
+export function getObjectReducer(modelName: string, defaultState: any = {}) {
+ return (state: any = defaultState, action: Action): any => {
+ switch (action.type) {
+ case `${storeActions['OBJECT.SET']}_${modelName}`:
+ return Object.assign({}, state, action.payload);
+ default:
+ return state;
+ }
+ };
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.spec.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.spec.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.spec.ts
index a8dc017..0ad3795 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.spec.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.spec.ts
@@ -19,6 +19,8 @@
import {TestBed, inject} from '@angular/core/testing';
import {StoreModule} from '@ngrx/store';
import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service';
+import {ClustersService, clusters} from '@app/services/storage/clusters.service';
+import {ComponentsService, components} from '@app/services/storage/components.service';
import {FilteringService} from './filtering.service';
@@ -27,12 +29,16 @@ describe('FilteringService', () => {
TestBed.configureTestingModule({
imports: [
StoreModule.provideStore({
- appSettings
+ appSettings,
+ clusters,
+ components
})
],
providers: [
FilteringService,
- AppSettingsService
+ AppSettingsService,
+ ClustersService,
+ ComponentsService
]
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.ts
index ce451d3..36bb756 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/filtering.service.ts
@@ -20,15 +20,28 @@ import {Injectable} from '@angular/core';
import {Subject} from 'rxjs/Subject';
import * as moment from 'moment-timezone';
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';
@Injectable()
export class FilteringService {
- constructor(private appSettings: AppSettingsService) {
- this.appSettings.getParameter('timeZone').subscribe(value => this.timeZone = value);
+ constructor(private appSettings: AppSettingsService, private clustersStorage: ClustersService, private componentsStorage: ComponentsService) {
+ this.appSettings.getParameter('timeZone').subscribe(value => this.timeZone = value || this.defaultTimeZone);
+ this.clustersStorage.getAll().subscribe(clusters => this.filters.clusters.options = [...this.filters.clusters.options, ...clusters.map(this.getListItem)]);
+ this.componentsStorage.getAll().subscribe(components => this.filters.components.options = [...this.filters.components.options, ...components.map(this.getListItem)]);
}
- timeZone: string;
+ private getListItem(name: string): any {
+ return {
+ label: name,
+ value: name
+ };
+ }
+
+ private readonly defaultTimeZone = moment.tz.guess();
+
+ timeZone: string = this.defaultTimeZone;
// TODO implement loading of real options data
filters = {
@@ -38,26 +51,6 @@ export class FilteringService {
{
label: 'filter.all',
value: ''
- },
- {
- label: 'cl0',
- value: 'cl0'
- },
- {
- label: 'cl1',
- value: 'cl1'
- },
- {
- label: 'cl2',
- value: 'cl2'
- },
- {
- label: 'cl3',
- value: 'cl3'
- },
- {
- label: 'cl4',
- value: 'cl4'
}
],
selectedValue: '',
@@ -152,8 +145,8 @@ export class FilteringService {
value: zone
};
}),
- selectedValue: moment.tz.guess(),
- selectedLabel: this.getTimeZoneLabel(moment.tz.guess())
+ selectedValue: this.defaultTimeZone,
+ selectedLabel: this.getTimeZoneLabel(this.defaultTimeZone)
},
components: {
label: 'filter.components',
@@ -162,22 +155,6 @@ export class FilteringService {
{
label: 'filter.all',
value: ''
- },
- {
- label: 'ambari_agent',
- value: 'ambari_agent'
- },
- {
- label: 'ams_collector',
- value: 'ams_collector'
- },
- {
- label: 'zookeeper_server',
- value: 'zookeeper_server'
- },
- {
- label: 'zookeeper_client',
- value: 'zookeeper_client'
}
],
selectedValue: '',
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.ts
index 4ab85e5..0d06899 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/http-client.service.ts
@@ -18,9 +18,8 @@
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
+import 'rxjs/add/operator/first';
import {Http, XHRBackend, Request, RequestOptions, RequestOptionsArgs, Response, Headers, URLSearchParams} from '@angular/http';
-import 'rxjs/add/operator/map';
-import 'rxjs/add/operator/catch';
import {AuditLogsQueryParams} from '@app/classes/queries/audit-logs-query-params.class';
import {ServiceLogsQueryParams} from '@app/classes/queries/service-logs-query-params.class';
import {AppStateService} from '@app/services/storage/app-state.service';
@@ -45,6 +44,12 @@ export class HttpClientService extends Http {
serviceLogs: {
url: 'service/logs',
params: opts => new ServiceLogsQueryParams(opts)
+ },
+ components: {
+ url: 'service/logs/components'
+ },
+ clusters: {
+ url: 'service/logs/clusters'
}
};
@@ -93,7 +98,7 @@ export class HttpClientService extends Http {
}
request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> {
- let req = super.request(this.generateUrl(url), options).share();
+ let req = super.request(this.generateUrl(url), options).share().first();
this.handleError(req);
return req;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/app-settings.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/app-settings.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/app-settings.service.ts
index faed254..9478510 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/app-settings.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/app-settings.service.ts
@@ -17,17 +17,17 @@
*/
import {Injectable} from '@angular/core';
-import {Action, Store} from '@ngrx/store';
-import {AppSettings, defaultSettings} from '@app/models/app-settings.model';
-import {AppStore, ObjectModelService, objectReducer} from '@app/models/store.model';
+import {Store} from '@ngrx/store';
+import {defaultSettings} from '@app/models/app-settings.model';
+import {AppStore, ObjectModelService, getObjectReducer} from '@app/models/store.model';
+
+export const modelName = 'appSettings';
@Injectable()
export class AppSettingsService extends ObjectModelService {
constructor(store: Store<AppStore>) {
- super('appSettings', store);
+ super(modelName, store);
}
}
-export function appSettings(state: AppSettings = defaultSettings, action: Action): any {
- return objectReducer(state, action);
-}
+export const appSettings = getObjectReducer(modelName, defaultSettings);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/app-state.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/app-state.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/app-state.service.ts
index 49dfa77..0beed98 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/app-state.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/app-state.service.ts
@@ -17,17 +17,17 @@
*/
import {Injectable} from '@angular/core';
-import {Action, Store} from '@ngrx/store';
-import {AppState, initialState} from '@app/models/app-state.model';
-import {AppStore, ObjectModelService, objectReducer} from '@app/models/store.model';
+import {Store} from '@ngrx/store';
+import {initialState} from '@app/models/app-state.model';
+import {AppStore, ObjectModelService, getObjectReducer} from '@app/models/store.model';
+
+export const modelName = 'appState';
@Injectable()
export class AppStateService extends ObjectModelService {
constructor(store: Store<AppStore>) {
- super('appState', store);
+ super(modelName, store);
}
}
-export function appState(state: AppState = initialState, action: Action): any {
- return objectReducer(state, action);
-}
+export const appState = getObjectReducer(modelName, initialState);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/audit-logs.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/audit-logs.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/audit-logs.service.ts
index a50c68d..c0a798e 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/audit-logs.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/audit-logs.service.ts
@@ -17,17 +17,16 @@
*/
import {Injectable} from '@angular/core';
-import {Action, Store} from '@ngrx/store';
-import {AuditLog} from '@app/models/audit-log.model';
-import {AppStore, CollectionModelService, collectionReducer} from '@app/models/store.model';
+import {Store} from '@ngrx/store';
+import {AppStore, CollectionModelService, getCollectionReducer} from '@app/models/store.model';
+
+export const modelName = 'auditLogs';
@Injectable()
export class AuditLogsService extends CollectionModelService {
constructor(store: Store<AppStore>) {
- super('auditLogs', store);
+ super(modelName, store);
}
}
-export function auditLogs(state: AuditLog[] = [], action: Action): any {
- return collectionReducer(state, action);
-}
+export const auditLogs = getCollectionReducer(modelName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/bar-graphs.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/bar-graphs.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/bar-graphs.service.ts
index b3b955a..e9a3cb7 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/bar-graphs.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/bar-graphs.service.ts
@@ -17,17 +17,16 @@
*/
import {Injectable} from '@angular/core';
-import {Action, Store} from '@ngrx/store';
-import {BarGraph} from '@app/models/bar-graph.model';
-import {AppStore, CollectionModelService, collectionReducer} from '@app/models/store.model';
+import {Store} from '@ngrx/store';
+import {AppStore, CollectionModelService, getCollectionReducer} from '@app/models/store.model';
+
+export const modelName = 'barGraphs';
@Injectable()
export class BarGraphsService extends CollectionModelService {
constructor(store: Store<AppStore>) {
- super('barGraphs', store);
+ super(modelName, store);
}
}
-export function barGraphs(state: BarGraph[] = [], action: Action): any {
- return collectionReducer(state, action);
-}
+export const barGraphs = getCollectionReducer(modelName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/clusters.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/clusters.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/clusters.service.ts
new file mode 100644
index 0000000..8313992
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/clusters.service.ts
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http; //www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {Injectable} from '@angular/core';
+import {Store} from '@ngrx/store';
+import {AppStore, CollectionModelService, getCollectionReducer} from '@app/models/store.model';
+
+export const modelName = 'clusters';
+
+@Injectable()
+export class ClustersService extends CollectionModelService {
+ constructor(store: Store<AppStore>) {
+ super(modelName, store);
+ }
+}
+
+export const clusters = getCollectionReducer(modelName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/components.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/components.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/components.service.ts
new file mode 100644
index 0000000..9fcddd4
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/components.service.ts
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http; //www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {Injectable} from '@angular/core';
+import {Store} from '@ngrx/store';
+import {AppStore, CollectionModelService, getCollectionReducer} from '@app/models/store.model';
+
+export const modelName = 'components';
+
+@Injectable()
+export class ComponentsService extends CollectionModelService {
+ constructor(store: Store<AppStore>) {
+ super(modelName, store);
+ }
+}
+
+export const components = getCollectionReducer(modelName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/filters.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/filters.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/filters.service.ts
index a06852c..37116b9 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/filters.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/filters.service.ts
@@ -18,17 +18,16 @@
import {Injectable} from '@angular/core';
-import {Action, Store} from '@ngrx/store';
-import {Filter} from '@app/models/filter.model';
-import {AppStore, CollectionModelService, collectionReducer} from '@app/models/store.model';
+import {Store} from '@ngrx/store';
+import {AppStore, CollectionModelService, getCollectionReducer} from '@app/models/store.model';
+
+export const modelName = 'filters';
@Injectable()
export class FiltersService extends CollectionModelService {
constructor(store: Store<AppStore>) {
- super('filters', store);
+ super(modelName, store);
}
}
-export function filters(state: Filter[] = [], action: Action): any {
- return collectionReducer(state, action);
-}
+export const filters = getCollectionReducer(modelName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/graphs.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/graphs.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/graphs.service.ts
index 0abd910..7c95fcf 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/graphs.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/graphs.service.ts
@@ -18,17 +18,16 @@
import {Injectable} from '@angular/core';
-import {Action, Store} from '@ngrx/store';
-import {Graph} from '@app/models/graph.model';
-import {AppStore, CollectionModelService, collectionReducer} from '@app/models/store.model';
+import {Store} from '@ngrx/store';
+import {AppStore, CollectionModelService, getCollectionReducer} from '@app/models/store.model';
+
+export const modelName = 'graphs';
@Injectable()
export class GraphsService extends CollectionModelService {
constructor(store: Store<AppStore>) {
- super('graphs', store);
+ super(modelName, store);
}
}
-export function graphs(state: Graph[] = [], action: Action): any {
- return collectionReducer(state, action);
-}
+export const graphs = getCollectionReducer(modelName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/nodes.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/nodes.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/nodes.service.ts
index 4e47609..594290a 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/nodes.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/nodes.service.ts
@@ -16,19 +16,17 @@
* limitations under the License.
*/
-
import {Injectable} from '@angular/core';
-import {Action, Store} from '@ngrx/store';
-import {Node} from '@app/models/node.model';
-import {AppStore, CollectionModelService, collectionReducer} from '@app/models/store.model';
+import {Store} from '@ngrx/store';
+import {AppStore, CollectionModelService, getCollectionReducer} from '@app/models/store.model';
+
+export const modelName = 'nodes';
@Injectable()
export class NodesService extends CollectionModelService {
constructor(store: Store<AppStore>) {
- super('nodes', store);
+ super(modelName, store);
}
}
-export function nodes(state: Node[] = [], action: Action): any {
- return collectionReducer(state, action);
-}
+export const nodes = getCollectionReducer(modelName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/reducers.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/reducers.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/reducers.service.ts
new file mode 100644
index 0000000..6665901
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/reducers.service.ts
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http; //www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {combineReducers} from '@ngrx/store';
+import {appSettings} from '@app/services/storage/app-settings.service';
+import {appState} from '@app/services/storage/app-state.service';
+import {auditLogs} from '@app/services/storage/audit-logs.service';
+import {barGraphs} from '@app/services/storage/bar-graphs.service';
+import {clusters} from '@app/services/storage/clusters.service';
+import {components} from '@app/services/storage/components.service';
+import {filters} from '@app/services/storage/filters.service';
+import {graphs} from '@app/services/storage/graphs.service';
+import {nodes} from '@app/services/storage/nodes.service';
+import {serviceLogs} from '@app/services/storage/service-logs.service';
+import {userConfigs} from '@app/services/storage/user-configs.service';
+
+export const reducers = {
+ appSettings,
+ appState,
+ auditLogs,
+ serviceLogs,
+ barGraphs,
+ graphs,
+ nodes,
+ userConfigs,
+ filters,
+ clusters,
+ components
+};
+
+export function reducer(state: any, action: any) {
+ return (combineReducers(reducers))(state, action);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/service-logs.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/service-logs.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/service-logs.service.ts
index ab77138..24c3776 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/service-logs.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/service-logs.service.ts
@@ -18,17 +18,16 @@
import {Injectable} from '@angular/core';
-import {Action, Store} from '@ngrx/store';
-import {ServiceLog} from '@app/models/service-log.model';
-import {AppStore, CollectionModelService, collectionReducer} from '@app/models/store.model';
+import {Store} from '@ngrx/store';
+import {AppStore, CollectionModelService, getCollectionReducer} from '@app/models/store.model';
+
+export const modelName = 'serviceLogs';
@Injectable()
export class ServiceLogsService extends CollectionModelService {
constructor(store: Store<AppStore>) {
- super('serviceLogs', store);
+ super(modelName, store);
}
}
-export function serviceLogs(state: ServiceLog[] = [], action: Action): any {
- return collectionReducer(state, action);
-}
+export const serviceLogs = getCollectionReducer(modelName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/user-configs.service.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/user-configs.service.ts b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/user-configs.service.ts
index 36cfd5f..6640a30 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/user-configs.service.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/app/services/storage/user-configs.service.ts
@@ -18,17 +18,16 @@
import {Injectable} from '@angular/core';
-import {Action, Store} from '@ngrx/store';
-import {UserConfig} from '@app/models/user-config.model';
-import {AppStore, CollectionModelService, collectionReducer} from '@app/models/store.model';
+import {Store} from '@ngrx/store';
+import {AppStore, CollectionModelService, getCollectionReducer} from '@app/models/store.model';
+
+export const modelName = 'userConfigs';
@Injectable()
export class UserConfigsService extends CollectionModelService {
constructor(store: Store<AppStore>) {
- super('userConfigs', store);
+ super(modelName, store);
}
}
-export function userConfigs(state: UserConfig[] = [], action: Action): any {
- return collectionReducer(state, action);
-}
+export const userConfigs = getCollectionReducer(modelName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/39e1922b/ambari-logsearch/ambari-logsearch-web-new/src/assets/mock-data.ts
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web-new/src/assets/mock-data.ts b/ambari-logsearch/ambari-logsearch-web-new/src/assets/mock-data.ts
index 732e8d3..3d04122 100644
--- a/ambari-logsearch/ambari-logsearch-web-new/src/assets/mock-data.ts
+++ b/ambari-logsearch/ambari-logsearch-web-new/src/assets/mock-data.ts
@@ -531,7 +531,21 @@ export const mockData = {
}
]
}
- }
+ },
+ groupList: [
+ {
+ type: 'ams_collector'
+ },
+ {
+ type: 'ambari_agent'
+ },
+ {
+ type: 'zookeeper_server'
+ },
+ {
+ type: 'zookeeper_client'
+ }
+ ]
},
files: {
hostLogFiles: {
@@ -798,7 +812,14 @@ export const mockData = {
_router_field_: 5
}
]
- }
+ },
+ clusters: [
+ 'cl0',
+ 'cl1',
+ 'cl2',
+ 'cl3',
+ 'cl4'
+ ]
}
},
status: {