From bb9cb03c8a9a9972505858be42eaca58809bb4b5 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Mon, 10 Feb 2025 11:22:48 +0000 Subject: [PATCH 1/7] Fix index out of range --- internal/glance/widget-videos.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/glance/widget-videos.go b/internal/glance/widget-videos.go index c67fbbe..fdc654c 100644 --- a/internal/glance/widget-videos.go +++ b/internal/glance/widget-videos.go @@ -52,10 +52,11 @@ func (widget *videosWidget) initialize() error { // playlists are separate things rather than specifying a list of channels and some of // them awkwardly have a "playlist:" prefix if len(widget.Playlists) > 0 { + initialLen := len(widget.Channels) widget.Channels = append(widget.Channels, make([]string, len(widget.Playlists))...) for i := range widget.Playlists { - widget.Channels[len(widget.Channels)-1+i] = "playlist:" + widget.Playlists[i] + widget.Channels[initialLen+i] = "playlist:" + widget.Playlists[i] } } From b301953249a268e4cb3e1b61192e2f2523985fd1 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Mon, 10 Feb 2025 20:38:50 +0000 Subject: [PATCH 2/7] Update docs --- docs/configuration.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 0cee1ec..79f9d88 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -97,9 +97,9 @@ Including config files from within your main config file is supported. This is d ```yaml pages: - !include home.yml - !include videos.yml - !include homelab.yml + !include: home.yml + !include: videos.yml + !include: homelab.yml ``` The file you are including should not have any additional indentation, its values should be at the top level and the appropriate amount of indentation will be added automatically depending on where the file is included. Example: @@ -112,14 +112,14 @@ pages: columns: - size: full widgets: - !include rss.yml + !include: rss.yml - name: News columns: - size: full widgets: - type: group widgets: - !include rss.yml + !include: rss.yml - type: reddit subreddit: news ``` From 232cab01f81802717439f54fba17b4342625ab9a Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Mon, 10 Feb 2025 23:15:12 +0000 Subject: [PATCH 3/7] Fix typo --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 79f9d88..74d10c2 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1672,7 +1672,7 @@ For services with multiple containers you can specify a `glance.id` on the "main
```yaml -servies: +services: immich-server: image: ghcr.io/immich-app/immich-server labels: From 3043a0bd155c4d12653acec70b4925d08a876f28 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Sat, 15 Feb 2025 13:46:58 +0000 Subject: [PATCH 4/7] Rework getting host info (#340) --- pkg/sysinfo/sysinfo.go | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/pkg/sysinfo/sysinfo.go b/pkg/sysinfo/sysinfo.go index f4adef8..3fd22ff 100644 --- a/pkg/sysinfo/sysinfo.go +++ b/pkg/sysinfo/sysinfo.go @@ -3,6 +3,7 @@ package sysinfo import ( "fmt" "math" + "os" "runtime" "sort" "strconv" @@ -85,12 +86,39 @@ type MointpointRequest struct { // Currently caches hostname indefinitely which isn't ideal // Potential issue with caching boot time as it may not initially get reported correctly: // https://github.com/shirou/gopsutil/issues/842#issuecomment-1908972344 -var cachedHostInfo = struct { +type cacheableHostInfo struct { available bool hostname string platform string bootTime timestampJSON -}{} +} + +var cachedHostInfo cacheableHostInfo + +func getHostInfo() (cacheableHostInfo, error) { + var err error + info := cacheableHostInfo{} + + info.hostname, err = os.Hostname() + if err != nil { + return info, err + } + + info.platform, _, _, err = host.PlatformInformation() + if err != nil { + return info, err + } + + bootTime, err := host.BootTime() + if err != nil { + return info, err + } + + info.bootTime = timestampJSON{time.Unix(int64(bootTime), 0)} + info.available = true + + return info, nil +} func Collect(req *SystemInfoRequest) (*SystemInfo, []error) { if req == nil { @@ -117,13 +145,9 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) { if cachedHostInfo.available { applyCachedHostInfo() } else { - hostInfo, err := host.Info() + hostInfo, err := getHostInfo() if err == nil { - cachedHostInfo.available = true - cachedHostInfo.bootTime = timestampJSON{time.Unix(int64(hostInfo.BootTime), 0)} - cachedHostInfo.hostname = hostInfo.Hostname - cachedHostInfo.platform = hostInfo.Platform - + cachedHostInfo = hostInfo applyCachedHostInfo() } else { addErr(fmt.Errorf("getting host info: %v", err)) From e01af4adec3d6aa2e2e7fbbc79c8af8e36833f37 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Sat, 15 Feb 2025 13:53:13 +0000 Subject: [PATCH 5/7] Delay changing popover display Previously would make the popover visible and then reposition it on the next frame in order to avoid getting called recursively due to the observer, however this causes the scrollbar to appear if it wasn't already visible for a single frame which is janky. This change fixes that. --- internal/glance/static/js/popover.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/glance/static/js/popover.js b/internal/glance/static/js/popover.js index 91c69e3..331ee26 100644 --- a/internal/glance/static/js/popover.js +++ b/internal/glance/static/js/popover.js @@ -98,7 +98,6 @@ function showPopover() { } contentElement.style.maxWidth = contentMaxWidth; - containerElement.style.display = "block"; activeTarget.classList.add("popover-active"); document.addEventListener("keydown", handleHidePopoverOnEscape); window.addEventListener("resize", queueRepositionContainer); @@ -106,6 +105,8 @@ function showPopover() { } function repositionContainer() { + containerElement.style.display = "block"; + const targetBounds = activeTarget.dataset.popoverAnchor !== undefined ? activeTarget.querySelector(activeTarget.dataset.popoverAnchor).getBoundingClientRect() : activeTarget.getBoundingClientRect(); From abeb11c8a6f9549a519e262bee440071d4fd02c4 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Sat, 15 Feb 2025 14:43:25 +0000 Subject: [PATCH 6/7] Add hide-mountpoints-by-default prop for server-stats --- docs/configuration.md | 18 ++++++++++++++++++ pkg/sysinfo/sysinfo.go | 13 +++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 74d10c2..01afc8e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1852,11 +1852,29 @@ Whether to hide the swap usage. | Name | Type | Required | Default | | ---- | ---- | -------- | ------- | | cpu-temp-sensor | string | no | | +| hide-mointpoints-by-default | boolean | no | false | | mountpoints | map\[string\]object | no | | ###### `cpu-temp-sensor` The name of the sensor to use for the CPU temperature. When not provided the widget will attempt to find the correct one, if it fails to do so the temperature will not be displayed. To view the available sensors you can use `sensors` command. +###### `hide-mountpoints-by-default` +If set to `true` you'll have to manually make each mountpoint visible by adding a `hide: false` property to it like so: + +```yaml +- type: server-stats + servers: + - type: local + hide-mountpoints-by-default: true + mountpoints: + "/": + hide: false + "/mnt/data": + hide: false +``` + +This is useful if you're running Glance inside of a container which usually mounts a lot of irrelevant filesystems. + ###### `mountpoints` A map of mountpoints to display disk usage for. The key is the path to the mountpoint and the value is an object with optional properties. Example: diff --git a/pkg/sysinfo/sysinfo.go b/pkg/sysinfo/sysinfo.go index 3fd22ff..09df02f 100644 --- a/pkg/sysinfo/sysinfo.go +++ b/pkg/sysinfo/sysinfo.go @@ -74,13 +74,14 @@ type MountpointInfo struct { } type SystemInfoRequest struct { - CPUTempSensor string `yaml:"cpu-temp-sensor"` - Mountpoints map[string]MointpointRequest `yaml:"mountpoints"` + CPUTempSensor string `yaml:"cpu-temp-sensor"` + HideMountpointsByDefault bool `yaml:"hide-mountpoints-by-default"` + Mountpoints map[string]MointpointRequest `yaml:"mountpoints"` } type MointpointRequest struct { Name string `yaml:"name"` - Hide bool `yaml:"hide"` + Hide *bool `yaml:"hide"` } // Currently caches hostname indefinitely which isn't ideal @@ -229,7 +230,11 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) { if err == nil { for _, fs := range filesystems { mpReq, ok := req.Mountpoints[fs.Mountpoint] - if ok && mpReq.Hide { + isHidden := req.HideMountpointsByDefault + if ok && mpReq.Hide != nil { + isHidden = *mpReq.Hide + } + if isHidden { continue } From 0ce45e32aa48f4d277bd7c00af56f5324c7377f2 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Sat, 15 Feb 2025 14:59:20 +0000 Subject: [PATCH 7/7] Update dashboard icons repo --- internal/glance/config-fields.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/glance/config-fields.go b/internal/glance/config-fields.go index 8aaac85..f3c836e 100644 --- a/internal/glance/config-fields.go +++ b/internal/glance/config-fields.go @@ -152,9 +152,9 @@ func newCustomIconField(value string) customIconField { } if prefix == "di" { - field.URL = "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/" + ext + "/" + basename + "." + ext + field.URL = "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/" + ext + "/" + basename + "." + ext } else { - field.URL = "https://cdn.jsdelivr.net/gh/selfhst/icons@main/" + ext + "/" + basename + "." + ext + field.URL = "https://cdn.jsdelivr.net/gh/selfhst/icons/" + ext + "/" + basename + "." + ext } default: field.URL = value