aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/users/user-edit
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-19 17:33:32 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-19 17:35:41 +0200
commit6a84aafd23c2f887f837cc4826cf7c8c07d1c60f (patch)
treecccff65aad1ff4eb53d40c604441db5d99e425b6 /client/src/app/+admin/users/user-edit
parenta10d56bafc31602dfee9b1c52bbf26ab9aca366a (diff)
downloadPeerTube-6a84aafd23c2f887f837cc4826cf7c8c07d1c60f.tar.gz
PeerTube-6a84aafd23c2f887f837cc4826cf7c8c07d1c60f.tar.zst
PeerTube-6a84aafd23c2f887f837cc4826cf7c8c07d1c60f.zip
Take in account transcoding for video quota
Diffstat (limited to 'client/src/app/+admin/users/user-edit')
-rw-r--r--client/src/app/+admin/users/user-edit/user-add.component.ts5
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.component.html5
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.component.scss4
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.ts24
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts7
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'
14import { ServerService } from '../../../core'
14import { UserCreate } from '../../../../../../shared' 15import { UserCreate } from '../../../../../../shared'
15import { UserEdit } from './user-edit' 16import { 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})
21export class UserAddComponent extends UserEdit implements OnInit { 23export 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 @@
1import { ServerService } from '../../../core'
1import { FormReactive } from '../../../shared' 2import { FormReactive } from '../../../shared'
3import { VideoResolution } from '../../../../../../shared/models/videos/video-resolution.enum'
2 4
3export abstract class UserEdit extends FormReactive { 5export 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
8import { UserService } from '../shared' 8import { UserService } from '../shared'
9import { USER_EMAIL, USER_VIDEO_QUOTA } from '../../../shared' 9import { USER_EMAIL, USER_VIDEO_QUOTA } from '../../../shared'
10import { ServerService } from '../../../core'
10import { UserUpdate } from '../../../../../../shared/models/users/user-update.model' 11import { UserUpdate } from '../../../../../../shared/models/users/user-update.model'
11import { User } from '../../../shared/users/user.model' 12import { User } from '../../../shared/users/user.model'
12import { UserEdit } from './user-edit' 13import { 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})
18export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { 20export 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()