diff options
Diffstat (limited to 'client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts')
-rw-r--r-- | client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts deleted file mode 100644 index e2ea87fb8..000000000 --- a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { Router } from '@angular/router' | ||
3 | import { AuthService, Notifier } from '@app/core' | ||
4 | import { | ||
5 | VIDEO_CHANNEL_DESCRIPTION_VALIDATOR, | ||
6 | VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, | ||
7 | VIDEO_CHANNEL_NAME_VALIDATOR, | ||
8 | VIDEO_CHANNEL_SUPPORT_VALIDATOR | ||
9 | } from '@app/shared/form-validators/video-channel-validators' | ||
10 | import { FormValidatorService } from '@app/shared/shared-forms' | ||
11 | import { VideoChannelService } from '@app/shared/shared-main' | ||
12 | import { VideoChannelCreate } from '@shared/models' | ||
13 | import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' | ||
14 | |||
15 | @Component({ | ||
16 | selector: 'my-account-video-channel-create', | ||
17 | templateUrl: './my-account-video-channel-edit.component.html', | ||
18 | styleUrls: [ './my-account-video-channel-edit.component.scss' ] | ||
19 | }) | ||
20 | export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelEdit implements OnInit { | ||
21 | error: string | ||
22 | |||
23 | constructor ( | ||
24 | protected formValidatorService: FormValidatorService, | ||
25 | private authService: AuthService, | ||
26 | private notifier: Notifier, | ||
27 | private router: Router, | ||
28 | private videoChannelService: VideoChannelService | ||
29 | ) { | ||
30 | super() | ||
31 | } | ||
32 | |||
33 | get instanceHost () { | ||
34 | return window.location.host | ||
35 | } | ||
36 | |||
37 | ngOnInit () { | ||
38 | this.buildForm({ | ||
39 | name: VIDEO_CHANNEL_NAME_VALIDATOR, | ||
40 | 'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, | ||
41 | description: VIDEO_CHANNEL_DESCRIPTION_VALIDATOR, | ||
42 | support: VIDEO_CHANNEL_SUPPORT_VALIDATOR | ||
43 | }) | ||
44 | } | ||
45 | |||
46 | formValidated () { | ||
47 | this.error = undefined | ||
48 | |||
49 | const body = this.form.value | ||
50 | const videoChannelCreate: VideoChannelCreate = { | ||
51 | name: body.name, | ||
52 | displayName: body['display-name'], | ||
53 | description: body.description || null, | ||
54 | support: body.support || null | ||
55 | } | ||
56 | |||
57 | this.videoChannelService.createVideoChannel(videoChannelCreate).subscribe( | ||
58 | () => { | ||
59 | this.authService.refreshUserInformation() | ||
60 | |||
61 | this.notifier.success($localize`Video channel ${videoChannelCreate.displayName} created.`) | ||
62 | this.router.navigate([ '/my-account', 'video-channels' ]) | ||
63 | }, | ||
64 | |||
65 | err => { | ||
66 | if (err.status === 409) { | ||
67 | this.error = $localize`This name already exists on this instance.` | ||
68 | return | ||
69 | } | ||
70 | |||
71 | this.error = err.message | ||
72 | } | ||
73 | ) | ||
74 | } | ||
75 | |||
76 | isCreation () { | ||
77 | return true | ||
78 | } | ||
79 | |||
80 | getFormButtonTitle () { | ||
81 | return $localize`Create` | ||
82 | } | ||
83 | } | ||