import { getCompleteLocale, ServerConfig } from '../../../../../shared'
import { About } from '../../../../../shared/models/server/about.model'
import { environment } from '../../../environments/environment'
-import { VideoConstant } from '../../../../../shared/models/videos'
+import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos'
import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n'
import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
import { sortBy } from '@app/shared/misc/utils'
}
}
}
- private videoCategories: Array<VideoConstant<string>> = []
- private videoLicences: Array<VideoConstant<string>> = []
+ private videoCategories: Array<VideoConstant<number>> = []
+ private videoLicences: Array<VideoConstant<number>> = []
private videoLanguages: Array<VideoConstant<string>> = []
- private videoPrivacies: Array<VideoConstant<string>> = []
+ private videoPrivacies: Array<VideoConstant<VideoPrivacy>> = []
constructor (
private http: HttpClient,
private loadVideoAttributeEnum (
attributeName: 'categories' | 'licences' | 'languages' | 'privacies',
- hashToPopulate: VideoConstant<string>[],
+ hashToPopulate: VideoConstant<string | number>[],
notifier: ReplaySubject<boolean>,
sort = false
) {
const label = data[ dataKey ]
hashToPopulate.push({
- id: dataKey,
+ id: attributeName === 'languages' ? dataKey : parseInt(dataKey, 10),
label: peertubeTranslate(label, translations)
})
})
@Output() filtered = new EventEmitter<AdvancedSearch>()
- videoCategories: VideoConstant<string>[] = []
- videoLicences: VideoConstant<string>[] = []
+ videoCategories: VideoConstant<number>[] = []
+ videoLicences: VideoConstant<number>[] = []
videoLanguages: VideoConstant<string>[] = []
publishedDateRanges: { id: string, label: string }[] = []
import { Observable } from 'rxjs'
import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } from '../../../../../shared'
import { ResultList } from '../../../../../shared/models/result-list.model'
-import { UserVideoRate, UserVideoRateUpdate, VideoFilter, VideoRateType, VideoUpdate } from '../../../../../shared/models/videos'
+import {
+ UserVideoRate,
+ UserVideoRateUpdate,
+ VideoConstant,
+ VideoFilter,
+ VideoPrivacy,
+ VideoRateType,
+ VideoUpdate
+} from '../../../../../shared/models/videos'
import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum'
import { environment } from '../../../environments/environment'
import { ComponentPagination } from '../rest/component-pagination.model'
import { ServerService } from '@app/core'
import { UserSubscriptionService } from '@app/shared/user-subscription'
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
+import { I18n } from '@ngx-translate/i18n-polyfill'
export interface VideosProvider {
getVideos (
private authHttp: HttpClient,
private restExtractor: RestExtractor,
private restService: RestService,
- private serverService: ServerService
+ private serverService: ServerService,
+ private i18n: I18n
) {}
getVideoViewUrl (uuid: string) {
)
}
+ explainedPrivacyLabels (privacies: VideoConstant<VideoPrivacy>[]) {
+ const newPrivacies = privacies.slice()
+
+ const privatePrivacy = newPrivacies.find(p => p.id === VideoPrivacy.PRIVATE)
+ if (privatePrivacy) privatePrivacy.label = this.i18n('Only I can see this video')
+
+ const unlistedPrivacy = newPrivacies.find(p => p.id === VideoPrivacy.UNLISTED)
+ if (unlistedPrivacy) unlistedPrivacy.label = this.i18n('Only people with the private link can see this video')
+
+ const publicPrivacy = newPrivacies.find(p => p.id === VideoPrivacy.PUBLIC)
+ if (publicPrivacy) publicPrivacy.label = this.i18n('Anyone can see this video')
+
+ return privacies
+ }
+
private setVideoRate (id: number, rateType: VideoRateType) {
const url = VideoService.BASE_VIDEO_URL + id + '/rate'
const body: UserVideoRateUpdate = {
import { VideoCaptionAddModalComponent } from '@app/videos/+video-edit/shared/video-caption-add-modal.component'
import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model'
import { removeElementFromArray } from '@app/shared/misc/utils'
-import { VideoConstant } from '../../../../../../shared'
+import { VideoConstant, VideoPrivacy } from '../../../../../../shared'
@Component({
selector: 'my-video-edit',
@Input() form: FormGroup
@Input() formErrors: { [ id: string ]: string } = {}
@Input() validationMessages: FormReactiveValidationMessages = {}
- @Input() videoPrivacies: { id: number, label: string }[] = []
+ @Input() videoPrivacies: VideoConstant<VideoPrivacy>[] = []
@Input() userVideoChannels: { id: number, label: string, support: string }[] = []
@Input() schedulePublicationPossible = true
@Input() videoCaptions: VideoCaptionEdit[] = []
// So that it can be accessed in the template
readonly SPECIAL_SCHEDULED_PRIVACY = VideoEdit.SPECIAL_SCHEDULED_PRIVACY
- videoCategories: VideoConstant<string>[] = []
- videoLicences: VideoConstant<string>[] = []
+ videoCategories: VideoConstant<number>[] = []
+ videoLicences: VideoConstant<number>[] = []
videoLanguages: VideoConstant<string>[] = []
tagValidators: ValidatorFn[]
thumbnailUrl: null,
previewUrl: null
}))
+
+ this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
+
this.hydrateFormFromVideo()
},
thumbnailUrl: null,
previewUrl: null
}))
+
+ this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
+
this.hydrateFormFromVideo()
},
export abstract class VideoSend extends FormReactive implements OnInit, CanComponentDeactivate {
userVideoChannels: { id: number, label: string, support: string }[] = []
- videoPrivacies: VideoConstant<string>[] = []
+ videoPrivacies: VideoConstant<VideoPrivacy>[] = []
videoCaptions: VideoCaptionEdit[] = []
firstStepPrivacyId = 0
channelId
})
+ this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
+
this.videoUploadObservable = this.videoService.uploadVideo(formData).subscribe(
event => {
if (event.type === HttpEventType.UploadProgress) {
video: VideoEdit
isUpdatingVideo = false
- videoPrivacies: VideoConstant<string>[] = []
+ videoPrivacies: VideoConstant<VideoPrivacy>[] = []
userVideoChannels: { id: number, label: string, support: string }[] = []
schedulePublicationPossible = false
videoCaptions: VideoCaptionEdit[] = []
// We cannot set private a video that was not private
if (this.video.privacy !== VideoPrivacy.PRIVATE) {
- this.videoPrivacies = this.videoPrivacies.filter(p => p.id.toString() !== VideoPrivacy.PRIVATE.toString())
+ this.videoPrivacies = this.videoPrivacies.filter(p => p.id !== VideoPrivacy.PRIVATE)
} else { // We can schedule video publication only if it it is private
this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
}
+ this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
+
// FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
setTimeout(() => this.hydrateFormFromVideo())
},