]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts
Migrate to $localize
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-ownership / my-account-ownership.component.ts
index 5167732c2a7312d15dce24f12695a5e13f9a6123..7473470aaa588938adb55109b72eed031ad46f99 100644 (file)
@@ -1,13 +1,15 @@
 import { SortMeta } from 'primeng/api'
 import { Component, OnInit, ViewChild } from '@angular/core'
 import { Notifier, RestPagination, RestTable } from '@app/core'
-import { Account, VideoOwnershipService } from '@app/shared/shared-main'
-import { VideoChangeOwnership } from '@shared/models'
+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[] = []
@@ -32,8 +34,19 @@ export class MyAccountOwnershipComponent extends RestTable implements OnInit {
     return 'MyAccountOwnershipComponent'
   }
 
-  createByString (account: Account) {
-    return Account.CREATE_BY_STRING(account.name, account.host)
+  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) {
@@ -56,7 +69,11 @@ export class MyAccountOwnershipComponent extends RestTable implements OnInit {
     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
         },