Browse Source

fix: pr feedbacks

pull/1556/head
TheDiaval 7 years ago
parent
commit
a1b7c6d730
  1. 2
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.html
  2. 141
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts
  3. 2
      npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.html
  4. 8
      npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html
  5. 10
      npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts
  6. 2
      npm/ng-packs/packages/theme-basic/src/lib/components/profile/profile.component.html

2
npm/ng-packs/packages/identity/src/lib/components/users/users.component.html

@ -77,7 +77,7 @@
</div> </div>
</div> </div>
<abp-modal [(visible)]="isModalVisible" *ngIf="isModalVisible" [centered]="true"> <abp-modal [(visible)]="isModalVisible" *ngIf="isModalVisible">
<ng-template #abpHeader> <ng-template #abpHeader>
<h3>{{ (selected?.id ? 'AbpIdentity::Edit' : 'AbpIdentity::NewUser') | abpLocalization }}</h3> <h3>{{ (selected?.id ? 'AbpIdentity::Edit' : 'AbpIdentity::NewUser') | abpLocalization }}</h3>
</ng-template> </ng-template>

141
npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

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

2
npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.html

@ -1,4 +1,4 @@
<abp-modal *ngIf="visible" size="lg" [(visible)]="visible" [centered]="true"> <abp-modal [(visible)]="visible" *ngIf="visible" size="lg">
<ng-container *ngIf="{ entityName: entityName$ | async } as data"> <ng-container *ngIf="{ entityName: entityName$ | async } as data">
<ng-template #abpHeader> <ng-template #abpHeader>
<h4>{{ 'AbpPermissionManagement::Permissions' | abpLocalization }} - {{ data.entityName }}</h4> <h4>{{ 'AbpPermissionManagement::Permissions' | abpLocalization }} - {{ data.entityName }}</h4>

8
npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html

@ -88,7 +88,7 @@
</div> </div>
</div> </div>
<abp-modal *ngIf="isModalVisible" size="md" [(visible)]="isModalVisible" [centered]="true"> <abp-modal [(visible)]="isModalVisible" *ngIf="isModalVisible">
<ng-template #abpHeader> <ng-template #abpHeader>
<h3>{{ selectedModalContent.title | abpLocalization }}</h3> <h3>{{ selectedModalContent.title | abpLocalization }}</h3>
</ng-template> </ng-template>
@ -107,7 +107,7 @@
</ng-template> </ng-template>
</abp-modal> </abp-modal>
<ng-template #TenantModalTemplate> <ng-template #tenantModalTemplate>
<form [formGroup]="tenantForm"> <form [formGroup]="tenantForm">
<div class="mt-2"> <div class="mt-2">
<div class="form-group"> <div class="form-group">
@ -118,7 +118,7 @@
</form> </form>
</ng-template> </ng-template>
<ng-template #ConnectionStringModalTemplate> <ng-template #connectionStringModalTemplate>
<form [formGroup]="defaultConnectionStringForm"> <form [formGroup]="defaultConnectionStringForm">
<div class="mt-2"> <div class="mt-2">
<div class="form-group"> <div class="form-group">
@ -144,6 +144,6 @@
</form> </form>
</ng-template> </ng-template>
<ng-template #FeaturesModalTemplate> <ng-template #featuresModalTemplate>
Manage Features Manage Features
</ng-template> </ng-template>

10
npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts

@ -36,12 +36,12 @@ export class TenantsComponent {
defaultConnectionString: string; defaultConnectionString: string;
_useSharedDatabase: boolean;
isModalVisible: boolean; isModalVisible: boolean;
selectedModalContent = {} as SelectedModalContent; selectedModalContent = {} as SelectedModalContent;
_useSharedDatabase: boolean;
get useSharedDatabase(): boolean { get useSharedDatabase(): boolean {
return this.defaultConnectionStringForm.get('useSharedDatabase').value; return this.defaultConnectionStringForm.get('useSharedDatabase').value;
} }
@ -50,13 +50,13 @@ export class TenantsComponent {
return this.defaultConnectionStringForm.get('defaultConnectionString').value; return this.defaultConnectionStringForm.get('defaultConnectionString').value;
} }
@ViewChild('TenantModalTemplate', { static: false }) @ViewChild('tenantModalTemplate', { static: false })
tenantModalTemplate: TemplateRef<any>; tenantModalTemplate: TemplateRef<any>;
@ViewChild('ConnectionStringModalTemplate', { static: false }) @ViewChild('connectionStringModalTemplate', { static: false })
connectionStringModalTemplate: TemplateRef<any>; connectionStringModalTemplate: TemplateRef<any>;
@ViewChild('FeaturesModalTemplate', { static: false }) @ViewChild('featuresModalTemplate', { static: false })
featuresModalTemplate: TemplateRef<any>; featuresModalTemplate: TemplateRef<any>;
constructor( constructor(

2
npm/ng-packs/packages/theme-basic/src/lib/components/profile/profile.component.html

@ -33,7 +33,7 @@
</form> </form>
</ng-template> </ng-template>
<ng-template #abpFooter> <ng-template #abpFooter>
<button type="button" class="btn btn-secondary" #abpClose> <button #abpClose type="button" class="btn btn-secondary">
{{ 'AbpIdentity::Cancel' | abpLocalization }} {{ 'AbpIdentity::Cancel' | abpLocalization }}
</button> </button>
<button type="button" class="btn btn-primary" (click)="onSubmit()"> <button type="button" class="btn btn-primary" (click)="onSubmit()">

Loading…
Cancel
Save