Move admin stuff in +admin
This commit is contained in:
parent
047f9585dd
commit
05ac4ac7ed
|
@ -33,7 +33,7 @@ import { VideoRedundancyInformationComponent } from './follows/video-redundancie
|
||||||
import { AbuseListComponent, VideoBlockListComponent } from './moderation'
|
import { AbuseListComponent, VideoBlockListComponent } from './moderation'
|
||||||
import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from './moderation/instance-blocklist'
|
import { InstanceAccountBlocklistComponent, InstanceServerBlocklistComponent } from './moderation/instance-blocklist'
|
||||||
import { VideoCommentListComponent } from './moderation/video-comment-list'
|
import { VideoCommentListComponent } from './moderation/video-comment-list'
|
||||||
import { UserCreateComponent, UserListComponent, UserPasswordComponent, UserUpdateComponent, VideoListComponent } from './overview'
|
import { UserCreateComponent, UserListComponent, UserPasswordComponent, UserUpdateComponent, VideoAdminService, VideoListComponent } from './overview'
|
||||||
import { PluginListInstalledComponent } from './plugins/plugin-list-installed/plugin-list-installed.component'
|
import { PluginListInstalledComponent } from './plugins/plugin-list-installed/plugin-list-installed.component'
|
||||||
import { PluginSearchComponent } from './plugins/plugin-search/plugin-search.component'
|
import { PluginSearchComponent } from './plugins/plugin-search/plugin-search.component'
|
||||||
import { PluginShowInstalledComponent } from './plugins/plugin-show-installed/plugin-show-installed.component'
|
import { PluginShowInstalledComponent } from './plugins/plugin-show-installed/plugin-show-installed.component'
|
||||||
|
@ -116,7 +116,8 @@ import { JobsComponent } from './system/jobs/jobs.component'
|
||||||
DebugService,
|
DebugService,
|
||||||
ConfigService,
|
ConfigService,
|
||||||
PluginApiService,
|
PluginApiService,
|
||||||
EditConfigurationService
|
EditConfigurationService,
|
||||||
|
VideoAdminService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AdminModule { }
|
export class AdminModule { }
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
|
export * from './video-admin.service'
|
||||||
export * from './video-list.component'
|
export * from './video-list.component'
|
||||||
export * from './video.routes'
|
export * from './video.routes'
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
import { Observable } from 'rxjs'
|
||||||
|
import { catchError, switchMap } from 'rxjs/operators'
|
||||||
|
import { HttpClient, HttpParams } from '@angular/common/http'
|
||||||
|
import { Injectable } from '@angular/core'
|
||||||
|
import { RestExtractor, RestPagination, RestService } from '@app/core'
|
||||||
|
import { AdvancedInputFilter } from '@app/shared/shared-forms'
|
||||||
|
import { CommonVideoParams, Video, VideoService } from '@app/shared/shared-main'
|
||||||
|
import { ResultList, VideoInclude } from '@shared/models'
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class VideoAdminService {
|
||||||
|
|
||||||
|
constructor (
|
||||||
|
private videoService: VideoService,
|
||||||
|
private authHttp: HttpClient,
|
||||||
|
private restExtractor: RestExtractor,
|
||||||
|
private restService: RestService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
getAdminVideos (
|
||||||
|
options: CommonVideoParams & { pagination: RestPagination, search?: string }
|
||||||
|
): Observable<ResultList<Video>> {
|
||||||
|
const { pagination, search } = options
|
||||||
|
|
||||||
|
let params = new HttpParams()
|
||||||
|
params = this.videoService.buildCommonVideosParams({ params, ...options })
|
||||||
|
|
||||||
|
params = params.set('start', pagination.start.toString())
|
||||||
|
.set('count', pagination.count.toString())
|
||||||
|
|
||||||
|
params = this.buildAdminParamsFromSearch(search, params)
|
||||||
|
|
||||||
|
return this.authHttp
|
||||||
|
.get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
|
||||||
|
.pipe(
|
||||||
|
switchMap(res => this.videoService.extractVideos(res)),
|
||||||
|
catchError(err => this.restExtractor.handleError(err))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
buildAdminInputFilter (): AdvancedInputFilter[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: $localize`Videos scope`,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
queryParams: { search: 'isLocal:false' },
|
||||||
|
label: $localize`Remote videos`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
queryParams: { search: 'isLocal:true' },
|
||||||
|
label: $localize`Local videos`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title: $localize`Include/Exclude`,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
queryParams: { search: 'excludeMuted' },
|
||||||
|
label: $localize`Exclude muted accounts`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildAdminParamsFromSearch (search: string, params: HttpParams) {
|
||||||
|
let include = VideoInclude.BLACKLISTED |
|
||||||
|
VideoInclude.BLOCKED_OWNER |
|
||||||
|
VideoInclude.HIDDEN_PRIVACY |
|
||||||
|
VideoInclude.NOT_PUBLISHED_STATE |
|
||||||
|
VideoInclude.FILES
|
||||||
|
|
||||||
|
if (!search) return this.restService.addObjectParams(params, { include })
|
||||||
|
|
||||||
|
const filters = this.restService.parseQueryStringFilter(search, {
|
||||||
|
isLocal: {
|
||||||
|
prefix: 'isLocal:',
|
||||||
|
isBoolean: true
|
||||||
|
},
|
||||||
|
excludeMuted: {
|
||||||
|
prefix: 'excludeMuted',
|
||||||
|
handler: () => true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (filters.excludeMuted) {
|
||||||
|
include &= ~VideoInclude.BLOCKED_OWNER
|
||||||
|
|
||||||
|
filters.excludeMuted = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.restService.addObjectParams(params, { ...filters, include })
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import { AdvancedInputFilter } from '@app/shared/shared-forms'
|
||||||
import { DropdownAction, Video, VideoService } from '@app/shared/shared-main'
|
import { DropdownAction, Video, VideoService } from '@app/shared/shared-main'
|
||||||
import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature'
|
import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature'
|
||||||
import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
|
import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
|
||||||
|
import { VideoAdminService } from './video-admin.service'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-video-list',
|
selector: 'my-video-list',
|
||||||
|
@ -46,7 +47,8 @@ export class VideoListComponent extends RestTable implements OnInit {
|
||||||
private confirmService: ConfirmService,
|
private confirmService: ConfirmService,
|
||||||
private auth: AuthService,
|
private auth: AuthService,
|
||||||
private notifier: Notifier,
|
private notifier: Notifier,
|
||||||
private videoService: VideoService
|
private videoService: VideoService,
|
||||||
|
private videoAdminService: VideoAdminService
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
@ -58,7 +60,7 @@ export class VideoListComponent extends RestTable implements OnInit {
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.initialize()
|
this.initialize()
|
||||||
|
|
||||||
this.inputFilters = this.videoService.buildAdminInputFilter()
|
this.inputFilters = this.videoAdminService.buildAdminInputFilter()
|
||||||
|
|
||||||
this.bulkVideoActions = [
|
this.bulkVideoActions = [
|
||||||
[
|
[
|
||||||
|
@ -128,7 +130,7 @@ export class VideoListComponent extends RestTable implements OnInit {
|
||||||
|
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
||||||
this.videoService.getAdminVideos({
|
this.videoAdminService.getAdminVideos({
|
||||||
pagination: this.pagination,
|
pagination: this.pagination,
|
||||||
sort: this.sort,
|
sort: this.sort,
|
||||||
search: this.search
|
search: this.search
|
||||||
|
|
|
@ -3,9 +3,8 @@ import { from, Observable } from 'rxjs'
|
||||||
import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
|
import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
|
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { ComponentPaginationLight, RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core'
|
import { ComponentPaginationLight, RestExtractor, RestService, ServerService, UserService } from '@app/core'
|
||||||
import { objectToFormData } from '@app/helpers'
|
import { objectToFormData } from '@app/helpers'
|
||||||
import { AdvancedInputFilter } from '@app/shared/shared-forms'
|
|
||||||
import {
|
import {
|
||||||
BooleanBothQuery,
|
BooleanBothQuery,
|
||||||
FeedFormat,
|
FeedFormat,
|
||||||
|
@ -204,27 +203,6 @@ export class VideoService {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getAdminVideos (
|
|
||||||
options: CommonVideoParams & { pagination: RestPagination, search?: string }
|
|
||||||
): Observable<ResultList<Video>> {
|
|
||||||
const { pagination, search } = options
|
|
||||||
|
|
||||||
let params = new HttpParams()
|
|
||||||
params = this.buildCommonVideosParams({ params, ...options })
|
|
||||||
|
|
||||||
params = params.set('start', pagination.start.toString())
|
|
||||||
.set('count', pagination.count.toString())
|
|
||||||
|
|
||||||
params = this.buildAdminParamsFromSearch(search, params)
|
|
||||||
|
|
||||||
return this.authHttp
|
|
||||||
.get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
|
|
||||||
.pipe(
|
|
||||||
switchMap(res => this.extractVideos(res)),
|
|
||||||
catchError(err => this.restExtractor.handleError(err))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
getVideos (parameters: CommonVideoParams): Observable<ResultList<Video>> {
|
getVideos (parameters: CommonVideoParams): Observable<ResultList<Video>> {
|
||||||
let params = new HttpParams()
|
let params = new HttpParams()
|
||||||
params = this.buildCommonVideosParams({ params, ...parameters })
|
params = this.buildCommonVideosParams({ params, ...parameters })
|
||||||
|
@ -405,21 +383,7 @@ export class VideoService {
|
||||||
: 'both'
|
: 'both'
|
||||||
}
|
}
|
||||||
|
|
||||||
private setVideoRate (id: number, rateType: UserVideoRateType) {
|
buildCommonVideosParams (options: CommonVideoParams & { params: HttpParams }) {
|
||||||
const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate`
|
|
||||||
const body: UserVideoRateUpdate = {
|
|
||||||
rating: rateType
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.authHttp
|
|
||||||
.put(url, body)
|
|
||||||
.pipe(
|
|
||||||
map(this.restExtractor.extractDataBool),
|
|
||||||
catchError(err => this.restExtractor.handleError(err))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private buildCommonVideosParams (options: CommonVideoParams & { params: HttpParams }) {
|
|
||||||
const {
|
const {
|
||||||
params,
|
params,
|
||||||
videoPagination,
|
videoPagination,
|
||||||
|
@ -453,60 +417,17 @@ export class VideoService {
|
||||||
return newParams
|
return newParams
|
||||||
}
|
}
|
||||||
|
|
||||||
buildAdminInputFilter (): AdvancedInputFilter[] {
|
private setVideoRate (id: number, rateType: UserVideoRateType) {
|
||||||
return [
|
const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate`
|
||||||
{
|
const body: UserVideoRateUpdate = {
|
||||||
title: $localize`Videos scope`,
|
rating: rateType
|
||||||
children: [
|
|
||||||
{
|
|
||||||
queryParams: { search: 'isLocal:false' },
|
|
||||||
label: $localize`Remote videos`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
queryParams: { search: 'isLocal:true' },
|
|
||||||
label: $localize`Local videos`
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
title: $localize`Include/Exclude`,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
queryParams: { search: 'excludeMuted' },
|
|
||||||
label: $localize`Exclude muted accounts`
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
private buildAdminParamsFromSearch (search: string, params: HttpParams) {
|
|
||||||
let include = VideoInclude.BLACKLISTED |
|
|
||||||
VideoInclude.BLOCKED_OWNER |
|
|
||||||
VideoInclude.HIDDEN_PRIVACY |
|
|
||||||
VideoInclude.NOT_PUBLISHED_STATE |
|
|
||||||
VideoInclude.FILES
|
|
||||||
|
|
||||||
if (!search) return this.restService.addObjectParams(params, { include })
|
|
||||||
|
|
||||||
const filters = this.restService.parseQueryStringFilter(search, {
|
|
||||||
isLocal: {
|
|
||||||
prefix: 'isLocal:',
|
|
||||||
isBoolean: true
|
|
||||||
},
|
|
||||||
excludeMuted: {
|
|
||||||
prefix: 'excludeMuted',
|
|
||||||
handler: () => true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (filters.excludeMuted) {
|
|
||||||
include &= ~VideoInclude.BLOCKED_OWNER
|
|
||||||
|
|
||||||
filters.excludeMuted = undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.restService.addObjectParams(params, { ...filters, include })
|
return this.authHttp
|
||||||
|
.put(url, body)
|
||||||
|
.pipe(
|
||||||
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(err => this.restExtractor.handleError(err))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue