From 3c10840fa90fc88fc98e8169faf4745ff6c80893 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Oct 2021 10:54:27 +0200 Subject: Add video file size info in admin videos list --- .../overview/videos/video-list.component.html | 38 +++++++++++++++++++--- .../overview/videos/video-list.component.scss | 5 +++ .../+admin/overview/videos/video-list.component.ts | 20 +++++++++++- .../shared-main/video/video-details.model.ts | 4 +-- .../app/shared/shared-main/video/video.model.ts | 10 +++++- .../app/shared/shared-main/video/video.service.ts | 6 +++- 6 files changed, 73 insertions(+), 10 deletions(-) (limited to 'client/src') diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html index 6250c00fb..eedf6f3dc 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.html +++ b/client/src/app/+admin/overview/videos/video-list.component.html @@ -37,6 +37,7 @@ Video Info + Files Published @@ -63,8 +64,8 @@ - - {{ video.privacy.label }} + + {{ video.privacy.label }} NSFW @@ -76,6 +77,13 @@ Blocked + + HLS + WebTorrent + + {{ getFilesSize(video) | bytes: 1 }} + + {{ video.publishedAt | date: 'short' }} @@ -85,8 +93,30 @@ - - + +
+
+ WebTorrent: + +
    +
  • + {{ file.resolution.label }}: {{ file.size | bytes: 1 }} +
  • +
+
+ +
+ HLS: + +
    +
  • + {{ file.resolution.label }}: {{ file.size | bytes: 1 }} +
  • +
+
+ + +
diff --git a/client/src/app/+admin/overview/videos/video-list.component.scss b/client/src/app/+admin/overview/videos/video-list.component.scss index 250a917e4..158c161af 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.scss +++ b/client/src/app/+admin/overview/videos/video-list.component.scss @@ -3,6 +3,7 @@ my-embed { display: block; max-width: 500px; + width: 50%; } .badge { @@ -10,3 +11,7 @@ my-embed { margin-right: 5px; } + +.video-info > div { + display: flex; +} diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts index dd9225e6a..6885abfc7 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.ts +++ b/client/src/app/+admin/overview/videos/video-list.component.ts @@ -3,7 +3,7 @@ import { Component, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { AuthService, ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' -import { UserRight, VideoPrivacy, VideoState } from '@shared/models' +import { UserRight, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' import { AdvancedInputFilter } from '@app/shared/shared-forms' import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature' @@ -114,6 +114,24 @@ export class VideoListComponent extends RestTable implements OnInit { return video.blacklisted } + isHLS (video: Video) { + return video.streamingPlaylists.some(p => p.type === VideoStreamingPlaylistType.HLS) + } + + isWebTorrent (video: Video) { + return video.files.length !== 0 + } + + getFilesSize (video: Video) { + let files = video.files + + if (this.isHLS(video)) { + files = files.concat(video.streamingPlaylists[0].files) + } + + return files.reduce((p, f) => p += f.size, 0) + } + protected reloadData () { this.selectedVideos = [] diff --git a/client/src/app/shared/shared-main/video/video-details.model.ts b/client/src/app/shared/shared-main/video/video-details.model.ts index f060d1dc9..45c053507 100644 --- a/client/src/app/shared/shared-main/video/video-details.model.ts +++ b/client/src/app/shared/shared-main/video/video-details.model.ts @@ -15,7 +15,6 @@ export class VideoDetails extends Video implements VideoDetailsServerModel { support: string channel: VideoChannel tags: string[] - files: VideoFile[] account: Account commentsEnabled: boolean downloadEnabled: boolean @@ -28,13 +27,13 @@ export class VideoDetails extends Video implements VideoDetailsServerModel { trackerUrls: string[] + files: VideoFile[] streamingPlaylists: VideoStreamingPlaylist[] constructor (hash: VideoDetailsServerModel, translations = {}) { super(hash, translations) this.descriptionPath = hash.descriptionPath - this.files = hash.files this.channel = new VideoChannel(hash.channel) this.account = new Account(hash.account) this.tags = hash.tags @@ -43,7 +42,6 @@ export class VideoDetails extends Video implements VideoDetailsServerModel { this.downloadEnabled = hash.downloadEnabled this.trackerUrls = hash.trackerUrls - this.streamingPlaylists = hash.streamingPlaylists this.buildLikeAndDislikePercents() } 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 699eac7f1..b11316471 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts @@ -10,9 +10,11 @@ import { UserRight, Video as VideoServerModel, VideoConstant, + VideoFile, VideoPrivacy, VideoScheduleUpdate, - VideoState + VideoState, + VideoStreamingPlaylist } from '@shared/models' export class Video implements VideoServerModel { @@ -96,6 +98,9 @@ export class Video implements VideoServerModel { pluginData?: any + streamingPlaylists?: VideoStreamingPlaylist[] + files?: VideoFile[] + static buildWatchUrl (video: Partial>) { return buildVideoWatchPath({ shortUUID: video.shortUUID || video.uuid }) } @@ -172,6 +177,9 @@ export class Video implements VideoServerModel { this.blockedOwner = hash.blockedOwner this.blockedServer = hash.blockedServer + this.streamingPlaylists = hash.streamingPlaylists + this.files = hash.files + this.userHistory = hash.userHistory this.originInstanceHost = this.account.host 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 0a3a51b0c..5db9a8704 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -208,7 +208,11 @@ export class VideoService { ): Observable> { const { pagination, search } = parameters - const include = VideoInclude.BLACKLISTED | VideoInclude.BLOCKED_OWNER | VideoInclude.HIDDEN_PRIVACY | VideoInclude.NOT_PUBLISHED_STATE + const include = VideoInclude.BLACKLISTED | + VideoInclude.BLOCKED_OWNER | + VideoInclude.HIDDEN_PRIVACY | + VideoInclude.NOT_PUBLISHED_STATE | + VideoInclude.FILES let params = new HttpParams() params = this.buildCommonVideosParams({ params, include, ...parameters }) -- cgit v1.2.3