]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts
add aria-hidden to non-descriptive icons (#2844)
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-ownership / my-account-ownership.component.ts
1 import { Component, OnInit, ViewChild } from '@angular/core'
2 import { Notifier } from '@app/core'
3 import { RestPagination, RestTable } from '@app/shared'
4 import { SortMeta } from 'primeng/api'
5 import { VideoChangeOwnership } from '../../../../../shared'
6 import { VideoOwnershipService } from '@app/shared/video-ownership'
7 import { Account } from '@app/shared/account/account.model'
8 import { MyAccountAcceptOwnershipComponent } from './my-account-accept-ownership/my-account-accept-ownership.component'
9
10 @Component({
11 selector: 'my-account-ownership',
12 templateUrl: './my-account-ownership.component.html'
13 })
14 export class MyAccountOwnershipComponent extends RestTable implements OnInit {
15 videoChangeOwnerships: VideoChangeOwnership[] = []
16 totalRecords = 0
17 sort: SortMeta = { field: 'createdAt', order: -1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
19
20 @ViewChild('myAccountAcceptOwnershipComponent', { static: true }) myAccountAcceptOwnershipComponent: MyAccountAcceptOwnershipComponent
21
22 constructor (
23 private notifier: Notifier,
24 private videoOwnershipService: VideoOwnershipService
25 ) {
26 super()
27 }
28
29 ngOnInit () {
30 this.initialize()
31 }
32
33 getIdentifier () {
34 return 'MyAccountOwnershipComponent'
35 }
36
37 createByString (account: Account) {
38 return Account.CREATE_BY_STRING(account.name, account.host)
39 }
40
41 openAcceptModal (videoChangeOwnership: VideoChangeOwnership) {
42 this.myAccountAcceptOwnershipComponent.show(videoChangeOwnership)
43 }
44
45 accepted () {
46 this.loadData()
47 }
48
49 refuse (videoChangeOwnership: VideoChangeOwnership) {
50 this.videoOwnershipService.refuseOwnership(videoChangeOwnership.id)
51 .subscribe(
52 () => this.loadData(),
53 err => this.notifier.error(err.message)
54 )
55 }
56
57 protected loadData () {
58 return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort)
59 .subscribe(
60 resultList => {
61 this.videoChangeOwnerships = resultList.data
62 this.totalRecords = resultList.total
63 },
64
65 err => this.notifier.error(err.message)
66 )
67 }
68 }