diff --git a/client/src/app/torrent-row/torrent-row.component.html b/client/src/app/torrent-row/torrent-row.component.html index 8f22f58..025f6b3 100644 --- a/client/src/app/torrent-row/torrent-row.component.html +++ b/client/src/app/torrent-row/torrent-row.component.html @@ -2,15 +2,32 @@ {{ torrent.rdSize | filesize }} + + {{ torrent.files.length | number }} + + + {{ torrent.downloads.length | number }} + + + + + + {{ torrent | status }} - + - - + + + diff --git a/client/src/app/torrent-row/torrent-row.component.scss b/client/src/app/torrent-row/torrent-row.component.scss index e8bc505..6a01b12 100644 --- a/client/src/app/torrent-row/torrent-row.component.scss +++ b/client/src/app/torrent-row/torrent-row.component.scss @@ -2,3 +2,7 @@ color: red; cursor: pointer; } + +.auto .fas { + margin-right: 4px; +} \ No newline at end of file diff --git a/client/src/app/torrent-row/torrent-row.component.ts b/client/src/app/torrent-row/torrent-row.component.ts index b8288ed..ed15e59 100644 --- a/client/src/app/torrent-row/torrent-row.component.ts +++ b/client/src/app/torrent-row/torrent-row.component.ts @@ -1,5 +1,5 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { Torrent } from 'src/app/models/torrent.model'; +import { RealDebridStatus, Torrent } from 'src/app/models/torrent.model'; import { TorrentService } from 'src/app/torrent.service'; @Component({ @@ -24,13 +24,42 @@ export class TorrentRowComponent implements OnInit { event.stopPropagation(); this.loading = true; - this.torrentService.download(this.torrent.torrentId).subscribe(() => { - this.loading = false; - }); + this.torrentService.download(this.torrent.torrentId).subscribe( + () => { + this.loading = false; + }, + (err) => { + this.loading = false; + } + ); + } + + public unpack(event: Event): void { + event.stopPropagation(); + + this.loading = true; + this.torrentService.unpack(this.torrent.torrentId).subscribe( + () => { + this.loading = false; + }, + (err) => { + this.loading = false; + } + ); } public delete1(event: Event): void { event.stopPropagation(); this.delete.emit(this.torrent.torrentId); } + + public canDownload(): boolean { + return this.torrent.rdStatus === RealDebridStatus.Finished && this.torrent.downloads.length === 0; + } + + public canUnpack(): boolean { + const downloadsDone = this.torrent.downloads.any((m) => m.downloadFinished != null); + const downloadsUnpacked = this.torrent.downloads.any((m) => m.unpackingQueued != null); + return downloadsDone && !downloadsUnpacked; + } } diff --git a/client/src/app/torrent-status.pipe.ts b/client/src/app/torrent-status.pipe.ts index 6fe0e2d..22ac8a6 100644 --- a/client/src/app/torrent-status.pipe.ts +++ b/client/src/app/torrent-status.pipe.ts @@ -19,11 +19,16 @@ export class TorrentStatusPipe implements PipeTransform { return 'Finished'; } + const errors = torrent.downloads.where((m) => m.error != null); const downloading = torrent.downloads.where((m) => m.downloadStarted && !m.downloadFinished); + const downloaded = torrent.downloads.where((m) => m.downloadFinished != null); const unpacking = torrent.downloads.where((m) => m.unpackingStarted && !m.unpackingFinished); + const queuedForDownload = torrent.downloads.where((m) => m.downloadQueued && !m.downloadStarted); + const queuedForUnpacking = torrent.downloads.where((m) => m.unpackingQueued && !m.unpackingStarted); - let downloadText = ''; - let unpackText = ''; + if (errors.length > 0) { + return 'Error'; + } if (downloading.length > 0) { const bytesDone = downloading.sum((m) => m.bytesDone); @@ -35,7 +40,7 @@ export class TorrentStatusPipe implements PipeTransform { if (allSpeeds > 0) { speed = this.pipe.transform(allSpeeds, 'filesize'); - downloadText = `Downloading (${progress.toFixed(2)}% - ${speed}/s)`; + return `Downloading (${progress.toFixed(2)}% - ${speed}/s)`; } } @@ -46,20 +51,20 @@ export class TorrentStatusPipe implements PipeTransform { let allSpeeds = unpacking.sum((m) => m.speed) / unpacking.length; if (allSpeeds > 0) { - downloadText = `Extracting (${progress.toFixed(2)}%)`; + return `Extracting (${progress.toFixed(2)}%)`; } } - let result: string[] = []; - if (downloadText) { - result.push(downloadText); - } - if (unpackText) { - result.push(unpackText); + if (queuedForUnpacking.length > 0) { + return `Queued for unpacking`; } - if (result.length > 0) { - return result.join('\r\n'); + if (queuedForDownload.length > 0) { + return `Queued for downloading`; + } + + if (downloaded.length > 0) { + return `Files downloaded to host`; } } diff --git a/client/src/app/torrent-table/torrent-table.component.html b/client/src/app/torrent-table/torrent-table.component.html index a599358..49ce02a 100644 --- a/client/src/app/torrent-table/torrent-table.component.html +++ b/client/src/app/torrent-table/torrent-table.component.html @@ -5,19 +5,23 @@
- + - - - + + + + + + + + - - + @@ -28,15 +32,12 @@ (click)="selectTorrent(torrent)" (delete)="showDeleteModal($event)" > - - - diff --git a/client/src/app/torrent.service.ts b/client/src/app/torrent.service.ts index 583fe8a..0081e32 100644 --- a/client/src/app/torrent.service.ts +++ b/client/src/app/torrent.service.ts @@ -42,6 +42,10 @@ export class TorrentService { return this.http.get(`/Api/Torrents/Download/${torrentId}`); } + public unpack(torrentId: string): Observable { + return this.http.get(`/Api/Torrents/Unpack/${torrentId}`); + } + public delete( torrentId: string, deleteData: boolean, diff --git a/server/RdtClient.Service/DiConfig.cs b/server/RdtClient.Service/DiConfig.cs index 00e9264..422f96a 100644 --- a/server/RdtClient.Service/DiConfig.cs +++ b/server/RdtClient.Service/DiConfig.cs @@ -13,7 +13,6 @@ namespace RdtClient.Service services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddScoped(); } } } \ No newline at end of file diff --git a/server/RdtClient.Service/Services/TorrentDownloadManager.cs b/server/RdtClient.Service/Services/TorrentDownloadManager.cs deleted file mode 100644 index d5ae9aa..0000000 --- a/server/RdtClient.Service/Services/TorrentDownloadManager.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Threading.Tasks; - -namespace RdtClient.Service.Services -{ - public interface ITorrentDownloadManager - { - Task Tick(); - } - - public class TorrentDownloadManager : ITorrentDownloadManager - { - public async Task Tick() - { - throw new System.NotImplementedException(); - } - } -} diff --git a/server/RdtClient.Service/Services/Torrents.cs b/server/RdtClient.Service/Services/Torrents.cs index d30d087..7a8ce3d 100644 --- a/server/RdtClient.Service/Services/Torrents.cs +++ b/server/RdtClient.Service/Services/Torrents.cs @@ -163,6 +163,15 @@ namespace RdtClient.Service.Services if (torrent != null) { + if (deleteLocalFiles) + { + var settingDownloadFolder = await _settings.GetString("DownloadFolder"); + + var torrentPath = Path.Combine(settingDownloadFolder, torrent.RdName); + + Directory.Delete(torrentPath, true); + } + if (deleteData) { await _downloads.DeleteForTorrent(torrent.TorrentId); @@ -173,11 +182,6 @@ namespace RdtClient.Service.Services { await GetRdNetClient().DeleteTorrentAsync(torrent.RdId); } - - if (deleteLocalFiles) - { - // TODO - } } } diff --git a/server/RdtClient.Web/Controllers/TorrentsController.cs b/server/RdtClient.Web/Controllers/TorrentsController.cs index e703b11..369759e 100644 --- a/server/RdtClient.Web/Controllers/TorrentsController.cs +++ b/server/RdtClient.Web/Controllers/TorrentsController.cs @@ -17,10 +17,12 @@ namespace RdtClient.Web.Controllers public class TorrentsController : Controller { private readonly ITorrents _torrents; + private readonly IDownloads _downloads; - public TorrentsController(ITorrents torrents) + public TorrentsController(ITorrents torrents, IDownloads downloads) { _torrents = torrents; + _downloads = downloads; } [HttpGet] @@ -102,6 +104,20 @@ namespace RdtClient.Web.Controllers return Ok(); } + + [HttpGet] + [Route("Unpack/{id}")] + public async Task Unpack(Guid id) + { + var downloads = await _downloads.GetForTorrent(id); + + foreach (var download in downloads) + { + await _torrents.Unpack(download.DownloadId); + } + + return Ok(); + } } public class TorrentControllerUploadFileRequest diff --git a/server/RdtClient.Web/Program.cs b/server/RdtClient.Web/Program.cs index 4fcfdc3..a0585a2 100644 --- a/server/RdtClient.Web/Program.cs +++ b/server/RdtClient.Web/Program.cs @@ -71,6 +71,7 @@ namespace RdtClient.Web .Enrich.FromLogContext() .Enrich.WithExceptionDetails() .WriteTo.File(appSettings.Logging.File.Path, logLevel, rollOnFileSizeLimit: true, fileSizeLimitBytes: appSettings.Logging.File.FileSizeLimitBytes, retainedFileCountLimit: appSettings.Logging.File.MaxRollingFiles) + .WriteTo.Console() .MinimumLevel.Information() .CreateLogger();
Name SizeFilesDownloadsAuto StatusAction