-
+
-
+
@if (provider === 0) {
diff --git a/client/src/app/setup/setup.component.ts b/client/src/app/setup/setup.component.ts
index 745ed29..99f65e8 100644
--- a/client/src/app/setup/setup.component.ts
+++ b/client/src/app/setup/setup.component.ts
@@ -1,12 +1,15 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '../auth.service';
+import { NgClass } from '@angular/common';
+import { FormsModule } from '@angular/forms';
@Component({
selector: 'app-setup',
templateUrl: './setup.component.html',
styleUrls: ['./setup.component.scss'],
- standalone: false,
+ imports: [FormsModule, NgClass],
+ standalone: true,
})
export class SetupComponent {
public userName: string;
@@ -28,29 +31,29 @@ export class SetupComponent {
this.error = null;
this.working = true;
- this.authService.create(this.userName, this.password).subscribe(
- () => {
+ this.authService.create(this.userName, this.password).subscribe({
+ next: () => {
this.step = 2;
this.working = false;
},
- (err) => {
+ error: (err) => {
this.working = false;
this.error = err.error;
},
- );
+ });
}
public setToken(): void {
- this.authService.setupProvider(this.provider, this.token).subscribe(
- () => {
+ this.authService.setupProvider(this.provider, this.token).subscribe({
+ next: () => {
this.step = 3;
this.working = false;
},
- (err: any) => {
+ error: (err: any) => {
this.working = false;
this.error = err.error;
},
- );
+ });
}
public close(): void {
diff --git a/client/src/app/sort.pipe.ts b/client/src/app/sort.pipe.ts
index 8a01723..5173cf5 100644
--- a/client/src/app/sort.pipe.ts
+++ b/client/src/app/sort.pipe.ts
@@ -1,9 +1,6 @@
import { Pipe, PipeTransform } from '@angular/core';
-@Pipe({
- name: 'sort',
- standalone: false,
-})
+@Pipe({ name: 'sort', })
export class SortPipe implements PipeTransform {
transform(array: any[], field: string, order: 'asc' | 'desc' = 'asc'): any[] {
if (!Array.isArray(array)) {
diff --git a/client/src/app/torrent-status.pipe.ts b/client/src/app/torrent-status.pipe.ts
index 9d827e8..6844f3e 100644
--- a/client/src/app/torrent-status.pipe.ts
+++ b/client/src/app/torrent-status.pipe.ts
@@ -2,10 +2,7 @@ import { Pipe, PipeTransform } from '@angular/core';
import { RealDebridStatus, Torrent } from './models/torrent.model';
import { FileSizePipe } from './filesize.pipe';
-@Pipe({
- name: 'status',
- standalone: false,
-})
+@Pipe({ name: 'status' })
export class TorrentStatusPipe implements PipeTransform {
constructor(private pipe: FileSizePipe) {}
@@ -15,59 +12,49 @@ export class TorrentStatusPipe implements PipeTransform {
}
if (torrent.downloads.length > 0) {
- const allFinished = torrent.downloads.all((m) => m.completed != null);
+ const allFinished = torrent.downloads.every((m) => m.completed != null);
if (allFinished) {
return 'Finished';
}
- const downloading = torrent.downloads.where((m) => m.downloadStarted && !m.downloadFinished && m.bytesDone > 0);
- const downloaded = torrent.downloads.where((m) => m.downloadFinished != null);
+ const downloading = torrent.downloads.filter((m) => m.downloadStarted && !m.downloadFinished && m.bytesDone > 0);
+ const downloaded = torrent.downloads.filter((m) => m.downloadFinished != null);
if (downloading.length > 0) {
- const bytesDone = downloading.sum((m) => m.bytesDone);
- const bytesTotal = downloading.sum((m) => m.bytesTotal);
- let progress = (bytesDone / bytesTotal) * 100;
+ const bytesDone = downloading.reduce((sum, m) => sum + m.bytesDone, 0);
+ const bytesTotal = downloading.reduce((sum, m) => sum + m.bytesTotal, 0);
+ const progress = (bytesDone / bytesTotal || 0) * 100;
- if (isNaN(progress)) {
- progress = 0;
- }
+ const allSpeeds = downloading.reduce((sum, m) => sum + m.speed, 0);
- let allSpeeds = downloading.sum((m) => m.speed);
-
- let speed: string | string[] = '0';
-
- speed = this.pipe.transform(allSpeeds, 'filesize');
+ const speed: string | string[] = this.pipe.transform(allSpeeds, 'filesize');
return `Downloading file ${downloading.length + downloaded.length}/${
torrent.downloads.length
} (${progress.toFixed(2)}% - ${speed}/s)`;
}
- const unpacking = torrent.downloads.where((m) => m.unpackingStarted && !m.unpackingFinished && m.bytesDone > 0);
- const unpacked = torrent.downloads.where((m) => m.unpackingFinished != null);
+ const unpacking = torrent.downloads.filter((m) => m.unpackingStarted && !m.unpackingFinished && m.bytesDone > 0);
+ const unpacked = torrent.downloads.filter((m) => m.unpackingFinished != null);
if (unpacking.length > 0) {
- const bytesDone = unpacking.sum((m) => m.bytesDone);
- const bytesTotal = unpacking.sum((m) => m.bytesTotal);
- let progress = (bytesDone / bytesTotal) * 100;
-
- if (isNaN(progress)) {
- progress = 0;
- }
+ const bytesDone = unpacking.reduce((sum, m) => sum + m.bytesDone, 0);
+ const bytesTotal = unpacking.reduce((sum, m) => sum + m.bytesTotal, 0);
+ const progress = (bytesDone / bytesTotal || 0) * 100;
return `Extracting file ${unpacking.length + unpacked.length}/${torrent.downloads.length} (${progress.toFixed(
2,
)}%)`;
}
- const queuedForUnpacking = torrent.downloads.where((m) => m.unpackingQueued && !m.unpackingStarted);
+ const queuedForUnpacking = torrent.downloads.filter((m) => m.unpackingQueued && !m.unpackingStarted);
if (queuedForUnpacking.length > 0) {
return `Queued for unpacking`;
}
- const queuedForDownload = torrent.downloads.where((m) => !m.downloadStarted && !m.downloadFinished);
+ const queuedForDownload = torrent.downloads.filter((m) => !m.downloadStarted && !m.downloadFinished);
if (queuedForDownload.length > 0) {
return `Queued for downloading`;
diff --git a/client/src/app/torrent-table/torrent-table.component.html b/client/src/app/torrent-table/torrent-table.component.html
index db890fd..f5b27c6 100644
--- a/client/src/app/torrent-table/torrent-table.component.html
+++ b/client/src/app/torrent-table/torrent-table.component.html
@@ -33,7 +33,7 @@
diff --git a/client/src/app/torrent-table/torrent-table.component.ts b/client/src/app/torrent-table/torrent-table.component.ts
index 4cab1d3..48454ba 100644
--- a/client/src/app/torrent-table/torrent-table.component.ts
+++ b/client/src/app/torrent-table/torrent-table.component.ts
@@ -3,12 +3,18 @@ import { Router } from '@angular/router';
import { Torrent } from '../models/torrent.model';
import { TorrentService } from '../torrent.service';
import { forkJoin, Observable } from 'rxjs';
+import { FormsModule } from '@angular/forms';
+import { NgClass, DecimalPipe, DatePipe } from '@angular/common';
+import { TorrentStatusPipe } from '../torrent-status.pipe';
+import { SortPipe } from '../sort.pipe';
+import { FileSizePipe } from '../filesize.pipe';
@Component({
selector: 'app-torrent-table',
templateUrl: './torrent-table.component.html',
styleUrls: ['./torrent-table.component.scss'],
- standalone: false,
+ imports: [FormsModule, NgClass, DecimalPipe, DatePipe, TorrentStatusPipe, SortPipe, FileSizePipe],
+ standalone: true,
})
export class TorrentTableComponent implements OnInit {
public torrents: Torrent[] = [];
@@ -48,18 +54,18 @@ export class TorrentTableComponent implements OnInit {
) {}
ngOnInit(): void {
- this.torrentService.getList().subscribe(
- (result) => {
+ this.torrentService.getList().subscribe({
+ next: (result) => {
this.torrents = result;
this.torrentService.update$.subscribe((result2) => {
this.torrents = result2;
});
},
- (err) => {
+ error: (err) => {
this.error = err.error;
},
- );
+ });
}
public sort(property: string): void {
@@ -107,7 +113,7 @@ export class TorrentTableComponent implements OnInit {
public deleteOk(): void {
this.deleting = true;
- let calls: Observable[] = [];
+ const calls: Observable[] = [];
this.selectedTorrents.forEach((torrentId) => {
calls.push(this.torrentService.delete(torrentId, this.deleteData, this.deleteRdTorrent, this.deleteLocalFiles));
@@ -140,7 +146,7 @@ export class TorrentTableComponent implements OnInit {
public retryOk(): void {
this.retrying = true;
- let calls: Observable[] = [];
+ const calls: Observable[] = [];
this.selectedTorrents.forEach((torrentId) => {
calls.push(this.torrentService.retry(torrentId));
@@ -163,30 +169,40 @@ export class TorrentTableComponent implements OnInit {
public changeSettingsModal(): void {
this.changeSettingsError = null;
- const selectedTorrents = this.torrents.where((m) => this.selectedTorrents.indexOf(m.torrentId) > -1);
+ const selectedTorrents = this.torrents.filter((m) => this.selectedTorrents.indexOf(m.torrentId) > -1);
- this.updateSettingsDownloadClient =
- selectedTorrents.distinctBy((m) => m.downloadClient).count() == 1 ? selectedTorrents[0].downloadClient : null;
- this.updateSettingsHostDownloadAction =
- selectedTorrents.distinctBy((m) => m.hostDownloadAction).count() == 1
- ? selectedTorrents[0].hostDownloadAction
- : null;
- this.updateSettingsCategory =
- selectedTorrents.distinctBy((m) => m.category).count() == 1 ? selectedTorrents[0].category : null;
- this.updateSettingsPriority =
- selectedTorrents.distinctBy((m) => m.priority).count() == 1 ? selectedTorrents[0].priority : null;
- this.updateSettingsDownloadRetryAttempts =
- selectedTorrents.distinctBy((m) => m.downloadRetryAttempts).count() == 1
- ? selectedTorrents[0].downloadRetryAttempts
- : null;
- this.updateSettingsTorrentRetryAttempts =
- selectedTorrents.distinctBy((m) => m.torrentRetryAttempts).count() == 1
- ? selectedTorrents[0].torrentRetryAttempts
- : null;
- this.updateSettingsDeleteOnError =
- selectedTorrents.distinctBy((m) => m.deleteOnError).count() == 1 ? selectedTorrents[0].deleteOnError : null;
- this.updateSettingsTorrentLifetime =
- selectedTorrents.distinctBy((m) => m.lifetime).count() == 1 ? selectedTorrents[0].lifetime : null;
+ this.updateSettingsDownloadClient = selectedTorrents.every(
+ (m, _, arr) => m.downloadClient === arr[0].downloadClient,
+ )
+ ? selectedTorrents[0].downloadClient
+ : null;
+ this.updateSettingsHostDownloadAction = selectedTorrents.every(
+ (m, _, arr) => m.hostDownloadAction === arr[0].hostDownloadAction,
+ )
+ ? selectedTorrents[0].hostDownloadAction
+ : null;
+ this.updateSettingsCategory = selectedTorrents.every((m, _, arr) => m.category === arr[0].category)
+ ? selectedTorrents[0].category
+ : null;
+ this.updateSettingsPriority = selectedTorrents.every((m, _, arr) => m.priority === arr[0].priority)
+ ? selectedTorrents[0].priority
+ : null;
+ this.updateSettingsDownloadRetryAttempts = selectedTorrents.every(
+ (m, _, arr) => m.downloadRetryAttempts === arr[0].downloadRetryAttempts,
+ )
+ ? selectedTorrents[0].downloadRetryAttempts
+ : null;
+ this.updateSettingsTorrentRetryAttempts = selectedTorrents.every(
+ (m, _, arr) => m.torrentRetryAttempts === arr[0].torrentRetryAttempts,
+ )
+ ? selectedTorrents[0].torrentRetryAttempts
+ : null;
+ this.updateSettingsDeleteOnError = selectedTorrents.every((m, _, arr) => m.deleteOnError === arr[0].deleteOnError)
+ ? selectedTorrents[0].deleteOnError
+ : null;
+ this.updateSettingsTorrentLifetime = selectedTorrents.every((m, _, arr) => m.lifetime === arr[0].lifetime)
+ ? selectedTorrents[0].lifetime
+ : null;
this.isChangeSettingsModalActive = true;
}
@@ -198,9 +214,9 @@ export class TorrentTableComponent implements OnInit {
public changeSettingsOk(): void {
this.changingSettings = true;
- let calls: Observable[] = [];
+ const calls: Observable[] = [];
- const selectedTorrents = this.torrents.where((m) => this.selectedTorrents.indexOf(m.torrentId) > -1);
+ const selectedTorrents = this.torrents.filter((m) => this.selectedTorrents.indexOf(m.torrentId) > -1);
selectedTorrents.forEach((torrent) => {
if (this.updateSettingsDownloadClient != null) {
diff --git a/client/src/app/torrent/torrent.component.scss b/client/src/app/torrent/torrent.component.scss
index 7021f84..5d62b1c 100644
--- a/client/src/app/torrent/torrent.component.scss
+++ b/client/src/app/torrent/torrent.component.scss
@@ -8,10 +8,6 @@ table {
}
}
-.fa-download {
- margin-left: 12px;
-}
-
.flex-container {
display: flex;
flex: 1 1 0;
diff --git a/client/src/app/torrent/torrent.component.ts b/client/src/app/torrent/torrent.component.ts
index 2f8f93c..8aaf2a0 100644
--- a/client/src/app/torrent/torrent.component.ts
+++ b/client/src/app/torrent/torrent.component.ts
@@ -3,12 +3,29 @@ import { ActivatedRoute, Router } from '@angular/router';
import { saveAs } from 'file-saver-es';
import { Torrent } from '../models/torrent.model';
import { TorrentService } from '../torrent.service';
+import { NgClass, DatePipe } from '@angular/common';
+import { CdkCopyToClipboard } from '@angular/cdk/clipboard';
+import { FormsModule } from '@angular/forms';
+import { TorrentStatusPipe } from '../torrent-status.pipe';
+import { DownloadStatusPipe } from '../download-status.pipe';
+import { DecodeURIPipe } from '../decode-uri.pipe';
+import { FileSizePipe } from '../filesize.pipe';
@Component({
selector: 'app-torrent',
templateUrl: './torrent.component.html',
styleUrls: ['./torrent.component.scss'],
- standalone: false,
+ imports: [
+ NgClass,
+ CdkCopyToClipboard,
+ FormsModule,
+ DatePipe,
+ TorrentStatusPipe,
+ DownloadStatusPipe,
+ DecodeURIPipe,
+ FileSizePipe,
+ ],
+ standalone: true,
})
export class TorrentComponent implements OnInit {
public torrent: Torrent;
@@ -59,23 +76,21 @@ export class TorrentComponent implements OnInit {
this.activatedRoute.params.subscribe((params) => {
const torrentId = params['id'];
- this.torrentService.get(torrentId).subscribe(
- (torrent) => {
+ this.torrentService.get(torrentId).subscribe({
+ next: (torrent) => {
this.torrent = torrent;
this.torrentService.update$.subscribe((result) => {
this.update(result);
});
},
- () => {
- this.router.navigate(['/']);
- },
- );
+ error: () => this.router.navigate(['/']),
+ });
});
}
public update(torrents: Torrent[]): void {
- const updatedTorrent = torrents.firstOrDefault((m) => m.torrentId === this.torrent.torrentId);
+ const updatedTorrent = torrents.find((m) => m.torrentId === this.torrent.torrentId);
if (updatedTorrent == null) {
return;
@@ -94,7 +109,7 @@ export class TorrentComponent implements OnInit {
}),
);
- var blob = new Blob([byteArray], { type: 'application/x-bittorrent' });
+ const blob = new Blob([byteArray], { type: 'application/x-bittorrent' });
saveAs(blob, `${this.torrent.rdName}.torrent`);
}
@@ -116,18 +131,18 @@ export class TorrentComponent implements OnInit {
this.torrentService
.delete(this.torrent.torrentId, this.deleteData, this.deleteRdTorrent, this.deleteLocalFiles)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.isDeleteModalActive = false;
this.deleting = false;
this.router.navigate(['/']);
},
- (err) => {
+ error: (err) => {
this.deleteError = err.error;
this.deleting = false;
},
- );
+ });
}
public showRetryModal(): void {
@@ -143,18 +158,18 @@ export class TorrentComponent implements OnInit {
public retryOk(): void {
this.retrying = true;
- this.torrentService.retry(this.torrent.torrentId).subscribe(
- () => {
+ this.torrentService.retry(this.torrent.torrentId).subscribe({
+ next: () => {
this.isRetryModalActive = false;
this.retrying = false;
this.router.navigate(['/']);
},
- (err) => {
+ error: (err) => {
this.retryError = err.error;
this.retrying = false;
},
- );
+ });
}
public showDownloadRetryModal(downloadId: string): void {
@@ -171,16 +186,16 @@ export class TorrentComponent implements OnInit {
public downloadRetryOk(): void {
this.downloadRetrying = true;
- this.torrentService.retryDownload(this.downloadRetryId).subscribe(
- () => {
+ this.torrentService.retryDownload(this.downloadRetryId).subscribe({
+ next: () => {
this.isDownloadRetryModalActive = false;
this.downloadRetrying = false;
},
- (err) => {
+ error: (err) => {
this.downloadRetryError = err.error;
this.downloadRetrying = false;
},
- );
+ });
}
public showUpdateSettingsModal(): void {
@@ -212,16 +227,16 @@ export class TorrentComponent implements OnInit {
this.torrent.deleteOnError = this.updateSettingsDeleteOnError;
this.torrent.lifetime = this.updateSettingsTorrentLifetime;
- this.torrentService.update(this.torrent).subscribe(
- () => {
+ this.torrentService.update(this.torrent).subscribe({
+ next: () => {
this.isUpdateSettingsModalActive = false;
this.updating = false;
},
- () => {
+ error: () => {
this.isUpdateSettingsModalActive = false;
this.updating = false;
},
- );
+ });
}
toggleDeleteSelectAllOptions() {
this.deleteData = this.deleteSelectAll;
diff --git a/client/src/index.html b/client/src/index.html
index c00d504..baa81c3 100644
--- a/client/src/index.html
+++ b/client/src/index.html
@@ -6,11 +6,10 @@
|