]>
Commit | Line | Data |
---|---|---|
74d63469 | 1 | import { Component, OnInit, ViewChild } from '@angular/core' |
f8b2c1b4 | 2 | import { Notifier } from '@app/core' |
74d63469 GR |
3 | import { RestPagination, RestTable } from '@app/shared' |
4 | import { SortMeta } from 'primeng/components/common/sortmeta' | |
5 | import { VideoChangeOwnership } from '../../../../../shared' | |
6 | import { VideoOwnershipService } from '@app/shared/video-ownership' | |
7 | import { Account } from '@app/shared/account/account.model' | |
f8b2c1b4 | 8 | import { 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 | }) | |
14 | export 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 | ||
21 | @ViewChild('myAccountAcceptOwnershipComponent') myAccountAcceptOwnershipComponent: MyAccountAcceptOwnershipComponent | |
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 | ||
74d63469 GR |
34 | createByString (account: Account) { |
35 | return Account.CREATE_BY_STRING(account.name, account.host) | |
36 | } | |
37 | ||
38 | openAcceptModal (videoChangeOwnership: VideoChangeOwnership) { | |
39 | this.myAccountAcceptOwnershipComponent.show(videoChangeOwnership) | |
40 | } | |
41 | ||
42 | accepted () { | |
43 | this.loadData() | |
44 | } | |
45 | ||
46 | refuse (videoChangeOwnership: VideoChangeOwnership) { | |
47 | this.videoOwnershipService.refuseOwnership(videoChangeOwnership.id) | |
48 | .subscribe( | |
49 | () => this.loadData(), | |
f8b2c1b4 | 50 | err => this.notifier.error(err.message) |
74d63469 GR |
51 | ) |
52 | } | |
dffd5d12 B |
53 | |
54 | protected loadData () { | |
55 | return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort) | |
56 | .subscribe( | |
57 | resultList => { | |
58 | this.videoChangeOwnerships = resultList.data | |
59 | this.totalRecords = resultList.total | |
60 | }, | |
61 | ||
f8b2c1b4 | 62 | err => this.notifier.error(err.message) |
dffd5d12 B |
63 | ) |
64 | } | |
74d63469 | 65 | } |