]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-watch/video-watch.component.ts
Fix client development so that it uses the local ng binary; (#177)
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / video-watch.component.ts
index df4cfa66687b9c2a48f36097867323036fd3b476..f1f19476483f29455b5f571e388cb21b289c6357 100644 (file)
@@ -14,9 +14,9 @@ import { VideoDetails } from '../../shared/video/video-details.model'
 import { Video } from '../../shared/video/video.model'
 import { VideoService } from '../../shared/video/video.service'
 import { MarkdownService } from '../shared'
-import { VideoDownloadComponent } from './video-download.component'
-import { VideoReportComponent } from './video-report.component'
-import { VideoShareComponent } from './video-share.component'
+import { VideoDownloadComponent } from './modal/video-download.component'
+import { VideoReportComponent } from './modal/video-report.component'
+import { VideoShareComponent } from './modal/video-share.component'
 
 @Component({
   selector: 'my-video-watch',
@@ -44,6 +44,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   completeVideoDescription: string
   shortVideoDescription: string
   videoHTMLDescription = ''
+  likesBarTooltipText = ''
 
   private paramsSub: Subscription
 
@@ -136,7 +137,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   blacklistVideo (event: Event) {
     event.preventDefault()
 
-    this.confirmService.confirm('Do you really want to blacklist this video ?', 'Blacklist').subscribe(
+    this.confirmService.confirm('Do you really want to blacklist this video?', 'Blacklist').subscribe(
       res => {
         if (res === false) return
 
@@ -147,7 +148,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
                                       this.router.navigate(['/videos/list'])
                                     },
 
-                                    error => this.notificationsService.error('Error', error.text)
+                                    error => this.notificationsService.error('Error', error.message)
                                   )
       }
     )
@@ -184,7 +185,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
         error => {
           this.descriptionLoading = false
-          this.notificationsService.error('Error', error.text)
+          this.notificationsService.error('Error', error.message)
         }
       )
   }
@@ -207,12 +208,16 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     return this.authService.isLoggedIn()
   }
 
+  isVideoUpdatable () {
+    return this.video.isUpdatableBy(this.authService.getUser())
+  }
+
   isVideoBlacklistable () {
     return this.video.isBlackistableBy(this.user)
   }
 
   getAvatarPath () {
-    return Account.GET_ACCOUNT_AVATAR_PATH(this.video.account)
+    return Account.GET_ACCOUNT_AVATAR_URL(this.video.account)
   }
 
   getVideoTags () {
@@ -228,23 +233,24 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   removeVideo (event: Event) {
     event.preventDefault()
 
-    this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe(
-      res => {
-        if (res === false) return
+    this.confirmService.confirm('Do you really want to delete this video?', 'Delete')
+      .subscribe(
+        res => {
+          if (res === false) return
 
-        this.videoService.removeVideo(this.video.id)
-          .subscribe(
-            status => {
-              this.notificationsService.success('Success', `Video ${this.video.name} deleted.`)
+          this.videoService.removeVideo(this.video.id)
+            .subscribe(
+              status => {
+                this.notificationsService.success('Success', `Video ${this.video.name} deleted.`)
 
-              // Go back to the video-list.
-              this.router.navigate([ '/videos/list' ])
-            },
+                // Go back to the video-list.
+                this.router.navigate([ '/videos/list' ])
+              },
 
-            error => this.notificationsService.error('Error', error.text)
-          )
-      }
-    )
+              error => this.notificationsService.error('Error', error.message)
+            )
+        }
+      )
   }
 
   private updateVideoDescription (description: string) {
@@ -261,6 +267,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     this.videoHTMLDescription = this.markdownService.markdownToHTML(this.video.description)
   }
 
+  private setVideoLikesBarTooltipText () {
+    this.likesBarTooltipText = `${this.video.likes} likes / ${this.video.dislikes} dislikes`
+  }
+
   private handleError (err: any) {
     const errorMessage: string = typeof err === 'string' ? err : err.message
     let message = ''
@@ -346,6 +356,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
         }
 
         this.setVideoDescriptionHTML()
+        this.setVideoLikesBarTooltipText()
 
         this.setOpenGraphTags()
         this.checkUserRating()