identity-admin 1.28.8 → 1.28.10

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 (183) hide show
  1. package/README.md +294 -294
  2. package/lib/Dashboard.d.ts +14 -14
  3. package/lib/Dashboard.js +95 -95
  4. package/lib/container/helpers/HelperInversify.d.ts +6 -6
  5. package/lib/container/helpers/HelperInversify.js +10 -10
  6. package/lib/container/helpers/HelperTypes.d.ts +5 -5
  7. package/lib/container/helpers/HelperTypes.js +7 -7
  8. package/lib/container/index.d.ts +1 -1
  9. package/lib/container/index.js +14 -14
  10. package/lib/container/repositories/RepositoryInversify.d.ts +4 -4
  11. package/lib/container/repositories/RepositoryInversify.js +13 -13
  12. package/lib/container/repositories/RepositoryTypes.d.ts +4 -4
  13. package/lib/container/repositories/RepositoryTypes.js +6 -6
  14. package/lib/container/types.d.ts +8 -8
  15. package/lib/container/types.js +9 -9
  16. package/lib/controllers/ActionController.d.ts +9 -9
  17. package/lib/controllers/ActionController.js +141 -136
  18. package/lib/controllers/AdminNotificationController.d.ts +8 -8
  19. package/lib/controllers/AdminNotificationController.js +69 -69
  20. package/lib/controllers/DashboardController.d.ts +44 -44
  21. package/lib/controllers/DashboardController.js +787 -787
  22. package/lib/controllers/ResourceController.d.ts +15 -15
  23. package/lib/controllers/ResourceController.js +135 -135
  24. package/lib/helpers/ActionsGenerator.d.ts +11 -11
  25. package/lib/helpers/ActionsGenerator.js +179 -179
  26. package/lib/helpers/AdminNotifications/AdminNotificationCreation.d.ts +53 -49
  27. package/lib/helpers/AdminNotifications/AdminNotificationCreation.js +66 -66
  28. package/lib/helpers/AdminNotifications/AdminNotificationFetcher.d.ts +61 -51
  29. package/lib/helpers/AdminNotifications/AdminNotificationFetcher.js +44 -39
  30. package/lib/helpers/FilterQueryHelper.d.ts +9 -9
  31. package/lib/helpers/FilterQueryHelper.js +83 -83
  32. package/lib/helpers/FiltersHelper.d.ts +9 -9
  33. package/lib/helpers/FiltersHelper.js +126 -126
  34. package/lib/helpers/LocalesHelper.d.ts +4 -4
  35. package/lib/helpers/LocalesHelper.js +73 -73
  36. package/lib/helpers/LocalizedStringHelper.d.ts +11 -11
  37. package/lib/helpers/LocalizedStringHelper.js +74 -74
  38. package/lib/helpers/Permissions/PermissionFetcher.d.ts +8 -8
  39. package/lib/helpers/Permissions/PermissionFetcher.js +95 -95
  40. package/lib/helpers/Permissions/PermissionLabel.d.ts +2 -2
  41. package/lib/helpers/Permissions/PermissionLabel.js +42 -42
  42. package/lib/helpers/Permissions/PermissionMapper.d.ts +13 -13
  43. package/lib/helpers/Permissions/PermissionMapper.js +35 -35
  44. package/lib/helpers/Permissions/PermissionResource.d.ts +6 -6
  45. package/lib/helpers/Permissions/PermissionResource.js +62 -62
  46. package/lib/helpers/Permissions/PermissionSavingService.d.ts +13 -13
  47. package/lib/helpers/Permissions/PermissionSavingService.js +32 -32
  48. package/lib/helpers/Permissions/SavePermissionGroup.d.ts +6 -6
  49. package/lib/helpers/Permissions/SavePermissionGroup.js +32 -32
  50. package/lib/helpers/Permissions/UpdatePermissionGroup.d.ts +6 -6
  51. package/lib/helpers/Permissions/UpdatePermissionGroup.js +50 -50
  52. package/lib/helpers/Permissions/types.d.ts +17 -17
  53. package/lib/helpers/Permissions/types.js +2 -2
  54. package/lib/helpers/PopulationHelper.d.ts +12 -12
  55. package/lib/helpers/PopulationHelper.js +50 -50
  56. package/lib/helpers/RecordsCounter.d.ts +10 -10
  57. package/lib/helpers/RecordsCounter.js +33 -33
  58. package/lib/helpers/ReportsGenerator.d.ts +26 -26
  59. package/lib/helpers/ReportsGenerator.js +162 -162
  60. package/lib/helpers/ResourceGenerator.d.ts +9 -9
  61. package/lib/helpers/ResourceGenerator.js +172 -172
  62. package/lib/helpers/ResourceHelper.d.ts +28 -28
  63. package/lib/helpers/ResourceHelper.js +395 -395
  64. package/lib/helpers/RportsGenerator.d.ts +10 -10
  65. package/lib/helpers/RportsGenerator.js +21 -21
  66. package/lib/helpers/SchemaGenerator.d.ts +7 -7
  67. package/lib/helpers/SchemaGenerator.js +132 -132
  68. package/lib/helpers/SchemaHelper.d.ts +5 -5
  69. package/lib/helpers/SchemaHelper.js +21 -21
  70. package/lib/helpers/UserActionsLog/UserActionsLogHelper.d.ts +2 -2
  71. package/lib/helpers/UserActionsLog/UserActionsLogHelper.js +49 -49
  72. package/lib/locales/en.json +53 -53
  73. package/lib/middlewares/cache/decorator.d.ts +3 -3
  74. package/lib/middlewares/cache/decorator.js +60 -60
  75. package/lib/middlewares/cache/deletionMethods.d.ts +3 -3
  76. package/lib/middlewares/cache/deletionMethods.js +23 -23
  77. package/lib/middlewares/isAuth.d.ts +13 -13
  78. package/lib/middlewares/isAuth.js +43 -43
  79. package/lib/models/ModelNames.d.ts +10 -10
  80. package/lib/models/ModelNames.js +13 -13
  81. package/lib/models/adminNotification/AdminNotification.d.ts +5 -5
  82. package/lib/models/adminNotification/AdminNotification.js +65 -53
  83. package/lib/models/adminNotification/IAdminNotification.d.ts +34 -30
  84. package/lib/models/adminNotification/IAdminNotification.js +15 -15
  85. package/lib/models/adminpermission/AdminPermission.d.ts +11 -11
  86. package/lib/models/adminpermission/AdminPermission.js +23 -23
  87. package/lib/models/adminpermission/IAdminPermission.d.ts +13 -13
  88. package/lib/models/adminpermission/IAdminPermission.js +2 -2
  89. package/lib/models/customPage/CustomPage.d.ts +2 -2
  90. package/lib/models/customPage/CustomPage.js +38 -38
  91. package/lib/models/customPage/ICustomPage.d.ts +17 -17
  92. package/lib/models/customPage/ICustomPage.js +2 -2
  93. package/lib/models/file/File.d.ts +2 -2
  94. package/lib/models/file/File.js +23 -23
  95. package/lib/models/file/IFile.d.ts +15 -15
  96. package/lib/models/file/IFile.js +2 -2
  97. package/lib/models/location/ILocation.d.ts +14 -14
  98. package/lib/models/location/ILocation.js +2 -2
  99. package/lib/models/location/Location.d.ts +2 -2
  100. package/lib/models/location/Location.js +21 -21
  101. package/lib/models/mailLog/IMailLog.d.ts +14 -14
  102. package/lib/models/mailLog/IMailLog.js +2 -2
  103. package/lib/models/mailLog/MailLog.d.ts +3 -3
  104. package/lib/models/mailLog/MailLog.js +23 -23
  105. package/lib/models/modelConfiguration/IModelConfigurations.d.ts +29 -29
  106. package/lib/models/modelConfiguration/IModelConfigurations.js +2 -2
  107. package/lib/models/modelConfiguration/ModelConfiguration.d.ts +13 -13
  108. package/lib/models/modelConfiguration/ModelConfiguration.js +95 -95
  109. package/lib/models/permission/IPermission.d.ts +14 -14
  110. package/lib/models/permission/IPermission.js +2 -2
  111. package/lib/models/permission/Permission.d.ts +2 -2
  112. package/lib/models/permission/Permission.js +21 -21
  113. package/lib/models/request-log/IRequestLog.d.ts +22 -22
  114. package/lib/models/request-log/IRequestLog.js +2 -2
  115. package/lib/models/request-log/RequestLog.d.ts +3 -3
  116. package/lib/models/request-log/RequestLog.js +51 -51
  117. package/lib/models/userActionsLog/IUserActionsLog.d.ts +26 -26
  118. package/lib/models/userActionsLog/IUserActionsLog.js +11 -11
  119. package/lib/models/userActionsLog/UserActionsLog.d.ts +3 -3
  120. package/lib/models/userActionsLog/UserActionsLog.js +41 -41
  121. package/lib/pdf/ReportTemplate.d.ts +71 -71
  122. package/lib/pdf/ReportTemplate.js +94 -94
  123. package/lib/repositories/AdminNotificationRepository.d.ts +7 -7
  124. package/lib/repositories/AdminNotificationRepository.js +23 -23
  125. package/lib/repositories/DashboardRepository.d.ts +5 -5
  126. package/lib/repositories/DashboardRepository.js +12 -12
  127. package/lib/repositories/Repository.d.ts +68 -68
  128. package/lib/repositories/Repository.js +215 -215
  129. package/lib/repositories/RequestLogRepository.d.ts +10 -10
  130. package/lib/repositories/RequestLogRepository.js +54 -54
  131. package/lib/repositories/SaveResult.d.ts +14 -14
  132. package/lib/repositories/SaveResult.js +18 -18
  133. package/lib/resources/AdminNotificationsResource.d.ts +3 -3
  134. package/lib/resources/AdminNotificationsResource.js +23 -23
  135. package/lib/resources/parents.d.ts +4 -4
  136. package/lib/resources/parents.js +7 -7
  137. package/lib/router/index.d.ts +8 -8
  138. package/lib/router/index.js +104 -104
  139. package/lib/types/DashbordConfig.d.ts +21 -21
  140. package/lib/types/DashbordConfig.js +2 -2
  141. package/lib/types/IConfigurationFile.d.ts +11 -11
  142. package/lib/types/IConfigurationFile.js +2 -2
  143. package/lib/types/IResourceFile.d.ts +719 -719
  144. package/lib/types/IResourceFile.js +2 -2
  145. package/lib/types/IResourceResponse.d.ts +95 -95
  146. package/lib/types/IResourceResponse.js +2 -2
  147. package/lib/types/helpers.d.ts +67 -67
  148. package/lib/types/helpers.js +82 -82
  149. package/lib/utils/DateUtils.d.ts +7 -7
  150. package/lib/utils/DateUtils.js +45 -45
  151. package/lib/utils/ResourceUtils.d.ts +2 -2
  152. package/lib/utils/ResourceUtils.js +7 -7
  153. package/lib/utils/ResponseUtils.d.ts +11 -11
  154. package/lib/utils/ResponseUtils.js +41 -41
  155. package/lib/utils/StringUtils.d.ts +9 -9
  156. package/lib/utils/StringUtils.js +46 -46
  157. package/lib/view/asset-manifest.json +18 -18
  158. package/lib/view/assets/icons/delete_icon.svg +3 -3
  159. package/lib/view/assets/icons/flags/ic_flag_cn.svg +9 -9
  160. package/lib/view/assets/icons/flags/ic_flag_sa.svg +9 -9
  161. package/lib/view/assets/icons/flags/ic_flag_vn.svg +9 -9
  162. package/lib/view/assets/icons/info_icon.svg +3 -3
  163. package/lib/view/assets/icons/navbar/ic_banking.svg +5 -5
  164. package/lib/view/assets/icons/navbar/ic_invoice.svg +4 -4
  165. package/lib/view/assets/icons/navbar/ic_kanban.svg +7 -7
  166. package/lib/view/assets/icons/navbar/ic_menu_item.svg +8 -8
  167. package/lib/view/assets/icons/small_info_icon.svg +3 -3
  168. package/lib/view/assets/illustrations/Group 16.svg +4 -4
  169. package/lib/view/assets/illustrations/logo.svg +5 -5
  170. package/lib/view/favicon/browserconfig.xml +9 -9
  171. package/lib/view/favicon/safari-pinned-tab.svg +182 -182
  172. package/lib/view/favicon/site.webmanifest +19 -19
  173. package/lib/view/fonts/index.css +18 -18
  174. package/lib/view/index.html +52 -52
  175. package/lib/view/manifest.json +20 -20
  176. package/lib/view/robots.txt +3 -3
  177. package/lib/view/static/css/main.54de06ef.css +1 -1
  178. package/lib/view/static/js/574.778b5963.chunk.js +1 -1
  179. package/lib/view/static/js/678.521704a3.chunk.js +1 -1
  180. package/lib/view/static/js/798.54856416.chunk.js +1 -1
  181. package/lib/view/static/js/main.4687f255.js +2 -2
  182. package/lib/view/static/js/main.4687f255.js.LICENSE.txt +214 -214
  183. package/package.json +63 -63
package/README.md CHANGED
@@ -1,295 +1,295 @@
1
- # Identity Admin Dashboard
2
-
3
- [![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger)
4
-
5
- ## How to install
6
-
7
- ```bash
8
- npm i identity-admin
9
- ```
10
-
11
- ## Features
12
-
13
- - Creating Dashboard with minimal Ui for mongoose models.
14
- - Provide DashboardController for custom routing and middlewares.
15
- - Provide multiple dashboard instances with diffrent routes.
16
-
17
- ## Create new `unAuthenticated` Dashboard:
18
-
19
- - Create new instance from Dashboard.
20
- - Provide Resources array of
21
- resources file.
22
- - Build the instance after mongoose setup by passing app instance to the build function.
23
-
24
- ```Typescript
25
- const dashboard: Dashboard = new Dashboard({ resources:[ <Resource: IResourceFile> ]);
26
- ```
27
-
28
- ```Typescript
29
- dashboard.build(app);
30
- ```
31
-
32
- ## To create new `Authenticated` Dashboard:
33
-
34
- - Create new instance from Dashboard.
35
- - Provide Resources array of
36
- resources file.
37
- - Provide authenticate function which take AdminCredentials as parameter and return a promise of boolean or user data.
38
- - Provide cookiesConfiguration (cookie name and cookie secret).
39
- - Build the instance after mongoose setup by passing app instance to the build function.
40
-
41
- ```Typescript
42
- const dashboard = new Dashboard({
43
- resources: [ UserResource ],
44
- cookiesConfiguration: {
45
- cookiesSecret: "cokieieSecret",
46
- cookieName: "connect.sid"
47
- },
48
- authenticate: async (credentials: AdminCredentials) => {
49
- const user = await Admin.findOne({ email: credentials.email });
50
- if (user) {
51
- const matched = await bcrypt.compare(credentials.password, user.encryptedPassword);
52
- if (matched) {
53
- return user;
54
- }
55
- }
56
- return false;
57
- }
58
- })
59
- ```
60
-
61
- ```Typescript
62
- dashboard.build(app);
63
- ```
64
-
65
- ## To create new `CustomRoutes` Dashboard:
66
-
67
- `This method require to implement your own view and new react app`
68
-
69
- - Create new controller class with invirsify-express-utils notaitions and extend ActionController.
70
- - Create new controller class with invirsify-express-utils notaitions and extend ResourceController.
71
- - Create new controller class with invirsify-express-utils notaitions and extend DashboardController.
72
- - Provide resource file and repository in super constructor.
73
- - ` Following class will create new route /v1/contries ***Now you can pass any auth middlewares you want`
74
-
75
- ```TypeScript
76
- @controller('/v1/actions', defaultHeaders)
77
- export default class ActionsController extends ActionController{
78
-
79
- constructor(
80
- @inject(TYPES.IResources) private resources: IResourceFile[]) {
81
- super(resources);
82
- }
83
- }
84
- ```
85
-
86
- ```TypeScript
87
- @controller('/v1/resources', defaultHeaders)
88
- export default class ResourcesController extends ResourceController{
89
-
90
- constructor(
91
- @inject(TYPES.IResources) private resources: IResourceFile[]) {
92
- super(resources);
93
- }
94
- }
95
- ```
96
-
97
- ```TypeScript
98
- @controller('/v1/contries', defaultHeaders)
99
- export default class CountryController extends DashboardController{
100
-
101
- constructor(
102
- @inject(TYPES.ICountryRepository) private countryRepository: CountryRepository,
103
- @inject(TYPES.ICountryResource) private countryResource: IResourceFile ) {
104
-
105
- super(CountryResource, countryRepository);
106
- }
107
- }
108
- ```
109
-
110
- ## Documentaion:
111
-
112
- ```Typescript
113
- Dashboard(dashBoardConfig: DashboardConfig);
114
- build(app: Application): void;
115
- ```
116
-
117
- #### Dashboard:
118
-
119
- Dashboard constructor to create new instance from idntity-admin.
120
-
121
- - dashBoardConfig:
122
-
123
- ```js
124
- {
125
- resources: IResourceFile[]; // Array of resources files.
126
- rootPath?: string; // optional root path default to /dashboard
127
- localesOptions?: i18n.ConfigurationOptions; // locales options for custom dashboard
128
- cookiesConfiguration: CookieConfiguration; // cookies configuration in case of authenticated dashboard
129
- authenticate?: AuthenticateMiddleWare; // authenticate function used to login the admin.
130
- }
131
- ```
132
-
133
- - IResourceFile
134
- ` For resource file example check`
135
- [IResourceFile](src/types/IResourceFile.ts)
136
-
137
- - CookieConfiguration
138
-
139
- ```js
140
- {
141
- cookiesSecret: string; // cookie secret to handle sessions
142
- cookieName: string; // cookie name as appeared in browser
143
- }
144
- ```
145
-
146
- ## Admin Notifications:
147
-
148
- `To add admin notifications in your project you should add the following`
149
-
150
- - Enable the admin notifications in the configuration file of the dashboard.
151
- > Configuration.ts
152
-
153
- ```Typescript
154
- import { IConfiguartionFile } from "identity-admin/lib/types/IConfigurationFile";
155
-
156
- export const configuration: IConfiguartionFile = {
157
- textFieldSize: 'small',
158
- defaultRowsPerPage: 50,
159
- adminNotifications: true // enable admin notifications
160
- }
161
- ```
162
-
163
- - Add these lines for the admin notification repository in the inversify container.
164
- > RepositoryTypes.ts
165
-
166
- ```Typescript
167
- IAdminNotificationRepository: Symbol.for('IAdminNotificationRepository')
168
-
169
- ```
170
-
171
- > RepositoryInversify.ts
172
-
173
- ```Typescript
174
- container.bind<IAdminNotificationRepository>(TYPES.IAdminNotificationRepository).to(AdminNotificationRepository);
175
-
176
- ```
177
-
178
- - Create new dashboard controller for the admin notifications CRUD operations and another controller for the notifications services.
179
- > AdminNotificationController.ts
180
-
181
- ```TypeScript
182
- import { controller } from "inversify-express-utils";
183
- import { defaultHeaders, isSessionAuth } from "@pbb/middlewares/isAuth";
184
- import DashboardController from "identity-admin/lib/controllers/DashboardController";
185
- import { inject } from "inversify";
186
- import TYPES from "@pbb/container/types";
187
- import AdminNotificationRepository from "identity-admin/lib/repositories/AdminNotificationRepository";
188
- import { modelConfigurations } from "@pbb/settings";
189
- import AdminNotificationsResource from "identity-admin/lib/resources/AdminNotificationsResource";
190
-
191
- @controller("/v1/admin/adminNotifications", isSessionAuth, defaultHeaders) // admin can be changed according to your base route
192
- export default class DashboardAdminNotificationController extends DashboardController {
193
- constructor(
194
- @inject(TYPES.IAdminNotificationRepository)
195
- private adminNotificationRepository: AdminNotificationRepository
196
- ) {
197
- super(
198
- AdminNotificationsResource,
199
- adminNotificationRepository,
200
- undefined,
201
- modelConfigurations
202
- );
203
- }
204
- }
205
-
206
- ```
207
-
208
- > DashboardNotifications.ts
209
-
210
- ```TypeScript
211
- import { defaultHeaders, isSessionAuth } from "@pbb/middlewares/isAuth";
212
- import { controller } from "inversify-express-utils";
213
-
214
- import NotificationController from "identity-admin/lib/controllers/AdminNotificationController";
215
-
216
- @controller("/v1/admin/notifications", isSessionAuth, defaultHeaders) // You can change the base route as your need.
217
- export default class DashboardNotificationController extends NotificationController {
218
- constructor() {
219
- super();
220
- }
221
- }
222
-
223
-
224
- ```
225
-
226
- - Import these 2 controllers in the index file of the controllers folder.
227
- > index.ts
228
-
229
- ```Typescript
230
- import './AdminNotificationController'
231
- import './DashboardNotifications';
232
- ```
233
-
234
- - Add the resource file of the admin notifications in your index file of the resources folder.
235
- > index.ts
236
-
237
- ```Typescript
238
- // other imports
239
- import AdminNotificationsResource from 'identity-admin/lib/resources/AdminNotificationsResource'
240
-
241
- ....
242
-
243
- const resources: IResourceFile[] = [
244
- // other resources
245
- ...
246
- AdminNotificationsResource,
247
- ...
248
- ];
249
- ```
250
-
251
- #### Add new notification:
252
-
253
- `To add a new notification just call the AdminNotificationCreation class as below`
254
-
255
- ```Typescript
256
-
257
- import {
258
- AdminNotificationCreation,
259
- NotificationNavigationType,
260
- } from "identity-admin/lib/helpers/AdminNotifications/AdminNotificationCreation";
261
-
262
- const record = await AdminNotificationCreation.insert({
263
- title: "Notification title",
264
- navigateTo: NotificationNavigationType.LIST,
265
- type: "Any notification type",
266
- modelName: ModelNames.User,
267
- });
268
- ```
269
-
270
- - In case you choose **NotificationNavigationType.LIST** then you should provide a model name to be navigated to
271
- - In case you choose **NotificationNavigationType.SHOW** then you should provide a model name to be navigated to and the relatedId of the record to be shown
272
- - In case you choose **NotificationNavigationType.EXTERNAL_LINK** then you should provide the external link
273
-
274
- #### The Frontend code:
275
-
276
- - Add the notification provider just before the router.
277
- > app.tsx
278
-
279
- ```tsx
280
- import { NotificationsContextProvider } from 'identity-admin-ui';
281
-
282
- <NotificationsContextProvider notificationsUrl="notifications">
283
- <Router />
284
- </NotificationsContextProvider>;
285
- ```
286
-
287
- - Add the notification icon in the dashboard header.
288
- > DashboardHeader.tsx
289
-
290
- ```tsx
291
- const showNotifications = resources?.appConfigurations?.adminNotifications;
292
-
293
- {showNotifications && <NotificationPopover />} // Add it just above the account popover
294
- <AccountPopover userType={userType} />
1
+ # Identity Admin Dashboard
2
+
3
+ [![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger)
4
+
5
+ ## How to install
6
+
7
+ ```bash
8
+ npm i identity-admin
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - Creating Dashboard with minimal Ui for mongoose models.
14
+ - Provide DashboardController for custom routing and middlewares.
15
+ - Provide multiple dashboard instances with diffrent routes.
16
+
17
+ ## Create new `unAuthenticated` Dashboard:
18
+
19
+ - Create new instance from Dashboard.
20
+ - Provide Resources array of
21
+ resources file.
22
+ - Build the instance after mongoose setup by passing app instance to the build function.
23
+
24
+ ```Typescript
25
+ const dashboard: Dashboard = new Dashboard({ resources:[ <Resource: IResourceFile> ]);
26
+ ```
27
+
28
+ ```Typescript
29
+ dashboard.build(app);
30
+ ```
31
+
32
+ ## To create new `Authenticated` Dashboard:
33
+
34
+ - Create new instance from Dashboard.
35
+ - Provide Resources array of
36
+ resources file.
37
+ - Provide authenticate function which take AdminCredentials as parameter and return a promise of boolean or user data.
38
+ - Provide cookiesConfiguration (cookie name and cookie secret).
39
+ - Build the instance after mongoose setup by passing app instance to the build function.
40
+
41
+ ```Typescript
42
+ const dashboard = new Dashboard({
43
+ resources: [ UserResource ],
44
+ cookiesConfiguration: {
45
+ cookiesSecret: "cokieieSecret",
46
+ cookieName: "connect.sid"
47
+ },
48
+ authenticate: async (credentials: AdminCredentials) => {
49
+ const user = await Admin.findOne({ email: credentials.email });
50
+ if (user) {
51
+ const matched = await bcrypt.compare(credentials.password, user.encryptedPassword);
52
+ if (matched) {
53
+ return user;
54
+ }
55
+ }
56
+ return false;
57
+ }
58
+ })
59
+ ```
60
+
61
+ ```Typescript
62
+ dashboard.build(app);
63
+ ```
64
+
65
+ ## To create new `CustomRoutes` Dashboard:
66
+
67
+ `This method require to implement your own view and new react app`
68
+
69
+ - Create new controller class with invirsify-express-utils notaitions and extend ActionController.
70
+ - Create new controller class with invirsify-express-utils notaitions and extend ResourceController.
71
+ - Create new controller class with invirsify-express-utils notaitions and extend DashboardController.
72
+ - Provide resource file and repository in super constructor.
73
+ - ` Following class will create new route /v1/contries ***Now you can pass any auth middlewares you want`
74
+
75
+ ```TypeScript
76
+ @controller('/v1/actions', defaultHeaders)
77
+ export default class ActionsController extends ActionController{
78
+
79
+ constructor(
80
+ @inject(TYPES.IResources) private resources: IResourceFile[]) {
81
+ super(resources);
82
+ }
83
+ }
84
+ ```
85
+
86
+ ```TypeScript
87
+ @controller('/v1/resources', defaultHeaders)
88
+ export default class ResourcesController extends ResourceController{
89
+
90
+ constructor(
91
+ @inject(TYPES.IResources) private resources: IResourceFile[]) {
92
+ super(resources);
93
+ }
94
+ }
95
+ ```
96
+
97
+ ```TypeScript
98
+ @controller('/v1/contries', defaultHeaders)
99
+ export default class CountryController extends DashboardController{
100
+
101
+ constructor(
102
+ @inject(TYPES.ICountryRepository) private countryRepository: CountryRepository,
103
+ @inject(TYPES.ICountryResource) private countryResource: IResourceFile ) {
104
+
105
+ super(CountryResource, countryRepository);
106
+ }
107
+ }
108
+ ```
109
+
110
+ ## Documentaion:
111
+
112
+ ```Typescript
113
+ Dashboard(dashBoardConfig: DashboardConfig);
114
+ build(app: Application): void;
115
+ ```
116
+
117
+ #### Dashboard:
118
+
119
+ Dashboard constructor to create new instance from idntity-admin.
120
+
121
+ - dashBoardConfig:
122
+
123
+ ```js
124
+ {
125
+ resources: IResourceFile[]; // Array of resources files.
126
+ rootPath?: string; // optional root path default to /dashboard
127
+ localesOptions?: i18n.ConfigurationOptions; // locales options for custom dashboard
128
+ cookiesConfiguration: CookieConfiguration; // cookies configuration in case of authenticated dashboard
129
+ authenticate?: AuthenticateMiddleWare; // authenticate function used to login the admin.
130
+ }
131
+ ```
132
+
133
+ - IResourceFile
134
+ ` For resource file example check`
135
+ [IResourceFile](src/types/IResourceFile.ts)
136
+
137
+ - CookieConfiguration
138
+
139
+ ```js
140
+ {
141
+ cookiesSecret: string; // cookie secret to handle sessions
142
+ cookieName: string; // cookie name as appeared in browser
143
+ }
144
+ ```
145
+
146
+ ## Admin Notifications:
147
+
148
+ `To add admin notifications in your project you should add the following`
149
+
150
+ - Enable the admin notifications in the configuration file of the dashboard.
151
+ > Configuration.ts
152
+
153
+ ```Typescript
154
+ import { IConfiguartionFile } from "identity-admin/lib/types/IConfigurationFile";
155
+
156
+ export const configuration: IConfiguartionFile = {
157
+ textFieldSize: 'small',
158
+ defaultRowsPerPage: 50,
159
+ adminNotifications: true // enable admin notifications
160
+ }
161
+ ```
162
+
163
+ - Add these lines for the admin notification repository in the inversify container.
164
+ > RepositoryTypes.ts
165
+
166
+ ```Typescript
167
+ IAdminNotificationRepository: Symbol.for('IAdminNotificationRepository')
168
+
169
+ ```
170
+
171
+ > RepositoryInversify.ts
172
+
173
+ ```Typescript
174
+ container.bind<IAdminNotificationRepository>(TYPES.IAdminNotificationRepository).to(AdminNotificationRepository);
175
+
176
+ ```
177
+
178
+ - Create new dashboard controller for the admin notifications CRUD operations and another controller for the notifications services.
179
+ > AdminNotificationController.ts
180
+
181
+ ```TypeScript
182
+ import { controller } from "inversify-express-utils";
183
+ import { defaultHeaders, isSessionAuth } from "@pbb/middlewares/isAuth";
184
+ import DashboardController from "identity-admin/lib/controllers/DashboardController";
185
+ import { inject } from "inversify";
186
+ import TYPES from "@pbb/container/types";
187
+ import AdminNotificationRepository from "identity-admin/lib/repositories/AdminNotificationRepository";
188
+ import { modelConfigurations } from "@pbb/settings";
189
+ import AdminNotificationsResource from "identity-admin/lib/resources/AdminNotificationsResource";
190
+
191
+ @controller("/v1/admin/adminNotifications", isSessionAuth, defaultHeaders) // admin can be changed according to your base route
192
+ export default class DashboardAdminNotificationController extends DashboardController {
193
+ constructor(
194
+ @inject(TYPES.IAdminNotificationRepository)
195
+ private adminNotificationRepository: AdminNotificationRepository
196
+ ) {
197
+ super(
198
+ AdminNotificationsResource,
199
+ adminNotificationRepository,
200
+ undefined,
201
+ modelConfigurations
202
+ );
203
+ }
204
+ }
205
+
206
+ ```
207
+
208
+ > DashboardNotifications.ts
209
+
210
+ ```TypeScript
211
+ import { defaultHeaders, isSessionAuth } from "@pbb/middlewares/isAuth";
212
+ import { controller } from "inversify-express-utils";
213
+
214
+ import NotificationController from "identity-admin/lib/controllers/AdminNotificationController";
215
+
216
+ @controller("/v1/admin/notifications", isSessionAuth, defaultHeaders) // You can change the base route as your need.
217
+ export default class DashboardNotificationController extends NotificationController {
218
+ constructor() {
219
+ super();
220
+ }
221
+ }
222
+
223
+
224
+ ```
225
+
226
+ - Import these 2 controllers in the index file of the controllers folder.
227
+ > index.ts
228
+
229
+ ```Typescript
230
+ import './AdminNotificationController'
231
+ import './DashboardNotifications';
232
+ ```
233
+
234
+ - Add the resource file of the admin notifications in your index file of the resources folder.
235
+ > index.ts
236
+
237
+ ```Typescript
238
+ // other imports
239
+ import AdminNotificationsResource from 'identity-admin/lib/resources/AdminNotificationsResource'
240
+
241
+ ....
242
+
243
+ const resources: IResourceFile[] = [
244
+ // other resources
245
+ ...
246
+ AdminNotificationsResource,
247
+ ...
248
+ ];
249
+ ```
250
+
251
+ #### Add new notification:
252
+
253
+ `To add a new notification just call the AdminNotificationCreation class as below`
254
+
255
+ ```Typescript
256
+
257
+ import {
258
+ AdminNotificationCreation,
259
+ NotificationNavigationType,
260
+ } from "identity-admin/lib/helpers/AdminNotifications/AdminNotificationCreation";
261
+
262
+ const record = await AdminNotificationCreation.insert({
263
+ title: "Notification title",
264
+ navigateTo: NotificationNavigationType.LIST,
265
+ type: "Any notification type",
266
+ modelName: ModelNames.User,
267
+ });
268
+ ```
269
+
270
+ - In case you choose **NotificationNavigationType.LIST** then you should provide a model name to be navigated to
271
+ - In case you choose **NotificationNavigationType.SHOW** then you should provide a model name to be navigated to and the relatedId of the record to be shown
272
+ - In case you choose **NotificationNavigationType.EXTERNAL_LINK** then you should provide the external link
273
+
274
+ #### The Frontend code:
275
+
276
+ - Add the notification provider just before the router.
277
+ > app.tsx
278
+
279
+ ```tsx
280
+ import { NotificationsContextProvider } from 'identity-admin-ui';
281
+
282
+ <NotificationsContextProvider notificationsUrl="notifications">
283
+ <Router />
284
+ </NotificationsContextProvider>;
285
+ ```
286
+
287
+ - Add the notification icon in the dashboard header.
288
+ > DashboardHeader.tsx
289
+
290
+ ```tsx
291
+ const showNotifications = resources?.appConfigurations?.adminNotifications;
292
+
293
+ {showNotifications && <NotificationPopover />} // Add it just above the account popover
294
+ <AccountPopover userType={userType} />
295
295
  ```
@@ -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
+ }