@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.
Files changed (93) hide show
  1. package/README.md +1 -1
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
  4. package/dist/runtime/components/MongocampAggregationBuilder.vue +29 -2
  5. package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
  6. package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +1 -0
  7. package/dist/runtime/components/MongocampAggregationStagePreview.vue +4 -3
  8. package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +1 -0
  9. package/dist/runtime/components/MongocampBucketFiles.vue +61 -0
  10. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +2 -12
  11. package/dist/runtime/components/MongocampBulkDelete.vue +14 -40
  12. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +2 -12
  13. package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +5 -6
  14. package/dist/runtime/components/MongocampBulkEdit.vue +43 -26
  15. package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +5 -6
  16. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +2 -0
  17. package/dist/runtime/components/MongocampCollectionCharts.vue +9 -8
  18. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +2 -0
  19. package/dist/runtime/components/MongocampCollectionCopy.vue +19 -258
  20. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +2 -0
  21. package/dist/runtime/components/MongocampCollectionData.vue +206 -126
  22. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +2 -0
  23. package/dist/runtime/components/MongocampCollectionRename.d.vue.ts +22 -0
  24. package/dist/runtime/components/MongocampCollectionRename.vue +116 -0
  25. package/dist/runtime/components/MongocampCollectionRename.vue.d.ts +22 -0
  26. package/dist/runtime/components/MongocampCollections.vue +31 -12
  27. package/dist/runtime/components/MongocampCommandPalette.vue +2 -2
  28. package/dist/runtime/components/MongocampDashboard.vue +19 -4
  29. package/dist/runtime/components/MongocampDatabases.vue +13 -2
  30. package/dist/runtime/components/MongocampExportAll.vue +13 -26
  31. package/dist/runtime/components/MongocampImport.vue +169 -3
  32. package/dist/runtime/components/MongocampIndexes.vue +54 -13
  33. package/dist/runtime/components/MongocampJobs.vue +14 -3
  34. package/dist/runtime/components/MongocampRoleGrants.vue +16 -3
  35. package/dist/runtime/components/MongocampRoles.vue +13 -2
  36. package/dist/runtime/components/MongocampServerOverview.vue +16 -39
  37. package/dist/runtime/components/MongocampSettings.d.vue.ts +3 -0
  38. package/dist/runtime/components/MongocampSettings.vue +14 -2
  39. package/dist/runtime/components/MongocampSettings.vue.d.ts +3 -0
  40. package/dist/runtime/components/MongocampUsers.vue +16 -3
  41. package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
  42. package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
  43. package/dist/runtime/composables/useMongocampAggregation.d.ts +11 -0
  44. package/dist/runtime/composables/useMongocampAggregation.js +12 -5
  45. package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
  46. package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
  47. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +25 -65
  48. package/dist/runtime/composables/useMongocampCollectionCopy.js +27 -84
  49. package/dist/runtime/composables/useMongocampExportAll.d.ts +27 -21
  50. package/dist/runtime/composables/useMongocampExportAll.js +51 -21
  51. package/dist/runtime/composables/useMongocampExtendedJson.d.ts +2 -1
  52. package/dist/runtime/composables/useMongocampExtendedJson.js +32 -5
  53. package/dist/runtime/composables/useMongocampFetchAll.js +1 -1
  54. package/dist/runtime/composables/useMongocampFieldTypes.d.ts +24 -0
  55. package/dist/runtime/composables/useMongocampFieldTypes.js +44 -0
  56. package/dist/runtime/composables/useMongocampImport.d.ts +4 -0
  57. package/dist/runtime/composables/useMongocampImport.js +5 -2
  58. package/dist/runtime/composables/useMongocampIndex.d.ts +6 -1
  59. package/dist/runtime/composables/useMongocampIndex.js +7 -1
  60. package/dist/runtime/composables/useMongocampPermissions.d.ts +8 -5
  61. package/dist/runtime/composables/useMongocampPermissions.js +24 -2
  62. package/dist/runtime/composables/useMongocampQuery.d.ts +3 -3
  63. package/dist/runtime/composables/useMongocampServerOverview.d.ts +4 -11
  64. package/dist/runtime/composables/useMongocampServerOverview.js +12 -22
  65. package/dist/runtime/locales/de.json +69 -71
  66. package/dist/runtime/locales/en.json +69 -71
  67. package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
  68. package/dist/runtime/utils/aggregationErrors.js +7 -0
  69. package/dist/runtime/utils/batchInsert.d.ts +6 -0
  70. package/dist/runtime/utils/batchInsert.js +31 -3
  71. package/dist/runtime/utils/bsonTypes.d.ts +10 -0
  72. package/dist/runtime/utils/bsonTypes.js +42 -0
  73. package/dist/runtime/utils/collectionCopy.d.ts +0 -2
  74. package/dist/runtime/utils/collectionCopy.js +0 -1
  75. package/dist/runtime/utils/configRows.d.ts +7 -0
  76. package/dist/runtime/utils/configRows.js +4 -0
  77. package/dist/runtime/utils/documentCompare.js +2 -1
  78. package/dist/runtime/utils/documentPaths.d.ts +5 -8
  79. package/dist/runtime/utils/documentPaths.js +5 -10
  80. package/dist/runtime/utils/documentTree.js +9 -1
  81. package/dist/runtime/utils/exportDocuments.d.ts +0 -2
  82. package/dist/runtime/utils/exportDocuments.js +0 -1
  83. package/dist/runtime/utils/exportRows.d.ts +2 -0
  84. package/dist/runtime/utils/exportRows.js +5 -2
  85. package/dist/runtime/utils/fieldDetails.d.ts +51 -0
  86. package/dist/runtime/utils/fieldDetails.js +113 -0
  87. package/dist/runtime/utils/indexForm.d.ts +47 -33
  88. package/dist/runtime/utils/indexForm.js +32 -21
  89. package/package.json +8 -8
  90. package/dist/runtime/utils/indexCopy.d.ts +0 -26
  91. package/dist/runtime/utils/indexCopy.js +0 -22
  92. package/dist/runtime/utils/limitedMap.d.ts +0 -17
  93. package/dist/runtime/utils/limitedMap.js +0 -19
@@ -20,13 +20,18 @@ import useMongocampDocument from "../composables/useMongocampDocument";
20
20
  import { useMongocampQuery } from "../composables/useMongocampQuery";
21
21
  import { useMongocampAggregation } from "../composables/useMongocampAggregation";
22
22
  import { useMongocampPersistedState } from "../composables/useMongocampPersistedState";
23
- import { useMongocampFetchAll } from "../composables/useMongocampFetchAll";
23
+ import { useMongocampBulkByFilter } from "../composables/useMongocampBulkByFilter";
24
+ import { useMongocampFieldTypes } from "../composables/useMongocampFieldTypes";
25
+ import { wireValue } from "../utils/bsonTypes";
24
26
  import MongocampDocumentView from "./MongocampDocumentView.vue";
25
27
  import MongocampQueryBar from "./MongocampQueryBar.vue";
26
28
  import MongocampExportAll from "./MongocampExportAll.vue";
29
+ import MongocampCollectionCharts from "./MongocampCollectionCharts.vue";
30
+ import { isFilterTooLong } from "../utils/requestLimits";
27
31
  const props = defineProps({
28
32
  collectionName: { type: String, required: true },
29
33
  infoPath: { type: String, required: false, default: "/secured/admin/collections" },
34
+ aggregatePath: { type: String, required: false, default: "" },
30
35
  persistState: { type: Boolean, required: false, default: true },
31
36
  stateKey: { type: String, required: false, default: "" }
32
37
  });
@@ -45,7 +50,8 @@ const { schemaFromSamples } = useMongocampSchema();
45
50
  const { listDistinct } = useMongocampAggregation();
46
51
  const { createIndexForField } = useMongocampIndex();
47
52
  const { isManager } = useMongocampRoles();
48
- const { canWrite } = useMongocampPermissions();
53
+ const { canWrite, load: loadPermissions } = useMongocampPermissions();
54
+ watch(() => props.collectionName, (name) => loadPermissions(name), { immediate: true });
49
55
  const writable = computed(() => canWrite(props.collectionName));
50
56
  const toast = useToast();
51
57
  const fileInputRef = ref(null);
@@ -103,24 +109,22 @@ function openInsert() {
103
109
  }
104
110
  isEditModalOpen.value = true;
105
111
  }
106
- async function loadFullRow(row) {
112
+ async function loadTypedRow(row) {
107
113
  const id = getDocId(row);
108
114
  if (!id) return void 0;
109
- const res = await documentApi.getDocumentRaw({ collectionName: props.collectionName, documentId: id });
115
+ const res = await documentApi.getDocumentRaw({ collectionName: props.collectionName, documentId: id, extendedJson: "canonical" });
110
116
  return await readJsonKeepingLongs(res);
111
117
  }
112
118
  async function openEdit(row) {
113
119
  const projected = activeProjection.value.length > 0;
114
- let source = row;
115
- if (projected) {
116
- try {
117
- const full = await loadFullRow(row);
118
- if (!full) throw new Error("no id");
119
- source = full;
120
- } catch {
121
- toast.add({ title: t("nuxtUiMongocamp.collectionData.editLoadFailed"), color: "error" });
122
- return;
123
- }
120
+ let source;
121
+ try {
122
+ const typed = await loadTypedRow(row);
123
+ if (!typed) throw new Error("no id");
124
+ source = typed;
125
+ } catch {
126
+ toast.add({ title: t("nuxtUiMongocamp.collectionData.editLoadFailed"), color: "error" });
127
+ return;
124
128
  }
125
129
  editMode.value = "update";
126
130
  editDocId.value = getDocId(source);
@@ -144,7 +148,7 @@ async function handleSave() {
144
148
  let payload;
145
149
  if (editSamples.value.length > 0) {
146
150
  const { slots: _slots, ...formValues } = editFormData.value;
147
- payload = wrapExtendedJson(formValues, editMode.value === "update" ? originalRow.value : void 0);
151
+ payload = wrapExtendedJson(formValues, editMode.value === "update" ? originalRow.value : void 0, fieldTypes.hints());
148
152
  } else {
149
153
  try {
150
154
  payload = JSON.parse(editJson.value);
@@ -165,6 +169,7 @@ async function handleSave() {
165
169
  try {
166
170
  if (editMode.value === "insert") {
167
171
  await documentApi.insert({ collectionName: props.collectionName, requestBody: payload });
172
+ void fieldTypes.load(true);
168
173
  } else {
169
174
  if (!editDocId.value) return;
170
175
  const changes = original ? diffDocument(original, payload) : null;
@@ -318,13 +323,20 @@ const filterText = ref("");
318
323
  const filterableColumns = ref([]);
319
324
  const query = ref(emptyQueryState());
320
325
  const queryBar = ref(null);
321
- const filterFields = ref([]);
326
+ const fieldTypes = useMongocampFieldTypes(() => props.collectionName);
327
+ const pageFilterFields = ref([]);
328
+ const filterFields = computed(() => {
329
+ const fromServer = fieldTypes.filterFields().filter((f) => operatorsFor(f.type).length > 0);
330
+ return fromServer.length > 0 ? fromServer : pageFilterFields.value;
331
+ });
322
332
  const sorting = ref([]);
323
333
  const columnVisibility = ref({});
324
334
  const PAGE_SIZES = [10, 20, 50, 100];
325
335
  const isInitializing = ref(false);
326
336
  const detailOpen = ref(false);
327
337
  const compareOpen = ref(false);
338
+ const compareState = ref("loading");
339
+ const typedPair = ref(null);
328
340
  const compareRows = computed(() => {
329
341
  const ticked = documents.value.filter((row, index) => rowSelection.value[rowId(row, index)]);
330
342
  return ticked.length === 2 && selectedDocIds.value.length === 2 ? ticked : [];
@@ -337,6 +349,14 @@ let filterTimer;
337
349
  function openView(row) {
338
350
  viewDoc.value = row;
339
351
  viewOpen.value = true;
352
+ void showTyped(row);
353
+ }
354
+ async function showTyped(row) {
355
+ try {
356
+ const typed = await loadTypedRow(row);
357
+ if (typed && viewDoc.value === row) viewDoc.value = typed;
358
+ } catch {
359
+ }
340
360
  }
341
361
  const pageJson = computed(() => valueToJson(documents.value, true));
342
362
  function openDetail(value) {
@@ -470,75 +490,52 @@ const bulkError = ref("");
470
490
  const bulkEditing = ref(false);
471
491
  const bulkEditError = ref("");
472
492
  const bulkEditOpen = ref(false);
473
- const MAX_MATCHING = 1e4;
474
- const { fetchAllDocuments } = useMongocampFetchAll();
493
+ const { countDocuments, deleteByFilter, updateByFilter } = useMongocampBulkByFilter();
475
494
  const matching = ref(null);
476
- const collecting = ref(null);
495
+ const counting = ref(false);
477
496
  const bulkNote = ref("");
478
- const bulkProgress = ref(null);
479
- let collectController;
480
- let bulkController;
481
- const bulkIds = computed(() => matching.value?.ids ?? selectedDocIds.value);
497
+ const bulkIds = computed(() => matching.value ? [] : selectedDocIds.value);
498
+ const bulkCount = computed(() => matching.value?.count ?? bulkIds.value.length);
482
499
  const selectablePageCount = computed(() => writable.value && !isBucketCollection(props.collectionName) ? documents.value.length : 0);
483
500
  function clearMatching() {
484
501
  matching.value = null;
485
502
  bulkNote.value = "";
486
503
  }
487
- function isAbort(error) {
488
- return error?.name === "AbortError";
489
- }
490
504
  async function collectMatching() {
491
505
  clearMatching();
492
- const target = total.value;
493
- if (target > MAX_MATCHING) {
494
- bulkNote.value = t("nuxtUiMongocamp.bulk.matchingTooMany", { total: target, cap: MAX_MATCHING });
495
- return;
496
- }
497
- const controller = new AbortController();
498
- collectController = controller;
499
- collecting.value = { loaded: 0, target };
506
+ const filter = buildLuceneFilter(filterText.value);
507
+ counting.value = true;
500
508
  try {
501
- const result = await fetchAllDocuments(props.collectionName, {
502
- filter: buildLuceneFilter(filterText.value),
503
- projection: ["_id"],
504
- pageSize: 1e3,
505
- maxRows: MAX_MATCHING,
506
- signal: controller.signal,
507
- keyOf: (row) => String(getDocId(row) ?? ""),
508
- onProgress: (p) => collecting.value = { loaded: p.loaded, target: p.target }
509
- });
510
- if (result.truncated) {
511
- bulkNote.value = t("nuxtUiMongocamp.bulk.matchingChanged");
512
- return;
513
- }
514
- const ids = result.rows.flatMap((row) => {
515
- const id = getDocId(row);
516
- return id ? [id] : [];
517
- });
518
- const reported = result.total ?? ids.length;
519
- matching.value = { ids, reported };
509
+ const count = await countDocuments(props.collectionName, filter);
510
+ matching.value = { filter, count };
520
511
  rowSelection.value = {};
521
- if (ids.length !== reported || result.totalChanged) {
522
- bulkNote.value = t("nuxtUiMongocamp.bulk.matchingDrift", { collected: ids.length, reported });
523
- }
512
+ if (count !== total.value) bulkNote.value = t("nuxtUiMongocamp.bulk.matchingDrift", { counted: count, reported: total.value });
524
513
  } catch (e) {
525
- if (!isAbort(e)) bulkNote.value = (await describeServerError(e)).message;
514
+ bulkNote.value = (await describeServerError(e)).message;
526
515
  } finally {
527
- collecting.value = null;
528
- if (collectController === controller) collectController = void 0;
516
+ counting.value = false;
529
517
  }
530
518
  }
531
- function cancelCollect() {
532
- collectController?.abort();
533
- }
534
- function stopBulk() {
535
- bulkController?.abort();
536
- }
537
519
  function clearBulkSelection() {
538
- collectController?.abort();
539
520
  rowSelection.value = {};
540
521
  clearMatching();
541
522
  }
523
+ async function openCompare() {
524
+ const [left, right] = compareRows.value;
525
+ if (!left || !right) return;
526
+ compareOpen.value = true;
527
+ compareState.value = "loading";
528
+ typedPair.value = null;
529
+ try {
530
+ const [typedLeft, typedRight] = await Promise.all([loadTypedRow(left), loadTypedRow(right)]);
531
+ if (!typedLeft || !typedRight) throw new Error("no id");
532
+ if (!compareOpen.value) return;
533
+ typedPair.value = [typedLeft, typedRight];
534
+ compareState.value = "typed";
535
+ } catch {
536
+ compareState.value = "untyped";
537
+ }
538
+ }
542
539
  function openBulkEdit() {
543
540
  bulkEditError.value = "";
544
541
  bulkEditOpen.value = true;
@@ -549,13 +546,17 @@ function rowId(row, index) {
549
546
  async function handleBulkDelete() {
550
547
  bulkDeleting.value = true;
551
548
  bulkError.value = "";
552
- const ids = [...bulkIds.value];
553
- const all = matching.value !== null;
554
- const controller = new AbortController();
555
- bulkController = controller;
556
- bulkProgress.value = all ? { done: 0, total: ids.length } : null;
557
549
  try {
558
- const { deleted, failed, notAttempted } = await runBulkDelete(
550
+ if (matching.value) {
551
+ const { filter, count } = matching.value;
552
+ const deleted = await deleteByFilter(props.collectionName, filter);
553
+ clearMatching();
554
+ await fetchDocuments();
555
+ toast.add({ title: t("nuxtUiMongocamp.bulk.matchingDeleted", { deleted, total: count }), color: "success" });
556
+ return;
557
+ }
558
+ const ids = [...bulkIds.value];
559
+ const { failed } = await runBulkDelete(
559
560
  ids,
560
561
  (documentId) => documentApi._delete({ collectionName: props.collectionName, documentId }),
561
562
  void 0,
@@ -567,28 +568,25 @@ async function handleBulkDelete() {
567
568
  collectionName: props.collectionName,
568
569
  requestBody: buildIdFilter(chunk)
569
570
  })).deletedCount
570
- },
571
- { signal: controller.signal, onProgress: (done, totalIds) => bulkProgress.value = all ? { done, total: totalIds } : null }
571
+ }
572
572
  );
573
573
  await fetchDocuments();
574
- const left = [...failed.map((f) => f.item), ...notAttempted ?? []];
575
- if (all) {
576
- if (left.length > 0) matching.value = { ids: left, reported: left.length };
577
- if (notAttempted?.length) bulkError.value = t("nuxtUiMongocamp.bulk.stoppedDelete", { done: deleted.length, total: ids.length, left: notAttempted.length });
578
- else if (failed.length > 0) bulkError.value = t("nuxtUiMongocamp.bulk.partialFailure", { failed: failed.length, total: ids.length, reason: describeError(failed[0].error).message });
579
- else toast.add({ title: t("nuxtUiMongocamp.bulk.matchingDeleted", { deleted: deleted.length, total: ids.length }), color: "success" });
580
- } else if (failed.length > 0) {
574
+ if (failed.length > 0) {
581
575
  rowSelection.value = Object.fromEntries(failed.map((f) => [f.item, true]));
582
576
  bulkError.value = t("nuxtUiMongocamp.bulk.partialFailure", { failed: failed.length, total: ids.length, reason: describeError(failed[0].error).message });
583
577
  }
578
+ } catch (e) {
579
+ bulkError.value = (await describeServerError(e)).message;
584
580
  } finally {
585
581
  bulkDeleting.value = false;
586
- bulkProgress.value = null;
587
- if (bulkController === controller) bulkController = void 0;
588
582
  }
589
583
  }
590
584
  const editableFields = computed(
591
- () => filterFields.value.filter((f) => f.key !== "metaData" && isEditableField(f.key)).flatMap((f) => f.type === "objectId" ? [] : [{ key: f.key, type: f.type === "array" || f.type === "object" ? "json" : f.type }])
585
+ () => filterFields.value.filter((f) => f.key !== "metaData" && isEditableField(f.key)).flatMap((f) => {
586
+ if (f.type === "objectId") return [];
587
+ const info = fieldTypes.typeOf(f.key);
588
+ return [{ key: f.key, type: f.type === "array" || f.type === "object" ? "json" : f.type, bson: info?.dominant, mixed: info?.mixed }];
589
+ })
592
590
  );
593
591
  function bulkEditFailureReason(error) {
594
592
  if (error instanceof BulkMatchShortfall) return t("nuxtUiMongocamp.bulk.editShortfall", { matched: error.matched, expected: error.expected });
@@ -598,38 +596,36 @@ function bulkEditFailureReason(error) {
598
596
  async function handleBulkEdit(edit) {
599
597
  bulkEditing.value = true;
600
598
  bulkEditError.value = "";
601
- const ids = [...bulkIds.value];
602
- const all = matching.value !== null;
603
- const controller = new AbortController();
604
- bulkController = controller;
605
- bulkProgress.value = all ? { done: 0, total: ids.length } : null;
606
- const document = { [edit.field]: edit.value };
599
+ const value = edit.bson ? wireValue(edit.bson, edit.value) : edit.value;
600
+ const document = { [edit.field]: value };
607
601
  try {
608
- const { updated, failed, notAttempted } = await runBulkUpdate(
602
+ if (matching.value) {
603
+ const { filter, count } = matching.value;
604
+ const { modified } = await updateByFilter(props.collectionName, filter, document);
605
+ clearMatching();
606
+ await fetchDocuments();
607
+ toast.add({ title: t("nuxtUiMongocamp.bulk.matchingUpdated", { updated: modified, total: count }), color: "success" });
608
+ return;
609
+ }
610
+ const ids = [...bulkIds.value];
611
+ const { failed } = await runBulkUpdate(
609
612
  ids,
610
613
  (chunk) => documentApi.updateMany({
611
614
  collectionName: props.collectionName,
612
615
  updateRequest: { filter: buildIdFilter(chunk), document }
613
- }),
614
- { signal: controller.signal, onProgress: (done, totalIds) => bulkProgress.value = all ? { done, total: totalIds } : null }
616
+ })
615
617
  );
616
618
  await fetchDocuments();
617
- const failedIds = failed.flatMap((f) => f.ids);
618
- if (all) {
619
- const left = [...failedIds, ...notAttempted ?? []];
620
- if (left.length > 0) matching.value = { ids: left, reported: left.length };
621
- if (notAttempted?.length) bulkEditError.value = t("nuxtUiMongocamp.bulk.stoppedEdit", { done: updated.length, total: ids.length, left: notAttempted.length });
622
- else if (failedIds.length > 0) bulkEditError.value = t("nuxtUiMongocamp.bulk.editPartialFailure", { failed: failedIds.length, total: ids.length, reason: bulkEditFailureReason(failed[0].error) });
623
- else toast.add({ title: t("nuxtUiMongocamp.bulk.matchingUpdated", { updated: updated.length, total: ids.length }), color: "success" });
624
- } else if (failed.length > 0) {
619
+ if (failed.length > 0) {
620
+ const failedIds = failed.flatMap((f) => f.ids);
625
621
  const onScreen = new Set(documents.value.map((row) => getDocId(row)));
626
622
  rowSelection.value = Object.fromEntries(failedIds.filter((id) => onScreen.has(id)).map((id) => [id, true]));
627
623
  bulkEditError.value = t("nuxtUiMongocamp.bulk.editPartialFailure", { failed: failedIds.length, total: ids.length, reason: bulkEditFailureReason(failed[0].error) });
628
624
  }
625
+ } catch (e) {
626
+ bulkEditError.value = (await describeServerError(e)).message;
629
627
  } finally {
630
628
  bulkEditing.value = false;
631
- bulkProgress.value = null;
632
- if (bulkController === controller) bulkController = void 0;
633
629
  }
634
630
  }
635
631
  const projectableKeys = computed(() => dataColumnKeys.value.filter((k) => k !== "_id"));
@@ -638,19 +634,20 @@ async function fetchDocuments() {
638
634
  loading.value = true;
639
635
  loadError.value = null;
640
636
  rowSelection.value = {};
641
- collectController?.abort();
642
637
  clearMatching();
643
638
  filterRejected.value = false;
644
639
  const filter = buildLuceneFilter(filterText.value);
645
640
  try {
646
- const res = await documentApi.listDocumentsRaw({
641
+ const res = await documentApi.searchDocumentsRaw({
647
642
  collectionName: props.collectionName,
648
643
  rowsPerPage: pagination.value.pageSize,
649
644
  page: pagination.value.pageIndex,
650
- sort: sorting.value.length ? sortingToMongoSort(sorting.value) : void 0,
651
- // only the fields asked for are loaded (the server always adds `_id`); never an empty list, which is a 500
652
- projection: activeProjection.value.length > 0 ? activeProjection.value : void 0,
653
- filter
645
+ searchRequest: {
646
+ filter,
647
+ sort: sorting.value.length ? sortingToMongoSort(sorting.value) : void 0,
648
+ // only the fields asked for are loaded (the server always adds `_id`); never an empty list, which is a 500
649
+ projection: activeProjection.value.length > 0 ? activeProjection.value : void 0
650
+ }
654
651
  });
655
652
  total.value = +(res.raw.headers.get("x-pagination-count-rows") ?? 0);
656
653
  const rows = await readJsonKeepingLongs(res);
@@ -671,7 +668,7 @@ async function fetchDocuments() {
671
668
  ...index === 0 ? { meta: { class: { th: "sticky left-0 z-10 bg-default", td: "sticky left-0 z-10 bg-default" } } } : {}
672
669
  }));
673
670
  filterableColumns.value = orderedKeys.filter((k) => k !== "_id" && k !== "metaData" && typeof firstRow[k] === "string");
674
- filterFields.value = schemaFromSamples(rows.map((row) => unwrapExtendedJson(row, { exactLongs: false }))).map((c) => ({ key: c.columnKey, type: c.columnKey === "_id" ? "objectId" : toFilterFieldType(c.columnType) })).filter((f) => operatorsFor(f.type).length > 0);
671
+ pageFilterFields.value = schemaFromSamples(rows.map((row) => unwrapExtendedJson(row, { exactLongs: false }))).map((c) => ({ key: c.columnKey, type: c.columnKey === "_id" ? "objectId" : toFilterFieldType(c.columnType) })).filter((f) => operatorsFor(f.type).length > 0);
675
672
  if (!isBucketCollection(props.collectionName) && writable.value) {
676
673
  columns.value.unshift(createSelectColumn(UCheckbox, { selectAll: t("nuxtUiMongocamp.bulk.selectAll"), selectRow: t("nuxtUiMongocamp.bulk.selectRow") }));
677
674
  }
@@ -736,6 +733,16 @@ function exportPage(format) {
736
733
  const keys = dataColumnKeys.value.filter((key) => effectiveVisibility.value[key] !== false);
737
734
  downloadTextFile(`${props.collectionName}.csv`, rowsToCsv(rows, keys), "text/csv");
738
735
  }
736
+ const chartOpen = ref(false);
737
+ const chartField = ref("");
738
+ const chartFields = computed(() => filterFields.value.filter((f) => f.type === "string" || f.type === "number" || f.type === "date-time" || f.type === "boolean").map((f) => f.key));
739
+ const chartItems = computed(() => chartFields.value.map((key) => ({ label: key, value: key })));
740
+ const chartFilter = computed(() => buildLuceneFilter(filterText.value));
741
+ const chartFilterTooLong = computed(() => isFilterTooLong(chartFilter.value));
742
+ function openChart() {
743
+ if (!chartFields.value.includes(chartField.value)) chartField.value = chartFields.value[0] ?? "";
744
+ chartOpen.value = true;
745
+ }
739
746
  const exportAllOpen = ref(false);
740
747
  const exportMenuItems = computed(() => [
741
748
  { label: t("nuxtUiMongocamp.collectionData.exportJson"), icon: "i-lucide-file-json", onSelect: () => exportPage("json") },
@@ -767,7 +774,8 @@ async function init() {
767
774
  pagination.value.pageIndex = 1;
768
775
  filterText.value = "";
769
776
  filterableColumns.value = [];
770
- filterFields.value = [];
777
+ pageFilterFields.value = [];
778
+ void fieldTypes.load(true);
771
779
  query.value = { ...emptyQueryState(), sort: sorting.value.map((e) => e.desc ? `-${e.id}` : e.id) };
772
780
  queryBar.value?.closePanel();
773
781
  columnVisibility.value = Object.fromEntries(
@@ -881,6 +889,27 @@ watch(() => props.collectionName, init, { immediate: true });
881
889
  :aria-label="t('nuxtUiMongocamp.collectionData.columnsTooltip')"
882
890
  />
883
891
  </UDropdownMenu>
892
+ <UButton
893
+ v-if="aggregatePath && !isBucketCollection(collectionName)"
894
+ icon="i-lucide-sigma"
895
+ color="neutral"
896
+ variant="ghost"
897
+ size="sm"
898
+ :disabled="chartFilterTooLong"
899
+ :to="{ path: `${aggregatePath}/${collectionName}/aggregate`, query: chartFilter ? { filter: chartFilter } : {} }"
900
+ :aria-label="t('nuxtUiMongocamp.collectionData.aggregateTooltip')"
901
+ data-test="aggregate-link"
902
+ />
903
+ <UButton
904
+ v-if="!isBucketCollection(collectionName)"
905
+ icon="i-lucide-chart-column"
906
+ color="neutral"
907
+ variant="ghost"
908
+ size="sm"
909
+ :disabled="chartFields.length === 0 || documents.length === 0"
910
+ :aria-label="t('nuxtUiMongocamp.collectionData.chartTooltip')"
911
+ @click="openChart"
912
+ />
884
913
  <UDropdownMenu :items="exportMenuItems">
885
914
  <UButton
886
915
  icon="i-lucide-download"
@@ -926,20 +955,18 @@ watch(() => props.collectionName, init, { immediate: true });
926
955
 
927
956
  <MongocampBulkDelete
928
957
  :selected="bulkIds"
958
+ :selected-count="bulkCount"
929
959
  :page-count="selectablePageCount"
930
960
  :total="total"
931
961
  :all-matching="matching !== null"
932
- :collecting="collecting"
962
+ :counting="counting"
933
963
  :note="bulkNote"
934
964
  :confirm-name="matching ? collectionName : void 0"
935
965
  :deleting="bulkDeleting"
936
- :progress="bulkProgress"
937
966
  :error="bulkError"
938
967
  @open="bulkError = ''"
939
968
  @clear="clearBulkSelection"
940
969
  @select-all="collectMatching"
941
- @cancel-collect="cancelCollect"
942
- @stop="stopBulk"
943
970
  @confirm="handleBulkDelete"
944
971
  >
945
972
  <template #actions>
@@ -951,7 +978,7 @@ watch(() => props.collectionName, init, { immediate: true });
951
978
  size="sm"
952
979
  :label="t('nuxtUiMongocamp.bulk.compareSelected')"
953
980
  data-testid="compare-selected"
954
- @click="compareOpen = true"
981
+ @click="openCompare"
955
982
  />
956
983
  <UButton
957
984
  v-if="editableFields.length > 0"
@@ -966,13 +993,11 @@ watch(() => props.collectionName, init, { immediate: true });
966
993
  </MongocampBulkDelete>
967
994
  <MongocampBulkEdit
968
995
  v-model:open="bulkEditOpen"
969
- :selected="bulkIds.length"
996
+ :selected="bulkCount"
970
997
  :fields="editableFields"
971
998
  :saving="bulkEditing"
972
- :progress="bulkProgress"
973
999
  :error="bulkEditError"
974
1000
  @apply="handleBulkEdit"
975
- @stop="stopBulk"
976
1001
  />
977
1002
 
978
1003
  <pre
@@ -1006,19 +1031,74 @@ watch(() => props.collectionName, init, { immediate: true });
1006
1031
  :total="total"
1007
1032
  />
1008
1033
 
1034
+ <UModal
1035
+ v-model:open="chartOpen"
1036
+ :title="t('nuxtUiMongocamp.collectionData.chartTitle')"
1037
+ :ui="{ content: 'sm:max-w-3xl' }"
1038
+ >
1039
+ <template #body>
1040
+ <div
1041
+ class="flex flex-col gap-3"
1042
+ data-test="chart-dialog"
1043
+ >
1044
+ <p class="text-sm text-dimmed">
1045
+ {{ chartFilter ? t("nuxtUiMongocamp.collectionData.chartScopeFiltered", { count: total }, total) : t("nuxtUiMongocamp.collectionData.chartScopeAll", { count: total }, total) }}
1046
+ </p>
1047
+ <UFormField :label="t('nuxtUiMongocamp.collectionData.chartField')">
1048
+ <USelect
1049
+ v-model="chartField"
1050
+ :items="chartItems"
1051
+ class="w-full"
1052
+ :aria-label="t('nuxtUiMongocamp.collectionData.chartField')"
1053
+ />
1054
+ </UFormField>
1055
+ <UAlert
1056
+ v-if="chartFilterTooLong"
1057
+ color="warning"
1058
+ variant="subtle"
1059
+ icon="i-lucide-triangle-alert"
1060
+ :description="t('nuxtUiMongocamp.collectionData.chartTooLong')"
1061
+ data-test="chart-too-long"
1062
+ />
1063
+ <MongocampCollectionCharts
1064
+ v-else-if="chartOpen && chartField"
1065
+ :collection-name="collectionName"
1066
+ :field="chartField"
1067
+ :filter="chartFilter"
1068
+ />
1069
+ </div>
1070
+ </template>
1071
+ </UModal>
1072
+
1009
1073
  <UModal
1010
1074
  v-model:open="compareOpen"
1011
1075
  :title="t('nuxtUiMongocamp.documentCompare.title')"
1012
1076
  :ui="{ content: 'sm:max-w-5xl' }"
1013
1077
  >
1014
1078
  <template #body>
1015
- <MongocampDocumentCompare
1016
- v-if="compareRows.length === 2"
1017
- :left="compareRows[0]"
1018
- :right="compareRows[1]"
1019
- :left-label="String(compareRows[0]._id ?? '')"
1020
- :right-label="String(compareRows[1]._id ?? '')"
1021
- />
1079
+ <p
1080
+ v-if="compareState === 'loading'"
1081
+ class="text-sm text-dimmed"
1082
+ role="status"
1083
+ data-test="compare-loading"
1084
+ >
1085
+ {{ t("nuxtUiMongocamp.collectionData.compareLoading") }}
1086
+ </p>
1087
+ <template v-else-if="compareRows.length === 2">
1088
+ <p
1089
+ v-if="compareState === 'untyped'"
1090
+ class="mb-2 text-sm text-warning"
1091
+ data-test="compare-untyped"
1092
+ >
1093
+ {{ t("nuxtUiMongocamp.collectionData.compareUntyped") }}
1094
+ </p>
1095
+ <MongocampDocumentCompare
1096
+ :left="typedPair?.[0] ?? compareRows[0]"
1097
+ :right="typedPair?.[1] ?? compareRows[1]"
1098
+ :left-label="String(compareRows[0]._id ?? '')"
1099
+ :right-label="String(compareRows[1]._id ?? '')"
1100
+ />
1101
+ </template>
1022
1102
  </template>
1023
1103
  </UModal>
1024
1104
 
@@ -1,11 +1,13 @@
1
1
  type __VLS_Props = {
2
2
  collectionName: string;
3
3
  infoPath?: string;
4
+ aggregatePath?: string;
4
5
  persistState?: boolean;
5
6
  stateKey?: string;
6
7
  };
7
8
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
8
9
  infoPath: string;
10
+ aggregatePath: string;
9
11
  persistState: boolean;
10
12
  stateKey: string;
11
13
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -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;