]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/video/video.model.ts
Add ability to schedule video publication
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video / video.model.ts
index 48d562f9c863fe8d88ce8423b7951f29d6726e21..7f421dbbb68222d080abc007a47f7adc8c339c68 100644 (file)
@@ -1,10 +1,12 @@
 import { User } from '../'
-import { Video as VideoServerModel, VideoPrivacy } from '../../../../../shared'
+import { Video as VideoServerModel, VideoPrivacy, VideoState } from '../../../../../shared'
 import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
 import { VideoConstant } from '../../../../../shared/models/videos/video.model'
 import { getAbsoluteAPIUrl } from '../misc/utils'
 import { ServerConfig } from '../../../../../shared/models'
 import { Actor } from '@app/shared/actor/actor.model'
+import { peertubeTranslate } from '@app/shared/i18n/i18n-utils'
+import { VideoScheduleUpdate } from '../../../../../shared/models/videos/video-schedule-update.model'
 
 export class Video implements VideoServerModel {
   by: string
@@ -35,6 +37,10 @@ export class Video implements VideoServerModel {
   dislikes: number
   nsfw: boolean
 
+  waitTranscoding?: boolean
+  state?: VideoConstant<VideoState>
+  scheduledUpdate?: VideoScheduleUpdate
+
   account: {
     id: number
     uuid: string
@@ -57,18 +63,17 @@ export class Video implements VideoServerModel {
 
   private static createDurationString (duration: number) {
     const hours = Math.floor(duration / 3600)
-    const minutes = Math.floor(duration % 3600 / 60)
+    const minutes = Math.floor((duration % 3600) / 60)
     const seconds = duration % 60
 
     const minutesPadding = minutes >= 10 ? '' : '0'
     const secondsPadding = seconds >= 10 ? '' : '0'
     const displayedHours = hours > 0 ? hours.toString() + ':' : ''
 
-    return displayedHours + minutesPadding +
-        minutes.toString() + ':' + secondsPadding + seconds.toString()
+    return displayedHours + minutesPadding + minutes.toString() + ':' + secondsPadding + seconds.toString()
   }
 
-  constructor (hash: VideoServerModel) {
+  constructor (hash: VideoServerModel, translations = {}) {
     const absoluteAPIUrl = getAbsoluteAPIUrl()
 
     this.createdAt = new Date(hash.createdAt.toString())
@@ -77,6 +82,8 @@ export class Video implements VideoServerModel {
     this.licence = hash.licence
     this.language = hash.language
     this.privacy = hash.privacy
+    this.waitTranscoding = hash.waitTranscoding
+    this.state = hash.state
     this.description = hash.description
     this.duration = hash.duration
     this.durationLabel = Video.createDurationString(hash.duration)
@@ -98,6 +105,14 @@ export class Video implements VideoServerModel {
 
     this.by = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host)
     this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
+
+    this.category.label = peertubeTranslate(this.category.label, translations)
+    this.licence.label = peertubeTranslate(this.licence.label, translations)
+    this.language.label = peertubeTranslate(this.language.label, translations)
+    this.privacy.label = peertubeTranslate(this.privacy.label, translations)
+
+    this.scheduledUpdate = hash.scheduledUpdate
+    if (this.state) this.state.label = peertubeTranslate(this.state.label, translations)
   }
 
   isVideoNSFWForUser (user: User, serverConfig: ServerConfig) {