1 import { SortMeta } from 'primeng/api'
2 import { Component, OnInit, ViewChild } from '@angular/core'
3 import { Notifier, RestPagination, RestTable } from '@app/core'
4 import { Account, VideoOwnershipService } from '@app/shared/shared-main'
5 import { VideoChangeOwnership } from '@shared/models'
6 import { MyAccountAcceptOwnershipComponent } from './my-account-accept-ownership/my-account-accept-ownership.component'
9 selector: 'my-account-ownership',
10 templateUrl: './my-account-ownership.component.html'
12 export class MyAccountOwnershipComponent extends RestTable implements OnInit {
13 videoChangeOwnerships: VideoChangeOwnership[] = []
15 sort: SortMeta = { field: 'createdAt', order: -1 }
16 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
18 @ViewChild('myAccountAcceptOwnershipComponent', { static: true }) myAccountAcceptOwnershipComponent: MyAccountAcceptOwnershipComponent
21 private notifier: Notifier,
22 private videoOwnershipService: VideoOwnershipService
32 return 'MyAccountOwnershipComponent'
35 createByString (account: Account) {
36 return Account.CREATE_BY_STRING(account.name, account.host)
39 openAcceptModal (videoChangeOwnership: VideoChangeOwnership) {
40 this.myAccountAcceptOwnershipComponent.show(videoChangeOwnership)
47 refuse (videoChangeOwnership: VideoChangeOwnership) {
48 this.videoOwnershipService.refuseOwnership(videoChangeOwnership.id)
50 () => this.loadData(),
51 err => this.notifier.error(err.message)
55 protected loadData () {
56 return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort)
59 this.videoChangeOwnerships = resultList.data
60 this.totalRecords = resultList.total
63 err => this.notifier.error(err.message)