From a1b7c6d730c794c8626f61e1df4647325f646486 Mon Sep 17 00:00:00 2001 From: TheDiaval Date: Wed, 31 Jul 2019 15:37:52 +0300 Subject: [PATCH] fix: pr feedbacks --- .../lib/components/users/users.component.html | 2 +- .../lib/components/users/users.component.ts | 141 ++++++------------ .../permission-management.component.html | 2 +- .../components/tenants/tenants.component.html | 8 +- .../components/tenants/tenants.component.ts | 10 +- .../components/profile/profile.component.html | 2 +- 6 files changed, 58 insertions(+), 107 deletions(-) diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html index d90287ec61..3801acc6d2 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html @@ -77,7 +77,7 @@ - +

{{ (selected?.id ? 'AbpIdentity::Edit' : 'AbpIdentity::NewUser') | abpLocalization }}

diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts index ddce116535..908a87454a 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts @@ -1,37 +1,25 @@ -import { ABP } from "@abp/ng.core"; -import { ConfirmationService, Toaster } from "@abp/ng.theme.shared"; -import { - Component, - OnInit, - TemplateRef, - TrackByFunction, - ViewChild -} from "@angular/core"; -import { - AbstractControl, - FormArray, - FormBuilder, - FormGroup, - Validators -} from "@angular/forms"; -import { validatePassword } from "@ngx-validate/core"; -import { Select, Store } from "@ngxs/store"; -import { combineLatest, Observable, Subject } from "rxjs"; -import { debounceTime, filter, map, pluck, take } from "rxjs/operators"; -import snq from "snq"; +import { ABP } from '@abp/ng.core'; +import { ConfirmationService, Toaster } from '@abp/ng.theme.shared'; +import { Component, OnInit, TemplateRef, TrackByFunction, ViewChild } from '@angular/core'; +import { AbstractControl, FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { validatePassword } from '@ngx-validate/core'; +import { Select, Store } from '@ngxs/store'; +import { combineLatest, Observable, Subject } from 'rxjs'; +import { debounceTime, filter, map, pluck, take } from 'rxjs/operators'; +import snq from 'snq'; import { IdentityAddUser, IdentityDeleteUser, IdentityGetUserById, IdentityGetUserRoles, IdentityGetUsers, - IdentityUpdateUser -} from "../../actions/identity.actions"; -import { Identity } from "../../models/identity"; -import { IdentityState } from "../../states/identity.state"; + IdentityUpdateUser, +} from '../../actions/identity.actions'; +import { Identity } from '../../models/identity'; +import { IdentityState } from '../../states/identity.state'; @Component({ - selector: "abp-users", - templateUrl: "./users.component.html" + selector: 'abp-users', + templateUrl: './users.component.html', }) export class UsersComponent implements OnInit { @Select(IdentityState.getUsers) @@ -40,7 +28,7 @@ export class UsersComponent implements OnInit { @Select(IdentityState.getUsersTotalCount) totalCount$: Observable; - @ViewChild("modalContent", { static: false }) + @ViewChild('modalContent', { static: false }) modalContent: TemplateRef; form: FormGroup; @@ -56,7 +44,7 @@ export class UsersComponent implements OnInit { providerKey: string; pageQuery: ABP.PageQueryParams = { - sorting: "userName" + sorting: 'userName', }; isModalVisible: boolean; @@ -65,21 +53,13 @@ export class UsersComponent implements OnInit { search$ = new Subject(); - trackByFn: TrackByFunction = (index, item) => - Object.keys(item)[0] || index; + trackByFn: TrackByFunction = (index, item) => Object.keys(item)[0] || index; get roleGroups(): FormGroup[] { - return snq( - () => (this.form.get("roleNames") as FormArray).controls as FormGroup[], - [] - ); + return snq(() => (this.form.get('roleNames') as FormArray).controls as FormGroup[], []); } - constructor( - private confirmationService: ConfirmationService, - private fb: FormBuilder, - private store: Store - ) {} + constructor(private confirmationService: ConfirmationService, private fb: FormBuilder, private store: Store) {} ngOnInit() { this.search$.pipe(debounceTime(300)).subscribe(value => { @@ -93,45 +73,28 @@ export class UsersComponent implements OnInit { this.form = this.fb.group({ password: [ - "", + '', [ Validators.required, Validators.maxLength(32), Validators.minLength(6), - validatePassword(["small", "capital", "number", "special"]) - ] - ], - userName: [ - this.selected.userName || "", - [Validators.required, Validators.maxLength(256)] - ], - email: [ - this.selected.email || "", - [Validators.required, Validators.email, Validators.maxLength(256)] - ], - name: [this.selected.name || "", [Validators.maxLength(64)]], - surname: [this.selected.surname || "", [Validators.maxLength(64)]], - phoneNumber: [ - this.selected.phoneNumber || "", - [Validators.maxLength(16)] - ], - lockoutEnabled: [ - this.selected.twoFactorEnabled || (this.selected.id ? false : true) - ], - twoFactorEnabled: [ - this.selected.twoFactorEnabled || (this.selected.id ? false : true) + validatePassword(['small', 'capital', 'number', 'special']), + ], ], + userName: [this.selected.userName || '', [Validators.required, Validators.maxLength(256)]], + email: [this.selected.email || '', [Validators.required, Validators.email, Validators.maxLength(256)]], + name: [this.selected.name || '', [Validators.maxLength(64)]], + surname: [this.selected.surname || '', [Validators.maxLength(64)]], + phoneNumber: [this.selected.phoneNumber || '', [Validators.maxLength(16)]], + lockoutEnabled: [this.selected.twoFactorEnabled || (this.selected.id ? false : true)], + twoFactorEnabled: [this.selected.twoFactorEnabled || (this.selected.id ? false : true)], roleNames: this.fb.array( this.roles.map(role => this.fb.group({ - [role.name]: [ - !!snq(() => - this.selectedUserRoles.find(userRole => userRole.id === role.id) - ) - ] - }) - ) - ) + [role.name]: [!!snq(() => this.selectedUserRoles.find(userRole => userRole.id === role.id))], + }), + ), + ), }); } @@ -147,15 +110,12 @@ export class UsersComponent implements OnInit { } onEdit(id: string) { - combineLatest([ - this.store.dispatch(new IdentityGetUserById(id)), - this.store.dispatch(new IdentityGetUserRoles(id)) - ]) + combineLatest([this.store.dispatch(new IdentityGetUserById(id)), this.store.dispatch(new IdentityGetUserRoles(id))]) .pipe( filter(([res1, res2]) => res1 && res2), map(([state, _]) => state), - pluck("IdentityState"), - take(1) + pluck('IdentityState'), + take(1), ) .subscribe((state: Identity.State) => { this.selected = state.selectedUser; @@ -169,11 +129,8 @@ export class UsersComponent implements OnInit { const { roleNames } = this.form.value; const mappedRoleNames = snq( - () => - roleNames - .filter(role => !!role[Object.keys(role)[0]]) - .map(role => Object.keys(role)[0]), - [] + () => roleNames.filter(role => !!role[Object.keys(role)[0]]).map(role => Object.keys(role)[0]), + [], ); this.store @@ -182,12 +139,12 @@ export class UsersComponent implements OnInit { ? new IdentityUpdateUser({ ...this.form.value, id: this.selected.id, - roleNames: mappedRoleNames + roleNames: mappedRoleNames, }) : new IdentityAddUser({ ...this.form.value, - roleNames: mappedRoleNames - }) + roleNames: mappedRoleNames, + }), ) .subscribe(() => { this.isModalVisible = false; @@ -196,13 +153,9 @@ export class UsersComponent implements OnInit { delete(id: string, userName: string) { this.confirmationService - .warn( - "AbpIdentity::UserDeletionConfirmationMessage", - "AbpIdentity::AreYouSure", - { - messageLocalizationParams: [userName] - } - ) + .warn('AbpIdentity::UserDeletionConfirmationMessage', 'AbpIdentity::AreYouSure', { + messageLocalizationParams: [userName], + }) .subscribe((status: Toaster.Status) => { if (status === Toaster.Status.confirm) { this.store.dispatch(new IdentityDeleteUser(id)); @@ -219,8 +172,6 @@ export class UsersComponent implements OnInit { get() { this.loading = true; - this.store - .dispatch(new IdentityGetUsers(this.pageQuery)) - .subscribe(() => (this.loading = false)); + this.store.dispatch(new IdentityGetUsers(this.pageQuery)).subscribe(() => (this.loading = false)); } } diff --git a/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.html b/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.html index ec73bda006..94b45d982b 100644 --- a/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.html +++ b/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.html @@ -1,4 +1,4 @@ - +

{{ 'AbpPermissionManagement::Permissions' | abpLocalization }} - {{ data.entityName }}

diff --git a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html index 4488d0fc34..102b1fd506 100644 --- a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html +++ b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html @@ -88,7 +88,7 @@ - +

{{ selectedModalContent.title | abpLocalization }}

@@ -107,7 +107,7 @@
- +
@@ -118,7 +118,7 @@ - +
@@ -144,6 +144,6 @@ - + Manage Features diff --git a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts index 38dd2f9d8a..a18667570c 100644 --- a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts +++ b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts @@ -36,12 +36,12 @@ export class TenantsComponent { defaultConnectionString: string; - _useSharedDatabase: boolean; - isModalVisible: boolean; selectedModalContent = {} as SelectedModalContent; + _useSharedDatabase: boolean; + get useSharedDatabase(): boolean { return this.defaultConnectionStringForm.get('useSharedDatabase').value; } @@ -50,13 +50,13 @@ export class TenantsComponent { return this.defaultConnectionStringForm.get('defaultConnectionString').value; } - @ViewChild('TenantModalTemplate', { static: false }) + @ViewChild('tenantModalTemplate', { static: false }) tenantModalTemplate: TemplateRef; - @ViewChild('ConnectionStringModalTemplate', { static: false }) + @ViewChild('connectionStringModalTemplate', { static: false }) connectionStringModalTemplate: TemplateRef; - @ViewChild('FeaturesModalTemplate', { static: false }) + @ViewChild('featuresModalTemplate', { static: false }) featuresModalTemplate: TemplateRef; constructor( diff --git a/npm/ng-packs/packages/theme-basic/src/lib/components/profile/profile.component.html b/npm/ng-packs/packages/theme-basic/src/lib/components/profile/profile.component.html index 0a7a1b6b32..9712ae1052 100644 --- a/npm/ng-packs/packages/theme-basic/src/lib/components/profile/profile.component.html +++ b/npm/ng-packs/packages/theme-basic/src/lib/components/profile/profile.component.html @@ -33,7 +33,7 @@ -