diff options
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/forms/form-validators/video-channel.ts | 34 | ||||
-rw-r--r-- | client/src/app/shared/video-channel/video-channel.service.ts | 22 |
2 files changed, 55 insertions, 1 deletions
diff --git a/client/src/app/shared/forms/form-validators/video-channel.ts b/client/src/app/shared/forms/form-validators/video-channel.ts new file mode 100644 index 000000000..6233d17f7 --- /dev/null +++ b/client/src/app/shared/forms/form-validators/video-channel.ts | |||
@@ -0,0 +1,34 @@ | |||
1 | import { Validators } from '@angular/forms' | ||
2 | |||
3 | export const VIDEO_CHANNEL_DISPLAY_NAME = { | ||
4 | VALIDATORS: [ | ||
5 | Validators.required, | ||
6 | Validators.minLength(3), | ||
7 | Validators.maxLength(120) | ||
8 | ], | ||
9 | MESSAGES: { | ||
10 | 'required': 'Display name is required.', | ||
11 | 'minlength': 'Display name must be at least 3 characters long.', | ||
12 | 'maxlength': 'Display name cannot be more than 120 characters long.' | ||
13 | } | ||
14 | } | ||
15 | export const VIDEO_CHANNEL_DESCRIPTION = { | ||
16 | VALIDATORS: [ | ||
17 | Validators.minLength(3), | ||
18 | Validators.maxLength(250) | ||
19 | ], | ||
20 | MESSAGES: { | ||
21 | 'minlength': 'Description must be at least 3 characters long.', | ||
22 | 'maxlength': 'Description cannot be more than 250 characters long.' | ||
23 | } | ||
24 | } | ||
25 | export const VIDEO_CHANNEL_SUPPORT = { | ||
26 | VALIDATORS: [ | ||
27 | Validators.minLength(3), | ||
28 | Validators.maxLength(300) | ||
29 | ], | ||
30 | MESSAGES: { | ||
31 | 'minlength': 'Support text must be at least 3 characters long.', | ||
32 | 'maxlength': 'Support text cannot be more than 300 characters long.' | ||
33 | } | ||
34 | } | ||
diff --git a/client/src/app/shared/video-channel/video-channel.service.ts b/client/src/app/shared/video-channel/video-channel.service.ts index d8efcc171..3533a0e9c 100644 --- a/client/src/app/shared/video-channel/video-channel.service.ts +++ b/client/src/app/shared/video-channel/video-channel.service.ts | |||
@@ -5,12 +5,14 @@ import { Observable } from 'rxjs/Observable' | |||
5 | import { RestExtractor } from '../rest/rest-extractor.service' | 5 | import { RestExtractor } from '../rest/rest-extractor.service' |
6 | import { RestService } from '../rest/rest.service' | 6 | import { RestService } from '../rest/rest.service' |
7 | import { HttpClient } from '@angular/common/http' | 7 | import { HttpClient } from '@angular/common/http' |
8 | import { VideoChannel as VideoChannelServer } from '../../../../../shared/models/videos' | 8 | import { VideoChannel as VideoChannelServer, VideoChannelCreate, VideoChannelUpdate } from '../../../../../shared/models/videos' |
9 | import { AccountService } from '../account/account.service' | 9 | import { AccountService } from '../account/account.service' |
10 | import { ResultList } from '../../../../../shared' | 10 | import { ResultList } from '../../../../../shared' |
11 | import { VideoChannel } from './video-channel.model' | 11 | import { VideoChannel } from './video-channel.model' |
12 | import { ReplaySubject } from 'rxjs/ReplaySubject' | 12 | import { ReplaySubject } from 'rxjs/ReplaySubject' |
13 | import { environment } from '../../../environments/environment' | 13 | import { environment } from '../../../environments/environment' |
14 | import { UserService } from '@app/+admin/users/shared/user.service' | ||
15 | import { User } from '@app/shared' | ||
14 | 16 | ||
15 | @Injectable() | 17 | @Injectable() |
16 | export class VideoChannelService { | 18 | export class VideoChannelService { |
@@ -37,6 +39,24 @@ export class VideoChannelService { | |||
37 | .catch((res) => this.restExtractor.handleError(res)) | 39 | .catch((res) => this.restExtractor.handleError(res)) |
38 | } | 40 | } |
39 | 41 | ||
42 | createVideoChannel (videoChannel: VideoChannelCreate) { | ||
43 | return this.authHttp.post(VideoChannelService.BASE_VIDEO_CHANNEL_URL, videoChannel) | ||
44 | .map(this.restExtractor.extractDataBool) | ||
45 | .catch(err => this.restExtractor.handleError(err)) | ||
46 | } | ||
47 | |||
48 | updateVideoChannel (videoChannelUUID: string, videoChannel: VideoChannelUpdate) { | ||
49 | return this.authHttp.put(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID, videoChannel) | ||
50 | .map(this.restExtractor.extractDataBool) | ||
51 | .catch(err => this.restExtractor.handleError(err)) | ||
52 | } | ||
53 | |||
54 | removeVideoChannel (videoChannel: VideoChannel) { | ||
55 | return this.authHttp.delete(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid) | ||
56 | .map(this.restExtractor.extractDataBool) | ||
57 | .catch(err => this.restExtractor.handleError(err)) | ||
58 | } | ||
59 | |||
40 | private extractVideoChannels (result: ResultList<VideoChannelServer>) { | 60 | private extractVideoChannels (result: ResultList<VideoChannelServer>) { |
41 | const videoChannels: VideoChannel[] = [] | 61 | const videoChannels: VideoChannel[] = [] |
42 | 62 | ||