@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
@@ -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,24 +20,29 @@ 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() {
24
37
  loading.value = true;
25
38
  loadError.value = null;
26
39
  try {
27
- const names = await collectionApi.listCollections();
28
- const rows = await Promise.all(
29
- names.filter((name) => !name.startsWith("mc")).map(async (name) => {
30
- const info = await collectionApi.getCollectionInformation({ collectionName: name });
31
- return {
32
- name,
33
- count: info.count,
34
- sizekb: Math.round(info.storageSize / 1024),
35
- indexCount: info.nindexes
36
- };
37
- })
38
- );
40
+ const [names, infos] = await Promise.all([collectionApi.listCollections(), collectionApi.listCollectionInformation({})]);
41
+ const byName = new Map(infos.map((info) => [info.name, info]));
42
+ const rows = names.filter((name) => !name.startsWith("mc")).flatMap((name) => {
43
+ const info = byName.get(name);
44
+ return info ? [{ name, count: info.count, sizekb: Math.round(info.storageSize / 1024), indexCount: info.nindexes }] : [];
45
+ });
39
46
  collections.value = rows;
40
47
  } catch (e) {
41
48
  loadError.value = e;
@@ -183,6 +190,22 @@ const columns = computed(() => [
183
190
  } else if (canClearOrDrop.value && !isProtectedCollection(row.original.name)) {
184
191
  const name = row.original.name;
185
192
  buttons.push(
193
+ withTooltip(t("nuxtUiMongocamp.collections.copyTooltip"), h(UButton, {
194
+ "icon": "i-lucide-copy",
195
+ "color": "neutral",
196
+ "variant": "ghost",
197
+ "size": "sm",
198
+ "aria-label": t("nuxtUiMongocamp.collections.copyTooltip"),
199
+ "onClick": () => openCopy(name)
200
+ })),
201
+ withTooltip(t("nuxtUiMongocamp.collections.renameTooltip"), h(UButton, {
202
+ "icon": "i-lucide-pencil",
203
+ "color": "neutral",
204
+ "variant": "ghost",
205
+ "size": "sm",
206
+ "aria-label": t("nuxtUiMongocamp.collections.renameTooltip"),
207
+ "onClick": () => openRename(name)
208
+ })),
186
209
  withTooltip(t("nuxtUiMongocamp.collections.clearTooltip"), h(UButton, {
187
210
  "icon": "i-lucide-eraser",
188
211
  "color": "warning",
@@ -205,6 +228,22 @@ const columns = computed(() => [
205
228
  }
206
229
  }
207
230
  ]);
231
+ const copySource = ref("");
232
+ const isCopyOpen = ref(false);
233
+ function openCopy(name) {
234
+ copySource.value = name;
235
+ isCopyOpen.value = true;
236
+ }
237
+ const renameSource = ref("");
238
+ const isRenameOpen = ref(false);
239
+ async function onRenamed() {
240
+ await fetchCollections();
241
+ emit("changed");
242
+ }
243
+ function openRename(name) {
244
+ renameSource.value = name;
245
+ isRenameOpen.value = true;
246
+ }
208
247
  fetchCollections();
209
248
  </script>
210
249
 
@@ -240,6 +279,34 @@ fetchCollections();
240
279
  @retry="fetchCollections"
241
280
  />
242
281
 
282
+ <!-- secondary: collapsed, built from the numbers the table already holds -->
283
+ <details
284
+ v-if="chartRows.length > 1"
285
+ class="text-sm"
286
+ data-testid="collections-chart"
287
+ >
288
+ <summary class="cursor-pointer text-dimmed">
289
+ {{ t("nuxtUiMongocamp.collections.chartSummary") }}
290
+ </summary>
291
+ <div class="mt-2 flex flex-col gap-2">
292
+ <USelect
293
+ v-model="chartMetric"
294
+ :items="chartMetrics"
295
+ size="sm"
296
+ class="w-44"
297
+ :aria-label="t('nuxtUiMongocamp.collections.chartMetric')"
298
+ />
299
+ <MongocampChart
300
+ :data="chartRows"
301
+ index="name"
302
+ :categories="[{ key: 'value', label: chartMetricLabel }]"
303
+ :format="chartMetric === 'storage' ? formatBytes : void 0"
304
+ :chart-label="t('nuxtUiMongocamp.collections.chartLabel', { metric: chartMetricLabel })"
305
+ :chart-description="t('nuxtUiMongocamp.collections.chartDescription', { count: chartRows.length })"
306
+ />
307
+ </div>
308
+ </details>
309
+
243
310
  <UTable
244
311
  v-model:global-filter="globalFilter"
245
312
  v-model:sorting="sorting"
@@ -252,6 +319,20 @@ fetchCollections();
252
319
  </template>
253
320
  </UTable>
254
321
 
322
+ <MongocampCollectionCopy
323
+ v-if="copySource"
324
+ v-model:open="isCopyOpen"
325
+ :source="copySource"
326
+ @done="fetchCollections"
327
+ />
328
+
329
+ <MongocampCollectionRename
330
+ v-if="renameSource"
331
+ v-model:open="isRenameOpen"
332
+ :source="renameSource"
333
+ @done="onRenamed"
334
+ />
335
+
255
336
  <MongocampConfirmByName
256
337
  v-if="pending"
257
338
  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;
@@ -0,0 +1,135 @@
1
+ <script setup>
2
+ import { computed, ref, watch } from "vue";
3
+ import { defineShortcuts, navigateTo, useI18n } from "#imports";
4
+ import useMongocampAdmin from "../composables/useMongocampAdmin";
5
+ import { useMongocampJobs } from "../composables/useMongocampJobs";
6
+ import { useMongocampPermissions } from "../composables/useMongocampPermissions";
7
+ import { useMongocampRoles } from "../composables/useMongocampRoles";
8
+ import { buildActions, buildEntries, isFresh } from "../utils/commandPalette";
9
+ const props = defineProps({
10
+ shortcut: { type: String, required: false, default: "meta_k" },
11
+ cacheMs: { type: Number, required: false, default: 6e4 },
12
+ navigate: { type: Boolean, required: false, default: true },
13
+ collectionPath: { type: String, required: false, default: "/secured/admin/collections" },
14
+ bucketPath: { type: String, required: false, default: "/secured/admin/buckets" },
15
+ usersPath: { type: String, required: false, default: "/secured/admin/users" },
16
+ rolePath: { type: String, required: false, default: "/secured/admin/roles" },
17
+ jobsPath: { type: String, required: false, default: "/secured/admin/jobs" },
18
+ settingsPath: { type: String, required: false, default: "/secured/admin/settings" },
19
+ accountPath: { type: String, required: false, default: "/secured/account" }
20
+ });
21
+ const emit = defineEmits(["select"]);
22
+ const open = defineModel("open", { type: Boolean, ...{ default: false } });
23
+ const { t } = useI18n();
24
+ const { listUsers, listRoles, listCollections } = useMongocampAdmin();
25
+ const { listJobs } = useMongocampJobs();
26
+ const { canRead, load: loadPermissions } = useMongocampPermissions();
27
+ const { isAdmin, logoutPath } = useMongocampRoles();
28
+ const data = ref({});
29
+ const loadedAt = ref(void 0);
30
+ const loading = ref(false);
31
+ const failed = ref([]);
32
+ let generation = 0;
33
+ const paths = computed(() => ({
34
+ collectionPath: props.collectionPath,
35
+ bucketPath: props.bucketPath,
36
+ usersPath: props.usersPath,
37
+ rolePath: props.rolePath,
38
+ jobsPath: props.jobsPath,
39
+ settingsPath: props.settingsPath,
40
+ accountPath: props.accountPath
41
+ }));
42
+ async function load() {
43
+ const current = ++generation;
44
+ loading.value = true;
45
+ const admin = isAdmin.value;
46
+ const parts = {
47
+ collections: () => listCollections(),
48
+ users: async () => (await listUsers()).map((u) => u.user),
49
+ roles: async () => (await listRoles()).map((r) => r.name),
50
+ jobs: async () => (await listJobs()).map((j) => ({ name: j.name, group: j.group }))
51
+ };
52
+ const wanted = admin ? ["collections", "users", "roles", "jobs"] : ["collections"];
53
+ const [results] = await Promise.all([Promise.allSettled(wanted.map((key) => parts[key]())), admin ? void 0 : loadPermissions()]);
54
+ if (current !== generation) return;
55
+ const next = {};
56
+ const errors = [];
57
+ results.forEach((result, index) => {
58
+ const key = wanted[index];
59
+ if (result.status === "fulfilled") next[key] = result.value;
60
+ else errors.push(key);
61
+ });
62
+ data.value = next;
63
+ failed.value = errors;
64
+ loadedAt.value = Date.now();
65
+ loading.value = false;
66
+ }
67
+ watch(open, (isOpen) => {
68
+ if (isOpen && !isFresh(loadedAt.value, Date.now(), props.cacheMs) && !loading.value) load();
69
+ });
70
+ const GROUP_ORDER = ["collection", "bucket", "user", "role", "job", "action"];
71
+ function choose(entry) {
72
+ open.value = false;
73
+ emit("select", entry);
74
+ if (entry.action === "refresh") {
75
+ load();
76
+ return;
77
+ }
78
+ if (!props.navigate) return;
79
+ if (entry.action === "logout") navigateTo(logoutPath);
80
+ else if (entry.to) navigateTo(entry.to);
81
+ }
82
+ const groups = computed(() => {
83
+ const entries = [
84
+ ...buildEntries(data.value, paths.value, { canRead }),
85
+ ...buildActions(paths.value, { isAdmin: isAdmin.value })
86
+ ];
87
+ return GROUP_ORDER.map((kind) => {
88
+ const items = entries.filter((e) => e.kind === kind).map((entry) => ({
89
+ label: entry.kind === "action" ? t(`nuxtUiMongocamp.commandPalette.action.${entry.label}`) : entry.label,
90
+ suffix: entry.description,
91
+ icon: entry.icon,
92
+ onSelect: () => choose(entry)
93
+ }));
94
+ return { id: kind, label: t(`nuxtUiMongocamp.commandPalette.group.${kind}`), items };
95
+ }).filter((group) => group.items.length);
96
+ });
97
+ defineShortcuts(computed(() => props.shortcut ? { [props.shortcut]: { usingInput: true, handler: () => {
98
+ open.value = !open.value;
99
+ } } } : {}));
100
+ </script>
101
+
102
+ <template>
103
+ <UModal
104
+ v-model:open="open"
105
+ :title="t('nuxtUiMongocamp.commandPalette.title')"
106
+ :description="t('nuxtUiMongocamp.commandPalette.description')"
107
+ :ui="{ content: 'sm:max-w-xl' }"
108
+ >
109
+ <template #content>
110
+ <UCommandPalette
111
+ :groups="groups"
112
+ :loading="loading"
113
+ :placeholder="t('nuxtUiMongocamp.commandPalette.placeholder')"
114
+ class="h-96"
115
+ close
116
+ @update:open="open = $event"
117
+ >
118
+ <template #empty>
119
+ <span data-testid="palette-empty">{{ t("nuxtUiMongocamp.commandPalette.empty") }}</span>
120
+ </template>
121
+ <template
122
+ v-if="failed.length"
123
+ #footer
124
+ >
125
+ <p
126
+ class="px-3 py-2 text-xs text-dimmed"
127
+ data-testid="palette-failed"
128
+ >
129
+ {{ t("nuxtUiMongocamp.commandPalette.failed", { parts: failed.join(", ") }) }}
130
+ </p>
131
+ </template>
132
+ </UCommandPalette>
133
+ </template>
134
+ </UModal>
135
+ </template>
@@ -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;
@@ -12,7 +12,7 @@ const props = defineProps({
12
12
  });
13
13
  const open = defineModel("open", { type: Boolean, ...{ default: false } });
14
14
  const { t } = useI18n();
15
- const { describeError } = useMongocampError();
15
+ const { describeServerError } = useMongocampError();
16
16
  const typed = ref("");
17
17
  const busy = ref(false);
18
18
  const error = ref("");
@@ -33,7 +33,7 @@ async function handleConfirm() {
33
33
  await props.onConfirm();
34
34
  close();
35
35
  } catch (e) {
36
- error.value = describeError(e).message;
36
+ error.value = (await describeServerError(e)).message;
37
37
  } finally {
38
38
  busy.value = false;
39
39
  }
@@ -2,6 +2,7 @@ type __VLS_Props = {
2
2
  collectionsPath?: string;
3
3
  usersPath?: string;
4
4
  rolesPath?: string;
5
+ autoRefresh?: number;
5
6
  };
6
7
  declare function refresh(): Promise<void>;
7
8
  declare const __VLS_template: () => {
@@ -13,9 +14,10 @@ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
13
14
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
14
15
  refresh: typeof refresh;
15
16
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
- collectionsPath: string;
17
17
  usersPath: string;
18
+ collectionsPath: string;
18
19
  rolesPath: string;
20
+ autoRefresh: number;
19
21
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
22
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
21
23
  declare const _default: typeof __VLS_export;
@@ -1,12 +1,15 @@
1
1
  <script setup>
2
- import { computed, ref } from "vue";
2
+ import { computed, onMounted, ref, watch } from "vue";
3
3
  import { useI18n } from "#imports";
4
4
  import { useNuxtApp } from "#app";
5
5
  import useMongocampAdmin from "../composables/useMongocampAdmin";
6
+ import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
7
+ import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
6
8
  const props = defineProps({
7
9
  collectionsPath: { type: String, required: false, default: "/secured/admin/collections" },
8
10
  usersPath: { type: String, required: false, default: "/secured/admin/users" },
9
- rolesPath: { type: String, required: false, default: "/secured/admin/roles" }
11
+ rolesPath: { type: String, required: false, default: "/secured/admin/roles" },
12
+ autoRefresh: { type: Number, required: false, default: 0 }
10
13
  });
11
14
  const { t } = useI18n();
12
15
  const { $mongocampVersion } = useNuxtApp();
@@ -28,13 +31,31 @@ async function refresh() {
28
31
  loading.value = false;
29
32
  }
30
33
  }
34
+ async function reloadQuietly() {
35
+ try {
36
+ const [users, roles, collections] = await Promise.all([listUsers(), listRoles(), listCollections()]);
37
+ stats.value = { users: users.length, roles: roles.length, collections: collections.length };
38
+ loadError.value = null;
39
+ } catch (e) {
40
+ loadError.value = e;
41
+ throw e;
42
+ }
43
+ }
44
+ const { blocked, message } = useMongocampAdminGate();
45
+ const auto = useMongocampAutoRefresh(reloadQuietly, { intervalMs: () => props.autoRefresh * 1e3 });
46
+ function syncAutoRefresh() {
47
+ auto.stop();
48
+ if (!blocked.value && props.autoRefresh > 0) auto.start();
49
+ }
50
+ onMounted(syncAutoRefresh);
51
+ watch(() => props.autoRefresh, syncAutoRefresh);
31
52
  const boxes = computed(() => [
32
53
  { key: "collections", label: t("nuxtUiMongocamp.dashboard.collections"), icon: "i-lucide-database", to: props.collectionsPath },
33
54
  { key: "users", label: t("nuxtUiMongocamp.dashboard.users"), icon: "i-lucide-users", to: props.usersPath },
34
55
  { key: "roles", label: t("nuxtUiMongocamp.dashboard.roles"), icon: "i-lucide-shield", to: props.rolesPath }
35
56
  ]);
36
57
  defineExpose({ refresh });
37
- refresh();
58
+ if (!blocked.value) refresh();
38
59
  </script>
39
60
 
40
61
  <template>
@@ -54,7 +75,10 @@ refresh();
54
75
  </span>
55
76
  </p>
56
77
  </div>
57
- <UTooltip :text="t('nuxtUiMongocamp.common.refresh')">
78
+ <UTooltip
79
+ v-if="!blocked"
80
+ :text="t('nuxtUiMongocamp.common.refresh')"
81
+ >
58
82
  <UButton
59
83
  icon="i-lucide-refresh-cw"
60
84
  color="neutral"
@@ -66,12 +90,22 @@ refresh();
66
90
  </UTooltip>
67
91
  </div>
68
92
 
93
+ <MongocampEmptyState
94
+ v-if="blocked"
95
+ icon="i-lucide-shield-alert"
96
+ :title="message"
97
+ data-test="admin-only"
98
+ />
69
99
  <MongocampErrorAlert
100
+ v-if="!blocked"
70
101
  :error="loadError"
71
102
  @retry="refresh"
72
103
  />
73
104
 
74
- <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">
105
+ <div
106
+ v-if="!blocked"
107
+ class="grid grid-cols-1 gap-4 sm:grid-cols-3"
108
+ >
75
109
  <NuxtLink
76
110
  v-for="box in boxes"
77
111
  :key="box.key"
@@ -2,6 +2,7 @@ type __VLS_Props = {
2
2
  collectionsPath?: string;
3
3
  usersPath?: string;
4
4
  rolesPath?: string;
5
+ autoRefresh?: number;
5
6
  };
6
7
  declare function refresh(): Promise<void>;
7
8
  declare const __VLS_template: () => {
@@ -13,9 +14,10 @@ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
13
14
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
14
15
  refresh: typeof refresh;
15
16
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
- collectionsPath: string;
17
17
  usersPath: string;
18
+ collectionsPath: string;
18
19
  rolesPath: string;
20
+ autoRefresh: number;
19
21
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
22
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
21
23
  declare const _default: typeof __VLS_export;
@@ -1,12 +1,17 @@
1
1
  <script setup>
2
2
  import { computed, h, ref, resolveComponent } from "vue";
3
3
  import { useI18n, useMongocampSystem } from "#imports";
4
+ import { formatBytes } from "../utils/formatBytes";
5
+ import { shortenLabel } from "../utils/chartData";
6
+ import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
4
7
  const { t } = useI18n();
5
8
  const { getDatabaseInfos, listCollectionsByDatabase } = useMongocampSystem();
6
9
  const databases = ref([]);
10
+ const chartRows = computed(() => [...databases.value].sort((a, b) => b.sizeKb - a.sizeKb).map((d) => ({ name: shortenLabel(d.name), size: d.sizeKb * 1024 })));
7
11
  const loading = ref(false);
8
12
  const sorting = ref([]);
9
13
  const loadError = ref(null);
14
+ const { blocked, message } = useMongocampAdminGate();
10
15
  async function fetchDatabases() {
11
16
  loading.value = true;
12
17
  loadError.value = null;
@@ -64,11 +69,20 @@ const columns = computed(() => [
64
69
  cell: ({ row }) => row.original.empty ? h(UBadge, { label: t("nuxtUiMongocamp.databases.emptyBadge"), color: "neutral", variant: "subtle" }) : h("span", { class: "text-dimmed" }, "\u2014")
65
70
  }
66
71
  ]);
67
- fetchDatabases();
72
+ if (!blocked.value) fetchDatabases();
68
73
  </script>
69
74
 
70
75
  <template>
71
- <div class="flex flex-col gap-4">
76
+ <MongocampEmptyState
77
+ v-if="blocked"
78
+ icon="i-lucide-shield-alert"
79
+ :title="message"
80
+ data-test="admin-only"
81
+ />
82
+ <div
83
+ v-else
84
+ class="flex flex-col gap-4"
85
+ >
72
86
  <div class="flex items-center justify-between gap-4">
73
87
  <h2 class="text-xl font-semibold">
74
88
  {{ t("nuxtUiMongocamp.databases.heading") }}
@@ -91,6 +105,25 @@ fetchDatabases();
91
105
  @retry="fetchDatabases"
92
106
  />
93
107
 
108
+ <details
109
+ v-if="chartRows.length > 1"
110
+ class="text-sm"
111
+ data-testid="databases-chart"
112
+ >
113
+ <summary class="cursor-pointer text-dimmed">
114
+ {{ t("nuxtUiMongocamp.databases.chartSummary") }}
115
+ </summary>
116
+ <MongocampChart
117
+ class="mt-2"
118
+ :data="chartRows"
119
+ index="name"
120
+ :categories="[{ key: 'size', label: t('nuxtUiMongocamp.databases.chartSize') }]"
121
+ :format="formatBytes"
122
+ :chart-label="t('nuxtUiMongocamp.databases.chartSize')"
123
+ :chart-description="t('nuxtUiMongocamp.databases.chartDescription', { count: chartRows.length })"
124
+ />
125
+ </details>
126
+
94
127
  <UTable
95
128
  v-model:sorting="sorting"
96
129
  :data="databases"
@@ -0,0 +1,20 @@
1
+ type __VLS_Props = {
2
+ left: unknown;
3
+ right: unknown;
4
+ leftLabel?: string;
5
+ rightLabel?: string;
6
+ };
7
+ type __VLS_ModelProps = {
8
+ 'onlyDifferences'?: boolean;
9
+ };
10
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
11
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
+ "update:onlyDifferences": (value: boolean) => any;
13
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
14
+ "onUpdate:onlyDifferences"?: ((value: boolean) => any) | undefined;
15
+ }>, {
16
+ leftLabel: string;
17
+ rightLabel: string;
18
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;