adding support for device sort in UI.

pull/262/head
Jason Kulatunga 3 years ago
parent 83839f7faf
commit 9846ba13e0

@ -51,7 +51,7 @@
<div class="flex flex-wrap w-full" *ngFor="let hostId of hostGroups | keyvalue">
<h3 class="ml-4" *ngIf="hostId.key">{{hostId.key}}</h3>
<div class="flex flex-wrap w-full">
<app-dashboard-device class="flex gt-sm:w-1/2 min-w-80 p-4" *ngFor="let wwn of hostId.value" [deviceWWN]="wwn" [deviceSummary]="data.data.summary[wwn]"></app-dashboard-device>
<app-dashboard-device class="flex gt-sm:w-1/2 min-w-80 p-4" *ngFor="let deviceSummary of (deviceSummariesForHostGroup(hostId.value) | deviceSort )" [deviceWWN]="deviceSummary.device.wwn" [deviceSummary]="deviceSummary"></app-dashboard-device>
</div>
</div>

@ -226,6 +226,14 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
return titleParts.join(' - ')
}
deviceSummariesForHostGroup(hostGroupWWNs: string[]) {
let deviceSummaries = []
for(let wwn of hostGroupWWNs){
deviceSummaries.push(this.data.data.summary[wwn])
}
return deviceSummaries
}
openDialog() {
const dialogRef = this.dialog.open(DashboardSettingsComponent);

@ -5,20 +5,20 @@ import { Pipe, PipeTransform } from '@angular/core';
})
export class DeviceSortPipe implements PipeTransform {
numericalStatus(device): number {
if(!device.smart_results[0]){
numericalStatus(deviceSummary): number {
if(!deviceSummary.smart){
return 0
} else if (device.smart_results[0].smart_status == 'passed'){
} else if (deviceSummary.device.device_status == 0){
return 1
} else {
return -1
return deviceSummary.device.device_status * -1 // will return range from -1, -2, -3
}
}
transform(devices: Array<unknown>, ...args: unknown[]): Array<unknown> {
transform(deviceSummaries: Array<unknown>, sortBy = ''): Array<unknown> {
//failed, unknown/empty, passed
devices.sort((a: any, b: any) => {
deviceSummaries.sort((a: any, b: any) => {
let left = this.numericalStatus(a)
let right = this.numericalStatus(b)
@ -27,7 +27,7 @@ export class DeviceSortPipe implements PipeTransform {
});
return devices;
return deviceSummaries;
}
}

Loading…
Cancel
Save