Rewrites the web app's comments to rule 32. Task, milestone, rule and spec ids are gone; regression stories are restated as the trap they guard (public auth routes, the menu's stopPropagation, universal loads under adapter-static, metric deltas with their margin). Flutter and Tauri mentions now name the Android app or a native shell, operator quotes and dates are dropped, and one library's counts no longer appear outside test fixtures. Verified with a TypeScript-scanner token comparison (template literals and regex literals re-scanned): only comment text changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
167 lines
5.9 KiB
Svelte
167 lines
5.9 KiB
Svelte
<script lang="ts">
|
|
import { onMount } from 'svelte';
|
|
import {
|
|
addAcquisitionService,
|
|
listAcquisitionServices,
|
|
type AcquisitionProtocol,
|
|
type AcquisitionService
|
|
} from '#lib/api/admin.js';
|
|
import { errMessage } from '#lib/api/errors.js';
|
|
import { pushToast } from '#lib/stores/toast.svelte.js';
|
|
import AcquisitionServiceRow from './AcquisitionServiceRow.svelte';
|
|
import SettingsGroup from '#lib/components/settings/SettingsGroup.svelte';
|
|
|
|
// Where Minstrel looks for music and what downloads it: two lists of
|
|
// connections an admin adds and configures. Nothing is seeded or copied. A
|
|
// FabledExchange is one entry under download clients, with a switch for each
|
|
// of its jobs.
|
|
|
|
let services = $state<AcquisitionService[] | null>(null);
|
|
let loadError = $state(false);
|
|
let adding = $state<'search' | 'download' | null>(null);
|
|
|
|
const indexers = $derived((services ?? []).filter((s) => s.kind === 'search'));
|
|
const clients = $derived((services ?? []).filter((s) => s.kind === 'download'));
|
|
const searchingExchanges = $derived(
|
|
clients.filter((s) => s.protocol === 'exchange' && s.serves_search)
|
|
);
|
|
const canSearch = $derived(
|
|
(services ?? []).some(
|
|
(s) => s.usable && (s.protocol === 'exchange' ? s.serves_search : s.kind === 'search')
|
|
)
|
|
);
|
|
const canFetch = $derived(
|
|
(services ?? []).some(
|
|
(s) => s.usable && (s.protocol === 'exchange' ? s.serves_downloads : s.kind === 'download')
|
|
)
|
|
);
|
|
|
|
const choices: Record<
|
|
'search' | 'download',
|
|
{ protocol: AcquisitionProtocol; name: string; note: string }[]
|
|
> = {
|
|
search: [
|
|
{
|
|
protocol: 'prowlarr',
|
|
name: 'Prowlarr',
|
|
note: 'Suggested. Every indexer you have set up in Prowlarr, asked in one search.'
|
|
},
|
|
{
|
|
protocol: 'torznab',
|
|
name: 'Torznab feed',
|
|
note: 'Jackett, or a single indexer you point at directly.'
|
|
}
|
|
],
|
|
download: [
|
|
{
|
|
protocol: 'qbittorrent',
|
|
name: 'qBittorrent',
|
|
note: 'Or anything else that speaks its WebUI.'
|
|
},
|
|
{
|
|
protocol: 'exchange',
|
|
name: 'FabledExchange',
|
|
note: 'If you run it: one entry that downloads, searches its DHT index and checks releases. Each job can be switched off.'
|
|
}
|
|
]
|
|
};
|
|
|
|
async function load() {
|
|
try {
|
|
services = await listAcquisitionServices();
|
|
loadError = false;
|
|
} catch {
|
|
loadError = true;
|
|
}
|
|
}
|
|
|
|
onMount(load);
|
|
|
|
async function add(protocol: AcquisitionProtocol) {
|
|
try {
|
|
const created = await addAcquisitionService(protocol);
|
|
adding = null;
|
|
pushToast(`${created.label} added. Give it an address, test it, then switch it on.`);
|
|
await load();
|
|
} catch (e) {
|
|
pushToast(errMessage(e), 'error');
|
|
}
|
|
}
|
|
|
|
const addButtonClass =
|
|
'rounded-md border border-border px-3 py-1.5 text-sm text-text-secondary hover:bg-surface-hover hover:text-text-primary';
|
|
</script>
|
|
|
|
{#snippet addMenu(kind: 'search' | 'download', label: string)}
|
|
<div class="px-4 py-3">
|
|
{#if adding === kind}
|
|
<div class="space-y-2" data-testid="add-{kind}">
|
|
{#each choices[kind] as choice (choice.protocol)}
|
|
<button
|
|
type="button"
|
|
class="block w-full rounded-md border border-border px-4 py-2 text-left hover:bg-surface-hover"
|
|
onclick={() => add(choice.protocol)}
|
|
>
|
|
<span class="block text-sm text-text-primary">{choice.name}</span>
|
|
<span class="block text-xs text-text-secondary">{choice.note}</span>
|
|
</button>
|
|
{/each}
|
|
<button type="button" class="text-sm text-text-secondary underline hover:no-underline" onclick={() => (adding = null)}
|
|
>Cancel</button
|
|
>
|
|
</div>
|
|
{:else}
|
|
<button type="button" class={addButtonClass} onclick={() => (adding = kind)}>{label}</button>
|
|
{/if}
|
|
</div>
|
|
{/snippet}
|
|
|
|
<div class="space-y-6" data-testid="acquisition-card">
|
|
{#if loadError}
|
|
<p class="text-sm text-error-fg">
|
|
Couldn't load indexers and download clients.
|
|
<button type="button" class="underline hover:no-underline" onclick={load}>Try again</button>
|
|
</p>
|
|
{:else if services === null}
|
|
<p class="text-sm text-text-secondary">Loading indexers and download clients…</p>
|
|
{:else}
|
|
<!-- The verdict first: can music be found and downloaded at all. -->
|
|
<p class="text-sm" data-testid="acquisition-health">
|
|
{#if !canFetch}
|
|
<span class="text-error-fg">No download client is switched on, so nothing can be downloaded.</span>
|
|
{:else if !canSearch}
|
|
<span class="text-error-fg">No indexer is switched on, so nothing new can be found.</span>
|
|
{:else}
|
|
<span class="text-text-secondary">Music can be searched for and downloaded.</span>
|
|
{/if}
|
|
</p>
|
|
|
|
<div data-testid="indexers">
|
|
<SettingsGroup title="Indexers" id="indexers" hint="Where music is looked for. Every one switched on is searched.">
|
|
{#each indexers as service (service.code)}
|
|
<AcquisitionServiceRow {service} onChanged={load} />
|
|
{:else}
|
|
<p class="px-4 py-3 text-sm text-text-secondary">No indexer yet. Prowlarr is the usual choice.</p>
|
|
{/each}
|
|
{#if searchingExchanges.length > 0}
|
|
<p class="px-4 py-3 text-xs text-text-secondary">
|
|
Also searched: {searchingExchanges.map((s) => s.label).join(', ')}, under download clients.
|
|
</p>
|
|
{/if}
|
|
{@render addMenu('search', 'Add indexer')}
|
|
</SettingsGroup>
|
|
</div>
|
|
|
|
<div data-testid="download-clients">
|
|
<SettingsGroup title="Download clients" id="download-clients" hint="What a grab is handed to.">
|
|
{#each clients as service (service.code)}
|
|
<AcquisitionServiceRow {service} onChanged={load} />
|
|
{:else}
|
|
<p class="px-4 py-3 text-sm text-text-secondary">No download client yet.</p>
|
|
{/each}
|
|
{@render addMenu('download', 'Add download client')}
|
|
</SettingsGroup>
|
|
</div>
|
|
{/if}
|
|
</div>
|