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,52 @@
1
+ {
2
+ "name": "spa",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "run-p type-check \"build-only {@}\" --",
9
+ "preview": "vite preview",
10
+ "build-only": "vite build",
11
+ "type-check": "vue-tsc --build --force",
12
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
13
+ },
14
+ "dependencies": {
15
+ "@iconify-prerendered/vue-flowbite": "^0.23.1714023977",
16
+ "@unhead/vue": "^1.9.12",
17
+ "@vueuse/core": "^10.10.0",
18
+ "dayjs": "^1.11.11",
19
+ "debounce": "^2.1.0",
20
+ "flowbite": "^2.3.0",
21
+ "flowbite-datepicker": "^1.2.6",
22
+ "pinia": "^2.1.7",
23
+ "sanitize-html": "^2.13.0",
24
+ "unhead": "^1.9.12",
25
+ "uuid": "^10.0.0",
26
+ "vue": "^3.4.21",
27
+ "vue-diff": "^1.2.4",
28
+ "vue-router": "^4.3.0",
29
+ "vue-slider-component": "^4.1.0-beta.7"
30
+ },
31
+ "devDependencies": {
32
+ "@rushstack/eslint-patch": "^1.8.0",
33
+ "@tsconfig/node20": "^20.1.4",
34
+ "@types/node": "^20.12.5",
35
+ "@vitejs/plugin-vue": "^5.0.4",
36
+ "@vue/eslint-config-typescript": "^13.0.0",
37
+ "@vue/tsconfig": "^0.5.1",
38
+ "autoprefixer": "^10.4.19",
39
+ "eslint": "^8.57.0",
40
+ "eslint-plugin-vue": "^9.23.0",
41
+ "flag-icons": "^7.2.3",
42
+ "i18n-iso-countries": "^7.12.0",
43
+ "npm-run-all2": "^6.1.2",
44
+ "postcss": "^8.4.38",
45
+ "sass": "^1.77.2",
46
+ "tailwindcss": "^3.4.3",
47
+ "typescript": "~5.4.0",
48
+ "vite": "^5.2.13",
49
+ "vue-tsc": "^2.0.11",
50
+ "vue3-json-viewer": "^2.2.2"
51
+ }
52
+ }
@@ -0,0 +1,6 @@
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
@@ -0,0 +1,418 @@
1
+ <template>
2
+ <div v-if="defaultLayout" >
3
+
4
+ <nav
5
+ v-if="loggedIn && routerIsReady && loginRedirectCheckIsReady"
6
+ class="fixed h-14 top-0 z-20 w-full border-b shadow-sm bg-lightNavbar shadow-headerShadow dark:bg-darkNavbar dark:border-darkSidebarDevider">
7
+ <div class="px-3 py-3 lg:px-5 lg:pl-3">
8
+ <div class="flex items-center justify-between">
9
+ <div class="flex items-center justify-start rtl:justify-end">
10
+ <button @click="sideBarOpen = !sideBarOpen"
11
+ type="button" class="inline-flex items-center p-2 text-sm rounded-lg sm:hidden hover:bg-lightSidebarItemHover focus:outline-none focus:ring-2 focus:ring-lightSidebarDevider dark:text-darkSidebarIcons dark:hover:bg-darkSidebarHover dark:focus:ring-lightSidebarDevider">
12
+ <span class="sr-only">Open sidebar</span>
13
+ <svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
14
+ <path clip-rule="evenodd" fill-rule="evenodd" d="M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zm0 10.5a.75.75 0 01.75-.75h7.5a.75.75 0 010 1.5h-7.5a.75.75 0 01-.75-.75zM2 10a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 10z"></path>
15
+ </svg>
16
+ </button>
17
+
18
+ </div>
19
+ <div class="flex items-center">
20
+
21
+ <component
22
+ v-for="c in coreStore?.config?.globalInjections?.header || []"
23
+ :is="getCustomComponent(c)"
24
+ :meta="c.meta"
25
+ :adminUser="coreStore.adminUser"
26
+ />
27
+
28
+ <div class="flex items-center ms-3 ">
29
+
30
+
31
+
32
+ <span
33
+ @click="toggleTheme" class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black hover:bg-lightHtml dark:text-darkSidebarTextHover dark:hover:bg-darkHtml dark:hover:text-darkSidebarTextActive" role="menuitem">
34
+ <IconMoonSolid class="w-5 h-5 text-blue-300" v-if="theme !== 'dark'" />
35
+ <IconSunSolid class="w-5 h-5 text-yellow-300" v-else />
36
+ </span>
37
+ <div>
38
+
39
+ <button type="button" class="flex text-sm bg- rounded-full focus:ring-4 focus:ring-lightSidebarDevider dark:focus:ring-darkSidebarDevider dark:bg-" aria-expanded="false" data-dropdown-toggle="dropdown-user">
40
+ <span class="sr-only">Open user menu</span>
41
+ <svg class="w-8 h-8 text-lightNavbarIcons dark:text-darkNavbarIcons" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
42
+ <path fill-rule="evenodd" d="M12 20a7.966 7.966 0 0 1-5.002-1.756l.002.001v-.683c0-1.794 1.492-3.25 3.333-3.25h3.334c1.84 0 3.333 1.456 3.333 3.25v.683A7.966 7.966 0 0 1 12 20ZM2 12C2 6.477 6.477 2 12 2s10 4.477 10 10c0 5.5-4.44 9.963-9.932 10h-.138C6.438 21.962 2 17.5 2 12Zm10-5c-1.84 0-3.333 1.455-3.333 3.25S10.159 13.5 12 13.5c1.84 0 3.333-1.455 3.333-3.25S13.841 7 12 7Z" clip-rule="evenodd"/>
43
+ </svg>
44
+ </button>
45
+ </div>
46
+ <div class="z-50 hidden my-4 text-base list-none bg-white divide-y divide-gray-100 rounded shadow dark:shadow-black dark:bg-darkSidebar dark:divide-darkSidebarDevider dark:shadow-black" id="dropdown-user">
47
+ <div class="px-4 py-3" role="none">
48
+ <p class="text-sm text-gray-900 dark:text-darkNavbarText" role="none" v-if="coreStore.userFullname">
49
+ {{ coreStore.userFullname }}
50
+ </p>
51
+ <p class="text-sm font-medium text-gray-900 truncate dark:text-darkSidebarText" role="none">
52
+ {{ coreStore.username }}
53
+ </p>
54
+ </div>
55
+ <ul class="py-1" role="none">
56
+
57
+ <li v-for="c in coreStore?.config?.globalInjections?.userMenu || []" >
58
+ <component
59
+ :is="getCustomComponent(c)"
60
+ :meta="c.meta"
61
+ :adminUser="coreStore.adminUser"
62
+ />
63
+ </li>
64
+ <li>
65
+ <button @click="logout" class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black hover:bg-html dark:text-darkSidebarTextHover dark:hover:bg-darkSidebarItemHover dark:hover:text-darkSidebarTextActive w-full" role="menuitem">Sign out</button>
66
+ </li>
67
+ </ul>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ </nav>
74
+
75
+
76
+
77
+ <aside
78
+
79
+ v-if="loggedIn && routerIsReady && loginRedirectCheckIsReady"
80
+
81
+ id="logo-lightSidebar" class="fixed bg-lightSidebar border-none top-0 left-0 z-20 w-64 h-screen transition-transform bg-lightSidebar dark:bg-darkSidebar border-r border-lightSidebarBorder sm:translate-x-0 dark:bg-darkSidebar dark:border-darkSidebarBorder"
82
+ :class="{ '-translate-x-full': !sideBarOpen, 'transform-none': sideBarOpen }"
83
+ aria-label="Sidebar"
84
+ >
85
+ <div class="h-full px-3 pb-4 overflow-y-auto bg-lightSidebar dark:bg-darkSidebar border-r border-lightSidebarBorder dark:border-darkSidebarBorder">
86
+ <div class="flex ms-2 md:me-24 m-4 ">
87
+ <img :src="loadFile(coreStore.config?.brandLogo || '@/assets/logo.svg')" :alt="`${ coreStore.config?.brandName } Logo`" class="h-8 me-3" />
88
+ <span
89
+ v-if="coreStore.config?.showBrandNameInSidebar"
90
+ class="self-center text-lightNavbarText-size font-semibold sm:text-lightNavbarText-size whitespace-nowrap dark:text-darkSidebarText text-lightSidebarText"
91
+ >
92
+ {{ coreStore.config?.brandName }}
93
+ </span>
94
+ </div>
95
+
96
+ <ul class="space-y-2 font-medium">
97
+ <template v-for="(item, i) in coreStore.menu" :key="`menu-${i}`">
98
+ <div v-if="item.type === 'divider'" class="border-t border-lightSidebarDevider dark:border-darkSidebarDevider"></div>
99
+ <div v-else-if="item.type === 'gap'" class="flex items-center justify-center h-8"></div>
100
+ <div v-else-if="item.type === 'heading'" class="flex items-center justify-left pl-2 h-8 text-lightSidebarHeading dark:text-darkSidebarHeading
101
+ ">{{ item.label }}</div>
102
+ <li v-else-if="item.children" class=" ">
103
+ <button @click="clickOnMenuItem(i)" type="button" class="flex items-center w-full p-2 text-base text-lightSidebarText rounded-default transition duration-75 group hover:bg-lightSidebarItemHover hover:text-lightSidebarTextHover dark:text-darkSidebarText dark:hover:bg-darkSidebarHover dark:hover:text-darkSidebarTextHover"
104
+ :aria-controls="`dropdown-example${i}`"
105
+ :data-collapse-toggle="`dropdown-example${i}`"
106
+ >
107
+
108
+ <component v-if="item.icon" :is="getIcon(item.icon)" class="w-5 h-5 text-lightSidebarIcons group-hover:text-lightSidebarIconsHover transition duration-75 dark:group-hover:text-darkSidebarIconsHover dark:text-darkSidebarIcons" ></component>
109
+
110
+ <span class="flex-1 ms-3 text-left rtl:text-right whitespace-nowrap">{{ item.label }}
111
+
112
+ <span v-if="item.badge" class="inline-flex items-center justify-center w-3 h-3 p-3 ms-3 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
113
+ fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent">{{ item.badge }}</span>
114
+ </span>
115
+
116
+ <svg :class="{'rotate-180': opened.includes(i) }" class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
117
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
118
+ </svg>
119
+ </button>
120
+
121
+ <ul :id="`dropdown-example${i}`" role="none" class="pt-1 space-y-1" :class="{ 'hidden': !opened.includes(i) }">
122
+ <template v-for="(child, j) in item.children" :key="`menu-${i}-${j}`">
123
+ <li>
124
+ <MenuLink :item="child" isChild="true" />
125
+ </li>
126
+ </template>
127
+ </ul>
128
+ </li>
129
+ <li v-else>
130
+ <MenuLink :item="item" />
131
+ </li>
132
+ </template>
133
+ </ul>
134
+
135
+
136
+ <div id="dropdown-cta" class="p-4 mt-6 rounded-lg bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
137
+ fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent text-sm" role="alert"
138
+ v-if="ctaBadge"
139
+ >
140
+ <div class="flex items-center mb-3" :class="!ctaBadge.title ? 'float-right' : ''">
141
+ <!-- <span class="bg-lightPrimaryOpacity dark:bg-darkPrimaryOpacity text-sm font-semibold me-2 px-2.5 py-0.5 rounded "
142
+ v-if="ctaBadge.title"
143
+ > -->
144
+ <span>
145
+ {{ctaBadge.title}}
146
+ </span>
147
+ <button type="button"
148
+ class="ms-auto -mx-1.5 -my-1.5 bg-lightPrimaryOpacity dark:bg-darkPrimaryOpacity inline-flex justify-center items-center w-6 h-6 rounded-lg p-1 hover:brightness-110"
149
+
150
+ data-dismiss-target="#dropdown-cta" aria-label="Close"
151
+ v-if="ctaBadge?.closable" @click="closeCTA"
152
+ >
153
+ <span class="sr-only">Close</span>
154
+ <svg class="w-2.5 h-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
155
+ <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"/>
156
+ </svg>
157
+ </button>
158
+ </div>
159
+ <p class="mb-3 text-sm " v-if="ctaBadge.html" v-html="ctaBadge.html"></p>
160
+ <p class="mb-3 text-sm fill-lightNavbarText dark:fill-darkPrimary text-lightNavbarText dark:text-darkNavbarPrimary" v-else>
161
+ {{ ctaBadge.text }}
162
+ </p>
163
+ <!-- <a class="text-sm text-lightPrimary underline font-medium hover:text-blue-900 dark:text-blue-400 dark:hover:text-blue-300" href="#">Turn new navigation off</a> -->
164
+ </div>
165
+
166
+ <component
167
+ v-for="c in coreStore?.config?.globalInjections?.sidebar || []"
168
+ :is="getCustomComponent(c)"
169
+ :meta="c.meta"
170
+ :adminUser="coreStore.adminUser"
171
+ />
172
+ </div>
173
+ </aside>
174
+
175
+
176
+ <div class="sm:ml-64 max-w-[100vw]" v-if="loggedIn && routerIsReady && loginRedirectCheckIsReady">
177
+ <div class="p-0 dark:border-gray-700 mt-14">
178
+ <RouterView/>
179
+ </div>
180
+ </div>
181
+
182
+ <div v-else-if="routerIsReady && loginRedirectCheckIsReady">
183
+ <RouterView/>
184
+ </div>
185
+ <div v-else class="flex items-center justify-center h-screen">
186
+ <div class="text-3xl text-gray-400 animate-bounce">
187
+ <svg aria-hidden="true" class="w-8 h-8 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>
188
+ <span class="sr-only">Loading...</span>
189
+ </div>
190
+ </div>
191
+ <AcceptModal />
192
+ <div v-if="toastStore.toasts.length>0" class="fixed bottom-5 right-5 flex gap-1 flex-col-reverse z-50">
193
+ <transition-group
194
+ name="fade"
195
+ tag="div"
196
+ class="flex flex-col-reverse gap-1"
197
+ >
198
+ <Toast :toast="t" @close="toastStore.removeToast(t)" v-for="(t,i) in toastStore.toasts" :key="`t-${t.id}`" ></Toast>
199
+ </transition-group>
200
+ </div>
201
+
202
+ <div v-if="sideBarOpen"
203
+ @click="sideBarOpen = false"
204
+
205
+ drawer-backdrop="" class="bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-5"></div>
206
+
207
+
208
+ </div>
209
+ <div v-else>
210
+ <div v-if="routerIsReady && loginRedirectCheckIsReady">
211
+ <RouterView/>
212
+ </div>
213
+ <AcceptModal />
214
+ <div v-if="toastStore.toasts.length>0" class="fixed bottom-5 right-5 flex gap-1 flex-col-reverse">
215
+ <transition-group
216
+ name="fade"
217
+ tag="div"
218
+ class="flex flex-col-reverse gap-1"
219
+ >
220
+ <Toast :toast="t" @close="toastStore.removeToast(t)" v-for="(t,i) in toastStore.toasts" :key="`t-${t.id}`" ></Toast>
221
+ </transition-group>
222
+ </div>
223
+ </div>
224
+ </template>
225
+
226
+ <style lang="scss" scoped>
227
+
228
+ .fade-leave-active {
229
+ @apply transition-opacity duration-500;
230
+ }
231
+ .fade-leave-to {
232
+ @apply opacity-0;
233
+ }
234
+ .fade-enter-active {
235
+ @apply transition-opacity duration-500;
236
+ }
237
+ .fade-enter-from {
238
+ @apply opacity-0;
239
+ }
240
+ .fade-enter-to {
241
+ @apply opacity-100;
242
+ }
243
+
244
+ </style>
245
+
246
+ <script setup lang="ts">
247
+ import { computed, onMounted, ref, watch, defineComponent, onBeforeMount } from 'vue';
248
+ import { RouterLink, RouterView } from 'vue-router';
249
+ import { initFlowbite, Dropdown } from 'flowbite'
250
+ import './index.scss'
251
+ import { useCoreStore } from '@/stores/core';
252
+ import { useUserStore } from '@/stores/user';
253
+ import {useModalStore} from '@/stores/modal';
254
+ import { IconMoonSolid, IconSunSolid } from '@iconify-prerendered/vue-flowbite';
255
+ import AcceptModal from './components/AcceptModal.vue';
256
+ import MenuLink from './components/MenuLink.vue';
257
+ import { useRoute, useRouter } from 'vue-router';
258
+ import { getIcon } from '@/utils';
259
+ import { useHead } from 'unhead'
260
+ import { createHead } from 'unhead'
261
+ import { loadFile } from '@/utils';
262
+ import Toast from './components/Toast.vue';
263
+ import {useToastStore} from '@/stores/toast';
264
+ import { FrontendAPI } from '@/composables/useStores';
265
+ import { getCustomComponent } from '@/utils';
266
+
267
+ // import { link } from 'fs';
268
+ const coreStore = useCoreStore();
269
+ const modalStore = useModalStore();
270
+ const toastStore = useToastStore();
271
+ const userStore = useUserStore();
272
+ const frontendApi = new FrontendAPI();
273
+ frontendApi.init();
274
+ const splitAtLast = (str: string, separator: string) => {
275
+ const index = str.lastIndexOf(separator);
276
+ return [str.slice(0, index), str.slice(index + 1)];
277
+ }
278
+ createHead()
279
+ const sideBarOpen = ref(false);
280
+ const defaultLayout = ref(true);
281
+ const route = useRoute();
282
+ const router = useRouter();
283
+ const title = ref('');
284
+ //create a ref to store the opened menu items with ts type;
285
+ const opened = ref<string[]>([]);
286
+
287
+
288
+ const routerIsReady = ref(false);
289
+ const loginRedirectCheckIsReady = ref(false);
290
+
291
+ const loggedIn = computed(() => route.name !== 'login');
292
+
293
+ const theme = ref('light');
294
+
295
+ function toggleTheme() {
296
+ theme.value = theme.value === 'light' ? 'dark' : 'light';
297
+ document.documentElement.classList.toggle('dark');
298
+ window.localStorage.setItem('af__theme', theme.value);
299
+
300
+ }
301
+
302
+ function clickOnMenuItem (label: string) {
303
+ if (opened.value.includes(label)) {
304
+ opened.value = opened.value.filter((item) => item !== label);
305
+ } else {
306
+ opened.value.push(label);
307
+ }
308
+
309
+ }
310
+
311
+ async function logout() {
312
+ userStore.unauthorize();
313
+ await userStore.logout();
314
+ router.push({ name: 'login' })
315
+ }
316
+
317
+
318
+
319
+
320
+ async function initRouter() {
321
+ await router.isReady();
322
+ routerIsReady.value = true;
323
+ }
324
+
325
+ async function loadMenu() {
326
+ await initRouter();
327
+ if (!route.meta.customLayout) {
328
+ // for custom layouts we don't need to fetch menu
329
+ await coreStore.fetchMenuAndResource();
330
+ }
331
+ loginRedirectCheckIsReady.value = true;
332
+ }
333
+
334
+ function handleCustomLayout() {
335
+ if (route.meta?.customLayout) {
336
+ defaultLayout.value = false;
337
+ } else {
338
+ defaultLayout.value = true;
339
+ }
340
+ }
341
+
342
+ function humanizeSnake(str: string): string {
343
+ if (!str) {
344
+ return '';
345
+ }
346
+ return str.split('_').map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
347
+ }
348
+
349
+ watch([route, () => coreStore.resourceById], async () => {
350
+ handleCustomLayout()
351
+ await new Promise((resolve) => setTimeout(resolve, 0));
352
+ const resourceTitle = coreStore.resourceById[route.params?.resourceId as string]?.label || humanizeSnake(Object.values(route.params)[0] as string);
353
+ title.value = `${coreStore.config?.title || coreStore.config?.brandName || 'Adminforth'} | ${ resourceTitle || route.meta.title || ' '}`;
354
+ useHead({
355
+ title: title.value,
356
+ })
357
+ });
358
+
359
+ watch (()=>coreStore.menu, () => {
360
+ coreStore.menu.forEach((item, i) => {
361
+ if (item.open) {
362
+ opened.value.push(i);
363
+ };
364
+ });
365
+ })
366
+
367
+ watch([loggedIn, routerIsReady, loginRedirectCheckIsReady], ([l,r,lr]) => {
368
+ if (l && r && lr) {
369
+ setTimeout(() => {
370
+ initFlowbite();
371
+
372
+ const dd = new Dropdown(
373
+ document.querySelector('#dropdown-user') as HTMLElement,
374
+ document.querySelector('[data-dropdown-toggle="dropdown-user"]') as HTMLElement,
375
+ );
376
+ window.adminforth.closeUserMenuDropdown = () => {
377
+ dd.hide();
378
+ }
379
+ });
380
+ }
381
+ })
382
+
383
+ // initialize components based on data attribute selectors
384
+ onMounted(async () => {
385
+ loadMenu(); // run this in async mode
386
+ // before init flowbite we have to wait router initialized because it affects dom(our v-ifs) and fetch menu
387
+ await initRouter()
388
+ handleCustomLayout()
389
+
390
+ })
391
+
392
+ onBeforeMount(()=>{
393
+ theme.value = window.localStorage.getItem('af__theme') || 'light';
394
+ document.documentElement.classList.toggle('dark', theme.value === 'dark');
395
+ })
396
+
397
+
398
+ const ctaBadge = computed(() => {
399
+ const badge = coreStore.config?.announcementBadge;
400
+ if (!badge) {
401
+ return null;
402
+ }
403
+ const hash = badge.closable ? JSON.stringify(badge).split('').reduce((a,b)=>{a=((a<<5)-a)+b.charCodeAt(0);return a&a},0) : '';
404
+ if (badge.closable && window.localStorage.getItem(`ctaBadge-${hash}`)) {
405
+ return null;
406
+ }
407
+ return {...badge, hash};
408
+ });
409
+
410
+ function closeCTA() {
411
+ const hash = ctaBadge.value.hash;
412
+ window.localStorage.setItem(`ctaBadge-${hash}`, '1');
413
+ }
414
+
415
+
416
+
417
+
418
+ </script>
@@ -0,0 +1,2 @@
1
+
2
+
@@ -0,0 +1,19 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_1_8)">
3
+ <path d="M8.034 6.006V13H6.097V12.194C5.59433 12.8007 4.86633 13.104 3.913 13.104C3.25433 13.104 2.65633 12.9567 2.119 12.662C1.59033 12.3673 1.17433 11.947 0.871 11.401C0.567667 10.855 0.416 10.2223 0.416 9.503C0.416 8.78367 0.567667 8.151 0.871 7.605C1.17433 7.059 1.59033 6.63867 2.119 6.344C2.65633 6.04933 3.25433 5.902 3.913 5.902C4.80567 5.902 5.50333 6.18367 6.006 6.747V6.006H8.034ZM4.264 11.44C4.77533 11.44 5.2 11.2667 5.538 10.92C5.876 10.5647 6.045 10.0923 6.045 9.503C6.045 8.91367 5.876 8.44567 5.538 8.099C5.2 7.74367 4.77533 7.566 4.264 7.566C3.744 7.566 3.315 7.74367 2.977 8.099C2.639 8.44567 2.47 8.91367 2.47 9.503C2.47 10.0923 2.639 10.5647 2.977 10.92C3.315 11.2667 3.744 11.44 4.264 11.44Z" fill="url(#paint0_linear_1_8)"/>
4
+ <path d="M13.317 5.538C12.589 5.538 12.0387 5.69833 11.666 6.019C11.2933 6.331 11.107 6.80333 11.107 7.436V7.995H14.851V9.685H11.107V13H9.001V7.449C9.001 6.279 9.365 5.369 10.093 4.719C10.8297 4.069 11.8567 3.744 13.174 3.744C13.694 3.744 14.1837 3.80033 14.643 3.913C15.1023 4.017 15.501 4.173 15.839 4.381L15.189 6.045C14.669 5.707 14.045 5.538 13.317 5.538Z" fill="url(#paint1_linear_1_8)"/>
5
+ </g>
6
+ <defs>
7
+ <linearGradient id="paint0_linear_1_8" x1="1.5" y1="6.93333" x2="7.31883" y2="11.8926" gradientUnits="userSpaceOnUse">
8
+ <stop stop-color="#656E7A"/>
9
+ <stop offset="1" stop-color="#99A6B8"/>
10
+ </linearGradient>
11
+ <linearGradient id="paint1_linear_1_8" x1="12.5" y1="3.73333" x2="9.68642" y2="12.7016" gradientUnits="userSpaceOnUse">
12
+ <stop stop-color="#48C5FF"/>
13
+ <stop offset="1" stop-color="#A1E1FF"/>
14
+ </linearGradient>
15
+ <clipPath id="clip0_1_8">
16
+ <rect width="16" height="16" fill="white"/>
17
+ </clipPath>
18
+ </defs>
19
+ </svg>
@@ -0,0 +1,45 @@
1
+ <script setup>
2
+ import { ref,onMounted } from 'vue'
3
+ import { useModalStore } from '@/stores/modal';
4
+
5
+ const modalStore = useModalStore();
6
+ </script>
7
+
8
+ <template>
9
+ <Teleport to="body">
10
+ <div v-if="modalStore.isOpened" class="bg-gray-900/50 dark:bg-gray-900/80 overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
11
+ <div class="relative p-4 w-full max-w-md max-h-full top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 " >
12
+ <div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black">
13
+ <button type="button"@click="modalStore.togleModal" class="absolute top-3 end-2.5 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" >
14
+ <svg class="w-3 h-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
15
+ <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"/>
16
+ </svg>
17
+ <span class="sr-only">Close modal</span>
18
+ </button>
19
+ <div class="p-4 md:p-5 text-center">
20
+ <svg class="mx-auto mb-4 text-gray-400 w-12 h-12 dark:text-gray-200" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
21
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 11V6m0 8h.01M19 10a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/>
22
+ </svg>
23
+ <h3 class="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{{ modalStore?.modalContent?.content }}</h3>
24
+ <button @click="()=>{ modalStore.onAcceptFunction(true);modalStore.togleModal()}" type="button" class="text-white bg-red-600 hover:bg-red-800 focus:ring-4 focus:outline-none focus:ring-red-300 dark:focus:ring-red-800 font-medium rounded-lg text-sm inline-flex items-center px-5 py-2.5 text-center">
25
+ {{ modalStore?.modalContent?.acceptText }}
26
+ </button>
27
+ <button @click="()=>{modalStore.onAcceptFunction(false);modalStore.togleModal()}" type="button" class="py-2.5 px-5 ms-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 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">{{ modalStore?.modalContent?.cancelText }}</button>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ </div>
32
+
33
+ </Teleport>
34
+ </template>
35
+
36
+ <style scoped>
37
+ .modal {
38
+ position: fixed;
39
+ z-index: 999;
40
+ top: 20%;
41
+ left: 50%;
42
+ width: 300px;
43
+ margin-left: -150px;
44
+ }
45
+ </style>
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <nav class="flex" aria-label="Breadcrumb">
3
+ <ol class="inline-flex items-center space-x-1 md:space-x-2 rtl:space-x-reverse flex-wrap">
4
+ <li class="inline-flex items-center">
5
+ <RouterLink :to="{name: 'home'}" class="inline-flex items-center text-sm font-medium text-gray-700 hover:text-lightPrimary dark:text-gray-400 dark:hover:text-white">
6
+ <svg class="w-3 h-3 me-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
7
+ <path d="m19.707 9.293-2-2-7-7a1 1 0 0 0-1.414 0l-7 7-2 2a1 1 0 0 0 1.414 1.414L2 10.414V18a2 2 0 0 0 2 2h3a1 1 0 0 0 1-1v-4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v4a1 1 0 0 0 1 1h3a2 2 0 0 0 2-2v-7.586l.293.293a1 1 0 0 0 1.414-1.414Z"/>
8
+ </svg>
9
+ Home
10
+ </RouterLink>
11
+ </li>
12
+ <li>
13
+ <div class="flex items-center">
14
+ <svg class="rtl:rotate-180 w-3 h-3 text-gray-400 mx-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
15
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
16
+ </svg>
17
+ <RouterLink :to="{name: 'resource-list', params: { resourceId: $route.params.resourceId }}" class="text-sm font-medium text-gray-500 md:ms-2 dark:text-gray-400">{{ coreStore.resourceById[$route.params.resourceId]?.label }}</RouterLink>
18
+ </div>
19
+ </li>
20
+
21
+ <li v-if="$route.params.primaryKey">
22
+ <div class="flex items-center">
23
+ <svg class="rtl:rotate-180 w-3 h-3 text-gray-400 mx-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
24
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
25
+ </svg>
26
+ <span class="ms-1 text-sm font-medium text-gray-500 md:ms-2 dark:text-gray-400
27
+ max-w-80 truncate">
28
+ {{ $route.name === 'resource-edit' ? 'Edit' : 'Show' }} {{ coreStore.record?._label }}</span>
29
+ </div>
30
+ </li>
31
+
32
+
33
+ </ol>
34
+ </nav>
35
+ </template>
36
+
37
+ <script setup>
38
+ import { useCoreStore } from '@/stores/core';
39
+
40
+ const coreStore = useCoreStore()
41
+ </script>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <div>
3
+ <div class="flex items-center justify-between mb-3 flex-wrap gap-y-2">
4
+ <Breadcrumbs />
5
+ <div class="flex items-center space-x-1 flex-wrap gap-y-1">
6
+ <slot></slot>
7
+ </div>
8
+ </div>
9
+ <div class="flex items-center justify-between mb-3 flex-wrap gap-y-2">
10
+ <div class="p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400" role="alert"
11
+ v-if="coreStore.resourceColumnsError">
12
+ <span class="font-medium">Error!</span> {{ coreStore.resourceColumnsError }}
13
+ </div>
14
+ </div>
15
+ </div>
16
+
17
+ </template>
18
+
19
+ <script setup>
20
+ import Breadcrumbs from '@/components/Breadcrumbs.vue';
21
+
22
+ import { useCoreStore } from '@/stores/core';
23
+
24
+ const coreStore = useCoreStore();
25
+
26
+ </script>