]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts
Use height instead of width to represent the video resolution
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-video-channels / my-account-video-channel-create.component.ts
CommitLineData
08c1efbe
C
1import { Component, OnInit } from '@angular/core'
2import { Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications'
08c1efbe 4import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
08c1efbe 5import { VideoChannelCreate } from '../../../../../shared/models/videos'
08c1efbe 6import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
95166f9a 7import { AuthService } from '@app/core'
b1d40cff 8import { I18n } from '@ngx-translate/i18n-polyfill'
d18d6478 9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
e309822b 10import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators/video-channel-validators.service'
08c1efbe
C
11
12@Component({
13 selector: 'my-account-video-channel-create',
14 templateUrl: './my-account-video-channel-edit.component.html',
15 styleUrls: [ './my-account-video-channel-edit.component.scss' ]
16})
17export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelEdit implements OnInit {
18 error: string
19
08c1efbe 20 constructor (
d18d6478 21 protected formValidatorService: FormValidatorService,
95166f9a 22 private authService: AuthService,
e309822b 23 private videoChannelValidatorsService: VideoChannelValidatorsService,
08c1efbe
C
24 private notificationsService: NotificationsService,
25 private router: Router,
b1d40cff
C
26 private videoChannelService: VideoChannelService,
27 private i18n: I18n
08c1efbe
C
28 ) {
29 super()
30 }
31
08c1efbe 32 ngOnInit () {
d18d6478 33 this.buildForm({
e309822b
C
34 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME,
35 description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION,
36 support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT
d18d6478 37 })
08c1efbe
C
38 }
39
40 formValidated () {
41 this.error = undefined
42
43 const body = this.form.value
44 const videoChannelCreate: VideoChannelCreate = {
45 displayName: body['display-name'],
360329cc
C
46 description: body.description || null,
47 support: body.support || null
08c1efbe
C
48 }
49
50 this.videoChannelService.createVideoChannel(videoChannelCreate).subscribe(
51 () => {
95166f9a 52 this.authService.refreshUserInformation()
b1d40cff
C
53 this.notificationsService.success(
54 this.i18n('Success'),
25acef90 55 this.i18n('Video channel {{videoChannelName}} created.', { videoChannelName: videoChannelCreate.displayName })
b1d40cff 56 )
08c1efbe
C
57 this.router.navigate([ '/my-account', 'video-channels' ])
58 },
59
60 err => this.error = err.message
61 )
62 }
63
64 isCreation () {
65 return true
66 }
67
68 getFormButtonTitle () {
b1d40cff 69 return this.i18n('Create')
08c1efbe
C
70 }
71}