@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,420 @@
1
+ <script setup>
2
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
3
+ import { useI18n } from "#imports";
4
+ import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
5
+ import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
6
+ import { useMongocampServerOverview } from "../composables/useMongocampServerOverview";
7
+ import { formatBytes } from "../utils/formatBytes";
8
+ import { BYTE_METRICS, nextJobs, overviewTotals, rankCollections, RANK_METRICS, shareSlices } from "../utils/serverOverview";
9
+ const props = defineProps({
10
+ infoPath: { type: String, required: false, default: "/secured/admin/collections" },
11
+ dataPath: { type: String, required: false, default: "/secured/admin/collections" },
12
+ jobsPath: { type: String, required: false, default: "/secured/admin/jobs" },
13
+ topN: { type: Number, required: false, default: 10 },
14
+ maxCollections: { type: Number, required: false, default: 200 },
15
+ autoRefresh: { type: Number, required: false, default: 0 },
16
+ hideCharts: { type: Boolean, required: false, default: false }
17
+ });
18
+ const { t, locale } = useI18n();
19
+ const { loadOverview } = useMongocampServerOverview();
20
+ const overview = ref(null);
21
+ const loading = ref(false);
22
+ const rankBy = ref("storageSize");
23
+ let controller;
24
+ async function load() {
25
+ controller?.abort();
26
+ const own = new AbortController();
27
+ controller = own;
28
+ loading.value = true;
29
+ try {
30
+ const result = await loadOverview({
31
+ maxCollections: props.maxCollections,
32
+ signal: own.signal
33
+ });
34
+ if (controller === own) overview.value = result;
35
+ } catch (e) {
36
+ if (own.signal.aborted) return;
37
+ throw e;
38
+ } finally {
39
+ if (controller === own) loading.value = false;
40
+ }
41
+ }
42
+ const { blocked, message } = useMongocampAdminGate();
43
+ const auto = useMongocampAutoRefresh(() => load(), { intervalMs: () => props.autoRefresh * 1e3 });
44
+ function syncAutoRefresh() {
45
+ auto.stop();
46
+ if (!blocked.value && props.autoRefresh > 0) auto.start();
47
+ }
48
+ onMounted(() => {
49
+ if (!blocked.value) void load();
50
+ syncAutoRefresh();
51
+ });
52
+ watch(() => props.autoRefresh, syncAutoRefresh);
53
+ onBeforeUnmount(() => controller?.abort());
54
+ const number = (value) => new Intl.NumberFormat(locale.value).format(value);
55
+ const collections = computed(() => overview.value?.collections ?? []);
56
+ const totals = computed(() => overviewTotals(collections.value, overview.value?.databases ?? null));
57
+ const indexShare = computed(() => {
58
+ const all = totals.value.storageBytes + totals.value.indexBytes;
59
+ return all > 0 ? `${Math.round(totals.value.indexBytes / all * 100)} %` : "0 %";
60
+ });
61
+ const metricItems = computed(() => RANK_METRICS.map((value) => ({ value, label: t(`nuxtUiMongocamp.serverOverview.metric${value.charAt(0).toUpperCase()}${value.slice(1)}`) })));
62
+ const metricLabel = computed(() => metricItems.value.find((m) => m.value === rankBy.value).label);
63
+ const formatMetric = (value) => BYTE_METRICS.has(rankBy.value) ? formatBytes(value) : number(value);
64
+ const ranked = computed(() => rankCollections(collections.value, rankBy.value, props.topN));
65
+ const rankedData = computed(() => ranked.value.map((c) => ({ name: c.name, value: c[rankBy.value] })));
66
+ const biggestDescription = computed(() => ranked.value[0] ? t("nuxtUiMongocamp.serverOverview.chartBiggestDescription", { shown: ranked.value.length, name: ranked.value[0].name, value: formatMetric(ranked.value[0][rankBy.value]) }) : "");
67
+ const shareData = computed(() => shareSlices(collections.value, "storageSize").map((s) => ({ name: s.name ?? t("nuxtUiMongocamp.serverOverview.otherCollections"), value: s.value })));
68
+ const shareDescription = computed(() => shareData.value[0] ? t("nuxtUiMongocamp.serverOverview.chartShareDescription", { shown: shareData.value.length, name: shareData.value[0].name, value: formatBytes(shareData.value[0].value) }) : "");
69
+ const databases = computed(() => overview.value?.databases ?? []);
70
+ const databaseData = computed(() => [...databases.value].sort((a, b) => b.sizeOnDisk - a.sizeOnDisk).map((d) => ({ name: d.name, value: d.sizeOnDisk })));
71
+ const databaseDescription = computed(() => databaseData.value[0] ? t("nuxtUiMongocamp.serverOverview.chartDatabasesDescription", { shown: databaseData.value.length, name: databaseData.value[0].name, value: formatBytes(databaseData.value[0].value) }) : "");
72
+ const jobs = computed(() => nextJobs(overview.value?.jobs ?? [], 5));
73
+ const failedParts = computed(() => ["databases", "collections", "cluster", "jobs"].filter((part) => overview.value?.errors[part] !== void 0));
74
+ const failedNames = computed(() => {
75
+ const names = overview.value?.failed ?? [];
76
+ return names.length > 5 ? `${names.slice(0, 5).join(", ")}, \u2026` : names.join(", ");
77
+ });
78
+ const seriesSize = computed(() => [{ key: "value", label: t("nuxtUiMongocamp.serverOverview.seriesSize") }]);
79
+ const seriesMetric = computed(() => [{ key: "value", label: metricLabel.value }]);
80
+ </script>
81
+
82
+ <template>
83
+ <MongocampEmptyState
84
+ v-if="blocked"
85
+ icon="i-lucide-shield-alert"
86
+ :title="message"
87
+ data-test="admin-only"
88
+ />
89
+ <div
90
+ v-else
91
+ class="flex flex-col gap-6"
92
+ data-test="server-overview"
93
+ >
94
+ <div class="flex flex-wrap items-start justify-between gap-2">
95
+ <div class="flex flex-col gap-1">
96
+ <h2 class="text-xl font-semibold">
97
+ {{ t("nuxtUiMongocamp.serverOverview.heading") }}
98
+ </h2>
99
+ <p class="text-sm text-dimmed">
100
+ {{ t("nuxtUiMongocamp.serverOverview.subtitle") }}
101
+ </p>
102
+ </div>
103
+ <UButton
104
+ icon="i-lucide-refresh-cw"
105
+ color="neutral"
106
+ variant="ghost"
107
+ :loading="loading"
108
+ :aria-label="t('nuxtUiMongocamp.common.refresh')"
109
+ @click="load()"
110
+ />
111
+ </div>
112
+
113
+ <UAlert
114
+ v-for="part in failedParts"
115
+ :key="part"
116
+ color="warning"
117
+ variant="subtle"
118
+ icon="i-lucide-triangle-alert"
119
+ :description="t(`nuxtUiMongocamp.serverOverview.error${part.charAt(0).toUpperCase()}${part.slice(1)}`)"
120
+ data-test="overview-error"
121
+ >
122
+ <template #actions>
123
+ <UButton
124
+ :label="t('nuxtUiMongocamp.serverOverview.retry')"
125
+ color="warning"
126
+ variant="subtle"
127
+ size="sm"
128
+ @click="load()"
129
+ />
130
+ </template>
131
+ </UAlert>
132
+
133
+ <template v-if="overview">
134
+ <div class="grid grid-cols-2 gap-3 lg:grid-cols-5">
135
+ <UCard>
136
+ <div class="text-sm text-dimmed">
137
+ {{ t("nuxtUiMongocamp.serverOverview.statDatabases") }}
138
+ </div>
139
+ <div
140
+ class="text-2xl font-semibold"
141
+ data-test="stat-databases"
142
+ >
143
+ {{ overview.databases ? totals.databases : "\u2014" }}
144
+ </div>
145
+ <div
146
+ v-if="overview.databases"
147
+ class="text-xs text-dimmed"
148
+ >
149
+ {{ t("nuxtUiMongocamp.serverOverview.statDisk", { size: formatBytes(totals.diskBytes) }) }}
150
+ </div>
151
+ </UCard>
152
+ <UCard>
153
+ <div class="text-sm text-dimmed">
154
+ {{ t("nuxtUiMongocamp.serverOverview.statCollections") }}
155
+ </div>
156
+ <div
157
+ class="text-2xl font-semibold"
158
+ data-test="stat-collections"
159
+ >
160
+ {{ number(overview.collectionCount) }}
161
+ </div>
162
+ </UCard>
163
+ <UCard>
164
+ <div class="text-sm text-dimmed">
165
+ {{ t("nuxtUiMongocamp.serverOverview.statDocuments") }}
166
+ </div>
167
+ <div
168
+ class="text-2xl font-semibold"
169
+ data-test="stat-documents"
170
+ >
171
+ {{ number(totals.documents) }}
172
+ </div>
173
+ </UCard>
174
+ <UCard>
175
+ <div class="text-sm text-dimmed">
176
+ {{ t("nuxtUiMongocamp.serverOverview.statStorage") }}
177
+ </div>
178
+ <div
179
+ class="text-2xl font-semibold"
180
+ data-test="stat-storage"
181
+ >
182
+ {{ formatBytes(totals.storageBytes) }}
183
+ </div>
184
+ </UCard>
185
+ <UCard>
186
+ <div class="text-sm text-dimmed">
187
+ {{ t("nuxtUiMongocamp.serverOverview.statIndexes") }}
188
+ </div>
189
+ <div
190
+ class="text-2xl font-semibold"
191
+ data-test="stat-indexes"
192
+ >
193
+ {{ formatBytes(totals.indexBytes) }}
194
+ </div>
195
+ <div class="text-xs text-dimmed">
196
+ {{ t("nuxtUiMongocamp.serverOverview.statIndexesHint", { share: indexShare }) }}
197
+ </div>
198
+ </UCard>
199
+ </div>
200
+
201
+ <p
202
+ v-if="overview.skipped > 0"
203
+ class="text-sm text-warning"
204
+ data-test="overview-partial"
205
+ >
206
+ {{ t("nuxtUiMongocamp.serverOverview.partial", { read: collections.length + overview.failed.length, total: overview.collectionCount, skipped: overview.skipped, max: maxCollections }) }}
207
+ </p>
208
+ <p
209
+ v-if="overview.failed.length > 0"
210
+ class="text-sm text-warning"
211
+ data-test="overview-failed"
212
+ >
213
+ {{ t("nuxtUiMongocamp.serverOverview.failedCollections", { count: overview.failed.length, names: failedNames }) }}
214
+ </p>
215
+
216
+ <UCard>
217
+ <template #header>
218
+ <div class="flex flex-wrap items-center justify-between gap-2">
219
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.serverOverview.biggestTitle") }}</span>
220
+ <div class="flex items-center gap-2">
221
+ <span class="text-xs text-dimmed">{{ t("nuxtUiMongocamp.serverOverview.rankBy") }}</span>
222
+ <USelect
223
+ v-model="rankBy"
224
+ :items="metricItems"
225
+ size="sm"
226
+ class="w-60"
227
+ :aria-label="t('nuxtUiMongocamp.serverOverview.rankBy')"
228
+ />
229
+ </div>
230
+ </div>
231
+ </template>
232
+ <p
233
+ v-if="ranked.length === 0"
234
+ class="text-sm text-dimmed"
235
+ data-test="overview-no-collections"
236
+ >
237
+ {{ t("nuxtUiMongocamp.serverOverview.noCollections") }}
238
+ </p>
239
+ <div
240
+ v-else
241
+ class="flex flex-col gap-4"
242
+ >
243
+ <MongocampChart
244
+ v-if="!hideCharts"
245
+ type="bar"
246
+ :data="rankedData"
247
+ index="name"
248
+ :categories="seriesMetric"
249
+ :chart-label="t('nuxtUiMongocamp.serverOverview.chartBiggest', { metric: metricLabel })"
250
+ :chart-description="biggestDescription"
251
+ :index-label="t('nuxtUiMongocamp.serverOverview.columnCollection')"
252
+ :format="formatMetric"
253
+ :show-table="false"
254
+ :legend="false"
255
+ />
256
+ <ol
257
+ class="flex flex-col divide-y divide-default text-sm"
258
+ data-test="ranked-list"
259
+ >
260
+ <li
261
+ v-for="(collection, index) in ranked"
262
+ :key="collection.name"
263
+ class="flex items-center gap-2 py-1.5"
264
+ >
265
+ <span class="w-6 text-right text-dimmed">{{ index + 1 }}</span>
266
+ <NuxtLink
267
+ :to="`${infoPath}/${collection.name}`"
268
+ class="min-w-0 flex-1 truncate font-medium hover:underline"
269
+ :aria-label="t('nuxtUiMongocamp.serverOverview.openInfo', { name: collection.name })"
270
+ >
271
+ {{ collection.name }}
272
+ </NuxtLink>
273
+ <span class="tabular-nums text-dimmed">{{ formatMetric(collection[rankBy]) }}</span>
274
+ <UButton
275
+ icon="i-lucide-table"
276
+ color="neutral"
277
+ variant="ghost"
278
+ size="xs"
279
+ :to="`${dataPath}/${collection.name}/data`"
280
+ :aria-label="t('nuxtUiMongocamp.serverOverview.openData', { name: collection.name })"
281
+ />
282
+ </li>
283
+ </ol>
284
+ </div>
285
+ </UCard>
286
+
287
+ <div class="grid grid-cols-1 gap-6 lg:grid-cols-2">
288
+ <UCard v-if="!hideCharts && shareData.length > 0">
289
+ <template #header>
290
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.serverOverview.shareTitle") }}</span>
291
+ </template>
292
+ <MongocampChart
293
+ type="donut"
294
+ :data="shareData"
295
+ index="name"
296
+ :categories="seriesSize"
297
+ :chart-label="t('nuxtUiMongocamp.serverOverview.chartShare')"
298
+ :chart-description="shareDescription"
299
+ :index-label="t('nuxtUiMongocamp.serverOverview.columnCollection')"
300
+ :format="formatBytes"
301
+ :height="240"
302
+ />
303
+ </UCard>
304
+
305
+ <UCard v-if="overview.databases">
306
+ <template #header>
307
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.serverOverview.databasesTitle") }}</span>
308
+ </template>
309
+ <div class="flex flex-col gap-3">
310
+ <MongocampChart
311
+ v-if="!hideCharts && databaseData.length > 1"
312
+ type="bar"
313
+ :data="databaseData"
314
+ index="name"
315
+ :categories="seriesSize"
316
+ :chart-label="t('nuxtUiMongocamp.serverOverview.chartDatabases')"
317
+ :chart-description="databaseDescription"
318
+ :index-label="t('nuxtUiMongocamp.serverOverview.columnName')"
319
+ :format="formatBytes"
320
+ :height="200"
321
+ :show-table="false"
322
+ :legend="false"
323
+ />
324
+ <ul
325
+ class="flex flex-col divide-y divide-default text-sm"
326
+ data-test="database-list"
327
+ >
328
+ <li
329
+ v-for="database in databases"
330
+ :key="database.name"
331
+ class="flex items-center gap-2 py-1.5"
332
+ >
333
+ <span class="min-w-0 flex-1 truncate font-medium">{{ database.name }}</span>
334
+ <UBadge
335
+ v-if="database.empty"
336
+ :label="t('nuxtUiMongocamp.serverOverview.databaseEmpty')"
337
+ color="neutral"
338
+ variant="subtle"
339
+ size="sm"
340
+ />
341
+ <span class="tabular-nums text-dimmed">{{ formatBytes(database.sizeOnDisk) }}</span>
342
+ </li>
343
+ </ul>
344
+ </div>
345
+ </UCard>
346
+
347
+ <UCard v-if="overview.cluster">
348
+ <template #header>
349
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.serverOverview.clusterTitle") }}</span>
350
+ </template>
351
+ <ul
352
+ class="flex flex-col divide-y divide-default text-sm"
353
+ data-test="cluster-list"
354
+ >
355
+ <li
356
+ v-for="member in overview.cluster.members"
357
+ :key="member.name"
358
+ class="flex flex-wrap items-center gap-2 py-1.5"
359
+ >
360
+ <span class="min-w-0 flex-1 truncate font-mono text-xs">{{ member.name }}</span>
361
+ <UBadge
362
+ v-if="member.coordinator"
363
+ :label="t('nuxtUiMongocamp.serverOverview.coordinator')"
364
+ color="primary"
365
+ variant="subtle"
366
+ size="sm"
367
+ />
368
+ <UBadge
369
+ v-if="member.siteMaster"
370
+ :label="t('nuxtUiMongocamp.serverOverview.siteMaster')"
371
+ color="info"
372
+ variant="subtle"
373
+ size="sm"
374
+ />
375
+ </li>
376
+ </ul>
377
+ </UCard>
378
+
379
+ <UCard v-if="overview.jobs">
380
+ <template #header>
381
+ <div class="flex items-center justify-between gap-2">
382
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.serverOverview.jobsTitle") }}</span>
383
+ <UButton
384
+ :label="t('nuxtUiMongocamp.serverOverview.allJobs')"
385
+ :to="jobsPath"
386
+ color="neutral"
387
+ variant="link"
388
+ size="xs"
389
+ />
390
+ </div>
391
+ </template>
392
+ <p
393
+ v-if="jobs.length === 0"
394
+ class="text-sm text-dimmed"
395
+ data-test="jobs-none"
396
+ >
397
+ {{ t("nuxtUiMongocamp.serverOverview.jobsNone") }}
398
+ </p>
399
+ <ul
400
+ v-else
401
+ class="flex flex-col divide-y divide-default text-sm"
402
+ data-test="jobs-list"
403
+ >
404
+ <li
405
+ v-for="job in jobs"
406
+ :key="`${job.group}/${job.name}`"
407
+ class="flex items-center gap-2 py-1.5"
408
+ >
409
+ <span class="min-w-0 flex-1 truncate font-medium">{{ job.group }} / {{ job.name }}</span>
410
+ <time
411
+ class="tabular-nums text-dimmed"
412
+ :datetime="job.next.toISOString()"
413
+ >{{ job.next.toLocaleString() }}</time>
414
+ </li>
415
+ </ul>
416
+ </UCard>
417
+ </div>
418
+ </template>
419
+ </div>
420
+ </template>
@@ -0,0 +1,20 @@
1
+ type __VLS_Props = {
2
+ infoPath?: string;
3
+ dataPath?: string;
4
+ jobsPath?: string;
5
+ topN?: number;
6
+ maxCollections?: number;
7
+ autoRefresh?: number;
8
+ hideCharts?: boolean;
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
+ infoPath: string;
12
+ dataPath: string;
13
+ jobsPath: string;
14
+ autoRefresh: number;
15
+ maxCollections: number;
16
+ topN: number;
17
+ hideCharts: boolean;
18
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;
@@ -1,3 +1,30 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ type __VLS_Props = {
2
+ /** Hide the "Server settings" heading. */
3
+ hideHeading?: boolean;
4
+ /** Hide the refresh button. */
5
+ hideRefresh?: boolean;
6
+ /** Hide the plugins card (the plugins request is skipped too). */
7
+ hidePlugins?: boolean;
8
+ /** Hide the cluster card (the cluster request is skipped too). */
9
+ hideCluster?: boolean;
10
+ /** Hide the whole configuration section — search, note and table (the configuration request is skipped too). */
11
+ hideConfigurations?: boolean;
12
+ /** Hide the configuration search box. */
13
+ hideSearch?: boolean;
14
+ /** Hide the note that secret values are masked. */
15
+ hideMaskedNote?: boolean;
16
+ /** Hide the hint that the server answers a missing grant with 401 (`AUTH_GRANT_DENIED_STATUS`). */
17
+ hideGrantHint?: boolean;
18
+ };
19
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
20
+ hideHeading: boolean;
21
+ hideRefresh: boolean;
22
+ hidePlugins: boolean;
23
+ hideCluster: boolean;
24
+ hideConfigurations: boolean;
25
+ hideSearch: boolean;
26
+ hideMaskedNote: boolean;
27
+ hideGrantHint: boolean;
28
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
29
  declare const _default: typeof __VLS_export;
3
30
  export default _default;
@@ -1,28 +1,47 @@
1
1
  <script setup>
2
2
  import { computed, h, ref, resolveComponent, watch } from "vue";
3
3
  import { useI18n, useMongocampRoles, useMongocampSystem } from "#imports";
4
- import { MASKED_VALUE } from "../utils/configRows";
4
+ import { grantStatusHint, MASKED_VALUE } from "../utils/configRows";
5
5
  const PAGE_SIZE = 10;
6
+ const props = defineProps({
7
+ hideHeading: { type: Boolean, required: false, default: false },
8
+ hideRefresh: { type: Boolean, required: false, default: false },
9
+ hidePlugins: { type: Boolean, required: false, default: false },
10
+ hideCluster: { type: Boolean, required: false, default: false },
11
+ hideConfigurations: { type: Boolean, required: false, default: false },
12
+ hideSearch: { type: Boolean, required: false, default: false },
13
+ hideMaskedNote: { type: Boolean, required: false, default: false },
14
+ hideGrantHint: { type: Boolean, required: false, default: false }
15
+ });
6
16
  const { t } = useI18n();
7
- const { getSettings, listConfigurations } = useMongocampSystem();
17
+ const { getSettings, listConfigurations, getCluster } = useMongocampSystem();
8
18
  const { isAdmin } = useMongocampRoles();
9
19
  const configurations = ref([]);
10
20
  const plugins = ref(null);
21
+ const cluster = ref(null);
11
22
  const loading = ref(false);
12
23
  const loadError = ref(null);
13
24
  const search = ref("");
25
+ const showGrantHint = computed(() => grantStatusHint(configurations.value));
14
26
  const page = ref(1);
15
27
  async function fetchSettings() {
16
28
  if (!isAdmin.value) return;
17
29
  loading.value = true;
18
30
  loadError.value = null;
19
31
  try {
20
- const [loadedPlugins, rows] = await Promise.all([getSettings(), listConfigurations()]);
32
+ const [loadedPlugins, rows, loadedCluster] = await Promise.all([
33
+ props.hidePlugins ? Promise.resolve(null) : getSettings(),
34
+ props.hideConfigurations ? Promise.resolve([]) : listConfigurations(),
35
+ // optional context: a failing cluster endpoint must not take the settings page down
36
+ props.hideCluster ? Promise.resolve(null) : getCluster().catch(() => null)
37
+ ]);
21
38
  plugins.value = loadedPlugins;
39
+ cluster.value = loadedCluster;
22
40
  configurations.value = rows;
23
41
  } catch (e) {
24
42
  loadError.value = e;
25
43
  plugins.value = null;
44
+ cluster.value = null;
26
45
  configurations.value = [];
27
46
  } finally {
28
47
  loading.value = false;
@@ -71,12 +90,19 @@ fetchSettings();
71
90
 
72
91
  <template>
73
92
  <div class="flex flex-col gap-4">
74
- <div class="flex items-center justify-between gap-4">
75
- <h2 class="text-xl font-semibold">
93
+ <div
94
+ v-if="!hideHeading || isAdmin && !hideRefresh"
95
+ class="flex items-center justify-between gap-4"
96
+ >
97
+ <h2
98
+ v-if="!hideHeading"
99
+ class="text-xl font-semibold"
100
+ >
76
101
  {{ t("nuxtUiMongocamp.settings.heading") }}
77
102
  </h2>
78
103
  <UTooltip
79
- v-if="isAdmin"
104
+ v-if="isAdmin && !hideRefresh"
105
+ class="ml-auto"
80
106
  :text="t('nuxtUiMongocamp.common.refresh')"
81
107
  >
82
108
  <UButton
@@ -105,7 +131,7 @@ fetchSettings();
105
131
  @retry="fetchSettings"
106
132
  />
107
133
 
108
- <UCard v-if="plugins">
134
+ <UCard v-if="plugins && !hidePlugins">
109
135
  <template #header>
110
136
  <span class="font-semibold">{{ t("nuxtUiMongocamp.settings.pluginsHeading") }}</span>
111
137
  </template>
@@ -141,20 +167,67 @@ fetchSettings();
141
167
  </div>
142
168
  </UCard>
143
169
 
144
- <div class="flex flex-wrap items-center justify-between gap-2">
170
+ <UCard v-if="cluster && !hideCluster">
171
+ <template #header>
172
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.settings.clusterHeading") }}</span>
173
+ </template>
174
+ <ul class="flex flex-col gap-2">
175
+ <li
176
+ v-for="member in cluster.members"
177
+ :key="member.name"
178
+ class="flex flex-wrap items-center gap-2"
179
+ >
180
+ <span class="font-mono text-xs">{{ member.name }}</span>
181
+ <UBadge
182
+ v-if="member.coordinator"
183
+ :label="t('nuxtUiMongocamp.settings.clusterCoordinator')"
184
+ color="primary"
185
+ variant="subtle"
186
+ size="sm"
187
+ />
188
+ <UBadge
189
+ v-if="member.siteMaster"
190
+ :label="t('nuxtUiMongocamp.settings.clusterSiteMaster')"
191
+ color="neutral"
192
+ variant="subtle"
193
+ size="sm"
194
+ />
195
+ </li>
196
+ </ul>
197
+ </UCard>
198
+
199
+ <div
200
+ v-if="!hideConfigurations && (!hideSearch || !hideMaskedNote)"
201
+ class="flex flex-wrap items-center justify-between gap-2"
202
+ >
145
203
  <UInput
204
+ v-if="!hideSearch"
146
205
  v-model="search"
147
206
  icon="i-lucide-search"
148
207
  :placeholder="t('nuxtUiMongocamp.settings.searchPlaceholder')"
149
208
  size="sm"
150
209
  class="w-full max-w-xs"
151
210
  />
152
- <p class="text-xs text-dimmed">
211
+ <p
212
+ v-if="!hideMaskedNote"
213
+ class="text-xs text-dimmed"
214
+ >
153
215
  {{ t("nuxtUiMongocamp.settings.maskedNote") }}
154
216
  </p>
155
217
  </div>
156
218
 
219
+ <UAlert
220
+ v-if="!hideConfigurations && !hideGrantHint && showGrantHint"
221
+ color="info"
222
+ variant="subtle"
223
+ icon="i-lucide-info"
224
+ :title="t('nuxtUiMongocamp.settings.grantHintTitle')"
225
+ :description="t('nuxtUiMongocamp.settings.grantHint')"
226
+ data-test="grant-hint"
227
+ />
228
+
157
229
  <UTable
230
+ v-if="!hideConfigurations"
158
231
  :data="pageRows"
159
232
  :columns="columns"
160
233
  :loading="loading"
@@ -165,7 +238,7 @@ fetchSettings();
165
238
  </UTable>
166
239
 
167
240
  <div
168
- v-if="filteredRows.length > PAGE_SIZE"
241
+ v-if="!hideConfigurations && filteredRows.length > PAGE_SIZE"
169
242
  class="flex justify-end"
170
243
  >
171
244
  <UPagination
@@ -1,3 +1,30 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ type __VLS_Props = {
2
+ /** Hide the "Server settings" heading. */
3
+ hideHeading?: boolean;
4
+ /** Hide the refresh button. */
5
+ hideRefresh?: boolean;
6
+ /** Hide the plugins card (the plugins request is skipped too). */
7
+ hidePlugins?: boolean;
8
+ /** Hide the cluster card (the cluster request is skipped too). */
9
+ hideCluster?: boolean;
10
+ /** Hide the whole configuration section — search, note and table (the configuration request is skipped too). */
11
+ hideConfigurations?: boolean;
12
+ /** Hide the configuration search box. */
13
+ hideSearch?: boolean;
14
+ /** Hide the note that secret values are masked. */
15
+ hideMaskedNote?: boolean;
16
+ /** Hide the hint that the server answers a missing grant with 401 (`AUTH_GRANT_DENIED_STATUS`). */
17
+ hideGrantHint?: boolean;
18
+ };
19
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
20
+ hideHeading: boolean;
21
+ hideRefresh: boolean;
22
+ hidePlugins: boolean;
23
+ hideCluster: boolean;
24
+ hideConfigurations: boolean;
25
+ hideSearch: boolean;
26
+ hideMaskedNote: boolean;
27
+ hideGrantHint: boolean;
28
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
29
  declare const _default: typeof __VLS_export;
3
30
  export default _default;