@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
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @frigear-nu/dashboard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Customisable dashboards: modules add items to a named dashboard with `extendDashboard` (on top of `@frigear-nu/widget`), pages render them with `<Dashboard>` or their own layout from `useDashboard`, and each user reorders, hides and collapses items (saved as a `@frigear-nu/preferences` preference when installed). With `@frigear-nu/mobile` it adds a Home tab.
|
|
4
|
+
|
|
5
|
+
See the [documentation](../../apps/docs/content/3.modules/7.interface/6.dashboard.md) for usage.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { WidgetDefinition } from '@frigear-nu/widget/utils';
|
|
3
|
+
|
|
4
|
+
/** Where the app runs: `mobile` inside the Capacitor shell of `@frigear-nu/mobile`, `web` everywhere else. */
|
|
5
|
+
type DashboardPlatform = 'web' | 'mobile';
|
|
6
|
+
/** A serialisable condition: every key that is set must hold. */
|
|
7
|
+
interface DashboardItemCondition {
|
|
8
|
+
/** The item ships only when this Nuxt module is installed (decided at build time). */
|
|
9
|
+
module?: string;
|
|
10
|
+
/** The item shows only on this platform. */
|
|
11
|
+
platform?: DashboardPlatform;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An item of a named dashboard: a widget (`@frigear-nu/widget`) plus a title and where it shows. Everything except
|
|
15
|
+
* `component` must be serialisable, it is written into the build.
|
|
16
|
+
*/
|
|
17
|
+
type DashboardItem = WidgetDefinition & {
|
|
18
|
+
/** Plain fallback title. */
|
|
19
|
+
title?: string;
|
|
20
|
+
/** i18n key of the title, translated at render time when `@nuxtjs/i18n` has it. */
|
|
21
|
+
titleKey?: string;
|
|
22
|
+
/** The platforms the item shows on. Default: both. */
|
|
23
|
+
platforms?: DashboardPlatform[];
|
|
24
|
+
when?: DashboardItemCondition;
|
|
25
|
+
};
|
|
26
|
+
/** What `#dashboard/registry` keeps of an item, next to the widget registry. */
|
|
27
|
+
interface DashboardRegistryEntry {
|
|
28
|
+
id: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
titleKey?: string;
|
|
31
|
+
platforms?: DashboardPlatform[];
|
|
32
|
+
when?: DashboardItemCondition;
|
|
33
|
+
}
|
|
34
|
+
/** One user's layout of one dashboard. Ids that no longer exist are ignored. */
|
|
35
|
+
interface DashboardLayout {
|
|
36
|
+
/** Item ids in the user's order. Items missing from it keep their registered place. */
|
|
37
|
+
order: string[];
|
|
38
|
+
hidden: string[];
|
|
39
|
+
collapsed: string[];
|
|
40
|
+
/** Per-item settings, by item id (`useDashboardItem().settings`). */
|
|
41
|
+
settings?: Record<string, Record<string, unknown>>;
|
|
42
|
+
}
|
|
43
|
+
/** What `GET` and `PATCH /api/dashboard/me/layouts` answer: the caller's layouts by dashboard name. */
|
|
44
|
+
interface DashboardLayoutsDto {
|
|
45
|
+
layouts: Record<string, DashboardLayout>;
|
|
46
|
+
}
|
|
47
|
+
/** The Home tab of `@frigear-nu/mobile`. */
|
|
48
|
+
interface DashboardHomeTabOptions {
|
|
49
|
+
/** The dashboard the tab renders. Default `crew.home`. */
|
|
50
|
+
dashboard?: string;
|
|
51
|
+
/** The page path of the tab. Default `/crew`. */
|
|
52
|
+
path?: string;
|
|
53
|
+
/** Tab label. Default `Home` (translated through `dashboard.home.label`). */
|
|
54
|
+
label?: string;
|
|
55
|
+
/** Nuxt UI icon of the web tab bar. Default `i-lucide-house`. */
|
|
56
|
+
icon?: string;
|
|
57
|
+
}
|
|
58
|
+
/** The pages of the signed-in hub. */
|
|
59
|
+
interface DashboardPagesOptions {
|
|
60
|
+
/**
|
|
61
|
+
* The hub: a signed-in page with shortcuts to the areas of the `dashboard` menu and the `settings.home.dashboard`
|
|
62
|
+
* dashboard, in the `dashboard` layout. A path, `true` for `/dashboard` (the default), or `false` to turn the area
|
|
63
|
+
* off. Needs `@frigear-nu/auth`.
|
|
64
|
+
*/
|
|
65
|
+
home?: string | boolean;
|
|
66
|
+
}
|
|
67
|
+
interface DashboardSettings {
|
|
68
|
+
pages?: DashboardPagesOptions;
|
|
69
|
+
home?: {
|
|
70
|
+
/** The dashboard the hub page renders below its shortcuts. Default `home`. */
|
|
71
|
+
dashboard?: string;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
interface ModuleOptions {
|
|
75
|
+
settings?: DashboardSettings;
|
|
76
|
+
/**
|
|
77
|
+
* With `@frigear-nu/mobile`: a Home tab and a page at `path` rendering `<Dashboard :name>`. `false` turns it off.
|
|
78
|
+
* Without mobile nothing is registered: a web app places `<Dashboard>` on a page itself.
|
|
79
|
+
*/
|
|
80
|
+
homeTab?: DashboardHomeTabOptions | false;
|
|
81
|
+
}
|
|
82
|
+
interface DashboardPublicConfig {
|
|
83
|
+
/** The dashboard the Home tab page renders, `''` without one. */
|
|
84
|
+
home: string;
|
|
85
|
+
pages: {
|
|
86
|
+
/** The hub's path, unset when the area is off. */
|
|
87
|
+
home?: string;
|
|
88
|
+
};
|
|
89
|
+
/** The dashboard the hub page renders, `''` when the area is off. */
|
|
90
|
+
homeDashboard: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare module 'nuxt/schema' {
|
|
94
|
+
interface NuxtConfig {
|
|
95
|
+
dashboard?: ModuleOptions;
|
|
96
|
+
}
|
|
97
|
+
interface PublicRuntimeConfig {
|
|
98
|
+
dashboard: DashboardPublicConfig;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
102
|
+
|
|
103
|
+
export { _default as default };
|
|
104
|
+
export type { DashboardHomeTabOptions, DashboardItem, DashboardItemCondition, DashboardLayout, DashboardLayoutsDto, DashboardPagesOptions, DashboardPlatform, DashboardPublicConfig, DashboardRegistryEntry, DashboardSettings, ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addImports, addComponent, hasNuxtModule, addTypeTemplate, useLogger } from '@nuxt/kit';
|
|
2
|
+
import { registerModule, inlineModuleRuntime, registerLocales, registerTailwindSource, addOptionalImports, defineVirtualRegistry, addModuleRoutes, addModulePages, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
|
|
3
|
+
import { getDashboardItems } from '../dist/runtime/utils/dashboard.js';
|
|
4
|
+
import { dashboardRegistryTemplate, resolveDashboardRegistry, dashboardOfArea, isModuleConditionMet } from '../dist/runtime/shared/registry.js';
|
|
5
|
+
import { resolveHomeTab } from '../dist/runtime/shared/home-tab.js';
|
|
6
|
+
import { resolveHub } from '../dist/runtime/shared/hub.js';
|
|
7
|
+
|
|
8
|
+
const MODULE_NAME = "@frigear-nu/dashboard";
|
|
9
|
+
const module$1 = defineNuxtModule({
|
|
10
|
+
meta: { name: MODULE_NAME, configKey: "dashboard", compatibility: { nuxt: ">=4.0.0" } },
|
|
11
|
+
defaults: {
|
|
12
|
+
homeTab: { dashboard: "crew.home", path: "/crew" }
|
|
13
|
+
},
|
|
14
|
+
moduleDependencies: {
|
|
15
|
+
"@frigear-nu/module-kit": { version: ">=0.0.0" },
|
|
16
|
+
// Items are widgets of the area `dashboard.<name>`, filtered by `widgets:filter`.
|
|
17
|
+
"@frigear-nu/widget": { version: ">=0.0.0" },
|
|
18
|
+
// `StatCard`, `ListCard`, `surfaceClass`, `useConfirmDialog` (and Nuxt UI through it).
|
|
19
|
+
"@frigear-nu/ui": { version: ">=0.0.0" },
|
|
20
|
+
// Soft: the per-user layout is stored as a `managed` preference when installed (read and written through
|
|
21
|
+
// `/api/dashboard/me/layouts`), else kept for the session.
|
|
22
|
+
"@frigear-nu/preferences": { version: ">=0.0.0", optional: true },
|
|
23
|
+
// Soft: the Home tab and the `mobile` platform.
|
|
24
|
+
"@frigear-nu/mobile": { version: ">=0.0.0", optional: true },
|
|
25
|
+
// Soft: whether someone is signed in, so a layout is only saved for a user; with Preferences, the `authorize` of
|
|
26
|
+
// the layout routes and their `dashboard:layouts` permission.
|
|
27
|
+
"@frigear-nu/auth": { version: ">=0.0.0", optional: true },
|
|
28
|
+
// Soft: the hub's navigation is the `dashboard` menu (other modules add their areas to it), and its entry in
|
|
29
|
+
// `account.dropdown`. Without it the hub lists only its Overview.
|
|
30
|
+
"@frigear-nu/menu": { version: ">=0.0.0", optional: true },
|
|
31
|
+
// Soft: guards the hub (signed-in only, through `guardPages`).
|
|
32
|
+
"@frigear-nu/authorization": { version: ">=0.0.0", optional: true }
|
|
33
|
+
},
|
|
34
|
+
async setup(options, nuxt) {
|
|
35
|
+
registerModule(MODULE_NAME, nuxt);
|
|
36
|
+
const resolver = createResolver(import.meta.url);
|
|
37
|
+
inlineModuleRuntime(nuxt, resolver);
|
|
38
|
+
registerLocales(nuxt, resolver.resolve("./runtime/i18n/lang"));
|
|
39
|
+
registerTailwindSource(nuxt, resolver.resolve("./runtime/app"));
|
|
40
|
+
addImports([
|
|
41
|
+
{ name: "useDashboard", from: resolver.resolve("./runtime/app/composables/useDashboard") },
|
|
42
|
+
{ name: "useDashboardItem", from: resolver.resolve("./runtime/app/composables/useDashboardItem") },
|
|
43
|
+
{ name: "useDashboardLayout", from: resolver.resolve("./runtime/app/composables/useDashboardLayout") },
|
|
44
|
+
{ name: "useDashboardPlatform", from: resolver.resolve("./runtime/app/composables/useDashboardPlatform") },
|
|
45
|
+
{ name: "dashboardSpanClass", from: resolver.resolve("./runtime/app/utils/span") },
|
|
46
|
+
{ name: "useSavedDashboardLayouts", from: resolver.resolve("./runtime/app/composables/useSavedDashboardLayouts") },
|
|
47
|
+
{ name: "useDashboardNav", from: resolver.resolve("./runtime/app/composables/useDashboardNav") }
|
|
48
|
+
]);
|
|
49
|
+
for (const name of ["Dashboard", "DashboardGrid", "DashboardItem", "ChartCard", "ActionCard", "EmptyCard"]) {
|
|
50
|
+
addComponent({ name, filePath: resolver.resolve(`./runtime/app/components/${name}.vue`) });
|
|
51
|
+
}
|
|
52
|
+
const resolveAuthMode = await import('@frigear-nu/auth/mode').then((mod) => mod.resolveAuthMode, () => void 0);
|
|
53
|
+
const persistable = () => hasNuxtModule("@frigear-nu/preferences", nuxt) && hasNuxtModule("@frigear-nu/auth", nuxt) && resolveAuthMode?.(nuxt) === "server";
|
|
54
|
+
addOptionalImports(nuxt, "#dashboard/optional", [
|
|
55
|
+
{
|
|
56
|
+
name: "useSavedDashboardLayouts",
|
|
57
|
+
available: persistable,
|
|
58
|
+
fallback: "undefined",
|
|
59
|
+
fallbackType: `undefined | typeof import(${JSON.stringify(resolver.resolve("./runtime/app/composables/useSavedDashboardLayouts"))}).useSavedDashboardLayouts`
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "useUserSession",
|
|
63
|
+
available: () => hasNuxtModule("@frigear-nu/auth", nuxt),
|
|
64
|
+
fallback: "undefined",
|
|
65
|
+
fallbackType: `undefined | (() => { loggedIn: import('vue').Ref<boolean> | import('vue').ComputedRef<boolean>, user: import('vue').Ref<{ id?: string | number } | null | undefined> })`
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "useMenu",
|
|
69
|
+
available: () => hasNuxtModule("@frigear-nu/menu", nuxt),
|
|
70
|
+
fallback: "undefined",
|
|
71
|
+
fallbackType: `undefined | ((path: string) => PromiseLike<unknown> & { data: import('vue').Ref<import('@frigear-nu/menu').MenuItem[] | null | undefined> })`
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "useCapacitor",
|
|
75
|
+
available: () => hasNuxtModule("@frigear-nu/mobile", nuxt),
|
|
76
|
+
fallback: "undefined",
|
|
77
|
+
fallbackType: `undefined | (() => { isNative: boolean })`
|
|
78
|
+
}
|
|
79
|
+
]);
|
|
80
|
+
const hasModule = (name) => hasNuxtModule(name, nuxt);
|
|
81
|
+
defineVirtualRegistry(nuxt, {
|
|
82
|
+
filename: "dashboard/registry.mjs",
|
|
83
|
+
alias: "#dashboard/registry",
|
|
84
|
+
collect: () => resolveDashboardRegistry(getDashboardItems(nuxt), hasModule),
|
|
85
|
+
contents: dashboardRegistryTemplate
|
|
86
|
+
});
|
|
87
|
+
pruneWidgetsByCondition(nuxt, hasModule);
|
|
88
|
+
addTypeTemplate({
|
|
89
|
+
filename: "types/dashboard-registry.d.ts",
|
|
90
|
+
getContents: () => `declare module '#dashboard/registry' {
|
|
91
|
+
import type { DashboardRegistryEntry } from ${JSON.stringify(resolver.resolve("./types"))}
|
|
92
|
+
export const dashboards: Record<string, Record<string, DashboardRegistryEntry>>
|
|
93
|
+
}
|
|
94
|
+
`
|
|
95
|
+
});
|
|
96
|
+
if (hasNuxtModule("@frigear-nu/preferences", nuxt)) {
|
|
97
|
+
const { addUserPreferences } = await import('@frigear-nu/preferences/utils');
|
|
98
|
+
addUserPreferences(nuxt, { path: resolver.resolve("./runtime/preferences") });
|
|
99
|
+
const [{ registerAccess }, { dashboardAccess }] = await Promise.all([
|
|
100
|
+
import('@frigear-nu/auth/utils'),
|
|
101
|
+
import('../dist/runtime/access.js')
|
|
102
|
+
]);
|
|
103
|
+
registerAccess(nuxt, dashboardAccess);
|
|
104
|
+
addModuleRoutes(resolver, [
|
|
105
|
+
{ method: "get", path: "me/layouts", file: "me/layouts.get" },
|
|
106
|
+
{ method: "patch", path: "me/layouts", file: "me/layouts.patch" }
|
|
107
|
+
], { base: "/api/dashboard" });
|
|
108
|
+
}
|
|
109
|
+
const home = resolveHomeTab(options.homeTab, { mobile: hasNuxtModule("@frigear-nu/mobile", nuxt) });
|
|
110
|
+
const publicConfig = nuxt.options.runtimeConfig.public;
|
|
111
|
+
publicConfig.dashboard = { home: home?.dashboard ?? "", pages: {}, homeDashboard: "", ...publicConfig.dashboard };
|
|
112
|
+
if (home) {
|
|
113
|
+
addModulePages(MODULE_NAME, resolver, [{ name: "dashboard-home", path: home.path, file: "./runtime/app/pages/home.vue" }]);
|
|
114
|
+
const { extendMobileTabs } = await import('@frigear-nu/mobile/utils');
|
|
115
|
+
extendMobileTabs(nuxt, home.tab);
|
|
116
|
+
}
|
|
117
|
+
await setupHub(nuxt, resolver, options);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
async function setupHub(nuxt, resolver, options) {
|
|
121
|
+
const planned = resolveHub(options.settings, { auth: true });
|
|
122
|
+
if (!planned) return;
|
|
123
|
+
const authUtils = await import('@frigear-nu/auth/utils').catch(() => void 0);
|
|
124
|
+
if (!authUtils) return;
|
|
125
|
+
const areaBase = [planned.path, `${planned.path}/**`];
|
|
126
|
+
const rules = nuxt.options.routeRules ||= {};
|
|
127
|
+
for (const pattern of authUtils.localizedRoutePatterns(nuxt, areaBase)) {
|
|
128
|
+
rules[pattern] = { appLayout: "dashboard", ...rules[pattern] };
|
|
129
|
+
}
|
|
130
|
+
authUtils.guardPages(nuxt, areaBase);
|
|
131
|
+
nuxt.hook("modules:done", () => {
|
|
132
|
+
const logger = useLogger("dashboard");
|
|
133
|
+
const hub = resolveHub(options.settings, { auth: hasNuxtModule("@frigear-nu/auth", nuxt) });
|
|
134
|
+
if (!hub) {
|
|
135
|
+
if (typeof options.settings?.pages?.home === "string") {
|
|
136
|
+
logger.warn("`dashboard.settings.pages.home` was set, but `@frigear-nu/auth` is not installed - skipping the hub.");
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (!hasNuxtModule("@frigear-nu/authorization", nuxt)) {
|
|
141
|
+
logger.warn(`@frigear-nu/authorization is not installed: the hub is not guarded. Install it and guard \`${hub.path}/**\` yourself.`);
|
|
142
|
+
}
|
|
143
|
+
const publicConfig = nuxt.options.runtimeConfig.public.dashboard;
|
|
144
|
+
publicConfig.pages = { ...publicConfig.pages, home: hub.path };
|
|
145
|
+
publicConfig.homeDashboard = hub.dashboard;
|
|
146
|
+
addModulePages(MODULE_NAME, resolver, [{ name: "dashboard-hub", path: hub.path, file: "./runtime/app/pages/hub.vue" }]);
|
|
147
|
+
nuxt.hook("app:resolve", (app) => {
|
|
148
|
+
app.layouts.dashboard ||= { name: "dashboard", file: resolver.resolve("./runtime/app/layouts/dashboard.vue") };
|
|
149
|
+
});
|
|
150
|
+
addOptionalMenuSource(nuxt, { file: resolver.resolve("./runtime/menus"), menu: "dashboard" });
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function pruneWidgetsByCondition(nuxt, hasModule) {
|
|
154
|
+
const logger = useLogger("dashboard");
|
|
155
|
+
const hooks = nuxt.hooks;
|
|
156
|
+
hooks.hook("widgets:resolved", (areas) => {
|
|
157
|
+
const dashboards = getDashboardItems(nuxt);
|
|
158
|
+
for (const [area, widgets] of Object.entries(areas)) {
|
|
159
|
+
const name = dashboardOfArea(area);
|
|
160
|
+
if (name === void 0) continue;
|
|
161
|
+
const entries = new Map((dashboards[name] ?? []).map((entry) => [entry.id, entry]));
|
|
162
|
+
const unregistered = widgets.filter((widget) => !entries.has(widget.id)).map((widget) => widget.id);
|
|
163
|
+
if (unregistered.length && !nuxt.options._prepare) {
|
|
164
|
+
logger.warn(`Widgets ${unregistered.map((id) => `"${id}"`).join(", ")} are in the area "${area}" but were not added with \`extendDashboard\`, so dashboard "${name}" does not show them. Use \`extendDashboard(nuxt, '${name}', ...)\` instead of \`extendWidgets\`.`);
|
|
165
|
+
}
|
|
166
|
+
const kept = widgets.filter((widget) => {
|
|
167
|
+
const entry = entries.get(widget.id);
|
|
168
|
+
return !entry || isModuleConditionMet(entry, hasModule);
|
|
169
|
+
});
|
|
170
|
+
widgets.splice(0, widgets.length, ...kept);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export { module$1 as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const dashboardAccess: import("@frigear-nu/auth/access").Access<"dashboard", "layouts", never, never>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineAccess } from "@frigear-nu/auth/access";
|
|
2
|
+
export const dashboardAccess = defineAccess("dashboard", {
|
|
3
|
+
permissions: {
|
|
4
|
+
// Self-service: every signed-in user holds it, and may delegate it to an API token or an OAuth access token. The
|
|
5
|
+
// routes only ever act on the caller (`/api/dashboard/me/...`), so no policy is needed.
|
|
6
|
+
layouts: {
|
|
7
|
+
label: "Your dashboard layouts",
|
|
8
|
+
description: "See and change the order, hidden and collapsed items of your dashboards.",
|
|
9
|
+
implicit: true
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A call to action: title, description, a tinted icon and one primary button that links to `to` or emits `action`.
|
|
3
|
+
* Name the object in `actionLabel` ("Apply for a shift", not "Apply").
|
|
4
|
+
*/
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
actionLabel: string;
|
|
10
|
+
to?: string;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
|
+
action: () => any;
|
|
15
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
16
|
+
onAction?: (() => any) | undefined;
|
|
17
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { surfaceClass } from "#imports";
|
|
3
|
+
defineProps({
|
|
4
|
+
title: { type: String, required: true },
|
|
5
|
+
description: { type: String, required: false },
|
|
6
|
+
icon: { type: String, required: false },
|
|
7
|
+
actionLabel: { type: String, required: true },
|
|
8
|
+
to: { type: String, required: false },
|
|
9
|
+
loading: { type: Boolean, required: false }
|
|
10
|
+
});
|
|
11
|
+
const emit = defineEmits(["action"]);
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<section :class="[surfaceClass, 'flex h-full flex-col gap-3 p-4']">
|
|
16
|
+
<div class="flex items-start gap-3">
|
|
17
|
+
<span
|
|
18
|
+
v-if="icon"
|
|
19
|
+
class="bg-primary/10 ring-primary/25 text-primary flex shrink-0 items-center justify-center rounded-full p-2.5 ring ring-inset"
|
|
20
|
+
>
|
|
21
|
+
<UIcon
|
|
22
|
+
:name="icon"
|
|
23
|
+
class="size-5"
|
|
24
|
+
/>
|
|
25
|
+
</span>
|
|
26
|
+
<div class="flex min-w-0 flex-1 flex-col gap-1">
|
|
27
|
+
<h2 class="text-highlighted text-sm font-semibold">
|
|
28
|
+
{{ title }}
|
|
29
|
+
</h2>
|
|
30
|
+
<div
|
|
31
|
+
v-if="loading"
|
|
32
|
+
class="space-y-2"
|
|
33
|
+
>
|
|
34
|
+
<USkeleton class="h-4 w-3/4" />
|
|
35
|
+
</div>
|
|
36
|
+
<p
|
|
37
|
+
v-else-if="description"
|
|
38
|
+
class="text-muted text-sm"
|
|
39
|
+
>
|
|
40
|
+
{{ description }}
|
|
41
|
+
</p>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="mt-auto">
|
|
45
|
+
<UButton
|
|
46
|
+
:to="to"
|
|
47
|
+
:label="actionLabel"
|
|
48
|
+
:disabled="loading"
|
|
49
|
+
trailing-icon="i-lucide-arrow-right"
|
|
50
|
+
@click="emit('action')"
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
</section>
|
|
54
|
+
</template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A call to action: title, description, a tinted icon and one primary button that links to `to` or emits `action`.
|
|
3
|
+
* Name the object in `actionLabel` ("Apply for a shift", not "Apply").
|
|
4
|
+
*/
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
actionLabel: string;
|
|
10
|
+
to?: string;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
|
+
action: () => any;
|
|
15
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
16
|
+
onAction?: (() => any) | undefined;
|
|
17
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A frame for a chart: title, optional description and `#actions`, a skeleton while `loading`, `empty` when `isEmpty`.
|
|
3
|
+
* The chart itself goes in the default slot (no chart library is bundled).
|
|
4
|
+
*/
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
isEmpty?: boolean;
|
|
10
|
+
empty?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_template: () => {
|
|
13
|
+
__VLS_Slots: {
|
|
14
|
+
actions?: (props: {}) => any;
|
|
15
|
+
} & {
|
|
16
|
+
default?: (props: {}) => any;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
20
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
22
|
+
declare const _default: typeof __VLS_export;
|
|
23
|
+
export default _default;
|
|
24
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
25
|
+
new (): {
|
|
26
|
+
$slots: S;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { surfaceClass } from "#imports";
|
|
3
|
+
defineProps({
|
|
4
|
+
title: { type: String, required: true },
|
|
5
|
+
description: { type: String, required: false },
|
|
6
|
+
loading: { type: Boolean, required: false },
|
|
7
|
+
isEmpty: { type: Boolean, required: false },
|
|
8
|
+
empty: { type: String, required: false }
|
|
9
|
+
});
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<section :class="[surfaceClass, 'flex h-full flex-col']">
|
|
14
|
+
<div class="border-default flex items-center justify-between gap-3 border-b px-4 py-3">
|
|
15
|
+
<div class="min-w-0">
|
|
16
|
+
<h2 class="text-highlighted text-sm font-semibold">
|
|
17
|
+
{{ title }}
|
|
18
|
+
</h2>
|
|
19
|
+
<p
|
|
20
|
+
v-if="description"
|
|
21
|
+
class="text-muted text-xs"
|
|
22
|
+
>
|
|
23
|
+
{{ description }}
|
|
24
|
+
</p>
|
|
25
|
+
</div>
|
|
26
|
+
<div
|
|
27
|
+
v-if="$slots.actions"
|
|
28
|
+
class="flex items-center gap-2"
|
|
29
|
+
>
|
|
30
|
+
<slot name="actions" />
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="flex-1 p-4">
|
|
34
|
+
<div
|
|
35
|
+
v-if="loading"
|
|
36
|
+
class="flex h-40 items-end gap-2"
|
|
37
|
+
>
|
|
38
|
+
<USkeleton class="h-1/3 flex-1" />
|
|
39
|
+
<USkeleton class="h-2/3 flex-1" />
|
|
40
|
+
<USkeleton class="h-1/2 flex-1" />
|
|
41
|
+
<USkeleton class="h-full flex-1" />
|
|
42
|
+
<USkeleton class="h-3/5 flex-1" />
|
|
43
|
+
</div>
|
|
44
|
+
<p
|
|
45
|
+
v-else-if="isEmpty"
|
|
46
|
+
class="text-muted py-6 text-center text-sm"
|
|
47
|
+
>
|
|
48
|
+
{{ empty }}
|
|
49
|
+
</p>
|
|
50
|
+
<slot v-else />
|
|
51
|
+
</div>
|
|
52
|
+
</section>
|
|
53
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A frame for a chart: title, optional description and `#actions`, a skeleton while `loading`, `empty` when `isEmpty`.
|
|
3
|
+
* The chart itself goes in the default slot (no chart library is bundled).
|
|
4
|
+
*/
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
isEmpty?: boolean;
|
|
10
|
+
empty?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_template: () => {
|
|
13
|
+
__VLS_Slots: {
|
|
14
|
+
actions?: (props: {}) => any;
|
|
15
|
+
} & {
|
|
16
|
+
default?: (props: {}) => any;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
20
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
22
|
+
declare const _default: typeof __VLS_export;
|
|
23
|
+
export default _default;
|
|
24
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
25
|
+
new (): {
|
|
26
|
+
$slots: S;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A named dashboard in the default grid: every item the viewer may see on this platform, in their order. With
|
|
3
|
+
* `editable` (default) the viewer can move, hide and show items and reset the layout. Each item receives its static
|
|
4
|
+
* `props`, then every entry of `context` as a prop.
|
|
5
|
+
*/
|
|
6
|
+
type __VLS_Props = {
|
|
7
|
+
name: string;
|
|
8
|
+
context?: Record<string, unknown>;
|
|
9
|
+
editable?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_template: () => {
|
|
12
|
+
__VLS_Slots: {
|
|
13
|
+
empty?: (props: {}) => any;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
17
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
18
|
+
editable: boolean;
|
|
19
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
21
|
+
declare const _default: typeof __VLS_export;
|
|
22
|
+
export default _default;
|
|
23
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
24
|
+
new (): {
|
|
25
|
+
$slots: S;
|
|
26
|
+
};
|
|
27
|
+
};
|