diff --git a/npm/ng-packs/packages/account-config/README.md b/npm/ng-packs/packages/account-config/README.md new file mode 100644 index 0000000000..9ace70206e --- /dev/null +++ b/npm/ng-packs/packages/account-config/README.md @@ -0,0 +1 @@ +# @abp/ng.account.config \ No newline at end of file diff --git a/npm/ng-packs/packages/account-config/karma.conf.js b/npm/ng-packs/packages/account-config/karma.conf.js new file mode 100644 index 0000000000..e74978b4ca --- /dev/null +++ b/npm/ng-packs/packages/account-config/karma.conf.js @@ -0,0 +1,32 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../coverage/account-config'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true + }); +}; diff --git a/npm/ng-packs/packages/account-config/ng-package.json b/npm/ng-packs/packages/account-config/ng-package.json new file mode 100644 index 0000000000..de9885883c --- /dev/null +++ b/npm/ng-packs/packages/account-config/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/account-config", + "lib": { + "entryFile": "src/public-api.ts" + } +} \ No newline at end of file diff --git a/npm/ng-packs/packages/account-config/package.json b/npm/ng-packs/packages/account-config/package.json new file mode 100644 index 0000000000..4113d6e984 --- /dev/null +++ b/npm/ng-packs/packages/account-config/package.json @@ -0,0 +1,7 @@ +{ + "name": "@abp/ng.account.config", + "version": "0.0.1", + "publishConfig": { + "access": "public" + } +} diff --git a/npm/ng-packs/packages/account-config/src/lib/account-config.module.ts b/npm/ng-packs/packages/account-config/src/lib/account-config.module.ts new file mode 100644 index 0000000000..a94997e846 --- /dev/null +++ b/npm/ng-packs/packages/account-config/src/lib/account-config.module.ts @@ -0,0 +1,37 @@ +import { CoreModule, noop } from '@abp/ng.core'; +import { ThemeSharedModule } from '@abp/ng.theme.shared'; +import { APP_INITIALIZER, InjectionToken, ModuleWithProviders, NgModule } from '@angular/core'; +import { AccountConfigService } from './services/account-config.service'; + +export interface AccountConfigOptions { + redirectUrl?: string; +} + +export function accountOptionsFactory(options: AccountConfigOptions) { + return { + redirectUrl: '/', + ...options, + }; +} + +export const ACCOUNT_OPTIONS = new InjectionToken('ACCOUNT_OPTIONS'); + +@NgModule({ + imports: [CoreModule, ThemeSharedModule], + providers: [{ provide: APP_INITIALIZER, multi: true, deps: [AccountConfigService], useFactory: noop }], +}) +export class AccountConfigModule { + static forRoot(options = {} as AccountConfigOptions): ModuleWithProviders { + return { + ngModule: AccountConfigModule, + providers: [ + { provide: ACCOUNT_OPTIONS, useValue: options }, + { + provide: 'ACCOUNT_OPTIONS', + useFactory: accountOptionsFactory, + deps: [ACCOUNT_OPTIONS], + }, + ], + }; + } +} diff --git a/npm/ng-packs/packages/account-config/src/lib/services/account-config.service.ts b/npm/ng-packs/packages/account-config/src/lib/services/account-config.service.ts new file mode 100644 index 0000000000..7af86a49c9 --- /dev/null +++ b/npm/ng-packs/packages/account-config/src/lib/services/account-config.service.ts @@ -0,0 +1,21 @@ +import { ABP_ROUTES, eLayoutType, RestService } from '@abp/ng.core'; +import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; + +@Injectable({ + providedIn: 'root', +}) +export class AccountConfigService { + constructor(private router: Router, private restService: RestService) { + ABP_ROUTES.push({ + name: 'AbpAccount::Menu:Account', + path: 'account', + invisible: true, + layout: eLayoutType.application, + children: [ + { path: 'login', name: 'AbpAccount::Login', order: 1 }, + { path: 'register', name: 'AbpAccount::Register', order: 2 }, + ], + }); + } +} diff --git a/npm/ng-packs/packages/account-config/src/public-api.ts b/npm/ng-packs/packages/account-config/src/public-api.ts new file mode 100644 index 0000000000..83270614c0 --- /dev/null +++ b/npm/ng-packs/packages/account-config/src/public-api.ts @@ -0,0 +1,2 @@ +export * from './lib/services/account-config.service'; +export * from './lib/account-config.module'; diff --git a/npm/ng-packs/packages/account-config/src/test.ts b/npm/ng-packs/packages/account-config/src/test.ts new file mode 100644 index 0000000000..978c64fb83 --- /dev/null +++ b/npm/ng-packs/packages/account-config/src/test.ts @@ -0,0 +1,21 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/zone'; +import 'zone.js/dist/zone-testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: any; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); diff --git a/npm/ng-packs/packages/account-config/tsconfig.lib.json b/npm/ng-packs/packages/account-config/tsconfig.lib.json new file mode 100644 index 0000000000..bd23948e59 --- /dev/null +++ b/npm/ng-packs/packages/account-config/tsconfig.lib.json @@ -0,0 +1,26 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/lib", + "target": "es2015", + "declaration": true, + "inlineSources": true, + "types": [], + "lib": [ + "dom", + "es2018" + ] + }, + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true, + "enableResourceInlining": true + }, + "exclude": [ + "src/test.ts", + "**/*.spec.ts" + ] +} diff --git a/npm/ng-packs/packages/account-config/tsconfig.spec.json b/npm/ng-packs/packages/account-config/tsconfig.spec.json new file mode 100644 index 0000000000..16da33db07 --- /dev/null +++ b/npm/ng-packs/packages/account-config/tsconfig.spec.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/spec", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "src/test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/npm/ng-packs/packages/account-config/tslint.json b/npm/ng-packs/packages/account-config/tslint.json new file mode 100644 index 0000000000..8c3919ea62 --- /dev/null +++ b/npm/ng-packs/packages/account-config/tslint.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tslint.json", + "rules": { + "directive-selector": [ + true, + "attribute", + "abp", + "camelCase" + ], + "component-selector": [ + true, + "element", + "abp", + "kebab-case" + ] + } +} diff --git a/npm/ng-packs/packages/account/src/lib/account.module.ts b/npm/ng-packs/packages/account/src/lib/account.module.ts index 8a790a21c1..d6b97fec84 100644 --- a/npm/ng-packs/packages/account/src/lib/account.module.ts +++ b/npm/ng-packs/packages/account/src/lib/account.module.ts @@ -18,6 +18,10 @@ import { ACCOUNT_OPTIONS, optionsFactory } from './tokens/options.token'; }) export class AccountModule {} +/** + * + * @deprecated since version 0.9 + */ export function AccountProviders(options = {} as Options): Provider[] { return [ { provide: ACCOUNT_OPTIONS, useValue: options }, diff --git a/npm/ng-packs/packages/account/src/lib/constants/routes.ts b/npm/ng-packs/packages/account/src/lib/constants/routes.ts index 762d10c313..119bde1e7f 100644 --- a/npm/ng-packs/packages/account/src/lib/constants/routes.ts +++ b/npm/ng-packs/packages/account/src/lib/constants/routes.ts @@ -1,5 +1,9 @@ import { ABP, eLayoutType } from '@abp/ng.core'; +/** + * + * @deprecated since version 0.9 + */ export const ACCOUNT_ROUTES = { routes: [ { diff --git a/npm/ng-packs/packages/core/src/lib/plugins/config/config.plugin.ts b/npm/ng-packs/packages/core/src/lib/plugins/config/config.plugin.ts index 42e8003abe..acecc36fb3 100644 --- a/npm/ng-packs/packages/core/src/lib/plugins/config/config.plugin.ts +++ b/npm/ng-packs/packages/core/src/lib/plugins/config/config.plugin.ts @@ -8,7 +8,7 @@ import clone from 'just-clone'; export const NGXS_CONFIG_PLUGIN_OPTIONS = new InjectionToken('NGXS_CONFIG_PLUGIN_OPTIONS'); -export const ABP_ROUTES = [] as ABP.FullRoute[]; +export let ABP_ROUTES = [] as ABP.FullRoute[]; @Injectable() export class ConfigPlugin implements NgxsPlugin { @@ -40,6 +40,17 @@ export class ConfigPlugin implements NgxsPlugin { } function transformRoutes(routes: Routes = [], wrappers: ABP.FullRoute[] = []): any { + /** + * + * @deprecated since version 0.9.0 + */ + const abpRoutes: ABP.FullRoute[] = routes + .filter(route => { + return snq(() => route.data.routes.routes.find(r => r.path === route.path), false); + }) + .reduce((acc, val) => [...acc, ...val.data.routes.routes], []); + ABP_ROUTES = [...ABP_ROUTES, ...abpRoutes]; + wrappers = ABP_ROUTES.filter(ar => ar.wrapper); const transformed = [] as ABP.FullRoute[]; routes diff --git a/npm/ng-packs/packages/identity/ng-package.json b/npm/ng-packs/packages/identity/ng-package.json index aa178ed0d5..5f547dee2b 100644 --- a/npm/ng-packs/packages/identity/ng-package.json +++ b/npm/ng-packs/packages/identity/ng-package.json @@ -4,5 +4,5 @@ "lib": { "entryFile": "src/public-api.ts" }, - "whitelistedNonPeerDependencies": ["@abp/ng.theme.shared", "@abp/ng.permission-management"] + "whitelistedNonPeerDependencies": ["@abp/ng.theme.shared", "@abp/ng.permission-management", "@abp/ng.identity.config"] } diff --git a/npm/ng-packs/packages/identity/package.json b/npm/ng-packs/packages/identity/package.json index f139753679..7f0c47ef61 100644 --- a/npm/ng-packs/packages/identity/package.json +++ b/npm/ng-packs/packages/identity/package.json @@ -2,7 +2,9 @@ "name": "@abp/ng.identity", "version": "0.9.0", "dependencies": { - "@abp/ng.permission-management": "^0.9.0" + "@abp/ng.theme.shared": "^0.9.0", + "@abp/ng.permission-management": "^0.9.0", + "@abp/ng.identity.config": "0.0.1" }, "publishConfig": { "access": "public"