Put video quota info in its own component
This commit is contained in:
parent
b0d6a800f8
commit
f67ac646a2
|
@ -49,6 +49,7 @@ import {
|
||||||
PluginSearchComponent,
|
PluginSearchComponent,
|
||||||
PluginShowInstalledComponent
|
PluginShowInstalledComponent
|
||||||
} from './plugins'
|
} from './plugins'
|
||||||
|
import { SharedAdminModule } from './shared'
|
||||||
import { JobService, LogsComponent, LogsService } from './system'
|
import { JobService, LogsComponent, LogsService } from './system'
|
||||||
import { DebugComponent, DebugService } from './system/debug'
|
import { DebugComponent, DebugService } from './system/debug'
|
||||||
import { JobsComponent } from './system/jobs/jobs.component'
|
import { JobsComponent } from './system/jobs/jobs.component'
|
||||||
|
@ -69,6 +70,7 @@ import { JobsComponent } from './system/jobs/jobs.component'
|
||||||
SharedVideoMiniatureModule,
|
SharedVideoMiniatureModule,
|
||||||
SharedTablesModule,
|
SharedTablesModule,
|
||||||
SharedUsersModule,
|
SharedUsersModule,
|
||||||
|
SharedAdminModule,
|
||||||
|
|
||||||
TableModule,
|
TableModule,
|
||||||
ChartModule
|
ChartModule
|
||||||
|
|
|
@ -218,10 +218,7 @@
|
||||||
[clearable]="false"
|
[clearable]="false"
|
||||||
></my-select-custom-value>
|
></my-select-custom-value>
|
||||||
|
|
||||||
<div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()">
|
<my-user-real-quota-info [videoQuota]="getUserVideoQuota()"></my-user-real-quota-info>
|
||||||
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 *ngIf="formErrors.user.videoQuota" class="form-error">{{ formErrors.user.videoQuota }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -60,6 +60,10 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
|
||||||
return !!enabled.find((e: string) => e === algorithm)
|
return !!enabled.find((e: string) => e === algorithm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUserVideoQuota () {
|
||||||
|
return this.form.value['user']['videoQuota']
|
||||||
|
}
|
||||||
|
|
||||||
isSignupEnabled () {
|
isSignupEnabled () {
|
||||||
return this.form.value['signup']['enabled'] === true
|
return this.form.value['signup']['enabled'] === true
|
||||||
}
|
}
|
||||||
|
@ -92,28 +96,6 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
|
||||||
return this.form.value['followings']['instance']['autoFollowIndex']['enabled'] === true
|
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 () {
|
buildLandingPageOptions () {
|
||||||
this.defaultLandingPageOptions = this.menuService.buildCommonLinks(this.serverConfig)
|
this.defaultLandingPageOptions = this.menuService.buildCommonLinks(this.serverConfig)
|
||||||
.links
|
.links
|
||||||
|
|
|
@ -150,3 +150,9 @@ ngb-tabset:not(.previews) ::ng-deep {
|
||||||
padding: 0 .3em;
|
padding: 0 .3em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my-user-real-quota-info {
|
||||||
|
display: block;
|
||||||
|
margin-top: 5px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
|
@ -152,10 +152,7 @@
|
||||||
[clearable]="false"
|
[clearable]="false"
|
||||||
></my-select-custom-value>
|
></my-select-custom-value>
|
||||||
|
|
||||||
<div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()">
|
<my-user-real-quota-info [videoQuota]="getUserVideoQuota()"></my-user-real-quota-info>
|
||||||
Transcoding is enabled. The video quota only takes into account <strong>original</strong> video size. <br />
|
|
||||||
At most, this user could upload ~ {{ computeQuotaWithTranscoding() | bytes: 0 }}.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="formErrors.videoQuota" class="form-error">
|
<div *ngIf="formErrors.videoQuota" class="form-error">
|
||||||
{{ formErrors.videoQuota }}
|
{{ formErrors.videoQuota }}
|
||||||
|
|
|
@ -41,7 +41,8 @@ button {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.transcoding-information {
|
my-user-real-quota-info {
|
||||||
|
display: block;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,33 +60,14 @@ export abstract class UserEdit extends FormReactive implements OnInit {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
isTranscodingInformationDisplayed () {
|
|
||||||
const formVideoQuota = parseInt(this.form.value['videoQuota'], 10)
|
|
||||||
|
|
||||||
return this.serverConfig.transcoding.enabledResolutions.length !== 0 &&
|
|
||||||
formVideoQuota > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
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['videoQuota'], 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
resetPassword () {
|
resetPassword () {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUserVideoQuota () {
|
||||||
|
return this.form.value['videoQuota']
|
||||||
|
}
|
||||||
|
|
||||||
protected buildAdminFlags (formValue: any) {
|
protected buildAdminFlags (formValue: any) {
|
||||||
return formValue.byPassAutoBlock ? UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST : UserAdminFlag.NONE
|
return formValue.byPassAutoBlock ? UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST : UserAdminFlag.NONE
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
export * from './user-real-quota-info.component'
|
||||||
|
|
||||||
|
export * from './shared-admin.module'
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { NgModule } from '@angular/core'
|
||||||
|
import { SharedMainModule } from '../../shared/shared-main/shared-main.module'
|
||||||
|
import { UserRealQuotaInfoComponent } from './user-real-quota-info.component'
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
SharedMainModule
|
||||||
|
],
|
||||||
|
|
||||||
|
declarations: [
|
||||||
|
UserRealQuotaInfoComponent
|
||||||
|
],
|
||||||
|
|
||||||
|
exports: [
|
||||||
|
UserRealQuotaInfoComponent
|
||||||
|
],
|
||||||
|
|
||||||
|
providers: []
|
||||||
|
})
|
||||||
|
export class SharedAdminModule { }
|
|
@ -0,0 +1,4 @@
|
||||||
|
<div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()">
|
||||||
|
The video quota only takes into account <strong>original</strong> video size. <br />
|
||||||
|
Since transcoding is enabled, videos size can be at most ~ {{ computeQuotaWithTranscoding() | bytes: 0 }}.
|
||||||
|
</div>
|
|
@ -0,0 +1,2 @@
|
||||||
|
@use '_variables' as *;
|
||||||
|
@use '_mixins' as *;
|
|
@ -0,0 +1,44 @@
|
||||||
|
import { Component, Input, OnInit } from '@angular/core'
|
||||||
|
import { ServerService } from '@app/core'
|
||||||
|
import { HTMLServerConfig, VideoResolution } from '@shared/models/index'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'my-user-real-quota-info',
|
||||||
|
templateUrl: './user-real-quota-info.component.html',
|
||||||
|
styleUrls: [ './user-real-quota-info.component.scss' ]
|
||||||
|
})
|
||||||
|
export class UserRealQuotaInfoComponent implements OnInit {
|
||||||
|
@Input() videoQuota: number | string
|
||||||
|
|
||||||
|
private serverConfig: HTMLServerConfig
|
||||||
|
|
||||||
|
constructor (private server: ServerService) { }
|
||||||
|
|
||||||
|
ngOnInit () {
|
||||||
|
this.serverConfig = this.server.getHTMLConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
isTranscodingInformationDisplayed () {
|
||||||
|
return this.serverConfig.transcoding.enabledResolutions.length !== 0 && this.getQuotaAsNumber() > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
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 * this.getQuotaAsNumber()
|
||||||
|
}
|
||||||
|
|
||||||
|
private getQuotaAsNumber () {
|
||||||
|
return parseInt(this.videoQuota + '', 10)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue