diff options
Diffstat (limited to 'client/src/app/videos/+video-watch/video-watch.component.ts')
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.component.ts | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index b26f3092f..d4e3ec014 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -2,6 +2,7 @@ import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/co | |||
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { MetaService } from '@ngx-meta/core' | 3 | import { MetaService } from '@ngx-meta/core' |
4 | import { NotificationsService } from 'angular2-notifications' | 4 | import { NotificationsService } from 'angular2-notifications' |
5 | import { VideoService } from 'app/shared/video/video.service' | ||
5 | import { Observable } from 'rxjs/Observable' | 6 | import { Observable } from 'rxjs/Observable' |
6 | import { Subscription } from 'rxjs/Subscription' | 7 | import { Subscription } from 'rxjs/Subscription' |
7 | import videojs from 'video.js' | 8 | import videojs from 'video.js' |
@@ -9,7 +10,10 @@ import { UserVideoRateType, VideoRateType } from '../../../../../shared' | |||
9 | import '../../../assets/player/peertube-videojs-plugin' | 10 | import '../../../assets/player/peertube-videojs-plugin' |
10 | import { AuthService, ConfirmService } from '../../core' | 11 | import { AuthService, ConfirmService } from '../../core' |
11 | import { VideoBlacklistService } from '../../shared' | 12 | import { VideoBlacklistService } from '../../shared' |
12 | import { MarkdownService, VideoDetails, VideoService } from '../shared' | 13 | import { Account } from '../../shared/account/account.model' |
14 | import { VideoDetails } from '../../shared/video/video-details.model' | ||
15 | import { Video } from '../../shared/video/video.model' | ||
16 | import { MarkdownService } from '../shared' | ||
13 | import { VideoDownloadComponent } from './video-download.component' | 17 | import { VideoDownloadComponent } from './video-download.component' |
14 | import { VideoReportComponent } from './video-report.component' | 18 | import { VideoReportComponent } from './video-report.component' |
15 | import { VideoShareComponent } from './video-share.component' | 19 | import { VideoShareComponent } from './video-share.component' |
@@ -24,13 +28,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
24 | @ViewChild('videoShareModal') videoShareModal: VideoShareComponent | 28 | @ViewChild('videoShareModal') videoShareModal: VideoShareComponent |
25 | @ViewChild('videoReportModal') videoReportModal: VideoReportComponent | 29 | @ViewChild('videoReportModal') videoReportModal: VideoReportComponent |
26 | 30 | ||
27 | downloadSpeed: number | 31 | otherVideos: Video[] = [] |
32 | |||
28 | error = false | 33 | error = false |
29 | loading = false | 34 | loading = false |
30 | numPeers: number | ||
31 | player: videojs.Player | 35 | player: videojs.Player |
32 | playerElement: HTMLMediaElement | 36 | playerElement: HTMLMediaElement |
33 | uploadSpeed: number | ||
34 | userRating: UserVideoRateType = null | 37 | userRating: UserVideoRateType = null |
35 | video: VideoDetails = null | 38 | video: VideoDetails = null |
36 | videoPlayerLoaded = false | 39 | videoPlayerLoaded = false |
@@ -58,6 +61,13 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
58 | ) {} | 61 | ) {} |
59 | 62 | ||
60 | ngOnInit () { | 63 | ngOnInit () { |
64 | this.videoService.getVideos({ currentPage: 1, itemsPerPage: 5 }, '-createdAt') | ||
65 | .subscribe( | ||
66 | data => this.otherVideos = data.videos, | ||
67 | |||
68 | err => console.error(err) | ||
69 | ) | ||
70 | |||
61 | this.paramsSub = this.route.params.subscribe(routeParams => { | 71 | this.paramsSub = this.route.params.subscribe(routeParams => { |
62 | let uuid = routeParams['uuid'] | 72 | let uuid = routeParams['uuid'] |
63 | this.videoService.getVideo(uuid).subscribe( | 73 | this.videoService.getVideo(uuid).subscribe( |
@@ -115,27 +125,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
115 | ) | 125 | ) |
116 | } | 126 | } |
117 | 127 | ||
118 | removeVideo (event: Event) { | ||
119 | event.preventDefault() | ||
120 | |||
121 | this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe( | ||
122 | res => { | ||
123 | if (res === false) return | ||
124 | |||
125 | this.videoService.removeVideo(this.video.id) | ||
126 | .subscribe( | ||
127 | status => { | ||
128 | this.notificationsService.success('Success', `Video ${this.video.name} deleted.`) | ||
129 | // Go back to the video-list. | ||
130 | this.router.navigate(['/videos/list']) | ||
131 | }, | ||
132 | |||
133 | error => this.notificationsService.error('Error', error.text) | ||
134 | ) | ||
135 | } | ||
136 | ) | ||
137 | } | ||
138 | |||
139 | blacklistVideo (event: Event) { | 128 | blacklistVideo (event: Event) { |
140 | event.preventDefault() | 129 | event.preventDefault() |
141 | 130 | ||
@@ -166,7 +155,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
166 | } | 155 | } |
167 | 156 | ||
168 | showLessDescription () { | 157 | showLessDescription () { |
169 | |||
170 | this.updateVideoDescription(this.shortVideoDescription) | 158 | this.updateVideoDescription(this.shortVideoDescription) |
171 | this.completeDescriptionShown = false | 159 | this.completeDescriptionShown = false |
172 | } | 160 | } |
@@ -211,16 +199,18 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
211 | return this.authService.isLoggedIn() | 199 | return this.authService.isLoggedIn() |
212 | } | 200 | } |
213 | 201 | ||
214 | canUserUpdateVideo () { | 202 | isVideoBlacklistable () { |
215 | return this.video.isUpdatableBy(this.authService.getUser()) | 203 | return this.video.isBlackistableBy(this.authService.getUser()) |
216 | } | 204 | } |
217 | 205 | ||
218 | isVideoRemovable () { | 206 | getAvatarPath () { |
219 | return this.video.isRemovableBy(this.authService.getUser()) | 207 | return Account.GET_ACCOUNT_AVATAR_PATH(this.video.account) |
220 | } | 208 | } |
221 | 209 | ||
222 | isVideoBlacklistable () { | 210 | getVideoTags () { |
223 | return this.video.isBlackistableBy(this.authService.getUser()) | 211 | if (!this.video || Array.isArray(this.video.tags) === false) return [] |
212 | |||
213 | return this.video.tags.join(', ') | ||
224 | } | 214 | } |
225 | 215 | ||
226 | private updateVideoDescription (description: string) { | 216 | private updateVideoDescription (description: string) { |
@@ -229,6 +219,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
229 | } | 219 | } |
230 | 220 | ||
231 | private setVideoDescriptionHTML () { | 221 | private setVideoDescriptionHTML () { |
222 | if (!this.video.description) { | ||
223 | this.videoHTMLDescription = '' | ||
224 | return | ||
225 | } | ||
226 | |||
232 | this.videoHTMLDescription = this.markdownService.markdownToHTML(this.video.description) | 227 | this.videoHTMLDescription = this.markdownService.markdownToHTML(this.video.description) |
233 | } | 228 | } |
234 | 229 | ||
@@ -281,7 +276,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
281 | return this.router.navigate([ '/videos/list' ]) | 276 | return this.router.navigate([ '/videos/list' ]) |
282 | } | 277 | } |
283 | 278 | ||
284 | this.playerElement = this.elementRef.nativeElement.querySelector('#video-container') | 279 | this.playerElement = this.elementRef.nativeElement.querySelector('#video-element') |
285 | 280 | ||
286 | const videojsOptions = { | 281 | const videojsOptions = { |
287 | controls: true, | 282 | controls: true, |
@@ -304,12 +299,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
304 | this.on('customError', (event, data) => { | 299 | this.on('customError', (event, data) => { |
305 | self.handleError(data.err) | 300 | self.handleError(data.err) |
306 | }) | 301 | }) |
307 | |||
308 | this.on('torrentInfo', (event, data) => { | ||
309 | self.downloadSpeed = data.downloadSpeed | ||
310 | self.numPeers = data.numPeers | ||
311 | self.uploadSpeed = data.uploadSpeed | ||
312 | }) | ||
313 | }) | 302 | }) |
314 | 303 | ||
315 | this.setVideoDescriptionHTML() | 304 | this.setVideoDescriptionHTML() |