From 4f5d045960b042eb27e10bac1bdaf1c074c9fa2a Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 23 Jul 2020 21:30:04 +0200 Subject: harmonize search for libraries --- .../my-account-video-channels.component.html | 19 +++++++++++----- .../my-account-video-channels.component.scss | 9 ++++---- .../my-account-video-channels.component.ts | 26 ++++++++++++++++++++-- 3 files changed, 41 insertions(+), 13 deletions(-) (limited to 'client/src/app/+my-account/+my-account-video-channels') diff --git a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.html b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.html index e8d44a45e..c20215cf9 100644 --- a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.html +++ b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.html @@ -1,14 +1,21 @@ -

- - My channels -

+

+ + + My channels + {{ totalItems }} + + +
+ + + Clear filters +
- +

diff --git a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.scss b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.scss index 76fb2cde0..4ecb4f408 100644 --- a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.scss +++ b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.scss @@ -5,6 +5,10 @@ @include create-button; } +input[type=text] { + @include peertube-input-text(300px); +} + ::ng-deep .action-button { &.action-button-edit { margin-right: 10px; @@ -55,11 +59,6 @@ } } -.video-channels-header { - text-align: right; - margin: 20px 0 50px; -} - ::ng-deep .chartjs-render-monitor { position: relative; top: 1px; diff --git a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.ts b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.ts index 70510d7c9..da8c7298f 100644 --- a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.ts +++ b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.ts @@ -1,10 +1,11 @@ import { ChartData } from 'chart.js' import { max, maxBy, min, minBy } from 'lodash-es' -import { flatMap } from 'rxjs/operators' +import { flatMap, debounceTime } from 'rxjs/operators' import { Component, OnInit } from '@angular/core' import { AuthService, ConfirmService, Notifier, ScreenService, User } from '@app/core' import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' import { I18n } from '@ngx-translate/i18n-polyfill' +import { Subject } from 'rxjs' @Component({ selector: 'my-account-video-channels', @@ -12,11 +13,16 @@ import { I18n } from '@ngx-translate/i18n-polyfill' styleUrls: [ './my-account-video-channels.component.scss' ] }) export class MyAccountVideoChannelsComponent implements OnInit { + totalItems: number + videoChannels: VideoChannel[] = [] videoChannelsChartData: ChartData[] videoChannelsMinimumDailyViews = 0 videoChannelsMaximumDailyViews: number + channelsSearch: string + channelsSearchChanged = new Subject() + private user: User constructor ( @@ -32,6 +38,12 @@ export class MyAccountVideoChannelsComponent implements OnInit { this.user = this.authService.getUser() this.loadVideoChannels() + + this.channelsSearchChanged + .pipe(debounceTime(500)) + .subscribe(() => { + this.loadVideoChannels() + }) } get isInSmallView () { @@ -87,6 +99,15 @@ export class MyAccountVideoChannelsComponent implements OnInit { } } + resetSearch() { + this.channelsSearch = '' + this.onChannelsSearchChanged() + } + + onChannelsSearchChanged () { + this.channelsSearchChanged.next() + } + async deleteVideoChannel (videoChannel: VideoChannel) { const res = await this.confirmService.confirmWithInput( this.i18n( @@ -118,9 +139,10 @@ export class MyAccountVideoChannelsComponent implements OnInit { private loadVideoChannels () { this.authService.userInformationLoaded - .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account, null, true))) + .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account, null, true, this.channelsSearch))) .subscribe(res => { this.videoChannels = res.data + this.totalItems = res.total // chart data this.videoChannelsChartData = this.videoChannels.map(v => ({ -- cgit v1.2.3