added debug logging message for detected devices.

adding a mocked class for Config.
Adding device type to Device struct. Will eventually be needed for raid drives.
adding End-to-end testing capabilties.
Added testdata json files for webserver requests.
Seperated Start code and Setup code in webapp so we can test.
renamed "smart_attributes" to "ata_attributes" - Backwards incomatible change.
Added front end device sorting (red, yellow, green)
show unknown icon/status if drive has no smart data yet.
Moved all attribute "getters" into the controller.
created a device-sort pipe.
This commit is contained in:
Jason Kulatunga
2020-08-26 21:35:13 -07:00
parent 5a80ae3e74
commit 2ad120c87b
20 changed files with 1583 additions and 201 deletions
@@ -0,0 +1,8 @@
import { DeviceSortPipe } from './device-sort.pipe';
describe('DeviceSortPipe', () => {
it('create an instance', () => {
const pipe = new DeviceSortPipe();
expect(pipe).toBeTruthy();
});
});
@@ -0,0 +1,33 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'deviceSort'
})
export class DeviceSortPipe implements PipeTransform {
numericalStatus(device): number {
if(!device.smart_results[0]){
return 0
} else if (device.smart_results[0].smart_status == 'passed'){
return 1
} else {
return -1
}
}
transform(devices: Array<unknown>, ...args: unknown[]): Array<unknown> {
//failed, unknown/empty, passed
devices.sort((a: any, b: any) => {
let left = this.numericalStatus(a)
let right = this.numericalStatus(b)
return left - right;
});
return devices;
}
}
@@ -2,10 +2,12 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import {FileSizePipe} from "./file-size.pipe";
import { DeviceSortPipe } from './device-sort.pipe';
@NgModule({
declarations: [
FileSizePipe
FileSizePipe,
DeviceSortPipe
],
imports: [
CommonModule,
@@ -16,7 +18,8 @@ import {FileSizePipe} from "./file-size.pipe";
CommonModule,
FormsModule,
ReactiveFormsModule,
FileSizePipe
FileSizePipe,
DeviceSortPipe
]
})
export class SharedModule