adding support for device sort in UI.
This commit is contained in:
@@ -51,7 +51,7 @@
|
|||||||
<div class="flex flex-wrap w-full" *ngFor="let hostId of hostGroups | keyvalue">
|
<div class="flex flex-wrap w-full" *ngFor="let hostId of hostGroups | keyvalue">
|
||||||
<h3 class="ml-4" *ngIf="hostId.key">{{hostId.key}}</h3>
|
<h3 class="ml-4" *ngIf="hostId.key">{{hostId.key}}</h3>
|
||||||
<div class="flex flex-wrap w-full">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -226,6 +226,14 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
|
|||||||
return titleParts.join(' - ')
|
return titleParts.join(' - ')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deviceSummariesForHostGroup(hostGroupWWNs: string[]) {
|
||||||
|
let deviceSummaries = []
|
||||||
|
for(let wwn of hostGroupWWNs){
|
||||||
|
deviceSummaries.push(this.data.data.summary[wwn])
|
||||||
|
}
|
||||||
|
return deviceSummaries
|
||||||
|
}
|
||||||
|
|
||||||
openDialog() {
|
openDialog() {
|
||||||
const dialogRef = this.dialog.open(DashboardSettingsComponent);
|
const dialogRef = this.dialog.open(DashboardSettingsComponent);
|
||||||
|
|
||||||
|
|||||||
@@ -5,20 +5,20 @@ import { Pipe, PipeTransform } from '@angular/core';
|
|||||||
})
|
})
|
||||||
export class DeviceSortPipe implements PipeTransform {
|
export class DeviceSortPipe implements PipeTransform {
|
||||||
|
|
||||||
numericalStatus(device): number {
|
numericalStatus(deviceSummary): number {
|
||||||
if(!device.smart_results[0]){
|
if(!deviceSummary.smart){
|
||||||
return 0
|
return 0
|
||||||
} else if (device.smart_results[0].smart_status == 'passed'){
|
} else if (deviceSummary.device.device_status == 0){
|
||||||
return 1
|
return 1
|
||||||
} else {
|
} 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
|
//failed, unknown/empty, passed
|
||||||
devices.sort((a: any, b: any) => {
|
deviceSummaries.sort((a: any, b: any) => {
|
||||||
|
|
||||||
let left = this.numericalStatus(a)
|
let left = this.numericalStatus(a)
|
||||||
let right = this.numericalStatus(b)
|
let right = this.numericalStatus(b)
|
||||||
@@ -27,7 +27,7 @@ export class DeviceSortPipe implements PipeTransform {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return devices;
|
return deviceSummaries;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user