@@ -3,91 +3,96 @@ import { MatDialog } from '@angular/material';
33import { finalize } from 'rxjs/operators' ;
44import { appModuleAnimation } from '@shared/animations/routerTransition' ;
55import {
6- PagedListingComponentBase ,
7- PagedRequestDto
6+ PagedListingComponentBase ,
7+ PagedRequestDto
88} from 'shared/paged-listing-component-base' ;
99import {
10- TenantServiceProxy ,
11- TenantDto ,
12- PagedResultDtoOfTenantDto
10+ TenantServiceProxy ,
11+ TenantDto ,
12+ PagedResultDtoOfTenantDto
1313} from '@shared/service-proxies/service-proxies' ;
1414import { CreateTenantDialogComponent } from './create-tenant/create-tenant-dialog.component' ;
1515import { EditTenantDialogComponent } from './edit-tenant/edit-tenant-dialog.component' ;
1616
17+ class PagedTenantsRequestDto extends PagedRequestDto {
18+ keyword : string ;
19+ isActive : boolean | null ;
20+ }
21+
1722@Component ( {
18- templateUrl : './tenants.component.html' ,
19- animations : [ appModuleAnimation ( ) ]
23+ templateUrl : './tenants.component.html' ,
24+ animations : [ appModuleAnimation ( ) ]
2025} )
2126export class TenantsComponent extends PagedListingComponentBase < TenantDto > {
22- tenants : TenantDto [ ] = [ ] ;
27+ tenants : TenantDto [ ] = [ ] ;
2328
24- constructor (
25- injector : Injector ,
26- private _tenantService : TenantServiceProxy ,
27- private _dialog : MatDialog
28- ) {
29- super ( injector ) ;
30- }
31-
32- list (
33- request : PagedRequestDto ,
34- pageNumber : number ,
35- finishedCallback : Function
36- ) : void {
37- this . _tenantService
38- . getAll ( request . skipCount , request . maxResultCount )
39- . pipe (
40- finalize ( ( ) => {
41- finishedCallback ( ) ;
42- } )
43- )
44- . subscribe ( ( result : PagedResultDtoOfTenantDto ) => {
45- this . tenants = result . items ;
46- this . showPaging ( result , pageNumber ) ;
47- } ) ;
48- }
29+ constructor (
30+ injector : Injector ,
31+ private _tenantService : TenantServiceProxy ,
32+ private _dialog : MatDialog
33+ ) {
34+ super ( injector ) ;
35+ }
4936
50- delete ( tenant : TenantDto ) : void {
51- abp . message . confirm (
52- this . l ( 'TenantDeleteWarningMessage' , tenant . name ) ,
53- ( result : boolean ) => {
54- if ( result ) {
55- this . _tenantService
56- . delete ( tenant . id )
37+ list (
38+ request : PagedTenantsRequestDto ,
39+ pageNumber : number ,
40+ finishedCallback : Function
41+ ) : void {
42+ this . _tenantService
43+ . getAll ( request . keyword , request . isActive , request . skipCount , request . maxResultCount )
5744 . pipe (
58- finalize ( ( ) => {
59- abp . notify . success ( this . l ( 'SuccessfullyDeleted' ) ) ;
60- this . refresh ( ) ;
61- } )
45+ finalize ( ( ) => {
46+ finishedCallback ( ) ;
47+ } )
6248 )
63- . subscribe ( ( ) => { } ) ;
64- }
65- }
66- ) ;
67- }
49+ . subscribe ( ( result : PagedResultDtoOfTenantDto ) => {
50+ this . tenants = result . items ;
51+ this . showPaging ( result , pageNumber ) ;
52+ } ) ;
53+ }
6854
69- createTenant ( ) : void {
70- this . showCreateOrEditTenantDialog ( ) ;
71- }
55+ delete ( tenant : TenantDto ) : void {
56+ abp . message . confirm (
57+ this . l ( 'TenantDeleteWarningMessage' , tenant . name ) ,
58+ ( result : boolean ) => {
59+ if ( result ) {
60+ this . _tenantService
61+ . delete ( tenant . id )
62+ . pipe (
63+ finalize ( ( ) => {
64+ abp . notify . success ( this . l ( 'SuccessfullyDeleted' ) ) ;
65+ this . refresh ( ) ;
66+ } )
67+ )
68+ . subscribe ( ( ) => { } ) ;
69+ }
70+ }
71+ ) ;
72+ }
7273
73- editTenant ( tenant : TenantDto ) : void {
74- this . showCreateOrEditTenantDialog ( tenant . id ) ;
75- }
74+ createTenant ( ) : void {
75+ this . showCreateOrEditTenantDialog ( ) ;
76+ }
7677
77- showCreateOrEditTenantDialog ( id ?: number ) : void {
78- let createOrEditTenantDialog ;
79- if ( id === undefined || id <= 0 ) {
80- createOrEditTenantDialog = this . _dialog . open ( CreateTenantDialogComponent ) ;
81- } else {
82- createOrEditTenantDialog = this . _dialog . open ( EditTenantDialogComponent , {
83- data : id
84- } ) ;
78+ editTenant ( tenant : TenantDto ) : void {
79+ this . showCreateOrEditTenantDialog ( tenant . id ) ;
8580 }
8681
87- createOrEditTenantDialog . afterClosed ( ) . subscribe ( result => {
88- if ( result ) {
89- this . refresh ( ) ;
90- }
91- } ) ;
92- }
82+ showCreateOrEditTenantDialog ( id ?: number ) : void {
83+ let createOrEditTenantDialog ;
84+ if ( id === undefined || id <= 0 ) {
85+ createOrEditTenantDialog = this . _dialog . open ( CreateTenantDialogComponent ) ;
86+ } else {
87+ createOrEditTenantDialog = this . _dialog . open ( EditTenantDialogComponent , {
88+ data : id
89+ } ) ;
90+ }
91+
92+ createOrEditTenantDialog . afterClosed ( ) . subscribe ( result => {
93+ if ( result ) {
94+ this . refresh ( ) ;
95+ }
96+ } ) ;
97+ }
9398}
0 commit comments