adminforth 1.1.32 → 1.1.33

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 (98) hide show
  1. package/dist/index.js +9 -0
  2. package/dist/modules/codeInjector.js +19 -7
  3. package/dist/modules/styles.js +2 -2
  4. package/dist/spa/index.html +2 -2
  5. package/dist/spa/package-lock.json +17 -4
  6. package/dist/spa/package.json +2 -1
  7. package/dist/spa/src/App.vue +125 -45
  8. package/dist/spa/src/assets/logo.svg +19 -1
  9. package/dist/spa/src/components/AcceptModal.vue +2 -9
  10. package/dist/spa/src/components/BreadcrumbsWithButtons.vue +1 -1
  11. package/dist/spa/src/components/CustomDatePicker.vue +16 -3
  12. package/dist/spa/src/components/CustomDateRangePicker.vue +11 -2
  13. package/dist/spa/src/components/Dropdown.vue +6 -1
  14. package/dist/spa/src/components/Filters.vue +40 -19
  15. package/dist/spa/src/components/ResourceForm.vue +26 -24
  16. package/dist/spa/src/components/ValueRenderer.vue +14 -8
  17. package/dist/spa/src/main.ts +1 -1
  18. package/dist/spa/src/router/index.ts +30 -20
  19. package/dist/spa/src/stores/core.ts +48 -31
  20. package/dist/spa/src/stores/modal.ts +13 -3
  21. package/dist/spa/src/utils.ts +62 -7
  22. package/dist/spa/src/views/CreateView.vue +67 -15
  23. package/dist/spa/src/views/EditView.vue +45 -11
  24. package/dist/spa/src/views/ListView.vue +82 -366
  25. package/dist/spa/src/views/LoginView.vue +16 -4
  26. package/dist/spa/src/views/ShowView.vue +105 -21
  27. package/dist/spa/tailwind.config.js +1 -1
  28. package/dist/spa/vite.config.ts +6 -0
  29. package/index.ts +11 -0
  30. package/modules/codeInjector.ts +19 -1
  31. package/modules/styles.ts +2 -2
  32. package/package.json +1 -1
  33. package/spa/index.html +1 -1
  34. package/spa/src/App.vue +2 -3
  35. package/types/AdminForthConfig.ts +15 -0
  36. package/dist/plugins/AccessControl/index.js +0 -66
  37. package/dist/plugins/AccessControl/types.js +0 -1
  38. package/dist/spa/public/favicon.ico +0 -0
  39. package/dist/spa/spa/.eslintrc.cjs +0 -14
  40. package/dist/spa/spa/.vscode/extensions.json +0 -6
  41. package/dist/spa/spa/README.md +0 -39
  42. package/dist/spa/spa/env.d.ts +0 -1
  43. package/dist/spa/spa/index.html +0 -23
  44. package/dist/spa/spa/package-lock.json +0 -4359
  45. package/dist/spa/spa/package.json +0 -47
  46. package/dist/spa/spa/postcss.config.js +0 -6
  47. package/dist/spa/spa/public/favicon.ico +0 -0
  48. package/dist/spa/spa/src/App.vue +0 -272
  49. package/dist/spa/spa/src/assets/base.css +0 -0
  50. package/dist/spa/spa/src/assets/logo.svg +0 -19
  51. package/dist/spa/spa/src/components/AcceptModal.vue +0 -45
  52. package/dist/spa/spa/src/components/Breadcrumbs.vue +0 -40
  53. package/dist/spa/spa/src/components/BreadcrumbsWithButtons.vue +0 -26
  54. package/dist/spa/spa/src/components/CustomDatePicker.vue +0 -174
  55. package/dist/spa/spa/src/components/CustomDateRangePicker.vue +0 -218
  56. package/dist/spa/spa/src/components/CustomRangePicker.vue +0 -148
  57. package/dist/spa/spa/src/components/Dropdown.vue +0 -168
  58. package/dist/spa/spa/src/components/Filters.vue +0 -211
  59. package/dist/spa/spa/src/components/HelloWorld.vue +0 -17
  60. package/dist/spa/spa/src/components/MenuLink.vue +0 -24
  61. package/dist/spa/spa/src/components/ResourceForm.vue +0 -265
  62. package/dist/spa/spa/src/components/SingleSkeletLoader.vue +0 -13
  63. package/dist/spa/spa/src/components/ValueRenderer.vue +0 -60
  64. package/dist/spa/spa/src/components/icons/IconCalendar.vue +0 -5
  65. package/dist/spa/spa/src/components/icons/IconCommunity.vue +0 -7
  66. package/dist/spa/spa/src/components/icons/IconDocumentation.vue +0 -7
  67. package/dist/spa/spa/src/components/icons/IconEcosystem.vue +0 -7
  68. package/dist/spa/spa/src/components/icons/IconSupport.vue +0 -7
  69. package/dist/spa/spa/src/components/icons/IconTime.vue +0 -5
  70. package/dist/spa/spa/src/components/icons/IconTooling.vue +0 -19
  71. package/dist/spa/spa/src/index.scss +0 -26
  72. package/dist/spa/spa/src/main.ts +0 -18
  73. package/dist/spa/spa/src/router/index.ts +0 -64
  74. package/dist/spa/spa/src/stores/core.ts +0 -144
  75. package/dist/spa/spa/src/stores/modal.ts +0 -48
  76. package/dist/spa/spa/src/utils.ts +0 -101
  77. package/dist/spa/spa/src/views/CreateView.vue +0 -163
  78. package/dist/spa/spa/src/views/EditView.vue +0 -165
  79. package/dist/spa/spa/src/views/ListView.vue +0 -257
  80. package/dist/spa/spa/src/views/LoginView.vue +0 -134
  81. package/dist/spa/spa/src/views/ResourceParent.vue +0 -18
  82. package/dist/spa/spa/src/views/ShowView.vue +0 -188
  83. package/dist/spa/spa/tailwind.config.js +0 -15
  84. package/dist/spa/spa/tsconfig.app.json +0 -14
  85. package/dist/spa/spa/tsconfig.json +0 -11
  86. package/dist/spa/spa/tsconfig.node.json +0 -19
  87. package/dist/spa/spa/vite.config.ts +0 -49
  88. package/dist/types.js +0 -30
  89. /package/dist/spa/{spa/public → public/assets}/favicon.png +0 -0
  90. /package/dist/spa/{spa/src → src}/components/ResourceListTable.vue +0 -0
  91. /package/dist/spa/{spa/src → src}/components/Toast.vue +0 -0
  92. /package/dist/spa/{spa/src → src}/composables/useFrontendApi.ts +0 -0
  93. /package/dist/spa/{spa/src → src}/composables/useStores.ts +0 -0
  94. /package/dist/spa/{spa/src → src}/spa_types/core.ts +0 -0
  95. /package/dist/spa/{spa/src → src}/stores/filters.ts +0 -0
  96. /package/dist/spa/{spa/src → src}/stores/toast.ts +0 -0
  97. /package/dist/spa/{spa/src → src}/stores/user.ts +0 -0
  98. /package/spa/public/{favicon.png → assets/favicon.png} +0 -0
package/dist/index.js CHANGED
@@ -123,12 +123,21 @@ class AdminForth {
123
123
  if (!this.config.baseUrl) {
124
124
  this.config.baseUrl = '';
125
125
  }
126
+ if (!this.config.baseUrl.endsWith('/')) {
127
+ this.baseUrlSlashed = this.config.baseUrl + '/';
128
+ }
129
+ else {
130
+ this.baseUrlSlashed = this.config.baseUrl;
131
+ }
126
132
  if (!((_b = this.config) === null || _b === void 0 ? void 0 : _b.customization.brandName)) {
127
133
  this.config.customization.brandName = 'AdminForth';
128
134
  }
129
135
  if (this.config.customization.brandLogo) {
130
136
  errors.push(...this.checkCustomFileExists(this.config.customization.brandLogo));
131
137
  }
138
+ if (!this.config.customization.favicon) {
139
+ errors.push(...this.checkCustomFileExists(this.config.customization.favicon));
140
+ }
132
141
  if (!this.config.customization.datesFormat) {
133
142
  this.config.customization.datesFormat = 'MMM D, YYYY HH:mm:ss';
134
143
  }
@@ -87,7 +87,7 @@ class CodeInjector {
87
87
  }
88
88
  prepareSources(_a) {
89
89
  return __awaiter(this, arguments, void 0, function* ({ filesUpdated, verbose = false }) {
90
- var _b, _c, _d, _e, _f, _g, _h, _j;
90
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
91
91
  // check SPA_TMP_PATH exists and create if not
92
92
  try {
93
93
  yield fs.promises.access(CodeInjector.SPA_TMP_PATH, fs.constants.F_OK);
@@ -191,6 +191,15 @@ class CodeInjector {
191
191
  if ((_b = this.adminforth.config.customization) === null || _b === void 0 ? void 0 : _b.customComponentsDir) {
192
192
  this.srcFoldersToSync[this.adminforth.config.customization.customComponentsDir] = './';
193
193
  }
194
+ // if this.adminforth.config.customization.favicon is set, copy it to assets
195
+ const customFav = (_c = this.adminforth.config.customization) === null || _c === void 0 ? void 0 : _c.favicon;
196
+ if (customFav) {
197
+ const faviconPath = path.join((_d = this.adminforth.config.customization) === null || _d === void 0 ? void 0 : _d.customComponentsDir, customFav.replace('@@/', ''));
198
+ const dest = path.join(CodeInjector.SPA_TMP_PATH, 'public', 'assets', customFav.replace('@@/', ''));
199
+ // make sure all folders in dest exist
200
+ yield fsExtra.ensureDir(path.dirname(dest));
201
+ yield fsExtra.copy(faviconPath, dest);
202
+ }
194
203
  for (const [src, dest] of Object.entries(this.srcFoldersToSync)) {
195
204
  const to = path.join(CodeInjector.SPA_TMP_PATH, 'src', 'custom', dest);
196
205
  if (process.env.HEAVY_DEBUG) {
@@ -278,7 +287,7 @@ class CodeInjector {
278
287
  }
279
288
  let imports = iconImports + '\n';
280
289
  imports += customComponentsImports + '\n';
281
- if ((_c = this.adminforth.config.customization) === null || _c === void 0 ? void 0 : _c.vueUsesFile) {
290
+ if ((_e = this.adminforth.config.customization) === null || _e === void 0 ? void 0 : _e.vueUsesFile) {
282
291
  imports += `import addCustomUses from '${this.adminforth.config.customization.vueUsesFile}';\n`;
283
292
  }
284
293
  // inject that code into spa_tmp/src/App.vue
@@ -286,13 +295,13 @@ class CodeInjector {
286
295
  let appVueContent = yield fs.promises.readFile(appVuePath, 'utf-8');
287
296
  appVueContent = appVueContent.replace('/* IMPORTANT:ADMINFORTH IMPORTS */', imports);
288
297
  appVueContent = appVueContent.replace('/* IMPORTANT:ADMINFORTH COMPONENT REGISTRATIONS */', iconComponents + '\n' + customComponentsComponents + '\n');
289
- if ((_d = this.adminforth.config.customization) === null || _d === void 0 ? void 0 : _d.vueUsesFile) {
298
+ if ((_f = this.adminforth.config.customization) === null || _f === void 0 ? void 0 : _f.vueUsesFile) {
290
299
  appVueContent = appVueContent.replace('/* IMPORTANT:ADMINFORTH CUSTOM USES */', 'addCustomUses(app);');
291
300
  }
292
301
  yield fs.promises.writeFile(appVuePath, appVueContent);
293
302
  // generate tailwind extend styles
294
- if ((_e = this.adminforth.config) === null || _e === void 0 ? void 0 : _e.styles) {
295
- const tailwindStyles = (_f = this.adminforth.config) === null || _f === void 0 ? void 0 : _f.styles;
303
+ if ((_g = this.adminforth.config) === null || _g === void 0 ? void 0 : _g.styles) {
304
+ const tailwindStyles = (_h = this.adminforth.config) === null || _h === void 0 ? void 0 : _h.styles;
296
305
  const stylesText = JSON.stringify(tailwindStyles, null, 2).slice(1, -1);
297
306
  let tailwindConfigPath = path.join(CodeInjector.SPA_TMP_PATH, 'tailwind.config.js');
298
307
  let tailwindConfigContent = yield fs.promises.readFile(tailwindConfigPath, 'utf-8');
@@ -312,14 +321,17 @@ class CodeInjector {
312
321
  const indexHtmlPath = path.join(CodeInjector.SPA_TMP_PATH, 'index.html');
313
322
  let indexHtmlContent = yield fs.promises.readFile(indexHtmlPath, 'utf-8');
314
323
  indexHtmlContent = indexHtmlContent.replace('/* IMPORTANT:ADMINFORTH TITLE */', `${this.adminforth.config.customization.title || 'AdminForth'}`);
324
+ indexHtmlContent = indexHtmlContent.replace('/* IMPORTANT:ADMINFORTH FAVICON */', ((_j = this.adminforth.config.customization.favicon) === null || _j === void 0 ? void 0 : _j.replace('@@/', `${this.adminforth.baseUrlSlashed}assets/`))
325
+ ||
326
+ `${this.adminforth.baseUrlSlashed}assets/favicon.png`);
315
327
  yield fs.promises.writeFile(indexHtmlPath, indexHtmlContent);
316
328
  /* generate custom routes */
317
329
  const homepageMenuItem = this.adminforth.config.menu.find((mi) => mi.homepage);
318
330
  let childrenHomePageMenuItem = this.adminforth.config.menu.find((mi) => { var _a; return mi.children && ((_a = mi.children) === null || _a === void 0 ? void 0 : _a.find((mi) => mi.homepage)); });
319
- let childrenHomepage = (_g = childrenHomePageMenuItem === null || childrenHomePageMenuItem === void 0 ? void 0 : childrenHomePageMenuItem.children) === null || _g === void 0 ? void 0 : _g.find((mi) => mi.homepage);
331
+ let childrenHomepage = (_k = childrenHomePageMenuItem === null || childrenHomePageMenuItem === void 0 ? void 0 : childrenHomePageMenuItem.children) === null || _k === void 0 ? void 0 : _k.find((mi) => mi.homepage);
320
332
  let homePagePath = (homepageMenuItem === null || homepageMenuItem === void 0 ? void 0 : homepageMenuItem.path) || `/resource/${childrenHomepage === null || childrenHomepage === void 0 ? void 0 : childrenHomepage.resourceId}`;
321
333
  if (!homePagePath) {
322
- homePagePath = ((_h = this.adminforth.config.menu.filter((mi) => mi.path)[0]) === null || _h === void 0 ? void 0 : _h.path) || `/resource/${(_j = this.adminforth.config.menu.filter((mi) => mi.children)[0]) === null || _j === void 0 ? void 0 : _j.resourceId}`;
334
+ homePagePath = ((_l = this.adminforth.config.menu.filter((mi) => mi.path)[0]) === null || _l === void 0 ? void 0 : _l.path) || `/resource/${(_m = this.adminforth.config.menu.filter((mi) => mi.children)[0]) === null || _m === void 0 ? void 0 : _m.resourceId}`;
323
335
  }
324
336
  routes += `{
325
337
  path: '/',
@@ -27,10 +27,10 @@ export const styles = () => `
27
27
 
28
28
  "list-view-bg": "#FFFFFF", // White background
29
29
  "list-view-table-bg": "#FFFFFF", // White table background
30
- "list-view-table-heading": "#F5F5F5", // Very light grey heading
30
+ "list-view-table-heading": "rgb(249 250 251)", // Very light grey heading
31
31
  "list-view-table-heading-text": "#333333", // Dark grey heading text
32
32
  "list-view-table-text": "#333333", // Dark grey text
33
- "list-view-table-row-hover": "#F0F0F0", // Very light grey row hover
33
+ "list-view-table-row-hover": "rgb(249 250 251)", // Very light grey row hover
34
34
  "list-view-bread-crumbs-text": "#666666", // Medium grey bread crumbs
35
35
  "list-view-border-color": "#DDDDDD", // Light grey border
36
36
 
@@ -2,9 +2,9 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
- <link rel="icon" href="/favicon.ico">
5
+ <link rel="icon" href="/* IMPORTANT:ADMINFORTH FAVICON */">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Vite App</title>
7
+ <title>/* IMPORTANT:ADMINFORTH TITLE */</title>
8
8
  <!--
9
9
  <script>
10
10
  // On page load or when changing themes, best to add inline in `head` to avoid FOUC
@@ -17,6 +17,7 @@
17
17
  "flowbite-datepicker": "^1.2.6",
18
18
  "pinia": "^2.1.7",
19
19
  "unhead": "^1.9.12",
20
+ "uuid": "^10.0.0",
20
21
  "vue": "^3.4.21",
21
22
  "vue-router": "^4.3.0",
22
23
  "vue-slider-component": "^4.1.0-beta.7"
@@ -36,7 +37,7 @@
36
37
  "sass": "^1.77.2",
37
38
  "tailwindcss": "^3.4.3",
38
39
  "typescript": "~5.4.0",
39
- "vite": "^5.2.12",
40
+ "vite": "^5.2.13",
40
41
  "vue-tsc": "^2.0.11"
41
42
  }
42
43
  },
@@ -4032,10 +4033,22 @@
4032
4033
  "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
4033
4034
  "dev": true
4034
4035
  },
4036
+ "node_modules/uuid": {
4037
+ "version": "10.0.0",
4038
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",
4039
+ "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",
4040
+ "funding": [
4041
+ "https://github.com/sponsors/broofa",
4042
+ "https://github.com/sponsors/ctavan"
4043
+ ],
4044
+ "bin": {
4045
+ "uuid": "dist/bin/uuid"
4046
+ }
4047
+ },
4035
4048
  "node_modules/vite": {
4036
- "version": "5.2.12",
4037
- "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.12.tgz",
4038
- "integrity": "sha512-/gC8GxzxMK5ntBwb48pR32GGhENnjtY30G4A0jemunsBkiEZFw60s8InGpN8gkhHEkjnRK1aSAxeQgwvFhUHAA==",
4049
+ "version": "5.2.13",
4050
+ "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.13.tgz",
4051
+ "integrity": "sha512-SSq1noJfY9pR3I1TUENL3rQYDQCFqgD+lM6fTRAM8Nv6Lsg5hDLaXkjETVeBt+7vZBCMoibD+6IWnT2mJ+Zb/A==",
4039
4052
  "dev": true,
4040
4053
  "dependencies": {
4041
4054
  "esbuild": "^0.20.1",
@@ -21,6 +21,7 @@
21
21
  "flowbite-datepicker": "^1.2.6",
22
22
  "pinia": "^2.1.7",
23
23
  "unhead": "^1.9.12",
24
+ "uuid": "^10.0.0",
24
25
  "vue": "^3.4.21",
25
26
  "vue-router": "^4.3.0",
26
27
  "vue-slider-component": "^4.1.0-beta.7"
@@ -40,7 +41,7 @@
40
41
  "sass": "^1.77.2",
41
42
  "tailwindcss": "^3.4.3",
42
43
  "typescript": "~5.4.0",
43
- "vite": "^5.2.12",
44
+ "vite": "^5.2.13",
44
45
  "vue-tsc": "^2.0.11"
45
46
  }
46
47
  }
@@ -1,11 +1,12 @@
1
1
  <template>
2
2
  <nav
3
- v-if="loggedIn"
4
- class="fixed h-14 top-0 z-40 w-full border-b shadow-sm bg-header-bg shadow-header-shadow dark:bg-header-bg-hover dark:border-nav-menu-devider">
3
+ v-if="loggedIn && routerIsReady && loginRedirectCheckIsReady"
4
+ class="fixed h-14 top-0 z-20 w-full border-b shadow-sm bg-header-bg shadow-header-shadow dark:bg-header-bg-hover dark:border-nav-menu-devider">
5
5
  <div class="px-3 py-3 lg:px-5 lg:pl-3">
6
6
  <div class="flex items-center justify-between">
7
7
  <div class="flex items-center justify-start rtl:justify-end">
8
- <button data-drawer-target="logo-sidebar" data-drawer-toggle="logo-sidebar" aria-controls="logo-sidebar" type="button" class="inline-flex items-center p-2 text-sm rounded-lg sm:hidden hover:bg-nav-menu-bg-hover focus:outline-none focus:ring-2 focus:ring-nav-menu-devider dark:text-nav-menu-icons dark:hover:bg-nav-menu-bg-hover dark:focus:ring-nav-menu-devider">
8
+ <button @click="sideBarOpen = !sideBarOpen"
9
+ type="button" class="inline-flex items-center p-2 text-sm rounded-lg sm:hidden hover:bg-nav-menu-bg-hover focus:outline-none focus:ring-2 focus:ring-nav-menu-devider dark:text-nav-menu-icons dark:hover:bg-nav-menu-bg-hover dark:focus:ring-nav-menu-devider">
9
10
  <span class="sr-only">Open sidebar</span>
10
11
  <svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
11
12
  <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>
@@ -55,38 +56,41 @@
55
56
 
56
57
 
57
58
  <aside
58
- v-if="loggedIn"
59
59
 
60
- id="logo-sidebar" class="fixed border-none top-0 left-0 z-50 w-64 h-screen transition-transform -translate-x-full bg-nav-menu-bg border-r border- sm:translate-x-0 dark:bg-gray-800 dark:border-gray-700" aria-label="Sidebar">
61
- <div class="h-full px-3 pb-4 overflow-y-auto bg-nav-menu-bg dark:bg-gray-800">
60
+ v-if="loggedIn && routerIsReady && loginRedirectCheckIsReady"
61
+
62
+ id="logo-sidebar" class="fixed border-none top-0 left-0 z-20 w-64 h-screen transition-transform border-r border-nav-menu-border sm:translate-x-0 dark:bg-gray-800 dark:border-gray-700"
63
+ :class="{ '-translate-x-full': !sideBarOpen, 'transform-none': sideBarOpen }"
64
+ aria-label="Sidebar"
65
+ >
66
+ <div class="h-full px-3 pb-4 overflow-y-auto bg-white dark:bg-gray-800 border-r">
62
67
  <div class="flex ms-2 md:me-24 m-4 ">
63
- <img src="https://flowbite.com/docs/images/logo.svg" class="h-8 me-3" alt="FlowBite Logo" />
64
- <span class="self-center text-header-text-size font-semibold sm:text-header-text-size whitespace-nowrap dark:text-header-text text-header-logo-color">
65
- {{ coreStore.config?.brandName }}
66
- </span>
67
- </div>
68
+ <img :src="loadFile(coreStore.config?.brandLogo || '@/assets/logo.svg')" :alt="`${ coreStore.config?.brandName } Logo`" class="h-8 me-3" />
69
+ <span class="self-center text-header-text-size font-semibold sm:text-header-text-size whitespace-nowrap dark:text-header-text text-header-logo-color">
70
+ {{ coreStore.config?.brandName }}
71
+ </span>
72
+ </div>
73
+
68
74
  <ul class="space-y-2 font-medium">
69
75
  <template v-for="(item, i) in coreStore.menu" :key="`menu-${i}`">
70
76
  <div v-if="item.type === 'divider'" class="border-t border-nav-menu-devider dark:border-gray-700"></div>
71
77
  <div v-else-if="item.type === 'gap'" class="flex items-center justify-center h-8"></div>
72
78
  <div v-else-if="item.type === 'heading'" class="flex items-center justify-left pl-2 h-8 text-gray-400 dark:text-gray-400
73
79
  ">{{ item.label }}</div>
74
-
75
-
76
80
  <li v-else-if="item.children">
77
- <button type="button" class="flex items-center w-full p-2 text-base text-nav-menu-text rounded-default transition duration-75 group hover:bg-nav-menu-bg-hover dark:text-white dark:hover:bg-gray-700"
81
+ <button @click="clickOnMenuItem(i)" type="button" class="flex items-center w-full p-2 text-base text-nav-menu-text rounded-default transition duration-75 group hover:bg-nav-menu-bg-hover dark:text-white dark:hover:bg-gray-700"
78
82
  :aria-controls="`dropdown-example${i}`"
79
83
  :data-collapse-toggle="`dropdown-example${i}`"
80
84
  >
81
85
  <component v-if="item.icon" :is="getIcon(item.icon)" class="w-5 h-5 text-gray-500 transition duration-75 dark:text-gray-400 dark:group-hover:text-white" ></component>
82
86
 
83
87
  <span class="flex-1 ms-3 text-left rtl:text-right whitespace-nowrap">{{ item.label }}</span>
84
- <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
88
+ <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">
85
89
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
86
90
  </svg>
87
91
  </button>
88
92
 
89
- <ul :id="`dropdown-example${i}`" role="none" class="pt-1 space-y-1" :class="{ 'hidden': !item.open }">
93
+ <ul :id="`dropdown-example${i}`" role="none" class="pt-1 space-y-1" :class="{ 'hidden': !opened.includes(i) }">
90
94
  <template v-for="(child, j) in item.children" :key="`menu-${i}-${j}`">
91
95
  <li>
92
96
  <MenuLink :item="child" isChild="true" />
@@ -101,20 +105,61 @@
101
105
  </ul>
102
106
  </div>
103
107
  </aside>
104
-
105
- <div class="p-4 sm:ml-64 dark:bg-gray-800" v-if="loggedIn">
108
+
109
+
110
+ <div class="p-4 sm:ml-64 dark:bg-gray-800" v-if="loggedIn && routerIsReady && loginRedirectCheckIsReady">
106
111
  <div class="p-0 dark:border-gray-700 mt-14">
107
112
  <RouterView/>
108
113
  </div>
109
114
  </div>
110
115
 
111
- <div v-else-if="routerIsReady">
116
+ <div v-else-if="routerIsReady && loginRedirectCheckIsReady">
112
117
  <RouterView/>
113
118
  </div>
119
+ <div v-else class="flex items-center justify-center h-screen">
120
+ <div class="text-3xl text-gray-400 animate-bounce">
121
+ <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>
122
+ <span class="sr-only">Loading...</span>
123
+ </div>
124
+ </div>
114
125
  <AcceptModal />
126
+ <div v-if="toastStore.toasts.length>0" class="fixed bottom-5 right-5 flex gap-1 flex-col-reverse">
127
+ <transition-group
128
+ name="fade"
129
+ tag="div"
130
+ class="flex flex-col-reverse gap-1"
131
+ >
132
+ <Toast :toast="t" @close="toastStore.removeToast(t)" v-for="(t,i) in toastStore.toasts" :key="`t-${t.id}`" ></Toast>
133
+ </transition-group>
134
+ </div>
135
+
136
+ <div v-if="sideBarOpen"
137
+ @click="sideBarOpen = false"
138
+
139
+ drawer-backdrop="" class="bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-5"></div>
140
+
141
+
142
+
115
143
  </template>
116
144
 
117
- <style scoped>
145
+ <style lang="scss" scoped>
146
+
147
+ .fade-leave-active {
148
+ @apply transition-opacity duration-500;
149
+ }
150
+ .fade-leave-to {
151
+ @apply opacity-0;
152
+ }
153
+ .fade-enter-active {
154
+ @apply transition-opacity duration-500;
155
+ }
156
+ .fade-enter-from {
157
+ @apply opacity-0;
158
+ }
159
+ .fade-enter-to {
160
+ @apply opacity-100;
161
+ }
162
+
118
163
  </style>
119
164
 
120
165
  <script setup lang="ts">
@@ -123,6 +168,8 @@ import { RouterLink, RouterView } from 'vue-router';
123
168
  import { initFlowbite } from 'flowbite'
124
169
  import './index.scss'
125
170
  import { useCoreStore } from '@/stores/core';
171
+ import { useUserStore } from '@/stores/user';
172
+ import {useModalStore} from '@/stores/modal';
126
173
  import { IconMoonSolid, IconSunSolid } from '@iconify-prerendered/vue-flowbite';
127
174
  import AcceptModal from './components/AcceptModal.vue';
128
175
  import MenuLink from './components/MenuLink.vue';
@@ -130,25 +177,34 @@ import { useRoute, useRouter } from 'vue-router';
130
177
  import { getIcon } from '@/utils';
131
178
  import { useHead } from 'unhead'
132
179
  import { createHead } from 'unhead'
180
+ import { loadFile } from '@/utils';
181
+ import Toast from './components/Toast.vue';
182
+ import {useToastStore} from '@/stores/toast';
183
+ import { FrontendAPI } from '@/composables/useStores'
133
184
  // import { link } from 'fs';
134
185
  const coreStore = useCoreStore();
135
-
136
-
186
+ const modalStore = useModalStore();
187
+ const toastStore = useToastStore();
188
+ const userStore = useUserStore();
189
+ const frontendApi = new FrontendAPI();
190
+ frontendApi.init();
191
+ const splitAtLast = (str: string, separator: string) => {
192
+ const index = str.lastIndexOf(separator);
193
+ return [str.slice(0, index), str.slice(index + 1)];
194
+ }
137
195
  createHead()
138
-
139
-
140
-
141
-
142
-
143
-
196
+ const sideBarOpen = ref(false);
144
197
  const route = useRoute();
145
198
  const router = useRouter();
146
199
  const title = ref('');
200
+ //create a ref to store the opened menu items with ts type;
201
+ const opened = ref<string[]>([]);
147
202
 
148
203
 
149
204
  const routerIsReady = ref(false);
205
+ const loginRedirectCheckIsReady = ref(false);
150
206
 
151
- const loggedIn = computed(() => route.name !== 'login' && routerIsReady.value);
207
+ const loggedIn = computed(() => route.name !== 'login');
152
208
 
153
209
  const theme = ref('light');
154
210
 
@@ -157,9 +213,19 @@ function toggleTheme() {
157
213
  document.documentElement.classList.toggle('dark');
158
214
  }
159
215
 
216
+ function clickOnMenuItem (label: string) {
217
+ if (opened.value.includes(label)) {
218
+ opened.value = opened.value.filter((item) => item !== label);
219
+ } else {
220
+ opened.value.push(label);
221
+ }
222
+
223
+ }
224
+
160
225
  async function logout() {
161
- await coreStore.logout();
162
- router.push({ name: 'login' });
226
+ userStore.unauthorize();
227
+ await userStore.logout();
228
+ router.push({ name: 'login' })
163
229
  }
164
230
 
165
231
 
@@ -170,22 +236,36 @@ async function initRouter() {
170
236
  routerIsReady.value = true;
171
237
  }
172
238
 
239
+ async function loadMenu() {
240
+ await coreStore.fetchMenuAndResource()
241
+ loginRedirectCheckIsReady.value = true;
242
+
243
+ coreStore.menu.forEach((item, i) => {
244
+ if (item.open) {
245
+ opened.value.push(i);
246
+ }
247
+ });
248
+ }
249
+
250
+
251
+
252
+ watch(route, () => {
253
+ title.value = `${coreStore.config?.title || coreStore.config?.brandName || 'Adminforth'} | ${ Object.values(route.params)[0] || route.meta.title || ' '}`;
254
+ useHead({
255
+ title: title.value,
256
+ })
257
+ });
258
+
173
259
  // initialize components based on data attribute selectors
174
260
  onMounted(async () => {
175
- initRouter();
176
- initFlowbite();
177
- await coreStore.fetchMenuAndResource();
178
- title.value = coreStore.config.title || 'Admin Forth';
179
- useHead({
180
- title: title.value,
181
- link: [
182
- {
183
- rel: 'icon',
184
- href: coreStore.config.favicon || '/favicon.ico',
185
- },
186
- ],
187
-
188
- })
261
+ loadMenu(); // run this in async mode
262
+ // before init flowbite we have to wait router initialized because it affects dom(our v-ifs) and fetch menu
263
+ await initRouter()
264
+ setTimeout(() => {
265
+ initFlowbite();
266
+ });
267
+
268
+
189
269
  })
190
270
 
191
271
  </script>
@@ -1 +1,19 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>
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>
@@ -3,13 +3,6 @@ import { ref,onMounted } from 'vue'
3
3
  import { useModalStore } from '@/stores/modal';
4
4
 
5
5
  const modalStore = useModalStore();
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
6
  </script>
14
7
 
15
8
  <template>
@@ -28,10 +21,10 @@ const modalStore = useModalStore();
28
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"/>
29
22
  </svg>
30
23
  <h3 class="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{{ modalStore?.modalContent?.content }}</h3>
31
- <button @click="()=>{modalStore.onAcceptFunction();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">
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">
32
25
  {{ modalStore?.modalContent?.acceptText }}
33
26
  </button>
34
- <button @click="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-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">{{ modalStore?.modalContent?.cancelText }}</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-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">{{ modalStore?.modalContent?.cancelText }}</button>
35
28
  </div>
36
29
  </div>
37
30
  </div>
@@ -2,7 +2,7 @@
2
2
  <div>
3
3
  <div class="flex items-center justify-between mb-3 flex-wrap gap-y-2">
4
4
  <Breadcrumbs />
5
- <div class="flex items-center space-x-1">
5
+ <div class="flex items-center space-x-1 flex-wrap gap-y-1">
6
6
  <slot></slot>
7
7
  </div>
8
8
  </div>
@@ -67,6 +67,9 @@ const props = defineProps({
67
67
  },
68
68
  label: {
69
69
  type: String,
70
+ },
71
+ autoHide: {
72
+ type: Boolean,
70
73
  }
71
74
  });
72
75
 
@@ -100,8 +103,7 @@ function updateFromProps() {
100
103
  if (!props.valueStart) {
101
104
  datepickerStartEl.value.value = '';
102
105
  startTime.value = '';
103
- }
104
- else {
106
+ } else {
105
107
  datepickerObject.value.setDate(dayjs(props.valueStart).format('DD MMM YYYY'));
106
108
  startTime.value = dayjs(props.valueStart).format('HH:mm:ss')
107
109
  }
@@ -121,7 +123,13 @@ watch(start, () => {
121
123
  })
122
124
 
123
125
  function initDatepickers() {
124
- datepickerObject.value = new Datepicker(datepickerStartEl.value, { format: 'dd M yyyy' });
126
+ const options = {format: 'dd M yyyy'};
127
+
128
+ if (props.autoHide) {
129
+ options.autohide = true;
130
+ }
131
+
132
+ datepickerObject.value = new Datepicker(datepickerStartEl.value, options);
125
133
 
126
134
  addChangeDateListener();
127
135
  }
@@ -134,6 +142,10 @@ function removeChangeDateListener() {
134
142
  datepickerStartEl.value.removeEventListener('changeDate', setStartDate);
135
143
  }
136
144
 
145
+ function destroyDatepickerElement() {
146
+ datepickerObject.value.destroy();
147
+ }
148
+
137
149
  function setStartDate(event) {
138
150
  startDate.value = event.detail.date
139
151
  }
@@ -157,5 +169,6 @@ onMounted(() => {
157
169
 
158
170
  onBeforeUnmount(() => {
159
171
  removeChangeDateListener();
172
+ destroyDatepickerElement();
160
173
  });
161
174
  </script>
@@ -101,6 +101,9 @@ const endDate = ref('');
101
101
  const startTime = ref('');
102
102
  const endTime = ref('');
103
103
 
104
+ const datepickerStartObject = ref('')
105
+ const datepickerEndObject = ref('')
106
+
104
107
  const start = computed(() => {
105
108
  if (!startDate.value) {
106
109
  return;
@@ -162,9 +165,9 @@ watch(end, () => {
162
165
 
163
166
  function initDatepickers() {
164
167
 
165
- new Datepicker(datepickerStartEl.value, {format: 'dd M yyyy'});
168
+ datepickerStartObject.value = new Datepicker(datepickerStartEl.value, {format: 'dd M yyyy'});
166
169
 
167
- new Datepicker(datepickerEndEl.value, {format: 'dd M yyyy'});
170
+ datepickerEndObject.value = new Datepicker(datepickerEndEl.value, {format: 'dd M yyyy'});
168
171
  addChangeDateListener();
169
172
  }
170
173
 
@@ -178,6 +181,11 @@ function removeChangeDateListener() {
178
181
  datepickerEndEl.value.removeEventListener('changeDate', setEndDate);
179
182
  }
180
183
 
184
+ function destroyDatepickerElement() {
185
+ datepickerStartObject.value.destroy();
186
+ datepickerEndObject.value.destroy();
187
+ }
188
+
181
189
  function setStartDate(event) {
182
190
  startDate.value = event.detail.date
183
191
  }
@@ -205,5 +213,6 @@ onMounted(() => {
205
213
 
206
214
  onBeforeUnmount(() => {
207
215
  removeChangeDateListener();
216
+ destroyDatepickerElement();
208
217
  })
209
218
  </script>
@@ -6,7 +6,7 @@
6
6
  v-model="search"
7
7
  @focus="showDropdown = true"
8
8
  class="block w-full pl-3 pr-10 py-2 border border-gray-300 rounded-md leading-5 bg-white placeholder-gray-500 focus:outline-none focus:shadow-outline-blue focus:border-blue-300 sm:text-sm transition duration-150 ease-in-out dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
9
- :placeholder="selectedItems.length ? '' : 'Select...'"
9
+ :placeholder="selectedItems.length ? '' : placeholder || 'Select...'"
10
10
  />
11
11
  <div class="absolute inset-y-0 left-2 flex items-center pr-2 flex-wrap">
12
12
  {{ }}
@@ -67,6 +67,11 @@ const props = defineProps({
67
67
  type: Boolean,
68
68
  default: false,
69
69
  },
70
+ placeholder: {
71
+ type: String,
72
+ default: '',
73
+
74
+ },
70
75
  });
71
76
 
72
77
  const emit = defineEmits(['update:modelValue']);