Browse Source

refactoring

pull/22829/head
erdemcaygor 1 year ago
parent
commit
8f6aed832d
  1. 5
      npm/ng-packs/apps/dev-app/src/app/app-routing.module.ts
  2. 54
      npm/ng-packs/packages/account/src/lib/account.config.ts
  3. 28
      npm/ng-packs/packages/account/src/lib/account.ts
  4. 3
      npm/ng-packs/packages/account/src/public-api.ts
  5. 39
      npm/ng-packs/packages/identity/src/lib/identity.config.ts
  6. 34
      npm/ng-packs/packages/identity/src/lib/identity.ts
  7. 3
      npm/ng-packs/packages/identity/src/public-api.ts

5
npm/ng-packs/apps/dev-app/src/app/app-routing.module.ts

@ -9,11 +9,12 @@ const routes: Routes = [
},
{
path: 'account',
loadChildren: () => import('@abp/ng.account').then(m => m.accountRoutes),
loadChildren: () => import('@abp/ng.account').then(m => m.createAccountRoutingConfiguration()),
},
{
path: 'identity',
loadChildren: () => import('@abp/ng.identity').then(m => m.identityRoutes),
loadChildren: () =>
import('@abp/ng.identity').then(m => m.createIdentityRoutingConfiguration()),
},
{
path: 'tenant-management',

54
npm/ng-packs/packages/account/src/lib/account.routes.ts → npm/ng-packs/packages/account/src/lib/account.config.ts

@ -1,3 +1,24 @@
import { Routes } from '@angular/router';
import { importProvidersFrom } from '@angular/core';
import {
ForgotPasswordComponent,
LoginComponent,
RegisterComponent,
ResetPasswordComponent,
ManageProfileComponent,
} from './components';
import { eAccountComponents } from './enums';
import { authenticationFlowGuard } from './guards';
import { accountExtensionsResolver } from './resolvers';
import {
RE_LOGIN_CONFIRMATION_TOKEN,
ACCOUNT_CONFIG_OPTIONS,
ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS,
} from './tokens';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { NgxValidateCoreModule } from '@ngx-validate/core';
import { AccountConfigOptions } from './models';
import { accountConfigOptionsFactory } from './utils';
import {
authGuard,
ReplaceableComponents,
@ -5,24 +26,33 @@ import {
RouterOutletComponent,
} from '@abp/ng.core';
import { ForgotPasswordComponent } from './components/forgot-password/forgot-password.component';
import { LoginComponent } from './components/login/login.component';
import { ManageProfileComponent } from './components/manage-profile/manage-profile.component';
import { RegisterComponent } from './components/register/register.component';
import { ResetPasswordComponent } from './components/reset-password/reset-password.component';
import { eAccountComponents } from './enums/components';
import { authenticationFlowGuard } from './guards';
import { accountExtensionsResolver } from './resolvers';
import { Routes } from '@angular/router';
import { provideAccount } from './account';
export function provideAccount(options: AccountConfigOptions = {}) {
return [
importProvidersFrom(NgbDropdownModule, NgxValidateCoreModule),
{ provide: ACCOUNT_CONFIG_OPTIONS, useValue: options },
{
provide: 'ACCOUNT_OPTIONS',
useFactory: accountConfigOptionsFactory,
deps: [ACCOUNT_CONFIG_OPTIONS],
},
{
provide: RE_LOGIN_CONFIRMATION_TOKEN,
useValue: options.isPersonalSettingsChangedConfirmationActive ?? true,
},
{
provide: ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS,
useValue: options.editFormPropContributors,
},
];
}
const canActivate = [authenticationFlowGuard];
export const accountRoutes: Routes = [
export const createAccountRoutingConfiguration = (options: AccountConfigOptions = {}): Routes => [
{
path: '',
component: RouterOutletComponent,
providers: [...provideAccount()],
providers: [...provideAccount(options)],
children: [
{ path: '', pathMatch: 'full', redirectTo: 'login' },
{

28
npm/ng-packs/packages/account/src/lib/account.ts

@ -1,28 +0,0 @@
import { importProvidersFrom } from '@angular/core';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { NgxValidateCoreModule } from '@ngx-validate/core';
import { AccountConfigOptions } from './models/config-options';
import { ACCOUNT_CONFIG_OPTIONS } from './tokens/config-options.token';
import { accountConfigOptionsFactory } from './utils/factory-utils';
import { RE_LOGIN_CONFIRMATION_TOKEN } from './tokens';
import { ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS } from './tokens/extensions.token';
export function provideAccount(options: AccountConfigOptions = {}) {
return [
importProvidersFrom(NgbDropdownModule, NgxValidateCoreModule),
{ provide: ACCOUNT_CONFIG_OPTIONS, useValue: options },
{
provide: 'ACCOUNT_OPTIONS',
useFactory: accountConfigOptionsFactory,
deps: [ACCOUNT_CONFIG_OPTIONS],
},
{
provide: RE_LOGIN_CONFIRMATION_TOKEN,
useValue: options.isPersonalSettingsChangedConfirmationActive ?? true,
},
{
provide: ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS,
useValue: options.editFormPropContributors,
},
];
}

3
npm/ng-packs/packages/account/src/public-api.ts

@ -7,5 +7,4 @@ export * from './lib/services';
export * from './lib/tokens';
export * from './lib/utils';
export * from './lib/resolvers';
export * from './lib/account.routes';
export * from './lib/account';
export * from './lib/account.config';

39
npm/ng-packs/packages/identity/src/lib/identity.routes.ts → npm/ng-packs/packages/identity/src/lib/identity.config.ts

@ -1,4 +1,13 @@
import { Provider } from '@angular/core';
import { Routes } from '@angular/router';
import {
IDENTITY_CREATE_FORM_PROP_CONTRIBUTORS,
IDENTITY_EDIT_FORM_PROP_CONTRIBUTORS,
IDENTITY_ENTITY_ACTION_CONTRIBUTORS,
IDENTITY_ENTITY_PROP_CONTRIBUTORS,
IDENTITY_TOOLBAR_ACTION_CONTRIBUTORS,
} from './tokens';
import { IdentityConfigOptions } from './models';
import {
authGuard,
permissionGuard,
@ -9,15 +18,39 @@ import {
import { RolesComponent, UsersComponent } from './components';
import { identityExtensionsResolver } from './resolvers';
import { eIdentityComponents } from './enums';
import { provideIdentity } from './identity';
export const identityRoutes: Routes = [
export function provideIdentity(options: IdentityConfigOptions = {}): Provider[] {
return [
{
provide: IDENTITY_ENTITY_ACTION_CONTRIBUTORS,
useValue: options.entityActionContributors,
},
{
provide: IDENTITY_TOOLBAR_ACTION_CONTRIBUTORS,
useValue: options.toolbarActionContributors,
},
{
provide: IDENTITY_ENTITY_PROP_CONTRIBUTORS,
useValue: options.entityPropContributors,
},
{
provide: IDENTITY_CREATE_FORM_PROP_CONTRIBUTORS,
useValue: options.createFormPropContributors,
},
{
provide: IDENTITY_EDIT_FORM_PROP_CONTRIBUTORS,
useValue: options.editFormPropContributors,
},
];
}
export const createIdentityRoutingConfiguration = (options: IdentityConfigOptions = {}): Routes => [
{
path: '',
component: RouterOutletComponent,
canActivate: [authGuard, permissionGuard],
resolve: [identityExtensionsResolver],
providers: provideIdentity({}),
providers: provideIdentity(options),
children: [
{ path: '', redirectTo: 'roles', pathMatch: 'full' },
{

34
npm/ng-packs/packages/identity/src/lib/identity.ts

@ -1,34 +0,0 @@
import {
IDENTITY_CREATE_FORM_PROP_CONTRIBUTORS,
IDENTITY_EDIT_FORM_PROP_CONTRIBUTORS,
IDENTITY_ENTITY_ACTION_CONTRIBUTORS,
IDENTITY_ENTITY_PROP_CONTRIBUTORS,
IDENTITY_TOOLBAR_ACTION_CONTRIBUTORS,
} from './tokens';
import { IdentityConfigOptions } from './models';
import { Provider } from '@angular/core';
export function provideIdentity(options: IdentityConfigOptions = {}): Provider[] {
return [
{
provide: IDENTITY_ENTITY_ACTION_CONTRIBUTORS,
useValue: options.entityActionContributors,
},
{
provide: IDENTITY_TOOLBAR_ACTION_CONTRIBUTORS,
useValue: options.toolbarActionContributors,
},
{
provide: IDENTITY_ENTITY_PROP_CONTRIBUTORS,
useValue: options.entityPropContributors,
},
{
provide: IDENTITY_CREATE_FORM_PROP_CONTRIBUTORS,
useValue: options.createFormPropContributors,
},
{
provide: IDENTITY_EDIT_FORM_PROP_CONTRIBUTORS,
useValue: options.editFormPropContributors,
},
];
}

3
npm/ng-packs/packages/identity/src/public-api.ts

@ -5,5 +5,4 @@ export * from './lib/identity.module';
export * from './lib/models';
export * from './lib/tokens';
export * from './lib/resolvers';
export * from './lib/identity.routes';
export * from './lib/identity';
export * from './lib/identity.config';

Loading…
Cancel
Save