@simitgroup/simpleapp-generator 1.0.32 → 1.0.35

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 (281) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/README.md +185 -16
  3. package/buildinschemas copy/autoincreament.autoinc.jsonschema.json +39 -0
  4. package/buildinschemas copy/branch.branch.jsonschema.json +41 -0
  5. package/buildinschemas copy/docnoformat.docno.jsonschema.json +41 -0
  6. package/buildinschemas copy/organization.org.jsonschema.json +50 -0
  7. package/buildinschemas copy/permission.perm.jsonschema.json +23 -0
  8. package/buildinschemas copy/permission.perm.jsonschema.try.json +25 -0
  9. package/buildinschemas copy/tenant.tenant.jsonschema.json +21 -0
  10. package/buildinschemas copy/tenant.tenant.jsonschema.try.json +27 -0
  11. package/buildinschemas copy/user.user.jsonschema.json +31 -0
  12. package/dist/buildinschemas/autoincreament.d.ts +3 -0
  13. package/dist/buildinschemas/autoincreament.d.ts.map +1 -0
  14. package/dist/buildinschemas/autoincreament.js +36 -0
  15. package/dist/buildinschemas/autoincreament.js.map +1 -0
  16. package/dist/buildinschemas/branch.d.ts +3 -0
  17. package/dist/buildinschemas/branch.d.ts.map +1 -0
  18. package/dist/buildinschemas/branch.js +41 -0
  19. package/dist/buildinschemas/branch.js.map +1 -0
  20. package/dist/buildinschemas/docnoformat.d.ts +3 -0
  21. package/dist/buildinschemas/docnoformat.d.ts.map +1 -0
  22. package/dist/buildinschemas/docnoformat.js +60 -0
  23. package/dist/buildinschemas/docnoformat.js.map +1 -0
  24. package/dist/buildinschemas/index.d.ts +8 -0
  25. package/dist/buildinschemas/index.d.ts.map +1 -0
  26. package/dist/buildinschemas/index.js +18 -0
  27. package/dist/buildinschemas/index.js.map +1 -0
  28. package/dist/buildinschemas/organization.d.ts +3 -0
  29. package/dist/buildinschemas/organization.d.ts.map +1 -0
  30. package/dist/buildinschemas/organization.js +34 -0
  31. package/dist/buildinschemas/organization.js.map +1 -0
  32. package/dist/buildinschemas/permission.d.ts +3 -0
  33. package/dist/buildinschemas/permission.d.ts.map +1 -0
  34. package/dist/buildinschemas/permission.js +34 -0
  35. package/dist/buildinschemas/permission.js.map +1 -0
  36. package/dist/buildinschemas/tenant.d.ts +3 -0
  37. package/dist/buildinschemas/tenant.d.ts.map +1 -0
  38. package/dist/buildinschemas/tenant.js +41 -0
  39. package/dist/buildinschemas/tenant.js.map +1 -0
  40. package/dist/buildinschemas/user.d.ts +3 -0
  41. package/dist/buildinschemas/user.d.ts.map +1 -0
  42. package/dist/buildinschemas/user.js +31 -0
  43. package/dist/buildinschemas/user.js.map +1 -0
  44. package/dist/constant.d.ts +4 -0
  45. package/dist/constant.d.ts.map +1 -0
  46. package/dist/constant.js +2 -1
  47. package/dist/constant.js.map +1 -1
  48. package/dist/framework.d.ts +10 -0
  49. package/dist/framework.d.ts.map +1 -0
  50. package/dist/framework.js +120 -68
  51. package/dist/framework.js.map +1 -1
  52. package/dist/generate-allow-changebackend.js +305 -0
  53. package/dist/generate-allow-changebackend.js.map +1 -0
  54. package/dist/generate.d.ts +2 -0
  55. package/dist/generate.d.ts.map +1 -0
  56. package/dist/generate.js +310 -230
  57. package/dist/generate.js.map +1 -1
  58. package/dist/index.d.ts +3 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +84 -20
  61. package/dist/index.js.map +1 -1
  62. package/dist/libs.d.ts +2 -0
  63. package/dist/libs.d.ts.map +1 -0
  64. package/dist/processors/groupsbuilder.js +2 -0
  65. package/dist/processors/groupsbuilder.js.map +1 -0
  66. package/dist/processors/jsonschemabuilder.d.ts +4 -0
  67. package/dist/processors/jsonschemabuilder.d.ts.map +1 -0
  68. package/dist/processors/jsonschemabuilder.js +146 -172
  69. package/dist/processors/jsonschemabuilder.js.map +1 -1
  70. package/dist/schematype/baseschema.js +25 -0
  71. package/dist/schematype/baseschema.js.map +1 -0
  72. package/dist/schematype/default.js +2 -0
  73. package/dist/schematype/default.js.map +1 -0
  74. package/dist/schematype/index.js +12 -0
  75. package/dist/schematype/index.js.map +1 -0
  76. package/dist/schematype/primarymasterdata.js +38 -0
  77. package/dist/schematype/primarymasterdata.js.map +1 -0
  78. package/dist/schematype/simple.js +24 -0
  79. package/dist/schematype/simple.js.map +1 -0
  80. package/dist/schematype/simplemasterdata.js +31 -0
  81. package/dist/schematype/simplemasterdata.js.map +1 -0
  82. package/dist/schematype/transaction.js +74 -0
  83. package/dist/schematype/transaction.js.map +1 -0
  84. package/dist/storage.d.ts +3 -0
  85. package/dist/storage.d.ts.map +1 -0
  86. package/dist/storage.js +2 -2
  87. package/dist/storage.js.map +1 -1
  88. package/dist/type.d.ts +164 -0
  89. package/dist/type.d.ts.map +1 -0
  90. package/dist/type.js +16 -1
  91. package/dist/type.js.map +1 -1
  92. package/dist/validation.d.ts +1 -0
  93. package/dist/validation.d.ts.map +1 -0
  94. package/documentation/designconcept.bpmn +349 -0
  95. package/documentation/documentation.png +0 -0
  96. package/documentation/infra.drawio +141 -0
  97. package/documentation/infra.png +0 -0
  98. package/documentation/management.drawio +57 -0
  99. package/documentation/stack.drawio +106 -0
  100. package/package.json +3 -1
  101. package/src/buildinschemas/autoincreament.ts +34 -0
  102. package/src/buildinschemas/branch.ts +39 -0
  103. package/src/buildinschemas/docnoformat.ts +58 -0
  104. package/src/buildinschemas/index.ts +7 -0
  105. package/src/buildinschemas/organization.ts +31 -0
  106. package/src/buildinschemas/permission.ts +31 -0
  107. package/src/buildinschemas/tenant.ts +38 -0
  108. package/src/buildinschemas/user.ts +28 -0
  109. package/src/constant.ts +2 -1
  110. package/src/framework.ts +126 -67
  111. package/src/generate.ts +327 -266
  112. package/src/generate.ts.backup +339 -0
  113. package/src/index.ts +93 -18
  114. package/src/processors/jsonschemabuilder.ts +199 -226
  115. package/src/processors/jsonschemabuilder.ts-old +383 -0
  116. package/src/storage.ts +1 -1
  117. package/src/type.ts +94 -27
  118. package/templates/basic/nest/controller.ts.eta +255 -0
  119. package/templates/basic/nest/default.ts.eta +42 -0
  120. package/templates/basic/{model.eta → nest/model.ts.eta} +18 -5
  121. package/templates/basic/nest/processor.ts.eta +129 -0
  122. package/templates/basic/nest/service.ts.eta +64 -0
  123. package/templates/basic/{type.eta → nest/type.ts.eta} +3 -3
  124. package/templates/basic/nuxt/default.ts.eta +42 -0
  125. package/templates/basic/{pageindex.vue.eta → nuxt/pages.crud.vue.eta} +85 -22
  126. package/templates/basic/nuxt/simpleapp.doc.ts.eta +11 -0
  127. package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +212 -0
  128. package/templates/nest/.env.eta +31 -0
  129. package/templates/nest/.gitignore.eta +40 -0
  130. package/templates/nest/src/app.controller.ts.eta +19 -0
  131. package/templates/nest/src/app.module.ts.eta +77 -0
  132. package/templates/nest/src/app.service.ts.eta +9 -0
  133. package/templates/nest/src/main.ts.eta +58 -0
  134. package/templates/nest/src/simpleapp/generate/apischemas/index.ts.eta +16 -0
  135. package/templates/nest/src/simpleapp/generate/commons/decorators/appuser.decorator.ts.eta +8 -0
  136. package/templates/nest/src/simpleapp/generate/commons/dicts/foreignkeys.ts.eta +1 -0
  137. package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +101 -0
  138. package/templates/nest/src/simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter.ts.eta +39 -0
  139. package/templates/nest/src/simpleapp/generate/commons/interceptors/response.interceptor.ts.eta +38 -0
  140. package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +88 -0
  141. package/templates/nest/{Workflow.eta → src/simpleapp/generate/commons/providers/workflow.provider.ts.etax} +20 -14
  142. package/templates/nest/src/simpleapp/generate/commons/roles/roles.decorator.ts.eta +6 -0
  143. package/templates/nest/src/simpleapp/generate/commons/roles/roles.enum.ts.eta +28 -0
  144. package/templates/nest/src/simpleapp/generate/commons/roles/roles.group.ts.eta +10 -0
  145. package/templates/nest/src/simpleapp/generate/commons/roles/roles.guard.ts.eta +34 -0
  146. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +391 -0
  147. package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +71 -0
  148. package/templates/nest/src/simpleapp/generate/models/perm.model.ts.eta +53 -0
  149. package/templates/nest/src/simpleapp/generate/models/tenant.model.ts.eta +45 -0
  150. package/templates/nest/src/simpleapp/generate/models/user.model.ts.eta +57 -0
  151. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +624 -0
  152. package/templates/nest/src/simpleapp/generate/types/index.ts.eta +19 -0
  153. package/templates/nest/src/simpleapp/profile/profile.apischema.ts.eta +74 -0
  154. package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +110 -0
  155. package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +195 -0
  156. package/templates/nest/src/simpleapp/profile/profile.types.ts.eta +18 -0
  157. package/templates/nest/src/simpleapp/services/autoinc.service.ts.eta +89 -0
  158. package/templates/nest/src/simpleapp/services/branch.service.ts.eta +66 -0
  159. package/templates/nest/src/simpleapp/services/docno.service.ts.eta +93 -0
  160. package/templates/nest/src/simpleapp/services/org.service.ts.eta +67 -0
  161. package/templates/nest/src/simpleapp/services/perm.service.ts.eta +102 -0
  162. package/templates/nest/src/simpleapp/services/tenant.service.ts.eta +69 -0
  163. package/templates/nest/src/simpleapp/services/user.service.ts.eta +66 -0
  164. package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +43 -0
  165. package/templates/nuxt/.env.eta +21 -0
  166. package/templates/nuxt/.gitignore.eta +28 -0
  167. package/templates/nuxt/app.vue.eta +5 -2
  168. package/templates/nuxt/assets/css/tailwind.css.eta +35 -0
  169. package/templates/nuxt/components/CrudNestedDoc.vue.eta +164 -0
  170. package/templates/nuxt/components/CrudSimple.vue.eta +179 -0
  171. package/templates/nuxt/{components.debugdocdata.vue.eta → components/DebugDocumentData.vue.eta} +4 -1
  172. package/templates/nuxt/{components.eventmonitor.vue.eta → components/EventMonitor.vue.eta} +27 -27
  173. package/templates/nuxt/components/Invitation.vue.eta +50 -0
  174. package/templates/nuxt/components/Menus.vue.eta +58 -0
  175. package/templates/nuxt/components/PermissionInfo.vue.eta +92 -0
  176. package/templates/nuxt/components/SimpleAppAutocomplete.vue.eta +131 -0
  177. package/templates/nuxt/components/SimpleAppAutocompletemulti.vue.eta +73 -0
  178. package/templates/nuxt/components/SimpleAppCalendar.vue.eta +55 -0
  179. package/templates/nuxt/components/SimpleAppCheckbox.vue.eta +29 -0
  180. package/templates/nuxt/components/SimpleAppChip.vue.eta +28 -0
  181. package/templates/nuxt/components/SimpleAppColor.vue.eta +41 -0
  182. package/templates/nuxt/components/SimpleAppDatatable.vue.eta +20 -0
  183. package/templates/nuxt/components/SimpleAppDocumentNo.vue.eta +90 -0
  184. package/templates/nuxt/components/SimpleAppDynamicInput.vue.eta +29 -0
  185. package/templates/nuxt/components/SimpleAppEditor.vue.eta +31 -0
  186. package/templates/nuxt/components/SimpleAppForm.vue.eta +131 -0
  187. package/templates/nuxt/components/SimpleAppInputTable.vue.eta +104 -0
  188. package/templates/nuxt/components/SimpleAppList.vue.eta +38 -0
  189. package/templates/nuxt/components/SimpleAppListmulti.vue.eta +41 -0
  190. package/templates/nuxt/components/SimpleAppNumber.vue.eta +32 -0
  191. package/templates/nuxt/components/SimpleAppPassword.vue.eta +41 -0
  192. package/templates/nuxt/components/SimpleAppRadio.vue.eta +42 -0
  193. package/templates/nuxt/components/SimpleAppRating.vue.eta +41 -0
  194. package/templates/nuxt/components/SimpleAppSelect.vue.eta +38 -0
  195. package/templates/nuxt/components/SimpleAppSelectmulti.vue.eta +39 -0
  196. package/templates/nuxt/components/SimpleAppSlider.vue.eta +42 -0
  197. package/templates/nuxt/components/SimpleAppSwitch.vue.eta +30 -0
  198. package/templates/nuxt/components/SimpleAppText.vue.eta +50 -0
  199. package/templates/nuxt/components/SimpleAppTextarea.vue.eta +30 -0
  200. package/templates/nuxt/components/SimpleAppValue.vue.eta +86 -0
  201. package/templates/nuxt/components/SimpleFieldContainer.vue.eta +102 -0
  202. package/templates/nuxt/components/XorgPicker.vue.eta +66 -0
  203. package/templates/nuxt/components/helper.ts.eta +90 -0
  204. package/templates/nuxt/components/type.ts.eta +32 -0
  205. package/templates/nuxt/composables/docformat.generate.ts.eta +5 -0
  206. package/templates/nuxt/{composables.getautocomplete.ts.eta → composables/getAutocomplete.generate.ts.eta} +4 -5
  207. package/templates/nuxt/{composables.getmenus.ts.eta → composables/getMenus.generate.ts.eta} +22 -7
  208. package/templates/nuxt/composables/getOpenApi.generate.ts.eta +6 -0
  209. package/templates/nuxt/composables/getTenant.generate.ts.eta +4 -0
  210. package/templates/nuxt/composables/getUserStore.generate.ts.eta +22 -0
  211. package/templates/nuxt/composables/logout.generate.ts.eta +22 -0
  212. package/templates/nuxt/composables/roles.generate.ts.eta +48 -0
  213. package/templates/nuxt/composables/stringHelper.generate.ts.eta +5 -0
  214. package/templates/nuxt/{layouts.default.vue.eta → layouts/default.vue.eta} +2 -0
  215. package/templates/nuxt/middleware/10.acl.global.ts.eta +38 -0
  216. package/templates/nuxt/nuxt.config.ts.eta +12 -2
  217. package/templates/nuxt/pages/[xorg]/branch/index.vue.eta +102 -0
  218. package/templates/nuxt/pages/[xorg]/docnoformat/[id].vue.eta +17 -0
  219. package/templates/nuxt/pages/[xorg]/docnoformat/index.vue.eta +269 -0
  220. package/templates/nuxt/pages/[xorg]/index.vue.eta +36 -0
  221. package/templates/nuxt/pages/[xorg]/organization/index.vue.eta +148 -0
  222. package/templates/nuxt/pages/[xorg]/permission/index.vue.eta +280 -0
  223. package/templates/nuxt/pages/[xorg]/tenant/index.vue.eta +93 -0
  224. package/templates/nuxt/pages/[xorg]/user/index.vue.eta +468 -0
  225. package/templates/nuxt/pages/index.vue.eta +191 -0
  226. package/templates/nuxt/pages/login.vue.eta +21 -0
  227. package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +53 -0
  228. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +155 -0
  229. package/templates/nuxt/plugins/50.simpleapp-client.ts.eta +23 -0
  230. package/templates/nuxt/{server.api.ts.eta → server/api/[xorg]/[...].ts.eta} +5 -2
  231. package/templates/nuxt/server/api/auth/[...].ts.eta +68 -0
  232. package/templates/nuxt/{server.api.auth.logout.ts.eta → server/api/auth/logout.ts.eta} +1 -3
  233. package/templates/nuxt/server/api/profile/[...].ts.eta +150 -0
  234. package/templates/nuxt/server/api/profile/index.ts.eta +103 -0
  235. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +187 -0
  236. package/templates/nuxt/simpleapp/generate/commons/documents.ts.eta +6 -0
  237. package/templates/nuxt/simpleapp/generate/commons/events.ts.eta +5 -0
  238. package/templates/nuxt/simpleapp/generate/commons/groups.ts.eta +11 -0
  239. package/templates/nuxt/simpleapp/generate/commons/roles.ts.eta +21 -0
  240. package/templates/nuxt/types/index.ts.eta +65 -0
  241. package/templates/project/README.md +11 -0
  242. package/templates/project/build.sh.eta +17 -0
  243. package/templates/project/config.json.eta +2 -0
  244. package/templates/project/generate.ts.eta +10 -0
  245. package/templates/project/schemas/category.ts.eta +26 -0
  246. package/templates/project/schemas/index.ts.eta +5 -0
  247. package/templates/project/schemas/product.ts.eta +59 -0
  248. package/templates/project/shares/hello.ts.eta +1 -0
  249. package/templates/project/shares/index.ts.eta +2 -0
  250. package/tsconfig.json +9 -2
  251. package/tsconfig.tsbuildinfo +1 -0
  252. package/definations/category.cat.jsonschema.json +0 -55
  253. package/definations/level.lvl.jsonschema.json +0 -48
  254. package/definations/product.prd.jsonschema.json +0 -46
  255. package/templates/basic/controller.eta +0 -152
  256. package/templates/basic/module.eta +0 -22
  257. package/templates/basic/service.eta +0 -62
  258. package/templates/basic/simpleappclient.eta +0 -120
  259. package/templates/nest/SimpleAppController.eta +0 -69
  260. package/templates/nest/SimpleAppService.eta +0 -366
  261. package/templates/nest/TenantMiddleware.eta +0 -34
  262. package/templates/nest/UserProvider.eta +0 -127
  263. package/templates/nest/app.controller.eta +0 -12
  264. package/templates/nest/app.module.eta +0 -64
  265. package/templates/nest/app.service.eta +0 -8
  266. package/templates/nest/inputvalidation-exception.eta +0 -6
  267. package/templates/nest/nest.env.eta +0 -28
  268. package/templates/nest/nest.main.eta +0 -31
  269. package/templates/nuxt/components.crudsimple.vue.eta +0 -124
  270. package/templates/nuxt/components.menus.vue.eta +0 -35
  271. package/templates/nuxt/env.eta +0 -17
  272. package/templates/nuxt/pages.[xorg].index.vue.eta +0 -20
  273. package/templates/nuxt/pages.index.vue.eta +0 -72
  274. package/templates/nuxt/pages.login.vue.eta +0 -20
  275. package/templates/nuxt/plugins.simpleapp.ts.eta +0 -88
  276. package/templates/nuxt/server.api.auth[...].ts.eta +0 -233
  277. package/templates/nuxt/tailwind.css.eta +0 -49
  278. /package/templates/basic/{apischema.eta → nest/apischema.ts.eta} +0 -0
  279. /package/templates/basic/{jsonschema.eta → nest/jsonschema.ts.eta} +0 -0
  280. /package/templates/basic/{pageindexwithid.vue.eta → nuxt/pages.[id].vue.eta} +0 -0
  281. /package/templates/nest/{oauth2-redirect.eta → public_html/oauth2-redirect.html.eta} +0 -0
@@ -0,0 +1,468 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * invite user into current tenant (put user into user catalogue)
4
+ * 1. user accept then have uid
5
+ * 2. no uid user will put at invite place
6
+ *
7
+ */
8
+ import Menu from "primevue/menu";
9
+ import Dialog from "primevue/dialog";
10
+ import {SearchBody} from '~/types'
11
+ import _ from "lodash";
12
+ import Panel from "primevue/panel";
13
+ import { ref } from "vue";
14
+ import {
15
+ UserListItem,
16
+ BranchListItem,
17
+ OrgListItem,
18
+ PermissionListItem,
19
+ } from "../../../types";
20
+ import SelectButton from "primevue/selectbutton";
21
+ import Button from "primevue/button";
22
+ import InputText from "primevue/inputtext";
23
+ import Card from "primevue/card";
24
+ import TabView from "primevue/tabview";
25
+ import TabPanel from "primevue/tabpanel";
26
+ import { Permission, User } from "../../../simpleapp/generate/openapi/api";
27
+ import BlockUI from "primevue/blockui";
28
+
29
+ //initialize api
30
+ const {
31
+ $PermissionDoc,
32
+ $OrganizationDoc,
33
+ $BranchDoc,
34
+ $UserDoc,
35
+ // $InvitationDoc,
36
+ } = useNuxtApp();
37
+ const permdoc = $PermissionDoc();
38
+ const orgdoc = $OrganizationDoc();
39
+ const branchdoc = $BranchDoc();
40
+ // const invitedoc = $InvitationDoc();
41
+ const userdoc = $UserDoc();
42
+ const userdata = userdoc.getReactiveData();
43
+ //initialize require list in UI
44
+ const permlist = ref<PermissionListItem[]>([]);
45
+ const userlist = ref<UserListItem[]>([]);
46
+
47
+ const orglist = ref<OrgListItem[]>([]);
48
+ const branchlist = ref<BranchListItem[]>([]);
49
+ const currentpermissions = ref<Permission[]>([]);
50
+ const grouplist = getAllGroups().map((item) => {
51
+ return { value: item, label: _.capitalize(item) };
52
+ });
53
+
54
+ //initialize some runtime variable
55
+ const blockscreen = ref(false);
56
+ const inviteemail = ref("");
57
+ const selected = ref("");
58
+ const activeuser = ref("");
59
+ const showpermissioninfo = ref(false);
60
+ const permissionselected = ref();
61
+ const usertitle = "User Information";
62
+ const permissiontitle = "Permission Information";
63
+
64
+ /**
65
+ * 1. get all users from this tenant
66
+ * @param resetpage after reload, will it reset user interface or remain as current
67
+ */
68
+ const refreshList = async (resetpage: boolean = true) => {
69
+ const items: any[] = [];
70
+ const searchbody: SearchBody = {fields:['uid','email','created','fullname','active']}
71
+ userlist.value = await userdoc.search(searchbody);
72
+ //listUser();
73
+ // userlist.value = _.uniqBy(permlist.value, "uid");
74
+ if (resetpage) {
75
+ selected.value = "";
76
+ activeuser.value = "";
77
+ }
78
+ blockscreen.value = false;
79
+ // console.log("userlist", userlist.value);
80
+ };
81
+
82
+ /**
83
+ * 2. select specific user
84
+ * - get list of
85
+ * a. orglist
86
+ * b. branch list
87
+ * c. permission for that user
88
+ * - render organization and branch ui
89
+ * @param user
90
+ */
91
+ const onSelectUser = async (menuitem: any) => {
92
+ const user: UserListItem = { ...menuitem };
93
+ const orgsearchbody: SearchBody = {fields:['orgId','orgCode','orgName','active']}
94
+ const branchsearchbody: SearchBody = {fields:['orgId','branchId','branchCode','branchName','active']}
95
+ const permsearchbody: SearchBody = {
96
+ filter:{$or: [{ uid: user.uid }, { user_id: user._id }],},
97
+ fields:['uid','branchId','tenantId','orgId','active','group','created']
98
+ }
99
+
100
+ orglist.value = await orgdoc.search(orgsearchbody);
101
+ branchlist.value = await branchdoc.search(branchsearchbody);
102
+ permlist.value = await permdoc.search(permsearchbody);
103
+ userdoc.getById(menuitem._id);
104
+ // console.log("orglist.value", orglist.value);
105
+ // console.log("branchlist.value", branchlist.value);
106
+ // console.log("permlist.value", permlist.value);
107
+ selected.value = String(user._id);
108
+
109
+ activeuser.value = user.fullName;
110
+ //sso id from keycloak
111
+ const uid = String(user.uid);
112
+ //_id from mongodb
113
+ const user_id = String(user._id);
114
+ currentpermissions.value = [];
115
+
116
+ for (let i = 0; i < branchlist.value.length; i++) {
117
+ const b = branchlist.value[i];
118
+ const permdata = getPermssionData(uid, b.branchId);
119
+ const tmp: Permission = {
120
+ _id: permdata?._id,
121
+ uid: uid,
122
+ user_id: user_id,
123
+ tenantId: b.tenantId,
124
+ orgId: b.orgId,
125
+ branchId: b.branchId,
126
+ group: permdata.group,
127
+ };
128
+ currentpermissions.value.push(tmp);
129
+ }
130
+ blockscreen.value = false;
131
+ };
132
+
133
+ /**
134
+ * prepare dataobj (existing or empty dummy data) for each branch permission
135
+ * @param uid
136
+ * @param branchId
137
+ */
138
+ const getPermssionData = (uid: string, branchId: number) => {
139
+ const result = permlist.value.find(
140
+ (el) => el.uid == uid && el.branchId == branchId,
141
+ );
142
+ let pm: Permission = {
143
+ _id: result?._id ?? "",
144
+ orgId: result?.orgId ?? 0,
145
+ tenantId: result?.tenantId ?? 0,
146
+ branchId: branchId,
147
+ uid: uid,
148
+ group: result?.group ?? "",
149
+ };
150
+ return pm;
151
+ };
152
+
153
+ /**
154
+ * identity branch object under org
155
+ * @param org object of org
156
+ * @param branch object of branch
157
+ */
158
+ const checkBranchInOrg = (org: OrgListItem, branch: BranchListItem) => {
159
+ return org.orgId === branch.orgId;
160
+ };
161
+
162
+ /**
163
+ * generate dialog for view each user group have what permission
164
+ */
165
+ const previewPermission = () => {
166
+ showpermissioninfo.value = true;
167
+ };
168
+
169
+ /***** send or remove invitation ******/
170
+ const saveUser = async () => {
171
+ await userdoc.update();
172
+ refreshList(false);
173
+ };
174
+ const invite = async () => {
175
+ // const invitedata:User = {}
176
+ const currentuser = getUserProfile();
177
+ const inviteuserdoc = $UserDoc();
178
+ inviteuserdoc.setNew();
179
+ const newuserdata = inviteuserdoc.getReactiveData();
180
+ newuserdata.value.email = inviteemail.value;
181
+ newuserdata.value.fullname = inviteemail.value.split("@")[0];
182
+ newuserdata.value.active = true;
183
+ newuserdata.value.tenantId = currentuser.tenantId;
184
+ newuserdata.value.orgId = currentuser.orgId;
185
+ newuserdata.value.branchId = currentuser.branchId;
186
+
187
+ const invitedata = await inviteuserdoc.create();
188
+ inviteemail.value = "";
189
+ await refreshList();
190
+ onSelectUser(invitedata);
191
+ };
192
+
193
+ /**
194
+ * delete user
195
+ * @param user:User object
196
+ */
197
+ const deleteUser = async (user: any) => {
198
+ await userdoc.delete(String(user._id));
199
+ refreshList();
200
+ };
201
+
202
+ /**********applPermission ******/
203
+ /**
204
+ * apply permission:
205
+ * _id:'', group:'' => skip
206
+ * _id: '', group:'something' => create
207
+ * _id:'something', 'group':'something' => update
208
+ * _id:'something', group:'' => remove
209
+ */
210
+ const applPermission = async (d: Permission) => {
211
+ let result;
212
+ blockscreen.value = true;
213
+ d._id = String(d._id ?? "");
214
+ d.group = String(d.group ?? "");
215
+ const data = permdoc.getReactiveData();
216
+ data.value = d;
217
+ // console.log("apply permission", data.value);
218
+ if (!d._id && !d.group) {
219
+ //no changes
220
+ } else if (!d._id && d.group) {
221
+ result = await permdoc.create();
222
+ } else if (d._id && d.group) {
223
+ data.value = d;
224
+ result = await permdoc.update();
225
+ } else if (d._id && !d.group) {
226
+ d.group = "";
227
+ data.value = d;
228
+ result = await permdoc.delete(d._id);
229
+ } else {
230
+ console.warn("unknown apply permission", result);
231
+ }
232
+ refreshList(false);
233
+ blockscreen.value = false;
234
+ };
235
+ //init ui
236
+ onMounted(() => {
237
+ refreshList();
238
+ });
239
+ </script>
240
+ <template>
241
+ <button
242
+ @click="refreshList()"
243
+ v-if="useRuntimeConfig().public.DEBUGDATA"
244
+ class="pi pi-refresh"
245
+ ></button>
246
+ <Dialog
247
+ v-model:visible="showpermissioninfo"
248
+ modal
249
+ :header="permissiontitle"
250
+ :autoZIndex="false"
251
+ :style="{ zIndex: 100, width: '80vw' }"
252
+ >
253
+ <PermissionInfo></PermissionInfo>
254
+ </Dialog>
255
+
256
+ <div class="grid grid-cols-4">
257
+ <div v-if="userlist">
258
+ <TabView>
259
+ <TabPanel header="Active">
260
+ <Menu
261
+ :model="userlist"
262
+ class="w w-auto border border-solid border-1"
263
+ :pt="{ root: { class: 'w-auto ' } }"
264
+ >
265
+ <template #start>
266
+ <div class="flex flex-column align">
267
+ <h1>Users</h1>
268
+ </div>
269
+ </template>
270
+ <template #item="{ item, label, props }">
271
+ <a
272
+ v-if="item.uid && item.active"
273
+ class="flex m-2 p-2 flex-row border border-b-2 cursor cursor-pointer"
274
+ @click="onSelectUser(item)"
275
+ >
276
+ <div class="flex-col basis-5/6">
277
+ <div class="text text-left text-base text-black">
278
+ {{ item.fullname }}
279
+ </div>
280
+ <div class="text text-sm text-right">{{ item.email }}</div>
281
+ </div>
282
+ <div class="basis-1/6 m-2">
283
+ <!-- only debug mode can delete user -->
284
+ <button
285
+ v-if="useRuntimeConfig().public.DEBUGDATA"
286
+ class="pi pi-times btn-danger"
287
+ @click="deleteUser(item)"
288
+ ></button>
289
+ </div>
290
+ </a>
291
+ </template>
292
+ </Menu>
293
+ </TabPanel>
294
+ <TabPanel header="Inactive">
295
+ <Menu
296
+ :model="userlist"
297
+ class="w w-auto border border-solid border-1"
298
+ :pt="{ root: { class: 'w-auto ' } }"
299
+ >
300
+ <template #start>
301
+ <div class="flex flex-column align">
302
+ <h1>Users</h1>
303
+ </div>
304
+ </template>
305
+ <template #item="{ item, label, props }">
306
+ <a
307
+ v-if="item.uid && !item.active"
308
+ class="flex m-2 p-2 flex-row border border-b-2 cursor cursor-pointer"
309
+ @click="onSelectUser(item)"
310
+ >
311
+ <div class="flex-col basis-5/6">
312
+ <div class="text text-left text-base text-black">
313
+ {{ item.fullname }}
314
+ </div>
315
+ <div class="text text-sm text-right">{{ item.email }}</div>
316
+ </div>
317
+ <div class="basis-1/6 m-2">
318
+ <!-- only debug mode can delete user -->
319
+ <button
320
+ v-if="useRuntimeConfig().public.DEBUGDATA"
321
+ class="pi pi-times btn-danger"
322
+ @click="deleteUser(item)"
323
+ ></button>
324
+ </div>
325
+ </a>
326
+ </template>
327
+ </Menu>
328
+ </TabPanel>
329
+ <TabPanel header="Invite">
330
+ <div class="padding p-2">
331
+ <form @submit.prevent="true" class="w-full">
332
+ <div class="p-inputgroup flex-1">
333
+ <InputText
334
+ type="email"
335
+ placeholder="email"
336
+ v-model="inviteemail"
337
+ />
338
+ <button label="Search" class="btn btn-primary" @click="invite">
339
+ Invite
340
+ </button>
341
+ </div>
342
+ </form>
343
+ </div>
344
+ <Menu
345
+ :model="userlist"
346
+ class="w w-auto border border-solid border-1"
347
+ :pt="{ root: { class: 'w-auto ' } }"
348
+ >
349
+ <template #start>
350
+ <div class="flex flex-column align">
351
+ <h1>Users</h1>
352
+ </div>
353
+ </template>
354
+ <template #item="{ item, label, props }">
355
+ <a
356
+ v-if="item.uid == ''"
357
+ class="flex m-2 p-2 flex-row border border-b-2 cursor cursor-pointer"
358
+ @click="onSelectUser(item)"
359
+ >
360
+ <div class="flex-col basis-5/6">
361
+ <div class="text text-left text-base text-black">
362
+ {{ item.fullname }}
363
+ </div>
364
+ <div class="text text-sm text-right">{{ item.email }}</div>
365
+ </div>
366
+ <div class="basis-1/6 m-2">
367
+ <button
368
+ class="pi pi-times btn-danger"
369
+ @click="deleteUser(item)"
370
+ ></button>
371
+ </div>
372
+ </a>
373
+ </template>
374
+ </Menu>
375
+ </TabPanel>
376
+ </TabView>
377
+ </div>
378
+ <div class="col-span-3" v-if="selected">
379
+ <Panel
380
+ :pt="{ content: { class: 'bg-sky-50' } }"
381
+ class="m-2"
382
+ :header="usertitle"
383
+ >
384
+ <SimpleAppForm :document="userdoc" #default="o">
385
+ <div class="grid grid-cols-4 gap-4 p">
386
+ <SimpleAppText
387
+ autofocus
388
+ :setting="o.getField('#/properties/fullname')"
389
+ v-model="userdata.fullname"
390
+ />
391
+
392
+ <SimpleAppText
393
+ autofocus
394
+ type="string"
395
+ :setting="o.getField('#/properties/email')"
396
+ v-model="userdata.email"
397
+ />
398
+
399
+ <SimpleAppCheckbox
400
+ autofocus
401
+ :setting="o.getField('#/properties/active')"
402
+ v-model="userdata.active"
403
+ />
404
+ <div>
405
+ <Button @click="saveUser" class="btn-primary pi pi-save"></Button>
406
+ </div>
407
+ </div>
408
+ </SimpleAppForm>
409
+ </Panel>
410
+
411
+ <Panel
412
+ :pt="{ content: { class: 'bg-sky-50' } }"
413
+ class="m-2"
414
+ :header="permissiontitle"
415
+ >
416
+ <BlockUI :blocked="blockscreen">
417
+ <div class="text-right m mr-2">
418
+ <button
419
+ class="btn-primary pi pi-question"
420
+ @click="previewPermission"
421
+ ></button>
422
+ </div>
423
+
424
+ <div class="grid grid-cols-2">
425
+ <Card v-for="o in orglist" class="m-2">
426
+ <template #title>{{ o.orgName }}</template>
427
+ <template #content>
428
+
429
+ <table class="w w-full">
430
+ <thead class="">
431
+ <tr>
432
+ <th>Branch Code</th>
433
+ <th>Access Right</th>
434
+ </tr>
435
+ </thead>
436
+ <tr v-for="(b, index) in branchlist">
437
+ <td v-if="checkBranchInOrg(o, b)">{{ b.branchCode }}</td>
438
+ <td v-if="checkBranchInOrg(o, b)" clas="flex flex-row">
439
+ <div>
440
+ <SelectButton
441
+ :pt="{
442
+ button: {
443
+ class: 'text-xs border border-1 bg-sky-primary',
444
+ },
445
+ }"
446
+ v-model="currentpermissions[index].group"
447
+ :options="grouplist"
448
+ option-label="label"
449
+ option-value="value"
450
+ @change="applPermission(currentpermissions[index])"
451
+ ></SelectButton>
452
+ </div>
453
+ </td>
454
+ </tr>
455
+ </table>
456
+ </template>
457
+ </Card>
458
+ </div>
459
+ </BlockUI>
460
+ </Panel>
461
+ </div>
462
+ </div>
463
+ </template>
464
+ <style scoped>
465
+ td {
466
+ text-align: center;
467
+ }
468
+ </style>
@@ -0,0 +1,191 @@
1
+ <script lang="ts" setup>
2
+ /**
3
+ * This file was automatically generated by simpleapp generator during initialization.
4
+ * You may modify it for your need
5
+ * last change 2023-09-09
6
+ * author: Ks Tan
7
+ */
8
+ import _ from "lodash";
9
+ import InputText from "primevue/inputtext";
10
+ import Dialog from "primevue/dialog";
11
+ import { ref, Ref } from "vue";
12
+ import { SimpleAppEventType } from "../simpleapp/generate/commons/events";
13
+ import { TenantDoc } from "../simpleapp/docs/TenantDoc";
14
+ import ProgressSpinner from 'primevue/progressspinner';
15
+ import Panel from "primevue/panel";
16
+ import Card from "primevue/card";
17
+ import { AxiosResponse } from "axios";
18
+
19
+ const { $event, $listen, $userstore } = useNuxtApp();
20
+ const errCreateTenant = ref();
21
+ const branches = ref([]);
22
+ const data = ref();
23
+ const visible = ref(false);
24
+ const userprofile = ref();
25
+ const createtitle = ref("Create My Company");
26
+ const orgList = ref();
27
+ const onhold = ref(false)
28
+ const loadProfile = async () => {
29
+ await reloadUserStore();
30
+ userprofile.value = getUserProfile();
31
+ console.log("useprofile", userprofile.value);
32
+ data.value = {
33
+ tenantName: "",
34
+ };
35
+
36
+ branches.value = userprofile.value.branches;
37
+
38
+ orgList.value = _.uniqBy(branches.value, "branch.orgId").map((item) => ({
39
+ orgId: item.branch.orgId,
40
+ orgName: item.branch.organization.label,
41
+ }));
42
+ //.map((item)=>{return {orgId: item.organization.orgId,orgName:item.organization.Name}})
43
+ console.log("user info.value", branches.value);
44
+ console.log("org list .value", orgList.value);
45
+ };
46
+
47
+ $listen(SimpleAppEventType.InvitationAccepted, async () => {
48
+ loadProfile();
49
+ });
50
+
51
+ onMounted(() => {
52
+ loadProfile();
53
+ });
54
+
55
+ const createTenant = async () => {
56
+
57
+ onhold.value=true
58
+ const { $axios, $listen } = useNuxtApp();
59
+
60
+ const openapi = getApi();
61
+ const apipath = `${useRuntimeConfig().public.API_URL}`;
62
+ let profileapi = new openapi.PROFILEApi(undefined, apipath, $axios);
63
+
64
+ profileapi
65
+ .createTenant(data.value)
66
+ .then((res) => {
67
+ if (res && res.status && res.status == 201) {
68
+ if (res.data && res.data["xOrg"]) {
69
+ const xorg = res.data["xOrg"];
70
+ navigateTo("/" + xorg, { external: true });
71
+ }
72
+ }
73
+
74
+ })
75
+ .catch((err) => {
76
+ errCreateTenant.value = err["message"];
77
+ console.error("errCreateTenant", err);
78
+
79
+ }).finally(()=>{
80
+ onhold.value=false
81
+ });
82
+ };
83
+ </script>
84
+ <template>
85
+ <div class="grid grid-cols-2">
86
+ <DebugDocumentData v-model="userprofile" label="User"></DebugDocumentData>
87
+ <Panel header="Create New Tenant">
88
+ <div>
89
+ <h1>Create new one?</h1>
90
+ <DebugDocumentData
91
+ v-model="data"
92
+ label="CreateTenant"
93
+ ></DebugDocumentData>
94
+ <button class="btn-primary" @click="visible = true">
95
+ Create My Company
96
+ </button>
97
+
98
+ <Dialog
99
+ v-model:visible="visible"
100
+ modal
101
+ :header="createtitle"
102
+ class="crudsimple-dialog"
103
+ >
104
+ <form @submit.prevent="true" class="flex flex-col text-center">
105
+
106
+ <div v-if="errCreateTenant" class="text-error">
107
+ {{ errCreateTenant }}
108
+ </div>
109
+ <ProgressSpinner v-if="onhold"></ProgressSpinner>
110
+ <InputText v-else
111
+ type="text"
112
+ autofocus="true"
113
+ v-model:model-value="data.tenantName"
114
+ placeholder="Organization Name"
115
+ />
116
+
117
+ <button class="btn-primary" type="submit" @click="createTenant">
118
+ Create
119
+ </button>
120
+ </form>
121
+ </Dialog>
122
+ </div>
123
+ </Panel>
124
+ <Panel header="Reserved">
125
+ <div>
126
+ <h1>reserved fuction</h1>
127
+ </div>
128
+ </Panel>
129
+ <Panel>
130
+ <template #header>
131
+ <div class="flex flex-row">
132
+ <div class="font font-bold">Login To</div>
133
+ <button
134
+ class="pi pi-refresh ml-4"
135
+ @click="loadProfile"
136
+ v-if="useRuntimeConfig().public.DEBUGDATA"
137
+ ></button>
138
+ </div>
139
+ </template>
140
+ <div class="grid grid-cols-2">
141
+ <Card v-for="org in orgList" class="m-2">
142
+ <template #header>
143
+ <div class="font font-bold ml-4">{{ org.orgName }}</div>
144
+ </template>
145
+ <template #content>
146
+ <div v-for="item in branches" class="hover-list-primary">
147
+ <NuxtLink
148
+ v-if="org.orgId == item.branch.orgId"
149
+ :external="true"
150
+ :to="item.xOrg"
151
+ class="tenant-link"
152
+ >
153
+ <div
154
+ class="grid grid-cols-2 p-2 align-items-center gap-0 w-full"
155
+ >
156
+ <div class="">
157
+ <p>
158
+ <span class="font font-semibold">{{
159
+ item.branch.branchName
160
+ }}</span
161
+ ><span class="ml-2 text text-gray-500">
162
+ {{ item.group }}</span
163
+ >
164
+ </p>
165
+ <span class="text-xs italic"
166
+ >{{ useRuntimeConfig().public.APP_URL }}/{{
167
+ item.xOrg
168
+ }}</span
169
+ >
170
+ </div>
171
+ <div class="font-bold text-900">
172
+ {{ item.branch.branchCode }}
173
+ </div>
174
+ </div>
175
+ </NuxtLink>
176
+ </div>
177
+ </template>
178
+ </Card>
179
+ </div>
180
+ </Panel>
181
+ </div>
182
+ </template>
183
+
184
+ <style scoped>
185
+ .p-panel {
186
+ @apply m-2;
187
+ }
188
+ /* .tenant-link:hover div {
189
+ @apply bg-gray-300;
190
+ } */
191
+ </style>
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <NuxtPage />
3
+ </template>
4
+ <script setup lang="ts">
5
+ definePageMeta({
6
+ name: "Login",
7
+ auth: false,
8
+ });
9
+
10
+ // const route = useRoute();
11
+ const { signIn } = useAuth();
12
+ onMounted(async () => {
13
+ // logout();
14
+ let callbackUrl = "/";
15
+ // console.log("redirect to login");
16
+ // if(route.params.redirect) {
17
+ // callbackUrl = <string>route.params.redirect;
18
+ // }
19
+ await signIn("keycloak", { callbackUrl: callbackUrl });
20
+ });
21
+ </script>