import { concat, Observable } from 'rxjs'
import { tap, toArray } from 'rxjs/operators'
-import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core'
+import { Component, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
-import { AuthService, ComponentPagination, ConfirmService, Notifier, RouteFilter, ScreenService, ServerService, User } from '@app/core'
+import { AuthService, ComponentPagination, ConfirmService, Notifier, ScreenService, ServerService, User } from '@app/core'
import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook'
import { immutableAssign } from '@app/helpers'
import { AdvancedInputFilter } from '@app/shared/shared-forms'
templateUrl: './my-videos.component.html',
styleUrls: [ './my-videos.component.scss' ]
})
-export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewInit, DisableForReuseHook {
+export class MyVideosComponent implements OnInit, DisableForReuseHook {
@ViewChild('videosSelection', { static: true }) videosSelection: VideosSelectionComponent
@ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent
@ViewChild('liveStreamInformationModal', { static: true }) liveStreamInformationModal: LiveStreamInformationComponent
videos: Video[] = []
getVideosObservableFunction = this.getVideosObservable.bind(this)
+
sort: VideoSortField = '-publishedAt'
user: User
inputFilters: AdvancedInputFilter[] = [
{
- queryParams: { 'search': 'isLive:true' },
+ queryParams: { search: 'isLive:true' },
label: $localize`Only live videos`
}
]
+ disabled = false
+
+ private search: string
+
constructor (
protected router: Router,
protected serverService: ServerService,
private confirmService: ConfirmService,
private videoService: VideoService
) {
- super()
-
this.titlePage = $localize`My videos`
}
this.buildActions()
this.user = this.authService.getUser()
-
- this.initSearch()
- this.listenToSearchChange()
}
- ngAfterViewInit () {
- if (this.search) this.setTableFilter(this.search, false)
+ onSearch (search: string) {
+ this.search = search
+ this.reloadData()
}
- loadData () {
+ reloadData () {
this.videosSelection.reloadVideos()
}
}
disableForReuse () {
- this.videosSelection.disableForReuse()
+ this.disabled = true
}
enabledForReuse () {
- this.videosSelection.enabledForReuse()
+ this.disabled = false
}
getVideosObservable (page: number) {
async deleteSelectedVideos () {
const toDeleteVideosIds = Object.keys(this.selection)
- .filter(k => this.selection[ k ] === true)
+ .filter(k => this.selection[k] === true)
.map(k => parseInt(k, 10))
const res = await this.confirmService.confirm(
concat(...observables)
.pipe(toArray())
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`${toDeleteVideosIds.length} videos deleted.`)
this.selection = {}
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async deleteVideo (video: Video) {
if (res === false) return
this.videoService.removeVideo(video.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video ${video.name} deleted.`)
this.removeVideoFromArray(video.id)
},
- error => this.notifier.error(error.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
changeOwnership (video: Video) {