Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate-3144 API compliance reports node filters #3664

Merged
merged 3 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
}