@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
|
@@ -1,21 +1,24 @@
|
|
|
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 },
|
|
16
|
-
hideCharts: { type: Boolean, required: false, default: false }
|
|
16
|
+
hideCharts: { type: Boolean, required: false, default: false },
|
|
17
|
+
hideHeading: { type: Boolean, required: false, default: false },
|
|
18
|
+
hideRefresh: { type: Boolean, required: false }
|
|
17
19
|
});
|
|
18
20
|
const { t, locale } = useI18n();
|
|
21
|
+
const paths = useMongocampPaths();
|
|
19
22
|
const { loadOverview } = useMongocampServerOverview();
|
|
20
23
|
const overview = ref(null);
|
|
21
24
|
const loading = ref(false);
|
|
@@ -77,6 +80,7 @@ const failedNames = computed(() => {
|
|
|
77
80
|
});
|
|
78
81
|
const seriesSize = computed(() => [{ key: "value", label: t("nuxtUiMongocamp.serverOverview.seriesSize") }]);
|
|
79
82
|
const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]);
|
|
83
|
+
defineExpose({ refresh: () => load() });
|
|
80
84
|
</script>
|
|
81
85
|
|
|
82
86
|
<template>
|
|
@@ -92,7 +96,10 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
92
96
|
data-test="server-overview"
|
|
93
97
|
>
|
|
94
98
|
<div class="flex flex-wrap items-start justify-between gap-2">
|
|
95
|
-
<div
|
|
99
|
+
<div
|
|
100
|
+
v-if="!hideHeading"
|
|
101
|
+
class="flex flex-col gap-1"
|
|
102
|
+
>
|
|
96
103
|
<h2 class="text-xl font-semibold">
|
|
97
104
|
{{ t("nuxtUiMongocamp.serverOverview.heading") }}
|
|
98
105
|
</h2>
|
|
@@ -100,14 +107,18 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
100
107
|
{{ t("nuxtUiMongocamp.serverOverview.subtitle") }}
|
|
101
108
|
</p>
|
|
102
109
|
</div>
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
<div class="ml-auto flex items-center gap-1">
|
|
111
|
+
<UButton
|
|
112
|
+
v-if="!hideRefresh"
|
|
113
|
+
icon="i-lucide-refresh-cw"
|
|
114
|
+
color="neutral"
|
|
115
|
+
variant="ghost"
|
|
116
|
+
:loading="loading"
|
|
117
|
+
:aria-label="t('nuxtUiMongocamp.common.refresh')"
|
|
118
|
+
@click="load()"
|
|
119
|
+
/>
|
|
120
|
+
<slot name="toolbar" />
|
|
121
|
+
</div>
|
|
111
122
|
</div>
|
|
112
123
|
|
|
113
124
|
<UAlert
|
|
@@ -137,7 +148,7 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
137
148
|
{{ t("nuxtUiMongocamp.serverOverview.statDatabases") }}
|
|
138
149
|
</div>
|
|
139
150
|
<div
|
|
140
|
-
class="text-2xl font-semibold"
|
|
151
|
+
class="tabular-nums text-2xl font-semibold"
|
|
141
152
|
data-test="stat-databases"
|
|
142
153
|
>
|
|
143
154
|
{{ overview.databases ? totals.databases : "\u2014" }}
|
|
@@ -154,7 +165,7 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
154
165
|
{{ t("nuxtUiMongocamp.serverOverview.statCollections") }}
|
|
155
166
|
</div>
|
|
156
167
|
<div
|
|
157
|
-
class="text-2xl font-semibold"
|
|
168
|
+
class="tabular-nums text-2xl font-semibold"
|
|
158
169
|
data-test="stat-collections"
|
|
159
170
|
>
|
|
160
171
|
{{ number(overview.collectionCount) }}
|
|
@@ -165,7 +176,7 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
165
176
|
{{ t("nuxtUiMongocamp.serverOverview.statDocuments") }}
|
|
166
177
|
</div>
|
|
167
178
|
<div
|
|
168
|
-
class="text-2xl font-semibold"
|
|
179
|
+
class="tabular-nums text-2xl font-semibold"
|
|
169
180
|
data-test="stat-documents"
|
|
170
181
|
>
|
|
171
182
|
{{ number(totals.documents) }}
|
|
@@ -176,7 +187,7 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
176
187
|
{{ t("nuxtUiMongocamp.serverOverview.statStorage") }}
|
|
177
188
|
</div>
|
|
178
189
|
<div
|
|
179
|
-
class="text-2xl font-semibold"
|
|
190
|
+
class="tabular-nums text-2xl font-semibold"
|
|
180
191
|
data-test="stat-storage"
|
|
181
192
|
>
|
|
182
193
|
{{ formatBytes(totals.storageBytes) }}
|
|
@@ -187,7 +198,7 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
187
198
|
{{ t("nuxtUiMongocamp.serverOverview.statIndexes") }}
|
|
188
199
|
</div>
|
|
189
200
|
<div
|
|
190
|
-
class="text-2xl font-semibold"
|
|
201
|
+
class="tabular-nums text-2xl font-semibold"
|
|
191
202
|
data-test="stat-indexes"
|
|
192
203
|
>
|
|
193
204
|
{{ formatBytes(totals.indexBytes) }}
|
|
@@ -264,7 +275,7 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
264
275
|
>
|
|
265
276
|
<span class="w-6 text-right text-dimmed">{{ index + 1 }}</span>
|
|
266
277
|
<NuxtLink
|
|
267
|
-
:to="`${infoPath}/${collection.name}`"
|
|
278
|
+
:to="`${infoPath ?? paths.collections}/${collection.name}`"
|
|
268
279
|
class="min-w-0 flex-1 truncate font-medium hover:underline"
|
|
269
280
|
:aria-label="t('nuxtUiMongocamp.serverOverview.openInfo', { name: collection.name })"
|
|
270
281
|
>
|
|
@@ -276,7 +287,7 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
276
287
|
color="neutral"
|
|
277
288
|
variant="ghost"
|
|
278
289
|
size="xs"
|
|
279
|
-
:to="`${dataPath}/${collection.name}/data`"
|
|
290
|
+
:to="`${dataPath ?? paths.collections}/${collection.name}/data`"
|
|
280
291
|
:aria-label="t('nuxtUiMongocamp.serverOverview.openData', { name: collection.name })"
|
|
281
292
|
/>
|
|
282
293
|
</li>
|
|
@@ -382,7 +393,7 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
382
393
|
<span class="font-semibold">{{ t("nuxtUiMongocamp.serverOverview.jobsTitle") }}</span>
|
|
383
394
|
<UButton
|
|
384
395
|
:label="t('nuxtUiMongocamp.serverOverview.allJobs')"
|
|
385
|
-
:to="jobsPath"
|
|
396
|
+
:to="jobsPath ?? paths.jobs"
|
|
386
397
|
color="neutral"
|
|
387
398
|
variant="link"
|
|
388
399
|
size="xs"
|
|
@@ -6,15 +6,29 @@ type __VLS_Props = {
|
|
|
6
6
|
maxCollections?: number;
|
|
7
7
|
autoRefresh?: number;
|
|
8
8
|
hideCharts?: boolean;
|
|
9
|
+
hideHeading?: boolean;
|
|
10
|
+
hideRefresh?: boolean;
|
|
9
11
|
};
|
|
10
|
-
declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
declare const __VLS_template: () => {
|
|
13
|
+
__VLS_Slots: {
|
|
14
|
+
toolbar?: (props: {}) => any;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
18
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
19
|
+
refresh: () => Promise<void>;
|
|
20
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
21
|
+
hideHeading: boolean;
|
|
14
22
|
autoRefresh: number;
|
|
15
23
|
maxCollections: number;
|
|
16
24
|
topN: number;
|
|
17
25
|
hideCharts: boolean;
|
|
18
26
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
19
28
|
declare const _default: typeof __VLS_export;
|
|
20
29
|
export default _default;
|
|
30
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
31
|
+
new (): {
|
|
32
|
+
$slots: S;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -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;
|
|
@@ -17,8 +17,8 @@ type __VLS_Props = {
|
|
|
17
17
|
hideGrantHint?: boolean;
|
|
18
18
|
};
|
|
19
19
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
20
|
-
hideHeading: boolean;
|
|
21
20
|
hideRefresh: boolean;
|
|
21
|
+
hideHeading: boolean;
|
|
22
22
|
hidePlugins: boolean;
|
|
23
23
|
hideCluster: boolean;
|
|
24
24
|
hideConfigurations: boolean;
|
|
@@ -17,8 +17,8 @@ type __VLS_Props = {
|
|
|
17
17
|
hideGrantHint?: boolean;
|
|
18
18
|
};
|
|
19
19
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
20
|
-
hideHeading: boolean;
|
|
21
20
|
hideRefresh: boolean;
|
|
21
|
+
hideHeading: boolean;
|
|
22
22
|
hidePlugins: boolean;
|
|
23
23
|
hideCluster: boolean;
|
|
24
24
|
hideConfigurations: boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
hideHeading?: boolean;
|
|
3
|
+
hideRefresh?: boolean;
|
|
4
|
+
hideStats?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare function refresh(): Promise<void>;
|
|
7
|
+
declare const __VLS_template: () => {
|
|
8
|
+
__VLS_Slots: {
|
|
9
|
+
toolbar?: (props: {}) => any;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
13
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
14
|
+
refresh: typeof refresh;
|
|
15
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
16
|
+
hideRefresh: boolean;
|
|
17
|
+
hideHeading: boolean;
|
|
18
|
+
hideStats: 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
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import { useI18n, useMongocampClientApi, useMongocampStorage } from "#imports";
|
|
4
|
+
defineProps({
|
|
5
|
+
hideHeading: { type: Boolean, required: false, default: false },
|
|
6
|
+
hideRefresh: { type: Boolean, required: false, default: false },
|
|
7
|
+
hideStats: { type: Boolean, required: false, default: false }
|
|
8
|
+
});
|
|
9
|
+
const FLAGS = ["read", "write", "administrate"];
|
|
10
|
+
const { t } = useI18n();
|
|
11
|
+
const { authApi } = useMongocampClientApi();
|
|
12
|
+
const state = useMongocampStorage();
|
|
13
|
+
const isAdmin = computed(() => state.value?.profile?.isAdmin === true);
|
|
14
|
+
const access = ref([]);
|
|
15
|
+
const loading = ref(false);
|
|
16
|
+
const loadError = ref(null);
|
|
17
|
+
async function refresh() {
|
|
18
|
+
if (isAdmin.value) return;
|
|
19
|
+
loading.value = true;
|
|
20
|
+
loadError.value = null;
|
|
21
|
+
try {
|
|
22
|
+
const rows = await authApi.userPermissions({}, { signal: AbortSignal.timeout(15e3) });
|
|
23
|
+
access.value = rows.filter((row) => !row.name.startsWith("mc_")).map((row) => ({ name: row.name, read: row.read === true, write: row.write === true, administrate: row.administrate === true })).sort((a, b) => a.name.localeCompare(b.name));
|
|
24
|
+
} catch (e) {
|
|
25
|
+
loadError.value = e;
|
|
26
|
+
access.value = [];
|
|
27
|
+
} finally {
|
|
28
|
+
loading.value = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const stats = computed(() => [
|
|
32
|
+
{ key: "collections", label: t("nuxtUiMongocamp.userAccess.collections"), icon: "i-lucide-database", value: access.value.length },
|
|
33
|
+
{ key: "read", label: t("nuxtUiMongocamp.userAccess.canRead"), icon: "i-lucide-eye", value: access.value.filter((r) => r.read).length },
|
|
34
|
+
{ key: "write", label: t("nuxtUiMongocamp.userAccess.canWrite"), icon: "i-lucide-pencil", value: access.value.filter((r) => r.write).length },
|
|
35
|
+
{ key: "administrate", label: t("nuxtUiMongocamp.userAccess.canAdministrate"), icon: "i-lucide-shield-check", value: access.value.filter((r) => r.administrate).length }
|
|
36
|
+
]);
|
|
37
|
+
defineExpose({ refresh });
|
|
38
|
+
refresh();
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<div class="flex flex-col gap-6">
|
|
43
|
+
<div
|
|
44
|
+
v-if="!hideHeading || !hideRefresh || $slots.toolbar"
|
|
45
|
+
class="flex items-center justify-between gap-2"
|
|
46
|
+
>
|
|
47
|
+
<h2
|
|
48
|
+
v-if="!hideHeading"
|
|
49
|
+
class="text-lg font-semibold"
|
|
50
|
+
>
|
|
51
|
+
{{ t("nuxtUiMongocamp.userAccess.heading") }}
|
|
52
|
+
</h2>
|
|
53
|
+
<div class="ml-auto flex items-center gap-2">
|
|
54
|
+
<UTooltip
|
|
55
|
+
v-if="!isAdmin && !hideRefresh"
|
|
56
|
+
:text="t('nuxtUiMongocamp.common.refresh')"
|
|
57
|
+
>
|
|
58
|
+
<UButton
|
|
59
|
+
icon="i-lucide-refresh-cw"
|
|
60
|
+
color="neutral"
|
|
61
|
+
variant="ghost"
|
|
62
|
+
:loading="loading"
|
|
63
|
+
:aria-label="t('nuxtUiMongocamp.common.refresh')"
|
|
64
|
+
@click="refresh"
|
|
65
|
+
/>
|
|
66
|
+
</UTooltip>
|
|
67
|
+
<slot name="toolbar" />
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<UAlert
|
|
72
|
+
v-if="isAdmin"
|
|
73
|
+
color="info"
|
|
74
|
+
variant="subtle"
|
|
75
|
+
icon="i-lucide-shield-check"
|
|
76
|
+
:title="t('nuxtUiMongocamp.userAccess.adminTitle')"
|
|
77
|
+
:description="t('nuxtUiMongocamp.userAccess.adminDescription')"
|
|
78
|
+
data-test="admin-access"
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<template v-else>
|
|
82
|
+
<div
|
|
83
|
+
v-if="!hideStats"
|
|
84
|
+
class="grid grid-cols-2 gap-4 lg:grid-cols-4"
|
|
85
|
+
>
|
|
86
|
+
<UCard
|
|
87
|
+
v-for="stat in stats"
|
|
88
|
+
:key="stat.key"
|
|
89
|
+
:data-test="`access-stat-${stat.key}`"
|
|
90
|
+
>
|
|
91
|
+
<div class="flex items-center gap-3">
|
|
92
|
+
<UIcon
|
|
93
|
+
:name="stat.icon"
|
|
94
|
+
class="size-6 text-primary"
|
|
95
|
+
/>
|
|
96
|
+
<div>
|
|
97
|
+
<div class="text-2xl font-semibold tabular-nums">
|
|
98
|
+
{{ loading || loadError ? "\u2026" : stat.value }}
|
|
99
|
+
</div>
|
|
100
|
+
<div class="text-sm text-muted">
|
|
101
|
+
{{ stat.label }}
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</UCard>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<MongocampErrorAlert
|
|
109
|
+
:error="loadError"
|
|
110
|
+
@retry="refresh"
|
|
111
|
+
/>
|
|
112
|
+
<MongocampEmptyState
|
|
113
|
+
v-if="!loadError && !loading && !access.length"
|
|
114
|
+
icon="i-lucide-lock"
|
|
115
|
+
:title="t('nuxtUiMongocamp.userAccess.emptyTitle')"
|
|
116
|
+
:description="t('nuxtUiMongocamp.userAccess.emptyDescription')"
|
|
117
|
+
/>
|
|
118
|
+
<table
|
|
119
|
+
v-else-if="access.length"
|
|
120
|
+
class="w-full text-sm"
|
|
121
|
+
>
|
|
122
|
+
<thead>
|
|
123
|
+
<tr class="text-left text-muted">
|
|
124
|
+
<th
|
|
125
|
+
scope="col"
|
|
126
|
+
class="py-2 font-medium"
|
|
127
|
+
>
|
|
128
|
+
{{ t("nuxtUiMongocamp.userAccess.collection") }}
|
|
129
|
+
</th>
|
|
130
|
+
<th
|
|
131
|
+
v-for="flag in FLAGS"
|
|
132
|
+
:key="flag"
|
|
133
|
+
scope="col"
|
|
134
|
+
class="py-2 font-medium"
|
|
135
|
+
>
|
|
136
|
+
{{ t(`nuxtUiMongocamp.userAccess.${flag}`) }}
|
|
137
|
+
</th>
|
|
138
|
+
</tr>
|
|
139
|
+
</thead>
|
|
140
|
+
<tbody>
|
|
141
|
+
<tr
|
|
142
|
+
v-for="row in access"
|
|
143
|
+
:key="row.name"
|
|
144
|
+
class="border-t border-default"
|
|
145
|
+
>
|
|
146
|
+
<th
|
|
147
|
+
scope="row"
|
|
148
|
+
class="py-2 text-left font-mono font-normal"
|
|
149
|
+
>
|
|
150
|
+
{{ row.name }}
|
|
151
|
+
</th>
|
|
152
|
+
<td
|
|
153
|
+
v-for="flag in FLAGS"
|
|
154
|
+
:key="flag"
|
|
155
|
+
class="py-2"
|
|
156
|
+
>
|
|
157
|
+
<UBadge
|
|
158
|
+
:label="row[flag] ? t('nuxtUiMongocamp.common.yes') : t('nuxtUiMongocamp.common.no')"
|
|
159
|
+
:color="row[flag] ? 'success' : 'neutral'"
|
|
160
|
+
variant="subtle"
|
|
161
|
+
/>
|
|
162
|
+
</td>
|
|
163
|
+
</tr>
|
|
164
|
+
</tbody>
|
|
165
|
+
</table>
|
|
166
|
+
</template>
|
|
167
|
+
</div>
|
|
168
|
+
</template>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
hideHeading?: boolean;
|
|
3
|
+
hideRefresh?: boolean;
|
|
4
|
+
hideStats?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare function refresh(): Promise<void>;
|
|
7
|
+
declare const __VLS_template: () => {
|
|
8
|
+
__VLS_Slots: {
|
|
9
|
+
toolbar?: (props: {}) => any;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
13
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
14
|
+
refresh: typeof refresh;
|
|
15
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
16
|
+
hideRefresh: boolean;
|
|
17
|
+
hideHeading: boolean;
|
|
18
|
+
hideStats: 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
|
+
};
|
|
@@ -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
|
+
};
|