|
|
@ -1,3 +1,22 @@ |
|
|
|
|
|
import { |
|
|
|
|
|
ChangeDetectionStrategy, |
|
|
|
|
|
Component, |
|
|
|
|
|
DOCUMENT, |
|
|
|
|
|
inject, |
|
|
|
|
|
Injector, |
|
|
|
|
|
makeStateKey, |
|
|
|
|
|
signal, |
|
|
|
|
|
} from '@angular/core'; |
|
|
|
|
|
import { toSignal } from '@angular/core/rxjs-interop'; |
|
|
|
|
|
import { |
|
|
|
|
|
FormsModule, |
|
|
|
|
|
ReactiveFormsModule, |
|
|
|
|
|
UntypedFormBuilder, |
|
|
|
|
|
UntypedFormGroup, |
|
|
|
|
|
} from '@angular/forms'; |
|
|
|
|
|
import { finalize } from 'rxjs/operators'; |
|
|
|
|
|
import { NgxValidateCoreModule } from '@ngx-validate/core'; |
|
|
|
|
|
|
|
|
import { |
|
|
import { |
|
|
ListService, |
|
|
ListService, |
|
|
LocalizationPipe, |
|
|
LocalizationPipe, |
|
|
@ -24,20 +43,11 @@ import { |
|
|
FormPropData, |
|
|
FormPropData, |
|
|
generateFormFromProps, |
|
|
generateFormFromProps, |
|
|
} from '@abp/ng.components/extensible'; |
|
|
} from '@abp/ng.components/extensible'; |
|
|
import { Component, DOCUMENT, inject, Injector, makeStateKey } from '@angular/core'; |
|
|
|
|
|
import { toSignal } from '@angular/core/rxjs-interop'; |
|
|
|
|
|
import { |
|
|
|
|
|
FormsModule, |
|
|
|
|
|
ReactiveFormsModule, |
|
|
|
|
|
UntypedFormBuilder, |
|
|
|
|
|
UntypedFormGroup, |
|
|
|
|
|
} from '@angular/forms'; |
|
|
|
|
|
import { finalize } from 'rxjs/operators'; |
|
|
|
|
|
import { eTenantManagementComponents } from '../../enums/components'; |
|
|
|
|
|
import { PageComponent } from '@abp/ng.components/page'; |
|
|
import { PageComponent } from '@abp/ng.components/page'; |
|
|
import { NgxValidateCoreModule } from '@ngx-validate/core'; |
|
|
import { eTenantManagementComponents } from '../../enums/components'; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush, |
|
|
selector: 'abp-tenants', |
|
|
selector: 'abp-tenants', |
|
|
templateUrl: './tenants.component.html', |
|
|
templateUrl: './tenants.component.html', |
|
|
providers: [ |
|
|
providers: [ |
|
|
@ -71,22 +81,23 @@ export class TenantsComponent { |
|
|
private readonly injector = inject(Injector); |
|
|
private readonly injector = inject(Injector); |
|
|
private document = inject(DOCUMENT); |
|
|
private document = inject(DOCUMENT); |
|
|
|
|
|
|
|
|
readonly data = toSignal(this.list.hookToQuery(query => this.service.getList(query)), { |
|
|
readonly data = toSignal( |
|
|
initialValue: { items: [], totalCount: 0 } as PagedResultDto<TenantDto>, |
|
|
this.list.hookToQuery(query => this.service.getList(query)), |
|
|
}); |
|
|
{ |
|
|
|
|
|
initialValue: { items: [], totalCount: 0 } as PagedResultDto<TenantDto>, |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
selected!: TenantDto; |
|
|
selected!: TenantDto; |
|
|
|
|
|
|
|
|
tenantForm!: UntypedFormGroup; |
|
|
tenantForm!: UntypedFormGroup; |
|
|
|
|
|
|
|
|
isModalVisible!: boolean; |
|
|
readonly isModalVisible = signal(false); |
|
|
|
|
|
readonly visibleFeatures = signal(false); |
|
|
visibleFeatures = false; |
|
|
readonly modalBusy = signal(false); |
|
|
|
|
|
|
|
|
providerKey!: string; |
|
|
providerKey!: string; |
|
|
|
|
|
|
|
|
modalBusy = false; |
|
|
|
|
|
|
|
|
|
|
|
featureManagementKey = eFeatureManagementComponents.FeatureManagement; |
|
|
featureManagementKey = eFeatureManagementComponents.FeatureManagement; |
|
|
TENANTS_KEY = makeStateKey<PagedResultDto<TenantDto>>('tenants'); |
|
|
TENANTS_KEY = makeStateKey<PagedResultDto<TenantDto>>('tenants'); |
|
|
|
|
|
|
|
|
@ -95,7 +106,7 @@ export class TenantsComponent { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
onVisibleFeaturesChange = (value: boolean) => { |
|
|
onVisibleFeaturesChange = (value: boolean) => { |
|
|
this.visibleFeatures = value; |
|
|
this.visibleFeatures.set(value); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
private createTenantForm() { |
|
|
private createTenantForm() { |
|
|
@ -106,20 +117,20 @@ export class TenantsComponent { |
|
|
addTenant() { |
|
|
addTenant() { |
|
|
this.selected = {} as TenantDto; |
|
|
this.selected = {} as TenantDto; |
|
|
this.createTenantForm(); |
|
|
this.createTenantForm(); |
|
|
this.isModalVisible = true; |
|
|
this.isModalVisible.set(true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
editTenant(id: string) { |
|
|
editTenant(id: string) { |
|
|
this.service.get(id).subscribe(res => { |
|
|
this.service.get(id).subscribe(res => { |
|
|
this.selected = res; |
|
|
this.selected = res; |
|
|
this.createTenantForm(); |
|
|
this.createTenantForm(); |
|
|
this.isModalVisible = true; |
|
|
this.isModalVisible.set(true); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
save() { |
|
|
save() { |
|
|
if (!this.tenantForm.valid || this.modalBusy) return; |
|
|
if (!this.tenantForm.valid || this.modalBusy()) return; |
|
|
this.modalBusy = true; |
|
|
this.modalBusy.set(true); |
|
|
|
|
|
|
|
|
const { id } = this.selected; |
|
|
const { id } = this.selected; |
|
|
|
|
|
|
|
|
@ -127,9 +138,9 @@ export class TenantsComponent { |
|
|
? this.service.update(id, { ...this.selected, ...this.tenantForm.value }) |
|
|
? this.service.update(id, { ...this.selected, ...this.tenantForm.value }) |
|
|
: this.service.create(this.tenantForm.value) |
|
|
: this.service.create(this.tenantForm.value) |
|
|
) |
|
|
) |
|
|
.pipe(finalize(() => (this.modalBusy = false))) |
|
|
.pipe(finalize(() => this.modalBusy.set(false))) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
this.isModalVisible = false; |
|
|
this.isModalVisible.set(false); |
|
|
this.toasterService.success('AbpUi::SavedSuccessfully'); |
|
|
this.toasterService.success('AbpUi::SavedSuccessfully'); |
|
|
this.list.get(); |
|
|
this.list.get(); |
|
|
}); |
|
|
}); |
|
|
@ -168,7 +179,7 @@ export class TenantsComponent { |
|
|
openFeaturesModal(providerKey: string) { |
|
|
openFeaturesModal(providerKey: string) { |
|
|
this.providerKey = providerKey; |
|
|
this.providerKey = providerKey; |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
this.visibleFeatures = true; |
|
|
this.visibleFeatures.set(true); |
|
|
}, 0); |
|
|
}, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|