aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-04-05 14:03:52 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-04-15 09:49:35 +0200
commit384ba8b77a8e4805c099f5ea12b41c2ca5776e26 (patch)
tree6b517033d9265d283677b85e0f57486e0e7fd8cf /client/src/app/shared/shared-main/video
parentb211106695bb82f6c32e53306081b5262c3d109d (diff)
downloadPeerTube-384ba8b77a8e4805c099f5ea12b41c2ca5776e26.tar.gz
PeerTube-384ba8b77a8e4805c099f5ea12b41c2ca5776e26.tar.zst
PeerTube-384ba8b77a8e4805c099f5ea12b41c2ca5776e26.zip
Support videos stats in client
Diffstat (limited to 'client/src/app/shared/shared-main/video')
-rw-r--r--client/src/app/shared/shared-main/video/index.ts1
-rw-r--r--client/src/app/shared/shared-main/video/video.model.ts11
-rw-r--r--client/src/app/shared/shared-main/video/video.resolver.ts17
-rw-r--r--client/src/app/shared/shared-main/video/video.service.ts4
4 files changed, 25 insertions, 8 deletions
diff --git a/client/src/app/shared/shared-main/video/index.ts b/client/src/app/shared/shared-main/video/index.ts
index e72c0c3d6..361601456 100644
--- a/client/src/app/shared/shared-main/video/index.ts
+++ b/client/src/app/shared/shared-main/video/index.ts
@@ -5,4 +5,5 @@ export * from './video-edit.model'
5export * from './video-import.service' 5export * from './video-import.service'
6export * from './video-ownership.service' 6export * from './video-ownership.service'
7export * from './video.model' 7export * from './video.model'
8export * from './video.resolver'
8export * from './video.service' 9export * from './video.service'
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index 2d4db9a28..022bb95ad 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -58,8 +58,7 @@ export class Video implements VideoServerModel {
58 url: string 58 url: string
59 59
60 views: number 60 views: number
61 // If live 61 viewers: number
62 viewers?: number
63 62
64 likes: number 63 likes: number
65 dislikes: number 64 dislikes: number
@@ -234,9 +233,13 @@ export class Video implements VideoServerModel {
234 this.isUpdatableBy(user) 233 this.isUpdatableBy(user)
235 } 234 }
236 235
236 canSeeStats (user: AuthUser) {
237 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.SEE_ALL_VIDEOS))
238 }
239
237 canRemoveFiles (user: AuthUser) { 240 canRemoveFiles (user: AuthUser) {
238 return this.isLocal && 241 return this.isLocal &&
239 user.hasRight(UserRight.MANAGE_VIDEO_FILES) && 242 user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) &&
240 this.state.id !== VideoState.TO_TRANSCODE && 243 this.state.id !== VideoState.TO_TRANSCODE &&
241 this.hasHLS() && 244 this.hasHLS() &&
242 this.hasWebTorrent() 245 this.hasWebTorrent()
@@ -244,7 +247,7 @@ export class Video implements VideoServerModel {
244 247
245 canRunTranscoding (user: AuthUser) { 248 canRunTranscoding (user: AuthUser) {
246 return this.isLocal && 249 return this.isLocal &&
247 user.hasRight(UserRight.RUN_VIDEO_TRANSCODING) && 250 user && user.hasRight(UserRight.RUN_VIDEO_TRANSCODING) &&
248 this.state.id !== VideoState.TO_TRANSCODE 251 this.state.id !== VideoState.TO_TRANSCODE
249 } 252 }
250 253
diff --git a/client/src/app/shared/shared-main/video/video.resolver.ts b/client/src/app/shared/shared-main/video/video.resolver.ts
new file mode 100644
index 000000000..65b7230ce
--- /dev/null
+++ b/client/src/app/shared/shared-main/video/video.resolver.ts
@@ -0,0 +1,17 @@
1import { Injectable } from '@angular/core'
2import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
3import { VideoService } from './video.service'
4
5@Injectable()
6export class VideoResolver implements Resolve<any> {
7 constructor (
8 private videoService: VideoService
9 ) {
10 }
11
12 resolve (route: ActivatedRouteSnapshot) {
13 const videoId: string = route.params['videoId']
14
15 return this.videoService.getVideo({ videoId })
16 }
17}
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts
index 94af9cd38..bc15c326f 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -65,10 +65,6 @@ export class VideoService {
65 return `${VideoService.BASE_VIDEO_URL}/${uuid}/views` 65 return `${VideoService.BASE_VIDEO_URL}/${uuid}/views`
66 } 66 }
67 67
68 getUserWatchingVideoUrl (uuid: string) {
69 return `${VideoService.BASE_VIDEO_URL}/${uuid}/watching`
70 }
71
72 getVideo (options: { videoId: string }): Observable<VideoDetails> { 68 getVideo (options: { videoId: string }): Observable<VideoDetails> {
73 return this.serverService.getServerLocale() 69 return this.serverService.getServerLocale()
74 .pipe( 70 .pipe(