-import { Component, OnInit, ViewChild } from '@angular/core'
-import { Notifier } from '@app/core'
-import { RestPagination, RestTable } from '@app/shared'
import { SortMeta } from 'primeng/api'
-import { VideoChangeOwnership } from '../../../../../shared'
-import { VideoOwnershipService } from '@app/shared/video-ownership'
-import { Account } from '@app/shared/account/account.model'
+import { Component, OnInit, ViewChild } from '@angular/core'
+import { Notifier, RestPagination, RestTable } from '@app/core'
+import { VideoOwnershipService, Actor, Video, Account } from '@app/shared/shared-main'
+import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '@shared/models'
import { MyAccountAcceptOwnershipComponent } from './my-account-accept-ownership/my-account-accept-ownership.component'
+import { getAbsoluteAPIUrl } from '@app/helpers'
@Component({
selector: 'my-account-ownership',
- templateUrl: './my-account-ownership.component.html'
+ templateUrl: './my-account-ownership.component.html',
+ styleUrls: [ './my-account-ownership.component.scss' ]
})
export class MyAccountOwnershipComponent extends RestTable implements OnInit {
videoChangeOwnerships: VideoChangeOwnership[] = []
totalRecords = 0
- rowsPerPage = 10
sort: SortMeta = { field: 'createdAt', order: -1 }
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
this.initialize()
}
- createByString (account: Account) {
- return Account.CREATE_BY_STRING(account.name, account.host)
+ getIdentifier () {
+ return 'MyAccountOwnershipComponent'
+ }
+
+ getStatusClass (status: VideoChangeOwnershipStatus) {
+ switch (status) {
+ case VideoChangeOwnershipStatus.ACCEPTED:
+ return 'badge-green'
+ case VideoChangeOwnershipStatus.REFUSED:
+ return 'badge-red'
+ default:
+ return 'badge-yellow'
+ }
+ }
+
+ switchToDefaultAvatar ($event: Event) {
+ ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
}
openAcceptModal (videoChangeOwnership: VideoChangeOwnership) {
return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort)
.subscribe(
resultList => {
- this.videoChangeOwnerships = resultList.data
+ this.videoChangeOwnerships = resultList.data.map(change => ({
+ ...change,
+ initiatorAccount: new Account(change.initiatorAccount),
+ nextOwnerAccount: new Account(change.nextOwnerAccount)
+ }))
this.totalRecords = resultList.total
},