Skip to content

Commit

Permalink
Automate-3144 API compliance reports node filters Signed-Off-By: Tara…
Browse files Browse the repository at this point in the history
… Black <tblack@chef.io>
  • Loading branch information
tarablack01 committed May 13, 2020
1 parent 4a73f93 commit 03aef3b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<chef-phat-radio
class="nodes-list-status-filters"
[value]="nodeFilterStatus"
(change)="filterNodeStatus($event, $event.target.value)">
(change)="statusFilter($event, $event.target.value)">
<chef-option class="filter all" value='all'>
<span class="filter-label">Total Nodes</span>
<span class="filter-total">
Expand Down Expand Up @@ -85,7 +85,7 @@
</chef-tr>
</chef-thead>
<chef-tbody *ngIf="!reportData.nodesListLoading">
<chef-tr *ngFor="let node of filteredNodes(reportData.nodesList.items)">
<chef-tr *ngFor="let node of reportData.nodesList.items">
<chef-td>
<chef-icon *ngIf="node.latest_report.status !== 'waived'" class="status-icon" [ngClass]="node.latest_report.status">
{{ statusIcon(node.latest_report.status) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { takeUntil } from 'rxjs/operators';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Subject } from 'rxjs';
import { groupBy } from 'lodash';
import { includes } from 'lodash/fp';
import * as moment from 'moment/moment';
import { FilterC } from '../types';
import { paginationOverride } from '../shared';
import { TelemetryService } from 'app/services/telemetry/telemetry.service';
import {
StatsService,
ReportQueryService,
Expand All @@ -25,18 +27,18 @@ export class ReportingNodesComponent implements OnInit, OnDestroy {
layerTwoData: any = {};
control: any = {};
nodeFilterStatus = 'all';

scanResultsPane = 0;
openControls = {};

private allowedStatus = ['failed', 'passed', 'skipped', 'waived'];
private isDestroyed: Subject<boolean> = new Subject<boolean>();

constructor(
private statsService: StatsService,
public reportQuery: ReportQueryService,
public reportData: ReportDataService,
private router: Router,
private route: ActivatedRoute
private route: ActivatedRoute,
private telemetryService: TelemetryService,
) {}

ngOnInit() {
Expand All @@ -50,20 +52,27 @@ export class ReportingNodesComponent implements OnInit, OnDestroy {
this.isDestroyed.complete();
}

filterNodeStatus(_event, status) {
public statusFilter(_event, status: string): void {
this.nodeFilterStatus = status;

const queryParams = {...this.route.snapshot.queryParams};

delete queryParams['status'];
delete queryParams['page'];

if ( includes(status, this.allowedStatus) ) {
queryParams['status'] = [status];
this.telemetryService.track('applicationsStatusFilter',
{ entity: 'reportingNodes', statusFilter: status});
}

this.router.navigate([], {queryParams});
}

isNodeStatusSelected(status): boolean {
return this.nodeFilterStatus === status;
}

filteredNodes(nodes) {
return this.nodeFilterStatus === 'all'
? nodes
: nodes.filter((node) => node.latest_report.status === this.nodeFilterStatus);
}

onNodesListPageChanged(event) {
const reportQuery = this.reportQuery.getReportQuery();
this.reportData.nodesListParams.page = event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export class ReportingComponent implements OnInit, OnDestroy {
ReportingFilterTypes.PROFILE_WITH_VERSION,
ReportingFilterTypes.PROFILE_NAME,
ReportingFilterTypes.RECIPE,
ReportingFilterTypes.ROLE
ReportingFilterTypes.ROLE,
ReportingFilterTypes.STATUS
];

// Query search bar
Expand Down
3 changes: 2 additions & 1 deletion components/automate-ui/src/app/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -869,5 +869,6 @@ export enum ReportingFilterTypes {
RECIPE = 'recipe',
ROLE = 'role',
END_TIME = 'end_time',
DATE_INTERVAL = 'date_interval'
DATE_INTERVAL = 'date_interval',
STATUS = 'status'
}

0 comments on commit 03aef3b

Please sign in to comment.