@acorex/platform-generator 18.0.7 → 18.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +11 -11
  2. package/generators.json +9 -9
  3. package/package.json +1 -1
  4. package/src/generators/app-module/files/.eslintrc.json.template +40 -40
  5. package/src/generators/app-module/files/jest.config.ts.template +22 -22
  6. package/src/generators/app-module/files/project.json.template +308 -308
  7. package/src/generators/app-module/files/src/app/app.component.ts.template +10 -10
  8. package/src/generators/app-module/files/src/app/app.module.ts.template +99 -99
  9. package/src/generators/app-module/files/src/app/app.routes.ts.template +13 -13
  10. package/src/generators/app-module/files/src/app/header-interceptor.interceptor.ts.template +33 -33
  11. package/src/generators/app-module/files/src/app/modules/auth/application.loader.ts.template +34 -34
  12. package/src/generators/app-module/files/src/app/modules/auth/auth-root.module.ts.template +52 -52
  13. package/src/generators/app-module/files/src/app/modules/auth/auth.strategy.ts.template +91 -91
  14. package/src/generators/app-module/files/src/app/modules/auth/feature.loader.ts.template +17 -17
  15. package/src/generators/app-module/files/src/app/modules/auth/permission.loader.ts.template +21 -21
  16. package/src/generators/app-module/files/src/app/modules/auth/tenant.loader.ts.template +32 -32
  17. package/src/generators/app-module/files/src/app/modules/common/translation-root.module.ts.template +45 -45
  18. package/src/generators/app-module/files/src/app/modules/layout/entity.loader.ts.template +21 -21
  19. package/src/generators/app-module/files/src/app/modules/layout/layout-root.module.ts.template +79 -79
  20. package/src/generators/app-module/files/src/app/modules/layout/menu.loader.ts.template +159 -159
  21. package/src/generators/app-module/files/src/app/modules/root/home/home.page.html.template +2 -2
  22. package/src/generators/app-module/files/src/app/modules/root/home/home.page.ts.template +9 -9
  23. package/src/generators/app-module/files/src/app/modules/root/root.module.ts.template +32 -32
  24. package/src/generators/app-module/files/src/app/modules/root/sample/sample.entity.ts.template +184 -184
  25. package/src/generators/app-module/files/src/assets/auth-background.svg +6 -6
  26. package/src/generators/app-module/files/src/assets/documents.svg +9 -9
  27. package/src/generators/app-module/files/src/assets/fonts/font-awesome/css/brands.min.css +1457 -1457
  28. package/src/generators/app-module/files/src/assets/fonts/font-awesome/css/fontawesome.min.css +11291 -11291
  29. package/src/generators/app-module/files/src/assets/fonts/font-awesome/css/light.min.css +22 -22
  30. package/src/generators/app-module/files/src/assets/fonts/font-awesome/css/regular.min.css +22 -22
  31. package/src/generators/app-module/files/src/assets/fonts/font-awesome/css/solid.min.css +5 -5
  32. package/src/generators/app-module/files/src/assets/i18n/en/auth.json +49 -49
  33. package/src/generators/app-module/files/src/assets/i18n/en/common.json +179 -179
  34. package/src/generators/app-module/files/src/assets/images/error/error-404.svg +336 -336
  35. package/src/generators/app-module/files/src/assets/images/error/error-offline.svg +133 -133
  36. package/src/generators/app-module/files/src/assets/logos/logo-colored.svg +18 -18
  37. package/src/generators/app-module/files/src/assets/logos/logo-white.svg +17 -17
  38. package/src/generators/app-module/files/src/assets/themes/default/default.scss.template +141 -141
  39. package/src/generators/app-module/files/src/environments/environment.dev.ts.template +19 -19
  40. package/src/generators/app-module/files/src/environments/environment.local.ts.template +19 -19
  41. package/src/generators/app-module/files/src/environments/environment.prod.ts.template +19 -19
  42. package/src/generators/app-module/files/src/environments/environment.test.local.ts.template +19 -19
  43. package/src/generators/app-module/files/src/environments/environment.test.ts.template +19 -19
  44. package/src/generators/app-module/files/src/environments/environment.ts.template +19 -19
  45. package/src/generators/app-module/files/src/index.html.template +34 -34
  46. package/src/generators/app-module/files/src/main.ts.template +6 -6
  47. package/src/generators/app-module/files/src/styles.scss.template +188 -188
  48. package/src/generators/app-module/files/src/test-setup.ts.template +7 -7
  49. package/src/generators/app-module/files/tailwind.config.js.template +18 -18
  50. package/src/generators/app-module/files/tsconfig.app.json.template +10 -10
  51. package/src/generators/app-module/files/tsconfig.editor.json.template +7 -7
  52. package/src/generators/app-module/files/tsconfig.json.template +34 -34
  53. package/src/generators/app-module/files/tsconfig.spec.json.template +11 -11
  54. package/src/generators/app-module/schema.d.ts +4 -4
  55. package/src/generators/app-module/schema.json +27 -27
@@ -1,99 +1,99 @@
1
- import { AXDialogModule } from '@acorex/components/dialog';
2
- import { CommonModule } from '@angular/common';
3
- import { HTTP_INTERCEPTORS, provideHttpClient } from '@angular/common/http';
4
- import { APP_INITIALIZER, NgModule, isDevMode } from '@angular/core';
5
- import { BrowserModule } from '@angular/platform-browser';
6
- import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
- import { RouterModule, provideRouter, withEnabledBlockingInitialNavigation } from '@angular/router';
8
- import { EffectsModule } from '@ngrx/effects';
9
- import { StoreModule } from '@ngrx/store';
10
- import { StoreDevtoolsModule } from '@ngrx/store-devtools';
11
- import { AppComponent } from './app.component';
12
- import { appRoutes } from './app.routes';
13
- import { headerInterceptorInterceptor } from './header-interceptor.interceptor';
14
-
15
- import { AXFormatModule } from '@acorex/core/format';
16
- import { AXValidationModule } from '@acorex/core/validation';
17
- import {
18
- AXPImageUrlLogoConfig,
19
- AXPTextLogoConfig,
20
- AXP_PLATFORM_CONFIG_TOKEN,
21
- configPlatform,
22
- } from '@acorex/platform/common';
23
- import { AXPAuthRootModule } from './modules/auth/auth-root.module';
24
- import { AXPTranslationRootModule } from './modules/common/translation-root.module';
25
- import { AXPLayoutRootModule } from './modules/layout/layout-root.module';
26
-
27
- import { AXLoadingDialogModule } from '@acorex/components/loading-dialog';
28
- import { AXP_ROOT_CONFIG_TOKEN } from '@acorex/platform/common';
29
- import { environment } from '../environments/environment';
30
-
31
- export function initApp() {
32
- return () => {
33
- const loadingText = document.querySelector('#loadingText');
34
- return new Promise((resolve) => {
35
- if (loadingText) loadingText.innerHTML = 'Initializing Modules...';
36
- resolve(0);
37
- });
38
- };
39
- }
40
-
41
-
42
- @NgModule({
43
- imports: [
44
- BrowserAnimationsModule,
45
- BrowserModule,
46
- CommonModule,
47
- RouterModule.forRoot(appRoutes, {
48
- bindToComponentInputs: true,
49
- onSameUrlNavigation: 'reload',
50
- }),
51
- StoreModule.forRoot([]),
52
- EffectsModule.forRoot(),
53
- AXFormatModule.forRoot(),
54
- AXValidationModule.forRoot(),
55
- //
56
- AXPTranslationRootModule,
57
- AXPLayoutRootModule,
58
- AXDialogModule,
59
- AXLoadingDialogModule,
60
- //
61
- AXPAuthRootModule,
62
- //
63
- StoreDevtoolsModule.instrument({
64
- maxAge: 25, // Retains last 25 states
65
- logOnly: !isDevMode(), // Restrict extension to log-only mode
66
- autoPause: true, // Pauses recording actions and state changes when the extension window is not open
67
- trace: false, // If set to true, will include stack trace for every dispatched action, so you can see it in trace tab jumping directly to that part of code
68
- traceLimit: 75, // maximum stack trace frames to be stored (in case trace option was provided as true)
69
- connectInZone: false, // If set to true, the connection is established outside the Angular zone for better performance
70
- }),
71
- ],
72
- providers: [
73
- provideHttpClient(),
74
- provideRouter(appRoutes, withEnabledBlockingInitialNavigation()),
75
- { provide: APP_INITIALIZER, useFactory: initApp, multi: true, deps: [] },
76
- { provide: HTTP_INTERCEPTORS, useClass: headerInterceptorInterceptor, multi: true },
77
- {
78
- provide: AXP_ROOT_CONFIG_TOKEN, useValue: {
79
- baseUrl: environment.baseUrl
80
- }
81
- },
82
- {
83
- provide: AXP_PLATFORM_CONFIG_TOKEN,
84
- useValue: configPlatform({
85
- logo: {
86
- light: new AXPTextLogoConfig('<%= title %>'),
87
- colored: new AXPImageUrlLogoConfig('assets/logos/logo.png'),
88
- //colored: new AXPImageUrlLogoConfig('assets/logos/logo-colored.svg'),
89
- },
90
- title: '<%= title %>',
91
- copyright:
92
- 'Copyright © 2024',
93
- }),
94
- },
95
- ],
96
- declarations: [AppComponent],
97
- bootstrap: [AppComponent],
98
- })
99
- export class AppModule { }
1
+ import { AXDialogModule } from '@acorex/components/dialog';
2
+ import { CommonModule } from '@angular/common';
3
+ import { HTTP_INTERCEPTORS, provideHttpClient } from '@angular/common/http';
4
+ import { APP_INITIALIZER, NgModule, isDevMode } from '@angular/core';
5
+ import { BrowserModule } from '@angular/platform-browser';
6
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
+ import { RouterModule, provideRouter, withEnabledBlockingInitialNavigation } from '@angular/router';
8
+ import { EffectsModule } from '@ngrx/effects';
9
+ import { StoreModule } from '@ngrx/store';
10
+ import { StoreDevtoolsModule } from '@ngrx/store-devtools';
11
+ import { AppComponent } from './app.component';
12
+ import { appRoutes } from './app.routes';
13
+ import { headerInterceptorInterceptor } from './header-interceptor.interceptor';
14
+
15
+ import { AXFormatModule } from '@acorex/core/format';
16
+ import { AXValidationModule } from '@acorex/core/validation';
17
+ import {
18
+ AXPImageUrlLogoConfig,
19
+ AXPTextLogoConfig,
20
+ AXP_PLATFORM_CONFIG_TOKEN,
21
+ configPlatform,
22
+ } from '@acorex/platform/common';
23
+ import { AXPAuthRootModule } from './modules/auth/auth-root.module';
24
+ import { AXPTranslationRootModule } from './modules/common/translation-root.module';
25
+ import { AXPLayoutRootModule } from './modules/layout/layout-root.module';
26
+
27
+ import { AXLoadingDialogModule } from '@acorex/components/loading-dialog';
28
+ import { AXP_ROOT_CONFIG_TOKEN } from '@acorex/platform/common';
29
+ import { environment } from '../environments/environment';
30
+
31
+ export function initApp() {
32
+ return () => {
33
+ const loadingText = document.querySelector('#loadingText');
34
+ return new Promise((resolve) => {
35
+ if (loadingText) loadingText.innerHTML = 'Initializing Modules...';
36
+ resolve(0);
37
+ });
38
+ };
39
+ }
40
+
41
+
42
+ @NgModule({
43
+ imports: [
44
+ BrowserAnimationsModule,
45
+ BrowserModule,
46
+ CommonModule,
47
+ RouterModule.forRoot(appRoutes, {
48
+ bindToComponentInputs: true,
49
+ onSameUrlNavigation: 'reload',
50
+ }),
51
+ StoreModule.forRoot([]),
52
+ EffectsModule.forRoot(),
53
+ AXFormatModule.forRoot(),
54
+ AXValidationModule.forRoot(),
55
+ //
56
+ AXPTranslationRootModule,
57
+ AXPLayoutRootModule,
58
+ AXDialogModule,
59
+ AXLoadingDialogModule,
60
+ //
61
+ AXPAuthRootModule,
62
+ //
63
+ StoreDevtoolsModule.instrument({
64
+ maxAge: 25, // Retains last 25 states
65
+ logOnly: !isDevMode(), // Restrict extension to log-only mode
66
+ autoPause: true, // Pauses recording actions and state changes when the extension window is not open
67
+ trace: false, // If set to true, will include stack trace for every dispatched action, so you can see it in trace tab jumping directly to that part of code
68
+ traceLimit: 75, // maximum stack trace frames to be stored (in case trace option was provided as true)
69
+ connectInZone: false, // If set to true, the connection is established outside the Angular zone for better performance
70
+ }),
71
+ ],
72
+ providers: [
73
+ provideHttpClient(),
74
+ provideRouter(appRoutes, withEnabledBlockingInitialNavigation()),
75
+ { provide: APP_INITIALIZER, useFactory: initApp, multi: true, deps: [] },
76
+ { provide: HTTP_INTERCEPTORS, useClass: headerInterceptorInterceptor, multi: true },
77
+ {
78
+ provide: AXP_ROOT_CONFIG_TOKEN, useValue: {
79
+ baseUrl: environment.baseUrl
80
+ }
81
+ },
82
+ {
83
+ provide: AXP_PLATFORM_CONFIG_TOKEN,
84
+ useValue: configPlatform({
85
+ logo: {
86
+ light: new AXPTextLogoConfig('<%= title %>'),
87
+ colored: new AXPImageUrlLogoConfig('assets/logos/logo.png'),
88
+ //colored: new AXPImageUrlLogoConfig('assets/logos/logo-colored.svg'),
89
+ },
90
+ title: '<%= title %>',
91
+ copyright:
92
+ 'Copyright © 2024',
93
+ }),
94
+ },
95
+ ],
96
+ declarations: [AppComponent],
97
+ bootstrap: [AppComponent],
98
+ })
99
+ export class AppModule { }
@@ -1,14 +1,14 @@
1
- import { AXPAdminLayoutComponent, AX_ADMIN_ROUTES } from '@acorex/platform/layouts';
2
- import { Route } from '@angular/router';
3
-
4
- export const appRoutes: Route[] = [
5
- {
6
- path: '<%= name %>',
7
- loadChildren: () => import('./modules/<%= name %>/<%= name %>-root.module').then((c) => c.<%= upperCase(name) %>RootModule),
8
- },
9
- {
10
- path: '',
11
- pathMatch: 'full',
12
- redirectTo: '<%= name %>',
13
- },
1
+ import { AXPAdminLayoutComponent, AX_ADMIN_ROUTES } from '@acorex/platform/layouts';
2
+ import { Route } from '@angular/router';
3
+
4
+ export const appRoutes: Route[] = [
5
+ {
6
+ path: '<%= name %>',
7
+ loadChildren: () => import('./modules/<%= name %>/<%= name %>-root.module').then((c) => c.<%= upperCase(name) %>RootModule),
8
+ },
9
+ {
10
+ path: '',
11
+ pathMatch: 'full',
12
+ redirectTo: '<%= name %>',
13
+ },
14
14
  ];
@@ -1,33 +1,33 @@
1
- import { AXPSessionService } from '@acorex/platform/auth';
2
- import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
3
- import { Injectable, inject } from '@angular/core';
4
- import { Observable, of, switchMap } from 'rxjs';
5
-
6
- @Injectable()
7
- export class headerInterceptorInterceptor implements HttpInterceptor {
8
- private sessionService = inject(AXPSessionService);
9
-
10
- intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
11
- return this.sessionService
12
- .getToken()
13
- .pipe(
14
- switchMap((token) => {
15
- let modifiedReq = req.clone();
16
- if (!(req.body instanceof FormData) && !req.headers.has('Content-Type')) {
17
- modifiedReq = modifiedReq.clone({ setHeaders: { 'Content-Type': 'application/json' } });
18
- }
19
-
20
- if (token) {
21
- modifiedReq = modifiedReq.clone({ setHeaders: { Authorization: `Bearer ${token}` } });
22
- }
23
-
24
- return next.handle(modifiedReq);
25
- })
26
- )
27
- .pipe(
28
- switchMap((response: HttpEvent<any>) => {
29
- return of(response);
30
- })
31
- );
32
- }
33
- }
1
+ import { AXPSessionService } from '@acorex/platform/auth';
2
+ import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
3
+ import { Injectable, inject } from '@angular/core';
4
+ import { Observable, of, switchMap } from 'rxjs';
5
+
6
+ @Injectable()
7
+ export class headerInterceptorInterceptor implements HttpInterceptor {
8
+ private sessionService = inject(AXPSessionService);
9
+
10
+ intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
11
+ return this.sessionService
12
+ .getToken()
13
+ .pipe(
14
+ switchMap((token) => {
15
+ let modifiedReq = req.clone();
16
+ if (!(req.body instanceof FormData) && !req.headers.has('Content-Type')) {
17
+ modifiedReq = modifiedReq.clone({ setHeaders: { 'Content-Type': 'application/json' } });
18
+ }
19
+
20
+ if (token) {
21
+ modifiedReq = modifiedReq.clone({ setHeaders: { Authorization: `Bearer ${token}` } });
22
+ }
23
+
24
+ return next.handle(modifiedReq);
25
+ })
26
+ )
27
+ .pipe(
28
+ switchMap((response: HttpEvent<any>) => {
29
+ return of(response);
30
+ })
31
+ );
32
+ }
33
+ }
@@ -1,34 +1,34 @@
1
- import { AXPApplication, AXPApplicationLoader, AXPSessionContext } from '@acorex/platform/auth';
2
- import { Injectable } from '@angular/core';
3
- import { Observable, delay, of } from 'rxjs';
4
-
5
- @Injectable()
6
- export class <%= upperCase(name) %>ApplicationLoader implements AXPApplicationLoader {
7
-
8
- getList(context: AXPSessionContext): Observable < AXPApplication[] > {
9
- const <%= name %>_app =
10
- {
11
- id: '1',
12
- name: '<%= name %>',
13
- title: '<%= upperCase(name) %> Application',
14
- version: '1.0.0',
15
- editionName: 'Standard',
16
- };
17
- const console_app =
18
- {
19
- id: '1',
20
- name: 'platform',
21
- title: 'Platform Console',
22
- version: '1.0.0',
23
- editionName: 'Standard',
24
- };
25
-
26
- if (context.user?.name == 'Root' && context.tenant?.id == '99') {
27
- return of([<%= name %>_app, console_app]).pipe(delay(500));
28
- }
29
- else {
30
- return of([<%= name %>_app]).pipe(delay(500));
31
- }
32
- }
33
-
34
- }
1
+ import { AXPApplication, AXPApplicationLoader, AXPSessionContext } from '@acorex/platform/auth';
2
+ import { Injectable } from '@angular/core';
3
+ import { Observable, delay, of } from 'rxjs';
4
+
5
+ @Injectable()
6
+ export class <%= upperCase(name) %>ApplicationLoader implements AXPApplicationLoader {
7
+
8
+ getList(context: AXPSessionContext): Observable < AXPApplication[] > {
9
+ const <%= name %>_app =
10
+ {
11
+ id: '1',
12
+ name: '<%= name %>',
13
+ title: '<%= upperCase(name) %> Application',
14
+ version: '1.0.0',
15
+ editionName: 'Standard',
16
+ };
17
+ const console_app =
18
+ {
19
+ id: '1',
20
+ name: 'platform',
21
+ title: 'Platform Console',
22
+ version: '1.0.0',
23
+ editionName: 'Standard',
24
+ };
25
+
26
+ if (context.user?.name == 'Root' && context.tenant?.id == '99') {
27
+ return of([<%= name %>_app, console_app]).pipe(delay(500));
28
+ }
29
+ else {
30
+ return of([<%= name %>_app]).pipe(delay(500));
31
+ }
32
+ }
33
+
34
+ }
@@ -1,52 +1,52 @@
1
- import { AXMAuthModule, AXMAuthenticationTypes, AXM_AUTH_CONFIG_TOKEN, configAuthModule } from '@acorex/modules/auth';
2
- import { AXPAuthModule, AXP_APPLICATION_LOADER, AXP_FEATURE_LOADER, AXP_PERMISSION_LOADER, AXP_TENANT_LOADER } from '@acorex/platform/auth';
3
- import { NgModule } from '@angular/core';
4
- import { environment } from '../../../environments/environment';
5
- import { <%= upperCase(name) %>TenantLoader } from './tenant.loader';
6
- import { <%= upperCase(name) %>ApplicationLoader } from './application.loader';
7
- import { <%= upperCase(name) %>PermissionLoader } from './permission.loader';
8
- import { <%= upperCase(name) %>FeatureLoader } from './feature.loader';
9
- import { <%= upperCase(name) %>Strategy } from './auth.strategy';
10
-
11
- @NgModule({
12
- imports: [
13
- AXMAuthModule.forRoot(),
14
- AXPAuthModule.forRoot({
15
- strategies: [<%= upperCase(name) %>Strategy],
16
- }),
17
- ],
18
- exports: [],
19
- providers: [
20
- {
21
- provide: AXM_AUTH_CONFIG_TOKEN,
22
- useValue: configAuthModule({
23
- type: AXMAuthenticationTypes.UsernameEmailPassword,
24
- oidc_settings: { ...environment.oidcConfig },
25
- signinPage: {
26
- description: `In this kind of post, the blogger introduces a person they’ve
27
- interviewed and provides some background information about the
28
- interviewee and their work following this is a transcript of the
29
- interview.`,
30
- slogan: 'Fast, Efficient and Productive',
31
- },
32
- }),
33
- },
34
- {
35
- provide: AXP_TENANT_LOADER,
36
- useClass: <%= upperCase(name) %>TenantLoader,
37
- },
38
- {
39
- provide: AXP_APPLICATION_LOADER,
40
- useClass: <%= upperCase(name) %>ApplicationLoader,
41
- },
42
- {
43
- provide: AXP_PERMISSION_LOADER,
44
- useClass: <%= upperCase(name) %>PermissionLoader,
45
- },
46
- {
47
- provide: AXP_FEATURE_LOADER,
48
- useClass: <%= upperCase(name) %>FeatureLoader,
49
- }
50
- ],
51
- })
52
- export class AXPAuthRootModule { }
1
+ import { AXMAuthModule, AXMAuthenticationTypes, AXM_AUTH_CONFIG_TOKEN, configAuthModule } from '@acorex/modules/auth';
2
+ import { AXPAuthModule, AXP_APPLICATION_LOADER, AXP_FEATURE_LOADER, AXP_PERMISSION_LOADER, AXP_TENANT_LOADER } from '@acorex/platform/auth';
3
+ import { NgModule } from '@angular/core';
4
+ import { environment } from '../../../environments/environment';
5
+ import { <%= upperCase(name) %>TenantLoader } from './tenant.loader';
6
+ import { <%= upperCase(name) %>ApplicationLoader } from './application.loader';
7
+ import { <%= upperCase(name) %>PermissionLoader } from './permission.loader';
8
+ import { <%= upperCase(name) %>FeatureLoader } from './feature.loader';
9
+ import { <%= upperCase(name) %>Strategy } from './auth.strategy';
10
+
11
+ @NgModule({
12
+ imports: [
13
+ AXMAuthModule.forRoot(),
14
+ AXPAuthModule.forRoot({
15
+ strategies: [<%= upperCase(name) %>Strategy],
16
+ }),
17
+ ],
18
+ exports: [],
19
+ providers: [
20
+ {
21
+ provide: AXM_AUTH_CONFIG_TOKEN,
22
+ useValue: configAuthModule({
23
+ type: AXMAuthenticationTypes.UsernameEmailPassword,
24
+ oidc_settings: { ...environment.oidcConfig },
25
+ signinPage: {
26
+ description: `In this kind of post, the blogger introduces a person they’ve
27
+ interviewed and provides some background information about the
28
+ interviewee and their work following this is a transcript of the
29
+ interview.`,
30
+ slogan: 'Fast, Efficient and Productive',
31
+ },
32
+ }),
33
+ },
34
+ {
35
+ provide: AXP_TENANT_LOADER,
36
+ useClass: <%= upperCase(name) %>TenantLoader,
37
+ },
38
+ {
39
+ provide: AXP_APPLICATION_LOADER,
40
+ useClass: <%= upperCase(name) %>ApplicationLoader,
41
+ },
42
+ {
43
+ provide: AXP_PERMISSION_LOADER,
44
+ useClass: <%= upperCase(name) %>PermissionLoader,
45
+ },
46
+ {
47
+ provide: AXP_FEATURE_LOADER,
48
+ useClass: <%= upperCase(name) %>FeatureLoader,
49
+ }
50
+ ],
51
+ })
52
+ export class AXPAuthRootModule { }
@@ -1,91 +1,91 @@
1
- import { AXPAuthStrategy, AXPBaseCredentials, AXPRefreshTokenResult, AXPSessionContext, AXPSignInResult, AXPUser } from '@acorex/platform/auth';
2
- import { AXPDataProvider } from '@acorex/platform/common';
3
- import { Injectable, Injector, inject } from '@angular/core';
4
-
5
-
6
- export interface <%= upperCase(name) %>UserPassCredentials extends AXPBaseCredentials {
7
- username: string;
8
- password: string;
9
- }
10
-
11
- @Injectable()
12
- export class <%= upperCase(name) %>Strategy implements AXPAuthStrategy {
13
-
14
- constructor() {
15
-
16
- }
17
-
18
- get name(): string {
19
- return 'user-pass';
20
- }
21
-
22
- async signin(credentials: <%= upperCase(name) %>UserPassCredentials): Promise<AXPSignInResult> {
23
- try {
24
- if (credentials.username == 'root' && credentials.password=='123') {
25
- const user: AXPUser = {
26
- id: 'a683a19a-e3eb-46a7-b81c-7cf9468ae831',
27
- name: 'Root',
28
- title: 'Root User',
29
- avatar: 'https://avatar.iran.liara.run/public/29'
30
- };
31
- const accessToken = 'access_token';
32
- const refreshToken = 'refresh_token';
33
- return {
34
- succeed: true,
35
- data: { user, accessToken, refreshToken },
36
- };
37
- }
38
- if (credentials.username == 'admin' && credentials.password=='123') {
39
- const user: AXPUser = {
40
- id: 'a683a19a-e3eb-46a7-b81c-7cf9468ae831',
41
- name: 'Admin',
42
- title: 'Admin User',
43
- avatar: 'https://avatar.iran.liara.run/public/47'
44
- };
45
- const accessToken = 'access_token';
46
- const refreshToken = 'refresh_token';
47
- return {
48
- succeed: true,
49
- data: { user, accessToken, refreshToken },
50
- };
51
- }
52
- if (credentials.username == 'user' && credentials.password=='123') {
53
- const user: AXPUser = {
54
- id: 'a683a19a-e3eb-76a7-b81c-7cf9468ae831',
55
- name: 'User',
56
- title: 'Sample User',
57
- avatar: 'https://avatar.iran.liara.run/public/56'
58
- };
59
- const accessToken = 'access_token';
60
- const refreshToken = 'refresh_token';
61
- return {
62
- succeed: true,
63
- data: { user, accessToken, refreshToken },
64
- };
65
- }
66
- return {
67
- succeed: false,
68
- };
69
- } catch (error: any) {
70
- if (error?.message) throw new Error(error.message);
71
- // Depending on the error type, you might want to throw a specific error
72
- throw new Error('Network or server error occurred');
73
- }
74
- }
75
-
76
- async signout(): Promise<void> {
77
- console.log('User signed out');
78
- }
79
-
80
- async refreshToken(context: AXPSessionContext): Promise<AXPRefreshTokenResult> {
81
- return {
82
- succeed: true,
83
- data: {
84
- accessToken: 'access_token',
85
- refreshToken: 'refresh_token',
86
- application: context.application,
87
- tenant: context.tenant,
88
- }
89
- }
90
- }
91
- }
1
+ import { AXPAuthStrategy, AXPBaseCredentials, AXPRefreshTokenResult, AXPSessionContext, AXPSignInResult, AXPUser } from '@acorex/platform/auth';
2
+ import { AXPDataProvider } from '@acorex/platform/common';
3
+ import { Injectable, Injector, inject } from '@angular/core';
4
+
5
+
6
+ export interface <%= upperCase(name) %>UserPassCredentials extends AXPBaseCredentials {
7
+ username: string;
8
+ password: string;
9
+ }
10
+
11
+ @Injectable()
12
+ export class <%= upperCase(name) %>Strategy implements AXPAuthStrategy {
13
+
14
+ constructor() {
15
+
16
+ }
17
+
18
+ get name(): string {
19
+ return 'user-pass';
20
+ }
21
+
22
+ async signin(credentials: <%= upperCase(name) %>UserPassCredentials): Promise<AXPSignInResult> {
23
+ try {
24
+ if (credentials.username == 'root' && credentials.password=='123') {
25
+ const user: AXPUser = {
26
+ id: 'a683a19a-e3eb-46a7-b81c-7cf9468ae831',
27
+ name: 'Root',
28
+ title: 'Root User',
29
+ avatar: 'https://avatar.iran.liara.run/public/29'
30
+ };
31
+ const accessToken = 'access_token';
32
+ const refreshToken = 'refresh_token';
33
+ return {
34
+ succeed: true,
35
+ data: { user, accessToken, refreshToken },
36
+ };
37
+ }
38
+ if (credentials.username == 'admin' && credentials.password=='123') {
39
+ const user: AXPUser = {
40
+ id: 'a683a19a-e3eb-46a7-b81c-7cf9468ae831',
41
+ name: 'Admin',
42
+ title: 'Admin User',
43
+ avatar: 'https://avatar.iran.liara.run/public/47'
44
+ };
45
+ const accessToken = 'access_token';
46
+ const refreshToken = 'refresh_token';
47
+ return {
48
+ succeed: true,
49
+ data: { user, accessToken, refreshToken },
50
+ };
51
+ }
52
+ if (credentials.username == 'user' && credentials.password=='123') {
53
+ const user: AXPUser = {
54
+ id: 'a683a19a-e3eb-76a7-b81c-7cf9468ae831',
55
+ name: 'User',
56
+ title: 'Sample User',
57
+ avatar: 'https://avatar.iran.liara.run/public/56'
58
+ };
59
+ const accessToken = 'access_token';
60
+ const refreshToken = 'refresh_token';
61
+ return {
62
+ succeed: true,
63
+ data: { user, accessToken, refreshToken },
64
+ };
65
+ }
66
+ return {
67
+ succeed: false,
68
+ };
69
+ } catch (error: any) {
70
+ if (error?.message) throw new Error(error.message);
71
+ // Depending on the error type, you might want to throw a specific error
72
+ throw new Error('Network or server error occurred');
73
+ }
74
+ }
75
+
76
+ async signout(): Promise<void> {
77
+ console.log('User signed out');
78
+ }
79
+
80
+ async refreshToken(context: AXPSessionContext): Promise<AXPRefreshTokenResult> {
81
+ return {
82
+ succeed: true,
83
+ data: {
84
+ accessToken: 'access_token',
85
+ refreshToken: 'refresh_token',
86
+ application: context.application,
87
+ tenant: context.tenant,
88
+ }
89
+ }
90
+ }
91
+ }