Fix user role edition
This commit is contained in:
parent
fad0759cab
commit
a31bec5155
|
@ -49,7 +49,7 @@
|
||||||
<label i18n for="role">Role</label>
|
<label i18n for="role">Role</label>
|
||||||
<div class="peertube-select-container">
|
<div class="peertube-select-container">
|
||||||
<select id="role" formControlName="role">
|
<select id="role" formControlName="role">
|
||||||
<option *ngFor="let role of getRoles()" [value]="role.value">
|
<option *ngFor="let role of roles" [value]="role.value">
|
||||||
{{ role.label }}
|
{{ role.label }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -11,6 +11,8 @@ export abstract class UserEdit extends FormReactive implements OnInit {
|
||||||
username: string
|
username: string
|
||||||
userId: number
|
userId: number
|
||||||
|
|
||||||
|
roles: { value: string, label: string }[] = []
|
||||||
|
|
||||||
protected serverConfig: ServerConfig
|
protected serverConfig: ServerConfig
|
||||||
|
|
||||||
protected abstract serverService: ServerService
|
protected abstract serverService: ServerService
|
||||||
|
@ -23,17 +25,20 @@ export abstract class UserEdit extends FormReactive implements OnInit {
|
||||||
this.serverConfig = this.serverService.getTmpConfig()
|
this.serverConfig = this.serverService.getTmpConfig()
|
||||||
this.serverService.getConfig()
|
this.serverService.getConfig()
|
||||||
.subscribe(config => this.serverConfig = config)
|
.subscribe(config => this.serverConfig = config)
|
||||||
|
|
||||||
|
this.buildRoles()
|
||||||
}
|
}
|
||||||
|
|
||||||
getRoles () {
|
buildRoles () {
|
||||||
const authUser = this.auth.getUser()
|
const authUser = this.auth.getUser()
|
||||||
|
|
||||||
if (authUser.role === UserRole.ADMINISTRATOR) {
|
if (authUser.role === UserRole.ADMINISTRATOR) {
|
||||||
return Object.keys(USER_ROLE_LABELS)
|
this.roles = Object.keys(USER_ROLE_LABELS)
|
||||||
.map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
|
.map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
this.roles = [
|
||||||
{ value: UserRole.USER.toString(), label: USER_ROLE_LABELS[UserRole.USER] }
|
{ value: UserRole.USER.toString(), label: USER_ROLE_LABELS[UserRole.USER] }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user