X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bmy-account%2Fmy-account-videos%2Fmy-account-videos.component.ts;h=2274c6a7b0f2a9e50c6b902be70c2d7944f84d03;hb=d607fc24631808fc70ce9fb8ddc323d8f856f8ed;hp=5f29364a857ed78c3e04d85cc3652e4b1b6bc4ab;hpb=97567dd81f508dd6295ac4d73d849aa2ce0a6549;p=github%2FChocobozzz%2FPeerTube.git 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.ts index 5f29364a8..2274c6a7b 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,48 +1,46 @@ -import { concat, Observable } from 'rxjs' -import { tap, toArray } from 'rxjs/operators' -import { Component, ViewChild } from '@angular/core' +import { concat, Observable, Subject } from 'rxjs' +import { debounceTime, tap, toArray } from 'rxjs/operators' +import { Component, OnInit, ViewChild } 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' -import { Notifier, ServerService } from '@app/core' -import { AuthService } from '../../core/auth' -import { ConfirmService } from '../../core/confirm' -import { Video } from '../../shared/video/video.model' -import { VideoService } from '../../shared/video/video.service' +import { AuthService, ComponentPagination, ConfirmService, Notifier, ScreenService, ServerService } from '@app/core' +import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' +import { immutableAssign } from '@app/helpers' +import { Video, VideoService } from '@app/shared/shared-main' +import { MiniatureDisplayOptions, OwnerDisplayType, SelectionType, VideosSelectionComponent } from '@app/shared/shared-video-miniature' import { I18n } from '@ngx-translate/i18n-polyfill' -import { ScreenService } from '@app/shared/misc/screen.service' +import { VideoSortField } from '@shared/models' import { VideoChangeOwnershipComponent } from './video-change-ownership/video-change-ownership.component' -import { MiniatureDisplayOptions } from '@app/shared/video/video-miniature.component' -import { SelectionType, VideosSelectionComponent } from '@app/shared/video/videos-selection.component' -import { VideoSortField } from '@app/shared/video/sort-field.type' -import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' @Component({ selector: 'my-account-videos', templateUrl: './my-account-videos.component.html', styleUrls: [ './my-account-videos.component.scss' ] }) -export class MyAccountVideosComponent implements DisableForReuseHook { - @ViewChild('videosSelection') videosSelection: VideosSelectionComponent - @ViewChild('videoChangeOwnershipModal') videoChangeOwnershipModal: VideoChangeOwnershipComponent +export class MyAccountVideosComponent implements OnInit, DisableForReuseHook { + @ViewChild('videosSelection', { static: true }) videosSelection: VideosSelectionComponent + @ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent titlePage: string selection: SelectionType = {} pagination: ComponentPagination = { currentPage: 1, - itemsPerPage: 5, + itemsPerPage: 10, totalItems: null } miniatureDisplayOptions: MiniatureDisplayOptions = { date: true, views: true, - by: false, + by: true, privacyLabel: false, privacyText: true, state: true, blacklistInfo: true } + ownerDisplayType: OwnerDisplayType = 'videoChannel' + videos: Video[] = [] + videosSearch: string + videosSearchChanged = new Subject() getVideosObservableFunction = this.getVideosObservable.bind(this) constructor ( @@ -59,6 +57,23 @@ export class MyAccountVideosComponent implements DisableForReuseHook { this.titlePage = this.i18n('My videos') } + ngOnInit () { + this.videosSearchChanged + .pipe(debounceTime(500)) + .subscribe(() => { + this.videosSelection.reloadVideos() + }) + } + + resetSearch () { + this.videosSearch = '' + this.onVideosSearchChanged() + } + + onVideosSearchChanged () { + this.videosSearchChanged.next() + } + disableForReuse () { this.videosSelection.disableForReuse() } @@ -70,7 +85,10 @@ 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) + .pipe( + tap(res => this.pagination.totalItems = res.total) + ) } async deleteSelectedVideos () {