ActivityPub-federated video streaming platform using P2P directly in your web browser
Add search bars for a user's videos and playlist library
Rigel Kentbf64ed419693
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.html b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.htmlindex 307884c706..8787723595 100644--- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.html+++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.html@@ -1,4 +1,6 @@<div class="video-playlists-header">+ <input type="text" placeholder="Search your playlists" i18n-placeholder [(ngModel)]="videoPlaylistsSearch" (ngModelChange)="onVideoPlaylistSearchChanged()" />+<a class="create-button" routerLink="create"><my-global-icon iconName="add"></my-global-icon><ng-container i18n>Create a new playlist</ng-container>diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.scss b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.scssindex d5635417df..4fb4ed4be2 100644--- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.scss+++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.scss@@ -29,12 +29,19 @@.video-playlist-buttons {min-width: 190px;+ height: max-content;}}.video-playlists-header {+ display: flex;+ justify-content: space-between;text-align: right;margin: 20px 0 50px;++ input[type=text] {+ @include peertube-input-text(300px);+ }}@media screen and (max-width: 800px) {diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.tsindex 76b13fe2b4..42e4782eb6 100644--- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts+++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts@@ -3,7 +3,7 @@ import { Notifier } from '@app/core'import { AuthService } from '../../core/auth'import { ConfirmService } from '../../core/confirm'import { User } from '@app/shared'-import { flatMap } from 'rxjs/operators'+import { flatMap, debounceTime } from 'rxjs/operators'import { I18n } from '@ngx-translate/i18n-polyfill'import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model'import { ComponentPagination } from '@app/shared/rest/component-pagination.model'@@ -17,7 +17,9 @@ import { Subject } from 'rxjs'styleUrls: [ './my-account-video-playlists.component.scss' ]})export class MyAccountVideoPlaylistsComponent implements OnInit {+ videoPlaylistsSearch: stringvideoPlaylists: VideoPlaylist[] = []+ videoPlaylistSearchChanged = new Subject<string>()pagination: ComponentPagination = {currentPage: 1,@@ -41,6 +43,13 @@ export class MyAccountVideoPlaylistsComponent implements OnInit {this.user = this.authService.getUser()this.loadVideoPlaylists()++ this.videoPlaylistSearchChanged+ .pipe(+ debounceTime(500))+ .subscribe(() => {+ this.loadVideoPlaylists()+ })}async deleteVideoPlaylist (videoPlaylist: VideoPlaylist) {@@ -80,12 +89,17 @@ export class MyAccountVideoPlaylistsComponent implements OnInit {this.loadVideoPlaylists()}+ onVideoPlaylistSearchChanged () {+ this.videoPlaylistSearchChanged.next()+ }+private loadVideoPlaylists () {this.authService.userInformationLoaded.pipe(flatMap(() => {- return this.videoPlaylistService.listAccountPlaylists(this.user.account, this.pagination, '-updatedAt')+ return this.videoPlaylistService.listAccountPlaylists(this.user.account, this.pagination, '-updatedAt', this.videoPlaylistsSearch)})).subscribe(res => {+ this.videoPlaylists = []this.videoPlaylists = this.videoPlaylists.concat(res.data)this.pagination.totalItems = res.totaldiff --git a/client/src/app/+my-account/my-account-videos/my-account-videos.component.html b/client/src/app/+my-account/my-account-videos/my-account-videos.component.htmlindex 2854093c46..a898cd9386 100644--- a/client/src/app/+my-account/my-account-videos/my-account-videos.component.html+++ b/client/src/app/+my-account/my-account-videos/my-account-videos.component.html@@ -1,3 +1,7 @@+<div class="videos-header">+ <input type="text" placeholder="Search your videos" i18n-placeholder [(ngModel)]="videosSearch" (ngModelChange)="onVideosSearchChanged()" />+</div>+<my-videos-selection[pagination]="pagination"[(selection)]="selection"diff --git a/client/src/app/+my-account/my-account-videos/my-account-videos.component.scss b/client/src/app/+my-account/my-account-videos/my-account-videos.component.scssindex 87398e7c87..44545b3e19 100644--- a/client/src/app/+my-account/my-account-videos/my-account-videos.component.scss+++ b/client/src/app/+my-account/my-account-videos/my-account-videos.component.scss@@ -1,6 +1,17 @@@import '_variables';@import '_mixins';+.videos-header {+ display: flex;+ justify-content: space-between;+ text-align: right;+ margin: 20px 0 50px;++ input[type=text] {+ @include peertube-input-text(300px);+ }+}+.action-button-delete-selection {display: inline-block;diff --git a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts b/client/src/app/+my-account/my-account-videos/my-account-videos.component.tsindex 2c86a3c568..dd4b25d083 100644--- a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts+++ b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts@@ -1,6 +1,6 @@-import { concat, Observable } from 'rxjs'-import { tap, toArray } from 'rxjs/operators'-import { Component, ViewChild } from '@angular/core'+import { concat, Observable, Subject } from 'rxjs'+import { tap, toArray, debounceTime } from 'rxjs/operators'+import { Component, ViewChild, OnInit } from '@angular/core'import { ActivatedRoute, Router } from '@angular/router'import { immutableAssign } from '@app/shared/misc/utils'import { ComponentPagination } from '@app/shared/rest/component-pagination.model'@@ -22,7 +22,7 @@ import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook'templateUrl: './my-account-videos.component.html',styleUrls: [ './my-account-videos.component.scss' ]})-export class MyAccountVideosComponent implements DisableForReuseHook {+export class MyAccountVideosComponent implements OnInit, DisableForReuseHook {@ViewChild('videosSelection', { static: true }) videosSelection: VideosSelectionComponent@ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent@@ -43,6 +43,8 @@ export class MyAccountVideosComponent implements DisableForReuseHook {blacklistInfo: true}videos: Video[] = []+ videosSearch: string+ videosSearchChanged = new Subject<string>()getVideosObservableFunction = this.getVideosObservable.bind(this)constructor (@@ -59,6 +61,19 @@ export class MyAccountVideosComponent implements DisableForReuseHook {this.titlePage = this.i18n('My videos')}+ ngOnInit () {+ this.videosSearchChanged+ .pipe(+ debounceTime(500))+ .subscribe(() => {+ this.videosSelection.reloadVideos()+ })+ }++ onVideosSearchChanged () {+ this.videosSearchChanged.next()+ }+disableForReuse () {this.videosSelection.disableForReuse()}@@ -70,7 +85,7 @@ export class MyAccountVideosComponent implements DisableForReuseHook {getVideosObservable (page: number, sort: VideoSortField) {const newPagination = immutableAssign(this.pagination, { currentPage: page })- return this.videoService.getMyVideos(newPagination, sort)+ return this.videoService.getMyVideos(newPagination, sort, this.videosSearch)}async deleteSelectedVideos () {diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.tsindex 41ee87197d..051e0bfa44 100644--- a/client/src/app/shared/users/user.service.ts+++ b/client/src/app/shared/users/user.service.ts@@ -88,7 +88,7 @@ export class UserService {}getMyVideoQuotaUsed () {- const url = UserService.BASE_USERS_URL + '/me/video-quota-used'+ const url = UserService.BASE_USERS_URL + 'me/video-quota-used'return this.authHttp.get<UserVideoQuota>(url).pipe(catchError(err => this.restExtractor.handleError(err)))diff --git a/client/src/app/shared/video-playlist/video-add-to-playlist.component.html b/client/src/app/shared/video-playlist/video-add-to-playlist.component.htmlindex ba30953b98..6e0989227f 100644--- a/client/src/app/shared/video-playlist/video-add-to-playlist.component.html+++ b/client/src/app/shared/video-playlist/video-add-to-playlist.component.html@@ -42,7 +42,7 @@</div><div class="input-container">- <input type="text" placeholder="Search playlists" [(ngModel)]="videoPlaylistSearch" (ngModelChange)="onVideoPlaylistSearchChanged()" />+ <input type="text" placeholder="Search playlists" i18n-placeholder [(ngModel)]="videoPlaylistSearch" (ngModelChange)="onVideoPlaylistSearchChanged()" /></div><div class="playlists">diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.tsindex a2a12bec74..7463598514 100644--- a/client/src/app/shared/video/abstract-video-list.ts+++ b/client/src/app/shared/video/abstract-video-list.ts@@ -150,6 +150,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableForthis.getVideosObservable(this.pagination.currentPage).subscribe(({ data, total }) => {this.pagination.totalItems = total+ this.videos = []this.videos = this.videos.concat(data)if (this.groupByDate) this.buildGroupedDateLabels()@@ -170,7 +171,6 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableForreloadVideos () {this.pagination.currentPage = 1- this.videos = []this.loadMoreVideos()}diff --git a/client/src/app/shared/video/video-miniature.component.scss b/client/src/app/shared/video/video-miniature.component.scssindex 3988cc0556..ac83c5dfa9 100644--- a/client/src/app/shared/video/video-miniature.component.scss+++ b/client/src/app/shared/video/video-miniature.component.scss@@ -100,7 +100,8 @@ $more-margin-right: 15px;flex-direction: row;margin-bottom: 0;height: auto;- width: 100%;+ display: flex;+ flex-grow: 1;my-video-thumbnail {margin-right: 10px;diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.tsindex 9adf46495c..2dd47d74e5 100644--- a/client/src/app/shared/video/video.service.ts+++ b/client/src/app/shared/video/video.service.ts@@ -121,14 +121,15 @@ export class VideoService implements VideosProvider {.pipe(catchError(err => this.restExtractor.handleError(err)))}- getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField): Observable<ResultList<Video>> {+ getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField, search?: string): Observable<ResultList<Video>> {const pagination = this.restService.componentPaginationToRestPagination(videoPagination)let params = new HttpParams()params = this.restService.addRestGetParams(params, pagination, sort)+ params = this.restService.addObjectParams(params, { search })return this.authHttp- .get<ResultList<Video>>(UserService.BASE_USERS_URL + '/me/videos', { params })+ .get<ResultList<Video>>(UserService.BASE_USERS_URL + 'me/videos', { params }).pipe(switchMap(res => this.extractVideos(res)),catchError(err => this.restExtractor.handleError(err))diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.scss b/client/src/app/videos/+video-watch/comment/video-comments.component.scssindex 9e36822952..c02f6c21bb 100644--- a/client/src/app/videos/+video-watch/comment/video-comments.component.scss+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.scss@@ -27,6 +27,7 @@font-weight: 600;text-transform: uppercase;border: none;+ transform: translateY(-7%);}my-feed {diff --git a/client/src/sass/primeng-custom.scss b/client/src/sass/primeng-custom.scssindex 0acffef3c2..9398f0adc7 100644--- a/client/src/sass/primeng-custom.scss+++ b/client/src/sass/primeng-custom.scss@@ -10,6 +10,12 @@color: var(--mainForegroundColor) !important;}+my-edit-button,+my-delete-button,+my-button {+ height: max-content;+}+// data table customizationsp-table {.ui-table-caption {diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.tsindex ba976ab033..b1f29f2526 100644--- a/server/controllers/api/users/me.ts+++ b/server/controllers/api/users/me.ts@@ -99,7 +99,8 @@ async function getUserVideos (req: express.Request, res: express.Response) {user.Account.id,req.query.start as number,req.query.count as number,- req.query.sort as VideoSortField+ req.query.sort as VideoSortField,+ req.query.search as string)const additionalAttributes = {diff --git a/server/models/video/video.ts b/server/models/video/video.tsindex 164122ee20..1f3c25ecbc 100644--- a/server/models/video/video.ts+++ b/server/models/video/video.ts@@ -1196,9 +1196,15 @@ export class VideoModel extends Model<VideoModel> {})}- static listUserVideosForApi (accountId: number, start: number, count: number, sort: string) {+ static listUserVideosForApi (+ accountId: number,+ start: number,+ count: number,+ sort: string,+ search?: string+ ) {function buildBaseQuery (): FindOptions {- return {+ let baseQuery = {offset: start,limit: count,order: getVideoSort(sort),@@ -1218,12 +1224,24 @@ export class VideoModel extends Model<VideoModel> {}]}++ if (search) {+ baseQuery = Object.assign(baseQuery, {+ where: {+ name: {+ [ Op.iLike ]: '%' + search + '%'+ }+ }+ })+ }++ return baseQuery}const countQuery = buildBaseQuery()const findQuery = buildBaseQuery()- const findScopes = [+ const findScopes: (string | ScopeOptions)[] = [ScopeNames.WITH_SCHEDULED_UPDATE,ScopeNames.WITH_BLACKLISTED,ScopeNames.WITH_THUMBNAILS