@simitgroup/simpleapp-generator 1.0.59 → 1.0.60

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 (96) hide show
  1. package/dist/buildinschemas/branch.d.ts.map +1 -1
  2. package/dist/buildinschemas/branch.js +1 -0
  3. package/dist/buildinschemas/branch.js.map +1 -1
  4. package/dist/buildinschemas/organization.d.ts.map +1 -1
  5. package/dist/buildinschemas/organization.js +1 -0
  6. package/dist/buildinschemas/organization.js.map +1 -1
  7. package/dist/buildinschemas/permission.js +1 -1
  8. package/dist/buildinschemas/permission.js.map +1 -1
  9. package/dist/buildinschemas/user.d.ts.map +1 -1
  10. package/dist/buildinschemas/user.js +4 -1
  11. package/dist/buildinschemas/user.js.map +1 -1
  12. package/dist/framework.js +1 -1
  13. package/dist/framework.js.map +1 -1
  14. package/dist/generate.js +6 -1
  15. package/dist/generate.js.map +1 -1
  16. package/dist/type.d.ts +1 -0
  17. package/dist/type.d.ts.map +1 -1
  18. package/docs/jsonschema.md +1 -0
  19. package/package.json +1 -1
  20. package/src/buildinschemas/branch.ts +1 -0
  21. package/src/buildinschemas/organization.ts +1 -0
  22. package/src/buildinschemas/permission.ts +1 -1
  23. package/src/buildinschemas/user.ts +4 -1
  24. package/src/framework.ts +1 -1
  25. package/src/generate.ts +6 -1
  26. package/src/type.ts +1 -0
  27. package/templates/basic/nest/controller.ts.eta +5 -3
  28. package/templates/basic/nest/model.ts.eta +32 -7
  29. package/templates/basic/nuxt/pages.crud.vue.eta +59 -163
  30. package/templates/basic/nuxt/pages.index.vue.eta +225 -0
  31. package/templates/nest/.env._eta +1 -0
  32. package/templates/nest/src/simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter.ts.eta +1 -1
  33. package/templates/nest/src/simpleapp/generate/commons/roles/roles.group.ts.eta +1 -1
  34. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +127 -22
  35. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +1 -1
  36. package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +25 -2
  37. package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +20 -2
  38. package/templates/nest/src/simpleapp/services/branch.service.ts.eta +41 -40
  39. package/templates/nest/src/simpleapp/services/user.service.ts.eta +10 -9
  40. package/templates/nuxt/app.vue.eta +2 -1
  41. package/templates/nuxt/assets/css/style.css._eta +3 -12
  42. package/templates/nuxt/assets/primevue/passthrough.ts._eta +24 -20
  43. package/templates/nuxt/components/ButtonCreateTenant.vue.eta +30 -23
  44. package/templates/nuxt/components/ButtonHome.vue.eta +15 -2
  45. package/templates/nuxt/components/ButtonMenuPicker.vue.eta +5 -20
  46. package/templates/nuxt/components/ButtonPermissionInfo.vue.eta +5 -7
  47. package/templates/nuxt/components/ButtonProfile.vue.eta +42 -25
  48. package/templates/nuxt/components/CrudSimple.vue.eta +1 -1
  49. package/templates/nuxt/components/EventDecision.vue.eta +115 -0
  50. package/templates/nuxt/components/EventNotification.vue.eta +157 -0
  51. package/templates/nuxt/components/HeaderBar.vue.eta +2 -2
  52. package/templates/nuxt/components/Invitation.vue.eta +3 -3
  53. package/templates/nuxt/components/SelectBranch.vue.eta +5 -2
  54. package/templates/nuxt/components/SimpleAppDatatable.vue.eta +151 -5
  55. package/templates/nuxt/components/TenantPicker.vue.eta +75 -0
  56. package/templates/nuxt/components/UserProfileListItem.vue.eta +65 -0
  57. package/templates/nuxt/components/renderers/BooleanRender.vue.eta +7 -0
  58. package/templates/nuxt/components/renderers/DateRender.vue.eta +6 -0
  59. package/templates/nuxt/components/renderers/ForeignKeyRender.vue.eta +10 -0
  60. package/templates/nuxt/components/renderers/MoneyRender.vue.eta +7 -0
  61. package/templates/nuxt/components/renderers/MultiTextRender.vue.eta +11 -0
  62. package/templates/nuxt/composables/getDocument.generate.ts.eta +4 -0
  63. package/templates/nuxt/composables/getMenus.generate.ts.eta +35 -31
  64. package/templates/nuxt/composables/getUserStore.generate.ts.eta +6 -1
  65. package/templates/nuxt/composables/goTo.generate.ts.eta +15 -0
  66. package/templates/nuxt/composables/notifications.generate.ts.eta +21 -0
  67. package/templates/nuxt/composables/stringHelper.generate.ts.eta +11 -1
  68. package/templates/nuxt/error.vue._eta +20 -5
  69. package/templates/nuxt/layouts/documentlist.vue.eta +166 -0
  70. package/templates/nuxt/middleware/30.acl.global.ts.eta +4 -1
  71. package/templates/nuxt/pages/[xorg]/organization/index.vue.eta +4 -4
  72. package/templates/nuxt/pages/[xorg]/profile.vue.eta +6 -0
  73. package/templates/nuxt/pages/[xorg]/user/[id].vue.eta +6 -0
  74. package/templates/nuxt/pages/[xorg]/user/index.vue.eta +211 -377
  75. package/templates/nuxt/pages/[xorg]/user.vue.eta +197 -0
  76. package/templates/nuxt/pages/index.vue._eta +101 -0
  77. package/templates/nuxt/pages/profile.vue.eta +94 -0
  78. package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +4 -4
  79. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +11 -10
  80. package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +69 -17
  81. package/templates/nuxt/simpleapp/generate/commons/documents.ts.eta +6 -3
  82. package/templates/nuxt/tailwind.config.ts._eta +10 -0
  83. package/templates/nuxt/types/documentlist.ts.eta +9 -0
  84. package/templates/nuxt/types/events.ts.eta +20 -0
  85. package/templates/nuxt/types/index.ts.eta +6 -79
  86. package/templates/nuxt/types/notifications.ts.eta +16 -0
  87. package/templates/nuxt/types/others.ts.eta +42 -0
  88. package/templates/nuxt/types/user.ts.eta +44 -0
  89. package/tsconfig.tsbuildinfo +1 -1
  90. package/templates/nest/src/simpleapp/generate/models/perm.model.ts.eta +0 -52
  91. package/templates/nest/src/simpleapp/generate/models/tenant.model.ts.eta +0 -43
  92. package/templates/nest/src/simpleapp/generate/models/user.model.ts.eta +0 -56
  93. package/templates/nuxt/components/EventMonitor.vue.eta +0 -85
  94. package/templates/nuxt/pages/[xorg]/tenant/index.vue.eta +0 -89
  95. package/templates/nuxt/pages/index.vue.eta +0 -116
  96. package/templates/nuxt/simpleapp/generate/commons/events.ts.eta +0 -11
@@ -0,0 +1,197 @@
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 userchild from './userchild.vue'
9
+ import Menu from "primevue/menu";
10
+ import Dialog from "primevue/dialog";
11
+ import { SearchBody, EventType } from "~/types";
12
+ import _ from "lodash";
13
+ import Panel from "primevue/panel";
14
+ import { ref } from "vue";
15
+ import {
16
+ UserListItem,
17
+ BranchListItem,
18
+ OrgListItem,
19
+ PermissionListItem,
20
+ } from "~/types";
21
+ import SelectButton from "primevue/selectbutton";
22
+ import Button from "primevue/button";
23
+ import InputText from "primevue/inputtext";
24
+ import Card from "primevue/card";
25
+ import TabView from "primevue/tabview";
26
+ import TabPanel from "primevue/tabpanel";
27
+ import { Permission, User } from "~/simpleapp/generate/openapi/api";
28
+ import BlockUI from "primevue/blockui";
29
+
30
+ //initialize api
31
+ const {
32
+ $listen,
33
+ $PermissionDoc,
34
+ $OrganizationDoc,
35
+ $BranchDoc,
36
+ $UserDoc,
37
+ // $InvitationDoc,
38
+ } = useNuxtApp();
39
+
40
+ const permdoc = $PermissionDoc();
41
+ const orgdoc = $OrganizationDoc();
42
+ const branchdoc = $BranchDoc();
43
+ // const invitedoc = $InvitationDoc();
44
+ const userdoc = $UserDoc();
45
+ const userdata = userdoc.getReactiveData();
46
+ //initialize require list in UI
47
+ const permlist = ref<PermissionListItem[]>([]);
48
+ const userlist = ref<UserListItem[]>([]);
49
+ const orglist = ref<OrgListItem[]>([]);
50
+ const branchlist = ref<BranchListItem[]>([]);
51
+ const currentpermissions = ref<Permission[]>([]);
52
+ const grouplist = getAllGroups().map((item) => {
53
+ return { value: item, label: _.capitalize(item) };
54
+ });
55
+
56
+ //initialize some runtime variable
57
+ const blockscreen = ref(false);
58
+ const inviteemail = ref("");
59
+ const selected = ref("");
60
+ const activeuser = ref("");
61
+ const showpermissioninfo = ref(false);
62
+ const permissionselected = ref();
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 = {
71
+ fields: [
72
+ "uid",
73
+ "email",
74
+ "created",
75
+ "fullname",
76
+ "active",
77
+ "lastActivity",
78
+ "description",
79
+ ],
80
+ };
81
+ userlist.value = await userdoc.search(searchbody);
82
+ //listUser();
83
+ // userlist.value = _.uniqBy(permlist.value, "uid");
84
+ if (resetpage) {
85
+ selected.value = "";
86
+ activeuser.value = "";
87
+ }
88
+ blockscreen.value = false;
89
+ // console.log("userlist", userlist.value);
90
+ };
91
+
92
+ /**
93
+ * identity branch object under org
94
+ * @param org object of org
95
+ * @param branch object of branch
96
+ */
97
+
98
+ /**
99
+ * generate dialog for view each user group have what permission
100
+ */
101
+ const previewPermission = () => {
102
+ showpermissioninfo.value = true;
103
+ };
104
+
105
+ /***** send or remove invitation ******/
106
+
107
+ const invite = async () => {
108
+ // const invitedata:User = {}
109
+ const currentuser = getUserProfile();
110
+ const inviteuserdoc = $UserDoc();
111
+ inviteuserdoc.setNew();
112
+ const newuserdata = inviteuserdoc.getReactiveData();
113
+ newuserdata.value.email = inviteemail.value;
114
+ newuserdata.value.fullname = inviteemail.value.split("@")[0];
115
+ newuserdata.value.active = true;
116
+ newuserdata.value.tenantId = currentuser.tenantId;
117
+ newuserdata.value.orgId = currentuser.orgId;
118
+ newuserdata.value.branchId = currentuser.branchId;
119
+
120
+ const invitedata = await inviteuserdoc.create();
121
+ inviteemail.value = "";
122
+ await refreshList();
123
+ // onSelectUser(invitedata);
124
+ };
125
+
126
+ $listen("RefreshUser", () => {
127
+ refreshList();
128
+ });
129
+ onMounted(() => {
130
+ refreshList();
131
+ });
132
+ </script>
133
+ <template>
134
+ <div class="grid grid-cols-4">
135
+ <div v-if="userlist" class="m-2 p-2 border-r-2">
136
+ <TabView>
137
+ <TabPanel header="Active">
138
+ <ul role="list" class="divide-y divide-gray-100">
139
+ <li v-for="item in userlist" :key="item.email">
140
+ <NuxtLink
141
+ v-if="item.uid && item.active"
142
+ :to="`${getPageBaseUrl('user')}/${item._id}`"
143
+ >
144
+ <UserProfileListItem :data="item"></UserProfileListItem>
145
+ </NuxtLink>
146
+ </li>
147
+ </ul>
148
+ </TabPanel>
149
+ <TabPanel header="Inactive">
150
+ <ul role="list" class="divide-y divide-gray-100">
151
+ <li v-for="item in userlist" :key="item.email">
152
+ <NuxtLink
153
+ v-if="item.uid && !item.active"
154
+ :to="`${getPageBaseUrl('user')}/${item._id}`"
155
+ >
156
+ <UserProfileListItem :data="item"></UserProfileListItem>
157
+ </NuxtLink>
158
+ </li>
159
+ </ul>
160
+ </TabPanel>
161
+ <TabPanel header="Invite">
162
+ <div class="padding p-2">
163
+ <form @submit.prevent="true" class="w-full">
164
+ <div class="p-inputgroup flex-1">
165
+ <InputText
166
+ type="email"
167
+ placeholder="email"
168
+ v-model="inviteemail"
169
+ />
170
+ <Button
171
+ label="Search"
172
+ class="hover:bg-primary-400 bg-primary-600 text-white"
173
+ @click="invite"
174
+ >
175
+ Invite
176
+ </Button>
177
+ </div>
178
+ </form>
179
+ </div>
180
+ <ul role="list" class="divide-y divide-gray-100">
181
+ <li v-for="item in userlist" :key="item.email">
182
+ <NuxtLink
183
+ v-if="!item.uid"
184
+ :to="`${getPageBaseUrl('user')}/${item._id}`"
185
+ >
186
+ <UserProfileListItem :data="item"></UserProfileListItem>
187
+ </NuxtLink>
188
+ </li>
189
+ </ul>
190
+ </TabPanel>
191
+ </TabView>
192
+ </div>
193
+ <div class="col-span-3 p-2">
194
+ <NuxtPage />
195
+ </div>
196
+ </div>
197
+ </template>
@@ -0,0 +1,101 @@
1
+ <script lang="ts" setup>
2
+ /**
3
+ * This file was automatically generated by simpleapp generator. Every
4
+ * MODIFICATION OVERRIDE BY GENERATEOR
5
+ * last change 2023-10-28
6
+ * Author: Ks Tan
7
+ */
8
+
9
+ import _ from "lodash";
10
+ // import InputText from "primevue/inputtext";
11
+ // import Dialog from "primevue/dialog";
12
+ import { ref, Ref } from "vue";
13
+ // import { EventType } from "~/types";
14
+ // import { TenantDoc } from "../simpleapp/docs/TenantDoc";
15
+ // import ProgressSpinner from "primevue/progressspinner";
16
+ // import Panel from "primevue/panel";
17
+ // import Card from "primevue/card";
18
+ // import { AxiosResponse } from "axios";
19
+ import {computed} from 'vue'
20
+ const { $event, $listen, $userstore } = useNuxtApp();
21
+ const branches = ref([]);
22
+ const userprofile = ref();
23
+ const orgList = ref();
24
+ const alltenants = ref()
25
+
26
+ const loadTenants = async () => {
27
+ const profileapi = getApi().PROFILEApi;
28
+ const axiosreturn = await new profileapi(
29
+ undefined,
30
+ useRuntimeConfig().public.API_URL,
31
+ ).getAllTenants();
32
+ alltenants.value = axiosreturn.data
33
+ };
34
+
35
+ // $listen("InvitationAccepted", async () => {
36
+ // loadProfile();
37
+ // });
38
+
39
+ onMounted(() => {
40
+ loadTenants();
41
+
42
+ // const profileapi = getApi().PROFILEApi;
43
+ });
44
+ </script>
45
+ <template>
46
+ <div
47
+ class="mx-4 md:mx-12 py-8 md:py-12 grid place-content-center px-4 md:px-0"
48
+ >
49
+ <div class="lg:flex justify-start lg:gap-28">
50
+ <div class="">
51
+ <h1 class="font-bold text-5xl text-gray-800 dark:text-white">
52
+ Welcome To SimpleApp
53
+ </h1>
54
+ <p class="pt-8 md:pt-4 text-gray-600 dark:text-gray-200">
55
+ It is product front page and by right you shall replace it with
56
+ something else.
57
+ </p>
58
+ <div class="mt-8 md:flex justify-start md:gap-4">
59
+ <ButtonCreateTenant></ButtonCreateTenant>
60
+ </div>
61
+ </div>
62
+ <div class="pt-8 lg:pt-0">
63
+ <svg
64
+ fill="#000000"
65
+ viewBox="0 0 512 512"
66
+ xmlns="http://www.w3.org/2000/svg"
67
+ >
68
+ <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
69
+ <g
70
+ id="SVGRepo_tracerCarrier"
71
+ stroke-linecap="round"
72
+ stroke-linejoin="round"
73
+ ></g>
74
+ <g id="SVGRepo_iconCarrier">
75
+ <g id="Anonymous">
76
+ <path
77
+ d="M475.3571,413.24a69.9,69.9,0,0,0-39.8845-57.4407l-39.9287-18.7987,21.5791-44.5621a89.4527,89.4527,0,0,0,.0025-77.9684L359.7988,96.0682C317.7933,9.3105,194.2088,9.31,152.2019,96.0666L94.87,214.4745a89.445,89.445,0,0,0,.0049,77.9692l21.581,44.5569L76.5256,355.8a69.898,69.898,0,0,0-39.8831,57.439l-3.612,43.3773a22.5157,22.5157,0,0,0,22.4381,24.3842H456.5337A22.5134,22.5134,0,0,0,478.97,456.6187ZM364,260.1205a107.9746,107.9746,0,0,1-98.1035,107.5V341.1249a9.8965,9.8965,0,0,0-19.793,0v26.4957A107.9746,107.9746,0,0,1,148,260.1205V203.44a28.8192,28.8192,0,0,1,28.8193-28.8193H335.1806A28.8193,28.8193,0,0,1,364,203.44Z"
78
+ ></path>
79
+ <path
80
+ d="M321.8213,275.9979a9.91,9.91,0,0,0-12.3135,6.6709,13.5776,13.5776,0,0,1-26.0156,0,9.9026,9.9026,0,1,0-18.9844,5.6426,33.3877,33.3877,0,0,0,63.9844,0A9.9125,9.9125,0,0,0,321.8213,275.9979Z"
81
+ ></path>
82
+ <path
83
+ d="M240.8213,275.9979a9.8908,9.8908,0,0,0-12.3135,6.6709,13.5776,13.5776,0,0,1-26.0156,0,9.9026,9.9026,0,1,0-18.9844,5.6426,33.3877,33.3877,0,0,0,63.9844,0A9.9125,9.9125,0,0,0,240.8213,275.9979Z"
84
+ ></path>
85
+ <path
86
+ d="M319,227.4384H283a9.8965,9.8965,0,1,0,0,19.7929h36a9.8965,9.8965,0,1,0,0-19.7929Z"
87
+ ></path>
88
+ <path
89
+ d="M193,247.2313h36a9.8965,9.8965,0,1,0,0-19.7929H193a9.8965,9.8965,0,1,0,0,19.7929Z"
90
+ ></path>
91
+ </g>
92
+ </g>
93
+ </svg>
94
+ <p class="text-gray-500">Real man code with simpleapp</p>
95
+ </div>
96
+ </div>
97
+ <div class="grid grid-cols-2">
98
+ <TenantPicker v-for="tenant in alltenants" :tenant="tenant" class="col col-span-1"></TenantPicker>
99
+ </div>
100
+ </div>
101
+ </template>
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <div class="p-4">
3
+ <div class="px-4 sm:px-0">
4
+ <h3 class="text-base font-semibold leading-7 text-gray-900">
5
+ User Information
6
+ </h3>
7
+ </div>
8
+ <div class="mt-6 border-t border-gray-100">
9
+ <dl class="divide-y divide-gray-100">
10
+ <div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
11
+ <dt class="text-sm font-medium leading-6 text-gray-900">Full name</dt>
12
+ <dd
13
+ class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0"
14
+ >
15
+ {{ getUserProfile().fullName }}
16
+ </dd>
17
+ </div>
18
+ <div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
19
+ <dt class="text-sm font-medium leading-6 text-gray-900">Group</dt>
20
+ <dd
21
+ class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0"
22
+ >
23
+ {{ getUserProfile().group }}
24
+ </dd>
25
+ </div>
26
+ <div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
27
+ <dt class="text-sm font-medium leading-6 text-gray-900">
28
+ Email address
29
+ </dt>
30
+ <dd
31
+ class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0"
32
+ >
33
+ {{ getUserProfile().email }}
34
+ </dd>
35
+ </div>
36
+
37
+ <div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
38
+ <dt class="text-sm font-medium leading-6 text-gray-900">
39
+ Branch Access
40
+ </dt>
41
+ <dd class="mt-2 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
42
+ <ul
43
+ role="list"
44
+ class="divide-y divide-gray-100 rounded-md border border-gray-200"
45
+ >
46
+ <li
47
+ class="flex items-center justify-between py-4 pl-4 pr-5 text-sm leading-6"
48
+ v-for="b in getUserProfile().branches"
49
+ >
50
+ <NuxtLink :href="`/${b.xOrg}`" :external="true">
51
+ <div class="flex w-0 flex-1 items-center">
52
+ <i class="pi pi-sitemap"></i>
53
+ <div class="ml-4 flex min-w-0 flex-1 gap-2">
54
+ <span class="truncate font-medium">
55
+ {{ b.branch.branchName }}
56
+ </span>
57
+ <span class="flex-shrink-0 text-gray-400">{{
58
+ b.branch.branchCode
59
+ }}</span>
60
+ </div>
61
+ </div>
62
+ <div class="ml-4 flex-shrink-0">
63
+ <p
64
+ href="#"
65
+ class="font-medium text-indigo-600 hover:text-indigo-500"
66
+ >
67
+ {{ b.group }}
68
+ </p>
69
+ </div>
70
+ </NuxtLink>
71
+ </li>
72
+ </ul>
73
+ </dd>
74
+ </div>
75
+
76
+ <div
77
+ v-if="useRuntimeConfig().public.DEBUGDATA == '1'"
78
+ class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0 bg-warning-100"
79
+ >
80
+ <dt class="text-sm font-medium leading-6 text-gray-900">
81
+ Current Branch Access Rights
82
+ <p class="text-danger-600">only appear in debug mode</p>
83
+ <p class="text-danger-600">{{ getUserProfile().sessionId }}</p>
84
+ </dt>
85
+ <dd
86
+ class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0"
87
+ >
88
+ {{ getUserProfile().roles }}
89
+ </dd>
90
+ </div>
91
+ </dl>
92
+ </div>
93
+ </div>
94
+ </template>
@@ -6,13 +6,13 @@
6
6
  */
7
7
  import { defineNuxtPlugin } from "#app";
8
8
  import axios, { Axios, AxiosResponse } from 'axios'
9
+ import {Notification,EventType} from '~/types'
9
10
  // import PrimeVue from "primevue/config";
10
11
  import mitt from 'mitt'
11
12
  // import ToastService from 'primevue/toastservice';
12
13
  // import ConfirmationService from 'primevue/confirmationservice';
13
14
  // import Tooltip from 'primevue/tooltip';
14
- const emitter = mitt()
15
-
15
+ const emitter = mitt<EventType>()
16
16
  export default defineNuxtPlugin( async(nuxtApp) => {
17
17
  //const { csrf } = useCsrf()
18
18
  //axios.defaults.headers.common = {"CSRF-TOKEN": csrf};
@@ -32,7 +32,7 @@ export default defineNuxtPlugin( async(nuxtApp) => {
32
32
  createError({
33
33
  statusCode:error.response.status,
34
34
  statusMessage:error.response.message})
35
- // return Promise.reject(error)
35
+ return Promise.reject(error)
36
36
  }else{
37
37
  console.error("unknown error")
38
38
  createError({statusCode:500,statusMessage:"Internal server error"})
@@ -53,7 +53,7 @@ export default defineNuxtPlugin( async(nuxtApp) => {
53
53
  event: emitter.emit, // Will emit an event
54
54
  listen: emitter.on, // Will register a listener for an event
55
55
  axios: myaxios,
56
- }
56
+ }
57
57
  }
58
58
  //other components that you need
59
59
  });
@@ -15,6 +15,7 @@ export default defineNuxtPlugin( async(nuxtApp) => {
15
15
 
16
16
  const useUserStore = defineStore('userstore', {
17
17
  state: ()=>({
18
+ sessionId:ref(''),
18
19
  tenantId:ref(0),
19
20
  orgId:ref(0),
20
21
  branchId:ref(0),
@@ -34,21 +35,24 @@ export default defineNuxtPlugin( async(nuxtApp) => {
34
35
 
35
36
  actions:{
36
37
  async loadRemoteUserInfo(){
37
- console.log('loadRemoteUserInfo')
38
+ // console.log('loadRemoteUserInfo')
39
+
38
40
  const {$axios} = useNuxtApp()
39
41
  const route = useRoute();
40
- let xorg = route.params.xorg
42
+ let xorg = this.getCurrentXorg()
43
+
41
44
  let apiurl=''
42
45
  if(xorg===undefined){
43
46
  apiurl = `${useRuntimeConfig().public.APP_URL}/api`
44
47
  }else{
45
48
  apiurl = `${useRuntimeConfig().public.APP_URL}/api/${xorg}`
46
49
  }
47
-
50
+ console.log(apiurl)
48
51
  return await new PROFILEApi(undefined,apiurl,$axios).getProfile().then((res:AxiosResponse)=>{
49
52
  if(!res){
50
53
  return
51
54
  }
55
+ this.sessionId = res.data.sessionId
52
56
  this.tenantId = res.data.tenantId
53
57
  this.orgId = res.data.orgId
54
58
  this.branchId = res.data.branchId
@@ -80,13 +84,9 @@ export default defineNuxtPlugin( async(nuxtApp) => {
80
84
  return Promise.reject(errdata)
81
85
  }
82
86
  })
83
- },
84
- getAvatarLink(size:number){
85
- return `https://i.pravatar.cc/${size}`
86
- },
87
+ },
87
88
  getCurrentXorg(){
88
- const currentxorg:string = String(useRoute().params.xorg)
89
- return currentxorg //_.find(this.branches,{xorg:currentxorg})
89
+ return (useRoute().params.xorg) ? String(useRoute().params.xorg) : undefined
90
90
  },
91
91
  async decideInvitation(id:string,decision:string){
92
92
  const apiurl = `${useRuntimeConfig().public.APP_URL}/api`
@@ -136,6 +136,7 @@ export default defineNuxtPlugin( async(nuxtApp) => {
136
136
  },
137
137
  getUserInfo(){
138
138
  return {
139
+ sessionId : this.sessionId,
139
140
  tenantId : this.tenantId,
140
141
  orgId : this.orgId,
141
142
  branchId : this.branchId,
@@ -151,7 +152,7 @@ export default defineNuxtPlugin( async(nuxtApp) => {
151
152
  roles:this.roles,
152
153
  group:this.group,
153
154
  time:this.time,
154
- currentxorg: this.getCurrentXorg()
155
+
155
156
 
156
157
 
157
158
  }
@@ -10,7 +10,7 @@ import addErrors from 'ajv-errors';
10
10
  import { ref } from 'vue';
11
11
  import type { Ref } from 'vue';
12
12
  import type { AxiosResponse } from 'axios';
13
- import {SearchBody} from '~/types'
13
+ import {SearchBody,Notification,NotificationStatus} from '~/types'
14
14
  // import { useToast, } from 'primevue/usetoast';
15
15
  // import type { ToastMessageOptions } from 'primevue/toast';
16
16
  // const toast = useToast();
@@ -61,63 +61,115 @@ export class SimpleAppClient<
61
61
  async getById(id: string) {
62
62
  return await this.docapi.runFindOne(id,{timeout:this.defaultTimeOut})
63
63
  .then((res: AxiosResponse) => {
64
- if(this.event){this.event('info:getById',res.data)}
64
+ // if(this.event){this.event('info:getById',res.data)}
65
65
  Object.assign(this.data.value, res.data);
66
66
  return res;
67
67
  }).catch((res:any)=>{
68
- if(this.event){this.event('error:getById',res)}
68
+ // if(this.event){this.event('error:getById',res)}
69
69
  return Promise.reject(res)
70
70
  });
71
71
  }
72
+
72
73
  async create() {
73
74
  const errors = this.validateFailed();
75
+ const {$event} =useNuxtApp()
74
76
  if (errors) {
75
- if(this.event){this.event('error:create',errors)}
77
+ $event('Notification',{
78
+ documentName:this.getDocName(),
79
+ summary:'Record create failed',
80
+ status:NotificationStatus.error,
81
+ data:errors
82
+ })
83
+ // this.event('error:create',errors)
76
84
  return await Promise.reject(errors);
77
85
  } else {
78
86
  return await this.docapi
79
87
  .runCreate(this.data.value,{timeout:this.defaultTimeOut})
80
88
  .then((res: AxiosResponse) => {
81
- if(this.event){this.event('success:create',res.data);return res.data}
89
+ // if(this.event){this.event('success:create',res.data);return res.data}
90
+ // console.log(this.getDocName(), "ok")
91
+ $event('Notification',{
92
+ documentName:this.getDocName(),
93
+ summary:'Record create successfully',
94
+ status:NotificationStatus.success
95
+ })
82
96
  this.data.value = { ...res.data };
83
97
  return res;
84
- }).catch((errors:any)=>{
85
- if(this.event){
86
- this.event('error:create',errors.response.data.data)}
98
+ }).catch((errors:any)=>{
99
+ // console.log(this.getDocName(),"-----failed")
100
+ $event('Notification',{
101
+ documentName:this.getDocName(),
102
+ summary:'Record create failed',
103
+ status:NotificationStatus.error,
104
+ data:errors.response.data.data
105
+ })
87
106
  console.error('error:create',errors.response.data.data)
88
107
  return Promise.reject(errors)
89
108
  });
90
109
  }
91
110
  }
111
+
92
112
  async update() {
113
+ const {$event} =useNuxtApp()
93
114
  const recordid: string = this.data.value._id ?? '';
94
115
  const errors = this.validateFailed();
95
116
  if (errors) {
96
- if(this.event){this.event('error:update',errors)}
97
- console.error(errors)
117
+ // if(this.event){this.event('error:update',errors)}
118
+ $event('Notification',{
119
+ documentName:this.getDocName(),
120
+ summary:'Record update failed',
121
+ status:NotificationStatus.error,
122
+ data:errors
123
+ })
124
+ console.error('update errors',errors)
98
125
  return await Promise.reject(errors);
99
126
  } else {
100
127
  return await this.docapi
101
128
  .runUpdate(recordid, this.data.value,{timeout:this.defaultTimeOut})
102
129
  .then((res: AxiosResponse) => {
103
- if(this.event){this.event('success:update',res.data)}
130
+ // if(this.event){this.event('success:update',res.data)}
131
+ $event('Notification',{
132
+ documentName:this.getDocName(),
133
+ summary:'Record update success',
134
+ status:NotificationStatus.success,
135
+ data:errors
136
+ })
104
137
  return res.data;
105
138
  }).catch((errors:any)=>{
139
+ $event('Notification',{
140
+ documentName:this.getDocName(),
141
+ summary:'Record update failed',
142
+ status:NotificationStatus.error,
143
+ data:errors.response.data.data
144
+ })
106
145
  // console.error('error:update---',errors,",---",errors.message)
107
- if(this.event){
108
- this.event('error:update',errors.response.data.data)}
146
+ // if(this.event){
147
+ // this.event('error:update',errors.response.data.data)}
109
148
  console.error('error:update',errors.response.data.data)
110
149
  return Promise.reject(errors)
111
150
  });
112
151
  }
113
152
  }
114
153
  async delete(id: string) {
154
+ const {$event} =useNuxtApp()
115
155
  return await this.docapi.runDelete(id,{timeout:this.defaultTimeOut})
116
156
  .then((res:AxiosResponse)=>{
117
- if(this.event){this.event('success:delete',res.data)}
157
+ // if(this.event){this.event('success:delete',res.data)}
158
+ $event('Notification',{
159
+ documentName:this.getDocName(),
160
+ summary:'Record deleted successfully',
161
+ status:NotificationStatus.success,
162
+ data:res.data
163
+ })
118
164
  return Promise.resolve(res.data)
119
165
  }).catch((errors:any)=>{
120
- if(this.event){this.event('error:delete',errors.response.data.data)}
166
+ // if(this.event){this.event('error:delete',errors.response.data.data)}
167
+ $event('Notification',{
168
+ documentName:this.getDocName(),
169
+ summary:'Record delete failed',
170
+ status:NotificationStatus.error,
171
+ data:errors.response.data.data
172
+ })
121
173
  console.error(errors.response.data.data)
122
174
  return Promise.reject(errors)
123
175
  });
@@ -125,10 +177,10 @@ export class SimpleAppClient<
125
177
  async search(searchbody:SearchBody) {
126
178
  return await this.docapi.runSearch(searchbody,{timeout:this.defaultTimeOut})
127
179
  .then((res:AxiosResponse)=>{
128
- if(this.event){this.event('info:listready',res.data);}
180
+ // if(this.event){this.event('info:listready',res.data);}
129
181
  return res.data
130
182
  }).catch((errors:any)=>{
131
- if(this.event){this.event('error:list',errors.response.data.data)}
183
+ // if(this.event){this.event('error:list',errors.response.data.data)}
132
184
  return Promise.reject(errors)
133
185
  });
134
186
  }
@@ -5,11 +5,14 @@
5
5
  * Author: Ks Tan
6
6
  */
7
7
  import { DocumentMetaData } from "~/types"
8
- export const alldocuments:DocumentMetaData[] = [
8
+
9
+
10
+ export const getAllDocuments = ():DocumentMetaData[] =>[
11
+
9
12
  <%for(let i=0; i<it.modules.length;i++){ %>
10
13
  <% const d = it.modules[i] %>
11
14
  <% const conf = d.schema["x-simpleapp-config"] %>
12
- {docName:'<%= d['docname'] %>',docType:'<%= d['doctype'].toUpperCase()%>',page: '<%=d['pagetype']%>', isolationType:'<%=conf['isolationType']%>',
13
- documentDate:'<%=conf['documentDate']??""%>', docNumber:<%=conf['generateDocumentNumber']??false%>},
15
+ {docName:'<%= d['docname'].toLowerCase() %>',docType:'<%= d['doctype'].toUpperCase()%>',page: '<%=d['pagetype']%>', isolationType:'<%=conf['isolationType']%>',
16
+ documentDate:'<%=conf['documentDate']??""%>', docNumber:<%=conf['generateDocumentNumber']??false%>, docClass: useNuxtApp().$<%=d['docname']%>Doc()},
14
17
  <%}%>
15
18
  ]
@@ -2,6 +2,16 @@ import type { Config } from 'tailwindcss'
2
2
 
3
3
  // Default are on https://tailwindcss.nuxtjs.org/tailwind/config#default-configuration
4
4
  export default <Partial<Config>>{
5
+ content: [
6
+ "./index.html",
7
+ "./components/**/*.{vue,js,ts,jsx,tsx}",
8
+ "./components/*.{vue,js,ts,jsx,tsx}",
9
+ "./assets/**/*.{vue,js,ts,jsx,tsx,css}",
10
+ "./layouts/*.{vue,js,ts,jsx,tsx,css}",
11
+ "./pages/**/*.{vue,js,ts,jsx,tsx}",
12
+ "./pages/*.{vue,js,ts,jsx,tsx}",
13
+ "./node_modules/primevue/**/*.{vue,js,ts,jsx,tsx}"
14
+ ],
5
15
  theme: {
6
16
  extend:{
7
17
  colors:{