Add the Config view: edit and save the settings, applied without a restart

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 23:31:13 +02:00
co-authored by Claude Sonnet 5.5
parent 0ccd02b3c5
commit a4ec9ad71e
25 changed files with 1168 additions and 54 deletions
+15 -2
View File
@@ -11,16 +11,26 @@ import (
"net/url"
"strconv"
"strings"
"sync"
"time"
)
// Client talks to a SABnzbd instance.
type Client struct {
mu sync.RWMutex // guards baseURL and apiKey, which Reconfigure can change
baseURL string
apiKey string
http *http.Client
}
// Reconfigure points the client at another instance or key.
func (c *Client) Reconfigure(baseURL, apiKey string) {
c.mu.Lock()
defer c.mu.Unlock()
c.baseURL = strings.TrimRight(baseURL, "/")
c.apiKey = apiKey
}
// NewClient returns a client for the instance at baseURL.
func NewClient(baseURL, apiKey string) *Client {
return &Client{
@@ -159,9 +169,12 @@ func boolParam(b bool) string {
// {"status": false, "error": "..."}, which is turned into an error here.
func (c *Client) call(ctx context.Context, params url.Values, out any) error {
params.Set("output", "json")
params.Set("apikey", c.apiKey)
c.mu.RLock()
baseURL, apiKey := c.baseURL, c.apiKey
c.mu.RUnlock()
params.Set("apikey", apiKey)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL+"/api?"+params.Encode(), nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, baseURL+"/api?"+params.Encode(), nil)
if err != nil {
return stripURL(err)
}