From 0f320037e689b2778959c12ddd4ce790f6e4ae4f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 11 May 2018 15:10:13 +0200 Subject: Add ability to update a video channel --- client/src/app/shared/actor/actor.model.ts | 6 +++--- client/src/app/shared/video/video-edit.model.ts | 6 +++--- client/src/app/shared/video/video.model.ts | 10 ++++++++++ client/src/app/shared/video/video.service.ts | 1 + .../app/videos/+video-edit/shared/video-edit.component.html | 2 +- .../app/videos/+video-edit/shared/video-edit.component.scss | 4 ---- .../src/app/videos/+video-edit/shared/video-edit.component.ts | 2 +- client/src/app/videos/+video-edit/video-add.component.ts | 2 +- client/src/app/videos/+video-edit/video-update.component.ts | 10 +++------- 9 files changed, 23 insertions(+), 20 deletions(-) (limited to 'client') diff --git a/client/src/app/shared/actor/actor.model.ts b/client/src/app/shared/actor/actor.model.ts index 56ff780b7..37d84cb6e 100644 --- a/client/src/app/shared/actor/actor.model.ts +++ b/client/src/app/shared/actor/actor.model.ts @@ -1,6 +1,6 @@ import { Actor as ActorServer } from '../../../../../shared/models/actors/actor.model' -import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' import { Avatar } from '../../../../../shared/models/avatars/avatar.model' +import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' export abstract class Actor implements ActorServer { id: number @@ -41,8 +41,8 @@ export abstract class Actor implements ActorServer { this.host = hash.host this.followingCount = hash.followingCount this.followersCount = hash.followersCount - this.createdAt = new Date(hash.createdAt.toString()) - this.updatedAt = new Date(hash.updatedAt.toString()) + this.createdAt = new Date(hash.createdAt) + this.updatedAt = new Date(hash.updatedAt) this.avatar = hash.avatar this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this) diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts index 39826d71e..ad2929db5 100644 --- a/client/src/app/shared/video/video-edit.model.ts +++ b/client/src/app/shared/video/video-edit.model.ts @@ -10,7 +10,7 @@ export class VideoEdit { tags: string[] nsfw: boolean commentsEnabled: boolean - channel: number + channelId: number privacy: VideoPrivacy support: string thumbnailfile?: any @@ -32,7 +32,7 @@ export class VideoEdit { this.tags = videoDetails.tags this.nsfw = videoDetails.nsfw this.commentsEnabled = videoDetails.commentsEnabled - this.channel = videoDetails.channel.id + this.channelId = videoDetails.channel.id this.privacy = videoDetails.privacy.id this.support = videoDetails.support this.thumbnailUrl = videoDetails.thumbnailUrl @@ -57,7 +57,7 @@ export class VideoEdit { tags: this.tags, nsfw: this.nsfw, commentsEnabled: this.commentsEnabled, - channelId: this.channel, + channelId: this.channelId, privacy: this.privacy } } diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index f56eecaeb..48d562f9c 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts @@ -45,6 +45,16 @@ export class Video implements VideoServerModel { avatar: Avatar } + channel: { + id: number + uuid: string + name: string + displayName: string + url: string + host: string + avatar: Avatar + } + private static createDurationString (duration: number) { const hours = Math.floor(duration / 3600) const minutes = Math.floor(duration % 3600 / 60) diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index b45777c55..cd8539b41 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@ -67,6 +67,7 @@ export class VideoService { language, support, description, + channelId: video.channelId, privacy: video.privacy, tags: video.tags, nsfw: video.nsfw, diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.html b/client/src/app/videos/+video-edit/shared/video-edit.component.html index 9cd3454a0..77b554ad5 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.html +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.html @@ -33,7 +33,7 @@
-
+
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.scss b/client/src/app/videos/+video-edit/shared/video-edit.component.scss index cf64ff589..58ed5ab98 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.scss +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.scss @@ -5,10 +5,6 @@ @include peertube-select-container(auto); } -.peertube-select-disabled-container { - @include peertube-select-disabled-container(auto); -} - .form-group-checkbox { my-help { margin-left: 5px } } diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts index 6ab1a4a24..77e984855 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts @@ -75,7 +75,7 @@ export class VideoEditComponent implements OnInit { this.form.addControl('name', new FormControl('', VIDEO_NAME.VALIDATORS)) this.form.addControl('privacy', new FormControl('', VIDEO_PRIVACY.VALIDATORS)) - this.form.addControl('channelId', new FormControl({ value: '', disabled: true })) + this.form.addControl('channelId', new FormControl('', VIDEO_CHANNEL.VALIDATORS)) this.form.addControl('nsfw', new FormControl(false)) this.form.addControl('commentsEnabled', new FormControl(true)) this.form.addControl('category', new FormControl('', VIDEO_CATEGORY.VALIDATORS)) diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts index ae5548897..fa967018d 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts @@ -220,7 +220,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy const video = new VideoEdit() video.patch(this.form.value) - video.channel = this.firstStepChannelId + video.channelId = this.firstStepChannelId video.id = this.videoUploadedIds.id video.uuid = this.videoUploadedIds.uuid diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts index 6cd204f72..73e2764c6 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts @@ -9,9 +9,9 @@ import { ServerService } from '../../core' import { AuthService } from '../../core/auth' import { FormReactive } from '../../shared' import { ValidatorMessage } from '../../shared/forms/form-validators/validator-message' -import { populateAsyncUserVideoChannels } from '../../shared/misc/utils' import { VideoEdit } from '../../shared/video/video-edit.model' import { VideoService } from '../../shared/video/video.service' +import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils' @Component({ selector: 'my-videos-update', @@ -64,12 +64,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { video => { this.video = new VideoEdit(video) - this.userVideoChannels = [ - { - id: video.channel.id, - label: video.channel.displayName - } - ] + populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) + .catch(err => console.error(err)) // We cannot set private a video that was not private if (video.privacy.id !== VideoPrivacy.PRIVATE) { -- cgit v1.2.3