From b0d6a800f84ac16fe541b1f098defe862d09069a Mon Sep 17 00:00:00 2001 From: The Cashew Trader Date: Tue, 27 Sep 2022 13:43:42 +0000 Subject: Add transcoding quota message to admin config page --- .../edit-basic-configuration.component.html | 5 +++++ .../edit-basic-configuration.component.ts | 24 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'client/src/app/+admin/config') diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html index 929ea3a90..728185195 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html @@ -218,6 +218,11 @@ [clearable]="false" > +
+ Transcoding is enabled. The video quota only takes into account original video size.
+ At most, a user could upload ~ {{ computeQuotaWithTranscoding() | bytes: 0 }}. +
+
{{ formErrors.user.videoQuota }}
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts index 90ed58c99..dc7802b2c 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts @@ -3,7 +3,7 @@ import { SelectOptionsItem } from 'src/types/select-options-item.model' import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' import { FormGroup } from '@angular/forms' import { MenuService, ThemeService } from '@app/core' -import { HTMLServerConfig } from '@shared/models' +import { HTMLServerConfig, VideoResolution } from '@shared/models' import { ConfigService } from '../shared/config.service' @Component({ @@ -92,6 +92,28 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { return this.form.value['followings']['instance']['autoFollowIndex']['enabled'] === true } + computeQuotaWithTranscoding () { + const transcodingConfig = this.serverConfig.transcoding + + const resolutions = transcodingConfig.enabledResolutions + const higherResolution = VideoResolution.H_4K + let multiplier = 0 + + for (const resolution of resolutions) { + multiplier += resolution / higherResolution + } + + if (transcodingConfig.hls.enabled) multiplier *= 2 + + return multiplier * parseInt(this.form.value['user']['videoQuota'], 10) + } + + isTranscodingInformationDisplayed () { + const formVideoQuota = parseInt(this.form.value['user']['videoQuota'], 10) + return this.serverConfig.transcoding.enabledResolutions.length !== 0 && + formVideoQuota > 0 + } + buildLandingPageOptions () { this.defaultLandingPageOptions = this.menuService.buildCommonLinks(this.serverConfig) .links -- cgit v1.2.3