@frigear-nu/dashboard 0.0.0-stage → 0.0.1
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/README.md +4 -2
- package/dist/module.d.mts +104 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +175 -0
- package/dist/runtime/access.d.ts +1 -0
- package/dist/runtime/access.js +12 -0
- package/dist/runtime/app/components/ActionCard.d.vue.ts +19 -0
- package/dist/runtime/app/components/ActionCard.vue +54 -0
- package/dist/runtime/app/components/ActionCard.vue.d.ts +19 -0
- package/dist/runtime/app/components/ChartCard.d.vue.ts +28 -0
- package/dist/runtime/app/components/ChartCard.vue +53 -0
- package/dist/runtime/app/components/ChartCard.vue.d.ts +28 -0
- package/dist/runtime/app/components/Dashboard.d.vue.ts +27 -0
- package/dist/runtime/app/components/Dashboard.vue +156 -0
- package/dist/runtime/app/components/Dashboard.vue.d.ts +27 -0
- package/dist/runtime/app/components/DashboardGrid.d.vue.ts +15 -0
- package/dist/runtime/app/components/DashboardGrid.vue +11 -0
- package/dist/runtime/app/components/DashboardGrid.vue.d.ts +15 -0
- package/dist/runtime/app/components/DashboardItem.d.vue.ts +26 -0
- package/dist/runtime/app/components/DashboardItem.vue +175 -0
- package/dist/runtime/app/components/DashboardItem.vue.d.ts +26 -0
- package/dist/runtime/app/components/EmptyCard.d.vue.ts +18 -0
- package/dist/runtime/app/components/EmptyCard.vue +25 -0
- package/dist/runtime/app/components/EmptyCard.vue.d.ts +18 -0
- package/dist/runtime/app/composables/useDashboard.d.ts +46 -0
- package/dist/runtime/app/composables/useDashboard.js +59 -0
- package/dist/runtime/app/composables/useDashboardItem.d.ts +39 -0
- package/dist/runtime/app/composables/useDashboardItem.js +29 -0
- package/dist/runtime/app/composables/useDashboardLayout.d.ts +24 -0
- package/dist/runtime/app/composables/useDashboardLayout.js +67 -0
- package/dist/runtime/app/composables/useDashboardNav.d.ts +23 -0
- package/dist/runtime/app/composables/useDashboardNav.js +16 -0
- package/dist/runtime/app/composables/useDashboardPlatform.d.ts +10 -0
- package/dist/runtime/app/composables/useDashboardPlatform.js +17 -0
- package/dist/runtime/app/composables/useSavedDashboardLayouts.d.ts +20 -0
- package/dist/runtime/app/composables/useSavedDashboardLayouts.js +35 -0
- package/dist/runtime/app/layouts/dashboard.d.vue.ts +15 -0
- package/dist/runtime/app/layouts/dashboard.vue +32 -0
- package/dist/runtime/app/layouts/dashboard.vue.d.ts +15 -0
- package/dist/runtime/app/pages/home.d.vue.ts +3 -0
- package/dist/runtime/app/pages/home.vue +16 -0
- package/dist/runtime/app/pages/home.vue.d.ts +3 -0
- package/dist/runtime/app/pages/hub.d.vue.ts +3 -0
- package/dist/runtime/app/pages/hub.vue +63 -0
- package/dist/runtime/app/pages/hub.vue.d.ts +3 -0
- package/dist/runtime/app/utils/components.d.ts +8 -0
- package/dist/runtime/app/utils/components.js +19 -0
- package/dist/runtime/app/utils/span.d.ts +1 -0
- package/dist/runtime/app/utils/span.js +10 -0
- package/dist/runtime/i18n/lang/da.json +71 -0
- package/dist/runtime/i18n/lang/en.json +71 -0
- package/dist/runtime/menus.d.ts +2 -0
- package/dist/runtime/menus.js +26 -0
- package/dist/runtime/preferences.d.ts +37 -0
- package/dist/runtime/preferences.js +25 -0
- package/dist/runtime/server/layouts.d.ts +9 -0
- package/dist/runtime/server/layouts.js +25 -0
- package/dist/runtime/server/routes/me/layouts.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/layouts.get.js +6 -0
- package/dist/runtime/server/routes/me/layouts.patch.d.ts +2 -0
- package/dist/runtime/server/routes/me/layouts.patch.js +10 -0
- package/dist/runtime/shared/home-tab.d.ts +31 -0
- package/dist/runtime/shared/home-tab.js +21 -0
- package/dist/runtime/shared/hub.d.ts +18 -0
- package/dist/runtime/shared/hub.js +8 -0
- package/dist/runtime/shared/layout.d.ts +62 -0
- package/dist/runtime/shared/layout.js +110 -0
- package/dist/runtime/shared/registry.d.ts +11 -0
- package/dist/runtime/shared/registry.js +15 -0
- package/dist/runtime/shared/stored-layouts.d.ts +12 -0
- package/dist/runtime/shared/stored-layouts.js +16 -0
- package/dist/runtime/utils/api.d.ts +11 -0
- package/dist/runtime/utils/api.js +11 -0
- package/dist/runtime/utils/dashboard.d.ts +22 -0
- package/dist/runtime/utils/dashboard.js +32 -0
- package/dist/runtime/utils/hub.d.ts +8 -0
- package/dist/runtime/utils/hub.js +5 -0
- package/dist/runtime/utils/index.d.ts +5 -0
- package/dist/runtime/utils/index.js +19 -0
- package/dist/types.d.mts +3 -0
- package/package.json +116 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { computed, inject, ref } from "vue";
|
|
2
|
+
export const dashboardItemKey = Symbol("dashboard-item");
|
|
3
|
+
function standalone() {
|
|
4
|
+
let handler;
|
|
5
|
+
const error = ref(null);
|
|
6
|
+
const settings = ref({});
|
|
7
|
+
return {
|
|
8
|
+
dashboard: "",
|
|
9
|
+
id: "",
|
|
10
|
+
loading: ref(false),
|
|
11
|
+
error,
|
|
12
|
+
empty: ref(false),
|
|
13
|
+
collapsed: computed(() => false),
|
|
14
|
+
settings: computed(() => settings.value),
|
|
15
|
+
setSettings: async (value) => {
|
|
16
|
+
settings.value = { ...value };
|
|
17
|
+
},
|
|
18
|
+
refresh: async () => {
|
|
19
|
+
error.value = null;
|
|
20
|
+
await handler?.();
|
|
21
|
+
},
|
|
22
|
+
onRefresh: (fn) => {
|
|
23
|
+
handler = fn;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function useDashboardItem() {
|
|
28
|
+
return inject(dashboardItemKey, null) ?? standalone();
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ComputedRef, type Ref } from 'vue';
|
|
2
|
+
import type { DashboardLayout } from '../../../types.js';
|
|
3
|
+
export interface DashboardLayoutState {
|
|
4
|
+
/** The user's layout of this dashboard: this session's changes, else the saved preference, else the default. */
|
|
5
|
+
layout: ComputedRef<DashboardLayout>;
|
|
6
|
+
/** Whether changes are saved for the user (Preferences, a cookie session, signed in), not only for this session. */
|
|
7
|
+
persisted: ComputedRef<boolean>;
|
|
8
|
+
/** Resolves once the saved layouts are loaded (at once when they are not saved). */
|
|
9
|
+
ready: Promise<void>;
|
|
10
|
+
/** Whether a save is in flight. */
|
|
11
|
+
saving: Ref<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Applies a change (ids that are not items of the dashboard are dropped), then saves it for the user when it can. A
|
|
14
|
+
* failed save shows an error toast and rolls the change back.
|
|
15
|
+
*/
|
|
16
|
+
update: (change: (layout: DashboardLayout) => DashboardLayout) => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The per-user layout of one dashboard. With `@frigear-nu/preferences`, Auth in server mode and a signed-in user it is
|
|
20
|
+
* the `dashboardLayouts` preference, read and written through `/api/dashboard/me/layouts` (it is `managed`, so never in
|
|
21
|
+
* the session cookie); otherwise it lives in `useState` for the session (keyed by user) and the registered default
|
|
22
|
+
* applies again on reload.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useDashboardLayout(name: string): DashboardLayoutState;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { computed, watch } from "vue";
|
|
2
|
+
import { useErrorToast, useModuleT, useNuxtApp, useState } from "#imports";
|
|
3
|
+
import { useSavedDashboardLayouts, useUserSession } from "#dashboard/optional";
|
|
4
|
+
import { normalizeLayout, pruneLayout } from "../../shared/layout.js";
|
|
5
|
+
import { getDashboardItemIds } from "../utils/components.js";
|
|
6
|
+
const writers = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
export function useDashboardLayout(name) {
|
|
8
|
+
const nuxtApp = useNuxtApp();
|
|
9
|
+
const t = useModuleT("dashboard");
|
|
10
|
+
const showError = useErrorToast();
|
|
11
|
+
const state = useState("dashboard:layouts", () => ({ owner: "anon", layouts: {}, confirmed: {} }));
|
|
12
|
+
const saving = useState("dashboard:saving", () => false);
|
|
13
|
+
const store = useSavedDashboardLayouts?.();
|
|
14
|
+
const userSession = useUserSession?.();
|
|
15
|
+
const owner = computed(() => {
|
|
16
|
+
const id = userSession?.loggedIn.value ? userSession.user.value?.id : void 0;
|
|
17
|
+
return id === void 0 || id === null ? "anon" : `user:${id}`;
|
|
18
|
+
});
|
|
19
|
+
const session = computed(() => state.value.owner === owner.value ? state.value.layouts : {});
|
|
20
|
+
const persisted = computed(() => !!store && !!userSession?.loggedIn.value);
|
|
21
|
+
const saved = computed(() => persisted.value ? store.layouts(owner.value) : {});
|
|
22
|
+
const layout = computed(() => normalizeLayout(session.value[name] ?? saved.value[name]));
|
|
23
|
+
const load = () => persisted.value ? store.load(owner.value) : Promise.resolve();
|
|
24
|
+
const ready = load();
|
|
25
|
+
watch(owner, () => {
|
|
26
|
+
void load();
|
|
27
|
+
});
|
|
28
|
+
const own = () => state.value.owner === owner.value ? state.value : { owner: owner.value, layouts: {}, confirmed: {} };
|
|
29
|
+
async function save() {
|
|
30
|
+
let writer = writers.get(nuxtApp);
|
|
31
|
+
if (!writer) writers.set(nuxtApp, writer = { running: null, dirty: false });
|
|
32
|
+
writer.dirty = true;
|
|
33
|
+
if (writer.running) return writer.running;
|
|
34
|
+
const current = writer;
|
|
35
|
+
current.running = (async () => {
|
|
36
|
+
saving.value = true;
|
|
37
|
+
try {
|
|
38
|
+
while (current.dirty) {
|
|
39
|
+
current.dirty = false;
|
|
40
|
+
const sent = { ...own().layouts };
|
|
41
|
+
try {
|
|
42
|
+
await store.save(owner.value, sent);
|
|
43
|
+
state.value = { ...own(), confirmed: sent };
|
|
44
|
+
} catch (error) {
|
|
45
|
+
current.dirty = false;
|
|
46
|
+
const base = own();
|
|
47
|
+
state.value = { ...base, layouts: { ...base.confirmed } };
|
|
48
|
+
showError(error, t("save.error", "Your dashboard layout could not be saved."));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} finally {
|
|
53
|
+
saving.value = false;
|
|
54
|
+
current.running = null;
|
|
55
|
+
}
|
|
56
|
+
})();
|
|
57
|
+
return current.running;
|
|
58
|
+
}
|
|
59
|
+
async function update(change) {
|
|
60
|
+
const next = pruneLayout(change(layout.value), getDashboardItemIds(name));
|
|
61
|
+
const base = own();
|
|
62
|
+
const layouts = { ...base.layouts, [name]: next };
|
|
63
|
+
state.value = { ...base, layouts, confirmed: persisted.value ? base.confirmed : layouts };
|
|
64
|
+
if (persisted.value) await save();
|
|
65
|
+
}
|
|
66
|
+
return { layout, persisted, ready, saving, update };
|
|
67
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** An entry of the hub navigation: an item of the `dashboard` menu, or the Overview without the menu module. */
|
|
2
|
+
export interface DashboardNavItem {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
to: string;
|
|
8
|
+
external?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** The id of the hub's own entry, the first of the `dashboard` menu. */
|
|
11
|
+
export declare const DASHBOARD_OVERVIEW_ID = "dashboard-overview";
|
|
12
|
+
/**
|
|
13
|
+
* The hub navigation: the items of the `dashboard` menu (the areas other modules add, filtered by their `permission`),
|
|
14
|
+
* or, without `@frigear-nu/menu`, only the Overview. `links` are ready for `AreaNavLayout`/`UNavigationMenu`
|
|
15
|
+
* (localised, `active` set, the Overview only active on the hub page), `shortcuts` are the items other than the
|
|
16
|
+
* Overview, and `current` is the item the route belongs to. Await it, so the menu is resolved before the page renders.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useDashboardNav(): Promise<{
|
|
19
|
+
items: import("vue").ComputedRef<DashboardNavItem[]>;
|
|
20
|
+
shortcuts: import("vue").ComputedRef<DashboardNavItem[]>;
|
|
21
|
+
links: import("vue").ComputedRef<import("@nuxt/ui").NavigationMenuItem[]>;
|
|
22
|
+
current: import("vue").ComputedRef<DashboardNavItem | undefined>;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { computed, useLocaleLink, useModuleT, useNavLinks, useRuntimeConfig } from "#imports";
|
|
2
|
+
import { useMenu } from "#dashboard/optional";
|
|
3
|
+
export const DASHBOARD_OVERVIEW_ID = "dashboard-overview";
|
|
4
|
+
export async function useDashboardNav() {
|
|
5
|
+
const t = useModuleT("dashboard");
|
|
6
|
+
const home = useRuntimeConfig().public.dashboard?.pages?.home;
|
|
7
|
+
const { isActive, strip } = useLocaleLink();
|
|
8
|
+
const menu = typeof useMenu === "function" ? useMenu("dashboard") : void 0;
|
|
9
|
+
const fallback = () => home ? [{ id: DASHBOARD_OVERVIEW_ID, to: home, label: t("menu.overview.label", "Overview"), description: t("menu.overview.description", "Your shortcuts and overview."), icon: "i-lucide-layout-dashboard" }] : [];
|
|
10
|
+
const items = computed(() => menu ? (menu.data.value ?? []).filter((item) => !!item.to).map((item) => ({ id: item.id ?? item.to, label: item.label, description: item.description, icon: item.icon, to: item.to, external: item.external })) : fallback());
|
|
11
|
+
const shortcuts = computed(() => items.value.filter((item) => item.id !== DASHBOARD_OVERVIEW_ID));
|
|
12
|
+
const links = useNavLinks(items, { exact: home ? [home] : [] });
|
|
13
|
+
const current = computed(() => items.value.filter((item) => !item.external && isActive(item.to, { exact: item.to === home })).sort((a, b) => strip(b.to).length - strip(a.to).length)[0]);
|
|
14
|
+
if (menu) await menu;
|
|
15
|
+
return { items, shortcuts, links, current };
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { DashboardPlatform } from '../../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* `mobile` inside the native shell of `@frigear-nu/mobile` (`useCapacitor().isNative`), `web` everywhere else,
|
|
5
|
+
* including the server and a browser without mobile installed.
|
|
6
|
+
*
|
|
7
|
+
* The server always renders `web`. When the page was server-rendered (mobile with `spa: false`), the client switches
|
|
8
|
+
* to `mobile` only once hydration is done, so the first client render matches the server's HTML.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useDashboardPlatform(): Ref<DashboardPlatform>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useNuxtApp, useState } from "#imports";
|
|
2
|
+
import { useCapacitor } from "#dashboard/optional";
|
|
3
|
+
export function useDashboardPlatform() {
|
|
4
|
+
const nuxtApp = useNuxtApp();
|
|
5
|
+
const platform = useState("dashboard:platform", () => "web");
|
|
6
|
+
if (import.meta.client && useCapacitor) {
|
|
7
|
+
const detected = useCapacitor().isNative ? "mobile" : "web";
|
|
8
|
+
if (platform.value !== detected) {
|
|
9
|
+
const apply = () => {
|
|
10
|
+
platform.value = detected;
|
|
11
|
+
};
|
|
12
|
+
if (nuxtApp.isHydrating) nuxtApp.hooks.hookOnce("app:suspense:resolve", apply);
|
|
13
|
+
else apply();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return platform;
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ComputedRef } from 'vue';
|
|
2
|
+
import type { DashboardLayout } from '../../../types.js';
|
|
3
|
+
type Layouts = Record<string, DashboardLayout>;
|
|
4
|
+
export interface SavedDashboardLayouts {
|
|
5
|
+
/** The saved layouts of `owner`, by dashboard name (empty while they load or for another owner). */
|
|
6
|
+
layouts: (owner: string) => Layouts;
|
|
7
|
+
/** Loads the saved layouts of `owner` once (on the server too, with the request's cookie). A failure leaves none. */
|
|
8
|
+
load: (owner: string) => Promise<void>;
|
|
9
|
+
/** Saves the named layouts (`null` removes one) and keeps the answer as the saved layouts. Throws on failure. */
|
|
10
|
+
save: (owner: string, change: Record<string, DashboardLayout | null>) => Promise<void>;
|
|
11
|
+
/** The last loaded owner. */
|
|
12
|
+
owner: ComputedRef<string | null>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The signed-in user's saved dashboard layouts, from `GET`/`PATCH /api/dashboard/me/layouts` (the `managed`
|
|
16
|
+
* `dashboardLayouts` preference, which is never in the session cookie). Used by `useDashboardLayout`; only available
|
|
17
|
+
* with `@frigear-nu/preferences` and Auth in server mode.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useSavedDashboardLayouts(): SavedDashboardLayouts;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { dashboardApi } from "../../utils/api.js";
|
|
3
|
+
import { $fetch, useRequestFetch, useState } from "#imports";
|
|
4
|
+
export function useSavedDashboardLayouts() {
|
|
5
|
+
const state = useState("dashboard:saved", () => ({ owner: null, layouts: {} }));
|
|
6
|
+
const requestFetch = import.meta.server ? useRequestFetch() : $fetch;
|
|
7
|
+
const loading = /* @__PURE__ */ new Map();
|
|
8
|
+
async function load(owner) {
|
|
9
|
+
if (state.value.owner === owner) return;
|
|
10
|
+
const running = loading.get(owner);
|
|
11
|
+
if (running) return running;
|
|
12
|
+
const promise = (async () => {
|
|
13
|
+
try {
|
|
14
|
+
const answer = await requestFetch(dashboardApi.me.layouts);
|
|
15
|
+
state.value = { owner, layouts: answer?.layouts ?? {} };
|
|
16
|
+
} catch {
|
|
17
|
+
state.value = { owner, layouts: {} };
|
|
18
|
+
} finally {
|
|
19
|
+
loading.delete(owner);
|
|
20
|
+
}
|
|
21
|
+
})();
|
|
22
|
+
loading.set(owner, promise);
|
|
23
|
+
return promise;
|
|
24
|
+
}
|
|
25
|
+
async function save(owner, change) {
|
|
26
|
+
const answer = await $fetch(dashboardApi.me.layouts, { method: "PATCH", body: { layouts: change } });
|
|
27
|
+
state.value = { owner, layouts: answer?.layouts ?? {} };
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
layouts: (owner) => state.value.owner === owner ? state.value.layouts : {},
|
|
31
|
+
load,
|
|
32
|
+
save,
|
|
33
|
+
owner: computed(() => state.value.owner)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const __VLS_template: () => {
|
|
2
|
+
__VLS_Slots: {
|
|
3
|
+
default?: (props: {}) => any;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
7
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, useDashboardNav, useHead, useModuleT } from "#imports";
|
|
3
|
+
import { useUserSession } from "#dashboard/optional";
|
|
4
|
+
defineOptions({ name: "DashboardLayout" });
|
|
5
|
+
const siteLayout = "default";
|
|
6
|
+
const t = useModuleT("dashboard");
|
|
7
|
+
const session = typeof useUserSession === "function" ? useUserSession() : void 0;
|
|
8
|
+
const { links, current } = await useDashboardNav();
|
|
9
|
+
const user = computed(() => {
|
|
10
|
+
const value = session?.user.value;
|
|
11
|
+
if (!value) return void 0;
|
|
12
|
+
const name = value.name || value.email || t("hub.title", "Your dashboard");
|
|
13
|
+
return {
|
|
14
|
+
name,
|
|
15
|
+
description: value.name ? value.email ?? void 0 : void 0,
|
|
16
|
+
avatar: { src: value.avatar || void 0, alt: name }
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
useHead({ title: () => current.value?.label ?? t("hub.title", "Your dashboard") }, { tagPriority: "low" });
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<NuxtLayout :name="siteLayout">
|
|
24
|
+
<AreaNavLayout
|
|
25
|
+
:links="links"
|
|
26
|
+
:user="user"
|
|
27
|
+
:label="t('nav.label', 'Dashboard navigation')"
|
|
28
|
+
>
|
|
29
|
+
<slot />
|
|
30
|
+
</AreaNavLayout>
|
|
31
|
+
</NuxtLayout>
|
|
32
|
+
</template>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const __VLS_template: () => {
|
|
2
|
+
__VLS_Slots: {
|
|
3
|
+
default?: (props: {}) => any;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
7
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useModuleT, useRuntimeConfig } from "#imports";
|
|
3
|
+
defineOptions({ name: "DashboardHomePage" });
|
|
4
|
+
const t = useModuleT("dashboard");
|
|
5
|
+
const name = useRuntimeConfig().public.dashboard?.home || "crew.home";
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<div class="flex flex-col gap-4">
|
|
10
|
+
<!-- The mobile navbar shows the tab label; the page still has one heading for screen readers. -->
|
|
11
|
+
<h1 class="sr-only">
|
|
12
|
+
{{ t("home.label", "Home") }}
|
|
13
|
+
</h1>
|
|
14
|
+
<Dashboard :name="name" />
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, useDashboardNav, useLocaleLink, useModuleT, useRuntimeConfig } from "#imports";
|
|
3
|
+
import { useUserSession } from "#dashboard/optional";
|
|
4
|
+
defineOptions({ name: "DashboardHubPage" });
|
|
5
|
+
const t = useModuleT("dashboard");
|
|
6
|
+
const { localize } = useLocaleLink();
|
|
7
|
+
const name = useRuntimeConfig().public.dashboard?.homeDashboard || "home";
|
|
8
|
+
const session = typeof useUserSession === "function" ? useUserSession() : void 0;
|
|
9
|
+
const { shortcuts } = await useDashboardNav();
|
|
10
|
+
const firstName = computed(() => {
|
|
11
|
+
const user = session?.user.value;
|
|
12
|
+
return user?.name?.trim().split(/\s+/)[0] || "";
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div class="flex flex-col gap-4">
|
|
18
|
+
<PageHeading
|
|
19
|
+
:title="firstName ? t('hub.greeting', 'Hi {name}', { name: firstName }) : t('hub.title', 'Your dashboard')"
|
|
20
|
+
:description="t('hub.description', 'Your shortcuts and what is happening.')"
|
|
21
|
+
/>
|
|
22
|
+
|
|
23
|
+
<UPageGrid
|
|
24
|
+
v-if="shortcuts.length"
|
|
25
|
+
class="lg:grid-cols-3"
|
|
26
|
+
data-dashboard-shortcuts
|
|
27
|
+
>
|
|
28
|
+
<UPageCard
|
|
29
|
+
v-for="item in shortcuts"
|
|
30
|
+
:key="item.id"
|
|
31
|
+
:title="item.label"
|
|
32
|
+
:description="item.description"
|
|
33
|
+
:icon="item.icon"
|
|
34
|
+
:to="item.external ? item.to : localize(item.to)"
|
|
35
|
+
variant="subtle"
|
|
36
|
+
:ui="{
|
|
37
|
+
container: 'gap-y-1.5',
|
|
38
|
+
wrapper: 'items-start',
|
|
39
|
+
leading: 'p-2.5 rounded-full bg-primary/10 ring ring-inset ring-primary/25 flex-col'
|
|
40
|
+
}"
|
|
41
|
+
/>
|
|
42
|
+
</UPageGrid>
|
|
43
|
+
|
|
44
|
+
<Dashboard :name="name">
|
|
45
|
+
<!-- An empty dashboard: the hub's own empty state, or nothing below the shortcuts (an empty slot would show the
|
|
46
|
+
dashboard's default one). -->
|
|
47
|
+
<template #empty>
|
|
48
|
+
<UEmpty
|
|
49
|
+
v-if="!shortcuts.length"
|
|
50
|
+
icon="i-lucide-layout-dashboard"
|
|
51
|
+
:title="t('hub.empty.title', 'Nothing here yet')"
|
|
52
|
+
:description="t('hub.empty.description', 'Shortcuts and overviews appear here as your organisation turns on more features.')"
|
|
53
|
+
variant="naked"
|
|
54
|
+
/>
|
|
55
|
+
<div
|
|
56
|
+
v-else
|
|
57
|
+
class="hidden"
|
|
58
|
+
data-dashboard-empty
|
|
59
|
+
/>
|
|
60
|
+
</template>
|
|
61
|
+
</Dashboard>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Component } from 'vue';
|
|
2
|
+
/** The lazily loaded component of a dashboard item. */
|
|
3
|
+
export declare function getDashboardComponent(name: string, id: string): Component | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Every item id of a dashboard in this build, in registered order: the items of every platform and permission, so a
|
|
6
|
+
* layout change never drops or reorders items the current viewer does not see.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDashboardItemIds(name: string): string[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineAsyncComponent, markRaw } from "vue";
|
|
2
|
+
import { widgets as registry } from "#widgets/registry";
|
|
3
|
+
import { dashboards } from "#dashboard/registry";
|
|
4
|
+
import { dashboardArea } from "../../shared/registry.js";
|
|
5
|
+
const cache = /* @__PURE__ */ new Map();
|
|
6
|
+
export function getDashboardComponent(name, id) {
|
|
7
|
+
const area = dashboardArea(name);
|
|
8
|
+
const key = `${area}::${id}`;
|
|
9
|
+
if (!cache.has(key)) {
|
|
10
|
+
const widget = (registry[area] ?? []).find((item) => item.id === id);
|
|
11
|
+
if (!widget) return void 0;
|
|
12
|
+
cache.set(key, markRaw(defineAsyncComponent(widget.component)));
|
|
13
|
+
}
|
|
14
|
+
return cache.get(key);
|
|
15
|
+
}
|
|
16
|
+
export function getDashboardItemIds(name) {
|
|
17
|
+
const entries = dashboards[name] ?? {};
|
|
18
|
+
return (registry[dashboardArea(name)] ?? []).map((item) => item.id).filter((id) => id in entries);
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dashboardSpanClass(span?: number): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const spans = {
|
|
2
|
+
1: "",
|
|
3
|
+
2: "@2xl:col-span-2",
|
|
4
|
+
3: "@2xl:col-span-2 @4xl:col-span-3",
|
|
5
|
+
4: "@2xl:col-span-2 @4xl:col-span-4"
|
|
6
|
+
};
|
|
7
|
+
export function dashboardSpanClass(span) {
|
|
8
|
+
const key = Math.min(4, Math.max(1, Math.trunc(span ?? 1)));
|
|
9
|
+
return spans[key];
|
|
10
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dashboard": {
|
|
3
|
+
"home": {
|
|
4
|
+
"label": "Hjem"
|
|
5
|
+
},
|
|
6
|
+
"edit": {
|
|
7
|
+
"start": "Tilpas oversigt",
|
|
8
|
+
"done": "Færdig",
|
|
9
|
+
"sessionOnly": "Ændringer gælder, indtil du genindlæser siden."
|
|
10
|
+
},
|
|
11
|
+
"reset": {
|
|
12
|
+
"button": "Nulstil layout",
|
|
13
|
+
"title": "Nulstil layout?",
|
|
14
|
+
"description": "Gendanner standardrækkefølgen og viser alle skjulte elementer. Sammenklappede elementer åbnes igen.",
|
|
15
|
+
"confirm": "Nulstil layout"
|
|
16
|
+
},
|
|
17
|
+
"item": {
|
|
18
|
+
"expand": "Udvid {title}",
|
|
19
|
+
"collapse": "Klap {title} sammen",
|
|
20
|
+
"moveUp": "Flyt {title} op",
|
|
21
|
+
"moveDown": "Flyt {title} ned",
|
|
22
|
+
"hide": "Skjul {title}",
|
|
23
|
+
"error": "{title} kunne ikke indlæses.",
|
|
24
|
+
"errorHint": "Noget gik galt. Prøv igen om lidt.",
|
|
25
|
+
"retry": "Prøv igen"
|
|
26
|
+
},
|
|
27
|
+
"hidden": {
|
|
28
|
+
"title": "Skjulte elementer",
|
|
29
|
+
"show": "Vis {title}"
|
|
30
|
+
},
|
|
31
|
+
"allHidden": {
|
|
32
|
+
"title": "Alle elementer er skjult",
|
|
33
|
+
"description": "Vis de elementer, du vil se igen."
|
|
34
|
+
},
|
|
35
|
+
"empty": {
|
|
36
|
+
"title": "Her er intet endnu",
|
|
37
|
+
"description": "Elementer vises her, når de moduler, der tilføjer dem, er installeret."
|
|
38
|
+
},
|
|
39
|
+
"error": "Oversigten kunne ikke indlæses.",
|
|
40
|
+
"save": {
|
|
41
|
+
"error": "Dit oversigtslayout kunne ikke gemmes."
|
|
42
|
+
},
|
|
43
|
+
"retry": "Prøv igen",
|
|
44
|
+
"permissions": {
|
|
45
|
+
"layouts": "Dine oversigter",
|
|
46
|
+
"layoutsDescription": "Se og ændr rækkefølgen og de skjulte og sammenklappede elementer på dine oversigter."
|
|
47
|
+
},
|
|
48
|
+
"hub": {
|
|
49
|
+
"title": "Dit dashboard",
|
|
50
|
+
"greeting": "Hej {name}",
|
|
51
|
+
"description": "Dine genveje og hvad der sker.",
|
|
52
|
+
"empty": {
|
|
53
|
+
"title": "Intet her endnu",
|
|
54
|
+
"description": "Genveje og overblik dukker op her, efterhånden som jeres organisation slår flere funktioner til."
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"nav": {
|
|
58
|
+
"label": "Dashboardnavigation"
|
|
59
|
+
},
|
|
60
|
+
"menu": {
|
|
61
|
+
"dashboard": {
|
|
62
|
+
"label": "Dashboard",
|
|
63
|
+
"description": "Dine genveje og dit overblik."
|
|
64
|
+
},
|
|
65
|
+
"overview": {
|
|
66
|
+
"label": "Overblik",
|
|
67
|
+
"description": "Dine genveje og dit overblik."
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dashboard": {
|
|
3
|
+
"home": {
|
|
4
|
+
"label": "Home"
|
|
5
|
+
},
|
|
6
|
+
"edit": {
|
|
7
|
+
"start": "Customise dashboard",
|
|
8
|
+
"done": "Done",
|
|
9
|
+
"sessionOnly": "Changes last until you reload the page."
|
|
10
|
+
},
|
|
11
|
+
"reset": {
|
|
12
|
+
"button": "Reset layout",
|
|
13
|
+
"title": "Reset layout?",
|
|
14
|
+
"description": "Restores the default order and shows every hidden item. Collapsed items open again.",
|
|
15
|
+
"confirm": "Reset layout"
|
|
16
|
+
},
|
|
17
|
+
"item": {
|
|
18
|
+
"expand": "Expand {title}",
|
|
19
|
+
"collapse": "Collapse {title}",
|
|
20
|
+
"moveUp": "Move {title} up",
|
|
21
|
+
"moveDown": "Move {title} down",
|
|
22
|
+
"hide": "Hide {title}",
|
|
23
|
+
"error": "{title} could not be loaded.",
|
|
24
|
+
"errorHint": "Something went wrong. Try again in a moment.",
|
|
25
|
+
"retry": "Try again"
|
|
26
|
+
},
|
|
27
|
+
"hidden": {
|
|
28
|
+
"title": "Hidden items",
|
|
29
|
+
"show": "Show {title}"
|
|
30
|
+
},
|
|
31
|
+
"allHidden": {
|
|
32
|
+
"title": "Every item is hidden",
|
|
33
|
+
"description": "Show the items you want to see again."
|
|
34
|
+
},
|
|
35
|
+
"empty": {
|
|
36
|
+
"title": "Nothing here yet",
|
|
37
|
+
"description": "Items appear here when the modules that add them are installed."
|
|
38
|
+
},
|
|
39
|
+
"error": "The dashboard could not be loaded.",
|
|
40
|
+
"save": {
|
|
41
|
+
"error": "Your dashboard layout could not be saved."
|
|
42
|
+
},
|
|
43
|
+
"retry": "Try again",
|
|
44
|
+
"permissions": {
|
|
45
|
+
"layouts": "Your dashboard layouts",
|
|
46
|
+
"layoutsDescription": "See and change the order, hidden and collapsed items of your dashboards."
|
|
47
|
+
},
|
|
48
|
+
"hub": {
|
|
49
|
+
"title": "Your dashboard",
|
|
50
|
+
"greeting": "Hi {name}",
|
|
51
|
+
"description": "Your shortcuts and what is happening.",
|
|
52
|
+
"empty": {
|
|
53
|
+
"title": "Nothing here yet",
|
|
54
|
+
"description": "Shortcuts and overviews appear here as your organisation turns on more features."
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"nav": {
|
|
58
|
+
"label": "Dashboard navigation"
|
|
59
|
+
},
|
|
60
|
+
"menu": {
|
|
61
|
+
"dashboard": {
|
|
62
|
+
"label": "Dashboard",
|
|
63
|
+
"description": "Your shortcuts and overview."
|
|
64
|
+
},
|
|
65
|
+
"overview": {
|
|
66
|
+
"label": "Overview",
|
|
67
|
+
"description": "Your shortcuts and overview."
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { extendMenuItem, defineMenuSource } from "@frigear-nu/menu/utils";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
export default defineMenuSource(() => {
|
|
4
|
+
const path = useRuntimeConfig().public.dashboard?.pages?.home;
|
|
5
|
+
if (!path) return;
|
|
6
|
+
extendMenuItem("account.dropdown", {
|
|
7
|
+
id: "dashboard",
|
|
8
|
+
label: "Dashboard",
|
|
9
|
+
labelKey: "dashboard.menu.dashboard.label",
|
|
10
|
+
description: "Your shortcuts and overview.",
|
|
11
|
+
descriptionKey: "dashboard.menu.dashboard.description",
|
|
12
|
+
icon: "i-lucide-layout-dashboard",
|
|
13
|
+
to: path,
|
|
14
|
+
order: -100
|
|
15
|
+
});
|
|
16
|
+
extendMenuItem("dashboard", {
|
|
17
|
+
id: "dashboard-overview",
|
|
18
|
+
label: "Overview",
|
|
19
|
+
labelKey: "dashboard.menu.overview.label",
|
|
20
|
+
description: "Your shortcuts and overview.",
|
|
21
|
+
descriptionKey: "dashboard.menu.overview.description",
|
|
22
|
+
icon: "i-lucide-layout-dashboard",
|
|
23
|
+
to: path,
|
|
24
|
+
order: 0
|
|
25
|
+
});
|
|
26
|
+
});
|