diff options
Diffstat (limited to 'client/src/app/+my-account')
8 files changed, 14 insertions, 171 deletions
diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.html b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.html deleted file mode 100644 index 90f657521..000000000 --- a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.html +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | <div class="admin-sub-header"> | ||
2 | <h1 i18n class="form-sub-title">Muted accounts</h1> | ||
3 | </div> | ||
4 | |||
5 | <p-table | ||
6 | [value]="blockedAccounts" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" | ||
7 | [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" | ||
8 | > | ||
9 | |||
10 | <ng-template pTemplate="header"> | ||
11 | <tr> | ||
12 | <th i18n>Account</th> | ||
13 | <th i18n pSortableColumn="createdAt">Muted at <p-sortIcon field="createdAt"></p-sortIcon></th> | ||
14 | <th></th> <!-- column for action buttons --> | ||
15 | </tr> | ||
16 | </ng-template> | ||
17 | |||
18 | <ng-template pTemplate="body" let-accountBlock> | ||
19 | <tr> | ||
20 | <td>{{ accountBlock.blockedAccount.nameWithHost }}</td> | ||
21 | <td>{{ accountBlock.createdAt }}</td> | ||
22 | <td class="action-cell"> | ||
23 | <button class="unblock-button" (click)="unblockAccount(accountBlock)" i18n>Unmute</button> | ||
24 | </td> | ||
25 | </tr> | ||
26 | </ng-template> | ||
27 | </p-table> | ||
diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.scss b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.scss deleted file mode 100644 index 6028b75ea..000000000 --- a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.scss +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .unblock-button { | ||
5 | @include peertube-button; | ||
6 | @include grey-button; | ||
7 | } \ No newline at end of file | ||
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 index fd1fabcdb..e48c39cdf 100644 --- 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 | |||
@@ -1,59 +1,15 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component } from '@angular/core' |
2 | import { Notifier } from '@app/core' | 2 | import { GenericAccountBlocklistComponent, BlocklistComponentType } from '@app/shared/blocklist' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { RestPagination, RestTable } from '@app/shared' | ||
5 | import { SortMeta } from 'primeng/api' | ||
6 | import { AccountBlock, BlocklistService } from '@app/shared/blocklist' | ||
7 | 3 | ||
8 | @Component({ | 4 | @Component({ |
9 | selector: 'my-account-blocklist', | 5 | selector: 'my-account-blocklist', |
10 | styleUrls: [ './my-account-blocklist.component.scss' ], | 6 | styleUrls: [ '../../shared/blocklist/account-blocklist.component.scss' ], |
11 | templateUrl: './my-account-blocklist.component.html' | 7 | templateUrl: '../../shared/blocklist/account-blocklist.component.html' |
12 | }) | 8 | }) |
13 | export class MyAccountBlocklistComponent extends RestTable implements OnInit { | 9 | export class MyAccountBlocklistComponent extends GenericAccountBlocklistComponent { |
14 | blockedAccounts: AccountBlock[] = [] | 10 | mode = BlocklistComponentType.Account |
15 | totalRecords = 0 | ||
16 | sort: SortMeta = { field: 'createdAt', order: -1 } | ||
17 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
18 | |||
19 | constructor ( | ||
20 | private notifier: Notifier, | ||
21 | private blocklistService: BlocklistService, | ||
22 | private i18n: I18n | ||
23 | ) { | ||
24 | super() | ||
25 | } | ||
26 | |||
27 | ngOnInit () { | ||
28 | this.initialize() | ||
29 | } | ||
30 | 11 | ||
31 | getIdentifier () { | 12 | getIdentifier () { |
32 | return 'MyAccountBlocklistComponent' | 13 | return 'MyAccountBlocklistComponent' |
33 | } | 14 | } |
34 | |||
35 | unblockAccount (accountBlock: AccountBlock) { | ||
36 | const blockedAccount = accountBlock.blockedAccount | ||
37 | |||
38 | this.blocklistService.unblockAccountByUser(blockedAccount) | ||
39 | .subscribe( | ||
40 | () => { | ||
41 | this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost })) | ||
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.notifier.error(err.message) | ||
57 | ) | ||
58 | } | ||
59 | } | 15 | } |
diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.html b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.html deleted file mode 100644 index c31cff16f..000000000 --- a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.html +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | <div class="admin-sub-header"> | ||
2 | <h1 i18n class="form-sub-title">Muted instances</h1> | ||
3 | </div> | ||
4 | |||
5 | <p-table | ||
6 | [value]="blockedServers" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" | ||
7 | [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" | ||
8 | > | ||
9 | |||
10 | <ng-template pTemplate="header"> | ||
11 | <tr> | ||
12 | <th i18n>Instance</th> | ||
13 | <th i18n pSortableColumn="createdAt">Muted at <p-sortIcon field="createdAt"></p-sortIcon></th> | ||
14 | <th></th> <!-- column for action buttons --> | ||
15 | </tr> | ||
16 | </ng-template> | ||
17 | |||
18 | <ng-template pTemplate="body" let-serverBlock> | ||
19 | <tr> | ||
20 | <td>{{ serverBlock.blockedServer.host }}</td> | ||
21 | <td>{{ serverBlock.createdAt }}</td> | ||
22 | <td class="action-cell"> | ||
23 | <button class="unblock-button" (click)="unblockServer(serverBlock)" i18n>Unmute</button> | ||
24 | </td> | ||
25 | </tr> | ||
26 | </ng-template> | ||
27 | </p-table> | ||
diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.scss b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.scss deleted file mode 100644 index 6028b75ea..000000000 --- a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.scss +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .unblock-button { | ||
5 | @include peertube-button; | ||
6 | @include grey-button; | ||
7 | } \ No newline at end of file | ||
diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts index 483c11804..cfaba1c7b 100644 --- a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts +++ b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts | |||
@@ -1,60 +1,15 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component } from '@angular/core' |
2 | import { Notifier } from '@app/core' | 2 | import { GenericServerBlocklistComponent, BlocklistComponentType } from '@app/shared/blocklist' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { RestPagination, RestTable } from '@app/shared' | ||
5 | import { SortMeta } from 'primeng/api' | ||
6 | import { ServerBlock } from '../../../../../shared' | ||
7 | import { BlocklistService } from '@app/shared/blocklist' | ||
8 | 3 | ||
9 | @Component({ | 4 | @Component({ |
10 | selector: 'my-account-server-blocklist', | 5 | selector: 'my-account-server-blocklist', |
11 | styleUrls: [ './my-account-server-blocklist.component.scss' ], | 6 | styleUrls: [ '../../+admin/moderation/moderation.component.scss', '../../shared/blocklist/server-blocklist.component.scss' ], |
12 | templateUrl: './my-account-server-blocklist.component.html' | 7 | templateUrl: '../../shared/blocklist/server-blocklist.component.html' |
13 | }) | 8 | }) |
14 | export class MyAccountServerBlocklistComponent extends RestTable implements OnInit { | 9 | export class MyAccountServerBlocklistComponent extends GenericServerBlocklistComponent { |
15 | blockedServers: ServerBlock[] = [] | 10 | mode = BlocklistComponentType.Account |
16 | totalRecords = 0 | ||
17 | sort: SortMeta = { field: 'createdAt', order: -1 } | ||
18 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
19 | |||
20 | constructor ( | ||
21 | private notifier: Notifier, | ||
22 | private blocklistService: BlocklistService, | ||
23 | private i18n: I18n | ||
24 | ) { | ||
25 | super() | ||
26 | } | ||
27 | |||
28 | ngOnInit () { | ||
29 | this.initialize() | ||
30 | } | ||
31 | 11 | ||
32 | getIdentifier () { | 12 | getIdentifier () { |
33 | return 'MyAccountServerBlocklistComponent' | 13 | return 'MyAccountServerBlocklistComponent' |
34 | } | 14 | } |
35 | |||
36 | unblockServer (serverBlock: ServerBlock) { | ||
37 | const host = serverBlock.blockedServer.host | ||
38 | |||
39 | this.blocklistService.unblockServerByUser(host) | ||
40 | .subscribe( | ||
41 | () => { | ||
42 | this.notifier.success(this.i18n('Instance {{host}} unmuted.', { host })) | ||
43 | |||
44 | this.loadData() | ||
45 | } | ||
46 | ) | ||
47 | } | ||
48 | |||
49 | protected loadData () { | ||
50 | return this.blocklistService.getUserServerBlocklist(this.pagination, this.sort) | ||
51 | .subscribe( | ||
52 | resultList => { | ||
53 | this.blockedServers = resultList.data | ||
54 | this.totalRecords = resultList.total | ||
55 | }, | ||
56 | |||
57 | err => this.notifier.error(err.message) | ||
58 | ) | ||
59 | } | ||
60 | } | 15 | } |
diff --git a/client/src/app/+my-account/my-account-routing.module.ts b/client/src/app/+my-account/my-account-routing.module.ts index f44b60ec9..f6b711e09 100644 --- a/client/src/app/+my-account/my-account-routing.module.ts +++ b/client/src/app/+my-account/my-account-routing.module.ts | |||
@@ -140,7 +140,7 @@ const myAccountRoutes: Routes = [ | |||
140 | component: MyAccountServerBlocklistComponent, | 140 | component: MyAccountServerBlocklistComponent, |
141 | data: { | 141 | data: { |
142 | meta: { | 142 | meta: { |
143 | title: 'Muted instances' | 143 | title: 'Muted servers' |
144 | } | 144 | } |
145 | } | 145 | } |
146 | }, | 146 | }, |
diff --git a/client/src/app/+my-account/my-account.component.ts b/client/src/app/+my-account/my-account.component.ts index 05dcf522d..ca447c054 100644 --- a/client/src/app/+my-account/my-account.component.ts +++ b/client/src/app/+my-account/my-account.component.ts | |||
@@ -72,7 +72,7 @@ export class MyAccountComponent implements OnInit { | |||
72 | iconName: 'user' | 72 | iconName: 'user' |
73 | }, | 73 | }, |
74 | { | 74 | { |
75 | label: this.i18n('Muted instances'), | 75 | label: this.i18n('Muted servers'), |
76 | routerLink: '/my-account/blocklist/servers', | 76 | routerLink: '/my-account/blocklist/servers', |
77 | iconName: 'server' | 77 | iconName: 'server' |
78 | }, | 78 | }, |