diff options
Diffstat (limited to 'client/src/app/+admin/shared')
5 files changed, 73 insertions, 0 deletions
diff --git a/client/src/app/+admin/shared/index.ts b/client/src/app/+admin/shared/index.ts new file mode 100644 index 000000000..9e3834aae --- /dev/null +++ b/client/src/app/+admin/shared/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './user-real-quota-info.component' | ||
2 | |||
3 | export * from './shared-admin.module' | ||
diff --git a/client/src/app/+admin/shared/shared-admin.module.ts b/client/src/app/+admin/shared/shared-admin.module.ts new file mode 100644 index 000000000..bef7d54ef --- /dev/null +++ b/client/src/app/+admin/shared/shared-admin.module.ts | |||
@@ -0,0 +1,20 @@ | |||
1 | import { NgModule } from '@angular/core' | ||
2 | import { SharedMainModule } from '../../shared/shared-main/shared-main.module' | ||
3 | import { UserRealQuotaInfoComponent } from './user-real-quota-info.component' | ||
4 | |||
5 | @NgModule({ | ||
6 | imports: [ | ||
7 | SharedMainModule | ||
8 | ], | ||
9 | |||
10 | declarations: [ | ||
11 | UserRealQuotaInfoComponent | ||
12 | ], | ||
13 | |||
14 | exports: [ | ||
15 | UserRealQuotaInfoComponent | ||
16 | ], | ||
17 | |||
18 | providers: [] | ||
19 | }) | ||
20 | export class SharedAdminModule { } | ||
diff --git a/client/src/app/+admin/shared/user-real-quota-info.component.html b/client/src/app/+admin/shared/user-real-quota-info.component.html new file mode 100644 index 000000000..b975ab17f --- /dev/null +++ b/client/src/app/+admin/shared/user-real-quota-info.component.html | |||
@@ -0,0 +1,4 @@ | |||
1 | <div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()"> | ||
2 | The video quota only takes into account <strong>original</strong> video size. <br /> | ||
3 | Since transcoding is enabled, videos size can be at most ~ {{ computeQuotaWithTranscoding() | bytes: 0 }}. | ||
4 | </div> | ||
diff --git a/client/src/app/+admin/shared/user-real-quota-info.component.scss b/client/src/app/+admin/shared/user-real-quota-info.component.scss new file mode 100644 index 000000000..40083bed3 --- /dev/null +++ b/client/src/app/+admin/shared/user-real-quota-info.component.scss | |||
@@ -0,0 +1,2 @@ | |||
1 | @use '_variables' as *; | ||
2 | @use '_mixins' as *; | ||
diff --git a/client/src/app/+admin/shared/user-real-quota-info.component.ts b/client/src/app/+admin/shared/user-real-quota-info.component.ts new file mode 100644 index 000000000..069eeba12 --- /dev/null +++ b/client/src/app/+admin/shared/user-real-quota-info.component.ts | |||
@@ -0,0 +1,44 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | ||
2 | import { ServerService } from '@app/core' | ||
3 | import { HTMLServerConfig, VideoResolution } from '@shared/models/index' | ||
4 | |||
5 | @Component({ | ||
6 | selector: 'my-user-real-quota-info', | ||
7 | templateUrl: './user-real-quota-info.component.html', | ||
8 | styleUrls: [ './user-real-quota-info.component.scss' ] | ||
9 | }) | ||
10 | export class UserRealQuotaInfoComponent implements OnInit { | ||
11 | @Input() videoQuota: number | string | ||
12 | |||
13 | private serverConfig: HTMLServerConfig | ||
14 | |||
15 | constructor (private server: ServerService) { } | ||
16 | |||
17 | ngOnInit () { | ||
18 | this.serverConfig = this.server.getHTMLConfig() | ||
19 | } | ||
20 | |||
21 | isTranscodingInformationDisplayed () { | ||
22 | return this.serverConfig.transcoding.enabledResolutions.length !== 0 && this.getQuotaAsNumber() > 0 | ||
23 | } | ||
24 | |||
25 | computeQuotaWithTranscoding () { | ||
26 | const transcodingConfig = this.serverConfig.transcoding | ||
27 | |||
28 | const resolutions = transcodingConfig.enabledResolutions | ||
29 | const higherResolution = VideoResolution.H_4K | ||
30 | let multiplier = 0 | ||
31 | |||
32 | for (const resolution of resolutions) { | ||
33 | multiplier += resolution / higherResolution | ||
34 | } | ||
35 | |||
36 | if (transcodingConfig.hls.enabled) multiplier *= 2 | ||
37 | |||
38 | return multiplier * this.getQuotaAsNumber() | ||
39 | } | ||
40 | |||
41 | private getQuotaAsNumber () { | ||
42 | return parseInt(this.videoQuota + '', 10) | ||
43 | } | ||
44 | } | ||