From 614d1ae928ec307b708c4a3eb423797353b1df2a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 14 Aug 2018 16:38:37 +0200 Subject: Regroup abuse and blacklisted videos inside "moderation" --- client/src/app/+admin/admin-routing.module.ts | 6 +- client/src/app/+admin/admin.component.html | 8 +- client/src/app/+admin/admin.module.ts | 8 +- client/src/app/+admin/moderation/index.ts | 4 + .../+admin/moderation/moderation.component.html | 11 ++ .../+admin/moderation/moderation.component.scss | 4 + .../app/+admin/moderation/moderation.component.ts | 19 ++++ .../src/app/+admin/moderation/moderation.routes.ts | 42 +++++++ .../+admin/moderation/video-abuse-list/index.ts | 2 + .../moderation-comment-modal.component.html | 32 ++++++ .../moderation-comment-modal.component.scss | 6 + .../moderation-comment-modal.component.ts | 73 ++++++++++++ .../video-abuse-list.component.html | 62 ++++++++++ .../video-abuse-list.component.scss | 6 + .../video-abuse-list/video-abuse-list.component.ts | 125 +++++++++++++++++++++ .../moderation/video-blacklist-list/index.ts | 1 + .../video-blacklist-list.component.html | 47 ++++++++ .../video-blacklist-list.component.scss | 6 + .../video-blacklist-list.component.ts | 81 +++++++++++++ client/src/app/+admin/video-abuses/index.ts | 3 - .../+admin/video-abuses/video-abuse-list/index.ts | 2 - .../moderation-comment-modal.component.html | 32 ------ .../moderation-comment-modal.component.scss | 6 - .../moderation-comment-modal.component.ts | 73 ------------ .../video-abuse-list.component.html | 66 ----------- .../video-abuse-list.component.scss | 6 - .../video-abuse-list/video-abuse-list.component.ts | 125 --------------------- .../+admin/video-abuses/video-abuses.component.ts | 8 -- .../app/+admin/video-abuses/video-abuses.routes.ts | 33 ------ client/src/app/+admin/video-blacklist/index.ts | 3 - .../video-blacklist/video-blacklist-list/index.ts | 1 - .../video-blacklist-list.component.html | 51 --------- .../video-blacklist-list.component.scss | 6 - .../video-blacklist-list.component.ts | 81 ------------- .../video-blacklist/video-blacklist.component.ts | 7 -- .../video-blacklist/video-blacklist.routes.ts | 33 ------ 36 files changed, 528 insertions(+), 551 deletions(-) create mode 100644 client/src/app/+admin/moderation/index.ts create mode 100644 client/src/app/+admin/moderation/moderation.component.html create mode 100644 client/src/app/+admin/moderation/moderation.component.scss create mode 100644 client/src/app/+admin/moderation/moderation.component.ts create mode 100644 client/src/app/+admin/moderation/moderation.routes.ts create mode 100644 client/src/app/+admin/moderation/video-abuse-list/index.ts create mode 100644 client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.html create mode 100644 client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.scss create mode 100644 client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts create mode 100644 client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html create mode 100644 client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.scss create mode 100644 client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts create mode 100644 client/src/app/+admin/moderation/video-blacklist-list/index.ts create mode 100644 client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.html create mode 100644 client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.scss create mode 100644 client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts delete mode 100644 client/src/app/+admin/video-abuses/index.ts delete mode 100644 client/src/app/+admin/video-abuses/video-abuse-list/index.ts delete mode 100644 client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.html delete mode 100644 client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.scss delete mode 100644 client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.ts delete mode 100644 client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html delete mode 100644 client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.scss delete mode 100644 client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts delete mode 100644 client/src/app/+admin/video-abuses/video-abuses.component.ts delete mode 100644 client/src/app/+admin/video-abuses/video-abuses.routes.ts delete mode 100644 client/src/app/+admin/video-blacklist/index.ts delete mode 100644 client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts delete mode 100644 client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html delete mode 100644 client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.scss delete mode 100644 client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts delete mode 100644 client/src/app/+admin/video-blacklist/video-blacklist.component.ts delete mode 100644 client/src/app/+admin/video-blacklist/video-blacklist.routes.ts (limited to 'client') diff --git a/client/src/app/+admin/admin-routing.module.ts b/client/src/app/+admin/admin-routing.module.ts index 0301d7601..ca31ba585 100644 --- a/client/src/app/+admin/admin-routing.module.ts +++ b/client/src/app/+admin/admin-routing.module.ts @@ -8,8 +8,7 @@ import { AdminComponent } from './admin.component' import { FollowsRoutes } from './follows' import { JobsRoutes } from './jobs/job.routes' import { UsersRoutes } from './users' -import { VideoAbusesRoutes } from './video-abuses' -import { VideoBlacklistRoutes } from './video-blacklist' +import { ModerationRoutes } from '@app/+admin/moderation/moderation.routes' const adminRoutes: Routes = [ { @@ -25,8 +24,7 @@ const adminRoutes: Routes = [ }, ...FollowsRoutes, ...UsersRoutes, - ...VideoAbusesRoutes, - ...VideoBlacklistRoutes, + ...ModerationRoutes, ...JobsRoutes, ...ConfigRoutes ] diff --git a/client/src/app/+admin/admin.component.html b/client/src/app/+admin/admin.component.html index 1b2b89c3a..345fb9f5a 100644 --- a/client/src/app/+admin/admin.component.html +++ b/client/src/app/+admin/admin.component.html @@ -8,12 +8,8 @@ Manage follows - - Video abuses - - - - Video blacklist + + Moderation diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts index 23ca5a6b3..e94aac1eb 100644 --- a/client/src/app/+admin/admin.module.ts +++ b/client/src/app/+admin/admin.module.ts @@ -11,9 +11,9 @@ import { JobsComponent } from './jobs/job.component' import { JobsListComponent } from './jobs/jobs-list/jobs-list.component' import { JobService } from './jobs/shared/job.service' import { UserCreateComponent, UserListComponent, UsersComponent, UserService, UserUpdateComponent } from './users' -import { ModerationCommentModalComponent, VideoAbuseListComponent, VideoAbusesComponent } from './video-abuses' -import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-blacklist' +import { ModerationCommentModalComponent, VideoAbuseListComponent, VideoBlacklistListComponent } from './moderation' import { UserBanModalComponent } from '@app/+admin/users/user-list/user-ban-modal.component' +import { ModerationComponent } from '@app/+admin/moderation/moderation.component' @NgModule({ imports: [ @@ -36,10 +36,8 @@ import { UserBanModalComponent } from '@app/+admin/users/user-list/user-ban-moda UserListComponent, UserBanModalComponent, - VideoBlacklistComponent, + ModerationComponent, VideoBlacklistListComponent, - - VideoAbusesComponent, VideoAbuseListComponent, ModerationCommentModalComponent, diff --git a/client/src/app/+admin/moderation/index.ts b/client/src/app/+admin/moderation/index.ts new file mode 100644 index 000000000..66e2c6a39 --- /dev/null +++ b/client/src/app/+admin/moderation/index.ts @@ -0,0 +1,4 @@ +export * from './video-abuse-list' +export * from './video-blacklist-list' +export * from './moderation.component' +export * from './moderation.routes' diff --git a/client/src/app/+admin/moderation/moderation.component.html b/client/src/app/+admin/moderation/moderation.component.html new file mode 100644 index 000000000..91e87fcd4 --- /dev/null +++ b/client/src/app/+admin/moderation/moderation.component.html @@ -0,0 +1,11 @@ +
+
Moderation
+ +
+
+ + \ No newline at end of file diff --git a/client/src/app/+admin/moderation/moderation.component.scss b/client/src/app/+admin/moderation/moderation.component.scss new file mode 100644 index 000000000..766d7853b --- /dev/null +++ b/client/src/app/+admin/moderation/moderation.component.scss @@ -0,0 +1,4 @@ +.form-sub-title { + flex-grow: 0; + margin-right: 30px; +} diff --git a/client/src/app/+admin/moderation/moderation.component.ts b/client/src/app/+admin/moderation/moderation.component.ts new file mode 100644 index 000000000..0f4efb970 --- /dev/null +++ b/client/src/app/+admin/moderation/moderation.component.ts @@ -0,0 +1,19 @@ +import { Component } from '@angular/core' +import { UserRight } from '../../../../../shared' +import { AuthService } from '@app/core/auth/auth.service' + +@Component({ + templateUrl: './moderation.component.html', + styleUrls: [ './moderation.component.scss' ] +}) +export class ModerationComponent { + constructor (private auth: AuthService) {} + + hasVideoAbusesRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_ABUSES) + } + + hasVideoBlacklistRight () { + return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) + } +} diff --git a/client/src/app/+admin/moderation/moderation.routes.ts b/client/src/app/+admin/moderation/moderation.routes.ts new file mode 100644 index 000000000..b133152d9 --- /dev/null +++ b/client/src/app/+admin/moderation/moderation.routes.ts @@ -0,0 +1,42 @@ +import { Routes } from '@angular/router' +import { UserRight } from '../../../../../shared' +import { UserRightGuard } from '@app/core' +import { VideoAbuseListComponent } from '@app/+admin/moderation/video-abuse-list' +import { VideoBlacklistListComponent } from '@app/+admin/moderation/video-blacklist-list' +import { ModerationComponent } from '@app/+admin/moderation/moderation.component' + +export const ModerationRoutes: Routes = [ + { + path: 'moderation', + component: ModerationComponent, + children: [ + { + path: '', + redirectTo: 'video-abuses/list', + pathMatch: 'full' + }, + { + path: 'video-abuses/list', + component: VideoAbuseListComponent, + canActivate: [ UserRightGuard ], + data: { + userRight: UserRight.MANAGE_VIDEO_ABUSES, + meta: { + title: 'Video abuses list' + } + } + }, + { + path: 'video-blacklist/list', + component: VideoBlacklistListComponent, + canActivate: [ UserRightGuard ], + data: { + userRight: UserRight.MANAGE_VIDEO_BLACKLIST, + meta: { + title: 'Blacklisted videos' + } + } + } + ] + } +] diff --git a/client/src/app/+admin/moderation/video-abuse-list/index.ts b/client/src/app/+admin/moderation/video-abuse-list/index.ts new file mode 100644 index 000000000..da7176e52 --- /dev/null +++ b/client/src/app/+admin/moderation/video-abuse-list/index.ts @@ -0,0 +1,2 @@ +export * from './video-abuse-list.component' +export * from './moderation-comment-modal.component' diff --git a/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.html b/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.html new file mode 100644 index 000000000..3a8424f68 --- /dev/null +++ b/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.html @@ -0,0 +1,32 @@ + + + + + + \ No newline at end of file diff --git a/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.scss b/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.scss new file mode 100644 index 000000000..afcdb9a16 --- /dev/null +++ b/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.scss @@ -0,0 +1,6 @@ +@import 'variables'; +@import 'mixins'; + +textarea { + @include peertube-textarea(100%, 100px); +} diff --git a/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts b/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts new file mode 100644 index 000000000..34ab384d1 --- /dev/null +++ b/client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts @@ -0,0 +1,73 @@ +import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' +import { NotificationsService } from 'angular2-notifications' +import { FormReactive, VideoAbuseService, VideoAbuseValidatorsService } from '../../../shared' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { NgbModal } from '@ng-bootstrap/ng-bootstrap' +import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' +import { FormValidatorService } from '../../../shared/forms/form-validators/form-validator.service' +import { VideoAbuse } from '../../../../../../shared/models/videos' + +@Component({ + selector: 'my-moderation-comment-modal', + templateUrl: './moderation-comment-modal.component.html', + styleUrls: [ './moderation-comment-modal.component.scss' ] +}) +export class ModerationCommentModalComponent extends FormReactive implements OnInit { + @ViewChild('modal') modal: NgbModal + @Output() commentUpdated = new EventEmitter() + + private abuseToComment: VideoAbuse + private openedModal: NgbModalRef + + constructor ( + protected formValidatorService: FormValidatorService, + private modalService: NgbModal, + private notificationsService: NotificationsService, + private videoAbuseService: VideoAbuseService, + private videoAbuseValidatorsService: VideoAbuseValidatorsService, + private i18n: I18n + ) { + super() + } + + ngOnInit () { + this.buildForm({ + moderationComment: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON + }) + } + + openModal (abuseToComment: VideoAbuse) { + this.abuseToComment = abuseToComment + this.openedModal = this.modalService.open(this.modal) + + this.form.patchValue({ + moderationComment: this.abuseToComment.moderationComment + }) + } + + hideModerationCommentModal () { + this.abuseToComment = undefined + this.openedModal.close() + this.form.reset() + } + + async banUser () { + const moderationComment: string = this.form.value['moderationComment'] + + this.videoAbuseService.updateVideoAbuse(this.abuseToComment, { moderationComment }) + .subscribe( + () => { + this.notificationsService.success( + this.i18n('Success'), + this.i18n('Comment updated.') + ) + + this.commentUpdated.emit(moderationComment) + this.hideModerationCommentModal() + }, + + err => this.notificationsService.error(this.i18n('Error'), err.message) + ) + } + +} diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html new file mode 100644 index 000000000..722ff7906 --- /dev/null +++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html @@ -0,0 +1,62 @@ + + + + + State + Reason + Reporter + Created + Video + + + + + + + + + + + + + + + + + + {{ videoAbuse.reason }} + + + + {{ createByString(videoAbuse.reporterAccount) }} + + + + {{ videoAbuse.createdAt }} + + + + {{ videoAbuse.video.name }} + + + + + + + + + + + + + Moderation comment: + {{ videoAbuse.moderationComment }} + + + + + + \ No newline at end of file diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.scss b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.scss new file mode 100644 index 000000000..2391fef8f --- /dev/null +++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.scss @@ -0,0 +1,6 @@ +@import 'variables'; +@import 'mixins'; + +.moderation-comment-label { + font-weight: $font-semibold; +} \ No newline at end of file diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts new file mode 100644 index 000000000..b17278b94 --- /dev/null +++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts @@ -0,0 +1,125 @@ +import { Component, OnInit, ViewChild } from '@angular/core' +import { Account } from '../../../shared/account/account.model' +import { NotificationsService } from 'angular2-notifications' +import { SortMeta } from 'primeng/components/common/sortmeta' +import { VideoAbuse, VideoAbuseState } from '../../../../../../shared' +import { RestPagination, RestTable, VideoAbuseService } from '../../../shared' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { DropdownAction } from '../../../shared/buttons/action-dropdown.component' +import { ConfirmService } from '../../../core/index' +import { ModerationCommentModalComponent } from './moderation-comment-modal.component' +import { Video } from '../../../shared/video/video.model' + +@Component({ + selector: 'my-video-abuse-list', + templateUrl: './video-abuse-list.component.html', + styleUrls: [ './video-abuse-list.component.scss'] +}) +export class VideoAbuseListComponent extends RestTable implements OnInit { + @ViewChild('moderationCommentModal') moderationCommentModal: ModerationCommentModalComponent + + videoAbuses: VideoAbuse[] = [] + totalRecords = 0 + rowsPerPage = 10 + sort: SortMeta = { field: 'createdAt', order: 1 } + pagination: RestPagination = { count: this.rowsPerPage, start: 0 } + + videoAbuseActions: DropdownAction[] = [] + + constructor ( + private notificationsService: NotificationsService, + private videoAbuseService: VideoAbuseService, + private confirmService: ConfirmService, + private i18n: I18n + ) { + super() + + this.videoAbuseActions = [ + { + label: this.i18n('Delete'), + handler: videoAbuse => this.removeVideoAbuse(videoAbuse) + }, + { + label: this.i18n('Update moderation comment'), + handler: videoAbuse => this.openModerationCommentModal(videoAbuse) + }, + { + label: this.i18n('Mark as accepted'), + handler: videoAbuse => this.updateVideoAbuseState(videoAbuse, VideoAbuseState.ACCEPTED), + isDisplayed: videoAbuse => !this.isVideoAbuseAccepted(videoAbuse) + }, + { + label: this.i18n('Mark as rejected'), + handler: videoAbuse => this.updateVideoAbuseState(videoAbuse, VideoAbuseState.REJECTED), + isDisplayed: videoAbuse => !this.isVideoAbuseRejected(videoAbuse) + } + ] + } + + ngOnInit () { + this.loadSort() + } + + openModerationCommentModal (videoAbuse: VideoAbuse) { + this.moderationCommentModal.openModal(videoAbuse) + } + + onModerationCommentUpdated () { + this.loadData() + } + + createByString (account: Account) { + return Account.CREATE_BY_STRING(account.name, account.host) + } + + isVideoAbuseAccepted (videoAbuse: VideoAbuse) { + return videoAbuse.state.id === VideoAbuseState.ACCEPTED + } + + isVideoAbuseRejected (videoAbuse: VideoAbuse) { + return videoAbuse.state.id === VideoAbuseState.REJECTED + } + + getVideoUrl (videoAbuse: VideoAbuse) { + return Video.buildClientUrl(videoAbuse.video.uuid) + } + + async removeVideoAbuse (videoAbuse: VideoAbuse) { + const res = await this.confirmService.confirm(this.i18n('Do you really want to delete this abuse?'), this.i18n('Delete')) + if (res === false) return + + this.videoAbuseService.removeVideoAbuse(videoAbuse).subscribe( + () => { + this.notificationsService.success( + this.i18n('Success'), + this.i18n('Abuse deleted.') + ) + this.loadData() + }, + + err => this.notificationsService.error(this.i18n('Error'), err.message) + ) + } + + updateVideoAbuseState (videoAbuse: VideoAbuse, state: VideoAbuseState) { + this.videoAbuseService.updateVideoAbuse(videoAbuse, { state }) + .subscribe( + () => this.loadData(), + + err => this.notificationsService.error(this.i18n('Error'), err.message) + ) + + } + + protected loadData () { + return this.videoAbuseService.getVideoAbuses(this.pagination, this.sort) + .subscribe( + resultList => { + this.videoAbuses = resultList.data + this.totalRecords = resultList.total + }, + + err => this.notificationsService.error(this.i18n('Error'), err.message) + ) + } +} diff --git a/client/src/app/+admin/moderation/video-blacklist-list/index.ts b/client/src/app/+admin/moderation/video-blacklist-list/index.ts new file mode 100644 index 000000000..4daf64187 --- /dev/null +++ b/client/src/app/+admin/moderation/video-blacklist-list/index.ts @@ -0,0 +1 @@ +export * from './video-blacklist-list.component' diff --git a/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.html b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.html new file mode 100644 index 000000000..dafaeb1e2 --- /dev/null +++ b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.html @@ -0,0 +1,47 @@ + + + + + Video name + Sensitive + Date + + + + + + + + + + + + + + + {{ videoBlacklist.video.name }} + + + + {{ videoBlacklist.video.nsfw }} + {{ videoBlacklist.createdAt }} + + + + + + + + + + + Blacklist reason: + {{ videoBlacklist.reason }} + + + + + diff --git a/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.scss b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.scss new file mode 100644 index 000000000..063f6324e --- /dev/null +++ b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.scss @@ -0,0 +1,6 @@ +@import 'variables'; +@import 'mixins'; + +.blacklist-reason-label { + font-weight: $font-semibold; +} \ No newline at end of file diff --git a/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts new file mode 100644 index 000000000..9890d1f90 --- /dev/null +++ b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts @@ -0,0 +1,81 @@ +import { Component, OnInit } from '@angular/core' +import { SortMeta } from 'primeng/components/common/sortmeta' +import { NotificationsService } from 'angular2-notifications' +import { ConfirmService } from '../../../core' +import { RestPagination, RestTable, VideoBlacklistService } from '../../../shared' +import { VideoBlacklist } from '../../../../../../shared' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { DropdownAction } from '../../../shared/buttons/action-dropdown.component' +import { Video } from '../../../shared/video/video.model' + +@Component({ + selector: 'my-video-blacklist-list', + templateUrl: './video-blacklist-list.component.html', + styleUrls: [ './video-blacklist-list.component.scss' ] +}) +export class VideoBlacklistListComponent extends RestTable implements OnInit { + blacklist: VideoBlacklist[] = [] + totalRecords = 0 + rowsPerPage = 10 + sort: SortMeta = { field: 'createdAt', order: 1 } + pagination: RestPagination = { count: this.rowsPerPage, start: 0 } + + videoBlacklistActions: DropdownAction[] = [] + + constructor ( + private notificationsService: NotificationsService, + private confirmService: ConfirmService, + private videoBlacklistService: VideoBlacklistService, + private i18n: I18n + ) { + super() + + this.videoBlacklistActions = [ + { + label: this.i18n('Unblacklist'), + handler: videoBlacklist => this.removeVideoFromBlacklist(videoBlacklist) + } + ] + } + + ngOnInit () { + this.loadSort() + } + + getVideoUrl (videoBlacklist: VideoBlacklist) { + return Video.buildClientUrl(videoBlacklist.video.uuid) + } + + async removeVideoFromBlacklist (entry: VideoBlacklist) { + const confirmMessage = this.i18n( + 'Do you really want to remove this video from the blacklist? It will be available again in the videos list.' + ) + + const res = await this.confirmService.confirm(confirmMessage, this.i18n('Unblacklist')) + if (res === false) return + + this.videoBlacklistService.removeVideoFromBlacklist(entry.video.id).subscribe( + () => { + this.notificationsService.success( + this.i18n('Success'), + this.i18n('Video {{name}} removed from the blacklist.', { name: entry.video.name }) + ) + this.loadData() + }, + + err => this.notificationsService.error(this.i18n('Error'), err.message) + ) + } + + protected loadData () { + this.videoBlacklistService.listBlacklist(this.pagination, this.sort) + .subscribe( + resultList => { + this.blacklist = resultList.data + this.totalRecords = resultList.total + }, + + err => this.notificationsService.error(this.i18n('Error'), err.message) + ) + } +} diff --git a/client/src/app/+admin/video-abuses/index.ts b/client/src/app/+admin/video-abuses/index.ts deleted file mode 100644 index 395fac2e7..000000000 --- a/client/src/app/+admin/video-abuses/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './video-abuse-list' -export * from './video-abuses.component' -export * from './video-abuses.routes' diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/index.ts b/client/src/app/+admin/video-abuses/video-abuse-list/index.ts deleted file mode 100644 index da7176e52..000000000 --- a/client/src/app/+admin/video-abuses/video-abuse-list/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './video-abuse-list.component' -export * from './moderation-comment-modal.component' diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.html b/client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.html deleted file mode 100644 index 3a8424f68..000000000 --- a/client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.scss b/client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.scss deleted file mode 100644 index afcdb9a16..000000000 --- a/client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.scss +++ /dev/null @@ -1,6 +0,0 @@ -@import 'variables'; -@import 'mixins'; - -textarea { - @include peertube-textarea(100%, 100px); -} diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.ts b/client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.ts deleted file mode 100644 index 7e8af6e5a..000000000 --- a/client/src/app/+admin/video-abuses/video-abuse-list/moderation-comment-modal.component.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' -import { NotificationsService } from 'angular2-notifications' -import { FormReactive, VideoAbuseService, VideoAbuseValidatorsService } from '../../../shared' -import { I18n } from '@ngx-translate/i18n-polyfill' -import { NgbModal } from '@ng-bootstrap/ng-bootstrap' -import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' -import { VideoAbuse } from '../../../../../../shared/models/videos' - -@Component({ - selector: 'my-moderation-comment-modal', - templateUrl: './moderation-comment-modal.component.html', - styleUrls: [ './moderation-comment-modal.component.scss' ] -}) -export class ModerationCommentModalComponent extends FormReactive implements OnInit { - @ViewChild('modal') modal: NgbModal - @Output() commentUpdated = new EventEmitter() - - private abuseToComment: VideoAbuse - private openedModal: NgbModalRef - - constructor ( - protected formValidatorService: FormValidatorService, - private modalService: NgbModal, - private notificationsService: NotificationsService, - private videoAbuseService: VideoAbuseService, - private videoAbuseValidatorsService: VideoAbuseValidatorsService, - private i18n: I18n - ) { - super() - } - - ngOnInit () { - this.buildForm({ - moderationComment: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON - }) - } - - openModal (abuseToComment: VideoAbuse) { - this.abuseToComment = abuseToComment - this.openedModal = this.modalService.open(this.modal) - - this.form.patchValue({ - moderationComment: this.abuseToComment.moderationComment - }) - } - - hideModerationCommentModal () { - this.abuseToComment = undefined - this.openedModal.close() - this.form.reset() - } - - async banUser () { - const moderationComment: string = this.form.value['moderationComment'] - - this.videoAbuseService.updateVideoAbuse(this.abuseToComment, { moderationComment }) - .subscribe( - () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Comment updated.') - ) - - this.commentUpdated.emit(moderationComment) - this.hideModerationCommentModal() - }, - - err => this.notificationsService.error(this.i18n('Error'), err.message) - ) - } - -} diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html deleted file mode 100644 index f213ab4b0..000000000 --- a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html +++ /dev/null @@ -1,66 +0,0 @@ -
-
Video abuses list
-
- - - - - - State - Reason - Reporter - Created - Video - - - - - - - - - - - - - - - - - - {{ videoAbuse.reason }} - - - - {{ createByString(videoAbuse.reporterAccount) }} - - - - {{ videoAbuse.createdAt }} - - - - {{ videoAbuse.video.name }} - - - - - - - - - - - - - Moderation comment: - {{ videoAbuse.moderationComment }} - - - - - - \ No newline at end of file diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.scss b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.scss deleted file mode 100644 index 951a3fc92..000000000 --- a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.scss +++ /dev/null @@ -1,6 +0,0 @@ -@import '_variables'; -@import '_mixins'; - -.moderation-comment-label { - font-weight: $font-semibold; -} \ No newline at end of file diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts deleted file mode 100644 index 377e9c80f..000000000 --- a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { Component, OnInit, ViewChild } from '@angular/core' -import { Account } from '@app/shared/account/account.model' -import { NotificationsService } from 'angular2-notifications' -import { SortMeta } from 'primeng/components/common/sortmeta' -import { VideoAbuse, VideoAbuseState } from '../../../../../../shared' -import { RestPagination, RestTable, VideoAbuseService } from '../../../shared' -import { I18n } from '@ngx-translate/i18n-polyfill' -import { DropdownAction } from '@app/shared/buttons/action-dropdown.component' -import { ConfirmService } from '@app/core' -import { ModerationCommentModalComponent } from './moderation-comment-modal.component' -import { Video } from '@app/shared/video/video.model' - -@Component({ - selector: 'my-video-abuse-list', - templateUrl: './video-abuse-list.component.html', - styleUrls: [ './video-abuse-list.component.scss'] -}) -export class VideoAbuseListComponent extends RestTable implements OnInit { - @ViewChild('moderationCommentModal') moderationCommentModal: ModerationCommentModalComponent - - videoAbuses: VideoAbuse[] = [] - totalRecords = 0 - rowsPerPage = 10 - sort: SortMeta = { field: 'createdAt', order: 1 } - pagination: RestPagination = { count: this.rowsPerPage, start: 0 } - - videoAbuseActions: DropdownAction[] = [] - - constructor ( - private notificationsService: NotificationsService, - private videoAbuseService: VideoAbuseService, - private confirmService: ConfirmService, - private i18n: I18n - ) { - super() - - this.videoAbuseActions = [ - { - label: this.i18n('Delete'), - handler: videoAbuse => this.removeVideoAbuse(videoAbuse) - }, - { - label: this.i18n('Update moderation comment'), - handler: videoAbuse => this.openModerationCommentModal(videoAbuse) - }, - { - label: this.i18n('Mark as accepted'), - handler: videoAbuse => this.updateVideoAbuseState(videoAbuse, VideoAbuseState.ACCEPTED), - isDisplayed: videoAbuse => !this.isVideoAbuseAccepted(videoAbuse) - }, - { - label: this.i18n('Mark as rejected'), - handler: videoAbuse => this.updateVideoAbuseState(videoAbuse, VideoAbuseState.REJECTED), - isDisplayed: videoAbuse => !this.isVideoAbuseRejected(videoAbuse) - } - ] - } - - ngOnInit () { - this.loadSort() - } - - openModerationCommentModal (videoAbuse: VideoAbuse) { - this.moderationCommentModal.openModal(videoAbuse) - } - - onModerationCommentUpdated () { - this.loadData() - } - - createByString (account: Account) { - return Account.CREATE_BY_STRING(account.name, account.host) - } - - isVideoAbuseAccepted (videoAbuse: VideoAbuse) { - return videoAbuse.state.id === VideoAbuseState.ACCEPTED - } - - isVideoAbuseRejected (videoAbuse: VideoAbuse) { - return videoAbuse.state.id === VideoAbuseState.REJECTED - } - - getVideoUrl (videoAbuse: VideoAbuse) { - return Video.buildClientUrl(videoAbuse.video.uuid) - } - - async removeVideoAbuse (videoAbuse: VideoAbuse) { - const res = await this.confirmService.confirm(this.i18n('Do you really want to delete this abuse?'), this.i18n('Delete')) - if (res === false) return - - this.videoAbuseService.removeVideoAbuse(videoAbuse).subscribe( - () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Abuse deleted.') - ) - this.loadData() - }, - - err => this.notificationsService.error(this.i18n('Error'), err.message) - ) - } - - updateVideoAbuseState (videoAbuse: VideoAbuse, state: VideoAbuseState) { - this.videoAbuseService.updateVideoAbuse(videoAbuse, { state }) - .subscribe( - () => this.loadData(), - - err => this.notificationsService.error(this.i18n('Error'), err.message) - ) - - } - - protected loadData () { - return this.videoAbuseService.getVideoAbuses(this.pagination, this.sort) - .subscribe( - resultList => { - this.videoAbuses = resultList.data - this.totalRecords = resultList.total - }, - - err => this.notificationsService.error(this.i18n('Error'), err.message) - ) - } -} diff --git a/client/src/app/+admin/video-abuses/video-abuses.component.ts b/client/src/app/+admin/video-abuses/video-abuses.component.ts deleted file mode 100644 index 9dae5c0b6..000000000 --- a/client/src/app/+admin/video-abuses/video-abuses.component.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Component } from '@angular/core' - -@Component({ - template: '' -}) - -export class VideoAbusesComponent { -} diff --git a/client/src/app/+admin/video-abuses/video-abuses.routes.ts b/client/src/app/+admin/video-abuses/video-abuses.routes.ts deleted file mode 100644 index 68b756059..000000000 --- a/client/src/app/+admin/video-abuses/video-abuses.routes.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Routes } from '@angular/router' - -import { UserRightGuard } from '../../core' -import { UserRight } from '../../../../../shared' -import { VideoAbusesComponent } from './video-abuses.component' -import { VideoAbuseListComponent } from './video-abuse-list' - -export const VideoAbusesRoutes: Routes = [ - { - path: 'video-abuses', - component: VideoAbusesComponent, - canActivate: [ UserRightGuard ], - data: { - userRight: UserRight.MANAGE_VIDEO_ABUSES - }, - children: [ - { - path: '', - redirectTo: 'list', - pathMatch: 'full' - }, - { - path: 'list', - component: VideoAbuseListComponent, - data: { - meta: { - title: 'Video abuses list' - } - } - } - ] - } -] diff --git a/client/src/app/+admin/video-blacklist/index.ts b/client/src/app/+admin/video-blacklist/index.ts deleted file mode 100644 index a5451e2e1..000000000 --- a/client/src/app/+admin/video-blacklist/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './video-blacklist-list' -export * from './video-blacklist.component' -export * from './video-blacklist.routes' diff --git a/client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts b/client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts deleted file mode 100644 index 4daf64187..000000000 --- a/client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './video-blacklist-list.component' diff --git a/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html deleted file mode 100644 index 05b3a300c..000000000 --- a/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html +++ /dev/null @@ -1,51 +0,0 @@ -
-
Blacklisted videos
-
- - - - - - Video name - Sensitive - Date - - - - - - - - - - - - - - - {{ videoBlacklist.video.name }} - - - - {{ videoBlacklist.video.nsfw }} - {{ videoBlacklist.createdAt }} - - - - - - - - - - - Blacklist reason: - {{ videoBlacklist.reason }} - - - - - diff --git a/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.scss b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.scss deleted file mode 100644 index 5265536ca..000000000 --- a/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.scss +++ /dev/null @@ -1,6 +0,0 @@ -@import '_variables'; -@import '_mixins'; - -.blacklist-reason-label { - font-weight: $font-semibold; -} \ No newline at end of file diff --git a/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts deleted file mode 100644 index 0618252b8..000000000 --- a/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { Component, OnInit } from '@angular/core' -import { SortMeta } from 'primeng/components/common/sortmeta' -import { NotificationsService } from 'angular2-notifications' -import { ConfirmService } from '../../../core' -import { RestPagination, RestTable, VideoBlacklistService } from '../../../shared' -import { VideoBlacklist } from '../../../../../../shared' -import { I18n } from '@ngx-translate/i18n-polyfill' -import { DropdownAction } from '@app/shared/buttons/action-dropdown.component' -import { Video } from '@app/shared/video/video.model' - -@Component({ - selector: 'my-video-blacklist-list', - templateUrl: './video-blacklist-list.component.html', - styleUrls: [ './video-blacklist-list.component.scss' ] -}) -export class VideoBlacklistListComponent extends RestTable implements OnInit { - blacklist: VideoBlacklist[] = [] - totalRecords = 0 - rowsPerPage = 10 - sort: SortMeta = { field: 'createdAt', order: 1 } - pagination: RestPagination = { count: this.rowsPerPage, start: 0 } - - videoBlacklistActions: DropdownAction[] = [] - - constructor ( - private notificationsService: NotificationsService, - private confirmService: ConfirmService, - private videoBlacklistService: VideoBlacklistService, - private i18n: I18n - ) { - super() - - this.videoBlacklistActions = [ - { - label: this.i18n('Unblacklist'), - handler: videoBlacklist => this.removeVideoFromBlacklist(videoBlacklist) - } - ] - } - - ngOnInit () { - this.loadSort() - } - - getVideoUrl (videoBlacklist: VideoBlacklist) { - return Video.buildClientUrl(videoBlacklist.video.uuid) - } - - async removeVideoFromBlacklist (entry: VideoBlacklist) { - const confirmMessage = this.i18n( - 'Do you really want to remove this video from the blacklist? It will be available again in the videos list.' - ) - - const res = await this.confirmService.confirm(confirmMessage, this.i18n('Unblacklist')) - if (res === false) return - - this.videoBlacklistService.removeVideoFromBlacklist(entry.video.id).subscribe( - () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Video {{name}} removed from the blacklist.', { name: entry.video.name }) - ) - this.loadData() - }, - - err => this.notificationsService.error(this.i18n('Error'), err.message) - ) - } - - protected loadData () { - this.videoBlacklistService.listBlacklist(this.pagination, this.sort) - .subscribe( - resultList => { - this.blacklist = resultList.data - this.totalRecords = resultList.total - }, - - err => this.notificationsService.error(this.i18n('Error'), err.message) - ) - } -} diff --git a/client/src/app/+admin/video-blacklist/video-blacklist.component.ts b/client/src/app/+admin/video-blacklist/video-blacklist.component.ts deleted file mode 100644 index 24b8c98f8..000000000 --- a/client/src/app/+admin/video-blacklist/video-blacklist.component.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Component } from '@angular/core' - -@Component({ - template: '' -}) -export class VideoBlacklistComponent { -} diff --git a/client/src/app/+admin/video-blacklist/video-blacklist.routes.ts b/client/src/app/+admin/video-blacklist/video-blacklist.routes.ts deleted file mode 100644 index b1e0e5049..000000000 --- a/client/src/app/+admin/video-blacklist/video-blacklist.routes.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Routes } from '@angular/router' - -import { UserRightGuard } from '../../core' -import { UserRight } from '../../../../../shared' -import { VideoBlacklistComponent } from './video-blacklist.component' -import { VideoBlacklistListComponent } from './video-blacklist-list' - -export const VideoBlacklistRoutes: Routes = [ - { - path: 'video-blacklist', - component: VideoBlacklistComponent, - canActivate: [ UserRightGuard ], - data: { - userRight: UserRight.MANAGE_VIDEO_BLACKLIST - }, - children: [ - { - path: '', - redirectTo: 'list', - pathMatch: 'full' - }, - { - path: 'list', - component: VideoBlacklistListComponent, - data: { - meta: { - title: 'Blacklisted videos' - } - } - } - ] - } -] -- cgit v1.2.3