@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.
Files changed (105) hide show
  1. package/README.md +1 -1
  2. package/dist/module.json +2 -2
  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/MongocampChart.vue +1 -4
  17. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +2 -0
  18. package/dist/runtime/components/MongocampCollectionCharts.vue +9 -8
  19. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +2 -0
  20. package/dist/runtime/components/MongocampCollectionCopy.vue +19 -258
  21. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +2 -0
  22. package/dist/runtime/components/MongocampCollectionData.vue +206 -126
  23. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +2 -0
  24. package/dist/runtime/components/MongocampCollectionRename.d.vue.ts +22 -0
  25. package/dist/runtime/components/MongocampCollectionRename.vue +116 -0
  26. package/dist/runtime/components/MongocampCollectionRename.vue.d.ts +22 -0
  27. package/dist/runtime/components/MongocampCollections.vue +31 -12
  28. package/dist/runtime/components/MongocampCommandPalette.vue +2 -2
  29. package/dist/runtime/components/MongocampDashboard.vue +19 -4
  30. package/dist/runtime/components/MongocampDatabases.vue +13 -2
  31. package/dist/runtime/components/MongocampExportAll.vue +13 -26
  32. package/dist/runtime/components/MongocampImport.vue +169 -3
  33. package/dist/runtime/components/MongocampIndexes.vue +54 -13
  34. package/dist/runtime/components/MongocampJobs.vue +14 -3
  35. package/dist/runtime/components/MongocampRoleGrants.vue +16 -3
  36. package/dist/runtime/components/MongocampRoles.vue +13 -2
  37. package/dist/runtime/components/MongocampServerInfo.d.vue.ts +24 -0
  38. package/dist/runtime/components/MongocampServerInfo.vue +331 -0
  39. package/dist/runtime/components/MongocampServerInfo.vue.d.ts +24 -0
  40. package/dist/runtime/components/MongocampServerOverview.vue +16 -39
  41. package/dist/runtime/components/MongocampSettings.d.vue.ts +3 -0
  42. package/dist/runtime/components/MongocampSettings.vue +14 -2
  43. package/dist/runtime/components/MongocampSettings.vue.d.ts +3 -0
  44. package/dist/runtime/components/MongocampUsers.vue +16 -3
  45. package/dist/runtime/components/MongocampVersion.d.vue.ts +7 -1
  46. package/dist/runtime/components/MongocampVersion.vue +49 -19
  47. package/dist/runtime/components/MongocampVersion.vue.d.ts +7 -1
  48. package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
  49. package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
  50. package/dist/runtime/composables/useMongocampAggregation.d.ts +11 -0
  51. package/dist/runtime/composables/useMongocampAggregation.js +12 -5
  52. package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
  53. package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
  54. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +25 -65
  55. package/dist/runtime/composables/useMongocampCollectionCopy.js +27 -84
  56. package/dist/runtime/composables/useMongocampExportAll.d.ts +27 -21
  57. package/dist/runtime/composables/useMongocampExportAll.js +51 -21
  58. package/dist/runtime/composables/useMongocampExtendedJson.d.ts +2 -1
  59. package/dist/runtime/composables/useMongocampExtendedJson.js +32 -5
  60. package/dist/runtime/composables/useMongocampFetchAll.js +1 -1
  61. package/dist/runtime/composables/useMongocampFieldTypes.d.ts +24 -0
  62. package/dist/runtime/composables/useMongocampFieldTypes.js +44 -0
  63. package/dist/runtime/composables/useMongocampImport.d.ts +4 -0
  64. package/dist/runtime/composables/useMongocampImport.js +5 -2
  65. package/dist/runtime/composables/useMongocampIndex.d.ts +6 -1
  66. package/dist/runtime/composables/useMongocampIndex.js +7 -1
  67. package/dist/runtime/composables/useMongocampPermissions.d.ts +8 -5
  68. package/dist/runtime/composables/useMongocampPermissions.js +24 -2
  69. package/dist/runtime/composables/useMongocampQuery.d.ts +3 -3
  70. package/dist/runtime/composables/useMongocampServerOverview.d.ts +4 -11
  71. package/dist/runtime/composables/useMongocampServerOverview.js +12 -22
  72. package/dist/runtime/composables/useMongocampSystem.d.ts +10 -1
  73. package/dist/runtime/composables/useMongocampSystem.js +11 -1
  74. package/dist/runtime/locales/de.json +104 -71
  75. package/dist/runtime/locales/en.json +104 -71
  76. package/dist/runtime/plugin.d.ts +2 -2
  77. package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
  78. package/dist/runtime/utils/aggregationErrors.js +7 -0
  79. package/dist/runtime/utils/batchInsert.d.ts +6 -0
  80. package/dist/runtime/utils/batchInsert.js +31 -3
  81. package/dist/runtime/utils/bsonTypes.d.ts +10 -0
  82. package/dist/runtime/utils/bsonTypes.js +42 -0
  83. package/dist/runtime/utils/collectionCopy.d.ts +0 -2
  84. package/dist/runtime/utils/collectionCopy.js +0 -1
  85. package/dist/runtime/utils/configRows.d.ts +7 -0
  86. package/dist/runtime/utils/configRows.js +4 -0
  87. package/dist/runtime/utils/documentCompare.js +2 -1
  88. package/dist/runtime/utils/documentPaths.d.ts +5 -8
  89. package/dist/runtime/utils/documentPaths.js +5 -10
  90. package/dist/runtime/utils/documentTree.js +9 -1
  91. package/dist/runtime/utils/exportDocuments.d.ts +0 -2
  92. package/dist/runtime/utils/exportDocuments.js +0 -1
  93. package/dist/runtime/utils/exportRows.d.ts +2 -0
  94. package/dist/runtime/utils/exportRows.js +5 -2
  95. package/dist/runtime/utils/fieldDetails.d.ts +51 -0
  96. package/dist/runtime/utils/fieldDetails.js +113 -0
  97. package/dist/runtime/utils/indexForm.d.ts +47 -33
  98. package/dist/runtime/utils/indexForm.js +32 -21
  99. package/dist/runtime/utils/serverInfo.d.ts +8 -0
  100. package/dist/runtime/utils/serverInfo.js +21 -0
  101. package/package.json +11 -11
  102. package/dist/runtime/utils/indexCopy.d.ts +0 -26
  103. package/dist/runtime/utils/indexCopy.js +0 -22
  104. package/dist/runtime/utils/limitedMap.d.ts +0 -17
  105. package/dist/runtime/utils/limitedMap.js +0 -19
@@ -2,17 +2,18 @@
2
2
  import { computed, onBeforeUnmount, ref, watch } from "vue";
3
3
  import { useI18n } from "#imports";
4
4
  import { useMongocampAggregation } from "../composables/useMongocampAggregation";
5
- import { analyzeSamples } from "../utils/analyzeSamples";
6
- import { chartKindFor, chartRequest, chartTypeFor, DEFAULT_BUCKETS, DEFAULT_TOP, dominantKind, highestPoint, MAX_PERIODS, rowsToPoints } from "../utils/collectionChart";
5
+ import { dominantKindOfField } from "../utils/fieldDetails";
6
+ import { chartKindFor, chartRequest, chartTypeFor, DEFAULT_BUCKETS, DEFAULT_TOP, highestPoint, MAX_PERIODS, rowsToPoints } from "../utils/collectionChart";
7
7
  const props = defineProps({
8
8
  collectionName: { type: String, required: true },
9
9
  field: { type: String, required: true },
10
10
  kind: { type: String, required: false, default: void 0 },
11
11
  top: { type: Number, required: false, default: DEFAULT_TOP },
12
- buckets: { type: Number, required: false, default: DEFAULT_BUCKETS }
12
+ buckets: { type: Number, required: false, default: DEFAULT_BUCKETS },
13
+ filter: { type: String, required: false, default: void 0 }
13
14
  });
14
15
  const { t } = useI18n();
15
- const { runAggregation, sampleDocuments, describeAggregationError } = useMongocampAggregation();
16
+ const { runAggregation, listFieldDetails, describeAggregationError } = useMongocampAggregation();
16
17
  const status = ref("loading");
17
18
  const current = ref(void 0);
18
19
  const detectedType = ref(void 0);
@@ -37,9 +38,9 @@ async function load() {
37
38
  if (!chartKind) {
38
39
  const key = `${props.collectionName}\0${props.field}`;
39
40
  if (detected?.key !== key) {
40
- const { rows } = await sampleDocuments(props.collectionName, 200);
41
+ const details = await listFieldDetails(props.collectionName);
41
42
  if (mine !== run) return;
42
- const found = dominantKind(analyzeSamples(rows), props.field);
43
+ const found = dominantKindOfField(details, props.field);
43
44
  detected = { key, kind: chartKindFor(found), type: found };
44
45
  }
45
46
  detectedType.value = detected.type;
@@ -55,7 +56,7 @@ async function load() {
55
56
  status.value = "invalid";
56
57
  return;
57
58
  }
58
- const result = await runAggregation(props.collectionName, request.pipeline, { page: 1, rowsPerPage: request.rowsPerPage }, { signal: own.signal });
59
+ const result = await runAggregation(props.collectionName, request.pipeline, { page: 1, rowsPerPage: request.rowsPerPage }, { signal: own.signal, filter: props.filter });
59
60
  if (mine !== run) return;
60
61
  points.value = rowsToPoints(chartKind, result.rows, t("nuxtUiMongocamp.charts.noneLabel"));
61
62
  total.value = result.total;
@@ -66,7 +67,7 @@ async function load() {
66
67
  if (mine === run) status.value = "error";
67
68
  }
68
69
  }
69
- watch(() => [props.collectionName, props.field, props.kind, props.top, props.buckets], load, { immediate: true });
70
+ watch(() => [props.collectionName, props.field, props.kind, props.top, props.buckets, props.filter], load, { immediate: true });
70
71
  watch(unit, () => {
71
72
  if (current.value === "dates") void load();
72
73
  });
@@ -5,8 +5,10 @@ type __VLS_Props = {
5
5
  kind?: ChartKind;
6
6
  top?: number;
7
7
  buckets?: number;
8
+ filter?: string;
8
9
  };
9
10
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
11
+ filter: string;
10
12
  kind: ChartKind;
11
13
  buckets: number;
12
14
  top: number;
@@ -2,7 +2,7 @@
2
2
  import { computed, ref, watch } from "vue";
3
3
  import { useI18n, useMongocampError } from "#imports";
4
4
  import { useMongocampCollectionCopy } from "../composables/useMongocampCollectionCopy";
5
- import { backupName, canCopyCollection, MAX_COLLECTION_NAME_LENGTH, MAX_COPY_DOCUMENTS, validateTargetName } from "../utils/collectionCopy";
5
+ import { backupName, canCopyCollection, MAX_COLLECTION_NAME_LENGTH, validateTargetName } from "../utils/collectionCopy";
6
6
  const props = defineProps({
7
7
  source: { type: String, required: true },
8
8
  filter: { type: String, required: false }
@@ -11,44 +11,23 @@ const emit = defineEmits(["done"]);
11
11
  const isOpen = defineModel("open", { type: Boolean, ...{ default: false } });
12
12
  const { t } = useI18n();
13
13
  const { describeServerError } = useMongocampError();
14
- const { copyCollection, copyIndexes, backupCollection, retryBatches, listCollectionNames, countDocuments, collectionCount } = useMongocampCollectionCopy();
14
+ const { copyCollection, backupCollection, listCollectionNames, countDocuments } = useMongocampCollectionCopy();
15
15
  const step = ref("form");
16
16
  const target = ref("");
17
17
  const existing = ref([]);
18
18
  const sourceCount = ref(void 0);
19
19
  const countFailed = ref(false);
20
- const progress = ref({ phase: "reading", done: 0, total: 0 });
21
20
  const result = ref(null);
22
- const failures = ref([]);
23
- const totalInserted = ref(0);
24
- const aborted = ref(false);
25
- const skipped = ref(0);
26
- const finalCount = ref(void 0);
27
21
  const errorText = ref("");
28
22
  const withIndexes = ref(true);
29
- const indexResult = ref(null);
30
- const indexesError = ref(false);
31
- const indexFailureReasons = ref({});
32
- let controller;
33
23
  let opened = 0;
34
24
  watch(isOpen, async (open) => {
35
- if (!open) {
36
- controller?.abort();
37
- return;
38
- }
25
+ if (!open) return;
39
26
  const mine = ++opened;
40
27
  step.value = "form";
41
28
  target.value = "";
42
29
  result.value = null;
43
- failures.value = [];
44
- totalInserted.value = 0;
45
- aborted.value = false;
46
- skipped.value = 0;
47
- finalCount.value = void 0;
48
30
  errorText.value = "";
49
- indexResult.value = null;
50
- indexesError.value = false;
51
- indexFailureReasons.value = {};
52
31
  sourceCount.value = void 0;
53
32
  countFailed.value = false;
54
33
  const [names, count] = await Promise.allSettled([listCollectionNames(), countDocuments(props.source, props.filter)]);
@@ -62,148 +41,43 @@ const problemText = computed(() => {
62
41
  const key = { "empty": "problemEmpty", "too-long": "problemTooLong", "invalid-characters": "problemInvalid", "protected": "problemProtected", "same-as-source": "problemSame", "exists": "problemExists" }[problem.value ?? "empty"];
63
42
  return problem.value ? t(`nuxtUiMongocamp.collectionCopy.${key}`, { max: MAX_COLLECTION_NAME_LENGTH }) : "";
64
43
  });
65
- const tooMany = computed(() => sourceCount.value !== void 0 && sourceCount.value > MAX_COPY_DOCUMENTS);
66
- const canStart = computed(() => target.value.trim() !== "" && problem.value === void 0 && sourceCount.value !== void 0 && !tooMany.value);
67
44
  const targetName = computed(() => target.value.trim());
68
- const canBackup = computed(() => canCopyCollection(props.source) && sourceCount.value !== void 0 && !tooMany.value);
45
+ const canStart = computed(() => targetName.value !== "" && problem.value === void 0);
46
+ const canBackup = computed(() => canCopyCollection(props.source));
69
47
  const backupPreview = computed(() => backupName(props.source, existing.value));
70
- const percent = computed(() => progress.value.total === 0 ? 0 : Math.round(progress.value.done / progress.value.total * 100));
71
48
  async function reasonOf(error) {
72
49
  return (await describeServerError(error, "nuxtUiMongocamp.collectionCopy.failedGeneric")).message;
73
50
  }
74
- const SKIP_KEYS = {
75
- "multi-field-text": "skipMultiText",
76
- "custom-weights": "skipWeights",
77
- "unsupported-key": "skipKeyType",
78
- "unknown-key-order": "skipOrder"
79
- };
80
- const skipText = (reason) => t(`nuxtUiMongocamp.collectionCopy.${SKIP_KEYS[reason]}`);
81
- async function applyIndexes(indexes, failedToList) {
82
- indexResult.value = indexes ?? null;
83
- indexesError.value = failedToList !== void 0;
84
- indexFailureReasons.value = Object.fromEntries(await Promise.all((indexes?.failed ?? []).map(async (f) => [f.name, await reasonOf(f.error)])));
85
- }
86
- async function describeFailures(failed) {
87
- failures.value = await Promise.all(failed.map(async (batch) => ({
88
- from: batch.start + 1,
89
- to: batch.start + batch.count,
90
- reason: await reasonOf(batch.error),
91
- mayBePartial: batch.mayBePartial,
92
- batch
93
- })));
94
- }
95
- async function finish(copied) {
96
- step.value = "done";
97
- if (copied > 0) {
98
- emit("done", { target: targetName.value, copied });
99
- try {
100
- finalCount.value = await collectionCount(targetName.value);
101
- } catch {
102
- finalCount.value = void 0;
103
- }
104
- }
105
- }
106
51
  async function start(quick = false) {
107
52
  if (quick ? !canBackup.value : !canStart.value) return;
108
53
  errorText.value = "";
109
54
  step.value = "running";
110
- progress.value = { phase: "reading", done: 0, total: sourceCount.value ?? 0 };
111
- const run = new AbortController();
112
- controller = run;
113
55
  try {
114
- const common = {
115
- source: props.source,
116
- filter: props.filter,
117
- copyIndexes: withIndexes.value,
118
- signal: run.signal,
119
- onProgress: (p) => {
120
- progress.value = p;
121
- }
122
- };
56
+ const common = { source: props.source, filter: props.filter, withIndexes: withIndexes.value };
123
57
  const outcome = quick ? await backupCollection({ ...common, onTarget: (name) => {
124
58
  target.value = name;
125
59
  } }) : await copyCollection({ ...common, target: targetName.value });
126
- if (!isOpen.value) return;
127
60
  result.value = outcome;
128
61
  if (outcome.refused === "target-exists") {
129
- existing.value = [...existing.value, targetName.value];
62
+ existing.value = [...existing.value, outcome.target];
130
63
  step.value = "form";
131
- errorText.value = t("nuxtUiMongocamp.collectionCopy.refusedExists", { target: targetName.value });
64
+ errorText.value = t("nuxtUiMongocamp.collectionCopy.refusedExists", { target: outcome.target });
132
65
  return;
133
66
  }
134
- if (outcome.refused === "too-many-documents") {
135
- sourceCount.value = outcome.sourceTotal;
136
- step.value = "form";
137
- return;
138
- }
139
- totalInserted.value = outcome.inserted;
140
- aborted.value = outcome.aborted;
141
- skipped.value = outcome.skipped;
142
- await applyIndexes(outcome.indexes, outcome.indexesError);
143
- await describeFailures(outcome.failedBatches);
144
- await finish(outcome.inserted);
67
+ step.value = "done";
68
+ emit("done", { target: outcome.target, copied: outcome.count });
145
69
  } catch (e) {
146
- if (!isOpen.value) return;
147
- if (e?.name === "AbortError") {
148
- step.value = "form";
149
- return;
150
- }
151
70
  errorText.value = await reasonOf(e);
152
71
  step.value = "form";
153
- } finally {
154
- if (controller === run) controller = void 0;
155
72
  }
156
73
  }
157
- async function retry() {
158
- if (!result.value) return;
159
- const rows = result.value.rows;
160
- const failed = failures.value.map((f) => f.batch);
161
- step.value = "running";
162
- progress.value = { phase: "writing", done: 0, total: failed.reduce((sum, f) => sum + f.count, 0) };
163
- const run = new AbortController();
164
- controller = run;
165
- try {
166
- const again = await retryBatches(targetName.value, rows, failed, { signal: run.signal, onProgress: (p) => {
167
- progress.value = p;
168
- } });
169
- if (!isOpen.value) return;
170
- totalInserted.value += again.inserted;
171
- skipped.value = again.skipped;
172
- aborted.value = again.aborted;
173
- const originals = failed.flatMap((f) => Array.from({ length: f.count }, (_, i) => f.start + i));
174
- failures.value = await Promise.all(again.failedBatches.map(async (batch) => ({
175
- from: originals[batch.start] + 1,
176
- to: originals[batch.start + batch.count - 1] + 1,
177
- reason: await reasonOf(batch.error),
178
- mayBePartial: batch.mayBePartial,
179
- batch: { ...batch, start: originals[batch.start] }
180
- })));
181
- if (withIndexes.value && failures.value.length === 0 && !aborted.value && !indexResult.value) {
182
- try {
183
- await applyIndexes(await copyIndexes(props.source, targetName.value), void 0);
184
- } catch (e) {
185
- await applyIndexes(void 0, e);
186
- }
187
- }
188
- await finish(totalInserted.value);
189
- } finally {
190
- if (controller === run) controller = void 0;
191
- }
192
- }
193
- function stop() {
194
- controller?.abort();
195
- }
196
- const anyMayBePartial = computed(() => failures.value.some((f) => f.mayBePartial));
197
- const failedCount = computed(() => failures.value.reduce((sum, f) => sum + (f.to - f.from + 1), 0));
198
- const complete = computed(() => step.value === "done" && failures.value.length === 0 && !aborted.value && totalInserted.value > 0);
199
- const indexesPending = computed(() => withIndexes.value && failures.value.length > 0 && !indexResult.value && !indexesError.value);
200
- const sourceTotal = computed(() => result.value?.sourceTotal ?? sourceCount.value ?? 0);
201
74
  </script>
202
75
 
203
76
  <template>
204
77
  <UModal
205
78
  v-model:open="isOpen"
206
79
  :title="filter ? t('nuxtUiMongocamp.collectionCopy.titleFiltered', { source }) : t('nuxtUiMongocamp.collectionCopy.title', { source })"
80
+ :dismissible="step !== 'running'"
207
81
  :ui="{ footer: 'justify-end' }"
208
82
  >
209
83
  <template #body>
@@ -229,14 +103,14 @@ const sourceTotal = computed(() => result.value?.sourceTotal ?? sourceCount.valu
229
103
  />
230
104
  </UFormField>
231
105
  <p
232
- v-if="sourceCount !== void 0 && !tooMany"
106
+ v-if="sourceCount !== void 0"
233
107
  class="text-sm"
234
108
  data-test="copy-count"
235
109
  >
236
110
  {{ t(filter ? "nuxtUiMongocamp.collectionCopy.countFiltered" : "nuxtUiMongocamp.collectionCopy.count", { count: sourceCount }, sourceCount) }}
237
111
  </p>
238
112
  <p
239
- v-else-if="!tooMany && !countFailed"
113
+ v-else-if="!countFailed"
240
114
  class="text-sm text-dimmed"
241
115
  >
242
116
  {{ t("nuxtUiMongocamp.collectionCopy.countLoading") }}
@@ -248,13 +122,6 @@ const sourceTotal = computed(() => result.value?.sourceTotal ?? sourceCount.valu
248
122
  >
249
123
  {{ t("nuxtUiMongocamp.collectionCopy.countFailed") }}
250
124
  </p>
251
- <p
252
- v-if="tooMany"
253
- class="text-sm text-error"
254
- role="alert"
255
- >
256
- {{ t("nuxtUiMongocamp.collectionCopy.tooMany", { count: sourceCount, cap: MAX_COPY_DOCUMENTS }) }}
257
- </p>
258
125
  <UCheckbox
259
126
  v-model="withIndexes"
260
127
  :label="t('nuxtUiMongocamp.collectionCopy.withIndexes')"
@@ -275,11 +142,8 @@ const sourceTotal = computed(() => result.value?.sourceTotal ?? sourceCount.valu
275
142
  role="status"
276
143
  data-test="copy-progress"
277
144
  >
278
- <UProgress
279
- :model-value="percent"
280
- :max="100"
281
- />
282
- <span class="text-sm text-dimmed">{{ t(`nuxtUiMongocamp.collectionCopy.${progress.phase}`, { done: progress.done, total: progress.total }) }}</span>
145
+ <UProgress />
146
+ <span class="text-sm text-dimmed">{{ t("nuxtUiMongocamp.collectionCopy.running", { source, count: sourceCount ?? 0 }, sourceCount ?? 0) }}</span>
283
147
  </div>
284
148
 
285
149
  <div
@@ -288,127 +152,24 @@ const sourceTotal = computed(() => result.value?.sourceTotal ?? sourceCount.valu
288
152
  data-test="copy-result"
289
153
  >
290
154
  <UAlert
291
- v-if="complete"
292
155
  color="success"
293
156
  variant="subtle"
294
157
  icon="i-lucide-circle-check"
295
- :title="t('nuxtUiMongocamp.collectionCopy.doneTitle', { count: totalInserted, target: targetName }, totalInserted)"
158
+ :title="t('nuxtUiMongocamp.collectionCopy.doneTitle', { count: result?.count ?? 0, target: result?.target ?? targetName }, result?.count ?? 0)"
296
159
  />
297
- <UAlert
298
- v-else-if="aborted"
299
- color="warning"
300
- variant="subtle"
301
- icon="i-lucide-circle-alert"
302
- :title="t('nuxtUiMongocamp.collectionCopy.stopped', { done: totalInserted, total: sourceTotal, skipped, target: targetName })"
303
- />
304
- <UAlert
305
- v-else-if="failures.length > 0"
306
- color="error"
307
- variant="subtle"
308
- icon="i-lucide-circle-alert"
309
- :title="t('nuxtUiMongocamp.collectionCopy.failedTitle', { failed: failedCount, total: sourceTotal })"
310
- >
311
- <template #description>
312
- <p
313
- v-for="failure in failures"
314
- :key="failure.from"
315
- class="text-sm"
316
- >
317
- {{ t("nuxtUiMongocamp.collectionCopy.failedRange", { from: failure.from, to: failure.to, reason: failure.reason }) }}
318
- </p>
319
- <p class="mt-1 text-sm">
320
- {{ t("nuxtUiMongocamp.collectionCopy.incomplete", { target: targetName }) }}
321
- </p>
322
- <p
323
- v-if="anyMayBePartial"
324
- class="mt-1 text-sm"
325
- >
326
- {{ t("nuxtUiMongocamp.collectionCopy.maybePartial") }}
327
- </p>
328
- </template>
329
- </UAlert>
330
160
  <p
331
- v-else
161
+ v-if="withIndexes"
332
162
  class="text-sm"
333
- >
334
- {{ t("nuxtUiMongocamp.collectionCopy.doneTitle", { count: 0, target: targetName }, 0) }}
335
- </p>
336
- <div
337
- v-if="indexResult"
338
- class="flex flex-col gap-1 text-sm"
339
163
  data-test="copy-indexes"
340
164
  >
341
- <p v-if="indexResult.copied.length > 0 || indexResult.skipped.length === 0 && indexResult.failed.length === 0">
342
- {{ indexResult.copied.length > 0 ? t("nuxtUiMongocamp.collectionCopy.indexesCopied", { count: indexResult.copied.length }) : t("nuxtUiMongocamp.collectionCopy.indexesNone") }}
343
- </p>
344
- <p
345
- v-for="item in indexResult.skipped"
346
- :key="`s-${item.name}`"
347
- class="text-warning"
348
- >
349
- {{ t("nuxtUiMongocamp.collectionCopy.indexSkipped", { name: item.name, reason: skipText(item.reason) }) }}
350
- </p>
351
- <p
352
- v-for="item in indexResult.failed"
353
- :key="`f-${item.name}`"
354
- class="text-error"
355
- >
356
- {{ t("nuxtUiMongocamp.collectionCopy.indexFailed", { name: item.name, reason: indexFailureReasons[item.name] ?? "" }) }}
357
- </p>
358
- </div>
359
- <p
360
- v-else-if="indexesError"
361
- class="text-sm text-error"
362
- role="alert"
363
- >
364
- {{ t("nuxtUiMongocamp.collectionCopy.indexesError") }}
365
- </p>
366
- <p
367
- v-else-if="indexesPending"
368
- class="text-sm text-dimmed"
369
- >
370
- {{ t("nuxtUiMongocamp.collectionCopy.indexesPending") }}
371
- </p>
372
- <p
373
- v-if="finalCount !== void 0 && finalCount === totalInserted"
374
- class="text-sm text-dimmed"
375
- data-test="copy-verified"
376
- >
377
- {{ t("nuxtUiMongocamp.collectionCopy.verified", { count: finalCount }) }}
378
- </p>
379
- <p
380
- v-else-if="finalCount !== void 0"
381
- class="text-sm text-warning"
382
- role="alert"
383
- data-test="copy-mismatch"
384
- >
385
- {{ t("nuxtUiMongocamp.collectionCopy.verifyMismatch", { actual: finalCount, expected: totalInserted }) }}
386
- </p>
387
- <p
388
- v-if="result?.totalChanged"
389
- class="text-sm text-warning"
390
- >
391
- {{ t("nuxtUiMongocamp.collectionCopy.changed") }}
165
+ {{ (result?.indexes ?? 0) > 0 ? t("nuxtUiMongocamp.collectionCopy.indexesCopied", { count: result?.indexes ?? 0 }) : t("nuxtUiMongocamp.collectionCopy.indexesNone") }}
392
166
  </p>
393
167
  </div>
394
168
  </template>
395
169
 
396
170
  <template #footer>
397
- <template v-if="step === 'running'">
398
- <UButton
399
- :label="t('nuxtUiMongocamp.collectionCopy.stop')"
400
- color="neutral"
401
- variant="soft"
402
- @click="stop"
403
- />
404
- </template>
171
+ <template v-if="step === 'running'" />
405
172
  <template v-else-if="step === 'done'">
406
- <UButton
407
- v-if="failures.length > 0 && !aborted"
408
- :label="t('nuxtUiMongocamp.collectionCopy.retry')"
409
- icon="i-lucide-rotate-cw"
410
- @click="retry"
411
- />
412
173
  <UButton
413
174
  :label="t('nuxtUiMongocamp.collectionCopy.close')"
414
175
  color="neutral"
@@ -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>;