adminforth 1.2.39 → 1.2.40
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.
- package/dataConnectors/mongo.ts +7 -5
- package/dist/dataConnectors/mongo.js +4 -1
- package/dist/spa/index.html +4 -4
- package/dist/spa/package-lock.json +5 -206
- package/dist/spa/package.json +2 -8
- package/dist/spa/public/favicon.ico +0 -0
- package/dist/spa/spa/public/favicon.ico +0 -0
- package/dist/spa/spa/src/views/HomeView.vue +8 -0
- package/dist/spa/src/App.vue +72 -171
- package/dist/spa/src/assets/logo.svg +1 -19
- package/dist/spa/src/components/AcceptModal.vue +10 -3
- package/dist/spa/src/components/BreadcrumbsWithButtons.vue +1 -1
- package/dist/spa/src/components/CustomDatePicker.vue +6 -19
- package/dist/spa/src/components/CustomDateRangePicker.vue +5 -14
- package/dist/spa/src/components/Dropdown.vue +5 -19
- package/dist/spa/src/components/Filters.vue +37 -91
- package/dist/spa/src/components/MenuLink.vue +2 -2
- package/dist/spa/src/components/ResourceForm.vue +103 -163
- package/dist/spa/src/components/ValueRenderer.vue +6 -22
- package/dist/spa/src/main.ts +1 -1
- package/dist/spa/src/router/index.ts +19 -30
- package/dist/spa/src/stores/core.ts +59 -65
- package/dist/spa/src/stores/modal.ts +3 -13
- package/dist/spa/src/utils.ts +8 -65
- package/dist/spa/src/views/CreateView.vue +16 -76
- package/dist/spa/src/views/EditView.vue +14 -76
- package/dist/spa/src/views/HomeView.vue +8 -0
- package/dist/spa/src/views/ListView.vue +360 -88
- package/dist/spa/src/views/LoginView.vue +5 -17
- package/dist/spa/src/views/ResourceParent.vue +1 -1
- package/dist/spa/src/views/ShowView.vue +19 -114
- package/dist/spa/tailwind.config.js +2 -5
- package/dist/spa/vite.config.ts +0 -6
- package/dist/types.js +30 -0
- package/package.json +1 -1
- package/dist/spa/public/assets/favicon.png +0 -0
- package/dist/spa/src/components/CustomRangePicker.vue +0 -148
- package/dist/spa/src/components/ResourceListTable.vue +0 -419
- package/dist/spa/src/components/Toast.vue +0 -66
- package/dist/spa/src/composables/useFrontendApi.ts +0 -26
- package/dist/spa/src/composables/useStores.ts +0 -113
- package/dist/spa/src/spa_types/core.ts +0 -51
- package/dist/spa/src/stores/filters.ts +0 -22
- package/dist/spa/src/stores/toast.ts +0 -15
- package/dist/spa/src/stores/user.ts +0 -54
|
@@ -1,419 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- table -->
|
|
3
|
-
<div class="relative overflow-x-auto shadow-list-table-shadow dark:shadow-black overflow-y-hidden rounded-default">
|
|
4
|
-
|
|
5
|
-
<!-- skelet loader -->
|
|
6
|
-
<div role="status" v-if="!resource || !resource.columns"
|
|
7
|
-
class="max-w p-4 space-y-4 divide-y divide-gray-200 rounded shadow animate-pulse dark:divide-gray-700 md:p-6 dark:border-gray-700">
|
|
8
|
-
<div class="flex items-center justify-between h-16">
|
|
9
|
-
<div>
|
|
10
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-600 w-24 mb-2.5"></div>
|
|
11
|
-
<div class="w-32 h-2 bg-gray-200 rounded-full dark:bg-gray-700"></div>
|
|
12
|
-
</div>
|
|
13
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-700 w-12"></div>
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
<div class="flex items-center justify-between h-16 pt-4" v-for="i in new Array(10)">
|
|
17
|
-
<div>
|
|
18
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-600 w-24 mb-2.5"></div>
|
|
19
|
-
<div class="w-32 h-2 bg-gray-200 rounded-full dark:bg-gray-700"></div>
|
|
20
|
-
</div>
|
|
21
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-700 w-12"></div>
|
|
22
|
-
</div>
|
|
23
|
-
<span class="sr-only">Loading...</span>
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
<table v-else class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 rounded-default">
|
|
27
|
-
<thead class="text-xs text-view-table-heading-text bg-list-view-table-heading dark:bg-gray-700 dark:text-gray-400">
|
|
28
|
-
<tr>
|
|
29
|
-
<th scope="col" class="p-4">
|
|
30
|
-
<div v-if="rows && rows.length" class="flex items-center">
|
|
31
|
-
<input id="checkbox-all-search" type="checkbox" :checked="allFromThisPageChecked" @change="selectAll()"
|
|
32
|
-
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
|
|
33
|
-
<label for="checkbox-all-search" class="sr-only">checkbox</label>
|
|
34
|
-
</div>
|
|
35
|
-
</th>
|
|
36
|
-
|
|
37
|
-
<th v-for="c in columnsListed" scope="col" class="px-6 py-3">
|
|
38
|
-
<div @click="() => c.sortable && onSortButtonClick(c.name)" class="flex items-center " :class="{'cursor-pointer':c.sortable}">
|
|
39
|
-
{{ c.label }}
|
|
40
|
-
|
|
41
|
-
<div v-if="c.sortable"
|
|
42
|
-
:style="{ 'color':ascArr.includes(c.name)?'green':descArr.includes(c.name)?'red':'currentColor'}">
|
|
43
|
-
<svg v-if="ascArr.includes(c.name) || descArr.includes(c.name)" class="w-3 h-3 ms-1.5"
|
|
44
|
-
:class="{'rotate-180':descArr.includes(c.name)}" viewBox="0 0 24 24">
|
|
45
|
-
<path
|
|
46
|
-
d="M8.574 11.024h6.852a2.075 2.075 0 0 0 1.847-1.086 1.9 1.9 0 0 0-.11-1.986L13.736 2.9a2.122 2.122 0 0 0-3.472 0L6.837 7.952a1.9 1.9 0 0 0-.11 1.986 2.074 2.074 0 0 0 1.847"/>
|
|
47
|
-
</svg>
|
|
48
|
-
<svg v-else class="w-3 h-3 ms-1.5 opacity-30" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
|
|
49
|
-
fill='currentColor'
|
|
50
|
-
viewBox="0 0 24 24">
|
|
51
|
-
<path
|
|
52
|
-
d="M8.574 11.024h6.852a2.075 2.075 0 0 0 1.847-1.086 1.9 1.9 0 0 0-.11-1.986L13.736 2.9a2.122 2.122 0 0 0-3.472 0L6.837 7.952a1.9 1.9 0 0 0-.11 1.986 2.074 2.074 0 0 0 1.847 1.086Zm6.852 1.952H8.574a2.072 2.072 0 0 0-1.847 1.087 1.9 1.9 0 0 0 .11 1.985l3.426 5.05a2.123 2.123 0 0 0 3.472 0l3.427-5.05a1.9 1.9 0 0 0 .11-1.985 2.074 2.074 0 0 0-1.846-1.087Z"/>
|
|
53
|
-
</svg>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</th>
|
|
57
|
-
|
|
58
|
-
<th scope="col" class="px-6 py-3">
|
|
59
|
-
Actions
|
|
60
|
-
</th>
|
|
61
|
-
</tr>
|
|
62
|
-
</thead>
|
|
63
|
-
<tbody>
|
|
64
|
-
<tr v-if="!rows" class="bg-list-view-table-bg border-b dark:bg-gray-800 dark:border-gray-700">
|
|
65
|
-
<td :colspan="resource?.columns.length + 2">
|
|
66
|
-
|
|
67
|
-
<div role="status"
|
|
68
|
-
class="max-w p-4 space-y-4 divide-y divide-gray-200 rounded animate-pulse dark:divide-gray-700 md:p-6 dark:border-gray-700">
|
|
69
|
-
<div class="flex items-center justify-between">
|
|
70
|
-
<div>
|
|
71
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-600 w-24 mb-2.5"></div>
|
|
72
|
-
<div class="w-32 h-2 bg-gray-200 rounded-full dark:bg-gray-700"></div>
|
|
73
|
-
</div>
|
|
74
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-700 w-12"></div>
|
|
75
|
-
</div>
|
|
76
|
-
<div class="flex items-center justify-between pt-4">
|
|
77
|
-
<div>
|
|
78
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-600 w-24 mb-2.5"></div>
|
|
79
|
-
<div class="w-32 h-2 bg-gray-200 rounded-full dark:bg-gray-700"></div>
|
|
80
|
-
</div>
|
|
81
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-700 w-12"></div>
|
|
82
|
-
</div>
|
|
83
|
-
<div class="flex items-center justify-between pt-4">
|
|
84
|
-
<div>
|
|
85
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-600 w-24 mb-2.5"></div>
|
|
86
|
-
<div class="w-32 h-2 bg-gray-200 rounded-full dark:bg-gray-700"></div>
|
|
87
|
-
</div>
|
|
88
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-700 w-12"></div>
|
|
89
|
-
</div>
|
|
90
|
-
<div class="flex items-center justify-between pt-4">
|
|
91
|
-
<div>
|
|
92
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-600 w-24 mb-2.5"></div>
|
|
93
|
-
<div class="w-32 h-2 bg-gray-200 rounded-full dark:bg-gray-700"></div>
|
|
94
|
-
</div>
|
|
95
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-700 w-12"></div>
|
|
96
|
-
</div>
|
|
97
|
-
<div class="flex items-center justify-between pt-4">
|
|
98
|
-
<div>
|
|
99
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-600 w-24 mb-2.5"></div>
|
|
100
|
-
<div class="w-32 h-2 bg-gray-200 rounded-full dark:bg-gray-700"></div>
|
|
101
|
-
</div>
|
|
102
|
-
<div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-700 w-12"></div>
|
|
103
|
-
</div>
|
|
104
|
-
<span class="sr-only">Loading...</span>
|
|
105
|
-
</div>
|
|
106
|
-
</td>
|
|
107
|
-
</tr>
|
|
108
|
-
<tr v-else-if="rows.length === 0" class="bg-list-view-table-bg border-b dark:bg-gray-800 dark:border-gray-700">
|
|
109
|
-
<td :colspan="resource?.columns.length + 2">
|
|
110
|
-
|
|
111
|
-
<div id="toast-simple"
|
|
112
|
-
class=" mx-auto my-5 flex items-center w-full max-w-xs p-4 space-x-4 rtl:space-x-reverse text-gray-500 divide-x rtl:divide-x-reverse divide-gray-200 dark:text-gray-400 dark:divide-gray-700 space-x dark:bg-gray-800"
|
|
113
|
-
role="alert">
|
|
114
|
-
<IconInboxOutline class="w-6 h-6 text-gray-500 dark:text-gray-400"/>
|
|
115
|
-
<div class="ps-4 text-sm font-normal">No items here yet</div>
|
|
116
|
-
</div>
|
|
117
|
-
|
|
118
|
-
</td>
|
|
119
|
-
</tr>
|
|
120
|
-
|
|
121
|
-
<tr v-else v-for="(row, rowI) in rows" :key="row.id"
|
|
122
|
-
class="bg-list-view-table-bg border-b dark:bg-gray-800 border-list-view-border-color dark:border-gray-700 hover:bg-list-view-table-row-hover dark:hover:bg-gray-600">
|
|
123
|
-
<td class="w-4 p-4">
|
|
124
|
-
<div class="flex items center">
|
|
125
|
-
<input
|
|
126
|
-
id="checkbox-table-search-1"
|
|
127
|
-
type="checkbox"
|
|
128
|
-
:checked="checkboxesInternal.includes(row.id)"
|
|
129
|
-
@change="(e)=>{addToCheckedValues(row.id)}"
|
|
130
|
-
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
|
|
131
|
-
<label for="checkbox-table-search-1" class="sr-only">checkbox</label>
|
|
132
|
-
</div>
|
|
133
|
-
</td>
|
|
134
|
-
<td v-for="c in columnsListed" class="px-6 py-4">
|
|
135
|
-
<!-- if c.name in listComponentsPerColumn, render it. If not, render ValueRenderer -->
|
|
136
|
-
<component
|
|
137
|
-
:is="c?.components?.list ? getCustomComponent(c.components.list) : ValueRenderer"
|
|
138
|
-
:meta="c?.components?.list.meta"
|
|
139
|
-
:column="c"
|
|
140
|
-
:record="row"
|
|
141
|
-
:adminUser="coreStore.adminUser"
|
|
142
|
-
:resource="resource"
|
|
143
|
-
/>
|
|
144
|
-
</td>
|
|
145
|
-
<td class=" items-center px-6 py-4">
|
|
146
|
-
<div class="flex">
|
|
147
|
-
<RouterLink
|
|
148
|
-
v-if="resource.options?.allowedActions.show"
|
|
149
|
-
:to="{
|
|
150
|
-
name: 'resource-show',
|
|
151
|
-
params: {
|
|
152
|
-
resourceId: resource.resourceId,
|
|
153
|
-
primaryKey: row._primaryKeyValue,
|
|
154
|
-
}
|
|
155
|
-
}"
|
|
156
|
-
class="font-medium text-blue-600 dark:text-blue-500 hover:underline"
|
|
157
|
-
:data-tooltip-target="`tooltip-show-${rowI}`"
|
|
158
|
-
>
|
|
159
|
-
<IconEyeSolid class="w-5 h-5 me-2"/>
|
|
160
|
-
</RouterLink>
|
|
161
|
-
|
|
162
|
-
<div :id="`tooltip-show-${rowI}`"
|
|
163
|
-
role="tooltip"
|
|
164
|
-
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">
|
|
165
|
-
Show item
|
|
166
|
-
<div class="tooltip-arrow" data-popper-arrow></div>
|
|
167
|
-
</div>
|
|
168
|
-
|
|
169
|
-
<RouterLink v-if="resource.options?.allowedActions.edit"
|
|
170
|
-
:to="{
|
|
171
|
-
name: 'resource-edit',
|
|
172
|
-
params: {
|
|
173
|
-
resourceId: resource.resourceId,
|
|
174
|
-
primaryKey: row._primaryKeyValue
|
|
175
|
-
}
|
|
176
|
-
}"
|
|
177
|
-
class="font-medium text-blue-600 dark:text-blue-500 hover:underline ms-3"
|
|
178
|
-
:data-tooltip-target="`tooltip-edit-${rowI}`"
|
|
179
|
-
>
|
|
180
|
-
<IconPenSolid class="w-5 h-5 me-2"/>
|
|
181
|
-
</RouterLink>
|
|
182
|
-
|
|
183
|
-
<div :id="`tooltip-edit-${rowI}`"
|
|
184
|
-
role="tooltip"
|
|
185
|
-
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">
|
|
186
|
-
Edit
|
|
187
|
-
<div class="tooltip-arrow" data-popper-arrow></div>
|
|
188
|
-
</div>
|
|
189
|
-
|
|
190
|
-
<button v-if="resource.options?.allowedActions.delete"
|
|
191
|
-
class="font-medium text-red-600 dark:text-red-500 hover:underline ms-3"
|
|
192
|
-
:data-tooltip-target="`tooltip-delete-${rowI}`"
|
|
193
|
-
@click="deleteRecord(row)"
|
|
194
|
-
>
|
|
195
|
-
<IconTrashBinSolid class="w-5 h-5 me-2"/>
|
|
196
|
-
</button>
|
|
197
|
-
|
|
198
|
-
<div :id="`tooltip-delete-${rowI}`"
|
|
199
|
-
role="tooltip"
|
|
200
|
-
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">
|
|
201
|
-
Delete
|
|
202
|
-
<div class="tooltip-arrow" data-popper-arrow></div>
|
|
203
|
-
</div>
|
|
204
|
-
</div>
|
|
205
|
-
</td>
|
|
206
|
-
</tr>
|
|
207
|
-
</tbody>
|
|
208
|
-
</table>
|
|
209
|
-
</div>
|
|
210
|
-
<!-- pagination -->
|
|
211
|
-
<div class="flex flex-col items-center mt-4 mb-4 xs:flex-row xs:justify-between xs:items-center"
|
|
212
|
-
v-if="rows && totalRows >= pageSize && totalRows > 0"
|
|
213
|
-
>
|
|
214
|
-
<!-- Help text -->
|
|
215
|
-
<span class="text-sm text-gray-700 dark:text-gray-400">
|
|
216
|
-
Showing <span class="font-semibold text-gray-900 dark:text-white">
|
|
217
|
-
{{ (page - 1) * pageSize + 1 }}
|
|
218
|
-
</span> to <span class="font-semibold text-gray-900 dark:text-white">
|
|
219
|
-
{{ Math.min(page * pageSize, totalRows) }}
|
|
220
|
-
</span> of <span class="font-semibold text-gray-900 dark:text-white">{{
|
|
221
|
-
totalRows
|
|
222
|
-
}}</span> Entries
|
|
223
|
-
</span>
|
|
224
|
-
<div class="inline-flex mt-2 xs:mt-0">
|
|
225
|
-
<!-- Buttons -->
|
|
226
|
-
<button
|
|
227
|
-
class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-r-0 rounded-s border border-gray-300 hover:bg-gray-100 hover:text-blue-700 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 disabled:opacity-50"
|
|
228
|
-
@click="page--" :disabled="page <= 1">
|
|
229
|
-
<svg class="w-3.5 h-3.5 me-2 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
|
230
|
-
viewBox="0 0 14 10">
|
|
231
|
-
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
232
|
-
d="M13 5H1m0 0 4 4M1 5l4-4"/>
|
|
233
|
-
</svg>
|
|
234
|
-
Prev
|
|
235
|
-
</button>
|
|
236
|
-
<button
|
|
237
|
-
class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-r-0 border border-gray-300 hover:bg-gray-100 hover:text-blue-700 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 disabled:opacity-50"
|
|
238
|
-
@click="page = 1" :disabled="page <= 1">
|
|
239
|
-
<!-- <IconChevronDoubleLeftOutline class="w-4 h-4" /> -->
|
|
240
|
-
1
|
|
241
|
-
</button>
|
|
242
|
-
<input type="text"
|
|
243
|
-
class="w-10 py-1.5 px-3 text-sm text-center text-gray-700 border border-gray-300 dark:border-gray-700 dark:text-gray-400 dark:bg-gray-800 z-10"
|
|
244
|
-
v-model="page"/>
|
|
245
|
-
|
|
246
|
-
<button
|
|
247
|
-
class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-l-0 border border-gray-300 hover:bg-gray-100 hover:text-blue-700 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 disabled:opacity-50"
|
|
248
|
-
@click="page = totalPages" :disabled="page >= totalPages">
|
|
249
|
-
{{ totalPages }}
|
|
250
|
-
|
|
251
|
-
<!-- <IconChevronDoubleRightOutline class="w-4 h-4" /> -->
|
|
252
|
-
</button>
|
|
253
|
-
<button
|
|
254
|
-
class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-l-0 rounded-e border border-gray-300 hover:bg-gray-100 hover:text-blue-700 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 disabled:opacity-50"
|
|
255
|
-
|
|
256
|
-
@click="page++" :disabled="page >= totalPages">
|
|
257
|
-
Next
|
|
258
|
-
<svg class="w-3.5 h-3.5 ms-2 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
|
259
|
-
viewBox="0 0 14 10">
|
|
260
|
-
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
261
|
-
d="M1 5h12m0 0L9 1m4 4L9 9"/>
|
|
262
|
-
</svg>
|
|
263
|
-
</button>
|
|
264
|
-
</div>
|
|
265
|
-
|
|
266
|
-
</div>
|
|
267
|
-
</template>
|
|
268
|
-
|
|
269
|
-
<script setup>
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
import { initFlowbite } from 'flowbite';
|
|
273
|
-
import { computed, onMounted, ref, watch } from 'vue';
|
|
274
|
-
import { useRoute } from 'vue-router';
|
|
275
|
-
import { callAdminForthApi, getIcon } from '@/utils';
|
|
276
|
-
|
|
277
|
-
import ValueRenderer from '@/components/ValueRenderer.vue';
|
|
278
|
-
import { getCustomComponent } from '@/utils';
|
|
279
|
-
import { useCoreStore } from '@/stores/core';
|
|
280
|
-
import { showSuccesTost } from '@/composables/useFrontendApi';
|
|
281
|
-
|
|
282
|
-
import {
|
|
283
|
-
IconInboxOutline,
|
|
284
|
-
IconPlusOutline
|
|
285
|
-
} from '@iconify-prerendered/vue-flowbite';
|
|
286
|
-
|
|
287
|
-
import {
|
|
288
|
-
IconBanOutline,
|
|
289
|
-
IconEyeSolid,
|
|
290
|
-
IconFilterOutline,
|
|
291
|
-
IconPenSolid,
|
|
292
|
-
IconTrashBinSolid
|
|
293
|
-
} from '@iconify-prerendered/vue-flowbite';
|
|
294
|
-
|
|
295
|
-
const coreStore = useCoreStore();
|
|
296
|
-
|
|
297
|
-
const props = defineProps([
|
|
298
|
-
'resource',
|
|
299
|
-
'rows',
|
|
300
|
-
'totalRows',
|
|
301
|
-
'pageSize',
|
|
302
|
-
'checkboxes'
|
|
303
|
-
])
|
|
304
|
-
|
|
305
|
-
// emits, update page
|
|
306
|
-
const emits = defineEmits([
|
|
307
|
-
'update:page',
|
|
308
|
-
'update:sort',
|
|
309
|
-
'update:checkboxes',
|
|
310
|
-
'update:records'
|
|
311
|
-
|
|
312
|
-
]);
|
|
313
|
-
|
|
314
|
-
const checkboxesInternal = ref([]);
|
|
315
|
-
const page = ref(1);
|
|
316
|
-
const sort = ref([]);
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
watch(() => page.value, (newPage) => {
|
|
320
|
-
emits('update:page', newPage);
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
watch(() => sort.value, (newSort) => {
|
|
324
|
-
emits('update:sort', newSort);
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
watch(() => checkboxesInternal.value, (newCheckboxes) => {
|
|
328
|
-
console.log('checkboxesInternal ch changed, emiting', newCheckboxes)
|
|
329
|
-
|
|
330
|
-
emits('update:checkboxes', newCheckboxes);
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
watch(() => props.checkboxes, (newCheckboxes) => {
|
|
334
|
-
console.log('Props ch changed', newCheckboxes)
|
|
335
|
-
checkboxesInternal.value = newCheckboxes;
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
function addToCheckedValues(id) {
|
|
339
|
-
if (checkboxesInternal.value.includes(id)) {
|
|
340
|
-
checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== id);
|
|
341
|
-
} else {
|
|
342
|
-
checkboxesInternal.value.push(id);
|
|
343
|
-
}
|
|
344
|
-
checkboxesInternal.value = [ ...checkboxesInternal.value ]
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
const columnsListed = computed(() => props.resource?.columns?.filter(c => c.showIn.includes('list')));
|
|
348
|
-
|
|
349
|
-
async function selectAll(value) {
|
|
350
|
-
props.rows.forEach((r) => {
|
|
351
|
-
if (!checkboxesInternal.value.includes(r.id)) {
|
|
352
|
-
checkboxesInternal.value.push(r.id)
|
|
353
|
-
} else {
|
|
354
|
-
checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== r.id)
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
checkboxesInternal.value = [ ...checkboxesInternal.value ]
|
|
358
|
-
// checkboxes.value = rows.value.map((v) => v.id);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const totalPages = computed(() => Math.ceil(props.totalRows / props.pageSize));
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const allFromThisPageChecked = computed(() => {
|
|
367
|
-
if (!props.rows) return false;
|
|
368
|
-
return props.rows.every((r) => props.checkboxes.includes(r.id));
|
|
369
|
-
});
|
|
370
|
-
const ascArr = computed(() => sort.value.filter((s) => s.direction === 'asc').map((s) => s.field));
|
|
371
|
-
const descArr = computed(() => sort.value.filter((s) => s.direction === 'desc').map((s) => s.field));
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
function onSortButtonClick(field) {
|
|
375
|
-
const sortIndex = sort.value.findIndex((s) => s.field === field);
|
|
376
|
-
if (sortIndex === -1) {
|
|
377
|
-
sort.value = [{field, direction: 'asc'}, ...sort.value];
|
|
378
|
-
} else {
|
|
379
|
-
const sortField = sort.value[sortIndex];
|
|
380
|
-
if (sortField.direction === 'asc') {
|
|
381
|
-
sort.value[sortIndex].direction = 'desc';
|
|
382
|
-
} else {
|
|
383
|
-
sort.value.splice(sortIndex, 1);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
async function deleteRecord(row) {
|
|
389
|
-
const data = await window.adminforth.confirm({
|
|
390
|
-
message: 'Are you sure you want to delete this item?',
|
|
391
|
-
yes: 'Delete',
|
|
392
|
-
no: 'Cancel',
|
|
393
|
-
});
|
|
394
|
-
if (data) {
|
|
395
|
-
try {
|
|
396
|
-
const res = await callAdminForthApi({
|
|
397
|
-
path: '/delete_record',
|
|
398
|
-
method: 'POST',
|
|
399
|
-
body: {
|
|
400
|
-
resourceId: props.resource.resourceId,
|
|
401
|
-
primaryKey: row._primaryKeyValue,
|
|
402
|
-
}});
|
|
403
|
-
if (!res.error){
|
|
404
|
-
emits('update:records', true)
|
|
405
|
-
showSuccesTost('Record deleted successfully')
|
|
406
|
-
} else {
|
|
407
|
-
console.error(res.error)
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
} catch (e) {
|
|
411
|
-
console.error(e);
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
</script>
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<div id="toast-default" class="flex items-center w-full max-w-xs p-4 text-gray-500 bg-white rounded-lg shadow dark:text-gray-400 dark:bg-gray-800" role="alert">
|
|
5
|
-
<div v-if="toast.variant == 'info'" class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-blue-500 bg-blue-100 rounded-lg dark:bg-blue-800 dark:text-blue-200">
|
|
6
|
-
<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 20">
|
|
7
|
-
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.147 15.085a7.159 7.159 0 0 1-6.189 3.307A6.713 6.713 0 0 1 3.1 15.444c-2.679-4.513.287-8.737.888-9.548A4.373 4.373 0 0 0 5 1.608c1.287.953 6.445 3.218 5.537 10.5 1.5-1.122 2.706-3.01 2.853-6.14 1.433 1.049 3.993 5.395 1.757 9.117Z"/>
|
|
8
|
-
</svg>
|
|
9
|
-
<span class="sr-only">Fire icon</span>
|
|
10
|
-
</div>
|
|
11
|
-
<div v-else-if="toast.variant == 'danger'" class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-red-500 bg-red-100 rounded-lg dark:bg-red-800 dark:text-red-200">
|
|
12
|
-
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
13
|
-
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 11.793a1 1 0 1 1-1.414 1.414L10 11.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L8.586 10 6.293 7.707a1 1 0 0 1 1.414-1.414L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414L11.414 10l2.293 2.293Z"/>
|
|
14
|
-
</svg>
|
|
15
|
-
<span class="sr-only">Error icon</span>
|
|
16
|
-
</div>
|
|
17
|
-
<div v-else-if="toast.variant == 'warning'"class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-orange-500 bg-orange-100 rounded-lg dark:bg-orange-700 dark:text-orange-200">
|
|
18
|
-
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
19
|
-
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z"/>
|
|
20
|
-
</svg>
|
|
21
|
-
<span class="sr-only">Warning icon</span>
|
|
22
|
-
</div>
|
|
23
|
-
<div v-else class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-green-500 bg-green-100 rounded-lg dark:bg-green-800 dark:text-green-200">
|
|
24
|
-
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
25
|
-
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/>
|
|
26
|
-
</svg>
|
|
27
|
-
<span class="sr-only">Check icon</span>
|
|
28
|
-
</div>
|
|
29
|
-
<div class="ms-3 text-sm font-normal">{{toast.message}}</div>
|
|
30
|
-
<button @click="closeToast" type="button" class="ms-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex items-center justify-center h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700" >
|
|
31
|
-
<svg class="w-3 h-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
|
32
|
-
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
|
33
|
-
</svg>
|
|
34
|
-
</button>
|
|
35
|
-
</div>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</template>
|
|
39
|
-
|
|
40
|
-
<script setup lang="ts">
|
|
41
|
-
import { onMounted } from 'vue';
|
|
42
|
-
import { useToastStore } from '@/stores/toast';
|
|
43
|
-
const toastStore = useToastStore();
|
|
44
|
-
const emit = defineEmits(['close']);
|
|
45
|
-
const props = defineProps<{
|
|
46
|
-
toast:{message: string;
|
|
47
|
-
variant: string;
|
|
48
|
-
id: string;
|
|
49
|
-
timeout?: number|'unlimited';}
|
|
50
|
-
}>();
|
|
51
|
-
function closeToast() {
|
|
52
|
-
emit('close');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
onMounted(() => {
|
|
56
|
-
if (props.toast.timeout === 'unlimited') return;
|
|
57
|
-
else {
|
|
58
|
-
setTimeout(() => {emit('close');}, props.toast.timeout || 10000 );
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
</script>
|
|
63
|
-
|
|
64
|
-
<style lang="scss" scoped>
|
|
65
|
-
|
|
66
|
-
</style>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export function showSuccesTost(message: string) {
|
|
2
|
-
window.adminforth.alert({ message, variant: 'success' });
|
|
3
|
-
return message;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function showWarningTost(message: string) {
|
|
7
|
-
window.adminforth.alert({ message, variant: 'warning' });
|
|
8
|
-
return message;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function showErrorTost(message: string, timeout?: number) {
|
|
12
|
-
window.adminforth.alert({ message, variant: 'danger', timeout: timeout || 'unlimited'});
|
|
13
|
-
return message;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const useFrontendApi = () => {
|
|
18
|
-
return {
|
|
19
|
-
showSuccesTost,
|
|
20
|
-
showWarningTost,
|
|
21
|
-
showErrorTost
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export default useFrontendApi;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { FrontendAPIInterface, ConfirmParams, AlertParams, FilterParams,Operator } from '../types/FrontendAPI';
|
|
2
|
-
import { useToastStore } from '../stores/toast';
|
|
3
|
-
import { useModalStore } from '../stores/modal';
|
|
4
|
-
import { useCoreStore } from '@/stores/core';
|
|
5
|
-
import { useFiltersStore } from '@/stores/filters';
|
|
6
|
-
import router from '@/router'
|
|
7
|
-
import type { AdminForthResourceColumn } from '@/types/AdminForthConfig';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare global {
|
|
14
|
-
interface Window {
|
|
15
|
-
adminforth: {
|
|
16
|
-
confirm: (params: ConfirmParams) => Promise<void>;
|
|
17
|
-
alert: (params: AlertParams) => void;
|
|
18
|
-
setListFilter: (filter: any) => void;
|
|
19
|
-
updateListFilter: (filter: any) => void;
|
|
20
|
-
clearListFilters: () => void;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class FrontendAPI implements FrontendAPIInterface {
|
|
26
|
-
private validOperators: Operator[] = ['lte', 'gte', 'in','ilike'];
|
|
27
|
-
private toastStore:any
|
|
28
|
-
private modalStore:any
|
|
29
|
-
private filtersStore:any
|
|
30
|
-
private coreStore:any
|
|
31
|
-
init() {
|
|
32
|
-
if (window.adminforth) {
|
|
33
|
-
throw new Error('adminforth already initialized');
|
|
34
|
-
}
|
|
35
|
-
this.toastStore = useToastStore();
|
|
36
|
-
this.modalStore = useModalStore();
|
|
37
|
-
console.log(this.toastStore, this.modalStore,'init of adminforth frontend api')
|
|
38
|
-
window.adminforth = {
|
|
39
|
-
confirm: this.confirm.bind(this),
|
|
40
|
-
alert: this.alert.bind(this),
|
|
41
|
-
setListFilter: this.setListFilter.bind(this),
|
|
42
|
-
updateListFilter: this.updateListFilter.bind(this),
|
|
43
|
-
clearListFilters: this.clearListFilters.bind(this),
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
confirm(params: ConfirmParams): Promise<void> {
|
|
48
|
-
return new Promise((resolve, reject) => {
|
|
49
|
-
this.modalStore.setModalContent({ content: params.message, acceptText: params.yes, cancelText: params.no })
|
|
50
|
-
this.modalStore.onAcceptFunction = resolve
|
|
51
|
-
this.modalStore.onCancelFunction = reject
|
|
52
|
-
this.modalStore.togleModal()
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
alert(params: AlertParams): void {
|
|
57
|
-
this.toastStore.addToast({
|
|
58
|
-
message: params.message,
|
|
59
|
-
variant: params.variant,
|
|
60
|
-
timeout: params.timeout
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
listFilterValidation(filter: FilterParams): boolean {
|
|
65
|
-
if(router.currentRoute.value.meta.type !== 'list'){
|
|
66
|
-
throw new Error(`Cannot use ${this.setListFilter.name} filter on a list page`)
|
|
67
|
-
} else {
|
|
68
|
-
if(!this.coreStore) this.coreStore = useCoreStore()
|
|
69
|
-
console.log(this.coreStore.resourceColumnsWithFilters,'core store')
|
|
70
|
-
const filterField = this.coreStore.resourceColumnsWithFilters.find((col: AdminForthResourceColumn) => col.name === filter.field)
|
|
71
|
-
if(!filterField){
|
|
72
|
-
throw new Error(`Field ${filter.field} is not available for filtering`)
|
|
73
|
-
}
|
|
74
|
-
if(filterField) {
|
|
75
|
-
if(!this.validOperators.includes(filter.operator)){
|
|
76
|
-
throw new Error(`Operator ${filter.operator} is not valid`)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return true
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
setListFilter(filter: FilterParams): void {
|
|
84
|
-
if(this.listFilterValidation(filter)){
|
|
85
|
-
this.filtersStore = useFiltersStore()
|
|
86
|
-
if(this.filtersStore.filters.some((f) => {return f.field === filter.field && f.operator === filter.operator})){
|
|
87
|
-
throw new Error(`Filter ${filter.field} with operator ${filter.operator} already exists`)
|
|
88
|
-
} else {
|
|
89
|
-
this.filtersStore.setFilter(filter)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
clearListFilters(): void {
|
|
95
|
-
this.filtersStore = useFiltersStore()
|
|
96
|
-
this.filtersStore.clearFilters()
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
updateListFilter(filter: FilterParams): void {
|
|
100
|
-
if(this.listFilterValidation(filter)){
|
|
101
|
-
this.filtersStore = useFiltersStore()
|
|
102
|
-
const index = this.filtersStore.filters.findIndex((f: FilterParams) => f.field === filter.field)
|
|
103
|
-
if(index === -1) {
|
|
104
|
-
this.filtersStore.setFilter(filter)
|
|
105
|
-
} else {
|
|
106
|
-
this.filtersStore.setFilters([...this.filtersStore.filters.slice(0, index), filter, ...this.filtersStore.filters.slice(index + 1)])
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { AdminForthResource, AdminForthResourceColumn } from '../types/AdminForthConfig';
|
|
2
|
-
|
|
3
|
-
export type resourceById = {
|
|
4
|
-
[key: string]: AdminForthResource;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export type Menu = {
|
|
8
|
-
label: string,
|
|
9
|
-
icon: string,
|
|
10
|
-
resourceId: string,
|
|
11
|
-
children?: Array<Menu>,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type Record = {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type ResourceColumns = {
|
|
19
|
-
[key: string]: Array<AdminForthResourceColumn>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type CoreConfig = {
|
|
23
|
-
brandName: string,
|
|
24
|
-
brandLogo: string,
|
|
25
|
-
title: string,
|
|
26
|
-
datesFormat: string,
|
|
27
|
-
usernameField: string,
|
|
28
|
-
usernameFieldName?: string,
|
|
29
|
-
deleteConfirmation?: boolean,
|
|
30
|
-
auth?: {
|
|
31
|
-
resourceId: string,
|
|
32
|
-
usernameField: string,
|
|
33
|
-
passwordHashField: string,
|
|
34
|
-
loginBackgroundImage: string,
|
|
35
|
-
userFullnameField: string,
|
|
36
|
-
},
|
|
37
|
-
emptyFieldPlaceholder?: {
|
|
38
|
-
show: string,
|
|
39
|
-
list: string,
|
|
40
|
-
|
|
41
|
-
} | string,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export type AllowedActions = {
|
|
46
|
-
show: boolean,
|
|
47
|
-
create: boolean,
|
|
48
|
-
edit: boolean,
|
|
49
|
-
delete: boolean,
|
|
50
|
-
}
|
|
51
|
-
|