@sfxcode/nuxt-ui-mongocamp 1.5.2 → 1.5.3
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/module.d.mts +9 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +0 -1
- package/dist/runtime/components/MongocampCollectionData.vue +4 -3
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +0 -1
- package/dist/runtime/components/MongocampCollections.vue +7 -4
- package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +0 -7
- package/dist/runtime/components/MongocampCommandPalette.vue +16 -15
- package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +0 -7
- package/dist/runtime/components/MongocampDashboard.d.vue.ts +0 -3
- package/dist/runtime/components/MongocampDashboard.vue +8 -7
- package/dist/runtime/components/MongocampDashboard.vue.d.ts +0 -3
- package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +0 -1
- package/dist/runtime/components/MongocampPermissionMatrix.vue +4 -3
- package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +0 -1
- package/dist/runtime/components/MongocampRoles.vue +3 -2
- package/dist/runtime/components/MongocampServerOverview.d.vue.ts +0 -3
- package/dist/runtime/components/MongocampServerOverview.vue +8 -7
- package/dist/runtime/components/MongocampServerOverview.vue.d.ts +0 -3
- package/dist/runtime/components/MongocampServerStatus.d.vue.ts +13 -0
- package/dist/runtime/components/MongocampServerStatus.vue +147 -0
- package/dist/runtime/components/MongocampServerStatus.vue.d.ts +13 -0
- package/dist/runtime/components/MongocampUserAccess.d.vue.ts +27 -0
- package/dist/runtime/components/MongocampUserAccess.vue +168 -0
- package/dist/runtime/components/MongocampUserAccess.vue.d.ts +27 -0
- package/dist/runtime/components/MongocampVersion.vue +3 -3
- package/dist/runtime/composables/useMongocampAdminGate.js +2 -3
- package/dist/runtime/composables/useMongocampBreadcrumbs.d.ts +12 -0
- package/dist/runtime/composables/useMongocampBreadcrumbs.js +13 -0
- package/dist/runtime/composables/useMongocampCollectionNames.d.ts +21 -0
- package/dist/runtime/composables/useMongocampCollectionNames.js +46 -0
- package/dist/runtime/composables/useMongocampNavigation.d.ts +32 -0
- package/dist/runtime/composables/useMongocampNavigation.js +15 -0
- package/dist/runtime/composables/useMongocampPaths.d.ts +6 -0
- package/dist/runtime/composables/useMongocampPaths.js +6 -0
- package/dist/runtime/composables/useMongocampPermissions.js +2 -3
- package/dist/runtime/composables/useMongocampProxyMode.d.ts +5 -0
- package/dist/runtime/composables/useMongocampProxyMode.js +4 -0
- package/dist/runtime/composables/useMongocampRoles.d.ts +3 -0
- package/dist/runtime/composables/useMongocampRoles.js +5 -1
- package/dist/runtime/composables/useMongocampSession.js +2 -3
- package/dist/runtime/locales/de.json +42 -0
- package/dist/runtime/locales/en.json +42 -0
- package/dist/runtime/publicUtils.d.ts +4 -0
- package/dist/runtime/publicUtils.js +4 -0
- package/dist/runtime/utils/collectionNames.d.ts +13 -0
- package/dist/runtime/utils/collectionNames.js +14 -0
- package/dist/runtime/utils/collectionProtection.d.ts +2 -0
- package/dist/runtime/utils/collectionProtection.js +3 -0
- package/dist/runtime/utils/navigation.d.ts +39 -0
- package/dist/runtime/utils/navigation.js +65 -0
- package/dist/runtime/utils/paths.d.ts +32 -0
- package/dist/runtime/utils/paths.js +24 -0
- package/dist/runtime/utils/serverStatus.d.ts +20 -0
- package/dist/runtime/utils/serverStatus.js +11 -0
- package/package.json +8 -1
package/dist/module.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { MongocampPaths } from '../dist/runtime/utils/paths.js';
|
|
2
3
|
|
|
3
4
|
interface ModuleOptions {
|
|
4
5
|
useGlobalAuthMiddleware?: boolean;
|
|
@@ -66,6 +67,14 @@ interface ModuleOptions {
|
|
|
66
67
|
* Local route prefix the proxy listens on when `useServerProxy` is enabled.
|
|
67
68
|
*/
|
|
68
69
|
serverProxyPath?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Base routes of the app's MongoCamp pages. Every `*Path` prop of the components falls back to
|
|
72
|
+
* these (and `useMongocampPaths()` returns them), so an app with other routes sets them once
|
|
73
|
+
* instead of a prop per component. Keys: `home`, `account`, `collections`, `buckets`, `users`,
|
|
74
|
+
* `roles`, `permissions`, `jobs`, `databases`, `overview`, `server`, `settings`; a key left out
|
|
75
|
+
* keeps its default (`/secured`, `/secured/account`, `/secured/admin/<key>`).
|
|
76
|
+
*/
|
|
77
|
+
paths?: Partial<MongocampPaths>;
|
|
69
78
|
/**
|
|
70
79
|
* Load the module's default styles for FormKit's label, help text, validation message and form
|
|
71
80
|
* spacing (`runtime/assets/formkit.css`, built on Nuxt UI's `--ui-*` tokens). It is loaded before
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -61,6 +61,7 @@ const module$1 = defineNuxtModule({
|
|
|
61
61
|
useServerProxy: false,
|
|
62
62
|
serverProxyPath: "/api/_mongocamp",
|
|
63
63
|
formkitStyles: true
|
|
64
|
+
// `paths` has no entry here: `useMongocampPaths()` fills in the defaults at runtime (`utils/paths.ts`).
|
|
64
65
|
},
|
|
65
66
|
// A function, not an object: the FormKit entry depends on the app (does it bring its own config?).
|
|
66
67
|
// It has to be decided here — `@formkit/nuxt` is set up before this module's `setup()` runs, the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, h, ref, resolveComponent, watch } from "vue";
|
|
3
|
-
import { useI18n, useMongocampClientApi, useMongocampError, useMongocampPermissions, useMongocampRoles, useMongocampSchema, useToast } from "#imports";
|
|
3
|
+
import { useI18n, useMongocampClientApi, useMongocampError, useMongocampPermissions, useMongocampRoles, useMongocampSchema, useToast, useMongocampPaths } from "#imports";
|
|
4
4
|
import useMongocampCollection from "../composables/useMongocampCollection";
|
|
5
5
|
import { useMongocampBucket } from "../composables/useMongocampBucket";
|
|
6
6
|
import { useMongocampIndex } from "../composables/useMongocampIndex";
|
|
@@ -30,7 +30,7 @@ import MongocampCollectionCharts from "./MongocampCollectionCharts.vue";
|
|
|
30
30
|
import { isFilterTooLong } from "../utils/requestLimits";
|
|
31
31
|
const props = defineProps({
|
|
32
32
|
collectionName: { type: String, required: true },
|
|
33
|
-
infoPath: { type: String, required: false
|
|
33
|
+
infoPath: { type: String, required: false },
|
|
34
34
|
aggregatePath: { type: String, required: false, default: "" },
|
|
35
35
|
persistState: { type: Boolean, required: false, default: true },
|
|
36
36
|
stateKey: { type: String, required: false, default: "" },
|
|
@@ -38,6 +38,7 @@ const props = defineProps({
|
|
|
38
38
|
});
|
|
39
39
|
const emit = defineEmits(["changed"]);
|
|
40
40
|
const { t } = useI18n();
|
|
41
|
+
const paths = useMongocampPaths();
|
|
41
42
|
const { documentApi } = useMongocampClientApi();
|
|
42
43
|
const { pagination, total } = useMongocampCollection();
|
|
43
44
|
const { state: persisted } = useMongocampPersistedState(
|
|
@@ -291,7 +292,7 @@ async function indexField(key, ascending) {
|
|
|
291
292
|
title: t("nuxtUiMongocamp.collectionData.indexCreatedTitle"),
|
|
292
293
|
description: t("nuxtUiMongocamp.collectionData.indexCreatedDescription", { name: created.name, collection: props.collectionName }),
|
|
293
294
|
color: "success",
|
|
294
|
-
actions: [{ label: t("nuxtUiMongocamp.collectionData.viewIndexes"), to: `${props.infoPath}/${props.collectionName}` }]
|
|
295
|
+
actions: [{ label: t("nuxtUiMongocamp.collectionData.viewIndexes"), to: `${props.infoPath ?? paths.collections}/${props.collectionName}` }]
|
|
295
296
|
});
|
|
296
297
|
} catch (e) {
|
|
297
298
|
toast.add({ title: t("nuxtUiMongocamp.collectionData.indexFailedTitle", { field: key }), description: await indexFailureMessage(e), color: "error" });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { formatBytes } from "../utils/formatBytes";
|
|
3
3
|
import { shortenLabel, topNWithOther } from "../utils/chartData";
|
|
4
4
|
import { computed, h, ref, resolveComponent } from "vue";
|
|
5
|
-
import { useI18n, useMongocampClientApi, useMongocampBucket, useMongocampRoles, useToast } from "#imports";
|
|
5
|
+
import { useI18n, useMongocampClientApi, useMongocampBucket, useMongocampCollectionNames, useMongocampRoles, useToast, useMongocampPaths } from "#imports";
|
|
6
6
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
7
7
|
import { isProtectedCollection } from "../utils/collectionProtection";
|
|
8
8
|
const props = defineProps({
|
|
@@ -15,6 +15,8 @@ const props = defineProps({
|
|
|
15
15
|
});
|
|
16
16
|
const emit = defineEmits(["changed"]);
|
|
17
17
|
const { t } = useI18n();
|
|
18
|
+
const paths = useMongocampPaths();
|
|
19
|
+
const sharedNames = useMongocampCollectionNames();
|
|
18
20
|
const { collectionApi } = useMongocampClientApi();
|
|
19
21
|
const { isBucketCollection, bucketNameFor, bucketActionInFlight, clearBucket, deleteBucket } = useMongocampBucket();
|
|
20
22
|
const { clearCollection, deleteCollection } = useMongocampAdmin();
|
|
@@ -40,6 +42,7 @@ async function fetchCollections() {
|
|
|
40
42
|
loadError.value = null;
|
|
41
43
|
try {
|
|
42
44
|
const [names, infos] = await Promise.all([collectionApi.listCollections(), collectionApi.listCollectionInformation({})]);
|
|
45
|
+
sharedNames.set(names);
|
|
43
46
|
const byName = new Map(infos.map((info) => [info.name, info]));
|
|
44
47
|
const rows = names.filter((name) => !name.startsWith("mc")).flatMap((name) => {
|
|
45
48
|
const info = byName.get(name);
|
|
@@ -148,7 +151,7 @@ const columns = computed(() => [
|
|
|
148
151
|
"variant": "ghost",
|
|
149
152
|
"size": "sm",
|
|
150
153
|
"aria-label": t("nuxtUiMongocamp.collections.infoTooltip"),
|
|
151
|
-
"to": `${props.infoPath ??
|
|
154
|
+
"to": `${props.infoPath ?? paths.collections}/${row.original.name}`
|
|
152
155
|
})),
|
|
153
156
|
withTooltip(t("nuxtUiMongocamp.collections.dataTooltip"), h(UButton, {
|
|
154
157
|
"icon": "i-lucide-table",
|
|
@@ -156,7 +159,7 @@ const columns = computed(() => [
|
|
|
156
159
|
"variant": "ghost",
|
|
157
160
|
"size": "sm",
|
|
158
161
|
"aria-label": t("nuxtUiMongocamp.collections.dataTooltip"),
|
|
159
|
-
"to": `${props.dataPath ??
|
|
162
|
+
"to": `${props.dataPath ?? paths.collections}/${row.original.name}/data`
|
|
160
163
|
}))
|
|
161
164
|
];
|
|
162
165
|
if (isBucketCollection(row.original.name)) {
|
|
@@ -168,7 +171,7 @@ const columns = computed(() => [
|
|
|
168
171
|
"variant": "ghost",
|
|
169
172
|
"size": "sm",
|
|
170
173
|
"aria-label": t("nuxtUiMongocamp.collections.browseFilesTooltip"),
|
|
171
|
-
"to": `${props.bucketFilesPath ??
|
|
174
|
+
"to": `${props.bucketFilesPath ?? paths.buckets}/${bucketName}`
|
|
172
175
|
})),
|
|
173
176
|
withTooltip(t("nuxtUiMongocamp.collections.clearBucketTooltip"), h(UButton, {
|
|
174
177
|
"icon": "i-lucide-eraser",
|
|
@@ -28,13 +28,6 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
28
28
|
shortcut: string;
|
|
29
29
|
cacheMs: number;
|
|
30
30
|
navigate: boolean;
|
|
31
|
-
collectionPath: string;
|
|
32
|
-
bucketPath: string;
|
|
33
|
-
usersPath: string;
|
|
34
|
-
rolePath: string;
|
|
35
|
-
jobsPath: string;
|
|
36
|
-
settingsPath: string;
|
|
37
|
-
accountPath: string;
|
|
38
31
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
39
32
|
declare const _default: typeof __VLS_export;
|
|
40
33
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, ref, watch } from "vue";
|
|
3
|
-
import { defineShortcuts, navigateTo, useI18n } from "#imports";
|
|
3
|
+
import { defineShortcuts, navigateTo, useI18n, useMongocampPaths } from "#imports";
|
|
4
4
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
5
5
|
import { useMongocampJobs } from "../composables/useMongocampJobs";
|
|
6
6
|
import { useMongocampPermissions } from "../composables/useMongocampPermissions";
|
|
@@ -10,17 +10,18 @@ const props = defineProps({
|
|
|
10
10
|
shortcut: { type: String, required: false, default: "meta_k" },
|
|
11
11
|
cacheMs: { type: Number, required: false, default: 6e4 },
|
|
12
12
|
navigate: { type: Boolean, required: false, default: true },
|
|
13
|
-
collectionPath: { type: String, required: false
|
|
14
|
-
bucketPath: { type: String, required: false
|
|
15
|
-
usersPath: { type: String, required: false
|
|
16
|
-
rolePath: { type: String, required: false
|
|
17
|
-
jobsPath: { type: String, required: false
|
|
18
|
-
settingsPath: { type: String, required: false
|
|
19
|
-
accountPath: { type: String, required: false
|
|
13
|
+
collectionPath: { type: String, required: false },
|
|
14
|
+
bucketPath: { type: String, required: false },
|
|
15
|
+
usersPath: { type: String, required: false },
|
|
16
|
+
rolePath: { type: String, required: false },
|
|
17
|
+
jobsPath: { type: String, required: false },
|
|
18
|
+
settingsPath: { type: String, required: false },
|
|
19
|
+
accountPath: { type: String, required: false }
|
|
20
20
|
});
|
|
21
21
|
const emit = defineEmits(["select"]);
|
|
22
22
|
const open = defineModel("open", { type: Boolean, ...{ default: false } });
|
|
23
23
|
const { t } = useI18n();
|
|
24
|
+
const basePaths = useMongocampPaths();
|
|
24
25
|
const { listUsers, listRoles, listCollections } = useMongocampAdmin();
|
|
25
26
|
const { listJobs } = useMongocampJobs();
|
|
26
27
|
const { canRead, load: loadPermissions } = useMongocampPermissions();
|
|
@@ -31,13 +32,13 @@ const loading = ref(false);
|
|
|
31
32
|
const failed = ref([]);
|
|
32
33
|
let generation = 0;
|
|
33
34
|
const paths = computed(() => ({
|
|
34
|
-
collectionPath: props.collectionPath,
|
|
35
|
-
bucketPath: props.bucketPath,
|
|
36
|
-
usersPath: props.usersPath,
|
|
37
|
-
rolePath: props.rolePath,
|
|
38
|
-
jobsPath: props.jobsPath,
|
|
39
|
-
settingsPath: props.settingsPath,
|
|
40
|
-
accountPath: props.accountPath
|
|
35
|
+
collectionPath: props.collectionPath ?? basePaths.collections,
|
|
36
|
+
bucketPath: props.bucketPath ?? basePaths.buckets,
|
|
37
|
+
usersPath: props.usersPath ?? basePaths.users,
|
|
38
|
+
rolePath: props.rolePath ?? basePaths.roles,
|
|
39
|
+
jobsPath: props.jobsPath ?? basePaths.jobs,
|
|
40
|
+
settingsPath: props.settingsPath ?? basePaths.settings,
|
|
41
|
+
accountPath: props.accountPath ?? basePaths.account
|
|
41
42
|
}));
|
|
42
43
|
async function load() {
|
|
43
44
|
const current = ++generation;
|
|
@@ -28,13 +28,6 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
28
28
|
shortcut: string;
|
|
29
29
|
cacheMs: number;
|
|
30
30
|
navigate: boolean;
|
|
31
|
-
collectionPath: string;
|
|
32
|
-
bucketPath: string;
|
|
33
|
-
usersPath: string;
|
|
34
|
-
rolePath: string;
|
|
35
|
-
jobsPath: string;
|
|
36
|
-
settingsPath: string;
|
|
37
|
-
accountPath: string;
|
|
38
31
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
39
32
|
declare const _default: typeof __VLS_export;
|
|
40
33
|
export default _default;
|
|
@@ -17,9 +17,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
17
17
|
refresh: typeof refresh;
|
|
18
18
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
19
19
|
hideHeading: boolean;
|
|
20
|
-
usersPath: string;
|
|
21
|
-
collectionsPath: string;
|
|
22
|
-
rolesPath: string;
|
|
23
20
|
autoRefresh: number;
|
|
24
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
22
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, onMounted, ref, watch } from "vue";
|
|
3
|
-
import { useI18n } from "#imports";
|
|
3
|
+
import { useI18n, useMongocampPaths } from "#imports";
|
|
4
4
|
import { useNuxtApp } from "#app";
|
|
5
5
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
6
6
|
import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
|
|
7
7
|
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
8
8
|
const props = defineProps({
|
|
9
|
-
collectionsPath: { type: String, required: false
|
|
10
|
-
usersPath: { type: String, required: false
|
|
11
|
-
rolesPath: { type: String, required: false
|
|
9
|
+
collectionsPath: { type: String, required: false },
|
|
10
|
+
usersPath: { type: String, required: false },
|
|
11
|
+
rolesPath: { type: String, required: false },
|
|
12
12
|
autoRefresh: { type: Number, required: false, default: 0 },
|
|
13
13
|
hideHeading: { type: Boolean, required: false, default: false },
|
|
14
14
|
hideRefresh: { type: Boolean, required: false }
|
|
15
15
|
});
|
|
16
16
|
const { t } = useI18n();
|
|
17
|
+
const paths = useMongocampPaths();
|
|
17
18
|
const { $mongocampVersion } = useNuxtApp();
|
|
18
19
|
const { listUsers, listRoles, listCollections } = useMongocampAdmin();
|
|
19
20
|
const version = computed(() => $mongocampVersion.value);
|
|
@@ -52,9 +53,9 @@ function syncAutoRefresh() {
|
|
|
52
53
|
onMounted(syncAutoRefresh);
|
|
53
54
|
watch(() => props.autoRefresh, syncAutoRefresh);
|
|
54
55
|
const boxes = computed(() => [
|
|
55
|
-
{ key: "collections", label: t("nuxtUiMongocamp.dashboard.collections"), icon: "i-lucide-database", to: props.collectionsPath },
|
|
56
|
-
{ key: "users", label: t("nuxtUiMongocamp.dashboard.users"), icon: "i-lucide-users", to: props.usersPath },
|
|
57
|
-
{ key: "roles", label: t("nuxtUiMongocamp.dashboard.roles"), icon: "i-lucide-shield", to: props.rolesPath }
|
|
56
|
+
{ key: "collections", label: t("nuxtUiMongocamp.dashboard.collections"), icon: "i-lucide-database", to: props.collectionsPath ?? paths.collections },
|
|
57
|
+
{ key: "users", label: t("nuxtUiMongocamp.dashboard.users"), icon: "i-lucide-users", to: props.usersPath ?? paths.users },
|
|
58
|
+
{ key: "roles", label: t("nuxtUiMongocamp.dashboard.roles"), icon: "i-lucide-shield", to: props.rolesPath ?? paths.roles }
|
|
58
59
|
]);
|
|
59
60
|
defineExpose({ refresh });
|
|
60
61
|
if (!blocked.value) refresh();
|
|
@@ -17,9 +17,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
17
17
|
refresh: typeof refresh;
|
|
18
18
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
19
19
|
hideHeading: boolean;
|
|
20
|
-
usersPath: string;
|
|
21
|
-
collectionsPath: string;
|
|
22
|
-
rolesPath: string;
|
|
23
20
|
autoRefresh: number;
|
|
24
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
22
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -16,7 +16,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
16
16
|
refresh: typeof load;
|
|
17
17
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
18
18
|
hideHeading: boolean;
|
|
19
|
-
grantsPath: string;
|
|
20
19
|
maxCollections: number;
|
|
21
20
|
maxUsers: number;
|
|
22
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, ref } from "vue";
|
|
3
|
-
import { useI18n } from "#imports";
|
|
3
|
+
import { useI18n, useMongocampPaths } from "#imports";
|
|
4
4
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
5
5
|
import {
|
|
6
6
|
buildPermissionMatrix,
|
|
@@ -14,13 +14,14 @@ import {
|
|
|
14
14
|
import { downloadTextFile, rowsToCsv } from "../utils/exportRows";
|
|
15
15
|
import { isBucketMemberCollection } from "../utils/collectionProtection";
|
|
16
16
|
const props = defineProps({
|
|
17
|
-
grantsPath: { type: String, required: false
|
|
17
|
+
grantsPath: { type: String, required: false },
|
|
18
18
|
maxCollections: { type: Number, required: false, default: 60 },
|
|
19
19
|
maxUsers: { type: Number, required: false, default: 200 },
|
|
20
20
|
hideHeading: { type: Boolean, required: false, default: false },
|
|
21
21
|
hideRefresh: { type: Boolean, required: false }
|
|
22
22
|
});
|
|
23
23
|
const { t } = useI18n();
|
|
24
|
+
const paths = useMongocampPaths();
|
|
24
25
|
const { listUsers, listRoles, listCollections } = useMongocampAdmin();
|
|
25
26
|
const matrix = ref(null);
|
|
26
27
|
const roleNames = ref([]);
|
|
@@ -269,7 +270,7 @@ defineExpose({ refresh: load });
|
|
|
269
270
|
<NuxtLink
|
|
270
271
|
v-for="roleName in userByName.get(row).roles"
|
|
271
272
|
:key="roleName"
|
|
272
|
-
:to="`${grantsPath}/${roleName}`"
|
|
273
|
+
:to="`${grantsPath ?? paths.roles}/${roleName}`"
|
|
273
274
|
class="rounded bg-elevated px-1.5 py-0.5 text-xs hover:underline"
|
|
274
275
|
:class="userByName.get(row).unknownRoles.includes(roleName) ? 'text-warning' : 'text-dimmed'"
|
|
275
276
|
:title="userByName.get(row).unknownRoles.includes(roleName) ? t('nuxtUiMongocamp.permissionMatrix.unknownRoleNote') : t('nuxtUiMongocamp.permissionMatrix.openRole', { role: roleName })"
|
|
@@ -16,7 +16,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
16
16
|
refresh: typeof load;
|
|
17
17
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
18
18
|
hideHeading: boolean;
|
|
19
|
-
grantsPath: string;
|
|
20
19
|
maxCollections: number;
|
|
21
20
|
maxUsers: number;
|
|
22
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, h, reactive, ref, resolveComponent } from "vue";
|
|
3
|
-
import { useI18n, useMongocampError } from "#imports";
|
|
3
|
+
import { useI18n, useMongocampError, useMongocampPaths } from "#imports";
|
|
4
4
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
5
5
|
import { runBulkDelete } from "../utils/bulkDelete";
|
|
6
6
|
import { createSelectColumn } from "../utils/createSelectColumn";
|
|
@@ -12,6 +12,7 @@ const props = defineProps({
|
|
|
12
12
|
});
|
|
13
13
|
const emit = defineEmits(["changed"]);
|
|
14
14
|
const { t } = useI18n();
|
|
15
|
+
const paths = useMongocampPaths();
|
|
15
16
|
const { listRoles, addRole, updateRole, deleteRole } = useMongocampAdmin();
|
|
16
17
|
const roles = ref([]);
|
|
17
18
|
const loading = ref(false);
|
|
@@ -244,7 +245,7 @@ const columns = computed(() => [
|
|
|
244
245
|
"variant": "ghost",
|
|
245
246
|
"size": "sm",
|
|
246
247
|
"aria-label": t("nuxtUiMongocamp.roles.manageGrantsTooltip"),
|
|
247
|
-
"to":
|
|
248
|
+
"to": `${props.grantsPath || paths.roles}/${row.original.name}`
|
|
248
249
|
})),
|
|
249
250
|
withTooltip(t("nuxtUiMongocamp.roles.editRoleTooltip"), h(UButton, {
|
|
250
251
|
"icon": "i-lucide-pencil",
|
|
@@ -18,10 +18,7 @@ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
|
18
18
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
19
19
|
refresh: () => Promise<void>;
|
|
20
20
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
21
|
-
infoPath: string;
|
|
22
|
-
dataPath: string;
|
|
23
21
|
hideHeading: boolean;
|
|
24
|
-
jobsPath: string;
|
|
25
22
|
autoRefresh: number;
|
|
26
23
|
maxCollections: number;
|
|
27
24
|
topN: number;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
3
|
-
import { useI18n } from "#imports";
|
|
3
|
+
import { useI18n, useMongocampPaths } from "#imports";
|
|
4
4
|
import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
|
|
5
5
|
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
6
6
|
import { useMongocampServerOverview } from "../composables/useMongocampServerOverview";
|
|
7
7
|
import { formatBytes } from "../utils/formatBytes";
|
|
8
8
|
import { BYTE_METRICS, nextJobs, overviewTotals, rankCollections, RANK_METRICS, shareSlices } from "../utils/serverOverview";
|
|
9
9
|
const props = defineProps({
|
|
10
|
-
infoPath: { type: String, required: false
|
|
11
|
-
dataPath: { type: String, required: false
|
|
12
|
-
jobsPath: { type: String, required: false
|
|
10
|
+
infoPath: { type: String, required: false },
|
|
11
|
+
dataPath: { type: String, required: false },
|
|
12
|
+
jobsPath: { type: String, required: false },
|
|
13
13
|
topN: { type: Number, required: false, default: 10 },
|
|
14
14
|
maxCollections: { type: Number, required: false, default: 200 },
|
|
15
15
|
autoRefresh: { type: Number, required: false, default: 0 },
|
|
@@ -18,6 +18,7 @@ const props = defineProps({
|
|
|
18
18
|
hideRefresh: { type: Boolean, required: false }
|
|
19
19
|
});
|
|
20
20
|
const { t, locale } = useI18n();
|
|
21
|
+
const paths = useMongocampPaths();
|
|
21
22
|
const { loadOverview } = useMongocampServerOverview();
|
|
22
23
|
const overview = ref(null);
|
|
23
24
|
const loading = ref(false);
|
|
@@ -274,7 +275,7 @@ defineExpose({ refresh: () => load() });
|
|
|
274
275
|
>
|
|
275
276
|
<span class="w-6 text-right text-dimmed">{{ index + 1 }}</span>
|
|
276
277
|
<NuxtLink
|
|
277
|
-
:to="`${infoPath}/${collection.name}`"
|
|
278
|
+
:to="`${infoPath ?? paths.collections}/${collection.name}`"
|
|
278
279
|
class="min-w-0 flex-1 truncate font-medium hover:underline"
|
|
279
280
|
:aria-label="t('nuxtUiMongocamp.serverOverview.openInfo', { name: collection.name })"
|
|
280
281
|
>
|
|
@@ -286,7 +287,7 @@ defineExpose({ refresh: () => load() });
|
|
|
286
287
|
color="neutral"
|
|
287
288
|
variant="ghost"
|
|
288
289
|
size="xs"
|
|
289
|
-
:to="`${dataPath}/${collection.name}/data`"
|
|
290
|
+
:to="`${dataPath ?? paths.collections}/${collection.name}/data`"
|
|
290
291
|
:aria-label="t('nuxtUiMongocamp.serverOverview.openData', { name: collection.name })"
|
|
291
292
|
/>
|
|
292
293
|
</li>
|
|
@@ -392,7 +393,7 @@ defineExpose({ refresh: () => load() });
|
|
|
392
393
|
<span class="font-semibold">{{ t("nuxtUiMongocamp.serverOverview.jobsTitle") }}</span>
|
|
393
394
|
<UButton
|
|
394
395
|
:label="t('nuxtUiMongocamp.serverOverview.allJobs')"
|
|
395
|
-
:to="jobsPath"
|
|
396
|
+
:to="jobsPath ?? paths.jobs"
|
|
396
397
|
color="neutral"
|
|
397
398
|
variant="link"
|
|
398
399
|
size="xs"
|
|
@@ -18,10 +18,7 @@ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
|
18
18
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
19
19
|
refresh: () => Promise<void>;
|
|
20
20
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
21
|
-
infoPath: string;
|
|
22
|
-
dataPath: string;
|
|
23
21
|
hideHeading: boolean;
|
|
24
|
-
jobsPath: string;
|
|
25
22
|
autoRefresh: number;
|
|
26
23
|
maxCollections: number;
|
|
27
24
|
topN: number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
collapsed?: boolean;
|
|
3
|
+
autoRefresh?: number;
|
|
4
|
+
detailsPath?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
7
|
+
refresh: () => Promise<void>;
|
|
8
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
9
|
+
collapsed: boolean;
|
|
10
|
+
autoRefresh: number;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, onMounted, ref, resolveComponent, watch } from "vue";
|
|
3
|
+
import { useI18n, useMongocampAdminGate, useMongocampAutoRefresh, useMongocampPaths, useMongocampProxyMode, useMongocampRoles, useMongocampStorage, useMongocampSystem } from "#imports";
|
|
4
|
+
import { useNuxtApp } from "#app";
|
|
5
|
+
import { connectionUsage, formatCount, formatUptime } from "../utils/serverInfo";
|
|
6
|
+
import { outcomeOfError, serverHealth } from "../utils/serverStatus";
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
collapsed: { type: Boolean, required: false, default: false },
|
|
9
|
+
autoRefresh: { type: Number, required: false, default: 30 },
|
|
10
|
+
detailsPath: { type: String, required: false }
|
|
11
|
+
});
|
|
12
|
+
const { t } = useI18n();
|
|
13
|
+
const paths = useMongocampPaths();
|
|
14
|
+
const { $mongocampVersion } = useNuxtApp();
|
|
15
|
+
const { getStats, getServerInfo } = useMongocampSystem();
|
|
16
|
+
const { canSeeAdmin } = useMongocampRoles();
|
|
17
|
+
const { blocked } = useMongocampAdminGate();
|
|
18
|
+
const state = useMongocampStorage();
|
|
19
|
+
const isProxyMode = useMongocampProxyMode();
|
|
20
|
+
const server = computed(() => $mongocampVersion.value);
|
|
21
|
+
const mongoDbVersion = ref();
|
|
22
|
+
const connections = ref();
|
|
23
|
+
const uptimeSeconds = ref();
|
|
24
|
+
const outcome = ref({ info: "skipped", stats: "skipped" });
|
|
25
|
+
const canAskInfo = computed(() => isProxyMode || !!state.value?.profile);
|
|
26
|
+
const canAskStats = computed(() => canAskInfo.value && !blocked.value);
|
|
27
|
+
async function refresh() {
|
|
28
|
+
const [info, stats] = await Promise.allSettled([
|
|
29
|
+
canAskInfo.value ? getServerInfo() : Promise.reject(new Error("skipped")),
|
|
30
|
+
canAskStats.value ? getStats() : Promise.reject(new Error("skipped"))
|
|
31
|
+
]);
|
|
32
|
+
mongoDbVersion.value = info.status === "fulfilled" ? info.value.mongoDbVersion || void 0 : void 0;
|
|
33
|
+
const current = stats.status === "fulfilled" ? stats.value.connections?.current : void 0;
|
|
34
|
+
const available = stats.status === "fulfilled" ? stats.value.connections?.available : void 0;
|
|
35
|
+
connections.value = typeof current === "number" && typeof available === "number" ? { current, available } : void 0;
|
|
36
|
+
const uptime = stats.status === "fulfilled" ? stats.value.uptimeSeconds : void 0;
|
|
37
|
+
uptimeSeconds.value = typeof uptime === "number" ? uptime : void 0;
|
|
38
|
+
outcome.value = {
|
|
39
|
+
info: !canAskInfo.value ? "skipped" : info.status === "fulfilled" ? "ok" : outcomeOfError(info.reason),
|
|
40
|
+
stats: !canAskStats.value ? "skipped" : stats.status === "fulfilled" ? "ok" : outcomeOfError(stats.reason)
|
|
41
|
+
};
|
|
42
|
+
if (health.value === "down" && canAskInfo.value) throw info.status === "rejected" ? info.reason : new Error("server unreachable");
|
|
43
|
+
}
|
|
44
|
+
const health = computed(() => serverHealth({ ...outcome.value, hasConnections: !!connections.value, versionKnown: !!server.value }));
|
|
45
|
+
const healthLabel = computed(() => t(`nuxtUiMongocamp.serverStatus.${health.value}`));
|
|
46
|
+
const dotClass = computed(() => ({ ok: "bg-success", partial: "bg-warning", down: "bg-error" })[health.value]);
|
|
47
|
+
const usage = computed(() => connections.value ? connectionUsage(connections.value.current, connections.value.available) : null);
|
|
48
|
+
const versions = computed(() => [
|
|
49
|
+
server.value?.version ? `MongoCamp ${server.value.version}` : void 0,
|
|
50
|
+
mongoDbVersion.value ? `MongoDB ${mongoDbVersion.value}` : void 0
|
|
51
|
+
].filter((entry) => Boolean(entry)));
|
|
52
|
+
const linkTarget = computed(() => canSeeAdmin.value ? props.detailsPath ?? paths.server : "");
|
|
53
|
+
const NuxtLink = resolveComponent("NuxtLink");
|
|
54
|
+
const auto = useMongocampAutoRefresh(refresh, { intervalMs: () => props.autoRefresh * 1e3 });
|
|
55
|
+
function syncAutoRefresh() {
|
|
56
|
+
auto.stop();
|
|
57
|
+
if (props.autoRefresh > 0) auto.start();
|
|
58
|
+
}
|
|
59
|
+
const quietRefresh = () => refresh().catch(() => {
|
|
60
|
+
});
|
|
61
|
+
onMounted(() => {
|
|
62
|
+
quietRefresh();
|
|
63
|
+
syncAutoRefresh();
|
|
64
|
+
});
|
|
65
|
+
watch(() => props.autoRefresh, syncAutoRefresh);
|
|
66
|
+
watch(canAskInfo, quietRefresh);
|
|
67
|
+
defineExpose({ refresh: quietRefresh });
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<template>
|
|
71
|
+
<UTooltip
|
|
72
|
+
v-if="collapsed"
|
|
73
|
+
:text="healthLabel"
|
|
74
|
+
>
|
|
75
|
+
<div
|
|
76
|
+
class="flex justify-center py-1.5"
|
|
77
|
+
role="status"
|
|
78
|
+
:aria-label="healthLabel"
|
|
79
|
+
data-test="server-status"
|
|
80
|
+
:data-health="health"
|
|
81
|
+
>
|
|
82
|
+
<span
|
|
83
|
+
class="size-2.5 rounded-full"
|
|
84
|
+
:class="dotClass"
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
</UTooltip>
|
|
88
|
+
|
|
89
|
+
<component
|
|
90
|
+
:is="linkTarget ? NuxtLink : 'div'"
|
|
91
|
+
v-else
|
|
92
|
+
:to="linkTarget || void 0"
|
|
93
|
+
class="flex flex-col gap-1.5 rounded-md text-xs"
|
|
94
|
+
:class="linkTarget ? 'hover:bg-elevated' : ''"
|
|
95
|
+
:aria-label="linkTarget ? t('nuxtUiMongocamp.serverStatus.details') : void 0"
|
|
96
|
+
data-test="server-status"
|
|
97
|
+
:data-health="health"
|
|
98
|
+
>
|
|
99
|
+
<div
|
|
100
|
+
class="flex items-center gap-2"
|
|
101
|
+
role="status"
|
|
102
|
+
>
|
|
103
|
+
<span
|
|
104
|
+
class="size-2 shrink-0 rounded-full"
|
|
105
|
+
:class="dotClass"
|
|
106
|
+
aria-hidden="true"
|
|
107
|
+
/>
|
|
108
|
+
<span class="truncate font-medium text-highlighted">{{ health === "down" ? healthLabel : server?.name ?? healthLabel }}</span>
|
|
109
|
+
<span class="sr-only">{{ healthLabel }}</span>
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
<div
|
|
113
|
+
v-for="entry in versions"
|
|
114
|
+
:key="entry"
|
|
115
|
+
class="truncate text-muted"
|
|
116
|
+
>
|
|
117
|
+
{{ entry }}
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<template v-if="connections && usage !== null">
|
|
121
|
+
<div class="mt-1 flex items-baseline justify-between gap-2 text-muted">
|
|
122
|
+
<span>{{ t("nuxtUiMongocamp.serverStatus.connections") }}</span>
|
|
123
|
+
<span class="tabular-nums text-default">{{ formatCount(connections.current) }}</span>
|
|
124
|
+
</div>
|
|
125
|
+
<div
|
|
126
|
+
class="h-1 overflow-hidden rounded-full bg-accented"
|
|
127
|
+
role="meter"
|
|
128
|
+
:aria-label="t('nuxtUiMongocamp.serverStatus.connections')"
|
|
129
|
+
aria-valuemin="0"
|
|
130
|
+
aria-valuemax="100"
|
|
131
|
+
:aria-valuenow="usage"
|
|
132
|
+
>
|
|
133
|
+
<div
|
|
134
|
+
class="h-full rounded-full bg-primary"
|
|
135
|
+
:style="{ width: `${Math.max(usage, 2)}%` }"
|
|
136
|
+
/>
|
|
137
|
+
</div>
|
|
138
|
+
</template>
|
|
139
|
+
|
|
140
|
+
<div
|
|
141
|
+
v-if="uptimeSeconds !== void 0"
|
|
142
|
+
class="text-dimmed"
|
|
143
|
+
>
|
|
144
|
+
{{ t("nuxtUiMongocamp.serverStatus.uptime", { time: formatUptime(uptimeSeconds) }) }}
|
|
145
|
+
</div>
|
|
146
|
+
</component>
|
|
147
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
collapsed?: boolean;
|
|
3
|
+
autoRefresh?: number;
|
|
4
|
+
detailsPath?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
7
|
+
refresh: () => Promise<void>;
|
|
8
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
9
|
+
collapsed: boolean;
|
|
10
|
+
autoRefresh: number;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|