From d92d070c91ee73657f2e3a5756954ef63fdba306 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 21 Jan 2022 11:03:25 +0100 Subject: Split user service --- client/src/app/+admin/admin.module.ts | 2 ++ .../overview/users/user-edit/user-create.component.ts | 7 ++++--- .../overview/users/user-edit/user-password.component.ts | 7 ++++--- .../overview/users/user-edit/user-update.component.ts | 6 ++++-- .../+admin/overview/users/user-list/user-list.component.ts | 13 +++++++------ 5 files changed, 21 insertions(+), 14 deletions(-) (limited to 'client/src/app/+admin') diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts index e0dea3ba5..c672fa280 100644 --- a/client/src/app/+admin/admin.module.ts +++ b/client/src/app/+admin/admin.module.ts @@ -10,6 +10,7 @@ import { SharedGlobalIconModule } from '@app/shared/shared-icons' import { SharedMainModule } from '@app/shared/shared-main' import { SharedModerationModule } from '@app/shared/shared-moderation' import { SharedTablesModule } from '@app/shared/shared-tables' +import { SharedUsersModule } from '@app/shared/shared-users' import { SharedVideoCommentModule } from '@app/shared/shared-video-comment' import { SharedVideoMiniatureModule } from '@app/shared/shared-video-miniature' import { AdminRoutingModule } from './admin-routing.module' @@ -67,6 +68,7 @@ import { JobsComponent } from './system/jobs/jobs.component' SharedCustomMarkupModule, SharedVideoMiniatureModule, SharedTablesModule, + SharedUsersModule, TableModule, ChartModule diff --git a/client/src/app/+admin/overview/users/user-edit/user-create.component.ts b/client/src/app/+admin/overview/users/user-edit/user-create.component.ts index b61b22fd0..1713e06ce 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-create.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-create.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core' import { Router } from '@angular/router' import { ConfigService } from '@app/+admin/config/shared/config.service' -import { AuthService, Notifier, ScreenService, ServerService, UserService } from '@app/core' +import { AuthService, Notifier, ScreenService, ServerService } from '@app/core' import { USER_CHANNEL_NAME_VALIDATOR, USER_EMAIL_VALIDATOR, @@ -13,6 +13,7 @@ import { USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormValidatorService } from '@app/shared/shared-forms' +import { UserAdminService } from '@app/shared/shared-users' import { UserCreate, UserRole } from '@shared/models' import { UserEdit } from './user-edit' @@ -32,7 +33,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { protected auth: AuthService, private router: Router, private notifier: Notifier, - private userService: UserService + private userAdminService: UserAdminService ) { super() @@ -71,7 +72,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { userCreate.videoQuota = parseInt(this.form.value['videoQuota'], 10) userCreate.videoQuotaDaily = parseInt(this.form.value['videoQuotaDaily'], 10) - this.userService.addUser(userCreate) + this.userAdminService.addUser(userCreate) .subscribe({ next: () => { this.notifier.success($localize`User ${userCreate.username} created.`) diff --git a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts index 42bf20de1..8999d1f00 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts @@ -1,7 +1,8 @@ import { Component, Input, OnInit } from '@angular/core' -import { Notifier, UserService } from '@app/core' +import { Notifier } from '@app/core' import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' +import { UserAdminService } from '@app/shared/shared-users' import { UserUpdate } from '@shared/models' @Component({ @@ -19,7 +20,7 @@ export class UserPasswordComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, private notifier: Notifier, - private userService: UserService + private userAdminService: UserAdminService ) { super() } @@ -35,7 +36,7 @@ export class UserPasswordComponent extends FormReactive implements OnInit { const userUpdate: UserUpdate = this.form.value - this.userService.updateUser(this.userId, userUpdate) + this.userAdminService.updateUser(this.userId, userUpdate) .subscribe({ next: () => this.notifier.success($localize`Password changed for user ${this.username}.`), diff --git a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts index 42599a17e..bab288a67 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts @@ -10,6 +10,7 @@ import { USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormValidatorService } from '@app/shared/shared-forms' +import { UserAdminService } from '@app/shared/shared-users' import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models' import { UserEdit } from './user-edit' @@ -32,7 +33,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { private route: ActivatedRoute, private router: Router, private notifier: Notifier, - private userService: UserService + private userService: UserService, + private userAdminService: UserAdminService ) { super() @@ -86,7 +88,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { if (userUpdate.pluginAuth === 'null') userUpdate.pluginAuth = null - this.userService.updateUser(this.user.id, userUpdate) + this.userAdminService.updateUser(this.user.id, userUpdate) .subscribe({ next: () => { this.notifier.success($localize`User ${this.user.username} updated.`) diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.ts b/client/src/app/+admin/overview/users/user-list/user-list.component.ts index 9fba11cbd..9a9d0f5c6 100644 --- a/client/src/app/+admin/overview/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/overview/users/user-list/user-list.component.ts @@ -1,10 +1,11 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit, ViewChild } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' -import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService, UserService } from '@app/core' +import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' import { AdvancedInputFilter } from '@app/shared/shared-forms' import { DropdownAction } from '@app/shared/shared-main' import { UserBanModalComponent } from '@app/shared/shared-moderation' +import { UserAdminService } from '@app/shared/shared-users' import { User, UserRole } from '@shared/models' type UserForList = User & { @@ -57,7 +58,7 @@ export class UserListComponent extends RestTable implements OnInit { private confirmService: ConfirmService, private serverService: ServerService, private auth: AuthService, - private userService: UserService + private userAdminService: UserAdminService ) { super() } @@ -177,7 +178,7 @@ export class UserListComponent extends RestTable implements OnInit { const res = await this.confirmService.confirm($localize`Do you really want to unban ${users.length} users?`, $localize`Unban`) if (res === false) return - this.userService.unbanUsers(users) + this.userAdminService.unbanUsers(users) .subscribe({ next: () => { this.notifier.success($localize`${users.length} users unbanned.`) @@ -200,7 +201,7 @@ export class UserListComponent extends RestTable implements OnInit { const res = await this.confirmService.confirm(message, $localize`Delete`) if (res === false) return - this.userService.removeUser(users) + this.userAdminService.removeUser(users) .subscribe({ next: () => { this.notifier.success($localize`${users.length} users deleted.`) @@ -212,7 +213,7 @@ export class UserListComponent extends RestTable implements OnInit { } setEmailsAsVerified (users: User[]) { - this.userService.updateUsers(users, { emailVerified: true }) + this.userAdminService.updateUsers(users, { emailVerified: true }) .subscribe({ next: () => { this.notifier.success($localize`${users.length} users email set as verified.`) @@ -230,7 +231,7 @@ export class UserListComponent extends RestTable implements OnInit { protected reloadData () { this.selectedUsers = [] - this.userService.getUsers({ + this.userAdminService.getUsers({ pagination: this.pagination, sort: this.sort, search: this.search -- cgit v1.2.3