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