@sfxcode/nuxt-ui-mongocamp 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/module.json +2 -2
- package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampAggregationBuilder.vue +29 -2
- package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.vue +4 -3
- package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampBucketFiles.vue +61 -0
- package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +2 -12
- package/dist/runtime/components/MongocampBulkDelete.vue +14 -40
- package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +2 -12
- package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +5 -6
- package/dist/runtime/components/MongocampBulkEdit.vue +43 -26
- package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +5 -6
- package/dist/runtime/components/MongocampChart.vue +1 -4
- package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +2 -0
- package/dist/runtime/components/MongocampCollectionCharts.vue +9 -8
- package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +2 -0
- package/dist/runtime/components/MongocampCollectionCopy.vue +19 -258
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +2 -0
- package/dist/runtime/components/MongocampCollectionData.vue +206 -126
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +2 -0
- package/dist/runtime/components/MongocampCollectionRename.d.vue.ts +22 -0
- package/dist/runtime/components/MongocampCollectionRename.vue +116 -0
- package/dist/runtime/components/MongocampCollectionRename.vue.d.ts +22 -0
- package/dist/runtime/components/MongocampCollections.vue +31 -12
- package/dist/runtime/components/MongocampCommandPalette.vue +2 -2
- package/dist/runtime/components/MongocampDashboard.vue +19 -4
- package/dist/runtime/components/MongocampDatabases.vue +13 -2
- package/dist/runtime/components/MongocampExportAll.vue +13 -26
- package/dist/runtime/components/MongocampImport.vue +169 -3
- package/dist/runtime/components/MongocampIndexes.vue +54 -13
- package/dist/runtime/components/MongocampJobs.vue +14 -3
- package/dist/runtime/components/MongocampRoleGrants.vue +16 -3
- package/dist/runtime/components/MongocampRoles.vue +13 -2
- package/dist/runtime/components/MongocampServerInfo.d.vue.ts +24 -0
- package/dist/runtime/components/MongocampServerInfo.vue +331 -0
- package/dist/runtime/components/MongocampServerInfo.vue.d.ts +24 -0
- package/dist/runtime/components/MongocampServerOverview.vue +16 -39
- package/dist/runtime/components/MongocampSettings.d.vue.ts +3 -0
- package/dist/runtime/components/MongocampSettings.vue +14 -2
- package/dist/runtime/components/MongocampSettings.vue.d.ts +3 -0
- package/dist/runtime/components/MongocampUsers.vue +16 -3
- package/dist/runtime/components/MongocampVersion.d.vue.ts +7 -1
- package/dist/runtime/components/MongocampVersion.vue +49 -19
- package/dist/runtime/components/MongocampVersion.vue.d.ts +7 -1
- package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
- package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
- package/dist/runtime/composables/useMongocampAggregation.d.ts +11 -0
- package/dist/runtime/composables/useMongocampAggregation.js +12 -5
- package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
- package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
- package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +25 -65
- package/dist/runtime/composables/useMongocampCollectionCopy.js +27 -84
- package/dist/runtime/composables/useMongocampExportAll.d.ts +27 -21
- package/dist/runtime/composables/useMongocampExportAll.js +51 -21
- package/dist/runtime/composables/useMongocampExtendedJson.d.ts +2 -1
- package/dist/runtime/composables/useMongocampExtendedJson.js +32 -5
- package/dist/runtime/composables/useMongocampFetchAll.js +1 -1
- package/dist/runtime/composables/useMongocampFieldTypes.d.ts +24 -0
- package/dist/runtime/composables/useMongocampFieldTypes.js +44 -0
- package/dist/runtime/composables/useMongocampImport.d.ts +4 -0
- package/dist/runtime/composables/useMongocampImport.js +5 -2
- package/dist/runtime/composables/useMongocampIndex.d.ts +6 -1
- package/dist/runtime/composables/useMongocampIndex.js +7 -1
- package/dist/runtime/composables/useMongocampPermissions.d.ts +8 -5
- package/dist/runtime/composables/useMongocampPermissions.js +24 -2
- package/dist/runtime/composables/useMongocampQuery.d.ts +3 -3
- package/dist/runtime/composables/useMongocampServerOverview.d.ts +4 -11
- package/dist/runtime/composables/useMongocampServerOverview.js +12 -22
- package/dist/runtime/composables/useMongocampSystem.d.ts +10 -1
- package/dist/runtime/composables/useMongocampSystem.js +11 -1
- package/dist/runtime/locales/de.json +104 -71
- package/dist/runtime/locales/en.json +104 -71
- package/dist/runtime/plugin.d.ts +2 -2
- package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
- package/dist/runtime/utils/aggregationErrors.js +7 -0
- package/dist/runtime/utils/batchInsert.d.ts +6 -0
- package/dist/runtime/utils/batchInsert.js +31 -3
- package/dist/runtime/utils/bsonTypes.d.ts +10 -0
- package/dist/runtime/utils/bsonTypes.js +42 -0
- package/dist/runtime/utils/collectionCopy.d.ts +0 -2
- package/dist/runtime/utils/collectionCopy.js +0 -1
- package/dist/runtime/utils/configRows.d.ts +7 -0
- package/dist/runtime/utils/configRows.js +4 -0
- package/dist/runtime/utils/documentCompare.js +2 -1
- package/dist/runtime/utils/documentPaths.d.ts +5 -8
- package/dist/runtime/utils/documentPaths.js +5 -10
- package/dist/runtime/utils/documentTree.js +9 -1
- package/dist/runtime/utils/exportDocuments.d.ts +0 -2
- package/dist/runtime/utils/exportDocuments.js +0 -1
- package/dist/runtime/utils/exportRows.d.ts +2 -0
- package/dist/runtime/utils/exportRows.js +5 -2
- package/dist/runtime/utils/fieldDetails.d.ts +51 -0
- package/dist/runtime/utils/fieldDetails.js +113 -0
- package/dist/runtime/utils/indexForm.d.ts +47 -33
- package/dist/runtime/utils/indexForm.js +32 -21
- package/dist/runtime/utils/serverInfo.d.ts +8 -0
- package/dist/runtime/utils/serverInfo.js +21 -0
- package/package.json +11 -11
- package/dist/runtime/utils/indexCopy.d.ts +0 -26
- package/dist/runtime/utils/indexCopy.js +0 -22
- package/dist/runtime/utils/limitedMap.d.ts +0 -17
- package/dist/runtime/utils/limitedMap.js +0 -19
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref, watch } from "vue";
|
|
3
|
+
import { useI18n, useMongocampError } from "#imports";
|
|
4
|
+
import { useMongocampCollectionCopy } from "../composables/useMongocampCollectionCopy";
|
|
5
|
+
import { MAX_COLLECTION_NAME_LENGTH, validateTargetName } from "../utils/collectionCopy";
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
source: { type: String, required: true }
|
|
8
|
+
});
|
|
9
|
+
const emit = defineEmits(["done"]);
|
|
10
|
+
const isOpen = defineModel("open", { type: Boolean, ...{ default: false } });
|
|
11
|
+
const { t } = useI18n();
|
|
12
|
+
const { describeServerError } = useMongocampError();
|
|
13
|
+
const { renameCollection, listCollectionNames } = useMongocampCollectionCopy();
|
|
14
|
+
const target = ref("");
|
|
15
|
+
const existing = ref([]);
|
|
16
|
+
const renaming = ref(false);
|
|
17
|
+
const errorText = ref("");
|
|
18
|
+
let opened = 0;
|
|
19
|
+
watch(isOpen, async (open) => {
|
|
20
|
+
if (!open) return;
|
|
21
|
+
const mine = ++opened;
|
|
22
|
+
target.value = "";
|
|
23
|
+
errorText.value = "";
|
|
24
|
+
renaming.value = false;
|
|
25
|
+
try {
|
|
26
|
+
const names = await listCollectionNames();
|
|
27
|
+
if (mine === opened) existing.value = names;
|
|
28
|
+
} catch {
|
|
29
|
+
if (mine === opened) existing.value = [];
|
|
30
|
+
}
|
|
31
|
+
}, { immediate: true });
|
|
32
|
+
const problem = computed(() => target.value === "" ? void 0 : validateTargetName(target.value, props.source, existing.value));
|
|
33
|
+
const problemText = computed(() => {
|
|
34
|
+
const key = { "empty": "problemEmpty", "too-long": "problemTooLong", "invalid-characters": "problemInvalid", "protected": "problemProtected", "same-as-source": "problemSame", "exists": "problemExists" }[problem.value ?? "empty"];
|
|
35
|
+
return problem.value ? t(`nuxtUiMongocamp.collectionCopy.${key}`, { max: MAX_COLLECTION_NAME_LENGTH }) : "";
|
|
36
|
+
});
|
|
37
|
+
const targetName = computed(() => target.value.trim());
|
|
38
|
+
const canRename = computed(() => targetName.value !== "" && problem.value === void 0 && !renaming.value);
|
|
39
|
+
async function rename() {
|
|
40
|
+
if (!canRename.value) return;
|
|
41
|
+
renaming.value = true;
|
|
42
|
+
errorText.value = "";
|
|
43
|
+
try {
|
|
44
|
+
const result = await renameCollection(props.source, targetName.value);
|
|
45
|
+
if (result.refused === "target-exists") {
|
|
46
|
+
existing.value = [...existing.value, targetName.value];
|
|
47
|
+
errorText.value = t("nuxtUiMongocamp.collectionRename.refusedExists", { target: targetName.value });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
emit("done", { source: props.source, target: result.target });
|
|
51
|
+
isOpen.value = false;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
errorText.value = (await describeServerError(e, "nuxtUiMongocamp.collectionRename.failedGeneric")).message;
|
|
54
|
+
} finally {
|
|
55
|
+
renaming.value = false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<UModal
|
|
62
|
+
v-model:open="isOpen"
|
|
63
|
+
:title="t('nuxtUiMongocamp.collectionRename.title', { source })"
|
|
64
|
+
:dismissible="!renaming"
|
|
65
|
+
:ui="{ footer: 'justify-end' }"
|
|
66
|
+
>
|
|
67
|
+
<template #body>
|
|
68
|
+
<div class="flex flex-col gap-4">
|
|
69
|
+
<UAlert
|
|
70
|
+
color="warning"
|
|
71
|
+
variant="subtle"
|
|
72
|
+
icon="i-lucide-triangle-alert"
|
|
73
|
+
:description="t('nuxtUiMongocamp.collectionRename.grantsWarning')"
|
|
74
|
+
data-test="rename-grants-warning"
|
|
75
|
+
/>
|
|
76
|
+
<UFormField
|
|
77
|
+
:label="t('nuxtUiMongocamp.collectionRename.targetLabel')"
|
|
78
|
+
:help="t('nuxtUiMongocamp.collectionCopy.targetHelp')"
|
|
79
|
+
:error="problemText || void 0"
|
|
80
|
+
>
|
|
81
|
+
<UInput
|
|
82
|
+
v-model="target"
|
|
83
|
+
class="w-full"
|
|
84
|
+
autocomplete="off"
|
|
85
|
+
:disabled="renaming"
|
|
86
|
+
:aria-label="t('nuxtUiMongocamp.collectionRename.targetLabel')"
|
|
87
|
+
@keydown.enter.prevent="rename"
|
|
88
|
+
/>
|
|
89
|
+
</UFormField>
|
|
90
|
+
<p
|
|
91
|
+
v-if="errorText"
|
|
92
|
+
class="text-sm text-error"
|
|
93
|
+
role="alert"
|
|
94
|
+
>
|
|
95
|
+
{{ errorText }}
|
|
96
|
+
</p>
|
|
97
|
+
</div>
|
|
98
|
+
</template>
|
|
99
|
+
<template #footer>
|
|
100
|
+
<UButton
|
|
101
|
+
:label="t('nuxtUiMongocamp.common.cancel')"
|
|
102
|
+
color="neutral"
|
|
103
|
+
variant="ghost"
|
|
104
|
+
:disabled="renaming"
|
|
105
|
+
@click="isOpen = false"
|
|
106
|
+
/>
|
|
107
|
+
<UButton
|
|
108
|
+
:label="t('nuxtUiMongocamp.collectionRename.confirm')"
|
|
109
|
+
icon="i-lucide-pencil"
|
|
110
|
+
:loading="renaming"
|
|
111
|
+
:disabled="!canRename"
|
|
112
|
+
@click="rename"
|
|
113
|
+
/>
|
|
114
|
+
</template>
|
|
115
|
+
</UModal>
|
|
116
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
source: string;
|
|
3
|
+
};
|
|
4
|
+
type __VLS_ModelProps = {
|
|
5
|
+
'open'?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
"update:open": (value: boolean) => any;
|
|
10
|
+
done: (payload: {
|
|
11
|
+
source: string;
|
|
12
|
+
target: string;
|
|
13
|
+
}) => any;
|
|
14
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
15
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
16
|
+
onDone?: ((payload: {
|
|
17
|
+
source: string;
|
|
18
|
+
target: string;
|
|
19
|
+
}) => any) | undefined;
|
|
20
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
declare const _default: typeof __VLS_export;
|
|
22
|
+
export default _default;
|
|
@@ -37,18 +37,12 @@ async function fetchCollections() {
|
|
|
37
37
|
loading.value = true;
|
|
38
38
|
loadError.value = null;
|
|
39
39
|
try {
|
|
40
|
-
const names = await collectionApi.listCollections();
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
count: info.count,
|
|
47
|
-
sizekb: Math.round(info.storageSize / 1024),
|
|
48
|
-
indexCount: info.nindexes
|
|
49
|
-
};
|
|
50
|
-
})
|
|
51
|
-
);
|
|
40
|
+
const [names, infos] = await Promise.all([collectionApi.listCollections(), collectionApi.listCollectionInformation({})]);
|
|
41
|
+
const byName = new Map(infos.map((info) => [info.name, info]));
|
|
42
|
+
const rows = names.filter((name) => !name.startsWith("mc")).flatMap((name) => {
|
|
43
|
+
const info = byName.get(name);
|
|
44
|
+
return info ? [{ name, count: info.count, sizekb: Math.round(info.storageSize / 1024), indexCount: info.nindexes }] : [];
|
|
45
|
+
});
|
|
52
46
|
collections.value = rows;
|
|
53
47
|
} catch (e) {
|
|
54
48
|
loadError.value = e;
|
|
@@ -204,6 +198,14 @@ const columns = computed(() => [
|
|
|
204
198
|
"aria-label": t("nuxtUiMongocamp.collections.copyTooltip"),
|
|
205
199
|
"onClick": () => openCopy(name)
|
|
206
200
|
})),
|
|
201
|
+
withTooltip(t("nuxtUiMongocamp.collections.renameTooltip"), h(UButton, {
|
|
202
|
+
"icon": "i-lucide-pencil",
|
|
203
|
+
"color": "neutral",
|
|
204
|
+
"variant": "ghost",
|
|
205
|
+
"size": "sm",
|
|
206
|
+
"aria-label": t("nuxtUiMongocamp.collections.renameTooltip"),
|
|
207
|
+
"onClick": () => openRename(name)
|
|
208
|
+
})),
|
|
207
209
|
withTooltip(t("nuxtUiMongocamp.collections.clearTooltip"), h(UButton, {
|
|
208
210
|
"icon": "i-lucide-eraser",
|
|
209
211
|
"color": "warning",
|
|
@@ -232,6 +234,16 @@ function openCopy(name) {
|
|
|
232
234
|
copySource.value = name;
|
|
233
235
|
isCopyOpen.value = true;
|
|
234
236
|
}
|
|
237
|
+
const renameSource = ref("");
|
|
238
|
+
const isRenameOpen = ref(false);
|
|
239
|
+
async function onRenamed() {
|
|
240
|
+
await fetchCollections();
|
|
241
|
+
emit("changed");
|
|
242
|
+
}
|
|
243
|
+
function openRename(name) {
|
|
244
|
+
renameSource.value = name;
|
|
245
|
+
isRenameOpen.value = true;
|
|
246
|
+
}
|
|
235
247
|
fetchCollections();
|
|
236
248
|
</script>
|
|
237
249
|
|
|
@@ -314,6 +326,13 @@ fetchCollections();
|
|
|
314
326
|
@done="fetchCollections"
|
|
315
327
|
/>
|
|
316
328
|
|
|
329
|
+
<MongocampCollectionRename
|
|
330
|
+
v-if="renameSource"
|
|
331
|
+
v-model:open="isRenameOpen"
|
|
332
|
+
:source="renameSource"
|
|
333
|
+
@done="onRenamed"
|
|
334
|
+
/>
|
|
335
|
+
|
|
317
336
|
<MongocampConfirmByName
|
|
318
337
|
v-if="pending"
|
|
319
338
|
v-model:open="isConfirmOpen"
|
|
@@ -23,7 +23,7 @@ const open = defineModel("open", { type: Boolean, ...{ default: false } });
|
|
|
23
23
|
const { t } = useI18n();
|
|
24
24
|
const { listUsers, listRoles, listCollections } = useMongocampAdmin();
|
|
25
25
|
const { listJobs } = useMongocampJobs();
|
|
26
|
-
const { canRead } = useMongocampPermissions();
|
|
26
|
+
const { canRead, load: loadPermissions } = useMongocampPermissions();
|
|
27
27
|
const { isAdmin, logoutPath } = useMongocampRoles();
|
|
28
28
|
const data = ref({});
|
|
29
29
|
const loadedAt = ref(void 0);
|
|
@@ -50,7 +50,7 @@ async function load() {
|
|
|
50
50
|
jobs: async () => (await listJobs()).map((j) => ({ name: j.name, group: j.group }))
|
|
51
51
|
};
|
|
52
52
|
const wanted = admin ? ["collections", "users", "roles", "jobs"] : ["collections"];
|
|
53
|
-
const results = await Promise.allSettled(wanted.map((key) => parts[key]()));
|
|
53
|
+
const [results] = await Promise.all([Promise.allSettled(wanted.map((key) => parts[key]())), admin ? void 0 : loadPermissions()]);
|
|
54
54
|
if (current !== generation) return;
|
|
55
55
|
const next = {};
|
|
56
56
|
const errors = [];
|
|
@@ -4,6 +4,7 @@ import { useI18n } from "#imports";
|
|
|
4
4
|
import { useNuxtApp } from "#app";
|
|
5
5
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
6
6
|
import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
|
|
7
|
+
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
7
8
|
const props = defineProps({
|
|
8
9
|
collectionsPath: { type: String, required: false, default: "/secured/admin/collections" },
|
|
9
10
|
usersPath: { type: String, required: false, default: "/secured/admin/users" },
|
|
@@ -40,10 +41,11 @@ async function reloadQuietly() {
|
|
|
40
41
|
throw e;
|
|
41
42
|
}
|
|
42
43
|
}
|
|
44
|
+
const { blocked, message } = useMongocampAdminGate();
|
|
43
45
|
const auto = useMongocampAutoRefresh(reloadQuietly, { intervalMs: () => props.autoRefresh * 1e3 });
|
|
44
46
|
function syncAutoRefresh() {
|
|
45
47
|
auto.stop();
|
|
46
|
-
if (props.autoRefresh > 0) auto.start();
|
|
48
|
+
if (!blocked.value && props.autoRefresh > 0) auto.start();
|
|
47
49
|
}
|
|
48
50
|
onMounted(syncAutoRefresh);
|
|
49
51
|
watch(() => props.autoRefresh, syncAutoRefresh);
|
|
@@ -53,7 +55,7 @@ const boxes = computed(() => [
|
|
|
53
55
|
{ key: "roles", label: t("nuxtUiMongocamp.dashboard.roles"), icon: "i-lucide-shield", to: props.rolesPath }
|
|
54
56
|
]);
|
|
55
57
|
defineExpose({ refresh });
|
|
56
|
-
refresh();
|
|
58
|
+
if (!blocked.value) refresh();
|
|
57
59
|
</script>
|
|
58
60
|
|
|
59
61
|
<template>
|
|
@@ -73,7 +75,10 @@ refresh();
|
|
|
73
75
|
</span>
|
|
74
76
|
</p>
|
|
75
77
|
</div>
|
|
76
|
-
<UTooltip
|
|
78
|
+
<UTooltip
|
|
79
|
+
v-if="!blocked"
|
|
80
|
+
:text="t('nuxtUiMongocamp.common.refresh')"
|
|
81
|
+
>
|
|
77
82
|
<UButton
|
|
78
83
|
icon="i-lucide-refresh-cw"
|
|
79
84
|
color="neutral"
|
|
@@ -85,12 +90,22 @@ refresh();
|
|
|
85
90
|
</UTooltip>
|
|
86
91
|
</div>
|
|
87
92
|
|
|
93
|
+
<MongocampEmptyState
|
|
94
|
+
v-if="blocked"
|
|
95
|
+
icon="i-lucide-shield-alert"
|
|
96
|
+
:title="message"
|
|
97
|
+
data-test="admin-only"
|
|
98
|
+
/>
|
|
88
99
|
<MongocampErrorAlert
|
|
100
|
+
v-if="!blocked"
|
|
89
101
|
:error="loadError"
|
|
90
102
|
@retry="refresh"
|
|
91
103
|
/>
|
|
92
104
|
|
|
93
|
-
<div
|
|
105
|
+
<div
|
|
106
|
+
v-if="!blocked"
|
|
107
|
+
class="grid grid-cols-1 gap-4 sm:grid-cols-3"
|
|
108
|
+
>
|
|
94
109
|
<NuxtLink
|
|
95
110
|
v-for="box in boxes"
|
|
96
111
|
:key="box.key"
|
|
@@ -3,6 +3,7 @@ import { computed, h, ref, resolveComponent } from "vue";
|
|
|
3
3
|
import { useI18n, useMongocampSystem } from "#imports";
|
|
4
4
|
import { formatBytes } from "../utils/formatBytes";
|
|
5
5
|
import { shortenLabel } from "../utils/chartData";
|
|
6
|
+
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
6
7
|
const { t } = useI18n();
|
|
7
8
|
const { getDatabaseInfos, listCollectionsByDatabase } = useMongocampSystem();
|
|
8
9
|
const databases = ref([]);
|
|
@@ -10,6 +11,7 @@ const chartRows = computed(() => [...databases.value].sort((a, b) => b.sizeKb -
|
|
|
10
11
|
const loading = ref(false);
|
|
11
12
|
const sorting = ref([]);
|
|
12
13
|
const loadError = ref(null);
|
|
14
|
+
const { blocked, message } = useMongocampAdminGate();
|
|
13
15
|
async function fetchDatabases() {
|
|
14
16
|
loading.value = true;
|
|
15
17
|
loadError.value = null;
|
|
@@ -67,11 +69,20 @@ const columns = computed(() => [
|
|
|
67
69
|
cell: ({ row }) => row.original.empty ? h(UBadge, { label: t("nuxtUiMongocamp.databases.emptyBadge"), color: "neutral", variant: "subtle" }) : h("span", { class: "text-dimmed" }, "\u2014")
|
|
68
70
|
}
|
|
69
71
|
]);
|
|
70
|
-
fetchDatabases();
|
|
72
|
+
if (!blocked.value) fetchDatabases();
|
|
71
73
|
</script>
|
|
72
74
|
|
|
73
75
|
<template>
|
|
74
|
-
<
|
|
76
|
+
<MongocampEmptyState
|
|
77
|
+
v-if="blocked"
|
|
78
|
+
icon="i-lucide-shield-alert"
|
|
79
|
+
:title="message"
|
|
80
|
+
data-test="admin-only"
|
|
81
|
+
/>
|
|
82
|
+
<div
|
|
83
|
+
v-else
|
|
84
|
+
class="flex flex-col gap-4"
|
|
85
|
+
>
|
|
75
86
|
<div class="flex items-center justify-between gap-4">
|
|
76
87
|
<h2 class="text-xl font-semibold">
|
|
77
88
|
{{ t("nuxtUiMongocamp.databases.heading") }}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { computed, ref, watch } from "vue";
|
|
3
3
|
import { useI18n, useMongocampError } from "#imports";
|
|
4
4
|
import { useMongocampExportAll } from "../composables/useMongocampExportAll";
|
|
5
|
-
import {
|
|
5
|
+
import { formatBytes } from "../utils/formatBytes";
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
collection: { type: String, required: true },
|
|
8
8
|
filter: { type: String, required: false },
|
|
@@ -16,7 +16,7 @@ const { describeServerError } = useMongocampError();
|
|
|
16
16
|
const { exportCollection } = useMongocampExportAll();
|
|
17
17
|
const step = ref("form");
|
|
18
18
|
const format = ref("json");
|
|
19
|
-
const progress = ref({
|
|
19
|
+
const progress = ref({ bytes: 0, lines: 0 });
|
|
20
20
|
const result = ref(null);
|
|
21
21
|
const cancelled = ref(false);
|
|
22
22
|
const errorText = ref("");
|
|
@@ -36,13 +36,13 @@ const formatItems = computed(() => [
|
|
|
36
36
|
{ label: t("nuxtUiMongocamp.exportAll.formatNdjson"), value: "ndjson" },
|
|
37
37
|
{ label: t("nuxtUiMongocamp.exportAll.formatCsv"), value: "csv" }
|
|
38
38
|
]);
|
|
39
|
-
const
|
|
39
|
+
const received = computed(() => formatBytes(progress.value.bytes));
|
|
40
40
|
async function start() {
|
|
41
41
|
errorText.value = "";
|
|
42
42
|
cancelled.value = false;
|
|
43
43
|
result.value = null;
|
|
44
44
|
step.value = "running";
|
|
45
|
-
progress.value = {
|
|
45
|
+
progress.value = { bytes: 0, lines: 0 };
|
|
46
46
|
const run = new AbortController();
|
|
47
47
|
controller = run;
|
|
48
48
|
try {
|
|
@@ -52,9 +52,10 @@ async function start() {
|
|
|
52
52
|
filter: props.filter,
|
|
53
53
|
sort: props.sort?.length ? props.sort : void 0,
|
|
54
54
|
projection: props.projection?.length ? props.projection : void 0,
|
|
55
|
+
expected: props.total,
|
|
55
56
|
signal: run.signal,
|
|
56
57
|
onProgress: (p) => {
|
|
57
|
-
progress.value =
|
|
58
|
+
progress.value = p;
|
|
58
59
|
}
|
|
59
60
|
});
|
|
60
61
|
step.value = "done";
|
|
@@ -104,7 +105,7 @@ function cancel() {
|
|
|
104
105
|
/>
|
|
105
106
|
</UFormField>
|
|
106
107
|
<p class="text-xs text-dimmed">
|
|
107
|
-
{{ t("nuxtUiMongocamp.exportAll.
|
|
108
|
+
{{ t("nuxtUiMongocamp.exportAll.streamNote") }}
|
|
108
109
|
</p>
|
|
109
110
|
</div>
|
|
110
111
|
|
|
@@ -114,11 +115,8 @@ function cancel() {
|
|
|
114
115
|
role="status"
|
|
115
116
|
data-test="export-progress"
|
|
116
117
|
>
|
|
117
|
-
<UProgress
|
|
118
|
-
|
|
119
|
-
:max="100"
|
|
120
|
-
/>
|
|
121
|
-
<span class="text-sm text-dimmed">{{ t("nuxtUiMongocamp.exportAll.reading", { done: progress.loaded, total: progress.target }) }}</span>
|
|
118
|
+
<UProgress />
|
|
119
|
+
<span class="text-sm text-dimmed">{{ t("nuxtUiMongocamp.exportAll.receiving", { size: received }) }}</span>
|
|
122
120
|
</div>
|
|
123
121
|
|
|
124
122
|
<div
|
|
@@ -141,31 +139,20 @@ function cancel() {
|
|
|
141
139
|
</p>
|
|
142
140
|
<template v-else-if="result">
|
|
143
141
|
<UAlert
|
|
144
|
-
v-if="result.
|
|
142
|
+
v-if="result.incomplete"
|
|
145
143
|
color="warning"
|
|
146
144
|
variant="subtle"
|
|
147
145
|
icon="i-lucide-circle-alert"
|
|
148
|
-
:title="t('nuxtUiMongocamp.exportAll.
|
|
146
|
+
:title="t('nuxtUiMongocamp.exportAll.incomplete', { file: result.filename })"
|
|
147
|
+
data-test="export-incomplete"
|
|
149
148
|
/>
|
|
150
149
|
<UAlert
|
|
151
150
|
v-else
|
|
152
151
|
color="success"
|
|
153
152
|
variant="subtle"
|
|
154
153
|
icon="i-lucide-circle-check"
|
|
155
|
-
:title="t('nuxtUiMongocamp.exportAll.done', { count: result.
|
|
154
|
+
:title="result.documents === void 0 ? t('nuxtUiMongocamp.exportAll.doneSize', { size: formatBytes(result.bytes), file: result.filename }) : t('nuxtUiMongocamp.exportAll.done', { count: result.documents, file: result.filename }, result.documents)"
|
|
156
155
|
/>
|
|
157
|
-
<p
|
|
158
|
-
v-if="result.truncated"
|
|
159
|
-
class="text-sm text-dimmed"
|
|
160
|
-
>
|
|
161
|
-
{{ t("nuxtUiMongocamp.exportAll.done", { count: result.rowCount, file: result.filename }, result.rowCount) }}
|
|
162
|
-
</p>
|
|
163
|
-
<p
|
|
164
|
-
v-if="result.totalChanged"
|
|
165
|
-
class="text-sm text-warning"
|
|
166
|
-
>
|
|
167
|
-
{{ t("nuxtUiMongocamp.exportAll.changed") }}
|
|
168
|
-
</p>
|
|
169
156
|
</template>
|
|
170
157
|
</div>
|
|
171
158
|
</template>
|