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>
<abp-modal [(visible)]="isModalVisible" *ngIf="isModalVisible" [centered]="true">
<abp-modal [(visible)]="isModalVisible" *ngIf="isModalVisible">
<ng-template #abpHeader>
<h3>{{ (selected?.id ? 'AbpIdentity::Edit' : 'AbpIdentity::NewUser') | abpLocalization }}</h3>
</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 { 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<number>;
@ViewChild("modalContent", { static: false })
@ViewChild('modalContent', { static: false })
modalContent: TemplateRef<any>;
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<string>();
trackByFn: TrackByFunction<AbstractControl> = (index, item) =>
Object.keys(item)[0] || index;
trackByFn: TrackByFunction<AbstractControl> = (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));
}
}

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

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

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

Loading…
Cancel
Save