X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bmy-library%2F%2Bmy-video-channels%2Fmy-video-channels.component.ts;h=b6a2f592dcd954468b429a0a0e2d3c42e130a4be;hb=171efc48e67498406feb6d7873b3482b41505515;hp=f6ba50a4883f546f5348096c725ed700d255f863;hpb=4f926722ea6784ea389013378fd233f59077ec8a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts b/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts index f6ba50a48..b6a2f592d 100644 --- a/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts +++ b/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts @@ -1,29 +1,26 @@ import { ChartData } from 'chart.js' import { max, maxBy, min, minBy } from 'lodash-es' -import { Subject } from 'rxjs' -import { debounceTime, mergeMap } from 'rxjs/operators' -import { Component, OnInit } from '@angular/core' -import { AuthService, ConfirmService, Notifier, ScreenService, User } from '@app/core' +import { mergeMap } from 'rxjs/operators' +import { Component } from '@angular/core' +import { AuthService, ConfirmService, Notifier, ScreenService } from '@app/core' import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' @Component({ templateUrl: './my-video-channels.component.html', styleUrls: [ './my-video-channels.component.scss' ] }) -export class MyVideoChannelsComponent implements OnInit { +export class MyVideoChannelsComponent { totalItems: number videoChannels: VideoChannel[] = [] + videoChannelsChartData: ChartData[] videoChannelsMinimumDailyViews = 0 videoChannelsMaximumDailyViews: number - channelsSearch: string - channelsSearchChanged = new Subject() - chartOptions: any - private user: User + search: string constructor ( private authService: AuthService, @@ -31,31 +28,15 @@ export class MyVideoChannelsComponent implements OnInit { private confirmService: ConfirmService, private videoChannelService: VideoChannelService, private screenService: ScreenService - ) {} - - ngOnInit () { - this.user = this.authService.getUser() - - this.loadVideoChannels() - - this.channelsSearchChanged - .pipe(debounceTime(500)) - .subscribe(() => { - this.loadVideoChannels() - }) - } + ) {} get isInSmallView () { return this.screenService.isInSmallView() } - resetSearch () { - this.channelsSearch = '' - this.onChannelsSearchChanged() - } - - onChannelsSearchChanged () { - this.channelsSearchChanged.next() + onSearch (search: string) { + this.search = search + this.loadVideoChannels() } async deleteVideoChannel (videoChannel: VideoChannel) { @@ -64,9 +45,9 @@ export class MyVideoChannelsComponent implements OnInit { It will delete ${videoChannel.videosCount} videos uploaded in this channel, and you will not be able to create another channel with the same name (${videoChannel.name})!`, - $localize`Please type the display name of the video channel (${videoChannel.displayName}) to confirm`, + $localize`Please type the name of the video channel (${videoChannel.name}) to confirm`, - videoChannel.displayName, + videoChannel.name, $localize`Delete` ) @@ -85,8 +66,17 @@ channel with the same name (${videoChannel.name})!`, private loadVideoChannels () { this.authService.userInformationLoaded - .pipe(mergeMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account, null, true, this.channelsSearch))) - .subscribe(res => { + .pipe(mergeMap(() => { + const user = this.authService.getUser() + const options = { + account: user.account, + withStats: true, + search: this.search, + sort: '-updatedAt' + } + + return this.videoChannelService.listAccountVideoChannels(options) + })).subscribe(res => { this.videoChannels = res.data this.totalItems = res.total