adminforth 1.3.55-next.0 → 1.3.55

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 (63) hide show
  1. package/dist/spa/.eslintrc.cjs +14 -0
  2. package/dist/spa/README.md +39 -0
  3. package/dist/spa/env.d.ts +1 -0
  4. package/dist/spa/index.html +23 -0
  5. package/dist/spa/package-lock.json +4659 -0
  6. package/dist/spa/package.json +52 -0
  7. package/dist/spa/postcss.config.js +6 -0
  8. package/dist/spa/public/assets/favicon.png +0 -0
  9. package/dist/spa/src/App.vue +418 -0
  10. package/dist/spa/src/assets/base.css +2 -0
  11. package/dist/spa/src/assets/logo.svg +19 -0
  12. package/dist/spa/src/components/AcceptModal.vue +45 -0
  13. package/dist/spa/src/components/Breadcrumbs.vue +41 -0
  14. package/dist/spa/src/components/BreadcrumbsWithButtons.vue +26 -0
  15. package/dist/spa/src/components/CustomDatePicker.vue +176 -0
  16. package/dist/spa/src/components/CustomDateRangePicker.vue +218 -0
  17. package/dist/spa/src/components/CustomRangePicker.vue +156 -0
  18. package/dist/spa/src/components/Dropdown.vue +168 -0
  19. package/dist/spa/src/components/Filters.vue +222 -0
  20. package/dist/spa/src/components/HelloWorld.vue +17 -0
  21. package/dist/spa/src/components/MenuLink.vue +27 -0
  22. package/dist/spa/src/components/ResourceForm.vue +325 -0
  23. package/dist/spa/src/components/ResourceListTable.vue +466 -0
  24. package/dist/spa/src/components/SingleSkeletLoader.vue +13 -0
  25. package/dist/spa/src/components/SkeleteLoader.vue +23 -0
  26. package/dist/spa/src/components/ThreeDotsMenu.vue +43 -0
  27. package/dist/spa/src/components/Toast.vue +78 -0
  28. package/dist/spa/src/components/ValueRenderer.vue +141 -0
  29. package/dist/spa/src/components/icons/IconCalendar.vue +5 -0
  30. package/dist/spa/src/components/icons/IconCommunity.vue +7 -0
  31. package/dist/spa/src/components/icons/IconDocumentation.vue +7 -0
  32. package/dist/spa/src/components/icons/IconEcosystem.vue +7 -0
  33. package/dist/spa/src/components/icons/IconSupport.vue +7 -0
  34. package/dist/spa/src/components/icons/IconTime.vue +5 -0
  35. package/dist/spa/src/components/icons/IconTooling.vue +19 -0
  36. package/dist/spa/src/composables/useFrontendApi.ts +26 -0
  37. package/dist/spa/src/composables/useStores.ts +131 -0
  38. package/dist/spa/src/index.scss +31 -0
  39. package/dist/spa/src/main.ts +18 -0
  40. package/dist/spa/src/renderers/CompactUUID.vue +48 -0
  41. package/dist/spa/src/renderers/CountryFlag.vue +69 -0
  42. package/dist/spa/src/router/index.ts +59 -0
  43. package/dist/spa/src/spa_types/core.ts +53 -0
  44. package/dist/spa/src/stores/core.ts +148 -0
  45. package/dist/spa/src/stores/filters.ts +27 -0
  46. package/dist/spa/src/stores/modal.ts +48 -0
  47. package/dist/spa/src/stores/toast.ts +31 -0
  48. package/dist/spa/src/stores/user.ts +72 -0
  49. package/dist/spa/src/types/AdminForthConfig.ts +1762 -0
  50. package/dist/spa/src/types/FrontendAPI.ts +143 -0
  51. package/dist/spa/src/utils.ts +160 -0
  52. package/dist/spa/src/views/CreateView.vue +167 -0
  53. package/dist/spa/src/views/EditView.vue +170 -0
  54. package/dist/spa/src/views/ListView.vue +352 -0
  55. package/dist/spa/src/views/LoginView.vue +192 -0
  56. package/dist/spa/src/views/ResourceParent.vue +17 -0
  57. package/dist/spa/src/views/ShowView.vue +194 -0
  58. package/dist/spa/tailwind.config.js +17 -0
  59. package/dist/spa/tsconfig.app.json +14 -0
  60. package/dist/spa/tsconfig.json +11 -0
  61. package/dist/spa/tsconfig.node.json +19 -0
  62. package/dist/spa/vite.config.ts +56 -0
  63. package/package.json +2 -2
@@ -0,0 +1,352 @@
1
+ <template>
2
+ <div class="relative">
3
+ <Teleport to="body">
4
+ <Filters
5
+ :columns="coreStore.resource?.columns"
6
+ :columnsMinMax="columnsMinMax" :show="filtersShow"
7
+ @hide="filtersShow = false"
8
+ />
9
+ </Teleport>
10
+
11
+ <component
12
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.beforeBreadcrumbs || []"
13
+ :is="getCustomComponent(c)"
14
+ :meta="c.meta"
15
+ :resource="coreStore.resource"
16
+ :adminUser="coreStore.adminUser"
17
+ />
18
+
19
+ <BreadcrumbsWithButtons>
20
+ <button
21
+ @click="()=>{checkboxes = []}"
22
+ v-if="checkboxes.length"
23
+ data-tooltip-target="tooltip-remove-all"
24
+ class="flex gap-1 items-center py-1 px-3 me-2 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-darkListTable dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 rounded-default"
25
+ >
26
+ <IconBanOutline class="w-5 h-5 "/>
27
+
28
+ <div id="tooltip-remove-all" role="tooltip"
29
+ class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700">
30
+ Remove selection
31
+ <div class="tooltip-arrow" data-popper-arrow></div>
32
+ </div>
33
+ </button>
34
+
35
+ <button
36
+ v-if="checkboxes.length"
37
+ v-for="(action,i) in coreStore.resource?.options?.bulkActions"
38
+ :key="action.id"
39
+ @click="startBulkAction(action.id)"
40
+ class="flex gap-1 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"
41
+ :class="{'bg-red-100 text-red-800 border-red-400 dark:bg-red-700 dark:text-red-400 dark:border-red-400':action.state==='danger', 'bg-green-100 text-green-800 border-green-400 dark:bg-green-700 dark:text-green-400 dark:border-green-400':action.state==='success',
42
+ 'bg-lightPrimaryOpacity text-lightPrimary border-blue-400 dark:bg-blue-700 dark:text-blue-400 dark:border-blue-400':action.state==='active',
43
+ }"
44
+ >
45
+ <component
46
+ v-if="action.icon"
47
+ :is="getIcon(action.icon)"
48
+ class="w-5 h-5 text-gray-500 transition duration-75 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white"></component>
49
+
50
+ {{ `${action.label} (${checkboxes.length})` }}
51
+ </button>
52
+
53
+ <RouterLink v-if="coreStore.resource?.options?.allowedActions?.create"
54
+ :to="{ name: 'resource-create', params: { resourceId: $route.params.resourceId } }"
55
+ class="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"
56
+ >
57
+ <IconPlusOutline class="w-4 h-4 me-2"/>
58
+ Create
59
+ </RouterLink>
60
+
61
+ <button
62
+ class="flex gap-1 items-center py-1 px-3 me-2 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"
63
+ @click="()=>{filtersShow = !filtersShow}"
64
+ v-if="coreStore.resource?.options?.allowedActions?.filter"
65
+ >
66
+ <IconFilterOutline class="w-4 h-4 me-2"/>
67
+ Filter
68
+ <span
69
+ class="bg-red-100 text-red-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-gray-700 dark:text-red-400 border border-red-400"
70
+ v-if="filtersStore.filters.length">
71
+ {{ filtersStore.filters.length }}
72
+ </span>
73
+ </button>
74
+
75
+ <ThreeDotsMenu
76
+ :threeDotsDropdownItems="coreStore.resourceOptions?.pageInjections?.list?.threeDotsDropdownItems"
77
+ ></ThreeDotsMenu>
78
+ </BreadcrumbsWithButtons>
79
+
80
+ <component
81
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.afterBreadcrumbs || []"
82
+ :is="getCustomComponent(c)"
83
+ :meta="c.meta"
84
+ :resource="coreStore.resource"
85
+ :adminUser="coreStore.adminUser"
86
+ />
87
+
88
+ <ResourceListTable
89
+ :resource="coreStore.resource"
90
+ :rows="rows"
91
+ :page="page"
92
+ @update:page="page = $event"
93
+ @update:sort="sort = $event"
94
+ @update:checkboxes="checkboxes = $event"
95
+ @update:records="getList"
96
+ :sort="sort"
97
+ :pageSize="pageSize"
98
+ :totalRows="totalRows"
99
+ :checkboxes="checkboxes"
100
+ />
101
+
102
+ <component
103
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.bottom || []"
104
+ :is="getCustomComponent(c)"
105
+ :meta="c.meta"
106
+ :resource="coreStore.resource"
107
+ :adminUser="coreStore.adminUser"
108
+ />
109
+
110
+ </div>
111
+ </template>
112
+
113
+ <script setup>
114
+ import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
115
+ import ResourceListTable from '@/components/ResourceListTable.vue';
116
+ import { useCoreStore } from '@/stores/core';
117
+ import { useFiltersStore } from '@/stores/filters';
118
+ import { callAdminForthApi, currentQuery, getIcon, setQuery } from '@/utils';
119
+ import { computed, onMounted, ref, watch } from 'vue';
120
+ import { useRoute } from 'vue-router';
121
+ import { showErrorTost } from '@/composables/useFrontendApi'
122
+ import { getCustomComponent, initThreeDotsDropdown } from '@/utils';
123
+ import { initFlowbite } from 'flowbite';
124
+ import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
125
+
126
+
127
+ import {
128
+ IconBanOutline,
129
+ IconFilterOutline,
130
+ IconPlusOutline
131
+ } from '@iconify-prerendered/vue-flowbite';
132
+
133
+ import Filters from '@/components/Filters.vue';
134
+
135
+ const filtersShow = ref(false);
136
+
137
+ const coreStore = useCoreStore();
138
+ const filtersStore = useFiltersStore();
139
+
140
+ const route = useRoute();
141
+
142
+ const page = ref(1);
143
+ const columnsMinMax = ref({});
144
+ const sort = ref([]);
145
+
146
+ watch(() => sort, async (to, from) => {
147
+ // in store sort might be needed for plugins
148
+ filtersStore.setSort(sort.value);
149
+ }, {deep: true});
150
+
151
+ const rows = ref(null);
152
+ const totalRows = ref(0);
153
+ const checkboxes = ref([]);
154
+
155
+ const DEFAULT_PAGE_SIZE = 10;
156
+
157
+
158
+ const pageSize = computed(() => coreStore.resource?.options?.listPageSize || DEFAULT_PAGE_SIZE);
159
+
160
+
161
+ async function getList() {
162
+ rows.value = null;
163
+ const data = await callAdminForthApi({
164
+ path: '/get_resource_data',
165
+ method: 'POST',
166
+ body: {
167
+ source: 'list',
168
+ resourceId: route.params.resourceId,
169
+ limit: pageSize.value,
170
+ offset: ((page.value || 1) - 1) * pageSize.value,
171
+ filters: filtersStore.filters,
172
+ sort: sort.value,
173
+ }
174
+ });
175
+ if (data.error) {
176
+ showErrorTost(data.error);
177
+ rows.value = [];
178
+ totalRows.value = 0;
179
+ return;
180
+ }
181
+ rows.value = data.data?.map(row => {
182
+ row._primaryKeyValue = row[coreStore.resource.columns.find(c => c.primaryKey).name];
183
+ return row;
184
+ });
185
+ totalRows.value = data.total;
186
+ await new Promise(resolve => setTimeout(resolve, 0));
187
+ initFlowbite(); // for tooltips in table
188
+
189
+ }
190
+
191
+ async function startBulkAction(actionId) {
192
+ const action = coreStore.resource.options.bulkActions.find(a => a.id === actionId);
193
+ if (action.confirm) {
194
+ const confirmed = await window.adminforth.confirm({
195
+ message: action.confirm,
196
+ });
197
+ if (!confirmed) {
198
+ return;
199
+ }
200
+ }
201
+
202
+ const data = await callAdminForthApi({
203
+ path: '/start_bulk_action',
204
+ method: 'POST',
205
+ body: {
206
+ resourceId: route.params.resourceId,
207
+ actionId: actionId,
208
+ recordIds: checkboxes.value
209
+
210
+ }
211
+ });
212
+ if (data?.ok) {
213
+ checkboxes.value = [];
214
+ await getList();
215
+
216
+ if (data.successMessage) {
217
+ window.adminforth.alert({
218
+ message: data.successMessage,
219
+ variant: 'success'
220
+ });
221
+ }
222
+
223
+ }
224
+ if (data?.error) {
225
+ showErrorTost(data.error);
226
+ }
227
+ }
228
+
229
+
230
+ class SortQuerySerializer {
231
+ static serialize(sort) {
232
+ return sort.map(s => `${s.field}__${s.direction}`).join(',');
233
+ }
234
+ static deserialize(str) {
235
+ return str.split(',').map(s => {
236
+ const [field, direction] = s.split('__');
237
+ return { field, direction };
238
+ });
239
+ }
240
+ }
241
+
242
+
243
+ async function init() {
244
+
245
+ await coreStore.fetchResourceFull({
246
+ resourceId: route.params.resourceId
247
+ });
248
+
249
+ initFlowbite();
250
+
251
+ // !!! clear filters should be in same tick with sort assignment so that watch can catch it as one change
252
+
253
+ // try to init filters from query params
254
+ const filters = Object.keys(route.query).filter(k => k.startsWith('filter__')).map(k => {
255
+ const [_, field, operator] = k.split('__');
256
+ return {
257
+ field,
258
+ operator,
259
+ value: JSON.parse(decodeURIComponent(route.query[k]))
260
+ }
261
+ });
262
+ if (filters.length) {
263
+ filtersStore.setFilters(filters);
264
+ } else {
265
+ filtersStore.clearFilters();
266
+ }
267
+
268
+ if (route.query.sort) {
269
+ sort.value = SortQuerySerializer.deserialize(route.query.sort);
270
+ } else if (coreStore.resource.options?.defaultSort) {
271
+ sort.value = [{
272
+ field: coreStore.resource.options.defaultSort.columnName,
273
+ direction: coreStore.resource.options.defaultSort.direction
274
+ }];
275
+ } else {
276
+ sort.value = [];
277
+ }
278
+ // page init should be also in same tick
279
+ if (route.query.page) {
280
+ page.value = parseInt(route.query.page);
281
+ }
282
+
283
+ // await getList(); - Not needed here, watch will trigger it
284
+ columnsMinMax.value = await callAdminForthApi({
285
+ path: '/get_min_max_for_columns',
286
+ method: 'POST',
287
+ body: {
288
+ resourceId: route.params.resourceId
289
+ }
290
+ });
291
+ }
292
+
293
+ watch([page, sort, () => filtersStore.filters], async () => {
294
+ console.log('🔄️ page/sort/filter change fired, page:', page.value);
295
+
296
+ await getList();
297
+ }, { deep: true });
298
+
299
+ window.adminforth.list.refresh = async () => {
300
+ await getList();
301
+ }
302
+
303
+ let initInProcess = false;
304
+
305
+ watch(() => filtersStore.filters, async (to, from) => {
306
+ if (initInProcess) {
307
+ return;
308
+ }
309
+ console.log('🔄️ filters changed', JSON.stringify(to))
310
+ page.value = 1;
311
+ checkboxes.value = [];
312
+ // update query param for each filter as filter_<column_name>=value
313
+ const query = {};
314
+ const currentQ = currentQuery();
315
+ filtersStore.filters.forEach(f => {
316
+ if (f.value) {
317
+ query[`filter__${f.field}__${f.operator}`] = encodeURIComponent(JSON.stringify(f.value));
318
+ }
319
+ });
320
+ // set every key in currentQ which starts with filter_ to undefined if it is not in query
321
+ Object.keys(currentQ).forEach(k => {
322
+ if (k.startsWith('filter_') && !query[k]) {
323
+ query[k] = undefined;
324
+ }
325
+ });
326
+ setQuery(query);
327
+ }, {deep: true});
328
+
329
+ onMounted(async () => {
330
+ initInProcess = true;
331
+ await init();
332
+ initThreeDotsDropdown();
333
+ initInProcess = false;
334
+ });
335
+
336
+ watch([page], async () => {
337
+ setQuery({ page: page.value });
338
+ });
339
+
340
+
341
+
342
+
343
+ watch([sort], async () => {
344
+ if (!sort.value.length) {
345
+ setQuery({ sort: undefined });
346
+ return;
347
+ }
348
+ setQuery({ sort: SortQuerySerializer.serialize(sort.value) });
349
+ });
350
+
351
+
352
+ </script>
@@ -0,0 +1,192 @@
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"
3
+ :style="coreStore.config?.loginBackgroundImage && backgroundPosition === 'over' ? {
4
+ 'background-image': 'url(' + loadFile(coreStore.config?.loginBackgroundImage) + ')',
5
+ 'background-size': 'cover',
6
+ 'background-position': 'center',
7
+ 'background-blend-mode': 'darken'
8
+ }: {}"
9
+ >
10
+
11
+ <img v-if="coreStore.config?.loginBackgroundImage && backgroundPosition !== 'over'"
12
+ :src="loadFile(coreStore.config?.loginBackgroundImage)"
13
+ class="position-absolute top-0 left-0 h-screen object-cover w-0"
14
+ :class="{
15
+ '1/2': 'md:w-1/2',
16
+ '1/3': 'md:w-1/3',
17
+ '2/3': 'md:w-2/3',
18
+ '3/4': 'md:w-3/4',
19
+ '2/5': 'md:w-2/5',
20
+ '3/5': 'md:w-3/5',
21
+ }[backgroundPosition]"
22
+ />
23
+
24
+ <!-- Main modal -->
25
+ <div id="authentication-modal" tabindex="-1"
26
+ class="overflow-y-auto flex flex-grow
27
+ overflow-x-hidden z-50 min-w-[350px] justify-center items-center md:inset-0 h-[calc(100%-1rem)] max-h-full">
28
+ <div class="relative p-4 w-full max-h-full max-w-[400px]">
29
+ <!-- Modal content -->
30
+ <div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black" >
31
+ <!-- Modal header -->
32
+ <div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t dark:border-gray-600">
33
+ <h3 class="text-xl font-semibold text-gray-900 dark:text-white">
34
+ Sign in to {{ coreStore.config?.brandName }}
35
+ </h3>
36
+ </div>
37
+ <!-- Modal body -->
38
+ <div class="p-4 md:p-5">
39
+ <form class="space-y-4" @submit.prevent>
40
+ <div>
41
+ <label for="username" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your {{ coreStore.config?.usernameFieldName?.toLowerCase() }}</label>
42
+ <input type="username" name="username" id="username"
43
+ ref="usernameInput"
44
+ @keydown.enter="passwordInput.focus()"
45
+ class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" placeholder="name@company.com" required />
46
+ </div>
47
+ <div class="relative">
48
+ <label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your password</label>
49
+ <input
50
+ ref="passwordInput"
51
+ @keydown.enter="login"
52
+ :type="!showPw ? 'password': 'text'" name="password" id="password" placeholder="••••••••" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" required />
53
+ <button type="button" @click="showPw = !showPw" class="absolute top-12 right-3 -translate-y-1/2 text-gray-400 dark:text-gray-300">
54
+ <IconEyeSolid class="w-5 h-5" v-if="!showPw" />
55
+ <IconEyeSlashSolid class="w-5 h-5" v-else />
56
+ </button>
57
+ </div>
58
+
59
+ <div v-if="coreStore.config.rememberMeDays"
60
+ class="flex items-start mb-5"
61
+ :title="`Stay logged in for ${coreStore.config.rememberMeDays} days`"
62
+ >
63
+ <div class="flex items-center h-5">
64
+ <input id="remember"
65
+ ref="rememberInput"
66
+ type="checkbox"
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" />
69
+ </div>
70
+ <label for="remember" class="ms-2 text-sm font-medium text-gray-900 dark:text-gray-300">Remember me</label>
71
+ </div>
72
+
73
+ <component
74
+ v-for="c in coreStore?.config?.loginPageInjections?.underInputs || []"
75
+ :is="getCustomComponent(c)"
76
+ :meta="c.meta"
77
+ />
78
+
79
+ <div v-if="error" class="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">
80
+ <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">
81
+ <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"/>
82
+ </svg>
83
+ <span class="sr-only">Info</span>
84
+ <div>
85
+ {{ error }}
86
+ </div>
87
+ </div>
88
+
89
+
90
+
91
+ <div v-if="coreStore.config?.loginPromptHTML"
92
+ 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"
93
+ >
94
+ <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">
95
+ <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"/>
96
+ </svg>
97
+ <span class="sr-only">Info</span>
98
+ <div v-html="coreStore.config?.loginPromptHTML"></div>
99
+ </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
+
107
+ Login to your account
108
+
109
+ </button>
110
+ </form>
111
+
112
+
113
+
114
+ </div>
115
+ </div>
116
+ </div>
117
+ </div>
118
+
119
+ </div>
120
+ </template>
121
+
122
+
123
+ <script setup>
124
+
125
+ import { getCustomComponent } from '@/utils';
126
+ import { onMounted, ref, computed } from 'vue';
127
+ import { useCoreStore } from '@/stores/core';
128
+ import { useUserStore } from '@/stores/user';
129
+ import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
130
+ import { callAdminForthApi, loadFile } from '@/utils';
131
+ import { useRouter } from 'vue-router';
132
+
133
+ const passwordInput = ref(null);
134
+ const usernameInput = ref(null);
135
+ const rememberInput = ref(null);
136
+
137
+ const router = useRouter();
138
+ const inProgress = ref(false);
139
+
140
+ const coreStore = useCoreStore();
141
+ const user = useUserStore();
142
+
143
+ const showPw = ref(false);
144
+
145
+ const error = ref(null);
146
+
147
+ const backgroundPosition = computed(() => {
148
+ return coreStore.config?.loginBackgroundPosition || '1/2';
149
+ });
150
+
151
+ onMounted(async () => {
152
+ await coreStore.getPublicConfig();
153
+ if (coreStore.config?.demoCredentials) {
154
+ console.log('Setting demo credentials');
155
+ const [username, password] = coreStore.config.demoCredentials.split(':');
156
+ usernameInput.value.value = username;
157
+ passwordInput.value.value = password;
158
+ }
159
+ usernameInput.value.focus();
160
+ });
161
+
162
+
163
+ async function login() {
164
+ const username = usernameInput.value.value;
165
+ const password = passwordInput.value.value;
166
+
167
+ if (!username || !password) {
168
+ return;
169
+ }
170
+ inProgress.value = true;
171
+ const resp = await callAdminForthApi({
172
+ path: '/login',
173
+ method: 'POST',
174
+ body: {
175
+ username,
176
+ password,
177
+ rememberMe: rememberInput.value?.checked,
178
+ }
179
+ });
180
+ inProgress.value = false;
181
+ if (resp.error) {
182
+ error.value = resp.error;
183
+ } else if (resp.redirectTo) {
184
+ router.push(resp.redirectTo);
185
+ } else {
186
+ error.value = null;
187
+ await user.finishLogin();
188
+ }
189
+ }
190
+
191
+
192
+ </script>
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <div :key="`${$route?.params.resourceId}---${$route?.params.primaryKey}`" class="p-4">
3
+ <RouterView/>
4
+ </div>
5
+ </template>
6
+
7
+ <style>
8
+ </style>
9
+
10
+ <script setup>
11
+
12
+
13
+ import { useCoreStore } from '@/stores/core';
14
+
15
+ const coreStore = useCoreStore()
16
+
17
+ </script>