@acorex/platform-generator 1.0.1

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 (83) hide show
  1. package/README.md +11 -0
  2. package/generators.json +9 -0
  3. package/package.json +12 -0
  4. package/src/generators/app-module/files/.eslintrc.json.template +40 -0
  5. package/src/generators/app-module/files/jest.config.ts.template +22 -0
  6. package/src/generators/app-module/files/project.json.template +308 -0
  7. package/src/generators/app-module/files/src/app/app.component.ts.template +10 -0
  8. package/src/generators/app-module/files/src/app/app.module.ts.template +99 -0
  9. package/src/generators/app-module/files/src/app/app.routes.ts.template +26 -0
  10. package/src/generators/app-module/files/src/app/header-interceptor.interceptor.ts.template +33 -0
  11. package/src/generators/app-module/files/src/app/modules/auth/application.loader.ts.template +34 -0
  12. package/src/generators/app-module/files/src/app/modules/auth/auth-root.module.ts.template +52 -0
  13. package/src/generators/app-module/files/src/app/modules/auth/auth.strategy.ts.template +83 -0
  14. package/src/generators/app-module/files/src/app/modules/auth/feature.loader.ts.template +17 -0
  15. package/src/generators/app-module/files/src/app/modules/auth/permission.loader.ts.template +21 -0
  16. package/src/generators/app-module/files/src/app/modules/auth/tenant.loader.ts.template +32 -0
  17. package/src/generators/app-module/files/src/app/modules/common/translation-root.module.ts.template +45 -0
  18. package/src/generators/app-module/files/src/app/modules/layout/entity.loader.ts.template +21 -0
  19. package/src/generators/app-module/files/src/app/modules/layout/layout-root.module.ts.template +75 -0
  20. package/src/generators/app-module/files/src/app/modules/layout/menu.loader.ts.template +159 -0
  21. package/src/generators/app-module/files/src/app/modules/root/home/home.page.html.template +3 -0
  22. package/src/generators/app-module/files/src/app/modules/root/home/home.page.ts.template +10 -0
  23. package/src/generators/app-module/files/src/app/modules/root/root.module.ts.template +30 -0
  24. package/src/generators/app-module/files/src/app/modules/root/sample/sample.entity.ts.template +185 -0
  25. package/src/generators/app-module/files/src/assets/auth-background.svg +6 -0
  26. package/src/generators/app-module/files/src/assets/documents.svg +9 -0
  27. package/src/generators/app-module/files/src/assets/fonts/font-awesome/css/brands.min.css +1457 -0
  28. package/src/generators/app-module/files/src/assets/fonts/font-awesome/css/fontawesome.min.css +11291 -0
  29. package/src/generators/app-module/files/src/assets/fonts/font-awesome/css/light.min.css +22 -0
  30. package/src/generators/app-module/files/src/assets/fonts/font-awesome/css/regular.min.css +22 -0
  31. package/src/generators/app-module/files/src/assets/fonts/font-awesome/css/solid.min.css +6 -0
  32. package/src/generators/app-module/files/src/assets/fonts/font-awesome/webfonts/fa-brands-400.ttf +0 -0
  33. package/src/generators/app-module/files/src/assets/fonts/font-awesome/webfonts/fa-brands-400.woff2 +0 -0
  34. package/src/generators/app-module/files/src/assets/fonts/font-awesome/webfonts/fa-light-300.ttf +0 -0
  35. package/src/generators/app-module/files/src/assets/fonts/font-awesome/webfonts/fa-light-300.woff2 +0 -0
  36. package/src/generators/app-module/files/src/assets/fonts/font-awesome/webfonts/fa-regular-400.ttf +0 -0
  37. package/src/generators/app-module/files/src/assets/fonts/font-awesome/webfonts/fa-regular-400.woff2 +0 -0
  38. package/src/generators/app-module/files/src/assets/fonts/font-awesome/webfonts/fa-solid-900.ttf +0 -0
  39. package/src/generators/app-module/files/src/assets/fonts/font-awesome/webfonts/fa-solid-900.woff2 +0 -0
  40. package/src/generators/app-module/files/src/assets/i18n/en/auth.json +49 -0
  41. package/src/generators/app-module/files/src/assets/i18n/en/common.json +179 -0
  42. package/src/generators/app-module/files/src/assets/images/error/error-401.svg +1 -0
  43. package/src/generators/app-module/files/src/assets/images/error/error-404.svg +336 -0
  44. package/src/generators/app-module/files/src/assets/images/error/error-offline.png +0 -0
  45. package/src/generators/app-module/files/src/assets/images/error/error-offline.svg +133 -0
  46. package/src/generators/app-module/files/src/assets/images/register/smart-phone.png +0 -0
  47. package/src/generators/app-module/files/src/assets/logos/logo-colored.svg +19 -0
  48. package/src/generators/app-module/files/src/assets/logos/logo-white.svg +18 -0
  49. package/src/generators/app-module/files/src/assets/logos/logo.png +0 -0
  50. package/src/generators/app-module/files/src/assets/themes/default/default.scss.template +141 -0
  51. package/src/generators/app-module/files/src/environments/environment.d.ts +19 -0
  52. package/src/generators/app-module/files/src/environments/environment.dev.d.ts +19 -0
  53. package/src/generators/app-module/files/src/environments/environment.dev.js +24 -0
  54. package/src/generators/app-module/files/src/environments/environment.dev.js.map +1 -0
  55. package/src/generators/app-module/files/src/environments/environment.js +24 -0
  56. package/src/generators/app-module/files/src/environments/environment.js.map +1 -0
  57. package/src/generators/app-module/files/src/environments/environment.local.d.ts +19 -0
  58. package/src/generators/app-module/files/src/environments/environment.local.js +24 -0
  59. package/src/generators/app-module/files/src/environments/environment.local.js.map +1 -0
  60. package/src/generators/app-module/files/src/environments/environment.prod.d.ts +19 -0
  61. package/src/generators/app-module/files/src/environments/environment.prod.js +24 -0
  62. package/src/generators/app-module/files/src/environments/environment.prod.js.map +1 -0
  63. package/src/generators/app-module/files/src/environments/environment.test.local.d.ts +19 -0
  64. package/src/generators/app-module/files/src/environments/environment.test.local.js +24 -0
  65. package/src/generators/app-module/files/src/environments/environment.test.local.js.map +1 -0
  66. package/src/generators/app-module/files/src/favicon.ico +0 -0
  67. package/src/generators/app-module/files/src/index.html.template +35 -0
  68. package/src/generators/app-module/files/src/main.ts.template +6 -0
  69. package/src/generators/app-module/files/src/styles.scss.template +188 -0
  70. package/src/generators/app-module/files/src/test-setup.ts.template +7 -0
  71. package/src/generators/app-module/files/tailwind.config.js.template +15 -0
  72. package/src/generators/app-module/files/tsconfig.app.json.template +10 -0
  73. package/src/generators/app-module/files/tsconfig.editor.json.template +7 -0
  74. package/src/generators/app-module/files/tsconfig.json.template +34 -0
  75. package/src/generators/app-module/files/tsconfig.spec.json.template +11 -0
  76. package/src/generators/app-module/generator.d.ts +5 -0
  77. package/src/generators/app-module/generator.js +31 -0
  78. package/src/generators/app-module/generator.js.map +1 -0
  79. package/src/generators/app-module/schema.d.ts +4 -0
  80. package/src/generators/app-module/schema.json +27 -0
  81. package/src/index.d.ts +0 -0
  82. package/src/index.js +1 -0
  83. package/src/index.js.map +1 -0
@@ -0,0 +1,83 @@
1
+ import { AXPAuthStrategy, AXPBaseCredentials, AXPRefreshTokenResult, 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
+ refreshToken(refreshToken: string): Promise<AXPRefreshTokenResult> {
81
+ throw new Error('Method not implemented.');
82
+ }
83
+ }
@@ -0,0 +1,17 @@
1
+ import { AXPFeature, AXPFeatureLoader } from '@acorex/platform/auth';
2
+ import { Observable, delay, of } from 'rxjs';
3
+
4
+ export class <%= upperCase(name) %>FeatureLoader implements AXPFeatureLoader {
5
+
6
+ private list: AXPFeature[] = [
7
+ // {
8
+ // name: 'feature name',
9
+ // title: 'Feature Title',
10
+ // value: false
11
+ // },
12
+ ]
13
+
14
+ getList(): Observable < AXPFeature[] > {
15
+ return of(this.list).pipe(delay(0));
16
+ }
17
+ }
@@ -0,0 +1,21 @@
1
+ import { AXPPermission, AXPPermissionLoader, AXPSessionContext } from '@acorex/platform/auth';
2
+ import { AXP_ROOT_CONFIG_TOKEN } from '@acorex/platform/core';
3
+ import { Injectable, inject } from '@angular/core';
4
+ import { Observable, map, of } from 'rxjs';
5
+
6
+ @Injectable()
7
+ export class <%= upperCase(name) %>PermissionLoader implements AXPPermissionLoader {
8
+
9
+ getList(context: AXPSessionContext): Observable<AXPPermission[]> {
10
+ if (context.user?.name == 'Root') {
11
+ return of(['admin', 'platform.admin.settings', 'platform.admin.reports']);
12
+ }
13
+ else if (context.user?.name == 'Admin') {
14
+ return of(['admin', '<%= name %>.admin.settings']);
15
+ }
16
+ else {
17
+ return of(['<%= name %>_app.forms']);
18
+ }
19
+ }
20
+
21
+ }
@@ -0,0 +1,32 @@
1
+ import { AXPTenant, AXPTenantLoader, AXPSessionContext } from '@acorex/platform/auth';
2
+ import { AXP_ROOT_CONFIG_TOKEN } from '@acorex/platform/core';
3
+ import { Injectable, inject } from '@angular/core';
4
+ import { Observable, delay, of } from 'rxjs';
5
+
6
+ @Injectable()
7
+ export class <%= upperCase(name) %>TenantLoader implements AXPTenantLoader {
8
+
9
+ getList(context: AXPSessionContext): Observable<AXPTenant[]> {
10
+
11
+ const acorex_tenant = {
12
+ id: '99',
13
+ name: 'acorex-tenant',
14
+ title: 'ACoreX Platform Tenant',
15
+ };
16
+
17
+ const <%= name %>_tenant = {
18
+ id: '1',
19
+ name: '<%= name %>-tenant',
20
+ title: '<%= upperCase(name) %> Tenant',
21
+ };
22
+
23
+ if (context.user?.name == 'Root') {
24
+ return of([<%= name %>_tenant, acorex_tenant]).pipe(delay(500));
25
+ }
26
+ else {
27
+ return of([<%= name %>_tenant]).pipe(delay(500));
28
+ }
29
+
30
+ }
31
+
32
+ }
@@ -0,0 +1,45 @@
1
+ import {
2
+ AX_TRANSLATION_CONFIG,
3
+ AX_TRANSLATION_LOADER,
4
+ AXTranslation,
5
+ AXTranslationLoader,
6
+ AXTranslationLoaderOptions,
7
+ AXTranslationModule,
8
+ translationConfig,
9
+ } from '@acorex/core/translation';
10
+ import { HttpClient } from '@angular/common/http';
11
+
12
+ import { Injectable, NgModule } from '@angular/core';
13
+ import { Observable } from 'rxjs';
14
+
15
+ @Injectable()
16
+ export class MyTranslationLoader implements AXTranslationLoader {
17
+ constructor(private http: HttpClient) { }
18
+
19
+ getTranslation(options: AXTranslationLoaderOptions): Observable<AXTranslation> {
20
+ return this.http
21
+ .get<AXTranslation>(`/assets/i18n/${options.lang}/${options.scope}.json`)
22
+ .pipe();
23
+ }
24
+ }
25
+
26
+ @NgModule({
27
+ exports: [AXTranslationModule],
28
+ imports: [],
29
+ providers: [
30
+ {
31
+ provide: AX_TRANSLATION_LOADER,
32
+ useClass: MyTranslationLoader,
33
+ },
34
+ {
35
+ provide: AX_TRANSLATION_CONFIG,
36
+ useValue: translationConfig({
37
+ preloadLangs: ['en'],
38
+ preloadScopes: ['common', 'auth'],
39
+ defaultLang: 'en',
40
+ availableLangs: ['en'],
41
+ }),
42
+ },
43
+ ],
44
+ })
45
+ export class AXPTranslationRootModule { }
@@ -0,0 +1,21 @@
1
+ import { AXPEntityConfig, AXPEntityLoader } from '@acorex/platform/layouts';
2
+ import { Injectable, Injector, inject } from '@angular/core';
3
+
4
+ @Injectable()
5
+ export class AXPRootEntityLoader implements AXPEntityLoader {
6
+ private injector = inject(Injector);
7
+
8
+ async get(moduleName: string, entityName: string): Promise<AXPEntityConfig | null> {
9
+ return new Promise(async (resolve) => {
10
+ switch (entityName) {
11
+ case 'sample': {
12
+ const entity = (await import('../<%= name %>/sample/sample.entity')).entityFactory;
13
+ resolve(entity(this.injector));
14
+ break;
15
+ }
16
+ default:
17
+ resolve(null);
18
+ }
19
+ });
20
+ }
21
+ }
@@ -0,0 +1,75 @@
1
+ import {
2
+ AXPAdminLayoutModule,
3
+ AXPFooterTextSlotComponent,
4
+ AXPLayoutModule,
5
+ AXPNavBarSlotComponent,
6
+ AXPThemeSlotComponent,
7
+ AXP_ENTITY_LOADER,
8
+ } from '@acorex/platform/layouts';
9
+ import { NgModule, inject } from '@angular/core';
10
+ import { AXPRootMenuLoader } from './menu.loader';
11
+ import { AXPRootEntityLoader } from './entity.loader';
12
+ import { AXPCommonModule, AXPMenuItem, AXPNavigateAction, AXP_MENU_LOADER, AXP_PLATFORM_CONFIG_TOKEN } from '@acorex/platform/common';
13
+ import pkg from '../../../../../../package.json';
14
+ import { AXPComponentSlotModule } from '@acorex/platform/layout';
15
+
16
+
17
+ @NgModule({
18
+ imports: [
19
+ AXPAdminLayoutModule,
20
+ AXPCommonModule,
21
+ AXPLayoutModule,
22
+ AXPComponentSlotModule.forRoot({
23
+ "footer-start": [
24
+ {
25
+ name: "version",
26
+ component: AXPFooterTextSlotComponent,
27
+ options: () => {
28
+ return { text: `v${pkg.version}` };
29
+ }
30
+ },
31
+ {
32
+ name: "copyright",
33
+ component: AXPFooterTextSlotComponent,
34
+ options: () => {
35
+ const a = inject(AXP_PLATFORM_CONFIG_TOKEN);
36
+ return { text: a.copyright };
37
+ }
38
+ },
39
+ ],
40
+ "auth-footer-links": [
41
+ {
42
+ name: "links",
43
+ component: AXPNavBarSlotComponent,
44
+ options: () => {
45
+ const items: AXPMenuItem[] = [
46
+ // {
47
+ // text: 'About',
48
+ // command: AXPNavigateAction({ payload: { commands: ['asc/help/about'] } })
49
+ // }
50
+ ];
51
+ return { items };
52
+ }
53
+ }
54
+ ],
55
+ "header-end": [
56
+ {
57
+ name: 'theme',
58
+ component: AXPThemeSlotComponent,
59
+ },
60
+ ],
61
+ })
62
+ ],
63
+ exports: [],
64
+ providers: [
65
+ {
66
+ provide: AXP_MENU_LOADER,
67
+ useClass: AXPRootMenuLoader
68
+ },
69
+ {
70
+ provide: AXP_ENTITY_LOADER,
71
+ useClass: AXPRootEntityLoader
72
+ },
73
+ ],
74
+ })
75
+ export class AXPLayoutRootModule { }
@@ -0,0 +1,159 @@
1
+ import { AXPMenuItem, AXPMenuLoader } from '@acorex/platform/common';
2
+ import { Injectable } from '@angular/core';
3
+ import { Router } from '@angular/router';
4
+ import { cloneDeep, omit } from 'lodash-es';
5
+ import { Observable, of } from 'rxjs';
6
+
7
+ @Injectable()
8
+ export class AXPRootMenuLoader implements AXPMenuLoader {
9
+ private initialMenu: AXPMenuItem[] = [
10
+ {
11
+ text: 'Home',
12
+ path: '/<%= name %>/home',
13
+ icon: 'fa-solid fa-grid-2',
14
+ data: {
15
+ //requiredPermission: '',
16
+ },
17
+ },
18
+ {
19
+ text: 'Administration',
20
+ type: 'group',
21
+ data: {
22
+ requiredPermission: 'admin',
23
+ },
24
+ },
25
+ {
26
+ text: 'General Settings',
27
+ icon: 'fa-solid fa-gear',
28
+ data: {
29
+ requiredPermission: '<%= name %>.admin.settings',
30
+ },
31
+ children: [
32
+ {
33
+ text: 'Sample Dynamic Entity',
34
+ path: '/<%= name %>/sample/e/sample/list',
35
+ },
36
+ ]
37
+ },
38
+ {
39
+ text: 'Security Management',
40
+ path: '/security',
41
+ icon: 'fa-solid fa-lock',
42
+ data: {
43
+ requiredPermission: '<%= name %>.admin.settings',
44
+ },
45
+ opened: false,
46
+ children: [
47
+ {
48
+ text: 'User Management',
49
+ icon: 'fa-solid fa-users',
50
+ },
51
+ {
52
+ text: 'Roles Management',
53
+ icon: 'fa-solid fa-key',
54
+ },
55
+ ],
56
+ },
57
+ {
58
+ text: 'Security Management',
59
+ path: '/security',
60
+ icon: 'fa-solid fa-lock',
61
+ data: {
62
+ requiredPermission: 'platform.admin.settings',
63
+ },
64
+ opened: false,
65
+ children: [
66
+ {
67
+ text: 'User Management',
68
+ icon: 'fa-solid fa-users',
69
+ },
70
+ {
71
+ text: 'Roles Management',
72
+ icon: 'fa-solid fa-key',
73
+ },
74
+ ],
75
+ },
76
+ {
77
+ text: 'Tenant Management',
78
+ path: '/tenant-managemenet',
79
+ icon: 'fa-solid fa-sitemap',
80
+ data: {
81
+ requiredPermission: 'platform.admin.settings',
82
+ },
83
+ },
84
+ {
85
+ text: 'Reports',
86
+ type: 'group',
87
+ data: {
88
+ requiredPermission: 'platform.admin.reports',
89
+ },
90
+ },
91
+ {
92
+ text: 'log Management',
93
+ path: '/log-managemenet',
94
+ icon: 'fa-solid fa-file-lines',
95
+ data: {
96
+ requiredPermission: 'platform.admin.reports',
97
+ },
98
+ },
99
+ ];
100
+
101
+ constructor(private router: Router) { }
102
+
103
+ getItems(depth: number | null = null): Observable<AXPMenuItem[]> {
104
+ const menuClone = cloneDeep(this.initialMenu);
105
+ const result = this.internalGetMenuItemsByDepth(menuClone, depth);
106
+ return of(result);
107
+ }
108
+
109
+ private internalGetMenuItemsByDepth(menuItems: AXPMenuItem[], depth: number | null, parent: AXPMenuItem | undefined = undefined): AXPMenuItem[] {
110
+ return menuItems.map((item) => {
111
+ // Create a new item with parent set
112
+ const newItem: AXPMenuItem = { ...item, parent: parent };
113
+
114
+ if (depth !== null) {
115
+ if (depth === 0) {
116
+ // If depth is 0, return the item without children
117
+ return omit(newItem, 'children');
118
+ } else if (item.children) {
119
+ // If the item has children, recursively set their parent and limit depth
120
+ newItem.children = this.internalGetMenuItemsByDepth(item.children, depth - 1, newItem);
121
+ }
122
+ } else if (item.children) {
123
+ // If depth is null, process all children without depth limit
124
+ newItem.children = this.internalGetMenuItemsByDepth(item.children, null, newItem);
125
+ }
126
+
127
+ return newItem;
128
+ });
129
+ }
130
+
131
+ currentMenuItem(): AXPMenuItem | null {
132
+ return this.internalCurrentMenuItem(this.internalGetMenuItemsByDepth(this.initialMenu, null), this.getCurrentRoutePath());
133
+ }
134
+
135
+ private internalCurrentMenuItem(menuItems: AXPMenuItem[], currentPath: string): AXPMenuItem | null {
136
+ for (const item of menuItems) {
137
+ // Check if the current item's path matches the current path
138
+ if (item.path === currentPath) {
139
+ return item;
140
+ }
141
+
142
+ // If the current item has children, search recursively in the children
143
+ if (item.children && item.children.length > 0) {
144
+ const found = this.internalCurrentMenuItem(item.children, currentPath);
145
+ if (found) {
146
+ return found;
147
+ }
148
+ }
149
+ }
150
+
151
+ // Return null if no matching item is found
152
+ return null;
153
+ }
154
+
155
+ private getCurrentRoutePath(): string {
156
+ // Using window.location to get the current browser URL
157
+ return window.location.pathname;
158
+ }
159
+ }
@@ -0,0 +1,3 @@
1
+ <div class="ax-flex ax-p-7">
2
+ <div class="ax-font-bold ax-text-3xl">Welcome to ACoreX Platform</div>
3
+ </div>
@@ -0,0 +1,10 @@
1
+ import { Component } from '@angular/core';
2
+
3
+ @Component({
4
+ templateUrl: 'home.page.html',
5
+ standalone: true
6
+ })
7
+
8
+ export class <%= upperCase(name) %>HomePage {
9
+
10
+ }
@@ -0,0 +1,30 @@
1
+ import { AXPAuthGuard, AXPPermissionGuard } from '@acorex/platform/auth';
2
+ import { CommonModule } from '@angular/common';
3
+ import { NgModule } from '@angular/core';
4
+ import { RouterModule, Routes } from '@angular/router';
5
+
6
+ const routes: Routes = [
7
+ {
8
+ path: '',
9
+ redirectTo: 'home',
10
+ pathMatch: 'full',
11
+ },
12
+ {
13
+ path: '',
14
+ children: [
15
+ {
16
+ //canActivate: [AXPAuthGuard],
17
+ path: 'home',
18
+ loadComponent: () => import('./home/home.page').then((c) => c.<%= upperCase(name) %>HomePage),
19
+ }
20
+ ]
21
+ },
22
+ ];
23
+
24
+ @NgModule({
25
+ imports: [CommonModule, RouterModule.forChild(routes)],
26
+ exports: [RouterModule],
27
+ providers: [],
28
+ declarations: [],
29
+ })
30
+ export class <%= upperCase(name) %>RootModule { }
@@ -0,0 +1,185 @@
1
+ import { AXDataSourceQuery } from '@acorex/components/common';
2
+ import { applyFilterArray, applySortArray } from '@acorex/modules/backend';
3
+ import {
4
+ AXPEntityConfig,
5
+ AXPEntityListDisplayColumnConfig,
6
+ AXPEntityProperty,
7
+ convertPropertiesToColumns,
8
+ widgetSchemas,
9
+ } from '@acorex/platform/layouts';
10
+ import { Injector } from '@angular/core';
11
+ import { assign } from 'lodash-es';
12
+
13
+ const properties: AXPEntityProperty[] = [
14
+ {
15
+ name: 'firstname',
16
+ title: 'First Name',
17
+ schema: widgetSchemas.text,
18
+ canEdit: true,
19
+ canInsert: true,
20
+ canInlineFilter: true,
21
+ validationRules: [
22
+ {
23
+ rule: 'required',
24
+ },
25
+ ],
26
+ layout: {
27
+ positions: {
28
+ default: {
29
+ start: 0,
30
+ span: 6,
31
+ },
32
+ },
33
+ },
34
+ },
35
+ {
36
+ name: 'lastname',
37
+ title: 'Last Name',
38
+ schema: widgetSchemas.text,
39
+ canEdit: true,
40
+ canInsert: true,
41
+ canInlineFilter: true,
42
+ validationRules: [
43
+ {
44
+ rule: 'required',
45
+ },
46
+ ],
47
+ layout: {
48
+ positions: {
49
+ default: {
50
+ start: 6,
51
+ span: 6,
52
+ },
53
+ },
54
+ },
55
+ },
56
+ {
57
+ name: 'birthDate',
58
+ title: 'Birth Date',
59
+ schema: widgetSchemas.date,
60
+ canEdit: true,
61
+ canInsert: true,
62
+ validationRules: [
63
+ {
64
+ rule: 'required',
65
+ },
66
+ ],
67
+ },
68
+ {
69
+ name: 'notify',
70
+ title: 'Notification',
71
+ schema: widgetSchemas.toggle,
72
+ canEdit: true,
73
+ canInsert: false,
74
+ component: {
75
+ common: {
76
+ options: {
77
+ trulyText: 'Enabled',
78
+ falsyText: 'Disabled',
79
+ },
80
+ },
81
+ },
82
+ },
83
+ ];
84
+
85
+ const result = Array.from({ length: 30 }).map((_, i) => ({
86
+ id: i,
87
+ firstname: ['John', 'Allen', 'Jak', 'Rose', 'Kate'][Math.floor(Math.random() * 5)],
88
+ lastname: ['Gates', 'Jonsen', 'Smith', 'Ford', 'Jakson'][Math.floor(Math.random() * 5)],
89
+ birthDate: new Date(),
90
+ phone: `123456789${i}`,
91
+ email: `example@gmail.com`,
92
+ notify: Math.floor(Math.random() * 5) % 3 == 0,
93
+ }));
94
+
95
+ const entityName = 'sample';
96
+
97
+ const columns: AXPEntityListDisplayColumnConfig[] = convertPropertiesToColumns(...properties);
98
+
99
+ export async function entityFactory(injector: Injector): Promise<AXPEntityConfig> {
100
+
101
+ const entity: AXPEntityConfig = {
102
+ module: '<% name %>',
103
+ name: entityName,
104
+ title: 'Sample Entity',
105
+ properties: properties,
106
+ formats: {
107
+ default: '{{firstname}} {{lastname}}',
108
+ },
109
+ dataSource: {
110
+ key: 'id',
111
+ pageSize: 20,
112
+ load: async (e: AXDataSourceQuery) => {
113
+ const sortedItems = applySortArray(result, e.sort);
114
+ const filteredItems = applyFilterArray(sortedItems, e.filter?.filters);
115
+ return new Promise((resolve) => {
116
+ setTimeout(() => {
117
+ resolve({
118
+ items: filteredItems.slice(e.skip, (e.skip ?? 0) + (e.take ?? 0)),
119
+ total: filteredItems.length,
120
+ });
121
+ }, 100);
122
+ });
123
+ },
124
+ byKey: (id: any) => {
125
+ return new Promise((resolve) => {
126
+ setTimeout(() => {
127
+ resolve(result.find((c) => c.id.toString() == id));
128
+ }, 100);
129
+ });
130
+ },
131
+ },
132
+ views: {
133
+ list: {
134
+ title: 'Sample Entity List',
135
+ views: [
136
+ {
137
+ name: 'all',
138
+ title: 'All Items',
139
+ fixed: true,
140
+ columns: columns,
141
+ conditions: [],
142
+ sorts: [
143
+ {
144
+ name: 'firstname',
145
+ dir: 'asc',
146
+ },
147
+ {
148
+ name: 'lastname',
149
+ dir: 'asc',
150
+ },
151
+ ],
152
+ },
153
+ ],
154
+ },
155
+ quickView: {
156
+ root: {
157
+ properties: properties.map((c) => c.name),
158
+ },
159
+ },
160
+ detailView: {
161
+ root: {
162
+ properties: properties.map((c) => c.name),
163
+ },
164
+ },
165
+ createView: {
166
+ root: {
167
+ properties: properties.slice(0, properties.length - 1).map((c) => c.name),
168
+ },
169
+ },
170
+ },
171
+ commands: {
172
+ create: async (values) => {
173
+ return Promise.resolve({ id: Math.floor(Math.random() * 10000) });
174
+ },
175
+ update: async (id: string, values) => {
176
+ return Promise.resolve();
177
+ },
178
+ delete: (id: string) => {
179
+ return Promise.resolve();
180
+ },
181
+ }
182
+ };
183
+
184
+ return entity;
185
+ }