Better label for video privacies
This commit is contained in:
parent
a94419a604
commit
8cd7faaa33
|
@ -6,7 +6,7 @@ import { Observable, of, ReplaySubject } from 'rxjs'
|
|||
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'
|
||||
|
@ -82,10 +82,10 @@ export class ServerService {
|
|||
}
|
||||
}
|
||||
}
|
||||
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,
|
||||
|
@ -147,7 +147,7 @@ export class ServerService {
|
|||
|
||||
private loadVideoAttributeEnum (
|
||||
attributeName: 'categories' | 'licences' | 'languages' | 'privacies',
|
||||
hashToPopulate: VideoConstant<string>[],
|
||||
hashToPopulate: VideoConstant<string | number>[],
|
||||
notifier: ReplaySubject<boolean>,
|
||||
sort = false
|
||||
) {
|
||||
|
@ -164,7 +164,7 @@ export class ServerService {
|
|||
const label = data[ dataKey ]
|
||||
|
||||
hashToPopulate.push({
|
||||
id: dataKey,
|
||||
id: attributeName === 'languages' ? dataKey : parseInt(dataKey, 10),
|
||||
label: peertubeTranslate(label, translations)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -18,8 +18,8 @@ export class SearchFiltersComponent implements OnInit {
|
|||
|
||||
@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 }[] = []
|
||||
|
|
|
@ -4,7 +4,15 @@ import { Injectable } from '@angular/core'
|
|||
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'
|
||||
|
@ -22,6 +30,7 @@ import { VideoChannelService } from '@app/shared/video-channel/video-channel.ser
|
|||
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 (
|
||||
|
@ -41,7 +50,8 @@ export class VideoService implements VideosProvider {
|
|||
private authHttp: HttpClient,
|
||||
private restExtractor: RestExtractor,
|
||||
private restService: RestService,
|
||||
private serverService: ServerService
|
||||
private serverService: ServerService,
|
||||
private i18n: I18n
|
||||
) {}
|
||||
|
||||
getVideoViewUrl (uuid: string) {
|
||||
|
@ -300,6 +310,21 @@ export class VideoService implements VideosProvider {
|
|||
)
|
||||
}
|
||||
|
||||
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 = {
|
||||
|
|
|
@ -12,7 +12,7 @@ import { VideoCaptionService } from '@app/shared/video-caption'
|
|||
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',
|
||||
|
@ -23,7 +23,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
|
|||
@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[] = []
|
||||
|
@ -33,8 +33,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
|
|||
// 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[]
|
||||
|
|
|
@ -95,6 +95,9 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca
|
|||
thumbnailUrl: null,
|
||||
previewUrl: null
|
||||
}))
|
||||
|
||||
this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
|
||||
|
||||
this.hydrateFormFromVideo()
|
||||
},
|
||||
|
||||
|
|
|
@ -87,6 +87,9 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
|
|||
thumbnailUrl: null,
|
||||
previewUrl: null
|
||||
}))
|
||||
|
||||
this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
|
||||
|
||||
this.hydrateFormFromVideo()
|
||||
},
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils'
|
|||
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
|
||||
|
|
|
@ -182,6 +182,8 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
|
|||
channelId
|
||||
})
|
||||
|
||||
this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
|
||||
|
||||
this.videoUploadObservable = this.videoService.uploadVideo(formData).subscribe(
|
||||
event => {
|
||||
if (event.type === HttpEventType.UploadProgress) {
|
||||
|
|
|
@ -24,7 +24,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
|
|||
video: VideoEdit
|
||||
|
||||
isUpdatingVideo = false
|
||||
videoPrivacies: VideoConstant<string>[] = []
|
||||
videoPrivacies: VideoConstant<VideoPrivacy>[] = []
|
||||
userVideoChannels: { id: number, label: string, support: string }[] = []
|
||||
schedulePublicationPossible = false
|
||||
videoCaptions: VideoCaptionEdit[] = []
|
||||
|
@ -62,11 +62,13 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
|
|||
|
||||
// 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())
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue