aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-15 16:52:15 +0200
committerChocobozzz <me@florianbigard.com>2018-06-15 18:20:56 +0200
commitbbe0f0645ca958d33a3f409b15166609733b663f (patch)
treeedcd5d702c73cda74a2177c4bdc08c616334337d /client/src/app/shared/video
parent2baea0c77cc765f7cbca9c9a2f4272268892a35c (diff)
downloadPeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.tar.gz
PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.tar.zst
PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.zip
Add ability to schedule video publication
Diffstat (limited to 'client/src/app/shared/video')
-rw-r--r--client/src/app/shared/video/abstract-video-list.ts5
-rw-r--r--client/src/app/shared/video/video-edit.model.ts32
-rw-r--r--client/src/app/shared/video/video-thumbnail.component.ts6
-rw-r--r--client/src/app/shared/video/video.model.ts3
-rw-r--r--client/src/app/shared/video/video.service.ts3
5 files changed, 42 insertions, 7 deletions
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts
index 1c84573da..a468d3231 100644
--- a/client/src/app/shared/video/abstract-video-list.ts
+++ b/client/src/app/shared/video/abstract-video-list.ts
@@ -2,7 +2,6 @@ import { debounceTime } from 'rxjs/operators'
2import { ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core' 2import { ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'
3import { ActivatedRoute, Router } from '@angular/router' 3import { ActivatedRoute, Router } from '@angular/router'
4import { Location } from '@angular/common' 4import { Location } from '@angular/common'
5import { isInMobileView } from '@app/shared/misc/utils'
6import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive' 5import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive'
7import { NotificationsService } from 'angular2-notifications' 6import { NotificationsService } from 'angular2-notifications'
8import { fromEvent, Observable, Subscription } from 'rxjs' 7import { fromEvent, Observable, Subscription } from 'rxjs'
@@ -11,6 +10,7 @@ import { ComponentPagination } from '../rest/component-pagination.model'
11import { VideoSortField } from './sort-field.type' 10import { VideoSortField } from './sort-field.type'
12import { Video } from './video.model' 11import { Video } from './video.model'
13import { I18n } from '@ngx-translate/i18n-polyfill' 12import { I18n } from '@ngx-translate/i18n-polyfill'
13import { ScreenService } from '@app/shared/misc/screen.service'
14 14
15export abstract class AbstractVideoList implements OnInit, OnDestroy { 15export abstract class AbstractVideoList implements OnInit, OnDestroy {
16 private static LINES_PER_PAGE = 4 16 private static LINES_PER_PAGE = 4
@@ -41,6 +41,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
41 protected abstract authService: AuthService 41 protected abstract authService: AuthService
42 protected abstract router: Router 42 protected abstract router: Router
43 protected abstract route: ActivatedRoute 43 protected abstract route: ActivatedRoute
44 protected abstract screenService: ScreenService
44 protected abstract i18n: I18n 45 protected abstract i18n: I18n
45 protected abstract location: Location 46 protected abstract location: Location
46 protected abstract currentRoute: string 47 protected abstract currentRoute: string
@@ -199,7 +200,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
199 } 200 }
200 201
201 private calcPageSizes () { 202 private calcPageSizes () {
202 if (isInMobileView() || this.baseVideoWidth === -1) { 203 if (this.screenService.isInMobileView() || this.baseVideoWidth === -1) {
203 this.pagination.itemsPerPage = 5 204 this.pagination.itemsPerPage = 5
204 205
205 // Video takes all the width 206 // Video takes all the width
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts
index f045a3acd..78aed4f9f 100644
--- a/client/src/app/shared/video/video-edit.model.ts
+++ b/client/src/app/shared/video/video-edit.model.ts
@@ -1,8 +1,11 @@
1import { VideoDetails } from './video-details.model' 1import { VideoDetails } from './video-details.model'
2import { VideoPrivacy } from '../../../../../shared/models/videos/video-privacy.enum' 2import { VideoPrivacy } from '../../../../../shared/models/videos/video-privacy.enum'
3import { VideoUpdate } from '../../../../../shared/models/videos' 3import { VideoUpdate } from '../../../../../shared/models/videos'
4import { VideoScheduleUpdate } from '../../../../../shared/models/videos/video-schedule-update.model'
4 5
5export class VideoEdit implements VideoUpdate { 6export class VideoEdit implements VideoUpdate {
7 static readonly SPECIAL_SCHEDULED_PRIVACY = -1
8
6 category: number 9 category: number
7 licence: number 10 licence: number
8 language: string 11 language: string
@@ -21,6 +24,7 @@ export class VideoEdit implements VideoUpdate {
21 previewUrl: string 24 previewUrl: string
22 uuid?: string 25 uuid?: string
23 id?: number 26 id?: number
27 scheduleUpdate?: VideoScheduleUpdate
24 28
25 constructor (videoDetails?: VideoDetails) { 29 constructor (videoDetails?: VideoDetails) {
26 if (videoDetails) { 30 if (videoDetails) {
@@ -40,6 +44,8 @@ export class VideoEdit implements VideoUpdate {
40 this.support = videoDetails.support 44 this.support = videoDetails.support
41 this.thumbnailUrl = videoDetails.thumbnailUrl 45 this.thumbnailUrl = videoDetails.thumbnailUrl
42 this.previewUrl = videoDetails.previewUrl 46 this.previewUrl = videoDetails.previewUrl
47
48 this.scheduleUpdate = videoDetails.scheduledUpdate
43 } 49 }
44 } 50 }
45 51
@@ -47,10 +53,22 @@ export class VideoEdit implements VideoUpdate {
47 Object.keys(values).forEach((key) => { 53 Object.keys(values).forEach((key) => {
48 this[ key ] = values[ key ] 54 this[ key ] = values[ key ]
49 }) 55 })
56
57 // If schedule publication, the video is private and will be changed to public privacy
58 if (values['schedulePublicationAt']) {
59 const updateAt = (values['schedulePublicationAt'] as Date)
60 updateAt.setSeconds(0)
61
62 this.privacy = VideoPrivacy.PRIVATE
63 this.scheduleUpdate = {
64 updateAt: updateAt.toISOString(),
65 privacy: VideoPrivacy.PUBLIC
66 }
67 }
50 } 68 }
51 69
52 toJSON () { 70 toFormPatch () {
53 return { 71 const json = {
54 category: this.category, 72 category: this.category,
55 licence: this.licence, 73 licence: this.licence,
56 language: this.language, 74 language: this.language,
@@ -64,5 +82,15 @@ export class VideoEdit implements VideoUpdate {
64 channelId: this.channelId, 82 channelId: this.channelId,
65 privacy: this.privacy 83 privacy: this.privacy
66 } 84 }
85
86 // Special case if we scheduled an update
87 if (this.scheduleUpdate) {
88 Object.assign(json, {
89 privacy: VideoEdit.SPECIAL_SCHEDULED_PRIVACY,
90 schedulePublicationAt: new Date(this.scheduleUpdate.updateAt.toString())
91 })
92 }
93
94 return json
67 } 95 }
68} 96}
diff --git a/client/src/app/shared/video/video-thumbnail.component.ts b/client/src/app/shared/video/video-thumbnail.component.ts
index e52f7dfb0..86d8f6f74 100644
--- a/client/src/app/shared/video/video-thumbnail.component.ts
+++ b/client/src/app/shared/video/video-thumbnail.component.ts
@@ -1,6 +1,6 @@
1import { Component, Input } from '@angular/core' 1import { Component, Input } from '@angular/core'
2import { isInMobileView } from '@app/shared/misc/utils'
3import { Video } from './video.model' 2import { Video } from './video.model'
3import { ScreenService } from '@app/shared/misc/screen.service'
4 4
5@Component({ 5@Component({
6 selector: 'my-video-thumbnail', 6 selector: 'my-video-thumbnail',
@@ -11,10 +11,12 @@ export class VideoThumbnailComponent {
11 @Input() video: Video 11 @Input() video: Video
12 @Input() nsfw = false 12 @Input() nsfw = false
13 13
14 constructor (private screenService: ScreenService) {}
15
14 getImageUrl () { 16 getImageUrl () {
15 if (!this.video) return '' 17 if (!this.video) return ''
16 18
17 if (isInMobileView()) { 19 if (this.screenService.isInMobileView()) {
18 return this.video.previewUrl 20 return this.video.previewUrl
19 } 21 }
20 22
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index 48a4b4260..7f421dbbb 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -6,6 +6,7 @@ import { getAbsoluteAPIUrl } from '../misc/utils'
6import { ServerConfig } from '../../../../../shared/models' 6import { ServerConfig } from '../../../../../shared/models'
7import { Actor } from '@app/shared/actor/actor.model' 7import { Actor } from '@app/shared/actor/actor.model'
8import { peertubeTranslate } from '@app/shared/i18n/i18n-utils' 8import { peertubeTranslate } from '@app/shared/i18n/i18n-utils'
9import { VideoScheduleUpdate } from '../../../../../shared/models/videos/video-schedule-update.model'
9 10
10export class Video implements VideoServerModel { 11export class Video implements VideoServerModel {
11 by: string 12 by: string
@@ -38,6 +39,7 @@ export class Video implements VideoServerModel {
38 39
39 waitTranscoding?: boolean 40 waitTranscoding?: boolean
40 state?: VideoConstant<VideoState> 41 state?: VideoConstant<VideoState>
42 scheduledUpdate?: VideoScheduleUpdate
41 43
42 account: { 44 account: {
43 id: number 45 id: number
@@ -109,6 +111,7 @@ export class Video implements VideoServerModel {
109 this.language.label = peertubeTranslate(this.language.label, translations) 111 this.language.label = peertubeTranslate(this.language.label, translations)
110 this.privacy.label = peertubeTranslate(this.privacy.label, translations) 112 this.privacy.label = peertubeTranslate(this.privacy.label, translations)
111 113
114 this.scheduledUpdate = hash.scheduledUpdate
112 if (this.state) this.state.label = peertubeTranslate(this.state.label, translations) 115 if (this.state) this.state.label = peertubeTranslate(this.state.label, translations)
113 } 116 }
114 117
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index d63915ad2..3af90e7ad 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -83,7 +83,8 @@ export class VideoService {
83 waitTranscoding: video.waitTranscoding, 83 waitTranscoding: video.waitTranscoding,
84 commentsEnabled: video.commentsEnabled, 84 commentsEnabled: video.commentsEnabled,
85 thumbnailfile: video.thumbnailfile, 85 thumbnailfile: video.thumbnailfile,
86 previewfile: video.previewfile 86 previewfile: video.previewfile,
87 scheduleUpdate: video.scheduleUpdate || undefined
87 } 88 }
88 89
89 const data = objectToFormData(body) 90 const data = objectToFormData(body)