]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts
variable columns for users list, more columns possible, badge display for statuses
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-ownership / my-account-ownership.component.ts
CommitLineData
f77eb73b 1import { SortMeta } from 'primeng/api'
67ed6552
C
2import { Component, OnInit, ViewChild } from '@angular/core'
3import { Notifier, RestPagination, RestTable } from '@app/core'
4c9e9d2e 4import { VideoOwnershipService, Actor, Video, Account } from '@app/shared/shared-main'
67ed6552 5import { VideoChangeOwnership } from '@shared/models'
f8b2c1b4 6import { MyAccountAcceptOwnershipComponent } from './my-account-accept-ownership/my-account-accept-ownership.component'
4c9e9d2e 7import { getAbsoluteAPIUrl } from '@app/helpers'
74d63469
GR
8
9@Component({
10 selector: 'my-account-ownership',
4c9e9d2e
RK
11 templateUrl: './my-account-ownership.component.html',
12 styleUrls: [ './my-account-ownership.component.scss' ]
74d63469
GR
13})
14export class MyAccountOwnershipComponent extends RestTable implements OnInit {
15 videoChangeOwnerships: VideoChangeOwnership[] = []
16 totalRecords = 0
74d63469
GR
17 sort: SortMeta = { field: 'createdAt', order: -1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
19
f36da21e 20 @ViewChild('myAccountAcceptOwnershipComponent', { static: true }) myAccountAcceptOwnershipComponent: MyAccountAcceptOwnershipComponent
74d63469
GR
21
22 constructor (
f8b2c1b4
C
23 private notifier: Notifier,
24 private videoOwnershipService: VideoOwnershipService
74d63469
GR
25 ) {
26 super()
27 }
28
29 ngOnInit () {
24b9417c 30 this.initialize()
74d63469
GR
31 }
32
8e11a1b3
C
33 getIdentifier () {
34 return 'MyAccountOwnershipComponent'
35 }
36
4c9e9d2e
RK
37 switchToDefaultAvatar ($event: Event) {
38 ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
74d63469
GR
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(),
f8b2c1b4 53 err => this.notifier.error(err.message)
74d63469
GR
54 )
55 }
dffd5d12
B
56
57 protected loadData () {
58 return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort)
59 .subscribe(
60 resultList => {
4c9e9d2e
RK
61 this.videoChangeOwnerships = resultList.data.map(change => ({
62 ...change,
63 initiatorAccount: new Account(change.initiatorAccount),
64 nextOwnerAccount: new Account(change.nextOwnerAccount)
65 }))
dffd5d12
B
66 this.totalRecords = resultList.total
67 },
68
f8b2c1b4 69 err => this.notifier.error(err.message)
dffd5d12
B
70 )
71 }
74d63469 72}