]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts
Improving select displays, focus box-shadows for paginators, instructions for index url
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-blocklist / my-account-server-blocklist.component.ts
CommitLineData
af5767ff 1import { Component, OnInit } from '@angular/core'
f8b2c1b4 2import { Notifier } from '@app/core'
af5767ff
C
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { RestPagination, RestTable } from '@app/shared'
f77eb73b 5import { SortMeta } from 'primeng/api'
af5767ff
C
6import { ServerBlock } from '../../../../../shared'
7import { BlocklistService } from '@app/shared/blocklist'
8
9@Component({
10 selector: 'my-account-server-blocklist',
11 styleUrls: [ './my-account-server-blocklist.component.scss' ],
12 templateUrl: './my-account-server-blocklist.component.html'
13})
14export class MyAccountServerBlocklistComponent extends RestTable implements OnInit {
92ea70a7 15 blockedServers: ServerBlock[] = []
af5767ff
C
16 totalRecords = 0
17 rowsPerPage = 10
18 sort: SortMeta = { field: 'createdAt', order: -1 }
19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
20
21 constructor (
f8b2c1b4 22 private notifier: Notifier,
af5767ff
C
23 private blocklistService: BlocklistService,
24 private i18n: I18n
25 ) {
26 super()
27 }
28
29 ngOnInit () {
30 this.initialize()
31 }
32
8e11a1b3
C
33 getIdentifier () {
34 return 'MyAccountServerBlocklistComponent'
35 }
36
af5767ff
C
37 unblockServer (serverBlock: ServerBlock) {
38 const host = serverBlock.blockedServer.host
39
40 this.blocklistService.unblockServerByUser(host)
41 .subscribe(
42 () => {
f8b2c1b4 43 this.notifier.success(this.i18n('Instance {{host}} unmuted.', { host }))
af5767ff
C
44
45 this.loadData()
46 }
47 )
48 }
49
50 protected loadData () {
51 return this.blocklistService.getUserServerBlocklist(this.pagination, this.sort)
52 .subscribe(
53 resultList => {
92ea70a7 54 this.blockedServers = resultList.data
af5767ff
C
55 this.totalRecords = resultList.total
56 },
57
f8b2c1b4 58 err => this.notifier.error(err.message)
af5767ff
C
59 )
60 }
61}