]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/overview/videos/video-list.component.ts
Add ability to exclude muted accounts
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / overview / videos / video-list.component.ts
index 6885abfc7835d7490f377ba44482a50928028a63..31bf1707b6cb1196a867e8da1392782b6520dfb0 100644 (file)
@@ -1,11 +1,12 @@
 import { SortMeta } from 'primeng/api'
+import { finalize } from 'rxjs/operators'
 import { Component, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { AuthService, ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'
-import { DropdownAction, Video, VideoService } from '@app/shared/shared-main'
-import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
 import { AdvancedInputFilter } from '@app/shared/shared-forms'
+import { DropdownAction, Video, VideoService } from '@app/shared/shared-main'
 import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature'
+import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
 
 @Component({
   selector: 'my-video-list',
@@ -16,28 +17,14 @@ export class VideoListComponent extends RestTable implements OnInit {
   videos: Video[] = []
 
   totalRecords = 0
-  sort: SortMeta = { field: 'publishedAt', order: 1 }
+  sort: SortMeta = { field: 'publishedAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
   bulkVideoActions: DropdownAction<Video[]>[][] = []
 
   selectedVideos: Video[] = []
 
-  inputFilters: AdvancedInputFilter[] = [
-    {
-      title: $localize`Advanced filters`,
-      children: [
-        {
-          queryParams: { search: 'isLocal:false' },
-          label: $localize`Remote videos`
-        },
-        {
-          queryParams: { search: 'isLocal:true' },
-          label: $localize`Local videos`
-        }
-      ]
-    }
-  ]
+  inputFilters: AdvancedInputFilter[]
 
   videoActionsOptions: VideoActionsDisplayType = {
     playlist: false,
@@ -51,6 +38,8 @@ export class VideoListComponent extends RestTable implements OnInit {
     liveInfo: false
   }
 
+  loading = true
+
   constructor (
     protected route: ActivatedRoute,
     protected router: Router,
@@ -69,6 +58,8 @@ export class VideoListComponent extends RestTable implements OnInit {
   ngOnInit () {
     this.initialize()
 
+    this.inputFilters = this.videoService.buildAdminInputFilter()
+
     this.bulkVideoActions = [
       [
         {
@@ -99,7 +90,7 @@ export class VideoListComponent extends RestTable implements OnInit {
   }
 
   isUnpublished (state: VideoState) {
-    return state !== VideoState.PUBLISHED
+    return state !== VideoState.LIVE_ENDED && state !== VideoState.PUBLISHED
   }
 
   isAccountBlocked (video: Video) {
@@ -135,18 +126,21 @@ export class VideoListComponent extends RestTable implements OnInit {
   protected reloadData () {
     this.selectedVideos = []
 
+    this.loading = true
+
     this.videoService.getAdminVideos({
       pagination: this.pagination,
       sort: this.sort,
       search: this.search
-    }).subscribe({
-      next: resultList => {
-        this.videos = resultList.data
-        this.totalRecords = resultList.total
-      },
-
-      error: err => this.notifier.error(err.message)
-    })
+    }).pipe(finalize(() => this.loading = false))
+      .subscribe({
+        next: resultList => {
+          this.videos = resultList.data
+          this.totalRecords = resultList.total
+        },
+
+        error: err => this.notifier.error(err.message)
+      })
   }
 
   private async removeVideos (videos: Video[]) {