Add information concerning video privacy in my videos list
This commit is contained in:
parent
41f657c570
commit
2243730c8e
|
@ -18,6 +18,7 @@
|
||||||
<div class="video-info">
|
<div class="video-info">
|
||||||
<a class="video-info-name" [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name">{{ video.name }}</a>
|
<a class="video-info-name" [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name">{{ video.name }}</a>
|
||||||
<span class="video-info-date-views">{{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span>
|
<span class="video-info-date-views">{{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span>
|
||||||
|
<div class="video-info-private">{{ video.privacy.label }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Display only once -->
|
<!-- Display only once -->
|
||||||
|
|
|
@ -79,8 +79,12 @@
|
||||||
font-weight: $font-semibold;
|
font-weight: $font-semibold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.video-info-date-views {
|
.video-info-date-views, .video-info-private {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|
||||||
|
&.video-info-private {
|
||||||
|
font-weight: $font-semibold;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ export class AuthUser extends User {
|
||||||
ROLE: 'role',
|
ROLE: 'role',
|
||||||
EMAIL: 'email',
|
EMAIL: 'email',
|
||||||
USERNAME: 'username',
|
USERNAME: 'username',
|
||||||
DEFAULT_NSFW_POLICY: 'nsfw_policy',
|
NSFW_POLICY: 'nsfw_policy',
|
||||||
AUTO_PLAY_VIDEO: 'auto_play_video'
|
AUTO_PLAY_VIDEO: 'auto_play_video'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ export class AuthUser extends User {
|
||||||
username: peertubeLocalStorage.getItem(this.KEYS.USERNAME),
|
username: peertubeLocalStorage.getItem(this.KEYS.USERNAME),
|
||||||
email: peertubeLocalStorage.getItem(this.KEYS.EMAIL),
|
email: peertubeLocalStorage.getItem(this.KEYS.EMAIL),
|
||||||
role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole,
|
role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole,
|
||||||
nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.DEFAULT_NSFW_POLICY) as NSFWPolicyType,
|
nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.NSFW_POLICY) as NSFWPolicyType,
|
||||||
autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true'
|
autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true'
|
||||||
},
|
},
|
||||||
Tokens.load()
|
Tokens.load()
|
||||||
|
@ -100,7 +100,7 @@ export class AuthUser extends User {
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.USERNAME)
|
peertubeLocalStorage.removeItem(this.KEYS.USERNAME)
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.ID)
|
peertubeLocalStorage.removeItem(this.KEYS.ID)
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.ROLE)
|
peertubeLocalStorage.removeItem(this.KEYS.ROLE)
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.DEFAULT_NSFW_POLICY)
|
peertubeLocalStorage.removeItem(this.KEYS.NSFW_POLICY)
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO)
|
peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO)
|
||||||
peertubeLocalStorage.removeItem(this.KEYS.EMAIL)
|
peertubeLocalStorage.removeItem(this.KEYS.EMAIL)
|
||||||
Tokens.flush()
|
Tokens.flush()
|
||||||
|
@ -137,7 +137,7 @@ export class AuthUser extends User {
|
||||||
peertubeLocalStorage.setItem(AuthUser.KEYS.USERNAME, this.username)
|
peertubeLocalStorage.setItem(AuthUser.KEYS.USERNAME, this.username)
|
||||||
peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email)
|
peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email)
|
||||||
peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString())
|
peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString())
|
||||||
peertubeLocalStorage.setItem(AuthUser.KEYS.DEFAULT_NSFW_POLICY, this.nsfwPolicy.toString())
|
peertubeLocalStorage.setItem(AuthUser.KEYS.NSFW_POLICY, this.nsfwPolicy.toString())
|
||||||
peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo))
|
peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo))
|
||||||
this.tokens.save()
|
this.tokens.save()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
import {
|
import { UserRight, VideoChannel, VideoDetails as VideoDetailsServerModel, VideoFile } from '../../../../../shared'
|
||||||
UserRight,
|
|
||||||
VideoChannel,
|
|
||||||
VideoDetails as VideoDetailsServerModel,
|
|
||||||
VideoFile,
|
|
||||||
VideoPrivacy
|
|
||||||
} from '../../../../../shared'
|
|
||||||
import { Account } from '../../../../../shared/models/actors'
|
import { Account } from '../../../../../shared/models/actors'
|
||||||
import { VideoConstant } from '../../../../../shared/models/videos/video.model'
|
|
||||||
import { AuthUser } from '../../core'
|
import { AuthUser } from '../../core'
|
||||||
import { Video } from '../../shared/video/video.model'
|
import { Video } from '../../shared/video/video.model'
|
||||||
|
|
||||||
export class VideoDetails extends Video implements VideoDetailsServerModel {
|
export class VideoDetails extends Video implements VideoDetailsServerModel {
|
||||||
privacy: VideoConstant<VideoPrivacy>
|
|
||||||
descriptionPath: string
|
descriptionPath: string
|
||||||
support: string
|
support: string
|
||||||
channel: VideoChannel
|
channel: VideoChannel
|
||||||
|
@ -26,7 +18,6 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
|
||||||
constructor (hash: VideoDetailsServerModel) {
|
constructor (hash: VideoDetailsServerModel) {
|
||||||
super(hash)
|
super(hash)
|
||||||
|
|
||||||
this.privacy = hash.privacy
|
|
||||||
this.descriptionPath = hash.descriptionPath
|
this.descriptionPath = hash.descriptionPath
|
||||||
this.files = hash.files
|
this.files = hash.files
|
||||||
this.channel = hash.channel
|
this.channel = hash.channel
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Account } from '@app/shared/account/account.model'
|
import { Account } from '@app/shared/account/account.model'
|
||||||
import { User } from '../'
|
import { User } from '../'
|
||||||
import { Video as VideoServerModel } from '../../../../../shared'
|
import { Video as VideoServerModel, VideoPrivacy } from '../../../../../shared'
|
||||||
import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
|
import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
|
||||||
import { VideoConstant } from '../../../../../shared/models/videos/video.model'
|
import { VideoConstant } from '../../../../../shared/models/videos/video.model'
|
||||||
import { getAbsoluteAPIUrl } from '../misc/utils'
|
import { getAbsoluteAPIUrl } from '../misc/utils'
|
||||||
|
@ -14,6 +14,7 @@ export class Video implements VideoServerModel {
|
||||||
category: VideoConstant<number>
|
category: VideoConstant<number>
|
||||||
licence: VideoConstant<number>
|
licence: VideoConstant<number>
|
||||||
language: VideoConstant<number>
|
language: VideoConstant<number>
|
||||||
|
privacy: VideoConstant<VideoPrivacy>
|
||||||
description: string
|
description: string
|
||||||
duration: number
|
duration: number
|
||||||
durationLabel: string
|
durationLabel: string
|
||||||
|
@ -62,6 +63,7 @@ export class Video implements VideoServerModel {
|
||||||
this.category = hash.category
|
this.category = hash.category
|
||||||
this.licence = hash.licence
|
this.licence = hash.licence
|
||||||
this.language = hash.language
|
this.language = hash.language
|
||||||
|
this.privacy = hash.privacy
|
||||||
this.description = hash.description
|
this.description = hash.description
|
||||||
this.duration = hash.duration
|
this.duration = hash.duration
|
||||||
this.durationLabel = Video.createDurationString(hash.duration)
|
this.durationLabel = Video.createDurationString(hash.duration)
|
||||||
|
|
|
@ -168,7 +168,7 @@ const CONFIG = {
|
||||||
get DESCRIPTION () { return config.get<string>('instance.description') },
|
get DESCRIPTION () { return config.get<string>('instance.description') },
|
||||||
get TERMS () { return config.get<string>('instance.terms') },
|
get TERMS () { return config.get<string>('instance.terms') },
|
||||||
get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') },
|
get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') },
|
||||||
get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') },
|
get NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') },
|
||||||
CUSTOMIZATIONS: {
|
CUSTOMIZATIONS: {
|
||||||
get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') },
|
get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') },
|
||||||
get CSS () { return config.get<string>('instance.customizations.css') }
|
get CSS () { return config.get<string>('instance.customizations.css') }
|
||||||
|
|
|
@ -884,6 +884,13 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
return languageLabel
|
return languageLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static getPrivacyLabel (id: number) {
|
||||||
|
let privacyLabel = VIDEO_PRIVACIES[id]
|
||||||
|
if (!privacyLabel) privacyLabel = 'Unknown'
|
||||||
|
|
||||||
|
return privacyLabel
|
||||||
|
}
|
||||||
|
|
||||||
getOriginalFile () {
|
getOriginalFile () {
|
||||||
if (Array.isArray(this.VideoFiles) === false) return undefined
|
if (Array.isArray(this.VideoFiles) === false) return undefined
|
||||||
|
|
||||||
|
@ -990,6 +997,10 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
id: this.language,
|
id: this.language,
|
||||||
label: VideoModel.getLanguageLabel(this.language)
|
label: VideoModel.getLanguageLabel(this.language)
|
||||||
},
|
},
|
||||||
|
privacy: {
|
||||||
|
id: this.privacy,
|
||||||
|
label: VideoModel.getPrivacyLabel(this.privacy)
|
||||||
|
},
|
||||||
nsfw: this.nsfw,
|
nsfw: this.nsfw,
|
||||||
description: this.getTruncatedDescription(),
|
description: this.getTruncatedDescription(),
|
||||||
isLocal: this.isOwned(),
|
isLocal: this.isOwned(),
|
||||||
|
@ -1016,15 +1027,7 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
toFormattedDetailsJSON (): VideoDetails {
|
toFormattedDetailsJSON (): VideoDetails {
|
||||||
const formattedJson = this.toFormattedJSON()
|
const formattedJson = this.toFormattedJSON()
|
||||||
|
|
||||||
// Maybe our server is not up to date and there are new privacy settings since our version
|
|
||||||
let privacyLabel = VIDEO_PRIVACIES[this.privacy]
|
|
||||||
if (!privacyLabel) privacyLabel = 'Unknown'
|
|
||||||
|
|
||||||
const detailsJson = {
|
const detailsJson = {
|
||||||
privacy: {
|
|
||||||
id: this.privacy,
|
|
||||||
label: privacyLabel
|
|
||||||
},
|
|
||||||
support: this.support,
|
support: this.support,
|
||||||
descriptionPath: this.getDescriptionPath(),
|
descriptionPath: this.getDescriptionPath(),
|
||||||
channel: this.VideoChannel.toFormattedJSON(),
|
channel: this.VideoChannel.toFormattedJSON(),
|
||||||
|
|
|
@ -442,6 +442,8 @@ async function completeVideoCheck (
|
||||||
expect(video.licence.label).to.equal(VIDEO_LICENCES[attributes.licence] || 'Unknown')
|
expect(video.licence.label).to.equal(VIDEO_LICENCES[attributes.licence] || 'Unknown')
|
||||||
expect(video.language.id).to.equal(attributes.language)
|
expect(video.language.id).to.equal(attributes.language)
|
||||||
expect(video.language.label).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown')
|
expect(video.language.label).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown')
|
||||||
|
expect(video.privacy.id).to.deep.equal(attributes.privacy)
|
||||||
|
expect(video.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy])
|
||||||
expect(video.nsfw).to.equal(attributes.nsfw)
|
expect(video.nsfw).to.equal(attributes.nsfw)
|
||||||
expect(video.description).to.equal(attributes.description)
|
expect(video.description).to.equal(attributes.description)
|
||||||
expect(video.account.host).to.equal(attributes.account.host)
|
expect(video.account.host).to.equal(attributes.account.host)
|
||||||
|
@ -459,8 +461,6 @@ async function completeVideoCheck (
|
||||||
|
|
||||||
expect(videoDetails.files).to.have.lengthOf(attributes.files.length)
|
expect(videoDetails.files).to.have.lengthOf(attributes.files.length)
|
||||||
expect(videoDetails.tags).to.deep.equal(attributes.tags)
|
expect(videoDetails.tags).to.deep.equal(attributes.tags)
|
||||||
expect(videoDetails.privacy.id).to.deep.equal(attributes.privacy)
|
|
||||||
expect(videoDetails.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy])
|
|
||||||
expect(videoDetails.account.name).to.equal(attributes.account.name)
|
expect(videoDetails.account.name).to.equal(attributes.account.name)
|
||||||
expect(videoDetails.account.host).to.equal(attributes.account.host)
|
expect(videoDetails.account.host).to.equal(attributes.account.host)
|
||||||
expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled)
|
expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled)
|
||||||
|
|
|
@ -26,6 +26,7 @@ export interface Video {
|
||||||
category: VideoConstant<number>
|
category: VideoConstant<number>
|
||||||
licence: VideoConstant<number>
|
licence: VideoConstant<number>
|
||||||
language: VideoConstant<number>
|
language: VideoConstant<number>
|
||||||
|
privacy: VideoConstant<VideoPrivacy>
|
||||||
description: string
|
description: string
|
||||||
duration: number
|
duration: number
|
||||||
isLocal: boolean
|
isLocal: boolean
|
||||||
|
@ -48,7 +49,6 @@ export interface Video {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VideoDetails extends Video {
|
export interface VideoDetails extends Video {
|
||||||
privacy: VideoConstant<VideoPrivacy>
|
|
||||||
descriptionPath: string
|
descriptionPath: string
|
||||||
support: string
|
support: string
|
||||||
channel: VideoChannel
|
channel: VideoChannel
|
||||||
|
|
Loading…
Reference in New Issue