Browse Source

Merge branch 'dev' of https://github.com/abpframework/abp into dev

pull/1595/head
Halil İbrahim Kalkan 7 years ago
parent
commit
7e149b7885
  1. 1
      npm/ng-packs/packages/identity/src/lib/actions/identity.actions.ts
  2. 15
      npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html
  3. 45
      npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts
  4. 2
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.html
  5. 7
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts
  6. 3
      npm/ng-packs/packages/identity/src/lib/services/identity.service.ts
  7. 4
      npm/ng-packs/packages/identity/src/lib/states/identity.state.ts
  8. 2
      npm/ng-packs/packages/tenant-management/src/lib/actions/tenant-management.actions.ts
  9. 25
      npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html
  10. 44
      npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts
  11. 3
      npm/ng-packs/packages/tenant-management/src/lib/services/tenant-management.service.ts
  12. 9
      npm/ng-packs/packages/tenant-management/src/lib/states/tenant-management.state.ts

1
npm/ng-packs/packages/identity/src/lib/actions/identity.actions.ts

@ -3,6 +3,7 @@ import { ABP } from '@abp/ng.core';
export class IdentityGetRoles { export class IdentityGetRoles {
static readonly type = '[Identity] Get Roles'; static readonly type = '[Identity] Get Roles';
constructor(public payload?: ABP.PageQueryParams) {}
} }
export class IdentityGetRoleById { export class IdentityGetRoleById {

15
npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html

@ -17,11 +17,20 @@
><input ><input
type="search" type="search"
class="form-control form-control-sm" class="form-control form-control-sm"
placeholder="Search" [placeholder]="'AbpUi::PagerSearch' | abpLocalization"
(input)="dt.filterGlobal($event.target.value, 'contains')" (input)="search$.next($event.target.value)"
/></label> /></label>
</div> </div>
<p-table #dt [value]="roles$ | async" [globalFilterFields]="['name']" [paginator]="true" [rows]="10"> <p-table
[value]="data$ | async"
[lazy]="true"
[lazyLoadOnInit]="false"
[paginator]="true"
[rows]="10"
[totalRecords]="totalCount$ | async"
[loading]="loading"
(onLazyLoad)="onPageChange($event)"
>
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th>{{ 'AbpIdentity::Actions' | abpLocalization }}</th> <th>{{ 'AbpIdentity::Actions' | abpLocalization }}</th>

45
npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts

@ -1,6 +1,6 @@
import { Component, TemplateRef, ViewChild } from '@angular/core'; import { Component, TemplateRef, ViewChild, OnInit } from '@angular/core';
import { Select, Store } from '@ngxs/store'; import { Select, Store } from '@ngxs/store';
import { Observable } from 'rxjs'; import { Observable, Subject } from 'rxjs';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { IdentityState } from '../../states/identity.state'; import { IdentityState } from '../../states/identity.state';
import { Identity } from '../../models/identity'; import { Identity } from '../../models/identity';
@ -9,17 +9,22 @@ import {
IdentityAddRole, IdentityAddRole,
IdentityDeleteRole, IdentityDeleteRole,
IdentityGetRoleById, IdentityGetRoleById,
IdentityGetRoles,
} from '../../actions/identity.actions'; } from '../../actions/identity.actions';
import { pluck } from 'rxjs/operators'; import { pluck, debounceTime, finalize } from 'rxjs/operators';
import { ConfirmationService, Toaster } from '@abp/ng.theme.shared'; import { ConfirmationService, Toaster } from '@abp/ng.theme.shared';
import { ABP } from '@abp/ng.core';
@Component({ @Component({
selector: 'abp-roles', selector: 'abp-roles',
templateUrl: './roles.component.html', templateUrl: './roles.component.html',
}) })
export class RolesComponent { export class RolesComponent implements OnInit {
@Select(IdentityState.getRoles) @Select(IdentityState.getRoles)
roles$: Observable<Identity.RoleItem[]>; data$: Observable<Identity.RoleItem[]>;
@Select(IdentityState.getRolesTotalCount)
totalCount$: Observable<number>;
form: FormGroup; form: FormGroup;
@ -31,11 +36,26 @@ export class RolesComponent {
providerKey: string; providerKey: string;
pageQuery: ABP.PageQueryParams = {
sorting: 'name',
};
loading: boolean = false;
search$ = new Subject<string>();
@ViewChild('modalContent', { static: false }) @ViewChild('modalContent', { static: false })
modalContent: TemplateRef<any>; modalContent: TemplateRef<any>;
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 => {
this.pageQuery.filter = value;
this.get();
});
}
createForm() { createForm() {
this.form = this.fb.group({ this.form = this.fb.group({
name: [this.selected.name || '', [Validators.required, Validators.maxLength(256)]], name: [this.selected.name || '', [Validators.required, Validators.maxLength(256)]],
@ -89,4 +109,19 @@ export class RolesComponent {
} }
}); });
} }
onPageChange(data) {
this.pageQuery.skipCount = data.first;
this.pageQuery.maxResultCount = data.rows;
this.get();
}
get() {
this.loading = true;
this.store
.dispatch(new IdentityGetRoles(this.pageQuery))
.pipe(finalize(() => (this.loading = false)))
.subscribe();
}
} }

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

@ -23,7 +23,7 @@
><input ><input
type="search" type="search"
class="form-control form-control-sm" class="form-control form-control-sm"
placeholder="Search" [placeholder]="'AbpUi::PagerSearch' | abpLocalization"
(input)="search$.next($event.target.value)" (input)="search$.next($event.target.value)"
/></label> /></label>
</div> </div>

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

@ -4,7 +4,7 @@ import { Component, OnInit, TemplateRef, TrackByFunction, ViewChild } from '@ang
import { AbstractControl, FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { AbstractControl, FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Select, Store } from '@ngxs/store'; import { Select, Store } from '@ngxs/store';
import { combineLatest, Observable, Subject } from 'rxjs'; import { combineLatest, Observable, Subject } from 'rxjs';
import { debounceTime, filter, map, pluck, take } from 'rxjs/operators'; import { debounceTime, filter, map, pluck, take, finalize } from 'rxjs/operators';
import snq from 'snq'; import snq from 'snq';
import { import {
IdentityAddUser, IdentityAddUser,
@ -163,6 +163,9 @@ export class UsersComponent implements OnInit {
get() { get() {
this.loading = true; this.loading = true;
this.store.dispatch(new IdentityGetUsers(this.pageQuery)).subscribe(() => (this.loading = false)); this.store
.dispatch(new IdentityGetUsers(this.pageQuery))
.pipe(finalize(() => (this.loading = false)))
.subscribe();
} }
} }

3
npm/ng-packs/packages/identity/src/lib/services/identity.service.ts

@ -9,10 +9,11 @@ import { Identity } from '../models/identity';
export class IdentityService { export class IdentityService {
constructor(private rest: RestService) {} constructor(private rest: RestService) {}
getRoles(): Observable<Identity.RoleResponse> { getRoles(params = {} as ABP.PageQueryParams): Observable<Identity.RoleResponse> {
const request: Rest.Request<null> = { const request: Rest.Request<null> = {
method: 'GET', method: 'GET',
url: '/api/identity/roles', url: '/api/identity/roles',
params,
}; };
return this.rest.request<null, Identity.RoleResponse>(request); return this.rest.request<null, Identity.RoleResponse>(request);

4
npm/ng-packs/packages/identity/src/lib/states/identity.state.ts

@ -44,8 +44,8 @@ export class IdentityState {
constructor(private identityService: IdentityService) {} constructor(private identityService: IdentityService) {}
@Action(IdentityGetRoles) @Action(IdentityGetRoles)
getRoles({ patchState }: StateContext<Identity.State>) { getRoles({ patchState }: StateContext<Identity.State>, { payload }: IdentityGetRoles) {
return this.identityService.getRoles().pipe( return this.identityService.getRoles(payload).pipe(
tap(roles => tap(roles =>
patchState({ patchState({
roles, roles,

2
npm/ng-packs/packages/tenant-management/src/lib/actions/tenant-management.actions.ts

@ -1,7 +1,9 @@
import { TenantManagement } from '../models/tenant-management'; import { TenantManagement } from '../models/tenant-management';
import { ABP } from '@abp/ng.core';
export class TenantManagementGet { export class TenantManagementGet {
static readonly type = '[TenantManagement] Get'; static readonly type = '[TenantManagement] Get';
constructor(public payload?: ABP.PageQueryParams) {}
} }
export class TenantManagementGetById { export class TenantManagementGetById {

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

@ -26,11 +26,20 @@
><input ><input
type="search" type="search"
class="form-control form-control-sm" class="form-control form-control-sm"
placeholder="Search" [placeholder]="'AbpUi::PagerSearch' | abpLocalization"
(input)="dt.filterGlobal($event.target.value, 'contains')" (input)="search$.next($event.target.value)"
/></label> /></label>
</div> </div>
<p-table #dt [value]="datas$ | async" [globalFilterFields]="['name']" [paginator]="true" [rows]="10"> <p-table
[value]="data$ | async"
[lazy]="true"
[lazyLoadOnInit]="false"
[paginator]="true"
[rows]="10"
[totalRecords]="totalCount$ | async"
[loading]="loading"
(onLazyLoad)="onPageChange($event)"
>
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th>{{ 'AbpTenantManagement::Actions' | abpLocalization }}</th> <th>{{ 'AbpTenantManagement::Actions' | abpLocalization }}</th>
@ -112,7 +121,7 @@
<div class="mt-2"> <div class="mt-2">
<div class="form-group"> <div class="form-group">
<label for="name">{{ 'AbpTenantManagement::TenantName' | abpLocalization }}</label> <label for="name">{{ 'AbpTenantManagement::TenantName' | abpLocalization }}</label>
<input type="text" id="name" class="form-control" formControlName="name" autofocus/> <input type="text" id="name" class="form-control" formControlName="name" autofocus />
</div> </div>
</div> </div>
</form> </form>
@ -123,7 +132,13 @@
<div class="mt-2"> <div class="mt-2">
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input id="useSharedDatabase" type="checkbox" class="form-check-input" formControlName="useSharedDatabase" autofocus/> <input
id="useSharedDatabase"
type="checkbox"
class="form-check-input"
formControlName="useSharedDatabase"
autofocus
/>
<label for="useSharedDatabase" class="font-check-label">{{ <label for="useSharedDatabase" class="font-check-label">{{
'AbpTenantManagement::DisplayName:UseSharedDatabase' | abpLocalization 'AbpTenantManagement::DisplayName:UseSharedDatabase' | abpLocalization
}}</label> }}</label>

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

@ -1,13 +1,14 @@
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 { Component, TemplateRef, ViewChild } from '@angular/core'; import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Select, Store } from '@ngxs/store'; import { Select, Store } from '@ngxs/store';
import { Observable } from 'rxjs'; import { Observable, Subject } from 'rxjs';
import { pluck, switchMap, take } from 'rxjs/operators'; import { debounceTime, finalize, pluck, switchMap, take } from 'rxjs/operators';
import { import {
TenantManagementAdd, TenantManagementAdd,
TenantManagementDelete, TenantManagementDelete,
TenantManagementGet,
TenantManagementGetById, TenantManagementGetById,
TenantManagementUpdate, TenantManagementUpdate,
} from '../../actions/tenant-management.actions'; } from '../../actions/tenant-management.actions';
@ -24,9 +25,12 @@ type SelectedModalContent = {
selector: 'abp-tenants', selector: 'abp-tenants',
templateUrl: './tenants.component.html', templateUrl: './tenants.component.html',
}) })
export class TenantsComponent { export class TenantsComponent implements OnInit {
@Select(TenantManagementState.get) @Select(TenantManagementState.get)
datas$: Observable<ABP.BasicItem[]>; data$: Observable<ABP.BasicItem[]>;
@Select(TenantManagementState.getTenantsTotalCount)
totalCount$: Observable<number>;
selected: ABP.BasicItem; selected: ABP.BasicItem;
@ -42,6 +46,14 @@ export class TenantsComponent {
_useSharedDatabase: boolean; _useSharedDatabase: boolean;
pageQuery: ABP.PageQueryParams = {
sorting: 'name',
};
loading: boolean = false;
search$ = new Subject<string>();
get useSharedDatabase(): boolean { get useSharedDatabase(): boolean {
return this.defaultConnectionStringForm.get('useSharedDatabase').value; return this.defaultConnectionStringForm.get('useSharedDatabase').value;
} }
@ -66,6 +78,13 @@ export class TenantsComponent {
private store: Store, private store: Store,
) {} ) {}
ngOnInit() {
this.search$.pipe(debounceTime(300)).subscribe(value => {
this.pageQuery.filter = value;
this.get();
});
}
private createTenantForm() { private createTenantForm() {
this.tenantForm = this.fb.group({ this.tenantForm = this.fb.group({
name: [this.selected.name || '', [Validators.required, Validators.maxLength(256)]], name: [this.selected.name || '', [Validators.required, Validators.maxLength(256)]],
@ -178,4 +197,19 @@ export class TenantsComponent {
} }
}); });
} }
onPageChange(data) {
this.pageQuery.skipCount = data.first;
this.pageQuery.maxResultCount = data.rows;
this.get();
}
get() {
this.loading = true;
this.store
.dispatch(new TenantManagementGet(this.pageQuery))
.pipe(finalize(() => (this.loading = false)))
.subscribe();
}
} }

3
npm/ng-packs/packages/tenant-management/src/lib/services/tenant-management.service.ts

@ -9,10 +9,11 @@ import { TenantManagement } from '../models/tenant-management';
export class TenantManagementService { export class TenantManagementService {
constructor(private rest: RestService) {} constructor(private rest: RestService) {}
get(): Observable<TenantManagement.Response> { get(params = {} as ABP.PageQueryParams): Observable<TenantManagement.Response> {
const request: Rest.Request<null> = { const request: Rest.Request<null> = {
method: 'GET', method: 'GET',
url: '/api/multi-tenancy/tenants', url: '/api/multi-tenancy/tenants',
params,
}; };
return this.rest.request<null, TenantManagement.Response>(request); return this.rest.request<null, TenantManagement.Response>(request);

9
npm/ng-packs/packages/tenant-management/src/lib/states/tenant-management.state.ts

@ -21,11 +21,16 @@ export class TenantManagementState {
return result.items || []; return result.items || [];
} }
@Selector()
static getTenantsTotalCount({ result }: TenantManagement.State): number {
return result.totalCount;
}
constructor(private tenantManagementService: TenantManagementService) {} constructor(private tenantManagementService: TenantManagementService) {}
@Action(TenantManagementGet) @Action(TenantManagementGet)
get({ patchState }: StateContext<TenantManagement.State>) { get({ patchState }: StateContext<TenantManagement.State>, { payload }: TenantManagementGet) {
return this.tenantManagementService.get().pipe( return this.tenantManagementService.get(payload).pipe(
tap(result => tap(result =>
patchState({ patchState({
result, result,

Loading…
Cancel
Save