aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/app/core/server/server.service.ts12
-rw-r--r--client/src/app/search/search-filters.component.ts4
-rw-r--r--client/src/app/shared/video/video.service.ts29
-rw-r--r--client/src/app/videos/+video-edit/shared/video-edit.component.ts8
-rw-r--r--client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts3
-rw-r--r--client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts3
-rw-r--r--client/src/app/videos/+video-edit/video-add-components/video-send.ts2
-rw-r--r--client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts2
-rw-r--r--client/src/app/videos/+video-edit/video-update.component.ts6
9 files changed, 52 insertions, 17 deletions
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index e7152efa0..2f1ef1fc2 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -6,7 +6,7 @@ import { Observable, of, ReplaySubject } from 'rxjs'
6import { getCompleteLocale, ServerConfig } from '../../../../../shared' 6import { getCompleteLocale, ServerConfig } from '../../../../../shared'
7import { About } from '../../../../../shared/models/server/about.model' 7import { About } from '../../../../../shared/models/server/about.model'
8import { environment } from '../../../environments/environment' 8import { environment } from '../../../environments/environment'
9import { VideoConstant } from '../../../../../shared/models/videos' 9import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos'
10import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n' 10import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n'
11import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' 11import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
12import { sortBy } from '@app/shared/misc/utils' 12import { sortBy } from '@app/shared/misc/utils'
@@ -82,10 +82,10 @@ export class ServerService {
82 } 82 }
83 } 83 }
84 } 84 }
85 private videoCategories: Array<VideoConstant<string>> = [] 85 private videoCategories: Array<VideoConstant<number>> = []
86 private videoLicences: Array<VideoConstant<string>> = [] 86 private videoLicences: Array<VideoConstant<number>> = []
87 private videoLanguages: Array<VideoConstant<string>> = [] 87 private videoLanguages: Array<VideoConstant<string>> = []
88 private videoPrivacies: Array<VideoConstant<string>> = [] 88 private videoPrivacies: Array<VideoConstant<VideoPrivacy>> = []
89 89
90 constructor ( 90 constructor (
91 private http: HttpClient, 91 private http: HttpClient,
@@ -147,7 +147,7 @@ export class ServerService {
147 147
148 private loadVideoAttributeEnum ( 148 private loadVideoAttributeEnum (
149 attributeName: 'categories' | 'licences' | 'languages' | 'privacies', 149 attributeName: 'categories' | 'licences' | 'languages' | 'privacies',
150 hashToPopulate: VideoConstant<string>[], 150 hashToPopulate: VideoConstant<string | number>[],
151 notifier: ReplaySubject<boolean>, 151 notifier: ReplaySubject<boolean>,
152 sort = false 152 sort = false
153 ) { 153 ) {
@@ -164,7 +164,7 @@ export class ServerService {
164 const label = data[ dataKey ] 164 const label = data[ dataKey ]
165 165
166 hashToPopulate.push({ 166 hashToPopulate.push({
167 id: dataKey, 167 id: attributeName === 'languages' ? dataKey : parseInt(dataKey, 10),
168 label: peertubeTranslate(label, translations) 168 label: peertubeTranslate(label, translations)
169 }) 169 })
170 }) 170 })
diff --git a/client/src/app/search/search-filters.component.ts b/client/src/app/search/search-filters.component.ts
index a40648eb4..f2f001e3f 100644
--- a/client/src/app/search/search-filters.component.ts
+++ b/client/src/app/search/search-filters.component.ts
@@ -18,8 +18,8 @@ export class SearchFiltersComponent implements OnInit {
18 18
19 @Output() filtered = new EventEmitter<AdvancedSearch>() 19 @Output() filtered = new EventEmitter<AdvancedSearch>()
20 20
21 videoCategories: VideoConstant<string>[] = [] 21 videoCategories: VideoConstant<number>[] = []
22 videoLicences: VideoConstant<string>[] = [] 22 videoLicences: VideoConstant<number>[] = []
23 videoLanguages: VideoConstant<string>[] = [] 23 videoLanguages: VideoConstant<string>[] = []
24 24
25 publishedDateRanges: { id: string, label: string }[] = [] 25 publishedDateRanges: { id: string, label: string }[] = []
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index 5c0674e58..4a78d70ea 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -4,7 +4,15 @@ import { Injectable } from '@angular/core'
4import { Observable } from 'rxjs' 4import { Observable } from 'rxjs'
5import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } from '../../../../../shared' 5import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } from '../../../../../shared'
6import { ResultList } from '../../../../../shared/models/result-list.model' 6import { ResultList } from '../../../../../shared/models/result-list.model'
7import { UserVideoRate, UserVideoRateUpdate, VideoFilter, VideoRateType, VideoUpdate } from '../../../../../shared/models/videos' 7import {
8 UserVideoRate,
9 UserVideoRateUpdate,
10 VideoConstant,
11 VideoFilter,
12 VideoPrivacy,
13 VideoRateType,
14 VideoUpdate
15} from '../../../../../shared/models/videos'
8import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' 16import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum'
9import { environment } from '../../../environments/environment' 17import { environment } from '../../../environments/environment'
10import { ComponentPagination } from '../rest/component-pagination.model' 18import { ComponentPagination } from '../rest/component-pagination.model'
@@ -22,6 +30,7 @@ import { VideoChannelService } from '@app/shared/video-channel/video-channel.ser
22import { ServerService } from '@app/core' 30import { ServerService } from '@app/core'
23import { UserSubscriptionService } from '@app/shared/user-subscription' 31import { UserSubscriptionService } from '@app/shared/user-subscription'
24import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 32import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
33import { I18n } from '@ngx-translate/i18n-polyfill'
25 34
26export interface VideosProvider { 35export interface VideosProvider {
27 getVideos ( 36 getVideos (
@@ -41,7 +50,8 @@ export class VideoService implements VideosProvider {
41 private authHttp: HttpClient, 50 private authHttp: HttpClient,
42 private restExtractor: RestExtractor, 51 private restExtractor: RestExtractor,
43 private restService: RestService, 52 private restService: RestService,
44 private serverService: ServerService 53 private serverService: ServerService,
54 private i18n: I18n
45 ) {} 55 ) {}
46 56
47 getVideoViewUrl (uuid: string) { 57 getVideoViewUrl (uuid: string) {
@@ -300,6 +310,21 @@ export class VideoService implements VideosProvider {
300 ) 310 )
301 } 311 }
302 312
313 explainedPrivacyLabels (privacies: VideoConstant<VideoPrivacy>[]) {
314 const newPrivacies = privacies.slice()
315
316 const privatePrivacy = newPrivacies.find(p => p.id === VideoPrivacy.PRIVATE)
317 if (privatePrivacy) privatePrivacy.label = this.i18n('Only I can see this video')
318
319 const unlistedPrivacy = newPrivacies.find(p => p.id === VideoPrivacy.UNLISTED)
320 if (unlistedPrivacy) unlistedPrivacy.label = this.i18n('Only people with the private link can see this video')
321
322 const publicPrivacy = newPrivacies.find(p => p.id === VideoPrivacy.PUBLIC)
323 if (publicPrivacy) publicPrivacy.label = this.i18n('Anyone can see this video')
324
325 return privacies
326 }
327
303 private setVideoRate (id: number, rateType: VideoRateType) { 328 private setVideoRate (id: number, rateType: VideoRateType) {
304 const url = VideoService.BASE_VIDEO_URL + id + '/rate' 329 const url = VideoService.BASE_VIDEO_URL + id + '/rate'
305 const body: UserVideoRateUpdate = { 330 const body: UserVideoRateUpdate = {
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 b394a13e4..eb9396d70 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
@@ -12,7 +12,7 @@ import { VideoCaptionService } from '@app/shared/video-caption'
12import { VideoCaptionAddModalComponent } from '@app/videos/+video-edit/shared/video-caption-add-modal.component' 12import { VideoCaptionAddModalComponent } from '@app/videos/+video-edit/shared/video-caption-add-modal.component'
13import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model' 13import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model'
14import { removeElementFromArray } from '@app/shared/misc/utils' 14import { removeElementFromArray } from '@app/shared/misc/utils'
15import { VideoConstant } from '../../../../../../shared' 15import { VideoConstant, VideoPrivacy } from '../../../../../../shared'
16 16
17@Component({ 17@Component({
18 selector: 'my-video-edit', 18 selector: 'my-video-edit',
@@ -23,7 +23,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
23 @Input() form: FormGroup 23 @Input() form: FormGroup
24 @Input() formErrors: { [ id: string ]: string } = {} 24 @Input() formErrors: { [ id: string ]: string } = {}
25 @Input() validationMessages: FormReactiveValidationMessages = {} 25 @Input() validationMessages: FormReactiveValidationMessages = {}
26 @Input() videoPrivacies: { id: number, label: string }[] = [] 26 @Input() videoPrivacies: VideoConstant<VideoPrivacy>[] = []
27 @Input() userVideoChannels: { id: number, label: string, support: string }[] = [] 27 @Input() userVideoChannels: { id: number, label: string, support: string }[] = []
28 @Input() schedulePublicationPossible = true 28 @Input() schedulePublicationPossible = true
29 @Input() videoCaptions: VideoCaptionEdit[] = [] 29 @Input() videoCaptions: VideoCaptionEdit[] = []
@@ -33,8 +33,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
33 // So that it can be accessed in the template 33 // So that it can be accessed in the template
34 readonly SPECIAL_SCHEDULED_PRIVACY = VideoEdit.SPECIAL_SCHEDULED_PRIVACY 34 readonly SPECIAL_SCHEDULED_PRIVACY = VideoEdit.SPECIAL_SCHEDULED_PRIVACY
35 35
36 videoCategories: VideoConstant<string>[] = [] 36 videoCategories: VideoConstant<number>[] = []
37 videoLicences: VideoConstant<string>[] = [] 37 videoLicences: VideoConstant<number>[] = []
38 videoLanguages: VideoConstant<string>[] = [] 38 videoLanguages: VideoConstant<string>[] = []
39 39
40 tagValidators: ValidatorFn[] 40 tagValidators: ValidatorFn[]
diff --git a/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts
index 9623c2bf4..0f7184ff8 100644
--- a/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts
+++ b/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts
@@ -95,6 +95,9 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca
95 thumbnailUrl: null, 95 thumbnailUrl: null,
96 previewUrl: null 96 previewUrl: null
97 })) 97 }))
98
99 this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
100
98 this.hydrateFormFromVideo() 101 this.hydrateFormFromVideo()
99 }, 102 },
100 103
diff --git a/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts
index 97b402bfe..031e557ed 100644
--- a/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts
+++ b/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts
@@ -87,6 +87,9 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
87 thumbnailUrl: null, 87 thumbnailUrl: null,
88 previewUrl: null 88 previewUrl: null
89 })) 89 }))
90
91 this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
92
90 this.hydrateFormFromVideo() 93 this.hydrateFormFromVideo()
91 }, 94 },
92 95
diff --git a/client/src/app/videos/+video-edit/video-add-components/video-send.ts b/client/src/app/videos/+video-edit/video-add-components/video-send.ts
index efd182269..bfe588676 100644
--- a/client/src/app/videos/+video-edit/video-add-components/video-send.ts
+++ b/client/src/app/videos/+video-edit/video-add-components/video-send.ts
@@ -15,7 +15,7 @@ import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils'
15export abstract class VideoSend extends FormReactive implements OnInit, CanComponentDeactivate { 15export abstract class VideoSend extends FormReactive implements OnInit, CanComponentDeactivate {
16 16
17 userVideoChannels: { id: number, label: string, support: string }[] = [] 17 userVideoChannels: { id: number, label: string, support: string }[] = []
18 videoPrivacies: VideoConstant<string>[] = [] 18 videoPrivacies: VideoConstant<VideoPrivacy>[] = []
19 videoCaptions: VideoCaptionEdit[] = [] 19 videoCaptions: VideoCaptionEdit[] = []
20 20
21 firstStepPrivacyId = 0 21 firstStepPrivacyId = 0
diff --git a/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts
index b59fb7335..f9af1655b 100644
--- a/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts
+++ b/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts
@@ -182,6 +182,8 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
182 channelId 182 channelId
183 }) 183 })
184 184
185 this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
186
185 this.videoUploadObservable = this.videoService.uploadVideo(formData).subscribe( 187 this.videoUploadObservable = this.videoService.uploadVideo(formData).subscribe(
186 event => { 188 event => {
187 if (event.type === HttpEventType.UploadProgress) { 189 if (event.type === HttpEventType.UploadProgress) {
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 0c60e3439..75b11f46c 100644
--- a/client/src/app/videos/+video-edit/video-update.component.ts
+++ b/client/src/app/videos/+video-edit/video-update.component.ts
@@ -24,7 +24,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
24 video: VideoEdit 24 video: VideoEdit
25 25
26 isUpdatingVideo = false 26 isUpdatingVideo = false
27 videoPrivacies: VideoConstant<string>[] = [] 27 videoPrivacies: VideoConstant<VideoPrivacy>[] = []
28 userVideoChannels: { id: number, label: string, support: string }[] = [] 28 userVideoChannels: { id: number, label: string, support: string }[] = []
29 schedulePublicationPossible = false 29 schedulePublicationPossible = false
30 videoCaptions: VideoCaptionEdit[] = [] 30 videoCaptions: VideoCaptionEdit[] = []
@@ -62,11 +62,13 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
62 62
63 // We cannot set private a video that was not private 63 // We cannot set private a video that was not private
64 if (this.video.privacy !== VideoPrivacy.PRIVATE) { 64 if (this.video.privacy !== VideoPrivacy.PRIVATE) {
65 this.videoPrivacies = this.videoPrivacies.filter(p => p.id.toString() !== VideoPrivacy.PRIVATE.toString()) 65 this.videoPrivacies = this.videoPrivacies.filter(p => p.id !== VideoPrivacy.PRIVATE)
66 } else { // We can schedule video publication only if it it is private 66 } else { // We can schedule video publication only if it it is private
67 this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE 67 this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
68 } 68 }
69 69
70 this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
71
70 // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout 72 // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
71 setTimeout(() => this.hydrateFormFromVideo()) 73 setTimeout(() => this.hydrateFormFromVideo())
72 }, 74 },