diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-26 16:11:38 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-26 16:18:01 +0200 |
commit | 08c1efbe32244c321de28b0f2a6aaa3f99f46b58 (patch) | |
tree | 10a1b6c12f3e30a20f3d0dd66c698d9bae2aa41f /client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.ts | |
parent | 7de6afdf542da6968d3f412df9c3318ba19ad229 (diff) | |
download | PeerTube-08c1efbe32244c321de28b0f2a6aaa3f99f46b58.tar.gz PeerTube-08c1efbe32244c321de28b0f2a6aaa3f99f46b58.tar.zst PeerTube-08c1efbe32244c321de28b0f2a6aaa3f99f46b58.zip |
Add video channel management
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 | 59 |
1 files changed, 59 insertions, 0 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 new file mode 100644 index 000000000..eb04094e1 --- /dev/null +++ b/client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.ts | |||
@@ -0,0 +1,59 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { NotificationsService } from 'angular2-notifications' | ||
3 | import 'rxjs/add/observable/from' | ||
4 | import 'rxjs/add/operator/concatAll' | ||
5 | import { AuthService } from '../../core/auth' | ||
6 | import { ConfirmService } from '../../core/confirm' | ||
7 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | ||
8 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | ||
9 | import { User } from '@app/shared' | ||
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 | }) | ||
16 | export class MyAccountVideoChannelsComponent implements OnInit{ | ||
17 | videoChannels: VideoChannel[] = [] | ||
18 | |||
19 | private user: User | ||
20 | |||
21 | constructor ( | ||
22 | private authService: AuthService, | ||
23 | private notificationsService: NotificationsService, | ||
24 | private confirmService: ConfirmService, | ||
25 | private videoChannelService: VideoChannelService | ||
26 | ) {} | ||
27 | |||
28 | ngOnInit () { | ||
29 | this.user = this.authService.getUser() | ||
30 | |||
31 | this.loadVideoChannels() | ||
32 | } | ||
33 | |||
34 | async deleteVideoChannel (videoChannel: VideoChannel) { | ||
35 | const res = await this.confirmService.confirmWithInput( | ||
36 | `Do you really want to delete ${videoChannel.displayName}? It will delete all videos uploaded in this channel too.`, | ||
37 | 'Please type the name of the video channel to confirm', | ||
38 | videoChannel.displayName, | ||
39 | 'Delete' | ||
40 | ) | ||
41 | if (res === false) return | ||
42 | |||
43 | this.videoChannelService.removeVideoChannel(videoChannel) | ||
44 | .subscribe( | ||
45 | status => { | ||
46 | this.loadVideoChannels() | ||
47 | this.notificationsService.success('Success', `Video channel ${videoChannel.name} deleted.`) | ||
48 | }, | ||
49 | |||
50 | error => this.notificationsService.error('Error', error.message) | ||
51 | ) | ||
52 | } | ||
53 | |||
54 | private loadVideoChannels () { | ||
55 | this.authService.userInformationLoaded | ||
56 | .flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account.id)) | ||
57 | .subscribe(res => this.videoChannels = res.data) | ||
58 | } | ||
59 | } | ||