From 8e84e09cad5b2537d199485fb9b6729fc5aa897d Mon Sep 17 00:00:00 2001 From: Tara Black Date: Thu, 14 May 2020 12:28:44 -0500 Subject: [PATCH] filter only nodes Signed-Off-By: Tara Black --- .../+reporting-nodes/reporting-nodes.component.ts | 3 ++- .../+compliance/+reporting/reporting.component.ts | 3 +-- .../+compliance/shared/reporting/stats.service.ts | 15 +++++++++++++-- components/automate-ui/src/app/types/types.ts | 3 +-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/components/automate-ui/src/app/pages/+compliance/+reporting/+reporting-nodes/reporting-nodes.component.ts b/components/automate-ui/src/app/pages/+compliance/+reporting/+reporting-nodes/reporting-nodes.component.ts index 35d7ce1f1ae..b465333772c 100644 --- a/components/automate-ui/src/app/pages/+compliance/+reporting/+reporting-nodes/reporting-nodes.component.ts +++ b/components/automate-ui/src/app/pages/+compliance/+reporting/+reporting-nodes/reporting-nodes.component.ts @@ -42,6 +42,7 @@ export class ReportingNodesComponent implements OnInit, OnDestroy { ) {} ngOnInit() { + this.nodeFilterStatus = this.route.queryParams['_value'].status || 'all'; this.reportQuery.state.pipe( takeUntil(this.isDestroyed)) .subscribe(this.getData.bind(this)); @@ -61,7 +62,7 @@ export class ReportingNodesComponent implements OnInit, OnDestroy { delete queryParams['page']; if ( includes(status, this.allowedStatus) ) { - queryParams['status'] = [status]; + queryParams['status'] = status; this.telemetryService.track('applicationsStatusFilter', { entity: 'reportingNodes', statusFilter: status}); } diff --git a/components/automate-ui/src/app/pages/+compliance/+reporting/reporting.component.ts b/components/automate-ui/src/app/pages/+compliance/+reporting/reporting.component.ts index afb192a43f8..996791c80aa 100644 --- a/components/automate-ui/src/app/pages/+compliance/+reporting/reporting.component.ts +++ b/components/automate-ui/src/app/pages/+compliance/+reporting/reporting.component.ts @@ -60,8 +60,7 @@ export class ReportingComponent implements OnInit, OnDestroy { ReportingFilterTypes.PROFILE_WITH_VERSION, ReportingFilterTypes.PROFILE_NAME, ReportingFilterTypes.RECIPE, - ReportingFilterTypes.ROLE, - ReportingFilterTypes.STATUS + ReportingFilterTypes.ROLE ]; // Query search bar diff --git a/components/automate-ui/src/app/pages/+compliance/shared/reporting/stats.service.ts b/components/automate-ui/src/app/pages/+compliance/shared/reporting/stats.service.ts index 568b2dc8b61..e2ac8bc1819 100644 --- a/components/automate-ui/src/app/pages/+compliance/shared/reporting/stats.service.ts +++ b/components/automate-ui/src/app/pages/+compliance/shared/reporting/stats.service.ts @@ -2,6 +2,7 @@ import { map } from 'rxjs/operators'; import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; +import { ActivatedRoute } from '@angular/router'; import * as moment from 'moment/moment'; import { omitBy, isNil } from 'lodash'; import { environment } from '../../../../../environments/environment'; @@ -20,7 +21,8 @@ export type ControlStatus = 'passed' | 'failed' | 'waived' | 'skipped'; @Injectable() export class StatsService { constructor( - private httpClient: HttpClient + private httpClient: HttpClient, + private route: ActivatedRoute ) {} getFailures(types: Array, reportQuery: ReportQuery): Observable { @@ -100,8 +102,9 @@ export class StatsService { getNodes(reportQuery: ReportQuery, listParams: any): Observable { const url = `${CC_API_URL}/reporting/nodes/search`; + let formatted = this.formatFilters(reportQuery); + formatted = this.addStatusParam(formatted); - const formatted = this.formatFilters(reportQuery); let body = { filters: formatted }; const {page, perPage} = listParams; @@ -119,6 +122,14 @@ export class StatsService { ({ total, total_failed, total_passed, total_skipped, total_waived, items: nodes }))); } + private addStatusParam(filters): any { + const statusValue = this.route.queryParams['_value'].status; + if (statusValue) { + filters.push({ type: 'status', values: [statusValue] }); + } + return filters; + } + getProfiles(reportQuery: ReportQuery, listParams: any): Observable { const url = `${CC_API_URL}/reporting/profiles`; diff --git a/components/automate-ui/src/app/types/types.ts b/components/automate-ui/src/app/types/types.ts index 7e5b154ce01..9f3dff51044 100644 --- a/components/automate-ui/src/app/types/types.ts +++ b/components/automate-ui/src/app/types/types.ts @@ -869,6 +869,5 @@ export enum ReportingFilterTypes { RECIPE = 'recipe', ROLE = 'role', END_TIME = 'end_time', - DATE_INTERVAL = 'date_interval', - STATUS = 'status' + DATE_INTERVAL = 'date_interval' }