aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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
-rw-r--r--client/src/app/core/server/server.service.ts3
-rw-r--r--server/controllers/api/config.ts10
-rw-r--r--shared/models/server-config.model.ts3
8 files changed, 56 insertions, 5 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()
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index f24df5a89..ae507afce 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -11,6 +11,9 @@ export class ServerService {
11 private config: ServerConfig = { 11 private config: ServerConfig = {
12 signup: { 12 signup: {
13 allowed: false 13 allowed: false
14 },
15 transcoding: {
16 enabledResolutions: []
14 } 17 }
15 } 18 }
16 private videoCategories: Array<{ id: number, label: string }> = [] 19 private videoCategories: Array<{ id: number, label: string }> = []
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index f02a2bc58..c9a051bdc 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -1,21 +1,29 @@
1import * as express from 'express' 1import * as express from 'express'
2 2
3import { isSignupAllowed } from '../../helpers' 3import { isSignupAllowed } from '../../helpers'
4import { CONFIG } from '../../initializers'
4import { ServerConfig } from '../../../shared' 5import { ServerConfig } from '../../../shared'
5 6
6const configRouter = express.Router() 7const configRouter = express.Router()
7 8
8configRouter.get('/', getConfig) 9configRouter.get('/', getConfig)
9 10
10// Get the client credentials for the PeerTube front end
11function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { 11function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
12 12
13 isSignupAllowed().then(allowed => { 13 isSignupAllowed().then(allowed => {
14 const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
15 .filter(key => CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
16 .map(r => parseInt(r, 10))
17
14 const json: ServerConfig = { 18 const json: ServerConfig = {
15 signup: { 19 signup: {
16 allowed 20 allowed
21 },
22 transcoding: {
23 enabledResolutions
17 } 24 }
18 } 25 }
26
19 res.json(json) 27 res.json(json)
20 }) 28 })
21} 29}
diff --git a/shared/models/server-config.model.ts b/shared/models/server-config.model.ts
index aab842905..8de808e60 100644
--- a/shared/models/server-config.model.ts
+++ b/shared/models/server-config.model.ts
@@ -2,4 +2,7 @@ export interface ServerConfig {
2 signup: { 2 signup: {
3 allowed: boolean 3 allowed: boolean
4 } 4 }
5 transcoding: {
6 enabledResolutions: number[]
7 }
5} 8}