Fixed text truncate, req params and css

pull/543/head
ThiemeH 2025-03-31 21:46:19 +07:00
parent 38bdc69e67
commit 7a1fd8acf9
3 changed files with 11 additions and 12 deletions

@ -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";

@ -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">

@ -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)
}