AMBARI-22416 Log Search UI: fixes for filtering form. (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ebc627a2 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ebc627a2 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ebc627a2 Branch: refs/heads/branch-feature-AMBARI-22008 Commit: ebc627a2b70a7ddd9f890c0b4f54bde09ec0054d Parents: 3ad469d Author: ababiichuk <ababiic...@hortonworks.com> Authored: Fri Nov 10 18:16:45 2017 +0200 Committer: Attila Magyar <amag...@hortonworks.com> Committed: Thu Nov 16 16:35:28 2017 +0100 ---------------------------------------------------------------------- .../ambari-logsearch-web/src/app/app.module.ts | 2 - .../src/app/classes/filtering.ts | 355 +--------- .../src/app/classes/models/app-state.ts | 6 +- .../src/app/classes/models/node-item.ts | 30 + .../src/app/classes/models/node.ts | 30 - .../src/app/classes/models/store.ts | 6 +- .../src/app/classes/models/tab.ts | 12 +- .../src/app/components/app.component.ts | 6 +- .../dropdown-button.component.html | 4 +- .../dropdown-button.component.spec.ts | 2 - .../dropdown-button.component.ts | 55 +- .../dropdown-list/dropdown-list.component.html | 2 +- .../dropdown-list.component.spec.ts | 6 +- .../filter-button.component.spec.ts | 2 - .../filter-button/filter-button.component.ts | 35 +- .../filter-dropdown.component.spec.ts | 14 +- .../filter-dropdown.component.ts | 22 +- .../filters-panel/filters-panel.component.html | 6 +- .../filters-panel.component.spec.ts | 6 +- .../filters-panel/filters-panel.component.ts | 18 +- .../log-context/log-context.component.spec.ts | 4 +- .../logs-container.component.spec.ts | 2 - .../logs-container/logs-container.component.ts | 26 +- .../logs-list/logs-list.component.html | 3 +- .../logs-list/logs-list.component.spec.ts | 21 +- .../components/logs-list/logs-list.component.ts | 10 +- .../menu-button/menu-button.component.spec.ts | 2 - .../menu-button/menu-button.component.ts | 4 +- .../pagination-controls.component.ts | 7 +- .../pagination/pagination.component.html | 2 +- .../pagination/pagination.component.spec.ts | 9 +- .../pagination/pagination.component.ts | 10 +- .../search-box/search-box.component.ts | 12 +- .../time-range-picker.component.html | 3 +- .../time-range-picker.component.spec.ts | 29 +- .../time-range-picker.component.ts | 47 +- .../timezone-picker.component.spec.ts | 2 - .../services/component-actions.service.spec.ts | 2 - .../app/services/component-actions.service.ts | 24 +- .../component-generator.service.spec.ts | 2 - .../src/app/services/filtering.service.spec.ts | 97 --- .../src/app/services/filtering.service.ts | 253 ------- .../app/services/logs-container.service.spec.ts | 31 +- .../src/app/services/logs-container.service.ts | 678 ++++++++++++++++++- .../src/app/services/utils.service.spec.ts | 285 +++++++- .../src/app/services/utils.service.ts | 65 +- 46 files changed, 1257 insertions(+), 992 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts ---------------------------------------------------------------------- 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 56562df..37f3a49 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/app.module.ts @@ -34,7 +34,6 @@ import {environment} from '@envs/environment'; import {mockApiDataService} from '@app/services/mock-api-data.service' import {HttpClientService} from '@app/services/http-client.service'; import {ComponentActionsService} from '@app/services/component-actions.service'; -import {FilteringService} from '@app/services/filtering.service'; import {UtilsService} from '@app/services/utils.service'; import {LogsContainerService} from '@app/services/logs-container.service'; import {ComponentGeneratorService} from '@app/services/component-generator.service'; @@ -164,7 +163,6 @@ export function getXHRBackend(injector: Injector, browser: BrowserXhr, xsrf: XSR providers: [ HttpClientService, ComponentActionsService, - FilteringService, UtilsService, LogsContainerService, ComponentGeneratorService, http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/classes/filtering.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/classes/filtering.ts b/ambari-logsearch/ambari-logsearch-web/src/app/classes/filtering.ts index dde144b..2a7205f 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/classes/filtering.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/classes/filtering.ts @@ -16,354 +16,37 @@ * limitations under the License. */ -import {FormGroup, FormControl} from '@angular/forms'; +import {Moment, unitOfTime} from 'moment'; import {ListItem} from '@app/classes/list-item'; export interface TimeUnit { type: 'CURRENT' | 'LAST' | 'PAST'; - unit: 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'M' | 'Y'; + unit: unitOfTime.DurationConstructor; interval?: number; } +export interface CustomTimeRange { + type: 'CUSTOM'; + start?: Moment; + end?: Moment; +} + +export interface SortingConditions { + key: string; + type: 'asc' | 'desc'; +} + export interface TimeUnitListItem extends ListItem { - value: TimeUnit; + value: TimeUnit | CustomTimeRange; +} + +export interface SortingListItem extends ListItem { + value: SortingConditions; } export interface FilterCondition { label?: string; options?: (ListItem | TimeUnitListItem[])[]; - defaultValue?: string | number | {[key: string]: any}; - defaultLabel?: string; + defaultSelection?: ListItem | ListItem[] | number; iconClass?: string; } - -const paginationOptions: string[] = ['10', '25', '50', '100']; - -export const filters: {[key: string]: FilterCondition} = { - clusters: { - label: 'filter.clusters', - options: [], - defaultValue: '' - }, - timeRange: { - options: [ - [ - { - label: 'filter.timeRange.7d', - value: { - type: 'LAST', - unit: 'd', - interval: 7 - } - }, - { - label: 'filter.timeRange.30d', - value: { - type: 'LAST', - unit: 'd', - interval: 30 - } - }, - { - label: 'filter.timeRange.60d', - value: { - type: 'LAST', - unit: 'd', - interval: 60 - } - }, - { - label: 'filter.timeRange.90d', - value: { - type: 'LAST', - unit: 'd', - interval: 90 - } - }, - { - label: 'filter.timeRange.6m', - value: { - type: 'LAST', - unit: 'M', - interval: 6 - } - }, - { - label: 'filter.timeRange.1y', - value: { - type: 'LAST', - unit: 'Y', - interval: 1 - } - }, - { - label: 'filter.timeRange.2y', - value: { - type: 'LAST', - unit: 'Y', - interval: 2 - } - }, - { - label: 'filter.timeRange.5y', - value: { - type: 'LAST', - unit: 'Y', - interval: 5 - } - } - ], - [ - { - label: 'filter.timeRange.yesterday', - value: { - type: 'PAST', - unit: 'd' - } - }, - // TODO implement time range calculation - /* - { - label: 'filter.timeRange.beforeYesterday', - value: { - type: 'PAST', - unit: 'd' - } - }, - { - label: 'filter.timeRange.thisDayLastWeek', - value: { - type: 'PAST', - unit: 'd' - } - }, - */ - { - label: 'filter.timeRange.previousWeek', - value: { - type: 'PAST', - unit: 'w' - } - }, - { - label: 'filter.timeRange.previousMonth', - value: { - type: 'PAST', - unit: 'M' - } - }, - { - label: 'filter.timeRange.previousYear', - value: { - type: 'PAST', - unit: 'Y' - } - } - ], - [ - { - label: 'filter.timeRange.today', - value: { - type: 'CURRENT', - unit: 'd' - } - }, - { - label: 'filter.timeRange.thisWeek', - value: { - type: 'CURRENT', - unit: 'w' - } - }, - { - label: 'filter.timeRange.thisMonth', - value: { - type: 'CURRENT', - unit: 'M' - } - }, - { - label: 'filter.timeRange.thisYear', - value: { - type: 'CURRENT', - unit: 'Y' - } - } - ], - [ - { - label: 'filter.timeRange.5min', - value: { - type: 'LAST', - unit: 'm', - interval: 5 - } - }, - { - label: 'filter.timeRange.15min', - value: { - type: 'LAST', - unit: 'm', - interval: 15 - } - }, - { - label: 'filter.timeRange.30min', - value: { - type: 'LAST', - unit: 'm', - interval: 30 - } - }, - { - label: 'filter.timeRange.1hr', - value: { - type: 'LAST', - unit: 'h', - interval: 1 - } - }, - { - label: 'filter.timeRange.3hr', - value: { - type: 'LAST', - unit: 'h', - interval: 3 - } - }, - { - label: 'filter.timeRange.6hr', - value: { - type: 'LAST', - unit: 'h', - interval: 6 - } - }, - { - label: 'filter.timeRange.12hr', - value: { - type: 'LAST', - unit: 'h', - interval: 12 - } - }, - { - label: 'filter.timeRange.24hr', - value: { - type: 'LAST', - unit: 'h', - interval: 24 - } - }, - ] - ], - defaultValue: { - type: 'LAST', - unit: 'h', - interval: 1 - }, - defaultLabel: 'filter.timeRange.1hr' - }, - components: { - label: 'filter.components', - iconClass: 'fa fa-cubes', - options: [], - defaultValue: '' - }, - levels: { - label: 'filter.levels', - iconClass: 'fa fa-sort-amount-asc', - options: [ - { - label: 'levels.fatal', - value: 'FATAL' - }, - { - label: 'levels.error', - value: 'ERROR' - }, - { - label: 'levels.warn', - value: 'WARN' - }, - { - label: 'levels.info', - value: 'INFO' - }, - { - label: 'levels.debug', - value: 'DEBUG' - }, - { - label: 'levels.trace', - value: 'TRACE' - }, - { - label: 'levels.unknown', - value: 'UNKNOWN' - } - ], - defaultValue: '' - }, - hosts: { - label: 'filter.hosts', - iconClass: 'fa fa-server', - options: [], - defaultValue: '' - }, - sorting: { - label: 'sorting.title', - options: [ - { - label: 'sorting.time.asc', - value: { - key: 'logtime', - type: 'asc' - } - }, - { - label: 'sorting.time.desc', - value: { - key: 'logtime', - type: 'desc' - } - } - ], - defaultValue: '', - defaultLabel: '' - }, - pageSize: { - label: 'pagination.title', - options: paginationOptions.map((option: string): ListItem => { - return { - label: option, - value: option - } - }), - defaultValue: '10', - defaultLabel: '10' - }, - page: { - defaultValue: 0 - }, - query: {} -}; - -export const filtersFormItemsMap: {[key: string]: string[]} = { - serviceLogs: ['clusters', 'timeRange', 'components', 'levels', 'hosts', 'sorting', 'pageSize', 'page', 'query'], - auditLogs: ['clusters', 'timeRange', 'sorting', 'pageSize', 'page', 'query'] // TODO add all the required fields -}; - -export const getFiltersForm = (listType: string): FormGroup => { - const itemsList = filtersFormItemsMap[listType], - keys = Object.keys(filters).filter((key: string): boolean => itemsList.indexOf(key) > -1), - items = keys.reduce((currentObject: any, key: string): any => { - let formControl = new FormControl(), - item = { - [key]: formControl - }; - formControl.setValue(filters[key].defaultValue); - return Object.assign(currentObject, item); - }, {}); - return new FormGroup(items); -}; http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/app-state.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/app-state.ts b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/app-state.ts index 2c5c083..afed497 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/app-state.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/app-state.ts @@ -16,9 +16,7 @@ * limitations under the License. */ -import {FormGroup} from '@angular/forms'; import {ActiveServiceLogEntry} from '@app/classes/active-service-log-entry'; -import {Tab, initialTabs} from '@app/classes/models/tab'; export interface AppState { isAuthorized: boolean; @@ -28,7 +26,7 @@ export interface AppState { isServiceLogsFileView: boolean; isServiceLogContextView: boolean; activeLog: ActiveServiceLogEntry | null; - activeFiltersForm: FormGroup; + activeFilters: object; } export const initialState: AppState = { @@ -39,5 +37,5 @@ export const initialState: AppState = { isServiceLogsFileView: false, isServiceLogContextView: false, activeLog: null, - activeFiltersForm: initialTabs.find((tab: Tab): boolean => tab.isActive).appState.activeFiltersForm + activeFilters: null }; http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts ---------------------------------------------------------------------- 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 new file mode 100644 index 0000000..ef5f772 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node-item.ts @@ -0,0 +1,30 @@ +/** + * 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 {CommonEntry} from '@app/classes/models/common-entry'; + +export interface NodeItem { + name: string; + type?: string; + value: string; + isParent: boolean; + isRoot: boolean; + childs?: NodeItem[]; + logLevelCount?: CommonEntry[]; + vNodeList?: CommonEntry[]; +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node.ts b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node.ts deleted file mode 100644 index a14e51a..0000000 --- a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/node.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 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 {CommonEntry} from '@app/classes/models/common-entry'; - -export interface Node { - name: string; - type?: string; - value: string; - isParent: boolean; - isRoot: boolean; - childs?: Node[]; - logLevelCount?: CommonEntry[]; - vNodeList?: CommonEntry[]; -} http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/store.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/store.ts b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/store.ts index d912b35..f996d92 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/store.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/store.ts @@ -24,7 +24,7 @@ import {AuditLog} from '@app/classes/models/audit-log'; import {ServiceLog} from '@app/classes/models/service-log'; import {BarGraph} from '@app/classes/models/bar-graph'; import {Graph} from '@app/classes/models/graph'; -import {Node} from '@app/classes/models/node'; +import {NodeItem} from '@app/classes/models/node-item'; import {UserConfig} from '@app/classes/models/user-config'; import {Filter} from '@app/classes/models/filter'; import {AuditLogField} from '@app/classes/models/audit-log-field'; @@ -50,11 +50,11 @@ export interface AppStore { serviceLogsHistogramData: BarGraph[]; serviceLogsTruncated: ServiceLog[]; graphs: Graph[]; - hosts: Node[]; + hosts: NodeItem[]; userConfigs: UserConfig[]; filters: Filter[]; clusters: string[]; - components: Node[]; + components: NodeItem[]; serviceLogsFields: ServiceLogField[]; auditLogsFields: AuditLogField[]; tabs: Tab[]; http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/tab.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/tab.ts b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/tab.ts index bb8028a..05ea59d 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/tab.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/classes/models/tab.ts @@ -16,15 +16,13 @@ * limitations under the License. */ -import {getFiltersForm} from '@app/classes/filtering'; - export interface Tab { id: string; type: string; - isActive: boolean; + isActive?: boolean; isCloseable?: boolean; label: string; - appState: any; + appState?: object; } export const initialTabs: Tab[] = [ @@ -35,8 +33,7 @@ export const initialTabs: Tab[] = [ label: 'common.serviceLogs', appState: { activeLogsType: 'serviceLogs', - isServiceLogsFileView: false, - activeFiltersForm: getFiltersForm('serviceLogs') + isServiceLogsFileView: false } }, { @@ -46,8 +43,7 @@ export const initialTabs: Tab[] = [ label: 'common.auditLogs', appState: { activeLogsType: 'auditLogs', - isServiceLogsFileView: false, - activeFiltersForm: getFiltersForm('auditLogs') + isServiceLogsFileView: false } } ]; http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/app.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/app.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/app.component.ts index 4de47ea..038dd2a 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/app.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/app.component.ts @@ -30,12 +30,12 @@ import {HttpClientService} from '@app/services/http-client.service'; export class AppComponent { constructor(private httpClient: HttpClientService, private translate: TranslateService, private appState: AppStateService) { - appState.getParameter('isAuthorized').subscribe(value => this.isAuthorized = value); + appState.getParameter('isAuthorized').subscribe((value: boolean) => this.isAuthorized = value); appState.setParameter('isInitialLoading', true); - this.httpClient.get('status').subscribe(() => this.appState.setParameters({ + httpClient.get('status').subscribe(() => appState.setParameters({ isAuthorized: true, isInitialLoading: false - }), () => this.appState.setParameter('isInitialLoading', false)); + }), () => appState.setParameter('isInitialLoading', false)); translate.setDefaultLang('en'); translate.use('en'); } http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.html b/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.html index 798a609..b5f1e56 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.html +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.html @@ -22,10 +22,10 @@ <span *ngIf="iconClass" [ngClass]="iconClass"></span> <span *ngIf="label">{{label | translate}}</span> </span> - <span *ngIf="showSelectedValue && !isMultipleChoice">{{selectedLabel | translate}}</span> + <span *ngIf="showSelectedValue && !isMultipleChoice && selection.length">{{selection[0].label | translate}}</span> <span *ngIf="!hideCaret" class="caret"></span> </button> <ul data-component="dropdown-list" [ngClass]="{'dropdown-menu': true, 'dropdown-menu-right': isRightAlign}" - [items]="options" [isMultipleChoice]="isMultipleChoice" (selectedItemChange)="updateValue($event)" + [items]="options" [isMultipleChoice]="isMultipleChoice" (selectedItemChange)="updateSelection($event)" [actionArguments]="additionalArgs"></ul> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.spec.ts index f11ca09..bd41c04 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.spec.ts @@ -32,7 +32,6 @@ import {ServiceLogsFieldsService, serviceLogsFields} from '@app/services/storage import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/services/storage/service-logs-histogram-data.service'; import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/storage/service-logs-truncated.service'; import {TabsService, tabs} from '@app/services/storage/tabs.service'; -import {FilteringService} from '@app/services/filtering.service'; import {UtilsService} from '@app/services/utils.service'; import {ComponentActionsService} from '@app/services/component-actions.service'; import {HttpClientService} from '@app/services/http-client.service'; @@ -85,7 +84,6 @@ describe('DropdownButtonComponent', () => { ServiceLogsHistogramDataService, ServiceLogsTruncatedService, TabsService, - FilteringService, UtilsService, ComponentActionsService, { http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.ts index 0bf4422..148e1b4 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-button/dropdown-button.component.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -import {Component, OnInit, Input} from '@angular/core'; +import {Component, Input} from '@angular/core'; import {ListItem} from '@app/classes/list-item'; import {ComponentActionsService} from '@app/services/component-actions.service'; import {UtilsService} from '@app/services/utils.service'; @@ -26,14 +26,10 @@ import {UtilsService} from '@app/services/utils.service'; templateUrl: './dropdown-button.component.html', styleUrls: ['./dropdown-button.component.less'] }) -export class DropdownButtonComponent implements OnInit { +export class DropdownButtonComponent { constructor(protected actions: ComponentActionsService, protected utils: UtilsService) { } - - ngOnInit() { - this.selectedLabel = this.defaultLabel; - } @Input() label?: string; @@ -48,13 +44,7 @@ export class DropdownButtonComponent implements OnInit { showSelectedValue: boolean = true; @Input() - options?: ListItem[]; - - @Input() - defaultValue?: string; - - @Input() - defaultLabel?: string; + options: ListItem[] = []; @Input() action?: string; @@ -71,36 +61,33 @@ export class DropdownButtonComponent implements OnInit { @Input() isDropup: boolean = false; - protected selectedValue?: any; - - selectedLabel: string; + protected selectedItems?: ListItem[] = []; - get value(): any { - return this.selectedValue; + get selection(): ListItem[] { + return this.selectedItems; } - set value(value: any) { - this.selectedValue = value; + set selection(items: ListItem[]) { + this.selectedItems = items; } - updateValue(eventOptions: ListItem): void { - const value = eventOptions && eventOptions.value, - action = this.action && this.actions[this.action]; + updateSelection(item: ListItem): void { + const action = this.action && this.actions[this.action]; if (this.isMultipleChoice) { - this.value = this.utils.updateMultiSelectValue(this.value, value, eventOptions.isChecked); - this.options.find(item => item.value === value).isChecked = eventOptions.isChecked; + this.options.find((option: ListItem): boolean => { + return this.utils.isEqual(option.value, item.value); + }).isChecked = item.isChecked; + const checkedItems = this.options.filter((option: ListItem): boolean => option.isChecked); + this.selection = checkedItems; if (action) { - action(this.options.filter(item => item.isChecked).map(item => item.value), ...this.additionalArgs); + action(checkedItems.map((option: ListItem): any => option.value), ...this.additionalArgs); } - } else { - if (this.utils.valueHasChanged(this.value, value)) { - this.value = value; - this.selectedLabel = eventOptions.label; - if (action) { - action(this.value, ...this.additionalArgs); - } + } else if (!this.utils.isEqual(this.selection[0], item)) { + this.selection = [item]; + if (action) { + action(item.value, ...this.additionalArgs); } } } - + } http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-list/dropdown-list.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-list/dropdown-list.component.html b/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-list/dropdown-list.component.html index 5de78ad..df564e5 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-list/dropdown-list.component.html +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-list/dropdown-list.component.html @@ -17,7 +17,7 @@ <li *ngFor="let item of items"> <label class="list-item-label" *ngIf="isMultipleChoice"> - <input type="checkbox" [attr.id]="item.id || item.value" [attr.checked]="item.isChecked ? 'checked' : null" + <input type="checkbox" [attr.id]="item.id || item.value" [(ngModel)]="item.isChecked" (change)="changeSelectedItem({value: item.value, isChecked: $event.currentTarget.checked})"> <label [attr.for]="item.id || item.value" class="label-container"> <span *ngIf="item.iconClass" [ngClass]="item.iconClass"></span> http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-list/dropdown-list.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-list/dropdown-list.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-list/dropdown-list.component.spec.ts index 5455e67..ac2fa84 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-list/dropdown-list.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/dropdown-list/dropdown-list.component.spec.ts @@ -17,6 +17,7 @@ */ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {FormsModule} from '@angular/forms'; import {StoreModule} from '@ngrx/store'; import {TranslationModules} from '@app/test-config.spec'; import {HostsService, hosts} from '@app/services/storage/hosts.service'; @@ -34,7 +35,6 @@ import {TabsService, tabs} from '@app/services/storage/tabs.service'; import {ComponentGeneratorService} from '@app/services/component-generator.service'; import {LogsContainerService} from '@app/services/logs-container.service'; import {HttpClientService} from '@app/services/http-client.service'; -import {FilteringService} from '@app/services/filtering.service'; import {ComponentActionsService} from '@app/services/component-actions.service'; import {DropdownListComponent} from './dropdown-list.component'; @@ -69,7 +69,8 @@ describe('DropdownListComponent', () => { components, serviceLogsTruncated, tabs - }) + }), + FormsModule ], providers: [ ComponentGeneratorService, @@ -78,7 +79,6 @@ describe('DropdownListComponent', () => { provide: HttpClientService, useValue: httpClient }, - FilteringService, ComponentActionsService, HostsService, AuditLogsService, http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-button/filter-button.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-button/filter-button.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-button/filter-button.component.spec.ts index 3e40455..f9ae154 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-button/filter-button.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-button/filter-button.component.spec.ts @@ -33,7 +33,6 @@ import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/se import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/storage/service-logs-truncated.service'; import {TabsService, tabs} from '@app/services/storage/tabs.service'; import {ComponentActionsService} from '@app/services/component-actions.service'; -import {FilteringService} from '@app/services/filtering.service'; import {UtilsService} from '@app/services/utils.service'; import {HttpClientService} from '@app/services/http-client.service'; import {LogsContainerService} from '@app/services/logs-container.service'; @@ -86,7 +85,6 @@ describe('FilterButtonComponent', () => { ServiceLogsTruncatedService, TabsService, ComponentActionsService, - FilteringService, UtilsService, { provide: HttpClientService, http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-button/filter-button.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-button/filter-button.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-button/filter-button.component.ts index 2c8ecd7..2dcecd1 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-button/filter-button.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-button/filter-button.component.ts @@ -41,34 +41,35 @@ export class FilterButtonComponent extends MenuButtonComponent implements Contro super(actions); } - @Input() - defaultValue?: string; - - private selectedValue: any; + private selectedItems: ListItem[] = []; private onChange: (fn: any) => void; - get value(): any { - return this.selectedValue; + get selection(): ListItem[] { + return this.selectedItems; } - set value(newValue: any) { - this.selectedValue = newValue; - this.onChange(newValue); + set selection(items: ListItem[]) { + this.selectedItems = items; + if (this.onChange) { + this.onChange(items); + } } - updateValue(options: ListItem): void { - const value = options && options.value; + updateSelection(item: ListItem): void { if (this.isMultipleChoice) { - this.value = this.utils.updateMultiSelectValue(this.value, value, options.isChecked); - } else { - if (this.utils.valueHasChanged(this.selectedValue, value)) { - this.value = value; - } + this.subItems.find((option: ListItem): boolean => { + return this.utils.isEqual(option.value, item.value); + }).isChecked = item.isChecked; + const checkedItems = this.subItems.filter((option: ListItem): boolean => option.isChecked); + this.selection = checkedItems; + } else if (!this.utils.isEqual(this.selection[0], item)) { + this.selection = [item]; } } - writeValue() { + writeValue(items: ListItem[]) { + this.selection = items; } registerOnChange(callback: any): void { http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-dropdown/filter-dropdown.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-dropdown/filter-dropdown.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-dropdown/filter-dropdown.component.spec.ts index c294e8e..f9192f4 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-dropdown/filter-dropdown.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-dropdown/filter-dropdown.component.spec.ts @@ -28,7 +28,9 @@ import {ServiceLogsFieldsService, serviceLogsFields} from '@app/services/storage import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/services/storage/service-logs-histogram-data.service'; import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/storage/service-logs-truncated.service'; import {TabsService, tabs} from '@app/services/storage/tabs.service'; -import {FilteringService} from '@app/services/filtering.service'; +import {ClustersService, clusters} from '@app/services/storage/clusters.service'; +import {ComponentsService, components} from '@app/services/storage/components.service'; +import {HostsService, hosts} from '@app/services/storage/hosts.service'; import {UtilsService} from '@app/services/utils.service'; import {ComponentActionsService} from '@app/services/component-actions.service'; import {LogsContainerService} from '@app/services/logs-container.service'; @@ -77,7 +79,10 @@ describe('FilterDropdownComponent', () => { serviceLogsFields, serviceLogsHistogramData, serviceLogsTruncated, - tabs + tabs, + clusters, + components, + hosts }), ...TranslationModules ], @@ -91,8 +96,11 @@ describe('FilterDropdownComponent', () => { ServiceLogsHistogramDataService, ServiceLogsTruncatedService, TabsService, + ClustersService, + ComponentsService, + HostsService, { - provide: FilteringService, + provide: LogsContainerService, useValue: filtering }, UtilsService, http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-dropdown/filter-dropdown.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-dropdown/filter-dropdown.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-dropdown/filter-dropdown.component.ts index 9e5a6f1..d677d81 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-dropdown/filter-dropdown.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/filter-dropdown/filter-dropdown.component.ts @@ -20,6 +20,7 @@ import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; import {ComponentActionsService} from '@app/services/component-actions.service'; import {UtilsService} from '@app/services/utils.service'; import {DropdownButtonComponent} from '@app/components/dropdown-button/dropdown-button.component'; +import {ListItem} from '@app/classes/list-item'; @Component({ selector: 'filter-dropdown', @@ -41,16 +42,25 @@ export class FilterDropdownComponent extends DropdownButtonComponent implements private onChange: (fn: any) => void; - get value(): any { - return this.selectedValue; + get selection(): ListItem[] { + return this.selectedItems; } - set value(newValue: any) { - this.selectedValue = newValue; - this.onChange(newValue); + set selection(items: ListItem[]) { + this.selectedItems = items; + if (this.isMultipleChoice) { + this.options.forEach((option: ListItem): void => { + const selectionItem = items.find((item: ListItem): boolean => this.utils.isEqual(item.value, option.value)); + option.isChecked = Boolean(selectionItem); + }); + } + if (this.onChange) { + this.onChange(items); + } } - writeValue() { + writeValue(items: ListItem[]) { + this.selection = items; } registerOnChange(callback: any): void { http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/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 fa739a4..2d327a6 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 @@ -17,13 +17,13 @@ <form [formGroup]="filtersForm"> <div class="form-inline filter-input-container col-md-8"> - <filter-dropdown [label]="filters.clusters.label" formControlName="clusters" [options]="filters.clusters.options" - [defaultLabel]="filters.clusters.defaultLabel" [isMultipleChoice]="true" + <filter-dropdown *ngIf="isFilterConditionDisplayed('clusters')" [label]="filters.clusters.label" + formControlName="clusters" [options]="filters.clusters.options" [isMultipleChoice]="true" class="filter-input"></filter-dropdown> <search-box formControlName="query" [items]="searchBoxItemsTranslated" class="filter-input" [parameterNameChangeSubject]="queryParameterNameChange" [parameterAddSubject]="queryParameterAdd"></search-box> - <time-range-picker formControlName="timeRange" [defaultLabel]="filters.timeRange.defaultLabel" + <time-range-picker *ngIf="isFilterConditionDisplayed('timeRange')" formControlName="timeRange" class="filter-input"></time-range-picker> <timezone-picker class="filter-input"></timezone-picker> <!--button class="btn btn-success" type="button"> http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.spec.ts index 0bb0204..1f7e8db 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.spec.ts @@ -18,6 +18,7 @@ import {NO_ERRORS_SCHEMA} from '@angular/core'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {FormGroup, FormControl} from '@angular/forms'; import {TranslationModules} from '@app/test-config.spec'; import {StoreModule} from '@ngrx/store'; import {AppSettingsService, appSettings} from '@app/services/storage/app-settings.service'; @@ -32,7 +33,6 @@ import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/se import {AppStateService, appState} from '@app/services/storage/app-state.service'; import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/storage/service-logs-truncated.service'; import {TabsService, tabs} from '@app/services/storage/tabs.service'; -import {FilteringService} from '@app/services/filtering.service'; import {HttpClientService} from '@app/services/http-client.service'; import {UtilsService} from '@app/services/utils.service'; import {LogsContainerService} from '@app/services/logs-container.service'; @@ -88,7 +88,6 @@ describe('FiltersPanelComponent', () => { AppStateService, ServiceLogsTruncatedService, TabsService, - FilteringService, LogsContainerService, { provide: HttpClientService, @@ -104,6 +103,9 @@ describe('FiltersPanelComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(FiltersPanelComponent); component = fixture.componentInstance; + component.filtersForm = new FormGroup({ + control: new FormControl() + }); fixture.detectChanges(); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.ts index 9601a0e..3314252 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/filters-panel/filters-panel.component.ts @@ -21,10 +21,8 @@ import {FormGroup} from '@angular/forms'; import {Subject} from 'rxjs/Subject'; import {TranslateService} from '@ngx-translate/core'; import {ListItem} from '@app/classes/list-item'; -import {filtersFormItemsMap} from '@app/classes/filtering'; import {CommonEntry} from '@app/classes/models/common-entry'; import {LogField} from '@app/classes/models/log-field'; -import {FilteringService} from '@app/services/filtering.service'; import {LogsContainerService} from '@app/services/logs-container.service'; import {AppStateService} from '@app/services/storage/app-state.service'; @@ -35,7 +33,10 @@ import {AppStateService} from '@app/services/storage/app-state.service'; }) export class FiltersPanelComponent { - constructor(private translate: TranslateService, private filtering: FilteringService, private logsContainer: LogsContainerService, private appState: AppStateService) { + constructor( + private translate: TranslateService, private logsContainer: LogsContainerService, + private appState: AppStateService + ) { appState.getParameter('activeLogsType').subscribe(value => { this.logsType = value; logsContainer.logsTypeMap[value].fieldsModel.getAll().subscribe((fields: LogField[]): void => { @@ -80,23 +81,24 @@ export class FiltersPanelComponent { searchBoxItemsTranslated: CommonEntry[] = []; get filters(): any { - return this.filtering.filters; + return this.logsContainer.filters; } get queryParameterNameChange(): Subject<any> { - return this.filtering.queryParameterNameChange; + return this.logsContainer.queryParameterNameChange; } get queryParameterAdd(): Subject<any> { - return this.filtering.queryParameterAdd; + return this.logsContainer.queryParameterAdd; } get captureSeconds(): number { - return this.filtering.captureSeconds; + return this.logsContainer.captureSeconds; } isFilterConditionDisplayed(key: string): boolean { - return filtersFormItemsMap[this.logsType].indexOf(key) > -1; + return this.logsContainer.filtersFormItemsMap[this.logsType].indexOf(key) > -1 + && Boolean(this.filtersForm.controls[key]); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/log-context/log-context.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/log-context/log-context.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/log-context/log-context.component.spec.ts index 4e9bdc9..7bd87ad 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/log-context/log-context.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/log-context/log-context.component.spec.ts @@ -34,7 +34,6 @@ import {TranslationModules} from '@app/test-config.spec'; import {ModalComponent} from '@app/components/modal/modal.component'; import {LogsContainerService} from '@app/services/logs-container.service'; import {HttpClientService} from '@app/services/http-client.service'; -import {FilteringService} from '@app/services/filtering.service'; import {LogContextComponent} from './log-context.component'; @@ -90,8 +89,7 @@ describe('LogContextComponent', () => { { provide: HttpClientService, useValue: httpClient - }, - FilteringService + } ], schemas: [CUSTOM_ELEMENTS_SCHEMA] }) http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-container/logs-container.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-container/logs-container.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-container/logs-container.component.spec.ts index 0a9418f..2bb8731 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-container/logs-container.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-container/logs-container.component.spec.ts @@ -33,7 +33,6 @@ import {HostsService, hosts} from '@app/services/storage/hosts.service'; import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/storage/service-logs-truncated.service'; import {TabsService, tabs} from '@app/services/storage/tabs.service'; import {HttpClientService} from '@app/services/http-client.service'; -import {FilteringService} from '@app/services/filtering.service'; import {UtilsService} from '@app/services/utils.service'; import {LogsContainerService} from '@app/services/logs-container.service'; import {TabsComponent} from '@app/components/tabs/tabs.component'; @@ -92,7 +91,6 @@ describe('LogsContainerComponent', () => { HostsService, ServiceLogsTruncatedService, TabsService, - FilteringService, UtilsService, LogsContainerService ], http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-container/logs-container.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-container/logs-container.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-container/logs-container.component.ts index 21949f1..f8acd50 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-container/logs-container.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-container/logs-container.component.ts @@ -22,7 +22,6 @@ import {Observable} from 'rxjs/Observable'; import {Subject} from 'rxjs/Subject'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/takeUntil'; -import {FilteringService} from '@app/services/filtering.service'; import {LogsContainerService} from '@app/services/logs-container.service'; import {ServiceLogsHistogramDataService} from '@app/services/storage/service-logs-histogram-data.service'; import {AppStateService} from '@app/services/storage/app-state.service'; @@ -43,9 +42,11 @@ import {ListItem} from '@app/classes/list-item'; }) export class LogsContainerComponent { - constructor(private serviceLogsHistogramStorage: ServiceLogsHistogramDataService, private appState: AppStateService, private tabsStorage: TabsService, private filtering: FilteringService, private logsContainer: LogsContainerService) { + constructor( + private serviceLogsHistogramStorage: ServiceLogsHistogramDataService, private appState: AppStateService, + private tabsStorage: TabsService, private logsContainer: LogsContainerService + ) { this.logsContainer.loadColumnsNames(); - this.logsTypeChange.first().subscribe(() => this.logsContainer.loadLogs()); appState.getParameter('activeLogsType').subscribe((value: string): void => { this.logsType = value; this.logsTypeChange.next(); @@ -75,11 +76,6 @@ export class LogsContainerComponent { this.displayedColumns = columns.filter((column: LogField): boolean => column.isAvailable && column.isDisplayed); }); }); - appState.getParameter('activeFiltersForm').subscribe((form: FormGroup): void => { - this.filtersFormChange.next(); - form.valueChanges.takeUntil(this.filtersFormChange).subscribe(() => this.logsContainer.loadLogs()); - this.filtersForm = form; - }); serviceLogsHistogramStorage.getAll().subscribe((data: BarGraph[]): void => { this.histogramData = this.logsContainer.getHistogramData(data); }); @@ -88,12 +84,12 @@ export class LogsContainerComponent { tabs: Observable<Tab[]> = this.tabsStorage.getAll(); - filtersForm: FormGroup; + get filtersForm(): FormGroup { + return this.logsContainer.filtersForm; + }; private logsType: string; - private filtersFormChange: Subject<any> = new Subject(); - private logsTypeChange: Subject<any> = new Subject(); get logsTypeMapObject(): any { @@ -117,10 +113,10 @@ export class LogsContainerComponent { }; get autoRefreshRemainingSeconds(): number { - return this.filtering.autoRefreshRemainingSeconds; + return this.logsContainer.autoRefreshRemainingSeconds; } - get autoRefreshMessageParams(): any { + get autoRefreshMessageParams(): object { return { remainingSeconds: this.autoRefreshRemainingSeconds }; @@ -133,7 +129,7 @@ export class LogsContainerComponent { get totalEventsFoundMessageParams(): object { return { totalCount: this.totalCount - } + }; } isServiceLogContextView: boolean = false; @@ -147,7 +143,7 @@ export class LogsContainerComponent { } setCustomTimeRange(startTime: number, endTime: number): void { - this.filtering.setCustomTimeRange(startTime, endTime); + this.logsContainer.setCustomTimeRange(startTime, endTime); } onSwitchTab(activeTab: Tab): void { http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.html b/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.html index 10f4af1..7de0b96 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.html +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.html @@ -17,8 +17,7 @@ <form *ngIf="logs && logs.length" [formGroup]="filtersForm" class="row pull-right"> <filter-dropdown [label]="filters.sorting.label" formControlName="sorting" [options]="filters.sorting.options" - [defaultLabel]="filters.sorting.defaultLabel" [isRightAlign]="true" - class="col-md-12"></filter-dropdown> + [isRightAlign]="true" class="col-md-12"></filter-dropdown> </form> <div class="panel panel-default"> <div class="panel-body"> http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.spec.ts index 8ee4ca3..21c4f02 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.spec.ts @@ -28,8 +28,13 @@ import {AppStateService, appState} from '@app/services/storage/app-state.service import {ClustersService, clusters} from '@app/services/storage/clusters.service'; import {ComponentsService, components} from '@app/services/storage/components.service'; import {HostsService, hosts} from '@app/services/storage/hosts.service'; +import {AuditLogsFieldsService, auditLogsFields} from '@app/services/storage/audit-logs-fields.service'; +import {ServiceLogsFieldsService, serviceLogsFields} from '@app/services/storage/service-logs-fields.service'; +import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/services/storage/service-logs-histogram-data.service'; +import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/storage/service-logs-truncated.service'; +import {TabsService, tabs} from '@app/services/storage/tabs.service'; import {HttpClientService} from '@app/services/http-client.service'; -import {FilteringService} from '@app/services/filtering.service'; +import {LogsContainerService} from '@app/services/logs-container.service'; import {UtilsService} from '@app/services/utils.service'; import {LogsListComponent} from './logs-list.component'; @@ -57,7 +62,12 @@ describe('LogsListComponent', () => { appState, clusters, components, - hosts + hosts, + auditLogsFields, + serviceLogsFields, + serviceLogsHistogramData, + serviceLogsTruncated, + tabs }), MomentModule, MomentTimezoneModule, @@ -75,7 +85,12 @@ describe('LogsListComponent', () => { ClustersService, ComponentsService, HostsService, - FilteringService, + AuditLogsFieldsService, + ServiceLogsFieldsService, + ServiceLogsHistogramDataService, + ServiceLogsTruncatedService, + TabsService, + LogsContainerService, UtilsService ], schemas: [NO_ERRORS_SCHEMA] http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.ts index 017bc82..3a56fca 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/logs-list/logs-list.component.ts @@ -18,7 +18,7 @@ import {Component, AfterViewInit, Input, ViewChild, ElementRef} from '@angular/core'; import {FormGroup} from '@angular/forms'; import 'rxjs/add/operator/map'; -import {FilteringService} from '@app/services/filtering.service'; +import {LogsContainerService} from '@app/services/logs-container.service'; import {UtilsService} from '@app/services/utils.service'; import {AuditLog} from '@app/classes/models/audit-log'; import {ServiceLog} from '@app/classes/models/service-log'; @@ -31,7 +31,7 @@ import {LogField} from '@app/classes/models/log-field'; }) export class LogsListComponent implements AfterViewInit { - constructor(private filtering: FilteringService, private utils: UtilsService) { + constructor(private logsContainer: LogsContainerService, private utils: UtilsService) { } ngAfterViewInit() { @@ -104,11 +104,11 @@ export class LogsListComponent implements AfterViewInit { readonly timeFormat: string = 'h:mm:ss A'; get timeZone(): string { - return this.filtering.timeZone; + return this.logsContainer.timeZone; } get filters(): any { - return this.filtering.filters; + return this.logsContainer.filters; } isDifferentDates(dateA, dateB): boolean { @@ -135,7 +135,7 @@ export class LogsListComponent implements AfterViewInit { } updateQuery(event: any) { - this.filtering.queryParameterAdd.next({ + this.logsContainer.queryParameterAdd.next({ name: this.messageFilterParameterName, value: this.selectedText, isExclude: event.value http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.spec.ts index 261e213..71bbf67 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.spec.ts @@ -33,7 +33,6 @@ import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/se import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/storage/service-logs-truncated.service'; import {TabsService, tabs} from '@app/services/storage/tabs.service'; import {ComponentActionsService} from '@app/services/component-actions.service'; -import {FilteringService} from '@app/services/filtering.service'; import {HttpClientService} from '@app/services/http-client.service'; import {LogsContainerService} from '@app/services/logs-container.service'; @@ -85,7 +84,6 @@ describe('MenuButtonComponent', () => { ServiceLogsTruncatedService, TabsService, ComponentActionsService, - FilteringService, { provide: HttpClientService, useValue: httpClient http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.ts index 5932e1b..ca89935 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.ts @@ -202,11 +202,11 @@ export class MenuButtonComponent { * @param {ListItem} options The selected item(s) from the dropdown list. */ onDropdownItemChange(options: ListItem) { - this.updateValue(options); + this.updateSelection(options); !this.isMultipleChoice && this.closeDropdown(); } - updateValue(options: ListItem) { + updateSelection(options: ListItem) { // TODO implement value change behaviour } http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination-controls/pagination-controls.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination-controls/pagination-controls.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination-controls/pagination-controls.component.ts index 81676a9..5f85da7 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination-controls/pagination-controls.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination-controls/pagination-controls.component.ts @@ -54,7 +54,9 @@ export class PaginationControlsComponent implements ControlValueAccessor { if (this.isValidValue(newValue)) { // this is the last validation check this.currentPage = newValue; this.currentPageChange.emit(newValue); - this.onChange(newValue); + if (this.onChange) { + this.onChange(newValue); + } } else { throw new Error(`Invalid value ${newValue}. The currentPage should be between 0 and ${this.pagesCount}.`); } @@ -121,7 +123,8 @@ export class PaginationControlsComponent implements ControlValueAccessor { return this.pagesCount > 0 && this.value > 0; } - writeValue() { + writeValue(value: number) { + this.value = value; } registerOnChange(callback: any): void { http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.html b/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.html index 679a7e5..4be0a47 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.html +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.html @@ -17,7 +17,7 @@ <form class="pagination-form" [formGroup]="filtersForm"> <filter-dropdown [label]="filterInstance.label" formControlName="pageSize" [options]="filterInstance.options" - [defaultLabel]="filterInstance.defaultLabel" [isRightAlign]="true" isDropup="true"></filter-dropdown> + [isRightAlign]="true" [isDropup]="true"></filter-dropdown> <span>{{'pagination.numbers' | translate: numbersTranslateParams}}</span> <pagination-controls formControlName="page" [totalCount]="totalCount" [pagesCount]="pagesCount" (currentPageChange)="setCurrentPage($event)"></pagination-controls> http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.spec.ts index ff8675d..c820027 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.spec.ts @@ -39,7 +39,14 @@ describe('PaginationComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(PaginationComponent); component = fixture.componentInstance; - component.filterInstance = {}; + component.filterInstance = { + defaultSelection: [ + { + label: '10', + value: '10' + } + ] + }; component.filtersForm = new FormGroup({ pageSize: new FormControl() }); http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.ts index cc5589f..890c2ee 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/pagination/pagination.component.ts @@ -18,6 +18,8 @@ import {Component, OnInit, Input} from '@angular/core'; import {FormGroup} from '@angular/forms'; +import {ListItem} from '@app/classes/list-item'; +import {FilterCondition} from '@app/classes/filtering'; @Component({ selector: 'pagination', @@ -27,9 +29,9 @@ import {FormGroup} from '@angular/forms'; export class PaginationComponent implements OnInit { ngOnInit() { - this.setPageSizeFromString(this.filterInstance.defaultValue); - this.filtersForm.controls.pageSize.valueChanges.subscribe((value: string): void => { - this.setPageSizeFromString(value); + this.setPageSizeFromString(this.filterInstance.defaultSelection[0].value); + this.filtersForm.controls.pageSize.valueChanges.subscribe((selection: ListItem): void => { + this.setPageSizeFromString(selection[0].value); }); } @@ -37,7 +39,7 @@ export class PaginationComponent implements OnInit { filtersForm: FormGroup; @Input() - filterInstance: any; + filterInstance: FilterCondition; @Input() currentCount?: number; http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/search-box/search-box.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/search-box/search-box.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/search-box/search-box.component.ts index 5520310..18ff715 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/search-box/search-box.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/search-box/search-box.component.ts @@ -159,7 +159,7 @@ export class SearchBoxComponent implements OnInit, OnDestroy, ControlValueAccess this.isValueInput = true; this.currentValue = ''; setTimeout(() => this.valueInput.focus(), 0); - } + }; onParameterValueChange(event: KeyboardEvent): void { if (this.utils.isEnterPressed(event) && this.currentValue) { @@ -187,7 +187,7 @@ export class SearchBoxComponent implements OnInit, OnDestroy, ControlValueAccess isExclude: options.isExclude }); this.updateValue(); - } + }; removeParameter(event: MouseEvent, id: number): void { this.parameters = this.parameters.filter(parameter => parameter.id !== id); @@ -196,10 +196,14 @@ export class SearchBoxComponent implements OnInit, OnDestroy, ControlValueAccess } updateValue() { - this.onChange(this.parameters); + if (this.onChange) { + this.onChange(this.parameters); + } } - writeValue() { + writeValue(parameters: any [] = []) { + this.parameters = parameters; + this.updateValue(); } registerOnChange(callback: any): void { http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.html b/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.html index 973db61..621f995 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.html +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.html @@ -16,7 +16,8 @@ --> <button class="btn btn-link dropdown-toggle" data-toggle="dropdown"> - {{selectedLabel | translate}} <span class="caret"></span> + <span *ngIf="selection">{{selection.label | translate}}</span> + <span class="caret"></span> </button> <div class="dropdown-menu row col-md-12"> <div class="col-md-4" (click)="$event.stopPropagation()"> http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.spec.ts index 7612cc3..43e4bd5 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.spec.ts @@ -25,8 +25,15 @@ import {AppStateService, appState} from '@app/services/storage/app-state.service import {ClustersService, clusters} from '@app/services/storage/clusters.service'; import {ComponentsService, components} from '@app/services/storage/components.service'; import {HostsService, hosts} from '@app/services/storage/hosts.service'; +import {AuditLogsService, auditLogs} from '@app/services/storage/audit-logs.service'; +import {AuditLogsFieldsService, auditLogsFields} from '@app/services/storage/audit-logs-fields.service'; +import {ServiceLogsService, serviceLogs} from '@app/services/storage/service-logs.service'; +import {ServiceLogsFieldsService, serviceLogsFields} from '@app/services/storage/service-logs-fields.service'; +import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/services/storage/service-logs-histogram-data.service'; +import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/storage/service-logs-truncated.service'; +import {TabsService, tabs} from '@app/services/storage/tabs.service'; import {HttpClientService} from '@app/services/http-client.service'; -import {FilteringService} from '@app/services/filtering.service'; +import {LogsContainerService} from '@app/services/logs-container.service'; import {TimeRangePickerComponent} from './time-range-picker.component'; @@ -51,7 +58,14 @@ describe('TimeRangePickerComponent', () => { appState, clusters, components, - hosts + hosts, + auditLogs, + auditLogsFields, + serviceLogs, + serviceLogsFields, + serviceLogsHistogramData, + serviceLogsTruncated, + tabs }), ...TranslationModules ], @@ -60,12 +74,19 @@ describe('TimeRangePickerComponent', () => { provide: HttpClientService, useValue: httpClient }, - FilteringService, + LogsContainerService, AppSettingsService, AppStateService, ClustersService, ComponentsService, - HostsService + HostsService, + AuditLogsService, + AuditLogsFieldsService, + ServiceLogsService, + ServiceLogsFieldsService, + ServiceLogsHistogramDataService, + ServiceLogsTruncatedService, + TabsService ], schemas: [CUSTOM_ELEMENTS_SCHEMA] }) http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.ts index af4933a..cacabc3 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/time-range-picker/time-range-picker.component.ts @@ -16,10 +16,10 @@ * limitations under the License. */ -import {Component, OnInit, Input, forwardRef} from '@angular/core'; +import {Component, forwardRef} from '@angular/core'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; import {Moment} from 'moment'; -import {FilteringService} from '@app/services/filtering.service'; +import {LogsContainerService} from '@app/services/logs-container.service'; import {ListItem} from '@app/classes/list-item'; import {TimeUnitListItem} from '@app/classes/filtering'; @@ -35,20 +35,11 @@ import {TimeUnitListItem} from '@app/classes/filtering'; } ] }) -export class TimeRangePickerComponent implements OnInit, ControlValueAccessor { +export class TimeRangePickerComponent implements ControlValueAccessor { - constructor(private filtering: FilteringService) { + constructor(private logsContainer: LogsContainerService) { } - ngOnInit() { - this.selectedLabel = this.defaultLabel; - } - - @Input() - defaultLabel?: string; - - selectedLabel: string; - startTime: Moment; endTime: Moment; @@ -56,18 +47,20 @@ export class TimeRangePickerComponent implements OnInit, ControlValueAccessor { private onChange: (fn: any) => void; get quickRanges(): (ListItem | TimeUnitListItem[])[] { - return this.filtering.filters.timeRange.options; + return this.logsContainer.filters.timeRange.options; } - private timeRange?: any; + private timeRange?: TimeUnitListItem; - get value(): any { + get selection(): TimeUnitListItem { return this.timeRange; } - set value(newValue: any) { + set selection(newValue: TimeUnitListItem) { this.timeRange = newValue; - this.onChange(newValue); + if (this.onChange) { + this.onChange(newValue); + } } setStartTime(timeObject: Moment): void { @@ -79,20 +72,22 @@ export class TimeRangePickerComponent implements OnInit, ControlValueAccessor { } setTimeRange(value: any, label: string) { - this.value = value; - this.selectedLabel = label; + this.selection = {label, value}; } setCustomTimeRange() { - this.value = { - type: 'CUSTOM', - start: this.startTime, - end: this.endTime + this.selection = { + label: 'filter.timeRange.custom', + value: { + type: 'CUSTOM', + start: this.startTime, + end: this.endTime + } }; - this.selectedLabel = 'filter.timeRange.custom'; } - writeValue() { + writeValue(selection: TimeUnitListItem) { + this.selection = selection; } registerOnChange(callback: any): void { http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/components/timezone-picker/timezone-picker.component.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/timezone-picker/timezone-picker.component.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/timezone-picker/timezone-picker.component.spec.ts index 53afc47..0e4c8a8 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/timezone-picker/timezone-picker.component.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/timezone-picker/timezone-picker.component.spec.ts @@ -32,7 +32,6 @@ import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/se import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/storage/service-logs-truncated.service'; import {TabsService, tabs} from '@app/services/storage/tabs.service'; import {ComponentActionsService} from '@app/services/component-actions.service'; -import {FilteringService} from '@app/services/filtering.service'; import {HttpClientService} from '@app/services/http-client.service'; import {LogsContainerService} from '@app/services/logs-container.service'; import {TimeZoneAbbrPipe} from '@app/pipes/timezone-abbr.pipe'; @@ -90,7 +89,6 @@ describe('TimeZonePickerComponent', () => { ServiceLogsTruncatedService, TabsService, ComponentActionsService, - FilteringService, { provide: HttpClientService, useValue: httpClient http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/services/component-actions.service.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/component-actions.service.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/component-actions.service.spec.ts index e6a02c0..6f54e65 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/services/component-actions.service.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/component-actions.service.spec.ts @@ -30,7 +30,6 @@ import {ServiceLogsFieldsService, serviceLogsFields} from '@app/services/storage import {ServiceLogsHistogramDataService, serviceLogsHistogramData} from '@app/services/storage/service-logs-histogram-data.service'; import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/storage/service-logs-truncated.service'; import {TabsService, tabs} from '@app/services/storage/tabs.service'; -import {FilteringService} from '@app/services/filtering.service'; import {HttpClientService} from '@app/services/http-client.service'; import {LogsContainerService} from '@app/services/logs-container.service'; @@ -78,7 +77,6 @@ describe('ComponentActionsService', () => { ServiceLogsHistogramDataService, ServiceLogsTruncatedService, TabsService, - FilteringService, { provide: HttpClientService, useValue: httpClient http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/services/component-actions.service.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/component-actions.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/component-actions.service.ts index c483cd8..73fc94c 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/services/component-actions.service.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/component-actions.service.ts @@ -20,15 +20,17 @@ import {Injectable} from '@angular/core'; import {AppSettingsService} from '@app/services/storage/app-settings.service'; import {TabsService} from '@app/services/storage/tabs.service'; import {CollectionModelService} from '@app/classes/models/store'; -import {FilteringService} from '@app/services/filtering.service'; import {LogsContainerService} from '@app/services/logs-container.service'; import {ServiceLog} from '@app/classes/models/service-log'; -import {getFiltersForm} from '@app/classes/filtering'; +import {ListItem} from '@app/classes/list-item'; @Injectable() export class ComponentActionsService { - constructor(private appSettings: AppSettingsService, private tabsStorage: TabsService, private filtering: FilteringService, private logsContainer: LogsContainerService) { + constructor( + private appSettings: AppSettingsService, private tabsStorage: TabsService, + private logsContainer: LogsContainerService + ) { } //TODO implement actions @@ -81,7 +83,6 @@ export class ComponentActionsService { const tab = { id: log.id, type: 'serviceLogs', - isActive: true, isCloseable: true, label: `${log.host} >> ${log.type}`, appState: { @@ -92,7 +93,14 @@ export class ComponentActionsService { host_name: log.host, component_name: log.type }, - activeFiltersForm: getFiltersForm('serviceLogs') + activeFilters: Object.assign(this.logsContainer.getFiltersData('serviceLogs'), { + components: this.logsContainer.filters.components.options.find((option: ListItem): boolean => { + return option.value === log.type; + }), + hosts: this.logsContainer.filters.hosts.options.find((option: ListItem): boolean => { + return option.value === log.host; + }) + }) } }; this.tabsStorage.addInstance(tab); @@ -104,11 +112,11 @@ export class ComponentActionsService { } startCapture(): void { - this.filtering.startCaptureTimer(); + this.logsContainer.startCaptureTimer(); } stopCapture(): void { - this.filtering.stopCaptureTimer(); + this.logsContainer.stopCaptureTimer(); } setTimeZone(timeZone: string): void { @@ -121,7 +129,7 @@ export class ComponentActionsService { })); } - proceedWithExclude = (item: string): void => this.filtering.queryParameterNameChange.next({ + proceedWithExclude = (item: string): void => this.logsContainer.queryParameterNameChange.next({ item: item, isExclude: true }); http://git-wip-us.apache.org/repos/asf/ambari/blob/ebc627a2/ambari-logsearch/ambari-logsearch-web/src/app/services/component-generator.service.spec.ts ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/component-generator.service.spec.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/component-generator.service.spec.ts index 5dc38b4..a161190 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/services/component-generator.service.spec.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/component-generator.service.spec.ts @@ -32,7 +32,6 @@ import {ServiceLogsTruncatedService, serviceLogsTruncated} from '@app/services/s import {TabsService, tabs} from '@app/services/storage/tabs.service'; import {LogsContainerService} from '@app/services/logs-container.service'; import {HttpClientService} from '@app/services/http-client.service'; -import {FilteringService} from '@app/services/filtering.service'; import {ComponentGeneratorService} from './component-generator.service'; @@ -70,7 +69,6 @@ describe('ComponentGeneratorService', () => { provide: HttpClientService, useValue: httpClient }, - FilteringService, HostsService, AuditLogsService, ServiceLogsService,