From 3827c3b3488845f4235714e92eea439423df2909 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 26 Sep 2018 14:46:54 +0200 Subject: Fix quota translations --- .../+admin/users/user-edit/user-create.component.ts | 4 ++++ client/src/app/+admin/users/user-edit/user-edit.ts | 19 +++++++++++++------ .../+admin/users/user-edit/user-update.component.ts | 6 +++++- 3 files changed, 22 insertions(+), 7 deletions(-) (limited to 'client/src/app/+admin/users') diff --git a/client/src/app/+admin/users/user-edit/user-create.component.ts b/client/src/app/+admin/users/user-edit/user-create.component.ts index 25c060344..132e280b9 100644 --- a/client/src/app/+admin/users/user-edit/user-create.component.ts +++ b/client/src/app/+admin/users/user-edit/user-create.component.ts @@ -8,6 +8,7 @@ import { UserEdit } from './user-edit' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' +import { ConfigService } from '@app/+admin/config/shared/config.service' @Component({ selector: 'my-user-create', @@ -20,6 +21,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { constructor ( protected serverService: ServerService, protected formValidatorService: FormValidatorService, + protected configService: ConfigService, private userValidatorsService: UserValidatorsService, private router: Router, private notificationsService: NotificationsService, @@ -27,6 +29,8 @@ export class UserCreateComponent extends UserEdit implements OnInit { private i18n: I18n ) { super() + + this.buildQuotaOptions() } ngOnInit () { 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 4e7ca8a1b..07b087b5b 100644 --- a/client/src/app/+admin/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/users/user-edit/user-edit.ts @@ -2,18 +2,16 @@ import { ServerService } from '../../../core' import { FormReactive } from '../../../shared' import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared' import { EditCustomConfigComponent } from '../../../+admin/config/edit-custom-config/' +import { ConfigService } from '@app/+admin/config/shared/config.service' export abstract class UserEdit extends FormReactive { - // These are used by a HTML select, so convert key into strings - videoQuotaOptions = EditCustomConfigComponent.videoQuotaOptions - .map(q => ({ value: q.value.toString(), label: q.label })) - videoQuotaDailyOptions = EditCustomConfigComponent.videoQuotaDailyOptions - .map(q => ({ value: q.value.toString(), label: q.label })) - + videoQuotaOptions: { value: string, label: string }[] = [] + videoQuotaDailyOptions: { value: string, label: string }[] = [] roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] })) protected abstract serverService: ServerService + protected abstract configService: ConfigService abstract isCreation (): boolean abstract getFormButtonTitle (): string @@ -35,4 +33,13 @@ export abstract class UserEdit extends FormReactive { return multiplier * parseInt(this.form.value['videoQuota'], 10) } + + protected buildQuotaOptions () { + // These are used by a HTML select, so convert key into strings + this.videoQuotaOptions = this.configService + .videoQuotaOptions.map(q => ({ value: q.value.toString(), label: q.label })) + + this.videoQuotaDailyOptions = this.configService + .videoQuotaDailyOptions.map(q => ({ value: q.value.toString(), label: q.label })) + } } 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 5821229b3..9eb91ac95 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 @@ -5,10 +5,11 @@ import { NotificationsService } from 'angular2-notifications' import { UserService } from '../shared' import { ServerService } from '../../../core' import { UserEdit } from './user-edit' -import { UserUpdate, User } from '../../../../../../shared' +import { User, UserUpdate } from '../../../../../../shared' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' +import { ConfigService } from '@app/+admin/config/shared/config.service' @Component({ selector: 'my-user-update', @@ -25,6 +26,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { constructor ( protected formValidatorService: FormValidatorService, protected serverService: ServerService, + protected configService: ConfigService, private userValidatorsService: UserValidatorsService, private route: ActivatedRoute, private router: Router, @@ -33,6 +35,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { private i18n: I18n ) { super() + + this.buildQuotaOptions() } ngOnInit () { -- cgit v1.2.3