@sfxcode/nuxt-ui-mongocamp 1.5.1 → 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 +15 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +25 -4
- package/dist/runtime/assets/formkit.css +1 -0
- package/dist/runtime/components/MongocampAccount.vue +4 -4
- package/dist/runtime/components/MongocampBucketFiles.d.vue.ts +21 -1
- package/dist/runtime/components/MongocampBucketFiles.vue +17 -5
- package/dist/runtime/components/MongocampBucketFiles.vue.d.ts +21 -1
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +22 -2
- package/dist/runtime/components/MongocampCollectionData.vue +31 -9
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +22 -2
- package/dist/runtime/components/MongocampCollectionInfos.vue +12 -12
- package/dist/runtime/components/MongocampCollections.d.vue.ts +19 -1
- package/dist/runtime/components/MongocampCollections.vue +20 -7
- package/dist/runtime/components/MongocampCollections.vue.d.ts +19 -1
- 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 +3 -3
- package/dist/runtime/components/MongocampDashboard.vue +19 -12
- package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -3
- package/dist/runtime/components/MongocampDatabases.d.vue.ts +20 -1
- package/dist/runtime/components/MongocampDatabases.vue +15 -2
- package/dist/runtime/components/MongocampDatabases.vue.d.ts +20 -1
- package/dist/runtime/components/MongocampIndexes.vue +1 -1
- package/dist/runtime/components/MongocampJobs.d.vue.ts +23 -1
- package/dist/runtime/components/MongocampJobs.vue +18 -4
- package/dist/runtime/components/MongocampJobs.vue.d.ts +23 -1
- package/dist/runtime/components/MongocampLogin.d.vue.ts +16 -1
- package/dist/runtime/components/MongocampLogin.vue +13 -5
- package/dist/runtime/components/MongocampLogin.vue.d.ts +16 -1
- package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +19 -2
- package/dist/runtime/components/MongocampPermissionMatrix.vue +15 -6
- package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +19 -2
- package/dist/runtime/components/MongocampRoleGrants.d.vue.ts +22 -1
- package/dist/runtime/components/MongocampRoleGrants.vue +16 -4
- package/dist/runtime/components/MongocampRoleGrants.vue.d.ts +22 -1
- package/dist/runtime/components/MongocampRoles.d.vue.ts +22 -1
- package/dist/runtime/components/MongocampRoles.vue +22 -5
- package/dist/runtime/components/MongocampRoles.vue.d.ts +22 -1
- package/dist/runtime/components/MongocampServerInfo.d.vue.ts +2 -2
- package/dist/runtime/components/MongocampServerInfo.vue +14 -4
- package/dist/runtime/components/MongocampServerInfo.vue.d.ts +2 -2
- package/dist/runtime/components/MongocampServerOverview.d.vue.ts +18 -4
- package/dist/runtime/components/MongocampServerOverview.vue +33 -22
- package/dist/runtime/components/MongocampServerOverview.vue.d.ts +18 -4
- 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/MongocampSettings.d.vue.ts +1 -1
- package/dist/runtime/components/MongocampSettings.vue.d.ts +1 -1
- 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/MongocampUsers.d.vue.ts +24 -1
- package/dist/runtime/components/MongocampUsers.vue +22 -4
- package/dist/runtime/components/MongocampUsers.vue.d.ts +24 -1
- 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/formkit.config.d.ts +3 -0
- package/dist/runtime/formkit.config.js +9 -0
- 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
|
@@ -5,6 +5,11 @@ import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
|
5
5
|
import { runBulkDelete } from "../utils/bulkDelete";
|
|
6
6
|
import { createSelectColumn } from "../utils/createSelectColumn";
|
|
7
7
|
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
8
|
+
defineProps({
|
|
9
|
+
hideHeading: { type: Boolean, required: false },
|
|
10
|
+
hideRefresh: { type: Boolean, required: false }
|
|
11
|
+
});
|
|
12
|
+
const emit = defineEmits(["changed"]);
|
|
8
13
|
const { t } = useI18n();
|
|
9
14
|
const { listUsers, addUser, deleteUser, updateUserRoles, updateUserPassword, listRoles, regenerateUserApiKey } = useMongocampAdmin();
|
|
10
15
|
const toast = useToast();
|
|
@@ -50,7 +55,7 @@ const addUserSchema = reactive([
|
|
|
50
55
|
options: [],
|
|
51
56
|
filter: true,
|
|
52
57
|
class: "h-60",
|
|
53
|
-
transferHeaderClass: "text-sm text-
|
|
58
|
+
transferHeaderClass: "text-sm text-muted font-medium",
|
|
54
59
|
transferAll: true,
|
|
55
60
|
transferLeftHeaderText: t("nuxtUiMongocamp.users.available"),
|
|
56
61
|
transferRightHeaderText: t("nuxtUiMongocamp.users.assigned")
|
|
@@ -72,7 +77,7 @@ const editUserSchema = reactive([
|
|
|
72
77
|
displayMode: "transfer",
|
|
73
78
|
filter: true,
|
|
74
79
|
class: "h-60",
|
|
75
|
-
transferHeaderClass: "text-sm text-
|
|
80
|
+
transferHeaderClass: "text-sm text-muted font-medium",
|
|
76
81
|
options: [],
|
|
77
82
|
transferAll: true,
|
|
78
83
|
transferLeftHeaderText: t("nuxtUiMongocamp.users.available"),
|
|
@@ -100,6 +105,7 @@ async function handleBulkDelete() {
|
|
|
100
105
|
try {
|
|
101
106
|
const { failed } = await runBulkDelete(ids, (id) => deleteUser(id));
|
|
102
107
|
await fetchUsers();
|
|
108
|
+
emit("changed");
|
|
103
109
|
if (failed.length > 0) {
|
|
104
110
|
rowSelection.value = Object.fromEntries(failed.map((f) => [f.item, true]));
|
|
105
111
|
bulkError.value = t("nuxtUiMongocamp.bulk.partialFailure", { failed: failed.length, total: ids.length, reason: describeError(failed[0].error).message });
|
|
@@ -140,6 +146,7 @@ async function handleAddUser() {
|
|
|
140
146
|
isAddModalOpen.value = false;
|
|
141
147
|
newUser.value = { userId: "", password: "", roles: [] };
|
|
142
148
|
await fetchUsers();
|
|
149
|
+
emit("changed");
|
|
143
150
|
} catch (e) {
|
|
144
151
|
errorMessage.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.users.errorAddUser");
|
|
145
152
|
}
|
|
@@ -162,6 +169,7 @@ async function handleEditUser() {
|
|
|
162
169
|
}
|
|
163
170
|
isEditModalOpen.value = false;
|
|
164
171
|
await fetchUsers();
|
|
172
|
+
emit("changed");
|
|
165
173
|
} catch (e) {
|
|
166
174
|
errorMessage.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.users.errorEditUser");
|
|
167
175
|
}
|
|
@@ -180,6 +188,7 @@ async function handleDeleteUser() {
|
|
|
180
188
|
await deleteUser(userToDelete.value);
|
|
181
189
|
isDeleteModalOpen.value = false;
|
|
182
190
|
await fetchUsers();
|
|
191
|
+
emit("changed");
|
|
183
192
|
} catch (e) {
|
|
184
193
|
deleteError.value = (await describeServerError(e, "nuxtUiMongocamp.users.errorDelete")).message;
|
|
185
194
|
} finally {
|
|
@@ -205,6 +214,7 @@ async function handleRegenerateKey() {
|
|
|
205
214
|
try {
|
|
206
215
|
newApiKey.value = await regenerateUserApiKey(keyUser.value);
|
|
207
216
|
await fetchUsers();
|
|
217
|
+
emit("changed");
|
|
208
218
|
} catch (e) {
|
|
209
219
|
keyError.value = (await describeServerError(e)).message;
|
|
210
220
|
} finally {
|
|
@@ -333,6 +343,7 @@ if (!blocked.value) {
|
|
|
333
343
|
fetchUsers();
|
|
334
344
|
fetchRoles();
|
|
335
345
|
}
|
|
346
|
+
defineExpose({ refresh: fetchUsers });
|
|
336
347
|
</script>
|
|
337
348
|
|
|
338
349
|
<template>
|
|
@@ -347,7 +358,10 @@ if (!blocked.value) {
|
|
|
347
358
|
class="flex flex-col gap-4"
|
|
348
359
|
>
|
|
349
360
|
<div class="flex items-center justify-between gap-4">
|
|
350
|
-
<h2
|
|
361
|
+
<h2
|
|
362
|
+
v-if="!hideHeading"
|
|
363
|
+
class="text-xl font-semibold"
|
|
364
|
+
>
|
|
351
365
|
{{ t("nuxtUiMongocamp.users.heading") }}
|
|
352
366
|
</h2>
|
|
353
367
|
<div class="flex flex-1 items-center gap-2">
|
|
@@ -359,7 +373,10 @@ if (!blocked.value) {
|
|
|
359
373
|
class="flex-1 max-w-xs"
|
|
360
374
|
@input="onFilterInput"
|
|
361
375
|
/>
|
|
362
|
-
<UTooltip
|
|
376
|
+
<UTooltip
|
|
377
|
+
v-if="!hideRefresh"
|
|
378
|
+
:text="t('nuxtUiMongocamp.common.refresh')"
|
|
379
|
+
>
|
|
363
380
|
<UButton
|
|
364
381
|
icon="i-lucide-refresh-cw"
|
|
365
382
|
color="neutral"
|
|
@@ -369,6 +386,7 @@ if (!blocked.value) {
|
|
|
369
386
|
@click="fetchUsers"
|
|
370
387
|
/>
|
|
371
388
|
</UTooltip>
|
|
389
|
+
<slot name="toolbar" />
|
|
372
390
|
<UButton
|
|
373
391
|
icon="i-lucide-plus"
|
|
374
392
|
:label="t('nuxtUiMongocamp.users.addUser')"
|
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
hideHeading?: boolean;
|
|
3
|
+
hideRefresh?: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare function fetchUsers(): Promise<void>;
|
|
6
|
+
declare const __VLS_template: () => {
|
|
7
|
+
__VLS_Slots: {
|
|
8
|
+
toolbar?: (props: {}) => any;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
12
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
13
|
+
refresh: typeof fetchUsers;
|
|
14
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
+
changed: () => any;
|
|
16
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
17
|
+
onChanged?: (() => any) | undefined;
|
|
18
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
2
20
|
declare const _default: typeof __VLS_export;
|
|
3
21
|
export default _default;
|
|
22
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
23
|
+
new (): {
|
|
24
|
+
$slots: S;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, ref, watch } from "vue";
|
|
3
|
-
import { useI18n, useMongocampStorage, useMongocampSystem } from "#imports";
|
|
4
|
-
import { useNuxtApp
|
|
3
|
+
import { useI18n, useMongocampProxyMode, useMongocampStorage, useMongocampSystem } from "#imports";
|
|
4
|
+
import { useNuxtApp } from "#app";
|
|
5
5
|
const props = defineProps({
|
|
6
6
|
hideDatabase: { type: Boolean, required: false, default: false }
|
|
7
7
|
});
|
|
@@ -9,7 +9,7 @@ const { t } = useI18n();
|
|
|
9
9
|
const { $mongocampVersion } = useNuxtApp();
|
|
10
10
|
const { getServerInfo } = useMongocampSystem();
|
|
11
11
|
const state = useMongocampStorage();
|
|
12
|
-
const isProxyMode =
|
|
12
|
+
const isProxyMode = useMongocampProxyMode();
|
|
13
13
|
const version = computed(() => $mongocampVersion.value);
|
|
14
14
|
const mongoDbVersion = ref(null);
|
|
15
15
|
const canAsk = computed(() => !props.hideDatabase && (isProxyMode || !!state.value?.profile));
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "#app";
|
|
2
1
|
import { useI18n, useMongocampStorage } from "#imports";
|
|
3
2
|
import { computed } from "vue";
|
|
3
|
+
import { useMongocampProxyMode } from "./useMongocampProxyMode.js";
|
|
4
4
|
export function useMongocampAdminGate() {
|
|
5
|
-
const config = useRuntimeConfig();
|
|
6
5
|
const state = useMongocampStorage();
|
|
7
6
|
const { t } = useI18n();
|
|
8
|
-
const isProxyMode =
|
|
7
|
+
const isProxyMode = useMongocampProxyMode();
|
|
9
8
|
const blocked = computed(() => !isProxyMode && state.value?.profile?.isAdmin === false);
|
|
10
9
|
const message = computed(() => t("nuxtUiMongocamp.common.adminOnly"));
|
|
11
10
|
return { blocked, message };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface MongocampBreadcrumbItem {
|
|
2
|
+
label: string;
|
|
3
|
+
/** Absent on the last item — the current page. */
|
|
4
|
+
to?: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The breadcrumb of the current route among the module's pages (module option `paths`): Home › Collections ›
|
|
9
|
+
* test_customer › Data. Section names follow the locale; a collection, bucket or role name is shown as it is in the URL.
|
|
10
|
+
* A route outside every configured page is just Home. The items fit `UBreadcrumb`'s `items`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useMongocampBreadcrumbs(): import("vue").ComputedRef<MongocampBreadcrumbItem[]>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useI18n, useMongocampPaths, useRoute } from "#imports";
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { buildBreadcrumbs } from "../utils/navigation.js";
|
|
4
|
+
export function useMongocampBreadcrumbs() {
|
|
5
|
+
const { t } = useI18n();
|
|
6
|
+
const paths = useMongocampPaths();
|
|
7
|
+
const route = useRoute();
|
|
8
|
+
return computed(() => buildBreadcrumbs(route.path, paths).map((part) => ({
|
|
9
|
+
label: part.labelKey ? t(part.labelKey) : part.text ?? "",
|
|
10
|
+
...part.to ? { to: part.to } : {},
|
|
11
|
+
...part.icon ? { icon: part.icon } : {}
|
|
12
|
+
})));
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type CollectionNamesStatus = 'idle' | 'loading' | 'ready' | 'failed';
|
|
2
|
+
/**
|
|
3
|
+
* The collection names of the server, **loaded once and shared** by everything that shows them (a sidebar, a panel, a
|
|
4
|
+
* switcher) — a `useState` cache per signed-in user, instead of one `listCollections` request per component. `load()` asks
|
|
5
|
+
* only when nothing is loaded yet, `refresh()` always; neither throws (`status` becomes `failed`, the last list stays).
|
|
6
|
+
* `collections` / `buckets` / `system` are the same list split the usual way (`utils/collectionNames.ts`).
|
|
7
|
+
*
|
|
8
|
+
* `MongocampCollections` writes every list it loads into this cache (`set`), so after a create / drop / rename / copy done
|
|
9
|
+
* there the shared list is current without another request. Code that changes collections elsewhere calls `refresh()`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useMongocampCollectionNames(): {
|
|
12
|
+
names: import("vue").ComputedRef<string[]>;
|
|
13
|
+
collections: import("vue").ComputedRef<string[]>;
|
|
14
|
+
buckets: import("vue").ComputedRef<string[]>;
|
|
15
|
+
system: import("vue").ComputedRef<string[]>;
|
|
16
|
+
status: import("vue").ComputedRef<CollectionNamesStatus>;
|
|
17
|
+
load: (force?: boolean) => Promise<void>;
|
|
18
|
+
refresh: () => Promise<void>;
|
|
19
|
+
set: (loaded: readonly string[]) => void;
|
|
20
|
+
invalidate: () => void;
|
|
21
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useMongocampClientApi, useMongocampStorage, useState } from "#imports";
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { groupCollectionNames } from "../utils/collectionNames.js";
|
|
4
|
+
const REQUEST_TIMEOUT_MS = 15e3;
|
|
5
|
+
let inFlight;
|
|
6
|
+
export function useMongocampCollectionNames() {
|
|
7
|
+
const { collectionApi } = useMongocampClientApi();
|
|
8
|
+
const storage = useMongocampStorage();
|
|
9
|
+
const cache = useState("mongocamp-collection-names", () => ({ user: "", status: "idle", names: [] }));
|
|
10
|
+
const currentUser = () => storage.value?.profile?.user ?? "";
|
|
11
|
+
const own = () => cache.value.user === currentUser();
|
|
12
|
+
const names = computed(() => own() ? cache.value.names : []);
|
|
13
|
+
const status = computed(() => own() ? cache.value.status : "idle");
|
|
14
|
+
const groups = computed(() => groupCollectionNames(names.value));
|
|
15
|
+
const collections = computed(() => groups.value.collections);
|
|
16
|
+
const buckets = computed(() => groups.value.buckets);
|
|
17
|
+
const system = computed(() => groups.value.system);
|
|
18
|
+
async function load(force = false) {
|
|
19
|
+
const user = currentUser();
|
|
20
|
+
if (inFlight?.user === user) return inFlight.run;
|
|
21
|
+
if (!force && own() && cache.value.status === "ready") return;
|
|
22
|
+
const previous = own() ? cache.value.names : [];
|
|
23
|
+
cache.value = { user, status: "loading", names: previous };
|
|
24
|
+
const flight = { user, run: Promise.resolve() };
|
|
25
|
+
inFlight = flight;
|
|
26
|
+
flight.run = (async () => {
|
|
27
|
+
try {
|
|
28
|
+
const loaded = await collectionApi.listCollections({ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
|
|
29
|
+
if (currentUser() === user) cache.value = { user, status: "ready", names: [...loaded] };
|
|
30
|
+
} catch {
|
|
31
|
+
if (currentUser() === user) cache.value = { user, status: "failed", names: previous };
|
|
32
|
+
} finally {
|
|
33
|
+
if (inFlight === flight) inFlight = void 0;
|
|
34
|
+
}
|
|
35
|
+
})();
|
|
36
|
+
return flight.run;
|
|
37
|
+
}
|
|
38
|
+
const refresh = () => load(true);
|
|
39
|
+
function set(loaded) {
|
|
40
|
+
cache.value = { user: currentUser(), status: "ready", names: [...loaded] };
|
|
41
|
+
}
|
|
42
|
+
function invalidate() {
|
|
43
|
+
cache.value = { user: currentUser(), status: "idle", names: [] };
|
|
44
|
+
}
|
|
45
|
+
return { names, collections, buckets, system, status, load, refresh, set, invalidate };
|
|
46
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { NavigationGroup } from '../utils/navigation.js';
|
|
2
|
+
import type { MongocampPaths } from '../utils/paths.js';
|
|
3
|
+
export interface MongocampNavigationItem {
|
|
4
|
+
/** Stable id of the page — its key in the module's `paths` option. */
|
|
5
|
+
key: keyof MongocampPaths;
|
|
6
|
+
label: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
to: string;
|
|
9
|
+
exact?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface MongocampNavigationGroup {
|
|
12
|
+
key: NavigationGroup['key'];
|
|
13
|
+
label?: string;
|
|
14
|
+
items: MongocampNavigationItem[];
|
|
15
|
+
}
|
|
16
|
+
type MenuRow = MongocampNavigationItem | {
|
|
17
|
+
type: 'label';
|
|
18
|
+
label: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The module's pages as role-aware navigation data, from the module option `paths`: Home and Account for everyone (no
|
|
22
|
+
* Account in server proxy mode), the admin pages in three groups (data, access, server) for whoever may see them
|
|
23
|
+
* (`canSeeAdmin`). Labels follow the current locale.
|
|
24
|
+
*
|
|
25
|
+
* `groups` is the plain structure; `menu` is the same in the shape `UNavigationMenu`'s `items` takes (one array per group,
|
|
26
|
+
* a `{ type: 'label' }` row first where the group has a label). Add your own pages by spreading either.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useMongocampNavigation(): {
|
|
29
|
+
groups: import("vue").ComputedRef<MongocampNavigationGroup[]>;
|
|
30
|
+
menu: import("vue").ComputedRef<MenuRow[][]>;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useI18n, useMongocampPaths, useMongocampRoles } from "#imports";
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { buildNavigation } from "../utils/navigation.js";
|
|
4
|
+
export function useMongocampNavigation() {
|
|
5
|
+
const { t } = useI18n();
|
|
6
|
+
const paths = useMongocampPaths();
|
|
7
|
+
const { canSeeAdmin, isProxyMode } = useMongocampRoles();
|
|
8
|
+
const groups = computed(() => buildNavigation(paths, { canSeeAdmin: canSeeAdmin.value, isProxyMode }).map((group) => ({
|
|
9
|
+
key: group.key,
|
|
10
|
+
...group.labelKey ? { label: t(group.labelKey) } : {},
|
|
11
|
+
items: group.items.map(({ labelKey, ...item }) => ({ ...item, label: t(labelKey) }))
|
|
12
|
+
})));
|
|
13
|
+
const menu = computed(() => groups.value.map((group) => [...group.label ? [{ type: "label", label: group.label }] : [], ...group.items]));
|
|
14
|
+
return { groups, menu };
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MongocampPaths } from '../utils/paths.js';
|
|
2
|
+
/**
|
|
3
|
+
* The base routes of the app's MongoCamp pages (module option `paths`, defaults `/secured/admin/...`). Every `*Path` prop of
|
|
4
|
+
* the components falls back to these, so an app with other routes sets them once. Use it for your own links as well.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useMongocampPaths(): MongocampPaths;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "#app";
|
|
2
1
|
import { useMongocampClientApi, useMongocampStorage, useState } from "#imports";
|
|
3
2
|
import { permissionFromGrants } from "../utils/grantMatching.js";
|
|
3
|
+
import { useMongocampProxyMode } from "./useMongocampProxyMode.js";
|
|
4
4
|
const REQUEST_TIMEOUT_MS = 15e3;
|
|
5
5
|
export function useMongocampPermissions() {
|
|
6
|
-
const config = useRuntimeConfig();
|
|
7
6
|
const state = useMongocampStorage();
|
|
8
7
|
const cache = useState("mongocamp-permissions", () => ({ user: "", byName: {} }));
|
|
9
|
-
const isProxyMode =
|
|
8
|
+
const isProxyMode = useMongocampProxyMode();
|
|
10
9
|
const currentUser = () => state.value?.profile?.user ?? "";
|
|
11
10
|
const key = (name) => name.trim().toLowerCase();
|
|
12
11
|
function fromServer(collectionName) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `true` when the module runs in server proxy mode (module option `useServerProxy`): there is no login and no profile, the
|
|
3
|
+
* server-side api key decides what is allowed. A plain boolean — the option is fixed at build time.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useMongocampProxyMode(): boolean;
|
|
@@ -2,6 +2,9 @@ export declare function useMongocampRoles(): {
|
|
|
2
2
|
isLoggedIn: import("vue").ComputedRef<boolean>;
|
|
3
3
|
isAdmin: import("vue").ComputedRef<boolean>;
|
|
4
4
|
isManager: import("vue").ComputedRef<boolean>;
|
|
5
|
+
isProxyMode: boolean;
|
|
6
|
+
canSeeAdmin: import("vue").ComputedRef<boolean>;
|
|
7
|
+
canSeeManagement: import("vue").ComputedRef<boolean>;
|
|
5
8
|
notAllowedPath: string;
|
|
6
9
|
logoutRedirectPath: string;
|
|
7
10
|
logoutPath: string;
|
|
@@ -2,6 +2,7 @@ import { useRuntimeConfig } from "#app";
|
|
|
2
2
|
import { minimatch } from "minimatch";
|
|
3
3
|
import { useMongocampAuth, useMongocampStorage } from "#imports";
|
|
4
4
|
import { computed } from "vue";
|
|
5
|
+
import { useMongocampProxyMode } from "./useMongocampProxyMode.js";
|
|
5
6
|
export function useMongocampRoles() {
|
|
6
7
|
const config = useRuntimeConfig();
|
|
7
8
|
const { isLoggedIn } = useMongocampAuth();
|
|
@@ -20,6 +21,9 @@ export function useMongocampRoles() {
|
|
|
20
21
|
return allowedRoles.some((role) => roles.value.includes(role));
|
|
21
22
|
}
|
|
22
23
|
const isManager = computed(() => isAdmin.value || matchesAnyRole(managerRoles));
|
|
24
|
+
const isProxyMode = useMongocampProxyMode();
|
|
25
|
+
const canSeeAdmin = computed(() => isProxyMode || isAdmin.value);
|
|
26
|
+
const canSeeManagement = computed(() => isProxyMode || isManager.value);
|
|
23
27
|
function matchesAnyPattern(route, patterns) {
|
|
24
28
|
return patterns.some((pattern) => minimatch(route, pattern) || minimatch(`${route}/`, pattern));
|
|
25
29
|
}
|
|
@@ -36,5 +40,5 @@ export function useMongocampRoles() {
|
|
|
36
40
|
}
|
|
37
41
|
return true;
|
|
38
42
|
}
|
|
39
|
-
return { isLoggedIn, isAdmin, isManager, notAllowedPath, logoutRedirectPath, logoutPath, loginPath, isAllowedPathForRoute };
|
|
43
|
+
return { isLoggedIn, isAdmin, isManager, isProxyMode, canSeeAdmin, canSeeManagement, notAllowedPath, logoutRedirectPath, logoutPath, loginPath, isAllowedPathForRoute };
|
|
40
44
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "#app";
|
|
2
1
|
import { useMongocampAuth, useMongocampClientApi, useMongocampStorage } from "#imports";
|
|
3
2
|
import { tokenExpiryState } from "../utils/jwtExpiry.js";
|
|
3
|
+
import { useMongocampProxyMode } from "./useMongocampProxyMode.js";
|
|
4
4
|
const VERIFY_TIMEOUT_MS = 15e3;
|
|
5
5
|
export function useMongocampSession() {
|
|
6
|
-
const config = useRuntimeConfig();
|
|
7
6
|
const { logout } = useMongocampAuth();
|
|
8
7
|
const storage = useMongocampStorage();
|
|
9
8
|
const { authApi } = useMongocampClientApi();
|
|
10
|
-
const isProxyMode =
|
|
9
|
+
const isProxyMode = useMongocampProxyMode();
|
|
11
10
|
function checkExpiry() {
|
|
12
11
|
if (isProxyMode) return "unknown";
|
|
13
12
|
const token = storage.value?.token;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { nuxtUIInputs, nuxtUIOutputs } from "@sfxcode/nuxt-ui-formkit/definitions";
|
|
2
|
+
import { addNuxtAsteriskPlugin } from "@sfxcode/nuxt-ui-formkit/plugins";
|
|
3
|
+
const config = {
|
|
4
|
+
inputs: { ...nuxtUIInputs, ...nuxtUIOutputs },
|
|
5
|
+
// The module's forms use Nuxt UI icons, not FormKit's own icon set
|
|
6
|
+
iconLoader: () => void 0,
|
|
7
|
+
plugins: [addNuxtAsteriskPlugin]
|
|
8
|
+
};
|
|
9
|
+
export default config;
|
|
@@ -1072,6 +1072,48 @@
|
|
|
1072
1072
|
"ariaDescription": "{count} Werte der angezeigten Ergebnisseite",
|
|
1073
1073
|
"cut": "Nur die ersten {max} Zeilen dieser Seite werden dargestellt.",
|
|
1074
1074
|
"skipped": "{count} Zeilen ohne Zahl wurden ausgelassen."
|
|
1075
|
+
},
|
|
1076
|
+
"navigation": {
|
|
1077
|
+
"home": "Start",
|
|
1078
|
+
"account": "Konto",
|
|
1079
|
+
"collections": "Collections",
|
|
1080
|
+
"buckets": "Buckets",
|
|
1081
|
+
"databases": "Datenbanken",
|
|
1082
|
+
"jobs": "Jobs",
|
|
1083
|
+
"users": "Benutzer",
|
|
1084
|
+
"roles": "Rollen",
|
|
1085
|
+
"permissions": "Berechtigungen",
|
|
1086
|
+
"overview": "Übersicht",
|
|
1087
|
+
"server": "Server",
|
|
1088
|
+
"settings": "Einstellungen",
|
|
1089
|
+
"data": "Daten",
|
|
1090
|
+
"aggregate": "Aggregation",
|
|
1091
|
+
"groupData": "Daten",
|
|
1092
|
+
"groupAccess": "Zugriff",
|
|
1093
|
+
"groupServer": "Server"
|
|
1094
|
+
},
|
|
1095
|
+
"serverStatus": {
|
|
1096
|
+
"ok": "Server erreichbar",
|
|
1097
|
+
"partial": "Server erreichbar, einige Angaben fehlen",
|
|
1098
|
+
"down": "Server nicht erreichbar",
|
|
1099
|
+
"connections": "Verbindungen",
|
|
1100
|
+
"uptime": "Läuft seit {time}",
|
|
1101
|
+
"details": "Details zum Serverstatus"
|
|
1102
|
+
},
|
|
1103
|
+
"userAccess": {
|
|
1104
|
+
"heading": "Ihr Zugriff",
|
|
1105
|
+
"collections": "Collections",
|
|
1106
|
+
"canRead": "Lesbar",
|
|
1107
|
+
"canWrite": "Schreibbar",
|
|
1108
|
+
"canAdministrate": "Verwaltbar",
|
|
1109
|
+
"collection": "Collection",
|
|
1110
|
+
"read": "Lesen",
|
|
1111
|
+
"write": "Schreiben",
|
|
1112
|
+
"administrate": "Verwalten",
|
|
1113
|
+
"emptyTitle": "Noch keine Collections",
|
|
1114
|
+
"emptyDescription": "Ihnen wurde noch keine Collection freigegeben. Bitten Sie einen Administrator um Zugriff.",
|
|
1115
|
+
"adminTitle": "Sie sind Administrator",
|
|
1116
|
+
"adminDescription": "Administratoren dürfen jede Collection lesen, schreiben und verwalten."
|
|
1075
1117
|
}
|
|
1076
1118
|
}
|
|
1077
1119
|
}
|
|
@@ -1072,6 +1072,48 @@
|
|
|
1072
1072
|
"ariaDescription": "{count} values from the shown page of the result",
|
|
1073
1073
|
"cut": "Only the first {max} rows of this page are charted.",
|
|
1074
1074
|
"skipped": "{count} rows without a number were left out."
|
|
1075
|
+
},
|
|
1076
|
+
"navigation": {
|
|
1077
|
+
"home": "Home",
|
|
1078
|
+
"account": "Account",
|
|
1079
|
+
"collections": "Collections",
|
|
1080
|
+
"buckets": "Buckets",
|
|
1081
|
+
"databases": "Databases",
|
|
1082
|
+
"jobs": "Jobs",
|
|
1083
|
+
"users": "Users",
|
|
1084
|
+
"roles": "Roles",
|
|
1085
|
+
"permissions": "Permissions",
|
|
1086
|
+
"overview": "Overview",
|
|
1087
|
+
"server": "Server",
|
|
1088
|
+
"settings": "Settings",
|
|
1089
|
+
"data": "Data",
|
|
1090
|
+
"aggregate": "Aggregate",
|
|
1091
|
+
"groupData": "Data",
|
|
1092
|
+
"groupAccess": "Access",
|
|
1093
|
+
"groupServer": "Server"
|
|
1094
|
+
},
|
|
1095
|
+
"serverStatus": {
|
|
1096
|
+
"ok": "Server reachable",
|
|
1097
|
+
"partial": "Server reachable, some details unavailable",
|
|
1098
|
+
"down": "Server not reachable",
|
|
1099
|
+
"connections": "Connections",
|
|
1100
|
+
"uptime": "Up {time}",
|
|
1101
|
+
"details": "Server status details"
|
|
1102
|
+
},
|
|
1103
|
+
"userAccess": {
|
|
1104
|
+
"heading": "Your access",
|
|
1105
|
+
"collections": "Collections",
|
|
1106
|
+
"canRead": "Can read",
|
|
1107
|
+
"canWrite": "Can write",
|
|
1108
|
+
"canAdministrate": "Can administrate",
|
|
1109
|
+
"collection": "Collection",
|
|
1110
|
+
"read": "Read",
|
|
1111
|
+
"write": "Write",
|
|
1112
|
+
"administrate": "Administrate",
|
|
1113
|
+
"emptyTitle": "No collections yet",
|
|
1114
|
+
"emptyDescription": "No collection has been granted to you. Ask an administrator for access.",
|
|
1115
|
+
"adminTitle": "You are an administrator",
|
|
1116
|
+
"adminDescription": "Administrators may read, write and administrate every collection."
|
|
1075
1117
|
}
|
|
1076
1118
|
}
|
|
1077
1119
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { formatBytes } from './utils/formatBytes.js';
|
|
2
|
+
export { connectionUsage, formatCount, formatUptime } from './utils/serverInfo.js';
|
|
3
|
+
export { groupCollectionNames } from './utils/collectionNames.js';
|
|
4
|
+
export { bucketNameOf, isBucketMemberCollection, isProtectedCollection } from './utils/collectionProtection.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { formatBytes } from "./utils/formatBytes.js";
|
|
2
|
+
export { connectionUsage, formatCount, formatUptime } from "./utils/serverInfo.js";
|
|
3
|
+
export { groupCollectionNames } from "./utils/collectionNames.js";
|
|
4
|
+
export { bucketNameOf, isBucketMemberCollection, isProtectedCollection } from "./utils/collectionProtection.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CollectionNameGroups {
|
|
2
|
+
/** Ordinary collections: not MongoCamp's own, not half of a GridFS bucket. */
|
|
3
|
+
collections: string[];
|
|
4
|
+
/** GridFS bucket names (`images` for `images.files` / `images.chunks`), each once. */
|
|
5
|
+
buckets: string[];
|
|
6
|
+
/** MongoCamp's own `mc_*` collections. */
|
|
7
|
+
system: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Splits a collection list the way every navigation shows it. Each group is sorted and free of duplicates; a `mc_*` name is
|
|
11
|
+
* always `system`, also when it looks like a bucket half. A bucket is listed when either of its halves is present.
|
|
12
|
+
*/
|
|
13
|
+
export declare function groupCollectionNames(names: readonly string[]): CollectionNameGroups;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { bucketNameOf, isBucketMemberCollection } from "./collectionProtection.js";
|
|
2
|
+
export function groupCollectionNames(names) {
|
|
3
|
+
const collections = /* @__PURE__ */ new Set();
|
|
4
|
+
const buckets = /* @__PURE__ */ new Set();
|
|
5
|
+
const system = /* @__PURE__ */ new Set();
|
|
6
|
+
for (const name of names) {
|
|
7
|
+
if (typeof name !== "string" || !name) continue;
|
|
8
|
+
if (name.startsWith("mc_")) system.add(name);
|
|
9
|
+
else if (isBucketMemberCollection(name)) buckets.add(bucketNameOf(name));
|
|
10
|
+
else collections.add(name);
|
|
11
|
+
}
|
|
12
|
+
const sorted = (set) => [...set].sort((a, b) => a.localeCompare(b));
|
|
13
|
+
return { collections: sorted(collections), buckets: sorted(buckets), system: sorted(system) };
|
|
14
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const BUCKET_COLLECTION_SUFFIX: RegExp;
|
|
2
2
|
export declare function isBucketMemberCollection(collectionName: string): boolean;
|
|
3
|
+
/** `fs` for `fs.files` / `fs.chunks`; `null` for a collection that is not half of a GridFS bucket. */
|
|
4
|
+
export declare function bucketNameOf(collectionName: string): string | null;
|
|
3
5
|
export declare function isProtectedCollection(collectionName: string): boolean;
|
|
@@ -2,6 +2,9 @@ export const BUCKET_COLLECTION_SUFFIX = /\.(?:files|chunks)$/;
|
|
|
2
2
|
export function isBucketMemberCollection(collectionName) {
|
|
3
3
|
return BUCKET_COLLECTION_SUFFIX.test(collectionName);
|
|
4
4
|
}
|
|
5
|
+
export function bucketNameOf(collectionName) {
|
|
6
|
+
return isBucketMemberCollection(collectionName) ? collectionName.replace(BUCKET_COLLECTION_SUFFIX, "") : null;
|
|
7
|
+
}
|
|
5
8
|
export function isProtectedCollection(collectionName) {
|
|
6
9
|
return collectionName.startsWith("mc_") || isBucketMemberCollection(collectionName);
|
|
7
10
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MongocampPaths } from './paths.js';
|
|
2
|
+
export interface NavigationEntry {
|
|
3
|
+
/** Stable id of the page — also its key in the module's `paths` option. */
|
|
4
|
+
key: keyof MongocampPaths;
|
|
5
|
+
labelKey: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
to: string;
|
|
8
|
+
/** Highlight only on the exact route (the home page, whose path is a prefix of every other). */
|
|
9
|
+
exact?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface NavigationGroup {
|
|
12
|
+
key: 'main' | 'data' | 'access' | 'server';
|
|
13
|
+
/** No label for the first group. */
|
|
14
|
+
labelKey?: string;
|
|
15
|
+
items: NavigationEntry[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The module's pages as navigation groups. Everyone gets Home and Account (no account in server proxy mode — nobody is
|
|
19
|
+
* logged in); the admin pages come in three groups for whoever may see them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildNavigation(paths: MongocampPaths, who: {
|
|
22
|
+
canSeeAdmin: boolean;
|
|
23
|
+
isProxyMode: boolean;
|
|
24
|
+
}): NavigationGroup[];
|
|
25
|
+
export interface BreadcrumbPart {
|
|
26
|
+
/** A translation key … */
|
|
27
|
+
labelKey?: string;
|
|
28
|
+
/** … or a name taken from the URL (a collection, a bucket, a role), shown as it is. */
|
|
29
|
+
text?: string;
|
|
30
|
+
/** Absent on the last part: that is the current page. */
|
|
31
|
+
to?: string;
|
|
32
|
+
icon?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Where a route sits among the module's pages: Home › Collections › test_customer › Data. The section is the `paths` entry
|
|
36
|
+
* that is the longest prefix of the route; a route outside every section is just Home. Buckets have no list page of their
|
|
37
|
+
* own, so that part links to the collections list. The last part carries no link.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildBreadcrumbs(routePath: string, paths: MongocampPaths): BreadcrumbPart[];
|