]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-videos/my-account-videos.component.ts
Better typings
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-videos / my-account-videos.component.ts
index afc01073c0c6a2d0f6d4f25aa8a84b31849e2523..2d88ac760bc6254fb9e3a08d3432a4f23f7896d4 100644 (file)
@@ -1,6 +1,6 @@
 import { from as observableFrom, Observable } from 'rxjs'
 import { concatAll, tap } from 'rxjs/operators'
-import { Component, OnDestroy, OnInit } from '@angular/core'
+import { Component, OnDestroy, OnInit, Inject, LOCALE_ID, ViewChild } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { Location } from '@angular/common'
 import { immutableAssign } from '@app/shared/misc/utils'
@@ -12,7 +12,9 @@ import { AbstractVideoList } from '../../shared/video/abstract-video-list'
 import { Video } from '../../shared/video/video.model'
 import { VideoService } from '../../shared/video/video.service'
 import { I18n } from '@ngx-translate/i18n-polyfill'
-import { VideoState } from '../../../../../shared/models/videos'
+import { VideoPrivacy, VideoState } from '../../../../../shared/models/videos'
+import { ScreenService } from '@app/shared/misc/screen.service'
+import { VideoChangeOwnershipComponent } from './video-change-ownership/video-change-ownership.component'
 
 @Component({
   selector: 'my-account-videos',
@@ -32,15 +34,19 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
   protected baseVideoWidth = -1
   protected baseVideoHeight = 155
 
+  @ViewChild('videoChangeOwnershipModal') videoChangeOwnershipModal: VideoChangeOwnershipComponent
+
   constructor (
     protected router: Router,
     protected route: ActivatedRoute,
     protected authService: AuthService,
     protected notificationsService: NotificationsService,
-    protected confirmService: ConfirmService,
     protected location: Location,
+    protected screenService: ScreenService,
     protected i18n: I18n,
-    private videoService: VideoService
+    private confirmService: ConfirmService,
+    private videoService: VideoService,
+    @Inject(LOCALE_ID) private localeId: string
   ) {
     super()
 
@@ -130,13 +136,30 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
         )
   }
 
-  getStateLabel (video: Video) {
-    if (video.state.id === VideoState.PUBLISHED) return this.i18n('Published')
+  changeOwnership (event: Event, video: Video) {
+    event.preventDefault()
+    this.videoChangeOwnershipModal.show(video)
+  }
 
-    if (video.state.id === VideoState.TO_TRANSCODE && video.waitTranscoding === true) return this.i18n('Waiting transcoding')
-    if (video.state.id === VideoState.TO_TRANSCODE) return this.i18n('To transcode')
+  getStateLabel (video: Video) {
+    let suffix: string
+
+    if (video.privacy.id !== VideoPrivacy.PRIVATE && video.state.id === VideoState.PUBLISHED) {
+      suffix = this.i18n('Published')
+    } else if (video.scheduledUpdate) {
+      const updateAt = new Date(video.scheduledUpdate.updateAt.toString()).toLocaleString(this.localeId)
+      suffix = this.i18n('Publication scheduled on ') + updateAt
+    } else if (video.state.id === VideoState.TO_TRANSCODE && video.waitTranscoding === true) {
+      suffix = this.i18n('Waiting transcoding')
+    } else if (video.state.id === VideoState.TO_TRANSCODE) {
+      suffix = this.i18n('To transcode')
+    } else if (video.state.id === VideoState.TO_IMPORT) {
+      suffix = this.i18n('To import')
+    } else {
+      return ''
+    }
 
-    return this.i18n('Unknown state')
+    return ' - ' + suffix
   }
 
   protected buildVideoHeight () {
@@ -146,7 +169,7 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
 
   private spliceVideosById (id: number) {
     for (const key of Object.keys(this.loadedPages)) {
-      const videos = this.loadedPages[ key ]
+      const videos: Video[] = this.loadedPages[ key ]
       const index = videos.findIndex(v => v.id === id)
 
       if (index !== -1) {