]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts
Help translators to translate trending title/tooltip
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-video-channels / my-account-video-channels.component.ts
... / ...
CommitLineData
1import { Component, OnInit } from '@angular/core'
2import { Notifier } from '@app/core'
3import { AuthService } from '../../core/auth'
4import { ConfirmService } from '../../core/confirm'
5import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
6import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
7import { User } from '@app/shared'
8import { flatMap } from 'rxjs/operators'
9import { I18n } from '@ngx-translate/i18n-polyfill'
10
11@Component({
12 selector: 'my-account-video-channels',
13 templateUrl: './my-account-video-channels.component.html',
14 styleUrls: [ './my-account-video-channels.component.scss' ]
15})
16export class MyAccountVideoChannelsComponent implements OnInit {
17 videoChannels: VideoChannel[] = []
18
19 private user: User
20
21 constructor (
22 private authService: AuthService,
23 private notifier: Notifier,
24 private confirmService: ConfirmService,
25 private videoChannelService: VideoChannelService,
26 private i18n: I18n
27 ) {}
28
29 ngOnInit () {
30 this.user = this.authService.getUser()
31
32 this.loadVideoChannels()
33 }
34
35 async deleteVideoChannel (videoChannel: VideoChannel) {
36 const res = await this.confirmService.confirmWithInput(
37 this.i18n(
38 'Do you really want to delete {{videoChannelName}}? It will delete all videos uploaded in this channel too.',
39 { videoChannelName: videoChannel.displayName }
40 ),
41 this.i18n('Please type the name of the video channel to confirm'),
42 videoChannel.displayName,
43 this.i18n('Delete')
44 )
45 if (res === false) return
46
47 this.videoChannelService.removeVideoChannel(videoChannel)
48 .subscribe(
49 () => {
50 this.loadVideoChannels()
51 this.notifier.success(
52 this.i18n('Video channel {{videoChannelName}} deleted.', { videoChannelName: videoChannel.displayName })
53 )
54 },
55
56 error => this.notifier.error(error.message)
57 )
58 }
59
60 private loadVideoChannels () {
61 this.authService.userInformationLoaded
62 .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account)))
63 .subscribe(res => this.videoChannels = res.data)
64 }
65}