adminforth 1.6.2-next.3 → 1.6.2-next.4
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/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/spa/.eslintrc.cjs +14 -0
- package/dist/spa/README.md +39 -0
- package/dist/spa/env.d.ts +1 -0
- package/dist/spa/index.html +23 -0
- package/dist/spa/package-lock.json +5062 -0
- package/dist/spa/package.json +58 -0
- package/dist/spa/postcss.config.js +6 -0
- package/dist/spa/public/assets/favicon.png +0 -0
- package/dist/spa/src/App.vue +432 -0
- package/dist/spa/src/adminforth.ts +160 -0
- package/dist/spa/src/afcl/AreaChart.vue +160 -0
- package/dist/spa/src/afcl/BarChart.vue +170 -0
- package/dist/spa/src/afcl/Button.vue +27 -0
- package/dist/spa/src/afcl/Checkbox.vue +24 -0
- package/dist/spa/src/afcl/Dropzone.vue +128 -0
- package/dist/spa/src/afcl/Input.vue +41 -0
- package/dist/spa/src/afcl/Link.vue +17 -0
- package/dist/spa/src/afcl/LinkButton.vue +25 -0
- package/dist/spa/src/afcl/PieChart.vue +175 -0
- package/dist/spa/src/afcl/ProgressBar.vue +57 -0
- package/dist/spa/src/afcl/Select.vue +246 -0
- package/dist/spa/src/afcl/Skeleton.vue +26 -0
- package/dist/spa/src/afcl/Spinner.vue +9 -0
- package/dist/spa/src/afcl/Table.vue +116 -0
- package/dist/spa/src/afcl/Tooltip.vue +43 -0
- package/dist/spa/src/afcl/VerticalTabs.vue +49 -0
- package/dist/spa/src/afcl/index.ts +20 -0
- package/dist/spa/src/assets/base.css +2 -0
- package/dist/spa/src/assets/logo.svg +19 -0
- package/dist/spa/src/components/AcceptModal.vue +44 -0
- package/dist/spa/src/components/Breadcrumbs.vue +41 -0
- package/dist/spa/src/components/BreadcrumbsWithButtons.vue +25 -0
- package/dist/spa/src/components/CustomDatePicker.vue +180 -0
- package/dist/spa/src/components/CustomDateRangePicker.vue +218 -0
- package/dist/spa/src/components/CustomRangePicker.vue +156 -0
- package/dist/spa/src/components/Filters.vue +232 -0
- package/dist/spa/src/components/GroupsTable.vue +218 -0
- package/dist/spa/src/components/HelloWorld.vue +17 -0
- package/dist/spa/src/components/MenuLink.vue +41 -0
- package/dist/spa/src/components/ResourceForm.vue +260 -0
- package/dist/spa/src/components/ResourceListTable.vue +486 -0
- package/dist/spa/src/components/ShowTable.vue +81 -0
- package/dist/spa/src/components/SingleSkeletLoader.vue +13 -0
- package/dist/spa/src/components/SkeleteLoader.vue +18 -0
- package/dist/spa/src/components/ThreeDotsMenu.vue +43 -0
- package/dist/spa/src/components/Toast.vue +78 -0
- package/dist/spa/src/components/ValueRenderer.vue +141 -0
- package/dist/spa/src/components/icons/IconCalendar.vue +5 -0
- package/dist/spa/src/components/icons/IconCommunity.vue +7 -0
- package/dist/spa/src/components/icons/IconDocumentation.vue +7 -0
- package/dist/spa/src/components/icons/IconEcosystem.vue +7 -0
- package/dist/spa/src/components/icons/IconSupport.vue +7 -0
- package/dist/spa/src/components/icons/IconTime.vue +5 -0
- package/dist/spa/src/components/icons/IconTooling.vue +19 -0
- package/dist/spa/src/composables/useFrontendApi.ts +28 -0
- package/dist/spa/src/i18n.ts +54 -0
- package/dist/spa/src/index.scss +34 -0
- package/dist/spa/src/main.ts +22 -0
- package/dist/spa/src/renderers/CompactField.vue +46 -0
- package/dist/spa/src/renderers/CompactUUID.vue +46 -0
- package/dist/spa/src/renderers/CountryFlag.vue +65 -0
- package/dist/spa/src/renderers/HumanNumber.vue +58 -0
- package/dist/spa/src/renderers/RelativeTime.vue +42 -0
- package/dist/spa/src/renderers/URL.vue +18 -0
- package/dist/spa/src/router/index.ts +70 -0
- package/dist/spa/src/spa_types/core.ts +51 -0
- package/dist/spa/src/stores/core.ts +228 -0
- package/dist/spa/src/stores/filters.ts +27 -0
- package/dist/spa/src/stores/modal.ts +48 -0
- package/dist/spa/src/stores/toast.ts +30 -0
- package/dist/spa/src/stores/user.ts +79 -0
- package/dist/spa/src/types/Adapters.ts +26 -0
- package/dist/spa/src/types/Back.ts +1344 -0
- package/dist/spa/src/types/Common.ts +940 -0
- package/dist/spa/src/types/FrontendAPI.ts +189 -0
- package/dist/spa/src/utils.ts +184 -0
- package/dist/spa/src/views/CreateView.vue +167 -0
- package/dist/spa/src/views/EditView.vue +171 -0
- package/dist/spa/src/views/ListView.vue +442 -0
- package/dist/spa/src/views/LoginView.vue +199 -0
- package/dist/spa/src/views/PageNotFound.vue +20 -0
- package/dist/spa/src/views/ResourceParent.vue +50 -0
- package/dist/spa/src/views/ShowView.vue +209 -0
- package/dist/spa/src/websocket.ts +129 -0
- package/dist/spa/tailwind.config.js +19 -0
- package/dist/spa/tsconfig.app.json +14 -0
- package/dist/spa/tsconfig.json +11 -0
- package/dist/spa/tsconfig.node.json +19 -0
- package/dist/spa/vite.config.ts +52 -0
- package/package.json +1 -1
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative flex flex-col max-w-full w-full">
|
|
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
|
+
{{ $t('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 && !bulkActionLoadingStates[action.id]"
|
|
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
|
+
<div v-if="bulkActionLoadingStates[action.id]">
|
|
50
|
+
<svg
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
class="w-5 h-5 animate-spin"
|
|
53
|
+
:class="{
|
|
54
|
+
'text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300': action.state !== 'danger',
|
|
55
|
+
'text-red-200 dark:text-red-800 fill-red-600 dark:fill-red-500': action.state === 'danger'
|
|
56
|
+
}"
|
|
57
|
+
viewBox="0 0 100 101"
|
|
58
|
+
fill="none"
|
|
59
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
+
>
|
|
61
|
+
<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"/>
|
|
62
|
+
<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"/>
|
|
63
|
+
</svg>
|
|
64
|
+
<span class="sr-only">Loading...</span>
|
|
65
|
+
</div>
|
|
66
|
+
{{ `${action.label} (${checkboxes.length})` }}
|
|
67
|
+
</button>
|
|
68
|
+
|
|
69
|
+
<RouterLink v-if="coreStore.resource?.options?.allowedActions?.create"
|
|
70
|
+
:to="{ name: 'resource-create', params: { resourceId: $route.params.resourceId } }"
|
|
71
|
+
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"
|
|
72
|
+
>
|
|
73
|
+
<IconPlusOutline class="w-4 h-4 me-2"/>
|
|
74
|
+
{{ $t('Create') }}
|
|
75
|
+
</RouterLink>
|
|
76
|
+
|
|
77
|
+
<button
|
|
78
|
+
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"
|
|
79
|
+
@click="()=>{filtersShow = !filtersShow}"
|
|
80
|
+
v-if="coreStore.resource?.options?.allowedActions?.filter"
|
|
81
|
+
>
|
|
82
|
+
<IconFilterOutline class="w-4 h-4 me-2"/>
|
|
83
|
+
{{ $t('Filter') }}
|
|
84
|
+
<span
|
|
85
|
+
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"
|
|
86
|
+
v-if="filtersStore.filters.length">
|
|
87
|
+
{{ filtersStore.filters.length }}
|
|
88
|
+
</span>
|
|
89
|
+
</button>
|
|
90
|
+
|
|
91
|
+
<ThreeDotsMenu
|
|
92
|
+
:threeDotsDropdownItems="coreStore.resourceOptions?.pageInjections?.list?.threeDotsDropdownItems"
|
|
93
|
+
></ThreeDotsMenu>
|
|
94
|
+
</BreadcrumbsWithButtons>
|
|
95
|
+
|
|
96
|
+
<component
|
|
97
|
+
v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.afterBreadcrumbs || []"
|
|
98
|
+
:is="getCustomComponent(c)"
|
|
99
|
+
:meta="c.meta"
|
|
100
|
+
:resource="coreStore.resource"
|
|
101
|
+
:adminUser="coreStore.adminUser"
|
|
102
|
+
/>
|
|
103
|
+
|
|
104
|
+
<ResourceListTable
|
|
105
|
+
:resource="coreStore.resource"
|
|
106
|
+
:rows="rows"
|
|
107
|
+
:page="page"
|
|
108
|
+
@update:page="page = $event"
|
|
109
|
+
@update:sort="sort = $event"
|
|
110
|
+
@update:checkboxes="checkboxes = $event"
|
|
111
|
+
@update:records="getList"
|
|
112
|
+
:sort="sort"
|
|
113
|
+
:pageSize="pageSize"
|
|
114
|
+
:totalRows="totalRows"
|
|
115
|
+
:checkboxes="checkboxes"
|
|
116
|
+
:customActionsInjection="coreStore.resourceOptions?.pageInjections?.list?.customActionIcons"
|
|
117
|
+
/>
|
|
118
|
+
|
|
119
|
+
<component
|
|
120
|
+
v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.bottom || []"
|
|
121
|
+
:is="getCustomComponent(c)"
|
|
122
|
+
:meta="c.meta"
|
|
123
|
+
:resource="coreStore.resource"
|
|
124
|
+
:adminUser="coreStore.adminUser"
|
|
125
|
+
/>
|
|
126
|
+
|
|
127
|
+
</div>
|
|
128
|
+
</template>
|
|
129
|
+
|
|
130
|
+
<script setup lang="ts">
|
|
131
|
+
import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
|
|
132
|
+
import ResourceListTable from '@/components/ResourceListTable.vue';
|
|
133
|
+
import { useCoreStore } from '@/stores/core';
|
|
134
|
+
import { useFiltersStore } from '@/stores/filters';
|
|
135
|
+
import { callAdminForthApi, currentQuery, getIcon, setQuery } from '@/utils';
|
|
136
|
+
import { computed, onMounted, ref, watch, nextTick, type Ref } from 'vue';
|
|
137
|
+
import { useRoute } from 'vue-router';
|
|
138
|
+
import { showErrorTost } from '@/composables/useFrontendApi'
|
|
139
|
+
import { getCustomComponent, initThreeDotsDropdown } from '@/utils';
|
|
140
|
+
import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
import {
|
|
144
|
+
IconBanOutline,
|
|
145
|
+
IconFilterOutline,
|
|
146
|
+
IconPlusOutline
|
|
147
|
+
} from '@iconify-prerendered/vue-flowbite';
|
|
148
|
+
|
|
149
|
+
import Filters from '@/components/Filters.vue';
|
|
150
|
+
import adminforth from '@/adminforth';
|
|
151
|
+
|
|
152
|
+
const filtersShow = ref(false);
|
|
153
|
+
|
|
154
|
+
const coreStore = useCoreStore();
|
|
155
|
+
const filtersStore = useFiltersStore();
|
|
156
|
+
|
|
157
|
+
const route = useRoute();
|
|
158
|
+
|
|
159
|
+
const page = ref(1);
|
|
160
|
+
const columnsMinMax = ref({});
|
|
161
|
+
const sort = ref([]);
|
|
162
|
+
|
|
163
|
+
watch(() => sort, async (to, from) => {
|
|
164
|
+
// in store sort might be needed for plugins
|
|
165
|
+
filtersStore.setSort(sort.value);
|
|
166
|
+
}, {deep: true});
|
|
167
|
+
|
|
168
|
+
const rows: Ref<any[]|null> = ref(null);
|
|
169
|
+
const totalRows = ref(0);
|
|
170
|
+
const checkboxes = ref([]);
|
|
171
|
+
const bulkActionLoadingStates = ref<{[key: string]: boolean}>({});
|
|
172
|
+
|
|
173
|
+
const DEFAULT_PAGE_SIZE = 10;
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
const pageSize = computed(() => coreStore.resource?.options?.listPageSize || DEFAULT_PAGE_SIZE);
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
async function getList() {
|
|
180
|
+
rows.value = null;
|
|
181
|
+
const data = await callAdminForthApi({
|
|
182
|
+
path: '/get_resource_data',
|
|
183
|
+
method: 'POST',
|
|
184
|
+
body: {
|
|
185
|
+
source: 'list',
|
|
186
|
+
resourceId: route.params.resourceId,
|
|
187
|
+
limit: pageSize.value,
|
|
188
|
+
offset: ((page.value || 1) - 1) * pageSize.value,
|
|
189
|
+
filters: filtersStore.filters,
|
|
190
|
+
sort: sort.value,
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
if (data.error) {
|
|
194
|
+
showErrorTost(data.error);
|
|
195
|
+
rows.value = [];
|
|
196
|
+
totalRows.value = 0;
|
|
197
|
+
return {error: data.error};
|
|
198
|
+
}
|
|
199
|
+
rows.value = data.data?.map(row => {
|
|
200
|
+
row._primaryKeyValue = row[coreStore.resource.columns.find(c => c.primaryKey).name];
|
|
201
|
+
return row;
|
|
202
|
+
});
|
|
203
|
+
totalRows.value = data.total;
|
|
204
|
+
|
|
205
|
+
// if checkboxes have items which are not in current data, remove them
|
|
206
|
+
checkboxes.value = checkboxes.value.filter(pk => rows.value!.some(r => r._primaryKeyValue === pk));
|
|
207
|
+
await nextTick();
|
|
208
|
+
return {}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async function refreshExistingList(pk?: any) {
|
|
212
|
+
const currentData = rows.value;
|
|
213
|
+
if (!currentData) {
|
|
214
|
+
throw new Error('No rows loaded yet. Silent refresh is possible only after some rows are loaded. COnsider calling getList() instead first');
|
|
215
|
+
}
|
|
216
|
+
if (!coreStore.resource) {
|
|
217
|
+
throw new Error('Resource not loaded yet');
|
|
218
|
+
}
|
|
219
|
+
let pks;
|
|
220
|
+
if (pk && !currentData.some(r => r._primaryKeyValue === pk)) {
|
|
221
|
+
return {error: `Primary key ${pk} not found in current data`};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (pk) {
|
|
225
|
+
pks = [pk];
|
|
226
|
+
} else {
|
|
227
|
+
pks = currentData.map(r => r._primaryKeyValue);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const data = await callAdminForthApi({
|
|
231
|
+
path: '/get_resource_data',
|
|
232
|
+
method: 'POST',
|
|
233
|
+
body: {
|
|
234
|
+
source: 'list',
|
|
235
|
+
resourceId: route.params.resourceId,
|
|
236
|
+
limit: pks.length,
|
|
237
|
+
offset: 0,
|
|
238
|
+
filters: [
|
|
239
|
+
{
|
|
240
|
+
field: coreStore.resource!.columns.find(c => c.primaryKey)!.name,
|
|
241
|
+
operator: 'in',
|
|
242
|
+
value: pks
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
sort: sort.value,
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
if (data.error) {
|
|
249
|
+
return data;
|
|
250
|
+
}
|
|
251
|
+
data.data.forEach((row: any) => {
|
|
252
|
+
const pkKeyName = coreStore.resource!.columns.find(c => c.primaryKey)!.name;
|
|
253
|
+
|
|
254
|
+
const existingRow = currentData.find(r => r._primaryKeyValue === row[pkKeyName]);
|
|
255
|
+
if (existingRow) {
|
|
256
|
+
Object.assign(existingRow, row);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return {}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
async function startBulkAction(actionId) {
|
|
264
|
+
const action = coreStore.resource.options.bulkActions.find(a => a.id === actionId);
|
|
265
|
+
if (action.confirm) {
|
|
266
|
+
const confirmed = await adminforth.confirm({
|
|
267
|
+
message: action.confirm,
|
|
268
|
+
});
|
|
269
|
+
if (!confirmed) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
bulkActionLoadingStates.value[actionId] = true;
|
|
274
|
+
|
|
275
|
+
const data = await callAdminForthApi({
|
|
276
|
+
path: '/start_bulk_action',
|
|
277
|
+
method: 'POST',
|
|
278
|
+
body: {
|
|
279
|
+
resourceId: route.params.resourceId,
|
|
280
|
+
actionId: actionId,
|
|
281
|
+
recordIds: checkboxes.value
|
|
282
|
+
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
bulkActionLoadingStates.value[actionId] = false;
|
|
286
|
+
if (data?.ok) {
|
|
287
|
+
checkboxes.value = [];
|
|
288
|
+
await getList();
|
|
289
|
+
|
|
290
|
+
if (data.successMessage) {
|
|
291
|
+
adminforth.alert({
|
|
292
|
+
message: data.successMessage,
|
|
293
|
+
variant: 'success'
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
if (data?.error) {
|
|
299
|
+
showErrorTost(data.error);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
class SortQuerySerializer {
|
|
305
|
+
static serialize(sort) {
|
|
306
|
+
return sort.map(s => `${s.field}__${s.direction}`).join(',');
|
|
307
|
+
}
|
|
308
|
+
static deserialize(str) {
|
|
309
|
+
return str.split(',').map(s => {
|
|
310
|
+
const [field, direction] = s.split('__');
|
|
311
|
+
return { field, direction };
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
let listAutorefresher: any = null;
|
|
317
|
+
|
|
318
|
+
async function init() {
|
|
319
|
+
|
|
320
|
+
await coreStore.fetchResourceFull({
|
|
321
|
+
resourceId: route.params.resourceId
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// !!! clear filters should be in same tick with sort assignment so that watch can catch it as one change
|
|
325
|
+
|
|
326
|
+
// try to init filters from query params
|
|
327
|
+
const filters = Object.keys(route.query).filter(k => k.startsWith('filter__')).map(k => {
|
|
328
|
+
const [_, field, operator] = k.split('__');
|
|
329
|
+
return {
|
|
330
|
+
field,
|
|
331
|
+
operator,
|
|
332
|
+
value: JSON.parse(decodeURIComponent(route.query[k]))
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
if (filters.length) {
|
|
336
|
+
filtersStore.setFilters(filters);
|
|
337
|
+
} else {
|
|
338
|
+
filtersStore.clearFilters();
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (route.query.sort) {
|
|
342
|
+
sort.value = SortQuerySerializer.deserialize(route.query.sort);
|
|
343
|
+
} else if (coreStore.resource.options?.defaultSort) {
|
|
344
|
+
sort.value = [{
|
|
345
|
+
field: coreStore.resource.options.defaultSort.columnName,
|
|
346
|
+
direction: coreStore.resource.options.defaultSort.direction
|
|
347
|
+
}];
|
|
348
|
+
} else {
|
|
349
|
+
sort.value = [];
|
|
350
|
+
}
|
|
351
|
+
// page init should be also in same tick
|
|
352
|
+
if (route.query.page) {
|
|
353
|
+
page.value = parseInt(route.query.page);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// getList(); - Not needed here, watch will trigger it
|
|
357
|
+
columnsMinMax.value = await callAdminForthApi({
|
|
358
|
+
path: '/get_min_max_for_columns',
|
|
359
|
+
method: 'POST',
|
|
360
|
+
body: {
|
|
361
|
+
resourceId: route.params.resourceId
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
if (listAutorefresher) {
|
|
366
|
+
clearInterval(listAutorefresher);
|
|
367
|
+
listAutorefresher = null;
|
|
368
|
+
}
|
|
369
|
+
if (coreStore.resource!.options?.listRowsAutoRefreshSeconds) {
|
|
370
|
+
listAutorefresher = setInterval(async () => {
|
|
371
|
+
await adminforth.list.silentRefresh();
|
|
372
|
+
}, coreStore.resource!.options.listRowsAutoRefreshSeconds * 1000);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
watch([page, sort, () => filtersStore.filters], async () => {
|
|
377
|
+
// console.log('🔄️ page/sort/filter change fired, page:', page.value);
|
|
378
|
+
await getList();
|
|
379
|
+
}, { deep: true });
|
|
380
|
+
|
|
381
|
+
adminforth.list.refresh = async () => {
|
|
382
|
+
return await getList();
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
adminforth.list.silentRefresh = async () => {
|
|
386
|
+
return await refreshExistingList();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
adminforth.list.silentRefreshRow = async (pk: any) => {
|
|
390
|
+
return await refreshExistingList(pk);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
let initInProcess = false;
|
|
394
|
+
|
|
395
|
+
watch(() => filtersStore.filters, async (to, from) => {
|
|
396
|
+
if (initInProcess) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
console.log('🔄️ filters changed', JSON.stringify(to))
|
|
400
|
+
page.value = 1;
|
|
401
|
+
checkboxes.value = []; // TODO: not sure absolutely needed here
|
|
402
|
+
// update query param for each filter as filter_<column_name>=value
|
|
403
|
+
const query = {};
|
|
404
|
+
const currentQ = currentQuery();
|
|
405
|
+
filtersStore.filters.forEach(f => {
|
|
406
|
+
if (f.value) {
|
|
407
|
+
query[`filter__${f.field}__${f.operator}`] = encodeURIComponent(JSON.stringify(f.value));
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
// set every key in currentQ which starts with filter_ to undefined if it is not in query
|
|
411
|
+
Object.keys(currentQ).forEach(k => {
|
|
412
|
+
if (k.startsWith('filter_') && !query[k]) {
|
|
413
|
+
query[k] = undefined;
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
setQuery(query);
|
|
417
|
+
}, {deep: true});
|
|
418
|
+
|
|
419
|
+
onMounted(async () => {
|
|
420
|
+
initInProcess = true;
|
|
421
|
+
await init();
|
|
422
|
+
initThreeDotsDropdown();
|
|
423
|
+
initInProcess = false;
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
watch([page], async () => {
|
|
427
|
+
setQuery({ page: page.value });
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
watch([sort], async () => {
|
|
434
|
+
if (!sort.value.length) {
|
|
435
|
+
setQuery({ sort: undefined });
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
setQuery({ sort: SortQuerySerializer.serialize(sort.value) });
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
</script>
|
|
@@ -0,0 +1,199 @@
|
|
|
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
|
+
{{ $t('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">{{ $t('Your') }} {{ coreStore.config?.usernameFieldName?.toLowerCase() }}</label>
|
|
42
|
+
<input
|
|
43
|
+
autocomplete="username"
|
|
44
|
+
type="username"
|
|
45
|
+
name="username"
|
|
46
|
+
id="username"
|
|
47
|
+
ref="usernameInput"
|
|
48
|
+
@keydown.enter="passwordInput.focus()"
|
|
49
|
+
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 />
|
|
50
|
+
</div>
|
|
51
|
+
<div class="relative">
|
|
52
|
+
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{ $t('Your password') }}</label>
|
|
53
|
+
<input
|
|
54
|
+
ref="passwordInput"
|
|
55
|
+
autocomplete="current-password"
|
|
56
|
+
@keydown.enter="login"
|
|
57
|
+
: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 />
|
|
58
|
+
<button type="button" @click="showPw = !showPw" class="absolute top-12 right-3 -translate-y-1/2 text-gray-400 dark:text-gray-300">
|
|
59
|
+
<IconEyeSolid class="w-5 h-5" v-if="!showPw" />
|
|
60
|
+
<IconEyeSlashSolid class="w-5 h-5" v-else />
|
|
61
|
+
</button>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div v-if="coreStore.config.rememberMeDays"
|
|
65
|
+
class="flex items-start mb-5"
|
|
66
|
+
:title="$t(`Stay logged in for {days} days`, {days: coreStore.config.rememberMeDays})"
|
|
67
|
+
>
|
|
68
|
+
<Checkbox v-model="rememberMeValue" class="mr-2">
|
|
69
|
+
{{ $t('Remember me') }}
|
|
70
|
+
</Checkbox>
|
|
71
|
+
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<component
|
|
75
|
+
v-for="c in coreStore?.config?.loginPageInjections?.underInputs || []"
|
|
76
|
+
:is="getCustomComponent(c)"
|
|
77
|
+
:meta="c.meta"
|
|
78
|
+
/>
|
|
79
|
+
|
|
80
|
+
<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">
|
|
81
|
+
<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">
|
|
82
|
+
<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"/>
|
|
83
|
+
</svg>
|
|
84
|
+
<span class="sr-only">{{ $t('Info') }}</span>
|
|
85
|
+
<div>
|
|
86
|
+
{{ error }}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div v-if="coreStore.config?.loginPromptHTML"
|
|
91
|
+
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"
|
|
92
|
+
>
|
|
93
|
+
<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">
|
|
94
|
+
<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"/>
|
|
95
|
+
</svg>
|
|
96
|
+
<span class="sr-only">{{ $t('Info') }}</span>
|
|
97
|
+
<div v-html="coreStore.config?.loginPromptHTML"></div>
|
|
98
|
+
</div>
|
|
99
|
+
<Button @click="login" :loader="inProgress" :disabled="inProgress" class="w-full">
|
|
100
|
+
{{ $t('Login to your account') }}
|
|
101
|
+
</Button>
|
|
102
|
+
</form>
|
|
103
|
+
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
</div>
|
|
110
|
+
</template>
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
<script setup>
|
|
114
|
+
|
|
115
|
+
import { getCustomComponent } from '@/utils';
|
|
116
|
+
import { onBeforeMount, onMounted, ref, computed } from 'vue';
|
|
117
|
+
import { useCoreStore } from '@/stores/core';
|
|
118
|
+
import { useUserStore } from '@/stores/user';
|
|
119
|
+
import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
|
|
120
|
+
import { callAdminForthApi, loadFile } from '@/utils';
|
|
121
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
122
|
+
import { Button, Checkbox } from '@/afcl';
|
|
123
|
+
|
|
124
|
+
const passwordInput = ref(null);
|
|
125
|
+
const usernameInput = ref(null);
|
|
126
|
+
const rememberMeValue= ref(false);
|
|
127
|
+
|
|
128
|
+
const route = useRoute();
|
|
129
|
+
const router = useRouter();
|
|
130
|
+
const inProgress = ref(false);
|
|
131
|
+
|
|
132
|
+
const coreStore = useCoreStore();
|
|
133
|
+
const user = useUserStore();
|
|
134
|
+
|
|
135
|
+
const showPw = ref(false);
|
|
136
|
+
|
|
137
|
+
const error = ref(null);
|
|
138
|
+
|
|
139
|
+
const backgroundPosition = computed(() => {
|
|
140
|
+
return coreStore.config?.loginBackgroundPosition || '1/2';
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
onBeforeMount(() => {
|
|
144
|
+
if (localStorage.getItem('isAuthorized') === 'true') {
|
|
145
|
+
// if route has next param, redirect
|
|
146
|
+
coreStore.fetchMenuAndResource();
|
|
147
|
+
if (route.query.next) {
|
|
148
|
+
router.push(route.query.next.toString());
|
|
149
|
+
} else {
|
|
150
|
+
router.push({ name: 'home' });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
onMounted(async () => {
|
|
156
|
+
if (coreStore.config?.demoCredentials) {
|
|
157
|
+
const [username, password] = coreStore.config.demoCredentials.split(':');
|
|
158
|
+
usernameInput.value.value = username;
|
|
159
|
+
passwordInput.value.value = password;
|
|
160
|
+
}
|
|
161
|
+
usernameInput.value.focus();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
async function login() {
|
|
166
|
+
|
|
167
|
+
const username = usernameInput.value.value;
|
|
168
|
+
const password = passwordInput.value.value;
|
|
169
|
+
|
|
170
|
+
if (!username || !password) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (inProgress.value) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
inProgress.value = true;
|
|
177
|
+
const resp = await callAdminForthApi({
|
|
178
|
+
path: '/login',
|
|
179
|
+
method: 'POST',
|
|
180
|
+
body: {
|
|
181
|
+
username,
|
|
182
|
+
password,
|
|
183
|
+
rememberMe: rememberMeValue.value,
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
if (resp.error) {
|
|
187
|
+
error.value = resp.error;
|
|
188
|
+
} else if (resp.redirectTo) {
|
|
189
|
+
router.push(resp.redirectTo);
|
|
190
|
+
} else {
|
|
191
|
+
error.value = null;
|
|
192
|
+
await user.finishLogin();
|
|
193
|
+
}
|
|
194
|
+
inProgress.value = false;
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
</script>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section class="bg-white dark:bg-gray-900">
|
|
3
|
+
<div class="py-8 px-4 mx-auto max-w-screen-xl lg:py-16 lg:px-6">
|
|
4
|
+
<div class="mx-auto max-w-screen-sm text-center">
|
|
5
|
+
<h1 class="mb-4 text-7xl tracking-tight font-extrabold lg:text-9xl text-lightPrimary dark:text-darkPrimary">404</h1>
|
|
6
|
+
<p class="mb-4 text-3xl tracking-tight font-bold text-gray-900 md:text-4xl dark:text-white">{{ $t("Something's missing.") }}</p>
|
|
7
|
+
<p class="mb-4 text-lg font-light text-gray-500 dark:text-gray-400">{{ $t("Sorry, we can't find that page. You'll find lots to explore on the home page.") }} </p>
|
|
8
|
+
<div class="flex justify-center">
|
|
9
|
+
<LinkButton to="/">{{ $t('Go back home') }}</LinkButton>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</section>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
|
|
18
|
+
import { LinkButton } from '@/afcl';
|
|
19
|
+
|
|
20
|
+
</script>
|