identity-admin 1.25.24 → 1.26.0
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.
- package/README.md +126 -126
- package/lib/Dashboard.d.ts +14 -14
- package/lib/Dashboard.js +95 -95
- package/lib/container/helpers/HelperInversify.d.ts +6 -6
- package/lib/container/helpers/HelperInversify.js +10 -10
- package/lib/container/helpers/HelperTypes.d.ts +5 -5
- package/lib/container/helpers/HelperTypes.js +7 -7
- package/lib/container/index.d.ts +1 -1
- package/lib/container/index.js +14 -14
- package/lib/container/repositories/RepositoryInversify.d.ts +4 -4
- package/lib/container/repositories/RepositoryInversify.js +13 -13
- package/lib/container/repositories/RepositoryTypes.d.ts +4 -4
- package/lib/container/repositories/RepositoryTypes.js +6 -6
- package/lib/container/types.d.ts +8 -8
- package/lib/container/types.js +9 -9
- package/lib/controllers/ActionController.d.ts +8 -8
- package/lib/controllers/ActionController.js +79 -79
- package/lib/controllers/DashboardController.d.ts +43 -43
- package/lib/controllers/DashboardController.js +695 -695
- package/lib/controllers/ResourceController.d.ts +15 -15
- package/lib/controllers/ResourceController.js +134 -134
- package/lib/helpers/ActionsGenerator.d.ts +11 -11
- package/lib/helpers/ActionsGenerator.js +179 -179
- package/lib/helpers/FiltersHelper.d.ts +9 -9
- package/lib/helpers/FiltersHelper.js +113 -105
- package/lib/helpers/LocalesHelper.d.ts +4 -4
- package/lib/helpers/LocalesHelper.js +73 -73
- package/lib/helpers/LocalizedStringHelper.d.ts +9 -9
- package/lib/helpers/LocalizedStringHelper.js +57 -57
- package/lib/helpers/Permissions/PermissionFetcher.d.ts +7 -7
- package/lib/helpers/Permissions/PermissionFetcher.js +78 -78
- package/lib/helpers/Permissions/PermissionLabel.d.ts +2 -2
- package/lib/helpers/Permissions/PermissionLabel.js +42 -42
- package/lib/helpers/Permissions/PermissionMapper.d.ts +13 -13
- package/lib/helpers/Permissions/PermissionMapper.js +35 -35
- package/lib/helpers/Permissions/PermissionResource.d.ts +5 -5
- package/lib/helpers/Permissions/PermissionResource.js +31 -31
- package/lib/helpers/Permissions/PermissionSavingService.d.ts +13 -13
- package/lib/helpers/Permissions/PermissionSavingService.js +32 -32
- package/lib/helpers/Permissions/SavePermissionGroup.d.ts +6 -6
- package/lib/helpers/Permissions/SavePermissionGroup.js +32 -32
- package/lib/helpers/Permissions/UpdatePermissionGroup.d.ts +6 -6
- package/lib/helpers/Permissions/UpdatePermissionGroup.js +50 -50
- package/lib/helpers/Permissions/types.d.ts +17 -17
- package/lib/helpers/Permissions/types.js +2 -2
- package/lib/helpers/PopulationHelper.d.ts +12 -12
- package/lib/helpers/PopulationHelper.js +50 -50
- package/lib/helpers/ReportsGenerator.d.ts +11 -11
- package/lib/helpers/ReportsGenerator.js +57 -57
- package/lib/helpers/ResourceGenerator.d.ts +9 -9
- package/lib/helpers/ResourceGenerator.js +172 -172
- package/lib/helpers/ResourceHelper.d.ts +28 -28
- package/lib/helpers/ResourceHelper.js +376 -376
- package/lib/helpers/RportsGenerator.d.ts +10 -10
- package/lib/helpers/RportsGenerator.js +21 -21
- package/lib/helpers/SchemaGenerator.d.ts +5 -5
- package/lib/helpers/SchemaGenerator.js +97 -97
- package/lib/helpers/SchemaHelper.d.ts +5 -5
- package/lib/helpers/SchemaHelper.js +21 -21
- package/lib/locales/en.json +53 -53
- package/lib/middlewares/isAuth.d.ts +13 -13
- package/lib/middlewares/isAuth.js +43 -43
- package/lib/models/ModelNames.d.ts +7 -7
- package/lib/models/ModelNames.js +10 -10
- package/lib/models/adminpermission/AdminPermission.d.ts +6 -6
- package/lib/models/adminpermission/AdminPermission.js +23 -23
- package/lib/models/adminpermission/IAdminPermission.d.ts +13 -13
- package/lib/models/adminpermission/IAdminPermission.js +2 -2
- package/lib/models/customPage/CustomPage.d.ts +2 -2
- package/lib/models/customPage/CustomPage.js +38 -38
- package/lib/models/customPage/ICustomPage.d.ts +17 -17
- package/lib/models/customPage/ICustomPage.js +2 -2
- package/lib/models/file/File.d.ts +2 -2
- package/lib/models/file/File.js +23 -23
- package/lib/models/file/IFile.d.ts +15 -15
- package/lib/models/file/IFile.js +2 -2
- package/lib/models/location/ILocation.d.ts +14 -14
- package/lib/models/location/ILocation.js +2 -2
- package/lib/models/location/Location.d.ts +2 -2
- package/lib/models/location/Location.js +21 -21
- package/lib/models/modelConfiguration/IModelConfigurations.d.ts +29 -29
- package/lib/models/modelConfiguration/IModelConfigurations.js +2 -2
- package/lib/models/modelConfiguration/ModelConfiguration.d.ts +13 -13
- package/lib/models/modelConfiguration/ModelConfiguration.js +95 -95
- package/lib/models/permission/IPermission.d.ts +14 -14
- package/lib/models/permission/IPermission.js +2 -2
- package/lib/models/permission/Permission.d.ts +2 -2
- package/lib/models/permission/Permission.js +21 -21
- package/lib/models/request-log/IRequestLog.d.ts +22 -22
- package/lib/models/request-log/IRequestLog.js +2 -2
- package/lib/models/request-log/RequestLog.d.ts +3 -3
- package/lib/models/request-log/RequestLog.js +51 -51
- package/lib/pdf/ReportTemplate.d.ts +71 -71
- package/lib/pdf/ReportTemplate.js +94 -94
- package/lib/repositories/DashboardRepository.d.ts +5 -5
- package/lib/repositories/DashboardRepository.js +12 -12
- package/lib/repositories/Repository.d.ts +68 -68
- package/lib/repositories/Repository.js +212 -212
- package/lib/repositories/RequestLogRepository.d.ts +10 -10
- package/lib/repositories/RequestLogRepository.js +54 -54
- package/lib/repositories/SaveResult.d.ts +14 -14
- package/lib/repositories/SaveResult.js +18 -18
- package/lib/router/index.d.ts +8 -8
- package/lib/router/index.js +104 -104
- package/lib/types/DashbordConfig.d.ts +21 -21
- package/lib/types/DashbordConfig.js +2 -2
- package/lib/types/IConfigurationFile.d.ts +9 -9
- package/lib/types/IConfigurationFile.js +2 -2
- package/lib/types/IResourceFile.d.ts +629 -624
- package/lib/types/IResourceFile.js +2 -2
- package/lib/types/IResourceResponse.d.ts +95 -95
- package/lib/types/IResourceResponse.js +2 -2
- package/lib/types/helpers.d.ts +61 -61
- package/lib/types/helpers.js +71 -71
- package/lib/utils/ResourceUtils.d.ts +2 -2
- package/lib/utils/ResourceUtils.js +7 -7
- package/lib/utils/ResponseUtils.d.ts +11 -11
- package/lib/utils/ResponseUtils.js +41 -41
- package/lib/utils/StringUtils.d.ts +9 -9
- package/lib/utils/StringUtils.js +46 -46
- package/lib/view/asset-manifest.json +18 -18
- package/lib/view/assets/icons/delete_icon.svg +3 -3
- package/lib/view/assets/icons/flags/ic_flag_cn.svg +9 -9
- package/lib/view/assets/icons/flags/ic_flag_sa.svg +9 -9
- package/lib/view/assets/icons/flags/ic_flag_vn.svg +9 -9
- package/lib/view/assets/icons/info_icon.svg +3 -3
- package/lib/view/assets/icons/navbar/ic_banking.svg +5 -5
- package/lib/view/assets/icons/navbar/ic_invoice.svg +4 -4
- package/lib/view/assets/icons/navbar/ic_kanban.svg +7 -7
- package/lib/view/assets/icons/navbar/ic_menu_item.svg +8 -8
- package/lib/view/assets/icons/small_info_icon.svg +3 -3
- package/lib/view/assets/illustrations/Group 16.svg +4 -4
- package/lib/view/assets/illustrations/logo.svg +5 -5
- package/lib/view/favicon/browserconfig.xml +9 -9
- package/lib/view/favicon/safari-pinned-tab.svg +182 -182
- package/lib/view/favicon/site.webmanifest +19 -19
- package/lib/view/fonts/index.css +18 -18
- package/lib/view/index.html +52 -52
- package/lib/view/manifest.json +20 -20
- package/lib/view/robots.txt +3 -3
- package/lib/view/static/css/main.54de06ef.css +1 -1
- package/lib/view/static/js/574.778b5963.chunk.js +1 -1
- package/lib/view/static/js/678.521704a3.chunk.js +1 -1
- package/lib/view/static/js/798.54856416.chunk.js +1 -1
- package/lib/view/static/js/main.4687f255.js +2 -2
- package/lib/view/static/js/main.4687f255.js.LICENSE.txt +214 -214
- package/package.json +58 -58
package/README.md
CHANGED
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
# Identity Admin Dashboard
|
|
2
|
-
[](https://travis-ci.org/joemccann/dillinger)
|
|
3
|
-
|
|
4
|
-
## How to install
|
|
5
|
-
```bash
|
|
6
|
-
npm i identity-admin
|
|
7
|
-
```
|
|
8
|
-
## Features
|
|
9
|
-
- Creating Dashboard with minimal Ui for mongoose models.
|
|
10
|
-
- Provide DashboardController for custom routing and middlewares.
|
|
11
|
-
- Provide multiple dashboard instances with diffrent routes.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## Create new ```unAuthenticated``` Dashboard:
|
|
16
|
-
- Create new instance from Dashboard.
|
|
17
|
-
- Provide Resources array of
|
|
18
|
-
resources file.
|
|
19
|
-
- Build the instance after mongoose setup by passing app instance to the build function.
|
|
20
|
-
```Typescript
|
|
21
|
-
const dashboard: Dashboard = new Dashboard({ resources:[ <Resource: IResourceFile> ]);
|
|
22
|
-
```
|
|
23
|
-
```Typescript
|
|
24
|
-
dashboard.build(app);
|
|
25
|
-
```
|
|
26
|
-
## To create new ```Authenticated``` Dashboard:
|
|
27
|
-
- Create new instance from Dashboard.
|
|
28
|
-
- Provide Resources array of
|
|
29
|
-
resources file.
|
|
30
|
-
- Provide authenticate function which take AdminCredentials as parameter and return a promise of boolean or user data.
|
|
31
|
-
- Provide cookiesConfiguration (cookie name and cookie secret).
|
|
32
|
-
- Build the instance after mongoose setup by passing app instance to the build function.
|
|
33
|
-
|
|
34
|
-
```Typescript
|
|
35
|
-
const dashboard = new Dashboard({
|
|
36
|
-
resources: [ UserResource ],
|
|
37
|
-
cookiesConfiguration: {
|
|
38
|
-
cookiesSecret: "cokieieSecret",
|
|
39
|
-
cookieName: "connect.sid"
|
|
40
|
-
},
|
|
41
|
-
authenticate: async (credentials: AdminCredentials) => {
|
|
42
|
-
const user = await Admin.findOne({ email: credentials.email });
|
|
43
|
-
if (user) {
|
|
44
|
-
const matched = await bcrypt.compare(credentials.password, user.encryptedPassword);
|
|
45
|
-
if (matched) {
|
|
46
|
-
return user;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
```
|
|
53
|
-
```Typescript
|
|
54
|
-
dashboard.build(app);
|
|
55
|
-
```
|
|
56
|
-
## To create new ```CustomRoutes``` Dashboard:
|
|
57
|
-
``` This method require to implement your own view and new react app ```
|
|
58
|
-
- Create new controller class with invirsify-express-utils notaitions and extend ActionController.
|
|
59
|
-
- Create new controller class with invirsify-express-utils notaitions and extend ResourceController.
|
|
60
|
-
- Create new controller class with invirsify-express-utils notaitions and extend DashboardController.
|
|
61
|
-
- Provide resource file and repository in super constructor.
|
|
62
|
-
- ``` Following class will create new route /v1/contries ***Now you can pass any auth middlewares you want```
|
|
63
|
-
|
|
64
|
-
```TypeScript
|
|
65
|
-
@controller('/v1/actions', defaultHeaders)
|
|
66
|
-
export default class ActionsController extends ActionController{
|
|
67
|
-
|
|
68
|
-
constructor(
|
|
69
|
-
@inject(TYPES.IResources) private resources: IResourceFile[]) {
|
|
70
|
-
super(resources);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
```TypeScript
|
|
76
|
-
@controller('/v1/resources', defaultHeaders)
|
|
77
|
-
export default class ResourcesController extends ResourceController{
|
|
78
|
-
|
|
79
|
-
constructor(
|
|
80
|
-
@inject(TYPES.IResources) private resources: IResourceFile[]) {
|
|
81
|
-
super(resources);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
```TypeScript
|
|
87
|
-
@controller('/v1/contries', defaultHeaders)
|
|
88
|
-
export default class CountryController extends DashboardController{
|
|
89
|
-
|
|
90
|
-
constructor(
|
|
91
|
-
@inject(TYPES.ICountryRepository) private countryRepository: CountryRepository,
|
|
92
|
-
@inject(TYPES.ICountryResource) private countryResource: IResourceFile ) {
|
|
93
|
-
|
|
94
|
-
super(CountryResource, countryRepository);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Documentaion:
|
|
100
|
-
```Typescript
|
|
101
|
-
Dashboard(dashBoardConfig: DashboardConfig);
|
|
102
|
-
build(app: Application): void;
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
#### Dashboard:
|
|
106
|
-
Dashboard constructor to create new instance from idntity-admin.
|
|
107
|
-
- dashBoardConfig:
|
|
108
|
-
```js
|
|
109
|
-
{
|
|
110
|
-
resources: IResourceFile[]; // Array of resources files.
|
|
111
|
-
rootPath?: string; // optional root path default to /dashboard
|
|
112
|
-
localesOptions?: i18n.ConfigurationOptions; // locales options for custom dashboard
|
|
113
|
-
cookiesConfiguration: CookieConfiguration; // cookies configuration in case of authenticated dashboard
|
|
114
|
-
authenticate?: AuthenticateMiddleWare; // authenticate function used to login the admin.
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
- IResourceFile
|
|
118
|
-
``` For resource file example check```
|
|
119
|
-
[IResourceFile](src/types/IResourceFile.ts)
|
|
120
|
-
|
|
121
|
-
- CookieConfiguration
|
|
122
|
-
```js
|
|
123
|
-
{
|
|
124
|
-
cookiesSecret: string; // cookie secret to handle sessions
|
|
125
|
-
cookieName: string; // cookie name as appeared in browser
|
|
126
|
-
}
|
|
1
|
+
# Identity Admin Dashboard
|
|
2
|
+
[](https://travis-ci.org/joemccann/dillinger)
|
|
3
|
+
|
|
4
|
+
## How to install
|
|
5
|
+
```bash
|
|
6
|
+
npm i identity-admin
|
|
7
|
+
```
|
|
8
|
+
## Features
|
|
9
|
+
- Creating Dashboard with minimal Ui for mongoose models.
|
|
10
|
+
- Provide DashboardController for custom routing and middlewares.
|
|
11
|
+
- Provide multiple dashboard instances with diffrent routes.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Create new ```unAuthenticated``` Dashboard:
|
|
16
|
+
- Create new instance from Dashboard.
|
|
17
|
+
- Provide Resources array of
|
|
18
|
+
resources file.
|
|
19
|
+
- Build the instance after mongoose setup by passing app instance to the build function.
|
|
20
|
+
```Typescript
|
|
21
|
+
const dashboard: Dashboard = new Dashboard({ resources:[ <Resource: IResourceFile> ]);
|
|
22
|
+
```
|
|
23
|
+
```Typescript
|
|
24
|
+
dashboard.build(app);
|
|
25
|
+
```
|
|
26
|
+
## To create new ```Authenticated``` Dashboard:
|
|
27
|
+
- Create new instance from Dashboard.
|
|
28
|
+
- Provide Resources array of
|
|
29
|
+
resources file.
|
|
30
|
+
- Provide authenticate function which take AdminCredentials as parameter and return a promise of boolean or user data.
|
|
31
|
+
- Provide cookiesConfiguration (cookie name and cookie secret).
|
|
32
|
+
- Build the instance after mongoose setup by passing app instance to the build function.
|
|
33
|
+
|
|
34
|
+
```Typescript
|
|
35
|
+
const dashboard = new Dashboard({
|
|
36
|
+
resources: [ UserResource ],
|
|
37
|
+
cookiesConfiguration: {
|
|
38
|
+
cookiesSecret: "cokieieSecret",
|
|
39
|
+
cookieName: "connect.sid"
|
|
40
|
+
},
|
|
41
|
+
authenticate: async (credentials: AdminCredentials) => {
|
|
42
|
+
const user = await Admin.findOne({ email: credentials.email });
|
|
43
|
+
if (user) {
|
|
44
|
+
const matched = await bcrypt.compare(credentials.password, user.encryptedPassword);
|
|
45
|
+
if (matched) {
|
|
46
|
+
return user;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
```Typescript
|
|
54
|
+
dashboard.build(app);
|
|
55
|
+
```
|
|
56
|
+
## To create new ```CustomRoutes``` Dashboard:
|
|
57
|
+
``` This method require to implement your own view and new react app ```
|
|
58
|
+
- Create new controller class with invirsify-express-utils notaitions and extend ActionController.
|
|
59
|
+
- Create new controller class with invirsify-express-utils notaitions and extend ResourceController.
|
|
60
|
+
- Create new controller class with invirsify-express-utils notaitions and extend DashboardController.
|
|
61
|
+
- Provide resource file and repository in super constructor.
|
|
62
|
+
- ``` Following class will create new route /v1/contries ***Now you can pass any auth middlewares you want```
|
|
63
|
+
|
|
64
|
+
```TypeScript
|
|
65
|
+
@controller('/v1/actions', defaultHeaders)
|
|
66
|
+
export default class ActionsController extends ActionController{
|
|
67
|
+
|
|
68
|
+
constructor(
|
|
69
|
+
@inject(TYPES.IResources) private resources: IResourceFile[]) {
|
|
70
|
+
super(resources);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```TypeScript
|
|
76
|
+
@controller('/v1/resources', defaultHeaders)
|
|
77
|
+
export default class ResourcesController extends ResourceController{
|
|
78
|
+
|
|
79
|
+
constructor(
|
|
80
|
+
@inject(TYPES.IResources) private resources: IResourceFile[]) {
|
|
81
|
+
super(resources);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```TypeScript
|
|
87
|
+
@controller('/v1/contries', defaultHeaders)
|
|
88
|
+
export default class CountryController extends DashboardController{
|
|
89
|
+
|
|
90
|
+
constructor(
|
|
91
|
+
@inject(TYPES.ICountryRepository) private countryRepository: CountryRepository,
|
|
92
|
+
@inject(TYPES.ICountryResource) private countryResource: IResourceFile ) {
|
|
93
|
+
|
|
94
|
+
super(CountryResource, countryRepository);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Documentaion:
|
|
100
|
+
```Typescript
|
|
101
|
+
Dashboard(dashBoardConfig: DashboardConfig);
|
|
102
|
+
build(app: Application): void;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### Dashboard:
|
|
106
|
+
Dashboard constructor to create new instance from idntity-admin.
|
|
107
|
+
- dashBoardConfig:
|
|
108
|
+
```js
|
|
109
|
+
{
|
|
110
|
+
resources: IResourceFile[]; // Array of resources files.
|
|
111
|
+
rootPath?: string; // optional root path default to /dashboard
|
|
112
|
+
localesOptions?: i18n.ConfigurationOptions; // locales options for custom dashboard
|
|
113
|
+
cookiesConfiguration: CookieConfiguration; // cookies configuration in case of authenticated dashboard
|
|
114
|
+
authenticate?: AuthenticateMiddleWare; // authenticate function used to login the admin.
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
- IResourceFile
|
|
118
|
+
``` For resource file example check```
|
|
119
|
+
[IResourceFile](src/types/IResourceFile.ts)
|
|
120
|
+
|
|
121
|
+
- CookieConfiguration
|
|
122
|
+
```js
|
|
123
|
+
{
|
|
124
|
+
cookiesSecret: string; // cookie secret to handle sessions
|
|
125
|
+
cookieName: string; // cookie name as appeared in browser
|
|
126
|
+
}
|
|
127
127
|
```
|
package/lib/Dashboard.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Application } from "express";
|
|
2
|
-
import i18n from "i18n";
|
|
3
|
-
import DashboardConfig from "./types/DashbordConfig";
|
|
4
|
-
export default class Dashboard {
|
|
5
|
-
private dashBoardConfig;
|
|
6
|
-
private DEFAULT_ROOT_PATH;
|
|
7
|
-
constructor(dashBoardConfig: DashboardConfig);
|
|
8
|
-
build(app: Application): void;
|
|
9
|
-
private configureLocalization;
|
|
10
|
-
private buildRouter;
|
|
11
|
-
private configureAuthentication;
|
|
12
|
-
private configureSession;
|
|
13
|
-
static configurBaseLocalization(options: i18n.ConfigurationOptions, locale: string): void;
|
|
14
|
-
}
|
|
1
|
+
import { Application } from "express";
|
|
2
|
+
import i18n from "i18n";
|
|
3
|
+
import DashboardConfig from "./types/DashbordConfig";
|
|
4
|
+
export default class Dashboard {
|
|
5
|
+
private dashBoardConfig;
|
|
6
|
+
private DEFAULT_ROOT_PATH;
|
|
7
|
+
constructor(dashBoardConfig: DashboardConfig);
|
|
8
|
+
build(app: Application): void;
|
|
9
|
+
private configureLocalization;
|
|
10
|
+
private buildRouter;
|
|
11
|
+
private configureAuthentication;
|
|
12
|
+
private configureSession;
|
|
13
|
+
static configurBaseLocalization(options: i18n.ConfigurationOptions, locale: string): void;
|
|
14
|
+
}
|
package/lib/Dashboard.js
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const express_1 = __importDefault(require("express"));
|
|
30
|
-
const DashboardController_1 = __importDefault(require("./controllers/DashboardController"));
|
|
31
|
-
const router_1 = __importStar(require("./router"));
|
|
32
|
-
const i18n_1 = __importDefault(require("i18n"));
|
|
33
|
-
const ResourceController_1 = __importDefault(require("./controllers/ResourceController"));
|
|
34
|
-
const path_1 = __importDefault(require("path"));
|
|
35
|
-
const ActionController_1 = __importDefault(require("./controllers/ActionController"));
|
|
36
|
-
var session = require('express-session');
|
|
37
|
-
var cookieParser = require('cookie-parser');
|
|
38
|
-
class Dashboard {
|
|
39
|
-
constructor(dashBoardConfig) {
|
|
40
|
-
this.dashBoardConfig = dashBoardConfig;
|
|
41
|
-
this.DEFAULT_ROOT_PATH = "/dashboard";
|
|
42
|
-
}
|
|
43
|
-
build(app) {
|
|
44
|
-
this.configureLocalization();
|
|
45
|
-
app.use(i18n_1.default.init);
|
|
46
|
-
app.use((req, res, next) => {
|
|
47
|
-
req.setLocale(req.headers['accept-language'] ? req.headers['accept-language'] : 'en');
|
|
48
|
-
i18n_1.default.setLocale(req.headers['accept-language'] ? req.headers['accept-language'] : 'en');
|
|
49
|
-
next();
|
|
50
|
-
});
|
|
51
|
-
this.configureAuthentication(app);
|
|
52
|
-
this.buildRouter(app);
|
|
53
|
-
}
|
|
54
|
-
configureLocalization() {
|
|
55
|
-
var _a;
|
|
56
|
-
i18n_1.default.configure((_a = this.dashBoardConfig.localesOptions) !== null && _a !== void 0 ? _a : {
|
|
57
|
-
locales: ["en", "ar"],
|
|
58
|
-
directory: __dirname + '/locales',
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
buildRouter(app) {
|
|
62
|
-
var _a;
|
|
63
|
-
const dashboardController = new DashboardController_1.default(undefined, undefined, this.dashBoardConfig.resources);
|
|
64
|
-
const resourceController = new ResourceController_1.default(this.dashBoardConfig.resources, this.dashBoardConfig.configurations);
|
|
65
|
-
const actionController = new ActionController_1.default(this.dashBoardConfig.resources);
|
|
66
|
-
const appPath = path_1.default.normalize(path_1.default.join(__dirname, '/view'));
|
|
67
|
-
const router = (0, router_1.default)(dashboardController, resourceController, actionController, this.dashBoardConfig.authenticate);
|
|
68
|
-
app.use(express_1.default.static(appPath));
|
|
69
|
-
(0, router_1.createViewRoute)(router, appPath);
|
|
70
|
-
app.use((_a = this.dashBoardConfig.rootPath) !== null && _a !== void 0 ? _a : this.DEFAULT_ROOT_PATH, router);
|
|
71
|
-
}
|
|
72
|
-
configureAuthentication(app) {
|
|
73
|
-
if (!this.dashBoardConfig.authenticate || !this.dashBoardConfig.cookiesConfiguration) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
app.use(cookieParser());
|
|
77
|
-
this.configureSession(app, this.dashBoardConfig.cookiesConfiguration);
|
|
78
|
-
}
|
|
79
|
-
configureSession(app, cookiesConfiguration) {
|
|
80
|
-
var _a;
|
|
81
|
-
const rootPath = (_a = this.dashBoardConfig.rootPath) !== null && _a !== void 0 ? _a : this.DEFAULT_ROOT_PATH;
|
|
82
|
-
app.use(`${rootPath}`, session({
|
|
83
|
-
secret: cookiesConfiguration.cookiesSecret,
|
|
84
|
-
resave: false,
|
|
85
|
-
saveUninitialized: false,
|
|
86
|
-
name: cookiesConfiguration.cookieName,
|
|
87
|
-
cookie: { path: `${rootPath}`, httpOnly: true }
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
static configurBaseLocalization(options, locale) {
|
|
91
|
-
i18n_1.default.configure(options);
|
|
92
|
-
i18n_1.default.setLocale(locale);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.default = Dashboard;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const express_1 = __importDefault(require("express"));
|
|
30
|
+
const DashboardController_1 = __importDefault(require("./controllers/DashboardController"));
|
|
31
|
+
const router_1 = __importStar(require("./router"));
|
|
32
|
+
const i18n_1 = __importDefault(require("i18n"));
|
|
33
|
+
const ResourceController_1 = __importDefault(require("./controllers/ResourceController"));
|
|
34
|
+
const path_1 = __importDefault(require("path"));
|
|
35
|
+
const ActionController_1 = __importDefault(require("./controllers/ActionController"));
|
|
36
|
+
var session = require('express-session');
|
|
37
|
+
var cookieParser = require('cookie-parser');
|
|
38
|
+
class Dashboard {
|
|
39
|
+
constructor(dashBoardConfig) {
|
|
40
|
+
this.dashBoardConfig = dashBoardConfig;
|
|
41
|
+
this.DEFAULT_ROOT_PATH = "/dashboard";
|
|
42
|
+
}
|
|
43
|
+
build(app) {
|
|
44
|
+
this.configureLocalization();
|
|
45
|
+
app.use(i18n_1.default.init);
|
|
46
|
+
app.use((req, res, next) => {
|
|
47
|
+
req.setLocale(req.headers['accept-language'] ? req.headers['accept-language'] : 'en');
|
|
48
|
+
i18n_1.default.setLocale(req.headers['accept-language'] ? req.headers['accept-language'] : 'en');
|
|
49
|
+
next();
|
|
50
|
+
});
|
|
51
|
+
this.configureAuthentication(app);
|
|
52
|
+
this.buildRouter(app);
|
|
53
|
+
}
|
|
54
|
+
configureLocalization() {
|
|
55
|
+
var _a;
|
|
56
|
+
i18n_1.default.configure((_a = this.dashBoardConfig.localesOptions) !== null && _a !== void 0 ? _a : {
|
|
57
|
+
locales: ["en", "ar"],
|
|
58
|
+
directory: __dirname + '/locales',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
buildRouter(app) {
|
|
62
|
+
var _a;
|
|
63
|
+
const dashboardController = new DashboardController_1.default(undefined, undefined, this.dashBoardConfig.resources);
|
|
64
|
+
const resourceController = new ResourceController_1.default(this.dashBoardConfig.resources, this.dashBoardConfig.configurations);
|
|
65
|
+
const actionController = new ActionController_1.default(this.dashBoardConfig.resources);
|
|
66
|
+
const appPath = path_1.default.normalize(path_1.default.join(__dirname, '/view'));
|
|
67
|
+
const router = (0, router_1.default)(dashboardController, resourceController, actionController, this.dashBoardConfig.authenticate);
|
|
68
|
+
app.use(express_1.default.static(appPath));
|
|
69
|
+
(0, router_1.createViewRoute)(router, appPath);
|
|
70
|
+
app.use((_a = this.dashBoardConfig.rootPath) !== null && _a !== void 0 ? _a : this.DEFAULT_ROOT_PATH, router);
|
|
71
|
+
}
|
|
72
|
+
configureAuthentication(app) {
|
|
73
|
+
if (!this.dashBoardConfig.authenticate || !this.dashBoardConfig.cookiesConfiguration) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
app.use(cookieParser());
|
|
77
|
+
this.configureSession(app, this.dashBoardConfig.cookiesConfiguration);
|
|
78
|
+
}
|
|
79
|
+
configureSession(app, cookiesConfiguration) {
|
|
80
|
+
var _a;
|
|
81
|
+
const rootPath = (_a = this.dashBoardConfig.rootPath) !== null && _a !== void 0 ? _a : this.DEFAULT_ROOT_PATH;
|
|
82
|
+
app.use(`${rootPath}`, session({
|
|
83
|
+
secret: cookiesConfiguration.cookiesSecret,
|
|
84
|
+
resave: false,
|
|
85
|
+
saveUninitialized: false,
|
|
86
|
+
name: cookiesConfiguration.cookieName,
|
|
87
|
+
cookie: { path: `${rootPath}`, httpOnly: true }
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
static configurBaseLocalization(options, locale) {
|
|
91
|
+
i18n_1.default.configure(options);
|
|
92
|
+
i18n_1.default.setLocale(locale);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.default = Dashboard;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Container } from 'inversify';
|
|
2
|
-
import { IResourceFile } from '../../types/IResourceFile';
|
|
3
|
-
export default class HelperInversify {
|
|
4
|
-
static register(container: Container): void;
|
|
5
|
-
static registerResources(container: Container, resources: IResourceFile[]): void;
|
|
6
|
-
}
|
|
1
|
+
import { Container } from 'inversify';
|
|
2
|
+
import { IResourceFile } from '../../types/IResourceFile';
|
|
3
|
+
export default class HelperInversify {
|
|
4
|
+
static register(container: Container): void;
|
|
5
|
+
static registerResources(container: Container, resources: IResourceFile[]): void;
|
|
6
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class HelperInversify {
|
|
4
|
-
static register(container) {
|
|
5
|
-
// container.bind<IResourceFile[]>(TYPES.Resources).toConstantValue([]);
|
|
6
|
-
}
|
|
7
|
-
static registerResources(container, resources) {
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.default = HelperInversify;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class HelperInversify {
|
|
4
|
+
static register(container) {
|
|
5
|
+
// container.bind<IResourceFile[]>(TYPES.Resources).toConstantValue([]);
|
|
6
|
+
}
|
|
7
|
+
static registerResources(container, resources) {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = HelperInversify;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const HelperTypes: {
|
|
2
|
-
Resources: symbol;
|
|
3
|
-
RootPath: symbol;
|
|
4
|
-
};
|
|
5
|
-
export default HelperTypes;
|
|
1
|
+
declare const HelperTypes: {
|
|
2
|
+
Resources: symbol;
|
|
3
|
+
RootPath: symbol;
|
|
4
|
+
};
|
|
5
|
+
export default HelperTypes;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const HelperTypes = {
|
|
4
|
-
Resources: Symbol.for("Resources"),
|
|
5
|
-
RootPath: Symbol.for("rootPath")
|
|
6
|
-
};
|
|
7
|
-
exports.default = HelperTypes;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const HelperTypes = {
|
|
4
|
+
Resources: Symbol.for("Resources"),
|
|
5
|
+
RootPath: Symbol.for("rootPath")
|
|
6
|
+
};
|
|
7
|
+
exports.default = HelperTypes;
|
package/lib/container/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/lib/container/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// let weapons = new ContainerModule(
|
|
4
|
-
// (
|
|
5
|
-
// bind: interfaces.Bind,
|
|
6
|
-
// unbind: interfaces.Unbind,
|
|
7
|
-
// isBound: interfaces.IsBound,
|
|
8
|
-
// rebind: interfaces.Rebind
|
|
9
|
-
// ) => {
|
|
10
|
-
// bind<Katana>("Katana").to(Katana);
|
|
11
|
-
// bind<Shuriken>("Shuriken").to(Shuriken);
|
|
12
|
-
// }
|
|
13
|
-
// );
|
|
14
|
-
// export default container;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// let weapons = new ContainerModule(
|
|
4
|
+
// (
|
|
5
|
+
// bind: interfaces.Bind,
|
|
6
|
+
// unbind: interfaces.Unbind,
|
|
7
|
+
// isBound: interfaces.IsBound,
|
|
8
|
+
// rebind: interfaces.Rebind
|
|
9
|
+
// ) => {
|
|
10
|
+
// bind<Katana>("Katana").to(Katana);
|
|
11
|
+
// bind<Shuriken>("Shuriken").to(Shuriken);
|
|
12
|
+
// }
|
|
13
|
+
// );
|
|
14
|
+
// export default container;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Container } from 'inversify';
|
|
2
|
-
export default class RepositoryInversify {
|
|
3
|
-
static register(container: Container): void;
|
|
4
|
-
}
|
|
1
|
+
import { Container } from 'inversify';
|
|
2
|
+
export default class RepositoryInversify {
|
|
3
|
+
static register(container: Container): void;
|
|
4
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const RequestLogRepository_1 = __importDefault(require("../../repositories/RequestLogRepository"));
|
|
7
|
-
const types_1 = __importDefault(require("../types"));
|
|
8
|
-
class RepositoryInversify {
|
|
9
|
-
static register(container) {
|
|
10
|
-
container.bind(types_1.default.IRequestLogRepository).to(RequestLogRepository_1.default);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.default = RepositoryInversify;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const RequestLogRepository_1 = __importDefault(require("../../repositories/RequestLogRepository"));
|
|
7
|
+
const types_1 = __importDefault(require("../types"));
|
|
8
|
+
class RepositoryInversify {
|
|
9
|
+
static register(container) {
|
|
10
|
+
container.bind(types_1.default.IRequestLogRepository).to(RequestLogRepository_1.default);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.default = RepositoryInversify;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const RepositoryTypes: {
|
|
2
|
-
IRequestLogRepository: symbol;
|
|
3
|
-
};
|
|
4
|
-
export default RepositoryTypes;
|
|
1
|
+
declare const RepositoryTypes: {
|
|
2
|
+
IRequestLogRepository: symbol;
|
|
3
|
+
};
|
|
4
|
+
export default RepositoryTypes;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const RepositoryTypes = {
|
|
4
|
-
IRequestLogRepository: Symbol.for('IRequestLogRepository')
|
|
5
|
-
};
|
|
6
|
-
exports.default = RepositoryTypes;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const RepositoryTypes = {
|
|
4
|
+
IRequestLogRepository: Symbol.for('IRequestLogRepository')
|
|
5
|
+
};
|
|
6
|
+
exports.default = RepositoryTypes;
|
package/lib/container/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare const TYPES: {
|
|
2
|
-
DashboardController: symbol;
|
|
3
|
-
ResourceController: symbol;
|
|
4
|
-
IRequestLogRepository: symbol;
|
|
5
|
-
Resources: symbol;
|
|
6
|
-
RootPath: symbol;
|
|
7
|
-
};
|
|
8
|
-
export default TYPES;
|
|
1
|
+
declare const TYPES: {
|
|
2
|
+
DashboardController: symbol;
|
|
3
|
+
ResourceController: symbol;
|
|
4
|
+
IRequestLogRepository: symbol;
|
|
5
|
+
Resources: symbol;
|
|
6
|
+
RootPath: symbol;
|
|
7
|
+
};
|
|
8
|
+
export default TYPES;
|