This is an automated email from the ASF dual-hosted git repository. ababiichuk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push: new 4f93c3c AMBARI-23514 Log Search UI: various fixes for History feature 4f93c3c is described below commit 4f93c3c793da419b684a56b6e282947d7b974316 Author: Istvan Tobias <tobias.ist...@gmail.com> AuthorDate: Thu Apr 12 12:17:28 2018 +0200 AMBARI-23514 Log Search UI: various fixes for History feature --- .../action-menu/action-menu.component.html | 12 +- .../action-menu/action-menu.component.less | 70 ++++++++ .../action-menu/action-menu.component.ts | 8 +- .../menu-button/menu-button.component.html | 2 +- .../menu-button/menu-button.component.less | 10 ++ .../menu-button/menu-button.component.ts | 51 +++--- .../src/app/modules/app-load/app-load.module.ts | 4 +- .../modules/app-load/services/app-load.service.ts | 8 +- .../dropdown-list/dropdown-list.component.html | 6 +- .../src/app/modules/shared/variables.less | 2 +- .../src/app/services/auth.service.ts | 6 +- .../src/app/services/history-manager.service.ts | 93 +++++----- .../src/app/services/http-client.service.ts | 2 +- .../src/app/services/logs-container.service.ts | 5 +- .../app/services/logs-filtering-utils.service.ts | 196 ++++++++++++++++++++- 15 files changed, 389 insertions(+), 86 deletions(-) diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.html b/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.html index b2bf90f..3df719a 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.html +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.html @@ -17,12 +17,16 @@ <!-- TODO use listClass="history-dropdown" for custom styling --> <menu-button label="{{'topMenu.undo' | translate}}" [subItems]="undoItems" iconClass="fa fa-arrow-left" - listClass="history-dropdown" (buttonClick)="undoLatest()" (selectItem)="undo($event)"></menu-button> + class="history-menu" [class.disabled]="!undoItems.length" [isDisabled]="!undoItems.length" + listClass="history-dropdown" (buttonClick)="undoLatest()" (selectItem)="undo($event)"> +</menu-button> <menu-button label="{{'topMenu.redo' | translate}}" [subItems]="redoItems" iconClass="fa fa-arrow-right" - listClass="history-dropdown" (buttonClick)="redoLatest()" (selectItem)="redo($event)"></menu-button> + class="history-menu" [class.disabled]="!redoItems.length" [isDisabled]="!redoItems.length" + listClass="history-dropdown" (buttonClick)="redoLatest()" (selectItem)="redo($event)"> +</menu-button> <menu-button label="{{'topMenu.history' | translate}}" [subItems]="historyItems" iconClass="fa fa-history" - listClass="history-dropdown" [isRightAlign]="true" - additionalLabelComponentSetter="getHistoryItemIcons"></menu-button> + class="history-menu" [class.disabled]="!historyItems.length" [isDisabled]="!historyItems.length" + listClass="history-dropdown" [isRightAlign]="true"></menu-button> <menu-button label="{{'topMenu.filter' | translate}}" iconClass="fa fa-filter" (buttonClick)="openLogIndexFilter()"></menu-button> <menu-button *ngIf="!captureSeconds" label="{{'filter.capture' | translate}}" iconClass="fa fa-caret-right" diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.less b/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.less index 024e1d5..66648bb 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.less +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.less @@ -25,5 +25,75 @@ /deep/ .stop-icon { color: @exclude-color; } + &.history-menu { + /deep/ ul { + li:not(.selection-all) { + margin: 0; + overflow: hidden; + position: relative; + transition: background-color 300ms ease-in, opacity 300ms ease-in, height 100ms 400ms ease-in; + &:before { + border-left: 1px solid darken(@unknown-color, 25%); + bottom: 0; + content: ""; + display: block; + left: 12px; + position: absolute; + top: 0; + } + &:after { + background: #fff; + border: 1px solid darken(@unknown-color, 25%); + border-radius: 100%; + content: ""; + height: 12px; + left: 7px; + position: absolute; + top: 6px; + transition: background-color 300ms; + width: 12px; + } + + .list-item-label.label-container { + border-radius: 3px; + display: flex; + margin: 0 3px 0 25px; + padding: 3px 25px 3px 1em; + .item-label-text { + flex-grow: 1; + padding-right: 1em; + } + /deep/ history-item-controls { + float: none; + justify-self: right; + } + } + + &.active > a, &:hover { + color: #262626; + text-decoration: none; + background-color: transparent; + .list-item-label.label-container { + background-color: #f5f5f5; + } + } + } + li:not(.selection-all):first-child { + &:before { + top: 50%; + } + } + li:not(.selection-all):last-child { + &:before { + bottom: 50%; + } + } + li:not(.selection-all):hover { + &:after { + background: @unknown-color; + } + } + } + } } } diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.ts index 6b02843..394bebc 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/action-menu/action-menu.component.ts @@ -63,11 +63,15 @@ export class ActionMenuComponent { } undoLatest(): void { - this.historyManager.undo(this.undoItems[0]); + if (this.undoItems.length) { + this.historyManager.undo(this.undoItems[0]); + } } redoLatest(): void { - this.historyManager.redo(this.redoItems[0]); + if (this.redoItems.length) { + this.historyManager.redo(this.redoItems[0]); + } } undo(item: ListItem): void { diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.html b/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.html index 12dd59c..111127c 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.html +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.html @@ -15,7 +15,7 @@ limitations under the License. --> -<div #dropdown [ngClass]="{'dropdown': hasSubItems, 'text-center': true, 'open': dropdownIsOpen}"> +<div #dropdown [ngClass]="{'dropdown': hasSubItems, 'text-center': true, 'open': dropdownIsOpen, 'disabled': isDisabled}"> <a class="dropdown-toggle" [ngClass]="(labelClass || '') + (hasCaret ? ' has-caret' : '')" (click)="onMouseClick($event)" (mousedown)="onMouseDown($event)"> diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.less b/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.less index ba9b461..f5f2079 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.less +++ b/ambari-logsearch/ambari-logsearch-web/src/app/components/menu-button/menu-button.component.less @@ -21,6 +21,9 @@ cursor: pointer; display: inline-block; position: relative; + &.disabled { + cursor: auto; + } a { text-align: center; text-decoration: none; @@ -45,4 +48,11 @@ top: 0; right: -1em; } + + .disabled { + * { + color: @unknown-color; + cursor: auto; + } + } } 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 f94bc0e..ae27851 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 @@ -79,6 +79,9 @@ export class MenuButtonComponent { maxLongClickDelay: number = 0; @Input() + isDisabled: boolean = false; + + @Input() listClass: string = ''; @Output() @@ -116,23 +119,25 @@ export class MenuButtonComponent { * @param {MouseEvent} event */ onMouseClick(event: MouseEvent): void { - let el = <HTMLElement>event.target; - let now = Date.now(); - let mdt = this.mouseDownTimestamp; // mousedown time - let isLongClick = mdt && mdt + this.minLongClickDelay <= now && ( - !this.maxLongClickDelay || mdt + this.maxLongClickDelay >= now - ); - let openDropdown = this.hasSubItems && ( - el.classList.contains(this.caretClass) || isLongClick || !this.buttonClick.observers.length - ); - if (openDropdown && this.dropdown) { - if (this.toggleDropdown()) { - this.listenToClickOut(); + if (!this.isDisabled) { + const el = <HTMLElement>event.target; + const now = Date.now(); + const mdt = this.mouseDownTimestamp; // mousedown time + const isLongClick = mdt && mdt + this.minLongClickDelay <= now && ( + !this.maxLongClickDelay || mdt + this.maxLongClickDelay >= now + ); + const openDropdown = this.hasSubItems && ( + el.classList.contains(this.caretClass) || isLongClick || !this.buttonClick.observers.length + ); + if (openDropdown && this.dropdown) { + if (this.toggleDropdown()) { + this.listenToClickOut(); + } + } else if (this.buttonClick.observers.length) { + this.buttonClick.emit(); } - } else if (this.buttonClick.observers.length) { - this.buttonClick.emit(); + this.mouseDownTimestamp = 0; } - this.mouseDownTimestamp = 0; event.preventDefault(); } @@ -141,20 +146,22 @@ export class MenuButtonComponent { * component. */ private listenToClickOut = (): void => { - this.dropdownIsOpen && document.addEventListener('click', this.onDocumentMouseClick); - }; + if (this.dropdownIsOpen) { + document.addEventListener('click', this.onDocumentMouseClick); + } + } /** * Handling the click event on the document to hide the dropdown list if it needs. * @param {MouseEvent} event */ private onDocumentMouseClick = (event: MouseEvent): void => { - let el = <HTMLElement>event.target; + const el = <HTMLElement>event.target; if (!this.dropdown.nativeElement.contains(el)) { this.closeDropdown(); - this.removeDocumentClickListener() + this.removeDocumentClickListener(); } - }; + } /** * Handling the mousedown event, so that we can check the long clicks and open the dropdown if any. @@ -162,12 +169,12 @@ export class MenuButtonComponent { */ onMouseDown = (event: MouseEvent): void => { if (this.hasSubItems) { - let el = <HTMLElement>event.target; + const el = <HTMLElement>event.target; if (!el.classList.contains(this.caretClass)) { this.mouseDownTimestamp = Date.now(); } } - }; + } /** * The goal is to have one and only one place where we open the dropdown. So that later if we need to change the way diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/modules/app-load/app-load.module.ts b/ambari-logsearch/ambari-logsearch-web/src/app/modules/app-load/app-load.module.ts index 62c7ac5..9ce6662 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/modules/app-load/app-load.module.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/modules/app-load/app-load.module.ts @@ -32,8 +32,8 @@ export function set_translation_service(appLoadService: AppLoadService) { imports: [HttpClientModule], providers: [ AppLoadService, - { provide: APP_INITIALIZER, useFactory: check_if_authorized, deps: [AppLoadService], multi: true }, - { provide: APP_INITIALIZER, useFactory: set_translation_service, deps: [AppLoadService], multi: true } + { provide: APP_INITIALIZER, useFactory: set_translation_service, deps: [AppLoadService], multi: true }, + { provide: APP_INITIALIZER, useFactory: check_if_authorized, deps: [AppLoadService], multi: true } ] }) export class AppLoadModule { } diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/modules/app-load/services/app-load.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/modules/app-load/services/app-load.service.ts index 3a207be..43985c0 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/modules/app-load/services/app-load.service.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/modules/app-load/services/app-load.service.ts @@ -176,9 +176,11 @@ export class AppLoadService { isInitialLoading: false }); }; - const statusRequestPromise: Promise<Response> = this.httpClient.get('status').toPromise(); - statusRequestPromise.then((response: Response) => setAuthorization(response.ok)); - return statusRequestPromise; + return this.httpClient.get('status').toPromise() + .then( + (response: Response) => setAuthorization(response.ok), + (response: Response) => setAuthorization(false) + ); } setTranslationService() { diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.html b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.html index e2c6daa..f0c5854 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.html +++ b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.html @@ -23,13 +23,13 @@ (change)="changeSelectedItem({value: item.value, isChecked: $event.currentTarget.checked}, $event)"> <label [attr.for]="item.id || item.value" class="label-container"> <span *ngIf="item.iconClass" [ngClass]="item.iconClass"></span> - {{item.label | translate}} + <span class="item-label-text">{{item.label | translate}}</span> <span #additionalComponent></span> </label> </label> <span class="list-item-label label-container" *ngIf="!isMultipleChoice" (click)="changeSelectedItem(item, $event)"> <span *ngIf="item.iconClass" [ngClass]="item.iconClass"></span> - {{item.label | translate}} + <span class="item-label-text">{{item.label | translate}}</span> <span #additionalComponent></span> </span> </ng-container> @@ -41,7 +41,7 @@ <i class="fa fa-search"></i> <i class="fa fa-times-circle-o clear-filter" [class.hide]="!filterRegExp" (click)="clearFilter($event)"></i> </li> -<li class="selection-all"> +<li class="selection-all" *ngIf="isMultipleChoice"> <label *ngIf="isMultipleChoice && items && items.length" class="list-item-label" (click)="changeAllSelection($event)"> <input type="checkbox" #selectAll [value]="items && items.length" [checked]="items && (items.length === itemsSelected.length)"> diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/variables.less b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/variables.less index 5dfbe9e..7ee8faf 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/variables.less +++ b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/variables.less @@ -35,7 +35,7 @@ @list-header-background-color: #F2F2F2; @checkbox-top: 4px; @dropdown-min-width: 160px; -@dropdown-max-height: 500px; // TODO get rid of magic number, base on actual design +@dropdown-max-height: 60vh; // TODO get rid of magic number, base on actual design @dropdown-border-radius: 2px; @input-height: 34px; @input-padding: 10px; diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/auth.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/auth.service.ts index 2880aa7..50586f6 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/services/auth.service.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/auth.service.ts @@ -54,9 +54,9 @@ export class AuthService { )); } - onAppStateIsAuthorizedChanged = (isAuthorized):void => { - if (isAuthorized && this.redirectUrl) { - this.router.navigate([this.redirectUrl]); + onAppStateIsAuthorizedChanged = (isAuthorized): void => { + if (isAuthorized) { + this.router.navigate([this.redirectUrl || '/']); this.redirectUrl = ''; } } diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/history-manager.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/history-manager.service.ts index 9d314b6..9851398 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/services/history-manager.service.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/history-manager.service.ts @@ -161,23 +161,26 @@ export class HistoryManagerService { } else { this.currentHistoryItemId = currentHistory.length; } - this.activeHistory = [ - { - value: { - currentValue: Object.assign({}, value), - previousValue: Object.assign({}, previousValue), - changeId: this.currentHistoryItemId, - previousChangeId, - isUndoOrRedo - }, - label: this.getHistoryItemLabel(previousValue, value) + const newItem = { + value: { + currentValue: Object.assign({}, value), + previousValue: Object.assign({}, previousValue), + changeId: this.currentHistoryItemId, + previousChangeId, + isUndoOrRedo }, - ...currentHistory - ].slice(0, this.maxHistoryItemsCount); - this.appState.setParameter('history', { - items: this.activeHistory.slice(), - currentId: this.currentHistoryItemId - }); + label: this.getHistoryItemLabel(previousValue, value) + }; + if (newItem.label) { + this.activeHistory = [ + newItem, + ...currentHistory + ].slice(0, this.maxHistoryItemsCount); + this.appState.setParameter('history', { + items: this.activeHistory.slice(), + currentId: this.currentHistoryItemId + }); + } } } @@ -191,14 +194,14 @@ export class HistoryManagerService { return item.value.changeId === this.currentHistoryItemId && !item.value.isUndoOrRedo; }); let endIndex = allItems.slice(startIndex + 1).findIndex((item: ListItem): boolean => item.value.isUndoOrRedo); + let items = []; if (startIndex > -1) { if (endIndex === -1) { endIndex = allItems.length; - return allItems.slice(startIndex, startIndex + endIndex + 1); } - } else { - return []; + items = allItems.slice(startIndex, startIndex + endIndex + 1); } + return items; } /** @@ -270,16 +273,18 @@ export class HistoryManagerService { * @returns {string} */ private getHistoryItemLabel(previousFormValue: object, currentFormValue: object): string { - return this.filterParameters.reduce((currentResult: string, currentName: string): string => { - const currentValue = currentFormValue[currentName]; - if (this.ignoredParameters.indexOf(currentName) > -1 - || this.utils.isEqual(previousFormValue[currentName], currentValue)) { - return currentResult; - } else { - const currentLabel = this.getItemValueString(currentName, currentValue); - return `${currentResult} ${currentLabel}`; - } - }, ''); + return this.filterParameters.reduce( + (currentResult: string, currentName: string): string => { + const currentValue = currentFormValue[currentName]; + if (this.ignoredParameters.indexOf(currentName) > -1 + || this.utils.isEqual(previousFormValue[currentName], currentValue)) { + return currentResult; + } else { + const currentLabel = this.getItemValueString(currentName, currentValue); + return `${currentResult} ${currentLabel}`; + } + }, '' + ); } /** @@ -289,25 +294,33 @@ export class HistoryManagerService { private handleUndoOrRedo(value: object): void { const filtersForm = this.logsContainerService.filtersForm; this.hasNoPendingUndoOrRedo = false; - this.filterParameters.forEach((controlName: string): void => { - if (this.ignoredParameters.indexOf(controlName) === -1) { - filtersForm.controls[controlName].setValue(value[controlName]); - } - }); + this.logsContainerService.filtersFormSyncInProgress.next(true); + this.filterParameters.filter(controlName => this.ignoredParameters.indexOf(controlName) === -1) + .forEach((controlName: string): void => { + filtersForm.controls[controlName].setValue(value[controlName], { + emitEvent: false, + onlySelf: true + }); + }); + this.logsContainerService.filtersFormSyncInProgress.next(false); this.hasNoPendingUndoOrRedo = true; filtersForm.controls.isUndoOrRedo.setValue(true); } undo(item: ListItem): void { - this.hasNoPendingUndoOrRedo = false; - this.currentHistoryItemId = item.value.previousChangeId; - this.handleUndoOrRedo(item.value.previousValue); + if (item) { + this.hasNoPendingUndoOrRedo = false; + this.currentHistoryItemId = item.value.previousChangeId; + this.handleUndoOrRedo(item.value.previousValue); + } } redo(item: ListItem): void { - this.hasNoPendingUndoOrRedo = false; - this.currentHistoryItemId = item.value.changeId; - this.handleUndoOrRedo(item.value.currentValue); + if (item) { + this.hasNoPendingUndoOrRedo = false; + this.currentHistoryItemId = item.value.changeId; + this.handleUndoOrRedo(item.value.currentValue); + } } } diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/http-client.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/http-client.service.ts index 9d186b2..8c222e0 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/services/http-client.service.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/http-client.service.ts @@ -160,7 +160,7 @@ export class HttpClientService extends Http { } return handled; }; - const req: Observable<Response> = super.request(this.generateUrl(url), options).share() + const req: Observable<Response> = super.request(this.generateUrl(url), options).first() .map(response => response) .catch((error: any) => { return handleResponseError(error) ? Observable.of(error) : Observable.throw(error); diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-container.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-container.service.ts index 29a8437..68b90ac 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-container.service.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-container.service.ts @@ -117,7 +117,7 @@ export class LogsContainerService { defaultSelection: [], fieldName: 'cluster' }, - timeRange: { + timeRange: { // @ToDo remove duplication, this options are in the LogFilteringUtilsService too label: 'logs.duration', options: [ [ @@ -661,7 +661,8 @@ export class LogsContainerService { this.compareFilterOptions ); }); - this.clusterSelectionStoreService.getParameter(LogsContainerService.clusterSelectionStoreKey).subscribe(this.onClusterSelectionChanged); + this.clusterSelectionStoreService.getParameter(LogsContainerService.clusterSelectionStoreKey) + .filter(selection => !!selection).subscribe(this.onClusterSelectionChanged); } // diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-filtering-utils.service.ts b/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-filtering-utils.service.ts index 03a817c..f88fe72 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-filtering-utils.service.ts +++ b/ambari-logsearch/ambari-logsearch-web/src/app/services/logs-filtering-utils.service.ts @@ -23,6 +23,190 @@ import {HomogeneousObject} from '@app/classes/object'; import {LogsType, SortingType} from '@app/classes/string'; import {UtilsService} from '@app/services/utils.service'; +// @ToDo remove duplication, this options are in the LogContainerService +const timeRangeFilterOptions = [{ + 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' + } + }, + { + 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 + } + }]; + @Injectable() export class LogsFilteringUtilsService { @@ -226,9 +410,17 @@ export class LogsFilteringUtilsService { break; case 'timeRangeType': const type = queryParams.timeRangeType || 'LAST'; - const timeRangeFilterValue: {[key: string]: any} = {type}; + const interval = parseInt(queryParams.timeRangeInterval, 0); + const unit = queryParams.timeRangeUnit; + const timeRangeFilterValue: {[key: string]: any} = {type, unit, interval}; let timeRangeFilterLabel = 'filter.timeRange.'; - if (queryParams.timeRangeType !== 'CUSTOM') { + const timeRangeOption = timeRangeFilterOptions.find((option: any) => { + const value = option.value; + return value.type === type && value.unit === timeRangeFilterValue.unit && value.interval === timeRangeFilterValue.interval; + }); + if (timeRangeOption) { + timeRangeFilterLabel = timeRangeOption.label; + } else if (queryParams.timeRangeType !== 'CUSTOM') { Object.assign(timeRangeFilterValue, { unit: queryParams.timeRangeUnit, interval: parseInt(queryParams.timeRangeInterval, 0) -- To stop receiving notification emails like this one, please contact ababiic...@apache.org.