Skip to content

Commit

Permalink
filter only nodes Signed-Off-By: Tara Black <tblack@chef.io>
Browse files Browse the repository at this point in the history
  • Loading branch information
tarablack01 committed May 14, 2020
1 parent cc51438 commit f49f168
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<string>, reportQuery: ReportQuery): Observable<any> {
Expand Down Expand Up @@ -100,8 +102,9 @@ export class StatsService {

getNodes(reportQuery: ReportQuery, listParams: any): Observable<any> {
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;
Expand All @@ -119,6 +122,14 @@ export class StatsService {
({ total, total_failed, total_passed, total_skipped, total_waived, items: nodes })));
}

private addStatusParam(filters): any {
let statusValue = this.route.queryParams['_value'].status;
if (statusValue) {
filters.push({ type: 'status', values: [statusValue] });
}
return filters;
}

getProfiles(reportQuery: ReportQuery, listParams: any): Observable<any> {
const url = `${CC_API_URL}/reporting/profiles`;

Expand Down
3 changes: 1 addition & 2 deletions components/automate-ui/src/app/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

0 comments on commit f49f168

Please sign in to comment.