adminforth 1.4.3-next.2 → 1.4.3-next.21

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 (191) hide show
  1. package/commands/bundle.js +29 -0
  2. package/commands/generateModels.js +63 -0
  3. package/commands/utils.js +93 -0
  4. package/dist/adminforth/auth.d.ts +31 -0
  5. package/dist/adminforth/auth.d.ts.map +1 -0
  6. package/dist/adminforth/auth.js +119 -0
  7. package/dist/adminforth/auth.js.map +1 -0
  8. package/dist/adminforth/basePlugin.d.ts +23 -0
  9. package/dist/adminforth/basePlugin.d.ts.map +1 -0
  10. package/dist/adminforth/basePlugin.js +51 -0
  11. package/dist/adminforth/basePlugin.js.map +1 -0
  12. package/dist/adminforth/dataConnectors/baseConnector.d.ts +95 -0
  13. package/dist/adminforth/dataConnectors/baseConnector.d.ts.map +1 -0
  14. package/dist/adminforth/dataConnectors/baseConnector.js +178 -0
  15. package/dist/adminforth/dataConnectors/baseConnector.js.map +1 -0
  16. package/dist/adminforth/dataConnectors/clickhouse.d.ts +93 -0
  17. package/dist/adminforth/dataConnectors/clickhouse.d.ts.map +1 -0
  18. package/dist/adminforth/dataConnectors/clickhouse.js +297 -0
  19. package/dist/adminforth/dataConnectors/clickhouse.js.map +1 -0
  20. package/dist/adminforth/dataConnectors/mongo.d.ts +94 -0
  21. package/dist/adminforth/dataConnectors/mongo.d.ts.map +1 -0
  22. package/dist/adminforth/dataConnectors/mongo.js +168 -0
  23. package/dist/adminforth/dataConnectors/mongo.js.map +1 -0
  24. package/dist/adminforth/dataConnectors/postgres.d.ts +72 -0
  25. package/dist/adminforth/dataConnectors/postgres.d.ts.map +1 -0
  26. package/dist/adminforth/dataConnectors/postgres.js +298 -0
  27. package/dist/adminforth/dataConnectors/postgres.js.map +1 -0
  28. package/dist/adminforth/dataConnectors/sqlite.d.ts +67 -0
  29. package/dist/adminforth/dataConnectors/sqlite.d.ts.map +1 -0
  30. package/dist/adminforth/dataConnectors/sqlite.js +251 -0
  31. package/dist/adminforth/dataConnectors/sqlite.js.map +1 -0
  32. package/dist/adminforth/index.d.ts +94 -0
  33. package/dist/adminforth/index.d.ts.map +1 -0
  34. package/dist/adminforth/index.js +357 -0
  35. package/dist/adminforth/index.js.map +1 -0
  36. package/dist/adminforth/modules/codeInjector.d.ts +38 -0
  37. package/dist/adminforth/modules/codeInjector.d.ts.map +1 -0
  38. package/dist/adminforth/modules/codeInjector.js +673 -0
  39. package/dist/adminforth/modules/codeInjector.js.map +1 -0
  40. package/dist/adminforth/modules/configValidator.d.ts +13 -0
  41. package/dist/adminforth/modules/configValidator.d.ts.map +1 -0
  42. package/dist/adminforth/modules/configValidator.js +511 -0
  43. package/dist/adminforth/modules/configValidator.js.map +1 -0
  44. package/dist/adminforth/modules/operationalResource.d.ts +17 -0
  45. package/dist/adminforth/modules/operationalResource.d.ts.map +1 -0
  46. package/dist/adminforth/modules/operationalResource.js +75 -0
  47. package/dist/adminforth/modules/operationalResource.js.map +1 -0
  48. package/dist/adminforth/modules/restApi.d.ts +11 -0
  49. package/dist/adminforth/modules/restApi.d.ts.map +1 -0
  50. package/dist/adminforth/modules/restApi.js +657 -0
  51. package/dist/adminforth/modules/restApi.js.map +1 -0
  52. package/dist/adminforth/modules/styleGenerator.d.ts +9 -0
  53. package/dist/adminforth/modules/styleGenerator.d.ts.map +1 -0
  54. package/dist/adminforth/modules/styleGenerator.js +47 -0
  55. package/dist/adminforth/modules/styleGenerator.js.map +1 -0
  56. package/dist/adminforth/modules/styles.d.ts +96 -0
  57. package/dist/adminforth/modules/styles.d.ts.map +1 -0
  58. package/dist/adminforth/modules/styles.js +105 -0
  59. package/dist/adminforth/modules/styles.js.map +1 -0
  60. package/dist/adminforth/modules/utils.d.ts +39 -0
  61. package/dist/adminforth/modules/utils.d.ts.map +1 -0
  62. package/dist/adminforth/modules/utils.js +421 -0
  63. package/dist/adminforth/modules/utils.js.map +1 -0
  64. package/dist/adminforth/plugins/audit-log/index.d.ts +25 -0
  65. package/dist/adminforth/plugins/audit-log/index.d.ts.map +1 -0
  66. package/dist/adminforth/plugins/audit-log/index.js +129 -0
  67. package/dist/adminforth/plugins/audit-log/index.js.map +1 -0
  68. package/dist/adminforth/plugins/audit-log/types.d.ts +35 -0
  69. package/dist/adminforth/plugins/audit-log/types.d.ts.map +1 -0
  70. package/dist/adminforth/plugins/audit-log/types.js +2 -0
  71. package/dist/adminforth/plugins/audit-log/types.js.map +1 -0
  72. package/dist/adminforth/plugins/chat-gpt/index.d.ts +14 -0
  73. package/dist/adminforth/plugins/chat-gpt/index.d.ts.map +1 -0
  74. package/dist/adminforth/plugins/chat-gpt/index.js +147 -0
  75. package/dist/adminforth/plugins/chat-gpt/index.js.map +1 -0
  76. package/dist/adminforth/plugins/chat-gpt/types.d.ts +82 -0
  77. package/dist/adminforth/plugins/chat-gpt/types.d.ts.map +1 -0
  78. package/dist/adminforth/plugins/chat-gpt/types.js +2 -0
  79. package/dist/adminforth/plugins/chat-gpt/types.js.map +1 -0
  80. package/dist/adminforth/plugins/email-password-reset/index.d.ts +15 -0
  81. package/dist/adminforth/plugins/email-password-reset/index.d.ts.map +1 -0
  82. package/dist/adminforth/plugins/email-password-reset/index.js +176 -0
  83. package/dist/adminforth/plugins/email-password-reset/index.js.map +1 -0
  84. package/dist/adminforth/plugins/email-password-reset/types.d.ts +28 -0
  85. package/dist/adminforth/plugins/email-password-reset/types.d.ts.map +1 -0
  86. package/dist/adminforth/plugins/email-password-reset/types.js +2 -0
  87. package/dist/adminforth/plugins/email-password-reset/types.js.map +1 -0
  88. package/dist/adminforth/plugins/foreign-inline-list/index.d.ts +13 -0
  89. package/dist/adminforth/plugins/foreign-inline-list/index.d.ts.map +1 -0
  90. package/dist/adminforth/plugins/foreign-inline-list/index.js +56 -0
  91. package/dist/adminforth/plugins/foreign-inline-list/index.js.map +1 -0
  92. package/dist/adminforth/plugins/foreign-inline-list/types.d.ts +19 -0
  93. package/dist/adminforth/plugins/foreign-inline-list/types.d.ts.map +1 -0
  94. package/dist/adminforth/plugins/foreign-inline-list/types.js +2 -0
  95. package/dist/adminforth/plugins/foreign-inline-list/types.js.map +1 -0
  96. package/dist/adminforth/plugins/import-export/index.d.ts +15 -0
  97. package/dist/adminforth/plugins/import-export/index.d.ts.map +1 -0
  98. package/dist/adminforth/plugins/import-export/index.js +127 -0
  99. package/dist/adminforth/plugins/import-export/index.js.map +1 -0
  100. package/dist/adminforth/plugins/import-export/types.d.ts +3 -0
  101. package/dist/adminforth/plugins/import-export/types.d.ts.map +1 -0
  102. package/dist/adminforth/plugins/import-export/types.js +2 -0
  103. package/dist/adminforth/plugins/import-export/types.js.map +1 -0
  104. package/dist/adminforth/plugins/rich-editor/index.d.ts +17 -0
  105. package/dist/adminforth/plugins/rich-editor/index.d.ts.map +1 -0
  106. package/dist/adminforth/plugins/rich-editor/index.js +262 -0
  107. package/dist/adminforth/plugins/rich-editor/index.js.map +1 -0
  108. package/dist/adminforth/plugins/rich-editor/types.d.ts +153 -0
  109. package/dist/adminforth/plugins/rich-editor/types.d.ts.map +1 -0
  110. package/dist/adminforth/plugins/rich-editor/types.js +16 -0
  111. package/dist/adminforth/plugins/rich-editor/types.js.map +1 -0
  112. package/dist/adminforth/plugins/two-factors-auth/index.d.ts +16 -0
  113. package/dist/adminforth/plugins/two-factors-auth/index.d.ts.map +1 -0
  114. package/dist/adminforth/plugins/two-factors-auth/index.js +134 -0
  115. package/dist/adminforth/plugins/two-factors-auth/index.js.map +1 -0
  116. package/dist/adminforth/plugins/two-factors-auth/types.d.ts +18 -0
  117. package/dist/adminforth/plugins/two-factors-auth/types.d.ts.map +1 -0
  118. package/dist/adminforth/plugins/two-factors-auth/types.js +2 -0
  119. package/dist/adminforth/plugins/two-factors-auth/types.js.map +1 -0
  120. package/dist/adminforth/plugins/upload/index.d.ts +14 -0
  121. package/dist/adminforth/plugins/upload/index.d.ts.map +1 -0
  122. package/dist/adminforth/plugins/upload/index.js +450 -0
  123. package/dist/adminforth/plugins/upload/index.js.map +1 -0
  124. package/dist/adminforth/plugins/upload/types.d.ts +132 -0
  125. package/dist/adminforth/plugins/upload/types.d.ts.map +1 -0
  126. package/dist/adminforth/plugins/upload/types.js +2 -0
  127. package/dist/adminforth/plugins/upload/types.js.map +1 -0
  128. package/dist/adminforth/servers/express.d.ts +18 -0
  129. package/dist/adminforth/servers/express.d.ts.map +1 -0
  130. package/dist/adminforth/servers/express.js +238 -0
  131. package/dist/adminforth/servers/express.js.map +1 -0
  132. package/dist/adminforth/types/Back.d.ts +1103 -0
  133. package/dist/adminforth/types/Back.d.ts.map +1 -0
  134. package/dist/adminforth/types/Back.js +86 -0
  135. package/dist/adminforth/types/Back.js.map +1 -0
  136. package/dist/adminforth/types/Common.d.ts +616 -0
  137. package/dist/adminforth/types/Common.d.ts.map +1 -0
  138. package/dist/adminforth/types/Common.js +65 -0
  139. package/dist/adminforth/types/Common.js.map +1 -0
  140. package/dist/adminforth/types/FrontendAPI.d.ts +134 -0
  141. package/dist/adminforth/types/FrontendAPI.d.ts.map +1 -0
  142. package/dist/adminforth/types/FrontendAPI.js +8 -0
  143. package/dist/adminforth/types/FrontendAPI.js.map +1 -0
  144. package/dist/dataConnectors/baseConnector.d.ts.map +1 -1
  145. package/dist/dataConnectors/baseConnector.js +7 -2
  146. package/dist/dataConnectors/baseConnector.js.map +1 -1
  147. package/dist/dataConnectors/postgres.js +3 -3
  148. package/dist/dataConnectors/postgres.js.map +1 -1
  149. package/dist/dev-demo/index.d.ts +3 -0
  150. package/dist/dev-demo/index.d.ts.map +1 -0
  151. package/dist/dev-demo/index.js +1052 -0
  152. package/dist/dev-demo/index.js.map +1 -0
  153. package/dist/modules/codeInjector.d.ts +4 -2
  154. package/dist/modules/codeInjector.d.ts.map +1 -1
  155. package/dist/modules/codeInjector.js +93 -69
  156. package/dist/modules/codeInjector.js.map +1 -1
  157. package/dist/modules/restApi.d.ts.map +1 -1
  158. package/dist/modules/restApi.js +33 -19
  159. package/dist/modules/restApi.js.map +1 -1
  160. package/dist/modules/utils.d.ts.map +1 -1
  161. package/dist/modules/utils.js +0 -1
  162. package/dist/modules/utils.js.map +1 -1
  163. package/dist/servers/express.d.ts.map +1 -1
  164. package/dist/servers/express.js +4 -1
  165. package/dist/servers/express.js.map +1 -1
  166. package/dist/spa/package-lock.json +64 -4
  167. package/dist/spa/package.json +1 -0
  168. package/dist/spa/src/App.vue +15 -25
  169. package/dist/spa/src/acl/Button.vue +21 -0
  170. package/dist/spa/src/acl/Link.vue +9 -0
  171. package/dist/spa/src/afcl/Button.vue +27 -0
  172. package/dist/spa/src/afcl/Input.vue +41 -0
  173. package/dist/spa/src/afcl/Link.vue +9 -0
  174. package/dist/spa/src/afcl/Select.vue +206 -0
  175. package/dist/spa/src/afcl/index.ts +6 -0
  176. package/dist/spa/src/components/Filters.vue +11 -5
  177. package/dist/spa/src/components/GroupsTable.vue +23 -23
  178. package/dist/spa/src/components/ValueRenderer.vue +3 -1
  179. package/dist/spa/src/renderers/CompactField.vue +1 -1
  180. package/dist/spa/src/renderers/CompactUUID.vue +1 -1
  181. package/dist/spa/src/renderers/CountryFlag.vue +3 -4
  182. package/dist/spa/src/renderers/HumanNumber.vue +3 -2
  183. package/dist/spa/src/renderers/RelativeTime.vue +3 -2
  184. package/dist/spa/src/router/index.ts +1 -1
  185. package/dist/spa/src/types/Back.ts +47 -13
  186. package/dist/spa/src/views/LoginView.vue +4 -15
  187. package/dist/spa/vite.config.ts +16 -34
  188. package/dist/types/Back.d.ts +21 -6
  189. package/dist/types/Back.d.ts.map +1 -1
  190. package/dist/types/Back.js.map +1 -1
  191. package/package.json +3 -2
@@ -0,0 +1,206 @@
1
+ <template>
2
+ <div class="relative inline-block afcl-select">
3
+ <div class="relative">
4
+ <input
5
+ type="text"
6
+ v-model="search"
7
+ @click="inputClick"
8
+ @input="inputInput"
9
+ class="block w-full pl-3 pr-10 py-2.5 border border-gray-300 rounded-md leading-5 bg-gray-50 placeholder-gray-500 sm:text-sm transition duration-150 ease-in-out dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white focus:ring-lightPrimary focus:border-lightPrimary dark:focus:ring-darkPrimary dark:focus:border-darkPrimary"
10
+ :placeholder="
11
+ selectedItems.length && !multiple ? '' : (showDropdown ? 'Search' : placeholder || 'Select...')
12
+ "
13
+ />
14
+
15
+ <div v-if="!multiple && selectedItems.length" class="absolute pointer-events-none inset-y-0 left-2 flex items-center pr-2 px-1">
16
+ <slot
17
+ name="selected-item"
18
+ :option="selectedItems[0]"
19
+ ></slot>
20
+ <span v-if="!$slots['selected-item']" class="text-lightPrimary dark:text-white font-medium ">
21
+ {{ selectedItems[0]?.label }}
22
+ </span>
23
+ </div>
24
+
25
+ <div class="absolute inset-y-0 right-2 flex items-center pointer-events-none">
26
+ <!-- triangle icon -->
27
+ <IconCaretDownSolid class="h-5 w-5 text-lightPrimary dark:text-gray-400 opacity-50 transition duration-150 ease-in"
28
+ :class="{ 'transform rotate-180': showDropdown }"
29
+ />
30
+ </div>
31
+ </div>
32
+ <div v-if="showDropdown" class="absolute z-10 mt-1 w-full bg-white shadow-lg dark:shadow-black dark:bg-gray-700 dark:border-gray-600 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm max-h-96">
33
+ <div
34
+ v-for="item in filteredItems"
35
+ :key="item.value"
36
+ class="px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400"
37
+ :class="{ 'bg-lightPrimaryOpacity dark:bg-darkPrimaryOpacity': selectedItems.includes(item) }"
38
+ @click="toogleItem(item)"
39
+ >
40
+ <slot name="item" :option="item"></slot>
41
+ <label v-if="!$slots.item" :for="item.value">{{ item.label }}</label>
42
+ </div>
43
+ <div v-if="!filteredItems.length" class="px-4 py-2 cursor-pointer text-gray-400 dark:text-gray-300">
44
+ No results found
45
+ </div>
46
+ </div>
47
+
48
+ <div v-if="multiple && selectedItems.length"
49
+ class="inset-y-0 left-2 flex items-center pr-2 flex-wrap gap-y-2 py-2"
50
+ >
51
+ <template v-for="item in selectedItems" :key="`afcl-select-${item.value}`">
52
+ <slot name="selected-item" :item="item"></slot>
53
+ <div v-if="!$slots['selected-item']"
54
+ class="bg-lightPrimaryOpacity text-lightPrimary text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-darkPrimaryOpacity dark:text-darkPrimary">
55
+ <span>{{ item.label }}</span>
56
+ <button
57
+ type="button"
58
+ @click="toogleItem(item)"
59
+ class="z-index-100 flex-shrink-0 ml-1 h-4 w-4 -mr-1 rounded-full inline-flex items-center justify-center text-gray-400 hover:text-gray-500 focus:outline-none focus:text-gray-500 focus:bg-gray-100"
60
+ >
61
+ <span class="sr-only">Remove item</span>
62
+ <svg class="h-2 w-2" stroke="currentColor" fill="none" viewBox="0 0 8 8">
63
+ <path
64
+ stroke-linecap="round"
65
+ stroke-linejoin="round"
66
+ stroke-width="1.5"
67
+ d="M1 1l6 6m0-6L1 7"
68
+ />
69
+ </svg>
70
+ </button>
71
+ </div>
72
+ </template>
73
+ </div>
74
+ </div>
75
+ </template>
76
+
77
+ <script setup lang="ts">
78
+ import { ref, computed, onMounted, onUnmounted, watch, type Ref } from 'vue';
79
+ import { IconCaretDownSolid } from '@iconify-prerendered/vue-flowbite';
80
+
81
+
82
+ const props = defineProps({
83
+ options: Array,
84
+ modelValue: {
85
+ default: undefined,
86
+ },
87
+ multiple: {
88
+ type: Boolean,
89
+ default: false,
90
+ },
91
+ placeholder: {
92
+ type: String,
93
+ default: '',
94
+ },
95
+ });
96
+
97
+ const emit = defineEmits(['update:modelValue']);
98
+
99
+ const search = ref('');
100
+ const showDropdown = ref(false);
101
+
102
+ const selectedItems: Ref<any[]> = ref([]);
103
+
104
+ function inputInput() {
105
+ if (!props.multiple && selectedItems.value.length) {
106
+ selectedItems.value = [];
107
+ emit('update:modelValue', null);
108
+ }
109
+ }
110
+
111
+ function updateFromProps() {
112
+ if (props.modelValue !== undefined) {
113
+ if (!props.multiple) {
114
+ const el = props.options.find(item => item.value === props.modelValue);
115
+ if (el) {
116
+ selectedItems.value = [el];
117
+ } else {
118
+ selectedItems.value = [];
119
+ }
120
+ } else {
121
+ selectedItems.value = props.options.filter(item => props.modelValue.includes(item.value));
122
+ }
123
+ }
124
+ }
125
+
126
+ function inputClick() {
127
+ if (!showDropdown.value) {
128
+ showDropdown.value = true;
129
+ } else {
130
+ if (!search.value) {
131
+ showDropdown.value = false;
132
+ }
133
+ }
134
+ }
135
+
136
+ onMounted(() => {
137
+ updateFromProps();
138
+
139
+ watch(() => props.modelValue, (value) => {
140
+ updateFromProps();
141
+ });
142
+
143
+ watch(() => props.options, () => {
144
+ updateFromProps();
145
+ });
146
+
147
+ addClickListener();
148
+
149
+ });
150
+
151
+ const filteredItems = computed(() => {
152
+ return props.options.filter(item =>
153
+ item.label.toLowerCase().includes(search.value.toLowerCase())
154
+ );
155
+ });
156
+
157
+ const handleClickOutside = (event) => {
158
+ if (!event.target.closest('.afcl-select')) {
159
+ showDropdown.value = false;
160
+ }
161
+ };
162
+
163
+ const addClickListener = () => {
164
+ document.addEventListener('click', handleClickOutside);
165
+ };
166
+
167
+ const removeClickListener = () => {
168
+ document.removeEventListener('click', handleClickOutside);
169
+ };
170
+
171
+ const toogleItem = (item) => {
172
+ if (selectedItems.value.includes(item)) {
173
+ selectedItems.value = selectedItems.value.filter(i => i !== item);
174
+ } else {
175
+ if (!props.multiple) {
176
+ selectedItems.value = [item];
177
+ } else {
178
+ selectedItems.value = [...selectedItems.value, item];
179
+ }
180
+ }
181
+ if (!props.multiple) {
182
+ showDropdown.value = false;
183
+ }
184
+ if (!props.multiple && search.value) {
185
+ search.value = '';
186
+ }
187
+
188
+ const list = selectedItems.value.map(item => item.value);
189
+ const updValue = list.length ? list : null;
190
+ let emitValue;
191
+ if (!props.multiple) {
192
+ emitValue = updValue ? updValue[0] : null;
193
+ } else {
194
+ emitValue = updValue;
195
+ }
196
+ emit('update:modelValue', emitValue);
197
+
198
+ };
199
+
200
+
201
+ onUnmounted(() => {
202
+ removeClickListener();
203
+ });
204
+
205
+
206
+ </script>
@@ -0,0 +1,6 @@
1
+
2
+
3
+ export { default as Select } from './Select.vue';
4
+ export { default as Link } from './Link.vue';
5
+ export { default as Button } from './Button.vue';
6
+ export { default as Input } from './Input.vue';
@@ -11,7 +11,7 @@
11
11
  <h5 id="drawer-navigation-label" class="text-base font-semibold text-gray-500 uppercase dark:text-gray-400">
12
12
  Filters
13
13
 
14
- <button type="button" @click="$emit('hide')" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 absolute end-2.5 inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white" >
14
+ <button type="button" @click="$emit('hide')" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 absolute end-2.5 inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white" >
15
15
  <svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
16
16
  <span class="sr-only">Close menu</span>
17
17
  </button>
@@ -22,23 +22,28 @@
22
22
  <li v-for="c in columnsWithFilter" :key="c">
23
23
  <p class="dark:text-gray-400">{{ c.label }}</p>
24
24
 
25
- <Dropdown
25
+ <Select
26
26
  v-if="c.foreignResource"
27
+ multiple
28
+ class="w-full"
27
29
  :options="columnOptions[c.name] || []"
28
30
  @update:modelValue="setFilterItem({ column: c, operator: 'in', value: $event || undefined })"
29
31
  :modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === 'in')?.value || []"
30
32
  />
31
- <Dropdown
33
+ <Select
34
+ multiple
35
+ class="w-full"
32
36
  v-else-if="c.type === 'boolean'"
33
37
  :options="[{ label: 'Yes', value: true }, { label: 'No', value: false }, { label: 'Unset', value: undefined }]"
34
38
  @update:modelValue="setFilterItem({ column: c, operator: 'in', value: $event || undefined })"
35
39
  :modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === 'in')?.value || []"
36
40
  />
37
41
 
38
- <Dropdown
42
+ <Select
43
+ multiple
44
+ class="w-full"
39
45
  v-else-if="c.enum"
40
46
  :options="c.enum"
41
- :allowCustom="c.allowCustom"
42
47
  @update:modelValue="setFilterItem({ column: c, operator: 'in', value: $event || undefined })"
43
48
  :modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === 'in')?.value || []"
44
49
  />
@@ -123,6 +128,7 @@ import { useRouter } from 'vue-router';
123
128
  import { computedAsync } from '@vueuse/core'
124
129
  import CustomRangePicker from "@/components/CustomRangePicker.vue";
125
130
  import { useFiltersStore } from '@/stores/filters';
131
+ import Select from '@/afcl/Select.vue';
126
132
 
127
133
  const filtersStore = useFiltersStore();
128
134
 
@@ -55,28 +55,28 @@
55
55
  />
56
56
  </template>
57
57
  <template v-else>
58
- <Dropdown
59
- single
60
- v-if="column.foreignResource"
61
- :options="columnOptions[column.name] || []"
62
- :placeholder = "columnOptions[column.name]?.length ?'Select...': 'There are no options available'"
63
- :modelValue="currentValues[column.name]"
64
- @update:modelValue="setCurrentValue(column.name, $event)"
65
- ></Dropdown>
66
- <Dropdown
67
- single
68
- v-else-if="column.enum"
69
- :options="column.enum"
70
- :modelValue="currentValues[column.name]"
71
- @update:modelValue="setCurrentValue(column.name, $event)"
72
- />
73
- <Dropdown
74
- single
75
- v-else-if="column.type === 'boolean'"
76
- :options="[{ label: 'Yes', value: true }, { label: 'No', value: false }, { label: 'Unset', value: null }]"
77
- :modelValue="currentValues[column.name]"
78
- @update:modelValue="setCurrentValue(column.name, $event)"
79
- />
58
+ <Select
59
+ class="w-full"
60
+ v-if="column.foreignResource"
61
+ :options="columnOptions[column.name] || []"
62
+ :placeholder = "columnOptions[column.name]?.length ?'Select...': 'There are no options available'"
63
+ :modelValue="currentValues[column.name]"
64
+ @update:modelValue="setCurrentValue(column.name, $event)"
65
+ ></Select>
66
+ <Select
67
+ class="w-full"
68
+ v-else-if="column.enum"
69
+ :options="column.enum"
70
+ :modelValue="currentValues[column.name]"
71
+ @update:modelValue="setCurrentValue(column.name, $event)"
72
+ ></Select>
73
+ <Select
74
+ class="w-full"
75
+ v-else-if="column.type === 'boolean'"
76
+ :options="[{ label: 'Yes', value: true }, { label: 'No', value: false }, { label: 'Unset', value: null }]"
77
+ :modelValue="currentValues[column.name]"
78
+ @update:modelValue="setCurrentValue(column.name, $event)"
79
+ ></Select>
80
80
  <input
81
81
  v-else-if="['integer'].includes(column.type)"
82
82
  type="number"
@@ -153,7 +153,7 @@
153
153
  <script setup>
154
154
  import { IconExclamationCircleSolid, IconEyeSlashSolid, IconEyeSolid } from '@iconify-prerendered/vue-flowbite';
155
155
  import CustomDatePicker from "@/components/CustomDatePicker.vue";
156
- import Dropdown from '@/components/Dropdown.vue';
156
+ import Select from '@/afcl/Select.vue';
157
157
  import AfTooltip from "./AfTooltip.vue";
158
158
  import { getCustomComponent } from '@/utils';
159
159
 
@@ -29,9 +29,11 @@
29
29
  <span v-else-if="column.type === 'richtext'">
30
30
  <div v-html="protectAgainstXSS(record[column.name])" class="allow-lists"></div>
31
31
  </span>
32
+ <span v-else-if="column.type === 'decimal'">
33
+ {{ checkEmptyValues(record[column.name] && parseFloat(record[column.name]), route.meta.type) }}
34
+ </span>
32
35
  <span v-else-if="column.type === 'json'">
33
36
  <JsonViewer :value="record[column.name]" :expandDepth="column.extra?.jsonCollapsedLevel" copyable sort :theme="coreStore.theme" />
34
-
35
37
  </span>
36
38
  <span v-else>
37
39
  {{ checkEmptyValues(record[column.name],route.meta.type) }}
@@ -25,7 +25,7 @@ const visualValue = computed(() => {
25
25
  return val;
26
26
  });
27
27
 
28
- const props = defineProps(['column', 'record', 'meta']);
28
+ const props = defineProps(['column', 'record', 'meta', 'resource', 'adminUser']);
29
29
 
30
30
  const id = ref();
31
31
 
@@ -25,7 +25,7 @@ const visualValue = computed(() => {
25
25
  return val;
26
26
  });
27
27
 
28
- const props = defineProps(['column', 'record', 'meta']);
28
+ const props = defineProps(['column', 'record', 'meta', 'resource', 'adminUser']);
29
29
 
30
30
  const id = ref();
31
31
 
@@ -51,14 +51,13 @@ const countryName = computed(() => {
51
51
  <style scoped lang="scss">
52
52
 
53
53
  .flag-icon {
54
- width: 2rem;
55
- height: 1.5rem;
54
+ width: 1.8rem;
55
+ height: 1.35rem;
56
56
  flex-shrink: 0;
57
57
 
58
58
  // border radius for background
59
59
  border-radius: 2px;
60
- // add some silkiness to the flag
61
- box-shadow: inset -1px -1px 0.5px 0px rgba(0 0 0 / 0.2), inset 1px 1px 0.5px 0px rgba(255 255 255 / 0.2);
60
+ box-shadow: inset -0.3px -0.3px 0.3px 0px rgba(0 0 0 / 0.2), inset 0.3px 0.3px 0.3px 0px rgba(255 255 255 / 0.2);
62
61
  }
63
62
 
64
63
  </style>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <AfTooltip class="flex items-center" >
2
+ <AfTooltip>
3
3
  {{ formattedValue }}
4
4
  <template #tooltip v-if="formattedValue">
5
5
  {{ formattedTooltipValue }}
@@ -11,7 +11,8 @@
11
11
  import { computed, ref, onMounted, nextTick } from 'vue';
12
12
  import AfTooltip from '@/components/AfTooltip.vue';
13
13
 
14
- const props = defineProps(['column', 'record']);
14
+ const props = defineProps(['column', 'record', 'meta', 'resource', 'adminUser']);
15
+
15
16
  const id = ref();
16
17
  const userLocale = ref(navigator.language || 'en-US');
17
18
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <AfTooltip class="flex items-center">
2
+ <AfTooltip>
3
3
  {{ relativeTime }}
4
4
  <template #tooltip v-if="relativeTime">
5
5
  {{ fullTime }}
@@ -14,11 +14,12 @@ import en from 'javascript-time-ago/locale/en';
14
14
  import TimeAgo from 'javascript-time-ago';
15
15
  import dayjs from 'dayjs';
16
16
 
17
+
17
18
  const id = ref();
18
19
 
19
20
  TimeAgo.addLocale(en);
20
21
 
21
- const props = defineProps(['column', 'record']);
22
+ const props = defineProps(['column', 'record', 'meta', 'resource', 'adminUser']);
22
23
 
23
24
  const userLocale = ref(navigator.language || 'en-US');
24
25
  const timeAgoFormatter = new TimeAgo(userLocale.value);
@@ -10,7 +10,7 @@ const router = createRouter({
10
10
  path: '/login',
11
11
  name: 'login',
12
12
  component: () => import('@/views/LoginView.vue'),
13
- meta: { title: 'login' },
13
+ meta: { title: 'login', customLayout: true },
14
14
  beforeEnter: async (to, from, next) => {
15
15
  if(localStorage.getItem('isAuthorized') === 'true'){
16
16
  next({name: 'home'})
@@ -13,6 +13,7 @@ import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections,
13
13
  export interface ICodeInjector {
14
14
  srcFoldersToSync: Object;
15
15
  allComponentNames: Object;
16
+ devServerPort: number;
16
17
 
17
18
  getServeDir(): string;
18
19
  }
@@ -521,13 +522,17 @@ export type AdminForthConfigMenuItem = {
521
522
  * Modify query to change how data is fetched from database.
522
523
  * Return ok: false and error: string to stop execution and show error message to user. Return ok: true to continue execution.
523
524
  */
524
- export type BeforeDataSourceRequestFunction = (params: {resource: AdminForthResource, adminUser: AdminUser, query: any,
525
+ export type BeforeDataSourceRequestFunction = (params: {
526
+ resource: AdminForthResource,
527
+ adminUser: AdminUser,
528
+ query: any,
525
529
  extra: {
526
530
  body: any,
527
531
  query: Record<string, string>,
528
532
  headers: Record<string, string>,
529
533
  cookies: Record<string, string>,
530
- }
534
+ },
535
+ adminforth: IAdminForth,
531
536
  }) => Promise<{ok: boolean, error?: string}>;
532
537
 
533
538
  /**
@@ -543,20 +548,35 @@ export type AfterDataSourceResponseFunction = (params: {
543
548
  query: Record<string, string>,
544
549
  headers: Record<string, string>,
545
550
  cookies: { key: string, value: string }[],
546
- }
551
+ },
552
+ adminforth: IAdminForth,
547
553
  }) => Promise<{ok: boolean, error?: string}>;
548
554
 
549
555
  /**
550
556
  * Modify record to change how data is saved to database.
551
557
  * Return ok: false and error: string to stop execution and show error message to user. Return ok: true to continue execution.
552
558
  */
553
- export type BeforeSaveFunction = (params: {resource: AdminForthResource, recordId: any, adminUser: AdminUser, record: any, oldRecord?: any}) => Promise<{ok: boolean, error?: string}>;
559
+ export type BeforeSaveFunction = (params: {
560
+ resource: AdminForthResource,
561
+ recordId: any,
562
+ adminUser: AdminUser,
563
+ record: any,
564
+ oldRecord?: any,
565
+ adminforth: IAdminForth,
566
+ }) => Promise<{ok: boolean, error?: string}>;
554
567
 
555
568
  /**
556
569
  * Modify record to change how data is saved to database.
557
570
  * Return ok: false and error: string to stop execution and show error message to user. Return ok: true to continue execution.
558
571
  */
559
- export type AfterSaveFunction = (params: {resource: AdminForthResource, recordId: any, adminUser: AdminUser, record: any, oldRecord?: any}) => Promise<{ok: boolean, error?: string}>;
572
+ export type AfterSaveFunction = (params: {
573
+ resource: AdminForthResource,
574
+ recordId: any,
575
+ adminUser: AdminUser,
576
+ record: any,
577
+ oldRecord?: any,
578
+ adminforth: IAdminForth,
579
+ }) => Promise<{ok: boolean, error?: string}>;
560
580
 
561
581
  /**
562
582
  * Allow to get user data before login confirmation, will triger when user try to login.
@@ -564,6 +584,7 @@ export type AfterSaveFunction = (params: {resource: AdminForthResource, recordId
564
584
  export type BeforeLoginConfirmationFunction = (params?: {
565
585
  adminUser: AdminUser,
566
586
  response: IAdminForthHttpResponse,
587
+ adminforth: IAdminForth,
567
588
  }) => Promise<{
568
589
  ok:boolean,
569
590
  error?:string,
@@ -982,19 +1003,32 @@ export type AllowedActions = {
982
1003
  all?: AllowedActionValue;
983
1004
  }
984
1005
 
1006
+ /**
1007
+ * General options for resource.
1008
+ */
1009
+ export type ResourceOptions = Omit<AdminForthResourceCommon['options'], 'allowedActions' | 'bulkActions'> & {
985
1010
 
986
-
987
- type ResourceOptions = Omit<AdminForthResourceCommon['options'], 'allowedActions' | 'bulkActions'> & {
988
-
989
- /**
990
- * Array of bulk actions which will be displayed in the list view.
991
- * Bulk actions allow user to perform actions on multiple records at once.
992
- *
1011
+ /**
1012
+ * Custom bulk actions list. Bulk actions available in list view when user selects multiple records by
1013
+ * using checkboxes.
993
1014
  */
994
1015
  bulkActions?: Array<AdminForthBulkAction>,
995
1016
 
996
1017
  /**
997
- * Object which describes allowed actions for user.
1018
+ * Allowed actions for resource.
1019
+ *
1020
+ * Example:
1021
+ *
1022
+ * ```ts
1023
+ * allowedActions: {
1024
+ * create: ({ resource, adminUser }) => {
1025
+ * // Allow only superadmin to create records
1026
+ * return adminUser.dbUser.role === 'superadmin';
1027
+ * },
1028
+ * delete: false, // disable delete action for all users
1029
+ * }
1030
+ * ```
1031
+ *
998
1032
  */
999
1033
  allowedActions?: AllowedActions,
1000
1034
  };
@@ -65,7 +65,7 @@
65
65
  ref="rememberInput"
66
66
  type="checkbox"
67
67
  value=""
68
- class="w-4 h-4 border border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-blue-300 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-600 dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800" />
68
+ class="w-4 h-4 border border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-lightPrimary focus:ring-opacity-50 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-600 dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800 checked:bg-lightPrimary checked:dark:bg-darkPrimary" />
69
69
  </div>
70
70
  <label for="remember" class="ms-2 text-sm font-medium text-gray-900 dark:text-gray-300">Remember me</label>
71
71
  </div>
@@ -85,8 +85,6 @@
85
85
  {{ error }}
86
86
  </div>
87
87
  </div>
88
-
89
-
90
88
 
91
89
  <div v-if="coreStore.config?.loginPromptHTML"
92
90
  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,20 +95,11 @@
97
95
  <span class="sr-only">Info</span>
98
96
  <div v-html="coreStore.config?.loginPromptHTML"></div>
99
97
  </div>
100
-
101
- <button
102
- @click="login"
103
- type="submit" class="flex items-center justify-center gap-1 w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
104
- <svg v-if="inProgress"
105
- aria-hidden="true" class="w-4 h-4 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>
106
-
98
+ <Button @click="login" :loader="inProgress" :disabled="inProgress" class="w-full">
107
99
  Login to your account
108
-
109
- </button>
100
+ </Button>
110
101
  </form>
111
102
 
112
-
113
-
114
103
  </div>
115
104
  </div>
116
105
  </div>
@@ -129,6 +118,7 @@ import { useUserStore } from '@/stores/user';
129
118
  import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
130
119
  import { callAdminForthApi, loadFile } from '@/utils';
131
120
  import { useRouter } from 'vue-router';
121
+ import Button from '@/afcl/Button.vue';
132
122
 
133
123
  const passwordInput = ref(null);
134
124
  const usernameInput = ref(null);
@@ -149,7 +139,6 @@ const backgroundPosition = computed(() => {
149
139
  });
150
140
 
151
141
  onMounted(async () => {
152
- await coreStore.getPublicConfig();
153
142
  if (coreStore.config?.demoCredentials) {
154
143
  console.log('Setting demo credentials');
155
144
  const [username, password] = coreStore.config.demoCredentials.split(':');
@@ -2,48 +2,30 @@ import { fileURLToPath, URL } from 'node:url'
2
2
 
3
3
  import { defineConfig } from 'vite'
4
4
  import vue from '@vitejs/plugin-vue'
5
- import { clear, error } from 'node:console';
5
+ import portfinder from 'portfinder';
6
6
 
7
-
8
- const customLogger = {
9
- info(msg: string) {
10
- // Filter out the lines containing '➜ Local:' or '➜ Network:'
11
- if (!msg.includes('➜')) {
12
- console.log(msg);
13
- }
14
- },
15
- warnOnce(msg: string) {
16
- console.warn('warn once', msg);
17
- if (!this.hasWarned) {
18
- this.hasWarned = true;
19
- }
20
- },
21
- warn(msg: string) {
22
- console.warn(msg);
23
- },
24
- error(msg: string) {
25
- console.error(msg);
26
- },
27
- clear() {
28
- console.clear();
29
- },
30
- clearScreen() {
31
- console.clear();
32
- },
33
- hasWarned: false,
34
- hasErrorLogged: (error: any): boolean => {
35
- return false;
36
- }
7
+ /**
8
+ * Find the next available port after a specified port.
9
+ * @param {number} startPort - The starting port to check.
10
+ * @returns {Promise<number>} - A promise that resolves with the next available port.
11
+ */
12
+ async function getNextAvailablePort(startPort) {
13
+ return await portfinder.getPortPromise({ port: startPort });
37
14
  };
38
15
 
16
+ const appPort = await getNextAvailablePort(5173);
17
+ const hmrPort = await getNextAvailablePort(5273);
18
+ console.log(`App port: ${appPort}. HMR port: ${hmrPort}`);
39
19
  // https://vitejs.dev/config/
40
20
  export default defineConfig({
41
21
  base: process.env.VITE_ADMINFORTH_PUBLIC_PATH || '/',
42
22
  server: {
43
- port: 5173,
44
- strictPort: true, // better predictability
23
+ port: appPort,
24
+ hmr: {
25
+ path: '/adminforth-dev-server-ws', // Set your custom WebSocket path here
26
+ port: hmrPort,
27
+ },
45
28
  },
46
- customLogger,
47
29
  plugins: [
48
30
  vue(),
49
31
  ],