From 08c1efbe32244c321de28b0f2a6aaa3f99f46b58 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 26 Apr 2018 16:11:38 +0200 Subject: Add video channel management --- .../shared/forms/form-validators/video-channel.ts | 34 ++++++++++++++++++++++ .../shared/video-channel/video-channel.service.ts | 22 +++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 client/src/app/shared/forms/form-validators/video-channel.ts (limited to 'client/src/app/shared') 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 @@ +import { Validators } from '@angular/forms' + +export const VIDEO_CHANNEL_DISPLAY_NAME = { + VALIDATORS: [ + Validators.required, + Validators.minLength(3), + Validators.maxLength(120) + ], + MESSAGES: { + 'required': 'Display name is required.', + 'minlength': 'Display name must be at least 3 characters long.', + 'maxlength': 'Display name cannot be more than 120 characters long.' + } +} +export const VIDEO_CHANNEL_DESCRIPTION = { + VALIDATORS: [ + Validators.minLength(3), + Validators.maxLength(250) + ], + MESSAGES: { + 'minlength': 'Description must be at least 3 characters long.', + 'maxlength': 'Description cannot be more than 250 characters long.' + } +} +export const VIDEO_CHANNEL_SUPPORT = { + VALIDATORS: [ + Validators.minLength(3), + Validators.maxLength(300) + ], + MESSAGES: { + 'minlength': 'Support text must be at least 3 characters long.', + 'maxlength': 'Support text cannot be more than 300 characters long.' + } +} 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' import { RestExtractor } from '../rest/rest-extractor.service' import { RestService } from '../rest/rest.service' import { HttpClient } from '@angular/common/http' -import { VideoChannel as VideoChannelServer } from '../../../../../shared/models/videos' +import { VideoChannel as VideoChannelServer, VideoChannelCreate, VideoChannelUpdate } from '../../../../../shared/models/videos' import { AccountService } from '../account/account.service' import { ResultList } from '../../../../../shared' import { VideoChannel } from './video-channel.model' import { ReplaySubject } from 'rxjs/ReplaySubject' import { environment } from '../../../environments/environment' +import { UserService } from '@app/+admin/users/shared/user.service' +import { User } from '@app/shared' @Injectable() export class VideoChannelService { @@ -37,6 +39,24 @@ export class VideoChannelService { .catch((res) => this.restExtractor.handleError(res)) } + createVideoChannel (videoChannel: VideoChannelCreate) { + return this.authHttp.post(VideoChannelService.BASE_VIDEO_CHANNEL_URL, videoChannel) + .map(this.restExtractor.extractDataBool) + .catch(err => this.restExtractor.handleError(err)) + } + + updateVideoChannel (videoChannelUUID: string, videoChannel: VideoChannelUpdate) { + return this.authHttp.put(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID, videoChannel) + .map(this.restExtractor.extractDataBool) + .catch(err => this.restExtractor.handleError(err)) + } + + removeVideoChannel (videoChannel: VideoChannel) { + return this.authHttp.delete(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid) + .map(this.restExtractor.extractDataBool) + .catch(err => this.restExtractor.handleError(err)) + } + private extractVideoChannels (result: ResultList) { const videoChannels: VideoChannel[] = [] -- cgit v1.2.3