import { SortMeta } from 'primeng/api'
-import { filter, switchMap } from 'rxjs/operators'
+import { switchMap } from 'rxjs/operators'
import { buildVideoLink, buildVideoOrPlaylistEmbed } from 'src/assets/player/utils'
import { environment } from 'src/environments/environment'
import { AfterViewInit, Component, OnInit } from '@angular/core'
import { DomSanitizer } from '@angular/platform-browser'
import { ActivatedRoute, Params, Router } from '@angular/router'
import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'
+import { AdvancedInputFilter } from '@app/shared/shared-forms'
import { DropdownAction, Video, VideoService } from '@app/shared/shared-main'
import { VideoBlockService } from '@app/shared/shared-moderation'
import { VideoBlacklist, VideoBlacklistType } from '@shared/models'
videoBlocklistActions: DropdownAction<VideoBlacklist>[][] = []
+ inputFilters: AdvancedInputFilter[] = [
+ {
+ queryParams: { 'search': 'type:auto' },
+ label: $localize`Automatic blocks`
+ },
+ {
+ queryParams: { 'search': 'type:manual' },
+ label: $localize`Manual blocks`
+ }
+ ]
+
constructor (
+ protected route: ActivatedRoute,
+ protected router: Router,
private notifier: Notifier,
private serverService: ServerService,
private confirmService: ConfirmService,
private videoBlocklistService: VideoBlockService,
private markdownRenderer: MarkdownService,
private sanitizer: DomSanitizer,
- private videoService: VideoService,
- private route: ActivatedRoute,
- private router: Router
- ) {
+ private videoService: VideoService
+ ) {
super()
this.videoBlocklistActions = [
})
this.initialize()
-
- this.route.queryParams
- .pipe(filter(params => params.search !== undefined && params.search !== null))
- .subscribe(params => {
- this.search = params.search
- this.setTableFilter(params.search)
- this.loadData()
- })
+ this.listenToSearchChange()
}
ngAfterViewInit () {
- if (this.search) this.setTableFilter(this.search)
- }
-
- /* Table filter functions */
- onBlockSearch (event: Event) {
- this.onSearch(event)
- this.setQueryParams((event.target as HTMLInputElement).value)
- }
-
- setQueryParams (search: string) {
- const queryParams: Params = {}
- if (search) Object.assign(queryParams, { search })
- this.router.navigate([ '/admin/moderation/video-blocks/list' ], { queryParams })
- }
-
- resetTableFilter () {
- this.setTableFilter('')
- this.setQueryParams('')
- this.resetSearch()
+ if (this.search) this.setTableFilter(this.search, false)
}
- /* END Table filter functions */
getIdentifier () {
return 'VideoBlockListComponent'
return Video.buildClientUrl(videoBlock.video.uuid)
}
- booleanToText (value: boolean) {
- if (value === true) return $localize`yes`
-
- return $localize`no`
- }
-
toHtml (text: string) {
return this.markdownRenderer.textMarkdownToHTML(text)
}
getVideoEmbed (entry: VideoBlacklist) {
return buildVideoOrPlaylistEmbed(
buildVideoLink({
- baseUrl: `${environment.embedUrl}/videos/embed/${entry.video.uuid}`,
+ baseUrl: `${environment.originServerUrl}/videos/embed/${entry.video.uuid}`,
title: false,
warningTitle: false
- })
+ }),
+ entry.video.name
)
}