Skip to content

A self-hosted dashboard that puts all your feeds in one place

Fixed text truncate, req params and css

ThiemeH7a1fd8acf97a
diff --git a/internal/glance/static/css/widgets.css b/internal/glance/static/css/widgets.css
index 9c9e8ee..ac63040 100644
--- a/internal/glance/static/css/widgets.css
+++ b/internal/glance/static/css/widgets.css
@@ -6,6 +6,7 @@
@import "widget-group.css";
@import "widget-markets.css";
@import "widget-monitor.css";
+@import "widget-qbittorrent.css";
@import "widget-reddit.css";
@import "widget-releases.css";
@import "widget-rss.css";
diff --git a/internal/glance/templates/qbittorrent.html b/internal/glance/templates/qbittorrent.html
index 9ac6d71..ce969e2 100644
--- a/internal/glance/templates/qbittorrent.html
+++ b/internal/glance/templates/qbittorrent.html
@@ -5,8 +5,8 @@
{{- if .Torrents }}
{{- range .Torrents }}
<div class="qbittorrent-torrent">
- <div class="qbittorrent-torrent-header">
- <span class="qbittorrent-torrent-name text-truncate">{{ .Name }}</span>
+ <div class="qbittorrent-torrent-header text-truncate">
+ <span class="qbittorrent-torrent-name">{{ .Name }}</span>
</div>
<div class="qbittorrent-torrent-progress flex items-center gap-10">
<div class="progress-bar flex-1">
diff --git a/internal/glance/widget-qbittorrent.go b/internal/glance/widget-qbittorrent.go
index 99f490d..03d772c 100644
--- a/internal/glance/widget-qbittorrent.go
+++ b/internal/glance/widget-qbittorrent.go
@@ -10,7 +10,7 @@ import (
"net/http"
"net/http/cookiejar"
"net/url"
- "sort"
+ "strconv"
"strings"
"time"
)
@@ -104,7 +104,13 @@ func (widget *qbittorrentWidget) login() error {
}
func (widget *qbittorrentWidget) update(ctx context.Context) {
- req, err := http.NewRequestWithContext(ctx, "GET", widget.URL+qBittorrentTorrentsPath, nil)
+ params := url.Values{}
+ params.Set("limit", strconv.Itoa(widget.Limit))
+ params.Set("sort", "dlspeed")
+ params.Set("reverse", "true")
+
+ requestURL := widget.URL + qBittorrentTorrentsPath + "?" + params.Encode()
+ req, err := http.NewRequestWithContext(ctx, "GET", requestURL, nil)
if err != nil {
widget.withError(fmt.Errorf("creating torrents request: %w", err))
return
@@ -133,14 +139,6 @@ func (widget *qbittorrentWidget) update(ctx context.Context) {
return
}
- sort.Slice(torrents, func(i, j int) bool {
- return torrents[i].Progress > torrents[j].Progress
- })
-
- if len(torrents) > widget.Limit {
- torrents = torrents[:widget.Limit]
- }
-
widget.Torrents = torrents
widget.withError(nil)
}