Add categories list from settings in add-new-torrent

(cherry picked from commit 20b08c52a73f1f2725d96a520c7cdd511906b8ef)
This commit is contained in:
Sylvain DUARTE 2026-03-14 11:46:00 +01:00
parent b7090eeb3a
commit e2195944e4
No known key found for this signature in database
2 changed files with 37 additions and 3 deletions

View file

@ -220,9 +220,26 @@
<div class="field">
<label class="label">Category</label>
<div class="control">
<input class="input" type="text" [(ngModel)]="category" />
</div>
@if (categories.length > 0) {
<div class="control select is-fullwidth">
<select [(ngModel)]="categorySelect" (ngModelChange)="onCategorySelectChange($event)">
<option value="">— None —</option>
@for (cat of categories; track cat) {
<option [value]="cat">{{ cat }}</option>
}
<option value="__custom__">Custom…</option>
</select>
</div>
@if (categorySelect === '__custom__') {
<div class="control" style="margin-top: 0.5rem">
<input class="input" type="text" placeholder="Enter custom category" [(ngModel)]="category" />
</div>
}
} @else {
<div class="control">
<input class="input" type="text" [(ngModel)]="category" />
</div>
}
<p class="help">The category becomes a sub-folder in your main download path.</p>
</div>

View file

@ -25,6 +25,8 @@ export class AddNewTorrentComponent implements OnInit {
public downloadClient: number;
public category: string;
public categories: string[] = [];
public categorySelect: string = '';
public hostDownloadAction: number = 0;
public downloadAction: number = 0;
public finishedAction: number = 0;
@ -81,6 +83,13 @@ export class AddNewTorrentComponent implements OnInit {
this.downloadClient = settings.find((m) => m.key === 'DownloadClient:Client')?.value as number;
this.category = settings.find((m) => m.key === 'Gui:Default:Category')?.value as string;
const categoriesSetting = settings.find((m) => m.key === 'General:Categories')?.value as string;
this.categories = (categoriesSetting ?? '').split(',').map((c) => c.trim()).filter((c) => c.length > 0);
if (this.categories.includes(this.category)) {
this.categorySelect = this.category;
} else if (this.category) {
this.categorySelect = '__custom__';
}
this.hostDownloadAction = this.downloadAction = settings.find((m) => m.key === 'Gui:Default:HostDownloadAction')
?.value as number;
this.downloadAction =
@ -100,6 +109,14 @@ export class AddNewTorrentComponent implements OnInit {
});
}
public onCategorySelectChange(value: string): void {
if (value !== '__custom__') {
this.category = value;
} else {
this.category = '';
}
}
public setFinishAction() {
if (this.downloadClient === 2) {
if (this.finishedAction === 1) {