adminforth 1.1.47 → 1.1.48

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 (65) hide show
  1. package/dist/modules/codeInjector.js +13 -22
  2. package/dist/modules/styleGenerator.js +39 -0
  3. package/dist/modules/styles.js +84 -53
  4. package/dist/modules/utils.js +44 -0
  5. package/dist/plugins/AccessControl/index.js +66 -0
  6. package/dist/plugins/AccessControl/types.js +1 -0
  7. package/dist/spa/index.html +2 -2
  8. package/dist/spa/package-lock.json +4 -17
  9. package/dist/spa/package.json +1 -2
  10. package/dist/spa/public/favicon.ico +0 -0
  11. package/dist/spa/spa/index.html +1 -1
  12. package/dist/spa/spa/public/favicon.ico +0 -0
  13. package/dist/spa/spa/src/App.vue +16 -16
  14. package/dist/spa/spa/src/components/MenuLink.vue +3 -3
  15. package/dist/spa/spa/src/components/ResourceForm.vue +3 -3
  16. package/dist/spa/spa/src/components/ResourceListTable.vue +7 -64
  17. package/dist/spa/spa/src/components/SkeleteLoader.vue +23 -0
  18. package/dist/spa/spa/src/views/ListView.vue +1 -1
  19. package/dist/spa/spa/src/views/ShowView.vue +3 -3
  20. package/dist/spa/src/App.vue +45 -125
  21. package/dist/spa/src/assets/logo.svg +1 -19
  22. package/dist/spa/src/components/AcceptModal.vue +9 -2
  23. package/dist/spa/src/components/BreadcrumbsWithButtons.vue +1 -1
  24. package/dist/spa/src/components/CustomDatePicker.vue +3 -16
  25. package/dist/spa/src/components/CustomDateRangePicker.vue +2 -11
  26. package/dist/spa/src/components/Dropdown.vue +1 -6
  27. package/dist/spa/src/components/Filters.vue +19 -40
  28. package/dist/spa/src/components/ResourceForm.vue +24 -26
  29. package/dist/spa/src/components/ValueRenderer.vue +8 -14
  30. package/dist/spa/src/main.ts +1 -1
  31. package/dist/spa/src/router/index.ts +20 -30
  32. package/dist/spa/src/stores/core.ts +31 -48
  33. package/dist/spa/src/stores/modal.ts +3 -13
  34. package/dist/spa/src/utils.ts +7 -62
  35. package/dist/spa/src/views/CreateView.vue +15 -67
  36. package/dist/spa/src/views/EditView.vue +11 -45
  37. package/dist/spa/src/views/ListView.vue +366 -82
  38. package/dist/spa/src/views/LoginView.vue +4 -16
  39. package/dist/spa/src/views/ShowView.vue +21 -105
  40. package/dist/spa/tailwind.config.js +1 -1
  41. package/dist/spa/vite.config.ts +0 -6
  42. package/dist/types.js +30 -0
  43. package/modules/codeInjector.ts +10 -18
  44. package/modules/styleGenerator.ts +45 -0
  45. package/modules/styles.ts +95 -48
  46. package/modules/utils.ts +48 -0
  47. package/package.json +1 -1
  48. package/spa/index.html +1 -1
  49. package/spa/src/App.vue +16 -16
  50. package/spa/src/components/MenuLink.vue +3 -3
  51. package/spa/src/components/ResourceForm.vue +3 -3
  52. package/spa/src/components/ResourceListTable.vue +7 -64
  53. package/spa/src/components/SkeleteLoader.vue +23 -0
  54. package/spa/src/views/ListView.vue +1 -1
  55. package/spa/src/views/ShowView.vue +3 -3
  56. package/types/AdminForthConfig.ts +6 -4
  57. package/dist/spa/src/components/ResourceListTable.vue +0 -419
  58. package/dist/spa/src/components/Toast.vue +0 -66
  59. package/dist/spa/src/composables/useFrontendApi.ts +0 -26
  60. package/dist/spa/src/composables/useStores.ts +0 -113
  61. package/dist/spa/src/spa_types/core.ts +0 -51
  62. package/dist/spa/src/stores/filters.ts +0 -22
  63. package/dist/spa/src/stores/toast.ts +0 -15
  64. package/dist/spa/src/stores/user.ts +0 -54
  65. /package/dist/spa/{public/assets → spa/public}/favicon.png +0 -0
@@ -15,9 +15,8 @@ import fsExtra from 'fs-extra';
15
15
  import os from 'os';
16
16
  import path from 'path';
17
17
  import { promisify } from 'util';
18
- import { ADMIN_FORTH_ABSOLUTE_PATH } from './utils.js';
19
- import { getComponentNameFromPath } from './utils.js';
20
- import { styles } from './styles.js';
18
+ import { ADMIN_FORTH_ABSOLUTE_PATH, getComponentNameFromPath } from './utils.js';
19
+ import { StylesGenerator } from './styleGenerator.js';
21
20
  let TMP_DIR;
22
21
  try {
23
22
  TMP_DIR = os.tmpdir();
@@ -87,7 +86,7 @@ class CodeInjector {
87
86
  }
88
87
  prepareSources(_a) {
89
88
  return __awaiter(this, arguments, void 0, function* ({ filesUpdated, verbose = false }) {
90
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
89
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
91
90
  // check SPA_TMP_PATH exists and create if not
92
91
  try {
93
92
  yield fs.promises.access(CodeInjector.SPA_TMP_PATH, fs.constants.F_OK);
@@ -299,21 +298,13 @@ class CodeInjector {
299
298
  appVueContent = appVueContent.replace('/* IMPORTANT:ADMINFORTH CUSTOM USES */', 'addCustomUses(app);');
300
299
  }
301
300
  yield fs.promises.writeFile(appVuePath, appVueContent);
302
- // generate tailwind extend 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;
305
- const stylesText = JSON.stringify(tailwindStyles, null, 2).slice(1, -1);
306
- let tailwindConfigPath = path.join(CodeInjector.SPA_TMP_PATH, 'tailwind.config.js');
307
- let tailwindConfigContent = yield fs.promises.readFile(tailwindConfigPath, 'utf-8');
308
- tailwindConfigContent = tailwindConfigContent.replace('/* IMPORTANT:ADMINFORTH TAILWIND STYLES */', stylesText);
309
- yield fs.promises.writeFile(tailwindConfigPath, tailwindConfigContent);
310
- }
311
- else {
312
- let tailwindConfigPath = path.join(CodeInjector.SPA_TMP_PATH, 'tailwind.config.js');
313
- let tailwindConfigContent = yield fs.promises.readFile(tailwindConfigPath, 'utf-8');
314
- tailwindConfigContent = tailwindConfigContent.replace('/* IMPORTANT:ADMINFORTH TAILWIND STYLES */', styles());
315
- yield fs.promises.writeFile(tailwindConfigPath, tailwindConfigContent);
316
- }
301
+ // generate tailwind extend styles
302
+ const stylesGenerator = new StylesGenerator((_g = this.adminforth.config.customization) === null || _g === void 0 ? void 0 : _g.styles);
303
+ const stylesText = JSON.stringify(stylesGenerator.mergeStyles(), null, 2).slice(1, -1);
304
+ let tailwindConfigPath = path.join(CodeInjector.SPA_TMP_PATH, 'tailwind.config.js');
305
+ let tailwindConfigContent = yield fs.promises.readFile(tailwindConfigPath, 'utf-8');
306
+ tailwindConfigContent = tailwindConfigContent.replace('/* IMPORTANT:ADMINFORTH TAILWIND STYLES */', stylesText);
307
+ yield fs.promises.writeFile(tailwindConfigPath, tailwindConfigContent);
317
308
  const routerVuePath = path.join(CodeInjector.SPA_TMP_PATH, 'src', 'router', 'index.ts');
318
309
  let routerVueContent = yield fs.promises.readFile(routerVuePath, 'utf-8');
319
310
  routerVueContent = routerVueContent.replace('/* IMPORTANT:ADMINFORTH ROUTES IMPORTS */', routerComponents);
@@ -321,17 +312,17 @@ class CodeInjector {
321
312
  const indexHtmlPath = path.join(CodeInjector.SPA_TMP_PATH, 'index.html');
322
313
  let indexHtmlContent = yield fs.promises.readFile(indexHtmlPath, 'utf-8');
323
314
  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/`))
315
+ indexHtmlContent = indexHtmlContent.replace('/* IMPORTANT:ADMINFORTH FAVICON */', ((_h = this.adminforth.config.customization.favicon) === null || _h === void 0 ? void 0 : _h.replace('@@/', `${this.adminforth.baseUrlSlashed}assets/`))
325
316
  ||
326
317
  `${this.adminforth.baseUrlSlashed}assets/favicon.png`);
327
318
  yield fs.promises.writeFile(indexHtmlPath, indexHtmlContent);
328
319
  /* generate custom routes */
329
320
  const homepageMenuItem = this.adminforth.config.menu.find((mi) => mi.homepage);
330
321
  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)); });
331
- let childrenHomepage = (_k = childrenHomePageMenuItem === null || childrenHomePageMenuItem === void 0 ? void 0 : childrenHomePageMenuItem.children) === null || _k === void 0 ? void 0 : _k.find((mi) => mi.homepage);
322
+ let childrenHomepage = (_j = childrenHomePageMenuItem === null || childrenHomePageMenuItem === void 0 ? void 0 : childrenHomePageMenuItem.children) === null || _j === void 0 ? void 0 : _j.find((mi) => mi.homepage);
332
323
  let homePagePath = (homepageMenuItem === null || homepageMenuItem === void 0 ? void 0 : homepageMenuItem.path) || `/resource/${childrenHomepage === null || childrenHomepage === void 0 ? void 0 : childrenHomepage.resourceId}`;
333
324
  if (!homePagePath) {
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}`;
325
+ homePagePath = ((_k = this.adminforth.config.menu.filter((mi) => mi.path)[0]) === null || _k === void 0 ? void 0 : _k.path) || `/resource/${(_l = this.adminforth.config.menu.filter((mi) => mi.children)[0]) === null || _l === void 0 ? void 0 : _l.resourceId}`;
335
326
  }
336
327
  routes += `{
337
328
  path: '/',
@@ -0,0 +1,39 @@
1
+ import { transformObject, deepMerge } from "./utils.js";
2
+ import { styles } from "./styles.js";
3
+ const aliasObject = { lightSidebarText: 'lightSidebarIcons', darkSidebarText: 'darkSidebarIcons', lightSidebarTextHover: 'lightSidebarIconsHover', darkSidebarTextHover: 'darkSidebarIconsHover' };
4
+ export class StylesGenerator {
5
+ constructor(styleConfig) {
6
+ if (!styleConfig) {
7
+ console.log("No styles provided using default styles.");
8
+ }
9
+ this.styleConfig = styleConfig;
10
+ this.defaultStyles = styles();
11
+ }
12
+ generatePlainStyles(styleObj) {
13
+ let plainCustomStyles = {};
14
+ if (styleObj) {
15
+ Object.keys(styleObj).forEach((k) => {
16
+ plainCustomStyles[k] = transformObject(styleObj[k]);
17
+ });
18
+ }
19
+ return plainCustomStyles;
20
+ }
21
+ changeAliases(plateStyles) {
22
+ if (!plateStyles || !plateStyles.colors) {
23
+ return plateStyles;
24
+ }
25
+ let colors = plateStyles.colors;
26
+ Object.keys(aliasObject).forEach((aliasName) => {
27
+ if (colors[aliasObject[aliasName]])
28
+ return;
29
+ if (!colors[aliasName])
30
+ return;
31
+ colors[aliasObject[aliasName]] = colors[aliasName];
32
+ });
33
+ return plateStyles;
34
+ }
35
+ mergeStyles() {
36
+ let mergedStyles = deepMerge(this.defaultStyles, this.changeAliases(this.generatePlainStyles(this.styleConfig)));
37
+ return mergedStyles;
38
+ }
39
+ }
@@ -1,53 +1,84 @@
1
- export const styles = () => `
2
-
3
- "colors": {
4
- "html-bg": "#FFFFFF", // Changed to white
5
- "header-bg": "#FFFFFF", // Light grey
6
- "header-bg-hover": "#D3D3D3", // Light grey hover
7
- "header-text": "#333333", // Dark grey text
8
- "header-text-hover": "#333333", // Dark grey text hover
9
- "header-icons": "#333333", // Dark grey icons
10
- "header-icons-hover": "#333333", // Dark grey icons hover
11
- "header-logo-color": "#333333", // Dark grey logo
12
- "header-border-color": "rgb(229 231 235)", // Light grey border
13
-
14
- "nav-menu-bg": "#ffffff", // Very light grey
15
- "nav-menu-border": "rgb(229 231 235)",
16
- "nav-menu-bg-hover": "rgb(243 244 246)", // Light grey hover
17
- "nav-menu-bg-active": "rgb(233, 234, 236)", // Light grey active
18
- "nav-menu-hover": "#rgb(209 213 219)", // Light grey hover
19
- "nav-menu-active": "#CCCCCC", // Light grey active
20
- "nav-menu-active-text": "#333333", // Dark grey active text
21
- "nav-menu-text": "#333333", // Dark grey text
22
- "nav-menu-text-hover": "#333333", // Dark grey text hover
23
- "nav-menu-text-active": "#333333", // Dark grey text active
24
- "nav-menu-devider": "#E0E0E0", // Light grey divider
25
- "nav-menu-icons": "#333333", // Dark grey icons
26
- "nav-menu-heading": "#333333", // Dark grey heading
27
-
28
- "list-view-bg": "#FFFFFF", // White background
29
- "list-view-table-bg": "#FFFFFF", // White table background
30
- "list-view-table-heading": "rgb(249 250 251)", // Very light grey heading
31
- "list-view-table-heading-text": "#333333", // Dark grey heading text
32
- "list-view-table-text": "#333333", // Dark grey text
33
- "list-view-table-row-hover": "rgb(249 250 251)", // Very light grey row hover
34
- "list-view-bread-crumbs-text": "#666666", // Medium grey bread crumbs
35
- "list-view-border-color": "#DDDDDD", // Light grey border
36
-
37
- "form-view-bg": "#FFFFFF", // White form background
38
- "form-view-border-color": "#F5F5F5", // Very light grey border
39
- "form-view-heading": "#EDEDED" // Dark grey heading
40
- },
41
- "boxShadow": {
42
- "custom-light": "0 4px 8px rgba(0, 0, 0, 0.1)", // Lighter shadow
43
- "header-shadow": "0 4px 8px rgba(0, 0, 0, 0.1)", // Lighter shadow
44
- "list-table-shadow": "0 4px 8px rgba(0, 0, 0, 0.1)", // Lighter shadow
45
- "resourse-form-shadow": "0 4px 8px rgba(0, 0, 0, 0.1)" // Lighter shadow
46
- },
47
- "fontSize": {
48
- "header-text-size": "1rem"
49
- },
50
- "borderRadius": {
51
- "default": "2px"
52
- }
53
- `;
1
+ export const styles = () => ({
2
+ colors: {
3
+ lightHtml: "#FFFFFF", // main background
4
+ lightNavbar: "#FFFFFF", // navbar background
5
+ lightNavbarHover: "#D3D3D3", // in development
6
+ lightNavbarText: "#333333", // in development
7
+ lightNavbarTextHover: "#333333", // in development
8
+ lightNavbarIcons: "#333333", // in development
9
+ lightNavbarIconsHover: "#333333", // in development
10
+ lightNavbarLogo: "#333333", // in development
11
+ lightNavbarBorder: "rgb(229 231 235)", // border
12
+ lightSidebar: "#ffffff", // sidebar background
13
+ lightSidebarBorder: "rgb(229 231 235)", // sidebar right border
14
+ lightSidebarHover: "rgb(243 244 246)", // in development
15
+ lightSidebarActive: "rgb(233, 234, 236)", // in development
16
+ lightSidebarItemHover: "rgb(243 244 246)", // sidebar list item hover
17
+ lightSidebarItemActive: "rgb(233, 234, 236)", // sidebar list item active
18
+ lightSidebarText: "#4b5563", // sidebar list item text
19
+ lightSidebarTextHover: "#333333", // sidebar list item text hover
20
+ lightSidebarTextActive: "#333333", // sidebar list item text active
21
+ lightSidebarDevider: "#E0E0E0", // sidebar devider
22
+ lightSidebarIcons: "#6b7280", // sidebar list item icons
23
+ lightSidebarIconsHover: "#333333", // sidebar list item icons hover
24
+ lightSidebarHeading: "#333333", // sidebar heading
25
+ lightList: "#FFFFFF", // list view background
26
+ lightListTable: "#FFFFFF", // list view table background
27
+ lightListTableHeading: "rgb(249 250 251)", // list view table heading
28
+ lightListTableHeadingText: "#333333", // list view table heading text
29
+ lightListTableText: "#333333", // list view table text
30
+ lightListTableRowHover: "rgb(249 250 251)", // list view row hover
31
+ lightListBreadcrumbsText: "#666666", // list view breadcrumbs text
32
+ lightListBorder: "#DDDDDD", // list view rows border
33
+ lightForm: "#FFFFFF", // show view background
34
+ lightFormBorder: "#F5F5F5", // show view rows border
35
+ lightFormHeading: "#EDEDED", // show view heading
36
+ // colors for dark theme
37
+ darkHtml: "#111827",
38
+ darkNavbar: "#111827",
39
+ darkNavbarHover: "#444444",
40
+ darkNavbarText: "#FFFFFF",
41
+ darkNavbarTextHover: "#FFFFFF",
42
+ darkNavbarIcons: "#FFFFFF",
43
+ darkNavbarIconsHover: "#FFFFFF",
44
+ darkNavbarLogo: "#FFFFFF",
45
+ darkNavbarBorder: "#e5e7eb",
46
+ darkSidebar: "#1f2937",
47
+ darkSidebarBorder: "#374151",
48
+ darkSidebarHover: "#374151",
49
+ darkSidebarActive: "#444444",
50
+ darkSidebarItemHover: "#374151",
51
+ darkSidebarItemActive: "#52525b",
52
+ darkSidebarItemActiveText: "#FFFFFF",
53
+ darkSidebarText: "#9ca3af",
54
+ darkSidebarTextHover: "#FFFFFF",
55
+ darkSidebarTextActive: "#FFFFFF",
56
+ darkSidebarDevider: "#374151",
57
+ darkSidebarIcons: "#9ca3af",
58
+ darkSidebarIconsHover: "#FFFFFF",
59
+ darkSidebarHeading: "#FFFFFF",
60
+ darkList: "#111111",
61
+ darkListTable: "#1f2937",
62
+ darkListTableHeading: "#334155",
63
+ darkListTableHeadingText: "#9ca3af",
64
+ darkListTableText: "#9ca3af",
65
+ darkListTableRowHover: "#4b5563",
66
+ darkListBreadcrumbsText: "#BBBBBB",
67
+ darkListBorder: "#444444",
68
+ darkForm: "#111111",
69
+ darkFormBorder: "#222222",
70
+ darkFormHeading: "#333333"
71
+ },
72
+ boxShadow: {
73
+ customLight: "0 4px 8px rgba(0, 0, 0, 0.1)", // Lighter shadow
74
+ headerShadow: "0 4px 8px rgba(0, 0, 0, 0.1)", // Lighter shadow
75
+ listTableShadow: "0 4px 8px rgba(0, 0, 0, 0.1)", // Lighter shadow
76
+ resourseFormShadow: "0 4px 8px rgba(0, 0, 0, 0.1)" // Lighter shadow
77
+ },
78
+ fontSize: {
79
+ "headerText-size": "1rem"
80
+ },
81
+ borderRadius: {
82
+ "default": "2px"
83
+ }
84
+ });
@@ -31,3 +31,47 @@ export function getComponentNameFromPath(filePath) {
31
31
  export function listify(param) {
32
32
  return param || [];
33
33
  }
34
+ export function deepMerge(target, source) {
35
+ if (typeof target !== 'object' || target === null) {
36
+ return source;
37
+ }
38
+ for (let key in source) {
39
+ if (source.hasOwnProperty(key)) {
40
+ if (typeof source[key] === 'object' && source[key] !== null) {
41
+ if (!target[key]) {
42
+ target[key] = {};
43
+ }
44
+ deepMerge(target[key], source[key]);
45
+ }
46
+ else {
47
+ target[key] = source[key];
48
+ }
49
+ }
50
+ }
51
+ return target;
52
+ }
53
+ function toCamelCase(str) {
54
+ return str.replace(/[-_](.)/g, (_, char) => char.toUpperCase());
55
+ }
56
+ export function transformObject(obj, parentKey = '', result = {}) {
57
+ for (const key in obj) {
58
+ if (obj.hasOwnProperty(key)) {
59
+ const camelCaseKey = toCamelCase(parentKey ? `${parentKey}_${key}` : key);
60
+ if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
61
+ transformObject(obj[key], camelCaseKey, result);
62
+ }
63
+ else {
64
+ result[camelCaseKey] = obj[key];
65
+ }
66
+ }
67
+ }
68
+ //remove 'Default' from keys
69
+ for (const key in result) {
70
+ if (key.includes('Main')) {
71
+ const newKey = key.replace('Main', '');
72
+ result[newKey] = result[key];
73
+ delete result[key];
74
+ }
75
+ }
76
+ return result;
77
+ }
@@ -0,0 +1,66 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { AllowedActionsEnum } from "../../types/AdminForthConfig.js";
11
+ import AdminForthPlugin from "../base.js";
12
+ class AccessControlPlugin extends AdminForthPlugin {
13
+ constructor(options) {
14
+ super(options, import.meta.url);
15
+ this.options = options;
16
+ }
17
+ modifyResourceConfig(adminforth, resourceConfig) {
18
+ super.modifyResourceConfig(adminforth, resourceConfig);
19
+ this.adminforth = adminforth;
20
+ if (!resourceConfig.hooks) {
21
+ resourceConfig.hooks = {};
22
+ }
23
+ const checkAccess = (adminUser, action, meta) => __awaiter(this, void 0, void 0, function* () {
24
+ const hasAccessOrError = yield this.options.hasAccess(adminUser, action, meta);
25
+ if (hasAccessOrError === true) {
26
+ return { ok: true };
27
+ }
28
+ else {
29
+ return { ok: false, error: hasAccessOrError || AccessControlPlugin.defaultError };
30
+ }
31
+ });
32
+ const bindHookCheck = (action, hookName) => {
33
+ if (!resourceConfig.hooks[action]) {
34
+ resourceConfig.hooks[action] = {};
35
+ }
36
+ if (!resourceConfig.hooks[action][hookName]) {
37
+ resourceConfig.hooks[action][hookName] = [];
38
+ }
39
+ if (hookName === 'beforeDatasourceRequest') {
40
+ resourceConfig.hooks[action][hookName].unshift((_a) => __awaiter(this, [_a], void 0, function* ({ adminUser, query }) {
41
+ return checkAccess(adminUser, action, { query });
42
+ }));
43
+ }
44
+ else {
45
+ resourceConfig.hooks[action][hookName].unshift((_b) => __awaiter(this, [_b], void 0, function* ({ adminUser, record }) {
46
+ return checkAccess(adminUser, action, { record });
47
+ }));
48
+ }
49
+ };
50
+ // List check
51
+ bindHookCheck(AllowedActionsEnum.list, 'beforeDatasourceRequest');
52
+ // Show check
53
+ bindHookCheck(AllowedActionsEnum.show, 'beforeDatasourceRequest');
54
+ // Edit check
55
+ bindHookCheck(AllowedActionsEnum.edit, 'beforeDatasourceRequest');
56
+ // create check
57
+ bindHookCheck(AllowedActionsEnum.create, 'beforeSave');
58
+ // edit check
59
+ bindHookCheck(AllowedActionsEnum.edit, 'beforeSave');
60
+ // delete check
61
+ bindHookCheck(AllowedActionsEnum.delete, 'beforeSave');
62
+ console.log('resourceConfig', resourceConfig);
63
+ }
64
+ }
65
+ AccessControlPlugin.defaultError = 'Sorry, you do not have access to this resource.';
66
+ export default AccessControlPlugin;
@@ -0,0 +1 @@
1
+ export {};
@@ -2,9 +2,9 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
- <link rel="icon" href="/* IMPORTANT:ADMINFORTH FAVICON */">
5
+ <link rel="icon" href="/favicon.ico">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>/* IMPORTANT:ADMINFORTH TITLE */</title>
7
+ <title>Vite App</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,7 +17,6 @@
17
17
  "flowbite-datepicker": "^1.2.6",
18
18
  "pinia": "^2.1.7",
19
19
  "unhead": "^1.9.12",
20
- "uuid": "^10.0.0",
21
20
  "vue": "^3.4.21",
22
21
  "vue-router": "^4.3.0",
23
22
  "vue-slider-component": "^4.1.0-beta.7"
@@ -37,7 +36,7 @@
37
36
  "sass": "^1.77.2",
38
37
  "tailwindcss": "^3.4.3",
39
38
  "typescript": "~5.4.0",
40
- "vite": "^5.2.13",
39
+ "vite": "^5.2.12",
41
40
  "vue-tsc": "^2.0.11"
42
41
  }
43
42
  },
@@ -4033,22 +4032,10 @@
4033
4032
  "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
4034
4033
  "dev": true
4035
4034
  },
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
- },
4048
4035
  "node_modules/vite": {
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==",
4036
+ "version": "5.2.12",
4037
+ "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.12.tgz",
4038
+ "integrity": "sha512-/gC8GxzxMK5ntBwb48pR32GGhENnjtY30G4A0jemunsBkiEZFw60s8InGpN8gkhHEkjnRK1aSAxeQgwvFhUHAA==",
4052
4039
  "dev": true,
4053
4040
  "dependencies": {
4054
4041
  "esbuild": "^0.20.1",
@@ -21,7 +21,6 @@
21
21
  "flowbite-datepicker": "^1.2.6",
22
22
  "pinia": "^2.1.7",
23
23
  "unhead": "^1.9.12",
24
- "uuid": "^10.0.0",
25
24
  "vue": "^3.4.21",
26
25
  "vue-router": "^4.3.0",
27
26
  "vue-slider-component": "^4.1.0-beta.7"
@@ -41,7 +40,7 @@
41
40
  "sass": "^1.77.2",
42
41
  "tailwindcss": "^3.4.3",
43
42
  "typescript": "~5.4.0",
44
- "vite": "^5.2.13",
43
+ "vite": "^5.2.12",
45
44
  "vue-tsc": "^2.0.11"
46
45
  }
47
46
  }
Binary file
@@ -17,7 +17,7 @@
17
17
 
18
18
  </head>
19
19
  <body class=" ">
20
- <div id="app" class="min-h-screen bg-html-bg dark:bg-gray-800"></div>
20
+ <div id="app" class="min-h-screen bg-lightHtml dark:bg-darkHtml"></div>
21
21
  <script type="module" src="/src/main.ts"></script>
22
22
  </body>
23
23
  </html>
Binary file
@@ -1,12 +1,12 @@
1
1
  <template>
2
2
  <nav
3
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">
4
+ class="fixed h-14 top-0 z-20 w-full border-b shadow-sm bg-lightNavbar shadow-headerShadow dark:bg-darkNavbar dark:border-darkSidebarDevider">
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
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
+ 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">
10
10
  <span class="sr-only">Open sidebar</span>
11
11
  <svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
12
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>
@@ -17,25 +17,25 @@
17
17
  <div class="flex items-center">
18
18
  <div class="flex items-center ms-3 ">
19
19
  <div>
20
- <button type="button" class="flex text-sm bg-header-bg-hover rounded-full focus:ring-4 focus:ring-nav-menu-devider dark:focus:ring-nav-menu-devider dark:bg-header-bg-hover" aria-expanded="false" data-dropdown-toggle="dropdown-user">
20
+ <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">
21
21
  <span class="sr-only">Open user menu</span>
22
- <svg class="w-8 h-8 text-nav-menu-icons dark:text-header-icons" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
22
+ <svg class="w-8 h-8 text-lightSidebarIcons dark:text-darkSidebarIcons" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
23
23
  <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"/>
24
24
  </svg>
25
25
  </button>
26
26
  </div>
27
- <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-nav-menu-bg dark:divide-nav-menu-devider dark:shadow-black" id="dropdown-user">
27
+ <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">
28
28
  <div class="px-4 py-3" role="none">
29
- <p class="text-sm text-gray-900 dark:text-header-text" role="none" v-if="coreStore.userFullname">
29
+ <p class="text-sm text-gray-900 dark:text-darkNavbarText" role="none" v-if="coreStore.userFullname">
30
30
  {{ coreStore.userFullname }}
31
31
  </p>
32
- <p class="text-sm font-medium text-gray-900 truncate dark:text-nav-menu-text" role="none">
32
+ <p class="text-sm font-medium text-gray-900 truncate dark:text-darkSidebarText" role="none">
33
33
  {{ coreStore.username }}
34
34
  </p>
35
35
  </div>
36
36
  <ul class="py-1" role="none">
37
37
  <li>
38
- <span @click="toggleTheme" class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black hover:bg-html-bg dark:text-nav-menu-text-hover dark:hover:bg-nav-menu-hover dark:hover:text-nav-menu-text-active" role="menuitem">
38
+ <span @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">
39
39
  {{ theme === 'dark' ? 'Light' : 'Dark' }}
40
40
  <IconMoonSolid class="w-5 h-5 text-blue-300" v-if="theme !== 'dark'" />
41
41
  <IconSunSolid class="w-5 h-5 text-yellow-300" v-else />
@@ -43,7 +43,7 @@
43
43
  </span>
44
44
  </li>
45
45
  <li>
46
- <button @click="logout" class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black hover:bg-html-bg dark:text-nav-menu-text-hover dark:hover:bg-nav-menu-hover dark:hover:text-nav-menu-text-active w-full" role="menuitem">Sign out</button>
46
+ <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>
47
47
  </li>
48
48
  </ul>
49
49
  </div>
@@ -59,30 +59,30 @@
59
59
 
60
60
  v-if="loggedIn && routerIsReady && loginRedirectCheckIsReady"
61
61
 
62
- id="logo-sidebar" class="fixed border-none top-0 left-0 z-20 w-64 h-screen transition-transform bg-nav-menu-bg border-r border-nav-menu-border sm:translate-x-0 dark:bg-gray-800 dark:border-gray-700"
62
+ 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"
63
63
  :class="{ '-translate-x-full': !sideBarOpen, 'transform-none': sideBarOpen }"
64
64
  aria-label="Sidebar"
65
65
  >
66
- <div class="h-full px-3 pb-4 overflow-y-auto bg-nav-menu-bg dark:bg-gray-800 border-r">
66
+ <div class="h-full px-3 pb-4 overflow-y-auto bg-lightSidebar dark:bg-darkSidebar border-r dark:border-darkSidebarBorder">
67
67
  <div class="flex ms-2 md:me-24 m-4 ">
68
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">
69
+ <span class="self-center text-lightNavbarText-size font-semibold sm:text-lightNavbarText-size whitespace-nowrap dark:text-darkNavbarText text-lightNavbarLogo">
70
70
  {{ coreStore.config?.brandName }}
71
71
  </span>
72
72
  </div>
73
73
 
74
74
  <ul class="space-y-2 font-medium">
75
75
  <template v-for="(item, i) in coreStore.menu" :key="`menu-${i}`">
76
- <div v-if="item.type === 'divider'" class="border-t border-nav-menu-devider dark:border-gray-700"></div>
76
+ <div v-if="item.type === 'divider'" class="border-t border-lightSidebarDevider dark:border-darkSidebarDevider"></div>
77
77
  <div v-else-if="item.type === 'gap'" class="flex items-center justify-center h-8"></div>
78
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
79
79
  ">{{ item.label }}</div>
80
- <li v-else-if="item.children">
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"
80
+ <li v-else-if="item.children" class=" ">
81
+ <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"
82
82
  :aria-controls="`dropdown-example${i}`"
83
83
  :data-collapse-toggle="`dropdown-example${i}`"
84
84
  >
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>
85
+ <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>
86
86
 
87
87
  <span class="flex-1 ms-3 text-left rtl:text-right whitespace-nowrap">{{ item.label }}</span>
88
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">
@@ -1,16 +1,16 @@
1
1
  <template>
2
2
  <RouterLink
3
3
  :to="{name: item.resourceId ? 'resource-list' : item.path, params: item.resourceId ? { resourceId: item.resourceId }: {}}"
4
- class="flex items-center py-2 text-nav-menu-text rounded-default hover:bg-nav-menu-bg-hover active:bg-nav-menu-bg-active" role="menuitem"
4
+ class="flex group items-center py-2 text-lightSidebarText dark:text-darkSidebarText rounded-default hover:bg-lightSidebarItemHover hover:text-lightSidebarTextHover dark:hover:bg-darkSidebarHover dark:hover:text-darkSidebarTextHover active:bg-lightSidebarActive dark:active:bg-darkSidebarHover" role="menuitem"
5
5
  :class="{
6
6
  'px-4': isChild,
7
7
  'px-2': !isChild,
8
- 'bg-nav-menu-bg-active dark:bg-gray-700': item.resourceId ?
8
+ 'bg-sidebarActive dark:bg-gray-700': item.resourceId ?
9
9
  ($route.params.resourceId === item.resourceId && $route.name === 'resource-list') :
10
10
  ($route.name === item.path)
11
11
  }"
12
12
  >
13
- <component v-if="item.icon" :is="getIcon(item.icon)" 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>
13
+ <component v-if="item.icon" :is="getIcon(item.icon)" class="w-5 h-5 text-lightSidebarIcons dark:text-darkSidebarIcons transition duration-75 group-hover:text-lightSidebarIconsHover dark:group-hover:text-darkSidebarIconsHover" ></component>
14
14
  <span class="ms-3">{{ item.label }}</span>
15
15
  </RouterLink>
16
16
  </template>
@@ -2,11 +2,11 @@
2
2
  <div class="rounded-default">
3
3
 
4
4
  <div
5
- class="relative shadow-resourse-form-shadow sm:rounded-lg dark:shadow-2xl dark:shadow-black rounded-default"
5
+ class="relative shadow-resourseFormShadow sm:rounded-lg dark:shadow-2xl dark:shadow-black rounded-default"
6
6
  >
7
7
  <form autocomplete="off" @submit.prevent>
8
8
  <table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 ">
9
- <thead class="text-xs text-gray-700 uppercase bg-form-view-heading dark:bg-gray-700 dark:text-gray-400">
9
+ <thead class="text-xs text-gray-700 uppercase bg-lightormHeading dark:bg-gray-700 dark:text-gray-400">
10
10
  <tr>
11
11
  <th scope="col" class="px-6 py-3">
12
12
  Field
@@ -18,7 +18,7 @@
18
18
  </thead>
19
19
  <tbody>
20
20
  <tr v-for="column, i in editableColumns" :key="column.name"
21
- class="bg-form-view-bg dark:bg-gray-800 border-b dark:border-gray-700"
21
+ class="bg-ligftForm dark:bg-gray-800 border-b dark:border-gray-700"
22
22
  >
23
23
  <!-- if column is in customComponentsPerColumn, use this component. If not, use this code -->
24
24
  <template v-if="column?.components?.[props.source].file">