Add more filters for video miniatures
This commit is contained in:
parent
f7894f0964
commit
9105634f16
|
@ -6,6 +6,7 @@ import {
|
||||||
ContainerMarkupData,
|
ContainerMarkupData,
|
||||||
EmbedMarkupData,
|
EmbedMarkupData,
|
||||||
PlaylistMiniatureMarkupData,
|
PlaylistMiniatureMarkupData,
|
||||||
|
VideoFilter,
|
||||||
VideoMiniatureMarkupData,
|
VideoMiniatureMarkupData,
|
||||||
VideosListMarkupData
|
VideosListMarkupData
|
||||||
} from '@shared/models'
|
} from '@shared/models'
|
||||||
|
@ -108,15 +109,6 @@ export class CustomMarkupService {
|
||||||
return component
|
return component
|
||||||
}
|
}
|
||||||
|
|
||||||
private videoMiniatureBuilder (el: HTMLElement) {
|
|
||||||
const data = el.dataset as VideoMiniatureMarkupData
|
|
||||||
const component = this.dynamicElementService.createElement(VideoMiniatureMarkupComponent)
|
|
||||||
|
|
||||||
this.dynamicElementService.setModel(component, { uuid: data.uuid })
|
|
||||||
|
|
||||||
return component
|
|
||||||
}
|
|
||||||
|
|
||||||
private playlistMiniatureBuilder (el: HTMLElement) {
|
private playlistMiniatureBuilder (el: HTMLElement) {
|
||||||
const data = el.dataset as PlaylistMiniatureMarkupData
|
const data = el.dataset as PlaylistMiniatureMarkupData
|
||||||
const component = this.dynamicElementService.createElement(PlaylistMiniatureMarkupComponent)
|
const component = this.dynamicElementService.createElement(PlaylistMiniatureMarkupComponent)
|
||||||
|
@ -150,14 +142,30 @@ export class CustomMarkupService {
|
||||||
return component
|
return component
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private videoMiniatureBuilder (el: HTMLElement) {
|
||||||
|
const data = el.dataset as VideoMiniatureMarkupData
|
||||||
|
const component = this.dynamicElementService.createElement(VideoMiniatureMarkupComponent)
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
uuid: data.uuid,
|
||||||
|
onlyDisplayTitle: this.buildBoolean(data.onlyDisplayTitle) ?? false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dynamicElementService.setModel(component, model)
|
||||||
|
|
||||||
|
return component
|
||||||
|
}
|
||||||
|
|
||||||
private videosListBuilder (el: HTMLElement) {
|
private videosListBuilder (el: HTMLElement) {
|
||||||
const data = el.dataset as VideosListMarkupData
|
const data = el.dataset as VideosListMarkupData
|
||||||
const component = this.dynamicElementService.createElement(VideosListMarkupComponent)
|
const component = this.dynamicElementService.createElement(VideosListMarkupComponent)
|
||||||
|
|
||||||
const model = {
|
const model = {
|
||||||
sort: data.sort,
|
onlyDisplayTitle: this.buildBoolean(data.onlyDisplayTitle) ?? false,
|
||||||
categoryOneOf: this.buildArrayNumber(data.categoryOneOf),
|
sort: data.sort || '-publishedAt',
|
||||||
languageOneOf: this.buildArrayString(data.languageOneOf),
|
categoryOneOf: this.buildArrayNumber(data.categoryOneOf) ?? [],
|
||||||
|
languageOneOf: this.buildArrayString(data.languageOneOf) ?? [],
|
||||||
|
filter: this.buildBoolean(data.onlyLocal) ? 'local' as VideoFilter : undefined,
|
||||||
count: this.buildNumber(data.count) || 10
|
count: this.buildNumber(data.count) || 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { MiniatureDisplayOptions } from '../../shared-video-miniature'
|
||||||
})
|
})
|
||||||
export class VideoMiniatureMarkupComponent implements OnInit {
|
export class VideoMiniatureMarkupComponent implements OnInit {
|
||||||
@Input() uuid: string
|
@Input() uuid: string
|
||||||
|
@Input() onlyDisplayTitle: boolean
|
||||||
|
|
||||||
video: Video
|
video: Video
|
||||||
|
|
||||||
|
@ -38,6 +39,12 @@ export class VideoMiniatureMarkupComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
|
if (this.onlyDisplayTitle) {
|
||||||
|
for (const key of Object.keys(this.displayOptions)) {
|
||||||
|
this.displayOptions[key] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.videoService.getVideo({ videoId: this.uuid })
|
this.videoService.getVideo({ videoId: this.uuid })
|
||||||
.subscribe(video => this.video = video)
|
.subscribe(video => this.video = video)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Component, Input, OnInit } from '@angular/core'
|
import { Component, Input, OnInit } from '@angular/core'
|
||||||
import { AuthService } from '@app/core'
|
import { AuthService } from '@app/core'
|
||||||
import { VideoSortField } from '@shared/models'
|
import { VideoFilter, VideoSortField } from '@shared/models'
|
||||||
import { Video, VideoService } from '../../shared-main'
|
import { Video, VideoService } from '../../shared-main'
|
||||||
import { MiniatureDisplayOptions } from '../../shared-video-miniature'
|
import { MiniatureDisplayOptions } from '../../shared-video-miniature'
|
||||||
|
|
||||||
|
@ -14,15 +14,17 @@ import { MiniatureDisplayOptions } from '../../shared-video-miniature'
|
||||||
styleUrls: [ 'videos-list-markup.component.scss' ]
|
styleUrls: [ 'videos-list-markup.component.scss' ]
|
||||||
})
|
})
|
||||||
export class VideosListMarkupComponent implements OnInit {
|
export class VideosListMarkupComponent implements OnInit {
|
||||||
@Input() sort = '-publishedAt'
|
@Input() sort: string
|
||||||
@Input() categoryOneOf: number[]
|
@Input() categoryOneOf: number[]
|
||||||
@Input() languageOneOf: string[]
|
@Input() languageOneOf: string[]
|
||||||
@Input() count = 10
|
@Input() count: number
|
||||||
|
@Input() onlyDisplayTitle: boolean
|
||||||
|
@Input() filter: VideoFilter
|
||||||
|
|
||||||
videos: Video[]
|
videos: Video[]
|
||||||
|
|
||||||
displayOptions: MiniatureDisplayOptions = {
|
displayOptions: MiniatureDisplayOptions = {
|
||||||
date: true,
|
date: false,
|
||||||
views: true,
|
views: true,
|
||||||
by: true,
|
by: true,
|
||||||
avatar: false,
|
avatar: false,
|
||||||
|
@ -42,6 +44,12 @@ export class VideosListMarkupComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
|
if (this.onlyDisplayTitle) {
|
||||||
|
for (const key of Object.keys(this.displayOptions)) {
|
||||||
|
this.displayOptions[key] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
videoPagination: {
|
videoPagination: {
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
|
@ -49,6 +57,7 @@ export class VideosListMarkupComponent implements OnInit {
|
||||||
},
|
},
|
||||||
categoryOneOf: this.categoryOneOf,
|
categoryOneOf: this.categoryOneOf,
|
||||||
languageOneOf: this.languageOneOf,
|
languageOneOf: this.languageOneOf,
|
||||||
|
filter: this.filter,
|
||||||
sort: this.sort as VideoSortField
|
sort: this.sort as VideoSortField
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ export type EmbedMarkupData = {
|
||||||
export type VideoMiniatureMarkupData = {
|
export type VideoMiniatureMarkupData = {
|
||||||
// Video uuid
|
// Video uuid
|
||||||
uuid: string
|
uuid: string
|
||||||
|
|
||||||
|
onlyDisplayTitle?: string // boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PlaylistMiniatureMarkupData = {
|
export type PlaylistMiniatureMarkupData = {
|
||||||
|
@ -19,17 +21,22 @@ export type ChannelMiniatureMarkupData = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type VideosListMarkupData = {
|
export type VideosListMarkupData = {
|
||||||
sort: string
|
onlyDisplayTitle?: string // boolean
|
||||||
categoryOneOf: string // coma separated values
|
|
||||||
languageOneOf: string // coma separated values
|
sort?: string
|
||||||
count: string
|
count?: string
|
||||||
|
|
||||||
|
categoryOneOf?: string // coma separated values
|
||||||
|
languageOneOf?: string // coma separated values
|
||||||
|
|
||||||
|
onlyLocal?: string // boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ButtonMarkupData = {
|
export type ButtonMarkupData = {
|
||||||
theme: 'primary' | 'secondary'
|
theme: 'primary' | 'secondary'
|
||||||
href: string
|
href: string
|
||||||
label: string
|
label: string
|
||||||
blankTarget?: string
|
blankTarget?: string // boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ContainerMarkupData = {
|
export type ContainerMarkupData = {
|
||||||
|
|
Loading…
Reference in New Issue