Реализация, фаза 1: добавление данных в qbittorrent

This commit is contained in:
2026-06-14 12:10:48 +03:00
parent b1a4a846d6
commit 883148787a
22 changed files with 2352 additions and 86 deletions
+68
View File
@@ -0,0 +1,68 @@
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="refresh" content="5">
<title>jellybit</title>
<style>
:root { color-scheme: light dark; }
body { font-family: system-ui, sans-serif; max-width: 60rem; margin: 2rem auto; padding: 0 1rem; }
h1 { margin-bottom: .25rem; }
form.add { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
form.add input[name=source] { flex: 1 1 24rem; }
input, button { padding: .4rem .6rem; font-size: 1rem; }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid #8884; vertical-align: top; }
td.src { font-family: monospace; font-size: .85rem; word-break: break-all; }
.err { color: #c0392b; }
.state { font-size: .8rem; padding: .1rem .5rem; border-radius: 1rem; background: #8883; white-space: nowrap; }
.state-completed { background: #2ecc7155; }
.state-downloading { background: #3498db55; }
.state-stuck { background: #f39c1255; }
.state-failed { background: #e74c3c55; }
.state-cancelled { background: #95a5a655; }
small { color: #8888; }
</style>
</head>
<body>
<h1>jellybit</h1>
<p><small>обновляется каждые 5 с</small></p>
<form class="add" method="post" action="/ui/downloads">
<input type="text" name="source" placeholder="magnet:?xt=urn:btih:…" required>
<input type="text" name="context" placeholder="контекст (опц.)">
<button type="submit">Добавить</button>
</form>
{{if .Error}}<p class="err">{{.Error}}</p>{{end}}
<table>
<thead>
<tr><th>#</th><th>Источник</th><th>Контекст</th><th>Состояние</th><th></th></tr>
</thead>
<tbody>
{{range .Downloads}}
<tr>
<td>{{.ID}}</td>
<td class="src" title="{{.Infohash}}">{{.Source}}</td>
<td>{{.Context}}</td>
<td>
<span class="state state-{{.State}}">{{.State}}</span>
{{if .Error}}<br><small>{{.Error}}</small>{{end}}
</td>
<td>
{{if not .Terminal}}
<form method="post" action="/ui/downloads/{{.ID}}/cancel">
<button type="submit">Отклонить</button>
</form>
{{end}}
</td>
</tr>
{{else}}
<tr><td colspan="5"><small>пока пусто</small></td></tr>
{{end}}
</tbody>
</table>
</body>
</html>
+9
View File
@@ -0,0 +1,9 @@
// Package web несёт встроенные (embed) ресурсы веб-UI: HTML-шаблоны.
package web
import "embed"
// FS — встроенные шаблоны (templates/*.html).
//
//go:embed templates/*.html
var FS embed.FS