|
|
@ -1,9 +1,9 @@ |
|
|
import { ABP, SetTenant, SessionState } from '@abp/ng.core'; |
|
|
import { ABP, SetTenant, SessionState, GetAppConfiguration } from '@abp/ng.core'; |
|
|
import { ToasterService } from '@abp/ng.theme.shared'; |
|
|
import { ToasterService } from '@abp/ng.theme.shared'; |
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
import { Store } from '@ngxs/store'; |
|
|
import { Store } from '@ngxs/store'; |
|
|
import { throwError } from 'rxjs'; |
|
|
import { throwError } from 'rxjs'; |
|
|
import { catchError, take, finalize } from 'rxjs/operators'; |
|
|
import { catchError, take, finalize, switchMap } from 'rxjs/operators'; |
|
|
import snq from 'snq'; |
|
|
import snq from 'snq'; |
|
|
import { AccountService } from '../../services/account.service'; |
|
|
import { AccountService } from '../../services/account.service'; |
|
|
import { Account } from '../../models/account'; |
|
|
import { Account } from '../../models/account'; |
|
|
@ -52,29 +52,32 @@ export class TenantBoxComponent |
|
|
); |
|
|
); |
|
|
return throwError(err); |
|
|
return throwError(err); |
|
|
}), |
|
|
}), |
|
|
|
|
|
switchMap(({ success, tenantId }) => { |
|
|
|
|
|
if (success) { |
|
|
|
|
|
this.tenant = { |
|
|
|
|
|
id: tenantId, |
|
|
|
|
|
name: this.tenant.name, |
|
|
|
|
|
}; |
|
|
|
|
|
this.tenantName = this.tenant.name; |
|
|
|
|
|
this.isModalVisible = false; |
|
|
|
|
|
} else { |
|
|
|
|
|
this.toasterService.error( |
|
|
|
|
|
'AbpUiMultiTenancy::GivenTenantIsNotAvailable', |
|
|
|
|
|
'AbpUi::Error', |
|
|
|
|
|
{ |
|
|
|
|
|
messageLocalizationParams: [this.tenant.name], |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
this.tenant = {} as ABP.BasicItem; |
|
|
|
|
|
this.tenantName = ''; |
|
|
|
|
|
} |
|
|
|
|
|
this.store.dispatch(new SetTenant(success ? this.tenant : null)); |
|
|
|
|
|
return this.store.dispatch(new GetAppConfiguration()); |
|
|
|
|
|
}), |
|
|
) |
|
|
) |
|
|
.subscribe(({ success, tenantId }) => { |
|
|
.subscribe(); |
|
|
if (success) { |
|
|
|
|
|
this.tenant = { |
|
|
|
|
|
id: tenantId, |
|
|
|
|
|
name: this.tenant.name, |
|
|
|
|
|
}; |
|
|
|
|
|
this.tenantName = this.tenant.name; |
|
|
|
|
|
this.isModalVisible = false; |
|
|
|
|
|
} else { |
|
|
|
|
|
this.toasterService.error( |
|
|
|
|
|
'AbpUiMultiTenancy::GivenTenantIsNotAvailable', |
|
|
|
|
|
'AbpUi::Error', |
|
|
|
|
|
{ |
|
|
|
|
|
messageLocalizationParams: [this.tenant.name], |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
this.tenant = {} as ABP.BasicItem; |
|
|
|
|
|
} |
|
|
|
|
|
this.store.dispatch(new SetTenant(success ? this.tenant : null)); |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
this.store.dispatch(new SetTenant(null)); |
|
|
this.store.dispatch([new SetTenant(null), new GetAppConfiguration()]); |
|
|
this.tenantName = null; |
|
|
this.tenantName = null; |
|
|
this.isModalVisible = false; |
|
|
this.isModalVisible = false; |
|
|
} |
|
|
} |
|
|
|