1
0
Fork 0

Add transcoding quota message to admin config page

This commit is contained in:
The Cashew Trader 2022-09-27 13:43:42 +00:00 committed by Chocobozzz
parent b105ea6042
commit b0d6a800f8
2 changed files with 28 additions and 1 deletions

View File

@ -218,6 +218,11 @@
[clearable]="false"
></my-select-custom-value>
<div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()">
Transcoding is enabled. The video quota only takes into account <strong>original</strong> video size. <br />
At most, a user could upload ~ {{ computeQuotaWithTranscoding() | bytes: 0 }}.
</div>
<div *ngIf="formErrors.user.videoQuota" class="form-error">{{ formErrors.user.videoQuota }}</div>
</div>

View File

@ -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