@sfxcode/nuxt-ui-mongocamp 1.3.4 → 1.4.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 (212) hide show
  1. package/README.md +4 -0
  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.vue +302 -3
  6. package/dist/runtime/components/MongocampAggregationChart.d.vue.ts +6 -0
  7. package/dist/runtime/components/MongocampAggregationChart.vue +93 -0
  8. package/dist/runtime/components/MongocampAggregationChart.vue.d.ts +6 -0
  9. package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +9 -0
  10. package/dist/runtime/components/MongocampAggregationStagePreview.vue +148 -0
  11. package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +9 -0
  12. package/dist/runtime/components/MongocampBucketFiles.vue +169 -48
  13. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +19 -0
  14. package/dist/runtime/components/MongocampBulkDelete.vue +118 -23
  15. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +19 -0
  16. package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +6 -0
  17. package/dist/runtime/components/MongocampBulkEdit.vue +23 -2
  18. package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +6 -0
  19. package/dist/runtime/components/MongocampChart.d.vue.ts +29 -0
  20. package/dist/runtime/components/MongocampChart.vue +129 -0
  21. package/dist/runtime/components/MongocampChart.vue.d.ts +29 -0
  22. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +15 -0
  23. package/dist/runtime/components/MongocampCollectionCharts.vue +199 -0
  24. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +15 -0
  25. package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +23 -0
  26. package/dist/runtime/components/MongocampCollectionCopy.vue +445 -0
  27. package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +23 -0
  28. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +4 -0
  29. package/dist/runtime/components/MongocampCollectionData.vue +343 -146
  30. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +4 -0
  31. package/dist/runtime/components/MongocampCollectionInfos.vue +106 -238
  32. package/dist/runtime/components/MongocampCollections.vue +62 -0
  33. package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +40 -0
  34. package/dist/runtime/components/MongocampCommandPalette.vue +135 -0
  35. package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +40 -0
  36. package/dist/runtime/components/MongocampConfirmByName.vue +2 -2
  37. package/dist/runtime/components/MongocampDashboard.d.vue.ts +3 -1
  38. package/dist/runtime/components/MongocampDashboard.vue +21 -2
  39. package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -1
  40. package/dist/runtime/components/MongocampDatabases.vue +22 -0
  41. package/dist/runtime/components/MongocampDocumentCompare.d.vue.ts +20 -0
  42. package/dist/runtime/components/MongocampDocumentCompare.vue +146 -0
  43. package/dist/runtime/components/MongocampDocumentCompare.vue.d.ts +20 -0
  44. package/dist/runtime/components/MongocampDocumentView.d.vue.ts +22 -0
  45. package/dist/runtime/components/MongocampDocumentView.vue +202 -0
  46. package/dist/runtime/components/MongocampDocumentView.vue.d.ts +22 -0
  47. package/dist/runtime/components/MongocampErrorAlert.vue +12 -16
  48. package/dist/runtime/components/MongocampExportAll.d.vue.ts +18 -0
  49. package/dist/runtime/components/MongocampExportAll.vue +204 -0
  50. package/dist/runtime/components/MongocampExportAll.vue.d.ts +18 -0
  51. package/dist/runtime/components/MongocampFilePreview.d.vue.ts +16 -0
  52. package/dist/runtime/components/MongocampFilePreview.vue +162 -0
  53. package/dist/runtime/components/MongocampFilePreview.vue.d.ts +16 -0
  54. package/dist/runtime/components/MongocampFilterBuilder.vue +11 -0
  55. package/dist/runtime/components/MongocampImport.vue +2 -10
  56. package/dist/runtime/components/MongocampIndexes.d.vue.ts +18 -0
  57. package/dist/runtime/components/MongocampIndexes.vue +455 -0
  58. package/dist/runtime/components/MongocampIndexes.vue.d.ts +18 -0
  59. package/dist/runtime/components/MongocampJobs.d.vue.ts +6 -1
  60. package/dist/runtime/components/MongocampJobs.vue +24 -4
  61. package/dist/runtime/components/MongocampJobs.vue.d.ts +6 -1
  62. package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +12 -0
  63. package/dist/runtime/components/MongocampPermissionMatrix.vue +301 -0
  64. package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +12 -0
  65. package/dist/runtime/components/MongocampQueryBar.d.vue.ts +26 -0
  66. package/dist/runtime/components/MongocampQueryBar.vue +398 -0
  67. package/dist/runtime/components/MongocampQueryBar.vue.d.ts +26 -0
  68. package/dist/runtime/components/MongocampRoleGrants.vue +2 -2
  69. package/dist/runtime/components/MongocampRoles.vue +3 -3
  70. package/dist/runtime/components/MongocampServerOverview.d.vue.ts +20 -0
  71. package/dist/runtime/components/MongocampServerOverview.vue +443 -0
  72. package/dist/runtime/components/MongocampServerOverview.vue.d.ts +20 -0
  73. package/dist/runtime/components/MongocampSettings.d.vue.ts +25 -1
  74. package/dist/runtime/components/MongocampSettings.vue +70 -9
  75. package/dist/runtime/components/MongocampSettings.vue.d.ts +25 -1
  76. package/dist/runtime/components/MongocampUsers.vue +3 -3
  77. package/dist/runtime/composables/useMongocampAdmin.d.ts +2 -1
  78. package/dist/runtime/composables/useMongocampAdmin.js +7 -15
  79. package/dist/runtime/composables/useMongocampAggregation.d.ts +12 -1
  80. package/dist/runtime/composables/useMongocampAggregation.js +33 -25
  81. package/dist/runtime/composables/useMongocampAutoRefresh.d.ts +26 -0
  82. package/dist/runtime/composables/useMongocampAutoRefresh.js +78 -0
  83. package/dist/runtime/composables/useMongocampBucket.d.ts +13 -1
  84. package/dist/runtime/composables/useMongocampBucket.js +34 -0
  85. package/dist/runtime/composables/useMongocampClientApi.d.ts +1 -1
  86. package/dist/runtime/composables/useMongocampClientApi.js +2 -1
  87. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +85 -0
  88. package/dist/runtime/composables/useMongocampCollectionCopy.js +105 -0
  89. package/dist/runtime/composables/useMongocampCollectionStats.d.ts +10 -0
  90. package/dist/runtime/composables/useMongocampCollectionStats.js +17 -0
  91. package/dist/runtime/composables/useMongocampError.d.ts +2 -1
  92. package/dist/runtime/composables/useMongocampError.js +16 -1
  93. package/dist/runtime/composables/useMongocampExportAll.d.ts +47 -0
  94. package/dist/runtime/composables/useMongocampExportAll.js +27 -0
  95. package/dist/runtime/composables/useMongocampExtendedJson.d.ts +5 -1
  96. package/dist/runtime/composables/useMongocampExtendedJson.js +12 -6
  97. package/dist/runtime/composables/useMongocampFetchAll.d.ts +25 -0
  98. package/dist/runtime/composables/useMongocampFetchAll.js +27 -0
  99. package/dist/runtime/composables/useMongocampPermissions.d.ts +14 -0
  100. package/dist/runtime/composables/useMongocampPermissions.js +21 -0
  101. package/dist/runtime/composables/useMongocampPersistedState.d.ts +15 -0
  102. package/dist/runtime/composables/useMongocampPersistedState.js +21 -0
  103. package/dist/runtime/composables/useMongocampProxyApi.d.ts +1 -1
  104. package/dist/runtime/composables/useMongocampProxyApi.js +2 -1
  105. package/dist/runtime/composables/useMongocampQuery.d.ts +50 -2
  106. package/dist/runtime/composables/useMongocampQuery.js +72 -1
  107. package/dist/runtime/composables/useMongocampSavedPipelines.d.ts +25 -0
  108. package/dist/runtime/composables/useMongocampSavedPipelines.js +23 -0
  109. package/dist/runtime/composables/useMongocampSavedQueries.d.ts +37 -0
  110. package/dist/runtime/composables/useMongocampSavedQueries.js +50 -0
  111. package/dist/runtime/composables/useMongocampServerOverview.d.ts +42 -0
  112. package/dist/runtime/composables/useMongocampServerOverview.js +61 -0
  113. package/dist/runtime/composables/useMongocampSession.d.ts +3 -2
  114. package/dist/runtime/composables/useMongocampSession.js +14 -22
  115. package/dist/runtime/composables/useMongocampSystem.d.ts +7 -2
  116. package/dist/runtime/composables/useMongocampSystem.js +6 -2
  117. package/dist/runtime/locales/de.json +495 -10
  118. package/dist/runtime/locales/en.json +495 -10
  119. package/dist/runtime/plugin.js +8 -5
  120. package/dist/runtime/utils/aggregationPipeline.d.ts +5 -4
  121. package/dist/runtime/utils/aggregationPipeline.js +23 -9
  122. package/dist/runtime/utils/aggregationPreview.d.ts +13 -0
  123. package/dist/runtime/utils/aggregationPreview.js +10 -0
  124. package/dist/runtime/utils/aggregationResult.d.ts +5 -0
  125. package/dist/runtime/utils/aggregationResult.js +4 -0
  126. package/dist/runtime/utils/aggregationTemplates.d.ts +34 -0
  127. package/dist/runtime/utils/aggregationTemplates.js +47 -0
  128. package/dist/runtime/utils/analyzeSamples.d.ts +1 -0
  129. package/dist/runtime/utils/analyzeSamples.js +1 -1
  130. package/dist/runtime/utils/autoRefresh.d.ts +14 -0
  131. package/dist/runtime/utils/autoRefresh.js +15 -0
  132. package/dist/runtime/utils/bigIntJson.d.ts +15 -0
  133. package/dist/runtime/utils/bigIntJson.js +55 -0
  134. package/dist/runtime/utils/bulkDelete.d.ts +9 -1
  135. package/dist/runtime/utils/bulkDelete.js +15 -3
  136. package/dist/runtime/utils/bulkEdit.d.ts +6 -0
  137. package/dist/runtime/utils/bulkEdit.js +7 -0
  138. package/dist/runtime/utils/chartData.d.ts +11 -0
  139. package/dist/runtime/utils/chartData.js +9 -0
  140. package/dist/runtime/utils/collectionChart.d.ts +36 -0
  141. package/dist/runtime/utils/collectionChart.js +73 -0
  142. package/dist/runtime/utils/collectionCopy.d.ts +26 -0
  143. package/dist/runtime/utils/collectionCopy.js +38 -0
  144. package/dist/runtime/utils/collectionStats.d.ts +31 -0
  145. package/dist/runtime/utils/collectionStats.js +42 -0
  146. package/dist/runtime/utils/commandPalette.d.ts +48 -0
  147. package/dist/runtime/utils/commandPalette.js +39 -0
  148. package/dist/runtime/utils/createProxyMongocampApis.d.ts +2 -2
  149. package/dist/runtime/utils/createProxyMongocampApis.js +2 -2
  150. package/dist/runtime/utils/documentCompare.d.ts +31 -0
  151. package/dist/runtime/utils/documentCompare.js +70 -0
  152. package/dist/runtime/utils/documentDiff.d.ts +19 -0
  153. package/dist/runtime/utils/documentDiff.js +71 -0
  154. package/dist/runtime/utils/documentPaths.d.ts +44 -0
  155. package/dist/runtime/utils/documentPaths.js +144 -0
  156. package/dist/runtime/utils/documentTree.d.ts +40 -0
  157. package/dist/runtime/utils/documentTree.js +94 -0
  158. package/dist/runtime/utils/exportDocuments.d.ts +35 -0
  159. package/dist/runtime/utils/exportDocuments.js +54 -0
  160. package/dist/runtime/utils/exportRows.js +1 -1
  161. package/dist/runtime/utils/filePreview.d.ts +27 -0
  162. package/dist/runtime/utils/filePreview.js +50 -0
  163. package/dist/runtime/utils/filterBuilder.d.ts +6 -1
  164. package/dist/runtime/utils/filterBuilder.js +6 -5
  165. package/dist/runtime/utils/formatBytes.d.ts +2 -0
  166. package/dist/runtime/utils/formatBytes.js +11 -0
  167. package/dist/runtime/utils/grantMatching.d.ts +8 -0
  168. package/dist/runtime/utils/grantMatching.js +15 -0
  169. package/dist/runtime/utils/importRows.js +12 -2
  170. package/dist/runtime/utils/indexCopy.d.ts +26 -0
  171. package/dist/runtime/utils/indexCopy.js +22 -0
  172. package/dist/runtime/utils/indexForm.d.ts +69 -0
  173. package/dist/runtime/utils/indexForm.js +63 -0
  174. package/dist/runtime/utils/limitedMap.d.ts +17 -0
  175. package/dist/runtime/utils/limitedMap.js +19 -0
  176. package/dist/runtime/utils/luceneExpression.d.ts +15 -0
  177. package/dist/runtime/utils/luceneExpression.js +74 -0
  178. package/dist/runtime/utils/pagedFetch.d.ts +46 -0
  179. package/dist/runtime/utils/pagedFetch.js +58 -0
  180. package/dist/runtime/utils/paginationHeaders.d.ts +4 -0
  181. package/dist/runtime/utils/paginationHeaders.js +4 -0
  182. package/dist/runtime/utils/permissionDenied.d.ts +10 -0
  183. package/dist/runtime/utils/permissionDenied.js +23 -0
  184. package/dist/runtime/utils/permissionMatrix.d.ts +55 -0
  185. package/dist/runtime/utils/permissionMatrix.js +85 -0
  186. package/dist/runtime/utils/persistedState.d.ts +25 -0
  187. package/dist/runtime/utils/persistedState.js +47 -0
  188. package/dist/runtime/utils/queryState.d.ts +45 -0
  189. package/dist/runtime/utils/queryState.js +75 -0
  190. package/dist/runtime/utils/requestLimits.d.ts +2 -0
  191. package/dist/runtime/utils/requestLimits.js +4 -0
  192. package/dist/runtime/utils/resultChart.d.ts +32 -0
  193. package/dist/runtime/utils/resultChart.js +59 -0
  194. package/dist/runtime/utils/savedPipelines.d.ts +22 -0
  195. package/dist/runtime/utils/savedPipelines.js +46 -0
  196. package/dist/runtime/utils/savedQueries.d.ts +60 -0
  197. package/dist/runtime/utils/savedQueries.js +143 -0
  198. package/dist/runtime/utils/schemaAnalysis.d.ts +16 -0
  199. package/dist/runtime/utils/schemaAnalysis.js +57 -0
  200. package/dist/runtime/utils/serverError.d.ts +19 -0
  201. package/dist/runtime/utils/serverError.js +19 -0
  202. package/dist/runtime/utils/serverOverview.d.ts +47 -0
  203. package/dist/runtime/utils/serverOverview.js +40 -0
  204. package/dist/runtime/utils/sessionGuard.d.ts +3 -0
  205. package/dist/runtime/utils/sessionGuard.js +18 -1
  206. package/package.json +13 -12
  207. package/dist/runtime/utils/failureKind.d.ts +0 -3
  208. package/dist/runtime/utils/failureKind.js +0 -11
  209. package/dist/runtime/utils/serverProbe.d.ts +0 -10
  210. package/dist/runtime/utils/serverProbe.js +0 -25
  211. package/dist/runtime/utils/throttled.d.ts +0 -6
  212. package/dist/runtime/utils/throttled.js +0 -16
@@ -1,9 +1,13 @@
1
1
  type __VLS_Props = {
2
2
  collectionName: string;
3
3
  infoPath?: string;
4
+ persistState?: boolean;
5
+ stateKey?: string;
4
6
  };
5
7
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
8
  infoPath: string;
9
+ persistState: boolean;
10
+ stateKey: string;
7
11
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
12
  declare const _default: typeof __VLS_export;
9
13
  export default _default;
@@ -1,10 +1,13 @@
1
1
  <script setup>
2
- import { computed, h, reactive, ref, resolveComponent, watch } from "vue";
3
- import { useI18n, useMongocampClientApi, useMongocampIndex, useMongocampSchema, useToast } from "#imports";
2
+ import { computed, h, ref, resolveComponent, watch } from "vue";
3
+ import { useI18n, useMongocampClientApi, useMongocampSchema, useToast } from "#imports";
4
+ import MongocampIndexes from "./MongocampIndexes.vue";
4
5
  import { useMongocampAggregation } from "../composables/useMongocampAggregation";
5
6
  import useMongocampAdmin from "../composables/useMongocampAdmin";
6
7
  import { analyzeSamples } from "../utils/analyzeSamples";
8
+ import { shortenLabel } from "../utils/chartData";
7
9
  import { downloadTextFile } from "../utils/exportRows";
10
+ import { FULL_ANALYSIS_MAX_DOCUMENTS, statisticsFromSchemaAnalysis } from "../utils/schemaAnalysis";
8
11
  const props = defineProps({
9
12
  collectionName: { type: String, required: true },
10
13
  sampleSize: { type: Number, required: false, default: 500 }
@@ -12,24 +15,14 @@ const props = defineProps({
12
15
  const { t } = useI18n();
13
16
  const { collectionApi, documentApi } = useMongocampClientApi();
14
17
  const { schemaFromSamples, schemaToTsInterface } = useMongocampSchema();
15
- const { listIndexes, createIndex, createUniqueIndex, createTextIndex, createExpiringIndex, deleteIndex } = useMongocampIndex();
16
18
  const { sampleDocuments, describeAggregationError } = useMongocampAggregation();
17
- const { getJsonSchema } = useMongocampAdmin();
19
+ const { getJsonSchema, getSchemaAnalysis } = useMongocampAdmin();
18
20
  const UBadge = resolveComponent("UBadge");
19
21
  const UIcon = resolveComponent("UIcon");
20
- const UButton = resolveComponent("UButton");
21
- const UTooltip = resolveComponent("UTooltip");
22
- function withTooltip(text, node) {
23
- return h(UTooltip, { text }, { default: () => node });
24
- }
25
22
  const info = ref(null);
23
+ const chartField = ref("");
26
24
  const columnDefinitions = ref([]);
27
- const indexes = ref([]);
28
25
  const loading = ref(false);
29
- async function fetchIndexes() {
30
- if (!props.collectionName) return;
31
- indexes.value = await listIndexes(props.collectionName);
32
- }
33
26
  async function fetchInfo() {
34
27
  if (!props.collectionName) return;
35
28
  loading.value = true;
@@ -41,11 +34,11 @@ async function fetchInfo() {
41
34
  page: 1
42
35
  });
43
36
  columnDefinitions.value = schemaFromSamples(samples);
44
- await fetchIndexes();
45
37
  } finally {
46
38
  loading.value = false;
47
39
  }
48
40
  }
41
+ watch(() => props.collectionName, () => chartField.value = "");
49
42
  watch(() => [props.collectionName, props.sampleSize], fetchInfo, { immediate: true });
50
43
  const TYPE_COLORS = {
51
44
  "string": "neutral",
@@ -139,6 +132,7 @@ const KIND_COLORS = {
139
132
  null: "neutral"
140
133
  };
141
134
  const statsSampleSize = ref(500);
135
+ const statsMode = ref("sample");
142
136
  const statsLoading = ref(false);
143
137
  const statsError = ref(null);
144
138
  const statsAnalysis = ref(null);
@@ -147,6 +141,7 @@ async function analyzeFields() {
147
141
  const run = ++statsRun;
148
142
  statsLoading.value = true;
149
143
  statsError.value = null;
144
+ statsMode.value = "sample";
150
145
  try {
151
146
  const { rows } = await sampleDocuments(props.collectionName, statsSampleSize.value);
152
147
  if (run !== statsRun) return;
@@ -160,8 +155,32 @@ async function analyzeFields() {
160
155
  if (run === statsRun) statsLoading.value = false;
161
156
  }
162
157
  }
158
+ const canAnalyzeAll = computed(() => (info.value?.count ?? 0) > 0 && (info.value?.count ?? 0) <= FULL_ANALYSIS_MAX_DOCUMENTS);
159
+ async function analyzeAllDocuments() {
160
+ const run = ++statsRun;
161
+ statsLoading.value = true;
162
+ statsError.value = null;
163
+ statsMode.value = "server";
164
+ try {
165
+ const analysis = await getSchemaAnalysis(props.collectionName, info.value?.count ?? 0);
166
+ if (run !== statsRun) return;
167
+ statsAnalysis.value = statisticsFromSchemaAnalysis(analysis);
168
+ } catch (error) {
169
+ const timedOut = error?.name === "TimeoutError";
170
+ const described = timedOut ? { kind: "retryable", message: t("nuxtUiMongocamp.collectionInfos.statsServerTimeout") } : await describeAggregationError(error);
171
+ if (run !== statsRun) return;
172
+ statsAnalysis.value = null;
173
+ statsError.value = described;
174
+ } finally {
175
+ if (run === statsRun) statsLoading.value = false;
176
+ }
177
+ }
178
+ function retryStats() {
179
+ return statsMode.value === "server" ? analyzeAllDocuments() : analyzeFields();
180
+ }
163
181
  watch(() => props.collectionName, () => {
164
182
  statsRun++;
183
+ statsMode.value = "sample";
165
184
  statsAnalysis.value = null;
166
185
  statsError.value = null;
167
186
  statsLoading.value = false;
@@ -170,6 +189,8 @@ function percent(share) {
170
189
  if (share >= 1) return "100%";
171
190
  return share > 0 && share < 0.01 ? "<1%" : `${Math.round(share * 100)}%`;
172
191
  }
192
+ const PRESENCE_MAX_FIELDS = 20;
193
+ const presenceChart = computed(() => [...statsAnalysis.value?.fields ?? []].sort((a, b) => a.share - b.share || a.path.localeCompare(b.path)).slice(0, PRESENCE_MAX_FIELDS).map((f) => ({ path: shortenLabel(f.path, 32), share: Math.round(f.share * 100) })));
173
194
  const statsColumns = computed(() => [
174
195
  {
175
196
  accessorKey: "path",
@@ -190,7 +211,7 @@ const statsColumns = computed(() => [
190
211
  {
191
212
  id: "present",
192
213
  header: t("nuxtUiMongocamp.collectionInfos.statsColumnPresent"),
193
- cell: ({ row }) => h("span", { title: t("nuxtUiMongocamp.collectionInfos.statsPresentTitle", { present: row.original.present, sampled: statsAnalysis.value?.sampled ?? 0 }) }, percent(row.original.share))
214
+ cell: ({ row }) => h("span", { title: t(statsMode.value === "server" ? "nuxtUiMongocamp.collectionInfos.statsPresentTitleAll" : "nuxtUiMongocamp.collectionInfos.statsPresentTitle", { present: row.original.present, sampled: statsAnalysis.value?.sampled ?? 0 }) }, percent(row.original.share))
194
215
  },
195
216
  {
196
217
  id: "values",
@@ -198,143 +219,10 @@ const statsColumns = computed(() => [
198
219
  cell: ({ row }) => row.original.topValues ? h("span", { class: "text-xs" }, row.original.topValues.map((v) => `${v.value} (${v.count})`).join(", ")) : h("span", { class: "text-dimmed" }, "\u2014")
199
220
  }
200
221
  ]);
201
- const indexRows = computed(
202
- () => indexes.value.map((idx) => ({
203
- name: idx.name,
204
- keys: Object.entries(idx.keys ?? {}).map(([field, direction]) => `${field}: ${direction}`).join(", "),
205
- unique: idx.unique,
206
- text: idx.text,
207
- expire: idx.expire,
208
- sizeKb: Math.round((info.value?.indexSizes?.[idx.name] ?? 0) / 1024)
209
- }))
210
- );
211
- const isCreateIndexModalOpen = ref(false);
212
- const createIndexError = ref("");
213
- const newIndex = ref({ fieldName: "", sortAscending: true, indexType: "standard", duration: "3600s" });
214
- const createIndexSchema = reactive([
215
- {
216
- $formkit: "nuxtUIInput",
217
- name: "fieldName",
218
- label: t("nuxtUiMongocamp.collectionInfos.fieldName"),
219
- validation: "required"
220
- },
221
- {
222
- $formkit: "nuxtUISwitch",
223
- name: "sortAscending",
224
- label: t("nuxtUiMongocamp.collectionInfos.ascending")
225
- },
226
- {
227
- $formkit: "nuxtUISelectMenu",
228
- id: "indexType",
229
- name: "indexType",
230
- label: t("nuxtUiMongocamp.collectionInfos.indexType"),
231
- options: ["standard", "unique", "text", "expiring"],
232
- validation: "required"
233
- },
234
- {
235
- $formkit: "nuxtUIInput",
236
- name: "duration",
237
- label: t("nuxtUiMongocamp.collectionInfos.expireAfter"),
238
- help: t("nuxtUiMongocamp.collectionInfos.expireAfterHelp"),
239
- if: "$get(indexType).value === 'expiring'"
240
- }
241
- ]);
242
- function extractSelectValue(raw) {
243
- if (typeof raw === "object" && raw !== null) {
244
- const obj = raw;
245
- return obj.value ?? obj.label ?? "";
246
- }
247
- return String(raw ?? "");
248
- }
249
- function openCreateIndex() {
250
- createIndexError.value = "";
251
- newIndex.value = { fieldName: "", sortAscending: true, indexType: "standard", duration: "3600s" };
252
- isCreateIndexModalOpen.value = true;
253
- }
254
- async function handleCreateIndex() {
255
- createIndexError.value = "";
256
- const { fieldName, sortAscending } = newIndex.value;
257
- const indexType = extractSelectValue(newIndex.value.indexType);
258
- try {
259
- if (indexType === "unique") {
260
- await createUniqueIndex(props.collectionName, fieldName, sortAscending);
261
- } else if (indexType === "text") {
262
- await createTextIndex(props.collectionName, fieldName);
263
- } else if (indexType === "expiring") {
264
- await createExpiringIndex(props.collectionName, fieldName, newIndex.value.duration);
265
- } else {
266
- await createIndex(props.collectionName, { [fieldName]: sortAscending ? 1 : -1 });
267
- }
268
- isCreateIndexModalOpen.value = false;
269
- await fetchIndexes();
270
- } catch (e) {
271
- createIndexError.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.collectionInfos.errorCreateIndex");
272
- }
273
- }
274
- const isDeleteIndexModalOpen = ref(false);
275
- const deleteIndexError = ref("");
276
- const indexToDelete = ref(void 0);
277
- function confirmDeleteIndex(indexName) {
278
- indexToDelete.value = indexName;
279
- deleteIndexError.value = "";
280
- isDeleteIndexModalOpen.value = true;
222
+ const chartFieldItems = computed(() => columnDefinitions.value.filter((c) => c.columnType !== "object" && c.columnType !== "array").map((c) => ({ label: c.columnKey, value: c.columnKey })));
223
+ async function refreshInfo() {
224
+ info.value = await collectionApi.getCollectionInformation({ collectionName: props.collectionName });
281
225
  }
282
- async function handleDeleteIndex() {
283
- deleteIndexError.value = "";
284
- if (!indexToDelete.value) return;
285
- try {
286
- await deleteIndex(props.collectionName, indexToDelete.value);
287
- isDeleteIndexModalOpen.value = false;
288
- await fetchIndexes();
289
- } catch (e) {
290
- deleteIndexError.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.collectionInfos.errorDeleteIndex");
291
- }
292
- }
293
- const INDEX_FLAG_BADGES = [
294
- { key: "unique", label: "unique", color: "warning" },
295
- { key: "text", label: "text", color: "info" },
296
- { key: "expire", label: "expire", color: "secondary" }
297
- ];
298
- const indexTableColumns = computed(() => [
299
- {
300
- accessorKey: "name",
301
- header: t("nuxtUiMongocamp.collectionInfos.columnIndex")
302
- },
303
- {
304
- accessorKey: "keys",
305
- header: t("nuxtUiMongocamp.collectionInfos.columnKeys"),
306
- cell: ({ row }) => h("span", { class: "font-mono text-xs" }, row.original.keys)
307
- },
308
- {
309
- id: "flags",
310
- header: t("nuxtUiMongocamp.collectionInfos.columnType"),
311
- cell: ({ row }) => {
312
- const badges = INDEX_FLAG_BADGES.filter((flag) => row.original[flag.key]).map((flag) => h(UBadge, { label: flag.label, color: flag.color, variant: "subtle", size: "sm" }));
313
- if (badges.length === 0) {
314
- badges.push(h(UBadge, { label: t("nuxtUiMongocamp.collectionInfos.typeStandard"), color: "neutral", variant: "subtle", size: "sm" }));
315
- }
316
- return h("div", { class: "flex gap-1" }, badges);
317
- }
318
- },
319
- {
320
- accessorKey: "sizeKb",
321
- header: t("nuxtUiMongocamp.collectionInfos.columnSizeKb")
322
- },
323
- {
324
- id: "actions",
325
- header: "",
326
- cell: ({ row }) => row.original.name === "_id_" ? null : h("div", { class: "flex justify-end" }, [
327
- withTooltip(t("nuxtUiMongocamp.collectionInfos.deleteIndexTooltip"), h(UButton, {
328
- "icon": "i-lucide-trash-2",
329
- "color": "error",
330
- "variant": "ghost",
331
- "size": "sm",
332
- "aria-label": t("nuxtUiMongocamp.collectionInfos.deleteIndexTooltip"),
333
- "onClick": () => confirmDeleteIndex(row.original.name)
334
- }))
335
- ])
336
- }
337
- ]);
338
226
  </script>
339
227
 
340
228
  <template>
@@ -396,37 +284,12 @@ const indexTableColumns = computed(() => [
396
284
  </div>
397
285
  </UCard>
398
286
  </div>
399
- <UCard v-if="indexRows.length">
400
- <template #header>
401
- <div class="flex items-center justify-between gap-2">
402
- <div class="flex items-center gap-2">
403
- <UIcon
404
- name="i-lucide-list-tree"
405
- class="size-4 text-(--ui-primary)"
406
- />
407
- <span class="font-semibold">{{ t("nuxtUiMongocamp.collectionInfos.indexes") }}</span>
408
- <UBadge
409
- :label="t('nuxtUiMongocamp.collectionInfos.indexesCount', { count: indexRows.length })"
410
- variant="subtle"
411
- color="neutral"
412
- size="sm"
413
- />
414
- </div>
415
- <UButton
416
- icon="i-lucide-plus"
417
- :label="t('nuxtUiMongocamp.collectionInfos.createIndex')"
418
- color="neutral"
419
- variant="ghost"
420
- size="sm"
421
- @click="openCreateIndex"
422
- />
423
- </div>
424
- </template>
425
- <UTable
426
- :data="indexRows"
427
- :columns="indexTableColumns"
428
- />
429
- </UCard>
287
+ <MongocampIndexes
288
+ v-if="!loading"
289
+ :collection-name="collectionName"
290
+ :fields="columnDefinitions.map((c) => c.columnKey)"
291
+ @changed="refreshInfo"
292
+ />
430
293
 
431
294
  <UCard v-if="schemaRows.length">
432
295
  <template #header>
@@ -470,6 +333,32 @@ const indexTableColumns = computed(() => [
470
333
  />
471
334
  </UCard>
472
335
 
336
+ <UCard v-if="chartFieldItems.length > 0">
337
+ <template #header>
338
+ <div class="flex items-center gap-2">
339
+ <UIcon
340
+ name="i-lucide-chart-column"
341
+ class="size-4 text-(--ui-primary)"
342
+ />
343
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.collectionInfos.chartsTitle") }}</span>
344
+ </div>
345
+ </template>
346
+ <div class="flex flex-col gap-4">
347
+ <USelect
348
+ v-model="chartField"
349
+ :items="chartFieldItems"
350
+ :placeholder="t('nuxtUiMongocamp.collectionInfos.chartsPick')"
351
+ class="w-72"
352
+ :aria-label="t('nuxtUiMongocamp.collectionInfos.chartsField')"
353
+ />
354
+ <MongocampCollectionCharts
355
+ v-if="chartField"
356
+ :collection-name="collectionName"
357
+ :field="chartField"
358
+ />
359
+ </div>
360
+ </UCard>
361
+
473
362
  <UCard v-if="info && !loading">
474
363
  <template #header>
475
364
  <div class="flex flex-wrap items-center justify-between gap-2">
@@ -481,7 +370,7 @@ const indexTableColumns = computed(() => [
481
370
  <span class="font-semibold">{{ t("nuxtUiMongocamp.collectionInfos.statsTitle") }}</span>
482
371
  <UBadge
483
372
  v-if="statsAnalysis"
484
- :label="t('nuxtUiMongocamp.collectionInfos.statsSampled', { sampled: statsAnalysis.sampled, total: info.count })"
373
+ :label="statsMode === 'server' ? t('nuxtUiMongocamp.collectionInfos.statsAnalysed', { count: statsAnalysis.sampled }) : t('nuxtUiMongocamp.collectionInfos.statsSampled', { sampled: statsAnalysis.sampled, total: info.count })"
485
374
  variant="subtle"
486
375
  color="neutral"
487
376
  size="sm"
@@ -501,9 +390,21 @@ const indexTableColumns = computed(() => [
501
390
  color="neutral"
502
391
  variant="subtle"
503
392
  size="sm"
504
- :loading="statsLoading"
393
+ :loading="statsLoading && statsMode === 'sample'"
394
+ :disabled="statsLoading"
505
395
  @click="analyzeFields"
506
396
  />
397
+ <UButton
398
+ icon="i-lucide-scan-search"
399
+ :label="t('nuxtUiMongocamp.collectionInfos.statsAnalyzeAll')"
400
+ :title="canAnalyzeAll || (info.count ?? 0) === 0 ? t('nuxtUiMongocamp.collectionInfos.statsAnalyzeAllHint') : t('nuxtUiMongocamp.collectionInfos.statsAnalyzeAllTooLarge', { max: FULL_ANALYSIS_MAX_DOCUMENTS })"
401
+ color="neutral"
402
+ variant="outline"
403
+ size="sm"
404
+ :loading="statsLoading && statsMode === 'server'"
405
+ :disabled="!canAnalyzeAll || statsLoading"
406
+ @click="analyzeAllDocuments"
407
+ />
507
408
  </div>
508
409
  </div>
509
410
  </template>
@@ -537,13 +438,13 @@ const indexTableColumns = computed(() => [
537
438
  color="error"
538
439
  variant="subtle"
539
440
  icon="i-lucide-refresh-cw"
540
- @click="analyzeFields"
441
+ @click="retryStats"
541
442
  />
542
443
  </template>
543
444
  </UAlert>
544
445
  <template v-if="statsAnalysis">
545
446
  <p class="mb-2 text-xs text-dimmed">
546
- {{ t("nuxtUiMongocamp.collectionInfos.statsNote") }}
447
+ {{ statsMode === "server" ? t("nuxtUiMongocamp.collectionInfos.statsNoteAll", { count: statsAnalysis.sampled }) : t("nuxtUiMongocamp.collectionInfos.statsNote") }}
547
448
  <template v-if="statsAnalysis.truncated">
548
449
  {{ t("nuxtUiMongocamp.collectionInfos.statsTruncated", { count: statsAnalysis.fields.length }) }}
549
450
  </template>
@@ -556,59 +457,26 @@ const indexTableColumns = computed(() => [
556
457
  <MongocampEmptyState :title="t('nuxtUiMongocamp.collectionInfos.statsEmpty')" />
557
458
  </template>
558
459
  </UTable>
559
- </template>
560
- </UCard>
561
-
562
- <UModal
563
- v-model:open="isCreateIndexModalOpen"
564
- :title="t('nuxtUiMongocamp.collectionInfos.createIndexTitle')"
565
- >
566
- <template #body>
567
- <FUDataEdit
568
- :data="newIndex"
569
- :schema="createIndexSchema"
570
- :submit-label="t('nuxtUiMongocamp.collectionInfos.createIndex')"
571
- submit-icon="i-lucide-plus"
572
- @data-saved="handleCreateIndex"
573
- />
574
- <p
575
- v-if="createIndexError"
576
- class="mt-2 text-sm text-error-500"
460
+ <details
461
+ v-if="presenceChart.length > 1"
462
+ class="mt-3 text-sm"
463
+ data-testid="presence-chart"
577
464
  >
578
- {{ createIndexError }}
579
- </p>
580
- </template>
581
- </UModal>
582
-
583
- <UModal
584
- v-model:open="isDeleteIndexModalOpen"
585
- :title="t('nuxtUiMongocamp.collectionInfos.deleteIndexTitle')"
586
- :ui="{ footer: 'justify-end' }"
587
- >
588
- <template #body>
589
- <p>{{ t("nuxtUiMongocamp.collectionInfos.confirmDeleteIndex", { indexName: indexToDelete }) }}</p>
590
- <p
591
- v-if="deleteIndexError"
592
- class="mt-2 text-sm text-error-500"
593
- >
594
- {{ deleteIndexError }}
595
- </p>
596
- </template>
597
- <template #footer>
598
- <UButton
599
- :label="t('nuxtUiMongocamp.common.cancel')"
600
- color="neutral"
601
- variant="ghost"
602
- @click="isDeleteIndexModalOpen = false"
603
- />
604
- <UButton
605
- :label="t('nuxtUiMongocamp.common.delete')"
606
- color="error"
607
- icon="i-lucide-trash-2"
608
- @click="handleDeleteIndex"
609
- />
465
+ <summary class="cursor-pointer text-dimmed">
466
+ {{ t("nuxtUiMongocamp.collectionInfos.presenceSummary") }}
467
+ </summary>
468
+ <MongocampChart
469
+ class="mt-2"
470
+ :data="presenceChart"
471
+ index="path"
472
+ :categories="[{ key: 'share', label: t('nuxtUiMongocamp.collectionInfos.presenceLabel') }]"
473
+ :format="(v) => `${v}%`"
474
+ :chart-label="t('nuxtUiMongocamp.collectionInfos.presenceLabel')"
475
+ :chart-description="t('nuxtUiMongocamp.collectionInfos.presenceDescription', { count: presenceChart.length })"
476
+ />
477
+ </details>
610
478
  </template>
611
- </UModal>
479
+ </UCard>
612
480
 
613
481
  <UModal
614
482
  v-model:open="isSchemaOpen"
@@ -1,4 +1,6 @@
1
1
  <script setup>
2
+ import { formatBytes } from "../utils/formatBytes";
3
+ import { shortenLabel, topNWithOther } from "../utils/chartData";
2
4
  import { computed, h, ref, resolveComponent } from "vue";
3
5
  import { useI18n, useMongocampClientApi, useMongocampBucket, useMongocampRoles, useToast } from "#imports";
4
6
  import useMongocampAdmin from "../composables/useMongocampAdmin";
@@ -18,6 +20,17 @@ const { isAdmin } = useMongocampRoles();
18
20
  const toast = useToast();
19
21
  const canClearOrDrop = computed(() => props.canManage && isAdmin.value);
20
22
  const collections = ref([]);
23
+ const chartMetric = ref("storage");
24
+ const chartMetrics = computed(() => [
25
+ { value: "storage", label: t("nuxtUiMongocamp.collections.chartStorage") },
26
+ { value: "documents", label: t("nuxtUiMongocamp.collections.chartDocuments") }
27
+ ]);
28
+ const chartMetricLabel = computed(() => chartMetrics.value.find((m) => m.value === chartMetric.value).label);
29
+ const chartRows = computed(() => topNWithOther(
30
+ collections.value.map((c) => ({ label: shortenLabel(c.name), value: chartMetric.value === "storage" ? c.sizekb * 1024 : c.count })),
31
+ 10,
32
+ t("nuxtUiMongocamp.collections.chartOther")
33
+ ).map((item) => ({ name: item.label, value: item.value })));
21
34
  const loading = ref(false);
22
35
  const loadError = ref(null);
23
36
  async function fetchCollections() {
@@ -183,6 +196,14 @@ const columns = computed(() => [
183
196
  } else if (canClearOrDrop.value && !isProtectedCollection(row.original.name)) {
184
197
  const name = row.original.name;
185
198
  buttons.push(
199
+ withTooltip(t("nuxtUiMongocamp.collections.copyTooltip"), h(UButton, {
200
+ "icon": "i-lucide-copy",
201
+ "color": "neutral",
202
+ "variant": "ghost",
203
+ "size": "sm",
204
+ "aria-label": t("nuxtUiMongocamp.collections.copyTooltip"),
205
+ "onClick": () => openCopy(name)
206
+ })),
186
207
  withTooltip(t("nuxtUiMongocamp.collections.clearTooltip"), h(UButton, {
187
208
  "icon": "i-lucide-eraser",
188
209
  "color": "warning",
@@ -205,6 +226,12 @@ const columns = computed(() => [
205
226
  }
206
227
  }
207
228
  ]);
229
+ const copySource = ref("");
230
+ const isCopyOpen = ref(false);
231
+ function openCopy(name) {
232
+ copySource.value = name;
233
+ isCopyOpen.value = true;
234
+ }
208
235
  fetchCollections();
209
236
  </script>
210
237
 
@@ -240,6 +267,34 @@ fetchCollections();
240
267
  @retry="fetchCollections"
241
268
  />
242
269
 
270
+ <!-- secondary: collapsed, built from the numbers the table already holds -->
271
+ <details
272
+ v-if="chartRows.length > 1"
273
+ class="text-sm"
274
+ data-testid="collections-chart"
275
+ >
276
+ <summary class="cursor-pointer text-dimmed">
277
+ {{ t("nuxtUiMongocamp.collections.chartSummary") }}
278
+ </summary>
279
+ <div class="mt-2 flex flex-col gap-2">
280
+ <USelect
281
+ v-model="chartMetric"
282
+ :items="chartMetrics"
283
+ size="sm"
284
+ class="w-44"
285
+ :aria-label="t('nuxtUiMongocamp.collections.chartMetric')"
286
+ />
287
+ <MongocampChart
288
+ :data="chartRows"
289
+ index="name"
290
+ :categories="[{ key: 'value', label: chartMetricLabel }]"
291
+ :format="chartMetric === 'storage' ? formatBytes : void 0"
292
+ :chart-label="t('nuxtUiMongocamp.collections.chartLabel', { metric: chartMetricLabel })"
293
+ :chart-description="t('nuxtUiMongocamp.collections.chartDescription', { count: chartRows.length })"
294
+ />
295
+ </div>
296
+ </details>
297
+
243
298
  <UTable
244
299
  v-model:global-filter="globalFilter"
245
300
  v-model:sorting="sorting"
@@ -252,6 +307,13 @@ fetchCollections();
252
307
  </template>
253
308
  </UTable>
254
309
 
310
+ <MongocampCollectionCopy
311
+ v-if="copySource"
312
+ v-model:open="isCopyOpen"
313
+ :source="copySource"
314
+ @done="fetchCollections"
315
+ />
316
+
255
317
  <MongocampConfirmByName
256
318
  v-if="pending"
257
319
  v-model:open="isConfirmOpen"
@@ -0,0 +1,40 @@
1
+ import type { PaletteEntry } from '../utils/commandPalette.js';
2
+ type __VLS_Props = {
3
+ /** Keyboard shortcut in Nuxt UI's notation (`meta_k`); empty = no shortcut */
4
+ shortcut?: string;
5
+ /** How long loaded lists are reused, in milliseconds */
6
+ cacheMs?: number;
7
+ /** Open the page of a chosen entry; false = only emit `select` */
8
+ navigate?: boolean;
9
+ collectionPath?: string;
10
+ bucketPath?: string;
11
+ usersPath?: string;
12
+ rolePath?: string;
13
+ jobsPath?: string;
14
+ settingsPath?: string;
15
+ accountPath?: string;
16
+ };
17
+ type __VLS_ModelProps = {
18
+ 'open'?: boolean;
19
+ };
20
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
21
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
+ "update:open": (value: boolean) => any;
23
+ select: (entry: PaletteEntry) => any;
24
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
25
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
26
+ onSelect?: ((entry: PaletteEntry) => any) | undefined;
27
+ }>, {
28
+ shortcut: string;
29
+ cacheMs: number;
30
+ navigate: boolean;
31
+ collectionPath: string;
32
+ bucketPath: string;
33
+ usersPath: string;
34
+ rolePath: string;
35
+ jobsPath: string;
36
+ settingsPath: string;
37
+ accountPath: string;
38
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
39
+ declare const _default: typeof __VLS_export;
40
+ export default _default;