X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Badmin%2Fusers%2Fuser-edit%2Fuser-edit.ts;h=af5e674a7df718b6df9c282c44090f0ab16ebec5;hb=9df52d660feb722404be00a50f3c8a612bec1c15;hp=5f5cc590cc241d0c5dcc083b85e4583a0fb13858;hpb=3487330d308166afb542cbacae0475693c0b059e;p=github%2FChocobozzz%2FPeerTube.git 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 5f5cc590c..af5e674a7 100644 --- a/client/src/app/+admin/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/users/user-edit/user-edit.ts @@ -1,21 +1,22 @@ -import { AuthService, ServerService } from '../../../core' -import { FormReactive } from '../../../shared' -import { ServerConfig, USER_ROLE_LABELS, UserRole, VideoResolution } from '../../../../../../shared' +import { Directive, OnInit } from '@angular/core' import { ConfigService } from '@app/+admin/config/shared/config.service' -import { UserAdminFlag } from '@shared/models/users/user-flag.model' -import { OnInit } from '@angular/core' -import { User } from '@app/shared/users/user.model' -import { ScreenService } from '@app/shared/misc/screen.service' - +import { AuthService, ScreenService, ServerService, User } from '@app/core' +import { FormReactive } from '@app/shared/shared-forms' +import { USER_ROLE_LABELS } from '@shared/core-utils/users' +import { HTMLServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models' +import { SelectOptionsItem } from '../../../../types/select-options-item.model' + +@Directive() +// eslint-disable-next-line @angular-eslint/directive-class-suffix export abstract class UserEdit extends FormReactive implements OnInit { - videoQuotaOptions: { value: string, label: string, disabled?: boolean }[] = [] - videoQuotaDailyOptions: { value: string, label: string, disabled?: boolean }[] = [] + videoQuotaOptions: SelectOptionsItem[] = [] + videoQuotaDailyOptions: SelectOptionsItem[] = [] username: string user: User roles: { value: string, label: string }[] = [] - protected serverConfig: ServerConfig + protected serverConfig: HTMLServerConfig protected abstract serverService: ServerService protected abstract configService: ConfigService @@ -25,9 +26,7 @@ export abstract class UserEdit extends FormReactive implements OnInit { abstract getFormButtonTitle (): string ngOnInit (): void { - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) + this.serverConfig = this.serverService.getHTMLConfig() this.buildRoles() } @@ -42,6 +41,11 @@ export abstract class UserEdit extends FormReactive implements OnInit { return forAccount + forChannels } + getAuthPlugins () { + return this.serverConfig.plugin.registeredIdAndPassAuths.map(p => p.npmName) + .concat(this.serverConfig.plugin.registeredExternalAuths.map(p => p.npmName)) + } + isInBigView () { return this.screenService.getWindowInnerWidth() > 1600 } @@ -92,24 +96,7 @@ export abstract class UserEdit extends FormReactive implements OnInit { } 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, - disabled: q.disabled - })) - - this.videoQuotaDailyOptions = this.configService - .videoQuotaDailyOptions.map(q => ({ - value: q.value?.toString(), - label: q.label, - disabled: q.disabled - })) - - console.log( - this.videoQuotaOptions, - this.videoQuotaDailyOptions - ) + this.videoQuotaOptions = this.configService.videoQuotaOptions + this.videoQuotaDailyOptions = this.configService.videoQuotaDailyOptions } }