Browse Source

fix(account): add dispatch appconfig action after the switching tenant

pull/3146/head
mehmet-erim 7 years ago
parent
commit
57c1b72f01
  1. 3
      npm/ng-packs/apps/dev-app/src/app/shared/shared.module.ts
  2. 26
      npm/ng-packs/package.json
  3. 49
      npm/ng-packs/packages/account/src/lib/components/tenant-box/tenant-box.component.ts
  4. 2
      npm/ng-packs/scripts/install-new-dependencies.ts

3
npm/ng-packs/apps/dev-app/src/app/shared/shared.module.ts

@ -3,7 +3,6 @@ import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { NgModule } from '@angular/core';
import { ThemeBasicModule } from '@abp/ng.theme.basic';
import { ThemeSharedModule } from '@abp/ng.theme.shared';
import { TableModule } from 'primeng/table';
import { NgxValidateCoreModule } from '@ngx-validate/core';
@NgModule({
@ -12,7 +11,6 @@ import { NgxValidateCoreModule } from '@ngx-validate/core';
CoreModule,
ThemeSharedModule,
ThemeBasicModule,
TableModule,
NgbDropdownModule,
NgxValidateCoreModule,
],
@ -20,7 +18,6 @@ import { NgxValidateCoreModule } from '@ngx-validate/core';
CoreModule,
ThemeSharedModule,
ThemeBasicModule,
TableModule,
NgbDropdownModule,
NgxValidateCoreModule,
],

26
npm/ng-packs/package.json

@ -21,19 +21,19 @@
"generate:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
},
"devDependencies": {
"@abp/ng.account": "~2.1.0",
"@abp/ng.account.config": "~2.1.0",
"@abp/ng.core": "~2.1.0",
"@abp/ng.feature-management": "~2.1.0",
"@abp/ng.identity": "~2.1.0",
"@abp/ng.identity.config": "~2.1.0",
"@abp/ng.permission-management": "~2.1.0",
"@abp/ng.setting-management": "~2.1.0",
"@abp/ng.setting-management.config": "~2.1.0",
"@abp/ng.tenant-management": "~2.1.0",
"@abp/ng.tenant-management.config": "~2.1.0",
"@abp/ng.theme.basic": "~2.1.0",
"@abp/ng.theme.shared": "~2.1.0",
"@abp/ng.account": "~2.2.0",
"@abp/ng.account.config": "~2.2.0",
"@abp/ng.core": "~2.2.0",
"@abp/ng.feature-management": "~2.2.0",
"@abp/ng.identity": "~2.2.0",
"@abp/ng.identity.config": "~2.2.0",
"@abp/ng.permission-management": "~2.2.0",
"@abp/ng.setting-management": "~2.2.0",
"@abp/ng.setting-management.config": "~2.2.0",
"@abp/ng.tenant-management": "~2.2.0",
"@abp/ng.tenant-management.config": "~2.2.0",
"@abp/ng.theme.basic": "~2.2.0",
"@abp/ng.theme.shared": "~2.2.0",
"@angular-builders/jest": "^8.2.0",
"@angular-devkit/build-angular": "~0.803.21",
"@angular-devkit/build-ng-packagr": "~0.803.21",

49
npm/ng-packs/packages/account/src/lib/components/tenant-box/tenant-box.component.ts

@ -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 { Component, OnInit } from '@angular/core';
import { Store } from '@ngxs/store';
import { throwError } from 'rxjs';
import { catchError, take, finalize } from 'rxjs/operators';
import { catchError, take, finalize, switchMap } from 'rxjs/operators';
import snq from 'snq';
import { AccountService } from '../../services/account.service';
import { Account } from '../../models/account';
@ -52,29 +52,32 @@ export class TenantBoxComponent
);
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 }) => {
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));
});
.subscribe();
} else {
this.store.dispatch(new SetTenant(null));
this.store.dispatch([new SetTenant(null), new GetAppConfiguration()]);
this.tenantName = null;
this.isModalVisible = false;
}

2
npm/ng-packs/scripts/install-new-dependencies.ts

@ -17,7 +17,7 @@ const updateAndInstall = async () => {
...packageJson.devDependencies,
...dependencies,
...peerDependencies,
...{ [name]: `^${version}` },
...{ [name]: `~${version}` },
};
packageJson.devDependencies = Object.keys(packageJson.devDependencies)

Loading…
Cancel
Save