@sfxcode/nuxt-ui-mongocamp 1.4.0 → 1.5.0
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 +1 -1
- 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/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/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/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/locales/de.json +69 -71
- package/dist/runtime/locales/en.json +69 -71
- 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/package.json +8 -8
- 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
|
@@ -4,6 +4,7 @@ import { useI18n, useMongocampError } from "#imports";
|
|
|
4
4
|
import { useMongocampImport } from "../composables/useMongocampImport";
|
|
5
5
|
import { DEFAULT_IMPORT_LIMITS } from "../utils/importRows";
|
|
6
6
|
import { detectImportFormat, prepareImport } from "../utils/importPipeline";
|
|
7
|
+
import { formatBytes } from "../utils/formatBytes";
|
|
7
8
|
const props = defineProps({
|
|
8
9
|
collectionName: { type: String, required: true }
|
|
9
10
|
});
|
|
@@ -12,7 +13,7 @@ const PREVIEW_ROWS = 5;
|
|
|
12
13
|
const ERROR_LIMIT = 10;
|
|
13
14
|
const { t } = useI18n();
|
|
14
15
|
const { describeServerError } = useMongocampError();
|
|
15
|
-
const { importRows } = useMongocampImport();
|
|
16
|
+
const { importRows, importNdjson } = useMongocampImport();
|
|
16
17
|
const isOpen = ref(false);
|
|
17
18
|
const step = ref("select");
|
|
18
19
|
const fileInputRef = ref(null);
|
|
@@ -24,6 +25,12 @@ const delimiter = ref(",");
|
|
|
24
25
|
const userColumnTypes = ref(null);
|
|
25
26
|
const emptyAsText = ref(false);
|
|
26
27
|
const stampMetadata = ref(true);
|
|
28
|
+
const serverFile = ref(null);
|
|
29
|
+
const serverPreview = ref({ rows: [], columns: [], unreadable: 0 });
|
|
30
|
+
const serverResult = ref(null);
|
|
31
|
+
const serverError = ref("");
|
|
32
|
+
const NDJSON_HEAD_BYTES = 64 * 1024;
|
|
33
|
+
const isNdjsonName = (name) => /\.(?:ndjson|jsonl)$/i.test(name);
|
|
27
34
|
const progress = ref({ done: 0, total: 0 });
|
|
28
35
|
const attemptRows = ref([]);
|
|
29
36
|
const attemptSources = ref([]);
|
|
@@ -91,6 +98,9 @@ function resetState() {
|
|
|
91
98
|
userColumnTypes.value = null;
|
|
92
99
|
emptyAsText.value = false;
|
|
93
100
|
stampMetadata.value = true;
|
|
101
|
+
serverFile.value = null;
|
|
102
|
+
serverResult.value = null;
|
|
103
|
+
serverError.value = "";
|
|
94
104
|
progress.value = { done: 0, total: 0 };
|
|
95
105
|
attemptRows.value = [];
|
|
96
106
|
attemptSources.value = [];
|
|
@@ -113,6 +123,14 @@ async function handleFileSelected(event) {
|
|
|
113
123
|
input.value = "";
|
|
114
124
|
if (!file) return;
|
|
115
125
|
readError.value = "";
|
|
126
|
+
if (isNdjsonName(file.name)) {
|
|
127
|
+
try {
|
|
128
|
+
await prepareServerFile(file);
|
|
129
|
+
} catch {
|
|
130
|
+
readError.value = t("nuxtUiMongocamp.import.readError");
|
|
131
|
+
}
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
116
134
|
try {
|
|
117
135
|
const text = await file.text();
|
|
118
136
|
fileName.value = file.name;
|
|
@@ -125,7 +143,60 @@ async function handleFileSelected(event) {
|
|
|
125
143
|
readError.value = t("nuxtUiMongocamp.import.readError");
|
|
126
144
|
}
|
|
127
145
|
}
|
|
146
|
+
async function prepareServerFile(file) {
|
|
147
|
+
const head = await file.slice(0, NDJSON_HEAD_BYTES).text();
|
|
148
|
+
const lines = head.replace(/^\uFEFF/, "").split(/\r?\n/);
|
|
149
|
+
if (file.size > NDJSON_HEAD_BYTES) lines.pop();
|
|
150
|
+
const rows = [];
|
|
151
|
+
const columns = /* @__PURE__ */ new Set();
|
|
152
|
+
let unreadable = 0;
|
|
153
|
+
for (const line of lines.filter((l) => l.trim() !== "").slice(0, PREVIEW_ROWS)) {
|
|
154
|
+
try {
|
|
155
|
+
const value = JSON.parse(line);
|
|
156
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("not an object");
|
|
157
|
+
const shown = {};
|
|
158
|
+
for (const [key, inner] of Object.entries(value)) {
|
|
159
|
+
shown[key] = typeof inner === "object" && inner !== null ? JSON.stringify(inner) : String(inner);
|
|
160
|
+
columns.add(key);
|
|
161
|
+
}
|
|
162
|
+
rows.push(shown);
|
|
163
|
+
} catch {
|
|
164
|
+
unreadable++;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
fileName.value = file.name;
|
|
168
|
+
serverFile.value = file;
|
|
169
|
+
serverPreview.value = { rows, columns: [...columns], unreadable };
|
|
170
|
+
serverResult.value = null;
|
|
171
|
+
serverError.value = "";
|
|
172
|
+
step.value = "preview";
|
|
173
|
+
}
|
|
174
|
+
async function startServerImport() {
|
|
175
|
+
const file = serverFile.value;
|
|
176
|
+
if (!file) return;
|
|
177
|
+
serverError.value = "";
|
|
178
|
+
step.value = "importing";
|
|
179
|
+
const run = new AbortController();
|
|
180
|
+
controller = run;
|
|
181
|
+
try {
|
|
182
|
+
const result = await importNdjson(props.collectionName, file, { signal: run.signal });
|
|
183
|
+
if (controller === run) controller = null;
|
|
184
|
+
if (!isOpen.value) return;
|
|
185
|
+
serverResult.value = result;
|
|
186
|
+
if (result.inserted > 0) emit("imported", result.inserted);
|
|
187
|
+
} catch (e) {
|
|
188
|
+
if (controller === run) controller = null;
|
|
189
|
+
if (!isOpen.value) return;
|
|
190
|
+
if (e?.name === "AbortError") {
|
|
191
|
+
step.value = "preview";
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
serverError.value = await failureReason(e);
|
|
195
|
+
}
|
|
196
|
+
step.value = "done";
|
|
197
|
+
}
|
|
128
198
|
function backToSelect() {
|
|
199
|
+
serverFile.value = null;
|
|
129
200
|
fileName.value = "";
|
|
130
201
|
fileText.value = "";
|
|
131
202
|
userColumnTypes.value = null;
|
|
@@ -230,7 +301,7 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
|
|
|
230
301
|
ref="fileInputRef"
|
|
231
302
|
type="file"
|
|
232
303
|
class="hidden"
|
|
233
|
-
accept=".json,.csv,.tsv,.txt,application/json,text/csv"
|
|
304
|
+
accept=".json,.ndjson,.jsonl,.csv,.tsv,.txt,application/json,application/x-ndjson,text/csv"
|
|
234
305
|
data-testid="import-file-input"
|
|
235
306
|
@change="handleFileSelected"
|
|
236
307
|
>
|
|
@@ -248,6 +319,37 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
|
|
|
248
319
|
/>
|
|
249
320
|
</div>
|
|
250
321
|
|
|
322
|
+
<div
|
|
323
|
+
v-else-if="step === 'preview' && serverFile"
|
|
324
|
+
class="flex flex-col gap-4"
|
|
325
|
+
data-test="ndjson-preview"
|
|
326
|
+
>
|
|
327
|
+
<span class="text-sm font-medium break-all">{{ fileName }} ({{ formatBytes(serverFile.size) }})</span>
|
|
328
|
+
<UAlert
|
|
329
|
+
color="info"
|
|
330
|
+
variant="subtle"
|
|
331
|
+
icon="i-lucide-info"
|
|
332
|
+
:description="t('nuxtUiMongocamp.import.ndjsonNote')"
|
|
333
|
+
/>
|
|
334
|
+
<UAlert
|
|
335
|
+
v-if="serverPreview.unreadable > 0"
|
|
336
|
+
color="warning"
|
|
337
|
+
variant="subtle"
|
|
338
|
+
icon="i-lucide-triangle-alert"
|
|
339
|
+
:description="t('nuxtUiMongocamp.import.ndjsonUnreadable', { count: serverPreview.unreadable }, serverPreview.unreadable)"
|
|
340
|
+
/>
|
|
341
|
+
<div v-if="serverPreview.rows.length > 0">
|
|
342
|
+
<p class="mb-1 text-sm font-medium">
|
|
343
|
+
{{ t("nuxtUiMongocamp.import.previewTitle", { count: serverPreview.rows.length }) }}
|
|
344
|
+
</p>
|
|
345
|
+
<UTable
|
|
346
|
+
:data="serverPreview.rows"
|
|
347
|
+
:columns="serverPreview.columns.map((column2) => ({ id: column2, header: column2, accessorFn: (row) => row[column2] }))"
|
|
348
|
+
class="max-h-64"
|
|
349
|
+
/>
|
|
350
|
+
</div>
|
|
351
|
+
</div>
|
|
352
|
+
|
|
251
353
|
<div
|
|
252
354
|
v-else-if="step === 'preview' && prepared"
|
|
253
355
|
class="flex flex-col gap-4"
|
|
@@ -367,6 +469,17 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
|
|
|
367
469
|
</template>
|
|
368
470
|
</div>
|
|
369
471
|
|
|
472
|
+
<div
|
|
473
|
+
v-else-if="step === 'importing' && serverFile"
|
|
474
|
+
class="flex flex-col gap-3"
|
|
475
|
+
data-test="ndjson-importing"
|
|
476
|
+
>
|
|
477
|
+
<p class="text-sm">
|
|
478
|
+
{{ t("nuxtUiMongocamp.import.ndjsonImporting") }}
|
|
479
|
+
</p>
|
|
480
|
+
<UProgress :aria-label="t('nuxtUiMongocamp.import.ndjsonImporting')" />
|
|
481
|
+
</div>
|
|
482
|
+
|
|
370
483
|
<div
|
|
371
484
|
v-else-if="step === 'importing'"
|
|
372
485
|
class="flex flex-col gap-3"
|
|
@@ -380,6 +493,52 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
|
|
|
380
493
|
/>
|
|
381
494
|
</div>
|
|
382
495
|
|
|
496
|
+
<div
|
|
497
|
+
v-else-if="step === 'done' && serverFile"
|
|
498
|
+
class="flex flex-col gap-3"
|
|
499
|
+
data-test="ndjson-result"
|
|
500
|
+
>
|
|
501
|
+
<UAlert
|
|
502
|
+
v-if="serverError"
|
|
503
|
+
color="error"
|
|
504
|
+
variant="subtle"
|
|
505
|
+
icon="i-lucide-circle-alert"
|
|
506
|
+
:description="serverError"
|
|
507
|
+
/>
|
|
508
|
+
<template v-else-if="serverResult">
|
|
509
|
+
<UAlert
|
|
510
|
+
:color="serverResult.inserted > 0 ? 'success' : 'neutral'"
|
|
511
|
+
variant="subtle"
|
|
512
|
+
:icon="serverResult.inserted > 0 ? 'i-lucide-circle-check' : 'i-lucide-info'"
|
|
513
|
+
:title="t('nuxtUiMongocamp.import.result', { count: serverResult.inserted }, serverResult.inserted)"
|
|
514
|
+
/>
|
|
515
|
+
<UAlert
|
|
516
|
+
v-if="serverResult.failed > 0"
|
|
517
|
+
color="error"
|
|
518
|
+
variant="subtle"
|
|
519
|
+
icon="i-lucide-circle-alert"
|
|
520
|
+
:title="t('nuxtUiMongocamp.import.ndjsonFailed', { failed: serverResult.failed, read: serverResult.read })"
|
|
521
|
+
>
|
|
522
|
+
<template #description>
|
|
523
|
+
<ul class="list-disc pl-5 text-sm">
|
|
524
|
+
<li
|
|
525
|
+
v-for="error in (serverResult.errors ?? []).slice(0, ERROR_LIMIT)"
|
|
526
|
+
:key="error.index"
|
|
527
|
+
>
|
|
528
|
+
{{ t("nuxtUiMongocamp.import.ndjsonLine", { line: error.index, reason: error.message }) }}
|
|
529
|
+
</li>
|
|
530
|
+
</ul>
|
|
531
|
+
<p
|
|
532
|
+
v-if="serverResult.errorsTruncated || (serverResult.errors ?? []).length > ERROR_LIMIT"
|
|
533
|
+
class="mt-1 text-sm"
|
|
534
|
+
>
|
|
535
|
+
{{ t("nuxtUiMongocamp.import.ndjsonMoreErrors") }}
|
|
536
|
+
</p>
|
|
537
|
+
</template>
|
|
538
|
+
</UAlert>
|
|
539
|
+
</template>
|
|
540
|
+
</div>
|
|
541
|
+
|
|
383
542
|
<div
|
|
384
543
|
v-else-if="step === 'done'"
|
|
385
544
|
class="flex flex-col gap-3"
|
|
@@ -432,6 +591,13 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
|
|
|
432
591
|
@click="backToSelect"
|
|
433
592
|
/>
|
|
434
593
|
<UButton
|
|
594
|
+
v-if="serverFile"
|
|
595
|
+
:label="t('nuxtUiMongocamp.import.importFile')"
|
|
596
|
+
data-test="ndjson-import"
|
|
597
|
+
@click="startServerImport"
|
|
598
|
+
/>
|
|
599
|
+
<UButton
|
|
600
|
+
v-else
|
|
435
601
|
:label="t('nuxtUiMongocamp.import.importButton', { count: readyCount }, readyCount)"
|
|
436
602
|
:disabled="readyCount === 0"
|
|
437
603
|
@click="startImport"
|
|
@@ -447,7 +613,7 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
|
|
|
447
613
|
</template>
|
|
448
614
|
<template v-else-if="step === 'done'">
|
|
449
615
|
<UButton
|
|
450
|
-
v-if="failures.length > 0"
|
|
616
|
+
v-if="failures.length > 0 && !serverFile"
|
|
451
617
|
:label="t('nuxtUiMongocamp.import.retryFailed')"
|
|
452
618
|
color="neutral"
|
|
453
619
|
variant="subtle"
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
describeKey,
|
|
12
12
|
formatBytes,
|
|
13
13
|
indexKeys,
|
|
14
|
+
isExpiringIndex,
|
|
15
|
+
isTextIndex,
|
|
14
16
|
isUnusedIndex,
|
|
15
17
|
MAX_INDEX_FIELDS,
|
|
16
18
|
validateIndexForm
|
|
@@ -26,7 +28,7 @@ const emit = defineEmits(["changed"]);
|
|
|
26
28
|
const { t } = useI18n();
|
|
27
29
|
const toast = useToast();
|
|
28
30
|
const { describeServerError } = useMongocampError();
|
|
29
|
-
const {
|
|
31
|
+
const { listIndexDetails, createOrderedIndex, createExpiringIndex, deleteIndex } = useMongocampIndex();
|
|
30
32
|
const { getStorage, getIndexUsage } = useMongocampCollectionStats();
|
|
31
33
|
const UBadge = resolveComponent("UBadge");
|
|
32
34
|
const UButton = resolveComponent("UButton");
|
|
@@ -44,7 +46,7 @@ async function load() {
|
|
|
44
46
|
loading.value = true;
|
|
45
47
|
loadError.value = null;
|
|
46
48
|
try {
|
|
47
|
-
const [list, size, uses] = await Promise.allSettled([
|
|
49
|
+
const [list, size, uses] = await Promise.allSettled([listIndexDetails(props.collectionName), getStorage(props.collectionName), getIndexUsage(props.collectionName)]);
|
|
48
50
|
if (mine !== run) return;
|
|
49
51
|
if (list.status === "rejected") {
|
|
50
52
|
loadError.value = list.reason;
|
|
@@ -66,9 +68,13 @@ const rows = computed(
|
|
|
66
68
|
name: idx.name,
|
|
67
69
|
keys: indexKeys(idx).map(describeKey).join(", "),
|
|
68
70
|
unique: idx.unique,
|
|
69
|
-
text: idx
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
text: isTextIndex(idx),
|
|
72
|
+
sparse: idx.sparse,
|
|
73
|
+
hidden: idx.hidden,
|
|
74
|
+
partial: idx.partialFilterExpression != null,
|
|
75
|
+
collation: idx.collation != null,
|
|
76
|
+
language: idx.defaultLanguage ?? void 0,
|
|
77
|
+
expireAfterSeconds: isExpiringIndex(idx) ? idx.expireAfterSeconds : void 0,
|
|
72
78
|
size: storage.value?.indexSizes[idx.name],
|
|
73
79
|
ops: usage.value.get(idx.name)?.ops,
|
|
74
80
|
since: usage.value.get(idx.name)?.since
|
|
@@ -97,7 +103,12 @@ const columns = computed(() => [
|
|
|
97
103
|
const flags = [];
|
|
98
104
|
if (row.original.unique) flags.push({ label: "unique", color: "warning" });
|
|
99
105
|
if (row.original.text) flags.push({ label: "text", color: "info" });
|
|
100
|
-
if (row.original.
|
|
106
|
+
if (row.original.expireAfterSeconds !== void 0) flags.push({ label: `expire ${row.original.expireAfterSeconds}s`, color: "secondary" });
|
|
107
|
+
if (row.original.sparse) flags.push({ label: "sparse", color: "secondary" });
|
|
108
|
+
if (row.original.partial) flags.push({ label: "partial", color: "secondary" });
|
|
109
|
+
if (row.original.hidden) flags.push({ label: "hidden", color: "warning" });
|
|
110
|
+
if (row.original.collation) flags.push({ label: "collation", color: "secondary" });
|
|
111
|
+
if (row.original.text && row.original.language) flags.push({ label: row.original.language, color: "info" });
|
|
101
112
|
const badges = flags.map((flag) => h(UBadge, { label: flag.label, color: flag.color, variant: "subtle", size: "sm" }));
|
|
102
113
|
if (badges.length === 0) badges.push(h(UBadge, { label: t("nuxtUiMongocamp.collectionInfos.typeStandard"), color: "neutral", variant: "subtle", size: "sm" }));
|
|
103
114
|
return h("div", { class: "flex flex-wrap gap-1" }, badges);
|
|
@@ -153,17 +164,20 @@ const createError = ref("");
|
|
|
153
164
|
const creating = ref(false);
|
|
154
165
|
const form = ref(blankForm());
|
|
155
166
|
function blankForm() {
|
|
156
|
-
return { kind: "standard", fields: [{ field: "", descending: false }], name: "", expireAfter: "3600s" };
|
|
167
|
+
return { kind: "standard", fields: [{ field: "", descending: false }], name: "", expireAfter: "3600s", sparse: false, hidden: false, partialFilter: "" };
|
|
157
168
|
}
|
|
169
|
+
const PARTIAL_PLACEHOLDER = '{ "status": "active" }';
|
|
158
170
|
const kindItems = computed(() => ["standard", "unique", "text", "expiring"].map((kind) => ({
|
|
159
171
|
value: kind,
|
|
160
172
|
label: t(`nuxtUiMongocamp.indexes.kind${kind.charAt(0).toUpperCase()}${kind.slice(1)}`)
|
|
161
173
|
})));
|
|
162
|
-
const singleField = computed(() => form.value.kind === "
|
|
174
|
+
const singleField = computed(() => form.value.kind === "expiring");
|
|
175
|
+
const textKind = computed(() => form.value.kind === "text");
|
|
176
|
+
const takesOptions = computed(() => form.value.kind !== "expiring");
|
|
163
177
|
const shownFields = computed(() => singleField.value ? form.value.fields.slice(0, 1) : form.value.fields);
|
|
164
178
|
const problems = computed(() => validateIndexForm(form.value));
|
|
165
179
|
const problemText = (problem) => {
|
|
166
|
-
const key = { "no-field": "problemNoField", "empty-field": "problemEmptyField", "duplicate-field": "problemDuplicateField", "too-many-fields": "problemTooManyFields", "bad-duration": "problemBadDuration", "bad-name": "problemBadName" }[problem];
|
|
180
|
+
const key = { "no-field": "problemNoField", "empty-field": "problemEmptyField", "duplicate-field": "problemDuplicateField", "too-many-fields": "problemTooManyFields", "bad-duration": "problemBadDuration", "bad-name": "problemBadName", "bad-partial-filter": "problemPartialJson", "sparse-and-partial": "problemSparsePartial" }[problem];
|
|
167
181
|
return t(`nuxtUiMongocamp.indexes.${key}`, { max: MAX_INDEX_FIELDS });
|
|
168
182
|
};
|
|
169
183
|
function openCreate() {
|
|
@@ -194,7 +208,7 @@ async function submitCreate() {
|
|
|
194
208
|
const request = buildIndexRequest(form.value);
|
|
195
209
|
creating.value = true;
|
|
196
210
|
try {
|
|
197
|
-
const result = request.call === "
|
|
211
|
+
const result = request.call === "createOrderedIndex" ? await createOrderedIndex(props.collectionName, request.keys, request.options) : await createExpiringIndex(props.collectionName, request.field, request.duration);
|
|
198
212
|
createOpen.value = false;
|
|
199
213
|
toast.add({ title: t("nuxtUiMongocamp.indexes.created", { name: result.name }), color: "success" });
|
|
200
214
|
await load();
|
|
@@ -338,7 +352,7 @@ async function runDrop() {
|
|
|
338
352
|
:aria-label="t('nuxtUiMongocamp.indexes.fieldLabel', { position: index + 1 })"
|
|
339
353
|
/>
|
|
340
354
|
<UButton
|
|
341
|
-
v-if="!singleField"
|
|
355
|
+
v-if="!singleField && !textKind"
|
|
342
356
|
:icon="row.descending ? 'i-lucide-arrow-down-wide-narrow' : 'i-lucide-arrow-up-narrow-wide'"
|
|
343
357
|
color="neutral"
|
|
344
358
|
variant="ghost"
|
|
@@ -374,7 +388,7 @@ async function runDrop() {
|
|
|
374
388
|
@click="addField"
|
|
375
389
|
/>
|
|
376
390
|
<p
|
|
377
|
-
v-if="!singleField && form.fields.length > 1"
|
|
391
|
+
v-if="!singleField && !textKind && form.fields.length > 1"
|
|
378
392
|
class="text-xs text-dimmed"
|
|
379
393
|
>
|
|
380
394
|
{{ t("nuxtUiMongocamp.indexes.compoundNote") }}
|
|
@@ -400,7 +414,7 @@ async function runDrop() {
|
|
|
400
414
|
</UFormField>
|
|
401
415
|
|
|
402
416
|
<UFormField
|
|
403
|
-
v-if="
|
|
417
|
+
v-if="takesOptions"
|
|
404
418
|
:label="t('nuxtUiMongocamp.indexes.nameLabel')"
|
|
405
419
|
>
|
|
406
420
|
<UInput
|
|
@@ -410,6 +424,33 @@ async function runDrop() {
|
|
|
410
424
|
/>
|
|
411
425
|
</UFormField>
|
|
412
426
|
|
|
427
|
+
<template v-if="takesOptions">
|
|
428
|
+
<div class="flex flex-wrap gap-x-6 gap-y-2">
|
|
429
|
+
<UCheckbox
|
|
430
|
+
v-model="form.sparse"
|
|
431
|
+
:label="t('nuxtUiMongocamp.indexes.sparseLabel')"
|
|
432
|
+
:description="t('nuxtUiMongocamp.indexes.sparseHelp')"
|
|
433
|
+
/>
|
|
434
|
+
<UCheckbox
|
|
435
|
+
v-model="form.hidden"
|
|
436
|
+
:label="t('nuxtUiMongocamp.indexes.hiddenLabel')"
|
|
437
|
+
:description="t('nuxtUiMongocamp.indexes.hiddenHelp')"
|
|
438
|
+
/>
|
|
439
|
+
</div>
|
|
440
|
+
<UFormField
|
|
441
|
+
:label="t('nuxtUiMongocamp.indexes.partialLabel')"
|
|
442
|
+
:help="t('nuxtUiMongocamp.indexes.partialHelp')"
|
|
443
|
+
>
|
|
444
|
+
<UTextarea
|
|
445
|
+
v-model="form.partialFilter"
|
|
446
|
+
class="w-full font-mono"
|
|
447
|
+
:rows="2"
|
|
448
|
+
:placeholder="PARTIAL_PLACEHOLDER"
|
|
449
|
+
:aria-label="t('nuxtUiMongocamp.indexes.partialLabel')"
|
|
450
|
+
/>
|
|
451
|
+
</UFormField>
|
|
452
|
+
</template>
|
|
453
|
+
|
|
413
454
|
<ul
|
|
414
455
|
v-if="attempted && problems.length > 0"
|
|
415
456
|
class="list-disc pl-5 text-sm text-error"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed, h, onMounted, reactive, ref, resolveComponent, watch } from "vue";
|
|
3
3
|
import { useI18n, useMongocampError, useMongocampJobs, useToast } from "#imports";
|
|
4
4
|
import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
|
|
5
|
+
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
5
6
|
const props = defineProps({
|
|
6
7
|
autoRefresh: { type: Number, required: false, default: 0 }
|
|
7
8
|
});
|
|
@@ -42,10 +43,11 @@ async function reloadQuietly() {
|
|
|
42
43
|
throw e;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
46
|
+
const { blocked, message } = useMongocampAdminGate();
|
|
45
47
|
const auto = useMongocampAutoRefresh(reloadQuietly, { intervalMs: () => props.autoRefresh * 1e3 });
|
|
46
48
|
function syncAutoRefresh() {
|
|
47
49
|
auto.stop();
|
|
48
|
-
if (props.autoRefresh > 0) auto.start();
|
|
50
|
+
if (!blocked.value && props.autoRefresh > 0) auto.start();
|
|
49
51
|
}
|
|
50
52
|
onMounted(syncAutoRefresh);
|
|
51
53
|
watch(() => props.autoRefresh, syncAutoRefresh);
|
|
@@ -282,11 +284,20 @@ const columns = computed(() => [
|
|
|
282
284
|
}
|
|
283
285
|
}
|
|
284
286
|
]);
|
|
285
|
-
fetchJobs();
|
|
287
|
+
if (!blocked.value) fetchJobs();
|
|
286
288
|
</script>
|
|
287
289
|
|
|
288
290
|
<template>
|
|
289
|
-
<
|
|
291
|
+
<MongocampEmptyState
|
|
292
|
+
v-if="blocked"
|
|
293
|
+
icon="i-lucide-shield-alert"
|
|
294
|
+
:title="message"
|
|
295
|
+
data-test="admin-only"
|
|
296
|
+
/>
|
|
297
|
+
<div
|
|
298
|
+
v-else
|
|
299
|
+
class="flex flex-col gap-4"
|
|
300
|
+
>
|
|
290
301
|
<div class="flex items-center justify-between gap-4">
|
|
291
302
|
<h2 class="text-xl font-semibold">
|
|
292
303
|
{{ t("nuxtUiMongocamp.jobs.heading") }}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed, h, reactive, ref, resolveComponent } from "vue";
|
|
3
3
|
import { useI18n, useMongocampError } from "#imports";
|
|
4
4
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
5
|
+
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
5
6
|
const props = defineProps({
|
|
6
7
|
roleName: { type: String, required: true }
|
|
7
8
|
});
|
|
@@ -63,6 +64,7 @@ const editGrantSchema = reactive([
|
|
|
63
64
|
}
|
|
64
65
|
]);
|
|
65
66
|
const loadError = ref(null);
|
|
67
|
+
const { blocked, message } = useMongocampAdminGate();
|
|
66
68
|
async function fetchRole() {
|
|
67
69
|
loading.value = true;
|
|
68
70
|
loadError.value = null;
|
|
@@ -220,12 +222,23 @@ const columns = computed(() => [
|
|
|
220
222
|
])
|
|
221
223
|
}
|
|
222
224
|
]);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
+
if (!blocked.value) {
|
|
226
|
+
fetchRole();
|
|
227
|
+
fetchCollections();
|
|
228
|
+
}
|
|
225
229
|
</script>
|
|
226
230
|
|
|
227
231
|
<template>
|
|
228
|
-
<
|
|
232
|
+
<MongocampEmptyState
|
|
233
|
+
v-if="blocked"
|
|
234
|
+
icon="i-lucide-shield-alert"
|
|
235
|
+
:title="message"
|
|
236
|
+
data-test="admin-only"
|
|
237
|
+
/>
|
|
238
|
+
<div
|
|
239
|
+
v-else
|
|
240
|
+
class="flex flex-col gap-4"
|
|
241
|
+
>
|
|
229
242
|
<div class="flex items-center justify-between">
|
|
230
243
|
<h2 class="text-xl font-semibold">
|
|
231
244
|
{{ t("nuxtUiMongocamp.roleGrants.heading", { roleName }) }}
|
|
@@ -4,6 +4,7 @@ import { useI18n, useMongocampError } from "#imports";
|
|
|
4
4
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
5
5
|
import { runBulkDelete } from "../utils/bulkDelete";
|
|
6
6
|
import { createSelectColumn } from "../utils/createSelectColumn";
|
|
7
|
+
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
7
8
|
const props = defineProps({
|
|
8
9
|
grantsPath: { type: String, required: false }
|
|
9
10
|
});
|
|
@@ -82,6 +83,7 @@ async function handleBulkDelete() {
|
|
|
82
83
|
bulkDeleting.value = false;
|
|
83
84
|
}
|
|
84
85
|
}
|
|
86
|
+
const { blocked, message } = useMongocampAdminGate();
|
|
85
87
|
async function fetchRoles() {
|
|
86
88
|
loading.value = true;
|
|
87
89
|
loadError.value = null;
|
|
@@ -263,11 +265,20 @@ const columns = computed(() => [
|
|
|
263
265
|
])
|
|
264
266
|
}
|
|
265
267
|
]);
|
|
266
|
-
fetchRoles();
|
|
268
|
+
if (!blocked.value) fetchRoles();
|
|
267
269
|
</script>
|
|
268
270
|
|
|
269
271
|
<template>
|
|
270
|
-
<
|
|
272
|
+
<MongocampEmptyState
|
|
273
|
+
v-if="blocked"
|
|
274
|
+
icon="i-lucide-shield-alert"
|
|
275
|
+
:title="message"
|
|
276
|
+
data-test="admin-only"
|
|
277
|
+
/>
|
|
278
|
+
<div
|
|
279
|
+
v-else
|
|
280
|
+
class="flex flex-col gap-4"
|
|
281
|
+
>
|
|
271
282
|
<div class="flex items-center justify-between gap-4">
|
|
272
283
|
<h2 class="text-xl font-semibold">
|
|
273
284
|
{{ t("nuxtUiMongocamp.roles.heading") }}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
3
3
|
import { useI18n } from "#imports";
|
|
4
4
|
import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
|
|
5
|
+
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
5
6
|
import { useMongocampServerOverview } from "../composables/useMongocampServerOverview";
|
|
6
7
|
import { formatBytes } from "../utils/formatBytes";
|
|
7
8
|
import { BYTE_METRICS, nextJobs, overviewTotals, rankCollections, RANK_METRICS, shareSlices } from "../utils/serverOverview";
|
|
@@ -18,44 +19,34 @@ const { t, locale } = useI18n();
|
|
|
18
19
|
const { loadOverview } = useMongocampServerOverview();
|
|
19
20
|
const overview = ref(null);
|
|
20
21
|
const loading = ref(false);
|
|
21
|
-
const progress = ref(null);
|
|
22
22
|
const rankBy = ref("storageSize");
|
|
23
23
|
let controller;
|
|
24
|
-
async function load(
|
|
24
|
+
async function load() {
|
|
25
25
|
controller?.abort();
|
|
26
26
|
const own = new AbortController();
|
|
27
27
|
controller = own;
|
|
28
28
|
loading.value = true;
|
|
29
|
-
if (!options.silent) progress.value = null;
|
|
30
29
|
try {
|
|
31
30
|
const result = await loadOverview({
|
|
32
31
|
maxCollections: props.maxCollections,
|
|
33
|
-
signal: own.signal
|
|
34
|
-
onProgress: (p) => {
|
|
35
|
-
if (controller === own && !options.silent) progress.value = p;
|
|
36
|
-
}
|
|
32
|
+
signal: own.signal
|
|
37
33
|
});
|
|
38
34
|
if (controller === own) overview.value = result;
|
|
39
35
|
} catch (e) {
|
|
40
36
|
if (own.signal.aborted) return;
|
|
41
37
|
throw e;
|
|
42
38
|
} finally {
|
|
43
|
-
if (controller === own)
|
|
44
|
-
loading.value = false;
|
|
45
|
-
progress.value = null;
|
|
46
|
-
}
|
|
39
|
+
if (controller === own) loading.value = false;
|
|
47
40
|
}
|
|
48
41
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
const auto = useMongocampAutoRefresh(() => load({ silent: true }), { intervalMs: () => props.autoRefresh * 1e3 });
|
|
42
|
+
const { blocked, message } = useMongocampAdminGate();
|
|
43
|
+
const auto = useMongocampAutoRefresh(() => load(), { intervalMs: () => props.autoRefresh * 1e3 });
|
|
53
44
|
function syncAutoRefresh() {
|
|
54
45
|
auto.stop();
|
|
55
|
-
if (props.autoRefresh > 0) auto.start();
|
|
46
|
+
if (!blocked.value && props.autoRefresh > 0) auto.start();
|
|
56
47
|
}
|
|
57
48
|
onMounted(() => {
|
|
58
|
-
void load();
|
|
49
|
+
if (!blocked.value) void load();
|
|
59
50
|
syncAutoRefresh();
|
|
60
51
|
});
|
|
61
52
|
watch(() => props.autoRefresh, syncAutoRefresh);
|
|
@@ -89,7 +80,14 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
89
80
|
</script>
|
|
90
81
|
|
|
91
82
|
<template>
|
|
83
|
+
<MongocampEmptyState
|
|
84
|
+
v-if="blocked"
|
|
85
|
+
icon="i-lucide-shield-alert"
|
|
86
|
+
:title="message"
|
|
87
|
+
data-test="admin-only"
|
|
88
|
+
/>
|
|
92
89
|
<div
|
|
90
|
+
v-else
|
|
93
91
|
class="flex flex-col gap-6"
|
|
94
92
|
data-test="server-overview"
|
|
95
93
|
>
|
|
@@ -106,33 +104,12 @@ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]
|
|
|
106
104
|
icon="i-lucide-refresh-cw"
|
|
107
105
|
color="neutral"
|
|
108
106
|
variant="ghost"
|
|
109
|
-
:loading="loading
|
|
107
|
+
:loading="loading"
|
|
110
108
|
:aria-label="t('nuxtUiMongocamp.common.refresh')"
|
|
111
109
|
@click="load()"
|
|
112
110
|
/>
|
|
113
111
|
</div>
|
|
114
112
|
|
|
115
|
-
<div
|
|
116
|
-
v-if="progress"
|
|
117
|
-
class="flex items-center gap-3"
|
|
118
|
-
role="status"
|
|
119
|
-
data-test="overview-progress"
|
|
120
|
-
>
|
|
121
|
-
<UProgress
|
|
122
|
-
:model-value="progress.done"
|
|
123
|
-
:max="progress.total"
|
|
124
|
-
class="flex-1"
|
|
125
|
-
/>
|
|
126
|
-
<span class="text-sm text-dimmed">{{ t("nuxtUiMongocamp.serverOverview.reading", progress) }}</span>
|
|
127
|
-
<UButton
|
|
128
|
-
:label="t('nuxtUiMongocamp.serverOverview.stop')"
|
|
129
|
-
color="neutral"
|
|
130
|
-
variant="soft"
|
|
131
|
-
size="sm"
|
|
132
|
-
@click="stop"
|
|
133
|
-
/>
|
|
134
|
-
</div>
|
|
135
|
-
|
|
136
113
|
<UAlert
|
|
137
114
|
v-for="part in failedParts"
|
|
138
115
|
:key="part"
|
|
@@ -13,6 +13,8 @@ type __VLS_Props = {
|
|
|
13
13
|
hideSearch?: boolean;
|
|
14
14
|
/** Hide the note that secret values are masked. */
|
|
15
15
|
hideMaskedNote?: boolean;
|
|
16
|
+
/** Hide the hint that the server answers a missing grant with 401 (`AUTH_GRANT_DENIED_STATUS`). */
|
|
17
|
+
hideGrantHint?: boolean;
|
|
16
18
|
};
|
|
17
19
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
18
20
|
hideHeading: boolean;
|
|
@@ -22,6 +24,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
22
24
|
hideConfigurations: boolean;
|
|
23
25
|
hideSearch: boolean;
|
|
24
26
|
hideMaskedNote: boolean;
|
|
27
|
+
hideGrantHint: boolean;
|
|
25
28
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
26
29
|
declare const _default: typeof __VLS_export;
|
|
27
30
|
export default _default;
|