diff --git a/webapp/frontend/src/app/layout/common/dashboard-device/dashboard-device.component.html b/webapp/frontend/src/app/layout/common/dashboard-device/dashboard-device.component.html
index 43e8964..43f4e0b 100644
--- a/webapp/frontend/src/app/layout/common/dashboard-device/dashboard-device.component.html
+++ b/webapp/frontend/src/app/layout/common/dashboard-device/dashboard-device.component.html
@@ -63,7 +63,7 @@
Powered On
-
{{ humanizeDuration(deviceSummary.smart?.power_on_hours * 60 * 60 * 1000, { round: true, largest: 1, units: ['y', 'd', 'h'] }) }}
+
{{ deviceSummary.smart?.power_on_hours | deviceHours:config.powered_on_hours_unit:{ round: true, largest: 1, units: ['y', 'd', 'h'] } }}
--
diff --git a/webapp/frontend/src/app/layout/common/dashboard-device/dashboard-device.component.ts b/webapp/frontend/src/app/layout/common/dashboard-device/dashboard-device.component.ts
index 57da104..c54bbc7 100644
--- a/webapp/frontend/src/app/layout/common/dashboard-device/dashboard-device.component.ts
+++ b/webapp/frontend/src/app/layout/common/dashboard-device/dashboard-device.component.ts
@@ -4,7 +4,6 @@ import {takeUntil} from 'rxjs/operators';
import {AppConfig} from 'app/core/config/app.config';
import {ScrutinyConfigService} from 'app/core/config/scrutiny-config.service';
import {Subject} from 'rxjs';
-import humanizeDuration from 'humanize-duration'
import {MatDialog} from '@angular/material/dialog';
import {DashboardDeviceDeleteDialogComponent} from 'app/layout/common/dashboard-device-delete-dialog/dashboard-device-delete-dialog.component';
import {DeviceTitlePipe} from 'app/shared/device-title.pipe';
@@ -34,8 +33,6 @@ export class DashboardDeviceComponent implements OnInit {
private _unsubscribeAll: Subject;
- readonly humanizeDuration = humanizeDuration;
-
deviceStatusForModelWithThreshold = DeviceStatusPipe.deviceStatusForModelWithThreshold
ngOnInit(): void {
diff --git a/webapp/frontend/src/app/modules/detail/detail.component.html b/webapp/frontend/src/app/modules/detail/detail.component.html
index 0f37778..13b19c2 100644
--- a/webapp/frontend/src/app/modules/detail/detail.component.html
+++ b/webapp/frontend/src/app/modules/detail/detail.component.html
@@ -123,7 +123,7 @@
Power Cycle Count
-
{{humanizeDuration(smart_results[0]?.power_on_hours *60 * 60 * 1000, { round: true, largest: 1, units: ['y', 'd', 'h'] })}}
+
{{ smart_results[0]?.power_on_hours | deviceHours:config.powered_on_hours_unit:{ round: true, largest: 1, units: ['y', 'd', 'h'] } }}
Powered On
diff --git a/webapp/frontend/src/app/shared/device-hours.pipe.spec.ts b/webapp/frontend/src/app/shared/device-hours.pipe.spec.ts
new file mode 100644
index 0000000..cd9f1bc
--- /dev/null
+++ b/webapp/frontend/src/app/shared/device-hours.pipe.spec.ts
@@ -0,0 +1,9 @@
+import { DeviceHoursPipe } from './device-hours.pipe';
+
+
+describe('DeviceHoursPipe', () => {
+ it('create an instance', () => {
+ const pipe = new DeviceHoursPipe();
+ expect(pipe).toBeTruthy();
+ });
+});
diff --git a/webapp/frontend/src/app/shared/device-hours.pipe.ts b/webapp/frontend/src/app/shared/device-hours.pipe.ts
new file mode 100644
index 0000000..f6b5e1f
--- /dev/null
+++ b/webapp/frontend/src/app/shared/device-hours.pipe.ts
@@ -0,0 +1,16 @@
+import { Pipe, PipeTransform } from '@angular/core';
+import humanizeDuration from 'humanize-duration';
+
+@Pipe({ name: 'deviceHours' })
+export class DeviceHoursPipe implements PipeTransform {
+ static format(hoursOfRunTime: number, unit: string, humanizeConfig: object): string {
+ if (unit === 'device_hours') {
+ return `${hoursOfRunTime} hours`;
+ }
+ return humanizeDuration(hoursOfRunTime * 60 * 60 * 1000, humanizeConfig);
+ }
+
+ transform(hoursOfRunTime: number, unit = 'humanize', humanizeConfig: any = {}): string {
+ return DeviceHoursPipe.format(hoursOfRunTime, unit, humanizeConfig)
+ }
+}
diff --git a/webapp/frontend/src/app/shared/shared.module.ts b/webapp/frontend/src/app/shared/shared.module.ts
index c22fdb2..1f9779b 100644
--- a/webapp/frontend/src/app/shared/shared.module.ts
+++ b/webapp/frontend/src/app/shared/shared.module.ts
@@ -6,6 +6,7 @@ import { DeviceSortPipe } from './device-sort.pipe';
import { TemperaturePipe } from './temperature.pipe';
import { DeviceTitlePipe } from './device-title.pipe';
import { DeviceStatusPipe } from './device-status.pipe';
+import { DeviceHoursPipe } from './device-hours.pipe';
@NgModule({
declarations: [
@@ -13,7 +14,8 @@ import { DeviceStatusPipe } from './device-status.pipe';
DeviceSortPipe,
TemperaturePipe,
DeviceTitlePipe,
- DeviceStatusPipe
+ DeviceStatusPipe,
+ DeviceHoursPipe
],
imports: [
CommonModule,
@@ -28,7 +30,8 @@ import { DeviceStatusPipe } from './device-status.pipe';
DeviceSortPipe,
DeviceTitlePipe,
DeviceStatusPipe,
- TemperaturePipe
+ TemperaturePipe,
+ DeviceHoursPipe
]
})
export class SharedModule