]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts
Add external login buttons
[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 16 totalRecords = 0
af5767ff
C
17 sort: SortMeta = { field: 'createdAt', order: -1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
19
20 constructor (
f8b2c1b4 21 private notifier: Notifier,
af5767ff
C
22 private blocklistService: BlocklistService,
23 private i18n: I18n
24 ) {
25 super()
26 }
27
28 ngOnInit () {
29 this.initialize()
30 }
31
8e11a1b3
C
32 getIdentifier () {
33 return 'MyAccountServerBlocklistComponent'
34 }
35
af5767ff
C
36 unblockServer (serverBlock: ServerBlock) {
37 const host = serverBlock.blockedServer.host
38
39 this.blocklistService.unblockServerByUser(host)
40 .subscribe(
41 () => {
f8b2c1b4 42 this.notifier.success(this.i18n('Instance {{host}} unmuted.', { host }))
af5767ff
C
43
44 this.loadData()
45 }
46 )
47 }
48
49 protected loadData () {
50 return this.blocklistService.getUserServerBlocklist(this.pagination, this.sort)
51 .subscribe(
52 resultList => {
92ea70a7 53 this.blockedServers = resultList.data
af5767ff
C
54 this.totalRecords = resultList.total
55 },
56
f8b2c1b4 57 err => this.notifier.error(err.message)
af5767ff
C
58 )
59 }
60}