aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-12 15:28:54 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-13 12:02:21 +0100
commit17119e4a546522468878cf115558b17949ab50d0 (patch)
tree3f130cfd7fdccf5aeeac9beee941750590239047 /client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts
parentb4bc269e5517849b5b89052f0c1a2c01b6f65089 (diff)
downloadPeerTube-17119e4a546522468878cf115558b17949ab50d0.tar.gz
PeerTube-17119e4a546522468878cf115558b17949ab50d0.tar.zst
PeerTube-17119e4a546522468878cf115558b17949ab50d0.zip
Reorganize left menu and account menu
Add my-settings and my-library in left menu Move administration below my-library Split account menu: my-setting and my library
Diffstat (limited to 'client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts')
-rw-r--r--client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts91
1 files changed, 91 insertions, 0 deletions
diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts
new file mode 100644
index 000000000..5abea54b0
--- /dev/null
+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts
@@ -0,0 +1,91 @@
1import { Component, OnInit } from '@angular/core'
2import { Router } from '@angular/router'
3import { AuthService, Notifier, ServerService } from '@app/core'
4import { populateAsyncUserVideoChannels } from '@app/helpers'
5import {
6 setPlaylistChannelValidator,
7 VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
8 VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
9 VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
10 VIDEO_PLAYLIST_PRIVACY_VALIDATOR
11} from '@app/shared/form-validators/video-playlist-validators'
12import { FormValidatorService } from '@app/shared/shared-forms'
13import { VideoPlaylistService } from '@app/shared/shared-video-playlist'
14import { VideoPlaylistCreate } from '@shared/models/videos/playlist/video-playlist-create.model'
15import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model'
16import { MyVideoPlaylistEdit } from './my-video-playlist-edit'
17
18@Component({
19 templateUrl: './my-video-playlist-edit.component.html',
20 styleUrls: [ './my-video-playlist-edit.component.scss' ]
21})
22export class MyVideoPlaylistCreateComponent extends MyVideoPlaylistEdit implements OnInit {
23 error: string
24
25 constructor (
26 protected formValidatorService: FormValidatorService,
27 private authService: AuthService,
28 private notifier: Notifier,
29 private router: Router,
30 private videoPlaylistService: VideoPlaylistService,
31 private serverService: ServerService
32 ) {
33 super()
34 }
35
36 ngOnInit () {
37 this.buildForm({
38 displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
39 privacy: VIDEO_PLAYLIST_PRIVACY_VALIDATOR,
40 description: VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
41 videoChannelId: VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
42 thumbnailfile: null
43 })
44
45 this.form.get('privacy').valueChanges.subscribe(privacy => {
46 setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)
47 })
48
49 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
50 .catch(err => console.error('Cannot populate user video channels.', err))
51
52 this.serverService.getVideoPlaylistPrivacies()
53 .subscribe(videoPlaylistPrivacies => {
54 this.videoPlaylistPrivacies = videoPlaylistPrivacies
55
56 this.form.patchValue({
57 privacy: VideoPlaylistPrivacy.PRIVATE
58 })
59 })
60 }
61
62 formValidated () {
63 this.error = undefined
64
65 const body = this.form.value
66 const videoPlaylistCreate: VideoPlaylistCreate = {
67 displayName: body.displayName,
68 privacy: body.privacy,
69 description: body.description || null,
70 videoChannelId: body.videoChannelId || null,
71 thumbnailfile: body.thumbnailfile || null
72 }
73
74 this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate).subscribe(
75 () => {
76 this.notifier.success($localize`Playlist ${videoPlaylistCreate.displayName} created.`)
77 this.router.navigate([ '/my-library', 'video-playlists' ])
78 },
79
80 err => this.error = err.message
81 )
82 }
83
84 isCreation () {
85 return true
86 }
87
88 getFormButtonTitle () {
89 return $localize`Create`
90 }
91}