ui: truncate full path of host if using unix socket

This commit is contained in:
henrygd
2025-02-22 17:58:30 -05:00
parent 6404895a47
commit 1d13ecd8ec
3 changed files with 20 additions and 4 deletions

View File

@@ -336,3 +336,11 @@ export const alertInfo: Record<string, AlertInfo> = {
desc: () => t`Triggers when any sensor exceeds a threshold`,
},
}
/**
* Retuns value of system host, truncating full path if socket.
* @example
* // Assuming system.host is "/var/run/beszel.sock"
* const hostname = getHostDisplayValue(system) // hostname will be "beszel.sock"
*/
export const getHostDisplayValue = (system: SystemRecord): string => system.host.slice(system.host.lastIndexOf("/") + 1)