diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-08 15:15:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-08 15:55:32 +0200 |
commit | 791645e620fb98c6e7c32271d91d91ff7e41b892 (patch) | |
tree | b9554ae53c93c1e699d8cc2e137128e599a4c045 /client/src/app/shared/moderation/user-ban-modal.component.ts | |
parent | 80c7336a896d9eb1e71b7c89a72285f914259457 (diff) | |
download | PeerTube-791645e620fb98c6e7c32271d91d91ff7e41b892.tar.gz PeerTube-791645e620fb98c6e7c32271d91d91ff7e41b892.tar.zst PeerTube-791645e620fb98c6e7c32271d91d91ff7e41b892.zip |
Add bulk actions in users table
Diffstat (limited to 'client/src/app/shared/moderation/user-ban-modal.component.ts')
-rw-r--r-- | client/src/app/shared/moderation/user-ban-modal.component.ts | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/client/src/app/shared/moderation/user-ban-modal.component.ts b/client/src/app/shared/moderation/user-ban-modal.component.ts index 67ae38e48..60bd442dd 100644 --- a/client/src/app/shared/moderation/user-ban-modal.component.ts +++ b/client/src/app/shared/moderation/user-ban-modal.component.ts | |||
@@ -15,9 +15,9 @@ import { User } from '../../../../../shared' | |||
15 | }) | 15 | }) |
16 | export class UserBanModalComponent extends FormReactive implements OnInit { | 16 | export class UserBanModalComponent extends FormReactive implements OnInit { |
17 | @ViewChild('modal') modal: NgbModal | 17 | @ViewChild('modal') modal: NgbModal |
18 | @Output() userBanned = new EventEmitter<User>() | 18 | @Output() userBanned = new EventEmitter<User | User[]>() |
19 | 19 | ||
20 | private userToBan: User | 20 | private usersToBan: User | User[] |
21 | private openedModal: NgbModalRef | 21 | private openedModal: NgbModalRef |
22 | 22 | ||
23 | constructor ( | 23 | constructor ( |
@@ -37,28 +37,29 @@ export class UserBanModalComponent extends FormReactive implements OnInit { | |||
37 | }) | 37 | }) |
38 | } | 38 | } |
39 | 39 | ||
40 | openModal (user: User) { | 40 | openModal (user: User | User[]) { |
41 | this.userToBan = user | 41 | this.usersToBan = user |
42 | this.openedModal = this.modalService.open(this.modal) | 42 | this.openedModal = this.modalService.open(this.modal) |
43 | } | 43 | } |
44 | 44 | ||
45 | hideBanUserModal () { | 45 | hideBanUserModal () { |
46 | this.userToBan = undefined | 46 | this.usersToBan = undefined |
47 | this.openedModal.close() | 47 | this.openedModal.close() |
48 | } | 48 | } |
49 | 49 | ||
50 | async banUser () { | 50 | async banUser () { |
51 | const reason = this.form.value['reason'] || undefined | 51 | const reason = this.form.value['reason'] || undefined |
52 | 52 | ||
53 | this.userService.banUser(this.userToBan, reason) | 53 | this.userService.banUsers(this.usersToBan, reason) |
54 | .subscribe( | 54 | .subscribe( |
55 | () => { | 55 | () => { |
56 | this.notificationsService.success( | 56 | const message = Array.isArray(this.usersToBan) |
57 | this.i18n('Success'), | 57 | ? this.i18n('{{num}} users banned.', { num: this.usersToBan.length }) |
58 | this.i18n('User {{username}} banned.', { username: this.userToBan.username }) | 58 | : this.i18n('User {{username}} banned.', { username: this.usersToBan.username }) |
59 | ) | ||
60 | 59 | ||
61 | this.userBanned.emit(this.userToBan) | 60 | this.notificationsService.success(this.i18n('Success'), message) |
61 | |||
62 | this.userBanned.emit(this.usersToBan) | ||
62 | this.hideBanUserModal() | 63 | this.hideBanUserModal() |
63 | }, | 64 | }, |
64 | 65 | ||