@sfxcode/nuxt-ui-mongocamp 1.3.5 → 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 (224) hide show
  1. package/README.md +1 -1
  2. package/dist/module.d.mts +8 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +6 -0
  5. package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
  6. package/dist/runtime/components/MongocampAggregationBuilder.vue +331 -5
  7. package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
  8. package/dist/runtime/components/MongocampAggregationChart.d.vue.ts +6 -0
  9. package/dist/runtime/components/MongocampAggregationChart.vue +93 -0
  10. package/dist/runtime/components/MongocampAggregationChart.vue.d.ts +6 -0
  11. package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +10 -0
  12. package/dist/runtime/components/MongocampAggregationStagePreview.vue +149 -0
  13. package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +10 -0
  14. package/dist/runtime/components/MongocampBucketFiles.vue +230 -48
  15. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +9 -0
  16. package/dist/runtime/components/MongocampBulkDelete.vue +94 -25
  17. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +9 -0
  18. package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +5 -0
  19. package/dist/runtime/components/MongocampBulkEdit.vue +41 -3
  20. package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +5 -0
  21. package/dist/runtime/components/MongocampChart.d.vue.ts +29 -0
  22. package/dist/runtime/components/MongocampChart.vue +129 -0
  23. package/dist/runtime/components/MongocampChart.vue.d.ts +29 -0
  24. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +17 -0
  25. package/dist/runtime/components/MongocampCollectionCharts.vue +200 -0
  26. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +17 -0
  27. package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +23 -0
  28. package/dist/runtime/components/MongocampCollectionCopy.vue +206 -0
  29. package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +23 -0
  30. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +6 -0
  31. package/dist/runtime/components/MongocampCollectionData.vue +423 -138
  32. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +6 -0
  33. package/dist/runtime/components/MongocampCollectionInfos.vue +106 -238
  34. package/dist/runtime/components/MongocampCollectionRename.d.vue.ts +22 -0
  35. package/dist/runtime/components/MongocampCollectionRename.vue +116 -0
  36. package/dist/runtime/components/MongocampCollectionRename.vue.d.ts +22 -0
  37. package/dist/runtime/components/MongocampCollections.vue +93 -12
  38. package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +40 -0
  39. package/dist/runtime/components/MongocampCommandPalette.vue +135 -0
  40. package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +40 -0
  41. package/dist/runtime/components/MongocampConfirmByName.vue +2 -2
  42. package/dist/runtime/components/MongocampDashboard.d.vue.ts +3 -1
  43. package/dist/runtime/components/MongocampDashboard.vue +39 -5
  44. package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -1
  45. package/dist/runtime/components/MongocampDatabases.vue +35 -2
  46. package/dist/runtime/components/MongocampDocumentCompare.d.vue.ts +20 -0
  47. package/dist/runtime/components/MongocampDocumentCompare.vue +146 -0
  48. package/dist/runtime/components/MongocampDocumentCompare.vue.d.ts +20 -0
  49. package/dist/runtime/components/MongocampDocumentView.d.vue.ts +22 -0
  50. package/dist/runtime/components/MongocampDocumentView.vue +202 -0
  51. package/dist/runtime/components/MongocampDocumentView.vue.d.ts +22 -0
  52. package/dist/runtime/components/MongocampErrorAlert.vue +12 -4
  53. package/dist/runtime/components/MongocampExportAll.d.vue.ts +18 -0
  54. package/dist/runtime/components/MongocampExportAll.vue +191 -0
  55. package/dist/runtime/components/MongocampExportAll.vue.d.ts +18 -0
  56. package/dist/runtime/components/MongocampFilePreview.d.vue.ts +16 -0
  57. package/dist/runtime/components/MongocampFilePreview.vue +162 -0
  58. package/dist/runtime/components/MongocampFilePreview.vue.d.ts +16 -0
  59. package/dist/runtime/components/MongocampFilterBuilder.vue +11 -0
  60. package/dist/runtime/components/MongocampImport.vue +171 -13
  61. package/dist/runtime/components/MongocampIndexes.d.vue.ts +18 -0
  62. package/dist/runtime/components/MongocampIndexes.vue +496 -0
  63. package/dist/runtime/components/MongocampIndexes.vue.d.ts +18 -0
  64. package/dist/runtime/components/MongocampJobs.d.vue.ts +6 -1
  65. package/dist/runtime/components/MongocampJobs.vue +36 -5
  66. package/dist/runtime/components/MongocampJobs.vue.d.ts +6 -1
  67. package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +12 -0
  68. package/dist/runtime/components/MongocampPermissionMatrix.vue +301 -0
  69. package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +12 -0
  70. package/dist/runtime/components/MongocampQueryBar.d.vue.ts +26 -0
  71. package/dist/runtime/components/MongocampQueryBar.vue +398 -0
  72. package/dist/runtime/components/MongocampQueryBar.vue.d.ts +26 -0
  73. package/dist/runtime/components/MongocampRoleGrants.vue +18 -5
  74. package/dist/runtime/components/MongocampRoles.vue +16 -5
  75. package/dist/runtime/components/MongocampServerOverview.d.vue.ts +20 -0
  76. package/dist/runtime/components/MongocampServerOverview.vue +420 -0
  77. package/dist/runtime/components/MongocampServerOverview.vue.d.ts +20 -0
  78. package/dist/runtime/components/MongocampSettings.d.vue.ts +28 -1
  79. package/dist/runtime/components/MongocampSettings.vue +83 -10
  80. package/dist/runtime/components/MongocampSettings.vue.d.ts +28 -1
  81. package/dist/runtime/components/MongocampUsers.vue +19 -6
  82. package/dist/runtime/composables/useMongocampAdmin.d.ts +2 -1
  83. package/dist/runtime/composables/useMongocampAdmin.js +6 -1
  84. package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
  85. package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
  86. package/dist/runtime/composables/useMongocampAggregation.d.ts +23 -1
  87. package/dist/runtime/composables/useMongocampAggregation.js +41 -26
  88. package/dist/runtime/composables/useMongocampAutoRefresh.d.ts +26 -0
  89. package/dist/runtime/composables/useMongocampAutoRefresh.js +78 -0
  90. package/dist/runtime/composables/useMongocampBucket.d.ts +13 -1
  91. package/dist/runtime/composables/useMongocampBucket.js +34 -0
  92. package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
  93. package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
  94. package/dist/runtime/composables/useMongocampClientApi.js +2 -1
  95. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +45 -0
  96. package/dist/runtime/composables/useMongocampCollectionCopy.js +48 -0
  97. package/dist/runtime/composables/useMongocampCollectionStats.d.ts +10 -0
  98. package/dist/runtime/composables/useMongocampCollectionStats.js +17 -0
  99. package/dist/runtime/composables/useMongocampError.d.ts +2 -1
  100. package/dist/runtime/composables/useMongocampError.js +16 -1
  101. package/dist/runtime/composables/useMongocampExportAll.d.ts +53 -0
  102. package/dist/runtime/composables/useMongocampExportAll.js +57 -0
  103. package/dist/runtime/composables/useMongocampExtendedJson.d.ts +7 -2
  104. package/dist/runtime/composables/useMongocampExtendedJson.js +44 -11
  105. package/dist/runtime/composables/useMongocampFetchAll.d.ts +25 -0
  106. package/dist/runtime/composables/useMongocampFetchAll.js +27 -0
  107. package/dist/runtime/composables/useMongocampFieldTypes.d.ts +24 -0
  108. package/dist/runtime/composables/useMongocampFieldTypes.js +44 -0
  109. package/dist/runtime/composables/useMongocampImport.d.ts +4 -0
  110. package/dist/runtime/composables/useMongocampImport.js +5 -2
  111. package/dist/runtime/composables/useMongocampIndex.d.ts +6 -1
  112. package/dist/runtime/composables/useMongocampIndex.js +7 -1
  113. package/dist/runtime/composables/useMongocampPermissions.d.ts +17 -0
  114. package/dist/runtime/composables/useMongocampPermissions.js +43 -0
  115. package/dist/runtime/composables/useMongocampPersistedState.d.ts +15 -0
  116. package/dist/runtime/composables/useMongocampPersistedState.js +21 -0
  117. package/dist/runtime/composables/useMongocampProxyApi.js +2 -1
  118. package/dist/runtime/composables/useMongocampQuery.d.ts +50 -2
  119. package/dist/runtime/composables/useMongocampQuery.js +72 -1
  120. package/dist/runtime/composables/useMongocampSavedPipelines.d.ts +25 -0
  121. package/dist/runtime/composables/useMongocampSavedPipelines.js +23 -0
  122. package/dist/runtime/composables/useMongocampSavedQueries.d.ts +37 -0
  123. package/dist/runtime/composables/useMongocampSavedQueries.js +50 -0
  124. package/dist/runtime/composables/useMongocampServerOverview.d.ts +35 -0
  125. package/dist/runtime/composables/useMongocampServerOverview.js +51 -0
  126. package/dist/runtime/composables/useMongocampSession.d.ts +2 -0
  127. package/dist/runtime/composables/useMongocampSession.js +16 -2
  128. package/dist/runtime/composables/useMongocampSystem.d.ts +7 -2
  129. package/dist/runtime/composables/useMongocampSystem.js +6 -2
  130. package/dist/runtime/locales/de.json +509 -25
  131. package/dist/runtime/locales/en.json +509 -25
  132. package/dist/runtime/plugin.js +6 -3
  133. package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
  134. package/dist/runtime/utils/aggregationErrors.js +7 -0
  135. package/dist/runtime/utils/aggregationPipeline.d.ts +5 -4
  136. package/dist/runtime/utils/aggregationPipeline.js +23 -9
  137. package/dist/runtime/utils/aggregationPreview.d.ts +13 -0
  138. package/dist/runtime/utils/aggregationPreview.js +10 -0
  139. package/dist/runtime/utils/aggregationResult.d.ts +5 -0
  140. package/dist/runtime/utils/aggregationResult.js +4 -0
  141. package/dist/runtime/utils/aggregationTemplates.d.ts +34 -0
  142. package/dist/runtime/utils/aggregationTemplates.js +47 -0
  143. package/dist/runtime/utils/analyzeSamples.d.ts +1 -0
  144. package/dist/runtime/utils/analyzeSamples.js +1 -1
  145. package/dist/runtime/utils/autoRefresh.d.ts +14 -0
  146. package/dist/runtime/utils/autoRefresh.js +15 -0
  147. package/dist/runtime/utils/batchInsert.d.ts +6 -0
  148. package/dist/runtime/utils/batchInsert.js +31 -3
  149. package/dist/runtime/utils/bigIntJson.d.ts +15 -0
  150. package/dist/runtime/utils/bigIntJson.js +55 -0
  151. package/dist/runtime/utils/bsonTypes.d.ts +10 -0
  152. package/dist/runtime/utils/bsonTypes.js +42 -0
  153. package/dist/runtime/utils/bulkDelete.d.ts +9 -1
  154. package/dist/runtime/utils/bulkDelete.js +15 -3
  155. package/dist/runtime/utils/bulkEdit.d.ts +6 -0
  156. package/dist/runtime/utils/bulkEdit.js +7 -0
  157. package/dist/runtime/utils/chartData.d.ts +11 -0
  158. package/dist/runtime/utils/chartData.js +9 -0
  159. package/dist/runtime/utils/collectionChart.d.ts +36 -0
  160. package/dist/runtime/utils/collectionChart.js +73 -0
  161. package/dist/runtime/utils/collectionCopy.d.ts +24 -0
  162. package/dist/runtime/utils/collectionCopy.js +37 -0
  163. package/dist/runtime/utils/collectionStats.d.ts +31 -0
  164. package/dist/runtime/utils/collectionStats.js +42 -0
  165. package/dist/runtime/utils/commandPalette.d.ts +48 -0
  166. package/dist/runtime/utils/commandPalette.js +39 -0
  167. package/dist/runtime/utils/configRows.d.ts +7 -0
  168. package/dist/runtime/utils/configRows.js +4 -0
  169. package/dist/runtime/utils/documentCompare.d.ts +31 -0
  170. package/dist/runtime/utils/documentCompare.js +71 -0
  171. package/dist/runtime/utils/documentDiff.d.ts +19 -0
  172. package/dist/runtime/utils/documentDiff.js +71 -0
  173. package/dist/runtime/utils/documentPaths.d.ts +41 -0
  174. package/dist/runtime/utils/documentPaths.js +139 -0
  175. package/dist/runtime/utils/documentTree.d.ts +40 -0
  176. package/dist/runtime/utils/documentTree.js +102 -0
  177. package/dist/runtime/utils/exportDocuments.d.ts +33 -0
  178. package/dist/runtime/utils/exportDocuments.js +53 -0
  179. package/dist/runtime/utils/exportRows.d.ts +2 -0
  180. package/dist/runtime/utils/exportRows.js +6 -3
  181. package/dist/runtime/utils/fieldDetails.d.ts +51 -0
  182. package/dist/runtime/utils/fieldDetails.js +113 -0
  183. package/dist/runtime/utils/filePreview.d.ts +27 -0
  184. package/dist/runtime/utils/filePreview.js +50 -0
  185. package/dist/runtime/utils/filterBuilder.d.ts +6 -1
  186. package/dist/runtime/utils/filterBuilder.js +6 -5
  187. package/dist/runtime/utils/formatBytes.d.ts +2 -0
  188. package/dist/runtime/utils/formatBytes.js +11 -0
  189. package/dist/runtime/utils/grantMatching.d.ts +8 -0
  190. package/dist/runtime/utils/grantMatching.js +15 -0
  191. package/dist/runtime/utils/importRows.js +12 -2
  192. package/dist/runtime/utils/indexForm.d.ts +83 -0
  193. package/dist/runtime/utils/indexForm.js +74 -0
  194. package/dist/runtime/utils/luceneExpression.d.ts +15 -0
  195. package/dist/runtime/utils/luceneExpression.js +74 -0
  196. package/dist/runtime/utils/pagedFetch.d.ts +46 -0
  197. package/dist/runtime/utils/pagedFetch.js +58 -0
  198. package/dist/runtime/utils/paginationHeaders.d.ts +4 -0
  199. package/dist/runtime/utils/paginationHeaders.js +4 -0
  200. package/dist/runtime/utils/permissionDenied.d.ts +10 -0
  201. package/dist/runtime/utils/permissionDenied.js +23 -0
  202. package/dist/runtime/utils/permissionMatrix.d.ts +55 -0
  203. package/dist/runtime/utils/permissionMatrix.js +85 -0
  204. package/dist/runtime/utils/persistedState.d.ts +25 -0
  205. package/dist/runtime/utils/persistedState.js +47 -0
  206. package/dist/runtime/utils/queryState.d.ts +45 -0
  207. package/dist/runtime/utils/queryState.js +75 -0
  208. package/dist/runtime/utils/requestLimits.d.ts +2 -0
  209. package/dist/runtime/utils/requestLimits.js +4 -0
  210. package/dist/runtime/utils/resultChart.d.ts +32 -0
  211. package/dist/runtime/utils/resultChart.js +59 -0
  212. package/dist/runtime/utils/savedPipelines.d.ts +22 -0
  213. package/dist/runtime/utils/savedPipelines.js +46 -0
  214. package/dist/runtime/utils/savedQueries.d.ts +60 -0
  215. package/dist/runtime/utils/savedQueries.js +143 -0
  216. package/dist/runtime/utils/schemaAnalysis.d.ts +16 -0
  217. package/dist/runtime/utils/schemaAnalysis.js +57 -0
  218. package/dist/runtime/utils/serverError.d.ts +19 -0
  219. package/dist/runtime/utils/serverError.js +19 -0
  220. package/dist/runtime/utils/serverOverview.d.ts +47 -0
  221. package/dist/runtime/utils/serverOverview.js +40 -0
  222. package/dist/runtime/utils/sessionGuard.d.ts +3 -0
  223. package/dist/runtime/utils/sessionGuard.js +18 -1
  224. package/package.json +15 -14
@@ -0,0 +1,200 @@
1
+ <script setup>
2
+ import { computed, onBeforeUnmount, ref, watch } from "vue";
3
+ import { useI18n } from "#imports";
4
+ import { useMongocampAggregation } from "../composables/useMongocampAggregation";
5
+ import { dominantKindOfField } from "../utils/fieldDetails";
6
+ import { chartKindFor, chartRequest, chartTypeFor, DEFAULT_BUCKETS, DEFAULT_TOP, highestPoint, MAX_PERIODS, rowsToPoints } from "../utils/collectionChart";
7
+ const props = defineProps({
8
+ collectionName: { type: String, required: true },
9
+ field: { type: String, required: true },
10
+ kind: { type: String, required: false, default: void 0 },
11
+ top: { type: Number, required: false, default: DEFAULT_TOP },
12
+ buckets: { type: Number, required: false, default: DEFAULT_BUCKETS },
13
+ filter: { type: String, required: false, default: void 0 }
14
+ });
15
+ const { t } = useI18n();
16
+ const { runAggregation, listFieldDetails, describeAggregationError } = useMongocampAggregation();
17
+ const status = ref("loading");
18
+ const current = ref(void 0);
19
+ const detectedType = ref(void 0);
20
+ const points = ref([]);
21
+ const total = ref(0);
22
+ const unit = ref("month");
23
+ const error = ref(null);
24
+ let detected;
25
+ let run = 0;
26
+ let controller;
27
+ const unitItems = computed(() => ["year", "month", "day"].map((value) => ({ value, label: t(`nuxtUiMongocamp.charts.unit${value.charAt(0).toUpperCase()}${value.slice(1)}`) })));
28
+ async function load() {
29
+ controller?.abort();
30
+ const own = new AbortController();
31
+ controller = own;
32
+ const mine = ++run;
33
+ status.value = "loading";
34
+ error.value = null;
35
+ points.value = [];
36
+ try {
37
+ let chartKind = props.kind;
38
+ if (!chartKind) {
39
+ const key = `${props.collectionName}\0${props.field}`;
40
+ if (detected?.key !== key) {
41
+ const details = await listFieldDetails(props.collectionName);
42
+ if (mine !== run) return;
43
+ const found = dominantKindOfField(details, props.field);
44
+ detected = { key, kind: chartKindFor(found), type: found };
45
+ }
46
+ detectedType.value = detected.type;
47
+ chartKind = detected.kind;
48
+ if (!chartKind) {
49
+ status.value = detected.type === void 0 ? "unknown" : "unsupported";
50
+ return;
51
+ }
52
+ }
53
+ current.value = chartKind;
54
+ const request = chartRequest(chartKind, props.field, { top: props.top, buckets: props.buckets, unit: unit.value });
55
+ if (!request) {
56
+ status.value = "invalid";
57
+ return;
58
+ }
59
+ const result = await runAggregation(props.collectionName, request.pipeline, { page: 1, rowsPerPage: request.rowsPerPage }, { signal: own.signal, filter: props.filter });
60
+ if (mine !== run) return;
61
+ points.value = rowsToPoints(chartKind, result.rows, t("nuxtUiMongocamp.charts.noneLabel"));
62
+ total.value = result.total;
63
+ status.value = points.value.length === 0 ? "empty" : "ready";
64
+ } catch (e) {
65
+ if (mine !== run || own.signal.aborted) return;
66
+ error.value = await describeAggregationError(e);
67
+ if (mine === run) status.value = "error";
68
+ }
69
+ }
70
+ watch(() => [props.collectionName, props.field, props.kind, props.top, props.buckets, props.filter], load, { immediate: true });
71
+ watch(unit, () => {
72
+ if (current.value === "dates") void load();
73
+ });
74
+ onBeforeUnmount(() => {
75
+ controller?.abort();
76
+ run++;
77
+ });
78
+ const titleKey = computed(() => ({ values: "titleValues", dates: "titleDates", numbers: "titleNumbers" })[current.value ?? "values"]);
79
+ const title = computed(() => t(`nuxtUiMongocamp.charts.${titleKey.value}`));
80
+ const chartType = computed(() => chartTypeFor(current.value ?? "values", points.value.length));
81
+ const categories = computed(() => [{ key: "count", label: t("nuxtUiMongocamp.charts.seriesLabel") }]);
82
+ const ariaLabel = computed(() => t("nuxtUiMongocamp.charts.ariaLabel", { title: title.value, field: props.field }));
83
+ const ariaDescription = computed(() => {
84
+ const best = highestPoint(points.value);
85
+ if (!best) return "";
86
+ const common = { shown: points.value.length, label: best.label, count: best.count };
87
+ if (current.value === "dates") return t("nuxtUiMongocamp.charts.ariaDescriptionDates", { ...common, first: points.value[0].label, last: points.value.at(-1).label });
88
+ return t(current.value === "numbers" ? "nuxtUiMongocamp.charts.ariaDescriptionNumbers" : "nuxtUiMongocamp.charts.ariaDescriptionValues", common);
89
+ });
90
+ const note = computed(() => {
91
+ if (current.value === "values") return total.value > points.value.length ? t("nuxtUiMongocamp.charts.noteValues", { shown: points.value.length, total: total.value }) : t("nuxtUiMongocamp.charts.noteValuesAll", { total: total.value });
92
+ if (current.value === "dates") return total.value > MAX_PERIODS ? t("nuxtUiMongocamp.charts.notePeriods", { shown: points.value.length, total: total.value }) : "";
93
+ return t("nuxtUiMongocamp.charts.noteNumbers");
94
+ });
95
+ const unsupportedType = computed(() => t(`nuxtUiMongocamp.charts.type${(detectedType.value ?? "null").charAt(0).toUpperCase()}${(detectedType.value ?? "null").slice(1)}`));
96
+ </script>
97
+
98
+ <template>
99
+ <div
100
+ class="flex flex-col gap-3"
101
+ data-test="collection-chart"
102
+ >
103
+ <div class="flex flex-wrap items-center justify-between gap-2">
104
+ <h3 class="text-sm font-semibold">
105
+ {{ title }} <span class="font-mono font-normal text-dimmed">{{ field }}</span>
106
+ </h3>
107
+ <div
108
+ v-if="current === 'dates'"
109
+ class="flex items-center gap-2"
110
+ >
111
+ <span class="text-xs text-dimmed">{{ t("nuxtUiMongocamp.charts.unitLabel") }}</span>
112
+ <USelect
113
+ v-model="unit"
114
+ :items="unitItems"
115
+ size="sm"
116
+ class="w-28"
117
+ :aria-label="t('nuxtUiMongocamp.charts.unitLabel')"
118
+ />
119
+ </div>
120
+ </div>
121
+
122
+ <p
123
+ v-if="status === 'loading'"
124
+ class="text-sm text-dimmed"
125
+ role="status"
126
+ data-test="chart-loading"
127
+ >
128
+ {{ t("nuxtUiMongocamp.charts.loading") }}
129
+ </p>
130
+
131
+ <UAlert
132
+ v-else-if="status === 'error' && error"
133
+ color="error"
134
+ variant="subtle"
135
+ icon="i-lucide-circle-alert"
136
+ :title="t('nuxtUiMongocamp.charts.failedTitle')"
137
+ :description="error.message"
138
+ data-test="chart-error"
139
+ >
140
+ <template #actions>
141
+ <UButton
142
+ :label="t('nuxtUiMongocamp.charts.retry')"
143
+ color="error"
144
+ variant="subtle"
145
+ icon="i-lucide-refresh-cw"
146
+ @click="load"
147
+ />
148
+ </template>
149
+ </UAlert>
150
+
151
+ <p
152
+ v-else-if="status === 'unsupported'"
153
+ class="text-sm text-dimmed"
154
+ data-test="chart-unsupported"
155
+ >
156
+ {{ t("nuxtUiMongocamp.charts.unsupported", { type: unsupportedType }) }}
157
+ </p>
158
+ <p
159
+ v-else-if="status === 'unknown'"
160
+ class="text-sm text-dimmed"
161
+ data-test="chart-unknown"
162
+ >
163
+ {{ t("nuxtUiMongocamp.charts.unknownField", { field }) }}
164
+ </p>
165
+ <p
166
+ v-else-if="status === 'invalid'"
167
+ class="text-sm text-error"
168
+ data-test="chart-invalid"
169
+ >
170
+ {{ t("nuxtUiMongocamp.charts.invalidField") }}
171
+ </p>
172
+ <p
173
+ v-else-if="status === 'empty'"
174
+ class="text-sm text-dimmed"
175
+ data-test="chart-empty"
176
+ >
177
+ {{ t("nuxtUiMongocamp.charts.empty", { field }) }}
178
+ </p>
179
+
180
+ <template v-else>
181
+ <MongocampChart
182
+ :type="chartType"
183
+ :data="points"
184
+ index="label"
185
+ :categories="categories"
186
+ :chart-label="ariaLabel"
187
+ :chart-description="ariaDescription"
188
+ :legend="false"
189
+ :height="260"
190
+ />
191
+ <p
192
+ v-if="note"
193
+ class="text-xs text-dimmed"
194
+ data-test="chart-note"
195
+ >
196
+ {{ note }}
197
+ </p>
198
+ </template>
199
+ </div>
200
+ </template>
@@ -0,0 +1,17 @@
1
+ import type { ChartKind } from '../utils/collectionChart.js';
2
+ type __VLS_Props = {
3
+ collectionName: string;
4
+ field: string;
5
+ kind?: ChartKind;
6
+ top?: number;
7
+ buckets?: number;
8
+ filter?: string;
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;
12
+ kind: ChartKind;
13
+ buckets: number;
14
+ top: number;
15
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
+ declare const _default: typeof __VLS_export;
17
+ export default _default;
@@ -0,0 +1,23 @@
1
+ type __VLS_Props = {
2
+ source: string;
3
+ filter?: string;
4
+ };
5
+ type __VLS_ModelProps = {
6
+ 'open'?: boolean;
7
+ };
8
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ "update:open": (value: boolean) => any;
11
+ done: (payload: {
12
+ target: string;
13
+ copied: number;
14
+ }) => any;
15
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
16
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
17
+ onDone?: ((payload: {
18
+ target: string;
19
+ copied: number;
20
+ }) => any) | undefined;
21
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const _default: typeof __VLS_export;
23
+ export default _default;
@@ -0,0 +1,206 @@
1
+ <script setup>
2
+ import { computed, ref, watch } from "vue";
3
+ import { useI18n, useMongocampError } from "#imports";
4
+ import { useMongocampCollectionCopy } from "../composables/useMongocampCollectionCopy";
5
+ import { backupName, canCopyCollection, MAX_COLLECTION_NAME_LENGTH, validateTargetName } from "../utils/collectionCopy";
6
+ const props = defineProps({
7
+ source: { type: String, required: true },
8
+ filter: { type: String, required: false }
9
+ });
10
+ const emit = defineEmits(["done"]);
11
+ const isOpen = defineModel("open", { type: Boolean, ...{ default: false } });
12
+ const { t } = useI18n();
13
+ const { describeServerError } = useMongocampError();
14
+ const { copyCollection, backupCollection, listCollectionNames, countDocuments } = useMongocampCollectionCopy();
15
+ const step = ref("form");
16
+ const target = ref("");
17
+ const existing = ref([]);
18
+ const sourceCount = ref(void 0);
19
+ const countFailed = ref(false);
20
+ const result = ref(null);
21
+ const errorText = ref("");
22
+ const withIndexes = ref(true);
23
+ let opened = 0;
24
+ watch(isOpen, async (open) => {
25
+ if (!open) return;
26
+ const mine = ++opened;
27
+ step.value = "form";
28
+ target.value = "";
29
+ result.value = null;
30
+ errorText.value = "";
31
+ sourceCount.value = void 0;
32
+ countFailed.value = false;
33
+ const [names, count] = await Promise.allSettled([listCollectionNames(), countDocuments(props.source, props.filter)]);
34
+ if (mine !== opened) return;
35
+ existing.value = names.status === "fulfilled" ? names.value : [];
36
+ if (count.status === "fulfilled") sourceCount.value = count.value;
37
+ else countFailed.value = true;
38
+ }, { immediate: true });
39
+ const problem = computed(() => target.value === "" ? void 0 : validateTargetName(target.value, props.source, existing.value));
40
+ const problemText = computed(() => {
41
+ const key = { "empty": "problemEmpty", "too-long": "problemTooLong", "invalid-characters": "problemInvalid", "protected": "problemProtected", "same-as-source": "problemSame", "exists": "problemExists" }[problem.value ?? "empty"];
42
+ return problem.value ? t(`nuxtUiMongocamp.collectionCopy.${key}`, { max: MAX_COLLECTION_NAME_LENGTH }) : "";
43
+ });
44
+ const targetName = computed(() => target.value.trim());
45
+ const canStart = computed(() => targetName.value !== "" && problem.value === void 0);
46
+ const canBackup = computed(() => canCopyCollection(props.source));
47
+ const backupPreview = computed(() => backupName(props.source, existing.value));
48
+ async function reasonOf(error) {
49
+ return (await describeServerError(error, "nuxtUiMongocamp.collectionCopy.failedGeneric")).message;
50
+ }
51
+ async function start(quick = false) {
52
+ if (quick ? !canBackup.value : !canStart.value) return;
53
+ errorText.value = "";
54
+ step.value = "running";
55
+ try {
56
+ const common = { source: props.source, filter: props.filter, withIndexes: withIndexes.value };
57
+ const outcome = quick ? await backupCollection({ ...common, onTarget: (name) => {
58
+ target.value = name;
59
+ } }) : await copyCollection({ ...common, target: targetName.value });
60
+ result.value = outcome;
61
+ if (outcome.refused === "target-exists") {
62
+ existing.value = [...existing.value, outcome.target];
63
+ step.value = "form";
64
+ errorText.value = t("nuxtUiMongocamp.collectionCopy.refusedExists", { target: outcome.target });
65
+ return;
66
+ }
67
+ step.value = "done";
68
+ emit("done", { target: outcome.target, copied: outcome.count });
69
+ } catch (e) {
70
+ errorText.value = await reasonOf(e);
71
+ step.value = "form";
72
+ }
73
+ }
74
+ </script>
75
+
76
+ <template>
77
+ <UModal
78
+ v-model:open="isOpen"
79
+ :title="filter ? t('nuxtUiMongocamp.collectionCopy.titleFiltered', { source }) : t('nuxtUiMongocamp.collectionCopy.title', { source })"
80
+ :dismissible="step !== 'running'"
81
+ :ui="{ footer: 'justify-end' }"
82
+ >
83
+ <template #body>
84
+ <div
85
+ v-if="step === 'form'"
86
+ class="flex flex-col gap-4"
87
+ >
88
+ <p class="text-sm text-dimmed">
89
+ {{ t("nuxtUiMongocamp.collectionCopy.intro") }}
90
+ </p>
91
+ <UFormField
92
+ :label="t('nuxtUiMongocamp.collectionCopy.targetLabel')"
93
+ :help="t('nuxtUiMongocamp.collectionCopy.targetHelp')"
94
+ :error="problemText || void 0"
95
+ >
96
+ <UInput
97
+ v-model="target"
98
+ class="w-full"
99
+ autocomplete="off"
100
+ :placeholder="t('nuxtUiMongocamp.collectionCopy.targetPlaceholder')"
101
+ :aria-label="t('nuxtUiMongocamp.collectionCopy.targetLabel')"
102
+ @keydown.enter.prevent="start()"
103
+ />
104
+ </UFormField>
105
+ <p
106
+ v-if="sourceCount !== void 0"
107
+ class="text-sm"
108
+ data-test="copy-count"
109
+ >
110
+ {{ t(filter ? "nuxtUiMongocamp.collectionCopy.countFiltered" : "nuxtUiMongocamp.collectionCopy.count", { count: sourceCount }, sourceCount) }}
111
+ </p>
112
+ <p
113
+ v-else-if="!countFailed"
114
+ class="text-sm text-dimmed"
115
+ >
116
+ {{ t("nuxtUiMongocamp.collectionCopy.countLoading") }}
117
+ </p>
118
+ <p
119
+ v-if="countFailed"
120
+ class="text-sm text-error"
121
+ role="alert"
122
+ >
123
+ {{ t("nuxtUiMongocamp.collectionCopy.countFailed") }}
124
+ </p>
125
+ <UCheckbox
126
+ v-model="withIndexes"
127
+ :label="t('nuxtUiMongocamp.collectionCopy.withIndexes')"
128
+ :description="t('nuxtUiMongocamp.collectionCopy.withIndexesHelp')"
129
+ />
130
+ <p
131
+ v-if="errorText"
132
+ class="text-sm text-error"
133
+ role="alert"
134
+ >
135
+ {{ errorText }}
136
+ </p>
137
+ </div>
138
+
139
+ <div
140
+ v-else-if="step === 'running'"
141
+ class="flex flex-col gap-2"
142
+ role="status"
143
+ data-test="copy-progress"
144
+ >
145
+ <UProgress />
146
+ <span class="text-sm text-dimmed">{{ t("nuxtUiMongocamp.collectionCopy.running", { source, count: sourceCount ?? 0 }, sourceCount ?? 0) }}</span>
147
+ </div>
148
+
149
+ <div
150
+ v-else
151
+ class="flex flex-col gap-3"
152
+ data-test="copy-result"
153
+ >
154
+ <UAlert
155
+ color="success"
156
+ variant="subtle"
157
+ icon="i-lucide-circle-check"
158
+ :title="t('nuxtUiMongocamp.collectionCopy.doneTitle', { count: result?.count ?? 0, target: result?.target ?? targetName }, result?.count ?? 0)"
159
+ />
160
+ <p
161
+ v-if="withIndexes"
162
+ class="text-sm"
163
+ data-test="copy-indexes"
164
+ >
165
+ {{ (result?.indexes ?? 0) > 0 ? t("nuxtUiMongocamp.collectionCopy.indexesCopied", { count: result?.indexes ?? 0 }) : t("nuxtUiMongocamp.collectionCopy.indexesNone") }}
166
+ </p>
167
+ </div>
168
+ </template>
169
+
170
+ <template #footer>
171
+ <template v-if="step === 'running'" />
172
+ <template v-else-if="step === 'done'">
173
+ <UButton
174
+ :label="t('nuxtUiMongocamp.collectionCopy.close')"
175
+ color="neutral"
176
+ variant="ghost"
177
+ @click="isOpen = false"
178
+ />
179
+ </template>
180
+ <template v-else>
181
+ <UButton
182
+ :label="t('nuxtUiMongocamp.common.cancel')"
183
+ color="neutral"
184
+ variant="ghost"
185
+ @click="isOpen = false"
186
+ />
187
+ <UButton
188
+ :label="t('nuxtUiMongocamp.collectionCopy.quickBackup')"
189
+ icon="i-lucide-archive"
190
+ color="neutral"
191
+ variant="soft"
192
+ :disabled="!canBackup"
193
+ :title="t('nuxtUiMongocamp.collectionCopy.quickBackupHint', { name: backupPreview })"
194
+ data-test="quick-backup"
195
+ @click="start(true)"
196
+ />
197
+ <UButton
198
+ :label="t('nuxtUiMongocamp.collectionCopy.start')"
199
+ icon="i-lucide-copy"
200
+ :disabled="!canStart"
201
+ @click="start()"
202
+ />
203
+ </template>
204
+ </template>
205
+ </UModal>
206
+ </template>
@@ -0,0 +1,23 @@
1
+ type __VLS_Props = {
2
+ source: string;
3
+ filter?: string;
4
+ };
5
+ type __VLS_ModelProps = {
6
+ 'open'?: boolean;
7
+ };
8
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ "update:open": (value: boolean) => any;
11
+ done: (payload: {
12
+ target: string;
13
+ copied: number;
14
+ }) => any;
15
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
16
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
17
+ onDone?: ((payload: {
18
+ target: string;
19
+ copied: number;
20
+ }) => any) | undefined;
21
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const _default: typeof __VLS_export;
23
+ export default _default;
@@ -1,9 +1,15 @@
1
1
  type __VLS_Props = {
2
2
  collectionName: string;
3
3
  infoPath?: string;
4
+ aggregatePath?: string;
5
+ persistState?: boolean;
6
+ stateKey?: string;
4
7
  };
5
8
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
9
  infoPath: string;
10
+ aggregatePath: string;
11
+ persistState: boolean;
12
+ stateKey: string;
7
13
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
14
  declare const _default: typeof __VLS_export;
9
15
  export default _default;