adminforth 2.4.0-next.33 → 2.4.0-next.331

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 (177) hide show
  1. package/commands/callTsProxy.js +14 -4
  2. package/commands/createApp/templates/api.ts.hbs +10 -0
  3. package/commands/createApp/templates/custom/tsconfig.json.hbs +2 -3
  4. package/commands/createApp/templates/index.ts.hbs +12 -1
  5. package/commands/createApp/templates/package.json.hbs +1 -1
  6. package/commands/createApp/templates/prisma.config.ts.hbs +8 -0
  7. package/commands/createApp/templates/schema.prisma.hbs +0 -1
  8. package/commands/createApp/utils.js +10 -0
  9. package/commands/createCustomComponent/configLoader.js +17 -4
  10. package/commands/createCustomComponent/main.js +13 -7
  11. package/commands/createCustomComponent/templates/customCrud/beforeActionButtons.vue.hbs +38 -0
  12. package/commands/createCustomComponent/templates/customCrud/saveButton.vue.hbs +28 -0
  13. package/commands/createPlugin/templates/custom/tsconfig.json.hbs +2 -5
  14. package/commands/createPlugin/templates/package.json.hbs +1 -1
  15. package/commands/generateModels.js +30 -22
  16. package/dist/auth.d.ts +9 -1
  17. package/dist/auth.d.ts.map +1 -1
  18. package/dist/auth.js +21 -2
  19. package/dist/auth.js.map +1 -1
  20. package/dist/dataConnectors/baseConnector.d.ts +1 -1
  21. package/dist/dataConnectors/baseConnector.d.ts.map +1 -1
  22. package/dist/dataConnectors/baseConnector.js +70 -18
  23. package/dist/dataConnectors/baseConnector.js.map +1 -1
  24. package/dist/dataConnectors/clickhouse.d.ts.map +1 -1
  25. package/dist/dataConnectors/clickhouse.js +15 -0
  26. package/dist/dataConnectors/clickhouse.js.map +1 -1
  27. package/dist/dataConnectors/mongo.d.ts.map +1 -1
  28. package/dist/dataConnectors/mongo.js +50 -15
  29. package/dist/dataConnectors/mongo.js.map +1 -1
  30. package/dist/dataConnectors/mysql.d.ts.map +1 -1
  31. package/dist/dataConnectors/mysql.js +11 -0
  32. package/dist/dataConnectors/mysql.js.map +1 -1
  33. package/dist/dataConnectors/postgres.d.ts.map +1 -1
  34. package/dist/dataConnectors/postgres.js +43 -14
  35. package/dist/dataConnectors/postgres.js.map +1 -1
  36. package/dist/dataConnectors/sqlite.d.ts.map +1 -1
  37. package/dist/dataConnectors/sqlite.js +11 -0
  38. package/dist/dataConnectors/sqlite.js.map +1 -1
  39. package/dist/index.d.ts +11 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +44 -21
  42. package/dist/index.js.map +1 -1
  43. package/dist/modules/codeInjector.d.ts +2 -0
  44. package/dist/modules/codeInjector.d.ts.map +1 -1
  45. package/dist/modules/codeInjector.js +62 -6
  46. package/dist/modules/codeInjector.js.map +1 -1
  47. package/dist/modules/configValidator.d.ts +6 -0
  48. package/dist/modules/configValidator.d.ts.map +1 -1
  49. package/dist/modules/configValidator.js +209 -25
  50. package/dist/modules/configValidator.js.map +1 -1
  51. package/dist/modules/restApi.d.ts +1 -1
  52. package/dist/modules/restApi.d.ts.map +1 -1
  53. package/dist/modules/restApi.js +199 -31
  54. package/dist/modules/restApi.js.map +1 -1
  55. package/dist/modules/styles.d.ts +499 -13
  56. package/dist/modules/styles.d.ts.map +1 -1
  57. package/dist/modules/styles.js +555 -31
  58. package/dist/modules/styles.js.map +1 -1
  59. package/dist/modules/utils.d.ts +7 -15
  60. package/dist/modules/utils.d.ts.map +1 -1
  61. package/dist/modules/utils.js +45 -68
  62. package/dist/modules/utils.js.map +1 -1
  63. package/dist/servers/express.d.ts +5 -0
  64. package/dist/servers/express.d.ts.map +1 -1
  65. package/dist/servers/express.js +40 -1
  66. package/dist/servers/express.js.map +1 -1
  67. package/dist/spa/index.html +1 -1
  68. package/dist/spa/package-lock.json +1208 -708
  69. package/dist/spa/package.json +34 -34
  70. package/dist/spa/src/App.vue +132 -174
  71. package/dist/spa/src/adminforth.ts +41 -17
  72. package/dist/spa/src/afcl/AreaChart.vue +0 -1
  73. package/dist/spa/src/afcl/BarChart.vue +2 -2
  74. package/dist/spa/src/afcl/Button.vue +3 -3
  75. package/dist/spa/src/afcl/ButtonGroup.vue +91 -0
  76. package/dist/spa/src/afcl/Card.vue +25 -0
  77. package/dist/spa/src/afcl/Checkbox.vue +21 -13
  78. package/dist/spa/src/afcl/CountryFlag.vue +4 -1
  79. package/dist/spa/src/{components/CustomDatePicker.vue → afcl/DatePicker.vue} +95 -9
  80. package/dist/spa/src/afcl/Dialog.vue +47 -27
  81. package/dist/spa/src/afcl/Dropzone.vue +145 -48
  82. package/dist/spa/src/afcl/Input.vue +14 -6
  83. package/dist/spa/src/afcl/JsonViewer.vue +25 -0
  84. package/dist/spa/src/afcl/LinkButton.vue +3 -3
  85. package/dist/spa/src/afcl/PieChart.vue +5 -5
  86. package/dist/spa/src/afcl/ProgressBar.vue +7 -7
  87. package/dist/spa/src/afcl/Select.vue +82 -34
  88. package/dist/spa/src/afcl/Skeleton.vue +6 -6
  89. package/dist/spa/src/afcl/Table.vue +313 -75
  90. package/dist/spa/src/afcl/Textarea.vue +31 -0
  91. package/dist/spa/src/afcl/Toggle.vue +32 -0
  92. package/dist/spa/src/afcl/Tooltip.vue +28 -18
  93. package/dist/spa/src/afcl/VerticalTabs.vue +21 -7
  94. package/dist/spa/src/afcl/index.ts +6 -3
  95. package/dist/spa/src/components/AcceptModal.vue +48 -14
  96. package/dist/spa/src/components/Breadcrumbs.vue +5 -5
  97. package/dist/spa/src/components/CallActionWrapper.vue +15 -0
  98. package/dist/spa/src/components/ColumnValueInput.vue +38 -18
  99. package/dist/spa/src/components/ColumnValueInputWrapper.vue +4 -3
  100. package/dist/spa/src/components/CustomDateRangePicker.vue +9 -8
  101. package/dist/spa/src/components/CustomRangePicker.vue +37 -21
  102. package/dist/spa/src/components/ErrorMessage.vue +21 -0
  103. package/dist/spa/src/components/Filters.vue +195 -132
  104. package/dist/spa/src/components/GroupsTable.vue +9 -8
  105. package/dist/spa/src/components/MenuLink.vue +95 -23
  106. package/dist/spa/src/components/ResourceForm.vue +99 -51
  107. package/dist/spa/src/components/ResourceListTable.vue +121 -95
  108. package/dist/spa/src/components/ResourceListTableVirtual.vue +119 -88
  109. package/dist/spa/src/components/ShowTable.vue +21 -15
  110. package/dist/spa/src/components/Sidebar.vue +472 -0
  111. package/dist/spa/src/components/SingleSkeletLoader.vue +6 -6
  112. package/dist/spa/src/components/SkeleteLoader.vue +3 -3
  113. package/dist/spa/src/components/ThreeDotsMenu.vue +84 -15
  114. package/dist/spa/src/components/Toast.vue +40 -29
  115. package/dist/spa/src/components/UserMenuSettingsButton.vue +69 -0
  116. package/dist/spa/src/components/ValueRenderer.vue +44 -17
  117. package/dist/spa/src/controls/BoolToggle.vue +34 -0
  118. package/dist/spa/src/i18n.ts +5 -3
  119. package/dist/spa/src/main.ts +1 -1
  120. package/dist/spa/src/renderers/CompactField.vue +1 -1
  121. package/dist/spa/src/renderers/CompactUUID.vue +1 -1
  122. package/dist/spa/src/router/index.ts +8 -0
  123. package/dist/spa/src/shims-vue.d.ts +5 -0
  124. package/dist/spa/src/spa_types/core.ts +13 -1
  125. package/dist/spa/src/stores/core.ts +15 -1
  126. package/dist/spa/src/stores/filters.ts +33 -2
  127. package/dist/spa/src/stores/modal.ts +6 -1
  128. package/dist/spa/src/stores/toast.ts +22 -3
  129. package/dist/spa/src/types/Back.ts +168 -23
  130. package/dist/spa/src/types/Common.ts +109 -32
  131. package/dist/spa/src/types/FrontendAPI.ts +32 -23
  132. package/dist/spa/src/types/adapters/CaptchaAdapter.ts +34 -0
  133. package/dist/spa/src/types/adapters/EmailAdapter.ts +2 -4
  134. package/dist/spa/src/types/adapters/ImageVisionAdapter.ts +30 -0
  135. package/dist/spa/src/types/adapters/KeyValueAdapter.ts +16 -0
  136. package/dist/spa/src/types/adapters/StorageAdapter.ts +4 -2
  137. package/dist/spa/src/types/adapters/index.ts +3 -0
  138. package/dist/spa/src/utils.ts +291 -11
  139. package/dist/spa/src/views/CreateView.vue +88 -22
  140. package/dist/spa/src/views/EditView.vue +55 -22
  141. package/dist/spa/src/views/ListView.vue +144 -87
  142. package/dist/spa/src/views/LoginView.vue +26 -35
  143. package/dist/spa/src/views/ResourceParent.vue +2 -2
  144. package/dist/spa/src/views/SettingsView.vue +121 -0
  145. package/dist/spa/src/views/ShowView.vue +83 -53
  146. package/dist/spa/src/websocket.ts +6 -1
  147. package/dist/spa/tsconfig.app.json +1 -1
  148. package/dist/spa/vite.config.ts +45 -2
  149. package/dist/types/Back.d.ts +151 -14
  150. package/dist/types/Back.d.ts.map +1 -1
  151. package/dist/types/Back.js +15 -0
  152. package/dist/types/Back.js.map +1 -1
  153. package/dist/types/Common.d.ts +123 -29
  154. package/dist/types/Common.d.ts.map +1 -1
  155. package/dist/types/Common.js.map +1 -1
  156. package/dist/types/FrontendAPI.d.ts +32 -18
  157. package/dist/types/FrontendAPI.d.ts.map +1 -1
  158. package/dist/types/FrontendAPI.js.map +1 -1
  159. package/dist/types/adapters/CaptchaAdapter.d.ts +30 -0
  160. package/dist/types/adapters/CaptchaAdapter.d.ts.map +1 -0
  161. package/dist/types/adapters/CaptchaAdapter.js +5 -0
  162. package/dist/types/adapters/CaptchaAdapter.js.map +1 -0
  163. package/dist/types/adapters/EmailAdapter.d.ts +2 -3
  164. package/dist/types/adapters/EmailAdapter.d.ts.map +1 -1
  165. package/dist/types/adapters/ImageVisionAdapter.d.ts +25 -0
  166. package/dist/types/adapters/ImageVisionAdapter.d.ts.map +1 -0
  167. package/dist/types/adapters/ImageVisionAdapter.js +2 -0
  168. package/dist/types/adapters/ImageVisionAdapter.js.map +1 -0
  169. package/dist/types/adapters/KeyValueAdapter.d.ts +10 -0
  170. package/dist/types/adapters/KeyValueAdapter.d.ts.map +1 -0
  171. package/dist/types/adapters/KeyValueAdapter.js +2 -0
  172. package/dist/types/adapters/KeyValueAdapter.js.map +1 -0
  173. package/dist/types/adapters/StorageAdapter.d.ts +2 -0
  174. package/dist/types/adapters/StorageAdapter.d.ts.map +1 -1
  175. package/dist/types/adapters/index.d.ts +3 -0
  176. package/dist/types/adapters/index.d.ts.map +1 -1
  177. package/package.json +4 -2
@@ -1,10 +1,10 @@
1
1
  <template>
2
- <div class="relative flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-800 relative w-screen h-screen"
2
+ <div class="relative flex items-center justify-center min-h-screen bg-lightHtml dark:bg-darkHtml w-screen h-screen"
3
3
  :style="coreStore.config?.loginBackgroundImage && backgroundPosition === 'over' ? {
4
4
  'background-image': 'url(' + loadFile(coreStore.config?.loginBackgroundImage) + ')',
5
5
  'background-size': 'cover',
6
6
  'background-position': 'center',
7
- 'background-blend-mode': 'darken'
7
+ 'background-blend-mode': coreStore.config?.removeBackgroundBlendMode ? 'normal' : 'darken'
8
8
  }: {}"
9
9
  >
10
10
 
@@ -27,7 +27,7 @@
27
27
  overflow-x-hidden z-50 min-w-[350px] justify-center items-center md:inset-0 h-[calc(100%-1rem)] max-h-full">
28
28
  <div class="relative p-4 w-full max-h-full max-w-[400px]">
29
29
  <!-- Modal content -->
30
- <div class="af-login-modal-content relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black" >
30
+ <div class="af-login-popup af-login-modal-content relative bg-lightLoginViewBackground rounded-lg shadow dark:bg-darkLoginViewBackground dark:shadow-black" :class=" { 'rounded-b-none overflow-hidden': error } ">
31
31
  <!-- Modal header -->
32
32
  <div class="af-login-modal-header flex items-center justify-between flex-col p-4 md:p-5 border-b rounded-t dark:border-gray-600">
33
33
 
@@ -39,7 +39,7 @@
39
39
  :meta="c.meta"
40
40
  />
41
41
  </template>
42
- <h3 v-else class="text-xl font-semibold text-gray-900 dark:text-white">
42
+ <h3 v-else class="text-xl font-semibold text-lightLoginViewText dark:text-darkLoginViewTextColor">
43
43
  {{ $t('Sign in to') }} {{ coreStore.config?.brandName }}
44
44
  </h3>
45
45
  </div>
@@ -47,7 +47,7 @@
47
47
  <div class="af-login-modal-body p-4 md:p-5">
48
48
  <form class="space-y-4" @submit.prevent>
49
49
  <div>
50
- <label for="username" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{ $t('Your') }} {{ coreStore.config?.usernameFieldName?.toLowerCase() }}</label>
50
+ <label for="username" class="block mb-2 text-sm font-medium text-lightLoginViewText dark:text-darkLoginViewTextColor">{{ $t('Your') }} {{ coreStore.config?.usernameFieldName?.toLowerCase() }}</label>
51
51
  <Input
52
52
  v-model="username"
53
53
  autocomplete="username"
@@ -55,22 +55,20 @@
55
55
  name="username"
56
56
  id="username"
57
57
  ref="usernameInput"
58
- oninput="setCustomValidity('')"
59
58
  @keydown.enter="passwordInput.focus()"
60
59
  class="w-full"
61
60
  placeholder="name@company.com" required />
62
61
  </div>
63
62
  <div class="">
64
- <label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{ $t('Your password') }}</label>
63
+ <label for="password" class="block mb-2 text-sm font-medium text-lightLoginViewText dark:text-darkLoginViewTextColor">{{ $t('Your password') }}</label>
65
64
  <Input
66
65
  v-model="password"
67
66
  ref="passwordInput"
68
67
  autocomplete="current-password"
69
- oninput="setCustomValidity('')"
70
68
  @keydown.enter="login"
71
69
  :type="!showPw ? 'password': 'text'" name="password" id="password" placeholder="••••••••" class="w-full" required>
72
70
  <template #rightIcon>
73
- <button type="button" @click="showPw = !showPw" class="text-gray-400 dark:text-gray-300">
71
+ <button type="button" @click="showPw = !showPw" class="text-lightLoginViewSubTextColor dark:text-darkLoginViewSubTextColor">
74
72
  <IconEyeSolid class="w-5 h-5" v-if="!showPw" />
75
73
  <IconEyeSlashSolid class="w-5 h-5" v-else />
76
74
  </button>
@@ -92,20 +90,11 @@
92
90
  v-for="c in coreStore?.config?.loginPageInjections?.underInputs || []"
93
91
  :is="getCustomComponent(c)"
94
92
  :meta="c.meta"
93
+ @update:disableLoginButton="setDisableLoginButton($event)"
95
94
  />
96
-
97
- <div v-if="error" class="af-login-modal-error flex items-center p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400" role="alert">
98
- <svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
99
- <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
100
- </svg>
101
- <span class="sr-only">{{ $t('Info') }}</span>
102
- <div>
103
- {{ error }}
104
- </div>
105
- </div>
106
-
95
+
107
96
  <div v-if="coreStore.config?.loginPromptHTML"
108
- class="flex items-center p-4 mb-4 text-sm text-gray-800 rounded-lg bg-gray-50 dark:bg-gray-800 dark:text-gray-400" role="alert"
97
+ class="flex items-center p-4 mb-4 text-sm text-lightLoginViewPromptText rounded-lg bg-lightLoginViewPromptBackground dark:bg-darkLoginViewPromptBackground dark:text-darkLoginViewPromptText" role="alert"
109
98
  >
110
99
  <svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
111
100
  <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
@@ -113,13 +102,19 @@
113
102
  <span class="sr-only">{{ $t('Info') }}</span>
114
103
  <div v-html="coreStore.config?.loginPromptHTML"></div>
115
104
  </div>
116
- <Button @click="login" :loader="inProgress" :disabled="inProgress" class="w-full">
105
+ <Button @click="login" :loader="inProgress" :disabled="inProgress || disableLoginButton" class="w-full">
117
106
  {{ $t('Login to your account') }}
118
107
  </Button>
108
+ <component
109
+ v-for="c in coreStore?.config?.loginPageInjections?.underLoginButton || []"
110
+ :is="getCustomComponent(c)"
111
+ :meta="c.meta"
112
+ @update:disableLoginButton="setDisableLoginButton($event)"
113
+ />
119
114
  </form>
120
-
121
115
  </div>
122
116
  </div>
117
+ <ErrorMessage v-if="error" :error="error" class="absolute left-4 right-4 rounded-t-none mb-0 shadow px-9" />
123
118
  </div>
124
119
  </div>
125
120
 
@@ -127,7 +122,7 @@
127
122
  </template>
128
123
 
129
124
 
130
- <script setup>
125
+ <script setup lang="ts">
131
126
 
132
127
  import { getCustomComponent } from '@/utils';
133
128
  import { onBeforeMount, onMounted, ref, computed } from 'vue';
@@ -138,6 +133,7 @@ import { callAdminForthApi, loadFile } from '@/utils';
138
133
  import { useRoute, useRouter } from 'vue-router';
139
134
  import { Button, Checkbox, Input } from '@/afcl';
140
135
  import { useI18n } from 'vue-i18n';
136
+ import ErrorMessage from '@/components/ErrorMessage.vue';
141
137
 
142
138
  const { t } = useI18n();
143
139
 
@@ -150,18 +146,19 @@ const password = ref('');
150
146
  const route = useRoute();
151
147
  const router = useRouter();
152
148
  const inProgress = ref(false);
153
-
154
149
  const coreStore = useCoreStore();
155
150
  const user = useUserStore();
156
151
 
157
152
  const showPw = ref(false);
158
153
 
159
154
  const error = ref(null);
155
+ const disableLoginButton = ref(false);
160
156
 
161
157
  const backgroundPosition = computed(() => {
162
158
  return coreStore.config?.loginBackgroundPosition || '1/2';
163
159
  });
164
160
 
161
+
165
162
  onBeforeMount(() => {
166
163
  if (localStorage.getItem('isAuthorized') === 'true') {
167
164
  // if route has next param, redirect
@@ -175,6 +172,7 @@ onBeforeMount(() => {
175
172
  })
176
173
 
177
174
  onMounted(async () => {
175
+ coreStore.getLoginFormConfig();
178
176
  if (coreStore.config?.demoCredentials) {
179
177
  const [demoUsername, demoPassword] = coreStore.config.demoCredentials.split(':');
180
178
  username.value = demoUsername;
@@ -185,16 +183,6 @@ onMounted(async () => {
185
183
 
186
184
 
187
185
  async function login() {
188
-
189
- if (!username.value) {
190
- usernameInput.value.setCustomValidity(t('Please fill out this field.'));
191
- return;
192
- }
193
- if (!password.value) {
194
- passwordInput.value.setCustomValidity(t('Please fill out this field.'));
195
- return;
196
- }
197
-
198
186
  if (inProgress.value) {
199
187
  return;
200
188
  }
@@ -220,5 +208,8 @@ async function login() {
220
208
 
221
209
  }
222
210
 
211
+ function setDisableLoginButton(value: boolean) {
212
+ disableLoginButton.value = value;
213
+ }
223
214
 
224
215
  </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div :key="`${$route?.params.resourceId}---${$route?.params.primaryKey}`" class="p-4 flex"
2
+ <div :key="`${$route?.params.resourceId}---${$route?.params.primaryKey}`" class="af-resource-parent p-4 flex"
3
3
  :class="limitHeightToPage ? 'h-[calc(100dvh-3.5rem)]': undefined"
4
4
  >
5
5
  <RouterView/>
@@ -33,7 +33,7 @@ const limitHeightToPage = computed(() => {
33
33
  }
34
34
  const listPageInjects = coreStore.resource.options.pageInjections.list;
35
35
 
36
- for (const pi of [listPageInjects.beforeBreadcrumbs, listPageInjects.afterBreadcrumbs, listPageInjects.bottom]) {
36
+ for (const pi of [listPageInjects.beforeBreadcrumbs, listPageInjects.beforeActionButtons, listPageInjects.afterBreadcrumbs, listPageInjects.bottom]) {
37
37
  if (pi) {
38
38
  for (const piItem of pi) {
39
39
  if (!piItem.meta?.thinEnoughToShrinkTable) {
@@ -0,0 +1,121 @@
1
+ <template>
2
+ <div class="mt-20 h-full w-full" :class="{ 'hidden': initialTabSet === false }">
3
+ <div v-if="!coreStore?.config?.settingPages?.filter(page => page.isVisible) || coreStore?.config?.settingPages.length === 0">
4
+ <p>{{ $t('No setting pages configured or still loading...') }}</p>
5
+ </div>
6
+ <VerticalTabs v-else ref="VerticalTabsRef" hideTabesWhenSingle v-model:active-tab="activeTab" @update:active-tab="setURL({slug: $event, pageLabel: ''})">
7
+ <template v-for="(c,i) in coreStore?.config?.settingPages.filter(page => page.isVisible)" :key="`tab:${settingPageSlotName(c,i)}`" v-slot:['tab:'+c.slug]>
8
+ <div class="flex items-center justify-center whitespace-nowrap w-full px-4 gap-2" @click="setURL(c)">
9
+ <component v-if="c.icon" :is="getIcon(c.icon)" class="w-5 h-5 group-hover:text-lightSidebarIconsHover transition duration-75 dark:group-hover:text-darkSidebarIconsHover dark:text-darkSidebarIcons" ></component>
10
+ {{ c.pageLabel }}
11
+ </div>
12
+ </template>
13
+
14
+ <template v-for="(c,i) in coreStore?.config?.settingPages.filter(page => page.isVisible)" :key="`${settingPageSlotName(c,i)}-content`" v-slot:[c.slug]>
15
+ <component
16
+ :is="getCustomComponent({file: c.component || ''})"
17
+ :resource="coreStore.resource"
18
+ :adminUser="coreStore.adminUser"
19
+ />
20
+ </template>
21
+ </VerticalTabs>
22
+ </div>
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ import { ref, onMounted, watch } from 'vue';
27
+ import { useRouter } from 'vue-router';
28
+ import { useCoreStore } from '@/stores/core';
29
+ import { getCustomComponent, getIcon } from '@/utils';
30
+ import { Dropdown } from 'flowbite';
31
+ import adminforth from '@/adminforth';
32
+ import { VerticalTabs } from '@/afcl'
33
+ import { useRoute } from 'vue-router'
34
+
35
+ const route = useRoute()
36
+ const coreStore = useCoreStore();
37
+ const router = useRouter();
38
+
39
+ const routerIsReady = ref(false);
40
+ const loginRedirectCheckIsReady = ref(false);
41
+ const dropdownUserButton = ref<HTMLElement | null>(null);
42
+ const VerticalTabsRef = ref();
43
+ const activeTab = ref('');
44
+ const initialTabSet = ref(false);
45
+
46
+ watch(() => route?.params?.page, (val) => {
47
+ handleURLChange(val as string | null);
48
+ });
49
+
50
+ async function initRouter() {
51
+ await router.isReady();
52
+ routerIsReady.value = true;
53
+ }
54
+
55
+ watch(dropdownUserButton, (el) => {
56
+ if (el) {
57
+ const dd = new Dropdown(
58
+ document.querySelector('#dropdown-user') as HTMLElement,
59
+ document.querySelector('[data-dropdown-toggle="dropdown-user"]') as HTMLElement,
60
+ );
61
+ adminforth.closeUserMenuDropdown = () => dd.hide();
62
+ }
63
+ });
64
+
65
+ onMounted(async () => {
66
+ if (coreStore.adminUser) {
67
+ await loadMenu();
68
+ loginRedirectCheckIsReady.value = true;
69
+ const routeParamsPage = route?.params?.page;
70
+ if (!routeParamsPage) {
71
+ if (coreStore.config?.settingPages?.[0]) {
72
+ setURL(coreStore.config.settingPages[0]);
73
+ }
74
+ } else {
75
+ handleURLChange(routeParamsPage as string | null);
76
+ }
77
+ }
78
+ });
79
+
80
+ async function loadMenu() {
81
+ await initRouter();
82
+ await coreStore.fetchMenuAndResource();
83
+ }
84
+
85
+ function slugifyString(str: string): string {
86
+ return str
87
+ .toString()
88
+ .toLowerCase()
89
+ .replace(/\s+/g, '-')
90
+ .replace(/[^a-z0-9-_]/g, '-');
91
+ }
92
+
93
+ function setURL(item: {
94
+ pageLabel: string;
95
+ slug?: string | undefined;
96
+ }) {
97
+ router.replace({
98
+ name: 'settings',
99
+ params: { page: item?.slug }
100
+ });
101
+ }
102
+
103
+ function handleURLChange(val: string | null) {
104
+ let isParamInTabs;
105
+ for (const c of coreStore?.config?.settingPages || []) {
106
+ if (c.slug ? c.slug === val : slugifyString(c.pageLabel) === val) {
107
+ isParamInTabs = true;
108
+ break;
109
+ }
110
+ }
111
+ if (isParamInTabs) {
112
+ VerticalTabsRef.value.setActiveTab(val);
113
+ activeTab.value = val as string;
114
+ if (!initialTabSet.value) initialTabSet.value = true;
115
+ } else {
116
+ if (coreStore.config?.settingPages?.[0]) {
117
+ setURL(coreStore.config.settingPages[0]);
118
+ }
119
+ }
120
+ }
121
+ </script>
@@ -4,52 +4,60 @@
4
4
  v-if="!loading"
5
5
  v-for="c in coreStore?.resourceOptions?.pageInjections?.show?.beforeBreadcrumbs || []"
6
6
  :is="getCustomComponent(c)"
7
- :meta="c.meta"
7
+ :meta="(c as AdminForthComponentDeclarationFull).meta"
8
8
  :record="coreStore.record"
9
9
  :resource="coreStore.resource"
10
10
  :adminUser="coreStore.adminUser"
11
11
  />
12
12
  <BreadcrumbsWithButtons>
13
13
  <template v-if="coreStore.resource?.options?.actions">
14
- <button
15
- v-for="action in coreStore.resource.options.actions.filter(a => a.showIn?.showButton)"
16
- :key="action.id"
17
- @click="startCustomAction(action.id)"
18
- :disabled="actionLoadingStates[action.id]"
19
- class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-default border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
20
- >
21
- <component
22
- v-if="action.icon"
23
- :is="getIcon(action.icon)"
24
- class="w-4 h-4 me-2 text-lightPrimary dark:text-darkPrimary"
25
- />
26
- {{ action.name }}
27
- </button>
14
+
15
+ <template v-for="action in coreStore.resource.options.actions.filter(a => a.showIn?.showButton)" :key="action.id">
16
+ <component
17
+ :is="action?.customComponent ? getCustomComponent(action.customComponent) : CallActionWrapper"
18
+ :meta="action.customComponent?.meta"
19
+ @callAction="(payload?) => startCustomAction(action.id, payload)"
20
+ :disabled="actionLoadingStates[action.id]"
21
+ >
22
+ <button
23
+ :key="action.id"
24
+ :disabled="actionLoadingStates[action.id!]"
25
+ class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-default border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
26
+ >
27
+ <component
28
+ v-if="action.icon"
29
+ :is="getIcon(action.icon)"
30
+ class="w-4 h-4 me-2 text-lightPrimary dark:text-darkPrimary"
31
+ />
32
+ {{ action.name }}
33
+ </button>
34
+ </component>
35
+ </template>
28
36
  </template>
29
37
  <RouterLink v-if="coreStore.resource?.options?.allowedActions?.create"
30
38
  :to="{ name: 'resource-create', params: { resourceId: $route.params.resourceId } }"
31
- class="af-add-new-button flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 rounded-default"
39
+ class="af-add-new-button flex items-center py-1 px-3 text-sm font-medium text-lightShowViewButtonText focus:outline-none bg-lightShowViewButtonBackground rounded border border-lightShowViewButtonBorder hover:bg-lightShowViewButtonBackgroundHover hover:text-lightShowViewButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightShowViewButtonFocusRing dark:focus:ring-darkShowViewButtonFocusRing dark:bg-darkShowViewButtonBackground dark:text-darkShowViewButtonText dark:border-darkShowViewButtonBorder dark:hover:text-darkShowViewButtonTextHover dark:hover:bg-darkShowViewButtonBackgroundHover rounded-default gap-1"
32
40
  >
33
- <IconPlusOutline class="w-4 h-4 me-2"/>
41
+ <IconPlusOutline class="w-4 h-4"/>
34
42
  {{ $t('Add new') }}
35
43
  </RouterLink>
36
44
 
37
45
  <RouterLink v-if="coreStore?.resourceOptions?.allowedActions?.edit" :to="{ name: 'resource-edit', params: { resourceId: $route.params.resourceId, primaryKey: $route.params.primaryKey } }"
38
- class="flex items-center af-edit-button py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-default border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
46
+ class="flex items-center af-edit-button py-1 px-3 text-sm font-medium text-lightShowViewButtonText focus:outline-none bg-lightShowViewButtonBackground rounded-default border border-lightShowViewButtonBorder hover:bg-lightShowViewButtonBackgroundHover hover:text-lightShowViewButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightShowViewButtonFocusRing dark:focus:ring-darkShowViewButtonFocusRing dark:bg-darkShowViewButtonBackground dark:text-darkShowViewButtonText dark:border-darkShowViewButtonBorder dark:hover:text-darkShowViewButtonTextHover dark:hover:bg-darkShowViewButtonBackgroundHover gap-1"
39
47
  >
40
48
  <IconPenSolid class="w-4 h-4" />
41
49
  {{ $t('Edit') }}
42
50
  </RouterLink>
43
51
 
44
52
  <button v-if="coreStore?.resourceOptions?.allowedActions?.delete" @click="deleteRecord"
45
- class="flex items-center af-delete-button py-1 px-3 text-sm font-medium rounded-default text-red-600 focus:outline-none bg-white border border-gray-300 hover:bg-gray-100 hover:text-red-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-red-500 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
53
+ class="flex items-center af-delete-button py-1 px-3 text-sm font-medium rounded-default text-red-600 focus:outline-none bg-lightShowViewButtonBackground border border-lightShowViewButtonBorder hover:bg-lightShowViewButtonBackgroundHover hover:text-red-700 focus:z-10 focus:ring-4 focus:ring-lightShowViewButtonFocusRing dark:focus:ring-darkShowViewButtonFocusRing dark:bg-darkShowViewButtonBackground dark:text-red-500 dark:border-darkShowViewButtonBorder dark:hover:text-darkShowViewButtonTextHover dark:hover:bg-darkShowViewButtonBackgroundHover gap-1"
46
54
  >
47
55
  <IconTrashBinSolid class="w-4 h-4" />
48
56
  {{ $t('Delete') }}
49
57
  </button>
50
58
 
51
59
  <ThreeDotsMenu
52
- :threeDotsDropdownItems="coreStore.resourceOptions?.pageInjections?.show?.threeDotsDropdownItems"
60
+ :threeDotsDropdownItems="(coreStore.resourceOptions?.pageInjections?.show?.threeDotsDropdownItems as [])"
53
61
  :customActions="customActions"
54
62
  ></ThreeDotsMenu>
55
63
  </BreadcrumbsWithButtons>
@@ -57,7 +65,7 @@
57
65
  <component
58
66
  v-for="c in coreStore?.resourceOptions?.pageInjections?.show?.afterBreadcrumbs || []"
59
67
  :is="getCustomComponent(c)"
60
- :meta="c.meta"
68
+ :meta="(c as AdminForthComponentDeclarationFull).meta"
61
69
  :record="coreStore.record"
62
70
  :resource="coreStore.resource"
63
71
  :adminUser="coreStore.adminUser"
@@ -76,11 +84,11 @@
76
84
  v-else-if="coreStore.record"
77
85
  class="relative w-full flex flex-col gap-4"
78
86
  >
79
- <div v-if="!groups.length && allColumns.length">
87
+ <div v-if="!groups.length && allColumns?.length">
80
88
  <ShowTable
81
- :columns="allColumns"
82
89
  :resource="coreStore.resource"
83
90
  :record="coreStore.record"
91
+ :columns="allColumns as Array<{ name: string; label?: string; components?: any }>"
84
92
  />
85
93
  </div>
86
94
  <template v-else>
@@ -93,12 +101,12 @@
93
101
  :record="coreStore.record"
94
102
  />
95
103
  </template>
96
- <template v-if="otherColumns.length > 0">
104
+ <template v-if="otherColumns && otherColumns.length > 0">
97
105
  <ShowTable
98
- :columns="otherColumns"
99
106
  groupName="Other Fields"
100
107
  :resource="coreStore.resource"
101
108
  :record="coreStore.record"
109
+ :columns="otherColumns as Array<{ name: string; label?: string; components?: any }>"
102
110
  />
103
111
  </template>
104
112
  </template>
@@ -112,8 +120,7 @@
112
120
  v-if="!loading"
113
121
  v-for="c in coreStore?.resourceOptions?.pageInjections?.show?.bottom || []"
114
122
  :is="getCustomComponent(c)"
115
- :meta="c.meta"
116
- :column="column"
123
+ :meta="(c as AdminForthComponentDeclarationFull).meta"
117
124
  :record="coreStore.record"
118
125
  :resource="coreStore.resource"
119
126
  :adminUser="coreStore.adminUser"
@@ -140,6 +147,8 @@ import ShowTable from '@/components/ShowTable.vue';
140
147
  import adminforth from "@/adminforth";
141
148
  import { useI18n } from 'vue-i18n';
142
149
  import { getIcon } from '@/utils';
150
+ import { type AdminForthComponentDeclarationFull } from '@/types/Common.js';
151
+ import CallActionWrapper from '@/components/CallActionWrapper.vue'
143
152
 
144
153
  const route = useRoute();
145
154
  const router = useRouter();
@@ -147,62 +156,65 @@ const loading = ref(true);
147
156
  const { t } = useI18n();
148
157
  const coreStore = useCoreStore();
149
158
 
150
- const actionLoadingStates = ref({});
159
+ const actionLoadingStates = ref<Record<string, boolean>>({});
151
160
 
152
161
  const customActions = computed(() => {
153
- return coreStore.resource?.options?.actions?.filter(a => a.showIn?.showThreeDotsMenu) || [];
162
+ return coreStore.resource?.options?.actions?.filter((a: any) => a.showIn?.showThreeDotsMenu) || [];
154
163
  });
155
164
 
156
165
  onMounted(async () => {
157
166
  loading.value = true;
158
167
  await coreStore.fetchResourceFull({
159
- resourceId: route.params.resourceId
168
+ resourceId: route.params.resourceId as string,
160
169
  });
161
170
  initThreeDotsDropdown();
162
171
  await coreStore.fetchRecord({
163
- resourceId: route.params.resourceId,
164
- primaryKey: route.params.primaryKey,
172
+ resourceId: route.params.resourceId as string,
173
+ primaryKey: route.params.primaryKey as string,
165
174
  source: 'show',
166
175
  });
167
- checkAcessByAllowedActions(coreStore.resourceOptions.allowedActions,'show');
176
+ if(coreStore.resourceOptions){
177
+ checkAcessByAllowedActions(coreStore.resourceOptions.allowedActions,'show');
178
+ }
168
179
  loading.value = false;
169
180
  });
170
181
 
171
182
  const groups = computed(() => {
172
183
  let fieldGroupType;
173
- if (coreStore.resource.options?.showFieldGroups) {
174
- fieldGroupType = coreStore.resource.options.showFieldGroups;
175
- } else if (coreStore.resource.options?.showFieldGroups === null) {
176
- fieldGroupType = [];
177
- } else {
178
- fieldGroupType = coreStore.resource.options?.fieldGroups;
184
+ if (coreStore.resource) {
185
+ if (coreStore.resource.options?.showFieldGroups) {
186
+ fieldGroupType = coreStore.resource.options.showFieldGroups;
187
+ } else if (coreStore.resource.options?.showFieldGroups === null) {
188
+ fieldGroupType = [];
189
+ } else {
190
+ fieldGroupType = coreStore.resource.options?.fieldGroups;
191
+ }
179
192
  }
193
+ const activeGroups: typeof fieldGroupType | [] = fieldGroupType ?? [];
180
194
 
181
- const activeGroups = fieldGroupType ?? [];
182
-
183
- return activeGroups.map(group => ({
195
+ return activeGroups.map((group: FieldGroup) => ({
184
196
  ...group,
185
- columns: coreStore.resource.columns.filter(
186
- col => group.columns.includes(col.name) && col.showIn.show
197
+ columns: coreStore.resource?.columns.filter(
198
+ col => group.columns.includes(col.name) && col.showIn?.show
187
199
  ),
188
200
  }));
189
201
  });
190
202
 
191
203
  const allColumns = computed(() => {
192
- return coreStore.resource.columns.filter(col => col.showIn.show);
204
+ return coreStore.resource?.columns.filter(col => col.showIn?.show);
193
205
  });
194
206
 
195
207
  const otherColumns = computed(() => {
196
208
  const groupedColumnNames = new Set(
197
- groups.value.flatMap(group => group.columns.map(col => col.name))
209
+ groups.value.flatMap(group => group.columns.map((col: AdminForthResourceColumnCommon) => col.name))
198
210
  );
199
211
 
200
- return coreStore.resource.columns.filter(
201
- col => !groupedColumnNames.has(col.name) && col.showIn.show
212
+ return coreStore.resource?.columns.filter(
213
+ col => !groupedColumnNames.has(col.name) && col.showIn?.show
202
214
  );
203
215
  });
204
216
 
205
- async function deleteRecord(row) {
217
+ async function deleteRecord() {
206
218
  const data = await adminforth.confirm({
207
219
  message: t('Are you sure you want to delete this item?'),
208
220
  yes: t('Delete'),
@@ -231,7 +243,7 @@ async function deleteRecord(row) {
231
243
 
232
244
  }
233
245
 
234
- async function startCustomAction(actionId) {
246
+ async function startCustomAction(actionId: string, extra: any) {
235
247
  actionLoadingStates.value[actionId] = true;
236
248
 
237
249
  const data = await callAdminForthApi({
@@ -240,7 +252,8 @@ async function startCustomAction(actionId) {
240
252
  body: {
241
253
  resourceId: route.params.resourceId,
242
254
  actionId: actionId,
243
- recordId: route.params.primaryKey
255
+ recordId: route.params.primaryKey,
256
+ extra: extra,
244
257
  }
245
258
  });
246
259
 
@@ -263,8 +276,8 @@ async function startCustomAction(actionId) {
263
276
 
264
277
  if (data?.ok) {
265
278
  await coreStore.fetchRecord({
266
- resourceId: route.params.resourceId,
267
- primaryKey: route.params.primaryKey,
279
+ resourceId: route.params.resourceId as string,
280
+ primaryKey: route.params.primaryKey as string,
268
281
  source: 'show',
269
282
  });
270
283
 
@@ -281,4 +294,21 @@ async function startCustomAction(actionId) {
281
294
  }
282
295
  }
283
296
 
297
+ adminforth.show.refresh = () => {
298
+ (async () => {
299
+ try {
300
+ loading.value = true;
301
+ await coreStore.fetchRecord({
302
+ resourceId: String(route.params.resourceId),
303
+ primaryKey: String(route.params.primaryKey),
304
+ source: 'show',
305
+ });
306
+ } catch (e) {
307
+ showErrorTost((e as Error).message);
308
+ } finally {
309
+ loading.value = false;
310
+ }
311
+ })();
312
+ }
313
+
284
314
  </script>
@@ -1,8 +1,13 @@
1
1
 
2
2
  const subscriptions: { [topic: string]: ((data: any) => void)[] } = {};
3
+
4
+ interface ExtendedWebSocket extends WebSocket {
5
+ connected?: boolean;
6
+ }
7
+
3
8
  const state: {
4
9
  status: 'connecting' | 'connected' | 'disconnected';
5
- ws: WebSocket | null;
10
+ ws: ExtendedWebSocket | null;
6
11
  } = {
7
12
  status: 'connecting',
8
13
  ws: null
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "extends": "@vue/tsconfig/tsconfig.dom.json",
3
- "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
3
+ "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "src/**/*.d.ts"],
4
4
  "exclude": ["src/**/__tests__/*"],
5
5
  "compilerOptions": {
6
6
  "composite": true,