ActivityPub-federated video streaming platform using P2P directly in your web browser
Refactor primeng table
Chocobozzz03425e10d303
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.htmlindex 609f935306..6a8ca43519 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@@ -1,77 +1,56 @@-<p-table- [value]="followers" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order"- [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [(selection)]="selectedRows"+<my-table+ #table+ key="FollowersListComponent"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="followers per page"+ [dataLoader]="dataLoader"+ columnConfig="false"+ [bulkActions]="bulkActions">- <ng-template #caption>- <div class="caption">- <div class="left-buttons">- <my-action-dropdown- *ngIf="isInSelectionMode()" i18n-label label="Batch actions" theme="primary"- [actions]="bulkActions" [entry]="selectedRows"- >- </my-action-dropdown>- </div>-- <div class="ms-auto">- <my-advanced-input-filter [filters]="searchFilters" (search)="onSearch($event)"></my-advanced-input-filter>- </div>- </div>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No follower} =1 {1 follower} other {{{ totalRecords | myNumberFormatter }} followers}}</ng-container></ng-template>- <ng-template #header>- <tr>- <th class="checkbox-cell" scope="col" style="width: 40px">- <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>- </th>- <th scope="col" style="width: 150px;" i18n>Actions</th>- <th scope="col" i18n>Follower</th>- <th scope="col" style="width: 100px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th>- <th scope="col" style="width: 150px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="score">Link health <p-sortIcon field="score"></p-sortIcon></th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>- </tr>+ <ng-template #captionRight>+ <my-advanced-input-filter [filters]="searchFilters" (search)="table.onSearch($event)"></my-advanced-input-filter></ng-template>- <ng-template #body let-follow>- <tr>- <td class="checkbox-cell">- <p-tableCheckbox [value]="follow" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>- </td>-- <td class="action-cell">- <my-button *ngIf="follow.state !== 'accepted'" i18n-title title="Accept" icon="tick" (click)="acceptFollower([ follow ])"></my-button>- <my-button *ngIf="follow.state !== 'rejected'" i18n-title title="Reject" icon="cross" (click)="rejectFollower([ follow ])"></my-button>-- <my-delete-button *ngIf="follow.state === 'rejected'" (click)="deleteFollowers([ follow ])"></my-delete-button>- </td>- <td>- <a [href]="follow.follower.url" i18n-title title="Open actor page in a new tab" target="_blank" rel="noopener noreferrer">- {{ buildFollowerName(follow) }}- <my-global-icon iconName="external-link"></my-global-icon>- </a>- </td>+ <ng-template #tableCells let-follow>+ <td>+ <a [href]="follow.follower.url" i18n-title title="Open actor page in a new tab" target="_blank" rel="noopener noreferrer">+ {{ buildFollowerName(follow) }}+ <my-global-icon iconName="external-link"></my-global-icon>+ </a>+ </td>++ <td>+ @if (follow.state === 'accepted') {+ <span class="pt-badge badge-green" i18n>Accepted</span>+ } @else if (follow.state === 'pending') {+ <span class="pt-badge badge-yellow" i18n>Pending</span>+ } @else if (follow.state === 'rejected') {+ <span class="pt-badge badge-red" i18n>Rejected</span>+ }+ </td>++ <td>{{ follow.score / 10000 * 100 }}%</td>+ <td>{{ follow.createdAt | ptDate: 'short' }}</td>+ </ng-template>- <td>- <span *ngIf="follow.state === 'accepted'" class="pt-badge badge-green" i18n>Accepted</span>- <span *ngIf="follow.state === 'pending'" class="pt-badge badge-yellow" i18n>Pending</span>- <span *ngIf="follow.state === 'rejected'" class="pt-badge badge-red" i18n>Rejected</span>- </td>+ <ng-template #actionCell let-follow>+ <my-button *ngIf="follow.state !== 'accepted'" i18n-title title="Accept" icon="tick" (click)="acceptFollower([ follow ])"></my-button>+ <my-button *ngIf="follow.state !== 'rejected'" i18n-title title="Reject" icon="cross" (click)="rejectFollower([ follow ])"></my-button>- <td>{{ follow.score / 10000 * 100 }}</td>- <td>{{ follow.createdAt | ptDate: 'short' }}</td>- </tr>+ <my-delete-button *ngIf="follow.state === 'rejected'" (click)="deleteFollowers([ follow ])"></my-delete-button></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container *ngIf="search" i18n>No follower found matching current filters.</ng-container>- <ng-container *ngIf="!search" i18n>Your instance doesn't have any follower.</ng-container>- </div>- </td>- </tr>+ <ng-template #noResults let-search>+ @if (search) {+ <ng-container i18n>No follower found matching current filters.</ng-container>+ } @else {+ <ng-container i18n>Your instance doesn't have any follower.</ng-container>+ }</ng-template>-</p-table>+</my-table>+diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.scss b/client/src/app/+admin/follows/followers-list/followers-list.component.scssindex c442dca4c8..25189c5bcc 100644--- a/client/src/app/+admin/follows/followers-list/followers-list.component.scss+++ b/client/src/app/+admin/follows/followers-list/followers-list.component.scss@@ -1,11 +1,5 @@-@use '_variables' as *;-@use '_mixins' as *;--.action-cell {- my-button:first-child {- @include margin-right(10px);- }-}+@use "_variables" as *;+@use "_mixins" as *;my-delete-button {max-width: 130px;diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.tsindex 341d7e19ae..f47091cc89 100644--- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts+++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts@@ -1,55 +1,58 @@-import { NgIf } from '@angular/common'-import { Component, OnInit, inject } from '@angular/core'-import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'+import { CommonModule } from '@angular/common'+import { Component, OnInit, inject, viewChild } from '@angular/core'+import { ConfirmService, Notifier } from '@app/core'import { formatICU } from '@app/helpers'import { InstanceFollowService } from '@app/shared/shared-instance/instance-follow.service'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '@app/shared/shared-tables/table.component'import { ActorFollow } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'-import { ActionDropdownComponent, DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'+import { DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'import { DeleteButtonComponent } from '../../../shared/shared-main/buttons/delete-button.component'-import { AutoColspanDirective } from '../../../shared/shared-main/common/auto-colspan.directive'+import { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'@Component({selector: 'my-followers-list',templateUrl: './followers-list.component.html',styleUrls: [ './followers-list.component.scss' ],imports: [+ CommonModule,GlobalIconComponent,- TableModule,- SharedModule,- NgIf,- ActionDropdownComponent,AdvancedInputFilterComponent,- NgbTooltip,ButtonComponent,DeleteButtonComponent,- AutoColspanDirective,- PTDatePipe+ PTDatePipe,+ NumberFormatterPipe,+ TableComponent]})-export class FollowersListComponent extends RestTable<ActorFollow> implements OnInit {+export class FollowersListComponent implements OnInit {private confirmService = inject(ConfirmService)private notifier = inject(Notifier)private followService = inject(InstanceFollowService)- followers: ActorFollow[] = []- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<ActorFollow>>('table')searchFilters: AdvancedInputFilter[] = []bulkActions: DropdownAction<ActorFollow[]>[] = []- ngOnInit () {- this.initialize()+ columns: TableColumnInfo<string>[] = [+ { id: 'follower', label: $localize`Follower`, sortable: false },+ { id: 'state', label: $localize`State`, sortable: true },+ { id: 'score', label: $localize`Reliability`, sortable: true },+ { id: 'createdAt', label: $localize`Created`, sortable: true }+ ]++ dataLoader: typeof this._dataLoader+ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }++ ngOnInit () {this.searchFilters = this.followService.buildFollowsListFilters()this.bulkActions = [@@ -71,10 +74,6 @@ export class FollowersListComponent extends RestTable<ActorFollow> implements On]}- getIdentifier () {- return 'FollowersListComponent'- }-acceptFollower (follows: ActorFollow[]) {this.followService.acceptFollower(follows).subscribe({@@ -85,7 +84,7 @@ export class FollowersListComponent extends RestTable<ActorFollow> implements On)this.notifier.success(message)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -110,7 +109,7 @@ export class FollowersListComponent extends RestTable<ActorFollow> implements On)this.notifier.success(message)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -141,7 +140,7 @@ export class FollowersListComponent extends RestTable<ActorFollow> implements Onthis.notifier.success(message)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -152,15 +151,9 @@ export class FollowersListComponent extends RestTable<ActorFollow> implements Onreturn follow.follower.name + '@' + follow.follower.host}- protected reloadDataInternal () {- this.followService.getFollowers({ pagination: this.pagination, sort: this.sort, search: this.search })- .subscribe({- next: resultList => {- this.followers = resultList.data- this.totalRecords = resultList.total- },+ private _dataLoader (options: DataLoaderOptions) {+ const { pagination, sort, search } = options- error: err => this.notifier.error(err.message)- })+ return this.followService.getFollowers({ pagination, sort, search })}}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.htmlindex b7df57a3fc..a39a70853b 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@@ -1,88 +1,62 @@-<p-table- [value]="following" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order"- [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [(selection)]="selectedRows"+<my-table+ #table+ key="FollowingListComponent"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="subscriptions per page"+ [dataLoader]="dataLoader"+ columnConfig="false"+ [bulkActions]="bulkActions">- <ng-template #caption>- <div class="caption">- <div class="left-buttons">- <my-action-dropdown- *ngIf="isInSelectionMode()" i18n-label label="Batch actions" theme="primary"- [actions]="bulkActions" [entry]="selectedRows"- >- </my-action-dropdown>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No subscription} =1 {1 subscription} other {{{ totalRecords | myNumberFormatter }} subscriptions}}</ng-container>+ </ng-template>- <button *ngIf="!isInSelectionMode()" class="peertube-create-button" (click)="openFollowModal()">- <my-global-icon iconName="following" aria-hidden="true"></my-global-icon>- <ng-container i18n>Follow</ng-container>- </button>- </div>+ <ng-template #captionRight>+ <my-advanced-input-filter [filters]="searchFilters" (search)="table.onSearch($event)"></my-advanced-input-filter>- <div class="ms-auto d-flex gap-2 flex-wrap">- <my-advanced-input-filter [filters]="searchFilters" (search)="onSearch($event)"></my-advanced-input-filter>+ <my-button i18n-label label="Refresh" icon="refresh" (click)="table.loadData()"></my-button>- <my-button i18n-label label="Refresh" icon="refresh" (click)="reloadData()"></my-button>- </div>- </div>+ <button class="peertube-create-button" (click)="openFollowModal()">+ <my-global-icon iconName="following" aria-hidden="true"></my-global-icon>+ <ng-container i18n>Follow</ng-container>+ </button></ng-template>- <ng-template #header>- <tr>- <th class="checkbox-cell" scope="col" style="width: 40px">- <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>- </th>- <th scope="col" style="width: 150px;" i18n>Action</th>- <th scope="col" i18n>Following</th>- <th scope="col" style="width: 100px;" i18n pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th>- <th scope="col" style="width: 170px;" i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>- <th scope="col" style="width: 160px;" i18n pSortableColumn="redundancyAllowed">Redundancy allowed <p-sortIcon field="redundancyAllowed"></p-sortIcon></th>- </tr>+ <ng-template #tableCells let-follow>+ <td>+ <a [href]="follow.following.url" i18n-title title="Open instance in a new tab" target="_blank" rel="noopener noreferrer">+ {{ buildFollowingName(follow) }}+ <my-global-icon iconName="external-link"></my-global-icon>+ </a>+ </td>++ <td>+ <span *ngIf="follow.state === 'accepted'" class="pt-badge badge-green" i18n>Accepted</span>+ <span *ngIf="follow.state === 'pending'" class="pt-badge badge-yellow" i18n>Pending</span>+ <span *ngIf="follow.state === 'rejected'" class="pt-badge badge-red" i18n>Rejected</span>+ </td>++ <td>{{ follow.createdAt | ptDate: 'short' }}</td>+ <td>+ <my-redundancy-checkbox+ *ngIf="isInstanceFollowing(follow)"+ [host]="follow.following.host" [redundancyAllowed]="follow.following.hostRedundancyAllowed"+ ></my-redundancy-checkbox>+ </td></ng-template>- <ng-template #body let-follow>- <tr pSelectableRow="follow">- <td class="checkbox-cell">- <p-tableCheckbox [value]="follow" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>- </td>-- <td class="action-cell">- <my-delete-button label (click)="removeFollowing([ follow ])"></my-delete-button>- </td>- <td>- <a [href]="follow.following.url" i18n-title title="Open instance in a new tab" target="_blank" rel="noopener noreferrer">- {{ buildFollowingName(follow) }}- <my-global-icon iconName="external-link"></my-global-icon>- </a>- </td>-- <td>- <span *ngIf="follow.state === 'accepted'" class="pt-badge badge-green" i18n>Accepted</span>- <span *ngIf="follow.state === 'pending'" class="pt-badge badge-yellow" i18n>Pending</span>- <span *ngIf="follow.state === 'rejected'" class="pt-badge badge-red" i18n>Rejected</span>- </td>-- <td>{{ follow.createdAt | ptDate: 'short' }}</td>- <td>- <my-redundancy-checkbox- *ngIf="isInstanceFollowing(follow)"- [host]="follow.following.host" [redundancyAllowed]="follow.following.hostRedundancyAllowed"- ></my-redundancy-checkbox>- </td>- </tr>+ <ng-template #actionCell let-follow>+ <my-delete-button label (click)="removeFollowing([ follow ])"></my-delete-button></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container *ngIf="search" i18n>No host found matching current filters.</ng-container>- <ng-container *ngIf="!search" i18n>Your instance is not following anyone.</ng-container>- </div>- </td>- </tr>+ <ng-template #noResults let-search>+ @if (search) {+ <ng-container i18n>No host found matching current filters.</ng-container>+ } @else {+ <ng-container i18n>Your instance is not following anyone.</ng-container>+ }</ng-template>-</p-table>+</my-table><my-follow-modal #followModal></my-follow-modal>diff --git a/client/src/app/+admin/follows/following-list/following-list.component.scss b/client/src/app/+admin/follows/following-list/following-list.component.scssindex 89bde6b87d..25189c5bcc 100644--- a/client/src/app/+admin/follows/following-list/following-list.component.scss+++ b/client/src/app/+admin/follows/following-list/following-list.component.scss@@ -1,9 +1,5 @@-@use '_variables' as *;-@use '_mixins' as *;--a {- color: pvar(--fg);-}+@use "_variables" as *;+@use "_mixins" as *;my-delete-button {max-width: 130px;diff --git a/client/src/app/+admin/follows/following-list/following-list.component.ts b/client/src/app/+admin/follows/following-list/following-list.component.tsindex d63c5d61de..8a79cfb5b5 100644--- a/client/src/app/+admin/follows/following-list/following-list.component.ts+++ b/client/src/app/+admin/follows/following-list/following-list.component.ts@@ -1,18 +1,17 @@-import { NgIf } from '@angular/common'+import { CommonModule } from '@angular/common'import { Component, OnInit, inject, viewChild } from '@angular/core'-import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'+import { ConfirmService, Notifier } from '@app/core'import { formatICU } from '@app/helpers'import { InstanceFollowService } from '@app/shared/shared-instance/instance-follow.service'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { ActorFollow } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'-import { ActionDropdownComponent, DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'+import { DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'import { DeleteButtonComponent } from '../../../shared/shared-main/buttons/delete-button.component'-import { AutoColspanDirective } from '../../../shared/shared-main/common/auto-colspan.directive'+import { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'import { RedundancyCheckboxComponent } from '../shared/redundancy-checkbox.component'import { FollowModalComponent } from './follow-modal.component'@@ -20,39 +19,44 @@ import { FollowModalComponent } from './follow-modal.component'templateUrl: './following-list.component.html',styleUrls: [ './following-list.component.scss' ],imports: [+ CommonModule,GlobalIconComponent,- TableModule,- SharedModule,- NgIf,- ActionDropdownComponent,AdvancedInputFilterComponent,DeleteButtonComponent,RedundancyCheckboxComponent,- AutoColspanDirective,FollowModalComponent,PTDatePipe,- ButtonComponent+ ButtonComponent,+ TableComponent,+ NumberFormatterPipe]})-export class FollowingListComponent extends RestTable<ActorFollow> implements OnInit {+export class FollowingListComponent implements OnInit {private notifier = inject(Notifier)private confirmService = inject(ConfirmService)private followService = inject(InstanceFollowService)readonly followModal = viewChild<FollowModalComponent>('followModal')-- following: ActorFollow[] = []- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<ActorFollow>>('table')searchFilters: AdvancedInputFilter[] = []bulkActions: DropdownAction<ActorFollow[]>[] = []- ngOnInit () {- this.initialize()+ columns: TableColumnInfo<string>[] = [+ { id: 'following', label: $localize`Following`, sortable: false },+ { id: 'state', label: $localize`State`, sortable: true },+ { id: 'createdAt', label: $localize`Created`, sortable: true },+ { id: 'redundancyAllowed', label: $localize`Redundancy allowed`, sortable: true }+ ]++ dataLoader: typeof this._dataLoader+ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }++ ngOnInit () {this.searchFilters = this.followService.buildFollowsListFilters()this.bulkActions = [@@ -63,10 +67,6 @@ export class FollowingListComponent extends RestTable<ActorFollow> implements On]}- getIdentifier () {- return 'FollowingListComponent'- }-openFollowModal () {this.followModal().openModal()}@@ -99,22 +99,16 @@ export class FollowingListComponent extends RestTable<ActorFollow> implements On)this.notifier.success(message)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)})}- protected reloadDataInternal () {- this.followService.getFollowing({ pagination: this.pagination, sort: this.sort, search: this.search })- .subscribe({- next: resultList => {- this.following = resultList.data- this.totalRecords = resultList.total- },+ private _dataLoader (options: DataLoaderOptions) {+ const { pagination, sort, search } = options- error: err => this.notifier.error(err.message)- })+ return this.followService.getFollowing({ pagination, sort, search })}}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.htmlindex f872f26e8a..5a89faaa47 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@@ -1,87 +1,64 @@-<div class="admin-sub-header">- <div class="select-filter-block">- <label for="displayType" i18n>Display</label>-- <div class="peertube-select-container">- <select id="displayType" name="displayType" [(ngModel)]="displayType" (ngModelChange)="onDisplayTypeChanged()" class="form-control">- <option value="my-videos" i18n>My videos duplicated by remote instances</option>- <option value="remote-videos" i18n>Remote videos duplicated by my instance</option>- </select>- </div>- </div>-</div>--<p-table- [value]="videoRedundancies" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords"- [rows]="rowsPerPage" [first]="pagination.start" [rowsPerPageOptions]="rowsPerPageOptions"- [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id"- [expandedRowKeys]="expandedRows"+<my-table+ #table+ key="VideoRedundanciesListComponent"+ [defaultColumns]="columns"+ defaultSort="name"+ defaultSortOrder="asc"+ i18n-paginatorText+ paginatorText="redundancies per page"+ [dataLoader]="dataLoader"+ [customParseQueryParams]="customParseQueryParams"+ [customUpdateUrl]="customUpdateUrl"+ columnConfig="false">- <ng-template #header>- <tr>- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>- <th scope="col" style="width: 150px;" i18n>Action</th>- <th scope="col" style="width: 160px;" i18n *ngIf="isDisplayingRemoteVideos()">Strategy</th>- <th scope="col" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="name">Video <p-sortIcon field="name"></p-sortIcon></th >- <th scope="col" style="width: 100px;" i18n *ngIf="isDisplayingRemoteVideos()">Total size</th>- </tr>+<ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No redundancy} =1 {1 redundancy} other {{{ totalRecords | myNumberFormatter }} redundancies}}</ng-container></ng-template>- <ng-template #body let-expanded="expanded" let-redundancy>- <tr>- <td class="expand-cell">- <my-table-expander-icon [pRowToggler]="redundancy" [expanded]="expanded" i18n-tooltip tooltip="List redundancies"></my-table-expander-icon>- </td>+ <ng-template #captionRight>+ <div class="select-filter-block">+ <label for="displayType" i18n>Display</label>- <td class="action-cell">- <my-delete-button label (click)="removeRedundancy(redundancy)"></my-delete-button>- </td>+ <div class="peertube-select-container">+ <select id="displayType" name="displayType" [(ngModel)]="displayType" (ngModelChange)="onDisplayTypeChanged()" class="form-control">+ <option value="my-videos" i18n>My videos duplicated by remote instances</option>+ <option value="remote-videos" i18n>Remote videos duplicated by my instance</option>+ </select>+ </div>+ </div>+ </ng-template>- <td *ngIf="isDisplayingRemoteVideos()">{{ getRedundancyStrategy(redundancy) }}</td>+ <ng-template #tableCells let-redundancy>+ <td *ngIf="isDisplayingRemoteVideos()">{{ getRedundancyStrategy(redundancy) }}</td>- <td>- <a [href]="redundancy.url" i18n-title title="Open video in a new tab" target="_blank" rel="noopener noreferrer">- {{ redundancy.name }}- <my-global-icon iconName="external-link"></my-global-icon>- </a>- </td>+ <td>+ <a [href]="redundancy.url" i18n-title title="Open video in a new tab" target="_blank" rel="noopener noreferrer">+ {{ redundancy.name }}+ <my-global-icon iconName="external-link"></my-global-icon>+ </a>+ </td>- <td *ngIf="isDisplayingRemoteVideos()">{{ getTotalSize(redundancy) | bytes: 1 }}</td>- </tr>+ <td *ngIf="isDisplayingRemoteVideos()">{{ getTotalSize(redundancy) | bytes: 1 }}</td></ng-template>- <ng-template #expandedrow let-redundancy>- <tr *ngIf="redundancy.redundancies.files.length !== 0">- <td class="expand-cell" myAutoColspan>- <div *ngFor="let file of redundancy.redundancies.files" class="expansion-block">- <my-video-redundancy-information [redundancyElement]="file"></my-video-redundancy-information>- </div>- </td>- </tr>-- <tr *ngIf="redundancy.redundancies.streamingPlaylists.length !== 0">- <td class="expand-cell" myAutoColspan>- <div *ngFor="let playlist of redundancy.redundancies.streamingPlaylists">- <my-video-redundancy-information [redundancyElement]="playlist"></my-video-redundancy-information>- </div>- </td>- </tr>+ <ng-template #actionCell let-redundancy>+ <my-delete-button label (click)="removeRedundancy(redundancy)"></my-delete-button></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container *ngIf="isDisplayingRemoteVideos()" i18n>Your instance doesn't mirror any video.</ng-container>- <ng-container *ngIf="!isDisplayingRemoteVideos()" i18n>Your instance has no mirrored videos.</ng-container>- </div>- </td>- </tr>+ <ng-template #expandedRow let-redundancy>+ <div *ngFor="let playlist of redundancy.redundancies.streamingPlaylists">+ <my-video-redundancy-information [redundancyElement]="playlist"></my-video-redundancy-information>+ </div></ng-template>-</p-table>+ <ng-template #noResults>+ @if (isDisplayingRemoteVideos()) {+ <ng-container i18n>Your instance doesn't mirror any video.</ng-container>+ } @else {+ <ng-container i18n>Your instance has no mirrored videos.</ng-container>+ }+ </ng-template>+</my-table><div class="redundancies-charts" *ngIf="isDisplayingRemoteVideos() && dataLoaded"><h6 i18n>Enabled strategies stats</h6>diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.scss b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.scssindex bb88bb7261..e4a2fa3643 100644--- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.scss+++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.scss@@ -1,22 +1,6 @@-@use '_variables' as *;-@use '_mixins' as *;-@use '_form-mixins' as *;--a {- color: pvar(--fg);-}--.expansion-block {- margin-bottom: 20px;-}--.admin-sub-header {- justify-content: flex-end;-- .peertube-select-container {- @include peertube-select-container(auto);- }-}+@use "_variables" as *;+@use "_mixins" as *;+@use "_form-mixins" as *;.redundancies-charts {margin-top: 50px;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.tsindex 33daeea0b1..2ecbd91bd2 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@@ -1,55 +1,50 @@-import { NgFor, NgIf } from '@angular/common'-import { Component, OnInit, inject } from '@angular/core'+import { CommonModule } from '@angular/common'+import { Component, OnInit, inject, viewChild } from '@angular/core'import { FormsModule } from '@angular/forms'-import { ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'+import { ConfirmService, Notifier, ServerService } from '@app/core'import { BytesPipe } from '@app/shared/shared-main/common/bytes.pipe'import { RedundancyService } from '@app/shared/shared-main/video/redundancy.service'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { VideoRedundanciesTarget, VideoRedundancy, VideosRedundancyStats } from '@peertube/peertube-models'import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'import { ChartData, ChartOptions, TooltipItem } from 'chart.js'-import { SharedModule, SortMeta } from 'primeng/api'import { ChartModule } from 'primeng/chart'-import { TableModule } from 'primeng/table'+import { tap } from 'rxjs'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'import { DeleteButtonComponent } from '../../../shared/shared-main/buttons/delete-button.component'-import { AutoColspanDirective } from '../../../shared/shared-main/common/auto-colspan.directive'-import { TableExpanderIconComponent } from '../../../shared/shared-tables/table-expander-icon.component'+import { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent, TableQueryParams } from '../../../shared/shared-tables/table.component'import { VideoRedundancyInformationComponent } from './video-redundancy-information.component'+type QueryParams = TableQueryParams & {+ displayType: VideoRedundanciesTarget+}+@Component({selector: 'my-video-redundancies-list',templateUrl: './video-redundancies-list.component.html',styleUrls: [ './video-redundancies-list.component.scss' ],imports: [+ CommonModule,GlobalIconComponent,FormsModule,- TableModule,- SharedModule,- NgIf,- NgbTooltip,- TableExpanderIconComponent,DeleteButtonComponent,- AutoColspanDirective,- NgFor,VideoRedundancyInformationComponent,ChartModule,- BytesPipe+ BytesPipe,+ TableComponent,+ NumberFormatterPipe]})-export class VideoRedundanciesListComponent extends RestTable implements OnInit {+export class VideoRedundanciesListComponent implements OnInit {+ private static LS_DISPLAY_TYPE = 'video-redundancies-list-display-type'+private notifier = inject(Notifier)private confirmService = inject(ConfirmService)private redundancyService = inject(RedundancyService)private serverService = inject(ServerService)- private static LS_DISPLAY_TYPE = 'video-redundancies-list-display-type'-- videoRedundancies: VideoRedundancy[] = []- totalRecords = 0+ readonly table = viewChild<TableComponent<VideoRedundancy>>('table')- sort: SortMeta = { field: 'name', order: 1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }displayType: VideoRedundanciesTarget = 'my-videos'redundanciesGraphsData: { stats: VideosRedundancyStats, graphData: ChartData, options: ChartOptions, ariaLabel: string }[] = []@@ -61,20 +56,22 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInitprivate bytesPipe: BytesPipe- constructor () {- super()+ columns: TableColumnInfo<string>[]- this.bytesPipe = new BytesPipe()- }+ dataLoader: typeof this._dataLoader+ customUpdateUrl: typeof this._customUpdateUrl+ customParseQueryParams: typeof this._customParseQueryParams- getIdentifier () {- return 'VideoRedundanciesListComponent'+ constructor () {+ this.bytesPipe = new BytesPipe()+ this.customUpdateUrl = this._customUpdateUrl.bind(this)+ this.customParseQueryParams = this._customParseQueryParams.bind(this)+ this.dataLoader = this._dataLoader.bind(this)}ngOnInit () {this.loadSelectLocalStorage()-- this.initialize()+ this.buildColumns()this.serverService.getServerStats().subscribe(res => {@@ -97,10 +94,12 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit}onDisplayTypeChanged () {- this.pagination.start = 0+ this.dataLoaded = false+this.saveSelectLocalStorage()+ this.buildColumns()- this.reloadData()+ this.table().reloadData()}getRedundancyStrategy (redundancy: VideoRedundancy) {@@ -179,33 +178,42 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit.subscribe({next: () => {this.notifier.success($localize`Video redundancies removed!`)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)})}- protected reloadDataInternal () {- this.dataLoaded = false+ private _dataLoader (options: DataLoaderOptions) {+ return this.redundancyService.listVideoRedundancies({ ...options, target: this.displayType })+ .pipe(tap(() => this.dataLoaded = true))+ }- const options = {- pagination: this.pagination,- sort: this.sort,- target: this.displayType+ private _customUpdateUrl (): Partial<QueryParams> {+ return {+ displayType: this.displayType}+ }- this.redundancyService.listVideoRedundancies(options)- .subscribe({- next: resultList => {- this.videoRedundancies = resultList.data- this.totalRecords = resultList.total+ private _customParseQueryParams (queryParams: QueryParams) {+ if (queryParams.displayType) {+ this.displayType = queryParams.displayType+ }+ }- this.dataLoaded = true- },+ private buildColumns () {+ this.columns = [ { id: 'name', label: $localize`Name`, sortable: true } ]- error: err => this.notifier.error(err.message)- })+ if (this.isDisplayingRemoteVideos()) {+ this.columns = [+ { id: 'strategy', label: $localize`Strategy`, sortable: false },++ ...this.columns,++ { id: 'totalSize', label: $localize`Total size`, sortable: false }+ ]+ }}private loadSelectLocalStorage () {diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.html b/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.htmlindex 2b94ae2e0c..3ffdee582b 100644--- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.html+++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.html@@ -1,19 +1,19 @@<div>- <span class="label">Url</span>+ <strong>Url</strong><a target="_blank" rel="noopener noreferrer" [href]="redundancyElement().fileUrl">{{ redundancyElement().fileUrl }}</a></div><div>- <span class="label">Created on</span>+ <strong>Created on</strong><span>{{ redundancyElement().createdAt | ptDate: 'medium' }}</span></div><div>- <span class="label">Expires on</span>+ <strong>Expires on</strong><span>{{ redundancyElement().expiresOn | ptDate: 'medium' }}</span></div><div>- <span class="label">Size</span>+ <strong>Size</strong><span>{{ redundancyElement().size | bytes: 1 }}</span></div>diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.scss b/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.scssindex c96199bdbe..32ea09083c 100644--- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.scss+++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.scss@@ -1,8 +1,9 @@-@use '_variables' as *;-@use '_mixins' as *;+@use "_variables" as *;+@use "_mixins" as *;-.label {+strong {display: inline-block;min-width: 100px;font-weight: $font-semibold;+ color: pvar(--fg-300);}diff --git a/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts b/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.tsindex a2ba4b63d6..936a03d5b0 100644--- a/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts+++ b/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts@@ -1,34 +1,14 @@-import { NgIf } from '@angular/common'import { Component } from '@angular/core'-import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'-import { GenericAccountBlocklistComponent } from '@app/shared/shared-moderation/account-blocklist.component'import { BlocklistComponentType } from '@app/shared/shared-moderation/blocklist.service'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'-import { SharedModule } from 'primeng/api'-import { TableModule } from 'primeng/table'-import { ActorAvatarComponent } from '../../../shared/shared-actor-image/actor-avatar.component'-import { AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'-import { AutoColspanDirective } from '../../../shared/shared-main/common/auto-colspan.directive'+import { GenericAccountBlocklistComponent } from '@app/shared/shared-moderation/generic-account-blocklist.component'@Component({selector: 'my-instance-account-blocklist',- styleUrls: [ '../../../shared/shared-moderation/moderation.scss' ],- templateUrl: '../../../shared/shared-moderation/account-blocklist.component.html',+ template: `<my-generic-account-blocklist [mode]="mode" key="InstanceAccountBlocklistComponent" />`,imports: [- TableModule,- SharedModule,- AdvancedInputFilterComponent,- NgbTooltip,- ActorAvatarComponent,- AutoColspanDirective,- NgIf,- PTDatePipe+ GenericAccountBlocklistComponent]})-export class InstanceAccountBlocklistComponent extends GenericAccountBlocklistComponent {+export class InstanceAccountBlocklistComponent {mode = BlocklistComponentType.Instance-- getIdentifier () {- return 'InstanceAccountBlocklistComponent'- }}diff --git a/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.tsindex 02b4f72c76..0f542e889f 100644--- a/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts+++ b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts@@ -1,36 +1,14 @@-import { NgIf } from '@angular/common'import { Component } from '@angular/core'-import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { BlocklistComponentType } from '@app/shared/shared-moderation/blocklist.service'-import { GenericServerBlocklistComponent } from '@app/shared/shared-moderation/server-blocklist.component'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'-import { SharedModule } from 'primeng/api'-import { TableModule } from 'primeng/table'-import { AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'-import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'-import { AutoColspanDirective } from '../../../shared/shared-main/common/auto-colspan.directive'-import { BatchDomainsModalComponent } from '../../../shared/shared-moderation/batch-domains-modal.component'+import { GenericServerBlocklistComponent } from '../../../shared/shared-moderation/generic-server-blocklist.component'@Component({selector: 'my-instance-server-blocklist',- styleUrls: [ '../../../shared/shared-moderation/server-blocklist.component.scss' ],- templateUrl: '../../../shared/shared-moderation/server-blocklist.component.html',+ template: `<my-generic-server-blocklist [mode]="mode" key="InstanceServerBlocklistComponent" />`,imports: [- GlobalIconComponent,- TableModule,- SharedModule,- AdvancedInputFilterComponent,- NgbTooltip,- AutoColspanDirective,- NgIf,- BatchDomainsModalComponent,- PTDatePipe+ GenericServerBlocklistComponent]})-export class InstanceServerBlocklistComponent extends GenericServerBlocklistComponent {+export class InstanceServerBlocklistComponent {mode = BlocklistComponentType.Instance-- getIdentifier () {- return 'InstanceServerBlocklistComponent'- }}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.htmlindex 7bdbe0f9f5..4d67e03c00 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@@ -1,139 +1,97 @@-<p-table- [value]="registrations" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id"- [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false"- [(selection)]="selectedRows" [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [expandedRowKeys]="expandedRows"+<my-table+ #table+ key="RegistrationListComponent"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="registrations per page"+ [dataLoader]="dataLoader"+ columnConfig="true"+ [bulkActions]="bulkActions">- <ng-template #caption>- <div class="caption">- <div class="left-buttons">- <my-action-dropdown- *ngIf="isInSelectionMode()" i18n-label label="Batch actions" theme="primary"- [actions]="bulkActions" [entry]="selectedRows"- >- </my-action-dropdown>- </div>-- <div class="ms-auto">- <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter>- </div>- </div>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No registration} =1 {1 registration} other {{{ totalRecords | myNumberFormatter }} registrations}}</ng-container></ng-template>- <ng-template #header>- <tr> <!-- header -->- <th class="checkbox-cell" scope="col" style="width: 40px">- <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>- </th>- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>- <th scope="col" style="width: 150px;">- <span i18n class="visually-hidden">Actions</span>- </th>- <th scope="col" i18n>Account</th>- <th scope="col" i18n>Email</th>- <th scope="col" i18n>Channel</th>- <th scope="col" i18n>Registration reason</th>- <th scope="col" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="state" style="width: 80px;">State <p-sortIcon field="state"></p-sortIcon></th>- <th scope="col" i18n>Moderation response</th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Requested on <p-sortIcon field="createdAt"></p-sortIcon></th>- </tr>+ <ng-template #captionRight>+ <my-advanced-input-filter (search)="table.onSearch($event)"></my-advanced-input-filter></ng-template>- <ng-template #body let-expanded="expanded" let-registration>- <tr [pSelectableRow]="registration">- <td class="checkbox-cell">- <p-tableCheckbox [value]="registration" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>- </td>-- <td class="expand-cell">- <my-table-expander-icon [pRowToggler]="registration" [expanded]="expanded"></my-table-expander-icon>- </td>-- <td class="action-cell">- <my-action-dropdown- [ngClass]="{ 'show': expanded }" placement="bottom-right top-right left auto" container="body"- i18n-label label="Actions" [actions]="registrationActions" [entry]="registration" buttonSize="small"- ></my-action-dropdown>- </td>-- <td>- <div class="chip two-lines">- <div>- <span>{{ registration.username }}</span>- <span class="muted">{{ registration.accountDisplayName }}</span>- </div>+ <ng-template #tableCells let-registration>+ <td *ngIf="table.isColumnDisplayed('account')">+ <div class="chip two-lines">+ <div>+ <span>{{ registration.username }}</span>+ <span class="muted">{{ registration.accountDisplayName }}</span></div>- </td>+ </div>+ </td>- <td>- <my-user-email-info [entry]="registration" [showEmailVerifyInformation]="requiresEmailVerification"></my-user-email-info>- </td>+ <td *ngIf="table.isColumnDisplayed('email')">+ <my-user-email-info [entry]="registration" [showEmailVerifyInformation]="requiresEmailVerification"></my-user-email-info>+ </td>- <td>- <div class="chip two-lines">- <div>- <span>{{ registration.channelHandle }}</span>- <span class="muted">{{ registration.channelDisplayName }}</span>- </div>+ <td *ngIf="table.isColumnDisplayed('channel')">+ <div class="chip two-lines">+ <div>+ <span>{{ registration.channelHandle }}</span>+ <span class="muted">{{ registration.channelDisplayName }}</span></div>- </td>-- <td container="body" placement="left auto" [ngbTooltip]="registration.registrationReason">- {{ registration.registrationReason }}- </td>+ </div>+ </td>- <td class="c-hand abuse-states" [pRowToggler]="registration">+ <td *ngIf="table.isColumnDisplayed('registrationReason')" class="max-width-300px" container="body" placement="left auto" [ngbTooltip]="registration.registrationReason">+ {{ registration.registrationReason }}+ </td>- <div *ngIf="isRegistrationAccepted(registration)" [title]="registration.state.label" class="pt-badge badge-success">+ <td *ngIf="table.isColumnDisplayed('state')" class="abuse-states">+ @if (isRegistrationAccepted(registration)) {+ <div [title]="registration.state.label" class="pt-badge badge-success"><my-global-icon iconName="tick"></my-global-icon></div>-- <div *ngIf="isRegistrationRejected(registration)" [title]="registration.state.label" class="pt-badge badge-danger">+ } @else if (isRegistrationRejected(registration)) {+ <div [title]="registration.state.label" class="pt-badge badge-danger"><my-global-icon iconName="cross"></my-global-icon></div>- </td>+ }+ </td>- <td container="body" placement="left auto" [ngbTooltip]="registration.moderationResponse">- {{ registration.moderationResponse }}- </td>+ <td *ngIf="table.isColumnDisplayed('moderationResponse')" class="max-width-300px" container="body" placement="left auto" [ngbTooltip]="registration.moderationResponse">+ {{ registration.moderationResponse }}+ </td>- <td class="c-hand" [pRowToggler]="registration">{{ registration.createdAt | ptDate: 'short' }}</td>- </tr>+ <td *ngIf="table.isColumnDisplayed('createdAt')">{{ registration.createdAt | ptDate: 'short' }}</td></ng-template>- <ng-template #expandedrow let-registration>- <tr>- <td myAutoColspan>- <div class="moderation-expanded">- <div class="left">- <div class="d-flex">- <span class="moderation-expanded-label" i18n>Registration reason:</span>- <span class="moderation-expanded-text" [innerHTML]="registration.registrationReasonHTML"></span>- </div>+ <ng-template #actionCell let-registration>+ <my-action-dropdown+ placement="bottom-right top-right left auto" container="body"+ i18n-label label="Actions" [actions]="registrationActions" [entry]="registration"+ ></my-action-dropdown>+ </ng-template>- <div *ngIf="registration.moderationResponse">- <span class="moderation-expanded-label" i18n>Moderation response:</span>- <span class="moderation-expanded-text" [innerHTML]="registration.moderationResponseHTML"></span>- </div>- </div>+ <ng-template #expandedRow let-registration>+ <div class="moderation-expanded">+ <div class="left">+ <div class="d-flex">+ <span class="moderation-expanded-label" i18n>Registration reason:</span>+ <span class="moderation-expanded-text" [innerHTML]="registration.registrationReasonHTML"></span></div>- </td>- </tr>- </ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container *ngIf="search" i18n>No registrations found matching current filters.</ng-container>- <ng-container *ngIf="!search" i18n>No registrations found.</ng-container>+ <div *ngIf="registration.moderationResponse">+ <span class="moderation-expanded-label" i18n>Moderation response:</span>+ <span class="moderation-expanded-text" [innerHTML]="registration.moderationResponseHTML"></span></div>- </td>- </tr>+ </div>+ </div>+ </ng-template>++ <ng-template #noResults let-search>+ @if (search) {+ <ng-container i18n>No registrations found matching current filters.</ng-container>+ } @else {+ <ng-container i18n>No registrations found.</ng-container>+ }</ng-template>-</p-table>+</my-table><my-process-registration-modal #processRegistrationModal (registrationProcessed)="onRegistrationProcessed()"></my-process-registration-modal>diff --git a/client/src/app/+admin/moderation/registration-list/registration-list.component.ts b/client/src/app/+admin/moderation/registration-list/registration-list.component.tsindex 4bfb9c32de..490807829c 100644--- a/client/src/app/+admin/moderation/registration-list/registration-list.component.ts+++ b/client/src/app/+admin/moderation/registration-list/registration-list.component.ts@@ -1,43 +1,42 @@-import { NgClass, NgIf } from '@angular/common'+import { CommonModule } from '@angular/common'import { Component, OnInit, inject, viewChild } from '@angular/core'import { ActivatedRoute, Router } from '@angular/router'-import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'+import { ConfirmService, MarkdownService, Notifier, ServerService } from '@app/core'import { formatICU } from '@app/helpers'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'-import { UserRegistration, UserRegistrationState } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'+import { ResultList, UserRegistration as UserRegistrationServer, UserRegistrationState } from '@peertube/peertube-models'+import { switchMap } from 'rxjs'import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'import { ActionDropdownComponent, DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'-import { AutoColspanDirective } from '../../../shared/shared-main/common/auto-colspan.directive'-import { TableExpanderIconComponent } from '../../../shared/shared-tables/table-expander-icon.component'+import { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'import { UserEmailInfoComponent } from '../../shared/user-email-info.component'import { AdminRegistrationService } from './admin-registration.service'import { ProcessRegistrationModalComponent } from './process-registration-modal.component'+type UserRegistration = UserRegistrationServer & { registrationReasonHTML?: string, moderationResponseHTML?: string }+type ColumnName = 'account' | 'email' | 'channel' | 'registrationReason' | 'state' | 'moderationResponse' | 'createdAt'+@Component({selector: 'my-registration-list',templateUrl: './registration-list.component.html',styleUrls: [ '../../../shared/shared-moderation/moderation.scss', './registration-list.component.scss' ],imports: [GlobalIconComponent,- TableModule,- SharedModule,- NgIf,+ CommonModule,ActionDropdownComponent,AdvancedInputFilterComponent,NgbTooltip,- TableExpanderIconComponent,- NgClass,UserEmailInfoComponent,- AutoColspanDirective,ProcessRegistrationModalComponent,- PTDatePipe+ PTDatePipe,+ NumberFormatterPipe,+ TableComponent]})-export class RegistrationListComponent extends RestTable<UserRegistration> implements OnInit {+export class RegistrationListComponent implements OnInit {protected route = inject(ActivatedRoute)protected router = inject(Router)private server = inject(ServerService)@@ -47,11 +46,7 @@ export class RegistrationListComponent extends RestTable<UserRegistration> impleprivate adminRegistrationService = inject(AdminRegistrationService)readonly processRegistrationModal = viewChild<ProcessRegistrationModalComponent>('processRegistrationModal')-- registrations: (UserRegistration & { registrationReasonHTML?: string, moderationResponseHTML?: string })[] = []- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<UserRegistration, ColumnName>>('table')registrationActions: DropdownAction<UserRegistration>[][] = []bulkActions: DropdownAction<UserRegistration[]>[] = []@@ -60,8 +55,20 @@ export class RegistrationListComponent extends RestTable<UserRegistration> implerequiresEmailVerification: boolean+ columns: TableColumnInfo<ColumnName>[] = [+ { id: 'account', label: $localize`Account`, sortable: false },+ { id: 'email', label: $localize`Email`, sortable: false },+ { id: 'channel', label: $localize`Channel`, sortable: false },+ { id: 'registrationReason', label: $localize`Registration reason`, sortable: false },+ { id: 'state', label: $localize`State`, sortable: true },+ { id: 'moderationResponse', label: $localize`Moderation response`, sortable: false },+ { id: 'createdAt', label: $localize`Requested on`, sortable: true }+ ]++ dataLoader: typeof this._dataLoader+constructor () {- super()+ this.dataLoader = this._dataLoader.bind(this)this.registrationActions = [[@@ -92,18 +99,12 @@ export class RegistrationListComponent extends RestTable<UserRegistration> imple}ngOnInit () {- this.initialize()-this.server.getConfig().subscribe(config => {this.requiresEmailVerification = config.signup.requiresEmailVerification})}- getIdentifier () {- return 'RegistrationListComponent'- }-isRegistrationAccepted (registration: UserRegistration) {return registration.state.id === UserRegistrationState.ACCEPTED}@@ -113,27 +114,21 @@ export class RegistrationListComponent extends RestTable<UserRegistration> imple}onRegistrationProcessed () {- this.reloadData()+ this.table().reloadData({ field: 'createdAt', order: -1 })}- protected reloadDataInternal () {- this.adminRegistrationService.listRegistrations({- pagination: this.pagination,- sort: this.sort,- search: this.search- }).subscribe({- next: async resultList => {- this.totalRecords = resultList.total- this.registrations = resultList.data-- for (const registration of this.registrations) {- registration.registrationReasonHTML = await this.toHtml(registration.registrationReason)- registration.moderationResponseHTML = await this.toHtml(registration.moderationResponse)- }- },-- error: err => this.notifier.error(err.message)- })+ private _dataLoader (options: DataLoaderOptions) {+ return this.adminRegistrationService.listRegistrations(options)+ .pipe(+ switchMap(async (resultList: ResultList<UserRegistration>) => {+ for (const registration of resultList.data) {+ registration.registrationReasonHTML = await this.toHtml(registration.registrationReason)+ registration.moderationResponseHTML = await this.toHtml(registration.moderationResponse)+ }++ return resultList+ })+ )}private openRegistrationRequestProcessModal (registration: UserRegistration, mode: 'accept' | 'reject') {@@ -160,7 +155,7 @@ export class RegistrationListComponent extends RestTable<UserRegistration> imple)this.notifier.success(message)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)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.htmlindex 11b95c994f..23946f0cd6 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@@ -1,102 +1,70 @@-<p-table- [value]="blocklist" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id"- [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [expandedRowKeys]="expandedRows"+<my-table+ #table+ key="VideoBlockListComponent"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="videos per page"+ [dataLoader]="dataLoader"+ columnConfig="false">- <ng-template #caption>- <div class="caption">- <div class="ms-auto">- <my-advanced-input-filter [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter>- </div>- </div>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No video} =1 {1 video} other {{{ totalRecords | myNumberFormatter }} videos}}</ng-container></ng-template>- <ng-template #header>- <tr>- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>- <th scope="col" style="width: 150px;">- <span i18n class="visually-hidden">Actions</span>- </th>- <th scope="col" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="name">Video <p-sortIcon field="name"></p-sortIcon></th>- <th scope="col" style="width: 100px;" i18n>Sensitive</th>- <th scope="col" style="width: 120px;" i18n>Unfederated</th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Date <p-sortIcon field="createdAt"></p-sortIcon></th>- </tr>+ <ng-template #captionRight>+ <my-advanced-input-filter [filters]="inputFilters" (search)="table.onSearch($event)"></my-advanced-input-filter></ng-template>- <ng-template #body let-videoBlock let-expanded="expanded">- <tr>- <td *ngIf="!videoBlock.reason">- <span i18n class="visually-hidden">No more information is available for this row</span>- </td>-- <td class="expand-cell" *ngIf="videoBlock.reason" >- <my-table-expander-icon [pRowToggler]="videoBlock" [expanded]="expanded"></my-table-expander-icon>- </td>-- <td class="action-cell">- <my-action-dropdown- [ngClass]="{ 'show': expanded }" placement="bottom-right auto" container="body"- i18n-label label="Actions" [actions]="videoBlocklistActions" [entry]="videoBlock" buttonSize="small"- ></my-action-dropdown>- </td>-- <td>- <my-video-cell [video]="videoBlock.video" size="small">- <div>- @if (videoBlock.type === 2) {- <span i18n-title title="The video was blocked due to automatic blocking of new videos" class="pt-badge badge-info badge-small" i18n>Auto block</span>- }- </div>- </my-video-cell>- </td>+ <ng-template #tableCells let-videoBlock>+ <td>+ <my-video-cell [video]="videoBlock.video" size="small">+ <div>+ @if (videoBlock.type === 2) {+ <span i18n-title title="The video was blocked due to automatic blocking of new videos" class="pt-badge badge-info badge-small" i18n>Auto block</span>+ }+ </div>+ </my-video-cell>+ </td>- <td>- <my-video-nsfw-badge [video]="videoBlock.video" theme="red"></my-video-nsfw-badge>- </td>+ <td>+ <my-video-nsfw-badge [video]="videoBlock.video" theme="red"></my-video-nsfw-badge>+ </td>- <td>- <span *ngIf="videoBlock.unfederated" class="pt-badge badge-blue" i18n>Unfederated</span>- </td>+ <td>+ <span *ngIf="videoBlock.unfederated" class="pt-badge badge-blue" i18n>Unfederated</span>+ </td>- <td>- {{ videoBlock.createdAt | ptDate: 'short' }}- </td>- </tr>+ <td>+ {{ videoBlock.createdAt | ptDate: 'short' }}+ </td></ng-template>- <ng-template #expandedrow let-videoBlock>- <tr>- <td class="expand-cell" myAutoColspan>- <div class="d-flex moderation-expanded">-- <div class="left">- <span class="moderation-expanded-label" i18n>Block reason:</span>- <span class="moderation-expanded-text" [innerHTML]="videoBlock.reasonHtml"></span>- </div>+ <ng-template #actionCell let-videoBlock>+ <my-action-dropdown+ placement="bottom-right auto" container="body"+ i18n-label label="Actions" [actions]="videoBlocklistActions" [entry]="videoBlock"+ ></my-action-dropdown>+ </ng-template>- <div class="right">- <my-embed [video]="videoBlock.video"></my-embed>- </div>+ <ng-template #expandedRow let-videoBlock>+ <div *ngIf="videoBlock" class="d-flex moderation-expanded">+ <div class="left">+ <span class="moderation-expanded-label" i18n>Block reason:</span>+ <span class="moderation-expanded-text" [innerHTML]="videoBlock.reasonHtml"></span>+ </div>- </div>- </td>- </tr>+ <div class="right">+ <my-embed [video]="videoBlock.video"></my-embed>+ </div>+ </div></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container *ngIf="search" i18n>No blocked video found matching current filters.</ng-container>- <ng-container *ngIf="!search" i18n>No blocked video found.</ng-container>- </div>- </td>- </tr>+ <ng-template #noResults let-search>+ @if (search) {+ <ng-container i18n>No blocked video found matching current filters.</ng-container>+ } @else {+ <ng-container i18n>No blocked video found.</ng-container>+ }</ng-template>-</p-table>+</my-table>diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.tsindex 6a46e02a30..6af785cdb0 100644--- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts+++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts@@ -1,49 +1,41 @@-import { NgClass, NgIf } from '@angular/common'-import { Component, OnInit, inject } from '@angular/core'-import { ActivatedRoute, Router } from '@angular/router'-import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'+import { CommonModule } from '@angular/common'+import { Component, OnInit, inject, viewChild } from '@angular/core'+import { ConfirmService, MarkdownService, Notifier, ServerService } from '@app/core'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { VideoService } from '@app/shared/shared-main/video/video.service'import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { buildVideoEmbedLink, decorateVideoLink } from '@peertube/peertube-core-utils'-import { VideoBlacklist, VideoBlacklistType, VideoBlacklistType_Type } from '@peertube/peertube-models'+import { ResultList, VideoBlacklist as VideoBlacklistServer, VideoBlacklistType, VideoBlacklistType_Type } from '@peertube/peertube-models'import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'import { switchMap } from 'rxjs/operators'import { environment } from 'src/environments/environment'import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'import { ActionDropdownComponent, DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'-import { AutoColspanDirective } from '../../../shared/shared-main/common/auto-colspan.directive'+import { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'import { EmbedComponent } from '../../../shared/shared-main/video/embed.component'-import { TableExpanderIconComponent } from '../../../shared/shared-tables/table-expander-icon.component'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'import { VideoCellComponent } from '../../../shared/shared-tables/video-cell.component'import { VideoNSFWBadgeComponent } from '../../../shared/shared-video/video-nsfw-badge.component'+type VideoBlacklist = VideoBlacklistServer & { reasonHtml?: string }+@Component({selector: 'my-video-block-list',templateUrl: './video-block-list.component.html',styleUrls: [ '../../../shared/shared-moderation/moderation.scss' ],imports: [- TableModule,- SharedModule,+ CommonModule,AdvancedInputFilterComponent,- NgbTooltip,- NgIf,- TableExpanderIconComponent,ActionDropdownComponent,- NgClass,VideoCellComponent,- AutoColspanDirective,EmbedComponent,PTDatePipe,- VideoNSFWBadgeComponent+ VideoNSFWBadgeComponent,+ TableComponent,+ NumberFormatterPipe]})-export class VideoBlockListComponent extends RestTable implements OnInit {- protected route = inject(ActivatedRoute)- protected router = inject(Router)+export class VideoBlockListComponent implements OnInit {private notifier = inject(Notifier)private serverService = inject(ServerService)private confirmService = inject(ConfirmService)@@ -51,10 +43,8 @@ export class VideoBlockListComponent extends RestTable implements OnInit {private markdownRenderer = inject(MarkdownService)private videoService = inject(VideoService)- blocklist: (VideoBlacklist & { reasonHtml?: string })[] = []- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<VideoBlacklist>>('table')+blocklistTypeFilter: VideoBlacklistType_TypevideoBlocklistActions: DropdownAction<VideoBlacklist>[][] = []@@ -75,8 +65,17 @@ export class VideoBlockListComponent extends RestTable implements OnInit {}]+ columns: TableColumnInfo<string>[] = [+ { id: 'name', label: $localize`Video`, sortable: true },+ { id: 'sensitive', label: $localize`Sensitive`, sortable: false },+ { id: 'unfederated', label: $localize`Unfederated`, sortable: false },+ { id: 'createdAt', label: $localize`Date`, sortable: true }+ ]++ dataLoader: typeof this._dataLoader+constructor () {- super()+ this.dataLoader = this._dataLoader.bind(this)this.videoBlocklistActions = [[@@ -93,7 +92,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit {).subscribe({next: () => {this.notifier.success($localize`Video ${videoBlock.video.name} switched to manual block.`)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -125,7 +124,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit {.subscribe({next: () => {this.notifier.success($localize`Video deleted.`)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -143,12 +142,6 @@ export class VideoBlockListComponent extends RestTable implements OnInit {if (serverConfig.autoBlacklist.videos.ofUsers.enabled) {this.blocklistTypeFilter = VideoBlacklistType.MANUAL}-- this.initialize()- }-- getIdentifier () {- return 'VideoBlockListComponent'}toHtml (text: string) {@@ -165,7 +158,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit {.subscribe({next: () => {this.notifier.success($localize`Video ${entry.video.name} unblocked.`)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -185,25 +178,16 @@ export class VideoBlockListComponent extends RestTable implements OnInit {})}- protected reloadDataInternal () {- this.videoBlocklistService.listBlocks({- pagination: this.pagination,- sort: this.sort,- search: this.search- }).subscribe({- next: async resultList => {- this.totalRecords = resultList.total-- this.blocklist = resultList.data-- for (const element of this.blocklist) {- Object.assign(element, {- reasonHtml: await this.toHtml(element.reason)- })- }- },+ private _dataLoader (options: DataLoaderOptions) {+ return this.videoBlocklistService.listBlocks(options)+ .pipe(+ switchMap(async (resultList: ResultList<VideoBlacklist>) => {+ for (const element of resultList.data) {+ element.reasonHtml = await this.toHtml(element.reason)+ }- error: err => this.notifier.error(err.message)- })+ return resultList+ })+ )}}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.htmlindex c48853e9f9..412f9502f1 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@@ -1,4 +1,4 @@<em i18n>This view also shows comments from muted accounts.</em>-<my-video-comment-list-admin-owner mode="admin"></my-video-comment-list-admin-owner>+<my-video-comment-list-admin-owner mode="admin" key="AdminVideoCommentList"></my-video-comment-list-admin-owner>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.htmlindex 1f2124e335..c67c2d2c59 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@@ -1,161 +1,105 @@-<p-table- [value]="users" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id" [resizableColumns]="true"- [(selection)]="selectedRows" [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" [selectionPageOnly]="true"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()" [expandedRowKeys]="expandedRows"+<my-table+ #table+ key="UserListComponent"+ [defaultColumns]="columns"+ defaultSort="createdAt"+ i18n-paginatorText+ paginatorText="users per page"+ defaultRowsPerPage="10"+ [bulkActions]="bulkActions"+ [dataLoader]="dataLoader"+ columnConfig="true"+ [hasExpandedRow]="hasExpandedRow">- <ng-template #caption>- <div class="caption">- <div class="left-buttons">- <my-action-dropdown- *ngIf="isInSelectionMode()" i18n-label label="Batch actions" theme="primary"- [actions]="bulkActions" [entry]="selectedRows"- >- </my-action-dropdown>-- <a *ngIf="!isInSelectionMode()" class="peertube-create-button" routerLink="/admin/overview/users/create">- <my-global-icon iconName="user-add" aria-hidden="true"></my-global-icon>- <ng-container i18n>Create user</ng-container>- </a>- </div>-- <div class="ms-auto">- <my-advanced-input-filter [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter>- </div>-- </div>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No users} =1 {1 user} other {{{ totalRecords | myNumberFormatter }} users}}</ng-container></ng-template>- <ng-template #header>- <tr>- <th class="checkbox-cell" scope="col" style="width: 40px">- <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>- </th>-- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>-- <th scope="col" style="width: 70px;">- <div class="c-hand column-toggle" ngbDropdown placement="bottom-left auto" container="body" autoClose="outside">- <button type="button" class="border-0 p-0" ngbDropdownToggle i18n-title title="Open table configuration">- <my-global-icon iconName="columns"></my-global-icon>- </button>-- <div ngbDropdownMenu class="p-3">- <div class="form-group">- <label i18n for="select-columns">Select the columns to display</label>-- <my-select-checkbox- inputId="select-columns"- [availableItems]="columns"- [selectableGroup]="false" [(ngModel)]="selectedColumns"- i18n-placeholder placeholder="Select the columns to display"- >- </my-select-checkbox>- </div>-- <div class="form-group">- <my-peertube-checkbox- inputName="highlightBannedUsers" [(ngModel)]="highlightBannedUsers"- i18n-labelText labelText="Highlight banned users"- ></my-peertube-checkbox>- </div>+ <ng-template #captionRight>+ <my-advanced-input-filter [filters]="inputFilters" (search)="table.onSearch($event)"></my-advanced-input-filter>++ <a class="peertube-create-button" routerLink="/admin/overview/users/create">+ <my-global-icon iconName="user-add" aria-hidden="true"></my-global-icon>+ <ng-container i18n>Create user</ng-container>+ </a>+ </ng-template>++ <ng-template #tableCells let-user>+ <td *ngIf="table.isColumnDisplayed('username')" class="cell-username">+ <a i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer" [routerLink]="[ '/a/' + user.username ]">+ <div class="chip two-lines">+ <my-actor-avatar [actor]="user?.account" actorType="account" size="32"></my-actor-avatar>+ <div>+ <span>{{ user.account.displayName }}</span>+ <span class="muted">{{ user.username }}</span></div></div>- </th>- <th scope="col" *ngIf="isSelected('username')" pResizableColumn [ngbTooltip]="sortTooltip" container="body" pSortableColumn="username">{{ getColumn('username').label }} <p-sortIcon field="username"></p-sortIcon></th>- <th scope="col" *ngIf="isSelected('role')" style="width: 120px;" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="role">{{ getColumn('role').label }} <p-sortIcon field="role"></p-sortIcon></th>- <th scope="col" *ngIf="isSelected('email')">{{ getColumn('email').label }}</th>- <th scope="col" *ngIf="isSelected('quota')" style="width: 160px;" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="videoQuotaUsed">{{ getColumn('quota').label }} <p-sortIcon field="videoQuotaUsed"></p-sortIcon></th>- <th scope="col" *ngIf="isSelected('quotaDaily')" style="width: 160px;">{{ getColumn('quotaDaily').label }}</th>- <th scope="col" *ngIf="isSelected('totalVideoFileSize')" style="width: 100px;">{{ getColumn('totalVideoFileSize').label }}</th>- <th scope="col" *ngIf="isSelected('pluginAuth')" style="width: 140px;" pResizableColumn >{{ getColumn('pluginAuth').label }}</th>- <th scope="col" *ngIf="isSelected('createdAt')" style="width: 170px;" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">{{ getColumn('createdAt').label }} <p-sortIcon field="createdAt"></p-sortIcon></th>- <th scope="col" *ngIf="isSelected('lastLoginDate')" style="width: 170px;" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="lastLoginDate">{{ getColumn('lastLoginDate').label }} <p-sortIcon field="lastLoginDate"></p-sortIcon></th>- </tr>+ </a>++ <div *ngIf="user.accountMutedStatus.mutedByInstance" class="pt-badge badge-red" i18n>Muted</div>+ <div *ngIf="user.blocked" class="pt-badge badge-red" i18n>Banned</div>+ </td>++ <td *ngIf="table.isColumnDisplayed('role')">+ @if (user.blocked) {+ <span class="pt-badge badge-banned" i18n-title title="The user is banned">{{ user.role.label }}</span>+ } @else {+ <span class="pt-badge" [ngClass]="getRoleClass(user.role.id)">{{ user.role.label }}</span>+ }+ </td>++ <td *ngIf="table.isColumnDisplayed('email')">+ <my-user-email-info [entry]="user" showEmailVerifyInformation="true"></my-user-email-info>+ </td>++ <td *ngIf="table.isColumnDisplayed('videoQuotaUsed')">+ <my-progress-bar+ i18n-label label="Total video quota" [max]="user.rawVideoQuota" [value]="user.rawVideoQuotaUsed"+ [valueFormatted]="user.videoQuotaUsed" [maxFormatted]="user.videoQuota" size="small"+ >+ </my-progress-bar>+ </td>++ <td *ngIf="table.isColumnDisplayed('videoQuotaDailyUsed')">+ <my-progress-bar+ i18n-label label="Total daily video quota" [max]="user.rawVideoQuotaDaily" [value]="user.rawVideoQuotaUsedDaily"+ [valueFormatted]="user.videoQuotaUsedDaily" [maxFormatted]="user.videoQuotaDaily" size="small"+ >+ </my-progress-bar>+ </td>++ <td *ngIf="table.isColumnDisplayed('totalVideoFileSize')">+ {{ user.totalVideoFileSize | bytes }}+ </td>++ <td *ngIf="table.isColumnDisplayed('pluginAuth')">+ <span *ngIf="user.pluginAuth" [ngbTooltip]="user.pluginAuth">{{ user.pluginAuth.replace('peertube-plugin-', '') }}</span>+ </td>++ <td *ngIf="table.isColumnDisplayed('createdAt')" [title]="user.createdAt">{{ user.createdAt | ptDate: 'short' }}</td>++ <td *ngIf="table.isColumnDisplayed('lastLoginDate')" [title]="user.lastLoginDate">+ @if (user.lastLoginDate) {+ {{ user.lastLoginDate | ptDate: 'short' }}+ } @else {+ <span i18n>never</span>+ }+ </td></ng-template>- <ng-template #body let-expanded="expanded" let-user>-- <tr [pSelectableRow]="user" [ngClass]="{ banned: highlightBannedUsers && user.blocked }">- <td class="checkbox-cell">- <p-tableCheckbox [value]="user" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>- </td>-- <td class="expand-cell" [ngClass]="{ 'empty-cell': !user.blockedReason }">- <my-table-expander-icon *ngIf="user.blockedReason" [pRowToggler]="user" [expanded]="expanded"></my-table-expander-icon>- </td>-- <td class="action-cell">- <my-user-moderation-dropdown- *ngIf="!isInSelectionMode()" [user]="user" [account]="user.accountMutedStatus" [displayOptions]="userModerationDisplayOptions"- container="body" (userChanged)="onUserChanged()" (userDeleted)="onUserChanged()" buttonSize="small">- </my-user-moderation-dropdown>- </td>-- <td *ngIf="isSelected('username')" class="cell-username">- <a i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer" [routerLink]="[ '/a/' + user.username ]">- <div class="chip two-lines">- <my-actor-avatar [actor]="user?.account" actorType="account" size="32"></my-actor-avatar>- <div>- <span>{{ user.account.displayName }}</span>- <span class="muted">{{ user.username }}</span>- </div>- </div>- </a>-- <div *ngIf="user.accountMutedStatus.mutedByInstance" class="pt-badge badge-red" i18n>Muted</div>- <div *ngIf="user.blocked" class="pt-badge badge-red" i18n>Banned</div>- </td>-- <td *ngIf="isSelected('role')">- <span *ngIf="user.blocked" class="pt-badge badge-banned" i18n-title title="The user was banned">{{ user.role.label }}</span>- <span *ngIf="!user.blocked" class="pt-badge" [ngClass]="getRoleClass(user.role.id)">{{ user.role.label }}</span>- </td>-- <td *ngIf="isSelected('email')">- <my-user-email-info [entry]="user" showEmailVerifyInformation="true"></my-user-email-info>- </td>-- <td *ngIf="isSelected('quota')">- <my-progress-bar- i18n-label label="Total video quota" [max]="user.rawVideoQuota" [value]="user.rawVideoQuotaUsed"- [valueFormatted]="user.videoQuotaUsed" [maxFormatted]="user.videoQuota" size="small"- >- </my-progress-bar>- </td>-- <td *ngIf="isSelected('quotaDaily')">- <my-progress-bar- i18n-label label="Total daily video quota" [max]="user.rawVideoQuotaDaily" [value]="user.rawVideoQuotaUsedDaily"- [valueFormatted]="user.videoQuotaUsedDaily" [maxFormatted]="user.videoQuotaDaily" size="small"- >- </my-progress-bar>- </td>-- <td *ngIf="isSelected('totalVideoFileSize')">- {{ user.totalVideoFileSize | bytes }}- </td>-- <td *ngIf="isSelected('pluginAuth')">- <span *ngIf="user.pluginAuth" [ngbTooltip]="user.pluginAuth">{{ user.pluginAuth }}</span>- </td>-- <td *ngIf="isSelected('createdAt')" [title]="user.createdAt">{{ user.createdAt | ptDate: 'short' }}</td>-- <td *ngIf="isSelected('lastLoginDate')" [title]="user.lastLoginDate">{{ user.lastLoginDate | ptDate: 'short' }}</td>- </tr>+ <ng-template #actionCell let-user>+ <my-user-moderation-dropdown+ [user]="user" [account]="user.accountMutedStatus" [displayOptions]="userModerationDisplayOptions"+ container="body" (userChanged)="onUserChanged()" (userDeleted)="onUserChanged()"+ >+ </my-user-moderation-dropdown></ng-template>- <ng-template #expandedrow let-user>- <tr class="user-blocked-reason">- <td myAutoColspan>- <span i18n class="ban-reason-label">Ban reason:</span>- {{ user.blockedReason }}- </td>- </tr>+ <ng-template #expandedRow let-user>+ <span i18n class="ban-reason-label">Ban reason:</span>++ {{ user.blockedReason }}</ng-template>-</p-table>+</my-table><my-user-ban-modal #userBanModal (userBanned)="onUserChanged()"></my-user-ban-modal>diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.scss b/client/src/app/+admin/overview/users/user-list/user-list.component.scssindex fdb917103c..8d618cf542 100644--- a/client/src/app/+admin/overview/users/user-list/user-list.component.scss+++ b/client/src/app/+admin/overview/users/user-list/user-list.component.scss@@ -1,7 +1,7 @@-@use 'sass:color';-@use '_variables' as *;-@use '_mixins' as *;-@use 'bootstrap/scss/functions' as *;+@use "sass:color";+@use "_variables" as *;+@use "_mixins" as *;+@use "bootstrap/scss/functions" as *;.banned-info {font-style: italic;@@ -15,13 +15,7 @@@include margin-left(15px);}-p-tableCheckbox {- position: relative;- top: -2.5px;-}--@media screen and (max-width: $medium-view) {- .empty-cell {- padding: 0;- }+my-progress-bar {+ display: block;+ min-width: 120px;}diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.ts b/client/src/app/+admin/overview/users/user-list/user-list.component.tsindex 80bd015942..d964b95f73 100644--- a/client/src/app/+admin/overview/users/user-list/user-list.component.ts+++ b/client/src/app/+admin/overview/users/user-list/user-list.component.ts@@ -1,52 +1,44 @@-import { NgClass, NgIf } from '@angular/common'+import { CommonModule, NgClass } from '@angular/common'import { Component, OnDestroy, OnInit, inject, viewChild } from '@angular/core'import { FormsModule } from '@angular/forms'-import { ActivatedRoute, Router, RouterLink } from '@angular/router'-import {- AuthService,- ConfirmService,- HooksService,- LocalStorageService,- Notifier,- PluginService,- RestPagination,- RestTable-} from '@app/core'+import { RouterLink } from '@angular/router'+import { AuthService, ConfirmService, HooksService, Notifier, PluginService } from '@app/core'import { formatICU, getBackendHost } from '@app/helpers'import { Actor } from '@app/shared/shared-main/account/actor.model'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { ProgressBarComponent } from '@app/shared/shared-main/common/progress-bar.component'import { BlocklistService } from '@app/shared/shared-moderation/blocklist.service'import { UserBanModalComponent } from '@app/shared/shared-moderation/user-ban-modal.component'-import { UserAdminService } from '@app/shared/shared-users/user-admin.service'-import { NgbDropdown, NgbDropdownMenu, NgbDropdownToggle, NgbTooltip } from '@ng-bootstrap/ng-bootstrap'-import { User, UserRole, UserRoleType } from '@peertube/peertube-models'-import { logger } from '@root-helpers/logger'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'-import { lastValueFrom } from 'rxjs'+import { UserAdmin, UserAdminService } from '@app/shared/shared-users/user-admin.service'+import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'+import { UserRole, UserRoleType } from '@peertube/peertube-models'+import { map, switchMap } from 'rxjs'import { ActorAvatarComponent } from '../../../../shared/shared-actor-image/actor-avatar.component'import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../../shared/shared-forms/advanced-input-filter.component'-import { PeertubeCheckboxComponent } from '../../../../shared/shared-forms/peertube-checkbox.component'-import { SelectCheckboxComponent } from '../../../../shared/shared-forms/select/select-checkbox.component'import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'-import { ActionDropdownComponent, DropdownAction } from '../../../../shared/shared-main/buttons/action-dropdown.component'-import { AutoColspanDirective } from '../../../../shared/shared-main/common/auto-colspan.directive'+import { DropdownAction } from '../../../../shared/shared-main/buttons/action-dropdown.component'import { BytesPipe } from '../../../../shared/shared-main/common/bytes.pipe'+import { NumberFormatterPipe } from '../../../../shared/shared-main/common/number-formatter.pipe'import {AccountMutedStatus,UserModerationDisplayType,UserModerationDropdownComponent} from '../../../../shared/shared-moderation/user-moderation-dropdown.component'-import { TableExpanderIconComponent } from '../../../../shared/shared-tables/table-expander-icon.component'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'import { UserEmailInfoComponent } from '../../../shared/user-email-info.component'-type UserForList = User & {- rawVideoQuota: number- rawVideoQuotaUsed: number- rawVideoQuotaDaily: number- rawVideoQuotaUsedDaily: number-}+type User = UserAdmin & { accountMutedStatus: AccountMutedStatus }++type ColumnName =+ | 'username'+ | 'role'+ | 'email'+ | 'videoQuotaUsed'+ | 'videoQuotaDailyUsed'+ | 'totalVideoFileSize'+ | 'createdAt'+ | 'lastLoginDate'+ | 'pluginAuth'@Component({selector: 'my-user-list',@@ -54,57 +46,36 @@ type UserForList = User & {styleUrls: [ './user-list.component.scss' ],imports: [GlobalIconComponent,- TableModule,- SharedModule,- NgIf,- ActionDropdownComponent,+ CommonModule,RouterLink,AdvancedInputFilterComponent,- NgbDropdown,- NgbDropdownToggle,- NgbDropdownMenu,- SelectCheckboxComponent,FormsModule,- PeertubeCheckboxComponent,NgbTooltip,NgClass,- TableExpanderIconComponent,UserModerationDropdownComponent,ActorAvatarComponent,UserEmailInfoComponent,- AutoColspanDirective,UserBanModalComponent,PTDatePipe,BytesPipe,- ProgressBarComponent+ ProgressBarComponent,+ TableComponent,+ NumberFormatterPipe]})-export class UserListComponent extends RestTable<User> implements OnInit, OnDestroy {- protected route = inject(ActivatedRoute)- protected router = inject(Router)+export class UserListComponent implements OnInit, OnDestroy {private notifier = inject(Notifier)private confirmService = inject(ConfirmService)private auth = inject(AuthService)private blocklist = inject(BlocklistService)private userAdminService = inject(UserAdminService)- private peertubeLocalStorage = inject(LocalStorageService)private hooks = inject(HooksService)private pluginService = inject(PluginService)- private static readonly LS_SELECTED_COLUMNS_KEY = 'admin-user-list-selected-columns'-readonly userBanModal = viewChild<UserBanModalComponent>('userBanModal')-- users: (User & { accountMutedStatus: AccountMutedStatus })[] = []-- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: 1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }-- highlightBannedUsers = false+ readonly table = viewChild<TableComponent<User, ColumnName>>('table')bulkActions: DropdownAction<User[]>[][] = []- columns: { id: string, label: string }[]inputFilters: AdvancedInputFilter[] = [{@@ -124,26 +95,32 @@ export class UserListComponent extends RestTable<User> implements OnInit, OnDestmyAccount: false}- private _selectedColumns: string[] = []+ columns: TableColumnInfo<ColumnName>[] = [+ { id: 'username', label: $localize`Username`, sortable: true },+ { id: 'role', label: $localize`Role`, sortable: true },+ { id: 'email', label: $localize`Email`, sortable: false },+ { id: 'videoQuotaUsed', label: $localize`Video quota`, sortable: true },+ { id: 'videoQuotaDailyUsed', label: $localize`Daily quota`, sortable: false },+ { id: 'totalVideoFileSize', label: $localize`Total size`, sortable: false },+ { id: 'pluginAuth', label: $localize`Auth plugin`, sortable: false },+ { id: 'createdAt', label: $localize`Created`, sortable: true },+ { id: 'lastLoginDate', label: $localize`Last login`, sortable: true }+ ]- get authUser () {- return this.auth.getUser()- }+ dataLoader: typeof this._dataLoader+ hasExpandedRow: typeof this._hasExpandedRow- get selectedColumns () {- return this._selectedColumns || []+ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ this.hasExpandedRow = this._hasExpandedRow.bind(this)}- set selectedColumns (val: string[]) {- this._selectedColumns = val-- this.saveSelectedColumns()+ get authUser () {+ return this.auth.getUser()}async ngOnInit () {- this.initialize()-- this.pluginService.addAction('admin-users-list:load-data', () => this.reloadDataInternal())+ this.pluginService.addAction('admin-users-list:load-data', () => this.table().loadData())const bulkActions: DropdownAction<User[]>[][] = [[@@ -167,7 +144,7 @@ export class UserListComponent extends RestTable<User> implements OnInit, OnDest],[{- label: $localize`Set Email as Verified`,+ label: $localize`Set email as verified`,handler: users => this.setEmailsAsVerified(users),isDisplayed: users => {return users.every(u => this.authUser.canManage(u) && !u.blocked && u.emailVerified !== true)@@ -177,79 +154,25 @@ export class UserListComponent extends RestTable<User> implements OnInit, OnDest]this.bulkActions = await this.hooks.wrapObject(bulkActions, 'admin-users', 'filter:admin-users-list.bulk-actions.create.result')-- this.columns = [- { id: 'username', label: $localize`Username` },- { id: 'role', label: $localize`Role` },- { id: 'email', label: $localize`Email` },- { id: 'quota', label: $localize`Video quota` },- { id: 'totalVideoFileSize', label: $localize`Total size` },- { id: 'createdAt', label: $localize`Created` },- { id: 'lastLoginDate', label: $localize`Last login` },-- { id: 'quotaDaily', label: $localize`Daily quota` },- { id: 'pluginAuth', label: $localize`Auth plugin` }- ]-- this.loadSelectedColumns()}ngOnDestroy () {this.pluginService.removeAction('admin-users-list:load-data')}- loadSelectedColumns () {- const result = this.peertubeLocalStorage.getItem(UserListComponent.LS_SELECTED_COLUMNS_KEY)-- if (result) {- try {- this.selectedColumns = JSON.parse(result)- return- } catch (err) {- logger.error('Cannot load selected columns.', err)- }- }-- // Default behaviour- this.selectedColumns = [ 'username', 'role', 'email', 'quota', 'totalVideoFileSize', 'createdAt', 'lastLoginDate' ]- return- }-- saveSelectedColumns () {- this.peertubeLocalStorage.setItem(UserListComponent.LS_SELECTED_COLUMNS_KEY, JSON.stringify(this.selectedColumns))- }-- getIdentifier () {- return 'UserListComponent'- }-getRoleClass (role: UserRoleType) {switch (role) {case UserRole.ADMINISTRATOR:return 'badge-purple'+case UserRole.MODERATOR:return 'badge-blue'+default:return 'badge-yellow'}}- isSelected (id: string) {- return this.selectedColumns.find(c => c === id)- }-- getColumn (id: string) {- return this.columns.find(c => c.id === id)- }-- getUserVideoQuotaPercentage (user: UserForList) {- return user.rawVideoQuotaUsed * 100 / user.rawVideoQuota- }-- getUserVideoQuotaDailyPercentage (user: UserForList) {- return user.rawVideoQuotaUsedDaily * 100 / user.rawVideoQuotaDaily- }-openBanUserModal (users: User[]) {for (const user of users) {if (user.username === 'root') {@@ -262,7 +185,7 @@ export class UserListComponent extends RestTable<User> implements OnInit, OnDest}onUserChanged () {- this.reloadData()+ this.table().loadData()}async unbanUsers (users: User[]) {@@ -285,7 +208,7 @@ export class UserListComponent extends RestTable<User> implements OnInit, OnDest{ count: users.length }))- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -315,7 +238,7 @@ export class UserListComponent extends RestTable<User> implements OnInit, OnDest))- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -333,51 +256,42 @@ export class UserListComponent extends RestTable<User> implements OnInit, OnDest))- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)})}- protected async reloadDataInternal () {- const obs = this.userAdminService.getUsers({- pagination: this.pagination,- sort: this.sort,- search: this.search- })-- try {- const resultList = await lastValueFrom(obs)-- this.users = resultList.data.map(u => ({- ...u,-- accountMutedStatus: {- ...u.account,-- nameWithHost: Actor.CREATE_BY_STRING(u.account.name, u.account.host),-- mutedByInstance: false,- mutedByUser: false,- mutedServerByInstance: false,- mutedServerByUser: false- }- }))- this.totalRecords = resultList.total-- this.loadMutedStatus()- } catch (err) {- this.notifier.error(err.message)- }+ private _dataLoader (options: DataLoaderOptions) {+ return this.userAdminService.listUsers(options)+ .pipe(+ switchMap(result => {+ return this.blocklist.getStatus({ accounts: result.data.map(u => u.username + '@' + getBackendHost()) })+ .pipe(map(blockStatus => ({ result, blockStatus })))+ }),+ map(({ result, blockStatus }) => ({+ total: result.total,++ data: result.data.map(u => ({+ ...u,++ accountMutedStatus: {+ ...u.account,++ nameWithHost: Actor.CREATE_BY_STRING(u.account.name, u.account.host),++ mutedByInstance: blockStatus.accounts[u.username + '@' + getBackendHost()].blockedByServer,+ mutedByUser: false,+ mutedServerByInstance: false,+ mutedServerByUser: false+ }+ }))+ }))+ )}- private loadMutedStatus () {- this.blocklist.getStatus({ accounts: this.users.map(u => u.username + '@' + getBackendHost()) })- .subscribe(blockStatus => {- for (const user of this.users) {- user.accountMutedStatus.mutedByInstance = blockStatus.accounts[user.username + '@' + getBackendHost()].blockedByServer- }- })+ private _hasExpandedRow (user: User) {+ return !!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.htmlindex 0ffb5f17e3..def6a01361 100644--- a/client/src/app/+admin/overview/videos/video-list.component.html+++ b/client/src/app/+admin/overview/videos/video-list.component.html@@ -1,176 +1,149 @@-<p-table- [value]="videos" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id" [resizableColumns]="true"- [(selection)]="selectedRows" [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" [selectionPageOnly]="true"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [expandedRowKeys]="expandedRows" [ngClass]="{ loading: loading }" (onRowExpand)="onVideoPanelOpened($event)"+<my-table+ #table+ key="VideoAdminListComponent"+ [defaultColumns]="columns"+ defaultSort="publishedAt"+ i18n-paginatorText+ paginatorText="videos per page"+ defaultRowsPerPage="10"+ [bulkActions]="bulkActions"+ [dataLoader]="dataLoader"+ (rowExpand)="onRowExpand($event)"+ columnConfig="false">- <ng-template #caption>- <div class="caption">- <div class="left-buttons">- <my-action-dropdown- *ngIf="isInSelectionMode()" i18n-label label="Batch actions" theme="primary"- [actions]="bulkActions" [entry]="selectedRows"- >- </my-action-dropdown>- </div>- <div class="ms-auto right-form">- <my-advanced-input-filter [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No videos} =1 {1 video} other {{{ totalRecords | myNumberFormatter }} videos}}</ng-container>+ </ng-template>++ <ng-template #captionRight>+ <my-advanced-input-filter [filters]="inputFilters" (search)="table.onSearch($event)"></my-advanced-input-filter>++ <my-button i18n-label label="Refresh" icon="refresh" (click)="table.loadData()"></my-button>+ </ng-template>++ <ng-template #tableCells let-video>+ <td>+ <my-video-cell [video]="video" size="small"></my-video-cell>+ </td>++ <td>+ <div>+ @if (video.isLocal) {+ <span class="pt-badge badge-blue" i18n>Local</span>+ } @else {+ <span class="pt-badge badge-purple" i18n>Remote</span>+ }- <my-button i18n-label label="Refresh" icon="refresh" (click)="reloadData()"></my-button>+ <my-video-privacy-badge [video]="video"></my-video-privacy-badge>++ <my-video-nsfw-badge [video]="video" theme="red"></my-video-nsfw-badge>++ <span *ngIf="isUnpublished(video)" class="pt-badge badge-yellow">{{ video.state.label }}</span>++ <span *ngIf="isAccountBlocked(video)" class="pt-badge badge-red" i18n>Account muted</span>+ <span *ngIf="isServerBlocked(video)" class="pt-badge badge-red" i18n>Server muted</span>++ <span *ngIf="isVideoBlocked(video)" class="pt-badge badge-red" i18n>Blocked</span></div>- </div>+ <div>+ @for (tag of video.automaticTags; track tag) {+ <a+ i18n-title title="Only display videos with this tag"+ class="pt-badge badge-secondary me-1"+ [routerLink]="[ '.' ]" [queryParams]="{ 'search': buildSearchAutoTag(tag) }"+ >{{ tag }}</a>+ }+ </div>+ </td>++ <td>+ <span *ngIf="hasOriginalFile(video)" class="pt-badge badge-blue" i18n>Original file</span>+ <span *ngIf="hasHLS(video)" class="pt-badge badge-blue" i18n>HLS</span>+ <span *ngIf="hasWebVideos(video)" class="pt-badge badge-blue" i18n>Web Videos ({{ video.files.length }})</span>+ <span *ngIf="video.isLive" class="pt-badge badge-blue" i18n>Live</span>+ <span *ngIf="hasObjectStorage(video)" class="pt-badge badge-purple" i18n>Object storage</span>++ <span *ngIf="!isImport(video) && !video.isLive && video.isLocal">{{ getFilesSize(video) | bytes: 1 }}</span>+ </td>++ <td>+ {{ video.publishedAt | ptDate: 'short' }}+ </td></ng-template>- <ng-template #header>- <tr>- <th class="checkbox-cell" scope="col" style="width: 40px">- <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>- </th>- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>- <th scope="col" style="width: 70px;">- <span i18n class="visually-hidden">Actions</span>- </th>- <th scope="col" i18n>Video</th>- <th scope="col" i18n>Info</th>- <th scope="col" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="localVideoFilesSize">Files <p-sortIcon field="localVideoFilesSize"></p-sortIcon></th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="publishedAt">Published <p-sortIcon field="publishedAt"></p-sortIcon></th>- </tr>+ <ng-template #actionCell let-video>+ <my-video-actions-dropdown+ placement="bottom auto" buttonDirection="horizontal" buttonStyled="true" [video]="video" [displayOptions]="videoActionsOptions"+ (videoRemoved)="table.loadData()" (videoFilesRemoved)="table.loadData()" (transcodingCreated)="table.loadData()"+ ></my-video-actions-dropdown></ng-template>- <ng-template #body let-expanded="expanded" let-video>-- <tr [pSelectableRow]="video" (onRowExpand)="onVideoPanelOpened(video)">- <td class="checkbox-cell">- <p-tableCheckbox [value]="video" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>- </td>-- <td class="expand-cell">- <my-table-expander-icon [pRowToggler]="video" [expanded]="expanded"></my-table-expander-icon>- </td>-- <td class="action-cell">- <my-video-actions-dropdown- placement="bottom auto" buttonDirection="horizontal" buttonStyled="true" [video]="video" [displayOptions]="videoActionsOptions"- (videoRemoved)="reloadData()" (videoFilesRemoved)="reloadData()" (transcodingCreated)="reloadData()" buttonSize="small"- ></my-video-actions-dropdown>- </td>-- <td>- <my-video-cell [video]="video" size="small"></my-video-cell>- </td>-- <td>- <div>- @if (video.isLocal) {- <span class="pt-badge badge-blue" i18n>Local</span>- } @else {- <span class="pt-badge badge-purple" i18n>Remote</span>- }-- <my-video-privacy-badge [video]="video"></my-video-privacy-badge>-- <my-video-nsfw-badge [video]="video" theme="red"></my-video-nsfw-badge>-- <span *ngIf="isUnpublished(video)" class="pt-badge badge-yellow">{{ video.state.label }}</span>-- <span *ngIf="isAccountBlocked(video)" class="pt-badge badge-red" i18n>Account muted</span>- <span *ngIf="isServerBlocked(video)" class="pt-badge badge-red" i18n>Server muted</span>-- <span *ngIf="isVideoBlocked(video)" class="pt-badge badge-red" i18n>Blocked</span>- </div>-- <div>- @for (tag of video.automaticTags; track tag) {- <a- i18n-title title="Only display videos with this tag"- class="pt-badge badge-secondary me-1"- [routerLink]="[ '.' ]" [queryParams]="{ 'search': buildSearchAutoTag(tag) }"- >{{ tag }}</a>- }- </div>- </td>-- <td>- <span *ngIf="hasOriginalFile(video)" class="pt-badge badge-blue" i18n>Original file</span>- <span *ngIf="hasHLS(video)" class="pt-badge badge-blue" i18n>HLS</span>- <span *ngIf="hasWebVideos(video)" class="pt-badge badge-blue" i18n>Web Videos ({{ video.files.length }})</span>- <span *ngIf="video.isLive" class="pt-badge badge-blue" i18n>Live</span>- <span *ngIf="hasObjectStorage(video)" class="pt-badge badge-purple" i18n>Object storage</span>-- <span *ngIf="!isImport(video) && !video.isLive && video.isLocal">{{ getFilesSize(video) | bytes: 1 }}</span>- </td>-- <td>- {{ video.publishedAt | ptDate: 'short' }}- </td>-- </tr>+ <ng-template #expandedRow let-video>+ <div class="video-expanded-info">+ <div class="me-3" *ngIf="hasOriginalFile(video)">+ <ng-container i18n>Original file:</ng-container>++ <ul>+ <li>+ <a title="Download this file" i18n-title [href]="getDownloadUrl(video, video.videoSource.fileDownloadUrl)">{{ video.videoSource.inputFilename }}</a>: {{ video.videoSource.size | bytes: 1 }}++ <button class="border-0 p-0" i18n-title title="Delete this file" (click)="removeVideoSourceFile(video)">+ <my-global-icon iconName="delete"></my-global-icon>+ </button>+ </li>+ </ul>+ </div>++ <div class="me-3" *ngIf="hasWebVideos(video)">+ <ng-container i18n>Web Videos:</ng-container>++ <ul>+ <li *ngFor="let file of video.files">+ <a title="Download this file" i18n-title [href]="getDownloadUrl(video, file.fileDownloadUrl)">{{ file.resolution.label }}</a>: {{ file.size | bytes: 1 }}++ <button+ *ngIf="canRemoveOneFile(video)" class="border-0 p-0"+ i18n-title title="Delete this file"+ (click)="removeVideoFile(video, file, 'web-videos')"+ >+ <my-global-icon iconName="delete"></my-global-icon>+ </button>+ </li>+ </ul>+ </div>++ <div *ngIf="hasHLS(video)">+ <ng-container i18n>HLS:</ng-container>++ <ul>+ <li *ngFor="let file of video.streamingPlaylists[0].files">+ <a title="Download this file" i18n-title [href]="getDownloadUrl(video, file.fileDownloadUrl)">{{ file.resolution.label }}</a>: {{ file.size | bytes: 1 }}++ <button+ *ngIf="canRemoveOneFile(video)" class="border-0 p-0"+ i18n-title title="Delete this file"+ (click)="removeVideoFile(video, file, 'hls')"+ >+ <my-global-icon iconName="delete"></my-global-icon>+ </button>+ </li>+ </ul>+ </div>++ <my-embed class="ms-auto" [video]="video"></my-embed>+ </div></ng-template>- <ng-template #expandedrow let-video>- <tr>- <td class="video-info expand-cell" myAutoColspan>- <div>- <div class="me-3" *ngIf="hasOriginalFile(video)">- <ng-container i18n>Original file:</ng-container>-- <ul>- <li>- <a title="Download this file" i18n-title [href]="getDownloadUrl(video, video.videoSource.fileDownloadUrl)">{{ video.videoSource.inputFilename }}</a>: {{ video.videoSource.size | bytes: 1 }}-- <button class="border-0 p-0" i18n-title title="Delete this file" (click)="removeVideoSourceFile(video)">- <my-global-icon iconName="delete"></my-global-icon>- </button>- </li>- </ul>- </div>-- <div class="me-3" *ngIf="hasWebVideos(video)">- <ng-container i18n>Web Videos:</ng-container>-- <ul>- <li *ngFor="let file of video.files">- <a title="Download this file" i18n-title [href]="getDownloadUrl(video, file.fileDownloadUrl)">{{ file.resolution.label }}</a>: {{ file.size | bytes: 1 }}-- <button- *ngIf="canRemoveOneFile(video)" class="border-0 p-0"- i18n-title title="Delete this file"- (click)="removeVideoFile(video, file, 'web-videos')"- >- <my-global-icon iconName="delete"></my-global-icon>- </button>- </li>- </ul>- </div>-- <div *ngIf="hasHLS(video)">- <ng-container i18n>HLS:</ng-container>-- <ul>- <li *ngFor="let file of video.streamingPlaylists[0].files">- <a title="Download this file" i18n-title [href]="getDownloadUrl(video, file.fileDownloadUrl)">{{ file.resolution.label }}</a>: {{ file.size | bytes: 1 }}-- <button- *ngIf="canRemoveOneFile(video)" class="border-0 p-0"- i18n-title title="Delete this file"- (click)="removeVideoFile(video, file, 'hls')"- >- <my-global-icon iconName="delete"></my-global-icon>- </button>- </li>- </ul>- </div>-- <my-embed class="ms-auto" [video]="video"></my-embed>- </div>- </td>- </tr>+ <ng-template #noResults let-search>+ @if (search) {+ <ng-container i18n>No videos found matching current filters.</ng-container>+ } @else {+ <ng-container i18n>Your platform doesn't have videos.</ng-container>+ }</ng-template>-</p-table>-<my-video-block #videoBlockModal (videoBlocked)="reloadData()"></my-video-block>+</my-table>++<my-video-block #videoBlockModal (videoBlocked)="table.loadData()"></my-video-block>diff --git a/client/src/app/+admin/overview/videos/video-list.component.scss b/client/src/app/+admin/overview/videos/video-list.component.scssindex d9b832c93f..a7ac44c882 100644--- a/client/src/app/+admin/overview/videos/video-list.component.scss+++ b/client/src/app/+admin/overview/videos/video-list.component.scss@@ -1,11 +1,6 @@@use "_variables" as *;@use "_mixins" as *;-td {- padding-top: 0.25rem;- padding-bottom: 0.25rem;-}-my-embed {display: block;max-width: 500px;@@ -18,7 +13,7 @@ my-video-nsfw-badge {@include margin-right(5px);}-.video-info > div {+.video-expanded-info {display: flex;my-global-icon {@@ -29,17 +24,3 @@ my-video-nsfw-badge {@include margin-left(3px);}}--.loading {- opacity: 0.5;-}--.right-form {- display: flex;- flex-wrap: wrap;- row-gap: 0.5rem;-- > *:not(:last-child) {- @include margin-right(10px);- }-}diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.tsindex d64ed23383..2dcc18facc 100644--- a/client/src/app/+admin/overview/videos/video-list.component.ts+++ b/client/src/app/+admin/overview/videos/video-list.component.ts@@ -1,7 +1,7 @@-import { NgClass, NgFor, NgIf } from '@angular/common'+import { CommonModule } from '@angular/common'import { Component, OnInit, inject, viewChild } from '@angular/core'-import { ActivatedRoute, Router, RouterLink } from '@angular/router'-import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'+import { ActivatedRoute, RouterLink } from '@angular/router'+import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core'import { formatICU } from '@app/helpers'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'@@ -11,21 +11,18 @@ import { Video } from '@app/shared/shared-main/video/video.model'import { VideoService } from '@app/shared/shared-main/video/video.service'import { VideoBlockComponent } from '@app/shared/shared-moderation/video-block.component'import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { getAllFiles } from '@peertube/peertube-core-utils'import { FileStorage, NSFWFlag, UserRight, VideoFile, VideoState, VideoStreamingPlaylistType } from '@peertube/peertube-models'import { videoRequiresFileToken } from '@root-helpers/video'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule, TableRowExpandEvent } from 'primeng/table'-import { finalize } from 'rxjs/operators'+import { TableRowExpandEvent } from 'primeng/table'import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'-import { ActionDropdownComponent, DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'+import { DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'-import { AutoColspanDirective } from '../../../shared/shared-main/common/auto-colspan.directive'import { BytesPipe } from '../../../shared/shared-main/common/bytes.pipe'+import { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'import { EmbedComponent } from '../../../shared/shared-main/video/embed.component'-import { TableExpanderIconComponent } from '../../../shared/shared-tables/table-expander-icon.component'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'import { VideoCellComponent } from '../../../shared/shared-tables/video-cell.component'import {VideoActionsDisplayType,@@ -35,37 +32,36 @@ import { VideoNSFWBadgeComponent } from '../../../shared/shared-video/video-nsfwimport { VideoPrivacyBadgeComponent } from '../../../shared/shared-video/video-privacy-badge.component'import { VideoAdminService } from './video-admin.service'+type ColumnName =+ | 'video'+ | 'info'+ | 'localVideoFilesSize'+ | 'publishedAt'+@Component({selector: 'my-video-list',templateUrl: './video-list.component.html',styleUrls: [ './video-list.component.scss' ],imports: [+ CommonModule,GlobalIconComponent,- TableModule,- NgClass,- SharedModule,- NgIf,- ActionDropdownComponent,AdvancedInputFilterComponent,ButtonComponent,- NgbTooltip,- TableExpanderIconComponent,VideoActionsDropdownComponent,VideoCellComponent,- AutoColspanDirective,- NgFor,EmbedComponent,VideoBlockComponent,PTDatePipe,RouterLink,BytesPipe,VideoPrivacyBadgeComponent,- VideoNSFWBadgeComponent+ VideoNSFWBadgeComponent,+ TableComponent,+ NumberFormatterPipe]})-export class VideoListComponent extends RestTable<Video> implements OnInit {- protected route = inject(ActivatedRoute)- protected router = inject(Router)+export class VideoListComponent implements OnInit {+ private route = inject(ActivatedRoute)private confirmService = inject(ConfirmService)private auth = inject(AuthService)private notifier = inject(Notifier)@@ -77,15 +73,9 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {private videoFileTokenService = inject(VideoFileTokenService)readonly videoBlockModal = viewChild<VideoBlockComponent>('videoBlockModal')-- videos: Video[] = []-- totalRecords = 0- sort: SortMeta = { field: 'publishedAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<Video>>('table')bulkActions: DropdownAction<Video[]>[][] = []-inputFilters: AdvancedInputFilter[]videoActionsOptions: VideoActionsDisplayType = {@@ -103,10 +93,21 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {generateTranscription: true}- loading = true+ columns: TableColumnInfo<ColumnName>[] = [+ { id: 'video', label: $localize`Video`, sortable: false },+ { id: 'info', label: $localize`Info`, sortable: false },+ { id: 'localVideoFilesSize', label: $localize`Files`, sortable: true },+ { id: 'publishedAt', label: $localize`Published`, sortable: true }+ ]private videoFileTokens: { [videoId: number]: string } = {}+ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }+get authUser () {return this.auth.getUser()}@@ -116,8 +117,6 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {}ngOnInit () {- this.initialize()-this.inputFilters = this.videoAdminService.buildAdminInputFilter()this.bulkActions = [@@ -178,10 +177,6 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {]}- getIdentifier () {- return 'VideoListComponent'- }-isUnpublished (video: Video) {return video.state.id !== VideoState.LIVE_ENDED && video.state.id !== VideoState.PUBLISHED}@@ -248,7 +243,7 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {.subscribe({next: () => {this.notifier.success($localize`File removed.`)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -264,7 +259,7 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {.subscribe({next: () => {this.notifier.success($localize`Original file removed.`)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -274,14 +269,15 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {buildSearchAutoTag (tag: string) {const str = `autoTag:"${tag}"`- if (this.search) return this.search + ' ' + str+ const search = this.route.snapshot.queryParams.search+ if (search) return search + ' ' + strreturn str}// ---------------------------------------------------------------------------- onVideoPanelOpened (event: TableRowExpandEvent) {+ onRowExpand (event: TableRowExpandEvent) {const video = event.data as VideoDetailsif (!video.videoSource?.filename && !videoRequiresFileToken(video)) return@@ -301,27 +297,14 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {// ---------------------------------------------------------------------------- protected reloadDataInternal () {- this.loading = true-- this.videoAdminService.getAdminVideos({- pagination: this.pagination,- sort: this.sort,+ private _dataLoader (options: DataLoaderOptions) {+ return this.videoAdminService.getAdminVideos({+ ...options,// Always list NSFW video, overriding instance/user settingnsfw: 'both',- nsfwFlagsExcluded: NSFWFlag.NONE,-- search: this.search- }).pipe(finalize(() => this.loading = false))- .subscribe({- next: resultList => {- this.videos = resultList.data- this.totalRecords = resultList.total- },-- error: err => this.notifier.error(err.message)- })+ nsfwFlagsExcluded: NSFWFlag.NONE+ })}private async removeVideos (videos: Video[]) {@@ -343,7 +326,7 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {))- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -361,7 +344,7 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {))- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -390,7 +373,7 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {.subscribe({next: () => {this.notifier.success($localize`Files were removed.`)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -403,7 +386,7 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {next: () => {this.notifier.success($localize`Transcoding jobs created.`)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)diff --git a/client/src/app/+admin/system/jobs/jobs.component.html b/client/src/app/+admin/system/jobs/jobs.component.htmlindex 92e1741c49..a9bf7de160 100644--- a/client/src/app/+admin/system/jobs/jobs.component.html+++ b/client/src/app/+admin/system/jobs/jobs.component.html@@ -1,126 +1,102 @@-<div class="admin-sub-header">- <div class="select-filter-block">- <label for="jobType" i18n>Job type</label>-- <my-select-options- class="select-job-type" inputId="jobType" filter="true"- [items]="jobTypeItems" [(ngModel)]="jobType" (ngModelChange)="onJobStateOrTypeChanged()"- ></my-select-options>- </div>-- <div class="select-filter-block">- <label for="jobState" i18n>Job state</label>-- <my-select-options- class="select-job-state" inputId="jobState"- [items]="jobStateItems" [(ngModel)]="jobState" (ngModelChange)="onJobStateOrTypeChanged()"- ></my-select-options>- </div>-- <div class="align-self-end">- <my-button i18n-label label="Refresh" icon="refresh" (click)="refresh()"></my-button>- </div>-</div>--<p-table- [value]="jobs" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order"- (onLazyLoad)="loadLazy($event)" dataKey="uniqId" [first]="pagination.start" [tableStyle]="{'table-layout':'auto'}"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()" [expandedRowKeys]="expandedRows"+<my-table+ #table+ key="JobsComponent"+ dataKey="uniqId"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="jobs per page"+ columnConfig="true"+ [dataLoader]="dataLoader"+ [customParseQueryParams]="customParseQueryParams"+ [customUpdateUrl]="customUpdateUrl">- <ng-template #header>- <tr>- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>- <th scope="col" class="job-id" i18n>ID</th>- <th scope="col" style="width: 200px" class="job-type" i18n>Type</th>- <th scope="col" style="width: 200px" class="job-priority" i18n>Priority <small>(1 = highest priority)</small></th>- <th scope="col" style="width: 200px" class="job-state" i18n *ngIf="jobState === 'all'">State</th>- <th scope="col" style="width: 100px" class="job-progress" i18n *ngIf="hasGlobalProgress()">Progress</th>- <th scope="col" style="width: 200px" class="job-date" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>- <th scope="col" style="width: 230px;" i18n>Processed/Finished</th>- </tr>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No jobs} =1 {1 job} other {{{ totalRecords | myNumberFormatter }} jobs}}</ng-container></ng-template>- <ng-template #body let-expanded="expanded" let-job>- <tr>- <td class="expand-cell">- <my-table-expander-icon [pRowToggler]="job" [expanded]="expanded"></my-table-expander-icon>- </td>+ <ng-template #captionRight>+ <div class="select-filter-block">+ <label for="jobType" i18n>Job type</label>- <td class="job-id c-hand" [pRowToggler]="job" [title]="job.id">{{ job.id }}</td>+ <my-select-options+ class="select-job-type" inputId="jobType" filter="true"+ [items]="jobTypeItems" [(ngModel)]="jobType" (ngModelChange)="onJobStateOrTypeChanged()"+ ></my-select-options>+ </div>- <td class="job-type c-hand" [pRowToggler]="job">- <span class="pt-badge ellipsis" [ngClass]="getRandomJobTypeBadge(job.type)">{{ job.type }}</span>- </td>+ <div class="select-filter-block">+ <label for="jobState" i18n>Job state</label>- <td class="job-priority c-hand" [pRowToggler]="job">{{ job.priority }}</td>+ <my-select-options+ class="select-job-state" inputId="jobState"+ [items]="jobStateItems" [(ngModel)]="jobState" (ngModelChange)="onJobStateOrTypeChanged()"+ ></my-select-options>+ </div>- <td class="job-state c-hand" [pRowToggler]="job" *ngIf="jobState === 'all'">- <span class="ellipsis" [ngClass]="getJobStateClasses(job.state)">{{ job.state }}</span>- </td>+ <div class="align-self-end">+ <my-button i18n-label label="Refresh" icon="refresh" (click)="table.loadData()"></my-button>+ </div>+ </ng-template>++ <ng-template #tableCells let-job>+ <td *ngIf="table.isColumnDisplayed('id')" class="job-id c-hand" [title]="job.id">{{ job.id }}</td>++ <td *ngIf="table.isColumnDisplayed('type')" class="job-type c-hand" >+ <span class="pt-badge ellipsis" [ngClass]="getRandomJobTypeBadge(job.type)">{{ job.type }}</span>+ </td>- <td *ngIf="hasGlobalProgress()" class="job-progress c-hand" [pRowToggler]="job">- <ng-container *ngIf="hasProgress(job)">{{ getProgress(job) }}</ng-container>- </td>+ <td *ngIf="table.isColumnDisplayed('priority')" class="job-priority c-hand" >{{ job.priority }}</td>- <td class="job-date c-hand" [pRowToggler]="job">{{ job.createdAt }}</td>+ <td *ngIf="table.isColumnDisplayed('state') && table.isColumnDisplayed('state')" class="job-state c-hand" >+ <span class="ellipsis" [ngClass]="getJobStateClasses(job.state)">{{ job.state }}</span>+ </td>- <td class="fs-7">- <div>{{ job.processedOn }}</div>- <div>{{ job.finishedOn}}</div>- </td>- </tr>+ <td *ngIf="table.isColumnDisplayed('progress')" class="job-progress c-hand" >+ <ng-container *ngIf="hasProgress(job)">{{ getProgress(job) }}</ng-container>+ </td>++ <td *ngIf="table.isColumnDisplayed('createdAt')" class="job-date c-hand" >{{ job.createdAt }}</td>++ <td *ngIf="table.isColumnDisplayed('processed')" class="fs-7">+ <div>{{ job.processedOn }}</div>+ <div>{{ job.finishedOn}}</div>+ </td></ng-template>- <ng-template #expandedrow let-job>- <tr>- <td myAutoColspan>- <pre>{{ [- 'Job: ' + job.id,- 'Type: ' + job.type,- 'Processed on ' + (job.processedOn || '-'),- 'Finished on ' + (job.finishedOn || '-')- ].join('\n') }}</pre>- </td>- </tr>-- <tr>- <td myAutoColspan>- <pre>{{ job.data }}</pre>- </td>- </tr>-- <tr class="job-error" *ngIf="job.error">- <td myAutoColspan>- <pre>{{ job.error }}</pre>- </td>- </tr>+ <ng-template #expandedRow let-job>+ <div>+ <pre>{{ [+ 'Job: ' + job.id,+ 'Type: ' + job.type,+ 'Processed on ' + (job.processedOn || '-'),+ 'Finished on ' + (job.finishedOn || '-')+ ].join('\n') }}</pre>+ </div>++ <div>+ <pre>{{ job.data }}</pre>+ </div>++ <div>+ <pre>{{ job.error }}</pre>+ </div></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <div class="d-block">- @if (jobState === 'all') {- @if (jobType === 'all') {- <ng-container i18n>No jobs found.</ng-container>- } @else {- <ng-container i18n>No <code>{{ jobType }}</code> jobs found.</ng-container>- }- } @else {- @if (jobType === 'all') {- <ng-container i18n>No <span [ngClass]="getJobStateClasses(jobState)">{{ jobState }}</span> jobs found.</ng-container>- } @else {- <ng-container i18n>No <code>{{ jobType }}</code> jobs found that are <span [ngClass]="getJobStateClasses(jobState)">{{ jobState }}</span>.</ng-container>- }- }- </div>- </div>- </td>- </tr>+ <ng-template #noResults>+ @if (jobState === 'all') {+ @if (jobType === 'all') {+ <ng-container i18n>No jobs found.</ng-container>+ } @else {+ <ng-container i18n>No <code>{{ jobType }}</code> jobs found.</ng-container>+ }+ } @else {+ @if (jobType === 'all') {+ <ng-container i18n>No <span [ngClass]="getJobStateClasses(jobState)">{{ jobState }}</span> jobs found.</ng-container>+ } @else {+ <ng-container i18n>No <code>{{ jobType }}</code> jobs found that are <span [ngClass]="getJobStateClasses(jobState)">{{ jobState }}</span>.</ng-container>+ }+ }</ng-template>-</p-table>++</my-table>diff --git a/client/src/app/+admin/system/jobs/jobs.component.scss b/client/src/app/+admin/system/jobs/jobs.component.scssindex a4191a55a4..c360292ea2 100644--- a/client/src/app/+admin/system/jobs/jobs.component.scss+++ b/client/src/app/+admin/system/jobs/jobs.component.scss@@ -1,6 +1,6 @@-@use '_variables' as *;-@use '_mixins' as *;-@use 'form-mixins' as *;+@use "_variables" as *;+@use "_mixins" as *;+@use "form-mixins" as *;.select-job-state {display: block;@@ -32,14 +32,6 @@}}-.admin-sub-header {- justify-content: flex-end;-- .peertube-select-container {- @include peertube-select-container(auto);- }-}-pre {font-size: 11px;}diff --git a/client/src/app/+admin/system/jobs/jobs.component.ts b/client/src/app/+admin/system/jobs/jobs.component.tsindex 4ff7dd7ee2..c13777c0cd 100644--- a/client/src/app/+admin/system/jobs/jobs.component.ts+++ b/client/src/app/+admin/system/jobs/jobs.component.ts@@ -1,46 +1,48 @@-import { NgClass, NgIf } from '@angular/common'-import { Component, OnInit, inject } from '@angular/core'+import { CommonModule } from '@angular/common'+import { Component, OnInit, inject, viewChild } from '@angular/core'import { FormsModule } from '@angular/forms'-import { Notifier, RestPagination, RestTable } from '@app/core'+import { RestPagination } from '@app/core'import { SelectOptionsComponent } from '@app/shared/shared-forms/select/select-options.component'-import { AutoColspanDirective } from '@app/shared/shared-main/common/auto-colspan.directive'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { Job, JobState, JobType } from '@peertube/peertube-models'import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'+import { SortMeta } from 'primeng/api'import { SelectOptionsItem } from 'src/types'import { JobStateClient } from '../../../../types/job-state-client.type'import { JobTypeClient } from '../../../../types/job-type-client.type'import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'-import { TableExpanderIconComponent } from '../../../shared/shared-tables/table-expander-icon.component'+import { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'+import { TableColumnInfo, TableComponent, TableQueryParams } from '../../../shared/shared-tables/table.component'import { JobService } from './job.service'+type ColumnName = 'id' | 'type' | 'priority' | 'state' | 'progress' | 'createdAt' | 'processed'++type QueryParams = TableQueryParams & {+ jobType: string+ jobState: string+}+@Component({selector: 'my-jobs',templateUrl: './jobs.component.html',styleUrls: [ './jobs.component.scss' ],imports: [+ CommonModule,FormsModule,- NgClass,ButtonComponent,- TableModule,- SharedModule,- NgIf,- NgbTooltip,- TableExpanderIconComponent,SelectOptionsComponent,- AutoColspanDirective+ TableComponent,+ NumberFormatterPipe]})-export class JobsComponent extends RestTable implements OnInit {- private notifier = inject(Notifier)- private jobsService = inject(JobService)-+export class JobsComponent implements OnInit {private static LS_STATE = 'jobs-list-state'private static LS_TYPE = 'jobs-list-type'+ private jobsService = inject(JobService)++ readonly table = viewChild<TableComponent<Job, ColumnName>>('table')+jobState: JobStateClient = 'all'jobStates: JobStateClient[] = [ 'all', 'active', 'completed', 'failed', 'waiting', 'delayed' ]jobStateItems: SelectOptionsItem[] = this.jobStates.map(s => ({@@ -83,18 +85,27 @@ export class JobsComponent extends RestTable implements OnInit {]jobTypeItems: SelectOptionsItem[] = this.jobTypes.map(i => ({ id: i, label: i }))- jobs: Job[] = []- totalRecords: number- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ columns: TableColumnInfo<ColumnName>[] = [+ { id: 'id', class: 'job-id', label: $localize`ID`, sortable: false },+ { id: 'type', class: 'job-type', label: $localize`Type`, sortable: false },+ { id: 'priority', class: 'job-priority', label: $localize`Priority`, labelSmall: $localize`(1 = highest priority)`, sortable: false },+ { id: 'state', class: 'job-state', label: $localize`State`, isDisplayed: () => this.jobState === 'all', sortable: false },+ { id: 'progress', class: 'job-progress', label: $localize`Progress`, isDisplayed: () => this.hasGlobalProgress(), sortable: false },+ { id: 'createdAt', class: 'job-date', label: $localize`Created`, sortable: true },+ { id: 'processed', label: $localize`Processed/Finished`, sortable: false }+ ]+ customUpdateUrl: typeof this._customUpdateUrl+ customParseQueryParams: typeof this._customParseQueryParams+ dataLoader: typeof this._dataLoader++ constructor () {+ this.customUpdateUrl = this._customUpdateUrl.bind(this)+ this.customParseQueryParams = this._customParseQueryParams.bind(this)+ this.dataLoader = this._dataLoader.bind(this)+ }ngOnInit () {this.loadJobStateAndType()- this.initialize()- }-- getIdentifier () {- return 'JobsComponent'}getJobStateClasses (state: JobStateClient) {@@ -115,9 +126,7 @@ export class JobsComponent extends RestTable implements OnInit {}onJobStateOrTypeChanged () {- this.pagination.start = 0-- this.reloadData()+ this.table().onFilter()this.saveJobStateAndType()}@@ -135,36 +144,42 @@ export class JobsComponent extends RestTable implements OnInit {return ''}- refresh () {- this.jobs = []- this.totalRecords = 0+ getRandomJobTypeBadge (type: string) {+ return this.table().getRandomBadge('type', type)+ }- this.reloadData()+ private _customUpdateUrl (): Partial<QueryParams> {+ return {+ jobType: this.jobType,+ jobState: this.jobState+ }}- getRandomJobTypeBadge (type: string) {- return this.getRandomBadge('type', type)+ private _customParseQueryParams (queryParams: QueryParams) {+ if (queryParams.jobType) {+ this.jobType = queryParams.jobType as JobTypeClient+ }++ if (queryParams.jobState) {+ this.jobState = queryParams.jobState as JobStateClient+ }}- protected reloadDataInternal () {+ private _dataLoader (options: {+ pagination: RestPagination+ sort: SortMeta+ }) {+ const { pagination, sort } = options+let jobState = this.jobState as JobStateif (this.jobState === 'all') jobState = null- this.jobsService- .listJobs({- jobState,- jobType: this.jobType,- pagination: this.pagination,- sort: this.sort- })- .subscribe({- next: resultList => {- this.jobs = resultList.data- this.totalRecords = resultList.total- },-- error: err => this.notifier.error(err.message)- })+ return this.jobsService.listJobs({+ jobState,+ jobType: this.jobType,+ pagination,+ sort+ })}private loadJobStateAndType () {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.htmlindex 86ad7ddb73..955892f935 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@@ -1,129 +1,82 @@-<p-table- [value]="runnerJobs" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order"- [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false"- [(selection)]="selectedRows" [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [expandedRowKeys]="expandedRows" dataKey="uuid"+<my-table+ #table+ key="RunnerJobListComponent"+ dataKey="uuid"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="jobs per page"+ columnConfig="true"+ [dataLoader]="dataLoader"+ [bulkActions]="bulkActions">- <ng-template #header>- <tr>- <th class="checkbox-cell" scope="col" style="width: 40px">- <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>- </th>- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>- <th scope="col" style="width: 120px;">- <span i18n class="visually-hidden">Actions</span>- </th>- <th scope="col" i18n>UUID</th>- <th scope="col" i18n>Type</th>- <th scope="col" style="width: 150px" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th>- <th scope="col" style="width: 100px" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="priority">Priority <p-sortIcon field="priority"></p-sortIcon></th>- <th scope="col" style="width: 100px" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="progress">Progress <p-sortIcon field="progress"></p-sortIcon></th>- <th scope="col" style="width: 100px;" i18n>Runner</th>- <th scope="col" style="width: 200px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>- <th scope="col" style="width: 230px;" i18n>Processed/Finished</th>- </tr>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No job} =1 {1 job} other {{{ totalRecords | myNumberFormatter }} jobs}}</ng-container></ng-template>- <ng-template #caption>+ <ng-template #captionRight>+ <my-advanced-input-filter class="me-2" [filters]="inputFilters" (search)="table.onSearch($event)"></my-advanced-input-filter>- <div class="caption">- <div class="left-buttons">- <my-action-dropdown- *ngIf="isInSelectionMode()" i18n-label label="Batch actions" theme="primary"- [actions]="bulkActions" [entry]="selectedRows"- >- </my-action-dropdown>- </div>-- <div class="ms-auto d-flex flex-wrap gap-2">- <my-advanced-input-filter class="me-2" [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter>-- <my-button i18n-label label="Refresh" icon="refresh" (click)="reloadData()"></my-button>- </div>- </div>+ <my-button i18n-label label="Refresh" icon="refresh" (click)="table.loadData()"></my-button></ng-template>- <ng-template #body let-expanded="expanded" let-runnerJob>- <tr [pSelectableRow]="runnerJob">- <td class="checkbox-cell">- <p-tableCheckbox [value]="runnerJob" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>- </td>-- <td class="expand-cell">- <my-table-expander-icon [pRowToggler]="runnerJob" [expanded]="expanded"></my-table-expander-icon>- </td>+ <ng-template #tableCells let-runnerJob>+ <td *ngIf="table.isColumnDisplayed('uuid')">{{ runnerJob.uuid }}</td>- <td class="action-cell">- <my-action-dropdown- placement="bottom-right top-right left auto" container="body"- i18n-label label="Actions" [actions]="actions" [entry]="runnerJob" buttonSize="small"- ></my-action-dropdown>- </td>+ <td *ngIf="table.isColumnDisplayed('type')">+ <span class="pt-badge ellipsis" [title]="runnerJob.type" [ngClass]="getRandomRunnerTypeBadge(runnerJob.type)">{{ runnerJob.type }}</span>+ </td>- <td>{{ runnerJob.uuid }}</td>+ <td *ngIf="table.isColumnDisplayed('state')">+ <span class="pt-badge ellipsis" [title]="runnerJob.state.label" [ngClass]="getStateBadgeColor(runnerJob)">{{ runnerJob.state.label }}</span>+ </td>- <td>- <span class="pt-badge ellipsis" [title]="runnerJob.type" [ngClass]="getRandomRunnerTypeBadge(runnerJob.type)">{{ runnerJob.type }}</span>- </td>+ <td *ngIf="table.isColumnDisplayed('priority')">{{ runnerJob.priority }}</td>- <td>- <span class="pt-badge ellipsis" [title]="runnerJob.state.label" [ngClass]="getStateBadgeColor(runnerJob)">{{ runnerJob.state.label }}</span>- </td>+ <td *ngIf="table.isColumnDisplayed('progress')">+ <ng-container *ngIf="runnerJob.progress">{{ runnerJob.progress }}%</ng-container>+ </td>- <td>{{ runnerJob.priority }}</td>-- <td>- <ng-container *ngIf="runnerJob.progress">{{ runnerJob.progress }}%</ng-container>- </td>+ <td *ngIf="table.isColumnDisplayed('runner')">+ <div *ngIf="runnerJob.runner?.name" class="pt-badge" [ngClass]="getRandomRunnerNameBadge(runnerJob.runner.name)">+ {{ runnerJob.runner.name }}+ </div>+ </td>+ <td *ngIf="table.isColumnDisplayed('createdAt')">{{ runnerJob.createdAt }}</td>- <td>- <div *ngIf="runnerJob.runner?.name" class="pt-badge" [ngClass]="getRandomRunnerNameBadge(runnerJob.runner.name)">- {{ runnerJob.runner.name }}- </div>- </td>- <td>{{ runnerJob.createdAt }}</td>+ <td *ngIf="table.isColumnDisplayed('processed')" class="fs-7">+ <div>{{ runnerJob.startedAt }}</div>+ <div>{{ runnerJob.finishedAt}}</div>+ </td>+ </ng-template>- <td class="fs-7">- <div>{{ runnerJob.startedAt }}</div>- <div>{{ runnerJob.finishedAt}}</div>- </td>- </tr>+ <ng-template #actionCell let-runnerJob>+ <my-action-dropdown+ placement="bottom-right top-right left auto" container="body"+ i18n-label label="Actions" [actions]="actions" [entry]="runnerJob"+ ></my-action-dropdown></ng-template>- <ng-template #expandedrow let-runnerJob>- <tr>- <td myAutoColspan>- <div class="mt-2 fs-7 font-monospace">- Parent job: {{ runnerJob.parent?.uuid || '-' }} <br />- Processed on {{ (runnerJob.startedAt || '-') }} <br />- Finished on {{ (runnerJob.finishedAt || '-') }} <br />- </div>+ <ng-template #expandedRow let-runnerJob>+ <div class="mt-2 fs-7 font-monospace">+ Parent job: {{ runnerJob.parent?.uuid || '-' }} <br />+ Processed on {{ (runnerJob.startedAt || '-') }} <br />+ Finished on {{ (runnerJob.finishedAt || '-') }} <br />+ </div>- <div class="mt-2">- <strong i18n>Payload:</strong>- <pre>{{ runnerJob.payload }}</pre>- </div>+ <div class="mt-2">+ <strong i18n>Payload:</strong>+ <pre>{{ runnerJob.payload }}</pre>+ </div>- <div class="mt-2">- <strong i18n>Private payload:</strong>- <pre>{{ runnerJob.privatePayload }}</pre>- </div>+ <div class="mt-2">+ <strong i18n>Private payload:</strong>+ <pre>{{ runnerJob.privatePayload }}</pre>+ </div>- <pre *ngIf="runnerJob.error" class="text-danger" >{{ runnerJob.error }}</pre>- </td>- </tr>+ <pre *ngIf="runnerJob.error" class="text-danger" >{{ runnerJob.error }}</pre></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container i18n>No runner jobs found.</ng-container>- </div>- </td>- </tr>+ <ng-template #noResults>+ <ng-container i18n>No runner jobs found.</ng-container></ng-template>-</p-table>+</my-table>diff --git a/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts b/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.tsindex 2680789a24..eee5afda3c 100644--- a/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts+++ b/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts@@ -1,46 +1,35 @@-import { NgClass, NgIf } from '@angular/common'-import { Component, OnInit, inject } from '@angular/core'--import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'+import { CommonModule } from '@angular/common'+import { Component, OnInit, inject, viewChild } from '@angular/core'+import { ConfirmService, Notifier } from '@app/core'import { formatICU } from '@app/helpers'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { RunnerJob, RunnerJobState } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../../shared/shared-forms/advanced-input-filter.component'--import { AutoColspanDirective } from '../../../../shared/shared-main/common/auto-colspan.directive'import { ActionDropdownComponent, DropdownAction } from '../../../../shared/shared-main/buttons/action-dropdown.component'import { ButtonComponent } from '../../../../shared/shared-main/buttons/button.component'-import { TableExpanderIconComponent } from '../../../../shared/shared-tables/table-expander-icon.component'+import { NumberFormatterPipe } from '../../../../shared/shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'import { RunnerJobFormatted, RunnerService } from '../runner.service'+type ColumnName = 'uuid' | 'type' | 'state' | 'priority' | 'progress' | 'runner' | 'createdAt' | 'processed'+@Component({selector: 'my-runner-job-list',templateUrl: './runner-job-list.component.html',imports: [- TableModule,- SharedModule,- NgbTooltip,- NgIf,+ CommonModule,ActionDropdownComponent,AdvancedInputFilterComponent,ButtonComponent,- TableExpanderIconComponent,- NgClass,- AutoColspanDirective+ TableComponent,+ NumberFormatterPipe]})-export class RunnerJobListComponent extends RestTable<RunnerJob> implements OnInit {+export class RunnerJobListComponent implements OnInit {private runnerService = inject(RunnerService)private notifier = inject(Notifier)private confirmService = inject(ConfirmService)- runnerJobs: RunnerJobFormatted[] = []- totalRecords = 0-- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<RunnerJobFormatted, ColumnName>>('table')actions: DropdownAction<RunnerJob>[][] = []bulkActions: DropdownAction<RunnerJob[]>[][] = []@@ -69,6 +58,23 @@ export class RunnerJobListComponent extends RestTable<RunnerJob> implements OnIn}]+ columns: TableColumnInfo<ColumnName>[] = [+ { id: 'uuid', label: $localize`UUID`, sortable: false },+ { id: 'type', label: $localize`Type`, sortable: false },+ { id: 'state', label: $localize`State`, sortable: true },+ { id: 'priority', label: $localize`Priority`, sortable: true },+ { id: 'progress', label: $localize`Progress`, sortable: true },+ { id: 'runner', label: $localize`Runner`, sortable: false },+ { id: 'createdAt', label: $localize`Created`, sortable: true },+ { id: 'processed', label: $localize`Processed/Finished`, sortable: false }+ ]++ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }+ngOnInit () {this.actions = [[@@ -101,12 +107,6 @@ export class RunnerJobListComponent extends RestTable<RunnerJob> implements OnIn}]]-- this.initialize()- }-- getIdentifier () {- return 'RunnerJobListComponent'}async cancelJobs (jobs: RunnerJob[]) {@@ -122,7 +122,7 @@ export class RunnerJobListComponent extends RestTable<RunnerJob> implements OnInthis.runnerService.cancelJobs(jobs).subscribe({next: () => {- this.reloadData()+ this.table().loadData()this.notifier.success(formatICU(@@ -149,7 +149,7 @@ export class RunnerJobListComponent extends RestTable<RunnerJob> implements OnInthis.runnerService.removeJobs(jobs).subscribe({next: () => {- this.reloadData()+ this.table().loadData()this.notifier.success(formatICU(@@ -182,23 +182,17 @@ export class RunnerJobListComponent extends RestTable<RunnerJob> implements OnIn}getRandomRunnerNameBadge (value: string) {- return this.getRandomBadge('runner', value)+ return this.table().getRandomBadge('runner', value)}getRandomRunnerTypeBadge (value: string) {- return this.getRandomBadge('type', value)+ return this.table().getRandomBadge('type', value)}- protected reloadDataInternal () {- this.runnerService.listRunnerJobs({ pagination: this.pagination, sort: this.sort, search: this.search })- .subscribe({- next: resultList => {- this.runnerJobs = resultList.data- this.totalRecords = resultList.total- },+ private _dataLoader (options: DataLoaderOptions) {+ const { pagination, sort, search } = options- error: err => this.notifier.error(err.message)- })+ return this.runnerService.listRunnerJobs({ pagination, sort, search })}private canCancelJob (job: RunnerJob) {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.htmlindex e4e0205a4d..0f9fd7fdb3 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@@ -1,50 +1,36 @@-<p-table- [value]="runners" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order"- [lazy]="true" (onLazyLoad)="loadLazy($event)"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"+<my-table+ #table+ key="RunnerListComponent"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="runners per page"+ [dataLoader]="dataLoader"+ columnConfig="false">- <ng-template #header>- <tr>- <th scope="col" style="width: 120px;">- <span i18n class="visually-hidden">Actions</span>- </th>- <th scope="col" i18n>Name</th>- <th scope="col" i18n>Description</th>- <th scope="col" i18n>IP</th>- <th scope="col" i18n>Last contact</th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>- </tr>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No runner} =1 {1 runner} other {{{ totalRecords | myNumberFormatter }} runners}}</ng-container></ng-template>- <ng-template #body let-runner>- <tr>- <td class="action-cell">- <my-action-dropdown- placement="bottom-right top-right left auto" container="body"- i18n-label label="Actions" [actions]="actions" [entry]="runner" buttonSize="small"- ></my-action-dropdown>- </td>+ <ng-template #tableCells let-runner>+ <td>{{ runner.name }}</td>- <td>{{ runner.name }}</td>+ <td class="max-width-300px">{{ runner.description }}</td>- <td>{{ runner.description }}</td>+ <td>{{ runner.ip }}</td>- <td>{{ runner.ip }}</td>+ <td>{{ runner.lastContact | ptDate: 'short' }}</td>- <td>{{ runner.lastContact | ptDate: 'short' }}</td>+ <td>{{ runner.createdAt | ptDate: 'short' }}</td>+ </ng-template>- <td>{{ runner.createdAt | ptDate: 'short' }}</td>- </tr>+ <ng-template #actionCell let-runner>+ <my-action-dropdown+ placement="bottom-right top-right left auto" container="body"+ i18n-label label="Actions" [actions]="actions" [entry]="runner"+ ></my-action-dropdown></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container i18n>No remote runners found.</ng-container>- </div>- </td>- </tr>+ <ng-template #noResults>+ <ng-container i18n>No remote runners found.</ng-container></ng-template>-</p-table>+</my-table>diff --git a/client/src/app/+admin/system/runners/runner-list/runner-list.component.ts b/client/src/app/+admin/system/runners/runner-list/runner-list.component.tsindex 03a36c8143..37985618e1 100644--- a/client/src/app/+admin/system/runners/runner-list/runner-list.component.ts+++ b/client/src/app/+admin/system/runners/runner-list/runner-list.component.ts@@ -1,54 +1,56 @@-import { Component, OnInit, inject } from '@angular/core'-import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'+import { CommonModule } from '@angular/common'+import { Component, OnInit, inject, viewChild } from '@angular/core'+import { ConfirmService, Notifier } from '@app/core'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { Runner } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'import { ActionDropdownComponent, DropdownAction } from '../../../../shared/shared-main/buttons/action-dropdown.component'-import { AutoColspanDirective } from '../../../../shared/shared-main/common/auto-colspan.directive'+import { NumberFormatterPipe } from '../../../../shared/shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'import { RunnerService } from '../runner.service'@Component({selector: 'my-runner-list',templateUrl: './runner-list.component.html',imports: [- TableModule,- SharedModule,- NgbTooltip,+ CommonModule,ActionDropdownComponent,- AutoColspanDirective,- PTDatePipe+ PTDatePipe,+ TableComponent,+ NumberFormatterPipe]})-export class RunnerListComponent extends RestTable<Runner> implements OnInit {+export class RunnerListComponent implements OnInit {private runnerService = inject(RunnerService)private notifier = inject(Notifier)private confirmService = inject(ConfirmService)- runners: Runner[] = []- totalRecords = 0-- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<Runner>>('table')actions: DropdownAction<Runner>[][] = []+ columns: TableColumnInfo<string>[] = [+ { id: 'name', label: $localize`Name`, sortable: false },+ { id: 'description', label: $localize`Description`, sortable: false },+ { id: 'ip', label: $localize`IP`, sortable: false },+ { id: 'lastContact', label: $localize`Last contact`, sortable: false },+ { id: 'createdAt', label: $localize`Created`, sortable: true }+ ]++ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }+ngOnInit () {this.actions = [[{label: $localize`Remove`,- handler: runer => this.deleteRunner(runer)+ handler: runner => this.deleteRunner(runner)}]]-- this.initialize()- }-- getIdentifier () {- return 'RunnerListComponent'}async deleteRunner (runner: Runner) {@@ -62,7 +64,7 @@ export class RunnerListComponent extends RestTable<Runner> implements OnInit {this.runnerService.deleteRunner(runner).subscribe({next: () => {- this.reloadData()+ this.table().loadData()this.notifier.success($localize`Runner removed.`)},@@ -70,15 +72,7 @@ export class RunnerListComponent extends RestTable<Runner> implements OnInit {})}- protected reloadDataInternal () {- this.runnerService.listRunners({ pagination: this.pagination, sort: this.sort })- .subscribe({- next: resultList => {- this.runners = resultList.data- this.totalRecords = resultList.total- },-- error: err => this.notifier.error(err.message)- })+ private _dataLoader (options: DataLoaderOptions) {+ return this.runnerService.listRunners(options)}}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.htmlindex 940647d111..f014cad1a7 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@@ -1,59 +1,44 @@-<p-table- [value]="registrationTokens" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order"- [lazy]="true" (onLazyLoad)="loadLazy($event)"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"+<my-table+ #table+ key="RunnerRegistrationTokenListComponent"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="tokens per page"+ [dataLoader]="dataLoader"+ columnConfig="false">- <ng-template #header>- <tr>- <th scope="col" style="width: 120px;">- <span i18n class="visually-hidden">Actions</span>- </th>- <th scope="col" i18n>Token</th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>- <th scope="col" style="width: 160px;" i18n>Associated runners</th>- </tr>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No token} =1 {1 token} other {{{ totalRecords | myNumberFormatter }} tokens}}</ng-container></ng-template>- <ng-template #caption>- <div class="caption">- <div class="left-buttons">- <my-button theme="primary" i18n-label label="Generate token" icon="add" (click)="generateToken()"></my-button>- </div>- </div>+ <ng-template #captionRight>+ <my-button theme="primary" i18n-label label="Generate token" icon="add" (click)="generateToken()"></my-button>+</ng-template>- <ng-template #body let-registrationToken>- <tr>- <td class="action-cell">- <my-action-dropdown- placement="bottom-right top-right left auto" container="body"- i18n-label label="Actions" [actions]="actions" [entry]="registrationToken" buttonSize="small"- ></my-action-dropdown>- </td>+ <ng-template #tableCells let-registrationToken>+ <td>+ {{ registrationToken.registrationToken }}- <td>- {{ registrationToken.registrationToken }}+ <my-copy-button+ [value]="registrationToken.registrationToken" i18n-notification notification="Registration token copied"+ i18n-title title="Copy registration token"+ ></my-copy-button>+ </td>- <my-copy-button- [value]="registrationToken.registrationToken" i18n-notification notification="Registration token copied"- i18n-title title="Copy registration token"- ></my-copy-button>- </td>+ <td>{{ registrationToken.createdAt | ptDate: 'short' }}</td>- <td>{{ registrationToken.createdAt | ptDate: 'short' }}</td>+ <td>{{ registrationToken.registeredRunnersCount }}</td>+ </ng-template>- <td>{{ registrationToken.registeredRunnersCount }}</td>- </tr>+ <ng-template #actionCell let-registrationToken>+ <my-action-dropdown+ placement="bottom-right top-right left auto" container="body"+ i18n-label label="Actions" [actions]="actions" [entry]="registrationToken"+ ></my-action-dropdown></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container i18n>No registration token found for remote runners.</ng-container>- </div>- </td>- </tr>+ <ng-template #noResults>+ <ng-container i18n>No registration token found for remote runners.</ng-container></ng-template>-</p-table>+</my-table>diff --git a/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.scss b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.scssindex 1cfb2e65f9..f3e1405397 100644--- a/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.scss+++ b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.scss@@ -1,11 +1,11 @@-@use '_variables' as *;-@use '_mixins' as *;+@use "_variables" as *;+@use "_mixins" as *;my-copy-button {@include margin-left(3px);}-tr:not(:hover) {+my-table ::ng-deep tr:not(:hover) {my-copy-button {opacity: 0;}diff --git a/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.ts b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.tsindex c29bf62c70..1dc6dbc019 100644--- a/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.ts+++ b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.ts@@ -1,16 +1,13 @@-import { Component, OnInit, inject } from '@angular/core'--import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'+import { CommonModule } from '@angular/common'+import { Component, OnInit, inject, viewChild } from '@angular/core'+import { ConfirmService, Notifier } from '@app/core'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { RunnerRegistrationToken } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'-import { ActionDropdownComponent, DropdownAction } from '../../../../shared/shared-main/buttons/action-dropdown.component'import { ButtonComponent } from '../../../../shared/shared-main/buttons/button.component'import { CopyButtonComponent } from '../../../../shared/shared-main/buttons/copy-button.component'-import { AutoColspanDirective } from '../../../../shared/shared-main/common/auto-colspan.directive'+import { NumberFormatterPipe } from '../../../../shared/shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'import { RunnerService } from '../runner.service'@Component({@@ -18,29 +15,36 @@ import { RunnerService } from '../runner.service'styleUrls: [ './runner-registration-token-list.component.scss' ],templateUrl: './runner-registration-token-list.component.html',imports: [- TableModule,- SharedModule,- NgbTooltip,+ CommonModule,ButtonComponent,ActionDropdownComponent,CopyButtonComponent,- AutoColspanDirective,- PTDatePipe+ PTDatePipe,+ NumberFormatterPipe,+ TableComponent]})-export class RunnerRegistrationTokenListComponent extends RestTable<RunnerRegistrationToken> implements OnInit {+export class RunnerRegistrationTokenListComponent implements OnInit {private runnerService = inject(RunnerService)private notifier = inject(Notifier)private confirmService = inject(ConfirmService)- registrationTokens: RunnerRegistrationToken[] = []- totalRecords = 0-- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<RunnerRegistrationToken>>('table')actions: DropdownAction<RunnerRegistrationToken>[][] = []+ columns: TableColumnInfo<string>[] = [+ { id: 'token', label: $localize`Token`, sortable: false },+ { id: 'createdAt', label: $localize`Created`, sortable: true },+ { id: 'runners', label: $localize`Associated runners`, sortable: false }+ ]++ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }+ngOnInit () {this.actions = [[@@ -50,19 +54,13 @@ export class RunnerRegistrationTokenListComponent extends RestTable<RunnerRegist}]]-- this.initialize()- }-- getIdentifier () {- return 'RunnerRegistrationTokenListComponent'}generateToken () {this.runnerService.generateToken().subscribe({next: () => {- this.reloadData()+ this.table().loadData()this.notifier.success($localize`Registration token generated.`)},@@ -81,7 +79,7 @@ export class RunnerRegistrationTokenListComponent extends RestTable<RunnerRegistthis.runnerService.removeToken(token).subscribe({next: () => {- this.reloadData()+ this.table().loadData()this.notifier.success($localize`Registration token removed.`)},@@ -89,15 +87,7 @@ export class RunnerRegistrationTokenListComponent extends RestTable<RunnerRegist})}- protected reloadDataInternal () {- this.runnerService.listRegistrationTokens({ pagination: this.pagination, sort: this.sort })- .subscribe({- next: resultList => {- this.registrationTokens = resultList.data- this.totalRecords = resultList.total- },-- error: err => this.notifier.error(err.message)- })+ private _dataLoader (options: DataLoaderOptions) {+ return this.runnerService.listRegistrationTokens(options)}}diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.tsindex 6455e0a99a..89a3c57b15 100644--- a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts+++ b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts@@ -1,33 +1,14 @@-import { NgIf } from '@angular/common'import { Component } from '@angular/core'-import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'-import { GenericAccountBlocklistComponent } from '@app/shared/shared-moderation/account-blocklist.component'import { BlocklistComponentType } from '@app/shared/shared-moderation/blocklist.service'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'-import { SharedModule } from 'primeng/api'-import { TableModule } from 'primeng/table'-import { ActorAvatarComponent } from '../../shared/shared-actor-image/actor-avatar.component'-import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'-import { AutoColspanDirective } from '../../shared/shared-main/common/auto-colspan.directive'+import { GenericAccountBlocklistComponent } from '@app/shared/shared-moderation/generic-account-blocklist.component'@Component({selector: 'my-account-blocklist',- templateUrl: '../../shared/shared-moderation/account-blocklist.component.html',+ template: `<my-generic-account-blocklist [mode]="mode" key="MyAccountBlocklistComponent" />`,imports: [- TableModule,- SharedModule,- AdvancedInputFilterComponent,- NgbTooltip,- ActorAvatarComponent,- AutoColspanDirective,- NgIf,- PTDatePipe+ GenericAccountBlocklistComponent]})-export class MyAccountBlocklistComponent extends GenericAccountBlocklistComponent {+export class MyAccountBlocklistComponent {mode = BlocklistComponentType.Account-- getIdentifier () {- return 'MyAccountBlocklistComponent'- }}diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.tsindex 25adf4a291..be6c8e221d 100644--- a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts+++ b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts@@ -1,36 +1,14 @@-import { NgIf } from '@angular/common'import { Component } from '@angular/core'-import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { BlocklistComponentType } from '@app/shared/shared-moderation/blocklist.service'-import { GenericServerBlocklistComponent } from '@app/shared/shared-moderation/server-blocklist.component'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'-import { SharedModule } from 'primeng/api'-import { TableModule } from 'primeng/table'-import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'-import { GlobalIconComponent } from '../../shared/shared-icons/global-icon.component'-import { AutoColspanDirective } from '../../shared/shared-main/common/auto-colspan.directive'-import { BatchDomainsModalComponent } from '../../shared/shared-moderation/batch-domains-modal.component'+import { GenericServerBlocklistComponent } from '../../shared/shared-moderation/generic-server-blocklist.component'@Component({selector: 'my-account-server-blocklist',- styleUrls: [ '../../shared/shared-moderation/moderation.scss', '../../shared/shared-moderation/server-blocklist.component.scss' ],- templateUrl: '../../shared/shared-moderation/server-blocklist.component.html',+ template: `<my-generic-server-blocklist [mode]="mode" key="MyAccountServerBlocklistComponent" />`,imports: [- GlobalIconComponent,- TableModule,- SharedModule,- AdvancedInputFilterComponent,- NgbTooltip,- AutoColspanDirective,- NgIf,- BatchDomainsModalComponent,- PTDatePipe+ GenericServerBlocklistComponent]})-export class MyAccountServerBlocklistComponent extends GenericServerBlocklistComponent {+export class MyAccountServerBlocklistComponent {mode = BlocklistComponentType.Account-- getIdentifier () {- return 'MyAccountServerBlocklistComponent'- }}diff --git a/client/src/app/+my-library/+my-video-channels/my-video-channels.component.html b/client/src/app/+my-library/+my-video-channels/my-video-channels.component.htmlindex d8501fdd18..4c85429394 100644--- a/client/src/app/+my-library/+my-video-channels/my-video-channels.component.html+++ b/client/src/app/+my-library/+my-video-channels/my-video-channels.component.html@@ -1,10 +1,10 @@<my-channels-setup-message [hideLink]="true"></my-channels-setup-message>-<div class="video-channels-header d-flex justify-content-between align-items-end gap-2 flex-wrap">- <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter>-+<div class="video-channels-header d-flex align-items-end gap-2 flex-wrap"><span *ngIf="pagination.totalItems" class="total-items">{{ getTotalTitle() }}</span>+ <my-advanced-input-filter class="d-block ms-auto" (search)="onSearch($event)" emitOnInit="true"></my-advanced-input-filter>+<a class="peertube-create-button" routerLink="/manage/create"><my-global-icon iconName="add" aria-hidden="true"></my-global-icon><ng-container i18n>Create video channel</ng-container>diff --git a/client/src/app/+my-library/comments-on-my-videos/comments-on-my-videos.component.html b/client/src/app/+my-library/comments-on-my-videos/comments-on-my-videos.component.htmlindex 531cddb0e9..b655d7d322 100644--- a/client/src/app/+my-library/comments-on-my-videos/comments-on-my-videos.component.html+++ b/client/src/app/+my-library/comments-on-my-videos/comments-on-my-videos.component.html@@ -1,2 +1,2 @@-<my-video-comment-list-admin-owner mode="user"></my-video-comment-list-admin-owner>+<my-video-comment-list-admin-owner mode="user" key="UserVideoCommentList"></my-video-comment-list-admin-owner>diff --git a/client/src/app/+my-library/my-follows/my-followers.component.html b/client/src/app/+my-library/my-follows/my-followers.component.htmlindex 90adb5d341..33d144278b 100644--- a/client/src/app/+my-library/my-follows/my-followers.component.html+++ b/client/src/app/+my-library/my-follows/my-followers.component.html@@ -1,7 +1,7 @@<div class="followers-header d-flex justify-content-between align-items-end gap-2 flex-wrap"><span class="total-items" *ngIf="pagination.totalItems"> {{ getTotalTitle() }}</span>- <my-advanced-input-filter [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter>+ <my-advanced-input-filter class="d-block ms-auto" [filters]="inputFilters" (search)="onSearch($event)" emitOnInit="true"></my-advanced-input-filter></div><div class="no-results" i18n *ngIf="pagination.totalItems === 0">No follower found.</div>diff --git a/client/src/app/+my-library/my-follows/my-subscriptions.component.html b/client/src/app/+my-library/my-follows/my-subscriptions.component.htmlindex def2a4a239..8db7545216 100644--- a/client/src/app/+my-library/my-follows/my-subscriptions.component.html+++ b/client/src/app/+my-library/my-follows/my-subscriptions.component.html@@ -1,7 +1,7 @@<div class="mb-4 d-flex justify-content-between align-items-end gap-2 flex-wrap"><span class="total-items" *ngIf="pagination.totalItems"> {{ getTotalTitle() }}</span>- <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter>+ <my-advanced-input-filter class="d-block ms-auto" (search)="onSearch($event)" emitOnInit="true"></my-advanced-input-filter></div><div class="no-results" i18n *ngIf="pagination.totalItems === 0">You don't have any subscription yet.</div>diff --git a/client/src/app/+my-library/my-history/my-history.component.html b/client/src/app/+my-library/my-history/my-history.component.htmlindex d9c2f6339e..4e20c13e3f 100644--- a/client/src/app/+my-library/my-history/my-history.component.html+++ b/client/src/app/+my-library/my-history/my-history.component.html@@ -1,6 +1,6 @@<div class="top-buttons"><div class="search-wrapper">- <my-advanced-input-filter [emitOnInit]="false" (search)="onSearch($event)"></my-advanced-input-filter>+ <my-advanced-input-filter emitOnInit="true" (search)="onSearch($event)"></my-advanced-input-filter></div><div class="history-switch">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.htmlindex f0e32104d2..f22eb616d7 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@@ -1,62 +1,50 @@-<p-table- [value]="videoChangeOwnerships" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage"- [first]="pagination.start" [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)"+<my-table+ #table+ key="MyOwnershipComponent"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="entries per page"+ [dataLoader]="dataLoader"+ columnConfig="false">- <ng-template #header>- <tr>- <th scope="col" style="width: 150px;" i18n>Actions</th>- <th scope="col" style="width: 35%;" i18n>Initiator</th>- <th scope="col" style="width: 65%;" i18n>Video</th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">- Created- <p-sortIcon field="createdAt"></p-sortIcon>- </th>- <th scope="col" style="width: 100px;" i18n>Status</th>- </tr>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No entry} =1 {1 entry} other {{{ totalRecords | myNumberFormatter }} entries}}</ng-container></ng-template>- <ng-template #body let-videoChangeOwnership>- <tr>- <td class="action-cell">- <ng-container *ngIf="videoChangeOwnership.status === 'WAITING'">- <my-button i18n-title title="Accept" icon="tick" (click)="openAcceptModal(videoChangeOwnership)"></my-button>- <my-button i18n-title title="Refuse" icon="cross" (click)="refuse(videoChangeOwnership)"></my-button>- </ng-container>- </td>- <td>- <a [href]="videoChangeOwnership.initiatorAccount.url" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">- <div class="chip two-lines">- <my-actor-avatar [actor]="videoChangeOwnership.initiatorAccount" actorType="account" size="32"></my-actor-avatar>- <div>- {{ videoChangeOwnership.initiatorAccount.displayName }}- <span class="muted">{{ videoChangeOwnership.initiatorAccount.nameWithHost }}</span>- </div>+ <ng-template #tableCells let-entry>+ <td>+ <a [href]="entry.initiatorAccount.url" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">+ <div class="chip two-lines">+ <my-actor-avatar [actor]="entry.initiatorAccount" actorType="account" size="32"></my-actor-avatar>+ <div>+ {{ entry.initiatorAccount.displayName }}+ <span class="muted">{{ entry.initiatorAccount.nameWithHost }}</span></div>- </a>- </td>+ </div>+ </a>+ </td>- <td>- <my-video-cell [video]="videoChangeOwnership.video" size="small"></my-video-cell>- </td>+ <td>+ <my-video-cell [video]="entry.video" size="small"></my-video-cell>+ </td>- <td>{{ videoChangeOwnership.createdAt | ptDate: 'short' }}</td>+ <td>{{ entry.createdAt | ptDate: 'short' }}</td>- <td>- <span class="pt-badge"- [ngClass]="getStatusClass(videoChangeOwnership.status)">{{ videoChangeOwnership.status }}</span>- </td>- </tr>+ <td>+ <span class="pt-badge" [ngClass]="getStatusClass(entry.status)">{{ entry.status }}</span>+ </td></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container i18n>No ownership change request found.</ng-container>- </div>- </td>- </tr>+ <ng-template #actionCell let-entry>+ @if (entry.status === 'WAITING') {+ <my-button i18n-title title="Accept" icon="tick" (click)="openAcceptModal(entry)"></my-button>+ <my-button i18n-title title="Refuse" icon="cross" (click)="refuse(entry)"></my-button>+ }+ </ng-template>++ <ng-template #noResults>+ <ng-container i18n>No ownership change request found.</ng-container></ng-template>-</p-table>+</my-table><my-accept-ownership #myAcceptOwnershipComponent (accepted)="accepted()"></my-accept-ownership>diff --git a/client/src/app/+my-library/my-ownership/my-ownership.component.ts b/client/src/app/+my-library/my-ownership/my-ownership.component.tsindex 2fccabbf0f..eb48a2ac35 100644--- a/client/src/app/+my-library/my-ownership/my-ownership.component.ts+++ b/client/src/app/+my-library/my-ownership/my-ownership.component.ts@@ -1,52 +1,50 @@-import { NgClass, NgIf } from '@angular/common'-import { Component, OnInit, inject, viewChild } from '@angular/core'-import { Notifier, RestPagination, RestTable } from '@app/core'+import { CommonModule, NgClass } from '@angular/common'+import { Component, inject, viewChild } from '@angular/core'+import { Notifier } from '@app/core'import { Account } from '@app/shared/shared-main/account/account.model'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { VideoOwnershipService } from '@app/shared/shared-main/video/video-ownership.service'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '@app/shared/shared-tables/table.component'import { VideoChangeOwnership, VideoChangeOwnershipStatus, VideoChangeOwnershipStatusType } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'import { ActorAvatarComponent } from '../../shared/shared-actor-image/actor-avatar.component'import { ButtonComponent } from '../../shared/shared-main/buttons/button.component'-import { AutoColspanDirective } from '../../shared/shared-main/common/auto-colspan.directive'+import { NumberFormatterPipe } from '../../shared/shared-main/common/number-formatter.pipe'import { VideoCellComponent } from '../../shared/shared-tables/video-cell.component'import { MyAcceptOwnershipComponent } from './my-accept-ownership/my-accept-ownership.component'+import { map } from 'rxjs'@Component({templateUrl: './my-ownership.component.html',imports: [- TableModule,- SharedModule,- NgbTooltip,- NgIf,+ CommonModule,ButtonComponent,ActorAvatarComponent,NgClass,- AutoColspanDirective,MyAcceptOwnershipComponent,PTDatePipe,- VideoCellComponent+ VideoCellComponent,+ NumberFormatterPipe,+ TableComponent]})-export class MyOwnershipComponent extends RestTable implements OnInit {+export class MyOwnershipComponent {private notifier = inject(Notifier)private videoOwnershipService = inject(VideoOwnershipService)- videoChangeOwnerships: VideoChangeOwnership[] = []- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }-readonly myAccountAcceptOwnershipComponent = viewChild<MyAcceptOwnershipComponent>('myAcceptOwnershipComponent')+ readonly table = viewChild<TableComponent<VideoChangeOwnership>>('table')- ngOnInit () {- this.initialize()- }+ columns: TableColumnInfo<string>[] = [+ { id: 'initiator', label: $localize`Initiator`, sortable: false },+ { id: 'video', label: $localize`Video`, sortable: false },+ { id: 'createdAt', label: $localize`Created`, sortable: true },+ { id: 'status', label: $localize`Status`, sortable: false }+ ]- getIdentifier () {- return 'MyOwnershipComponent'+ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)}getStatusClass (status: VideoChangeOwnershipStatusType) {@@ -65,30 +63,29 @@ export class MyOwnershipComponent extends RestTable implements OnInit {}accepted () {- this.reloadData()+ this.table().loadData()}refuse (videoChangeOwnership: VideoChangeOwnership) {this.videoOwnershipService.refuseOwnership(videoChangeOwnership.id).subscribe({- next: () => this.reloadData(),+ next: () => this.table().loadData(),error: err => this.notifier.error(err.message)})}- protected reloadDataInternal () {- return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort)- .subscribe({- next: resultList => {- this.videoChangeOwnerships = resultList.data.map(change => ({+ private _dataLoader (options: DataLoaderOptions) {+ return this.videoOwnershipService.getOwnershipChanges(options.pagination, options.sort)+ .pipe(+ map(resultList => ({+ data: resultList.data.map(change => ({...change,+initiatorAccount: new Account(change.initiatorAccount),nextOwnerAccount: new Account(change.nextOwnerAccount)- }))- this.totalRecords = resultList.total- },-- error: err => this.notifier.error(err.message)- })+ })),+ total: resultList.total+ }))+ )}}diff --git a/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.html b/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.htmlindex b9c108fcda..c404382b5c 100644--- a/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.html+++ b/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.html@@ -1,87 +1,63 @@-<my-alert *ngIf="error" type="danger">{{ error }}</my-alert>-<div *ngIf="!syncEnabled()"><p class="muted" i18n>⚠️ The instance doesn't allow channel synchronization</p></div>-<p-table- *ngIf="syncEnabled()" [value]="channelSyncs" [lazy]="true"- [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions"- [first]="pagination.start" [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [expandedRowKeys]="expandedRows"+<my-table+ #table+ key="MyVideoChannelsSyncComponent"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="syncs per page"+ [dataLoader]="dataLoader"+ columnConfig="false">- <ng-template #caption>- <div class="caption">- <div class="left-buttons">- <a class="peertube-create-button" routerLink="{{ getSyncCreateLink() }}">- <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>- <ng-container i18n>Add synchronization</ng-container>- </a>- </div>- </div>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No sync} =1 {1 sync} other {{{ totalRecords | myNumberFormatter }} syncs}}</ng-container></ng-template>- <ng-template #header>- <tr>- <th scope="col" style="width: 10%;">- <span i18n class="visually-hidden">Actions</span>- </th>- <th scope="col" style="width: 25%" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="externalChannelUrl">External Channel <p-sortIcon field="externalChannelUrl"></p-sortIcon></th>- <th scope="col" style="width: 25%" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="videoChannel">Channel <p-sortIcon field="videoChannel"></p-sortIcon></th>- <th scope="col" style="width: 10%" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th>- <th scope="col" style="width: 10%" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>- <th scope="col" style="width: 10%" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="lastSyncAt">Last synchronization at <p-sortIcon field="lastSyncAt"></p-sortIcon></th>- </tr>+ <ng-template #captionRight>+ <a class="peertube-create-button" routerLink="{{ getSyncCreateLink() }}">+ <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>+ <ng-container i18n>Add synchronization</ng-container>+ </a></ng-template>- <ng-template #body let-expanded="expanded" let-videoChannelSync>- <tr>- <td class="action-cell">- <my-action-dropdown- container="body" [actions]="videoChannelSyncActions" [entry]="videoChannelSync"- buttonSize="small"- ></my-action-dropdown>- </td>-- <td>- <a [href]="videoChannelSync.externalChannelUrl" target="_blank" rel="noopener noreferrer">{{ videoChannelSync.externalChannelUrl }}</a>- </td>-- <td>- <a [routerLink]="[ '/c', videoChannelSync.channel.name ]" i18n-title title="Channel page">- <div class="chip two-lines">- <my-actor-avatar- [actor]="videoChannelSync.channel" actorType="channel"- [internalHref]="[ '/c', videoChannelSync.channel.name ]" size="32"- ></my-actor-avatar>-- <div>- <span class="fw-semibold">{{ videoChannelSync.channel.displayName }}</span>- <span class="muted">{{ videoChannelSync.channel.name }}</span>- </div>+ <ng-template #tableCells let-sync>+ <td>+ <a [href]="sync.externalChannelUrl" target="_blank" rel="noopener noreferrer">{{ sync.externalChannelUrl }}</a>+ </td>++ <td>+ <a [routerLink]="[ '/c', sync.channel.name ]" i18n-title title="Channel page">+ <div class="chip two-lines">+ <my-actor-avatar+ [actor]="sync.channel" actorType="channel"+ [internalHref]="[ '/c', sync.channel.name ]" size="32"+ ></my-actor-avatar>++ <div>+ <span class="fw-semibold">{{ sync.channel.displayName }}</span>+ <span class="muted">{{ sync.channel.name }}</span></div>- </a>- </td>+ </div>+ </a>+ </td>- <td>- <span [ngClass]="getSyncStateClass(videoChannelSync.state.id)">- {{ videoChannelSync.state.label }}- </span>- </td>+ <td>+ <span [ngClass]="getSyncStateClass(sync.state.id)">+ {{ sync.state.label }}+ </span>+ </td>- <td>{{ videoChannelSync.createdAt | ptDate: 'short' }}</td>- <td>{{ videoChannelSync.lastSyncAt | ptDate: 'short' }}</td>- </tr>+ <td>{{ sync.createdAt | ptDate: 'short' }}</td>+ <td>{{ sync.lastSyncAt | ptDate: 'short' }}</td></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container i18n>You don't have channel synchronisation configured.</ng-container>- </div>- </td>- </tr>+ <ng-template #actionCell let-sync>+ <my-action-dropdown container="body" [actions]="videoChannelSyncActions" [entry]="sync"></my-action-dropdown>+ </ng-template>++ <ng-template #noResults>+ <ng-container i18n>You don't have channel synchronisation configured.</ng-container></ng-template>-</p-table>+</my-table>diff --git a/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.ts b/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.tsindex 11e062686d..9e05844f21 100644--- a/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.ts+++ b/client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.ts@@ -1,53 +1,41 @@-import { NgClass, NgIf } from '@angular/common'-import { Component, OnInit, inject } from '@angular/core'+import { CommonModule } from '@angular/common'+import { Component, OnInit, inject, viewChild } from '@angular/core'import { RouterLink } from '@angular/router'-import { AuthService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'+import { AuthService, Notifier, ServerService } from '@app/core'import { VideoChannelSyncService } from '@app/shared/shared-main/channel/video-channel-sync.service'import { VideoChannelService } from '@app/shared/shared-main/channel/video-channel.service'-import { AlertComponent } from '@app/shared/shared-main/common/alert.component'-import { AutoColspanDirective } from '@app/shared/shared-main/common/auto-colspan.directive'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { HTMLServerConfig, VideoChannelSync, VideoChannelSyncState, VideoChannelSyncStateType } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'-import { mergeMap } from 'rxjs'+import { first, mergeMap } from 'rxjs'import { ActorAvatarComponent } from '../../shared/shared-actor-image/actor-avatar.component'import { GlobalIconComponent } from '../../shared/shared-icons/global-icon.component'import { ActionDropdownComponent, DropdownAction } from '../../shared/shared-main/buttons/action-dropdown.component'+import { NumberFormatterPipe } from '../../shared/shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../shared/shared-tables/table.component'@Component({templateUrl: './my-video-channel-syncs.component.html',imports: [- NgIf,+ CommonModule,GlobalIconComponent,- TableModule,- SharedModule,RouterLink,- NgbTooltip,ActionDropdownComponent,ActorAvatarComponent,- NgClass,PTDatePipe,- AlertComponent,- AutoColspanDirective+ TableComponent,+ NumberFormatterPipe]})-export class MyVideoChannelSyncsComponent extends RestTable implements OnInit {+export class MyVideoChannelSyncsComponent implements OnInit {private videoChannelsSyncService = inject(VideoChannelSyncService)private serverService = inject(ServerService)private notifier = inject(Notifier)private authService = inject(AuthService)private videoChannelService = inject(VideoChannelService)- error: string-- channelSyncs: VideoChannelSync[] = []- totalRecords = 0+ readonly table = viewChild<TableComponent<VideoChannelSync>>('table')videoChannelSyncActions: DropdownAction<VideoChannelSync>[][] = []- sort: SortMeta = { field: 'createdAt', order: 1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }private static STATE_CLASS_BY_ID = {[VideoChannelSyncState.FAILED]: 'badge-red',@@ -58,9 +46,22 @@ export class MyVideoChannelSyncsComponent extends RestTable implements OnInit {private serverConfig: HTMLServerConfig+ columns: TableColumnInfo<string>[] = [+ { id: 'externalChannelUrl', label: $localize`External Channel`, sortable: true },+ { id: 'videoChannel', label: $localize`Channel`, sortable: true },+ { id: 'state', label: $localize`State`, sortable: true },+ { id: 'createdAt', label: $localize`Created`, sortable: true },+ { id: 'lastSyncAt', label: $localize`Last synchronization at`, sortable: true }+ ]++ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }+ngOnInit () {this.serverConfig = this.serverService.getHTMLConfig()- this.initialize()this.videoChannelSyncActions = [[@@ -87,27 +88,18 @@ export class MyVideoChannelSyncsComponent extends RestTable implements OnInit {]}- protected reloadDataInternal () {- this.error = undefined-- this.authService.userInformationLoaded- .pipe(mergeMap(() => {- const user = this.authService.getUser()- return this.videoChannelsSyncService.listAccountVideoChannelsSyncs({- sort: this.sort,- account: user.account,- pagination: this.pagination+ private _dataLoader (options: DataLoaderOptions) {+ return this.authService.userInformationLoaded+ .pipe(+ first(),+ mergeMap(() => {+ return this.videoChannelsSyncService.listAccountVideoChannelsSyncs({+ sort: options.sort,+ pagination: options.pagination,+ account: this.authService.getUser().account+ })})- }))- .subscribe({- next: res => {- this.channelSyncs = res.data- this.totalRecords = res.total- },- error: err => {- this.error = err.message- }- })+ )}syncEnabled () {@@ -119,11 +111,9 @@ export class MyVideoChannelSyncsComponent extends RestTable implements OnInit {.subscribe({next: () => {this.notifier.success($localize`Synchronization removed successfully for ${videoChannelSync.channel.displayName}.`)- this.reloadData()+ this.table().loadData()},- error: err => {- this.error = err.message- }+ error: err => this.notifier.error(err.message)})}@@ -133,9 +123,7 @@ export class MyVideoChannelSyncsComponent extends RestTable implements OnInit {next: () => {this.notifier.success($localize`Full synchronization requested successfully for ${videoChannelSync.channel.displayName}.`)},- error: err => {- this.error = err.message- }+ error: err => this.notifier.error(err.message)})}@@ -147,10 +135,6 @@ export class MyVideoChannelSyncsComponent extends RestTable implements OnInit {return [ 'pt-badge', MyVideoChannelSyncsComponent.STATE_CLASS_BY_ID[stateId] ]}- getIdentifier () {- return 'MyVideoChannelsSyncComponent'- }-getChannelUrl (name: string) {return '/c/' + name}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.htmlindex 05d4e5bb11..bfa32645d0 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@@ -1,69 +1,69 @@-<div class="mb-4 d-flex justify-content-between">- <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter>-</div>--<p-table- [value]="videoImports" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" dataKey="id"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [expandedRowKeys]="expandedRows"+<my-table+ #table+ key="MyVideoImportsComponent"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="imports per page"+ [dataLoader]="dataLoader"+ columnConfig="false">- <ng-template #header>- <tr>- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>- <th scope="col" style="width: 200px">Action</th>- <th scope="col" style="width: 45%" i18n>Target</th>- <th scope="col" style="width: 55%" i18n>Video</th>- <th scope="col" style="width: 150px" i18n>State</th>- <th scope="col" style="width: 170px" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>- </tr>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No import} =1 {1 import} other {{{ totalRecords | myNumberFormatter }} imports}}</ng-container></ng-template>- <ng-template #body let-expanded="expanded" let-videoImport>- <tr>- <td class="expand-cell">- <my-table-expander-icon *ngIf="videoImport.error" [pRowToggler]="videoImport" [expanded]="expanded"></my-table-expander-icon>- </td>-- <td class="action-cell">- <my-button *ngIf="isVideoImportPending(videoImport)" i18n-label label="Cancel" icon="no" (click)="cancelImport(videoImport)"></my-button>- <my-delete-button *ngIf="isVideoImportFailed(videoImport) || isVideoImportCancelled(videoImport) || !videoImport.video" (click)="deleteImport(videoImport)"></my-delete-button>- <my-edit-button *ngIf="isVideoImportSuccess(videoImport) && videoImport.video" [ptRouterLink]="getEditVideoUrl(videoImport.video)"></my-edit-button>- </td>+ <ng-template #captionRight>+ <my-advanced-input-filter (search)="table.onSearch($event)"></my-advanced-input-filter>+ </ng-template>- <td>- <a *ngIf="videoImport.targetUrl; else torrent" [href]="videoImport.targetUrl" target="_blank" rel="noopener noreferrer">{{ videoImport.targetUrl }}</a>- <ng-template #torrent>- <span [title]="videoImport.torrentName || videoImport.magnetUri">{{ videoImport.torrentName || videoImport.magnetUri }}</span>- </ng-template>- </td>+ <ng-template #tableCells let-videoImport>+ <td class="max-width-300px">+ @if (videoImport.targetUrl) {+ <a [href]="videoImport.targetUrl" target="_blank" rel="noopener noreferrer" [title]="videoImport.targetUrl">{{ videoImport.targetUrl }}</a>+ } @else {+ <span [title]="videoImport.torrentName || videoImport.magnetUri">{{ videoImport.torrentName || videoImport.magnetUri }}</span>+ }+ </td>- <td>- <ng-container *ngIf="isVideoImportPending(videoImport)">{{ videoImport.video?.name }}</ng-container>- <ng-container *ngIf="isVideoImportSuccess(videoImport) && videoImport.video">+ <td>+ @if (isVideoImportPending(videoImport)) {+ {{ videoImport.video?.name }}+ } @else if (isVideoImportSuccess(videoImport)) {+ @if (videoImport.video) {<a [href]="getVideoUrl(videoImport.video)" target="_blank" rel="noopener noreferrer">{{ videoImport.video?.name }}</a>- </ng-container>- <ng-container *ngIf="isVideoImportSuccess(videoImport) && !videoImport.video" i18n>This video was deleted</ng-container>- <ng-container *ngIf="isVideoImportFailed(videoImport)"></ng-container>- </td>+ } @else {+ <ng-container i18n>This video has been deleted</ng-container>+ }+ }+ </td>- <td>- <span class="pt-badge" [ngClass]="getVideoImportStateClass(videoImport.state.id)">- {{ videoImport.state.label }}- </span>- </td>+ <td>+ <span class="pt-badge" [ngClass]="getVideoImportStateClass(videoImport.state.id)">+ {{ videoImport.state.label }}+ </span>+ </td>++ <td>{{ videoImport.createdAt | ptDate: 'short' }}</td>+ </ng-template>++ <ng-template #actionCell let-videoImport>+ @if (isVideoImportPending(videoImport)) {+ <my-button i18n-label label="Cancel" icon="no" (click)="cancelImport(videoImport)"></my-button>+ }++ @if (isVideoImportFailed(videoImport) || isVideoImportCancelled(videoImport) || !videoImport.video) {+ <my-delete-button (click)="deleteImport(videoImport)"></my-delete-button>+ }++ @if (isVideoImportSuccess(videoImport) && videoImport.video) {+ <my-edit-button [ptRouterLink]="getEditVideoUrl(videoImport.video)"></my-edit-button>+ }+ </ng-template>- <td>{{ videoImport.createdAt | ptDate: 'short' }}</td>- </tr>+ <ng-template #expandedRow let-videoImport>+ <pre>{{ videoImport.error }}</pre></ng-template>- <ng-template #expandedrow let-videoImport>- <tr class="video-import-error" *ngIf="videoImport.error">- <td myAutoColspan>- <pre>{{ videoImport.error }}</pre>- </td>- </tr>+ <ng-template #noResults>+ <ng-container i18n>No video import found.</ng-container></ng-template>-</p-table>+</my-table>diff --git a/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts b/client/src/app/+my-library/my-video-imports/my-video-imports.component.tsindex 7588a3728b..71321f6223 100644--- a/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts+++ b/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts@@ -1,53 +1,49 @@-import { NgClass, NgIf } from '@angular/common'-import { Component, OnInit, inject } from '@angular/core'-import { Notifier, RestPagination, RestTable } from '@app/core'+import { CommonModule, NgClass } from '@angular/common'+import { Component, inject, viewChild } from '@angular/core'+import { Notifier } from '@app/core'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { VideoImportService } from '@app/shared/shared-main/video/video-import.service'import { Video } from '@app/shared/shared-main/video/video.model'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { VideoImport, VideoImportState, VideoImportStateType } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'import { ButtonComponent } from '../../shared/shared-main/buttons/button.component'import { DeleteButtonComponent } from '../../shared/shared-main/buttons/delete-button.component'import { EditButtonComponent } from '../../shared/shared-main/buttons/edit-button.component'-import { AutoColspanDirective } from '../../shared/shared-main/common/auto-colspan.directive'-import { TableExpanderIconComponent } from '../../shared/shared-tables/table-expander-icon.component'+import { NumberFormatterPipe } from '../../shared/shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../shared/shared-tables/table.component'@Component({templateUrl: './my-video-imports.component.html',styleUrls: [ './my-video-imports.component.scss' ],imports: [AdvancedInputFilterComponent,- TableModule,- SharedModule,- NgbTooltip,- NgIf,- TableExpanderIconComponent,+ CommonModule,ButtonComponent,DeleteButtonComponent,EditButtonComponent,NgClass,- AutoColspanDirective,- PTDatePipe+ PTDatePipe,+ TableComponent,+ NumberFormatterPipe]})-export class MyVideoImportsComponent extends RestTable implements OnInit {+export class MyVideoImportsComponent {private notifier = inject(Notifier)private videoImportService = inject(VideoImportService)- videoImports: VideoImport[] = []- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: 1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<VideoImport>>('table')- ngOnInit () {- this.initialize()- }+ columns: TableColumnInfo<string>[] = [+ { id: 'target', label: $localize`Target`, sortable: false },+ { id: 'video', label: $localize`Video`, sortable: false },+ { id: 'state', label: $localize`State`, sortable: false },+ { id: 'createdAt', label: $localize`Created`, sortable: true }+ ]- getIdentifier () {- return 'MyVideoImportsComponent'+ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)}getVideoImportStateClass (state: VideoImportStateType) {@@ -96,7 +92,7 @@ export class MyVideoImportsComponent extends RestTable implements OnInit {deleteImport (videoImport: VideoImport) {this.videoImportService.deleteVideoImport(videoImport).subscribe({- next: () => this.reloadData(),+ next: () => this.table().loadData(),error: err => this.notifier.error(err.message)})@@ -105,21 +101,13 @@ export class MyVideoImportsComponent extends RestTable implements OnInit {cancelImport (videoImport: VideoImport) {this.videoImportService.cancelVideoImport(videoImport).subscribe({- next: () => this.reloadData(),+ next: () => this.table().loadData(),error: err => this.notifier.error(err.message)})}- protected reloadDataInternal () {- this.videoImportService.getMyVideoImports(this.pagination, this.sort, this.search)- .subscribe({- next: resultList => {- this.videoImports = resultList.data- this.totalRecords = resultList.total- },-- error: err => this.notifier.error(err.message)- })+ private _dataLoader (options: DataLoaderOptions) {+ return this.videoImportService.getMyVideoImports(options)}}diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.html b/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.htmlindex e420033c45..99d6bb5bd0 100644--- a/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.html+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.html@@ -1,8 +1,8 @@-<div class="video-playlists-header d-flex justify-content-between align-items-end gap-2 flex-wrap">- <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter>-+<div class="video-playlists-header d-flex align-items-end gap-2 flex-wrap"><span class="total-items" *ngIf="pagination.totalItems"> {{ getTotalTitle() }}</span>+ <my-advanced-input-filter class="d-block ms-auto" (search)="onSearch($event)" emitOnInit="true"></my-advanced-input-filter>+<a class="peertube-create-button" routerLink="create"><my-global-icon iconName="add" aria-hidden="true"></my-global-icon><ng-container i18n>Create playlist</ng-container>diff --git a/client/src/app/+my-library/my-videos/my-videos.component.html b/client/src/app/+my-library/my-videos/my-videos.component.htmlindex b4eedade03..bb4daa50e5 100644--- a/client/src/app/+my-library/my-videos/my-videos.component.html+++ b/client/src/app/+my-library/my-videos/my-videos.component.html@@ -2,209 +2,125 @@<div class="channels-label" i18n>Per channel:</div>@for (channel of channels; track channel.id) {- <my-channel-toggle [channel]="channel" [(ngModel)]="channel.selected" (ngModelChange)="onFilter()"></my-channel-toggle>+ <my-channel-toggle [channel]="channel" [(ngModel)]="channel.selected" (ngModelChange)="table.onFilter()"></my-channel-toggle>}</div>-<p-table- [value]="videos" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id" [resizableColumns]="false"- [(selection)]="selectedRows" [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" [selectionPageOnly]="true"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [expandedRowKeys]="expandedRows" [ngClass]="{ loading: loading }"- class="new-p-table sticky-p-table cell-wrap"+<my-table+ #table+ key="MyVideosComponent"+ [defaultColumns]="columns"+ defaultSort="publishedAt"+ i18n-paginatorText+ paginatorText="videos per page"+ defaultRowsPerPage="5"+ [bulkActions]="bulkActions"+ [dataLoader]="dataLoader"+ [customParseQueryParams]="customParseQueryParams"+ [customUpdateUrl]="customUpdateUrl">- <ng-template #caption>- <div class="caption">- <div class="left-buttons">- @if (isInSelectionMode()) {- <my-action-dropdown- i18n-label label="Batch actions" theme="primary"- [actions]="bulkActions" [entry]="selectedRows"- >- </my-action-dropdown>- } @else {- <strong i18n [hidden]="loading">- { totalRecords, plural, =0 {No videos} =1 {1 video} other {{{ totalRecords | myNumberFormatter }} videos}}- </strong>- }- </div>-- <div class="ms-auto right-form">- <div class="d-flex align-items-center">- <label class="label-inline d-none d-inline-block-mw" for="table-search" i18n>Search</label>-- <my-advanced-input-filter- inputId="table-search" icon="true" emitOnInit="false" i18n-placeholder placeholder="Search your videos"- (search)="onSearch($event)"- ></my-advanced-input-filter>- </div>-- <div class="d-flex align-items-center">- <label class="label-inline" for="table-filter" i18n>Filter</label>-- <my-select-checkbox- inputId="table-filter"- showToggleAll="false"- showClear="true"-- [availableItems]="filterItems"- [selectableGroup]="false"- [(ngModel)]="selectedFilterItems"- i18n-placeholder placeholder="All videos"- (ngModelChange)="onFilter()"- >- </my-select-checkbox>- </div>- </div>- </div>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No videos} =1 {1 video} other {{{ totalRecords | myNumberFormatter }} videos}}</ng-container></ng-template>- <ng-template #sorticon let-sortOrder>- @if (sortOrder === 1) {- <my-button class="ms-2" small="true" active="true" rounded="true" theme="tertiary" icon="chevron-up"></my-button>- } @else if (sortOrder === -1) {- <my-button class="ms-2" small="true" active="true" rounded="true" theme="tertiary" icon="chevron-down"></my-button>- } @else if (sortOrder === 0) {- <my-button class="ms-2" small="true" rounded="true" theme="tertiary" icon="chevron-down"></my-button>- }- </ng-template>+ <ng-template #captionRight>+ <div class="d-flex align-items-center">+ <label class="label-inline d-none d-inline-block-mw" for="table-search" i18n>Search</label>- <ng-template #paginatorright let-item>- <ng-container i18n>videos per page</ng-container>- </ng-template>+ <my-advanced-input-filter+ inputId="table-search" icon="true" emitOnInit="false" i18n-placeholder placeholder="Search your videos"+ (search)="table.onSearch($event, true)"+ ></my-advanced-input-filter>+ </div>- <ng-template #header>- <tr>- <th scope="col" width="25px" class="checkbox-cell">- <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>- </th>-- <th scope="col" *ngIf="isSelected('duration')" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="duration">{{ getColumn('duration').label }} <p-sortIcon field="duration"></p-sortIcon></th>- <th scope="col" *ngIf="isSelected('name')" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="name">{{ getColumn('name').label }} <p-sortIcon field="name"></p-sortIcon></th>- <th scope="col" *ngIf="isSelected('privacy')">{{ getColumn('privacy').label }}</th>- <th scope="col" *ngIf="isSelected('sensitive')">{{ getColumn('sensitive').label }}</th>- <th scope="col" *ngIf="isSelected('playlists')">{{ getColumn('playlists').label }}</th>- <th scope="col" *ngIf="isSelected('insights')" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="views">{{ getColumn('insights').label }} <p-sortIcon field="views"></p-sortIcon></th>- <th scope="col" *ngIf="isSelected('comments')" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="comments">{{ getColumn('comments').label }} <p-sortIcon field="comments"></p-sortIcon></th>- <th scope="col" *ngIf="isSelected('published')" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="publishedAt">{{ getColumn('published').label }} <p-sortIcon field="publishedAt"></p-sortIcon></th>- <th scope="col" *ngIf="isSelected('state')">{{ getColumn('state').label }}</th>-- <th scope="col" width="250px" class="action-head">- <div class="d-flex align-items-center justify-content-between">- <span i18>Actions</span>-- <span class="c-hand column-toggle" >- <div ngbDropdown placement="bottom-left auto" container="body" autoClose="outside" #columnsDropdown="ngbDropdown">- <my-button theme="tertiary" icon="columns" ngbDropdownToggle i18n-title title="Open table configuration" [show]="columnsDropdown.isOpen()"></my-button>-- <div ngbDropdownMenu class="p-3">- <div class="form-group">- <div class="muted small mb-2" i18n>Column displayed:</div>-- @for (column of columns; track column) {- <div class="ms-1 mb-1">- <my-peertube-checkbox- [inputName]="'column-' + column.id" [(ngModel)]="column.selected"- i18n-labelText [labelText]="column.label"- (ngModelChange)="saveSelectedColumns()"- ></my-peertube-checkbox>- </div>- }- </div>- </div>- </div>- </span>- </div>- </th>- </tr>+ <div class="d-flex align-items-center">+ <label class="label-inline" for="table-filter" i18n>Filter</label>++ <my-select-checkbox+ inputId="table-filter"+ showToggleAll="false"+ showClear="true"++ [availableItems]="filterItems"+ [selectableGroup]="false"+ [(ngModel)]="selectedFilterItems"+ i18n-placeholder placeholder="All videos"+ (ngModelChange)="table.onFilter()"+ >+ </my-select-checkbox>+ </div></ng-template>- <ng-template #body let-video>+ <ng-template #tableCells let-video>- <tr [pSelectableRow]="video">- <td class="checkbox-cell">- <p-tableCheckbox [value]="video" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>- </td>+ <td *ngIf="table.isColumnDisplayed('duration')">+ <my-video-cell [video]="video" thumbnail="true" title="false"></my-video-cell>+ </td>- <td *ngIf="isSelected('duration')">- <my-video-cell [video]="video" thumbnail="true" title="false"></my-video-cell>- </td>+ <td *ngIf="table.isColumnDisplayed('name')">+ <my-video-cell class="video-cell-name" [video]="video" thumbnail="false" title="true"></my-video-cell>+ </td>- <td *ngIf="isSelected('name')">- <my-video-cell class="video-cell-name" [video]="video" thumbnail="false" title="true"></my-video-cell>- </td>+ <td *ngIf="table.isColumnDisplayed('privacy')">+ <div class="d-flex flex-wrap gap-1">+ <my-video-privacy-badge [video]="video"></my-video-privacy-badge>- <td *ngIf="isSelected('privacy')">- <div class="d-flex flex-wrap gap-1">- <my-video-privacy-badge [video]="video"></my-video-privacy-badge>-- <span *ngIf="video.blacklisted" class="pt-badge badge-red" i18n [ngbTooltip]="video.blacklistedReason">Blocked</span>- </div>- </td>-- <td *ngIf="isSelected('sensitive')">- <my-video-nsfw-badge [video]="video"></my-video-nsfw-badge>- </td>+ <span *ngIf="video.blacklisted" class="pt-badge badge-red" i18n [ngbTooltip]="video.blacklistedReason">Blocked</span>+ </div>+ </td>- <td *ngIf="isSelected('playlists')">- <div class="badges playlists">- <a *ngFor="let playlist of (videosContainedInPlaylists[video.id] || [])" class="pt-badge badge-secondary" [routerLink]="['/w/p/', playlist.playlistShortUUID]">- {{ playlist.playlistDisplayName }}- </a>- </div>- </td>+ <td *ngIf="table.isColumnDisplayed('sensitive')">+ <my-video-nsfw-badge [video]="video"></my-video-nsfw-badge>+ </td>- <td *ngIf="isSelected('insights')">- <a class="pt" [routerLink]="[ '/videos/manage', video.shortUUID, 'stats' ]" i18n-title title="Navigate to the video stats page">- <ng-container i18n>{video.views, plural, =0 {No views} =1 {1 view} other {{{ video.views | myNumberFormatter }} views}}</ng-container>+ <td *ngIf="table.isColumnDisplayed('playlists')">+ <div class="badges playlists">+ <a *ngFor="let playlist of (videosContainedInPlaylists[video.id] || [])" class="pt-badge badge-secondary" [routerLink]="['/w/p/', playlist.playlistShortUUID]">+ {{ playlist.playlistDisplayName }}+ </a>+ </div>+ </td>- <br />+ <td *ngIf="table.isColumnDisplayed('insights')">+ <a class="pt" [routerLink]="[ '/videos/manage', video.shortUUID, 'stats' ]" i18n-title title="Navigate to the video stats page">+ <ng-container i18n>{video.views, plural, =0 {No views} =1 {1 view} other {{{ video.views | myNumberFormatter }} views}}</ng-container>- @if (video.isLive) {- <ng-container i18n>{video.viewers, plural, =0 {No viewers} =1 {1 viewer} other {{{ video.views | myNumberFormatter }} viewers}}</ng-container>- }- </a>- </td>+ <br />- <td *ngIf="isSelected('comments')">- <span i18n>{video.comments, plural, =0 {No comments} =1 {1 comment} other {{{ video.comments | myNumberFormatter }} comments}}</span>- </td>+ @if (video.isLive) {+ <ng-container i18n>{video.viewers, plural, =0 {No viewers} =1 {1 viewer} other {{{ video.views | myNumberFormatter }} viewers}}</ng-container>+ }+ </a>+ </td>- <td *ngIf="isSelected('published')">- {{ video.publishedAt | ptDate: 'short' }}- </td>+ <td *ngIf="table.isColumnDisplayed('comments')">+ <span i18n>{video.comments, plural, =0 {No comments} =1 {1 comment} other {{{ video.comments | myNumberFormatter }} comments}}</span>+ </td>- <td *ngIf="isSelected('state')">- <my-video-state-badge [video]="video"></my-video-state-badge>- </td>+ <td *ngIf="table.isColumnDisplayed('published')">+ {{ video.publishedAt | ptDate: 'short' }}+ </td>- <td class="action-cell">- <div class="d-flex justify-content-end">- <my-button class="me-3" i18n-label label="Manage" [ptRouterLink]="[ '/videos', 'manage', video.shortUUID ]" theme="secondary" icon="film" responsiveLabel="true"></my-button>+ <td *ngIf="table.isColumnDisplayed('state')">+ <my-video-state-badge [video]="video"></my-video-state-badge>+ </td>+ </ng-template>- <my-video-actions-dropdown- placement="bottom auto" buttonDirection="horizontal" buttonStyled="true" [video]="video" [displayOptions]="videoActionsOptions"- [moreActions]="moreVideoActions"- (videoRemoved)="reloadData()" (videoFilesRemoved)="reloadData()" (transcodingCreated)="reloadData()" (videoExistsInPlaylistChange)="fetchVideosContainedInPlaylists([ video ])"- ></my-video-actions-dropdown>- </div>- </td>+ <ng-template #actionCell let-video>+ <my-button class="me-3" i18n-label label="Manage" [ptRouterLink]="[ '/videos', 'manage', video.shortUUID ]" theme="secondary" icon="film" responsiveLabel="true"></my-button>- </tr>+ <my-video-actions-dropdown+ placement="bottom auto" buttonDirection="horizontal" buttonStyled="true" [video]="video" [displayOptions]="videoActionsOptions"+ [moreActions]="moreVideoActions"+ (videoRemoved)="table.loadData()" (videoFilesRemoved)="table.loadData()" (transcodingCreated)="table.loadData()" (videoExistsInPlaylistChange)="fetchVideosContainedInPlaylists([ video ])"+ ></my-video-actions-dropdown></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container *ngIf="search" i18n>No video found matching current filters.</ng-container>- <ng-container *ngIf="!search" i18n>You don't have any videos published yet.</ng-container>- </div>- </td>- </tr>+ <ng-template #noResults let-search>+ {{ getNoResults(search) }}</ng-template>-</p-table>++</my-table><my-video-change-ownership #videoChangeOwnershipModal></my-video-change-ownership>diff --git a/client/src/app/+my-library/my-videos/my-videos.component.scss b/client/src/app/+my-library/my-videos/my-videos.component.scssindex c3602635f4..8a9f9326cc 100644--- a/client/src/app/+my-library/my-videos/my-videos.component.scss+++ b/client/src/app/+my-library/my-videos/my-videos.component.scss@@ -29,12 +29,6 @@ my-select-checkbox {}}-.right-form {- display: flex;- flex-wrap: wrap;- gap: 1.5rem;-}-td {padding-top: 0.75rem;padding-bottom: 0.75rem;diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.tsindex dfdafeb5d6..41fd0293ca 100644--- a/client/src/app/+my-library/my-videos/my-videos.component.ts+++ b/client/src/app/+my-library/my-videos/my-videos.component.ts@@ -1,26 +1,16 @@-import { CommonModule, NgClass, NgIf } from '@angular/common'+import { CommonModule } from '@angular/common'import { Component, inject, OnDestroy, OnInit, viewChild } from '@angular/core'import { FormsModule } from '@angular/forms'-import { ActivatedRoute, Router, RouterLink } from '@angular/router'-import {- AuthService,- AuthUser,- ConfirmService,- LocalStorageService,- Notifier,- PeerTubeRouterService,- RestPagination,- RestTable,- ServerService-} from '@app/core'+import { RouterLink } from '@angular/router'+import { AuthService, AuthUser, ConfirmService, Notifier, RestPagination, ServerService } from '@app/core'import { HeaderService } from '@app/header/header.service'import { formatICU } from '@app/helpers'-import { AutoColspanDirective } from '@app/shared/shared-main/common/auto-colspan.directive'import { Video } from '@app/shared/shared-main/video/video.model'import { VideoService } from '@app/shared/shared-main/video/video.service'+import { TableColumnInfo, TableComponent, TableQueryParams } from '@app/shared/shared-tables/table.component'import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'import { ChannelToggleComponent } from '@app/shared/standalone-channels/channel-toggle.component'-import { NgbDropdownModule, NgbTooltip } from '@ng-bootstrap/ng-bootstrap'+import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'import { arrayify, pick } from '@peertube/peertube-core-utils'import {UserRight,@@ -30,17 +20,13 @@ import {VideoPrivacyType,VideosExistInPlaylists} from '@peertube/peertube-models'-import { logger } from '@root-helpers/logger'-import debug from 'debug'import uniqBy from 'lodash-es/uniqBy'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableLazyLoadEvent, TableModule } from 'primeng/table'-import { finalize } from 'rxjs/operators'+import { SortMeta } from 'primeng/api'+import { tap } from 'rxjs/operators'import { SelectOptionsItem } from 'src/types'import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'-import { PeertubeCheckboxComponent } from '../../shared/shared-forms/peertube-checkbox.component'import { SelectCheckboxComponent } from '../../shared/shared-forms/select/select-checkbox.component'-import { ActionDropdownComponent, DropdownAction } from '../../shared/shared-main/buttons/action-dropdown.component'+import { DropdownAction } from '../../shared/shared-main/buttons/action-dropdown.component'import { ButtonComponent } from '../../shared/shared-main/buttons/button.component'import { PTDatePipe } from '../../shared/shared-main/common/date.pipe'import { NumberFormatterPipe } from '../../shared/shared-main/common/number-formatter.pipe'@@ -54,20 +40,14 @@ import { VideoPrivacyBadgeComponent } from '../../shared/shared-video/video-privimport { VideoStateBadgeComponent } from '../../shared/shared-video/video-state-badge.component'import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component'-const debugLogger = debug('peertube:my-videos')--type Column = 'duration' | 'name' | 'privacy' | 'sensitive' | 'playlists' | 'insights' | 'published' | 'state' | 'comments'+type ColumnName = 'duration' | 'name' | 'privacy' | 'sensitive' | 'playlists' | 'insights' | 'published' | 'state' | 'comments'type CommonFilter = 'live' | 'vod' | 'private' | 'internal' | 'unlisted' | 'password-protected' | 'public'+type VideoType = 'live' | 'vod'-type QueryParams = {+type QueryParams = TableQueryParams & {channelNameOneOf?: string[]privacyOneOf?: string[]- start?: number- count?: number- sortOrder?: number- sortField?: stringsearch?: string-videoType?: VideoType}@@ -78,14 +58,9 @@ type QueryParams = {imports: [CommonModule,FormsModule,- TableModule,- NgClass,- SharedModule,- NgIf,- ActionDropdownComponent,AdvancedInputFilterComponent,ButtonComponent,- NgbTooltip,+ NgbTooltipModule,VideoActionsDropdownComponent,VideoCellComponent,RouterLink,@@ -93,38 +68,24 @@ type QueryParams = {VideoChangeOwnershipComponent,VideoPrivacyBadgeComponent,VideoStateBadgeComponent,- NgbDropdownModule,- PeertubeCheckboxComponent,ChannelToggleComponent,- AutoColspanDirective,SelectCheckboxComponent,PTDatePipe,- VideoNSFWBadgeComponent+ VideoNSFWBadgeComponent,+ TableComponent]})-export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDestroy {- protected route = inject(ActivatedRoute)- protected router = inject(Router)+export class MyVideosComponent implements OnInit, OnDestroy {private confirmService = inject(ConfirmService)private auth = inject(AuthService)private notifier = inject(Notifier)private videoService = inject(VideoService)private playlistService = inject(VideoPlaylistService)private server = inject(ServerService)- private peertubeLocalStorage = inject(LocalStorageService)- private peertubeRouter = inject(PeerTubeRouterService)private headerService = inject(HeaderService)- private static readonly LS_SELECTED_COLUMNS_KEY = 'user-my-videos-selected-columns'-readonly videoChangeOwnershipModal = viewChild<VideoChangeOwnershipComponent>('videoChangeOwnershipModal')-- videos: Video[] = []-- totalRecords = 0- sort: SortMeta = { field: 'publishedAt', order: -1 }- rowsPerPage = 5- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<Video, ColumnName, QueryParams>>('table')videosContainedInPlaylists: VideosExistInPlaylists = {}@@ -145,7 +106,6 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDes}moreVideoActions: DropdownAction<{ video: Video }>[][] = []- loading = trueuser: AuthUserchannels: (VideoChannel & { selected: boolean })[] = []@@ -153,29 +113,37 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDesfilterItems: SelectOptionsItem<CommonFilter>[] = []selectedFilterItems: CommonFilter[] = []- columns: { id: Column, label: string, selected: boolean }[] = []+ columns: TableColumnInfo<ColumnName>[] = []++ customUpdateUrl: typeof this._customUpdateUrl+ customParseQueryParams: typeof this._customParseQueryParams+ dataLoader: typeof this._dataLoader++ constructor () {+ this.customUpdateUrl = this._customUpdateUrl.bind(this)+ this.customParseQueryParams = this._customParseQueryParams.bind(this)+ this.dataLoader = this._dataLoader.bind(this)+ }get serverConfig () {return this.server.getHTMLConfig()}ngOnInit () {- this.initialize()-this.headerService.setSearchHidden(true)this.user = this.auth.getUser()this.columns = [- { id: 'duration', label: $localize`Duration`, selected: true },- { id: 'name', label: $localize`Name`, selected: true },- { id: 'privacy', label: $localize`Privacy`, selected: true },- { id: 'sensitive', label: $localize`Sensitive`, selected: true },- { id: 'playlists', label: $localize`Playlists`, selected: true },- { id: 'insights', label: $localize`Insights`, selected: true },- { id: 'comments', label: $localize`Comments`, selected: true },- { id: 'published', label: $localize`Published`, selected: true },- { id: 'state', label: $localize`State`, selected: true }+ { id: 'duration', label: $localize`Duration`, selected: true, sortable: true },+ { id: 'name', label: $localize`Name`, selected: true, sortable: true },+ { id: 'privacy', label: $localize`Privacy`, selected: true, sortable: false },+ { id: 'sensitive', label: $localize`Sensitive`, selected: true, sortable: false },+ { id: 'playlists', label: $localize`Playlists`, selected: true, sortable: false },+ { id: 'insights', label: $localize`Insights`, selected: true, sortable: true, sortKey: 'views' },+ { id: 'comments', label: $localize`Comments`, selected: true, sortable: true },+ { id: 'published', label: $localize`Published`, selected: true, sortable: true, sortKey: 'publishedAt' },+ { id: 'state', label: $localize`State`, selected: true, sortable: false }]this.filterItems = [@@ -209,24 +177,14 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDes}]- this.subscribeToQueryChanges()this.buildActions()- this.loadSelectedColumns()}ngOnDestroy () {this.headerService.setSearchHidden(false)}- private subscribeToQueryChanges () {- this.route.queryParams.subscribe(queryParams => {- this.parseQueryParams(queryParams)- })- }-- private parseQueryParams (queryParams: QueryParams) {- debugLogger('Parse query params', { queryParams })-+ private _customParseQueryParams (queryParams: QueryParams) {{const enabledChannels = queryParams.channelNameOneOf? new Set(arrayify(queryParams.channelNameOneOf))@@ -257,98 +215,32 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDesif (enabledPrivacies.has(VideoPrivacy.PASSWORD_PROTECTED)) this.selectedFilterItems.push('password-protected')if (enabledPrivacies.has(VideoPrivacy.PRIVATE)) this.selectedFilterItems.push('private')}-- if (queryParams.start !== undefined) this.pagination.start = +queryParams.start-- if (queryParams.count !== undefined) {- this.pagination.count = this.rowsPerPage = +queryParams.count- }-- if (queryParams.sortOrder !== undefined) this.sort.order = +queryParams.sortOrder- if (queryParams.sortField !== undefined) this.sort.field = queryParams.sortField-- if (queryParams.search !== undefined) this.search = queryParams.search-- this.reloadData()- }-- loadLazy (event: TableLazyLoadEvent) {- if (this.parseLazy(event)) {- this.updateUrl()- this.saveSort()- }- }-- getIdentifier () {- return 'MyVideosComponent'}// ---------------------------------------------------------------------------- isSelected (id: Column) {- return this.columns.some(c => c.id === id && c.selected)- }-- getColumn (id: Column) {- return this.columns.find(c => c.id === id)- }-- private loadSelectedColumns () {- const enabledString = this.peertubeLocalStorage.getItem(MyVideosComponent.LS_SELECTED_COLUMNS_KEY)-- if (!enabledString) return- try {- const enabled = JSON.parse(enabledString)-- for (const column of this.columns) {- column.selected = enabled.includes(column.id)- }- } catch (err) {- logger.error('Cannot load selected columns.', err)+ getNoResults (search?: string) {+ if (search || this.selectedFilterItems.length !== 0) {+ return $localize`No videos found matching your filters.`}- }- saveSelectedColumns () {- const enabled = this.columns.filter(c => c.selected).map(c => c.id)-- this.peertubeLocalStorage.setItem(MyVideosComponent.LS_SELECTED_COLUMNS_KEY, JSON.stringify(enabled))- }-- // ----------------------------------------------------------------------------- // Override REST table method- onSearch (search: string) {- this.search = search- this.sort = {- field: 'match',- order: -1+ if (this.channels.some(c => c.selected)) {+ return $localize`No videos found in selected channels.`}- this.onFilter()+ return $localize`You don't have any videos published yet.`}- onFilter () {- this.resetPagination()- this.updateUrl()- }+ // ---------------------------------------------------------------------------- private updateUrl () {+ private _customUpdateUrl (): Partial<Record<keyof QueryParams, any>> {const channelNameOneOf = this.channels.filter(c => c.selected).map(c => c.name)- const newParams: Record<keyof QueryParams, any> = {- ...this.route.snapshot.queryParams,-+ return {...pick(this.buildCommonVideoFilters(), [ 'privacyOneOf', 'videoType' ]),- search: this.search,- channelNameOneOf,- start: this.pagination.start,- count: this.pagination.count,- sortOrder: this.sort.order,- sortField: this.sort.field+ channelNameOneOf}-- this.peertubeRouter.silentNavigate([ '.' ], newParams, this.route)}private buildCommonVideoFilters () {@@ -384,32 +276,26 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDes// ---------------------------------------------------------------------------- protected reloadDataInternal () {- this.loading = true+ private _dataLoader (options: {+ pagination: RestPagination+ sort: SortMeta+ search: string+ }) {+ const { pagination, sort, search } = optionsconst channelNameOneOf = this.channels.filter(c => c.selected).map(c => c.name)return this.videoService.listMyVideos({- restPagination: this.pagination,- sort: this.sort,- search: this.search,+ restPagination: pagination,+ sort,+ search,channelNameOneOf: channelNameOneOf.length !== 0? channelNameOneOf: undefined,...pick(this.buildCommonVideoFilters(), [ 'isLive', 'privacyOneOf' ])- }).pipe(finalize(() => this.loading = false))- .subscribe({- next: resultList => {- this.videos = resultList.data- this.totalRecords = resultList.total-- this.fetchVideosContainedInPlaylists(resultList.data)- },-- error: err => this.notifier.error(err.message)- })+ }).pipe(tap(({ data }) => this.fetchVideosContainedInPlaylists(data)))}fetchVideosContainedInPlaylists (videos: Video[]) {@@ -441,23 +327,19 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDes))- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)})}- changeOwnership (video: Video) {- this.videoChangeOwnershipModal().show(video)- }-private buildActions () {this.moreVideoActions = [[{label: $localize`Change ownership`,- handler: ({ video }) => this.changeOwnership(video),+ handler: ({ video }) => this.videoChangeOwnershipModal().show(video),iconName: 'ownership-change'}]diff --git a/client/src/app/core/rest/index.ts b/client/src/app/core/rest/index.tsindex 93899beaf3..5668084e6f 100644--- a/client/src/app/core/rest/index.ts+++ b/client/src/app/core/rest/index.ts@@ -1,5 +1,4 @@export * from './component-pagination.model'export * from './rest-extractor.service'export * from './rest-pagination'-export * from './rest-table'export * from './rest.service'diff --git a/client/src/app/core/rest/rest-table.ts b/client/src/app/core/rest/rest-table.tsdeleted file mode 100644index 9c4228b67a..0000000000--- a/client/src/app/core/rest/rest-table.ts+++ /dev/null@@ -1,163 +0,0 @@-import { ActivatedRoute, Router } from '@angular/router'-import { logger } from '@root-helpers/logger'-import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'-import debug from 'debug'-import { SortMeta } from 'primeng/api'-import { TableLazyLoadEvent } from 'primeng/table'-import { RestPagination } from './rest-pagination'--const debugLogger = debug('peertube:tables:RestTable')--export abstract class RestTable<T = unknown> {- abstract totalRecords: number- abstract sort: SortMeta- abstract pagination: RestPagination-- rowsPerPageOptions = [ 5, 10, 20, 50, 100 ]- rowsPerPage = 10- expandedRows = {}-- selectedRows: T[] = []-- search: string-- sortTooltip = $localize`Sort by this column`-- protected route: ActivatedRoute- protected router: Router-- // First string is badge column type- // Inner Map is value -> badge name- private valueToBadge = new Map<string, Map<string, string>>()- private badgesUsed = new Set<string>()-- private lastLazyLoadEvent: TableLazyLoadEvent-- abstract getIdentifier (): string-- initialize () {- this.loadSort()- }-- loadSort () {- const result = peertubeLocalStorage.getItem(this.getSortLocalStorageKey())-- if (result) {- try {- this.sort = JSON.parse(result)- } catch (err) {- logger.error('Cannot load sort of local storage key ' + this.getSortLocalStorageKey(), err)- }- }- }-- saveSort () {- peertubeLocalStorage.setItem(this.getSortLocalStorageKey(), JSON.stringify(this.sort))- }-- protected parseLazy (event: TableLazyLoadEvent) {- debugLogger('Load lazy %o.', event)-- if (this.lastLazyLoadEvent) {- // Prevent lazy loading twice- // TODO: remove when https://github.com/primefaces/primeng/issues/5480 is fixed- if (- this.lastLazyLoadEvent.first === event.first &&- this.lastLazyLoadEvent.rows === event.rows &&- this.lastLazyLoadEvent.sortField === event.sortField &&- this.lastLazyLoadEvent.sortOrder === event.sortOrder- ) return false- }-- this.lastLazyLoadEvent = event-- this.sort = {- order: event.sortOrder,- field: event.sortField as string- }-- this.rowsPerPage = event.rows-- this.pagination = {- start: event.first,- count: this.rowsPerPage- }-- this.expandedRows = {}-- return true- }-- loadLazy (event: TableLazyLoadEvent) {- if (this.parseLazy(event)) {- this.reloadData()- this.saveSort()- }- }-- onSearch (search: string) {- this.search = search-- this.resetPagination()- this.reloadData()- }-- resetPagination () {- this.pagination = {- start: 0,- count: this.rowsPerPage- }- }-- isInSelectionMode () {- return this.selectedRows.length !== 0- }-- getPaginationTemplate () {- return $localize`Showing {first} to {last} of {totalRecords} elements`- }-- protected abstract reloadDataInternal (): void-- protected reloadData () {- this.selectedRows = []-- this.reloadDataInternal()- }-- protected getRandomBadge (type: string, value: string): string {- if (!this.valueToBadge.has(type)) {- this.valueToBadge.set(type, new Map())- }-- const badges = this.valueToBadge.get(type)- const badge = badges.get(value)- if (badge) return badge-- const toTry = [- 'badge-yellow',- 'badge-purple',- 'badge-blue',- 'badge-brown',- 'badge-green',- 'badge-secondary'- ]-- for (const badge of toTry) {- if (!this.badgesUsed.has(badge)) {- this.badgesUsed.add(badge)- badges.set(value, badge)- return badge- }- }-- // Reset, we used all available badges- this.badgesUsed.clear()-- return this.getRandomBadge(type, value)- }-- private getSortLocalStorageKey () {- return 'rest-table-sort-' + this.getIdentifier()- }-}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.htmlindex 1d077e24f6..46627bf4ed 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@@ -1,49 +1,24 @@-<p-table- [value]="abuses" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id" [resizableColumns]="true"- [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()" [expandedRowKeys]="expandedRows"+<my-table+ #table+ key="AbuseListTableComponent"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="abuses per page"+ [dataLoader]="dataLoader"+ columnConfig="false">- <ng-template #caption>- <div class="caption">- <div class="ms-auto">- <my-advanced-input-filter [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter>- </div>- </div>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No abuse} =1 {1 abuse} other {{{ totalRecords | myNumberFormatter }} abuses}}</ng-container></ng-template>- <ng-template #header>- <tr> <!-- header -->- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>- <th scope="col" style="width: 70px;">- <span i18n class="visually-hidden">Actions</span>- </th>- <th scope="col" *ngIf="isAdminView()" style="width: 20%;" pResizableColumn i18n>Reporter</th>- <th scope="col" i18n>Video/Comment/Account</th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>- <th scope="col" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="state" style="width: 80px;">State <p-sortIcon field="state"></p-sortIcon></th>- <th scope="col" i18n style="width: 80px;">Messages</th>- <th scope="col" i18n *ngIf="isAdminView()" style="width: 100px;">Internal note</th>- </tr>+ <ng-template #captionRight>+ <my-advanced-input-filter [filters]="inputFilters" (search)="table.onSearch($event)"></my-advanced-input-filter></ng-template>- <ng-template #body let-expanded="expanded" let-abuse>- <tr>- <td class="expand-cell">- <my-table-expander-icon [pRowToggler]="abuse" [expanded]="expanded"></my-table-expander-icon>- </td>-- <td class="action-cell">- <my-action-dropdown- [ngClass]="{ 'show': expanded }" placement="bottom-right top-right left auto" container="body"- [actions]="abuseActions" [entry]="abuse" buttonSize="small"- ></my-action-dropdown>- </td>-- <td *ngIf="isAdminView()">- <a *ngIf="abuse.reporterAccount" [href]="abuse.reporterAccount.url" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">+ <ng-template #tableCells let-abuse>+ <td *ngIf="isAdminView()">+ @if (abuse.reporterAccount) {+ <a [href]="abuse.reporterAccount.url" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer"><div class="chip two-lines"><my-actor-avatar [actor]="abuse.reporterAccount" actorType="account" size="32"></my-actor-avatar><div>@@ -52,27 +27,14 @@</div></div></a>+ } @else {+ <span i18n>Deleted account</span>+ }+ </td>- <span i18n *ngIf="!abuse.reporterAccount">- Deleted account- </span>- </td>-- <ng-container *ngIf="abuse.video">-- <td *ngIf="!abuse.video.deleted">- <my-video-cell [video]="abuse.video" size="small">- <div>- <span *ngIf="abuse.count > 1" class="pt-badge badge-secondary me-1" i18n-title title="This video has been reported multiple times" i18n>- {abuse.count, plural, =1 {1 abuse} other {{{ abuse.count }} abuses}}- </span>-- <span *ngIf="abuse.video.blacklisted" class="pt-badge badge-red" i18n-title title="The video is blocked" i18n>Blocked</span>- </div>- </my-video-cell>- </td>-- <td *ngIf="abuse.video.deleted" class="c-hand" [pRowToggler]="abuse">+ @if (abuse.video) {+ @if (abuse.video.deleted) {+ <td><div class="table-video" i18n-title title="Video was deleted"><div class="table-video-text"><div>@@ -85,87 +47,89 @@</div></div></td>- </ng-container>-- <ng-container *ngIf="abuse.comment">+ } @else {<td>- <a- [href]="getCommentUrl(abuse)" [innerHTML]="abuse.commentHTML" class="table-comment-link ellipsis-multiline-1"- [title]="abuse.comment.video.name" target="_blank" rel="noopener noreferrer"- ></a>-- <div class="comment-flagged-account" *ngIf="abuse.flaggedAccount">by {{ abuse.flaggedAccount.displayName }}</div>- </td>- </ng-container>-- <ng-container *ngIf="!abuse.comment && !abuse.video">- <td *ngIf="abuse.flaggedAccount">- <a [href]="getAccountUrl(abuse)" class="table-account-link" target="_blank" rel="noopener noreferrer">- <span>{{ abuse.flaggedAccount.displayName }}</span>-- <span class="account-flagged-handle">{{ abuse.flaggedAccount.nameWithHostForced }}</span>- </a>- </td>+ <my-video-cell [video]="abuse.video" size="small">+ <div>+ <span *ngIf="abuse.count > 1" class="pt-badge badge-secondary me-1" i18n-title title="This video has been reported multiple times" i18n>+ {abuse.count, plural, =1 {1 abuse} other {{{ abuse.count }} abuses}}+ </span>- <td i18n *ngIf="!abuse.flaggedAccount">- Account deleted+ <span *ngIf="abuse.video.blacklisted" class="pt-badge badge-red" i18n-title title="The video is blocked" i18n>Blocked</span>+ </div>+ </my-video-cell></td>+ }+ } @else if (abuse.comment) {+ <td>+ <a+ [href]="getCommentUrl(abuse)" [innerHTML]="abuse.commentHTML" class="table-comment-link ellipsis-multiline-1"+ [title]="abuse.comment.video.name" target="_blank" rel="noopener noreferrer"+ ></a>++ <div class="comment-flagged-account" *ngIf="abuse.flaggedAccount">by {{ abuse.flaggedAccount.displayName }}</div>+ </td>+ } @else if(abuse.flaggedAccount) {+ <td>+ <a [href]="getAccountUrl(abuse)" class="table-account-link" target="_blank" rel="noopener noreferrer">+ <span>{{ abuse.flaggedAccount.displayName }}</span>- </ng-container>-- <td class="c-hand" [pRowToggler]="abuse">{{ abuse.createdAt | ptDate: 'short' }}</td>+ <span class="account-flagged-handle">{{ abuse.flaggedAccount.nameWithHostForced }}</span>+ </a>+ </td>+ } @else {+ <td i18n>Account deleted</td>+ }- <td class="c-hand abuse-states" [pRowToggler]="abuse">- <div *ngIf="isAbuseAccepted(abuse)" [title]="abuse.state.label" class="pt-badge badge-success">- <my-global-icon iconName="tick"></my-global-icon>- </div>+ <td>{{ abuse.createdAt | ptDate: 'short' }}</td>- <div *ngIf="isAbuseRejected(abuse)" [title]="abuse.state.label" class="pt-badge badge-danger">- <my-global-icon iconName="cross"></my-global-icon>- </div>- </td>+ <td class="abuse-states">+ <div *ngIf="isAbuseAccepted(abuse)" [title]="abuse.state.label" class="pt-badge badge-success">+ <my-global-icon iconName="tick"></my-global-icon>+ </div>- <td class="abuse-messages">- <button- *ngIf="isLocalAbuse(abuse)" (click)="openAbuseMessagesModal(abuse)"- class="peertube-button secondary-button icon-only"- [ariaLabel]="getSendMessageButtonLabel(abuse)"- [title]="getSendMessageButtonLabel(abuse)"- >- {{ abuse.countMessages }}-- <my-global-icon aria- iconName="message-circle"></my-global-icon>- </button>- </td>+ <div *ngIf="isAbuseRejected(abuse)" [title]="abuse.state.label" class="pt-badge badge-danger">+ <my-global-icon iconName="cross"></my-global-icon>+ </div>+ </td>++ <td class="abuse-messages">+ <button+ *ngIf="isLocalAbuse(abuse)" (click)="openAbuseMessagesModal(abuse)"+ class="peertube-button secondary-button icon-only"+ [ariaLabel]="getSendMessageButtonLabel(abuse)"+ [title]="getSendMessageButtonLabel(abuse)"+ >+ {{ abuse.countMessages }}++ <my-global-icon aria- iconName="message-circle"></my-global-icon>+ </button>+ </td>++ <td *ngIf="isAdminView()" class="internal-note max-width-300px" container="body" placement="left auto" [ngbTooltip]="abuse.moderationComment">+ {{ abuse.moderationComment }}+ </td>+ </ng-template>- <td *ngIf="isAdminView()" class="internal-note" container="body" placement="left auto" [ngbTooltip]="abuse.moderationComment">- {{ abuse.moderationComment }}- </td>- </tr>+ <ng-template #actionCell let-abuse>+ <my-action-dropdown+ placement="bottom-right top-right left auto" container="body"+ [actions]="abuseActions" [entry]="abuse"+ ></my-action-dropdown></ng-template>- <ng-template #expandedrow let-abuse>- <tr>- <td *ngIf="isAdminView()" class="expand-cell" myAutoColspan>- <my-abuse-details [abuse]="abuse" [isAdminView]="true"></my-abuse-details>- </td>- <td *ngIf="!isAdminView()" class="expand-cell" myAutoColspan>- <my-abuse-details [abuse]="abuse" [isAdminView]="false"></my-abuse-details>- </td>- </tr>+ <ng-template #expandedRow let-abuse>+ <my-abuse-details [abuse]="abuse" [isAdminView]="isAdminView()"></my-abuse-details></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container *ngIf="search" i18n>No abuses found matching current filters.</ng-container>- <ng-container *ngIf="!search" i18n>No abuses found.</ng-container>- </div>- </td>- </tr>+ <ng-template #noResults let-search>+ @if (search) {+ <ng-container i18n>No abuses found matching current filters.</ng-container>+ } @else {+ <ng-container i18n>No abuses found.</ng-container>+ }</ng-template>-</p-table>+</my-table><my-moderation-comment-modal #moderationCommentModal (commentUpdated)="onModerationCommentUpdated()"></my-moderation-comment-modal><my-abuse-message-modal #abuseMessagesModal [isAdminView]="isAdminView()" (countMessagesUpdated)="onCountMessagesUpdated($event)"></my-abuse-message-modal>diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.tsindex ebd1744f4e..eac9ac8272 100644--- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts+++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts@@ -1,29 +1,26 @@-import { NgClass, NgIf } from '@angular/common'+import { CommonModule } from '@angular/common'import { Component, OnDestroy, OnInit, inject, input, viewChild } from '@angular/core'-import { ActivatedRoute, Router } from '@angular/router'-import { ConfirmService, HooksService, MarkdownService, Notifier, PluginService, RestPagination, RestTable } from '@app/core'+import { ConfirmService, HooksService, MarkdownService, Notifier, PluginService } from '@app/core'import { formatICU } from '@app/helpers'import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'-import { AbuseState, AbuseStateType, AdminAbuse } from '@peertube/peertube-models'+import { AbuseState, AbuseStateType, AdminAbuse, ResultList } from '@peertube/peertube-models'import { logger } from '@root-helpers/logger'import debug from 'debug'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'-import { lastValueFrom } from 'rxjs'+import { switchMap } from 'rxjs'import { ActorAvatarComponent } from '../shared-actor-image/actor-avatar.component'import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../shared-forms/advanced-input-filter.component'import { GlobalIconComponent } from '../shared-icons/global-icon.component'import { Account } from '../shared-main/account/account.model'import { Actor } from '../shared-main/account/actor.model'import { ActionDropdownComponent, DropdownAction } from '../shared-main/buttons/action-dropdown.component'-import { AutoColspanDirective } from '../shared-main/common/auto-colspan.directive'import { PTDatePipe } from '../shared-main/common/date.pipe'+import { NumberFormatterPipe } from '../shared-main/common/number-formatter.pipe'import { Video } from '../shared-main/video/video.model'import { VideoService } from '../shared-main/video/video.service'import { AbuseService } from '../shared-moderation/abuse.service'import { BlocklistService } from '../shared-moderation/blocklist.service'import { VideoBlockService } from '../shared-moderation/video-block.service'-import { TableExpanderIconComponent } from '../shared-tables/table-expander-icon.component'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../shared-tables/table.component'import { VideoCellComponent } from '../shared-tables/video-cell.component'import { VideoCommentService } from '../shared-video-comment/video-comment.service'import { AbuseDetailsComponent } from './abuse-details.component'@@ -38,27 +35,22 @@ const debugLogger = debug('peertube:moderation:AbuseListTableComponent')templateUrl: './abuse-list-table.component.html',styleUrls: [ '../shared-moderation/moderation.scss', './abuse-list-table.component.scss' ],imports: [- TableModule,- SharedModule,+ CommonModule,AdvancedInputFilterComponent,- NgIf,NgbTooltip,- TableExpanderIconComponent,ActionDropdownComponent,- NgClass,ActorAvatarComponent,VideoCellComponent,GlobalIconComponent,- AutoColspanDirective,AbuseDetailsComponent,ModerationCommentModalComponent,AbuseMessageModalComponent,- PTDatePipe+ PTDatePipe,+ TableComponent,+ NumberFormatterPipe]})-export class AbuseListTableComponent extends RestTable implements OnInit, OnDestroy {- protected route = inject(ActivatedRoute)- protected router = inject(Router)+export class AbuseListTableComponent implements OnInit, OnDestroy {private notifier = inject(Notifier)private abuseService = inject(AbuseService)private blocklistService = inject(BlocklistService)@@ -72,14 +64,10 @@ export class AbuseListTableComponent extends RestTable implements OnInit, OnDestreadonly viewType = input<'admin' | 'user'>(undefined)+ readonly table = viewChild<TableComponent<ProcessedAbuse>>('table')readonly abuseMessagesModal = viewChild<AbuseMessageModalComponent>('abuseMessagesModal')readonly moderationCommentModal = viewChild<ModerationCommentModalComponent>('moderationCommentModal')- abuses: ProcessedAbuse[] = []- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: 1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }-abuseActions: DropdownAction<ProcessedAbuse>[][] = []inputFilters: AdvancedInputFilter[] = [@@ -110,10 +98,32 @@ export class AbuseListTableComponent extends RestTable implements OnInit, OnDest}]+ columns: TableColumnInfo<string>[] = [+ { id: 'target', label: $localize`Video/Comment/Account`, sortable: false },+ { id: 'createdAt', label: $localize`Created`, sortable: true },+ { id: 'state', label: $localize`State`, sortable: true },+ { id: 'comment', label: $localize`Messages`, sortable: false }+ ]++ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }+async ngOnInit () {const viewType = this.viewType()+if (viewType === 'admin') {- this.pluginService.addAction('admin-abuse-list:load-data', () => this.reloadDataInternal())+ this.pluginService.addAction('admin-abuse-list:load-data', () => this.table().loadData())++ this.columns = [+ { id: 'reporterAccount', label: $localize`Reporter`, sortable: false },++ ...this.columns,++ { id: 'internalNote', label: $localize`Internal note`, sortable: false }+ ]}const abuseActions: DropdownAction<ProcessedAbuse>[][] = [@@ -128,8 +138,6 @@ export class AbuseListTableComponent extends RestTable implements OnInit, OnDestthis.buildAccountActions()]- this.initialize()-this.abuseActions = viewType === 'admin'? await this.hooks.wrapObject(abuseActions, 'admin-comments', 'filter:admin-abuse-list.actions.create.result'): abuseActions@@ -145,16 +153,12 @@ export class AbuseListTableComponent extends RestTable implements OnInit, OnDestreturn this.viewType() === 'admin'}- getIdentifier () {- return 'AbuseListTableComponent'- }-openModerationCommentModal (abuse: AdminAbuse) {this.moderationCommentModal().openModal(abuse)}onModerationCommentUpdated () {- this.reloadData()+ this.table().loadData()}isAbuseAccepted (abuse: AdminAbuse) {@@ -185,7 +189,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit, OnDest.subscribe({next: () => {this.notifier.success($localize`Abuse deleted.`)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)@@ -195,14 +199,14 @@ export class AbuseListTableComponent extends RestTable implements OnInit, OnDestupdateAbuseState (abuse: AdminAbuse, state: AbuseStateType) {this.abuseService.updateAbuse(abuse, { state }).subscribe({- next: () => this.reloadData(),+ next: () => this.table().loadData(),error: err => this.notifier.error(err.message)})}onCountMessagesUpdated (event: { abuseId: number, countMessages: number }) {- const abuse = this.abuses.find(a => a.id === event.abuseId)+ const abuse = this.table().data.find(a => a.id === event.abuseId)if (!abuse) {logger.error(`Cannot find abuse ${event.abuseId}`)@@ -237,29 +241,17 @@ export class AbuseListTableComponent extends RestTable implements OnInit, OnDest)}- protected async reloadDataInternal () {+ private _dataLoader (options: DataLoaderOptions) {debugLogger('Loading data.')- const options = {- pagination: this.pagination,- sort: this.sort,- search: this.search- }-const observable = this.viewType() === 'admin'? this.abuseService.getAdminAbuses(options): this.abuseService.getUserAbuses(options)- try {- const resultList = await lastValueFrom(observable)-- this.totalRecords = resultList.total-- this.abuses = []-- for (const a of resultList.data) {- const abuse = a as ProcessedAbuse+ return observable.pipe(switchMap(async (resultList: ResultList<ProcessedAbuse>) => {+ const abuses: ProcessedAbuse[] = []+ for (const abuse of resultList.data) {abuse.reasonHtml = await this.toHtml(abuse.reason)if (abuse.moderationComment) {@@ -290,11 +282,11 @@ export class AbuseListTableComponent extends RestTable implements OnInit, OnDestif (abuse.updatedAt === abuse.createdAt) delete abuse.updatedAt- this.abuses.push(abuse)+ abuses.push(abuse)}- } catch (err) {- this.notifier.error(err.message)- }++ return { total: resultList.total, data: abuses }+ }))}private buildInternalActions (): DropdownAction<ProcessedAbuse>[] {diff --git a/client/src/app/shared/shared-forms/advanced-input-filter.component.ts b/client/src/app/shared/shared-forms/advanced-input-filter.component.tsindex c5f97990b7..6c15bceb27 100644--- a/client/src/app/shared/shared-forms/advanced-input-filter.component.ts+++ b/client/src/app/shared/shared-forms/advanced-input-filter.component.ts@@ -34,7 +34,7 @@ export class AdvancedInputFilterComponent implements OnInit, AfterViewInit {private router = inject(Router)readonly filters = input<AdvancedInputFilter[]>([])- readonly emitOnInit = input(true, { transform: booleanAttribute })+ readonly emitOnInit = input(false, { transform: booleanAttribute })readonly icon = input(false, { transform: booleanAttribute })readonly placeholder = input($localize`Filter...`)readonly inputId = input('table-filter')diff --git a/client/src/app/shared/shared-main/video/video-import.service.ts b/client/src/app/shared/shared-main/video/video-import.service.tsindex fb184658a5..f1587ebeed 100644--- a/client/src/app/shared/shared-main/video/video-import.service.ts+++ b/client/src/app/shared/shared-main/video/video-import.service.ts@@ -26,7 +26,13 @@ export class VideoImportService {.pipe(catchError(res => this.restExtractor.handleError(res)))}- getMyVideoImports (pagination: RestPagination, sort: SortMeta, search?: string): Observable<ResultList<VideoImport>> {+ getMyVideoImports (options: {+ pagination: RestPagination+ sort: SortMeta+ search?: string+ }): Observable<ResultList<VideoImport>> {+ const { pagination, sort, search } = options+let params = new HttpParams()params = this.restService.addRestGetParams(params, pagination, sort)diff --git a/client/src/app/shared/shared-moderation/account-blocklist.component.html b/client/src/app/shared/shared-moderation/account-blocklist.component.htmldeleted file mode 100644index c1a9f15dd5..0000000000--- a/client/src/app/shared/shared-moderation/account-blocklist.component.html+++ /dev/null@@ -1,54 +0,0 @@-<p-table- [value]="blockedAccounts" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords"- [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions" [first]="pagination.start"- [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"->- <ng-template #caption>- <div class="caption">- <div class="ms-auto">- <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter>- </div>- </div>- </ng-template>-- <ng-template #header>- <tr>- <th scope="col" style="width: 150px;" i18n>Action</th> <!-- column for action buttons -->- <th scope="col" i18n>Account</th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Muted at <p-sortIcon field="createdAt"></p-sortIcon></th>- </tr>- </ng-template>-- <ng-template #body let-accountBlock>- <tr>- <td class="action-cell">- <button class="peertube-button secondary-button" (click)="unblockAccount(accountBlock)" i18n>Unmute</button>- </td>- <td>- <a [href]="accountBlock.blockedAccount.url" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">- <div class="chip two-lines">- <my-actor-avatar [actor]="accountBlock.blockedAccount" actorType="account" size="32"></my-actor-avatar>- <div>- {{ accountBlock.blockedAccount.displayName }}- <span class="muted">{{ accountBlock.blockedAccount.nameWithHost }}</span>- </div>- </div>- </a>- </td>-- <td>{{ accountBlock.createdAt | ptDate: 'short' }}</td>- </tr>- </ng-template>-- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container *ngIf="search" i18n>No account found matching current filters.</ng-container>- <ng-container *ngIf="!search" i18n>No account found.</ng-container>- </div>- </td>- </tr>- </ng-template>-</p-table>diff --git a/client/src/app/shared/shared-moderation/account-blocklist.component.ts b/client/src/app/shared/shared-moderation/account-blocklist.component.tsdeleted file mode 100644index 185d863718..0000000000--- a/client/src/app/shared/shared-moderation/account-blocklist.component.ts+++ /dev/null@@ -1,68 +0,0 @@-import { Directive, OnInit, inject } from '@angular/core'-import { Notifier, RestPagination, RestTable } from '@app/core'-import { SortMeta } from 'primeng/api'-import { AccountBlock } from './account-block.model'-import { BlocklistComponentType, BlocklistService } from './blocklist.service'--@Directive()-export class GenericAccountBlocklistComponent extends RestTable implements OnInit {- private notifier = inject(Notifier)- private blocklistService = inject(BlocklistService)-- // @ts-expect-error: "Abstract methods can only appear within an abstract class"- abstract mode: BlocklistComponentType-- blockedAccounts: AccountBlock[] = []- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }-- // @ts-expect-error: "Abstract methods can only appear within an abstract class"- abstract getIdentifier (): string-- ngOnInit () {- this.initialize()- }-- unblockAccount (accountBlock: AccountBlock) {- const blockedAccount = accountBlock.blockedAccount- const operation = this.mode === BlocklistComponentType.Account- ? this.blocklistService.unblockAccountByUser(blockedAccount)- : this.blocklistService.unblockAccountByInstance(blockedAccount)-- operation.subscribe(- () => {- this.notifier.success(- this.mode === BlocklistComponentType.Account- ? $localize`Account ${blockedAccount.nameWithHost} unmuted.`- : $localize`Account ${blockedAccount.nameWithHost} unmuted by your platform.`- )-- this.reloadData()- }- )- }-- protected reloadDataInternal () {- const operation = this.mode === BlocklistComponentType.Account- ? this.blocklistService.getUserAccountBlocklist({- pagination: this.pagination,- sort: this.sort,- search: this.search- })- : this.blocklistService.getInstanceAccountBlocklist({- pagination: this.pagination,- sort: this.sort,- search: this.search- })-- return operation.subscribe({- next: resultList => {- this.blockedAccounts = resultList.data- this.totalRecords = resultList.total- },-- error: err => this.notifier.error(err.message)- })- }-}diff --git a/client/src/app/shared/shared-moderation/generic-account-blocklist.component.html b/client/src/app/shared/shared-moderation/generic-account-blocklist.component.htmlnew file mode 100644index 0000000000..f2a8729cfc--- /dev/null+++ b/client/src/app/shared/shared-moderation/generic-account-blocklist.component.html@@ -0,0 +1,46 @@+<my-table+ #table+ [key]="key()"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="accounts per page"+ [dataLoader]="dataLoader"+ columnConfig="false"+>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No account} =1 {1 account} other {{{ totalRecords | myNumberFormatter }} accounts}}</ng-container>+ </ng-template>++ <ng-template #captionRight>+ <my-advanced-input-filter (search)="table.onSearch($event)"></my-advanced-input-filter>+ </ng-template>++ <ng-template #tableCells let-account>+ <td>+ <a [href]="account.blockedAccount.url" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">+ <div class="chip two-lines">+ <my-actor-avatar [actor]="account.blockedAccount" actorType="account" size="32"></my-actor-avatar>++ <div>+ {{ account.blockedAccount.displayName }}+ <span class="muted">{{ account.blockedAccount.nameWithHost }}</span>+ </div>+ </div>+ </a>+ </td>++ <td>{{ account.createdAt | ptDate: 'short' }}</td>+ </ng-template>++ <ng-template #actionCell let-account>+ <button class="peertube-button secondary-button" (click)="unblockAccount(account)" i18n>Unmute</button>+ </ng-template>++ <ng-template #noResults let-search>+ @if (search) {+ <ng-container i18n>No account found matching current filters.</ng-container>+ } @else {+ <ng-container i18n>No account found.</ng-container>+ }+ </ng-template>+</my-table>diff --git a/client/src/app/shared/shared-moderation/generic-account-blocklist.component.ts b/client/src/app/shared/shared-moderation/generic-account-blocklist.component.tsnew file mode 100644index 0000000000..6ec3b29f36--- /dev/null+++ b/client/src/app/shared/shared-moderation/generic-account-blocklist.component.ts@@ -0,0 +1,71 @@+import { CommonModule } from '@angular/common'+import { Component, inject, input, viewChild } from '@angular/core'+import { Notifier } from '@app/core'+import { ActorAvatarComponent } from '../shared-actor-image/actor-avatar.component'+import { AdvancedInputFilterComponent } from '../shared-forms/advanced-input-filter.component'+import { PTDatePipe } from '../shared-main/common/date.pipe'+import { NumberFormatterPipe } from '../shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../shared-tables/table.component'+import { AccountBlock } from './account-block.model'+import { BlocklistComponentType, BlocklistService } from './blocklist.service'++@Component({+ selector: 'my-generic-account-blocklist',+ templateUrl: './generic-account-blocklist.component.html',+ imports: [+ CommonModule,+ TableComponent,+ NumberFormatterPipe,+ AdvancedInputFilterComponent,+ ActorAvatarComponent,+ PTDatePipe+ ]+})+export class GenericAccountBlocklistComponent {+ private notifier = inject(Notifier)+ private blocklistService = inject(BlocklistService)++ readonly mode = input.required<BlocklistComponentType>()+ readonly key = input.required<string>()++ readonly table = viewChild<TableComponent<AccountBlock>>('table')++ columns: TableColumnInfo<string>[] = [+ { id: 'account', label: $localize`Account`, sortable: false },+ { id: 'createdAt', label: $localize`Muted at`, sortable: true }+ ]++ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }++ unblockAccount (accountBlock: AccountBlock) {+ const blockedAccount = accountBlock.blockedAccount++ const operation = this.mode() === BlocklistComponentType.Account+ ? this.blocklistService.unblockAccountByUser(blockedAccount)+ : this.blocklistService.unblockAccountByInstance(blockedAccount)++ operation.subscribe(+ () => {+ this.notifier.success(+ this.mode() === BlocklistComponentType.Account+ ? $localize`Account ${blockedAccount.nameWithHost} unmuted.`+ : $localize`Account ${blockedAccount.nameWithHost} unmuted by your platform.`+ )++ this.table().loadData()+ }+ )+ }++ private _dataLoader (options: DataLoaderOptions) {+ if (this.mode() === BlocklistComponentType.Account) {+ return this.blocklistService.getUserAccountBlocklist(options)+ }++ return this.blocklistService.getInstanceAccountBlocklist(options)+ }+}diff --git a/client/src/app/shared/shared-moderation/generic-server-blocklist.component.html b/client/src/app/shared/shared-moderation/generic-server-blocklist.component.htmlnew file mode 100644index 0000000000..49b0dd0a45--- /dev/null+++ b/client/src/app/shared/shared-moderation/generic-server-blocklist.component.html@@ -0,0 +1,47 @@+<my-table+ #table+ [key]="key()"+ [defaultColumns]="columns"+ i18n-paginatorText+ paginatorText="servers per page"+ [dataLoader]="dataLoader"+ columnConfig="false"+>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No server} =1 {1 server} other {{{ totalRecords | myNumberFormatter }} servers}}</ng-container>+ </ng-template>++ <ng-template #captionRight>+ <my-advanced-input-filter (search)="table.onSearch($event)"></my-advanced-input-filter>++ <button class="peertube-create-button" (click)="addServersToBlock()" (key.enter)="addServersToBlock()">+ <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>+ <ng-container i18n>Mute domains</ng-container>+ </button>+ </ng-template>++ <ng-template #tableCells let-serverBlock>+ <td>+ <a [href]="'https://' + serverBlock.blockedServer.host" i18n-title title="Open instance in a new tab" target="_blank" rel="noopener noreferrer">+ {{ serverBlock.blockedServer.host }}+ <my-global-icon iconName="external-link"></my-global-icon>+ </a>+ </td>++ <td>{{ serverBlock.createdAt | ptDate: 'short' }}</td>+ </ng-template>++ <ng-template #actionCell let-serverBlock>+ <button class="peertube-button secondary-button" (click)="unblockServer(serverBlock)" i18n>Unmute</button>+ </ng-template>++ <ng-template #noResults let-search>+ @if (search) {+ <ng-container i18n>No server found matching current filters.</ng-container>+ } @else {+ <ng-container i18n>No server found.</ng-container>+ }+ </ng-template>+</my-table>++<my-batch-domains-modal #batchDomainsModal i18n-action action="Mute domains" (domains)="onDomainsToBlock($event)"></my-batch-domains-modal>diff --git a/client/src/app/shared/shared-moderation/generic-server-blocklist.component.ts b/client/src/app/shared/shared-moderation/generic-server-blocklist.component.tsnew file mode 100644index 0000000000..6eff437fb3--- /dev/null+++ b/client/src/app/shared/shared-moderation/generic-server-blocklist.component.ts@@ -0,0 +1,99 @@+import { CommonModule } from '@angular/common'+import { Component, inject, input, viewChild } from '@angular/core'+import { Notifier } from '@app/core'+import { BatchDomainsModalComponent } from '@app/shared/shared-moderation/batch-domains-modal.component'+import { ServerBlock } from '@peertube/peertube-models'+import { AdvancedInputFilterComponent } from '../shared-forms/advanced-input-filter.component'+import { GlobalIconComponent } from '../shared-icons/global-icon.component'+import { PTDatePipe } from '../shared-main/common/date.pipe'+import { NumberFormatterPipe } from '../shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../shared-tables/table.component'+import { BlocklistComponentType, BlocklistService } from './blocklist.service'++@Component({+ selector: 'my-generic-server-blocklist',+ templateUrl: './generic-server-blocklist.component.html',+ imports: [+ CommonModule,+ TableComponent,+ NumberFormatterPipe,+ AdvancedInputFilterComponent,+ PTDatePipe,+ GlobalIconComponent,+ BatchDomainsModalComponent+ ]+})+export class GenericServerBlocklistComponent {+ private notifier = inject(Notifier)+ private blocklistService = inject(BlocklistService)++ readonly mode = input.required<BlocklistComponentType>()+ readonly key = input.required<string>()++ readonly batchDomainsModal = viewChild<BatchDomainsModalComponent>('batchDomainsModal')+ readonly table = viewChild<TableComponent<ServerBlock>>('table')++ columns: TableColumnInfo<string>[] = [+ { id: 'server', label: $localize`Server`, sortable: false },+ { id: 'createdAt', label: $localize`Muted at`, sortable: true }+ ]++ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }++ unblockServer (serverBlock: ServerBlock) {+ const operation = (host: string) =>+ this.mode() === BlocklistComponentType.Account+ ? this.blocklistService.unblockServerByUser(host)+ : this.blocklistService.unblockServerByInstance(host)+ const host = serverBlock.blockedServer.host++ operation(host).subscribe(+ () => {+ this.notifier.success(+ this.mode() === BlocklistComponentType.Account+ ? $localize`${host} unmuted.`+ : $localize`${host} unmuted by your platform.`+ )++ this.table().loadData()+ }+ )+ }++ addServersToBlock () {+ this.batchDomainsModal().openModal()+ }++ onDomainsToBlock (domains: string[]) {+ const operation = (domain: string) =>+ this.mode() === BlocklistComponentType.Account+ ? this.blocklistService.blockServerByUser(domain)+ : this.blocklistService.blockServerByInstance(domain)++ domains.forEach(domain => {+ operation(domain).subscribe(+ () => {+ this.notifier.success(+ this.mode() === BlocklistComponentType.Account+ ? $localize`Platform ${domain} muted.`+ : $localize`Platform ${domain} muted by your platform.`+ )++ this.table().loadData()+ }+ )+ })+ }++ private _dataLoader (options: DataLoaderOptions) {+ if (this.mode() === BlocklistComponentType.Account) {+ return this.blocklistService.getUserServerBlocklist(options)+ }++ return this.blocklistService.getInstanceServerBlocklist(options)+ }+}diff --git a/client/src/app/shared/shared-moderation/moderation.scss b/client/src/app/shared/shared-moderation/moderation.scssindex 472d2c48dc..15078dd805 100644--- a/client/src/app/shared/shared-moderation/moderation.scss+++ b/client/src/app/shared/shared-moderation/moderation.scss@@ -1,7 +1,7 @@-@use 'sass:math';-@use '_variables' as *;-@use '_mixins' as *;-@use '_miniature' as *;+@use "sass:math";+@use "_variables" as *;+@use "_mixins" as *;+@use "_miniature" as *;.moderation-expanded {font-size: 90%;@@ -40,12 +40,6 @@}}-my-action-dropdown.show {- ::ng-deep .dropdown-root {- display: block !important;- }-}-.table-comment-link,.table-account-link {text-decoration: none;diff --git a/client/src/app/shared/shared-moderation/server-blocklist.component.html b/client/src/app/shared/shared-moderation/server-blocklist.component.htmldeleted file mode 100644index f93bbaf954..0000000000--- a/client/src/app/shared/shared-moderation/server-blocklist.component.html+++ /dev/null@@ -1,58 +0,0 @@-<p-table- [value]="blockedServers" [paginator]="totalRecords > 0" [totalRecords]="totalRecords"- [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions" [first]="pagination.start"- [sortField]="sort.field" [sortOrder]="sort.order"- [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"->- <ng-template #caption>- <div class="caption">- <div class="left-buttons">- <button class="peertube-create-button" (click)="addServersToBlock()" (key.enter)="addServersToBlock()">- <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>- <ng-container i18n>Mute domains</ng-container>- </button>- </div>-- <div class="ms-auto">- <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter>- </div>- </div>- </ng-template>-- <ng-template #header>- <tr>- <th scope="col" style="width: 150px;" i18n>Action</th> <!-- column for action buttons -->- <th scope="col" i18n>Instance</th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Muted at <p-sortIcon field="createdAt"></p-sortIcon></th>- </tr>- </ng-template>-- <ng-template #body let-serverBlock>- <tr>- <td class="action-cell">- <button class="peertube-button secondary-button" (click)="unblockServer(serverBlock)" i18n>Unmute</button>- </td>- <td>- <a [href]="'https://' + serverBlock.blockedServer.host" i18n-title title="Open instance in a new tab" target="_blank" rel="noopener noreferrer">- {{ serverBlock.blockedServer.host }}- <my-global-icon iconName="external-link"></my-global-icon>- </a>- </td>- <td>{{ serverBlock.createdAt | ptDate: 'short' }}</td>- </tr>- </ng-template>-- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container *ngIf="search" i18n>No server found matching current filters.</ng-container>- <ng-container *ngIf="!search" i18n>No server found.</ng-container>- </div>- </td>- </tr>- </ng-template>-</p-table>--<my-batch-domains-modal #batchDomainsModal i18n-action action="Mute domains" (domains)="onDomainsToBlock($event)"></my-batch-domains-modal>diff --git a/client/src/app/shared/shared-moderation/server-blocklist.component.scss b/client/src/app/shared/shared-moderation/server-blocklist.component.scssdeleted file mode 100644index 78ebea6aa8..0000000000--- a/client/src/app/shared/shared-moderation/server-blocklist.component.scss+++ /dev/null@@ -1,6 +0,0 @@-@use '_variables' as *;-@use '_mixins' as *;--a {- color: pvar(--fg);-}diff --git a/client/src/app/shared/shared-moderation/server-blocklist.component.ts b/client/src/app/shared/shared-moderation/server-blocklist.component.tsdeleted file mode 100644index aff458f8b2..0000000000--- a/client/src/app/shared/shared-moderation/server-blocklist.component.ts+++ /dev/null@@ -1,97 +0,0 @@-import { Directive, OnInit, inject, viewChild } from '@angular/core'-import { Notifier, RestPagination, RestTable } from '@app/core'-import { BatchDomainsModalComponent } from '@app/shared/shared-moderation/batch-domains-modal.component'-import { ServerBlock } from '@peertube/peertube-models'-import { SortMeta } from 'primeng/api'-import { BlocklistComponentType, BlocklistService } from './blocklist.service'--@Directive()-export class GenericServerBlocklistComponent extends RestTable implements OnInit {- protected notifier = inject(Notifier)- protected blocklistService = inject(BlocklistService)-- readonly batchDomainsModal = viewChild<BatchDomainsModalComponent>('batchDomainsModal')-- // @ts-expect-error: "Abstract methods can only appear within an abstract class"- public abstract mode: BlocklistComponentType-- blockedServers: ServerBlock[] = []- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }-- // @ts-expect-error: "Abstract methods can only appear within an abstract class"- public abstract getIdentifier (): string-- ngOnInit () {- this.initialize()- }-- unblockServer (serverBlock: ServerBlock) {- const operation = (host: string) =>- this.mode === BlocklistComponentType.Account- ? this.blocklistService.unblockServerByUser(host)- : this.blocklistService.unblockServerByInstance(host)- const host = serverBlock.blockedServer.host-- operation(host).subscribe(- () => {- this.notifier.success(- this.mode === BlocklistComponentType.Account- ? $localize`${host} unmuted.`- : $localize`${host} unmuted by your platform.`- )-- this.reloadData()- }- )- }-- addServersToBlock () {- this.batchDomainsModal().openModal()- }-- onDomainsToBlock (domains: string[]) {- const operation = (domain: string) =>- this.mode === BlocklistComponentType.Account- ? this.blocklistService.blockServerByUser(domain)- : this.blocklistService.blockServerByInstance(domain)-- domains.forEach(domain => {- operation(domain).subscribe(- () => {- this.notifier.success(- this.mode === BlocklistComponentType.Account- ? $localize`Platform ${domain} muted.`- : $localize`Platform ${domain} muted by your platform.`- )-- this.reloadData()- }- )- })- }-- protected reloadDataInternal () {- const operation = this.mode === BlocklistComponentType.Account- ? this.blocklistService.getUserServerBlocklist({- pagination: this.pagination,- sort: this.sort,- search: this.search- })- : this.blocklistService.getInstanceServerBlocklist({- pagination: this.pagination,- sort: this.sort,- search: this.search- })-- return operation.subscribe({- next: resultList => {- this.blockedServers = resultList.data- this.totalRecords = resultList.total- },-- error: err => this.notifier.error(err.message)- })- }-}diff --git a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.tsindex 6835e3b0f7..4485dcd503 100644--- a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts+++ b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts@@ -370,7 +370,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {isDisplayed: ({ user }) => !this.isMyUser(user) && user.blocked},{- label: $localize`Set Email as Verified`,+ label: $localize`Set email as verified`,handler: ({ user }) => this.setEmailAsVerified(user),isDisplayed: ({ user }) => !user.blocked && user.emailVerified !== true}diff --git a/client/src/app/shared/shared-tables/table-expander-icon.component copy.ts b/client/src/app/shared/shared-tables/table-expander-icon.component copy.tsnew file mode 100644index 0000000000..ebe2da1d18--- /dev/null+++ b/client/src/app/shared/shared-tables/table-expander-icon.component copy.ts@@ -0,0 +1,16 @@+import { Component, input } from '@angular/core'+import { NgClass } from '@angular/common'+import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'++@Component({+ selector: 'my-table-expander-icon',+ template: `+<button type="button" class="expander border-0 p-0" [ngbTooltip]="tooltip()" [ariaLabel]="tooltip()">+ <i [ngClass]="expanded() ? 'chevron-down' : 'chevron-right'"></i>+</button>`,+ imports: [ NgbTooltip, NgClass ]+})+export class TableExpanderIconComponent {+ readonly expanded = input<boolean>(undefined)+ readonly tooltip = input($localize`Get more information`)+}diff --git a/client/src/app/shared/shared-tables/table.component.html b/client/src/app/shared/shared-tables/table.component.htmlnew file mode 100644index 0000000000..61ce0c9c00--- /dev/null+++ b/client/src/app/shared/shared-tables/table.component.html@@ -0,0 +1,174 @@+<p-table+ [value]="data"+ [paginator]="totalRecords > 0"+ [totalRecords]="totalRecords"+ [rows]="pagination.count"+ [first]="pagination.start"+ [rowsPerPageOptions]="rowsPerPageOptions"+ [sortField]="sort.field"+ [sortOrder]="sort.order"+ [dataKey]="dataKey()"+ resizableColumns="false"+ [(selection)]="selectedRows"+ lazy="true"+ (onLazyLoad)="onLoadLazy($event)"+ [currentPageReportTemplate]="getPaginationTemplate()"+ lazyLoadOnInit="false"+ selectionPageOnly="true"+ showCurrentPageReport="true"+ [expandedRowKeys]="expandedRows"+ (onRowExpand)="rowExpand.emit($event)"+ [ngClass]="{ loading: loading, 'sticky-table': actionCell }"+>+ <ng-template #caption>+ <div class="caption">+ <div class="left-buttons">+ @if (isInSelectionMode()) {+ <my-action-dropdown i18n-label label="Batch actions" theme="primary" [actions]="bulkActions()" [entry]="selectedRows"></my-action-dropdown>+ } @else {+ <strong *ngIf="totalTitle" i18n [ngClass]="{ 'opacity-0': loading }">+ <ng-template *ngTemplateOutlet="totalTitle; context: { $implicit: totalRecords }"></ng-template>+ </strong>++ <div *ngIf="captionLeft" class="ms-auto right-block">+ <ng-template *ngTemplateOutlet="captionLeft"></ng-template>+ </div>+ }+ </div>++ <div *ngIf="captionRight" class="ms-auto right-block">+ <ng-template *ngTemplateOutlet="captionRight"></ng-template>+ </div>+ </div>+ </ng-template>++ <ng-template #sorticon let-sortOrder>+ @if (sortOrder === 1) {+ <my-button class="ms-2" small="true" active="true" rounded="true" theme="tertiary" icon="chevron-up"></my-button>+ } @else if (sortOrder === -1) {+ <my-button class="ms-2" small="true" active="true" rounded="true" theme="tertiary" icon="chevron-down"></my-button>+ } @else if (sortOrder === 0) {+ <my-button class="ms-2" small="true" rounded="true" theme="tertiary" icon="chevron-down"></my-button>+ }+ </ng-template>++ <ng-template #paginatorright>+ {{ paginatorText() }}+ </ng-template>++ <ng-template #header>+ <tr>+ <th *ngIf="hasBulkActions()" scope="col" width="25px" class="checkbox-cell">+ <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>+ </th>++ <th *ngIf="expandedRow">+ <div class="visually-hidden">{{ expandedIconTooltip() }}</div>+ </th>++ @for (column of columns; track column.id) {+ @if (isColumnDisplayed(column.id)) {+ @if (column.sortable) {+ <th+ scope="col" [ngbTooltip]="sortTooltip" container="body" [pSortableColumn]="getUntypedColumnId(column)" [ngClass]="column.class"+ >+ {{ column.label }}+ <small *ngIf="column.labelSmall">{{ column.labelSmall }}</small>++ <p-sortIcon [field]="getUntypedColumnId(column)"></p-sortIcon>+ </th>+ } @else {+ <th scope="col" [ngClass]="column.class">+ {{ column.label }}++ <small *ngIf="column.labelSmall">{{ column.labelSmall }}</small>+ </th>+ }+ }+ }++ <th *ngIf="columnConfig() || actionCell" scope="col" class="action-head" [ngClass]="{ 'has-column-config': columnConfig(), 'has-action': actionCell }">+ <div class="d-flex align-items-center justify-content-end gap-2">+ <span *ngIf="actionCell" i18>Actions</span>++ <span *ngIf="columnConfig()" class="column-toggle">+ <div ngbDropdown placement="bottom-left auto" container="body" autoClose="outside" #columnsDropdown="ngbDropdown">+ <my-button+ theme="tertiary"+ icon="columns"+ ngbDropdownToggle+ i18n-title+ title="Open table configuration"+ [show]="columnsDropdown.isOpen()"+ ></my-button>++ <div ngbDropdownMenu class="p-3">+ <div class="form-group">+ <div class="muted small mb-2" i18n>Column displayed:</div>++ @for (column of columns; track column) {+ <div class="ms-1 mb-1">+ <my-peertube-checkbox+ [inputName]="'column-' + column.id"+ [(ngModel)]="column.selected"+ i18n-labelText+ [labelText]="column.label"+ (ngModelChange)="saveSelectedColumns()"+ ></my-peertube-checkbox>+ </div>+ }+ </div>+ </div>+ </div>+ </span>+ </div>+ </th>+ </tr>+ </ng-template>++ <ng-template #body let-item let-expanded="expanded">+ <tr [pSelectableRow]="item">+ <td *ngIf="hasBulkActions()" class="checkbox-cell">+ <p-tableCheckbox [value]="item" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>+ </td>++ <td *ngIf="expandedRow" class="expand-cell">+ <my-table-expander-icon *ngIf="hasExpandedRow()(item)" [pRowToggler]="item" [tooltip]="expandedIconTooltip()" [expanded]="expanded"></my-table-expander-icon>+ </td>++ <ng-template *ngTemplateOutlet="tableCells; context: { $implicit: item }"></ng-template>++ @if (columnConfig() || actionCell) {+ <td class="action-cell" [ngClass]="{ 'has-column-config': columnConfig(), 'has-action': actionCell }">+ <div class="d-flex justify-content-end gap-2">+ <ng-template *ngTemplateOutlet="actionCell; context: { $implicit: item }"></ng-template>+ </div>+ </td>+ }+ </tr>+ </ng-template>++ <ng-template #emptymessage>+ <tr *ngIf="loaded && !loading">+ <td myAutoColspan>+ <div class="no-results">+ @if (noResults) {+ <ng-template *ngTemplateOutlet="noResults; context: { $implicit: search }"></ng-template>+ } @else {+ <ng-container i18n>No results found.</ng-container>+ }+ </div>+ </td>+ </tr>+ </ng-template>++ @if (expandedRow) {+ <ng-template #expandedrow let-item>+ <tr>+ <td class="expand-cell" myAutoColspan>+ <ng-template *ngTemplateOutlet="expandedRow; context: { $implicit: item }"></ng-template>+ </td>+ </tr>+ </ng-template>+ }+</p-table>diff --git a/client/src/app/shared/shared-tables/table.component.ts b/client/src/app/shared/shared-tables/table.component.tsnew file mode 100644index 0000000000..34c9c97dc9--- /dev/null+++ b/client/src/app/shared/shared-tables/table.component.ts@@ -0,0 +1,456 @@+import { CommonModule } from '@angular/common'+import {+ booleanAttribute,+ Component,+ ContentChild,+ inject,+ input,+ numberAttribute,+ OnChanges,+ OnDestroy,+ OnInit,+ output,+ TemplateRef+} from '@angular/core'+import { FormsModule } from '@angular/forms'+import { ActivatedRoute } from '@angular/router'+import { LocalStorageService, Notifier, PeerTubeRouterService, RestPagination } from '@app/core'+import { NgbDropdownModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'+import { ResultList } from '@peertube/peertube-models'+import { logger } from '@root-helpers/logger'+import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'+import debug from 'debug'+import { SharedModule, SortMeta } from 'primeng/api'+import { TableLazyLoadEvent, TableModule, TableRowExpandEvent } from 'primeng/table'+import { finalize, Observable, Subscription } from 'rxjs'+import { PeertubeCheckboxComponent } from '../shared-forms/peertube-checkbox.component'+import { ActionDropdownComponent, DropdownAction } from '../shared-main/buttons/action-dropdown.component'+import { ButtonComponent } from '../shared-main/buttons/button.component'+import { AutoColspanDirective } from '../shared-main/common/auto-colspan.directive'+import { TableExpanderIconComponent } from './table-expander-icon.component'++const debugLogger = debug('peertube:table')++export type DataLoaderOptions = {+ pagination: RestPagination+ sort: SortMeta+ search?: string+}+export type DataLoader<Data> = (options: DataLoaderOptions) => Observable<ResultList<Data>>++export type TableQueryParams = {+ start?: number+ count?: number+ sortOrder?: number+ sortField?: string+ search?: string+}++export type TableColumnInfo<ColumnName> = {+ id: ColumnName++ label: string+ labelSmall?: string++ sortable: boolean++ class?: string+ selected?: boolean // true by default+ sortKey?: string // same as id by default+ isDisplayed?: () => boolean // true by default+}++type BulkActions<Data> = DropdownAction<Data[]>[][] | DropdownAction<Data[]>[]++@Component({+ selector: 'my-table',+ templateUrl: './table.component.html',+ standalone: true,+ imports: [+ CommonModule,+ FormsModule,+ TableModule,+ SharedModule,+ ActionDropdownComponent,+ ButtonComponent,+ NgbTooltipModule,+ NgbDropdownModule,+ PeertubeCheckboxComponent,+ AutoColspanDirective,+ TableExpanderIconComponent+ ]+})+export class TableComponent<Data, ColumnName = string, QueryParams extends TableQueryParams = TableQueryParams>+ implements OnInit, OnDestroy, OnChanges+{+ private peertubeLocalStorage = inject(LocalStorageService)+ private route = inject(ActivatedRoute)+ private peertubeRouter = inject(PeerTubeRouterService)+ private notifier = inject(Notifier)++ readonly key = input.required<string>()+ readonly dataKey = input<string>('id')+ readonly defaultColumns = input.required<TableColumnInfo<ColumnName>[]>()+ readonly dataLoader = input.required<DataLoader<Data>>()++ readonly defaultSort = input<string>('createdAt')+ readonly defaultSortOrder = input<'asc' | 'desc'>('desc')++ readonly defaultRowsPerPage = input(10, { transform: numberAttribute })+ readonly columnConfig = input(true, { transform: booleanAttribute })+ readonly hasExpandedRow = input<(item: Data) => boolean>(() => true)++ readonly paginatorText = input.required<string>()+ readonly expandedIconTooltip = input($localize`More information`)++ readonly bulkActions = input<BulkActions<Data>>()++ readonly customParseQueryParams = input<(queryParams: QueryParams) => void>(() => {})+ readonly customUpdateUrl = input<() => Partial<QueryParams>>(() => ({}))++ readonly cellWrap = input(false, { transform: booleanAttribute })++ @ContentChild('totalTitle', { descendants: false })+ totalTitle: TemplateRef<any>++ @ContentChild('captionRight', { descendants: false })+ captionRight: TemplateRef<any>++ @ContentChild('captionLeft', { descendants: false })+ captionLeft: TemplateRef<any>++ @ContentChild('tableCells', { descendants: false })+ tableCells: TemplateRef<any>++ @ContentChild('actionCell', { descendants: false })+ actionCell: TemplateRef<any>++ @ContentChild('noResults', { descendants: false })+ noResults: TemplateRef<any>++ @ContentChild('expandedRow', { descendants: false })+ expandedRow: TemplateRef<any>++ readonly rowExpand = output<TableRowExpandEvent>()++ selectedRows: Data[] = []+ expandedRows = {}+ data: Data[] = []+ columns: Required<TableColumnInfo<ColumnName>>[] = []++ totalRecords = 0+ rowsPerPageOptions = [ 5, 10, 20, 50, 100 ]+ sort: SortMeta = { field: undefined, order: -1 }+ pagination: RestPagination++ search: string++ loaded = false+ loading = false++ sortTooltip = $localize`Sort by this column`++ // First string is badge column type+ // Inner Map is value -> badge name+ private valueToBadge = new Map<string, Map<string, string>>()+ private badgesUsed = new Set<string>()++ private lastLazyLoadEvent: TableLazyLoadEvent+ private routeSubscription: Subscription++ ngOnInit (): void {+ this.sort = {+ field: this.defaultSort(),+ order: this.defaultSortOrder() === 'desc'+ ? -1+ : 1+ }++ this.pagination = {+ count: this.defaultRowsPerPage(),+ start: 0+ }++ this.loadSort()+ this.loadSelectedColumns()+ this.subscribeToQueryChanges()+ }++ ngOnDestroy () {+ this.routeSubscription?.unsubscribe()+ }++ ngOnChanges () {+ this.columns = this.defaultColumns().map(c => ({+ id: c.id,++ label: c.label,+ labelSmall: c.labelSmall,+ sortable: c.sortable,++ class: c.class || '',+ selected: c.selected ?? true,+ sortKey: c.sortKey || c.id as string,+ isDisplayed: c.isDisplayed || (() => true)+ }))+ }++ // ---------------------------------------------------------------------------++ getColumn (id: ColumnName) {+ return this.columns.find(c => c.id === id)+ }++ getUntypedColumnId (column: { id: ColumnName }) {+ return column.id as string+ }++ isColumnDisplayed (name: ColumnName) {+ const column = this.getColumn(name)+ if (column.selected === false) return false++ return column.isDisplayed()+ }++ // ---------------------------------------------------------------------------++ onSearch (search: string, useMatchSort = false) {+ debugLogger('On search', { search, useMatchSort })++ this.search = search++ if (useMatchSort) {+ this.sort = {+ field: 'match' as any,+ order: -1+ }+ }++ this.resetPagination()+ this.updateUrl()+ }++ onFilter () {+ debugLogger('On filter')++ this.resetPagination()+ this.updateUrl()+ }++ reloadData (sort?: SortMeta) {+ debugLogger('Reload data', sort)++ if (sort) this.sort = sort++ this.resetPagination()+ this.updateUrl()+ }++ private resetPagination () {+ this.pagination.start = 0++ this.selectedRows = []+ this.expandedRows = {}+ }++ // ---------------------------------------------------------------------------++ saveSelectedColumns () {+ const enabled = this.columns.filter(c => c.selected !== false).map(c => c.id)++ this.peertubeLocalStorage.setItem(this.getColumnLocalStorageKey(), JSON.stringify(enabled))+ }++ private loadSelectedColumns () {+ const enabledString = this.peertubeLocalStorage.getItem(this.getColumnLocalStorageKey())++ if (!enabledString) return+ try {+ const enabled = JSON.parse(enabledString)++ for (const column of this.columns) {+ column.selected = enabled.includes(column.id)+ }+ } catch (err) {+ logger.error('Cannot load selected columns.', err)+ }+ }++ private getColumnLocalStorageKey () {+ return 'rest-table-columns-' + this.key()+ }+ // ---------------------------------------------------------------------------++ loadSort () {+ const result = peertubeLocalStorage.getItem(this.getSortLocalStorageKey())++ if (result) {+ try {+ this.sort = JSON.parse(result)+ } catch (err) {+ logger.error('Cannot load sort of local storage key ' + this.getSortLocalStorageKey(), err)+ }+ }+ }++ saveSort () {+ peertubeLocalStorage.setItem(this.getSortLocalStorageKey(), JSON.stringify(this.sort))+ }++ private getSortLocalStorageKey () {+ return 'rest-table-sort-' + this.key()+ }++ // ---------------------------------------------------------------------------++ onLoadLazy (event: TableLazyLoadEvent) {+ if (this.parseLazy(event)) {+ debugLogger('Load lazy', event)++ this.saveSort()++ this.updateUrl()+ }+ }++ private parseLazy (event: TableLazyLoadEvent) {+ debugLogger('Parse lazy', event)++ if (this.lastLazyLoadEvent) {+ // Prevent lazy loading twice+ // TODO: remove when https://github.com/primefaces/primeng/issues/5480 is fixed+ if (+ this.lastLazyLoadEvent.first === event.first &&+ this.lastLazyLoadEvent.rows === event.rows &&+ this.lastLazyLoadEvent.sortField === event.sortField &&+ this.lastLazyLoadEvent.sortOrder === event.sortOrder+ ) return false+ }++ this.lastLazyLoadEvent = event++ this.sort = {+ order: event.sortOrder,+ field: event.sortField as string+ }++ this.pagination = {+ start: event.first,+ count: event.rows+ }++ this.expandedRows = {}+ this.selectedRows = []++ return true+ }++ private subscribeToQueryChanges () {+ this.routeSubscription = this.route.queryParams.subscribe(queryParams => {+ this.parseQueryParams(queryParams as QueryParams)+ })+ }++ private parseQueryParams (queryParams: QueryParams) {+ debugLogger('Parse query params', { queryParams })++ if (queryParams.search !== undefined) this.search = queryParams.search+ if (queryParams.start !== undefined) this.pagination.start = +queryParams.start+ if (queryParams.count !== undefined) this.pagination.count = +queryParams.count+ if (queryParams.sortOrder !== undefined) this.sort.order = +queryParams.sortOrder+ if (queryParams.sortField !== undefined) this.sort.field = queryParams.sortField++ this.customParseQueryParams()(queryParams)++ this.loadData()+ }++ private updateUrl () {+ const newParams: TableQueryParams = {+ ...this.route.snapshot.queryParams,+ ...this.customUpdateUrl()(),++ search: this.search,+ start: this.pagination.start,+ count: this.pagination.count,+ sortOrder: this.sort.order,+ sortField: this.sort.field+ }++ debugLogger('Update URL', { newParams })++ this.peertubeRouter.silentNavigate([ '.' ], newParams, this.route)+ }++ // ---------------------------------------------------------------------------++ isInSelectionMode () {+ return this.selectedRows.length !== 0+ }++ getPaginationTemplate () {+ return $localize`Showing {first} to {last} of {totalRecords} elements`+ }++ hasBulkActions () {+ return this.bulkActions() && this.bulkActions().length !== 0+ }++ getRandomBadge (type: string, value: string): string {+ if (!this.valueToBadge.has(type)) {+ this.valueToBadge.set(type, new Map())+ }++ const badges = this.valueToBadge.get(type)+ const badge = badges.get(value)+ if (badge) return badge++ const toTry = [+ 'badge-yellow',+ 'badge-purple',+ 'badge-blue',+ 'badge-brown',+ 'badge-green',+ 'badge-secondary'+ ]++ for (const badge of toTry) {+ if (!this.badgesUsed.has(badge)) {+ this.badgesUsed.add(badge)+ badges.set(value, badge)+ return badge+ }+ }++ // Reset, we used all available badges+ this.badgesUsed.clear()++ return this.getRandomBadge(type, value)+ }++ loadData () {+ this.loading = true++ return new Promise<void>((res, rej) => {+ this.dataLoader()({+ pagination: this.pagination,+ sort: this.sort,+ search: this.search+ }).pipe(finalize(() => this.loading = false))+ .subscribe({+ next: resultList => {+ this.data = resultList.data+ this.totalRecords = resultList.total+ this.loaded = true++ res()+ },++ error: err => {+ this.notifier.error(err.message)+ rej(err)+ }+ })+ })+ }+}diff --git a/client/src/app/shared/shared-users/user-admin.service.ts b/client/src/app/shared/shared-users/user-admin.service.tsindex 294193017e..3c110518ac 100644--- a/client/src/app/shared/shared-users/user-admin.service.ts+++ b/client/src/app/shared/shared-users/user-admin.service.ts@@ -1,12 +1,29 @@-import { SortMeta } from 'primeng/api'-import { from, Observable } from 'rxjs'-import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'import { HttpClient, HttpParams } from '@angular/common/http'-import { Injectable, inject } from '@angular/core'+import { inject, Injectable } from '@angular/core'import { RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core'-import { getBytes } from '@root-helpers/bytes'import { arrayify, peertubeTranslate } from '@peertube/peertube-core-utils'-import { ResultList, User as UserServerModel, UserCreate, UserUpdate } from '@peertube/peertube-models'+import { ResultList, UserCreate, UserRoleType, User as UserServerModel, UserUpdate } from '@peertube/peertube-models'+import { getBytes } from '@root-helpers/bytes'+import { SortMeta } from 'primeng/api'+import { from } from 'rxjs'+import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'++export type UserAdmin = UserServerModel & {+ role: {+ id: UserRoleType+ label: string+ }++ videoQuota: string+ videoQuotaUsed: string+ rawVideoQuota: number+ rawVideoQuotaUsed: number++ videoQuotaDaily: string+ videoQuotaUsedDaily: string+ rawVideoQuotaDaily: number+ rawVideoQuotaUsedDaily: number+}@Injectable()export class UserAdminService {@@ -34,11 +51,11 @@ export class UserAdminService {)}- getUsers (parameters: {+ listUsers (parameters: {pagination: RestPaginationsort: SortMetasearch?: string- }): Observable<ResultList<UserServerModel>> {+ }) {const { pagination, sort, search } = parameterslet params = new HttpParams()@@ -102,7 +119,7 @@ export class UserAdminService {)}- private formatUser (user: UserServerModel, translations: { [id: string]: string } = {}) {+ private formatUser (user: UserServerModel, translations: { [id: string]: string } = {}): UserAdmin {let videoQuotaif (user.videoQuota === -1) {videoQuota = '∞'diff --git a/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.html b/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.htmlindex 79ce4ffd52..1e4b112944 100644--- a/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.html+++ b/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.html@@ -1,122 +1,78 @@-<p-table- [value]="comments" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id"- [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" [selectionPageOnly]="true"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [expandedRowKeys]="expandedRows" [(selection)]="selectedRows"+<my-table+ #table+ [key]="key()"+ [defaultColumns]="columns"+ defaultSort="createdAt"+ i18n-paginatorText+ paginatorText="comments per page"+ [bulkActions]="bulkActions"+ [dataLoader]="dataLoader">- <ng-template #caption>- <div class="caption">- <div>- <my-action-dropdown- *ngIf="isInSelectionMode()" i18n-label label="Batch actions" theme="primary"- [actions]="bulkActions" [entry]="selectedRows"- >- </my-action-dropdown>- </div>-- <div class="ms-auto right-form">- <my-advanced-input-filter [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter>- <my-button i18n-label label="Refresh" icon="refresh" (click)="reloadData()"></my-button>- </div>- </div>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No comments} =1 {1 comment} other {{{ totalRecords | myNumberFormatter }} comments}}</ng-container></ng-template>- <ng-template #header>- <tr>- <th class="checkbox-cell" scope="col" style="width: 40px;">- <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>- </th>- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>- <th scope="col" style="width: 70px;">- <span i18n class="visually-hidden">Actions</span>- </th>- <th scope="col" i18n>Account</th>- <th scope="col" i18n>Video</th>- <th scope="col" i18n>Comment</th>- <th scope="col" i18n>Auto tags</th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Date <p-sortIcon field="createdAt"></p-sortIcon></th>- </tr>- </ng-template>-- <ng-template #body let-videoComment let-expanded="expanded">- <tr [pSelectableRow]="videoComment">-- <td class="checkbox-cell">- <p-tableCheckbox [value]="videoComment" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>- </td>-- <td class="expand-cell">- <my-table-expander-icon [pRowToggler]="videoComment" i18n-tooltip tooltip="See full comment" [expanded]="expanded"></my-table-expander-icon>- </td>+ <ng-template #captionRight>+ <my-advanced-input-filter [filters]="inputFilters" (search)="table.onSearch($event)"></my-advanced-input-filter>- <td class="action-cell">- <my-action-dropdown- [ngClass]="{ 'show': expanded }" placement="bottom-right" container="body"- [actions]="videoCommentActions" [entry]="videoComment" buttonSize="small"- ></my-action-dropdown>- </td>+ <my-button i18n-label label="Refresh" icon="refresh" (click)="table.loadData()"></my-button>+ </ng-template>- <td>- <a [href]="videoComment.account.localUrl" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">- <div class="chip two-lines">- <my-actor-avatar [actor]="videoComment.account" actorType="account" size="32"></my-actor-avatar>- <div>- {{ videoComment.account.displayName }}- <span>{{ videoComment.by }}</span>- </div>+ <ng-template #tableCells let-comment>+ <td *ngIf="table.isColumnDisplayed('account')">+ <a [href]="comment.account.localUrl" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">+ <div class="chip two-lines">+ <my-actor-avatar [actor]="comment.account" actorType="account" size="32"></my-actor-avatar>+ <div>+ {{ comment.account.displayName }}+ <span>{{ comment.by }}</span></div>- </a>- </td>-- <td class="video">- <em i18n>Commented video</em>+ </div>+ </a>+ </td>- <a [href]="videoComment.localUrl" target="_blank" rel="noopener noreferrer" class="text-decoration-none">{{ videoComment.video.name }}</a>- </td>+ <td *ngIf="table.isColumnDisplayed('video')" class="video">+ <em i18n>Commented video</em>- <td class="c-hand comment-content-cell" [pRowToggler]="videoComment">- <span *ngIf="videoComment.heldForReview" class="pt-badge badge-red float-start me-2" i18n>Pending review</span>+ <a [href]="comment.localUrl" target="_blank" rel="noopener noreferrer" class="text-decoration-none">{{ comment.video.name }}</a>+ </td>- <div class="comment-html">- <div [innerHTML]="videoComment.textHtml"></div>- </div>- </td>+ <td *ngIf="table.isColumnDisplayed('comment')" class="comment-content-cell">+ <span *ngIf="comment.heldForReview" class="pt-badge badge-red float-start me-2" i18n>Pending review</span>- <td>- @for (tag of videoComment.automaticTags; track tag) {- <a- i18n-title title="Only display comments with this tag"- class="pt-badge badge-secondary me-1"- [routerLink]="[ '.' ]" [queryParams]="{ 'search': buildSearchAutoTag(tag) }"- >{{ tag }}</a>- }- </td>+ <div class="comment-html">+ <div class="ellipsis" [innerHTML]="comment.textHtml"></div>+ </div>+ </td>++ <td *ngIf="table.isColumnDisplayed('autoTags')">+ @for (tag of comment.automaticTags; track tag) {+ <a+ i18n-title title="Only display comments with this tag"+ class="pt-badge badge-secondary me-1"+ [routerLink]="[ '.' ]" [queryParams]="{ 'search': buildSearchAutoTag(tag) }"+ >{{ tag }}</a>+ }+ </td>++ <td *ngIf="table.isColumnDisplayed('createdAt')">{{ comment.createdAt | ptDate: 'short' }}</td>+ </ng-template>- <td class="c-hand" [pRowToggler]="videoComment">{{ videoComment.createdAt | ptDate: 'short' }}</td>- </tr>+ <ng-template #actionCell let-comment>+ <my-action-dropdown placement="bottom-right" container="body" [actions]="videoCommentActions" [entry]="comment"></my-action-dropdown></ng-template>- <ng-template #expandedrow let-videoComment>- <tr>- <td class="expand-cell" myAutoColspan>- <div [innerHTML]="videoComment.textHtml"></div>- </td>- </tr>+ <ng-template #expandedRow let-comment>+ <div [innerHTML]="comment.textHtml"></div></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container *ngIf="search" i18n>No comments found matching current filters.</ng-container>- <ng-container *ngIf="!search" i18n>No comments found.</ng-container>- </div>- </td>- </tr>+ <ng-template #noResults let-search>+ @if (search) {+ <ng-container i18n>No comments found matching current filters.</ng-container>+ } @else {+ <ng-container i18n>No comments found.</ng-container>+ }</ng-template>-</p-table>+</my-table>diff --git a/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.scss b/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.scssindex 8f21163c12..b0d3808404 100644--- a/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.scss+++ b/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.scss@@ -1,10 +1,5 @@-@use '_variables' as *;-@use '_mixins' as *;--my-global-icon {- width: 24px;- height: 24px;-}+@use "_variables" as *;+@use "_mixins" as *;.video {display: flex;@@ -28,33 +23,21 @@ my-global-icon {}}-.comment-html {- ::ng-deep {- > div {- max-height: 22px;- }+.comment-html > div {+ max-width: 30vw;+ overflow: hidden;- div,- p {- @include ellipsis;+ ::ng-deep {+ * {+ display: inline;}- p {- margin: 0;+ br {+ display: none;}}}-.right-form {- display: flex;- flex-wrap: wrap;- row-gap: 0.5rem;-- > *:not(:last-child) {- @include margin-right(10px);- }-}-@media screen and (max-width: $medium-view) {.video {align-items: flex-start !important;diff --git a/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.ts b/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.tsindex a22234a7fd..806ee6eb01 100644--- a/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.ts+++ b/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.ts@@ -1,47 +1,46 @@-import { NgClass, NgIf } from '@angular/common'-import { Component, OnDestroy, OnInit, inject, input } from '@angular/core'-import { ActivatedRoute, Router, RouterLink } from '@angular/router'-import { AuthService, ConfirmService, HooksService, MarkdownService, Notifier, PluginService, RestPagination, RestTable } from '@app/core'+import { CommonModule } from '@angular/common'+import { Component, OnDestroy, OnInit, inject, input, viewChild } from '@angular/core'+import { ActivatedRoute, RouterLink } from '@angular/router'+import { AuthService, ConfirmService, HooksService, MarkdownService, Notifier, PluginService } from '@app/core'import { formatICU } from '@app/helpers'import { BulkService } from '@app/shared/shared-moderation/bulk.service'import { VideoCommentForAdminOrUser } from '@app/shared/shared-video-comment/video-comment.model'import { VideoCommentService } from '@app/shared/shared-video-comment/video-comment.service'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { UserRight } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'-import { lastValueFrom } from 'rxjs'+import { switchMap } from 'rxjs'import { ActorAvatarComponent } from '../shared-actor-image/actor-avatar.component'import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../shared-forms/advanced-input-filter.component'import { ActionDropdownComponent, DropdownAction } from '../shared-main/buttons/action-dropdown.component'import { ButtonComponent } from '../shared-main/buttons/button.component'-import { AutoColspanDirective } from '../shared-main/common/auto-colspan.directive'import { PTDatePipe } from '../shared-main/common/date.pipe'-import { TableExpanderIconComponent } from '../shared-tables/table-expander-icon.component'+import { NumberFormatterPipe } from '../shared-main/common/number-formatter.pipe'+import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../shared-tables/table.component'++type ColumnName =+ | 'account'+ | 'video'+ | 'comment'+ | 'autoTags'+ | 'createdAt'@Component({selector: 'my-video-comment-list-admin-owner',templateUrl: './video-comment-list-admin-owner.component.html',styleUrls: [ '../shared-moderation/moderation.scss', './video-comment-list-admin-owner.component.scss' ],imports: [- TableModule,- SharedModule,- NgIf,+ CommonModule,ActionDropdownComponent,AdvancedInputFilterComponent,ButtonComponent,- NgbTooltip,- TableExpanderIconComponent,- NgClass,ActorAvatarComponent,- AutoColspanDirective,PTDatePipe,- RouterLink+ RouterLink,+ TableComponent,+ NumberFormatterPipe]})-export class VideoCommentListAdminOwnerComponent extends RestTable<VideoCommentForAdminOrUser> implements OnInit, OnDestroy {- protected router = inject(Router)- protected route = inject(ActivatedRoute)+export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {+ private route = inject(ActivatedRoute)private auth = inject(AuthService)private notifier = inject(Notifier)private confirmService = inject(ConfirmService)@@ -51,28 +50,36 @@ export class VideoCommentListAdminOwnerComponent extends RestTable<VideoCommentFprivate hooks = inject(HooksService)private pluginService = inject(PluginService)+ readonly key = input.required<string>()readonly mode = input.required<'user' | 'admin'>()- comments: VideoCommentForAdminOrUser[]- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<VideoCommentForAdminOrUser, ColumnName>>('table')videoCommentActions: DropdownAction<VideoCommentForAdminOrUser>[][] = []-bulkActions: DropdownAction<VideoCommentForAdminOrUser[]>[] = []-inputFilters: AdvancedInputFilter[] = []+ columns: TableColumnInfo<ColumnName>[] = [+ { id: 'account', label: $localize`Account`, sortable: false },+ { id: 'video', label: $localize`Video`, sortable: false },+ { id: 'comment', label: $localize`Comment`, sortable: false },+ { id: 'autoTags', label: $localize`Auto tags`, sortable: false },+ { id: 'createdAt', label: $localize`Date`, sortable: true }+ ]++ dataLoader: typeof this._dataLoader++ constructor () {+ this.dataLoader = this._dataLoader.bind(this)+ }+get authUser () {return this.auth.getUser()}async ngOnInit () {- this.initialize()-if (this.mode() === 'admin') {- this.pluginService.addAction('admin-video-comment-list:load-data', () => this.reloadDataInternal())+ this.pluginService.addAction('admin-video-comment-list:load-data', () => this.table().loadData())}this.buildInputFilters()@@ -175,10 +182,6 @@ export class VideoCommentListAdminOwnerComponent extends RestTable<VideoCommentF]}- getIdentifier () {- return 'VideoCommentListAdminOwnerComponent'- }-toHtml (text: string) {return this.markdownRenderer.textMarkdownToHTML({ markdown: text, withHtml: true, withEmoji: true })}@@ -186,31 +189,32 @@ export class VideoCommentListAdminOwnerComponent extends RestTable<VideoCommentFbuildSearchAutoTag (tag: string) {const str = `autoTag:"${tag}"`- if (this.search) return this.search + ' ' + str+ const search = this.route.snapshot.queryParams.search+ if (search) return search + ' ' + strreturn str}- protected async reloadDataInternal () {+ private _dataLoader (options: DataLoaderOptions) {const method = this.mode() === 'admin'? this.videoCommentService.listAdminVideoComments.bind(this.videoCommentService): this.videoCommentService.listVideoCommentsOfMyVideos.bind(this.videoCommentService)- const obs = method({ pagination: this.pagination, sort: this.sort, search: this.search })+ return method(options)+ .pipe(+ switchMap(async result => {+ const comments: VideoCommentForAdminOrUser[] = []- try {- const resultList = await lastValueFrom(obs)-- this.totalRecords = resultList.total-- this.comments = []+ for (const c of result.data) {+ comments.push(new VideoCommentForAdminOrUser(c, await this.toHtml(c.text)))+ }- for (const c of resultList.data) {- this.comments.push(new VideoCommentForAdminOrUser(c, await this.toHtml(c.text)))- }- } catch (err) {- this.notifier.error(err.message)- }+ return {+ total: result.total,+ data: comments+ }+ })+ )}private approveComments (comments: VideoCommentForAdminOrUser[]) {@@ -226,12 +230,10 @@ export class VideoCommentListAdminOwnerComponent extends RestTable<VideoCommentF))- this.reloadData()+ this.table().loadData()},- error: err => this.notifier.error(err.message),-- complete: () => this.selectedRows = []+ error: err => this.notifier.error(err.message)})}@@ -248,19 +250,17 @@ export class VideoCommentListAdminOwnerComponent extends RestTable<VideoCommentF))- this.reloadData()+ this.table().loadData()},- error: err => this.notifier.error(err.message),-- complete: () => this.selectedRows = []+ error: err => this.notifier.error(err.message)})}private removeComment (comment: VideoCommentForAdminOrUser) {this.videoCommentService.deleteVideoComment(comment.video.id, comment.id).subscribe({- next: () => this.reloadData(),+ next: () => this.table().loadData(),error: err => this.notifier.error(err.message)})diff --git a/client/src/app/shared/shared-video-miniature/videos-selection.component.ts b/client/src/app/shared/shared-video-miniature/videos-selection.component.tsindex 2593d161bc..d864d1add0 100644--- a/client/src/app/shared/shared-video-miniature/videos-selection.component.ts+++ b/client/src/app/shared/shared-video-miniature/videos-selection.component.ts@@ -63,8 +63,6 @@ export class VideosSelectionComponent implements AfterContentInit {const t = this.templates().find(t => t.name() === 'globalButtons')if (t) this.globalButtonsTemplate = t.template}-- this.loadMoreVideos()}getVideosObservable (page: number) {diff --git a/client/src/app/shared/standalone-watched-words/watched-words-list-admin-owner.component.html b/client/src/app/shared/standalone-watched-words/watched-words-list-admin-owner.component.htmlindex f26421bf01..44f407d48b 100644--- a/client/src/app/shared/standalone-watched-words/watched-words-list-admin-owner.component.html+++ b/client/src/app/shared/standalone-watched-words/watched-words-list-admin-owner.component.html@@ -1,86 +1,56 @@-<p-table- [value]="lists" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"- [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id"- [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" [selectionPageOnly]="false"- [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"- [expandedRowKeys]="expandedRows"+<my-table+ #table+ key="WatchedWordsListAdminOwnerComponent"+ [defaultColumns]="columns"+ defaultSort="updatedAt"+ i18n-paginatorText+ paginatorText="lists per page"+ [dataLoader]="dataLoader"+ columnConfig="false">- <ng-template #caption>- <div class="caption">- <div class="left-buttons">- <button type="button" *ngIf="!isInSelectionMode()" class="peertube-create-button" (click)="openCreateOrUpdateList()">- <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>- <ng-container i18n>Create a new list</ng-container>- </button>- </div>-- <div class="ms-auto right-form">- <my-button i18n-label label="Refresh" icon="refresh" (click)="reloadData()"></my-button>- </div>- </div>- </ng-template>-- <ng-template #header>- <tr>- <th scope="col" style="width: 40px;">- <span i18n class="visually-hidden">More information</span>- </th>- <th scope="col" style="width: 150px;">- <span i18n class="visually-hidden">Actions</span>- </th>- <th scope="col" style="width: 300px;" i18n>List name</th>- <th scope="col" style="width: 300px;" i18n>Words</th>- <th scope="col" style="width: 170px;" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="updatedAt">Date <p-sortIcon field="updatedAt"></p-sortIcon></th>- </tr>+ <ng-template #totalTitle let-totalRecords>+ <ng-container i18n>{ totalRecords, plural, =0 {No list} =1 {1 list} other {{{ totalRecords | myNumberFormatter }} lists}}</ng-container></ng-template>- <ng-template #body let-list let-expanded="expanded">- <tr>+ <ng-template #captionRight>+ <my-button i18n-label label="Refresh" icon="refresh" (click)="table.loadData()"></my-button>- <td class="expand-cell">- <my-table-expander-icon [pRowToggler]="list" i18n-tooltip tooltip="See all words" [expanded]="expanded"></my-table-expander-icon>- </td>+ <button type="button" class="peertube-create-button" (click)="openCreateOrUpdateList()">+ <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>+ <ng-container i18n>Create a new list</ng-container>+ </button>+ </ng-template>- <td class="action-cell">- <my-action-dropdown- [ngClass]="{ 'show': expanded }" placement="bottom-right" container="body"- i18n-label label="Actions" [actions]="actions" [entry]="list" buttonSize="small"- ></my-action-dropdown>- </td>+ <ng-template #tableCells let-list>+ <td>+ {{ list.listName }}+ </td>- <td>- {{ list.listName }}- </td>+ <td i18n>+ {{ list.words.length }} words+ </td>- <td i18n>- {{ list.words.length }} words- </td>+ <td>{{ list.updatedAt | ptDate: 'short' }}</td>+ </ng-template>- <td>{{ list.updatedAt | ptDate: 'short' }}</td>- </tr>+ <ng-template #actionCell let-list>+ <my-action-dropdown+ placement="bottom-right" container="body"+ i18n-label label="Actions" [actions]="actions" [entry]="list"+ ></my-action-dropdown></ng-template>- <ng-template #expandedrow let-list>- <tr>- <td class="expand-cell" myAutoColspan>- <ul>- @for (word of list.words; track word) {- <li>{{ word }}</li>- }- </ul>- </td>- </tr>+ <ng-template #expandedRow let-list>+ <ul>+ @for (word of list.words; track word) {+ <li>{{ word }}</li>+ }+ </ul></ng-template>- <ng-template #emptymessage>- <tr>- <td myAutoColspan>- <div class="no-results">- <ng-container i18n>No watched word lists found.</ng-container>- </div>- </td>- </tr>+ <ng-template #noResults>+ <ng-container i18n>No watched word lists found.</ng-container></ng-template>-</p-table>+</my-table>-<my-watched-words-list-save-modal #saveModal [accountName]="accountNameParam" (listAddedOrUpdated)="reloadData()"></my-watched-words-list-save-modal>+<my-watched-words-list-save-modal #saveModal [accountName]="getAccountNameParam()" (listAddedOrUpdated)="onListAddedOrUpdated()"></my-watched-words-list-save-modal>diff --git a/client/src/app/shared/standalone-watched-words/watched-words-list-admin-owner.component.ts b/client/src/app/shared/standalone-watched-words/watched-words-list-admin-owner.component.tsindex bf85140899..473bb01c64 100644--- a/client/src/app/shared/standalone-watched-words/watched-words-list-admin-owner.component.ts+++ b/client/src/app/shared/standalone-watched-words/watched-words-list-admin-owner.component.ts@@ -1,18 +1,15 @@-import { NgClass, NgIf } from '@angular/common'-import { Component, OnInit, inject, input, viewChild } from '@angular/core'+import { Component, inject, input, viewChild } from '@angular/core'import { ActivatedRoute, Router } from '@angular/router'-import { AuthService, ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'+import { AuthService, ConfirmService, Notifier, RestPagination } from '@app/core'import { UserRight, WatchedWordsList } from '@peertube/peertube-models'-import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'-import { first } from 'rxjs'+import { SortMeta } from 'primeng/api'+import { first, switchMap } from 'rxjs'import { GlobalIconComponent } from '../shared-icons/global-icon.component'import { ActionDropdownComponent, DropdownAction } from '../shared-main/buttons/action-dropdown.component'import { ButtonComponent } from '../shared-main/buttons/button.component'-import { AutoColspanDirective } from '../shared-main/common/auto-colspan.directive'import { PTDatePipe } from '../shared-main/common/date.pipe'-import { TableExpanderIconComponent } from '../shared-tables/table-expander-icon.component'+import { NumberFormatterPipe } from '../shared-main/common/number-formatter.pipe'+import { TableColumnInfo, TableComponent } from '../shared-tables/table.component'import { WatchedWordsListSaveModalComponent } from './watched-words-list-save-modal.component'import { WatchedWordsListService } from './watched-words-list.service'@@ -21,20 +18,15 @@ import { WatchedWordsListService } from './watched-words-list.service'templateUrl: './watched-words-list-admin-owner.component.html',imports: [GlobalIconComponent,- TableModule,- SharedModule,- NgIf,ActionDropdownComponent,ButtonComponent,- TableExpanderIconComponent,- NgClass,- AutoColspanDirective,PTDatePipe,- NgbTooltip,- WatchedWordsListSaveModalComponent+ WatchedWordsListSaveModalComponent,+ NumberFormatterPipe,+ TableComponent]})-export class WatchedWordsListAdminOwnerComponent extends RestTable<WatchedWordsList> implements OnInit {+export class WatchedWordsListAdminOwnerComponent {protected router = inject(Router)protected route = inject(ActivatedRoute)private auth = inject(AuthService)@@ -45,28 +37,37 @@ export class WatchedWordsListAdminOwnerComponent extends RestTable<WatchedWordsLreadonly mode = input.required<'user' | 'admin'>()readonly saveModal = viewChild<WatchedWordsListSaveModalComponent>('saveModal')-- lists: WatchedWordsList[]- totalRecords = 0- sort: SortMeta = { field: 'createdAt', order: -1 }- pagination: RestPagination = { count: this.rowsPerPage, start: 0 }+ readonly table = viewChild<TableComponent<WatchedWordsList>>('table')actions: DropdownAction<WatchedWordsList>[][] = []- get authUser () {- return this.auth.getUser()- }-- get accountNameParam () {- if (this.mode() === 'admin') return undefined+ columns: TableColumnInfo<string>[] = [+ {+ id: 'listName',+ label: $localize`List name`,+ selected: true,+ sortable: true+ },+ {+ id: 'words',+ label: $localize`Words`,+ selected: true,+ sortable: false+ },+ {+ id: 'updatedAt',+ label: $localize`Date`,+ selected: true,+ sortable: true+ }+ ]- return this.authUser.account.name- }+ dataLoader: typeof this._dataLoaderconstructor () {- super()+ this.dataLoader = this._dataLoader.bind(this)- const isDisplayed = () => this.mode() === 'user' || this.authUser.hasRight(UserRight.MANAGE_INSTANCE_WATCHED_WORDS)+ const isDisplayed = () => this.mode() === 'user' || this.auth.getUser().hasRight(UserRight.MANAGE_INSTANCE_WATCHED_WORDS)this.actions = [[@@ -88,32 +89,31 @@ export class WatchedWordsListAdminOwnerComponent extends RestTable<WatchedWordsL]}- ngOnInit () {- this.initialize()-- this.auth.userInformationLoaded- .pipe(first())- .subscribe(() => this.reloadData())+ openCreateOrUpdateList (list?: WatchedWordsList) {+ this.saveModal().show(list)}- getIdentifier () {- return 'WatchedWordsListAdminOwnerComponent'+ onListAddedOrUpdated () {+ this.table().reloadData({ field: 'updatedAt', order: -1 })}- openCreateOrUpdateList (list?: WatchedWordsList) {- this.saveModal().show(list)- }+ getAccountNameParam () {+ if (this.mode() === 'admin') return undefined- protected reloadDataInternal () {- this.watchedWordsListService.list({ pagination: this.pagination, sort: this.sort, accountName: this.accountNameParam })- .subscribe({- next: resultList => {- this.totalRecords = resultList.total- this.lists = resultList.data- },+ return this.auth.getUser().account.name+ }- error: err => this.notifier.error(err.message)- })+ private _dataLoader (options: {+ pagination: RestPagination+ sort: SortMeta+ }) {+ const { pagination, sort } = options++ return this.auth.userInformationLoaded+ .pipe(+ first(),+ switchMap(() => this.watchedWordsListService.list({ pagination, sort, accountName: this.getAccountNameParam() }))+ )}private async removeList (list: WatchedWordsList) {@@ -123,12 +123,12 @@ export class WatchedWordsListAdminOwnerComponent extends RestTable<WatchedWordsLthis.watchedWordsListService.deleteList({listId: list.id,- accountName: this.accountNameParam+ accountName: this.getAccountNameParam()}).subscribe({next: () => {this.notifier.success($localize`${list.listName} removed`)- this.reloadData()+ this.table().loadData()},error: err => this.notifier.error(err.message)diff --git a/client/src/root-helpers/bytes.ts b/client/src/root-helpers/bytes.tsindex f2638dd5b7..a1823aa53a 100644--- a/client/src/root-helpers/bytes.ts+++ b/client/src/root-helpers/bytes.ts@@ -6,7 +6,7 @@ const dictionary: { max: number, type: string }[] = [{ max: 1.125899906842624e15, type: 'TB' }]-function getBytes (value: number, precision?: number): string | number {+export function getBytes (value: number, precision?: number) {const format = dictionary.find(d => value < d.max) || dictionary[dictionary.length - 1]const calc = value / (format.max / 1024)@@ -17,6 +17,10 @@ function getBytes (value: number, precision?: number): string | number {return `${num} ${format.type}`}+// ---------------------------------------------------------------------------+// Private+// ---------------------------------------------------------------------------+function applyPrecision (num: number, precision: number) {if (precision <= 0) {return Math.round(num)@@ -26,7 +30,3 @@ function applyPrecision (num: number, precision: number) {return Math.round(num * tho) / tho}--export {- getBytes-}diff --git a/client/src/sass/class-helpers/_layout.scss b/client/src/sass/class-helpers/_layout.scssindex 3bba6b6d1b..6e83576805 100644--- a/client/src/sass/class-helpers/_layout.scss+++ b/client/src/sass/class-helpers/_layout.scss@@ -1,6 +1,6 @@-@use 'sass:color';-@use '_variables' as *;-@use '_mixins' as *;+@use "sass:color";+@use "_variables" as *;+@use "_mixins" as *;.pt-two-cols {@include make-row();@@ -48,6 +48,10 @@min-width: 0;}+.max-width-300px {+ max-width: 300px;+}+.d-none-mw {@include on-mobile-main-col {display: none !important;diff --git a/client/src/sass/class-helpers/_text.scss b/client/src/sass/class-helpers/_text.scssindex 9636f1db56..014511afd4 100644--- a/client/src/sass/class-helpers/_text.scss+++ b/client/src/sass/class-helpers/_text.scss@@ -1,8 +1,8 @@-@use 'sass:color';-@use '_badges' as *;-@use '_icons' as *;-@use '_variables' as *;-@use '_mixins' as *;+@use "sass:color";+@use "_badges" as *;+@use "_icons" as *;+@use "_variables" as *;+@use "_mixins" as *;.red {color: pvar(--red);@@ -13,56 +13,58 @@}.text-fg {- color: pvar(--fg)+ color: pvar(--fg);}.fg-100 {- color: pvar(--fg-100)+ color: pvar(--fg-100);}// ---------------------------------------------------------------------------.fg-100 {- color: pvar(--fg-100)+ color: pvar(--fg-100);}.fg-150 {- color: pvar(--fg-150)+ color: pvar(--fg-150);}.fg-200 {- color: pvar(--fg-200)+ color: pvar(--fg-200);}.fg-250 {- color: pvar(--fg-250)+ color: pvar(--fg-250);}.fg-300 {- color: pvar(--fg-300)+ color: pvar(--fg-300);}.fg-350 {- color: pvar(--fg-350)+ color: pvar(--fg-350);}.fg-400 {- color: pvar(--fg-400)+ color: pvar(--fg-400);}.fg-450 {- color: pvar(--fg-450)+ color: pvar(--fg-450);}.fg-500 {- color: pvar(--fg-500)+ color: pvar(--fg-500);}// ---------------------------------------------------------------------------.total-items {color: pvar(--fg-300);- font-weight: $font-semibold;+ font-weight: $font-bold;++ @include font-size(22px);}.link-primary {@@ -82,7 +84,7 @@.border-highlight {&::after {- content: '';+ content: "";display: block;height: 4px;background-color: pvar(--border-primary);diff --git a/client/src/sass/primeng.scss b/client/src/sass/primeng.scssindex c66424112e..7d9e79e166 100644--- a/client/src/sass/primeng.scss+++ b/client/src/sass/primeng.scss@@ -130,16 +130,55 @@ p-toast {// ---------------------------------------------------------------------------p-table {+ --action-cell-padding-right: 0.25em;++ margin-bottom: 0.5rem;+ display: block;++ &.loading table {+ opacity: 0.5;+ }+table {- table-layout: fixed;+ table-layout: auto;}th {+ font-size: 14px;+ padding: 5px 0.25rem 5px 1rem !important;++ .column-toggle {+ .dropdown > my-button::after {+ display: none;+ }+ }+@include ellipsis;}+ .column-toggle .tertiary-button:not(.active) {+ color: pvar(--fg-300) !important;+ }++ td,+ th {+ // It's like min-height in tables+ min-height: 46px;+ }++ .p-sortable-column-icon {+ display: inline-block;+ position: relative;+ top: -1px;+ vertical-align: middle;++ .tertiary-button:not(.active) {+ color: pvar(--secondary-icon-color) !important;+ }+ }+.p-datatable-table-container {- overflow-x: auto;+ overflow: auto;max-width: 100%;table {@@ -148,6 +187,8 @@ p-table {}.p-datatable-header {+ border: 0;+.caption {min-height: 40px;width: 100%;@@ -161,6 +202,12 @@ p-table {@include font-size(22px);}++ .right-block {+ display: flex;+ flex-wrap: wrap;+ gap: 1rem;+ }}}@@ -183,20 +230,11 @@ p-table {}.action-cell {- width: 250px !important;-- .dropdown-root,- my-edit-button,- my-delete-button,- my-button {- display: inline-block !important;- max-width: 100%;+ @include padding-right(var(--action-cell-padding-right));- @include margin-left(5px);-- &:first-child {- @include margin-left(0);- }+ // Align with "actions" head title+ &.has-action.has-column-config {+ @include padding-right(calc(42px + var(--action-cell-padding-right)));}}@@ -206,8 +244,9 @@ p-table {p-paginator {.p-paginator {+ padding-top: 1rem;+border-top: 1px solid pvar(--bg-secondary-400) !important;- height: 40px;display: flex;justify-content: center;align-items: center;@@ -224,6 +263,16 @@ p-table {.p-iconwrapper {color: pvar(--fg-300);}++ .p-paginator-page-selected {+ font-weight: $font-bold !important;+ }++ .p-paginator-content-end {+ color: pvar(--fg-300);++ @include margin-left(0);+ }}@media screen and (max-width: $small-view) {@@ -261,86 +310,18 @@ p-table {}}-p-table:not(.cell-wrap) {- td:not(.action-cell):not(.expand-cell):not(.checkbox-cell) {- @include ellipsis;- }-}-p-tablecheckbox:hover div .p-checkbox-box {box-shadow: 0 0 0 0.1rem rgba(87, 85, 217, 0.2);}-.new-p-table {- margin-bottom: 0.5rem;- display: block;-- &.loading table {- opacity: 0.5;- }-- .column-toggle .tertiary-button:not(.active) {- color: pvar(--fg-300) !important;- }-- th {- font-size: 14px;- padding: 5px 0.25rem 5px 1rem !important;-- .column-toggle {- .dropdown > my-button::after {- display: none;- }- }- }-- .p-sortable-column-icon {- display: inline-block;- position: relative;- top: -1px;- vertical-align: middle;-- .tertiary-button:not(.active) {- color: pvar(--secondary-icon-color) !important;- }- }-- p-paginator {- .p-paginator {- padding-top: 1.5rem;- margin-top: 0.75rem;- height: auto !important;-- .p-paginator-page-selected {- font-weight: $font-bold !important;- }- }- }-- .p-paginator-content-end {- color: pvar(--fg-300);-- @include margin-left(0);- }-- .action-cell {- width: 0 !important;-- @include padding-right(0.25rem);- }-}--.sticky-p-table {- table {- table-layout: auto;- }-+.sticky-table {@media screen and (min-width: $small-view) {.action-cell,.action-head {position: sticky;right: 0;- padding-right: 0.5rem;++ @include padding-right(0.5rem !important);}.action-cell {@@ -348,19 +329,4 @@ p-tablecheckbox:hover div .p-checkbox-box {background-color: inherit;}}-- thead th {- position: sticky;- top: 0;- z-index: 20;- }-- .p-datatable,- .p-datatable-table-container {- max-height: inherit;- }-- .p-datatable-table-container {- overflow: auto;- }}diff --git a/config/dev.yaml b/config/dev.yamlindex 52bfb2d48b..a75bf6860a 100644--- a/config/dev.yaml+++ b/config/dev.yaml@@ -119,6 +119,8 @@ plugins:check_latest_versions_interval: '10 minutes'federation:+ # We use internal IP address in PeerTube tests+ prevent_ssrf: falsevideos:cleanup_remote_interactions: false