adminforth 1.3.54-next.9 → 1.3.55-next.0

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 (250) hide show
  1. package/dist/auth.d.ts +31 -0
  2. package/dist/auth.d.ts.map +1 -0
  3. package/dist/auth.js +42 -56
  4. package/dist/auth.js.map +1 -0
  5. package/dist/basePlugin.d.ts +18 -0
  6. package/dist/basePlugin.d.ts.map +1 -0
  7. package/dist/basePlugin.js +1 -0
  8. package/dist/basePlugin.js.map +1 -0
  9. package/dist/dataConnectors/baseConnector.d.ts +94 -0
  10. package/dist/dataConnectors/baseConnector.d.ts.map +1 -0
  11. package/dist/dataConnectors/baseConnector.js +108 -122
  12. package/dist/dataConnectors/baseConnector.js.map +1 -0
  13. package/dist/dataConnectors/clickhouse.d.ts +92 -0
  14. package/dist/dataConnectors/clickhouse.d.ts.map +1 -0
  15. package/dist/dataConnectors/clickhouse.js +132 -149
  16. package/dist/dataConnectors/clickhouse.js.map +1 -0
  17. package/dist/dataConnectors/mongo.d.ts +93 -0
  18. package/dist/dataConnectors/mongo.d.ts.map +1 -0
  19. package/dist/dataConnectors/mongo.js +75 -101
  20. package/dist/dataConnectors/mongo.js.map +1 -0
  21. package/dist/dataConnectors/postgres.d.ts +71 -0
  22. package/dist/dataConnectors/postgres.d.ts.map +1 -0
  23. package/dist/dataConnectors/postgres.js +124 -143
  24. package/dist/dataConnectors/postgres.js.map +1 -0
  25. package/dist/dataConnectors/sqlite.d.ts +67 -0
  26. package/dist/dataConnectors/sqlite.d.ts.map +1 -0
  27. package/dist/dataConnectors/sqlite.js +113 -130
  28. package/dist/dataConnectors/sqlite.js.map +1 -0
  29. package/dist/index.d.ts +92 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +197 -217
  32. package/dist/index.js.map +1 -0
  33. package/dist/modules/codeInjector.d.ts +35 -0
  34. package/dist/modules/codeInjector.d.ts.map +1 -0
  35. package/dist/modules/codeInjector.js +480 -486
  36. package/dist/modules/codeInjector.js.map +1 -0
  37. package/dist/modules/configValidator.d.ts +12 -0
  38. package/dist/modules/configValidator.d.ts.map +1 -0
  39. package/dist/modules/configValidator.js +31 -22
  40. package/dist/modules/configValidator.js.map +1 -0
  41. package/dist/modules/operationalResource.d.ts +17 -0
  42. package/dist/modules/operationalResource.d.ts.map +1 -0
  43. package/dist/modules/operationalResource.js +50 -70
  44. package/dist/modules/operationalResource.js.map +1 -0
  45. package/dist/modules/restApi.d.ts +10 -0
  46. package/dist/modules/restApi.d.ts.map +1 -0
  47. package/dist/modules/restApi.js +104 -116
  48. package/dist/modules/restApi.js.map +1 -0
  49. package/dist/modules/styleGenerator.d.ts +9 -0
  50. package/dist/modules/styleGenerator.d.ts.map +1 -0
  51. package/dist/modules/styleGenerator.js +1 -0
  52. package/dist/modules/styleGenerator.js.map +1 -0
  53. package/dist/modules/styles.d.ts +96 -0
  54. package/dist/modules/styles.d.ts.map +1 -0
  55. package/dist/modules/styles.js +1 -0
  56. package/dist/modules/styles.js.map +1 -0
  57. package/dist/modules/utils.d.ts +39 -0
  58. package/dist/modules/utils.d.ts.map +1 -0
  59. package/dist/modules/utils.js +1 -0
  60. package/dist/modules/utils.js.map +1 -0
  61. package/dist/plugins/audit-log/types.d.ts +35 -0
  62. package/dist/plugins/audit-log/types.d.ts.map +1 -0
  63. package/dist/plugins/audit-log/types.js +2 -0
  64. package/dist/plugins/audit-log/types.js.map +1 -0
  65. package/dist/plugins/chat-gpt/types.d.ts +82 -0
  66. package/dist/plugins/chat-gpt/types.d.ts.map +1 -0
  67. package/dist/plugins/chat-gpt/types.js +2 -0
  68. package/dist/plugins/chat-gpt/types.js.map +1 -0
  69. package/dist/plugins/email-password-reset/types.d.ts +28 -0
  70. package/dist/plugins/email-password-reset/types.d.ts.map +1 -0
  71. package/dist/plugins/email-password-reset/types.js +2 -0
  72. package/dist/plugins/email-password-reset/types.js.map +1 -0
  73. package/dist/plugins/foreign-inline-list/types.d.ts +19 -0
  74. package/dist/plugins/foreign-inline-list/types.d.ts.map +1 -0
  75. package/dist/plugins/foreign-inline-list/types.js +2 -0
  76. package/dist/plugins/foreign-inline-list/types.js.map +1 -0
  77. package/dist/plugins/import-export/types.d.ts +3 -0
  78. package/dist/plugins/import-export/types.d.ts.map +1 -0
  79. package/dist/plugins/import-export/types.js +2 -0
  80. package/dist/plugins/import-export/types.js.map +1 -0
  81. package/dist/plugins/rich-editor/custom/async-queue.d.ts +8 -0
  82. package/dist/plugins/rich-editor/custom/async-queue.d.ts.map +1 -0
  83. package/dist/plugins/rich-editor/custom/async-queue.js +29 -0
  84. package/dist/plugins/rich-editor/custom/async-queue.js.map +1 -0
  85. package/dist/plugins/rich-editor/dist/custom/async-queue.d.ts +8 -0
  86. package/dist/plugins/rich-editor/dist/custom/async-queue.d.ts.map +1 -0
  87. package/dist/plugins/rich-editor/dist/custom/async-queue.js +29 -0
  88. package/dist/plugins/rich-editor/dist/custom/async-queue.js.map +1 -0
  89. package/dist/plugins/rich-editor/types.d.ts +153 -0
  90. package/dist/plugins/rich-editor/types.d.ts.map +1 -0
  91. package/dist/plugins/rich-editor/types.js +16 -0
  92. package/dist/plugins/rich-editor/types.js.map +1 -0
  93. package/dist/plugins/two-factors-auth/types.d.ts +18 -0
  94. package/dist/plugins/two-factors-auth/types.d.ts.map +1 -0
  95. package/dist/plugins/two-factors-auth/types.js +2 -0
  96. package/dist/plugins/two-factors-auth/types.js.map +1 -0
  97. package/dist/plugins/upload/types.d.ts +132 -0
  98. package/dist/plugins/upload/types.d.ts.map +1 -0
  99. package/dist/plugins/upload/types.js +2 -0
  100. package/dist/plugins/upload/types.js.map +1 -0
  101. package/dist/servers/express.d.ts +18 -0
  102. package/dist/servers/express.d.ts.map +1 -0
  103. package/dist/servers/express.js +30 -42
  104. package/dist/servers/express.js.map +1 -0
  105. package/dist/types/AdminForthConfig.d.ts +1619 -0
  106. package/dist/types/AdminForthConfig.d.ts.map +1 -0
  107. package/dist/types/AdminForthConfig.js +1 -0
  108. package/dist/types/AdminForthConfig.js.map +1 -0
  109. package/{types/FrontendAPI.ts → dist/types/FrontendAPI.d.ts} +27 -52
  110. package/dist/types/FrontendAPI.d.ts.map +1 -0
  111. package/dist/types/FrontendAPI.js +1 -0
  112. package/dist/types/FrontendAPI.js.map +1 -0
  113. package/package.json +15 -5
  114. package/auth.ts +0 -140
  115. package/basePlugin.ts +0 -70
  116. package/dataConnectors/baseConnector.ts +0 -216
  117. package/dataConnectors/clickhouse.ts +0 -338
  118. package/dataConnectors/mongo.ts +0 -202
  119. package/dataConnectors/postgres.ts +0 -306
  120. package/dataConnectors/sqlite.ts +0 -254
  121. package/dist/spa/.eslintrc.cjs +0 -14
  122. package/dist/spa/README.md +0 -39
  123. package/dist/spa/env.d.ts +0 -1
  124. package/dist/spa/index.html +0 -23
  125. package/dist/spa/package-lock.json +0 -4573
  126. package/dist/spa/package.json +0 -49
  127. package/dist/spa/postcss.config.js +0 -6
  128. package/dist/spa/public/assets/favicon.png +0 -0
  129. package/dist/spa/src/App.vue +0 -314
  130. package/dist/spa/src/assets/base.css +0 -2
  131. package/dist/spa/src/assets/logo.svg +0 -19
  132. package/dist/spa/src/components/AcceptModal.vue +0 -45
  133. package/dist/spa/src/components/Breadcrumbs.vue +0 -41
  134. package/dist/spa/src/components/BreadcrumbsWithButtons.vue +0 -26
  135. package/dist/spa/src/components/CustomDatePicker.vue +0 -176
  136. package/dist/spa/src/components/CustomDateRangePicker.vue +0 -218
  137. package/dist/spa/src/components/CustomRangePicker.vue +0 -152
  138. package/dist/spa/src/components/Dropdown.vue +0 -168
  139. package/dist/spa/src/components/Filters.vue +0 -222
  140. package/dist/spa/src/components/HelloWorld.vue +0 -17
  141. package/dist/spa/src/components/MenuLink.vue +0 -24
  142. package/dist/spa/src/components/ResourceForm.vue +0 -294
  143. package/dist/spa/src/components/ResourceListTable.vue +0 -394
  144. package/dist/spa/src/components/SingleSkeletLoader.vue +0 -13
  145. package/dist/spa/src/components/SkeleteLoader.vue +0 -23
  146. package/dist/spa/src/components/Toast.vue +0 -77
  147. package/dist/spa/src/components/ValueRenderer.vue +0 -66
  148. package/dist/spa/src/components/icons/IconCalendar.vue +0 -5
  149. package/dist/spa/src/components/icons/IconCommunity.vue +0 -7
  150. package/dist/spa/src/components/icons/IconDocumentation.vue +0 -7
  151. package/dist/spa/src/components/icons/IconEcosystem.vue +0 -7
  152. package/dist/spa/src/components/icons/IconSupport.vue +0 -7
  153. package/dist/spa/src/components/icons/IconTime.vue +0 -5
  154. package/dist/spa/src/components/icons/IconTooling.vue +0 -19
  155. package/dist/spa/src/composables/useFrontendApi.ts +0 -26
  156. package/dist/spa/src/composables/useStores.ts +0 -127
  157. package/dist/spa/src/index.scss +0 -27
  158. package/dist/spa/src/main.ts +0 -18
  159. package/dist/spa/src/router/index.ts +0 -63
  160. package/dist/spa/src/spa_types/core.ts +0 -51
  161. package/dist/spa/src/stores/core.ts +0 -144
  162. package/dist/spa/src/stores/filters.ts +0 -22
  163. package/dist/spa/src/stores/modal.ts +0 -48
  164. package/dist/spa/src/stores/toast.ts +0 -15
  165. package/dist/spa/src/stores/user.ts +0 -72
  166. package/dist/spa/src/types/AdminForthConfig.ts +0 -1477
  167. package/dist/spa/src/types/FrontendAPI.ts +0 -121
  168. package/dist/spa/src/utils.ts +0 -103
  169. package/dist/spa/src/views/CreateView.vue +0 -156
  170. package/dist/spa/src/views/EditView.vue +0 -157
  171. package/dist/spa/src/views/ListView.vue +0 -258
  172. package/dist/spa/src/views/LoginView.vue +0 -160
  173. package/dist/spa/src/views/ResourceParent.vue +0 -17
  174. package/dist/spa/src/views/ShowView.vue +0 -184
  175. package/dist/spa/tailwind.config.js +0 -17
  176. package/dist/spa/tsconfig.app.json +0 -14
  177. package/dist/spa/tsconfig.json +0 -11
  178. package/dist/spa/tsconfig.node.json +0 -19
  179. package/dist/spa/vite.config.ts +0 -56
  180. package/index.ts +0 -428
  181. package/modules/codeInjector.ts +0 -736
  182. package/modules/configValidator.ts +0 -571
  183. package/modules/operationalResource.ts +0 -98
  184. package/modules/restApi.ts +0 -718
  185. package/modules/styleGenerator.ts +0 -55
  186. package/modules/styles.ts +0 -126
  187. package/modules/utils.ts +0 -472
  188. package/servers/express.ts +0 -259
  189. package/spa/.eslintrc.cjs +0 -14
  190. package/spa/README.md +0 -39
  191. package/spa/env.d.ts +0 -1
  192. package/spa/index.html +0 -23
  193. package/spa/package-lock.json +0 -4602
  194. package/spa/package.json +0 -51
  195. package/spa/postcss.config.js +0 -6
  196. package/spa/public/assets/favicon.png +0 -0
  197. package/spa/src/App.vue +0 -418
  198. package/spa/src/assets/base.css +0 -2
  199. package/spa/src/assets/logo.svg +0 -19
  200. package/spa/src/components/AcceptModal.vue +0 -45
  201. package/spa/src/components/Breadcrumbs.vue +0 -41
  202. package/spa/src/components/BreadcrumbsWithButtons.vue +0 -26
  203. package/spa/src/components/CustomDatePicker.vue +0 -176
  204. package/spa/src/components/CustomDateRangePicker.vue +0 -218
  205. package/spa/src/components/CustomRangePicker.vue +0 -156
  206. package/spa/src/components/Dropdown.vue +0 -168
  207. package/spa/src/components/Filters.vue +0 -222
  208. package/spa/src/components/HelloWorld.vue +0 -17
  209. package/spa/src/components/MenuLink.vue +0 -27
  210. package/spa/src/components/ResourceForm.vue +0 -290
  211. package/spa/src/components/ResourceListTable.vue +0 -466
  212. package/spa/src/components/SingleSkeletLoader.vue +0 -13
  213. package/spa/src/components/SkeleteLoader.vue +0 -23
  214. package/spa/src/components/ThreeDotsMenu.vue +0 -43
  215. package/spa/src/components/Toast.vue +0 -78
  216. package/spa/src/components/ValueRenderer.vue +0 -114
  217. package/spa/src/components/icons/IconCalendar.vue +0 -5
  218. package/spa/src/components/icons/IconCommunity.vue +0 -7
  219. package/spa/src/components/icons/IconDocumentation.vue +0 -7
  220. package/spa/src/components/icons/IconEcosystem.vue +0 -7
  221. package/spa/src/components/icons/IconSupport.vue +0 -7
  222. package/spa/src/components/icons/IconTime.vue +0 -5
  223. package/spa/src/components/icons/IconTooling.vue +0 -19
  224. package/spa/src/composables/useFrontendApi.ts +0 -26
  225. package/spa/src/composables/useStores.ts +0 -131
  226. package/spa/src/index.scss +0 -31
  227. package/spa/src/main.ts +0 -18
  228. package/spa/src/renderers/CompactUUID.vue +0 -48
  229. package/spa/src/renderers/CountryFlag.vue +0 -69
  230. package/spa/src/router/index.ts +0 -59
  231. package/spa/src/spa_types/core.ts +0 -53
  232. package/spa/src/stores/core.ts +0 -148
  233. package/spa/src/stores/filters.ts +0 -27
  234. package/spa/src/stores/modal.ts +0 -48
  235. package/spa/src/stores/toast.ts +0 -31
  236. package/spa/src/stores/user.ts +0 -72
  237. package/spa/src/utils.ts +0 -160
  238. package/spa/src/views/CreateView.vue +0 -167
  239. package/spa/src/views/EditView.vue +0 -170
  240. package/spa/src/views/ListView.vue +0 -352
  241. package/spa/src/views/LoginView.vue +0 -192
  242. package/spa/src/views/ResourceParent.vue +0 -17
  243. package/spa/src/views/ShowView.vue +0 -186
  244. package/spa/tailwind.config.js +0 -17
  245. package/spa/tsconfig.app.json +0 -14
  246. package/spa/tsconfig.json +0 -11
  247. package/spa/tsconfig.node.json +0 -19
  248. package/spa/vite.config.ts +0 -56
  249. package/tsconfig.json +0 -112
  250. package/types/AdminForthConfig.ts +0 -1762
@@ -1,26 +0,0 @@
1
- export function showSuccesTost(message: string) {
2
- window.adminforth.alert({ message, variant: 'success' });
3
- return message;
4
- }
5
-
6
- export function showWarningTost(message: string) {
7
- window.adminforth.alert({ message, variant: 'warning' });
8
- return message;
9
- }
10
-
11
- export function showErrorTost(message: string, timeout?: number) {
12
- window.adminforth.alert({ message, variant: 'danger', timeout: timeout || 'unlimited'});
13
- return message;
14
- }
15
-
16
-
17
- const useFrontendApi = () => {
18
- return {
19
- showSuccesTost,
20
- showWarningTost,
21
- showErrorTost
22
- }
23
- }
24
-
25
-
26
- export default useFrontendApi;
@@ -1,127 +0,0 @@
1
- import type { FrontendAPIInterface, ConfirmParams, AlertParams, } from '../types/FrontendAPI';
2
- import type { AdminForthFilterOperators } from '@/types/AdminForthConfig';
3
- import { useToastStore } from '../stores/toast';
4
- import { useModalStore } from '../stores/modal';
5
- import { useCoreStore } from '@/stores/core';
6
- import { useFiltersStore } from '@/stores/filters';
7
- import router from '@/router'
8
- import type { AdminForthResourceColumn } from '@/types/AdminForthConfig';
9
-
10
- type FilterParams = {
11
- /**
12
- * Field of resource to filter
13
- */
14
- field: string;
15
- /**
16
- * Operator of filter
17
- */
18
- operator: AdminForthFilterOperators;
19
- /**
20
- * Value of filter
21
- */
22
- value: string | number | boolean ;
23
- }
24
-
25
- declare global {
26
- interface Window {
27
- adminforth: {
28
- confirm: (params: ConfirmParams) => Promise<void>;
29
- alert: (params: AlertParams) => void;
30
- setListFilter: (filter: any) => void;
31
- updateListFilter: (filter: any) => void;
32
- clearListFilters: () => void;
33
- };
34
- }
35
- }
36
-
37
- export class FrontendAPI implements FrontendAPIInterface {
38
- private toastStore:any
39
- private modalStore:any
40
- private filtersStore:any
41
- private coreStore:any
42
- init() {
43
- if (window.adminforth) {
44
- throw new Error('adminforth already initialized');
45
- }
46
- this.toastStore = useToastStore();
47
- this.modalStore = useModalStore();
48
- console.log(this.toastStore, this.modalStore,'init of adminforth frontend api')
49
- window.adminforth = {
50
- confirm: this.confirm.bind(this),
51
- alert: this.alert.bind(this),
52
- setListFilter: this.setListFilter.bind(this),
53
- updateListFilter: this.updateListFilter.bind(this),
54
- clearListFilters: this.clearListFilters.bind(this),
55
- }
56
- }
57
-
58
- confirm(params: ConfirmParams): Promise<void> {
59
- return new Promise((resolve, reject) => {
60
- this.modalStore.setModalContent({ content: params.message, acceptText: params.yes, cancelText: params.no })
61
- this.modalStore.onAcceptFunction = resolve
62
- this.modalStore.onCancelFunction = reject
63
- this.modalStore.togleModal()
64
- })
65
- }
66
-
67
- alert(params: AlertParams): void {
68
- this.toastStore.addToast({
69
- message: params.message,
70
- messageHtml: params.messageHtml,
71
- variant: params.variant,
72
- timeout: params.timeout
73
- })
74
- }
75
-
76
- listFilterValidation(filter: FilterParams): boolean {
77
- if(router.currentRoute.value.meta.type !== 'list'){
78
- throw new Error(`Cannot use ${this.setListFilter.name} filter on a list page`)
79
- } else {
80
- if(!this.coreStore) this.coreStore = useCoreStore()
81
- console.log(this.coreStore.resourceColumnsWithFilters,'core store')
82
- const filterField = this.coreStore.resourceColumnsWithFilters.find((col: AdminForthResourceColumn) => col.name === filter.field)
83
- if(!filterField){
84
- throw new Error(`Field ${filter.field} is not available for filtering`)
85
- }
86
-
87
- }
88
- return true
89
- }
90
-
91
- setListFilter(filter: FilterParams): void {
92
- if(this.listFilterValidation(filter)){
93
- this.filtersStore = useFiltersStore()
94
- if(this.filtersStore.filters.some((f) => {return f.field === filter.field && f.operator === filter.operator})){
95
- throw new Error(`Filter ${filter.field} with operator ${filter.operator} already exists`)
96
- } else {
97
- this.filtersStore.setFilter(filter)
98
- }
99
- }
100
- }
101
-
102
- clearListFilters(): void {
103
- this.filtersStore = useFiltersStore()
104
- this.filtersStore.clearFilters()
105
- }
106
-
107
- updateListFilter(filter: FilterParams): void {
108
- if(this.listFilterValidation(filter)){
109
- this.filtersStore = useFiltersStore()
110
- const index = this.filtersStore.filters.findIndex((f: FilterParams) => f.field === filter.field)
111
- if(index === -1) {
112
- this.filtersStore.setFilter(filter)
113
- } else {
114
- const filters = [...this.filtersStore.filters];
115
- if (filter.value === undefined) {
116
- filters.splice(index, 1);
117
- } else {
118
- filters[index] = filter;
119
- }
120
- this.filtersStore.setFilters(filters);
121
- }
122
- }
123
- }
124
-
125
-
126
-
127
- }
@@ -1,27 +0,0 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
4
-
5
-
6
- // @layer base {
7
- // /* width */
8
- // ::-webkit-scrollbar {
9
- // @apply w-2 p-2
10
- // }
11
-
12
- // /* Track */
13
- // ::-webkit-scrollbar-track {
14
- // @apply bg-inherit
15
- // }
16
-
17
- // /* Handle */
18
- // ::-webkit-scrollbar-thumb {
19
- // @apply bg-gray-200 dark:bg-gray-600 rounded-xl
20
- // }
21
-
22
- // /* Handle on hover */
23
- // ::-webkit-scrollbar-thumb:hover {
24
- // @apply bg-gray-700
25
- // }
26
- // }
27
-
@@ -1,18 +0,0 @@
1
- import { createApp } from 'vue'
2
- import { createPinia } from 'pinia'
3
- /* IMPORTANT:ADMINFORTH IMPORTS */
4
-
5
-
6
- import App from './App.vue'
7
- import router from './router'
8
-
9
- export const app = createApp(App)
10
- /* IMPORTANT:ADMINFORTH COMPONENT REGISTRATIONS */
11
-
12
-
13
- app.use(createPinia())
14
- app.use(router)
15
-
16
- /* IMPORTANT:ADMINFORTH CUSTOM USES */
17
-
18
- app.mount('#app')
@@ -1,63 +0,0 @@
1
- import { createRouter, createWebHistory } from 'vue-router'
2
- import ResourceParent from '@/views/ResourceParent.vue'
3
- import { useUserStore } from '@/stores/user'
4
- /* IMPORTANT:ADMINFORTH ROUTES IMPORTS */
5
-
6
- const router = createRouter({
7
- history: createWebHistory(import.meta.env.BASE_URL),
8
- routes: [
9
- {
10
- path: '/login',
11
- name: 'login',
12
- component: () => import('@/views/LoginView.vue'),
13
- meta: { title: 'login' },
14
- beforeEnter: async (to, from, next) => {
15
- if(localStorage.getItem('isAuthorized') === 'true'){
16
- next({name: 'home'})
17
- } else {
18
- next()
19
- }
20
- }
21
- },
22
- {
23
- path: '/resource/:resourceId',
24
- component: ResourceParent,
25
- name: 'resource',
26
- children: [
27
- {
28
- path: '',
29
- component: () => import('@/views/ListView.vue'),
30
- name: 'resource-list',
31
- meta: { title: 'list',type: 'list' }
32
- },
33
- {
34
- path: 'show/:primaryKey',
35
- component: () => import('@/views/ShowView.vue'),
36
- name: 'resource-show',
37
- meta: { title: 'show', type: 'show'}
38
-
39
- },
40
- {
41
- path: 'edit/:primaryKey',
42
- component: () => import('@/views/EditView.vue'),
43
- name: 'resource-edit',
44
- meta: { title: 'edit', type: 'edit'}
45
- },
46
- {
47
- path: 'create',
48
- component: () => import('@/views/CreateView.vue'),
49
- name: 'resource-create',
50
- meta: { title: 'create', type: 'create'}
51
-
52
- },
53
- ]
54
- },
55
- /* IMPORTANT:ADMINFORTH ROUTES */
56
- ]
57
- })
58
-
59
-
60
-
61
-
62
-
63
- export default router
@@ -1,51 +0,0 @@
1
- import type { AdminForthResource, AdminForthResourceColumn } from '../types/AdminForthConfig';
2
-
3
- export type resourceById = {
4
- [key: string]: AdminForthResource;
5
- }
6
-
7
- export type Menu = {
8
- label: string,
9
- icon: string,
10
- resourceId: string,
11
- children?: Array<Menu>,
12
- }
13
-
14
- export type Record = {
15
- [key: string]: any;
16
- }
17
-
18
- export type ResourceColumns = {
19
- [key: string]: Array<AdminForthResourceColumn>;
20
- }
21
-
22
- export type CoreConfig = {
23
- brandName: string,
24
- brandLogo: string,
25
- title: string,
26
- datesFormat: string,
27
- usernameField: string,
28
- usernameFieldName?: string,
29
- deleteConfirmation?: boolean,
30
- auth?: {
31
- resourceId: string,
32
- usernameField: string,
33
- passwordHashField: string,
34
- loginBackgroundImage: string,
35
- userFullnameField: string,
36
- },
37
- emptyFieldPlaceholder?: {
38
- show: string,
39
- list: string,
40
-
41
- } | string,
42
- }
43
-
44
-
45
- export type AllowedActions = {
46
- show: boolean,
47
- create: boolean,
48
- edit: boolean,
49
- delete: boolean,
50
- }
51
-
@@ -1,144 +0,0 @@
1
- import { ref, computed } from 'vue'
2
- import { defineStore } from 'pinia'
3
- import { callAdminForthApi } from '@/utils';
4
- import type { AdminForthResource, AdminForthResourceColumn } from '@/types/AdminForthConfig';
5
- import type { Ref } from 'vue'
6
-
7
- export const useCoreStore = defineStore('core', () => {
8
- const resourceById: Ref<Object> = ref({});
9
- const menu = ref([]);
10
- const config = ref({});
11
- const record: Ref<any | null> = ref({});
12
- const resource: Ref<AdminForthResource | null> = ref(null);
13
-
14
- const resourceColumnsWithFilters = computed(() => {
15
- if (!resource.value) {
16
- return [];
17
- }
18
- return resource.value.columns.filter((col: AdminForthResourceColumn) => col.showIn?.includes('filter'));
19
- })
20
-
21
- const resourceOptions = ref(null);
22
- const resourceColumnsError = ref('');
23
- const resourceColumnsId = ref(null);
24
- const adminUser = ref(null);
25
-
26
- async function fetchMenuAndResource() {
27
- const resp = await callAdminForthApi({
28
- path: '/get_base_config',
29
- method: 'GET',
30
- });
31
- if(!resp){
32
- return
33
- }
34
- menu.value = resp.menu;
35
- resourceById.value = resp.resources.reduce((acc: Object, resource: AdminForthResource) => {
36
- acc[resource.resourceId] = resource;
37
- return acc;
38
- }, {});
39
- config.value = resp.config;
40
- adminUser.value = resp.user;
41
- console.log('🌍 AdminForth v', resp.version);
42
- }
43
-
44
- async function fetchRecord({ resourceId, primaryKey }) {
45
- record.value = null;
46
-
47
- if (!resource.value) {
48
- throw new Error('Columns not fetched yet');
49
- }
50
-
51
- const respData = await callAdminForthApi({
52
- path: '/get_resource_data',
53
- method: 'POST',
54
- body: {
55
- source: 'show',
56
- resourceId: resourceId,
57
- filters: [
58
- {
59
- field: resource.value.columns.find((col: AdminForthResourceColumn) => col.primaryKey).name,
60
- operator: 'eq',
61
- value: primaryKey
62
- }
63
- ],
64
- sort: [],
65
- limit: 1,
66
- offset: 0
67
- }
68
- });
69
-
70
- if (respData.error) {
71
- window.adminforth.alert({
72
- message: respData.error,
73
- variant: 'danger',
74
- timeout: 'unlimited'
75
- });
76
- record.value = {};
77
- } else {
78
- record.value = respData.data[0];
79
- }
80
-
81
- }
82
-
83
- async function fetchResourceFull({ resourceId }: { resourceId: string }) {
84
- if (resourceColumnsId.value === resourceId && resource.value) {
85
- // already fetched
86
- return;
87
- }
88
- resourceColumnsId.value = resourceId;
89
- resourceColumnsError.value = '';
90
- const res = await callAdminForthApi({
91
- path: '/get_resource',
92
- method: 'POST',
93
- body: {
94
- resourceId,
95
- }
96
- });
97
- if (res.error) {
98
- resourceColumnsError.value = res.error;
99
- } else {
100
- resourceById.value[resourceId] = res.resource;
101
- resource.value = res.resource;
102
- resourceOptions.value = res.resource.options;
103
- }
104
- }
105
-
106
- async function getPublicConfig() {
107
- const res = await callAdminForthApi({
108
- path: '/get_public_config',
109
- method: 'GET',
110
- });
111
- config.value = {...config.value, ...res};
112
- }
113
-
114
-
115
-
116
- const username = computed(() => {
117
- const usernameField = config.value.usernameField;
118
- return adminUser.value && adminUser.value[usernameField];
119
- });
120
-
121
- const userFullname = computed(() => {
122
- const userFullnameField = config.value.userFullnameField;
123
- return adminUser.value && adminUser.value[userFullnameField];
124
- })
125
-
126
-
127
- return {
128
- config,
129
- resourceById,
130
- menu,
131
- username,
132
- userFullname,
133
- getPublicConfig,
134
- fetchMenuAndResource,
135
- fetchRecord,
136
- record,
137
- fetchResourceFull,
138
- resourceColumnsError,
139
- resourceOptions,
140
- resource,
141
- adminUser,
142
- resourceColumnsWithFilters
143
- }
144
- })
@@ -1,22 +0,0 @@
1
- import { ref } from 'vue'
2
- import { defineStore } from 'pinia'
3
- import { callAdminForthApi } from '@/utils';
4
-
5
- export const useFiltersStore = defineStore('filters', () => {
6
- const filters = ref([]);
7
- const setFilter = (filter: any) => {
8
- filters.value = [...filters.value, filter];
9
- }
10
- const setFilters = (f: any) => {
11
- filters.value = [...f];
12
- }
13
- const getFilters = () => {
14
- return filters.value;
15
- }
16
- const clearFilters = () => {
17
- filters.value = [];
18
- }
19
- return {setFilter, getFilters,clearFilters, filters,setFilters}
20
- })
21
-
22
-
@@ -1,48 +0,0 @@
1
- import { ref } from 'vue'
2
- import { defineStore } from 'pinia'
3
-
4
- type ModalContentType = {
5
- title?: string;
6
- content?: string;
7
- acceptText?: string;
8
- cancelText?: string;
9
- }
10
-
11
-
12
- export const useModalStore = defineStore('modal', () => {
13
- const modalContent = ref({
14
- title: 'title',
15
- content: 'content',
16
- acceptText: 'acceptText',
17
- cancelText: 'cancelText',
18
- });
19
- const isOpened = ref(false);
20
- const onAcceptFunction: any = ref(()=>{});
21
- const onCancelFunction: any = ref(()=>{});
22
- function togleModal() {
23
- isOpened.value = !isOpened.value;
24
- }
25
- function setOnAcceptFunction(func: Function) {
26
- onAcceptFunction.value = func;
27
- }
28
- function setOnCancelFunction(func: Function) {
29
- onCancelFunction.value = func;
30
- }
31
- function setModalContent(content: ModalContentType) {
32
- modalContent.value = content;
33
- }
34
- function resetmodalState() {
35
- isOpened.value = false;
36
- modalContent.value = {
37
- title: 'title',
38
- content: 'content',
39
- acceptText: 'acceptText',
40
- cancelText: 'cancelText',
41
- };
42
- setOnAcceptFunction(()=>{});
43
-
44
- }
45
-
46
- return {isOpened, setModalContent,onCancelFunction, togleModal,modalContent, setOnAcceptFunction, onAcceptFunction,resetmodalState,setOnCancelFunction}
47
-
48
- })
@@ -1,15 +0,0 @@
1
- import { ref, computed } from 'vue'
2
- import { defineStore } from 'pinia'
3
- import { callAdminForthApi } from '@/utils';
4
- import { v1 as uuid } from 'uuid';
5
-
6
- export const useToastStore = defineStore('toast', () => {
7
- const toasts = ref([]);
8
- const addToast = (toast) => {
9
- toasts.value.push({...toast, id: uuid()});
10
- };
11
- const removeToast = (toast) => {
12
- toasts.value = toasts.value.filter((t) => t.id !== toast.id);
13
- };
14
- return { toasts, addToast, removeToast };
15
- });
@@ -1,72 +0,0 @@
1
- import { ref } from 'vue';
2
- import { defineStore } from 'pinia';
3
- import { callAdminForthApi } from '@/utils';
4
- import { initFlowbite } from 'flowbite'
5
- import { useRouter } from 'vue-router';
6
- import { useCoreStore } from './core';
7
- import router from '@/router';
8
-
9
-
10
-
11
- export const useUserStore = defineStore('user', () => {
12
- const isAuthorized = ref(false);
13
-
14
- function authorize() {
15
- isAuthorized.value = true;
16
- localStorage.setItem('isAuthorized', 'true');
17
- }
18
-
19
- function unauthorize() {
20
- isAuthorized.value = false;
21
- localStorage.setItem('isAuthorized', 'false');
22
- }
23
-
24
- async function finishLogin() {
25
- const coreStore = useCoreStore();
26
- authorize(); // TODO not sure we need this approach with localStorage
27
- await router.push('/');
28
- await router.isReady();
29
- await coreStore.fetchMenuAndResource();
30
- setTimeout(() => {
31
- initFlowbite();
32
- });
33
- }
34
-
35
- async function logout() {
36
- await callAdminForthApi({
37
- path: '/logout',
38
- method: 'POST',
39
- });
40
- unauthorize();
41
- }
42
-
43
- // async function checkAuth( skipApiCall = false){
44
- // console.log('checkAuth', isAuthorized.value, skipApiCall)
45
- // if(isAuthorized.value) {
46
- // return true}
47
- // else {
48
- // if(skipApiCall) return false;
49
- // const resp = await callAdminForthApi({
50
- // path: '/check_auth',
51
- // method: 'POST',
52
- // });
53
- // if (resp.status !== 401) {
54
- // authorize();
55
- // return true;
56
- // }
57
- // else {
58
- // unauthorize();
59
- // return false;}
60
- // }
61
-
62
- // }
63
-
64
- return {
65
- isAuthorized,
66
- authorize,
67
- unauthorize,
68
- logout,
69
- finishLogin
70
- }
71
-
72
- });