diff --git a/webapp/backend/pkg/database/scrutiny_repository_migrations.go b/webapp/backend/pkg/database/scrutiny_repository_migrations.go index e1b948b..829c833 100644 --- a/webapp/backend/pkg/database/scrutiny_repository_migrations.go +++ b/webapp/backend/pkg/database/scrutiny_repository_migrations.go @@ -332,6 +332,12 @@ func (sr *scrutinyRepository) Migrate(ctx context.Context) error { SettingDataType: "string", SettingValueString: "smooth", }, + { + SettingKeyName: "powered_on_hours_unit", + SettingKeyDescription: "Presentation format for device powered on time ('humanize' | 'device-hours')", + SettingDataType: "string", + SettingValueString: "humanize", + }, { SettingKeyName: "metrics.notify_level", diff --git a/webapp/backend/pkg/models/settings.go b/webapp/backend/pkg/models/settings.go index e564301..d40e3e9 100644 --- a/webapp/backend/pkg/models/settings.go +++ b/webapp/backend/pkg/models/settings.go @@ -8,13 +8,14 @@ package models //} type Settings struct { - Theme string `json:"theme" mapstructure:"theme"` - Layout string `json:"layout" mapstructure:"layout"` - DashboardDisplay string `json:"dashboard_display" mapstructure:"dashboard_display"` - DashboardSort string `json:"dashboard_sort" mapstructure:"dashboard_sort"` - TemperatureUnit string `json:"temperature_unit" mapstructure:"temperature_unit"` - FileSizeSIUnits bool `json:"file_size_si_units" mapstructure:"file_size_si_units"` - LineStroke string `json:"line_stroke" mapstructure:"line_stroke"` + Theme string `json:"theme" mapstructure:"theme"` + Layout string `json:"layout" mapstructure:"layout"` + DashboardDisplay string `json:"dashboard_display" mapstructure:"dashboard_display"` + DashboardSort string `json:"dashboard_sort" mapstructure:"dashboard_sort"` + TemperatureUnit string `json:"temperature_unit" mapstructure:"temperature_unit"` + FileSizeSIUnits bool `json:"file_size_si_units" mapstructure:"file_size_si_units"` + LineStroke string `json:"line_stroke" mapstructure:"line_stroke"` + PoweredOnHoursUnit string `json:"powered_on_hours_unit" mapstructure:"powered_on_hours_unit"` Metrics struct { NotifyLevel int `json:"notify_level" mapstructure:"notify_level"` diff --git a/webapp/frontend/src/app/core/config/app.config.ts b/webapp/frontend/src/app/core/config/app.config.ts index 1b6dfe3..c5a1f6f 100644 --- a/webapp/frontend/src/app/core/config/app.config.ts +++ b/webapp/frontend/src/app/core/config/app.config.ts @@ -12,6 +12,8 @@ export type TemperatureUnit = 'celsius' | 'fahrenheit' export type LineStroke = 'smooth' | 'straight' | 'stepline' +export type DevicePoweredOnUnit = 'humanize' | 'device_hours' + export enum MetricsNotifyLevel { Warn = 1, @@ -47,6 +49,8 @@ export interface AppConfig { file_size_si_units?: boolean; + powered_on_hours_unit?: DevicePoweredOnUnit; + line_stroke?: LineStroke; // Settings from Scrutiny API @@ -77,6 +81,7 @@ export const appConfig: AppConfig = { temperature_unit: 'celsius', file_size_si_units: false, + powered_on_hours_unit: 'humanize', line_stroke: 'smooth', diff --git a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html index 0eb9a03..970044c 100644 --- a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html +++ b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.html @@ -54,6 +54,14 @@
+ + Powered On Format + + Humanize + Device Hours + + + Line stroke diff --git a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.ts b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.ts index 94f262f..ec65157 100644 --- a/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.ts +++ b/webapp/frontend/src/app/layout/common/dashboard-settings/dashboard-settings.component.ts @@ -7,7 +7,8 @@ import { MetricsStatusThreshold, TemperatureUnit, LineStroke, - Theme + Theme, + DevicePoweredOnUnit } from 'app/core/config/app.config'; import {ScrutinyConfigService} from 'app/core/config/scrutiny-config.service'; import {Subject} from 'rxjs'; @@ -24,6 +25,7 @@ export class DashboardSettingsComponent implements OnInit { dashboardSort: string; temperatureUnit: string; fileSizeSIUnits: boolean; + poweredOnHoursUnit: string; lineStroke: string; theme: string; statusThreshold: number; @@ -51,6 +53,7 @@ export class DashboardSettingsComponent implements OnInit { this.dashboardSort = config.dashboard_sort; this.temperatureUnit = config.temperature_unit; this.fileSizeSIUnits = config.file_size_si_units; + this.poweredOnHoursUnit = config.powered_on_hours_unit; this.lineStroke = config.line_stroke; this.theme = config.theme; @@ -68,6 +71,7 @@ export class DashboardSettingsComponent implements OnInit { dashboard_sort: this.dashboardSort as DashboardSort, temperature_unit: this.temperatureUnit as TemperatureUnit, file_size_si_units: this.fileSizeSIUnits, + powered_on_hours_unit: this.poweredOnHoursUnit as DevicePoweredOnUnit, line_stroke: this.lineStroke as LineStroke, theme: this.theme as Theme, metrics: {