aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-12 17:26:40 +0200
committerChocobozzz <me@florianbigard.com>2018-10-16 16:41:36 +0200
commitaf5767ffae41b2d5604e41ba9a7225c623dd6735 (patch)
treeb96787bd134fe04d3d042795636df4bf17b5991f /client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
parent7ad9b9846c44d198a736183fb186c2039f5236b5 (diff)
downloadPeerTube-af5767ffae41b2d5604e41ba9a7225c623dd6735.tar.gz
PeerTube-af5767ffae41b2d5604e41ba9a7225c623dd6735.tar.zst
PeerTube-af5767ffae41b2d5604e41ba9a7225c623dd6735.zip
Add user/instance block by users in the client
Diffstat (limited to 'client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts')
-rw-r--r--client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts59
1 files changed, 59 insertions, 0 deletions
diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
new file mode 100644
index 000000000..fbad28410
--- /dev/null
+++ b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
@@ -0,0 +1,59 @@
1import { Component, OnInit } from '@angular/core'
2import { NotificationsService } from 'angular2-notifications'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { RestPagination, RestTable } from '@app/shared'
5import { SortMeta } from 'primeng/components/common/sortmeta'
6import { BlocklistService, AccountBlock } from '@app/shared/blocklist'
7
8@Component({
9 selector: 'my-account-blocklist',
10 styleUrls: [ './my-account-blocklist.component.scss' ],
11 templateUrl: './my-account-blocklist.component.html'
12})
13export class MyAccountBlocklistComponent extends RestTable implements OnInit {
14 blockedAccounts: AccountBlock[] = []
15 totalRecords = 0
16 rowsPerPage = 10
17 sort: SortMeta = { field: 'createdAt', order: -1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
19
20 constructor (
21 private notificationsService: NotificationsService,
22 private blocklistService: BlocklistService,
23 private i18n: I18n
24 ) {
25 super()
26 }
27
28 ngOnInit () {
29 this.initialize()
30 }
31
32 unblockAccount (accountBlock: AccountBlock) {
33 const blockedAccount = accountBlock.blockedAccount
34
35 this.blocklistService.unblockAccountByUser(blockedAccount)
36 .subscribe(
37 () => {
38 this.notificationsService.success(
39 this.i18n('Success'),
40 this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost })
41 )
42
43 this.loadData()
44 }
45 )
46 }
47
48 protected loadData () {
49 return this.blocklistService.getUserAccountBlocklist(this.pagination, this.sort)
50 .subscribe(
51 resultList => {
52 this.blockedAccounts = resultList.data
53 this.totalRecords = resultList.total
54 },
55
56 err => this.notificationsService.error(this.i18n('Error'), err.message)
57 )
58 }
59}