Fix quota translations
This commit is contained in:
parent
4a216666e7
commit
3827c3b348
|
@ -14,37 +14,10 @@ import { BuildFormDefaultValues, FormValidatorService } from '@app/shared/forms/
|
||||||
styleUrls: [ './edit-custom-config.component.scss' ]
|
styleUrls: [ './edit-custom-config.component.scss' ]
|
||||||
})
|
})
|
||||||
export class EditCustomConfigComponent extends FormReactive implements OnInit {
|
export class EditCustomConfigComponent extends FormReactive implements OnInit {
|
||||||
static videoQuotaOptions = [
|
|
||||||
{ value: -1, label: 'Unlimited' },
|
|
||||||
{ value: 0, label: '0' },
|
|
||||||
{ value: 100 * 1024 * 1024, label: '100MB' },
|
|
||||||
{ value: 500 * 1024 * 1024, label: '500MB' },
|
|
||||||
{ value: 1024 * 1024 * 1024, label: '1GB' },
|
|
||||||
{ value: 5 * 1024 * 1024 * 1024, label: '5GB' },
|
|
||||||
{ value: 20 * 1024 * 1024 * 1024, label: '20GB' },
|
|
||||||
{ value: 50 * 1024 * 1024 * 1024, label: '50GB' }
|
|
||||||
]
|
|
||||||
static videoQuotaDailyOptions = [
|
|
||||||
{ value: -1, label: 'Unlimited' },
|
|
||||||
{ value: 0, label: '0' },
|
|
||||||
{ value: 10 * 1024 * 1024, label: '10MB' },
|
|
||||||
{ value: 50 * 1024 * 1024, label: '50MB' },
|
|
||||||
{ value: 100 * 1024 * 1024, label: '100MB' },
|
|
||||||
{ value: 500 * 1024 * 1024, label: '500MB' },
|
|
||||||
{ value: 2 * 1024 * 1024 * 1024, label: '2GB' },
|
|
||||||
{ value: 5 * 1024 * 1024 * 1024, label: '5GB' }
|
|
||||||
]
|
|
||||||
|
|
||||||
customConfig: CustomConfig
|
customConfig: CustomConfig
|
||||||
resolutions = [ '240p', '360p', '480p', '720p', '1080p' ]
|
|
||||||
|
|
||||||
transcodingThreadOptions = [
|
resolutions: string[] = []
|
||||||
{ value: 0, label: 'Auto (via ffmpeg)' },
|
transcodingThreadOptions: { label: string, value: number }[] = []
|
||||||
{ value: 1, label: '1' },
|
|
||||||
{ value: 2, label: '2' },
|
|
||||||
{ value: 4, label: '4' },
|
|
||||||
{ value: 8, label: '8' }
|
|
||||||
]
|
|
||||||
|
|
||||||
private oldCustomJavascript: string
|
private oldCustomJavascript: string
|
||||||
private oldCustomCSS: string
|
private oldCustomCSS: string
|
||||||
|
@ -60,14 +33,30 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
|
||||||
private i18n: I18n
|
private i18n: I18n
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
this.resolutions = [
|
||||||
|
this.i18n('240p'),
|
||||||
|
this.i18n('360p'),
|
||||||
|
this.i18n('480p'),
|
||||||
|
this.i18n('720p'),
|
||||||
|
this.i18n('1080p')
|
||||||
|
]
|
||||||
|
|
||||||
|
this.transcodingThreadOptions = [
|
||||||
|
{ value: 0, label: this.i18n('Auto (via ffmpeg)') },
|
||||||
|
{ value: 1, label: '1' },
|
||||||
|
{ value: 2, label: '2' },
|
||||||
|
{ value: 4, label: '4' },
|
||||||
|
{ value: 8, label: '8' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
get videoQuotaOptions () {
|
get videoQuotaOptions () {
|
||||||
return EditCustomConfigComponent.videoQuotaOptions
|
return this.configService.videoQuotaOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
get videoQuotaDailyOptions () {
|
get videoQuotaDailyOptions () {
|
||||||
return EditCustomConfigComponent.videoQuotaDailyOptions
|
return this.configService.videoQuotaDailyOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
getResolutionKey (resolution: string) {
|
getResolutionKey (resolution: string) {
|
||||||
|
|
|
@ -4,15 +4,42 @@ import { Injectable } from '@angular/core'
|
||||||
import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model'
|
import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model'
|
||||||
import { environment } from '../../../../environments/environment'
|
import { environment } from '../../../../environments/environment'
|
||||||
import { RestExtractor } from '../../../shared'
|
import { RestExtractor } from '../../../shared'
|
||||||
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ConfigService {
|
export class ConfigService {
|
||||||
private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config'
|
private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config'
|
||||||
|
|
||||||
|
videoQuotaOptions: { value: number, label: string }[] = []
|
||||||
|
videoQuotaDailyOptions: { value: number, label: string }[] = []
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private authHttp: HttpClient,
|
private authHttp: HttpClient,
|
||||||
private restExtractor: RestExtractor
|
private restExtractor: RestExtractor,
|
||||||
) {}
|
private i18n: I18n
|
||||||
|
) {
|
||||||
|
this.videoQuotaOptions = [
|
||||||
|
{ value: -1, label: this.i18n('Unlimited') },
|
||||||
|
{ value: 0, label: '0' },
|
||||||
|
{ value: 100 * 1024 * 1024, label: this.i18n('100MB') },
|
||||||
|
{ value: 500 * 1024 * 1024, label: this.i18n('500MB') },
|
||||||
|
{ value: 1024 * 1024 * 1024, label: this.i18n('1GB') },
|
||||||
|
{ value: 5 * 1024 * 1024 * 1024, label: this.i18n('5GB') },
|
||||||
|
{ value: 20 * 1024 * 1024 * 1024, label: this.i18n('20GB') },
|
||||||
|
{ value: 50 * 1024 * 1024 * 1024, label: this.i18n('50GB') }
|
||||||
|
]
|
||||||
|
|
||||||
|
this.videoQuotaDailyOptions = [
|
||||||
|
{ value: -1, label: this.i18n('Unlimited') },
|
||||||
|
{ value: 0, label: '0' },
|
||||||
|
{ value: 10 * 1024 * 1024, label: this.i18n('10MB') },
|
||||||
|
{ value: 50 * 1024 * 1024, label: this.i18n('50MB') },
|
||||||
|
{ value: 100 * 1024 * 1024, label: this.i18n('100MB') },
|
||||||
|
{ value: 500 * 1024 * 1024, label: this.i18n('500MB') },
|
||||||
|
{ value: 2 * 1024 * 1024 * 1024, label: this.i18n('2GB') },
|
||||||
|
{ value: 5 * 1024 * 1024 * 1024, label: this.i18n('5GB') }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
getCustomConfig () {
|
getCustomConfig () {
|
||||||
return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom')
|
return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom')
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
<td>{{ follow.score }}</td>
|
<td>{{ follow.score }}</td>
|
||||||
<td>{{ follow.follower.name }}</td>
|
<td>{{ follow.follower.name }}</td>
|
||||||
<td>{{ follow.follower.host }}</td>
|
<td>{{ follow.follower.host }}</td>
|
||||||
<td>{{ follow.state }}</td>
|
|
||||||
|
<td *ngIf="follow.state === 'accepted'" i18n>Accepted</td>
|
||||||
|
<td *ngIf="follow.state === 'pending'" i18n>Pending</td>
|
||||||
|
|
||||||
<td>{{ follow.createdAt }}</td>
|
<td>{{ follow.createdAt }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
|
@ -17,7 +17,10 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ follow.id }}</td>
|
<td>{{ follow.id }}</td>
|
||||||
<td>{{ follow.following.host }}</td>
|
<td>{{ follow.following.host }}</td>
|
||||||
<td>{{ follow.state }}</td>
|
|
||||||
|
<td *ngIf="follow.state === 'accepted'" i18n>Accepted</td>
|
||||||
|
<td *ngIf="follow.state === 'pending'" i18n>Pending</td>
|
||||||
|
|
||||||
<td>{{ follow.createdAt }}</td>
|
<td>{{ follow.createdAt }}</td>
|
||||||
<td>
|
<td>
|
||||||
<my-redundancy-checkbox
|
<my-redundancy-checkbox
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { UserEdit } from './user-edit'
|
||||||
import { I18n } from '@ngx-translate/i18n-polyfill'
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
||||||
import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
|
import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
|
||||||
import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
|
import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
|
||||||
|
import { ConfigService } from '@app/+admin/config/shared/config.service'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-user-create',
|
selector: 'my-user-create',
|
||||||
|
@ -20,6 +21,7 @@ export class UserCreateComponent extends UserEdit implements OnInit {
|
||||||
constructor (
|
constructor (
|
||||||
protected serverService: ServerService,
|
protected serverService: ServerService,
|
||||||
protected formValidatorService: FormValidatorService,
|
protected formValidatorService: FormValidatorService,
|
||||||
|
protected configService: ConfigService,
|
||||||
private userValidatorsService: UserValidatorsService,
|
private userValidatorsService: UserValidatorsService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
|
@ -27,6 +29,8 @@ export class UserCreateComponent extends UserEdit implements OnInit {
|
||||||
private i18n: I18n
|
private i18n: I18n
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
this.buildQuotaOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
|
|
|
@ -2,18 +2,16 @@ import { ServerService } from '../../../core'
|
||||||
import { FormReactive } from '../../../shared'
|
import { FormReactive } from '../../../shared'
|
||||||
import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared'
|
import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared'
|
||||||
import { EditCustomConfigComponent } from '../../../+admin/config/edit-custom-config/'
|
import { EditCustomConfigComponent } from '../../../+admin/config/edit-custom-config/'
|
||||||
|
import { ConfigService } from '@app/+admin/config/shared/config.service'
|
||||||
|
|
||||||
export abstract class UserEdit extends FormReactive {
|
export abstract class UserEdit extends FormReactive {
|
||||||
|
|
||||||
// These are used by a HTML select, so convert key into strings
|
videoQuotaOptions: { value: string, label: string }[] = []
|
||||||
videoQuotaOptions = EditCustomConfigComponent.videoQuotaOptions
|
videoQuotaDailyOptions: { value: string, label: string }[] = []
|
||||||
.map(q => ({ value: q.value.toString(), label: q.label }))
|
|
||||||
videoQuotaDailyOptions = EditCustomConfigComponent.videoQuotaDailyOptions
|
|
||||||
.map(q => ({ value: q.value.toString(), label: q.label }))
|
|
||||||
|
|
||||||
roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
|
roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
|
||||||
|
|
||||||
protected abstract serverService: ServerService
|
protected abstract serverService: ServerService
|
||||||
|
protected abstract configService: ConfigService
|
||||||
abstract isCreation (): boolean
|
abstract isCreation (): boolean
|
||||||
abstract getFormButtonTitle (): string
|
abstract getFormButtonTitle (): string
|
||||||
|
|
||||||
|
@ -35,4 +33,13 @@ export abstract class UserEdit extends FormReactive {
|
||||||
|
|
||||||
return multiplier * parseInt(this.form.value['videoQuota'], 10)
|
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 }))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,11 @@ import { NotificationsService } from 'angular2-notifications'
|
||||||
import { UserService } from '../shared'
|
import { UserService } from '../shared'
|
||||||
import { ServerService } from '../../../core'
|
import { ServerService } from '../../../core'
|
||||||
import { UserEdit } from './user-edit'
|
import { UserEdit } from './user-edit'
|
||||||
import { UserUpdate, User } from '../../../../../../shared'
|
import { User, UserUpdate } from '../../../../../../shared'
|
||||||
import { I18n } from '@ngx-translate/i18n-polyfill'
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
||||||
import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
|
import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
|
||||||
import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
|
import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
|
||||||
|
import { ConfigService } from '@app/+admin/config/shared/config.service'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-user-update',
|
selector: 'my-user-update',
|
||||||
|
@ -25,6 +26,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
|
||||||
constructor (
|
constructor (
|
||||||
protected formValidatorService: FormValidatorService,
|
protected formValidatorService: FormValidatorService,
|
||||||
protected serverService: ServerService,
|
protected serverService: ServerService,
|
||||||
|
protected configService: ConfigService,
|
||||||
private userValidatorsService: UserValidatorsService,
|
private userValidatorsService: UserValidatorsService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
@ -33,6 +35,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
|
||||||
private i18n: I18n
|
private i18n: I18n
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
this.buildQuotaOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
|
|
|
@ -41,9 +41,9 @@ describe('Test jobs', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should list jobs with sort and pagination', async function () {
|
it('Should list jobs with sort and pagination', async function () {
|
||||||
const res = await getJobsListPaginationAndSort(servers[1].url, servers[1].accessToken, 'completed', 1, 1, 'createdAt')
|
const res = await getJobsListPaginationAndSort(servers[1].url, servers[1].accessToken, 'completed', 1, 2, 'createdAt')
|
||||||
expect(res.body.total).to.be.above(2)
|
expect(res.body.total).to.be.above(2)
|
||||||
expect(res.body.data).to.have.lengthOf(1)
|
expect(res.body.data).to.have.lengthOf(2)
|
||||||
|
|
||||||
let job = res.body.data[0]
|
let job = res.body.data[0]
|
||||||
// Skip repeat jobs
|
// Skip repeat jobs
|
||||||
|
|
Loading…
Reference in New Issue