adminforth 1.1.32 → 1.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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: '/',
@@ -11,7 +11,7 @@ export const styles = () => `
11
11
  "header-logo-color": "#333333", // Dark grey logo
12
12
  "header-border-color": "rgb(229 231 235)", // Light grey border
13
13
 
14
- "nav-menu-bg": "#f9fafb", // Very light grey
14
+ "nav-menu-bg": "#ffffff", // Very light grey
15
15
  "nav-menu-border": "rgb(229 231 235)",
16
16
  "nav-menu-bg-hover": "rgb(243 244 246)", // Light grey hover
17
17
  "nav-menu-bg-active": "rgb(233, 234, 236)", // Light grey active
@@ -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,7 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
- <link rel="icon" href="/favicon.png">
5
+ <link rel="icon" href="/* IMPORTANT:ADMINFORTH FAVICON */">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>/* IMPORTANT:ADMINFORTH TITLE */</title>
8
8
  <!--
@@ -242,7 +242,6 @@ async function loadMenu() {
242
242
 
243
243
  coreStore.menu.forEach((item, i) => {
244
244
  if (item.open) {
245
- console.log(item)
246
245
  opened.value.push(i);
247
246
  }
248
247
  });
@@ -118,7 +118,7 @@
118
118
  </td>
119
119
  </tr>
120
120
 
121
- <tr v-else v-for="(row, rowI) in rows" :key="row.id"
121
+ <tr @click="onClick" v-else v-for="(row, rowI) in rows" :key="row.id"
122
122
  class="bg-list-view-table-bg border-b dark:bg-gray-800 border-list-view-border-color dark:border-gray-700 hover:bg-list-view-table-row-hover dark:hover:bg-gray-600">
123
123
  <td class="w-4 p-4">
124
124
  <div class="flex items center">
@@ -385,6 +385,15 @@ function onSortButtonClick(field) {
385
385
  }
386
386
  }
387
387
 
388
+ const mouseDownTime = ref(0);
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
388
397
  async function deleteRecord(row) {
389
398
  const data = await window.adminforth.confirm({
390
399
  message: 'Are you sure you want to delete this item?',
package/index.ts CHANGED
@@ -49,6 +49,8 @@ class AdminForth implements AdminForthClass {
49
49
  runningHotReload: boolean;
50
50
  activatedPlugins: Array<AdminForthPlugin>;
51
51
 
52
+ baseUrlSlashed: string;
53
+
52
54
  statuses: {
53
55
  dbDiscover?: 'running' | 'done',
54
56
  }
@@ -159,6 +161,11 @@ class AdminForth implements AdminForthClass {
159
161
  if (!this.config.baseUrl) {
160
162
  this.config.baseUrl = '';
161
163
  }
164
+ if (!this.config.baseUrl.endsWith('/')) {
165
+ this.baseUrlSlashed = this.config.baseUrl + '/';
166
+ } else {
167
+ this.baseUrlSlashed = this.config.baseUrl;
168
+ }
162
169
  if (!this.config?.customization.brandName) {
163
170
  this.config.customization.brandName = 'AdminForth';
164
171
  }
@@ -166,6 +173,10 @@ class AdminForth implements AdminForthClass {
166
173
  errors.push(...this.checkCustomFileExists(this.config.customization.brandLogo));
167
174
  }
168
175
 
176
+ if (!this.config.customization.favicon) {
177
+ errors.push(...this.checkCustomFileExists(this.config.customization.favicon));
178
+ }
179
+
169
180
  if (!this.config.customization.datesFormat) {
170
181
  this.config.customization.datesFormat = 'MMM D, YYYY HH:mm:ss';
171
182
  }
@@ -209,6 +209,18 @@ class CodeInjector implements CodeInjectorType {
209
209
  this.srcFoldersToSync[this.adminforth.config.customization.customComponentsDir] = './'
210
210
  }
211
211
 
212
+ // if this.adminforth.config.customization.favicon is set, copy it to assets
213
+ const customFav = this.adminforth.config.customization?.favicon;
214
+ if (customFav) {
215
+
216
+ const faviconPath = path.join(this.adminforth.config.customization?.customComponentsDir, customFav.replace('@@/', ''));
217
+ const dest = path.join(CodeInjector.SPA_TMP_PATH, 'public', 'assets', customFav.replace('@@/', ''));
218
+ // make sure all folders in dest exist
219
+ await fsExtra.ensureDir(path.dirname(dest));
220
+
221
+ await fsExtra.copy(faviconPath, dest);
222
+ }
223
+
212
224
  for (const [src, dest] of Object.entries(this.srcFoldersToSync)) {
213
225
  const to = path.join(CodeInjector.SPA_TMP_PATH, 'src', 'custom', dest);
214
226
  if (process.env.HEAVY_DEBUG) {
@@ -343,7 +355,6 @@ class CodeInjector implements CodeInjectorType {
343
355
  await fs.promises.writeFile(tailwindConfigPath, tailwindConfigContent);
344
356
  }
345
357
 
346
-
347
358
  const routerVuePath = path.join(CodeInjector.SPA_TMP_PATH, 'src', 'router', 'index.ts');
348
359
 
349
360
  let routerVueContent = await fs.promises.readFile(routerVuePath, 'utf-8');
@@ -353,6 +364,13 @@ class CodeInjector implements CodeInjectorType {
353
364
  const indexHtmlPath = path.join(CodeInjector.SPA_TMP_PATH, 'index.html');
354
365
  let indexHtmlContent = await fs.promises.readFile(indexHtmlPath, 'utf-8');
355
366
  indexHtmlContent = indexHtmlContent.replace('/* IMPORTANT:ADMINFORTH TITLE */', `${this.adminforth.config.customization.title || 'AdminForth'}`);
367
+
368
+ indexHtmlContent = indexHtmlContent.replace(
369
+ '/* IMPORTANT:ADMINFORTH FAVICON */',
370
+ this.adminforth.config.customization.favicon?.replace('@@/', `${this.adminforth.baseUrlSlashed}assets/`)
371
+ ||
372
+ `${this.adminforth.baseUrlSlashed}assets/favicon.png`
373
+ );
356
374
  await fs.promises.writeFile(indexHtmlPath, indexHtmlContent);
357
375
 
358
376
 
package/modules/styles.ts CHANGED
@@ -11,7 +11,7 @@ export const styles = () => `
11
11
  "header-logo-color": "#333333", // Dark grey logo
12
12
  "header-border-color": "rgb(229 231 235)", // Light grey border
13
13
 
14
- "nav-menu-bg": "#f9fafb", // Very light grey
14
+ "nav-menu-bg": "#ffffff", // Very light grey
15
15
  "nav-menu-border": "rgb(229 231 235)",
16
16
  "nav-menu-bg-hover": "rgb(243 244 246)", // Light grey hover
17
17
  "nav-menu-bg-active": "rgb(233, 234, 236)", // Light grey active
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.1.32",
3
+ "version": "1.1.34",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/spa/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
- <link rel="icon" href="/favicon.png">
5
+ <link rel="icon" href="/* IMPORTANT:ADMINFORTH FAVICON */">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>/* IMPORTANT:ADMINFORTH TITLE */</title>
8
8
  <!--
Binary file
package/spa/src/App.vue CHANGED
@@ -242,7 +242,6 @@ async function loadMenu() {
242
242
 
243
243
  coreStore.menu.forEach((item, i) => {
244
244
  if (item.open) {
245
- console.log(item)
246
245
  opened.value.push(i);
247
246
  }
248
247
  });
@@ -118,7 +118,7 @@
118
118
  </td>
119
119
  </tr>
120
120
 
121
- <tr v-else v-for="(row, rowI) in rows" :key="row.id"
121
+ <tr @click="onClick" v-else v-for="(row, rowI) in rows" :key="row.id"
122
122
  class="bg-list-view-table-bg border-b dark:bg-gray-800 border-list-view-border-color dark:border-gray-700 hover:bg-list-view-table-row-hover dark:hover:bg-gray-600">
123
123
  <td class="w-4 p-4">
124
124
  <div class="flex items center">
@@ -385,6 +385,15 @@ function onSortButtonClick(field) {
385
385
  }
386
386
  }
387
387
 
388
+ const mouseDownTime = ref(0);
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
388
397
  async function deleteRecord(row) {
389
398
  const data = await window.adminforth.confirm({
390
399
  message: 'Are you sure you want to delete this item?',
@@ -742,6 +742,21 @@ export type AdminForthConfig = {
742
742
  */
743
743
  brandLogo?: string,
744
744
 
745
+ /**
746
+ * Path to your app favicon
747
+ *
748
+ * Example:
749
+ * Place file `favicon.png` to `./custom` folder and set this option:
750
+ *
751
+ * ```ts
752
+ * favicon: '@@/favicon.png',
753
+ * ```
754
+ */
755
+ favicon?: string,
756
+
757
+ /**
758
+ favicon?: string,
759
+
745
760
  /**
746
761
  * DayJS format string for all dates in the app
747
762
  */