aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-07-23 21:30:04 +0200
committerRigel Kent <par@rigelk.eu>2020-07-29 18:15:53 +0200
commit4f5d045960b042eb27e10bac1bdaf1c074c9fa2a (patch)
tree09e1e8cce0a2e64146ede51941cfa2f1bdcf3c2f /client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.ts
parentbc99dfe54e093e69ba8fd06d36b36fbbda3f45de (diff)
downloadPeerTube-4f5d045960b042eb27e10bac1bdaf1c074c9fa2a.tar.gz
PeerTube-4f5d045960b042eb27e10bac1bdaf1c074c9fa2a.tar.zst
PeerTube-4f5d045960b042eb27e10bac1bdaf1c074c9fa2a.zip
harmonize search for libraries
Diffstat (limited to 'client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.ts')
-rw-r--r--client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.ts26
1 files changed, 24 insertions, 2 deletions
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 @@
1import { ChartData } from 'chart.js' 1import { ChartData } from 'chart.js'
2import { max, maxBy, min, minBy } from 'lodash-es' 2import { max, maxBy, min, minBy } from 'lodash-es'
3import { flatMap } from 'rxjs/operators' 3import { flatMap, debounceTime } from 'rxjs/operators'
4import { Component, OnInit } from '@angular/core' 4import { Component, OnInit } from '@angular/core'
5import { AuthService, ConfirmService, Notifier, ScreenService, User } from '@app/core' 5import { AuthService, ConfirmService, Notifier, ScreenService, User } from '@app/core'
6import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' 6import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
7import { I18n } from '@ngx-translate/i18n-polyfill' 7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { Subject } from 'rxjs'
8 9
9@Component({ 10@Component({
10 selector: 'my-account-video-channels', 11 selector: 'my-account-video-channels',
@@ -12,11 +13,16 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
12 styleUrls: [ './my-account-video-channels.component.scss' ] 13 styleUrls: [ './my-account-video-channels.component.scss' ]
13}) 14})
14export class MyAccountVideoChannelsComponent implements OnInit { 15export class MyAccountVideoChannelsComponent implements OnInit {
16 totalItems: number
17
15 videoChannels: VideoChannel[] = [] 18 videoChannels: VideoChannel[] = []
16 videoChannelsChartData: ChartData[] 19 videoChannelsChartData: ChartData[]
17 videoChannelsMinimumDailyViews = 0 20 videoChannelsMinimumDailyViews = 0
18 videoChannelsMaximumDailyViews: number 21 videoChannelsMaximumDailyViews: number
19 22
23 channelsSearch: string
24 channelsSearchChanged = new Subject<string>()
25
20 private user: User 26 private user: User
21 27
22 constructor ( 28 constructor (
@@ -32,6 +38,12 @@ export class MyAccountVideoChannelsComponent implements OnInit {
32 this.user = this.authService.getUser() 38 this.user = this.authService.getUser()
33 39
34 this.loadVideoChannels() 40 this.loadVideoChannels()
41
42 this.channelsSearchChanged
43 .pipe(debounceTime(500))
44 .subscribe(() => {
45 this.loadVideoChannels()
46 })
35 } 47 }
36 48
37 get isInSmallView () { 49 get isInSmallView () {
@@ -87,6 +99,15 @@ export class MyAccountVideoChannelsComponent implements OnInit {
87 } 99 }
88 } 100 }
89 101
102 resetSearch() {
103 this.channelsSearch = ''
104 this.onChannelsSearchChanged()
105 }
106
107 onChannelsSearchChanged () {
108 this.channelsSearchChanged.next()
109 }
110
90 async deleteVideoChannel (videoChannel: VideoChannel) { 111 async deleteVideoChannel (videoChannel: VideoChannel) {
91 const res = await this.confirmService.confirmWithInput( 112 const res = await this.confirmService.confirmWithInput(
92 this.i18n( 113 this.i18n(
@@ -118,9 +139,10 @@ export class MyAccountVideoChannelsComponent implements OnInit {
118 139
119 private loadVideoChannels () { 140 private loadVideoChannels () {
120 this.authService.userInformationLoaded 141 this.authService.userInformationLoaded
121 .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account, null, true))) 142 .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account, null, true, this.channelsSearch)))
122 .subscribe(res => { 143 .subscribe(res => {
123 this.videoChannels = res.data 144 this.videoChannels = res.data
145 this.totalItems = res.total
124 146
125 // chart data 147 // chart data
126 this.videoChannelsChartData = this.videoChannels.map(v => ({ 148 this.videoChannelsChartData = this.videoChannels.map(v => ({