diff options
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.ts | 26 |
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 @@ | |||
1 | import { ChartData } from 'chart.js' | 1 | import { ChartData } from 'chart.js' |
2 | import { max, maxBy, min, minBy } from 'lodash-es' | 2 | import { max, maxBy, min, minBy } from 'lodash-es' |
3 | import { flatMap } from 'rxjs/operators' | 3 | import { flatMap, debounceTime } from 'rxjs/operators' |
4 | import { Component, OnInit } from '@angular/core' | 4 | import { Component, OnInit } from '@angular/core' |
5 | import { AuthService, ConfirmService, Notifier, ScreenService, User } from '@app/core' | 5 | import { AuthService, ConfirmService, Notifier, ScreenService, User } from '@app/core' |
6 | import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' | 6 | import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' |
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | 7 | import { I18n } from '@ngx-translate/i18n-polyfill' |
8 | import { 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 | }) |
14 | export class MyAccountVideoChannelsComponent implements OnInit { | 15 | export 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 => ({ |