1 import { SortMeta } from 'primeng/api'
2 import { Component, OnInit, ViewChild } from '@angular/core'
3 import { Notifier, RestPagination, RestTable } from '@app/core'
4 import { VideoOwnershipService, Actor, Video, Account } from '@app/shared/shared-main'
5 import { VideoChangeOwnership } from '@shared/models'
6 import { MyAccountAcceptOwnershipComponent } from './my-account-accept-ownership/my-account-accept-ownership.component'
7 import { getAbsoluteAPIUrl } from '@app/helpers'
10 selector: 'my-account-ownership',
11 templateUrl: './my-account-ownership.component.html',
12 styleUrls: [ './my-account-ownership.component.scss' ]
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 switchToDefaultAvatar ($event: Event) {
38 ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
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.map(change => ({
63 initiatorAccount: new Account(change.initiatorAccount),
64 nextOwnerAccount: new Account(change.nextOwnerAccount)
66 this.totalRecords = resultList.total
69 err => this.notifier.error(err.message)