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