From a910e9f34d4c333243b0648ee80ecea9ee0ee5c1 Mon Sep 17 00:00:00 2001 From: Felix Date: Sat, 4 Apr 2026 18:38:51 +0200 Subject: [PATCH 1/4] Provide a friendlyname via env --- .../database/scrutiny_repository_device.go | 10 ++++++++ webapp/backend/pkg/models/device.go | 1 + .../src/app/core/config/app.config.ts | 8 +++---- .../src/app/core/models/device-model.ts | 1 + .../dashboard-settings.component.html | 1 + .../src/app/shared/device-title.pipe.ts | 24 ++++++++++++------- 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/webapp/backend/pkg/database/scrutiny_repository_device.go b/webapp/backend/pkg/database/scrutiny_repository_device.go index 0279106fc..8dbfaf861 100644 --- a/webapp/backend/pkg/database/scrutiny_repository_device.go +++ b/webapp/backend/pkg/database/scrutiny_repository_device.go @@ -3,6 +3,8 @@ package database import ( "context" "fmt" + "os" + "strings" "time" "github.com/analogj/scrutiny/webapp/backend/pkg" @@ -35,6 +37,13 @@ func (sr *scrutinyRepository) GetDevices(ctx context.Context) ([]models.Device, if err := sr.gormClient.WithContext(ctx).Find(&devices).Error; err != nil { return nil, fmt.Errorf("could not get device summary from DB: %v", err) } + + for i := range devices { + var envuuid = strings.Replace(devices[i].ScrutinyUUID.String(), "-", "_", -1) + var env = "FRIENDLY_NAME_" + envuuid + devices[i].FriendlyName = os.Getenv(env) + } + return devices, nil } @@ -73,6 +82,7 @@ func (sr *scrutinyRepository) GetDeviceDetails(ctx context.Context, scrutiny_uui return models.Device{}, err } + device.FriendlyName = os.Getenv("FRIENDLY_NAME_" + device.ScrutinyUUID.String()) return device, nil } diff --git a/webapp/backend/pkg/models/device.go b/webapp/backend/pkg/models/device.go index 4028af949..cb8860666 100644 --- a/webapp/backend/pkg/models/device.go +++ b/webapp/backend/pkg/models/device.go @@ -27,6 +27,7 @@ type Device struct { DeviceUUID string `json:"device_uuid"` DeviceSerialID string `json:"device_serial_id"` DeviceLabel string `json:"device_label"` + FriendlyName string `json:"friendly_name"` Manufacturer string `json:"manufacturer"` ModelName string `json:"model_name"` diff --git a/webapp/frontend/src/app/core/config/app.config.ts b/webapp/frontend/src/app/core/config/app.config.ts index 91723869b..6fef6d2a8 100644 --- a/webapp/frontend/src/app/core/config/app.config.ts +++ b/webapp/frontend/src/app/core/config/app.config.ts @@ -4,7 +4,7 @@ import {Layout} from 'app/layout/layout.types'; export type Theme = 'light' | 'dark' | 'system'; // Device title to display on the dashboard -export type DashboardDisplay = 'name' | 'serial_id' | 'uuid' | 'label' +export type DashboardDisplay = 'name' | 'serial_id' | 'uuid' | 'label' | 'friendly_name' export type DashboardSort = 'status' | 'title' | 'age' @@ -54,7 +54,7 @@ export interface AppConfig { line_stroke?: LineStroke; // Settings from Scrutiny API - + collector?: { discard_sct_temp_history?: boolean } @@ -80,7 +80,7 @@ export const appConfig: AppConfig = { theme: 'light', layout: 'material', - dashboard_display: 'name', + dashboard_display: 'friendly_name', dashboard_sort: 'status', temperature_unit: 'celsius', @@ -88,7 +88,7 @@ export const appConfig: AppConfig = { powered_on_hours_unit: 'humanize', line_stroke: 'smooth', - + collector: { discard_sct_temp_history : false, }, diff --git a/webapp/frontend/src/app/core/models/device-model.ts b/webapp/frontend/src/app/core/models/device-model.ts index 2819a2d59..2e8e3544f 100644 --- a/webapp/frontend/src/app/core/models/device-model.ts +++ b/webapp/frontend/src/app/core/models/device-model.ts @@ -7,6 +7,7 @@ export interface DeviceModel { device_uuid?: string; device_serial_id?: string; device_label?: string; + friendly_name?: string; manufacturer: string; model_name: string; 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 c482506d8..aa5ea47fc 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 @@ -22,6 +22,7 @@

Scrutiny Settings

Serial ID UUID Label + Friendly Name diff --git a/webapp/frontend/src/app/shared/device-title.pipe.ts b/webapp/frontend/src/app/shared/device-title.pipe.ts index c37002420..f8947bcf1 100644 --- a/webapp/frontend/src/app/shared/device-title.pipe.ts +++ b/webapp/frontend/src/app/shared/device-title.pipe.ts @@ -9,14 +9,6 @@ export class DeviceTitlePipe implements PipeTransform { static deviceTitleForType(device: DeviceModel, titleType: string): string { const titleParts = [] switch(titleType){ - case 'name': - titleParts.push(`/dev/${device.device_name}`) - if (device.device_type && device.device_type !== 'scsi' && device.device_type !== 'ata'){ - titleParts.push(device.device_type) - } - titleParts.push(device.model_name) - - break; case 'serial_id': if(!device.device_serial_id) return '' titleParts.push(`/by-id/${device.device_serial_id}`) @@ -32,6 +24,22 @@ export class DeviceTitlePipe implements PipeTransform { titleParts.push(`/by-label/${device.device_label}`) } break; + case 'friendly_name': + if(device.friendly_name !== ''){ + console.log("fn") + titleParts.push(device.friendly_name) + } else { + console.log("fb") + titleParts.push(`/dev/${device.device_name}`) + } + break; + default: + titleParts.push(`/dev/${device.device_name}`) + if (device.device_type && device.device_type !== 'scsi' && device.device_type !== 'ata'){ + titleParts.push(device.device_type) + } + titleParts.push(device.model_name) + break; } return titleParts.join(' - ') } From f2a512e1174097fc1e9c484dd498e5b179174507 Mon Sep 17 00:00:00 2001 From: Felix Date: Sat, 4 Apr 2026 18:43:10 +0200 Subject: [PATCH 2/4] remove logging --- webapp/frontend/src/app/shared/device-title.pipe.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/webapp/frontend/src/app/shared/device-title.pipe.ts b/webapp/frontend/src/app/shared/device-title.pipe.ts index f8947bcf1..963e37012 100644 --- a/webapp/frontend/src/app/shared/device-title.pipe.ts +++ b/webapp/frontend/src/app/shared/device-title.pipe.ts @@ -26,10 +26,8 @@ export class DeviceTitlePipe implements PipeTransform { break; case 'friendly_name': if(device.friendly_name !== ''){ - console.log("fn") titleParts.push(device.friendly_name) } else { - console.log("fb") titleParts.push(`/dev/${device.device_name}`) } break; From 212b4e35b797220a18d0c5174e6d060d2721696d Mon Sep 17 00:00:00 2001 From: Felix Date: Sat, 4 Apr 2026 19:04:16 +0200 Subject: [PATCH 3/4] show friendlyname in details --- .../pkg/database/scrutiny_repository_device.go | 12 ++++++++---- .../src/app/modules/detail/detail.component.html | 10 ++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/webapp/backend/pkg/database/scrutiny_repository_device.go b/webapp/backend/pkg/database/scrutiny_repository_device.go index 8dbfaf861..e986b372e 100644 --- a/webapp/backend/pkg/database/scrutiny_repository_device.go +++ b/webapp/backend/pkg/database/scrutiny_repository_device.go @@ -18,6 +18,12 @@ import ( // Device //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +func (sr *scrutinyRepository) GetDeviceFriendlyName(scrutiny_uuid uuid.UUID) string { + var envuuid = strings.Replace(scrutiny_uuid.String(), "-", "_", -1) + var env = "FRIENDLY_NAME_" + envuuid + return os.Getenv(env) +} + // insert device into DB (and update specified columns if device is already registered) // update device fields that may change: (DeviceType, HostID) func (sr *scrutinyRepository) RegisterDevice(ctx context.Context, dev models.Device) error { @@ -39,9 +45,7 @@ func (sr *scrutinyRepository) GetDevices(ctx context.Context) ([]models.Device, } for i := range devices { - var envuuid = strings.Replace(devices[i].ScrutinyUUID.String(), "-", "_", -1) - var env = "FRIENDLY_NAME_" + envuuid - devices[i].FriendlyName = os.Getenv(env) + devices[i].FriendlyName = sr.GetDeviceFriendlyName(devices[i].ScrutinyUUID) } return devices, nil @@ -82,7 +86,7 @@ func (sr *scrutinyRepository) GetDeviceDetails(ctx context.Context, scrutiny_uui return models.Device{}, err } - device.FriendlyName = os.Getenv("FRIENDLY_NAME_" + device.ScrutinyUUID.String()) + device.FriendlyName = sr.GetDeviceFriendlyName(device.ScrutinyUUID) return device, nil } diff --git a/webapp/frontend/src/app/modules/detail/detail.component.html b/webapp/frontend/src/app/modules/detail/detail.component.html index 93f5719dc..dde1f325d 100644 --- a/webapp/frontend/src/app/modules/detail/detail.component.html +++ b/webapp/frontend/src/app/modules/detail/detail.component.html @@ -68,6 +68,16 @@

Drive Details - {{device | deviceTitle:config.dashboard_display}
Status
+
+
{{device?.friendly_name}}
+
Friendly Name
+
+ +
+
/dev/{{device?.device_name}}
+
Name
+
+
{{device?.host_id}}
Host ID
From 9b9d8fbc2ab6f93b26f8ba2834a61bdf707433bb Mon Sep 17 00:00:00 2001 From: Felix Date: Sat, 4 Apr 2026 19:10:18 +0200 Subject: [PATCH 4/4] add FriendlyName to Notifications --- webapp/backend/pkg/database/scrutiny_repository_device.go | 1 + webapp/backend/pkg/notify/notify.go | 8 +++++++- webapp/backend/pkg/web/handler/send_test_notification.go | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/webapp/backend/pkg/database/scrutiny_repository_device.go b/webapp/backend/pkg/database/scrutiny_repository_device.go index e986b372e..17e077d76 100644 --- a/webapp/backend/pkg/database/scrutiny_repository_device.go +++ b/webapp/backend/pkg/database/scrutiny_repository_device.go @@ -74,6 +74,7 @@ func (sr *scrutinyRepository) UpdateDeviceStatus(ctx context.Context, scrutiny_u } device.DeviceStatus = pkg.DeviceStatusSet(device.DeviceStatus, status) + device.FriendlyName = sr.GetDeviceFriendlyName(device.ScrutinyUUID) return device, sr.gormClient.Model(&device).Updates(device).Error } diff --git a/webapp/backend/pkg/notify/notify.go b/webapp/backend/pkg/notify/notify.go index e777e5eb5..3accca5a8 100644 --- a/webapp/backend/pkg/notify/notify.go +++ b/webapp/backend/pkg/notify/notify.go @@ -20,9 +20,9 @@ import ( "github.com/analogj/scrutiny/webapp/backend/pkg/models/measurements" "github.com/analogj/scrutiny/webapp/backend/pkg/thresholds" "github.com/gin-gonic/gin" + "github.com/gofrs/uuid/v5" "github.com/nicholas-fedor/shoutrrr" shoutrrrTypes "github.com/nicholas-fedor/shoutrrr/pkg/types" - "github.com/gofrs/uuid/v5" "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" ) @@ -127,6 +127,7 @@ type Payload struct { HostId string `json:"host_id,omitempty"` //host id (optional) DeviceType string `json:"device_type"` //ATA/SCSI/NVMe DeviceName string `json:"device_name"` //dev/sda + FriendlyName string `json:"friendly_name"` //dev/sda DeviceSerial string `json:"device_serial"` //WDDJ324KSO Test bool `json:"test"` // false @@ -142,6 +143,7 @@ func NewPayload(device models.Device, test bool, currentTime ...time.Time) Paylo HostId: strings.TrimSpace(device.HostId), DeviceType: device.DeviceType, DeviceName: device.DeviceName, + FriendlyName: device.FriendlyName, DeviceSerial: device.SerialNumber, Test: test, } @@ -196,6 +198,10 @@ func (p *Payload) GenerateMessage() string { messageParts = append(messageParts, fmt.Sprintf("Host Id: %s", p.HostId)) } + if len(p.FriendlyName) > 0 { + messageParts = append(messageParts, fmt.Sprintf("Name: %s", p.FriendlyName)) + } + messageParts = append(messageParts, fmt.Sprintf("Failure Type: %s", p.FailureType), fmt.Sprintf("Device Name: %s", p.DeviceName), diff --git a/webapp/backend/pkg/web/handler/send_test_notification.go b/webapp/backend/pkg/web/handler/send_test_notification.go index 4d8e56d48..94739045c 100644 --- a/webapp/backend/pkg/web/handler/send_test_notification.go +++ b/webapp/backend/pkg/web/handler/send_test_notification.go @@ -1,13 +1,14 @@ package handler import ( + "net/http" + "github.com/analogj/scrutiny/webapp/backend/pkg" "github.com/analogj/scrutiny/webapp/backend/pkg/config" "github.com/analogj/scrutiny/webapp/backend/pkg/models" "github.com/analogj/scrutiny/webapp/backend/pkg/notify" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" - "net/http" ) // Send test notification @@ -22,6 +23,7 @@ func SendTestNotification(c *gin.Context) { SerialNumber: "FAKEWDDJ324KSO", DeviceType: pkg.DeviceProtocolAta, DeviceName: "/dev/sda", + FriendlyName: "My Device", }, true, )