61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { Component, Injector } from '@angular/core';
|
|
import { BsModalRef } from 'ngx-bootstrap/modal';
|
|
import { AppComponentBase } from '@shared/app-component-base';
|
|
import { AccountServiceProxy } from '@shared/service-proxies/service-proxies';
|
|
import { AppTenantAvailabilityState } from '@shared/AppEnums';
|
|
import {
|
|
IsTenantAvailableInput,
|
|
IsTenantAvailableOutput
|
|
} from '@shared/service-proxies/service-proxies';
|
|
|
|
@Component({
|
|
templateUrl: './tenant-change-dialog.component.html'
|
|
})
|
|
export class TenantChangeDialogComponent extends AppComponentBase {
|
|
saving = false;
|
|
tenancyName = '';
|
|
|
|
constructor(
|
|
injector: Injector,
|
|
private _accountService: AccountServiceProxy,
|
|
public bsModalRef: BsModalRef
|
|
) {
|
|
super(injector);
|
|
}
|
|
|
|
save(): void {
|
|
if (!this.tenancyName) {
|
|
abp.multiTenancy.setTenantIdCookie(undefined);
|
|
this.bsModalRef.hide();
|
|
location.reload();
|
|
return;
|
|
}
|
|
|
|
const input = new IsTenantAvailableInput();
|
|
input.tenancyName = this.tenancyName;
|
|
|
|
this.saving = true;
|
|
this._accountService.isTenantAvailable(input).subscribe(
|
|
(result: IsTenantAvailableOutput) => {
|
|
switch (result.state) {
|
|
case AppTenantAvailabilityState.Available:
|
|
abp.multiTenancy.setTenantIdCookie(result.tenantId);
|
|
location.reload();
|
|
return;
|
|
case AppTenantAvailabilityState.InActive:
|
|
this.message.warn(this.l('TenantIsNotActive', this.tenancyName));
|
|
break;
|
|
case AppTenantAvailabilityState.NotFound:
|
|
this.message.warn(
|
|
this.l('ThereIsNoTenantDefinedWithName{0}', this.tenancyName)
|
|
);
|
|
break;
|
|
}
|
|
},
|
|
() => {
|
|
this.saving = false;
|
|
}
|
|
);
|
|
}
|
|
}
|