From 4b70c278a960a8d43407f0039aa03d0b08b44f9c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 26 May 2023 10:27:02 +0200 Subject: [PATCH] Automatic colspan for tables --- .../followers-list.component.html | 2 +- .../following-list.component.html | 2 +- .../video-redundancies-list.component.html | 6 ++--- .../video-redundancies-list.component.ts | 6 ----- .../registration-list.component.html | 4 ++-- .../video-block-list.component.html | 4 ++-- .../video-comment-list.component.html | 4 ++-- .../users/user-list/user-list.component.html | 2 +- .../overview/videos/video-list.component.html | 2 +- .../runner-job-list.component.html | 4 ++-- .../runner-list/runner-list.component.html | 2 +- ...ner-registration-token-list.component.html | 2 +- .../my-ownership/my-ownership.component.html | 2 +- .../my-video-imports.component.html | 2 +- .../abuse-list-table.component.html | 6 ++--- .../angular/auto-colspan.directive.ts | 22 +++++++++++++++++++ .../app/shared/shared-main/angular/index.ts | 1 + .../shared/shared-main/shared-main.module.ts | 3 +++ .../account-blocklist.component.html | 2 +- .../server-blocklist.component.html | 2 +- 20 files changed, 50 insertions(+), 30 deletions(-) create mode 100644 client/src/app/shared/shared-main/angular/auto-colspan.directive.ts diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.html b/client/src/app/+admin/follows/followers-list/followers-list.component.html index 14c62f1af..3326d59db 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.html +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.html @@ -72,7 +72,7 @@ - +
No follower found matching current filters. Your instance doesn't have any follower. diff --git a/client/src/app/+admin/follows/following-list/following-list.component.html b/client/src/app/+admin/follows/following-list/following-list.component.html index f46f36375..07495a74c 100644 --- a/client/src/app/+admin/follows/following-list/following-list.component.html +++ b/client/src/app/+admin/follows/following-list/following-list.component.html @@ -79,7 +79,7 @@ - +
No host found matching current filters. Your instance is not following anyone. diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.html b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.html index 2b52d3fd8..85b9d8913 100644 --- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.html +++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.html @@ -57,7 +57,7 @@ - +
@@ -65,7 +65,7 @@ - +
@@ -75,7 +75,7 @@ - +
Your instance doesn't mirror any video. Your instance has no mirrored videos. diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts index d65467a4d..efcefd509 100644 --- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts +++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts @@ -63,12 +63,6 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit }) } - getColspan () { - if (this.isDisplayingRemoteVideos()) return 5 - - return 4 - } - isDisplayingRemoteVideos () { return this.displayType === 'remote-videos' } diff --git a/client/src/app/+admin/moderation/registration-list/registration-list.component.html b/client/src/app/+admin/moderation/registration-list/registration-list.component.html index a2b888101..8e5e2cf49 100644 --- a/client/src/app/+admin/moderation/registration-list/registration-list.component.html +++ b/client/src/app/+admin/moderation/registration-list/registration-list.component.html @@ -102,7 +102,7 @@ - +
@@ -122,7 +122,7 @@ - +
No registrations found matching current filters. No registrations found. diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html index 28109d007..53bc6a178 100644 --- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html +++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html @@ -68,7 +68,7 @@ - +
@@ -87,7 +87,7 @@ - +
No blocked video found matching current filters. No blocked video found. diff --git a/client/src/app/+admin/overview/comments/video-comment-list.component.html b/client/src/app/+admin/overview/comments/video-comment-list.component.html index b0d8131bf..df9bccc0a 100644 --- a/client/src/app/+admin/overview/comments/video-comment-list.component.html +++ b/client/src/app/+admin/overview/comments/video-comment-list.component.html @@ -93,7 +93,7 @@ - +
@@ -101,7 +101,7 @@ - +
No comments found matching current filters. No comments found. diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.html b/client/src/app/+admin/overview/users/user-list/user-list.component.html index 30859a3ad..e37ad2a3e 100644 --- a/client/src/app/+admin/overview/users/user-list/user-list.component.html +++ b/client/src/app/+admin/overview/users/user-list/user-list.component.html @@ -146,7 +146,7 @@ - + Ban reason: {{ user.blockedReason }} diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html index 35b1f9dbd..c4f78cadc 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.html +++ b/client/src/app/+admin/overview/videos/video-list.component.html @@ -100,7 +100,7 @@ - +
WebTorrent: diff --git a/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.html b/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.html index 5356e0e03..a759e9186 100644 --- a/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.html +++ b/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.html @@ -87,7 +87,7 @@ - +
Parent job: {{ runnerJob.parent?.uuid || '-' }}
Processed on {{ (runnerJob.startedAt || '-') }}
@@ -111,7 +111,7 @@ - +
No runner jobs found.
diff --git a/client/src/app/+admin/system/runners/runner-list/runner-list.component.html b/client/src/app/+admin/system/runners/runner-list/runner-list.component.html index 606eb9afd..b131d1a74 100644 --- a/client/src/app/+admin/system/runners/runner-list/runner-list.component.html +++ b/client/src/app/+admin/system/runners/runner-list/runner-list.component.html @@ -51,7 +51,7 @@ - +
No remote runners found.
diff --git a/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.html b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.html index 2fd23e2fc..3e5cea881 100644 --- a/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.html +++ b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.html @@ -55,7 +55,7 @@ - +
No registration token found for remote runners.
diff --git a/client/src/app/+my-library/my-ownership/my-ownership.component.html b/client/src/app/+my-library/my-ownership/my-ownership.component.html index 5db1a9bb2..40bfdcdf1 100644 --- a/client/src/app/+my-library/my-ownership/my-ownership.component.html +++ b/client/src/app/+my-library/my-ownership/my-ownership.component.html @@ -67,7 +67,7 @@ - +
No ownership change request found.
diff --git a/client/src/app/+my-library/my-video-imports/my-video-imports.component.html b/client/src/app/+my-library/my-video-imports/my-video-imports.component.html index 92a4a4a52..d25eff24c 100644 --- a/client/src/app/+my-library/my-video-imports/my-video-imports.component.html +++ b/client/src/app/+my-library/my-video-imports/my-video-imports.component.html @@ -72,7 +72,7 @@ - +
{{ videoImport.error }}
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html index 2571cc952..5833e3465 100644 --- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html +++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html @@ -136,10 +136,10 @@ - + - + @@ -147,7 +147,7 @@ - +
No abuses found matching current filters. No abuses found. diff --git a/client/src/app/shared/shared-main/angular/auto-colspan.directive.ts b/client/src/app/shared/shared-main/angular/auto-colspan.directive.ts new file mode 100644 index 000000000..8da89b668 --- /dev/null +++ b/client/src/app/shared/shared-main/angular/auto-colspan.directive.ts @@ -0,0 +1,22 @@ +import { AfterViewInit, Directive, ElementRef, Renderer2 } from '@angular/core' + +@Directive({ + selector: '[myAutoColspan]' +}) +export class AutoColspanDirective implements AfterViewInit { + + constructor ( + private host: ElementRef, + private renderer: Renderer2 + ) { } + + ngAfterViewInit () { + const el = this.host.nativeElement as HTMLElement + const table = el.closest('table') + if (!table) throw new Error('table element not found') + + const th = table.querySelectorAll('th') + + this.renderer.setAttribute(el, 'colspan', th.length + '') + } +} diff --git a/client/src/app/shared/shared-main/angular/index.ts b/client/src/app/shared/shared-main/angular/index.ts index f72d60313..6ea494129 100644 --- a/client/src/app/shared/shared-main/angular/index.ts +++ b/client/src/app/shared/shared-main/angular/index.ts @@ -1,3 +1,4 @@ +export * from './auto-colspan.directive' export * from './autofocus.directive' export * from './bytes.pipe' export * from './defer-loading.directive' diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts index 0bdf27263..d3ec31d6e 100644 --- a/client/src/app/shared/shared-main/shared-main.module.ts +++ b/client/src/app/shared/shared-main/shared-main.module.ts @@ -18,6 +18,7 @@ import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client' import { SharedGlobalIconModule } from '../shared-icons' import { AccountService, SignupLabelComponent } from './account' import { + AutoColspanDirective, AutofocusDirective, BytesPipe, DeferLoadingDirective, @@ -89,6 +90,7 @@ import { VideoChannelService } from './video-channel' DurationFormatterPipe, AutofocusDirective, DeferLoadingDirective, + AutoColspanDirective, InfiniteScrollerDirective, PeerTubeTemplateDirective, @@ -150,6 +152,7 @@ import { VideoChannelService } from './video-channel' DurationFormatterPipe, AutofocusDirective, DeferLoadingDirective, + AutoColspanDirective, InfiniteScrollerDirective, PeerTubeTemplateDirective, diff --git a/client/src/app/shared/shared-moderation/account-blocklist.component.html b/client/src/app/shared/shared-moderation/account-blocklist.component.html index 8cf9aa4c9..609a8cecd 100644 --- a/client/src/app/shared/shared-moderation/account-blocklist.component.html +++ b/client/src/app/shared/shared-moderation/account-blocklist.component.html @@ -49,7 +49,7 @@ - +
No account found matching current filters. No account found. diff --git a/client/src/app/shared/shared-moderation/server-blocklist.component.html b/client/src/app/shared/shared-moderation/server-blocklist.component.html index 1a13e0207..a98333339 100644 --- a/client/src/app/shared/shared-moderation/server-blocklist.component.html +++ b/client/src/app/shared/shared-moderation/server-blocklist.component.html @@ -51,7 +51,7 @@ - +
No server found matching current filters. No server found. -- 2.41.0