diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-19 17:33:32 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-19 17:35:41 +0200 |
commit | 6a84aafd23c2f887f837cc4826cf7c8c07d1c60f (patch) | |
tree | cccff65aad1ff4eb53d40c604441db5d99e425b6 /client/src/app/+admin | |
parent | a10d56bafc31602dfee9b1c52bbf26ab9aca366a (diff) | |
download | PeerTube-6a84aafd23c2f887f837cc4826cf7c8c07d1c60f.tar.gz PeerTube-6a84aafd23c2f887f837cc4826cf7c8c07d1c60f.tar.zst PeerTube-6a84aafd23c2f887f837cc4826cf7c8c07d1c60f.zip |
Take in account transcoding for video quota
Diffstat (limited to 'client/src/app/+admin')
5 files changed, 41 insertions, 4 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-add.component.ts b/client/src/app/+admin/users/user-edit/user-add.component.ts index 5dc069104..6d8151b42 100644 --- a/client/src/app/+admin/users/user-edit/user-add.component.ts +++ b/client/src/app/+admin/users/user-edit/user-add.component.ts | |||
@@ -11,12 +11,14 @@ import { | |||
11 | USER_PASSWORD, | 11 | USER_PASSWORD, |
12 | USER_VIDEO_QUOTA | 12 | USER_VIDEO_QUOTA |
13 | } from '../../../shared' | 13 | } from '../../../shared' |
14 | import { ServerService } from '../../../core' | ||
14 | import { UserCreate } from '../../../../../../shared' | 15 | import { UserCreate } from '../../../../../../shared' |
15 | import { UserEdit } from './user-edit' | 16 | import { UserEdit } from './user-edit' |
16 | 17 | ||
17 | @Component({ | 18 | @Component({ |
18 | selector: 'my-user-add', | 19 | selector: 'my-user-add', |
19 | templateUrl: './user-edit.component.html' | 20 | templateUrl: './user-edit.component.html', |
21 | styleUrls: [ './user-edit.component.scss' ] | ||
20 | }) | 22 | }) |
21 | export class UserAddComponent extends UserEdit implements OnInit { | 23 | export class UserAddComponent extends UserEdit implements OnInit { |
22 | error: string | 24 | error: string |
@@ -36,6 +38,7 @@ export class UserAddComponent extends UserEdit implements OnInit { | |||
36 | } | 38 | } |
37 | 39 | ||
38 | constructor ( | 40 | constructor ( |
41 | protected serverService: ServerService, | ||
39 | private formBuilder: FormBuilder, | 42 | private formBuilder: FormBuilder, |
40 | private router: Router, | 43 | private router: Router, |
41 | private notificationsService: NotificationsService, | 44 | private notificationsService: NotificationsService, |
diff --git a/client/src/app/+admin/users/user-edit/user-edit.component.html b/client/src/app/+admin/users/user-edit/user-edit.component.html index 0e23cb731..6988071ce 100644 --- a/client/src/app/+admin/users/user-edit/user-edit.component.html +++ b/client/src/app/+admin/users/user-edit/user-edit.component.html | |||
@@ -47,6 +47,11 @@ | |||
47 | {{ videoQuotaOption.label }} | 47 | {{ videoQuotaOption.label }} |
48 | </option> | 48 | </option> |
49 | </select> | 49 | </select> |
50 | |||
51 | <div class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()"> | ||
52 | Transcoding is enabled on server. The video quota only take in account <strong>original</strong> video. <br /> | ||
53 | In maximum, this user could use ~ {{ computeQuotaWithTranscoding() | bytes }}. | ||
54 | </div> | ||
50 | </div> | 55 | </div> |
51 | 56 | ||
52 | <input type="submit" value="{{ getFormButtonTitle() }}" class="btn btn-default" [disabled]="!form.valid"> | 57 | <input type="submit" value="{{ getFormButtonTitle() }}" class="btn btn-default" [disabled]="!form.valid"> |
diff --git a/client/src/app/+admin/users/user-edit/user-edit.component.scss b/client/src/app/+admin/users/user-edit/user-edit.component.scss new file mode 100644 index 000000000..401caa0c6 --- /dev/null +++ b/client/src/app/+admin/users/user-edit/user-edit.component.scss | |||
@@ -0,0 +1,4 @@ | |||
1 | .transcoding-information { | ||
2 | margin-top: 5px; | ||
3 | font-size: 11px; | ||
4 | } | ||
diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts index 657c0f1c0..76497c9b6 100644 --- a/client/src/app/+admin/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/users/user-edit/user-edit.ts | |||
@@ -1,17 +1,39 @@ | |||
1 | import { ServerService } from '../../../core' | ||
1 | import { FormReactive } from '../../../shared' | 2 | import { FormReactive } from '../../../shared' |
3 | import { VideoResolution } from '../../../../../../shared/models/videos/video-resolution.enum' | ||
2 | 4 | ||
3 | export abstract class UserEdit extends FormReactive { | 5 | export abstract class UserEdit extends FormReactive { |
4 | videoQuotaOptions = [ | 6 | videoQuotaOptions = [ |
5 | { value: -1, label: 'Unlimited' }, | 7 | { value: -1, label: 'Unlimited' }, |
6 | { value: 0, label: '0'}, | 8 | { value: 0, label: '0'}, |
7 | { value: 100 * 1024 * 1024, label: '100MB' }, | 9 | { value: 100 * 1024 * 1024, label: '100MB' }, |
8 | { value: 5 * 1024 * 1024, label: '500MB' }, | 10 | { value: 500 * 1024 * 1024, label: '500MB' }, |
9 | { value: 1024 * 1024 * 1024, label: '1GB' }, | 11 | { value: 1024 * 1024 * 1024, label: '1GB' }, |
10 | { value: 5 * 1024 * 1024 * 1024, label: '5GB' }, | 12 | { value: 5 * 1024 * 1024 * 1024, label: '5GB' }, |
11 | { value: 20 * 1024 * 1024 * 1024, label: '20GB' }, | 13 | { value: 20 * 1024 * 1024 * 1024, label: '20GB' }, |
12 | { value: 50 * 1024 * 1024 * 1024, label: '50GB' } | 14 | { value: 50 * 1024 * 1024 * 1024, label: '50GB' } |
13 | ] | 15 | ] |
14 | 16 | ||
17 | protected abstract serverService: ServerService | ||
15 | abstract isCreation (): boolean | 18 | abstract isCreation (): boolean |
16 | abstract getFormButtonTitle (): string | 19 | abstract getFormButtonTitle (): string |
20 | |||
21 | isTranscodingInformationDisplayed () { | ||
22 | const formVideoQuota = parseInt(this.form.value['videoQuota'], 10) | ||
23 | |||
24 | return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 && | ||
25 | formVideoQuota > 0 | ||
26 | } | ||
27 | |||
28 | computeQuotaWithTranscoding () { | ||
29 | const resolutions = this.serverService.getConfig().transcoding.enabledResolutions | ||
30 | const higherResolution = VideoResolution.H_1080P | ||
31 | let multiplier = 0 | ||
32 | |||
33 | for (const resolution of resolutions) { | ||
34 | multiplier += resolution / higherResolution | ||
35 | } | ||
36 | |||
37 | return multiplier * parseInt(this.form.value['videoQuota'], 10) | ||
38 | } | ||
17 | } | 39 | } |
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts index 0966981c0..bd901e655 100644 --- a/client/src/app/+admin/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/users/user-edit/user-update.component.ts | |||
@@ -7,13 +7,15 @@ import { NotificationsService } from 'angular2-notifications' | |||
7 | 7 | ||
8 | import { UserService } from '../shared' | 8 | import { UserService } from '../shared' |
9 | import { USER_EMAIL, USER_VIDEO_QUOTA } from '../../../shared' | 9 | import { USER_EMAIL, USER_VIDEO_QUOTA } from '../../../shared' |
10 | import { ServerService } from '../../../core' | ||
10 | import { UserUpdate } from '../../../../../../shared/models/users/user-update.model' | 11 | import { UserUpdate } from '../../../../../../shared/models/users/user-update.model' |
11 | import { User } from '../../../shared/users/user.model' | 12 | import { User } from '../../../shared/users/user.model' |
12 | import { UserEdit } from './user-edit' | 13 | import { UserEdit } from './user-edit' |
13 | 14 | ||
14 | @Component({ | 15 | @Component({ |
15 | selector: 'my-user-update', | 16 | selector: 'my-user-update', |
16 | templateUrl: './user-edit.component.html' | 17 | templateUrl: './user-edit.component.html', |
18 | styleUrls: [ './user-edit.component.scss' ] | ||
17 | }) | 19 | }) |
18 | export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | 20 | export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { |
19 | error: string | 21 | error: string |
@@ -33,10 +35,11 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
33 | private paramsSub: Subscription | 35 | private paramsSub: Subscription |
34 | 36 | ||
35 | constructor ( | 37 | constructor ( |
36 | private formBuilder: FormBuilder, | 38 | protected serverService: ServerService, |
37 | private route: ActivatedRoute, | 39 | private route: ActivatedRoute, |
38 | private router: Router, | 40 | private router: Router, |
39 | private notificationsService: NotificationsService, | 41 | private notificationsService: NotificationsService, |
42 | private formBuilder: FormBuilder, | ||
40 | private userService: UserService | 43 | private userService: UserService |
41 | ) { | 44 | ) { |
42 | super() | 45 | super() |