From 004ed451441180ae99ba7f4c840ec82774db842b Mon Sep 17 00:00:00 2001 From: Sylvain DUARTE Date: Sat, 14 Mar 2026 11:46:15 +0100 Subject: [PATCH 1/2] Add mobile compatibility for torrent-table (cherry picked from commit 65e843489dfefcb621b3874e55e81dc8cbd3ffb3) --- .../torrent-table.component.html | 31 ++++++- .../torrent-table.component.scss | 87 +++++++++++++++++-- 2 files changed, 111 insertions(+), 7 deletions(-) diff --git a/client/src/app/torrent-table/torrent-table.component.html b/client/src/app/torrent-table/torrent-table.component.html index d441002..aaf146e 100644 --- a/client/src/app/torrent-table/torrent-table.component.html +++ b/client/src/app/torrent-table/torrent-table.component.html @@ -21,7 +21,7 @@ }
- +
@@ -84,6 +84,35 @@
+
+ @for (torrent of torrents | sort: sortProperty : sortDirection; track torrent.torrentId) { +
+
+ +
+
+

{{ torrent.rdName }}

+
+ {{ torrent | status }} + @if (torrent.category) { + {{ torrent.category }} + } +
+
+ Size {{ torrent.rdSize | filesize }} + Seeders {{ torrent.rdSeeders }} + Files {{ torrent.files.length | number }} + Downloads {{ torrent.downloads.length | number }} +
+
+
+ } +
+
@if (torrents.length > 0) {
}
- - - - - - - - - - - - - - - - - @for (torrent of torrents | sort: sortProperty : sortDirection; track torrent.torrentId) { + @if (!isMobile) { +
- - NameCategoryPrioritySeedersFilesDownloadsSizeRequestedStatus
+ - + + + + + + + + + + + + + @for (torrent of torrents | sort: sortProperty : sortDirection; track torrent.torrentId) { + + + + + + + + + + + + + } + +
+ + + NameCategoryPrioritySeedersFilesDownloadsSizeRequestedStatus
+ + + {{ torrent.rdName }} + + {{ torrent.category }} + + {{ torrent.priority }} + + {{ torrent.rdSeeders }} + + {{ torrent.files.length | number }} + + {{ torrent.downloads.length | number }} + + {{ torrent.rdSize | filesize }} + + {{ torrent.added | date: "medium" }} + + {{ torrent | status }} +
+ } @else { +
+ @for (torrent of torrents | sort: sortProperty : sortDirection; track torrent.torrentId) { +
+
- - - {{ torrent.rdName }} - - - {{ torrent.category }} - - - {{ torrent.priority }} - - - {{ torrent.rdSeeders }} - - - {{ torrent.files.length | number }} - - - {{ torrent.downloads.length | number }} - - - {{ torrent.rdSize | filesize }} - - - {{ torrent.added | date: "medium" }} - - - {{ torrent | status }} - - +
+
+

{{ torrent.rdName }}

+
+ {{ torrent | status }} + @if (torrent.category) { + {{ torrent.category }} + } +
+
+ Size {{ torrent.rdSize | filesize }} + Seeders {{ torrent.rdSeeders }} + Files {{ torrent.files.length | number }} + Downloads {{ torrent.downloads.length | number }} +
+
+
} - - - -
- @for (torrent of torrents | sort: sortProperty : sortDirection; track torrent.torrentId) { -
-
- -
-
-

{{ torrent.rdName }}

-
- {{ torrent | status }} - @if (torrent.category) { - {{ torrent.category }} - } -
-
- Size {{ torrent.rdSize | filesize }} - Seeders {{ torrent.rdSeeders }} - Files {{ torrent.files.length | number }} - Downloads {{ torrent.downloads.length | number }} -
-
-
- } -
+
+ }
@if (torrents.length > 0) { diff --git a/client/src/app/torrent-table/torrent-table.component.scss b/client/src/app/torrent-table/torrent-table.component.scss index a12787c..f741d20 100644 --- a/client/src/app/torrent-table/torrent-table.component.scss +++ b/client/src/app/torrent-table/torrent-table.component.scss @@ -7,20 +7,8 @@ table { } } -.desktop-table { - display: table; - - @media screen and (max-width: 768px) { - display: none; - } -} - .mobile-cards { - display: none; - - @media screen and (max-width: 768px) { - display: block; - } + display: block; } .mobile-card { diff --git a/client/src/app/torrent-table/torrent-table.component.ts b/client/src/app/torrent-table/torrent-table.component.ts index 4b5100e..44d9bbd 100644 --- a/client/src/app/torrent-table/torrent-table.component.ts +++ b/client/src/app/torrent-table/torrent-table.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnDestroy, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { Torrent } from '../models/torrent.model'; import { DiskSpaceStatus } from '../models/disk-space-status.model'; @@ -18,7 +18,7 @@ import { FileSizePipe } from '../filesize.pipe'; imports: [FormsModule, NgClass, DecimalPipe, DatePipe, TorrentStatusPipe, SortPipe, FileSizePipe], standalone: true, }) -export class TorrentTableComponent implements OnInit { +export class TorrentTableComponent implements OnInit, OnDestroy { public torrents: Torrent[] = []; public selectedTorrents: string[] = []; public error: string; @@ -53,12 +53,23 @@ export class TorrentTableComponent implements OnInit { public diskSpaceStatus: DiskSpaceStatus | null = null; public rateLimitStatus: RateLimitStatus | null = null; + public isMobile = false; + private mobileQuery: MediaQueryList; + private mobileQueryListener: (e: MediaQueryListEvent) => void; + constructor( private router: Router, private torrentService: TorrentService, ) {} ngOnInit(): void { + this.mobileQuery = window.matchMedia('(max-width: 768px)'); + this.isMobile = this.mobileQuery.matches; + this.mobileQueryListener = (e: MediaQueryListEvent) => { + this.isMobile = e.matches; + }; + this.mobileQuery.addEventListener('change', this.mobileQueryListener); + // Load persisted sort settings (if any) try { const sp = localStorage.getItem('torrentTable.sortProperty'); @@ -320,4 +331,8 @@ export class TorrentTableComponent implements OnInit { updateDeleteSelectAll() { this.deleteSelectAll = this.deleteData && this.deleteRdTorrent && this.deleteLocalFiles; } + + ngOnDestroy(): void { + this.mobileQuery?.removeEventListener('change', this.mobileQueryListener); + } }