Filters on topology summary added

This commit is contained in:
Piotr Pekala 2019-09-25 02:41:34 -07:00
parent 170560e5f7
commit 1b4d4d2837
3 changed files with 72 additions and 9 deletions

View File

@ -9,14 +9,14 @@
<div class="summaryFilters">
Filter by status <br/>
<div class="filterBox">
<mat-checkbox (change)="applyStatusFilter($event.checked, 'started')">Started</mat-checkbox>
<mat-checkbox (change)="applyStatusFilter($event.checked, 'suspended')">Suspended</mat-checkbox>
<mat-checkbox (change)="applyStatusFilter($event.checked, 'stopped')">Stopped</mat-checkbox>
<mat-checkbox (change)="applyStatusFilter($event.checked, 'started')">started</mat-checkbox>
<mat-checkbox (change)="applyStatusFilter($event.checked, 'suspended')">suspended</mat-checkbox>
<mat-checkbox (change)="applyStatusFilter($event.checked, 'stopped')">stopped</mat-checkbox>
</div>
Filter devices with captures <br/>
<div>
<mat-checkbox (change)="applyStatusFilter($event.checked, 'started')">Show devices with captures</mat-checkbox><br/>
<mat-checkbox (change)="applyStatusFilter($event.checked, 'started')">Show devices with packet filters</mat-checkbox>
Show devices with <br/>
<div class="filterBox">
<mat-checkbox (change)="applyCaptureFilter($event.checked, 'capture')">active capture(s)</mat-checkbox>
<mat-checkbox (change)="applyCaptureFilter($event.checked, 'packet')">active packet filters</mat-checkbox>
</div>
</div>
<div class="summarySorting">

View File

@ -36,7 +36,7 @@
.summaryContent {
margin-left: 5px;
margin-right: 5px;
max-height: 150px;
max-height: 180px;
overflow: auto;
scrollbar-color: darkgrey #263238;
scrollbar-width: thin;

View File

@ -8,6 +8,7 @@ import { ProjectService } from '../../services/project.service';
import { ProjectStatistics } from '../../models/project-statistics';
import { Compute } from '../../models/compute';
import { ComputeService } from '../../services/compute.service';
import { LinksDataSource } from '../../cartography/datasources/links-datasource';
@Component({
@ -29,13 +30,16 @@ export class TopologySummaryComponent implements OnInit, OnDestroy {
startedStatusFilterEnabled: boolean = false;
suspendedStatusFilterEnabled: boolean = false;
stoppedStatusFilterEnabled: boolean = false;
captureFilterEnabled: boolean = false;
packetFilterEnabled: boolean = false;
computes: Compute[] = [];
isTopologyVisible: boolean = true;
constructor(
private nodesDataSource: NodesDataSource,
private projectService: ProjectService,
private computeService: ComputeService
private computeService: ComputeService,
private linksDataSource: LinksDataSource
) {}
ngOnInit() {
@ -97,6 +101,15 @@ export class TopologySummaryComponent implements OnInit, OnDestroy {
this.applyFilters();
}
applyCaptureFilter(value: boolean, filter: string) {
if (filter === 'capture') {
this.captureFilterEnabled = value;
} else if (filter === 'packet') {
this.packetFilterEnabled = value;
}
this.applyFilters();
}
applyFilters() {
let nodes: Node[] = [];
@ -116,6 +129,14 @@ export class TopologySummaryComponent implements OnInit, OnDestroy {
nodes = nodes.concat(this.nodes);
}
if (this.captureFilterEnabled) {
nodes = this.checkCapturing(nodes);
}
if(this.packetFilterEnabled) {
nodes = this.checkPacketFilters(nodes);
}
if (this.sortingOrder === 'asc') {
this.filteredNodes = nodes.sort(this.compareAsc);
} else {
@ -123,6 +144,48 @@ export class TopologySummaryComponent implements OnInit, OnDestroy {
}
}
checkCapturing(nodes: Node[]): Node[] {
let links = this.linksDataSource.getItems();
let nodesWithCapturing: string[] = [];
links.forEach(link => {
if (link.capturing) {
link.nodes.forEach(node => {
nodesWithCapturing.push(node.node_id);
});
}
});
let filteredNodes: Node[] = [];
nodes.forEach(node => {
if (nodesWithCapturing.includes(node.node_id)) {
filteredNodes.push(node);
}
});
return filteredNodes;
}
checkPacketFilters(nodes: Node[]): Node[] {
let links = this.linksDataSource.getItems();
let nodesWithPacketFilters: string[] = [];
links.forEach(link => {
if (link.filters.bpf || link.filters.corrupt || link.filters.corrupt || link.filters.packet_loss || link.filters.frequency_drop) {
link.nodes.forEach(node => {
nodesWithPacketFilters.push(node.node_id);
});
}
});
let filteredNodes: Node[] = [];
nodes.forEach(node => {
if (nodesWithPacketFilters.includes(node.node_id)) {
filteredNodes.push(node);
}
});
return filteredNodes;
}
close() {
this.closeTopologySummary.emit(false);
}