From 1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 Apr 2019 10:49:46 +0200 Subject: Add user adminFlags --- .../src/app/+admin/users/user-edit/user-create.component.ts | 7 ++++++- .../src/app/+admin/users/user-edit/user-edit.component.html | 7 +++++++ client/src/app/+admin/users/user-edit/user-edit.ts | 5 +++++ .../src/app/+admin/users/user-edit/user-update.component.ts | 8 ++++++-- client/src/app/shared/users/user-notifications.component.html | 2 +- client/src/app/shared/users/user.model.ts | 11 ++++++++++- 6 files changed, 35 insertions(+), 5 deletions(-) (limited to 'client/src/app') 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 137ecfcbd..9a6801806 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 { FormValidatorService } from '@app/shared/forms/form-validators/form-val import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' import { ConfigService } from '@app/+admin/config/shared/config.service' import { UserService } from '@app/shared' +import { UserAdminFlag } from '@shared/models/users/user-flag.model' @Component({ selector: 'my-user-create', @@ -45,7 +46,8 @@ export class UserCreateComponent extends UserEdit implements OnInit { password: this.userValidatorsService.USER_PASSWORD, role: this.userValidatorsService.USER_ROLE, videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA, - videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY + videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY, + byPassAutoBlacklist: null }, defaultValues) } @@ -54,8 +56,11 @@ export class UserCreateComponent extends UserEdit implements OnInit { const userCreate: UserCreate = this.form.value + userCreate.adminFlags = this.buildAdminFlags(this.form.value) + // A select in HTML is always mapped as a string, we convert it to number userCreate.videoQuota = parseInt(this.form.value['videoQuota'], 10) + userCreate.videoQuotaDaily = parseInt(this.form.value['videoQuotaDaily'], 10) this.userService.addUser(userCreate).subscribe( () => { 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 c6566da24..400bac5d4 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 @@ -79,6 +79,13 @@ +
+ +
+ 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 649b35b0c..adce1b2d4 100644 --- a/client/src/app/+admin/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/users/user-edit/user-edit.ts @@ -2,6 +2,7 @@ import { ServerService } from '../../../core' import { FormReactive } from '../../../shared' import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared' import { ConfigService } from '@app/+admin/config/shared/config.service' +import { UserAdminFlag } from '@shared/models/users/user-flag.model' export abstract class UserEdit extends FormReactive { videoQuotaOptions: { value: string, label: string }[] = [] @@ -42,6 +43,10 @@ export abstract class UserEdit extends FormReactive { return } + protected buildAdminFlags (formValue: any) { + return formValue.byPassAutoBlacklist ? UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST : UserAdminFlag.NONE + } + protected buildQuotaOptions () { // These are used by a HTML select, so convert key into strings this.videoQuotaOptions = this.configService 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 94ef87b08..04b2935f4 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 @@ -10,6 +10,7 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' import { ConfigService } from '@app/+admin/config/shared/config.service' import { UserService } from '@app/shared' +import { UserAdminFlag } from '@shared/models/users/user-flag.model' @Component({ selector: 'my-user-update', @@ -46,7 +47,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { email: this.userValidatorsService.USER_EMAIL, role: this.userValidatorsService.USER_ROLE, videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA, - videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY + videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY, + byPassAutoBlacklist: null }, defaultValues) this.paramsSub = this.route.params.subscribe(routeParams => { @@ -67,6 +69,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { this.error = undefined const userUpdate: UserUpdate = this.form.value + userUpdate.adminFlags = this.buildAdminFlags(this.form.value) // A select in HTML is always mapped as a string, we convert it to number userUpdate.videoQuota = parseInt(this.form.value['videoQuota'], 10) @@ -111,7 +114,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { email: userJson.email, role: userJson.role, videoQuota: userJson.videoQuota, - videoQuotaDaily: userJson.videoQuotaDaily + videoQuotaDaily: userJson.videoQuotaDaily, + byPassAutoBlacklist: userJson.adminFlags & UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST }) } } diff --git a/client/src/app/shared/users/user-notifications.component.html b/client/src/app/shared/users/user-notifications.component.html index d27f60158..d0d9d9f35 100644 --- a/client/src/app/shared/users/user-notifications.component.html +++ b/client/src/app/shared/users/user-notifications.component.html @@ -107,7 +107,7 @@
- Your instance has a new follower + Your instance has a new follower ({{ notification.actorFollow.follower.host }}) awaiting your approval
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index c15f1de8c..e3ed2dfbd 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts @@ -2,15 +2,18 @@ import { hasUserRight, User as UserServerModel, UserNotificationSetting, UserRig import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' import { Account } from '@app/shared/account/account.model' import { Avatar } from '../../../../../shared/models/avatars/avatar.model' +import { UserAdminFlag } from '@shared/models/users/user-flag.model' export class User implements UserServerModel { id: number username: string email: string emailVerified: boolean - role: UserRole nsfwPolicy: NSFWPolicyType + role: UserRole + roleLabel: string + webTorrentEnabled: boolean autoPlayVideo: boolean videosHistoryEnabled: boolean @@ -21,6 +24,8 @@ export class User implements UserServerModel { videoChannels: VideoChannel[] createdAt: Date + adminFlags?: UserAdminFlag + blocked: boolean blockedReason?: string @@ -30,6 +35,7 @@ export class User implements UserServerModel { this.id = hash.id this.username = hash.username this.email = hash.email + this.role = hash.role this.videoChannels = hash.videoChannels @@ -40,6 +46,9 @@ export class User implements UserServerModel { this.videosHistoryEnabled = hash.videosHistoryEnabled this.autoPlayVideo = hash.autoPlayVideo this.createdAt = hash.createdAt + + this.adminFlags = hash.adminFlags + this.blocked = hash.blocked this.blockedReason = hash.blockedReason -- cgit v1.2.3