Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Build a new table filter component

Chocobozzzdad36c2e28cd
diff --git a/client/src/app/+about/about-follows/about-follows.component.ts b/client/src/app/+about/about-follows/about-follows.component.ts
index 91c0119675..36fa0f5595 100644
--- a/client/src/app/+about/about-follows/about-follows.component.ts
+++ b/client/src/app/+about/about-follows/about-follows.component.ts
@@ -90,7 +90,7 @@ export class AboutFollowsComponent implements OnInit {
const pagination = this.restService.componentToRestPagination(this.followersPagination)
- this.followService.getFollowers({ pagination, sort: this.sort, state: 'accepted' })
+ this.followService.listFollowers({ pagination, sort: this.sort, state: 'accepted' })
.subscribe({
next: resultList => {
if (reset) this.followers = []
@@ -116,7 +116,7 @@ export class AboutFollowsComponent implements OnInit {
const pagination = this.restService.componentToRestPagination(this.subscriptionsPagination)
- this.followService.getFollowing({ pagination, sort: this.sort, state: 'accepted' })
+ this.followService.listSubscriptions({ pagination, sort: this.sort, state: 'accepted' })
.subscribe({
next: resultList => {
if (reset) this.subscriptions = []
diff --git a/client/src/app/+admin/admin-overview.component.ts b/client/src/app/+admin/admin-overview.component.ts
index 7932ac5a38..54d355fc05 100644
--- a/client/src/app/+admin/admin-overview.component.ts
+++ b/client/src/app/+admin/admin-overview.component.ts
@@ -31,10 +31,7 @@ export class AdminOverviewComponent implements OnInit {
if (this.hasRight(UserRight.SEE_ALL_VIDEOS)) {
this.menuEntries.push({
label: $localize`Videos`,
- routerLink: '/admin/overview/videos',
- queryParams: {
- search: 'isLocal:true'
- }
+ routerLink: '/admin/overview/videos'
})
}
diff --git a/client/src/app/+admin/config/pages/admin-config-common.scss b/client/src/app/+admin/config/pages/admin-config-common.scss
index 99d9e7d47c..a4f3a99f36 100644
--- a/client/src/app/+admin/config/pages/admin-config-common.scss
+++ b/client/src/app/+admin/config/pages/admin-config-common.scss
@@ -28,10 +28,6 @@ input[type="number"] {
@include peertube-input-text($form-base-input-width);
}
-input[type="checkbox"] {
- @include peertube-checkbox;
-}
-
.peertube-select-container {
@include responsive-width($form-base-input-width);
}
diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.html b/client/src/app/+admin/follows/followers-list/followers-list.component.html
index 2beec853d7..3bf1a2b93d 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
@@ -7,15 +7,14 @@
[dataLoader]="dataLoader"
columnConfig="false"
[bulkActions]="bulkActions"
+ refreshButton="true"
+ searchInput="true"
+ [inputFilters]="inputFilters"
>
<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 #captionRight>
- <my-advanced-input-filter [filters]="searchFilters" (search)="table.onSearch($event)"></my-advanced-input-filter>
- </ng-template>
-
<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">
@@ -51,8 +50,8 @@
}
</ng-template>
- <ng-template #noResults let-search>
- @if (search) {
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ @if (search || hasFilters) {
<ng-container i18n>No follower found matching current filters.</ng-container>
} @else {
<ng-container i18n>Your instance doesn't have any follower.</ng-container>
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.ts
index 0f784bbb60..e49b3066ff 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
@@ -3,22 +3,23 @@ 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 { DataLoaderOptions, TableColumnInfo, TableComponent } from '@app/shared/shared-tables/table.component'
-import { ActorFollow } from '@peertube/peertube-models'
-import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '@app/shared/shared-tables/table.component'
+import { ActorFollow, FollowState } from '@peertube/peertube-models'
+import { AdvancedFilterDef } from '../../../shared/shared-forms/advanced-input-filter.component'
import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.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 { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'
+type DataLoaderParameter = Parameters<FollowersListComponent['_dataLoader']>[0]
+
@Component({
selector: 'my-followers-list',
templateUrl: './followers-list.component.html',
styleUrls: [ './followers-list.component.scss' ],
imports: [
GlobalIconComponent,
- AdvancedInputFilterComponent,
ButtonComponent,
DeleteButtonComponent,
PTDatePipe,
@@ -31,9 +32,9 @@ export class FollowersListComponent implements OnInit {
private notifier = inject(Notifier)
private followService = inject(InstanceFollowService)
- readonly table = viewChild<TableComponent<ActorFollow>>('table')
+ readonly table = viewChild<TableComponent<ActorFollow, DataLoaderParameter>>('table')
- searchFilters: AdvancedInputFilter[] = []
+ inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = []
bulkActions: DropdownAction<ActorFollow[]>[] = []
@@ -51,7 +52,7 @@ export class FollowersListComponent implements OnInit {
}
ngOnInit () {
- this.searchFilters = this.followService.buildFollowsListFilters()
+ this.inputFilters = this.followService.buildFollowsListFilters()
this.bulkActions = [
{
@@ -149,9 +150,7 @@ export class FollowersListComponent implements OnInit {
return follow.follower.name + '@' + follow.follower.host
}
- private _dataLoader (options: DataLoaderOptions) {
- const { pagination, sort, search } = options
-
- return this.followService.getFollowers({ pagination, sort, search })
+ private _dataLoader (options: DataLoaderOptionsBase & { state: FollowState }) {
+ return this.followService.listFollowers(options)
}
}
diff --git a/client/src/app/+admin/follows/following-list/following-list.component.html b/client/src/app/+admin/follows/following-list/following-list.component.html
index b44b846c9a..716aad6cbb 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
@@ -7,16 +7,15 @@
[dataLoader]="dataLoader"
columnConfig="false"
[bulkActions]="bulkActions"
+ refreshButton="true"
+ searchInput="true"
+ [inputFilters]="inputFilters"
>
<ng-template #totalTitle let-totalRecords>
<ng-container i18n>{ totalRecords, plural, =0 {No subscription} =1 {1 subscription} other {{{ totalRecords | myNumberFormatter }} subscriptions}}</ng-container>
</ng-template>
<ng-template #captionRight>
- <my-advanced-input-filter [filters]="searchFilters" (search)="table.onSearch($event)"></my-advanced-input-filter>
-
- <my-button i18n-label label="Refresh" icon="refresh" (click)="table.loadData()"></my-button>
-
<button class="peertube-create-button" (click)="openFollowModal()">
<my-global-icon iconName="following" aria-hidden="true"></my-global-icon>
<ng-container i18n>Follow</ng-container>
@@ -58,8 +57,8 @@
<my-delete-button label (click)="removeFollowing([ follow ])"></my-delete-button>
</ng-template>
- <ng-template #noResults let-search>
- @if (search) {
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ @if (search || hasFilters) {
<ng-container i18n>No host found matching current filters.</ng-container>
} @else {
<ng-container i18n>Your instance is not following anyone.</ng-container>
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.ts
index d2550b9d64..9ce7799d78 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
@@ -3,28 +3,27 @@ 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 { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'
+import { ActorFollow, FollowState } from '@peertube/peertube-models'
+import { AdvancedFilterDef } from '../../../shared/shared-forms/advanced-input-filter.component'
import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.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 { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'
-import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'
import { RedundancyCheckboxComponent } from '../shared/redundancy-checkbox.component'
import { FollowModalComponent } from './follow-modal.component'
+type DataLoaderParameter = Parameters<FollowingListComponent['_dataLoader']>[0]
+
@Component({
templateUrl: './following-list.component.html',
styleUrls: [ './following-list.component.scss' ],
imports: [
GlobalIconComponent,
- AdvancedInputFilterComponent,
DeleteButtonComponent,
RedundancyCheckboxComponent,
FollowModalComponent,
PTDatePipe,
- ButtonComponent,
TableComponent,
NumberFormatterPipe
]
@@ -35,9 +34,9 @@ export class FollowingListComponent implements OnInit {
private followService = inject(InstanceFollowService)
readonly followModal = viewChild<FollowModalComponent>('followModal')
- readonly table = viewChild<TableComponent<ActorFollow>>('table')
+ readonly table = viewChild<TableComponent<ActorFollow, DataLoaderParameter>>('table')
- searchFilters: AdvancedInputFilter[] = []
+ inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = []
bulkActions: DropdownAction<ActorFollow[]>[] = []
@@ -55,7 +54,7 @@ export class FollowingListComponent implements OnInit {
}
ngOnInit () {
- this.searchFilters = this.followService.buildFollowsListFilters()
+ this.inputFilters = this.followService.buildFollowsListFilters()
this.bulkActions = [
{
@@ -104,9 +103,7 @@ export class FollowingListComponent implements OnInit {
})
}
- private _dataLoader (options: DataLoaderOptions) {
- const { pagination, sort, search } = options
-
- return this.followService.getFollowing({ pagination, sort, search })
+ private _dataLoader (options: DataLoaderOptionsBase & { state?: FollowState }) {
+ return this.followService.listSubscriptions(options)
}
}
diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts
index be80f8f235..931f4d8fba 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
@@ -11,7 +11,7 @@ import { tap } from 'rxjs'
import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
import { DeleteButtonComponent } from '../../../shared/shared-main/buttons/delete-button.component'
import { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'
-import { DataLoaderOptions, TableColumnInfo, TableComponent, TableQueryParams } from '../../../shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent, TableQueryParams } from '../../../shared/shared-tables/table.component'
import { VideoRedundancyInformationComponent } from './video-redundancy-information.component'
type QueryParams = TableQueryParams & {
@@ -183,7 +183,7 @@ export class VideoRedundanciesListComponent implements OnInit {
})
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: DataLoaderOptionsBase) {
return this.redundancyService.listVideoRedundancies({ ...options, target: this.displayType })
.pipe(tap(() => this.dataLoaded = true))
}
diff --git a/client/src/app/+admin/moderation/registration-list/registration-list.component.html b/client/src/app/+admin/moderation/registration-list/registration-list.component.html
index 2e794f3363..4c55040419 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
@@ -7,15 +7,12 @@
[dataLoader]="dataLoader"
columnConfig="true"
[bulkActions]="bulkActions"
+ searchInput="true"
>
<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 #captionRight>
- <my-advanced-input-filter (search)="table.onSearch($event)"></my-advanced-input-filter>
- </ng-template>
-
<ng-template #tableCells let-registration>
@if (table.isColumnDisplayed('account')) {
<td>
@@ -101,8 +98,8 @@
</div>
</ng-template>
- <ng-template #noResults let-search>
- @if (search) {
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ @if (search || hasFilters) {
<ng-container i18n>No registrations found matching current filters.</ng-container>
} @else {
<ng-container i18n>No registrations found.</ng-container>
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.ts
index 7a7b01ac0c..b876af733e 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
@@ -6,11 +6,10 @@ import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
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 { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'
-import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, 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'
@@ -25,7 +24,6 @@ type ColumnName = 'account' | 'email' | 'channel' | 'registrationReason' | 'stat
imports: [
GlobalIconComponent,
ActionDropdownComponent,
- AdvancedInputFilterComponent,
NgbTooltip,
UserEmailInfoComponent,
ProcessRegistrationModalComponent,
@@ -44,13 +42,11 @@ export class RegistrationListComponent implements OnInit {
private adminRegistrationService = inject(AdminRegistrationService)
readonly processRegistrationModal = viewChild<ProcessRegistrationModalComponent>('processRegistrationModal')
- readonly table = viewChild<TableComponent<UserRegistration, ColumnName>>('table')
+ readonly table = viewChild<TableComponent<UserRegistration, DataLoaderOptionsBase, ColumnName>>('table')
registrationActions: DropdownAction<UserRegistration>[][] = []
bulkActions: DropdownAction<UserRegistration[]>[] = []
- inputFilters: AdvancedInputFilter[] = []
-
requiresEmailVerification: boolean
columns: TableColumnInfo<ColumnName>[] = [
@@ -115,7 +111,7 @@ export class RegistrationListComponent implements OnInit {
this.table().reloadData({ field: 'createdAt', order: -1 })
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: DataLoaderOptionsBase) {
return this.adminRegistrationService.listRegistrations(options)
.pipe(
switchMap(async (resultList: ResultList<UserRegistration>) => {
diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html
index 1ba9e9a294..ce103e9c99 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
@@ -6,15 +6,13 @@
paginatorText="videos per page"
[dataLoader]="dataLoader"
columnConfig="false"
+ [inputFilters]="inputFilters"
+ searchInput="true"
>
<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 #captionRight>
- <my-advanced-input-filter [filters]="inputFilters" (search)="table.onSearch($event)"></my-advanced-input-filter>
- </ng-template>
-
<ng-template #tableCells let-videoBlock>
<td>
<my-video-cell [video]="videoBlock.video" size="small">
@@ -62,8 +60,8 @@
}
</ng-template>
- <ng-template #noResults let-search>
- @if (search) {
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ @if (search || hasFilters) {
<ng-container i18n>No blocked video found matching current filters.</ng-container>
} @else {
<ng-container i18n>No blocked video found.</ng-container>
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.ts
index 6935f50361..2e6051e8a0 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
@@ -8,14 +8,15 @@ import { ResultList, VideoBlacklist as VideoBlacklistServer, VideoBlacklistType,
import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
import { switchMap } from 'rxjs/operators'
import { environment } from 'src/environments/environment'
-import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'
+import { AdvancedFilterDef } from '../../../shared/shared-forms/advanced-input-filter.component'
import { ActionDropdownComponent, DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'
import { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'
import { EmbedComponent } from '../../../shared/shared-main/video/embed.component'
-import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, 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 DataLoaderParameter = Parameters<VideoBlockListComponent['_dataLoader']>[0]
type VideoBlacklist = VideoBlacklistServer & { reasonHtml?: string }
@Component({
@@ -23,7 +24,6 @@ type VideoBlacklist = VideoBlacklistServer & { reasonHtml?: string }
templateUrl: './video-block-list.component.html',
styleUrls: [ '../../../shared/shared-moderation/moderation.scss' ],
imports: [
- AdvancedInputFilterComponent,
ActionDropdownComponent,
VideoCellComponent,
EmbedComponent,
@@ -41,24 +41,21 @@ export class VideoBlockListComponent implements OnInit {
private markdownRenderer = inject(MarkdownService)
private videoService = inject(VideoService)
- readonly table = viewChild<TableComponent<VideoBlacklist>>('table')
+ readonly table = viewChild<TableComponent<VideoBlacklist, DataLoaderParameter>>('table')
blocklistTypeFilter: VideoBlacklistType_Type
videoBlocklistActions: DropdownAction<VideoBlacklist>[][] = []
- inputFilters: AdvancedInputFilter[] = [
+ inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = [
{
- title: $localize`Advanced filters`,
- children: [
- {
- value: 'type:auto',
- label: $localize`Automatic blocks`
- },
- {
- value: 'type:manual',
- label: $localize`Manual blocks`
- }
+ type: 'options',
+ key: 'type',
+ title: $localize`Block type`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: VideoBlacklistType['AUTO_BEFORE_PUBLISHED'], label: $localize`Automatic blocks` },
+ { value: VideoBlacklistType['MANUAL'], label: $localize`Manual blocks` }
]
}
]
@@ -176,7 +173,7 @@ export class VideoBlockListComponent implements OnInit {
})
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: DataLoaderOptionsBase & { type?: VideoBlacklistType_Type }) {
return this.videoBlocklistService.listBlocks(options)
.pipe(
switchMap(async (resultList: ResultList<VideoBlacklist>) => {
diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.html b/client/src/app/+admin/overview/users/user-list/user-list.component.html
index def9eb0ae9..2fd0880e18 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
@@ -10,14 +10,14 @@
[dataLoader]="dataLoader"
columnConfig="true"
[hasExpandedRow]="hasExpandedRow"
+ [inputFilters]="inputFilters"
+ searchInput="true"
>
<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 #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>
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.ts
index 0bbe4c6597..9dbcf7d6a9 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
@@ -14,7 +14,7 @@ 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 { AdvancedFilterDef } from '../../../../shared/shared-forms/advanced-input-filter.component'
import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'
import { DropdownAction } from '../../../../shared/shared-main/buttons/action-dropdown.component'
import { BytesPipe } from '../../../../shared/shared-main/common/bytes.pipe'
@@ -24,9 +24,10 @@ import {
UserModerationDisplayType,
UserModerationDropdownComponent
} from '../../../../shared/shared-moderation/user-moderation-dropdown.component'
-import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'
import { UserEmailInfoComponent } from '../../../shared/user-email-info.component'
+type DataLoaderParameter = Parameters<UserListComponent['_dataLoader']>[0]
type User = UserAdmin & { accountMutedStatus: AccountMutedStatus }
type ColumnName =
@@ -49,7 +50,6 @@ type ColumnName =
GlobalIconComponent,
CommonModule,
RouterLink,
- AdvancedInputFilterComponent,
FormsModule,
NgbTooltip,
NgClass,
@@ -75,18 +75,19 @@ export class UserListComponent implements OnInit, OnDestroy {
private userService = inject(UserService)
readonly userBanModal = viewChild<UserBanModalComponent>('userBanModal')
- readonly table = viewChild<TableComponent<User, ColumnName>>('table')
+ readonly table = viewChild<TableComponent<User, DataLoaderParameter, ColumnName>>('table')
bulkActions: DropdownAction<User[]>[][] = []
- inputFilters: AdvancedInputFilter[] = [
+ inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = [
{
- title: $localize`Advanced filters`,
- children: [
- {
- value: 'banned:true',
- label: $localize`Banned users`
- }
+ type: 'options',
+ key: 'blocked',
+ title: $localize`Ban status`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: true, label: $localize`Banned` },
+ { value: false, label: $localize`Not banned` }
]
}
]
@@ -289,7 +290,7 @@ export class UserListComponent implements OnInit, OnDestroy {
})
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: DataLoaderOptionsBase & { blocked?: boolean }) {
return this.userAdminService.listUsers(options)
.pipe(
switchMap(result => {
diff --git a/client/src/app/+admin/overview/videos/video-admin.service.ts b/client/src/app/+admin/overview/videos/video-admin.service.ts
index 02c1bb87f5..868ea955d5 100644
--- a/client/src/app/+admin/overview/videos/video-admin.service.ts
+++ b/client/src/app/+admin/overview/videos/video-admin.service.ts
@@ -1,10 +1,9 @@
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable, inject } from '@angular/core'
import { RestExtractor, RestPagination, RestService } from '@app/core'
-import { AdvancedInputFilter } from '@app/shared/shared-forms/advanced-input-filter.component'
import { Video } from '@app/shared/shared-main/video/video.model'
import { VideoListParams, VideoService } from '@app/shared/shared-main/video/video.service'
-import { getAllPrivacies, omit } from '@peertube/peertube-core-utils'
+import { getAllPrivacies } from '@peertube/peertube-core-utils'
import { ResultList, VideoInclude, VideoPrivacy } from '@peertube/peertube-models'
import { Observable } from 'rxjs'
import { catchError, switchMap } from 'rxjs/operators'
@@ -16,106 +15,19 @@ export class VideoAdminService {
private restExtractor = inject(RestExtractor)
private restService = inject(RestService)
- getAdminVideos (
- options: VideoListParams & { pagination: RestPagination, search?: string }
+ listAdminVideos (
+ options: VideoListParams & {
+ pagination: RestPagination
+ search?: string
+ excludeMuted?: boolean
+ excludePublic?: boolean
+ }
): Observable<ResultList<Video>> {
- const { pagination, search } = options
+ const { pagination, search, excludeMuted, excludePublic, ...listParamsOptions } = options
let params = new HttpParams()
- params = this.videoService.buildVideoListParams({ params, ...omit(options, [ 'search', 'pagination' ]) })
-
- params = params.set('start', pagination.start.toString())
- .set('count', pagination.count.toString())
-
- params = this.buildAdminParamsFromSearch(search, params)
-
- return this.authHttp
- .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
- .pipe(
- switchMap(res => this.videoService.extractVideos(res)),
- catchError(err => this.restExtractor.handleError(err))
- )
- }
-
- buildAdminInputFilter (): AdvancedInputFilter[] {
- return [
- {
- title: $localize`Moderation`,
- children: [
- {
- value: 'nsfw:true',
- label: $localize`Sensitive videos`
- }
- ]
- },
-
- {
- title: $localize`Video type`,
- children: [
- {
- value: 'isLive:false',
- label: $localize`VOD`
- },
- {
- value: 'isLive:true',
- label: $localize`Live`
- }
- ]
- },
-
- {
- title: $localize`Video files`,
- children: [
- {
- value: 'webVideos:true isLocal:true',
- label: $localize`With Web Videos`
- },
- {
- value: 'webVideos:false isLocal:true',
- label: $localize`Without Web Videos`
- },
- {
- value: 'hls:true isLocal:true',
- label: $localize`With HLS`
- },
- {
- value: 'hls:false isLocal:true',
- label: $localize`Without HLS`
- }
- ]
- },
-
- {
- title: $localize`Videos scope`,
- children: [
- {
- value: 'isLocal:false',
- label: $localize`Remote videos`
- },
- {
- value: 'isLocal:true',
- label: $localize`Local videos`
- }
- ]
- },
+ params = this.videoService.buildVideoListParams({ params, ...listParamsOptions })
- {
- title: $localize`Exclude`,
- children: [
- {
- value: 'excludeMuted',
- label: $localize`Exclude muted accounts`
- },
- {
- value: 'excludePublic',
- label: $localize`Exclude public videos`
- }
- ]
- }
- ]
- }
-
- private buildAdminParamsFromSearch (search: string, params: HttpParams) {
let include = VideoInclude.BLACKLISTED |
VideoInclude.BLOCKED_OWNER |
VideoInclude.NOT_PUBLISHED_STATE |
@@ -125,55 +37,27 @@ export class VideoAdminService {
let privacyOneOf = getAllPrivacies()
- if (!search) return this.restService.addObjectParams(params, { include, privacyOneOf })
-
- const filters = this.restService.parseQueryStringFilter(search, {
- isLocal: {
- prefix: 'isLocal:',
- isBoolean: true
- },
- hasHLSFiles: {
- prefix: 'hls:',
- isBoolean: true
- },
- hasWebVideoFiles: {
- prefix: 'webVideos:',
- isBoolean: true
- },
- isLive: {
- prefix: 'isLive:',
- isBoolean: true
- },
- excludeMuted: {
- prefix: 'excludeMuted',
- handler: () => true
- },
- excludePublic: {
- prefix: 'excludePublic',
- handler: () => true
- },
- autoTagOneOf: {
- prefix: 'autoTag:',
- multiple: true
- },
- nsfw: {
- prefix: 'nsfw:',
- isBoolean: true
- }
- })
-
- if (filters.excludeMuted) {
+ if (excludeMuted) {
include &= ~VideoInclude.BLOCKED_OWNER
-
- filters.excludeMuted = undefined
}
- if (filters.excludePublic) {
+ if (excludePublic) {
privacyOneOf = [ VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED, VideoPrivacy.INTERNAL, VideoPrivacy.PASSWORD_PROTECTED ]
-
- filters.excludePublic = undefined
}
- return this.restService.addObjectParams(params, { ...filters, include, privacyOneOf })
+ params = this.restService.addObjectParams(params, {
+ include,
+ privacyOneOf,
+ search,
+ start: pagination.start,
+ count: pagination.count
+ })
+
+ return this.authHttp
+ .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
+ .pipe(
+ switchMap(res => this.videoService.extractVideos(res)),
+ catchError(err => this.restExtractor.handleError(err))
+ )
}
}
diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html
index a53df4dd58..dbeabd2a20 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.html
+++ b/client/src/app/+admin/overview/videos/video-list.component.html
@@ -10,18 +10,16 @@
[dataLoader]="dataLoader"
(rowExpand)="onRowExpand($event)"
columnConfig="false"
+ refreshButton="true"
+ searchInput="true"
+ [inputFilters]="inputFilters"
+ [defaultInputFilterValues]="defaultInputFilterValues"
>
<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>
@@ -60,7 +58,7 @@
<a
i18n-title title="Only display videos with this tag"
class="pt-badge badge-secondary me-1"
- [routerLink]="[ '.' ]" [queryParams]="{ 'search': buildSearchAutoTag(tag) }"
+ [routerLink]="[ '.' ]" [queryParams]="{ 'autoTagOneOf': tag }" queryParamsHandling="merge"
>{{ tag }}</a>
}
</div>
@@ -164,8 +162,8 @@
</div>
</ng-template>
- <ng-template #noResults let-search>
- @if (search) {
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ @if (search || hasFilters) {
<ng-container i18n>No videos found matching current filters.</ng-container>
} @else {
<ng-container i18n>Your platform doesn't have videos.</ng-container>
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts
index 16ce0dc93a..0b96869456 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.ts
+++ b/client/src/app/+admin/overview/videos/video-list.component.ts
@@ -1,5 +1,5 @@
-import { Component, OnInit, inject, viewChild } from '@angular/core'
-import { ActivatedRoute, RouterLink } from '@angular/router'
+import { Component, inject, OnInit, viewChild } from '@angular/core'
+import { 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'
@@ -15,14 +15,13 @@ 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 { TableRowExpandEvent } from 'primeng/table'
-import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'
+import { AdvancedFilterDef } from '../../../shared/shared-forms/advanced-input-filter.component'
import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
import { DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'
-import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
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 { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'
import { VideoCellComponent } from '../../../shared/shared-tables/video-cell.component'
import {
VideoActionsDisplayType,
@@ -31,6 +30,8 @@ import {
import { VideoNSFWBadgeComponent } from '../../../shared/shared-video/video-nsfw-badge.component'
import { VideoAdminService } from './video-admin.service'
+type DataLoaderParameter = Parameters<VideoListComponent['_dataLoader']>[0]
+
type ColumnName =
| 'video'
| 'info'
@@ -43,8 +44,6 @@ type ColumnName =
styleUrls: [ './video-list.component.scss' ],
imports: [
GlobalIconComponent,
- AdvancedInputFilterComponent,
- ButtonComponent,
VideoActionsDropdownComponent,
VideoCellComponent,
EmbedComponent,
@@ -59,7 +58,6 @@ type ColumnName =
]
})
export class VideoListComponent implements OnInit {
- private route = inject(ActivatedRoute)
private confirmService = inject(ConfirmService)
private auth = inject(AuthService)
private notifier = inject(Notifier)
@@ -71,10 +69,12 @@ export class VideoListComponent implements OnInit {
private videoFileTokenService = inject(VideoFileTokenService)
readonly videoBlockModal = viewChild<VideoBlockComponent>('videoBlockModal')
- readonly table = viewChild<TableComponent<Video>>('table')
+ readonly table = viewChild<TableComponent<Video, DataLoaderParameter, ColumnName>>('table')
bulkActions: DropdownAction<Video[]>[][] = []
- inputFilters: AdvancedInputFilter[]
+
+ defaultInputFilterValues: Partial<DataLoaderParameter> = {}
+ inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = []
videoActionsOptions: VideoActionsDisplayType = {
playlist: false,
@@ -115,7 +115,87 @@ export class VideoListComponent implements OnInit {
}
ngOnInit () {
- this.inputFilters = this.videoAdminService.buildAdminInputFilter()
+ this.defaultInputFilterValues = { isLocal: true }
+
+ this.inputFilters = [
+ {
+ type: 'options',
+ key: 'isLocal',
+ title: $localize`Videos scope`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: false, label: $localize`Remote videos` },
+ { value: true, label: $localize`Local videos` }
+ ]
+ },
+
+ {
+ type: 'options',
+ key: 'nsfw',
+ title: $localize`Sensitive videos`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: 'true', label: $localize`Sensitive` },
+ { value: 'false', label: $localize`Non sensitive` }
+ ]
+ },
+
+ {
+ type: 'title',
+ title: $localize`Moderation`
+ },
+
+ {
+ type: 'checkbox',
+ key: 'excludeMuted',
+ label: $localize`Exclude muted accounts`
+ },
+
+ {
+ type: 'checkbox',
+ key: 'excludePublic',
+ label: $localize`Exclude public videos`
+ },
+
+ {
+ type: 'options',
+ key: 'isLive',
+ title: $localize`Video type`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: false, label: $localize`VOD` },
+ { value: true, label: $localize`Live` }
+ ]
+ },
+
+ {
+ type: 'options',
+ key: 'hasWebVideoFiles',
+ title: $localize`Web files (local only)`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: true, label: $localize`With Web Videos files` },
+ { value: false, label: $localize`Without Web Videos files` }
+ ]
+ },
+
+ {
+ type: 'options',
+ key: 'hasHLSFiles',
+ title: $localize`HLS files (local only)`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: true, label: $localize`With HLS files` },
+ { value: false, label: $localize`Without HLS files` }
+ ]
+ },
+
+ {
+ type: 'tags',
+ key: 'autoTagOneOf',
+ title: $localize`Auto tags`
+ }
+ ]
this.bulkActions = [
[
@@ -266,15 +346,6 @@ export class VideoListComponent implements OnInit {
})
}
- buildSearchAutoTag (tag: string) {
- const str = `autoTag:"${tag}"`
-
- const search = this.route.snapshot.queryParams.search
- if (search) return search + ' ' + str
-
- return str
- }
-
// ---------------------------------------------------------------------------
onRowExpand (event: TableRowExpandEvent) {
@@ -297,13 +368,13 @@ export class VideoListComponent implements OnInit {
// ---------------------------------------------------------------------------
- private _dataLoader (options: DataLoaderOptions) {
- return this.videoAdminService.getAdminVideos({
- ...options,
-
+ private _dataLoader (options: DataLoaderOptionsBase & Partial<Parameters<VideoAdminService['listAdminVideos']>[0]>) {
+ return this.videoAdminService.listAdminVideos({
// Always list NSFW video, overriding instance/user setting
+ nsfwFlagsExcluded: NSFWFlag.NONE,
nsfw: 'both',
- nsfwFlagsExcluded: NSFWFlag.NONE
+
+ ...options
})
}
diff --git a/client/src/app/+admin/system/jobs/job.service.ts b/client/src/app/+admin/system/jobs/job.service.ts
index 0c7486c625..45550e88d0 100644
--- a/client/src/app/+admin/system/jobs/job.service.ts
+++ b/client/src/app/+admin/system/jobs/job.service.ts
@@ -1,13 +1,11 @@
-import { SortMeta } from 'primeng/api'
-import { Observable } from 'rxjs'
-import { catchError, map } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable, inject } from '@angular/core'
import { RestExtractor, RestPagination, RestService } from '@app/core'
-import { Job, ResultList } from '@peertube/peertube-models'
+import { Job, JobState, JobType, ResultList } from '@peertube/peertube-models'
+import { SortMeta } from 'primeng/api'
+import { Observable } from 'rxjs'
+import { catchError, map } from 'rxjs/operators'
import { environment } from '../../../../environments/environment'
-import { JobStateClient } from '../../../../types/job-state-client.type'
-import { JobTypeClient } from '../../../../types/job-type-client.type'
@Injectable()
export class JobService {
@@ -18,8 +16,8 @@ export class JobService {
private static BASE_JOB_URL = environment.apiUrl + '/api/v1/jobs'
listJobs (options: {
- jobState?: JobStateClient
- jobType: JobTypeClient
+ jobState?: JobState
+ jobType?: JobType
pagination: RestPagination
sort: SortMeta
}): Observable<ResultList<Job>> {
@@ -28,7 +26,7 @@ export class JobService {
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
- if (jobType !== 'all') params = params.append('jobType', jobType)
+ if (jobType) params = params.append('jobType', jobType)
return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + `/${jobState || ''}`, { params })
.pipe(
diff --git a/client/src/app/+admin/system/jobs/jobs.component.html b/client/src/app/+admin/system/jobs/jobs.component.html
index d6bacc17ba..9ebea30bf0 100644
--- a/client/src/app/+admin/system/jobs/jobs.component.html
+++ b/client/src/app/+admin/system/jobs/jobs.component.html
@@ -9,37 +9,13 @@
paginatorText="jobs per page"
columnConfig="true"
[dataLoader]="dataLoader"
- [customParseQueryParams]="customParseQueryParams"
- [customUpdateUrl]="customUpdateUrl"
+ [inputFilters]="inputFilters"
+ refreshButton="true"
>
<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 #captionRight>
- <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)="table.loadData()"></my-button>
- </div>
- </ng-template>
-
<ng-template #tableCells let-job>
@if (table.isColumnDisplayed('id')) {
<td class="job-id" [title]="job.id">{{ job.id }}</td>
@@ -100,20 +76,14 @@
</div>
</ng-template>
- <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>
+ <ng-template #noResults let-search="search" let-filters="filters">
+ <div>
+ @if (search || filters) {
+ <ng-container i18n>No job found for the current filters.</ng-container>
} @else {
- <ng-container i18n>No <code>{{ jobType }}</code> jobs found that are <span [ngClass]="getJobStateClasses(jobState)">{{ jobState }}</span>.</ng-container>
+ <ng-container i18n>No job found.</ng-container>
}
- }
+ </div>
</ng-template>
</my-table>
diff --git a/client/src/app/+admin/system/jobs/jobs.component.scss b/client/src/app/+admin/system/jobs/jobs.component.scss
index c360292ea2..7c2222e64e 100644
--- a/client/src/app/+admin/system/jobs/jobs.component.scss
+++ b/client/src/app/+admin/system/jobs/jobs.component.scss
@@ -2,20 +2,6 @@
@use "_mixins" as *;
@use "form-mixins" as *;
-.select-job-state {
- display: block;
- min-width: 120px;
-
- ::ng-deep .pt-badge {
- font-size: 13px;
- }
-}
-
-.select-job-type {
- display: block;
- min-width: 240px;
-}
-
@media screen and (min-width: $medium-view) {
.job-id {
max-width: 30vw !important;
diff --git a/client/src/app/+admin/system/jobs/jobs.component.ts b/client/src/app/+admin/system/jobs/jobs.component.ts
index e6dcb947b6..31ec33a8e5 100644
--- a/client/src/app/+admin/system/jobs/jobs.component.ts
+++ b/client/src/app/+admin/system/jobs/jobs.component.ts
@@ -1,26 +1,24 @@
import { CommonModule } from '@angular/common'
-import { Component, OnInit, inject, viewChild } from '@angular/core'
+import { Component, inject, viewChild } from '@angular/core'
import { FormsModule } from '@angular/forms'
+import { RouterLink } from '@angular/router'
import { RestPagination } from '@app/core'
-import { SelectOptionsComponent } from '@app/shared/shared-forms/select/select-options.component'
-
+import { AdvancedFilterDef } from '@app/shared/shared-forms/advanced-input-filter.component'
+import { PeerTubeBadgeService } from '@app/shared/shared-main/common/peertube-badge.service'
import { Job, JobState, JobType } from '@peertube/peertube-models'
-import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
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 { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'
-import { TableColumnInfo, TableComponent, TableQueryParams } from '../../../shared/shared-tables/table.component'
+import { TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'
import { JobService } from './job.service'
-import { RouterLink } from '@angular/router'
type ColumnName = 'id' | 'type' | 'priority' | 'state' | 'progress' | 'createdAt' | 'processed'
-type QueryParams = TableQueryParams & {
- jobType: string
- jobState: string
+type DataLoaderParameter = {
+ pagination: RestPagination
+ sort: SortMeta
+ search?: string
+ jobType?: JobType
+ jobState?: JobState
}
@Component({
@@ -30,33 +28,20 @@ type QueryParams = TableQueryParams & {
imports: [
CommonModule,
FormsModule,
- ButtonComponent,
- SelectOptionsComponent,
TableComponent,
NumberFormatterPipe,
RouterLink
]
})
-export class JobsComponent implements OnInit {
- private static LS_STATE = 'jobs-list-state'
- private static LS_TYPE = 'jobs-list-type'
-
+export class JobsComponent {
private jobsService = inject(JobService)
+ private peertubeBadgeService = inject(PeerTubeBadgeService)
- readonly table = viewChild<TableComponent<Job, ColumnName>>('table')
+ readonly table = viewChild<TableComponent<Job, DataLoaderParameter, ColumnName>>('table')
- jobState: JobStateClient = 'all'
- jobStates: JobStateClient[] = [ 'all', 'active', 'completed', 'failed', 'waiting', 'delayed' ]
- jobStateItems: SelectOptionsItem[] = this.jobStates.map(s => ({
- id: s,
- label: s,
- classes: this.getJobStateClasses(s)
- }))
-
- jobType: JobTypeClient = 'all'
- jobTypes: JobTypeClient[] = [
- 'all',
+ private jobStates: JobState[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed' ]
+ private jobTypes: JobType[] = [
'activitypub-cleaner',
'activitypub-follow',
'activitypub-http-broadcast-parallel',
@@ -85,34 +70,55 @@ export class JobsComponent implements OnInit {
'video-transcription',
'videos-stats'
]
- jobTypeItems: SelectOptionsItem[] = this.jobTypes.map(i => ({ id: i, label: i }))
+
+ readonly inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = [
+ {
+ type: 'select',
+ key: 'jobType',
+ title: $localize`Job type`,
+ clearable: true,
+ items: this.jobTypes.map(i => ({
+ id: i,
+ label: i.toLocaleUpperCase(),
+ classes: [ 'pt-badge', this.getRandomJobTypeBadge(i) ]
+ }))
+ },
+ {
+ type: 'select',
+ key: 'jobState',
+ title: $localize`Job state`,
+ clearable: true,
+ items: this.jobStates.map(s => ({
+ id: s,
+ label: s.toLocaleUpperCase(),
+ classes: this.getJobStateClasses(s)
+ }))
+ }
+ ]
+
+ defaultInputFilterValues: Partial<DataLoaderParameter>
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: 'state', class: 'job-state', label: $localize`State`, sortable: false },
+ { id: 'progress', class: 'job-progress', label: $localize`Progress`, isDisplayed: () => this.displayGlobalProgress, 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
+ displayGlobalProgress = true
+
constructor () {
- this.customUpdateUrl = this._customUpdateUrl.bind(this)
- this.customParseQueryParams = this._customParseQueryParams.bind(this)
this.dataLoader = this._dataLoader.bind(this)
}
- ngOnInit () {
- this.loadJobStateAndType()
- }
-
- getJobStateClasses (state: JobStateClient): string[] {
+ getJobStateClasses (state: JobState): string[] {
switch (state) {
- case 'all':
+ case undefined:
+ case null:
return []
case 'active':
@@ -138,15 +144,6 @@ export class JobsComponent implements OnInit {
return state
}
- onJobStateOrTypeChanged () {
- this.table().onFilter()
- this.saveJobStateAndType()
- }
-
- hasGlobalProgress () {
- return this.jobType === 'all' || this.jobType === 'video-transcoding'
- }
-
hasProgress (job: Job) {
return job.type === 'video-transcoding'
}
@@ -158,53 +155,24 @@ export class JobsComponent implements OnInit {
}
getRandomJobTypeBadge (type: string) {
- return this.table().getRandomBadge('type', type)
- }
-
- private _customUpdateUrl (): Partial<QueryParams> {
- return {
- jobType: this.jobType,
- jobState: this.jobState
- }
- }
-
- private _customParseQueryParams (queryParams: QueryParams) {
- if (queryParams.jobType) {
- this.jobType = queryParams.jobType as JobTypeClient
- }
-
- if (queryParams.jobState) {
- this.jobState = queryParams.jobState as JobStateClient
- }
+ return this.peertubeBadgeService.getRandomBadge('type', type)
}
private _dataLoader (options: {
pagination: RestPagination
sort: SortMeta
+ jobType?: JobType
+ jobState?: JobState
}) {
- const { pagination, sort } = options
+ const { pagination, sort, jobType, jobState } = options
- let jobState = this.jobState as JobState
- if (this.jobState === 'all') jobState = null
+ this.displayGlobalProgress = !jobType || jobType === 'video-transcoding'
return this.jobsService.listJobs({
jobState,
- jobType: this.jobType,
+ jobType,
pagination,
sort
})
}
-
- private loadJobStateAndType () {
- const state = peertubeLocalStorage.getItem(JobsComponent.LS_STATE)
- if (state && state !== 'undefined') this.jobState = state as JobState
-
- const jobType = peertubeLocalStorage.getItem(JobsComponent.LS_TYPE)
- if (jobType && jobType !== 'undefined') this.jobType = jobType as JobType
- }
-
- private saveJobStateAndType () {
- peertubeLocalStorage.setItem(JobsComponent.LS_STATE, this.jobState)
- peertubeLocalStorage.setItem(JobsComponent.LS_TYPE, this.jobType)
- }
}
diff --git a/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.html b/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.html
index 123d6bb967..1e138861da 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
@@ -8,17 +8,14 @@
columnConfig="true"
[dataLoader]="dataLoader"
[bulkActions]="bulkActions"
+ searchInput="true"
+ refreshButton="true"
+ [inputFilters]="inputFilters"
>
<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 #captionRight>
- <my-advanced-input-filter class="me-2" [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-runnerJob>
@if (table.isColumnDisplayed('uuid')) {
<td>{{ runnerJob.uuid }}</td>
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.ts
index 25d53d912a..9f2cf4f79a 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
@@ -2,14 +2,20 @@ 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 { RunnerJob, RunnerJobState } from '@peertube/peertube-models'
-import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../../shared/shared-forms/advanced-input-filter.component'
+import { PeerTubeBadgeService } from '@app/shared/shared-main/common/peertube-badge.service'
+import { RunnerJob, RunnerJobState, RunnerJobStateType, RunnerJobType } from '@peertube/peertube-models'
+import { AdvancedFilterDef } from '../../../../shared/shared-forms/advanced-input-filter.component'
import { ActionDropdownComponent, DropdownAction } from '../../../../shared/shared-main/buttons/action-dropdown.component'
-import { ButtonComponent } from '../../../../shared/shared-main/buttons/button.component'
import { NumberFormatterPipe } from '../../../../shared/shared-main/common/number-formatter.pipe'
-import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'
import { RunnerJobFormatted, RunnerService } from '../runner.service'
+type RunnerJobStateFilter = 'completed' | 'pending' | 'processing' | 'errored'
+
+type DataLoaderParameter = DataLoaderOptionsBase & {
+ state?: RunnerJobStateFilter
+ jobType?: RunnerJobType
+}
type ColumnName = 'uuid' | 'type' | 'state' | 'priority' | 'progress' | 'runner' | 'createdAt' | 'processed'
@Component({
@@ -18,8 +24,6 @@ type ColumnName = 'uuid' | 'type' | 'state' | 'priority' | 'progress' | 'runner'
imports: [
CommonModule,
ActionDropdownComponent,
- AdvancedInputFilterComponent,
- ButtonComponent,
TableComponent,
NumberFormatterPipe
]
@@ -28,33 +32,47 @@ export class RunnerJobListComponent implements OnInit {
private runnerService = inject(RunnerService)
private notifier = inject(Notifier)
private confirmService = inject(ConfirmService)
+ private peertubeBadgeService = inject(PeerTubeBadgeService)
- readonly table = viewChild<TableComponent<RunnerJobFormatted, ColumnName>>('table')
+ readonly table = viewChild<TableComponent<RunnerJobFormatted, DataLoaderParameter, ColumnName>>('table')
actions: DropdownAction<RunnerJob>[][] = []
bulkActions: DropdownAction<RunnerJob[]>[][] = []
- inputFilters: AdvancedInputFilter[] = [
+ private jobStates: RunnerJobStateFilter[] = [ 'completed', 'pending', 'processing', 'errored' ]
+
+ private jobTypes: RunnerJobType[] = [
+ 'vod-web-video-transcoding',
+ 'vod-hls-transcoding',
+ 'vod-audio-merge-transcoding',
+ 'live-rtmp-hls-transcoding',
+ 'video-studio-transcoding',
+ 'video-transcription',
+ 'generate-video-storyboard'
+ ]
+
+ inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = [
{
- title: $localize`Advanced filters`,
- children: [
- {
- value: 'state:completed',
- label: $localize`Completed jobs`
- },
- {
- value: 'state:pending state:waiting-for-parent-job',
- label: $localize`Pending jobs`
- },
- {
- value: 'state:processing',
- label: $localize`Jobs that are being processed`
- },
- {
- value: 'state:errored state:parent-errored',
- label: $localize`Failed jobs`
- }
- ]
+ type: 'select',
+ key: 'jobType',
+ title: $localize`Job type`,
+ clearable: true,
+ items: this.jobTypes.map(t => ({
+ id: t,
+ label: t.toLocaleUpperCase(),
+ classes: [ 'pt-badge', this.getRandomRunnerTypeBadge(t) ]
+ }))
+ },
+ {
+ type: 'select',
+ key: 'state',
+ title: $localize`Job state`,
+ clearable: true,
+ items: this.jobStates.map(s => ({
+ id: s,
+ label: s.toLocaleUpperCase(),
+ classes: [ 'pt-badge', this.getRandomRunnerNameBadge(s) ]
+ }))
}
]
@@ -109,6 +127,8 @@ export class RunnerJobListComponent implements OnInit {
]
}
+ // ---------------------------------------------------------------------------
+
async cancelJobs (jobs: RunnerJob[]) {
const message = formatICU(
$localize`Do you really want to cancel {count, plural, =1 {this job} other {{count} jobs}}? Children jobs will also be cancelled.`,
@@ -182,17 +202,37 @@ export class RunnerJobListComponent implements OnInit {
}
getRandomRunnerNameBadge (value: string) {
- return this.table().getRandomBadge('runner', value)
+ return this.peertubeBadgeService.getRandomBadge('runner', value)
}
getRandomRunnerTypeBadge (value: string) {
- return this.table().getRandomBadge('type', value)
+ return this.peertubeBadgeService.getRandomBadge('type', value)
}
- private _dataLoader (options: DataLoaderOptions) {
- const { pagination, sort, search } = options
-
- return this.runnerService.listRunnerJobs({ pagination, sort, search })
+ private _dataLoader (
+ options: DataLoaderOptionsBase & {
+ state?: RunnerJobStateFilter
+ jobType?: RunnerJobType
+ }
+ ) {
+ const { pagination, sort, search, state, jobType } = options
+
+ let stateOneOf: RunnerJobStateType[]
+
+ if (state) {
+ stateOneOf = []
+
+ if (state === 'completed') stateOneOf.push(RunnerJobState.COMPLETED)
+ else if (state === 'pending') {
+ stateOneOf.push(RunnerJobState.PENDING)
+ stateOneOf.push(RunnerJobState.WAITING_FOR_PARENT_JOB)
+ } else if (state === 'processing') stateOneOf.push(RunnerJobState.PROCESSING)
+ else if (state === 'errored') {
+ stateOneOf.push(RunnerJobState.ERRORED)
+ stateOneOf.push(RunnerJobState.PARENT_ERRORED)
+ }
+ }
+ return this.runnerService.listRunnerJobs({ pagination, sort, search, stateOneOf, jobType })
}
private canCancelJob (job: RunnerJob) {
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.ts
index 35df059ec1..b8b7111a64 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
@@ -4,7 +4,7 @@ import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'
import { Runner } from '@peertube/peertube-models'
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'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'
import { RunnerService } from '../runner.service'
@Component({
@@ -71,7 +71,7 @@ export class RunnerListComponent implements OnInit {
})
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: DataLoaderOptionsBase) {
return this.runnerService.listRunners(options)
}
}
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.ts
index 3bbf75dd17..2ab28f9c98 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
@@ -6,7 +6,7 @@ import { ActionDropdownComponent, DropdownAction } from '../../../../shared/shar
import { ButtonComponent } from '../../../../shared/shared-main/buttons/button.component'
import { CopyButtonComponent } from '../../../../shared/shared-main/buttons/copy-button.component'
import { NumberFormatterPipe } from '../../../../shared/shared-main/common/number-formatter.pipe'
-import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../../../../shared/shared-tables/table.component'
import { RunnerService } from '../runner.service'
@Component({
@@ -85,7 +85,7 @@ export class RunnerRegistrationTokenListComponent implements OnInit {
})
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: DataLoaderOptionsBase) {
return this.runnerService.listRegistrationTokens(options)
}
}
diff --git a/client/src/app/+admin/system/runners/runner.service.ts b/client/src/app/+admin/system/runners/runner.service.ts
index 772c51890d..875bba57c4 100644
--- a/client/src/app/+admin/system/runners/runner.service.ts
+++ b/client/src/app/+admin/system/runners/runner.service.ts
@@ -1,10 +1,18 @@
-import { SortMeta } from 'primeng/api'
-import { catchError, concatMap, forkJoin, from, map, toArray } from 'rxjs'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable, inject } from '@angular/core'
import { RestExtractor, RestPagination, RestService, ServerService } from '@app/core'
import { arrayify, peertubeTranslate } from '@peertube/peertube-core-utils'
-import { ResultList, Runner, RunnerJob, RunnerJobAdmin, RunnerJobState, RunnerRegistrationToken } from '@peertube/peertube-models'
+import {
+ ResultList,
+ Runner,
+ RunnerJob,
+ RunnerJobAdmin,
+ RunnerJobStateType,
+ RunnerJobType,
+ RunnerRegistrationToken
+} from '@peertube/peertube-models'
+import { SortMeta } from 'primeng/api'
+import { catchError, concatMap, forkJoin, from, map, toArray } from 'rxjs'
import { environment } from '../../../../environments/environment'
export type RunnerJobFormatted = RunnerJob & {
@@ -50,15 +58,17 @@ export class RunnerService {
pagination: RestPagination
sort: SortMeta
search?: string
+ stateOneOf?: RunnerJobStateType[]
+ jobType?: RunnerJobType
}) {
- const { pagination, sort, search } = options
+ const { pagination, sort, search, stateOneOf, jobType } = options
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
- if (search) {
- params = this.buildParamsFromSearch(search, params)
- }
+ if (search) params = params.append('search', search)
+ if (jobType) params = params.append('jobType', jobType)
+ if (stateOneOf) params = this.restService.addObjectParams(params, { stateOneOf })
return forkJoin([
this.authHttp.get<ResultList<RunnerJobAdmin>>(RunnerService.BASE_RUNNER_URL + '/jobs', { params }),
@@ -88,27 +98,6 @@ export class RunnerService {
)
}
- private buildParamsFromSearch (search: string, params: HttpParams) {
- const filters = this.restService.parseQueryStringFilter(search, {
- stateOneOf: {
- prefix: 'state:',
- multiple: true,
- handler: v => {
- if (v === 'completed') return RunnerJobState.COMPLETED
- if (v === 'processing') return RunnerJobState.PROCESSING
- if (v === 'errored') return RunnerJobState.ERRORED
- if (v === 'pending') return RunnerJobState.PENDING
- if (v === 'waiting-for-parent-job') return RunnerJobState.WAITING_FOR_PARENT_JOB
- if (v === 'parent-errored') return RunnerJobState.PARENT_ERRORED
-
- return undefined
- }
- }
- })
-
- return this.restService.addObjectParams(params, filters)
- }
-
// ---------------------------------------------------------------------------
cancelJobs (jobsArg: RunnerJob | RunnerJob[]) {
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.html
index 1486955688..e959c4785e 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
@@ -5,7 +5,7 @@
<span class="total-items">{{ getTotalTitle() }}</span>
}
- <my-advanced-input-filter class="d-block ms-auto" (search)="onSearch($event)" emitOnInit="true" i18n-placeholder placeholder="Search a channel"></my-advanced-input-filter>
+ <my-search-input class="d-block ms-auto" (search)="onSearch($event)" emitOnInit="true" i18n-placeholder placeholder="Search a channel"></my-search-input>
@if (user.isCollaboratingToChannels()) {
<div class="d-flex align-items-center">
@@ -48,7 +48,7 @@
<a
i18n class="followers"
- [routerLink]="[ '/my-library', 'followers' ]" [queryParams]="{ search: 'channel:' + videoChannel.name }"
+ [routerLink]="[ '/my-library', 'followers' ]" [queryParams]="{ channel: videoChannel.name }"
>
{videoChannel.followersCount, plural, =0 {No subscribers} =1 {1 subscriber} other {{{ videoChannel.followersCount }} subscribers}}
</a>
diff --git a/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts b/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts
index d361fa904a..4aaabdc606 100644
--- a/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts
+++ b/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts
@@ -23,7 +23,7 @@ import { ChartModule } from 'primeng/chart'
import { Subject, first, switchMap } from 'rxjs'
import { SelectOptionsItem } from 'src/types'
import { ActorAvatarComponent } from '../../shared/shared-actor-image/actor-avatar.component'
-import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'
+import { SearchInputComponent } from '../../shared/shared-forms/search-input.component'
import { GlobalIconComponent } from '../../shared/shared-icons/global-icon.component'
import { DeleteButtonComponent } from '../../shared/shared-main/buttons/delete-button.component'
import { EditButtonComponent } from '../../shared/shared-main/buttons/edit-button.component'
@@ -43,7 +43,7 @@ type DisplayFilter = 'all' | 'owned'
FormsModule,
RouterLink,
ChannelsSetupMessageComponent,
- AdvancedInputFilterComponent,
+ SearchInputComponent,
InfiniteScrollerDirective,
ActorAvatarComponent,
EditButtonComponent,
@@ -119,6 +119,7 @@ export class MyVideoChannelsComponent implements OnInit {
}
onSearch (search: string) {
+ console.log(search)
this.search = search
this.resetDataAndReload()
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.html
index f13666d8c5..3f77465ccd 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
@@ -3,7 +3,11 @@
<span class="total-items"> {{ getTotalTitle() }}</span>
}
- <my-advanced-input-filter class="d-block ms-auto" [filters]="inputFilters" (search)="onSearch($event)" emitOnInit="true"></my-advanced-input-filter>
+ <div class="d-flex gap-2 flex-wrap ms-auto">
+ <my-search-input (search)="onSearch($event)"></my-search-input>
+
+ <my-advanced-input-filter class="d-block ms-auto" [filters]="inputFilters" (filtersChange)="onFilter($event)"></my-advanced-input-filter>
+ </div>
</div>
@if (pagination.totalItems === 0) {
diff --git a/client/src/app/+my-library/my-follows/my-followers.component.ts b/client/src/app/+my-library/my-follows/my-followers.component.ts
index dbcfbf1a46..fd45e226f4 100644
--- a/client/src/app/+my-library/my-follows/my-followers.component.ts
+++ b/client/src/app/+my-library/my-follows/my-followers.component.ts
@@ -2,18 +2,19 @@ import { Component, OnInit, inject } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { AuthService, ComponentPagination, Notifier, resetCurrentPage } from '@app/core'
import { formatICU } from '@app/helpers'
+import { SearchInputComponent } from '@app/shared/shared-forms/search-input.component'
import { UserSubscriptionService } from '@app/shared/shared-user-subscription/user-subscription.service'
import { ActorFollow } from '@peertube/peertube-models'
import { Subject } from 'rxjs'
import { ActorAvatarComponent } from '../../shared/shared-actor-image/actor-avatar.component'
-import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'
+import { AdvancedFilterDef, AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'
import { GlobalIconComponent } from '../../shared/shared-icons/global-icon.component'
import { InfiniteScrollerDirective } from '../../shared/shared-main/common/infinite-scroller.directive'
@Component({
templateUrl: './my-followers.component.html',
styleUrls: [ './my-followers.component.scss' ],
- imports: [ GlobalIconComponent, AdvancedInputFilterComponent, InfiniteScrollerDirective, ActorAvatarComponent ]
+ imports: [ GlobalIconComponent, AdvancedInputFilterComponent, InfiniteScrollerDirective, ActorAvatarComponent, SearchInputComponent ]
})
export class MyFollowersComponent implements OnInit {
private route = inject(ActivatedRoute)
@@ -31,27 +32,27 @@ export class MyFollowersComponent implements OnInit {
onDataSubject = new Subject<any[]>()
search: string
+ channelFilter: string
- inputFilters: AdvancedInputFilter[]
+ inputFilters: AdvancedFilterDef<{ channel: string }>[]
ngOnInit () {
- if (this.route.snapshot.queryParams['search']) {
- this.search = this.route.snapshot.queryParams['search']
- }
-
- const channelFilters = this.auth.getUser().videoChannels.map(c => {
- return {
- value: 'channel:' + c.name,
- label: c.name
- }
- })
-
this.inputFilters = [
{
- title: $localize`Channel filters`,
- children: channelFilters
+ type: 'select',
+ key: 'channel',
+ title: $localize`Channel`,
+ items: this.auth.getUser().videoChannels.map(c => ({
+ id: c.name,
+ label: c.displayName
+ }))
}
]
+
+ this.search = this.route.snapshot.queryParamMap.get('search') || ''
+ this.channelFilter = this.route.snapshot.queryParamMap.get('channel') || ''
+
+ this.loadFollowers()
}
onNearOfBottom () {
@@ -66,7 +67,16 @@ export class MyFollowersComponent implements OnInit {
this.search = search
resetCurrentPage(this.pagination)
- this.loadFollowers(false)
+ this.loadFollowers({ more: false })
+ }
+
+ onFilter (filters: {
+ channel?: string
+ }) {
+ this.channelFilter = filters.channel
+ resetCurrentPage(this.pagination)
+
+ this.loadFollowers({ more: false })
}
isFollowingAccount (follow: ActorFollow) {
@@ -80,11 +90,16 @@ export class MyFollowersComponent implements OnInit {
)
}
- private loadFollowers (more = true) {
+ private loadFollowers (options: {
+ more?: boolean
+ } = {}) {
+ const { more = false } = options
+
this.userSubscriptionService.listFollowers({
pagination: this.pagination,
nameWithHost: this.getUsername(),
- search: this.search
+ search: this.search,
+ channel: this.channelFilter
}).subscribe({
next: res => {
this.follows = more
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.html
index dc2fcd8ffb..30b566ca31 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
@@ -3,7 +3,7 @@
<span class="total-items"> {{ getTotalTitle() }}</span>
}
- <my-advanced-input-filter class="d-block ms-auto" (search)="onSearch($event)" emitOnInit="true"></my-advanced-input-filter>
+ <my-search-input class="d-block ms-auto" (search)="onSearch($event)" emitOnInit="true"></my-search-input>
</div>
@if (pagination.totalItems === 0) {
diff --git a/client/src/app/+my-library/my-follows/my-subscriptions.component.ts b/client/src/app/+my-library/my-follows/my-subscriptions.component.ts
index f4940e2b1a..a7a173968a 100644
--- a/client/src/app/+my-library/my-follows/my-subscriptions.component.ts
+++ b/client/src/app/+my-library/my-follows/my-subscriptions.component.ts
@@ -6,7 +6,7 @@ import { VideoChannel } from '@app/shared/shared-main/channel/video-channel.mode
import { UserSubscriptionService } from '@app/shared/shared-user-subscription/user-subscription.service'
import { Subject } from 'rxjs'
import { ActorAvatarComponent } from '../../shared/shared-actor-image/actor-avatar.component'
-import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'
+import { SearchInputComponent } from '../../shared/shared-forms/search-input.component'
import { InfiniteScrollerDirective } from '../../shared/shared-main/common/infinite-scroller.directive'
import { SubscribeButtonComponent } from '../../shared/shared-user-subscription/subscribe-button.component'
@@ -14,7 +14,7 @@ import { SubscribeButtonComponent } from '../../shared/shared-user-subscription/
templateUrl: './my-subscriptions.component.html',
styleUrls: [ './my-subscriptions.component.scss' ],
imports: [
- AdvancedInputFilterComponent,
+ SearchInputComponent,
InfiniteScrollerDirective,
ActorAvatarComponent,
RouterLink,
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.html
index 4e20c13e3f..4660dba63f 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="true" (search)="onSearch($event)"></my-advanced-input-filter>
+ <my-search-input emitOnInit="true" (search)="onSearch($event)"></my-search-input>
</div>
<div class="history-switch">
diff --git a/client/src/app/+my-library/my-history/my-history.component.ts b/client/src/app/+my-library/my-history/my-history.component.ts
index b86e36a4c5..3d1bd7e00d 100644
--- a/client/src/app/+my-library/my-history/my-history.component.ts
+++ b/client/src/app/+my-library/my-history/my-history.component.ts
@@ -18,7 +18,7 @@ import { Video } from '@app/shared/shared-main/video/video.model'
import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature/video-miniature.component'
import { VideosSelectionComponent } from '@app/shared/shared-video-miniature/videos-selection.component'
import { tap } from 'rxjs/operators'
-import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'
+import { SearchInputComponent } from '../../shared/shared-forms/search-input.component'
import { InputSwitchComponent } from '../../shared/shared-forms/input-switch.component'
import { DeleteButtonComponent } from '../../shared/shared-main/buttons/delete-button.component'
import { PeerTubeTemplateDirective } from '../../shared/shared-main/common/peertube-template.directive'
@@ -28,7 +28,7 @@ import { PeerTubeTemplateDirective } from '../../shared/shared-main/common/peert
styleUrls: [ './my-history.component.scss' ],
imports: [
ButtonComponent,
- AdvancedInputFilterComponent,
+ SearchInputComponent,
InputSwitchComponent,
FormsModule,
VideosSelectionComponent,
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.ts
index 13fec434b2..74c62c0939 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
@@ -4,7 +4,7 @@ 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 { DataLoaderOptions, TableColumnInfo, TableComponent } from '@app/shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '@app/shared/shared-tables/table.component'
import { VideoChangeOwnership, VideoChangeOwnershipStatus, VideoChangeOwnershipStatusType } from '@peertube/peertube-models'
import { map } from 'rxjs'
import { ActorAvatarComponent } from '../../shared/shared-actor-image/actor-avatar.component'
@@ -74,7 +74,7 @@ export class MyOwnershipComponent {
})
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: DataLoaderOptionsBase) {
return this.videoOwnershipService.getOwnershipChanges(options.pagination, options.sort)
.pipe(
map(resultList => ({
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.ts
index c67689437c..9726e4ea25 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
@@ -11,7 +11,7 @@ import { first, mergeMap } from 'rxjs'
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'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../../shared/shared-tables/table.component'
@Component({
templateUrl: './my-video-channel-syncs.component.html',
@@ -72,7 +72,7 @@ export class MyVideoChannelSyncsComponent implements OnInit {
{
label: $localize`List imports`,
linkBuilder: () => [ '/my-library/video-imports' ],
- queryParamsBuilder: sync => ({ search: `videoChannelSyncId:${sync.id}` }),
+ queryParamsBuilder: sync => ({ videoChannelSyncId: sync.id }),
iconName: 'cloud-download'
}
],
@@ -92,7 +92,7 @@ export class MyVideoChannelSyncsComponent implements OnInit {
]
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: DataLoaderOptionsBase) {
return this.authService.userInformationLoaded
.pipe(
first(),
diff --git a/client/src/app/+my-library/my-video-imports/my-video-imports.component.html b/client/src/app/+my-library/my-video-imports/my-video-imports.component.html
index a031760264..7052e140d9 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
@@ -6,15 +6,14 @@
paginatorText="imports per page"
[dataLoader]="dataLoader"
columnConfig="false"
+ searchInput="true"
+ [inputFilters]="inputFilters"
+ refreshButton="true"
>
<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 #captionRight>
- <my-advanced-input-filter (search)="table.onSearch($event)"></my-advanced-input-filter>
- </ng-template>
-
<ng-template #tableCells let-videoImport>
<td class="max-width-300px ellipsis">
@if (videoImport.targetUrl) {
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.ts
index cad4c27abe..dac64b5d9d 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,21 +1,22 @@
import { CommonModule } from '@angular/common'
import { Component, inject, OnInit, viewChild } from '@angular/core'
import { Notifier } from '@app/core'
+import { AdvancedFilterDef } from '@app/shared/shared-forms/advanced-input-filter.component'
import { ActionDropdownComponent, DropdownAction } from '@app/shared/shared-main/buttons/action-dropdown.component'
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 { ActorCellComponent } from '@app/shared/shared-tables/actor-cell.component'
import { VideoImport, VideoImportState, VideoImportStateType } from '@peertube/peertube-models'
-import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'
import { NumberFormatterPipe } from '../../shared/shared-main/common/number-formatter.pipe'
-import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../../shared/shared-tables/table.component'
+
+type DataLoaderParameter = Parameters<MyVideoImportsComponent['_dataLoader']>[0]
@Component({
templateUrl: './my-video-imports.component.html',
styleUrls: [ './my-video-imports.component.scss' ],
imports: [
- AdvancedInputFilterComponent,
CommonModule,
CommonModule,
PTDatePipe,
@@ -29,7 +30,34 @@ export class MyVideoImportsComponent implements OnInit {
private notifier = inject(Notifier)
private videoImportService = inject(VideoImportService)
- readonly table = viewChild<TableComponent<VideoImport>>('table')
+ readonly table = viewChild<TableComponent<VideoImport, DataLoaderParameter>>('table')
+
+ inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = [
+ {
+ key: 'targetUrl',
+ type: 'text',
+ title: $localize`Target URL`,
+ placeholder: $localize`https://example.com/.../video.mp4`
+ },
+ {
+ key: 'id',
+ type: 'text',
+ title: $localize`Import ID`,
+ constraint: 'numeric'
+ },
+ {
+ key: 'videoId',
+ type: 'text',
+ title: $localize`Video ID`,
+ constraint: 'numeric'
+ },
+ {
+ key: 'videoChannelSyncId',
+ type: 'text',
+ title: $localize`Channel sync ID`,
+ constraint: 'numeric'
+ }
+ ]
videoImportActions: DropdownAction<VideoImport>[] = []
@@ -149,7 +177,15 @@ export class MyVideoImportsComponent implements OnInit {
})
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (
+ options: DataLoaderOptionsBase & {
+ id?: number
+ videoId?: number
+ videoChannelSyncId?: number
+ targetUrl?: string
+ search?: string
+ }
+ ) {
return this.videoImportService.listMyVideoImports({ ...options, includeCollaborations: true })
}
}
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.html
index c6ca3cae26..2fb331713d 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
@@ -22,6 +22,7 @@
[customUpdateUrl]="customUpdateUrl"
[hasExpandedRow]="hasExpandedRow"
columnConfig="false"
+ searchInput="true"
[reorderableRows]="hasReorderableRows()"
(rowReorder)="onRowReorder($event)"
dragHandleTitle="Drag and drop this row to reorder playlists in your channel"
@@ -36,11 +37,6 @@
</ng-template>
<ng-template #captionRight>
- <my-advanced-input-filter
- inputId="table-search" icon="true" emitOnInit="false" i18n-placeholder placeholder="Search your playlists"
- (search)="table.onSearch($event)"
- ></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>
@@ -109,7 +105,7 @@
{{ playlist.description }}
</ng-template>
- <ng-template #noResults let-search>
- {{ getNoResults(search) }}
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ {{ getNoResults(!!search || hasFilters) }}
</ng-template>
</my-table>
diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts
index b6fbaa915d..31230e52f1 100644
--- a/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts
+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts
@@ -6,7 +6,7 @@ import { AuthService, AuthUser, ConfirmService, Notifier, RestPagination, Screen
import { HeaderService } from '@app/header/header.service'
import { Actor } from '@app/shared/shared-main/account/actor.model'
import { CollaboratorStateComponent } from '@app/shared/shared-main/channel/collaborator-state.component'
-import { TableColumnInfo, TableComponent, TableQueryParams } from '@app/shared/shared-tables/table.component'
+import { DataLoaderOptionsBase, TableColumnInfo, TableComponent, TableQueryParams } from '@app/shared/shared-tables/table.component'
import { VideoPlaylist } from '@app/shared/shared-video-playlist/video-playlist.model'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'
import { VideoChannel, VideoPlaylistType } from '@peertube/peertube-models'
@@ -15,7 +15,6 @@ import { SortMeta } from 'primeng/api'
import { TableRowReorderEvent } from 'primeng/table'
import { Subject, tap } from 'rxjs'
import { ChannelToggleComponent } from '../../shared/shared-channels/channel-toggle.component'
-import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'
import { GlobalIconComponent } from '../../shared/shared-icons/global-icon.component'
import { DeleteButtonComponent } from '../../shared/shared-main/buttons/delete-button.component'
import { EditButtonComponent } from '../../shared/shared-main/buttons/edit-button.component'
@@ -38,7 +37,6 @@ const debugLogger = debug('peertube:my-video-playlists')
imports: [
FormsModule,
GlobalIconComponent,
- AdvancedInputFilterComponent,
RouterLink,
VideoPlaylistMiniatureComponent,
DeleteButtonComponent,
@@ -61,7 +59,7 @@ export class MyVideoPlaylistsComponent implements OnInit, OnDestroy {
private cdr = inject(ChangeDetectorRef)
private screenService = inject(ScreenService)
- readonly table = viewChild<TableComponent<VideoPlaylist, ColumnName, QueryParams>>('table')
+ readonly table = viewChild<TableComponent<VideoPlaylist, DataLoaderOptionsBase, ColumnName, QueryParams>>('table')
user: AuthUser
channels: (VideoChannel & { selected: boolean })[] = []
@@ -123,9 +121,9 @@ export class MyVideoPlaylistsComponent implements OnInit, OnDestroy {
// ---------------------------------------------------------------------------
- getNoResults (search?: string) {
- if (search) {
- return $localize`No playlists found matching your search.`
+ getNoResults (hasSearchOrFilters?: boolean) {
+ if (hasSearchOrFilters) {
+ return $localize`No playlists found matching your filters.`
}
if (this.getFilteredChannel()) {
@@ -208,7 +206,7 @@ export class MyVideoPlaylistsComponent implements OnInit, OnDestroy {
}
}
- this.table().onFilter()
+ this.table().onFiltersChange()
}
hasReorderableRows () {
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.html
index 3c139e6ad5..c0244f3369 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,7 +2,7 @@
<div class="channel-label" i18n>Per channel:</div>
@for (channel of channels; track channel.id) {
- <my-channel-toggle [channel]="channel" [(ngModel)]="channel.selected" (ngModelChange)="table.onFilter()"></my-channel-toggle>
+ <my-channel-toggle [channel]="channel" [(ngModel)]="channel.selected" (ngModelChange)="table.onFiltersChange()"></my-channel-toggle>
}
</div>
@@ -18,40 +18,15 @@
[dataLoader]="dataLoader"
[customParseQueryParams]="customParseQueryParams"
[customUpdateUrl]="customUpdateUrl"
+ searchInput="true"
+ [inputFilters]="inputFilters"
+ canUseMatchSort="true"
>
<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>
- <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)="table.onSearch($event, true)"
- ></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)="table.onFilter()"
- >
- </my-select-checkbox>
- </div>
- </ng-template>
-
<ng-template #tableCells let-video>
@if (table.isColumnDisplayed('duration')) {
@@ -144,8 +119,8 @@
></my-video-actions-dropdown>
</ng-template>
- <ng-template #noResults let-search>
- {{ getNoResults(search) }}
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ {{ getNoResults(!!search || hasFilters) }}
</ng-template>
</my-table>
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.ts
index d0f3a59991..92c5242ba0 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
@@ -4,20 +4,18 @@ 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 { AdvancedFilterDef } from '@app/shared/shared-forms/advanced-input-filter.component'
import { ChannelToggleComponent } from '@app/shared/shared-channels/channel-toggle.component'
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 { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'
-import { arrayify, pick } from '@peertube/peertube-core-utils'
+import { arrayify } from '@peertube/peertube-core-utils'
import { VideoChannel, VideoExistInPlaylist, VideoPrivacy, VideoPrivacyType, VideosExistInPlaylists } from '@peertube/peertube-models'
import uniqBy from 'lodash-es/uniqBy'
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 { SelectCheckboxComponent } from '../../shared/shared-forms/select/select-checkbox.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'
@@ -33,22 +31,19 @@ import { VideoStateBadgeComponent } from '../../shared/shared-video/video-state-
import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component'
type ColumnName = 'duration' | 'name' | 'language' | 'privacy' | 'sensitive' | 'playlists' | 'insights' | 'published' | 'state' | 'comments'
-type CommonFilter = 'live' | 'vod' | 'private' | 'internal' | 'unlisted' | 'password-protected' | 'public'
-type VideoType = 'live' | 'vod'
type QueryParams = TableQueryParams & {
channelNameOneOf?: string[]
- privacyOneOf?: string[]
- videoType?: VideoType
}
+type DataLoaderParameter = Parameters<MyVideosComponent['_dataLoader']>[0]
+
@Component({
selector: 'my-videos',
templateUrl: './my-videos.component.html',
styleUrls: [ './my-videos.component.scss' ],
imports: [
FormsModule,
- AdvancedInputFilterComponent,
ButtonComponent,
NgbTooltipModule,
VideoActionsDropdownComponent,
@@ -57,7 +52,6 @@ type QueryParams = TableQueryParams & {
NumberFormatterPipe,
VideoStateBadgeComponent,
ChannelToggleComponent,
- SelectCheckboxComponent,
PTDatePipe,
VideoNSFWBadgeComponent,
TableComponent,
@@ -74,7 +68,7 @@ export class MyVideosComponent implements OnInit, OnDestroy {
private headerService = inject(HeaderService)
readonly videoChangeOwnershipModal = viewChild<VideoChangeOwnershipComponent>('videoChangeOwnershipModal')
- readonly table = viewChild<TableComponent<Video, ColumnName, QueryParams>>('table')
+ readonly table = viewChild<TableComponent<Video, DataLoaderParameter, ColumnName, QueryParams>>('table')
videosContainedInPlaylists: VideosExistInPlaylists = {}
@@ -97,8 +91,7 @@ export class MyVideosComponent implements OnInit, OnDestroy {
user: AuthUser
channels: (VideoChannel & { selected: boolean })[] = []
- filterItems: SelectOptionsItem<CommonFilter>[] = []
- selectedFilterItems: CommonFilter[] = []
+ inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = []
columns: TableColumnInfo<ColumnName>[] = []
@@ -134,34 +127,30 @@ export class MyVideosComponent implements OnInit, OnDestroy {
{ id: 'language', label: $localize`Language`, selected: false, sortable: false }
]
- this.filterItems = [
- {
- id: 'live',
- label: $localize`Lives`
- },
- {
- id: 'vod',
- label: $localize`VOD`
- },
- {
- id: 'public',
- label: $localize`Public videos`
- },
- {
- id: 'internal',
- label: $localize`Internal videos`
- },
+ this.inputFilters = [
{
- id: 'unlisted',
- label: $localize`Unlisted videos`
- },
- {
- id: 'password-protected',
- label: $localize`Password protected videos`
+ type: 'options',
+ key: 'isLive',
+ title: $localize`Video type`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: true, label: $localize`Lives` },
+ { value: false, label: $localize`VOD` }
+ ]
},
+
{
- id: 'private',
- label: $localize`Private videos`
+ type: 'options',
+ key: 'privacyOneOf',
+ title: $localize`Privacy`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: VideoPrivacy.PUBLIC, label: $localize`Public videos` },
+ { value: VideoPrivacy.INTERNAL, label: $localize`Internal videos` },
+ { value: VideoPrivacy.UNLISTED, label: $localize`Unlisted videos` },
+ { value: VideoPrivacy.PASSWORD_PROTECTED, label: $localize`Password protected videos` },
+ { value: VideoPrivacy.PRIVATE, label: $localize`Private videos` }
+ ]
}
]
@@ -173,42 +162,22 @@ export class MyVideosComponent implements OnInit, OnDestroy {
}
private _customParseQueryParams (queryParams: QueryParams) {
- {
- const enabledChannels = queryParams.channelNameOneOf
- ? new Set(arrayify(queryParams.channelNameOneOf))
- : new Set<string>()
-
- this.user = this.auth.getUser()
- this.channels = [ ...this.user.videoChannels, ...this.user.videoChannelCollaborations ].map(c => ({
- ...c,
-
- selected: enabledChannels.has(c.name)
- }))
- }
-
- {
- this.selectedFilterItems = []
- const videoType = arrayify(queryParams.videoType)
-
- if (videoType.includes('live')) this.selectedFilterItems.push('live')
- if (videoType.includes('vod')) this.selectedFilterItems.push('vod')
+ const enabledChannels = queryParams.channelNameOneOf
+ ? new Set(arrayify(queryParams.channelNameOneOf))
+ : new Set<string>()
- const enabledPrivacies = queryParams.privacyOneOf
- ? new Set(arrayify(queryParams.privacyOneOf).map(t => parseInt(t) as VideoPrivacyType))
- : new Set<VideoPrivacyType>()
+ this.user = this.auth.getUser()
+ this.channels = [ ...this.user.videoChannels, ...this.user.videoChannelCollaborations ].map(c => ({
+ ...c,
- if (enabledPrivacies.has(VideoPrivacy.PUBLIC)) this.selectedFilterItems.push('public')
- if (enabledPrivacies.has(VideoPrivacy.INTERNAL)) this.selectedFilterItems.push('internal')
- if (enabledPrivacies.has(VideoPrivacy.UNLISTED)) this.selectedFilterItems.push('unlisted')
- if (enabledPrivacies.has(VideoPrivacy.PASSWORD_PROTECTED)) this.selectedFilterItems.push('password-protected')
- if (enabledPrivacies.has(VideoPrivacy.PRIVATE)) this.selectedFilterItems.push('private')
- }
+ selected: enabledChannels.has(c.name)
+ }))
}
// ---------------------------------------------------------------------------
- getNoResults (search?: string) {
- if (search || this.selectedFilterItems.length !== 0) {
+ getNoResults (hasSearchOrFilters?: boolean) {
+ if (hasSearchOrFilters) {
return $localize`No videos found matching your filters.`
}
@@ -225,51 +194,20 @@ export class MyVideosComponent implements OnInit, OnDestroy {
const channelNameOneOf = this.channels.filter(c => c.selected).map(c => c.name)
return {
- ...pick(this.buildCommonVideoFilters(), [ 'privacyOneOf', 'videoType' ]),
-
channelNameOneOf
}
}
- private buildCommonVideoFilters () {
- const selectedFilterSet = new Set(this.selectedFilterItems)
-
- let isLive: boolean
- const videoType: VideoType[] = []
- if (selectedFilterSet.has('live')) {
- videoType.push('live')
-
- if (!selectedFilterSet.has('vod')) isLive = true
- }
-
- if (selectedFilterSet.has('vod')) {
- videoType.push('vod')
-
- if (!selectedFilterSet.has('live')) isLive = false
- }
-
- const privacyOneOf: VideoPrivacyType[] = []
- if (selectedFilterSet.has('public')) privacyOneOf.push(VideoPrivacy.PUBLIC)
- if (selectedFilterSet.has('internal')) privacyOneOf.push(VideoPrivacy.INTERNAL)
- if (selectedFilterSet.has('unlisted')) privacyOneOf.push(VideoPrivacy.UNLISTED)
- if (selectedFilterSet.has('password-protected')) privacyOneOf.push(VideoPrivacy.PASSWORD_PROTECTED)
- if (selectedFilterSet.has('private')) privacyOneOf.push(VideoPrivacy.PRIVATE)
-
- return {
- isLive,
- videoType,
- privacyOneOf
- }
- }
-
// ---------------------------------------------------------------------------
private _dataLoader (options: {
pagination: RestPagination
sort: SortMeta
search: string
+ isLive?: boolean
+ privacyOneOf?: VideoPrivacyType
}) {
- const { pagination, sort, search } = options
+ const { pagination, sort, search, isLive, privacyOneOf } = options
const channelNameOneOf = this.channels.filter(c => c.selected).map(c => c.name)
@@ -283,7 +221,10 @@ export class MyVideosComponent implements OnInit, OnDestroy {
? channelNameOneOf
: undefined,
- ...pick(this.buildCommonVideoFilters(), [ 'isLive', 'privacyOneOf' ])
+ isLive,
+ privacyOneOf: privacyOneOf !== undefined
+ ? [ privacyOneOf ]
+ : undefined
}).pipe(tap(({ data }) => this.fetchVideosContainedInPlaylists(data)))
}
diff --git a/client/src/app/core/rest/rest.service.ts b/client/src/app/core/rest/rest.service.ts
index 18511f2f2d..9a51ec6eec 100644
--- a/client/src/app/core/rest/rest.service.ts
+++ b/client/src/app/core/rest/rest.service.ts
@@ -1,26 +1,9 @@
-import debug from 'debug'
-import { SortMeta } from 'primeng/api'
import { HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
+import { SortMeta } from 'primeng/api'
import { ComponentPaginationLight } from './component-pagination.model'
import { RestPagination } from './rest-pagination'
-const debugLogger = debug('peertube:rest')
-
-type ParseQueryHandlerResult = string | number | boolean | string[] | number[] | boolean[]
-
-interface QueryStringFilterPrefixes {
- [key: string]: {
- prefix: string
- handler?: (v: string) => ParseQueryHandlerResult
- multiple?: boolean
- isBoolean?: boolean
- }
-}
-
-type ParseQueryStringFilters<K extends keyof any> = Partial<Record<K, ParseQueryHandlerResult | ParseQueryHandlerResult[]>>
-type ParseQueryStringFiltersResult<K extends keyof any> = ParseQueryStringFilters<K> & { search?: string }
-
@Injectable()
export class RestService {
addRestGetParams (params: HttpParams, pagination?: RestPagination, sort?: SortMeta | string) {
@@ -77,72 +60,4 @@ export class RestService {
return { start, count: itemsPerPage }
}
-
- /*
- * Returns an object containing the filters and the remaining search
- */
- parseQueryStringFilter<T extends QueryStringFilterPrefixes> (q: string, prefixes: T): ParseQueryStringFiltersResult<keyof T> {
- if (!q) return {}
-
- const tokens = this.tokenizeString(q)
-
- // Build prefix array
- const prefixeStrings = Object.values(prefixes)
- .map(p => p.prefix)
-
- debugLogger(`Built tokens "${tokens.join(', ')}" for prefixes "${prefixeStrings.join(', ')}"`)
-
- // Search is the querystring minus defined filters
- const searchTokens = tokens.filter(t => {
- return prefixeStrings.every(prefixString => t.startsWith(prefixString) === false)
- })
-
- const additionalFilters: ParseQueryStringFilters<keyof T> = {}
-
- for (const prefixKey of Object.keys(prefixes) as (keyof T)[]) {
- const prefixObj = prefixes[prefixKey]
- const prefix = prefixObj.prefix
-
- const matchedTokens = tokens.filter(t => t.startsWith(prefix))
- .map(t => t.slice(prefix.length)) // Keep the value filter
- .map(t => t.replace(/^"|"$/g, '')) // Remove ""
- .map(t => {
- if (prefixObj.handler) return prefixObj.handler(t)
-
- if (prefixObj.isBoolean) {
- if (t === 'true') return true
- if (t === 'false') return false
-
- return undefined
- }
-
- return t
- })
- .filter(t => t !== null && t !== undefined)
-
- if (matchedTokens.length === 0) continue
-
- additionalFilters[prefixKey] = prefixObj.multiple === true
- ? matchedTokens
- : matchedTokens[0]
- }
-
- const search = searchTokens.join(' ') || undefined
-
- debugLogger('Built search: ' + search, additionalFilters)
-
- return {
- search,
-
- ...additionalFilters
- }
- }
-
- tokenizeString (q: string) {
- if (!q) return []
-
- // Tokenize the strings using spaces that are not in quotes
- return q.match(/(?:[^\s"]+|"[^"]*")+/g)
- .filter(token => !!token)
- }
}
diff --git a/client/src/app/shared/shared-abuse-list/abuse-details.component.html b/client/src/app/shared/shared-abuse-list/abuse-details.component.html
index af36c8133c..95f1b6906e 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-details.component.html
+++ b/client/src/app/shared/shared-abuse-list/abuse-details.component.html
@@ -8,19 +8,19 @@
<span class="moderation-expanded-label" i18n>Reporter</span>
<span class="moderation-expanded-text">
- <a [routerLink]="[ '.' ]" [queryParams]="{ 'search': 'reporter:&quot;' + abuse().reporterAccount.displayName + '&quot;' }"
- class="chip me-1"
+ <a [routerLink]="[ '.' ]" [queryParams]="{ 'searchReporter': abuse().reporterAccount.displayName }"
+ class="chip"
>
<my-actor-avatar size="18" [actor]="abuse().reporterAccount" actorType="account"></my-actor-avatar>
<span class="muted">{{ abuse().reporterAccount.nameWithHost }}</span>
</a>
<a
- [routerLink]="[ '.' ]" [queryParams]="{ 'search': 'reporter:&quot;' + abuse().reporterAccount.displayName + '&quot;' }"
+ [routerLink]="[ '.' ]" [queryParams]="{ 'searchReporter': abuse().reporterAccount.displayName }"
class="ms-auto muted abuse-details-links"
>
<ng-container i18n>{abuse().countReportsForReporter, plural, =1 {1 report} other {{{ abuse().countReportsForReporter }} reports}}</ng-container>
- <my-global-icon iconName="flag"></my-global-icon>
+ <my-global-icon class="d-inline-block ms-1" iconName="flag"></my-global-icon>
</a>
</span>
</div>
@@ -32,8 +32,8 @@
<span class="moderation-expanded-text">
<a
- [routerLink]="[ '.' ]" [queryParams]="{ 'search': 'reportee:&quot;' +abuse().flaggedAccount.displayName + '&quot;' }"
- class="chip me-1"
+ [routerLink]="[ '.' ]" [queryParams]="{ 'searchReportee': abuse().flaggedAccount.displayName }"
+ class="chip"
>
<my-actor-avatar size="18" [actor]="abuse().flaggedAccount" actorType="account"></my-actor-avatar>
<span class="muted">{{ abuse().flaggedAccount ? abuse().flaggedAccount.nameWithHost : '' }}</span>
@@ -41,11 +41,11 @@
@if (isAdminView()) {
<a
- [routerLink]="[ '.' ]" [queryParams]="{ 'search': 'reportee:&quot;' +abuse().flaggedAccount.displayName + '&quot;' }"
+ [routerLink]="[ '.' ]" [queryParams]="{ 'searchReportee': abuse().flaggedAccount.displayName }"
class="ms-auto muted abuse-details-links"
>
<ng-container i18n>{abuse().countReportsForReportee, plural, =1 {1 report} other {{{ abuse().countReportsForReportee }} reports}}</ng-container>
- <my-global-icon iconName="flag"></my-global-icon>
+ <my-global-icon class="d-inline-block ms-1" iconName="flag"></my-global-icon>
</a>
}
</span>
@@ -63,7 +63,7 @@
<div class="mt-3 d-flex">
<span class="moderation-expanded-label">
<ng-container i18n>Report</ng-container>
- <a [routerLink]="[ '.' ]" [queryParams]="{ 'search': '#' + abuse().id }" class="ms-1 muted">#{{ abuse().id }}</a>
+ <a [routerLink]="[ '.' ]" [queryParams]="{ 'id': abuse().id }" class="ms-1 muted">#{{ abuse().id }}</a>
</span>
<span class="moderation-expanded-text" [innerHTML]="abuse().reasonHtml"></span>
@@ -72,7 +72,7 @@
@if (predefinedReasons) {
<div class="mt-2 d-flex gap-1">
@for (reason of predefinedReasons; track reason) {
- <a [routerLink]="[ '.' ]" [queryParams]="{ 'search': 'tag:' + reason.id }" class="pt-badge badge-secondary">{{ reason.label }}</a>
+ <a [routerLink]="[ '.' ]" [queryParams]="{ 'predefinedReason': reason.id }" class="pt-badge badge-secondary">{{ reason.label }}</a>
}
</div>
}
diff --git a/client/src/app/shared/shared-abuse-list/abuse-details.component.scss b/client/src/app/shared/shared-abuse-list/abuse-details.component.scss
index 18bc4ff6de..3bfe2ee036 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-details.component.scss
+++ b/client/src/app/shared/shared-abuse-list/abuse-details.component.scss
@@ -19,3 +19,13 @@
my-global-icon[iconName="flag"] {
@include global-icon-size(15px);
}
+
+.moderation-expanded-text .chip {
+ align-items: baseline;
+
+ &::after {
+ content: "•";
+ display: inline-block;
+ margin: 0 0.25rem;
+ }
+}
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html
index fbba9bf711..bc62c8a582 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
@@ -6,15 +6,13 @@
paginatorText="abuses per page"
[dataLoader]="dataLoader"
columnConfig="false"
+ [inputFilters]="inputFilters"
+ searchInput="true"
>
<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 #captionRight>
- <my-advanced-input-filter [filters]="inputFilters" (search)="table.onSearch($event)"></my-advanced-input-filter>
- </ng-template>
-
<ng-template #tableCells let-abuse>
@if (isAdminView()) {
<td>
@@ -137,8 +135,8 @@
<my-abuse-details [abuse]="abuse" [isAdminView]="isAdminView()"></my-abuse-details>
</ng-template>
- <ng-template #noResults let-search>
- @if (search) {
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ @if (search || hasFilters) {
<ng-container i18n>No abuses found matching current filters.</ng-container>
} @else {
<ng-container i18n>No abuses found.</ng-container>
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.ts
index fcf1030d15..064c8472f0 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
@@ -7,7 +7,7 @@ import { logger } from '@root-helpers/logger'
import debug from 'debug'
import { switchMap } from 'rxjs'
import { ActorAvatarComponent } from '../shared-actor-image/actor-avatar.component'
-import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../shared-forms/advanced-input-filter.component'
+import { AdvancedFilterDef } 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'
@@ -19,7 +19,7 @@ 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 { DataLoaderOptions, TableColumnInfo, TableComponent } from '../shared-tables/table.component'
+import { 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'
@@ -29,12 +29,13 @@ import { ProcessedAbuse } from './processed-abuse.model'
const debugLogger = debug('peertube:moderation:AbuseListTableComponent')
+type DataLoaderParameter = Parameters<AbuseListTableComponent['_dataLoader']>[0]
+
@Component({
selector: 'my-abuse-list-table',
templateUrl: './abuse-list-table.component.html',
styleUrls: [ '../shared-moderation/moderation.scss', './abuse-list-table.component.scss' ],
imports: [
- AdvancedInputFilterComponent,
NgbTooltip,
ActionDropdownComponent,
ActorAvatarComponent,
@@ -62,37 +63,59 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
readonly viewType = input<'admin' | 'user'>(undefined)
- readonly table = viewChild<TableComponent<ProcessedAbuse>>('table')
+ readonly table = viewChild<TableComponent<ProcessedAbuse, DataLoaderParameter>>('table')
readonly abuseMessagesModal = viewChild<AbuseMessageModalComponent>('abuseMessagesModal')
readonly moderationCommentModal = viewChild<ModerationCommentModalComponent>('moderationCommentModal')
abuseActions: DropdownAction<ProcessedAbuse>[][] = []
- inputFilters: AdvancedInputFilter[] = [
+ inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = [
{
- title: $localize`Advanced filters`,
- children: [
- {
- value: 'state:pending',
- label: $localize`Unsolved reports`
- },
- {
- value: 'state:accepted',
- label: $localize`Accepted reports`
- },
- {
- value: 'state:rejected',
- label: $localize`Refused reports`
- },
- {
- value: 'videoIs:blacklisted',
- label: $localize`Reports with blocked videos`
- },
- {
- value: 'videoIs:deleted',
- label: $localize`Reports with deleted videos`
- }
+ type: 'options',
+ key: 'state',
+ title: $localize`Report state`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: AbuseState.PENDING, label: $localize`Unsolved reports` },
+ { value: AbuseState.ACCEPTED, label: $localize`Accepted reports` },
+ { value: AbuseState.REJECTED, label: $localize`Refused reports` }
]
+ },
+ {
+ type: 'options',
+ key: 'videoIs',
+ title: $localize`Video status`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: 'blacklisted', label: $localize`With blocked videos` },
+ { value: 'deleted', label: $localize`With deleted videos` }
+ ]
+ },
+ {
+ type: 'select',
+ title: $localize`Predefined reason`,
+ key: 'predefinedReason',
+ items: this.abuseService.getPredefinedReasons('all')
+ .map(reason => ({ id: reason.id, label: reason.label }))
+ },
+ {
+ type: 'text',
+ key: 'searchReporter',
+ title: $localize`Reporter`,
+ placeholder: $localize`Search by reporter name...`
+ },
+ {
+ type: 'text',
+ key: 'searchReportee',
+ title: $localize`Reportee`,
+ placeholder: $localize`Search by reportee name...`
+ },
+ {
+ type: 'text',
+ constraint: 'numeric',
+ key: 'id',
+ title: $localize`Report ID`,
+ placeholder: $localize`Search by report ID...`
}
]
@@ -239,12 +262,12 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
)
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: Parameters<AbuseService['listAdminAbuses']>[0]) {
debugLogger('Loading data.')
const observable = this.viewType() === 'admin'
- ? this.abuseService.getAdminAbuses(options)
- : this.abuseService.getUserAbuses(options)
+ ? this.abuseService.listAdminAbuses(options)
+ : this.abuseService.listUserAbuses(options)
return observable.pipe(switchMap(async (resultList: ResultList<ProcessedAbuse>) => {
const abuses: ProcessedAbuse[] = []
diff --git a/client/src/app/shared/shared-forms/advanced-input-filter.component.html b/client/src/app/shared/shared-forms/advanced-input-filter.component.html
index bb06084eec..fa16113323 100644
--- a/client/src/app/shared/shared-forms/advanced-input-filter.component.html
+++ b/client/src/app/shared/shared-forms/advanced-input-filter.component.html
@@ -1,39 +1,128 @@
-<div class="input-group has-clear flex-nowrap" [ngClass]="{ 'has-icon': icon() }" ngbDropdown placement="bottom-left auto" container="body">
+@if (hasFilters()) {
+ <div ngbDropdown placement="bottom-start auto" container="body" (openChange)="$event && onDropdownOpen()" #dropdown="ngbDropdown" [autoClose]="false">
- @if (hasFilters()) {
- <button class="input-group-text c-hand" title="Open quick filters" i18n-title ngbDropdownToggle>
+ <button class="peertube-button secondary-button filter-toggle" ngbDropdownToggle type="button" title="Open filters" i18n-title>
+ <my-global-icon iconName="filter" aria-hidden="true"></my-global-icon>
+
+ <span i18n>Filters</span>
+
+ @if (activeCount() > 0) {
+ <span class="active-counter ms-2">{{ activeCount() }}</span>
+ }
</button>
- <div role="menu" ngbDropdownMenu>
- @for (group of filters(); track group) {
- <div class="dropdown-header">{{ group.title }}</div>
+ <div ngbDropdownMenu class="filter-panel p-0">
+ <div class="filter-header d-flex align-items-center justify-content-between">
+ <span class="filter-header-title" i18n>Filters</span>
+
+ <my-button
+ rounded="true"
+ theme="tertiary"
+ icon="cross"
+ (click)="dropdown.close()"
+ i18n-title
+ title="Close filters"
+ ></my-button>
+ </div>
+
+ <div class="filter-panel-body px-3">
+ @for (def of filters(); track def) {
+
+ @if (def.type === 'title') {
+ <div class="filter-title">{{ def.title }}</div>
+ } @else if (def.type === 'options') {
+ @let key = def.key.toString();
+
+ <div>
+ <div class="filter-title">{{ def.title }}</div>
+
+ <div class="filter-options">
+ @for (option of def.options; track option.value) {
+ <div class="peertube-radio-container small">
+ <input
+ type="radio"
+ [name]="'filter-options-' + key"
+ [id]="'filter-option-' + key + '-' + $index"
+ [checked]="isOptionSelected(def, option.value)"
+ (click)="onOptionInputClick($event, def, option.value)"
+ >
+ <label class="radio" [for]="'filter-option-' + key + '-' + $index">{{ option.label }}</label>
+ </div>
+ }
+ </div>
+ </div>
+ } @else if (def.type === 'checkbox') {
+ @let key = def.key.toString();
+
+ <div class="mb-2">
+ <my-peertube-checkbox
+ [inputName]="key"
+ [labelText]="def.label"
+ [checked]="getCheckboxValue(key)"
+ (checkedChange)="setCheckboxValue(key, $event)"
+ small="true"
+ ></my-peertube-checkbox>
+ </div>
+ } @else if (def.type === 'select') {
+ @let key = def.key.toString();
+
+ <div class="mb-2">
+ <label class="filter-title" [for]="'filter-select-' + key">{{ def.title }}</label>
+
+ <my-select-options
+ (mousedown)="$event.stopPropagation(); $event.stopImmediatePropagation(); $event.preventDefault()"
+ (mouseup)="$event.stopPropagation(); $event.stopImmediatePropagation(); $event.preventDefault()"
+ (click)="$event.stopPropagation(); $event.stopImmediatePropagation(); $event.preventDefault()"
+ [inputId]="'filter-select-' + key"
+ [items]="def.items"
+ [clearable]="def.clearable ?? true"
+ [ngModel]="getSelectValue(key)"
+ (ngModelChange)="setSelectValue(key, $event)"
+ small="true"
+ appendTo="body"
+ ></my-select-options>
+ </div>
+ } @else if (def.type === 'tags') {
+ @let key = def.key.toString();
+
+ <div class="mb-2">
+ <label class="filter-title" [for]="'filter-tags-' + key">{{ def.title }}</label>
+
+ <my-select-tags
+ [inputId]="'filter-tags-' + key"
+ [selectedItems]="getTagsValue(key)"
+ (selectedItemsChange)="setTagsValue(key, $event)"
+ small="true"
+ ></my-select-tags>
+ </div>
+ } @else if (def.type === 'text') {
+ @let key = def.key.toString();
+
+ <div class="mb-2">
+ <label class="filter-title" [for]="'filter-text-' + key">{{ def.title }}</label>
+
+ <input
+ [id]="'filter-text-' + key"
+ type="text"
+ class="form-control pt-input-text"
+ [placeholder]="def.placeholder || ''"
+ [ngModel]="getTextValue(key)"
+ (ngModelChange)="setTextValue(key, $event)"
+ [attr.inputmode]="def.constraint === 'numeric' ? 'numeric' : 'text'"
+ >
+ </div>
+ }
- @for (filter of group.children; track filter) {
- <button (click)="onFilterClick(filter)" class="dropdown-item">
- <my-global-icon [ngClass]="{ 'no-visible': !isFilterEnabled(filter) }" iconName="tick"></my-global-icon>
- {{ filter.label }}
- </button>
}
- }
+ </div>
+
+ <div class="filter-footer d-flex justify-content-between gap-1 p-3">
+ <my-button type="button" theme="secondary" small="true" (click)="resetFilters(dropdown)" i18n>Reset</my-button>
+
+ <my-button type="button" theme="primary" small="true" (click)="applyFilters(dropdown)" i18n>Apply</my-button>
+ </div>
</div>
- }
- @if (icon()) {
- <button class="button-unstyle search-button" title="Search" i18n-title (click)="onSearchClick()">
- <my-global-icon iconName="search"></my-global-icon>
- </button>
- }
-
- <input
- type="text" [name]="inputId()" [id]="inputId()" [placeholder]="placeholder()"
- class="last-in-group"
- [ngClass]="{ 'first-in-group': !hasFilters() }"
- [(ngModel)]="searchValue"
- (keyup)="onInputSearch($event)"
- #input
- >
-
- <button class="p-0 border-0 form-control-clear" title="Clear filter" i18n-title (click)="onResetTableFilter(); input.focus()">
- <my-global-icon iconName="cross" ></my-global-icon>
- </button>
-</div>
+ </div>
+}
+
diff --git a/client/src/app/shared/shared-forms/advanced-input-filter.component.scss b/client/src/app/shared/shared-forms/advanced-input-filter.component.scss
index a4541aa6e5..f71a276bd5 100644
--- a/client/src/app/shared/shared-forms/advanced-input-filter.component.scss
+++ b/client/src/app/shared/shared-forms/advanced-input-filter.component.scss
@@ -1,68 +1,108 @@
-@use '_variables' as *;
-@use '_mixins' as *;
-@use '_form-mixins' as *;
+@use "sass:math";
+@use "_variables" as *;
+@use "_button-mixins" as *;
+@use "_mixins" as *;
-.input-group {
- width: fit-content;
-}
+// ---------------------------------------------------------------------------
+// Toggle button
+// ---------------------------------------------------------------------------
-.dropdown-item {
- font-size: 14px;
-}
+.filter-toggle {
+ my-global-icon {
+ @include global-icon-size(20px);
+ }
-input {
- @include peertube-input-text(250px);
-}
+ .active-counter {
+ background-color: var(--primary);
+ color: var(--on-primary);
+ font-weight: $font-bold;
+ font-size: 11px;
+ border-radius: 100%;
+ padding: 2px 6px;
+ position: relative;
+ top: -1px;
+ }
-.has-icon input {
- padding-inline-start: 46px;
+ &::after {
+ display: none;
+ }
}
-.search-button {
- position: absolute;
- top: 0;
- bottom: 0;
- left: 20px;
- color: pvar(--fg-200);
+// ---------------------------------------------------------------------------
+// Dropdown panel
+// ---------------------------------------------------------------------------
- my-global-icon {
- @include global-icon-size(19px);
- }
+.filter-panel {
+ min-width: 280px;
+ max-width: 360px;
+ border: 1px solid pvar(--input-border-color);
+ border-radius: pvar(--input-border-radius);
}
-.input-group-text {
- background-color: transparent;
- transition: 0.3s ease-out;
+.filter-header {
+ border-bottom: 1px solid pvar(--input-border-color);
+ background-color: pvar(--bg-secondary-350);
- &:hover {
- background-color: pvar(--input-bg);
- }
+ padding-top: 0.25rem;
+ padding-bottom: 0.25rem;
+
+ @include padding-left(1rem);
+
+ // Align button with form controls
+ @include padding-right(6px);
}
-.form-control-clear my-global-icon {
- @include global-icon-size(19px);
+.filter-header-title {
+ font-size: 1rem;
+ font-weight: $font-bold;
+ text-transform: uppercase;
+ color: pvar(--fg-300);
}
-div[role=menu] my-global-icon {
- $size: 19px;
- $margin: 2px;
+.filter-panel-body {
+ max-height: 60vh;
+ overflow: auto;
+}
- opacity: 1;
+// ---------------------------------------------------------------------------
+// Filter groups
+// ---------------------------------------------------------------------------
+
+.filter-title {
+ display: block;
+ font-size: 12px;
+ font-weight: $font-bold;
+ text-transform: uppercase;
+ color: pvar(--fg-300);
+ margin-bottom: 0.5rem;
+ margin-top: 0.75rem;
+}
- @include global-icon-size($size);
- @include margin-right($margin);
+// ---------------------------------------------------------------------------
+// Option inputs
+// ---------------------------------------------------------------------------
- &.no-visible {
- width: 0;
- height: 0;
+.filter-options {
+ display: flex;
+ flex-direction: column;
+}
- @include margin-right($size + $margin);
- }
+my-peertube-checkbox {
+ margin-bottom: 0.5rem;
}
+.pt-input-text {
+ padding: pvar(--input-y-padding) calc(#{pvar(--input-x-padding)} / 2);
+ @include font-size(14px);
+}
-div[role=menu] {
- max-height: 50vh;
- overflow: auto;
+// ---------------------------------------------------------------------------
+// Footer
+// ---------------------------------------------------------------------------
+
+.filter-footer {
+ border-top: 1px solid pvar(--input-border-color);
+ background-color: pvar(--bg);
+ margin-top: 0.5rem;
}
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.ts
index 3859a5c44e..5c02ba7cac 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
@@ -1,196 +1,305 @@
-import { NgClass } from '@angular/common'
-import { AfterViewInit, Component, OnInit, booleanAttribute, inject, input, output } from '@angular/core'
+import { Component, OnDestroy, OnInit, computed, inject, input, output, signal } from '@angular/core'
import { FormsModule } from '@angular/forms'
-import { ActivatedRoute, Router } from '@angular/router'
-import { RestService } from '@app/core'
+import { ActivatedRoute } from '@angular/router'
import { NgbDropdown, NgbDropdownMenu, NgbDropdownToggle } from '@ng-bootstrap/ng-bootstrap'
-import debug from 'debug'
-import { Subject } from 'rxjs'
-import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
+import { Subscription } from 'rxjs'
+import { SelectOptionsItem } from '../../../types/select-options-item.model'
import { GlobalIconComponent } from '../shared-icons/global-icon.component'
+import { ButtonComponent } from '../shared-main/buttons/button.component'
+import { PeertubeCheckboxComponent } from './peertube-checkbox.component'
+import { SelectOptionsComponent } from './select/select-options.component'
+import { SelectTagsComponent } from './select/select-tags.component'
-export type AdvancedInputFilter = {
- title: string
+// ---------------------------------------------------------------------------
+// Public types
+// ---------------------------------------------------------------------------
- children: AdvancedInputFilterChild[]
+export type TitleFilterDef = {
+ type: 'title'
+ title: string
}
-export type AdvancedInputFilterChild = {
+export type OptionsFilterDef<ServiceParameters extends Record<string, any>> = {
+ [Key in Extract<keyof ServiceParameters, string>]-?: {
+ type: 'options'
+ key: Key
+ title: string
+ options: { label: string, value: ServiceParameters[Key] | 'all', default?: true }[]
+ }
+}[Extract<keyof ServiceParameters, string>]
+
+export type CheckboxFilterDef<ServiceParameters extends Record<string, any>> = {
+ type: 'checkbox'
+ key: Extract<keyof ServiceParameters, string>
label: string
- value: string
}
-const debugLogger = debug('peertube:AdvancedInputFilterComponent')
+export type SelectFilterDef<ServiceParameters extends Record<string, any>> = {
+ [Key in Extract<keyof ServiceParameters, string>]-?: {
+ type: 'select'
+ key: Key
+ title: string
+ items: SelectOptionsItem<ServiceParameters[Key]>[]
+ clearable?: boolean
+ }
+}[Extract<keyof ServiceParameters, string>]
+
+export type TagsFilterDef<ServiceParameters extends Record<string, any>> = {
+ [Key in Extract<keyof ServiceParameters, string>]-?: {
+ type: 'tags'
+ key: Key
+ title: string
+ }
+}[Extract<keyof ServiceParameters, string>]
+
+export type TextFilterDef<ServiceParameters extends Record<string, any>> = {
+ [Key in Extract<keyof ServiceParameters, string>]-?: {
+ type: 'text'
+ key: Key
+ title: string
+ constraint?: 'numeric'
+ placeholder?: string
+ }
+}[Extract<keyof ServiceParameters, string>]
+
+export type AdvancedFilterDef<ServiceParameters extends Record<string, any> = any> =
+ | TitleFilterDef
+ | OptionsFilterDef<ServiceParameters>
+ | SelectFilterDef<ServiceParameters>
+ | CheckboxFilterDef<ServiceParameters>
+ | TagsFilterDef<ServiceParameters>
+ | TextFilterDef<ServiceParameters>
+
+export function parseQueryParamsToAdvancedFilters<ServiceParameters extends Record<string, any>> (
+ inputFilters: AdvancedFilterDef<ServiceParameters>[],
+ queryParams: Record<string, any>,
+ defaultValues: Partial<ServiceParameters> = {}
+) {
+ const result: Record<string, any> = {}
+
+ for (const def of inputFilters) {
+ if (def.type === 'title') continue
+
+ const key = def.key
+ const raw = queryParams[key]
+
+ if (raw === undefined) {
+ if (defaultValues[key] !== undefined) {
+ result[key] = defaultValues[key]
+ continue
+ }
+
+ if (def.type === 'options') {
+ if (def.options.some(o => o.value === 'all')) {
+ result[key] = 'all'
+ continue
+ }
+ }
+
+ result[key] = undefined
+ } else if (def.type === 'checkbox') {
+ result[key] = raw === 'true'
+ } else if (def.type === 'tags') {
+ // Handle tags as comma-separated values or array
+ result[key] = Array.isArray(raw) ? raw : (raw ? raw.split(',').map((v: string) => v.trim()) : [])
+ } else if (def.type === 'text') {
+ result[key] = raw
+ } else if (raw === 'true') {
+ result[key] = true
+ } else if (raw === 'false') {
+ result[key] = false
+ } else if (!isNaN(+raw)) {
+ result[key] = +raw
+ } else {
+ result[key] = raw
+ }
+ }
+
+ return result as Partial<ServiceParameters>
+}
+
+// ---------------------------------------------------------------------------
@Component({
selector: 'my-advanced-input-filter',
templateUrl: './advanced-input-filter.component.html',
styleUrls: [ './advanced-input-filter.component.scss' ],
- imports: [ NgbDropdown, NgbDropdownToggle, NgbDropdownMenu, GlobalIconComponent, NgClass, FormsModule ]
+ imports: [
+ NgbDropdown,
+ NgbDropdownToggle,
+ NgbDropdownMenu,
+ GlobalIconComponent,
+ FormsModule,
+ PeertubeCheckboxComponent,
+ SelectOptionsComponent,
+ SelectTagsComponent,
+ ButtonComponent
+ ]
})
-export class AdvancedInputFilterComponent implements OnInit, AfterViewInit {
+export class AdvancedInputFilterComponent<ServiceParameters extends Record<string, any>> implements OnInit, OnDestroy {
private route = inject(ActivatedRoute)
- private restService = inject(RestService)
- private router = inject(Router)
- readonly filters = input<AdvancedInputFilter[]>([])
- readonly emitOnInit = input(false, { transform: booleanAttribute })
- readonly icon = input(false, { transform: booleanAttribute })
- readonly placeholder = input($localize`Filter...`)
- readonly inputId = input('table-filter')
+ readonly filters = input<AdvancedFilterDef<ServiceParameters>[]>([])
+ readonly defaultValues = input<Partial<ServiceParameters>>()
+
+ readonly filtersChange = output<Partial<ServiceParameters>>()
+
+ /** Draft state while the dropdown is open – not yet applied. */
+ readonly filterState = signal<Partial<ServiceParameters>>({})
+
+ /** Committed/applied state that drives URL params and output emissions. */
+ readonly activeFilters = signal<Partial<ServiceParameters>>({})
- // eslint-disable-next-line @angular-eslint/no-output-native
- readonly search = output<string>()
+ /** Number of active (non-empty) filters for the badge. */
+ readonly activeCount = computed(() => {
+ const active = this.activeFilters()
- searchValue: string
+ return Object.keys(active).filter(k => {
+ const value = active[k]
+ const filter = this.filters().find(f => 'key' in f && f.key === k)
- private enabledFilters = new Set<string>()
+ if (value === undefined || value === 'all') return false
- private searchStream: Subject<string>
+ if (filter?.type === 'checkbox' && value === false) return false
- private viewInitialized = false
- private emitSearchAfterViewInit = false
+ return true
+ }).length
+ })
+
+ readonly hasFilters = computed(() => this.filters().length > 0)
+
+ private routeSub: Subscription
+
+ // ---------------------------------------------------------------------------
+ // Lifecycle
+ // ---------------------------------------------------------------------------
ngOnInit () {
- this.initSearchStream()
- this.listenToRouteSearchChange()
- }
+ this.routeSub = this.route.queryParams.subscribe(params => {
+ const initial = parseQueryParamsToAdvancedFilters(this.filters(), params, this.defaultValues())
- ngAfterViewInit () {
- this.viewInitialized = true
+ this.filterState.set({ ...initial })
+ this.activeFilters.set({ ...initial })
+ })
+ }
- // Init after view init to not send an event too early
- if (this.emitOnInit() && this.emitSearchAfterViewInit) this.emitSearch()
+ ngOnDestroy () {
+ this.routeSub?.unsubscribe()
}
- onInputSearch (event: Event) {
- this.scheduleSearchUpdate((event.target as HTMLInputElement).value)
+ // ---------------------------------------------------------------------------
+ // Template helpers – options filters
+ // ---------------------------------------------------------------------------
+
+ isOptionSelected (def: OptionsFilterDef<ServiceParameters>, optionValue: string): boolean {
+ return this.filterState()[def.key] === optionValue
}
- onSearchClick () {
- this.scheduleSearchUpdate(this.searchValue)
+ onOptionClick (def: OptionsFilterDef<ServiceParameters>, optionValue: string) {
+ const current = this.filterState()[def.key]
+
+ // Toggle off if already selected
+ const next = current === optionValue ? undefined : optionValue
+ this.filterState.update(s => ({ ...s, [def.key]: next }))
}
- onResetTableFilter () {
- this.immediateSearchUpdate('')
+ onOptionInputClick (event: MouseEvent, def: OptionsFilterDef<ServiceParameters>, optionValue: string) {
+ event.preventDefault()
+ this.onOptionClick(def, optionValue)
}
- hasFilters () {
- const filters = this.filters()
- return filters && filters.length !== 0
+ // ---------------------------------------------------------------------------
+ // Template helpers – checkbox filters
+ // ---------------------------------------------------------------------------
+
+ getCheckboxValue (key: string): boolean {
+ return this.filterState()[key] === true
}
- isFilterEnabled (filter: AdvancedInputFilterChild) {
- return this.enabledFilters.has(filter.value)
+ setCheckboxValue (key: string, value: boolean) {
+ this.filterState.update(s => ({ ...s, [key]: value || undefined }))
}
- onFilterClick (filter: AdvancedInputFilterChild) {
- const newSearch = this.isFilterEnabled(filter)
- ? this.removeFilterToSearch(this.searchValue, filter)
- : this.addFilterToSearch(this.searchValue, filter)
+ // ---------------------------------------------------------------------------
+ // Template helpers – select filters
+ // ---------------------------------------------------------------------------
- this.setQueryParams(newSearch)
+ getSelectValue (key: string): string | undefined {
+ const v = this.filterState()[key]
+ return v !== undefined ? String(v) : undefined
}
- private scheduleSearchUpdate (value: string) {
- this.searchValue = value
- this.searchStream.next(this.searchValue)
+ setSelectValue (key: string, value: string | undefined) {
+ this.filterState.update(s => ({ ...s, [key]: value || undefined }))
}
- private immediateSearchUpdate (value: string) {
- this.searchValue = value
+ // ---------------------------------------------------------------------------
+ // Template helpers – tags filters
+ // ---------------------------------------------------------------------------
- this.setQueryParams(this.searchValue)
- this.parseFilters(this.searchValue)
- this.emitSearch()
+ getTagsValue (key: string): string[] {
+ return this.filterState()[key]
}
- private listenToRouteSearchChange () {
- this.route.queryParams
- .subscribe(params => {
- const search = params.search || ''
-
- debugLogger('On route search change "%s".', search)
+ setTagsValue (key: string, value: string[]) {
+ this.filterState.update(s => ({ ...s, [key]: value?.length > 0 ? value : undefined }))
+ }
- if (this.searchValue === search) return
+ // ---------------------------------------------------------------------------
+ // Template helpers – text filters
+ // ---------------------------------------------------------------------------
- this.searchValue = search
+ getTextValue (key: string): string {
+ const value = this.filterState()[key]
+ const filterDef = this.filters().find(f => f.type === 'text' && f.key === key) as TextFilterDef<ServiceParameters>
- this.parseFilters(this.searchValue)
+ if (filterDef.constraint === 'numeric' && isNaN(+value)) return ''
- this.emitSearch()
- })
+ return value !== undefined ? String(value) : ''
}
- private initSearchStream () {
- this.searchStream = new Subject()
+ setTextValue (key: string, value: string) {
+ let trimmedValue: number | string = value.trim()
- this.searchStream
- .pipe(
- debounceTime(300),
- distinctUntilChanged()
- )
- .subscribe(() => {
- this.setQueryParams(this.searchValue)
- this.parseFilters(this.searchValue)
+ const filterDef = this.filters().find(f => f.type === 'text' && f.key === key) as TextFilterDef<ServiceParameters>
- this.emitSearch()
- })
- }
+ if (filterDef.constraint === 'numeric') {
+ trimmedValue = +trimmedValue
- private emitSearch () {
- if (!this.viewInitialized) {
- this.emitSearchAfterViewInit = true
- return
+ if (isNaN(trimmedValue)) trimmedValue = ''
}
- debugLogger('On search "%s".', this.searchValue)
-
- this.search.emit(this.searchValue)
+ this.filterState.update(s => ({ ...s, [key]: trimmedValue || undefined }))
}
- private setQueryParams (search: string) {
- const searchParams = search
- ? { search: search.trim() }
- : { search: undefined }
+ // ---------------------------------------------------------------------------
- this.router.navigate([ '.' ], { relativeTo: this.route, queryParams: { ...this.route.snapshot.queryParams, ...searchParams } })
- }
+ applyFilters (dropdown: NgbDropdown) {
+ this.activeFilters.set({ ...this.filterState() })
+ this.emitOutputs()
- private removeFilterToSearch (search: string, removedFilter: AdvancedInputFilterChild) {
- return search.replace(removedFilter.value, '')
+ dropdown.close()
}
- private addFilterToSearch (search: string, newFilter: AdvancedInputFilterChild) {
- const filterTokens = this.restService.tokenizeString(newFilter.value)
+ resetFilters (dropdown: NgbDropdown) {
+ const empty: Partial<ServiceParameters> = parseQueryParamsToAdvancedFilters(this.filters(), {}, this.defaultValues())
- const tokensToAdd: string[] = []
- let searchTokens = this.restService.tokenizeString(search)
+ this.filterState.set(empty)
+ this.activeFilters.set(empty)
- for (const filterToken of filterTokens) {
- const prefix = filterToken.split(':').shift()
-
- // Tokenize search and remove a potential existing filter
- searchTokens = searchTokens.filter(t => !t.startsWith(prefix))
- tokensToAdd.push(filterToken)
- }
+ this.emitOutputs()
- return searchTokens.concat(tokensToAdd).join(' ')
+ dropdown.close()
}
- private parseFilters (search: string) {
- const searchTokens = this.restService.tokenizeString(search)
-
- this.enabledFilters = new Set()
+ onDropdownOpen () {
+ // Sync draft state with committed state when dropdown is re-opened
+ this.filterState.set({ ...this.activeFilters() })
+ }
- for (const group of this.filters()) {
- for (const filter of group.children) {
- const filterTokens = this.restService.tokenizeString(filter.value)
+ private emitOutputs () {
+ const active = this.activeFilters()
- if (filterTokens.every(filterToken => searchTokens.includes(filterToken))) {
- this.enabledFilters.add(filter.value)
- }
- }
- }
+ this.filtersChange.emit(active)
}
}
diff --git a/client/src/app/shared/shared-forms/peertube-checkbox.component.html b/client/src/app/shared/shared-forms/peertube-checkbox.component.html
index 8427fce34f..dd8f27d31c 100644
--- a/client/src/app/shared/shared-forms/peertube-checkbox.component.html
+++ b/client/src/app/shared/shared-forms/peertube-checkbox.component.html
@@ -1,4 +1,4 @@
-<div class="root flex-column">
+<div class="root flex-column" [class.small]="small()">
<div class="d-flex align-items-center">
<label>
<input
diff --git a/client/src/app/shared/shared-forms/peertube-checkbox.component.scss b/client/src/app/shared/shared-forms/peertube-checkbox.component.scss
index f53cdf2509..2c8a149248 100644
--- a/client/src/app/shared/shared-forms/peertube-checkbox.component.scss
+++ b/client/src/app/shared/shared-forms/peertube-checkbox.component.scss
@@ -3,15 +3,93 @@
@use "form-mixins" as *;
.root {
+ --pt-checkbox-scale: 1;
+
display: flex;
+ &.small {
+ --pt-checkbox-scale: 0.875;
+ }
+
label {
display: flex;
align-items: center;
- font-size: $form-input-font-size;
+ font-size: calc(#{$form-input-font-size} * var(--pt-checkbox-scale));
+ position: relative;
input {
- @include peertube-checkbox;
+ $border-width: 2px;
+
+ opacity: 0;
+ position: absolute;
+
+ &:focus + span {
+ box-shadow: $focus-box-shadow-form;
+ }
+
+ // Checkbox
+ + span {
+ position: relative;
+ width: calc(20px * var(--pt-checkbox-scale));
+ min-width: calc(20px * var(--pt-checkbox-scale));
+ height: calc(20px * var(--pt-checkbox-scale));
+ border: $border-width solid pvar(--fg-400);
+ border-radius: 2px;
+ vertical-align: middle;
+ cursor: pointer;
+
+ &::after {
+ content: "";
+ position: absolute;
+ top: calc(4px * var(--pt-checkbox-scale));
+ left: calc(6px * var(--pt-checkbox-scale));
+ width: calc(5px * var(--pt-checkbox-scale));
+ height: calc(7px * var(--pt-checkbox-scale));
+ opacity: 0;
+ transform: rotate(45deg) scale(0);
+ border-right: 2px solid pvar(--input-check-active-fg);
+ border-bottom: 2px solid pvar(--input-check-active-fg);
+ }
+ }
+
+ // Checkbox checked
+ &:checked + span {
+ background: pvar(--input-check-active-bg);
+ animation: jelly 0.6s ease;
+
+ &::before {
+ content: "";
+ width: 100%;
+ height: 100%;
+ background: pvar(--input-check-active-bg);
+ position: absolute;
+ left: 0;
+ transition: all 0.2s ease;
+ border: 2px solid pvar(--input-check-active-fg);
+ border-radius: 2px;
+ }
+
+ &::after {
+ opacity: 1;
+ transform: rotate(45deg) scale(1);
+ }
+ }
+
+ // Label
+ + span + span {
+ font-weight: $font-regular;
+ cursor: pointer;
+ display: inline;
+ color: pvar(--fg-350);
+
+ @include margin-left(calc(8px * var(--pt-checkbox-scale)));
+ }
+
+ &[disabled] + span,
+ &[disabled] + span + span {
+ opacity: 0.5;
+ cursor: default;
+ }
}
}
diff --git a/client/src/app/shared/shared-forms/peertube-checkbox.component.ts b/client/src/app/shared/shared-forms/peertube-checkbox.component.ts
index a7deb60873..1b921a500e 100644
--- a/client/src/app/shared/shared-forms/peertube-checkbox.component.ts
+++ b/client/src/app/shared/shared-forms/peertube-checkbox.component.ts
@@ -1,5 +1,5 @@
import { NgTemplateOutlet } from '@angular/common'
-import { AfterContentInit, Component, contentChildren, forwardRef, input, model, TemplateRef } from '@angular/core'
+import { AfterContentInit, booleanAttribute, Component, contentChildren, forwardRef, input, model, TemplateRef } from '@angular/core'
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'
import { HelpComponent } from '../shared-main/buttons/help.component'
import { PeerTubeTemplateDirective } from '../shared-main/common/peertube-template.directive'
@@ -23,7 +23,8 @@ export class PeertubeCheckboxComponent implements ControlValueAccessor, AfterCon
readonly labelText = input<string>(undefined)
readonly labelInnerHTML = input<string>(undefined)
readonly helpPlacement = input('top auto')
- readonly recommended = input(false)
+ readonly recommended = input(false, { transform: booleanAttribute })
+ readonly small = input(false, { transform: booleanAttribute })
disabled = false
describedby: string
diff --git a/client/src/app/shared/shared-forms/search-input.component.html b/client/src/app/shared/shared-forms/search-input.component.html
new file mode 100644
index 0000000000..7a5edf20a2
--- /dev/null
+++ b/client/src/app/shared/shared-forms/search-input.component.html
@@ -0,0 +1,24 @@
+<div class="input-group has-clear flex-nowrap" [ngClass]="{ 'has-icon': icon() }">
+
+ @if (icon()) {
+ <button class="button-unstyle search-button" title="Search" i18n-title type="button" (click)="onSearchClick()">
+ <my-global-icon iconName="search"></my-global-icon>
+ </button>
+ }
+
+ <input
+ type="text"
+ [name]="inputId()"
+ [id]="inputId()"
+ [placeholder]="placeholder()"
+ class="last-in-group first-in-group"
+ [(ngModel)]="searchValue"
+ (keyup)="onInputSearch($event)"
+ #input
+ >
+
+ <button class="p-0 border-0 form-control-clear" title="Clear" i18n-title type="button" (click)="onClear(); input.focus()">
+ <my-global-icon iconName="cross"></my-global-icon>
+ </button>
+
+</div>
diff --git a/client/src/app/shared/shared-forms/search-input.component.scss b/client/src/app/shared/shared-forms/search-input.component.scss
new file mode 100644
index 0000000000..e585c03cd4
--- /dev/null
+++ b/client/src/app/shared/shared-forms/search-input.component.scss
@@ -0,0 +1,31 @@
+@use "_variables" as *;
+@use "_mixins" as *;
+@use "_form-mixins" as *;
+
+.input-group {
+ width: fit-content;
+}
+
+input {
+ @include peertube-input-text(250px);
+}
+
+.has-icon input {
+ padding-inline-start: 46px;
+}
+
+.search-button {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ left: 20px;
+ color: pvar(--fg-200);
+
+ my-global-icon {
+ @include global-icon-size(19px);
+ }
+}
+
+.form-control-clear my-global-icon {
+ @include global-icon-size(19px);
+}
diff --git a/client/src/app/shared/shared-forms/search-input.component.ts b/client/src/app/shared/shared-forms/search-input.component.ts
new file mode 100644
index 0000000000..14f209c234
--- /dev/null
+++ b/client/src/app/shared/shared-forms/search-input.component.ts
@@ -0,0 +1,121 @@
+import { NgClass } from '@angular/common'
+import { AfterViewInit, Component, OnInit, booleanAttribute, inject, input, output } from '@angular/core'
+import { FormsModule } from '@angular/forms'
+import { ActivatedRoute, Router } from '@angular/router'
+import debug from 'debug'
+import { Subject } from 'rxjs'
+import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
+import { GlobalIconComponent } from '../shared-icons/global-icon.component'
+
+const debugLogger = debug('peertube:SearchInputComponent')
+
+/**
+ * Simple debounced text-search input with optional icon, clear button and `?search=` URL param sync.
+ */
+@Component({
+ selector: 'my-search-input',
+ templateUrl: './search-input.component.html',
+ styleUrls: [ './search-input.component.scss' ],
+ imports: [ NgClass, FormsModule, GlobalIconComponent ]
+})
+export class SearchInputComponent implements OnInit, AfterViewInit {
+ private route = inject(ActivatedRoute)
+ private router = inject(Router)
+
+ readonly placeholder = input($localize`Filter...`)
+ readonly inputId = input('search-input')
+ readonly icon = input(false, { transform: booleanAttribute })
+ readonly emitOnInit = input(false, { transform: booleanAttribute })
+
+ // eslint-disable-next-line @angular-eslint/no-output-native
+ readonly search = output<string>()
+
+ searchValue: string
+
+ private searchStream: Subject<string>
+ private viewInitialized = false
+ private emitSearchAfterViewInit = false
+
+ ngOnInit () {
+ this.initSearchStream()
+ this.listenToRouteSearchChange()
+ }
+
+ ngAfterViewInit () {
+ this.viewInitialized = true
+
+ if (this.emitOnInit() && this.emitSearchAfterViewInit) this.emitSearch()
+ }
+
+ onInputSearch (event: Event) {
+ this.scheduleSearchUpdate((event.target as HTMLInputElement).value)
+ }
+
+ onSearchClick () {
+ this.scheduleSearchUpdate(this.searchValue)
+ }
+
+ onClear () {
+ this.immediateSearchUpdate('')
+ }
+
+ private scheduleSearchUpdate (value: string) {
+ this.searchValue = value
+ this.searchStream.next(this.searchValue)
+ }
+
+ private immediateSearchUpdate (value: string) {
+ this.searchValue = value
+ this.setQueryParam(this.searchValue)
+ this.emitSearch()
+ }
+
+ private listenToRouteSearchChange () {
+ this.route.queryParams
+ .subscribe(params => {
+ const search = params['search'] || ''
+
+ debugLogger('On route search change "%s".', search)
+
+ if (this.searchValue === search) return
+
+ this.searchValue = search
+ this.emitSearch()
+ })
+ }
+
+ private initSearchStream () {
+ this.searchStream = new Subject()
+
+ this.searchStream
+ .pipe(
+ debounceTime(300),
+ distinctUntilChanged()
+ )
+ .subscribe(() => {
+ this.setQueryParam(this.searchValue)
+ this.emitSearch()
+ })
+ }
+
+ private emitSearch () {
+ if (!this.viewInitialized) {
+ this.emitSearchAfterViewInit = true
+ return
+ }
+
+ debugLogger('On search "%s".', this.searchValue)
+ this.search.emit(this.searchValue)
+ }
+
+ private setQueryParam (search: string) {
+ const searchParams = search
+ ? { search: search.trim() }
+ : { search: undefined }
+
+ this.router.navigate([ '.' ], {
+ relativeTo: this.route,
+ queryParams: { ...this.route.snapshot.queryParams, ...searchParams }
+ })
+ }
+}
diff --git a/client/src/app/shared/shared-forms/select/select-options.component.html b/client/src/app/shared/shared-forms/select/select-options.component.html
index 0fb9c6be22..665f9cb2df 100644
--- a/client/src/app/shared/shared-forms/select/select-options.component.html
+++ b/client/src/app/shared/shared-forms/select/select-options.component.html
@@ -21,6 +21,9 @@
[virtualScrollItemSize]="virtualScrollItemSize()"
fluid="true"
+ [appendTo]="appendTo()"
+
+ [class.small]="small()"
>
<ng-template #itemTemplate let-item let-description="description">
@if (selectOptionTemplate) {
@@ -36,7 +39,7 @@
<img alt="" class="me-2" [src]="item.imageUrl" />
}
- <span class="ellipsis" [ngClass]="item.classes">{{ item.label }}</span>
+ <span class="ellipsis" [ngClass]="item?.classes">{{ item?.label }}</span>
@if (itemExtraTemplate) {
<ng-template [ngTemplateOutlet]="itemExtraTemplate" [ngTemplateOutletContext]="{ $implicit: item }"></ng-template>
diff --git a/client/src/app/shared/shared-forms/select/select-options.component.ts b/client/src/app/shared/shared-forms/select/select-options.component.ts
index dd6f62761d..07518df906 100644
--- a/client/src/app/shared/shared-forms/select/select-options.component.ts
+++ b/client/src/app/shared/shared-forms/select/select-options.component.ts
@@ -39,6 +39,9 @@ export class SelectOptionsComponent implements ControlValueAccessor {
readonly clearable = input(false, { transform: booleanAttribute })
readonly filter = input(false, { transform: booleanAttribute })
+ readonly small = input(false, { transform: booleanAttribute })
+
+ readonly appendTo = input<'body'>()
readonly virtualScroll = input(false, { transform: booleanAttribute })
readonly virtualScrollItemSize = input(39, { transform: numberAttribute })
diff --git a/client/src/app/shared/shared-forms/select/select-tags.component.html b/client/src/app/shared/shared-forms/select/select-tags.component.html
index e1b1285884..d8e4cc9c00 100644
--- a/client/src/app/shared/shared-forms/select/select-tags.component.html
+++ b/client/src/app/shared/shared-forms/select/select-tags.component.html
@@ -6,4 +6,5 @@
[allowDuplicate]="false"
[caseSensitiveDuplication]="false"
[separator]="separator"
+ [class.small]="small()"
></p-chips>
diff --git a/client/src/app/shared/shared-forms/select/select-tags.component.ts b/client/src/app/shared/shared-forms/select/select-tags.component.ts
index bb9febaa47..7624b2eaaa 100644
--- a/client/src/app/shared/shared-forms/select/select-tags.component.ts
+++ b/client/src/app/shared/shared-forms/select/select-tags.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, forwardRef, input, model } from '@angular/core'
+import { Component, OnInit, booleanAttribute, forwardRef, input, model } from '@angular/core'
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'
import { isMobile } from '@root-helpers/web-browser'
import { ChipsModule } from 'primeng/chips'
@@ -17,7 +17,7 @@ import { ChipsModule } from 'primeng/chips'
})
export class SelectTagsComponent implements OnInit, ControlValueAccessor {
readonly inputId = input.required<string>()
- readonly availableItems = input<string[]>([])
+ readonly small = input(false, { transform: booleanAttribute })
readonly selectedItems = model<string[]>([])
readonly placeholder = model($localize`Enter a new tag`)
diff --git a/client/src/app/shared/shared-instance/instance-follow.service.ts b/client/src/app/shared/shared-instance/instance-follow.service.ts
index 5109f79dff..dbbf91289b 100644
--- a/client/src/app/shared/shared-instance/instance-follow.service.ts
+++ b/client/src/app/shared/shared-instance/instance-follow.service.ts
@@ -1,13 +1,13 @@
-import { SortMeta } from 'primeng/api'
-import { from, Observable } from 'rxjs'
-import { catchError, concatMap, 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 } from '@app/core'
import { arrayify } from '@peertube/peertube-core-utils'
import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@peertube/peertube-models'
+import { SortMeta } from 'primeng/api'
+import { from, Observable } from 'rxjs'
+import { catchError, concatMap, toArray } from 'rxjs/operators'
import { environment } from '../../../environments/environment'
-import { AdvancedInputFilter } from '../shared-forms/advanced-input-filter.component'
+import { AdvancedFilterDef } from '../shared-forms/advanced-input-filter.component'
@Injectable()
export class InstanceFollowService {
@@ -17,7 +17,7 @@ export class InstanceFollowService {
private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/server'
- getFollowing (options: {
+ listSubscriptions (options: {
pagination: RestPagination
sort?: SortMeta
search?: string
@@ -29,10 +29,7 @@ export class InstanceFollowService {
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
- if (search) {
- params = this.restService.addObjectParams(params, this.parseFollowsListFilters(search))
- }
-
+ if (search) params = params.append('search', search)
if (state) params = params.append('state', state)
if (actorType) params = params.append('actorType', actorType)
@@ -40,7 +37,7 @@ export class InstanceFollowService {
.pipe(catchError(res => this.restExtractor.handleError(res)))
}
- getFollowers (options: {
+ listFollowers (options: {
pagination: RestPagination
sort: SortMeta
search?: string
@@ -52,10 +49,7 @@ export class InstanceFollowService {
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
- if (search) {
- params = this.restService.addObjectParams(params, this.parseFollowsListFilters(search))
- }
-
+ if (search) params = params.append('search', search)
if (state) params = params.append('state', state)
if (actorType) params = params.append('actorType', actorType)
@@ -133,33 +127,21 @@ export class InstanceFollowService {
)
}
- buildFollowsListFilters (): AdvancedInputFilter[] {
+ // ---------------------------------------------------------------------------
+
+ buildFollowsListFilters (): AdvancedFilterDef<{ state: FollowState }>[] {
return [
{
- title: $localize`Advanced filters`,
- children: [
- {
- value: 'state:accepted',
- label: $localize`Accepted follows`
- },
- {
- value: 'state:rejected',
- label: $localize`Rejected follows`
- },
- {
- value: 'state:pending',
- label: $localize`Pending follows`
- }
+ type: 'options',
+ key: 'state',
+ title: $localize`Follow state`,
+ options: [
+ { value: 'all', label: $localize`All follows` },
+ { value: 'accepted', label: $localize`Accepted follows` },
+ { value: 'rejected', label: $localize`Rejected follows` },
+ { value: 'pending', label: $localize`Pending follows` }
]
}
]
}
-
- private parseFollowsListFilters (search: string) {
- return this.restService.parseQueryStringFilter(search, {
- state: {
- prefix: 'state:'
- }
- })
- }
}
diff --git a/client/src/app/shared/shared-main/common/peertube-badge.service.ts b/client/src/app/shared/shared-main/common/peertube-badge.service.ts
new file mode 100644
index 0000000000..a80d4a4984
--- /dev/null
+++ b/client/src/app/shared/shared-main/common/peertube-badge.service.ts
@@ -0,0 +1,41 @@
+import { Injectable } from '@angular/core'
+
+@Injectable()
+export class PeerTubeBadgeService {
+ // 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>()
+
+ 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)
+ }
+}
diff --git a/client/src/app/shared/shared-main/main-providers.ts b/client/src/app/shared/shared-main/main-providers.ts
index e5e4c9a654..95e61a8ac1 100644
--- a/client/src/app/shared/shared-main/main-providers.ts
+++ b/client/src/app/shared/shared-main/main-providers.ts
@@ -2,6 +2,7 @@ import { DatePipe } from '@angular/common'
import { AccountService } from './account/account.service'
import { VideoChannelSyncService } from './channel/video-channel-sync.service'
import { VideoChannelService } from './channel/video-channel.service'
+import { PeerTubeBadgeService } from './common/peertube-badge.service'
import { CustomPageService } from './custom-page/custom-page.service'
import { FromNowPipe } from './date/from-now.pipe'
import { AUTH_INTERCEPTOR_PROVIDER } from './http/auth-interceptor.service'
@@ -42,6 +43,7 @@ export function getMainProviders () {
ActorRedirectGuard,
InstanceService,
VideoChannelSyncService,
- HorizontalMenuService
+ HorizontalMenuService,
+ PeerTubeBadgeService
]
}
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.ts
index abd613b57d..4195f9864a 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
@@ -30,33 +30,17 @@ export class VideoImportService {
pagination: RestPagination
sort: SortMeta
includeCollaborations: boolean
+ id?: number
+ videoId?: number
+ videoChannelSyncId?: number
+ targetUrl?: string
search?: string
}): Observable<ResultList<VideoImport>> {
- const { pagination, sort, search, includeCollaborations } = options
+ const { pagination, sort, ...otherOptions } = options
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
-
- if (includeCollaborations) params = params.append('includeCollaborations', 'true')
-
- if (search) {
- const filters = this.restService.parseQueryStringFilter(search, {
- id: {
- prefix: 'id:'
- },
- videoId: {
- prefix: 'videoId:'
- },
- videoChannelSyncId: {
- prefix: 'videoChannelSyncId:'
- },
- targetUrl: {
- prefix: 'targetUrl:'
- }
- })
-
- params = this.restService.addObjectParams(params, filters)
- }
+ params = this.restService.addObjectParams(params, otherOptions)
return this.authHttp
.get<ResultList<VideoImport>>(UserService.BASE_USERS_URL + 'me/videos/imports', { params })
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts
index 7feced79d1..00c2e93af8 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -219,6 +219,7 @@ export class VideoService {
nsfw,
nsfwFlagsExcluded,
nsfwFlagsIncluded,
+ autoTagOneOf,
...otherOptions
} = options
@@ -233,6 +234,7 @@ export class VideoService {
if (Array.isArray(languageOneOf)) newParams = this.restService.addArrayParams(newParams, 'languageOneOf', languageOneOf)
if (Array.isArray(categoryOneOf)) newParams = this.restService.addArrayParams(newParams, 'categoryOneOf', categoryOneOf)
if (Array.isArray(privacyOneOf)) newParams = this.restService.addArrayParams(newParams, 'privacyOneOf', privacyOneOf)
+ if (Array.isArray(autoTagOneOf)) newParams = this.restService.addArrayParams(newParams, 'autoTagOneOf', autoTagOneOf)
if (search) newParams = newParams.set('search', search)
newParams = this.buildNSFWParams(newParams, { nsfw, nsfwFlagsExcluded, nsfwFlagsIncluded })
diff --git a/client/src/app/shared/shared-moderation/abuse.service.ts b/client/src/app/shared/shared-moderation/abuse.service.ts
index 4bc3499b26..b36d4be8f4 100644
--- a/client/src/app/shared/shared-moderation/abuse.service.ts
+++ b/client/src/app/shared/shared-moderation/abuse.service.ts
@@ -1,7 +1,3 @@
-import { omit } from 'lodash-es'
-import { SortMeta } from 'primeng/api'
-import { Observable } from 'rxjs'
-import { catchError } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable, inject } from '@angular/core'
import { RestExtractor, RestPagination, RestService } from '@app/core'
@@ -10,12 +6,16 @@ import {
AbuseFilter,
AbuseMessage,
AbusePredefinedReasonsString,
- AbuseState,
+ AbuseStateType,
AbuseUpdate,
AdminAbuse,
ResultList,
UserAbuse
} from '@peertube/peertube-models'
+import { omit } from 'lodash-es'
+import { SortMeta } from 'primeng/api'
+import { Observable } from 'rxjs'
+import { catchError } from 'rxjs/operators'
import { environment } from '../../../environments/environment'
@Injectable()
@@ -27,48 +27,55 @@ export class AbuseService {
private static BASE_ABUSE_URL = environment.apiUrl + '/api/v1/abuses'
private static BASE_MY_ABUSE_URL = environment.apiUrl + '/api/v1/users/me/abuses'
- getAdminAbuses (options: {
- pagination: RestPagination
- sort: SortMeta
- search?: string
- }): Observable<ResultList<AdminAbuse>> {
- const { pagination, sort, search } = options
+ listAdminAbuses (options: Parameters<AbuseService['buildCommonAbuseParams']>[0]): Observable<ResultList<AdminAbuse>> {
const url = AbuseService.BASE_ABUSE_URL
+ const params = this.buildCommonAbuseParams(options)
- let params = new HttpParams()
- params = this.restService.addRestGetParams(params, pagination, sort)
+ return this.authHttp.get<ResultList<AdminAbuse>>(url, { params })
+ .pipe(
+ catchError(res => this.restExtractor.handleError(res))
+ )
+ }
- if (search) {
- params = this.buildParamsFromSearch(search, params)
- }
+ listUserAbuses (options: Parameters<AbuseService['buildCommonAbuseParams']>[0]): Observable<ResultList<UserAbuse>> {
+ const url = AbuseService.BASE_MY_ABUSE_URL
+ const params = this.buildCommonAbuseParams(options)
- return this.authHttp.get<ResultList<AdminAbuse>>(url, { params })
+ return this.authHttp.get<ResultList<UserAbuse>>(url, { params })
.pipe(
catchError(res => this.restExtractor.handleError(res))
)
}
- getUserAbuses (options: {
+ private buildCommonAbuseParams (options: {
pagination: RestPagination
sort: SortMeta
+ videoIs?: 'deleted' | 'blacklisted'
+ state?: AbuseStateType
search?: string
- }): Observable<ResultList<UserAbuse>> {
- const { pagination, sort, search } = options
- const url = AbuseService.BASE_MY_ABUSE_URL
+ id?: number
+ searchReporter?: string
+ searchReportee?: string
+ predefinedReason?: AbusePredefinedReasonsString
+ }) {
+ const { pagination, sort, search, videoIs, state, id, searchReporter, searchReportee, predefinedReason } = options
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
- if (search) {
- params = this.buildParamsFromSearch(search, params)
- }
+ if (search) params = params.append('search', search)
+ if (videoIs) params = params.append('videoIs', videoIs)
+ if (state) params = params.append('state', state.toString())
+ if (options.id) params = params.append('id', id.toString())
+ if (searchReporter) params = params.append('searchReporter', searchReporter)
+ if (searchReportee) params = params.append('searchReportee', searchReportee)
+ if (predefinedReason) params = params.append('predefinedReason', predefinedReason)
- return this.authHttp.get<ResultList<UserAbuse>>(url, { params })
- .pipe(
- catchError(res => this.restExtractor.handleError(res))
- )
+ return params
}
+ // ---------------------------------------------------------------------------
+
reportVideo (parameters: AbuseCreate) {
const url = AbuseService.BASE_ABUSE_URL
@@ -115,7 +122,7 @@ export class AbuseService {
.pipe(catchError(res => this.restExtractor.handleError(res)))
}
- getPrefefinedReasons (type: AbuseFilter) {
+ getPredefinedReasons (type: AbuseFilter | 'all') {
let reasons: { id: AbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [
{
id: 'violentOrRepulsive',
@@ -155,7 +162,7 @@ export class AbuseService {
}
]
- if (type === 'video') {
+ if (type === 'video' || type === 'all') {
reasons = reasons.concat([
{
id: 'thumbnails',
@@ -172,34 +179,4 @@ export class AbuseService {
return reasons
}
-
- private buildParamsFromSearch (search: string, params: HttpParams) {
- const filters = this.restService.parseQueryStringFilter(search, {
- id: { prefix: '#' },
- state: {
- prefix: 'state:',
- handler: v => {
- if (v === 'accepted') return AbuseState.ACCEPTED
- if (v === 'pending') return AbuseState.PENDING
- if (v === 'rejected') return AbuseState.REJECTED
-
- return undefined
- }
- },
- videoIs: {
- prefix: 'videoIs:',
- handler: v => {
- if (v === 'deleted') return v
- if (v === 'blacklisted') return v
-
- return undefined
- }
- },
- searchReporter: { prefix: 'reporter:' },
- searchReportee: { prefix: 'reportee:' },
- predefinedReason: { prefix: 'tag:' }
- })
-
- return this.restService.addObjectParams(params, filters)
- }
}
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.html
index f2a8729cfc..98d221e8d1 100644
--- a/client/src/app/shared/shared-moderation/generic-account-blocklist.component.html
+++ b/client/src/app/shared/shared-moderation/generic-account-blocklist.component.html
@@ -6,15 +6,12 @@
paginatorText="accounts per page"
[dataLoader]="dataLoader"
columnConfig="false"
+ searchInput="true"
>
<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">
@@ -36,8 +33,8 @@
<button class="peertube-button secondary-button" (click)="unblockAccount(account)" i18n>Unmute</button>
</ng-template>
- <ng-template #noResults let-search>
- @if (search) {
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ @if (search || hasFilters) {
<ng-container i18n>No account found matching current filters.</ng-container>
} @else {
<ng-container i18n>No account found.</ng-container>
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.ts
index 26747be92f..87468d47c2 100644
--- a/client/src/app/shared/shared-moderation/generic-account-blocklist.component.ts
+++ b/client/src/app/shared/shared-moderation/generic-account-blocklist.component.ts
@@ -1,10 +1,10 @@
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 { SearchInputComponent } from '../shared-forms/search-input.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 { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../shared-tables/table.component'
import { AccountBlock } from './account-block.model'
import { BlocklistComponentType, BlocklistService } from './blocklist.service'
@@ -14,7 +14,7 @@ import { BlocklistComponentType, BlocklistService } from './blocklist.service'
imports: [
TableComponent,
NumberFormatterPipe,
- AdvancedInputFilterComponent,
+ SearchInputComponent,
ActorAvatarComponent,
PTDatePipe
]
@@ -59,7 +59,7 @@ export class GenericAccountBlocklistComponent {
)
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: DataLoaderOptionsBase) {
if (this.mode() === BlocklistComponentType.Account) {
return this.blocklistService.getUserAccountBlocklist(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.html
index 49b0dd0a45..c439a2de22 100644
--- a/client/src/app/shared/shared-moderation/generic-server-blocklist.component.html
+++ b/client/src/app/shared/shared-moderation/generic-server-blocklist.component.html
@@ -6,14 +6,13 @@
paginatorText="servers per page"
[dataLoader]="dataLoader"
columnConfig="false"
+ searchInput="true"
>
<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>
@@ -35,8 +34,8 @@
<button class="peertube-button secondary-button" (click)="unblockServer(serverBlock)" i18n>Unmute</button>
</ng-template>
- <ng-template #noResults let-search>
- @if (search) {
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ @if (search || hasFilters) {
<ng-container i18n>No server found matching current filters.</ng-container>
} @else {
<ng-container i18n>No server found.</ng-container>
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.ts
index f3f683a147..b153115411 100644
--- a/client/src/app/shared/shared-moderation/generic-server-blocklist.component.ts
+++ b/client/src/app/shared/shared-moderation/generic-server-blocklist.component.ts
@@ -2,11 +2,11 @@ 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 { SearchInputComponent } from '../shared-forms/search-input.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 { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../shared-tables/table.component'
import { BlocklistComponentType, BlocklistService } from './blocklist.service'
@Component({
@@ -15,7 +15,7 @@ import { BlocklistComponentType, BlocklistService } from './blocklist.service'
imports: [
TableComponent,
NumberFormatterPipe,
- AdvancedInputFilterComponent,
+ SearchInputComponent,
PTDatePipe,
GlobalIconComponent,
BatchDomainsModalComponent
@@ -87,7 +87,7 @@ export class GenericServerBlocklistComponent {
})
}
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (options: DataLoaderOptionsBase) {
if (this.mode() === BlocklistComponentType.Account) {
return this.blocklistService.getUserServerBlocklist(options)
}
diff --git a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
index 67f992f0dc..d8fcffe290 100644
--- a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
+++ b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
@@ -61,7 +61,7 @@ export class AccountReportComponent extends FormReactive implements OnInit {
predefinedReasons: mapValues(abusePredefinedReasonsMap, _ => null as any)
})
- this.predefinedReasons = this.abuseService.getPrefefinedReasons('account')
+ this.predefinedReasons = this.abuseService.getPredefinedReasons('account')
}
show (account: Account) {
diff --git a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts
index b19e16bdf0..ce0fb8c75e 100644
--- a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts
+++ b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts
@@ -64,7 +64,7 @@ export class CommentReportComponent extends FormReactive implements OnInit {
predefinedReasons: mapValues(abusePredefinedReasonsMap, _ => null as any)
})
- this.predefinedReasons = this.abuseService.getPrefefinedReasons('comment')
+ this.predefinedReasons = this.abuseService.getPredefinedReasons('comment')
}
show () {
diff --git a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts
index 4f608367eb..292eb2a947 100644
--- a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts
+++ b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts
@@ -75,7 +75,7 @@ export class VideoReportComponent extends FormReactive implements OnInit {
}
})
- this.predefinedReasons = this.abuseService.getPrefefinedReasons('video')
+ this.predefinedReasons = this.abuseService.getPredefinedReasons('video')
}
show () {
diff --git a/client/src/app/shared/shared-moderation/video-block.service.ts b/client/src/app/shared/shared-moderation/video-block.service.ts
index f6bfb517b6..85a78c9887 100644
--- a/client/src/app/shared/shared-moderation/video-block.service.ts
+++ b/client/src/app/shared/shared-moderation/video-block.service.ts
@@ -1,11 +1,11 @@
-import { SortMeta } from 'primeng/api'
-import { from as observableFrom, Observable } from 'rxjs'
-import { catchError, concatMap, toArray } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable, inject } from '@angular/core'
import { RestExtractor, RestPagination, RestService } from '@app/core'
import { arrayify } from '@peertube/peertube-core-utils'
-import { ResultList, VideoBlacklist, VideoBlacklistType, VideoBlacklistType_Type } from '@peertube/peertube-models'
+import { ResultList, VideoBlacklist, VideoBlacklistType_Type } from '@peertube/peertube-models'
+import { SortMeta } from 'primeng/api'
+import { Observable, from as observableFrom } from 'rxjs'
+import { catchError, concatMap, toArray } from 'rxjs/operators'
import { environment } from '../../../environments/environment'
@Injectable()
@@ -27,21 +27,7 @@ export class VideoBlockService {
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
- if (search) {
- const filters = this.restService.parseQueryStringFilter(search, {
- type: {
- prefix: 'type:',
- handler: v => {
- if (v === 'manual') return VideoBlacklistType.MANUAL
- if (v === 'auto') return VideoBlacklistType.AUTO_BEFORE_PUBLISHED
-
- return undefined
- }
- }
- })
-
- params = this.restService.addObjectParams(params, filters)
- }
+ if (search) params = params.append('search', search)
if (type) params = params.append('type', type.toString())
return this.authHttp.get<ResultList<VideoBlacklist>>(VideoBlockService.BASE_VIDEOS_URL + 'blacklist', { params })
diff --git a/client/src/app/shared/shared-tables/table.component.html b/client/src/app/shared/shared-tables/table.component.html
index 2be2baf3e4..70104651cf 100644
--- a/client/src/app/shared/shared-tables/table.component.html
+++ b/client/src/app/shared/shared-tables/table.component.html
@@ -41,11 +41,29 @@
}
</div>
- @if (captionRight) {
- <div class="ms-auto right-block">
+ <div class="ms-auto right-block">
+ @if (searchInput()) {
+ <my-search-input
+ inputId="table-search" icon="true" emitOnInit="false" i18n-placeholder placeholder="Search"
+ (search)="onSearch($event)"
+ ></my-search-input>
+ }
+
+ @if (inputFilters()) {
+ <my-advanced-input-filter
+ #advancedInputFilter
+ [filters]="inputFilters()" (filtersChange)="onFiltersChange($event)" [defaultValues]="defaultInputFilterValues()"
+ ></my-advanced-input-filter>
+ }
+
+ @if (refreshButton()) {
+ <my-button i18n-label label="Refresh" icon="refresh" (click)="loadData()"></my-button>
+ }
+
+ @if (captionRight) {
<ng-template *ngTemplateOutlet="captionRight"></ng-template>
+ }
</div>
- }
</div>
</ng-template>
@@ -208,7 +226,7 @@
<td myAutoColspan>
<div class="no-results">
@if (noResults) {
- <ng-template *ngTemplateOutlet="noResults; context: { $implicit: search }"></ng-template>
+ <ng-template *ngTemplateOutlet="noResults; context: { search: search, hasFilters: hasFilters() }"></ng-template>
} @else {
<ng-container i18n>No results found.</ng-container>
}
diff --git a/client/src/app/shared/shared-tables/table.component.ts b/client/src/app/shared/shared-tables/table.component.ts
index 4d592fb29e..87083aa0aa 100644
--- a/client/src/app/shared/shared-tables/table.component.ts
+++ b/client/src/app/shared/shared-tables/table.component.ts
@@ -11,7 +11,8 @@ import {
OnInit,
output,
SimpleChanges,
- TemplateRef
+ TemplateRef,
+ viewChild
} from '@angular/core'
import { FormsModule } from '@angular/forms'
import { ActivatedRoute } from '@angular/router'
@@ -24,7 +25,13 @@ import debug from 'debug'
import { SharedModule, SortMeta } from 'primeng/api'
import { TableLazyLoadEvent, TableModule, TableRowExpandEvent, TableRowReorderEvent } from 'primeng/table'
import { finalize, Observable, Subscription } from 'rxjs'
+import {
+ AdvancedFilterDef,
+ AdvancedInputFilterComponent,
+ parseQueryParamsToAdvancedFilters
+} from '../shared-forms/advanced-input-filter.component'
import { PeertubeCheckboxComponent } from '../shared-forms/peertube-checkbox.component'
+import { SearchInputComponent } from '../shared-forms/search-input.component'
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'
@@ -33,12 +40,12 @@ import { TableExpanderIconComponent } from './table-expander-icon.component'
const debugLogger = debug('peertube:table')
-export type DataLoaderOptions = {
+export type DataLoaderOptionsBase = {
pagination: RestPagination
sort: SortMeta
search?: string
}
-export type DataLoader<Data> = (options: DataLoaderOptions) => Observable<ResultList<Data>>
+export type DataLoader<DataLoaderOptions extends DataLoaderOptionsBase, Data> = (options: DataLoaderOptions) => Observable<ResultList<Data>>
export type TableQueryParams = {
start?: number
@@ -82,22 +89,29 @@ type BulkActions<Data> = DropdownAction<Data[]>[][] | DropdownAction<Data[]>[]
PeertubeCheckboxComponent,
AutoColspanDirective,
TableExpanderIconComponent,
- GlobalIconComponent
+ GlobalIconComponent,
+ SearchInputComponent,
+ AdvancedInputFilterComponent
]
})
-export class TableComponent<Data, ColumnName = string, QueryParams extends TableQueryParams = TableQueryParams>
- implements OnInit, OnDestroy, OnChanges
-{
+export class TableComponent<
+ Data,
+ DataLoaderOptions extends DataLoaderOptionsBase = DataLoaderOptionsBase,
+ 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)
private screenService = inject(ScreenService)
+ private advancedInputFilter = viewChild<AdvancedInputFilterComponent<DataLoaderOptions>>('advancedInputFilter')
+
readonly key = input.required<string>()
readonly dataKey = input<string>('id')
readonly defaultColumns = input.required<TableColumnInfo<ColumnName>[]>()
- readonly dataLoader = input.required<DataLoader<Data>>()
+ readonly dataLoader = input.required<DataLoader<DataLoaderOptionsBase, Data>>()
readonly reorderableRows = input(false, { transform: booleanAttribute })
readonly dragHandleTitle = input<string>(undefined)
@@ -119,6 +133,16 @@ export class TableComponent<Data, ColumnName = string, QueryParams extends Table
readonly cellWrap = input(false, { transform: booleanAttribute })
+ readonly searchInput = input(false, { transform: booleanAttribute })
+ readonly canUseMatchSort = input(false, { transform: booleanAttribute })
+
+ readonly refreshButton = input(false, { transform: booleanAttribute })
+
+ readonly inputFilters = input<AdvancedFilterDef<DataLoaderOptions>[]>()
+ readonly defaultInputFilterValues = input<Partial<DataLoaderOptions>>()
+
+ private inputFilterValues: Partial<DataLoaderOptions> = {}
+
@ContentChild('totalTitle', { descendants: false })
totalTitle: TemplateRef<any>
@@ -142,6 +166,8 @@ export class TableComponent<Data, ColumnName = string, QueryParams extends Table
readonly rowExpand = output<TableRowExpandEvent>()
readonly rowReorder = output<TableRowReorderEvent>()
+ readonly filtersChange = output<Partial<DataLoaderOptions>>()
+ readonly searchChange = output<string>()
selectedRows: Data[] = []
expandedRows = {}
@@ -163,11 +189,6 @@ export class TableComponent<Data, ColumnName = string, QueryParams extends Table
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
@@ -224,13 +245,13 @@ export class TableComponent<Data, ColumnName = string, QueryParams extends Table
// ---------------------------------------------------------------------------
- onSearch (search: string, canUseMatchSort = false) {
- debugLogger('On search', { search, canUseMatchSort })
+ onSearch (search: string) {
+ debugLogger('On search', { search, canUseMatchSort: this.canUseMatchSort() })
this.search = search
if (this.search) {
- if (canUseMatchSort && this.sort.field !== 'match') {
+ if (this.canUseMatchSort() && this.sort.field !== 'match') {
debugLogger('Saving previous sort on search', { saveSort: this.sort })
this.saveSort = { ...this.sort }
@@ -246,17 +267,34 @@ export class TableComponent<Data, ColumnName = string, QueryParams extends Table
}
}
+ this.searchChange.emit(this.search)
+
this.resetPagination()
this.updateUrl()
}
- onFilter () {
- debugLogger('On filter')
+ onFiltersChange (filters: Partial<DataLoaderOptions> = {}) {
+ debugLogger('On filter', filters)
+
+ this.loadFilters(filters)
+
+ this.filtersChange.emit(filters)
this.resetPagination()
this.updateUrl()
}
+ // Remove default options from filters
+ private loadFilters (filters: Partial<DataLoaderOptions> = {}) {
+ this.inputFilterValues = {}
+
+ for (const [ key, value ] of Object.entries(filters)) {
+ ;(this.inputFilterValues as any)[key] = value !== undefined && value !== 'all'
+ ? value
+ : undefined
+ }
+ }
+
reloadData (sort?: SortMeta) {
debugLogger('Reload data', sort)
@@ -398,6 +436,10 @@ export class TableComponent<Data, ColumnName = string, QueryParams extends Table
if (queryParams.sortOrder !== undefined) this.sort.order = +queryParams.sortOrder
if (queryParams.sortField !== undefined) this.sort.field = queryParams.sortField
+ if (this.inputFilters()) {
+ this.loadFilters(parseQueryParamsToAdvancedFilters(this.inputFilters(), this.route.snapshot.queryParams))
+ }
+
this.customParseQueryParams()(queryParams)
this.loadData()
@@ -412,6 +454,8 @@ export class TableComponent<Data, ColumnName = string, QueryParams extends Table
...this.route.snapshot.queryParams,
...this.customUpdateUrl()(),
+ ...this.inputFilterValues,
+
search: this.search,
start: this.pagination.start,
count: this.pagination.count,
@@ -451,38 +495,6 @@ export class TableComponent<Data, ColumnName = string, QueryParams extends Table
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 (options: {
skipLoader?: boolean // default false
} = {}) {
@@ -494,6 +506,8 @@ export class TableComponent<Data, ColumnName = string, QueryParams extends Table
return new Promise<void>((res, rej) => {
this.dataLoader()({
+ ...this.inputFilterValues,
+
pagination: this.pagination,
sort: this.sort,
search: this.search
@@ -514,4 +528,10 @@ export class TableComponent<Data, ColumnName = string, QueryParams extends Table
})
})
}
+
+ hasFilters () {
+ const active = this.advancedInputFilter()?.activeCount() || 0
+
+ return active !== 0
+ }
}
diff --git a/client/src/app/shared/shared-user-subscription/user-subscription.service.ts b/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
index 56934c6a91..8d9311daef 100644
--- a/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
+++ b/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
@@ -1,16 +1,16 @@
-import debug from 'debug'
-import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'
-import { catchError, filter, map, switchMap, tap } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
-import { Injectable, inject } from '@angular/core'
+import { inject, Injectable } from '@angular/core'
import { ComponentPaginationLight, RestExtractor, RestService } from '@app/core'
import { buildBulkObservable } from '@app/helpers'
import { ActorFollow, ResultList, VideoChannel as VideoChannelServer, VideoSortField } from '@peertube/peertube-models'
+import debug from 'debug'
+import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'
+import { catchError, filter, map, switchMap, tap } from 'rxjs/operators'
import { environment } from '../../../environments/environment'
-import { Video } from '../shared-main/video/video.model'
import { VideoChannel } from '../shared-main/channel/video-channel.model'
-import { VideoService } from '../shared-main/video/video.service'
import { VideoChannelService } from '../shared-main/channel/video-channel.service'
+import { Video } from '../shared-main/video/video.model'
+import { VideoService } from '../shared-main/video/video.service'
const debugLogger = debug('peertube:subscriptions:UserSubscriptionService')
@@ -51,27 +51,18 @@ export class UserSubscriptionService {
pagination: ComponentPaginationLight
nameWithHost: string
search?: string
+ channel?: string
}) {
- const { pagination, nameWithHost, search } = parameters
-
- let url = `${UserSubscriptionService.BASE_ACCOUNTS_URL}/${nameWithHost}/followers`
+ const { pagination, nameWithHost, search, channel } = parameters
let params = new HttpParams()
params = this.restService.addRestGetParams(params, this.restService.componentToRestPagination(pagination), '-createdAt')
- if (search) {
- const filters = this.restService.parseQueryStringFilter(search, {
- channel: {
- prefix: 'channel:'
- }
- })
-
- if (filters.channel) {
- url = `${UserSubscriptionService.BASE_VIDEO_CHANNELS_URL}/${filters.channel}/followers`
- }
+ if (search) params = params.append('search', search)
- params = this.restService.addObjectParams(params, { search: filters.search })
- }
+ const url = channel
+ ? `${UserSubscriptionService.BASE_VIDEO_CHANNELS_URL}/${channel}/followers`
+ : `${UserSubscriptionService.BASE_ACCOUNTS_URL}/${nameWithHost}/followers`
return this.authHttp
.get<ResultList<ActorFollow>>(url, { params })
diff --git a/client/src/app/shared/shared-users/user-admin.service.ts b/client/src/app/shared/shared-users/user-admin.service.ts
index 3c110518ac..0e5ae11f04 100644
--- a/client/src/app/shared/shared-users/user-admin.service.ts
+++ b/client/src/app/shared/shared-users/user-admin.service.ts
@@ -55,22 +55,15 @@ export class UserAdminService {
pagination: RestPagination
sort: SortMeta
search?: string
+ blocked?: boolean
}) {
- const { pagination, sort, search } = parameters
+ const { pagination, sort, search, blocked } = parameters
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
- if (search) {
- const filters = this.restService.parseQueryStringFilter(search, {
- blocked: {
- prefix: 'banned:',
- isBoolean: true
- }
- })
-
- params = this.restService.addObjectParams(params, filters)
- }
+ if (search) params = params.append('search', search)
+ if (blocked !== undefined) params = params.append('blocked', blocked.toString())
return this.authHttp.get<ResultList<UserServerModel>>(UserService.BASE_USERS_URL, { params })
.pipe(
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.html
index b978eff30b..eb44cc316b 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
@@ -7,18 +7,15 @@
paginatorText="comments per page"
[bulkActions]="bulkActions"
[dataLoader]="dataLoader"
+ [inputFilters]="inputFilters"
+ searchInput="true"
+ refreshButton="true"
>
<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 #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-comment>
@if (table.isColumnDisplayed('video')) {
@@ -78,7 +75,7 @@
<a
i18n-title title="Only display comments with this tag"
class="pt-badge badge-secondary me-1"
- [routerLink]="[ '.' ]" [queryParams]="{ 'search': buildSearchAutoTag(tag) }"
+ [routerLink]="[ '.' ]" [queryParams]="{ 'autoTagOneOf': tag }"
>{{ tag }}</a>
}
</td>
@@ -97,8 +94,8 @@
<div [innerHTML]="comment.textHtml"></div>
</ng-template>
- <ng-template #noResults let-search>
- @if (search) {
+ <ng-template #noResults let-search="search" let-hasFilters="hasFilters">
+ @if (search || hasFilters) {
<ng-container i18n>No comments found matching current filters.</ng-container>
} @else {
<ng-container i18n>No comments found.</ng-container>
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.ts
index c427f13af8..b59213f06c 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,5 +1,5 @@
import { Component, OnDestroy, OnInit, inject, input, viewChild } from '@angular/core'
-import { ActivatedRoute, RouterLink } from '@angular/router'
+import { 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'
@@ -8,14 +8,15 @@ import { VideoCommentService } from '@app/shared/shared-video-comment/video-comm
import { BulkRemoveCommentsOfBody, UserRight } from '@peertube/peertube-models'
import { switchMap } from 'rxjs'
import { ActorAvatarComponent } from '../shared-actor-image/actor-avatar.component'
-import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../shared-forms/advanced-input-filter.component'
+import { AdvancedFilterDef } from '../shared-forms/advanced-input-filter.component'
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 { CollaboratorStateComponent } from '../shared-main/channel/collaborator-state.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 { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../shared-tables/table.component'
+
+type DataLoaderParameter = Parameters<VideoCommentListAdminOwnerComponent['_dataLoader']>[0]
type ColumnName =
| 'account'
@@ -30,8 +31,6 @@ type ColumnName =
styleUrls: [ '../shared-moderation/moderation.scss', './video-comment-list-admin-owner.component.scss' ],
imports: [
ActionDropdownComponent,
- AdvancedInputFilterComponent,
- ButtonComponent,
ActorAvatarComponent,
PTDatePipe,
RouterLink,
@@ -42,7 +41,6 @@ type ColumnName =
]
})
export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
- private route = inject(ActivatedRoute)
private auth = inject(AuthService)
private notifier = inject(Notifier)
private confirmService = inject(ConfirmService)
@@ -55,11 +53,11 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
readonly key = input.required<string>()
readonly mode = input.required<'user' | 'admin'>()
- readonly table = viewChild<TableComponent<VideoCommentForAdminOrUser, ColumnName>>('table')
+ readonly table = viewChild<TableComponent<VideoCommentForAdminOrUser, DataLoaderParameter, ColumnName>>('table')
videoCommentActions: DropdownAction<VideoCommentForAdminOrUser>[][] = []
bulkActions: DropdownAction<VideoCommentForAdminOrUser[]>[] = []
- inputFilters: AdvancedInputFilter[] = []
+ inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = []
columns: TableColumnInfo<ColumnName>[] = [
{ id: 'video', label: $localize`Commented video`, sortable: false },
@@ -157,39 +155,66 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
}
private buildInputFilters () {
+ this.inputFilters = []
+
if (this.mode() === 'admin') {
this.inputFilters = [
+ ...this.inputFilters,
+
{
- title: $localize`Advanced filters`,
- children: [
- {
- value: 'local:true',
- label: $localize`Local comments`
- },
- {
- value: 'local:false',
- label: $localize`Remote comments`
- },
- {
- value: 'localVideo:true',
- label: $localize`Comments on local videos`
- }
+ type: 'options',
+ key: 'isLocal',
+ title: $localize`Comment scope`,
+ options: [
+ { value: 'all', label: $localize`All` },
+ { value: true, label: $localize`Local` },
+ { value: false, label: $localize`Remote` }
]
+ },
+ {
+ type: 'title',
+ title: $localize`Commented video scope`
+ },
+ {
+ type: 'checkbox',
+ key: 'onLocalVideo',
+ label: $localize`Comments on local videos`
}
]
+ } else {
+ this.inputFilters = [
+ ...this.inputFilters,
+
+ {
+ type: 'title',
+ title: $localize`Moderation`
+ },
- return
+ {
+ type: 'checkbox',
+ key: 'isHeldForReview',
+ label: $localize`Awaiting your approval`
+ }
+ ]
}
this.inputFilters = [
+ ...this.inputFilters,
+
{
- title: $localize`Advanced filters`,
- children: [
- {
- value: 'heldForReview:true',
- label: $localize`Display comments awaiting your approval`
- }
- ]
+ type: 'text',
+ key: 'searchAccount',
+ title: $localize`Search by account`
+ },
+ {
+ type: 'text',
+ key: 'searchVideo',
+ title: $localize`Search by video`
+ },
+ {
+ type: 'tags',
+ key: 'autoTagOneOf',
+ title: $localize`Search by auto tag`
}
]
}
@@ -198,16 +223,12 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
return this.markdownRenderer.textMarkdownToHTML({ markdown: text, withHtml: true, withEmoji: true })
}
- buildSearchAutoTag (tag: string) {
- const str = `autoTag:"${tag}"`
-
- const search = this.route.snapshot.queryParams.search
- if (search) return search + ' ' + str
-
- return str
- }
-
- private _dataLoader (options: DataLoaderOptions) {
+ private _dataLoader (
+ options:
+ & DataLoaderOptionsBase
+ & Parameters<VideoCommentService['listAdminVideoComments']>[0]
+ & Parameters<VideoCommentService['listVideoCommentsOfMyVideos']>[0]
+ ) {
const method = this.mode() === 'admin'
? this.videoCommentService.listAdminVideoComments.bind(this.videoCommentService)
: this.videoCommentService.listVideoCommentsOfMyVideos.bind(this.videoCommentService)
diff --git a/client/src/app/shared/shared-video-comment/video-comment.service.ts b/client/src/app/shared/shared-video-comment/video-comment.service.ts
index 83d932dbb7..3b704f43e0 100644
--- a/client/src/app/shared/shared-video-comment/video-comment.service.ts
+++ b/client/src/app/shared/shared-video-comment/video-comment.service.ts
@@ -76,20 +76,20 @@ export class VideoCommentService {
// ---------------------------------------------------------------------------
- listVideoCommentsOfMyVideos (options: {
- pagination: RestPagination
- sort: SortMeta
- search?: string
- }): Observable<ResultList<VideoCommentForAdminOrUser>> {
- const { pagination, sort, search } = options
+ listVideoCommentsOfMyVideos (
+ options: Parameters<VideoCommentService['buildAdminVideoCommentsParams']>[0] & {
+ isHeldForReview?: boolean
+ }
+ ): Observable<ResultList<VideoCommentForAdminOrUser>> {
+ const { isHeldForReview } = options
+
const url = VideoCommentService.BASE_ME_URL + 'videos/comments'
- let params = new HttpParams()
- params = this.restService.addRestGetParams(params, pagination, sort)
+ let params = this.buildAdminVideoCommentsParams(options)
params = params.set('includeCollaborations', 'true')
- if (search) {
- params = this.buildParamsFromSearch(search, params)
+ if (isHeldForReview !== undefined) {
+ params = params.set('isHeldForReview', '' + isHeldForReview)
}
return this.authHttp.get<ResultList<VideoCommentForAdminOrUser>>(url, { params })
@@ -98,19 +98,24 @@ export class VideoCommentService {
)
}
- listAdminVideoComments (options: {
- pagination: RestPagination
- sort: SortMeta
- search?: string
- }): Observable<ResultList<VideoCommentForAdminOrUser>> {
- const { pagination, sort, search } = options
+ listAdminVideoComments (
+ options: Parameters<VideoCommentService['buildAdminVideoCommentsParams']>[0] & {
+ isLocal?: boolean
+ onLocalVideo?: boolean
+ }
+ ): Observable<ResultList<VideoCommentForAdminOrUser>> {
+ const { isLocal, onLocalVideo } = options
+
const url = VideoCommentService.BASE_VIDEO_URL + 'comments'
- let params = new HttpParams()
- params = this.restService.addRestGetParams(params, pagination, sort)
+ let params = this.buildAdminVideoCommentsParams(options)
- if (search) {
- params = this.buildParamsFromSearch(search, params)
+ if (isLocal !== undefined) {
+ params = params.set('isLocal', '' + isLocal)
+ }
+
+ if (onLocalVideo !== undefined) {
+ params = params.set('onLocalVideo', '' + onLocalVideo)
}
return this.authHttp.get<ResultList<VideoCommentForAdminOrUser>>(url, { params })
@@ -119,6 +124,23 @@ export class VideoCommentService {
)
}
+ private buildAdminVideoCommentsParams (options: {
+ pagination: RestPagination
+ sort: SortMeta
+ search?: string
+ searchAccount?: string
+ searchVideo?: string
+ autoTagOneOf?: string[]
+ }) {
+ const { pagination, sort, ...otherOptions } = options
+
+ let params = new HttpParams()
+ params = this.restService.addRestGetParams(params, pagination, sort)
+ params = this.restService.addObjectParams(params, otherOptions)
+
+ return params
+ }
+
// ---------------------------------------------------------------------------
getVideoCommentThreads (parameters: {
@@ -239,32 +261,4 @@ export class VideoCommentService {
return Object.assign(tree, { hasDisplayedChildren })
}
-
- private buildParamsFromSearch (search: string, params: HttpParams) {
- const filters = this.restService.parseQueryStringFilter(search, {
- isLocal: {
- prefix: 'local:',
- isBoolean: true
- },
- onLocalVideo: {
- prefix: 'localVideo:',
- isBoolean: true
- },
-
- isHeldForReview: {
- prefix: 'heldForReview:',
- isBoolean: true
- },
-
- autoTagOneOf: {
- prefix: 'autoTag:',
- multiple: true
- },
-
- searchAccount: { prefix: 'account:' },
- searchVideo: { prefix: 'video:' }
- })
-
- return this.restService.addObjectParams(params, filters)
- }
}
diff --git a/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts b/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts
index 21efa2816d..698673cbb5 100644
--- a/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts
@@ -103,7 +103,7 @@ export class VideoFiltersHeaderComponent implements OnInit {
this.serverService.getVideoLanguages()
.subscribe(languages => this.videoLanguages = languages)
- this.followService.getFollowing({ pagination: { count: 1, start: 0 }, state: 'accepted' })
+ this.followService.listSubscriptions({ pagination: { count: 1, start: 0 }, state: 'accepted' })
.subscribe(({ total }) => this.totalFollowing = total)
this.buildQuickFilters()
diff --git a/client/src/app/shared/shared-video/video-state-message.service.ts b/client/src/app/shared/shared-video/video-state-message.service.ts
index 13b4dda205..22201275d5 100644
--- a/client/src/app/shared/shared-video/video-state-message.service.ts
+++ b/client/src/app/shared/shared-video/video-state-message.service.ts
@@ -82,7 +82,7 @@ export class VideoStateMessageService {
routerLink: {
text: $localize`Review your import`,
link: [ '/my-library/video-imports' ],
- queryParams: { search: `videoId:${videoId}` }
+ queryParams: { videoId }
}
}
@@ -98,7 +98,7 @@ export class VideoStateMessageService {
routerLink: {
text: $localize`Review your import`,
link: [ '/my-library/video-imports' ],
- queryParams: { search: `videoId:${videoId}` }
+ queryParams: { videoId }
}
}
}
diff --git a/client/src/app/shared/shared-video/video-views-counter.component.scss b/client/src/app/shared/shared-video/video-views-counter.component.scss
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/client/src/app/shared/shared-video/video-views-counter.component.ts b/client/src/app/shared/shared-video/video-views-counter.component.ts
index d25d1f91e1..b9a285d803 100644
--- a/client/src/app/shared/shared-video/video-views-counter.component.ts
+++ b/client/src/app/shared/shared-video/video-views-counter.component.ts
@@ -4,7 +4,6 @@ import { NumberFormatterPipe } from '../shared-main/common/number-formatter.pipe
@Component({
selector: 'my-video-views-counter',
- styleUrls: [ './video-views-counter.component.scss' ],
templateUrl: './video-views-counter.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ NumberFormatterPipe ]
diff --git a/client/src/sass/application.scss b/client/src/sass/application.scss
index 7dcd2f2816..b3965db2c2 100644
--- a/client/src/sass/application.scss
+++ b/client/src/sass/application.scss
@@ -101,10 +101,13 @@ code {
color: pvar(--fg-400);
border-radius: 3px;
padding: 0.2em 0.4em;
- margin: auto 0.4em;
font-size: 75%;
- display: inline-block;
- vertical-align: middle;
+
+ &:not(.code-inline) {
+ margin: auto 0.4em;
+ display: inline-block;
+ vertical-align: middle;
+ }
}
a {
diff --git a/client/src/sass/include/_form-mixins.scss b/client/src/sass/include/_form-mixins.scss
index 6fbfa7fa96..045d1011a7 100644
--- a/client/src/sass/include/_form-mixins.scss
+++ b/client/src/sass/include/_form-mixins.scss
@@ -107,12 +107,15 @@
// Thanks: https://codepen.io/manabox/pen/raQmpL
@mixin peertube-radio-container {
+ --pt-radio-scale-font: 1;
+ --pt-radio-scale-el: 1;
+
&[disabled] {
opacity: 0.5;
}
label {
- font-size: $form-input-font-size;
+ font-size: calc(#{$form-input-font-size} * var(--pt-radio-scale-font));
color: pvar(--fg-350);
}
@@ -135,9 +138,9 @@
[type="radio"]:checked + label,
[type="radio"]:not(:checked) + label {
position: relative;
- padding-left: 28px;
+ padding-left: calc(28px * var(--pt-radio-scale-el));
cursor: pointer;
- line-height: 20px;
+ line-height: calc(20px * var(--pt-radio-scale-el));
display: inline-block;
font-weight: $font-regular;
}
@@ -147,9 +150,9 @@
content: "";
position: absolute;
left: 0;
- top: -1px;
- width: 20px;
- height: 20px;
+ top: calc(-1px * var(--pt-radio-scale-el));
+ width: calc(20px * var(--pt-radio-scale-el));
+ height: calc(20px * var(--pt-radio-scale-el));
border: 2px solid pvar(--fg-300);
border-radius: 100%;
}
@@ -157,12 +160,12 @@
[type="radio"]:checked + label::after,
[type="radio"]:not(:checked) + label::after {
content: "";
- width: 10px;
- height: 10px;
+ width: calc(10px * var(--pt-radio-scale-el));
+ height: calc(10px * var(--pt-radio-scale-el));
background: pvar(--input-check-active-bg);
position: absolute;
- top: 4px;
- left: 5px;
+ top: calc(4px * var(--pt-radio-scale-el));
+ left: calc(5px * var(--pt-radio-scale-el));
border-radius: 100%;
transition: all 0.2s ease;
}
@@ -186,79 +189,9 @@
margin-bottom: 10px;
margin-left: 29px;
}
-}
-
-@mixin peertube-checkbox {
- $border-width: 2px;
-
- opacity: 0;
- position: absolute;
-
- &:focus + span {
- box-shadow: $focus-box-shadow-form;
- }
-
- // Checkbox
- + span {
- position: relative;
- width: 20px;
- min-width: 20px;
- height: 20px;
- border: $border-width solid pvar(--fg-400);
- border-radius: 2px;
- vertical-align: middle;
- cursor: pointer;
-
- &::after {
- content: "";
- position: absolute;
- top: 4px;
- left: 6px;
- width: 5px;
- height: 7px;
- opacity: 0;
- transform: rotate(45deg) scale(0);
- border-right: 2px solid pvar(--input-check-active-fg);
- border-bottom: 2px solid pvar(--input-check-active-fg);
- }
- }
- // Checkbox checked
- &:checked + span {
- background: pvar(--input-check-active-bg);
- animation: jelly 0.6s ease;
-
- &::before {
- content: "";
- width: 100%;
- height: 100%;
- background: pvar(--input-check-active-bg);
- position: absolute;
- left: 0;
- transition: all 0.2s ease;
- border: 2px solid pvar(--input-check-active-fg);
- border-radius: 2px;
- }
-
- &::after {
- opacity: 1;
- transform: rotate(45deg) scale(1);
- }
- }
-
- // Label
- + span + span {
- font-weight: $font-regular;
- cursor: pointer;
- display: inline;
- color: pvar(--fg-350);
-
- @include margin-left(8px);
- }
-
- &[disabled] + span,
- &[disabled] + span + span {
- opacity: 0.5;
- cursor: default;
+ &.small {
+ --pt-radio-scale-font: 0.875;
+ --pt-radio-scale-el: 0.8;
}
}
diff --git a/client/src/sass/primeng.scss b/client/src/sass/primeng.scss
index 95d4582c9c..9808840900 100644
--- a/client/src/sass/primeng.scss
+++ b/client/src/sass/primeng.scss
@@ -1,3 +1,4 @@
+@use "sass:math";
@use "_variables" as *;
@use "_mixins" as *;
@@ -6,6 +7,13 @@
background: pvar(--bg-secondary-400);
}
+p-select.small {
+ .p-select-label {
+ @include padding-left(calc(#{var(--p-select-padding-x)} / 2));
+ @include padding-right(calc(#{var(--p-select-padding-x)} / 2));
+ }
+}
+
// ---------------------------------------------------------------------------
// Input chips
// ---------------------------------------------------------------------------
@@ -16,7 +24,6 @@
}
.p-inputchips-input {
- // TODO: fix in upstream?
gap: 1rem !important;
input::placeholder {
@@ -33,6 +40,17 @@
width: 100%;
}
+p-chips.small {
+ .p-inputchips-input {
+ padding-left: calc(#{pvar(--input-x-padding)} / 2) !important;
+ padding-right: calc(#{pvar(--input-x-padding)} / 2) !important;
+ }
+
+ .p-inputchips-input {
+ gap: 0.25rem !important;
+ }
+}
+
// ---------------------------------------------------------------------------
// Multi Select
// ---------------------------------------------------------------------------
diff --git a/client/src/sass/z-index.scss b/client/src/sass/z-index.scss
index f8b0e1cc0a..4aeee71bed 100644
--- a/client/src/sass/z-index.scss
+++ b/client/src/sass/z-index.scss
@@ -1,5 +1,5 @@
-@use '_variables' as *;
-@use '_mixins' as *;
+@use "_variables" as *;
+@use "_mixins" as *;
.root-header {
z-index: z(root-header);
@@ -13,10 +13,14 @@ ngx-loading-bar {
z-index: z(root-header) + 1 !important;
}
-// Dropdown added to body, override default z-index
body > .dropdown,
-body > .dropup {
+body > .dropup,
+body > .p-overlay {
z-index: z(dropdown) !important;
+
+ .p-overlay {
+ z-index: z(dropdown) + 1 !important;
+ }
}
.list-overflow-menu,
diff --git a/client/src/types/index.ts b/client/src/types/index.ts
index c170dcf94c..389a4f04a5 100644
--- a/client/src/types/index.ts
+++ b/client/src/types/index.ts
@@ -1,7 +1,5 @@
export * from './client-script.model'
export * from './server-error.model'
-export * from './job-state-client.type'
-export * from './job-type-client.type'
export * from './link.type'
export * from './register-client-option.model'
export * from './select-options-item.model'
diff --git a/client/src/types/job-state-client.type.ts b/client/src/types/job-state-client.type.ts
deleted file mode 100644
index c464f8b1e9..0000000000
--- a/client/src/types/job-state-client.type.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { JobState } from '@peertube/peertube-models'
-
-export type JobStateClient = JobState | 'all'
diff --git a/client/src/types/job-type-client.type.ts b/client/src/types/job-type-client.type.ts
deleted file mode 100644
index 9308090811..0000000000
--- a/client/src/types/job-type-client.type.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { JobType } from '@peertube/peertube-models'
-
-export type JobTypeClient = 'all' | JobType
diff --git a/packages/tests/src/shared/notifications/check-comment-notifications.ts b/packages/tests/src/shared/notifications/check-comment-notifications.ts
index 79e98774ca..c19024eecb 100644
--- a/packages/tests/src/shared/notifications/check-comment-notifications.ts
+++ b/packages/tests/src/shared/notifications/check-comment-notifications.ts
@@ -72,7 +72,7 @@ export async function checkNewCommentOnMyVideo (
}
const commentUrl = approval
- ? `${server.url}/my-account/videos/comments?search=heldForReview:true`
+ ? `${server.url}/my-account/videos/comments?isHeldForReview=true`
: `${server.url}/w/${shortUUID};threadId=${threadId}`
function emailNotificationFinder (email: object) {
diff --git a/server/core/lib/activitypub/process/process-download.ts b/server/core/lib/activitypub/process/process-download.ts
index a85380ac42..54a33428d7 100644
--- a/server/core/lib/activitypub/process/process-download.ts
+++ b/server/core/lib/activitypub/process/process-download.ts
@@ -22,7 +22,7 @@ async function processCreateDownload (activity: ActivityView) {
const { video } = await getOrCreateAPVideo({
videoObject,
- fetchType: 'only-video-and-blacklist',
+ fetchType: 'with-blacklist',
allowRefresh: false
})
diff --git a/server/core/lib/client-urls.ts b/server/core/lib/client-urls.ts
index e77ffd2bee..7e1c37c849 100644
--- a/server/core/lib/client-urls.ts
+++ b/server/core/lib/client-urls.ts
@@ -13,7 +13,7 @@ export const myVideoImportsUrl = `${WEBSERVER.URL}/my-library/video-imports`
export function getAdminAbuseUrl (abuse: MAbuseId) {
const suffix = abuse
- ? '?search=%23' + abuse.id
+ ? '?id=' + abuse.id
: ''
return WEBSERVER.URL + '/admin/moderation/abuses/list' + suffix
@@ -21,7 +21,7 @@ export function getAdminAbuseUrl (abuse: MAbuseId) {
export function getUserAbuseUrl (abuse: MAbuseId) {
const suffix = abuse
- ? '?search=%23' + abuse.id
+ ? '?id=' + abuse.id
: ''
return WEBSERVER.URL + '/my-account/abuses' + suffix
diff --git a/server/core/models/abuse/sql/abuse-query-builder.ts b/server/core/models/abuse/sql/abuse-query-builder.ts
index 5f3a92464d..9b603a9329 100644
--- a/server/core/models/abuse/sql/abuse-query-builder.ts
+++ b/server/core/models/abuse/sql/abuse-query-builder.ts
@@ -49,8 +49,10 @@ function buildAbuseListQuery (options: BuildAbusesQueryOptions, type: 'count' |
if (options.serverAccountId || options.userAccountId) {
whereAnd.push(
- '"abuse"."reporterAccountId" IS NULL OR ' +
- '"abuse"."reporterAccountId" NOT IN (' + buildBlockedAccountSQL([ options.serverAccountId, options.userAccountId ]) + ')'
+ '(' +
+ '"abuse"."reporterAccountId" IS NULL OR ' +
+ '"abuse"."reporterAccountId" NOT IN (' + buildBlockedAccountSQL([ options.serverAccountId, options.userAccountId ]) + ')' +
+ ')'
)
}
@@ -128,7 +130,6 @@ function buildAbuseListQuery (options: BuildAbusesQueryOptions, type: 'count' |
let suffix = ''
if (type !== 'count') {
-
if (options.sort) {
const order = buildAbuseOrder(options.sort)
suffix += `${order} `
diff --git a/server/core/models/video/video-comment.ts b/server/core/models/video/video-comment.ts
index 84b13eee86..9ccea23ae3 100644
--- a/server/core/models/video/video-comment.ts
+++ b/server/core/models/video/video-comment.ts
@@ -671,7 +671,7 @@ export class VideoCommentModel extends SequelizeModel<VideoCommentModel> {
}
getCommentUserReviewPath () {
- return '/my-account/videos/comments?search=heldForReview:true'
+ return '/my-account/videos/comments?isHeldForReview=true'
}
getThreadId (): number {