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'
11 selector: 'my-account-ownership',
12 templateUrl: './my-account-ownership.component.html'
14 export class MyAccountOwnershipComponent extends RestTable implements OnInit {
15 videoChangeOwnerships: VideoChangeOwnership[] = []
17 sort: SortMeta = { field: 'createdAt', order: -1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
20 @ViewChild('myAccountAcceptOwnershipComponent', { static: true }) myAccountAcceptOwnershipComponent: MyAccountAcceptOwnershipComponent
23 private notifier: Notifier,
24 private videoOwnershipService: VideoOwnershipService
34 return 'MyAccountOwnershipComponent'
37 createByString (account: Account) {
38 return Account.CREATE_BY_STRING(account.name, account.host)
41 openAcceptModal (videoChangeOwnership: VideoChangeOwnership) {
42 this.myAccountAcceptOwnershipComponent.show(videoChangeOwnership)
49 refuse (videoChangeOwnership: VideoChangeOwnership) {
50 this.videoOwnershipService.refuseOwnership(videoChangeOwnership.id)
52 () => this.loadData(),
53 err => this.notifier.error(err.message)
57 protected loadData () {
58 return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort)
61 this.videoChangeOwnerships = resultList.data
62 this.totalRecords = resultList.total
65 err => this.notifier.error(err.message)