Skip to content

Commit d30d645

Browse files
committed
Merge branch 'main' of github.com:devforth/adminforth into main
2 parents 8fbcde9 + 15f32c8 commit d30d645

File tree

22 files changed

+1552
-408
lines changed

22 files changed

+1552
-408
lines changed

adminforth/documentation/docs/tutorial/03-Customization/06-customPages.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Create a Vue component in the `custom` directory of your project, e.g. `Dashboar
3636
3737
```html title="./custom/Dashboard.vue"
3838
<template>
39-
<div class="px-4 py-8 bg-blue-50 dark:bg-gray-900 dark:shadow-none min-h-screen">
39+
<div class="px-4 py-8 bg-blue-50 dark:bg-gray-900 dark:shadow-none min-h-[calc(100vh-56px)]">
4040
<h1 class="mb-4 text-xl font-extrabold text-gray-900 dark:text-white md:text-2xl lg:text-3xl"><span
4141
class="text-transparent bg-clip-text bg-gradient-to-r to-emerald-600 from-sky-400">{{ $t('Apartments') }}</span>
4242
Statistics.</h1>
@@ -431,7 +431,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
431431
const days = req.body.days || 7;
432432
const apartsByDays = await admin.resource('aparts').dataConnector.db.prepare(
433433
`SELECT
434-
strftime('%Y-%m-%d', created_at, 'unixepoch') as day,
434+
strftime('%Y-%m-%d', created_at) as day,
435435
COUNT(*) as count
436436
FROM apartments
437437
GROUP BY day
@@ -445,7 +445,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
445445
// add listed, unlisted, listedPrice, unlistedPrice
446446
const listedVsUnlistedByDays = await admin.resource('aparts').dataConnector.db.prepare(
447447
`SELECT
448-
strftime('%Y-%m-%d', created_at, 'unixepoch') as day,
448+
strftime('%Y-%m-%d', created_at) as day,
449449
SUM(listed) as listed,
450450
COUNT(*) - SUM(listed) as unlisted,
451451
SUM(listed * price) as listedPrice,
@@ -459,7 +459,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
459459

460460
const listedVsUnlistedPriceByDays = await admin.resource('aparts').dataConnector.db.prepare(
461461
`SELECT
462-
strftime('%Y-%m-%d', created_at, 'unixepoch') as day,
462+
strftime('%Y-%m-%d', created_at) as day,
463463
SUM(listed * price) as listedPrice,
464464
SUM((1 - listed) * price) as unlistedPrice
465465
FROM apartments

adminforth/plugins/i18n/custom/LanguageInUserMenu.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div>
2+
<div class="min-w-40">
33
<div class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black
44
hover:bg-html dark:text-darkSidebarTextHover dark:hover:bg-darkSidebarItemHover dark:hover:text-darkSidebarTextActive
55
w-full select-none "

adminforth/spa/src/i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ export function initI18n(app: ReturnType<typeof createApp>) {
5151
})
5252

5353
app.use(i18n);
54-
54+
return i18n
5555
}

adminforth/spa/src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export const app: ReturnType<typeof createApp> = createApp(App)
1313
app.use(createPinia())
1414
app.use(router)
1515

16-
initI18n(app);
16+
// get access to i18n instance outside components
17+
window.i18n = initI18n(app);
1718

1819

1920
/* IMPORTANT:ADMINFORTH CUSTOM USES */

adminforth/spa/src/utils.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { onMounted, ref, resolveComponent } from 'vue';
22
import type { CoreConfig } from './spa_types/core';
33
import type { ValidationObject } from './types/AdminForthConfig';
4-
5-
64
import router from "./router";
75
import { useCoreStore } from './stores/core';
86
import { useUserStore } from './stores/user';
97
import { Dropdown } from 'flowbite';
108

9+
1110
const LS_LANG_KEY = `afLanguage`;
1211

1312
export async function callApi({path, method, body=undefined}: {
@@ -23,13 +22,18 @@ export async function callApi({path, method, body=undefined}: {
2322
body: JSON.stringify(body),
2423
};
2524
const fullPath = `${import.meta.env.VITE_ADMINFORTH_PUBLIC_PATH || ''}${path}`;
26-
const r = await fetch(fullPath, options);
27-
if (r.status == 401 ) {
28-
useUserStore().unauthorize();
29-
await router.push({ name: 'login' });
30-
return null;
31-
}
32-
return await r.json();
25+
try {
26+
const r = await fetch(fullPath, options);
27+
if (r.status == 401 ) {
28+
useUserStore().unauthorize();
29+
await router.push({ name: 'login' });
30+
return null;
31+
}
32+
return await r.json();
33+
} catch(e){
34+
window.adminforth.alert({variant:'danger', message:window.i18n?.global?.t('Something went wrong, please try again later'),})
35+
console.error(`error in callApi ${path}`,e);
36+
}
3337
}
3438

3539
export async function callAdminForthApi({ path, method, body=undefined, headers=undefined }: {

dev-demo/custom/Dash.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="px-4 py-8 bg-blue-50 dark:bg-gray-900 dark:shadow-none min-h-screen">
2+
<div class="px-4 py-8 bg-blue-50 dark:bg-gray-900 dark:shadow-none min-h-[calc(100vh-56px)]">
33

44
<h1 class="mb-4 text-xl font-extrabold text-gray-900 dark:text-white md:text-2xl lg:text-3xl"
55
v-html='$t("<span class=\"text-transparent bg-clip-text bg-gradient-to-r to-emerald-600 from-sky-400\">Apartments</span> Statistics.")'></h1>

dev-demo/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
325325
const days = req.body.days || 7;
326326
const apartsByDays = await db.prepare(
327327
`SELECT
328-
strftime('%Y-%m-%d', created_at, 'unixepoch') as day,
328+
strftime('%Y-%m-%d', created_at) as day,
329329
COUNT(*) as count
330330
FROM apartments
331331
GROUP BY day
@@ -339,7 +339,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
339339
// add listed, unlisted, listedPrice, unlistedPrice
340340
const listedVsUnlistedByDays = await db.prepare(
341341
`SELECT
342-
strftime('%Y-%m-%d', created_at, 'unixepoch') as day,
342+
strftime('%Y-%m-%d', created_at) as day,
343343
SUM(listed) as listed,
344344
COUNT(*) - SUM(listed) as unlisted,
345345
SUM(listed * price) as listedPrice,
@@ -353,7 +353,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
353353

354354
const listedVsUnlistedPriceByDays = await db.prepare(
355355
`SELECT
356-
strftime('%Y-%m-%d', created_at, 'unixepoch') as day,
356+
strftime('%Y-%m-%d', created_at) as day,
357357
SUM(listed * price) as listedPrice,
358358
SUM((1 - listed) * price) as unlistedPrice
359359
FROM apartments

0 commit comments

Comments
 (0)