You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2018/05/21 10:29:04 UTC
[ambari] branch trunk updated: AMBARI-23840 Log Search UI: Correct
the links from Ambari to Log Search
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 73a8c8a AMBARI-23840 Log Search UI: Correct the links from Ambari to Log Search
73a8c8a is described below
commit 73a8c8ae99d44bf48109ab31bf1d252b10daad02
Author: Istvan Tobias <to...@gmail.com>
AuthorDate: Mon May 21 12:29:00 2018 +0200
AMBARI-23840 Log Search UI: Correct the links from Ambari to Log Search
---
.../filter-button/filter-button.component.ts | 4 +-
.../logs-container/logs-container.component.ts | 20 +-
.../filter-dropdown/filter-dropdown.component.ts | 2 +-
.../src/app/services/auth.service.ts | 6 +-
.../src/app/services/logs-container.service.ts | 293 +++------------------
.../app/services/logs-filtering-utils.service.ts | 225 ++++++++++------
.../views/common/host_progress_popup_body_view.js | 2 +-
ambari-web/app/views/main/host/logs_view.js | 2 +-
ambari-web/test/views/main/host/logs_view_test.js | 4 +-
9 files changed, 209 insertions(+), 349 deletions(-)
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 c5e0c2c..5d47604 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
@@ -80,7 +80,9 @@ export class FilterButtonComponent extends MenuButtonComponent implements Contro
const checkedItems = this.subItems.filter((option: ListItem): boolean => option.isChecked);
this.selection = checkedItems;
this.selectItem.emit(checkedItems.map((option: ListItem): any => option.value));
- this.dropdownList.doItemsCheck();
+ if (this.dropdownList) {
+ this.dropdownList.doItemsCheck();
+ }
}
writeValue(items: ListItem[]) {
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 8ab1d49..1211eff 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
@@ -102,9 +102,11 @@ export class LogsContainerComponent implements OnInit, OnDestroy {
ngOnInit() {
this.logsContainerService.loadColumnsNames();
+ // set te logsType when the activeLogsType state has changed
this.subscriptions.push(
this.appState.getParameter('activeLogsType').subscribe((value: LogsType) => this.logsType = value)
);
+ // set the hhistogramm data
this.subscriptions.push(
this.serviceLogsHistogramStorage.getAll().subscribe((data: BarGraph[]): void => {
this.serviceLogsHistogramData = this.logsContainerService.getGraphData(data, this.logsContainerService.logLevels.map((
@@ -114,11 +116,13 @@ export class LogsContainerComponent implements OnInit, OnDestroy {
}));
})
);
+ // audit graph data set
this.subscriptions.push(
this.auditLogsGraphStorage.getAll().subscribe((data: BarGraph[]): void => {
this.auditLogsGraphData = this.logsContainerService.getGraphData(data);
})
);
+ // service log context flag subscription
this.subscriptions.push(
this.appState.getParameter('isServiceLogContextView').subscribe((value: boolean): void => {
this.isServiceLogContextView = value;
@@ -130,27 +134,28 @@ export class LogsContainerComponent implements OnInit, OnDestroy {
this.filtersForm.valueChanges
.filter(() => !this.logsContainerService.filtersFormSyncInProgress.getValue()).subscribe(this.onFiltersFormChange)
);
-
+ // change the active tab when the active tab id changed in the URL
this.subscriptions.push(
this.activatedRoute.params.map((params: {[key: string]: any}) => params && params.activeTab)
.subscribe(this.onActiveTabParamChange)
);
-
+ // sync to filters form when the query params changed (only when there is no other way sync)
this.subscriptions.push(
this.activatedRoute.queryParams.filter(() => !this.queryParamsSyncInProgress.getValue()).subscribe(this.onQueryParamsChange)
);
+ // get the current query params and sync them if any
this.activatedRoute.queryParams.first().subscribe((params) => {
if (!Object.keys(params).length) {
this.syncFiltersToQueryParams(this.filtersForm.value);
}
});
-
+ // when the active tab id changed in the store we sync the tab filters to the query params
this.subscriptions.push(
this.logsStateService.getParameter('activeTabId').skip(1).subscribe(this.onActiveTabSwitched)
);
-
+ // set the position of the filter panel depending on the scroll height: so it is fixed when it would be out from the screen
this.subscriptions.push(
- Observable.fromEvent(window, 'scroll').throttleTime(10).subscribe(() => {
+ Observable.fromEvent(window, 'scroll').subscribe(() => {
this.setFixedPositionValue();
})
);
@@ -273,7 +278,10 @@ export class LogsContainerComponent implements OnInit, OnDestroy {
const filtersFromQueryParams = this.logsFilteringUtilsService.getFilterFromQueryParams(
queryParams, this.logsContainerService.activeLogsType
);
- this.logsContainerService.syncFiltersToFiltersForms(filtersFromQueryParams);
+ this.logsContainerService.syncFiltersToFiltersForms({
+ ...this.logsFilteringUtilsService.defaultFilterSelections,
+ ...filtersFromQueryParams
+ });
}
}
diff --git a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/components/filter-dropdown/filter-dropdown.component.ts b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/components/filter-dropdown/filter-dropdown.component.ts
index 4381e39..6140e7d 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/components/filter-dropdown/filter-dropdown.component.ts
+++ b/ambari-logsearch/ambari-logsearch-web/src/app/modules/shared/components/filter-dropdown/filter-dropdown.component.ts
@@ -54,7 +54,7 @@ export class FilterDropdownComponent extends DropdownButtonComponent implements
}
writeValue(items: ListItem[]) {
- this.selection = items;
+ this.selection = items || [];
}
registerOnChange(callback: any): void {
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 1a26fe4..87cdb41 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
@@ -58,7 +58,11 @@ export class AuthService {
if (isAuthorized) {
const redirectTo = this.redirectUrl || (this.router.routerState.snapshot.url === '/login' ? '/' : null);
if (redirectTo) {
- this.router.navigate(Array.isArray(redirectTo) ? redirectTo : [redirectTo]);
+ if (Array.isArray(redirectTo)) {
+ this.router.navigate(redirectTo);
+ } else {
+ this.router.navigateByUrl(redirectTo);
+ }
}
this.redirectUrl = '';
} else if (!isAuthorized) {
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 4d74d6e..0772846 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
@@ -60,7 +60,7 @@ import {CommonEntry} from '@app/classes/models/common-entry';
import {ClusterSelectionService} from '@app/services/storage/cluster-selection.service';
import {ActivatedRoute, Router} from '@angular/router';
import {RoutingUtilsService} from '@app/services/routing-utils.service';
-import {LogsFilteringUtilsService} from '@app/services/logs-filtering-utils.service';
+import {LogsFilteringUtilsService, timeRangeFilterOptions} from '@app/services/logs-filtering-utils.service';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {LogsStateService} from '@app/services/storage/logs-state.service';
import {LogLevelComponent} from '@app/components/log-level/log-level.component';
@@ -115,236 +115,19 @@ export class LogsContainerService {
clusters: {
label: 'filter.clusters',
options: [],
- defaultSelection: [],
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.clusters,
fieldName: 'cluster'
},
timeRange: { // @ToDo remove duplication, this options are in the LogsFilteringUtilsService too
label: 'logs.duration',
- 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
- }
- },
- ]
- ],
- defaultSelection: {
- value: {
- type: 'LAST',
- unit: 'h',
- interval: 1
- },
- label: 'filter.timeRange.1hr'
- }
+ options: this.logsFilteringUtilsService.getTimeRandeOptionsByGroup(),
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.timeRange
},
components: {
label: 'filter.components',
iconClass: 'fa fa-cubes',
options: [],
- defaultSelection: [],
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.components,
fieldName: 'type'
},
levels: {
@@ -359,14 +142,14 @@ export class LogsContainerService {
iconClass: `fa ${LogLevelComponent.classMap[cssClass]}`
};
}),
- defaultSelection: [],
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.levels,
fieldName: 'level'
},
hosts: {
label: 'filter.hosts',
iconClass: 'fa fa-server',
options: [],
- defaultSelection: [],
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.hosts,
fieldName: 'host'
},
auditLogsSorting: {
@@ -387,15 +170,7 @@ export class LogsContainerService {
}
}
],
- defaultSelection: [
- {
- label: 'sorting.time.desc',
- value: {
- key: 'evtTime',
- type: 'desc'
- }
- }
- ]
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.auditLogsSorting
},
serviceLogsSorting: {
label: 'sorting.title',
@@ -415,15 +190,7 @@ export class LogsContainerService {
}
}
],
- defaultSelection: [
- {
- label: 'sorting.time.desc',
- value: {
- key: 'logtime',
- type: 'desc'
- }
- }
- ]
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.serviceLogsSorting
},
pageSize: {
label: 'pagination.title',
@@ -433,28 +200,23 @@ export class LogsContainerService {
value: option
};
}),
- defaultSelection: [
- {
- label: '10',
- value: '10'
- }
- ]
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.pageSize
},
page: {
- defaultSelection: 0
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.page
},
query: {
- defaultSelection: []
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.query
},
users: {
label: 'filter.users',
iconClass: 'fa fa-server',
options: [],
- defaultSelection: [],
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.users,
fieldName: 'reqUser'
},
isUndoOrRedo: {
- defaultSelection: false
+ defaultSelection: this.logsFilteringUtilsService.defaultFilterSelections.isUndoOrRedo
}
};
@@ -628,7 +390,7 @@ export class LogsContainerService {
const item = {
[key]: formControl
};
- formControl.setValue(this.filters[key].defaultSelection);
+ formControl.setValue(this.logsFilteringUtilsService.defaultFilterSelections[key]);
return Object.assign(currentObject, item);
}, {});
this.filtersForm = new FormGroup(formItems);
@@ -689,8 +451,12 @@ export class LogsContainerService {
.first()
.subscribe(() => {
this.filtersFormSyncInProgress.next(true);
- this.filtersForm.reset(filters, {emitEvent: false});
+ this.filtersForm.reset(
+ {...this.logsFilteringUtilsService.defaultFilterSelections, ...filters},
+ {emitEvent: false}
+ );
this.filtersFormSyncInProgress.next(false);
+ this.onFiltersFormValueChange();
});
}
@@ -755,6 +521,7 @@ export class LogsContainerService {
* Handle the filters form value changes in order to sync the current tab's filters and also to load the logs.
*/
private onFiltersFormValueChange = (): void => {
+ const filters = this.filtersForm.getRawValue();
this.syncFiltersToActiveTabFilters(this.filtersForm.getRawValue());
this.loadLogs();
}
@@ -925,13 +692,17 @@ export class LogsContainerService {
paramNames.forEach((paramName: string): void => {
let value;
const valueGetter = this.valueGetters[paramName] || this.logsFilteringUtilsService.defaultValueGetterFromListItem;
- if (paramName === 'from') {
- value = valueGetter(inputValue, params['to']);
+ if (inputValue === null || inputValue === undefined) {
+
} else {
- value = valueGetter(inputValue);
- }
- if (value != null && value !== '') {
- params[paramName] = value;
+ if (paramName === 'from') {
+ value = valueGetter(inputValue, params['to']);
+ } else {
+ value = valueGetter(inputValue);
+ }
+ if (value != null && value !== '') {
+ params[paramName] = value;
+ }
}
});
}, this);
@@ -1094,7 +865,7 @@ export class LogsContainerService {
const keys = Object.keys(this.filters).filter((key: string): boolean => itemsList.indexOf(key) > -1);
return keys.reduce((currentObject: object, key: string): object => {
return Object.assign(currentObject, {
- [key]: this.filters[key].defaultSelection
+ [key]: this.logsFilteringUtilsService.defaultFilterSelections[key]
});
}, {});
}
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 3b98b45..6566f4e 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
@@ -24,13 +24,14 @@ 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 = [{
+export const timeRangeFilterOptions = [{
label: 'filter.timeRange.7d',
value: {
type: 'LAST',
unit: 'd',
interval: 7
- }
+ },
+ group: 0
},
{
label: 'filter.timeRange.30d',
@@ -38,7 +39,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'd',
interval: 30
- }
+ },
+ group: 0
},
{
label: 'filter.timeRange.60d',
@@ -46,7 +48,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'd',
interval: 60
- }
+ },
+ group: 0
},
{
label: 'filter.timeRange.90d',
@@ -54,7 +57,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'd',
interval: 90
- }
+ },
+ group: 0
},
{
label: 'filter.timeRange.6m',
@@ -62,7 +66,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'M',
interval: 6
- }
+ },
+ group: 0
},
{
label: 'filter.timeRange.1y',
@@ -70,7 +75,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'y',
interval: 1
- }
+ },
+ group: 0
},
{
label: 'filter.timeRange.2y',
@@ -78,7 +84,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'y',
interval: 2
- }
+ },
+ group: 0
},
{
label: 'filter.timeRange.5y',
@@ -86,69 +93,81 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'y',
interval: 5
- }
- }, {
+ },
+ group: 0
+ },
+ {
label: 'filter.timeRange.yesterday',
value: {
type: 'PAST',
unit: 'd'
- }
+ },
+ group: 1
},
{
label: 'filter.timeRange.previousWeek',
value: {
type: 'PAST',
unit: 'w'
- }
+ },
+ group: 1
},
{
label: 'filter.timeRange.previousMonth',
value: {
type: 'PAST',
unit: 'M'
- }
+ },
+ group: 1
},
{
label: 'filter.timeRange.previousYear',
value: {
type: 'PAST',
unit: 'y'
- }
+ },
+ group: 1
},
{
label: 'filter.timeRange.today',
value: {
type: 'CURRENT',
unit: 'd'
- }
+ },
+ group: 1
},
{
label: 'filter.timeRange.thisWeek',
value: {
type: 'CURRENT',
unit: 'w'
- }
+ },
+ group: 1
},
{
label: 'filter.timeRange.thisMonth',
value: {
type: 'CURRENT',
unit: 'M'
- }
+ },
+ group: 1
},
{
label: 'filter.timeRange.thisYear',
value: {
type: 'CURRENT',
unit: 'y'
- }
- }, {
+ },
+ group: 1
+ },
+ {
label: 'filter.timeRange.5min',
value: {
type: 'LAST',
unit: 'm',
interval: 5
- }
+ },
+ group: 2
},
{
label: 'filter.timeRange.15min',
@@ -156,7 +175,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'm',
interval: 15
- }
+ },
+ group: 2
},
{
label: 'filter.timeRange.30min',
@@ -164,7 +184,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'm',
interval: 30
- }
+ },
+ group: 2
},
{
label: 'filter.timeRange.1hr',
@@ -172,7 +193,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'h',
interval: 1
- }
+ },
+ group: 2
},
{
label: 'filter.timeRange.3hr',
@@ -180,7 +202,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'h',
interval: 3
- }
+ },
+ group: 2
},
{
label: 'filter.timeRange.6hr',
@@ -188,7 +211,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'h',
interval: 6
- }
+ },
+ group: 2
},
{
label: 'filter.timeRange.12hr',
@@ -196,7 +220,8 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'h',
interval: 12
- }
+ },
+ group: 2
},
{
label: 'filter.timeRange.24hr',
@@ -204,16 +229,64 @@ const timeRangeFilterOptions = [{
type: 'LAST',
unit: 'h',
interval: 24
- }
+ },
+ group: 2
}];
@Injectable()
export class LogsFilteringUtilsService {
+ readonly defaultFilterSelections = {
+ clusters: [],
+ timeRange: {
+ value: {
+ type: 'LAST',
+ unit: 'h',
+ interval: 1
+ },
+ label: 'filter.timeRange.1hr'
+ },
+ components: [],
+ levels: [],
+ hosts: [],
+ auditLogsSorting: {
+ label: 'sorting.time.desc',
+ value: {
+ key: 'evtTime',
+ type: 'desc'
+ }
+ },
+ serviceLogsSorting: {
+ label: 'sorting.time.desc',
+ value: {
+ key: 'logtime',
+ type: 'desc'
+ }
+ },
+ pageSize: [{
+ label: '10',
+ value: '10'
+ }],
+ page: 0,
+ query: [],
+ users: [],
+ isUndoOrRedo: false
+ };
+
constructor(
private utilsService: UtilsService
) { }
+ getTimeRandeOptionsByGroup() {
+ return timeRangeFilterOptions.reduce((groups: any, item: any) => {
+ const groupItem = {...item};
+ delete groupItem.group;
+ groups[item.group] = groups[item.group] || [];
+ groups[item.group].push(groupItem);
+ return groups;
+ }, []);
+ }
+
getStartTimeMomentFromTimeUnitListItem(selection: TimeUnitListItem, end: moment.Moment, timeZone: string): moment.Moment | undefined {
let time;
const value = selection && selection.value;
@@ -298,11 +371,11 @@ export class LogsFilteringUtilsService {
}
getSortTypeFromSortingListItem(selection: SortingListItem[] = []): SortingType {
- return selection[0] && selection[0].value ? selection[0].value.type : 'desc';
+ return selection && selection[0] && selection[0].value ? selection[0].value.type : 'desc';
}
getSortKeyFromSortingListItem(selection: SortingListItem[] = []): string {
- return selection[0] && selection[0].value ? selection[0].value.key : '';
+ return selection && selection[0] && selection[0].value ? selection[0].value.key : '';
}
getPage(value: number | undefined): string | undefined {
@@ -326,52 +399,54 @@ export class LogsFilteringUtilsService {
const newParams = {
...currentParams
};
- switch (key) {
- case 'auditLogsSorting':
- case 'serviceLogsSorting':
- if (`${activeLogsType}Sorting` === key) {
- const item = Array.isArray(filters[key]) ? filters[key][0] : filters[key];
- const itemValue = item && item.value;
- Object.assign(newParams, {
- sortingKey: itemValue.key,
- sortingType: itemValue.type,
- });
- }
- break;
- case 'query' :
- Object.assign(newParams, {
- [key]: JSON.stringify(filters[key])
- });
- break;
- case 'timeRange' :
- const timeRangeValue: TimeUnit | CustomTimeRange = filters[key].value;
- const timeRangeParams: {[key: string]: string} = {
- timeRangeType: timeRangeValue.type
- };
- if (timeRangeValue.type === 'CUSTOM') {
- Object.assign(timeRangeParams, {
- timeRangeStart: timeRangeValue.start.toISOString(),
- timeRangeEnd: timeRangeValue.end.toISOString()
- });
- } else {
- Object.assign(timeRangeParams, {
- timeRangeInterval: timeRangeValue.interval,
- timeRangeUnit: timeRangeValue.unit
- });
- }
- Object.assign(newParams, timeRangeParams);
- break;
- default:
- const customMethodName: string = 'get' + (key.charAt(0).toUpperCase()) + key.slice(1);
- const valueGetter: Function = (
- this[customMethodName] || this.defaultValueGetterFromListItem
- );
- const paramValue = valueGetter(filters[key]);
+ if (filters[key] !== null && filters[key] !== undefined) {
+ switch (key) {
+ case 'auditLogsSorting':
+ case 'serviceLogsSorting':
+ if (`${activeLogsType}Sorting` === key) {
+ const item = Array.isArray(filters[key]) ? filters[key][0] : filters[key];
+ const itemValue = item && item.value;
+ Object.assign(newParams, {
+ sortingKey: itemValue.key,
+ sortingType: itemValue.type,
+ });
+ }
+ break;
+ case 'query' :
Object.assign(newParams, {
- ...newParams,
- [key]: paramValue
+ [key]: JSON.stringify(filters[key])
});
- break;
+ break;
+ case 'timeRange' :
+ const timeRangeValue: TimeUnit | CustomTimeRange = filters[key].value;
+ const timeRangeParams: {[key: string]: string} = {
+ timeRangeType: timeRangeValue.type
+ };
+ if (timeRangeValue.type === 'CUSTOM') {
+ Object.assign(timeRangeParams, {
+ timeRangeStart: timeRangeValue.start.toISOString(),
+ timeRangeEnd: timeRangeValue.end.toISOString()
+ });
+ } else {
+ Object.assign(timeRangeParams, {
+ timeRangeInterval: timeRangeValue.interval,
+ timeRangeUnit: timeRangeValue.unit
+ });
+ }
+ Object.assign(newParams, timeRangeParams);
+ break;
+ default:
+ const customMethodName: string = 'get' + (key.charAt(0).toUpperCase()) + key.slice(1);
+ const valueGetter: Function = (
+ this[customMethodName] || this.defaultValueGetterFromListItem
+ );
+ const paramValue = valueGetter(filters[key]);
+ Object.assign(newParams, {
+ ...newParams,
+ [key]: paramValue
+ });
+ break;
+ }
}
return newParams;
}, {});
@@ -443,13 +518,13 @@ export class LogsFilteringUtilsService {
case 'sortingKey' :
const sortingKey = `${activeLogsType}Sorting`;
newFilter = {
- [sortingKey]: [{
+ [sortingKey]: {
label: `sorting.time.${queryParams.sortingType}`,
value: {
key: queryParams.sortingKey,
type: queryParams.sortingType
}
- }]
+ }
};
break;
case 'query' :
diff --git a/ambari-web/app/views/common/host_progress_popup_body_view.js b/ambari-web/app/views/common/host_progress_popup_body_view.js
index d08cfeb..9422700 100644
--- a/ambari-web/app/views/common/host_progress_popup_body_view.js
+++ b/ambari-web/app/views/common/host_progress_popup_body_view.js
@@ -1141,7 +1141,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({
var relationType,
componentName,
hostName,
- linkTailTpl = '?host_name={0}&file_name={1}&component_name={2}';
+ linkTailTpl = '/#logs/serviceLogs?hosts={0}&components={2}&query=%5B%7B"id":0,"name":"path","label":"Path","value":"{1}","isExclude":false%7D%5D';
if (this.get('openedTask.id')) {
relationType = this._determineRoleRelation(this.get('openedTask'));
diff --git a/ambari-web/app/views/main/host/logs_view.js b/ambari-web/app/views/main/host/logs_view.js
index 4e634e7..78e6d44 100644
--- a/ambari-web/app/views/main/host/logs_view.js
+++ b/ambari-web/app/views/main/host/logs_view.js
@@ -45,7 +45,7 @@ App.MainHostLogsView = App.TableView.extend({
content: function() {
var self = this,
- linkTailTpl = '?host_name={0}&file_name={1}&component_name={2}';
+ linkTailTpl = '/#logs/serviceLogs?hosts={0}&components={2}&query=%5B%7B"id":0,"name":"path","label":"Path","value":"{1}","isExclude":false%7D%5D';
return this.get('hostLogs').map(function(i) {
return Em.Object.create({
diff --git a/ambari-web/test/views/main/host/logs_view_test.js b/ambari-web/test/views/main/host/logs_view_test.js
index 38159df..3f10f97 100644
--- a/ambari-web/test/views/main/host/logs_view_test.js
+++ b/ambari-web/test/views/main/host/logs_view_test.js
@@ -90,12 +90,12 @@ describe('App.MainHostLogsView', function() {
{
fileName: 'file1',
filePath: 'f1',
- linkTail: '?host_name=host1&file_name=f1&component_name=l1'
+ linkTail: '/#logs/serviceLogs?hosts=host1&components=l1&query=%5B%7B\"id\":0,\"name\":\"path\",\"label\":\"Path\",\"value\":\"f1\",\"isExclude\":false%7D%5D'
},
{
fileName: 'file1',
filePath: 'f2',
- linkTail: '?host_name=host1&file_name=f2&component_name=l1'
+ linkTail: '/#logs/serviceLogs?hosts=host1&components=l1&query=%5B%7B\"id\":0,\"name\":\"path\",\"label\":\"Path\",\"value\":\"f2\",\"isExclude\":false%7D%5D'
}
],
fileNamesFilterValue: 'f1,f2'
--
To stop receiving notification emails like this one, please contact
ababiichuk@apache.org.