@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,455 @@
1
+ <script setup>
2
+ import { computed, h, ref, resolveComponent, watch } from "vue";
3
+ import { useI18n, useMongocampError, useToast } from "#imports";
4
+ import { useMongocampIndex } from "../composables/useMongocampIndex";
5
+ import { useMongocampCollectionStats } from "../composables/useMongocampCollectionStats";
6
+ import { readServerError } from "../utils/serverError";
7
+ import {
8
+ buildIndexRequest,
9
+ canDropIndex,
10
+ classifyIndexError,
11
+ describeKey,
12
+ formatBytes,
13
+ indexKeys,
14
+ isUnusedIndex,
15
+ MAX_INDEX_FIELDS,
16
+ validateIndexForm
17
+ } from "../utils/indexForm";
18
+ import { shortenLabel } from "../utils/chartData";
19
+ import MongocampConfirmByName from "./MongocampConfirmByName.vue";
20
+ const props = defineProps({
21
+ collectionName: { type: String, required: true },
22
+ canManage: { type: Boolean, required: false, default: true },
23
+ fields: { type: Array, required: false, default: () => [] }
24
+ });
25
+ const emit = defineEmits(["changed"]);
26
+ const { t } = useI18n();
27
+ const toast = useToast();
28
+ const { describeServerError } = useMongocampError();
29
+ const { listIndexes, createIndex, createTextIndex, createExpiringIndex, deleteIndex } = useMongocampIndex();
30
+ const { getStorage, getIndexUsage } = useMongocampCollectionStats();
31
+ const UBadge = resolveComponent("UBadge");
32
+ const UButton = resolveComponent("UButton");
33
+ const UTooltip = resolveComponent("UTooltip");
34
+ const indexes = ref([]);
35
+ const storage = ref(null);
36
+ const usage = ref(/* @__PURE__ */ new Map());
37
+ const usageFailed = ref(false);
38
+ const loading = ref(false);
39
+ const loadError = ref(null);
40
+ let run = 0;
41
+ async function load() {
42
+ if (!props.collectionName) return;
43
+ const mine = ++run;
44
+ loading.value = true;
45
+ loadError.value = null;
46
+ try {
47
+ const [list, size, uses] = await Promise.allSettled([listIndexes(props.collectionName), getStorage(props.collectionName), getIndexUsage(props.collectionName)]);
48
+ if (mine !== run) return;
49
+ if (list.status === "rejected") {
50
+ loadError.value = list.reason;
51
+ indexes.value = [];
52
+ return;
53
+ }
54
+ indexes.value = list.value;
55
+ storage.value = size.status === "fulfilled" ? size.value : null;
56
+ usageFailed.value = uses.status === "rejected";
57
+ usage.value = new Map(uses.status === "fulfilled" ? uses.value.map((u) => [u.name, u]) : []);
58
+ } finally {
59
+ if (mine === run) loading.value = false;
60
+ }
61
+ }
62
+ watch(() => props.collectionName, load, { immediate: true });
63
+ defineExpose({ refresh: load });
64
+ const rows = computed(
65
+ () => indexes.value.map((idx) => ({
66
+ name: idx.name,
67
+ keys: indexKeys(idx).map(describeKey).join(", "),
68
+ unique: idx.unique,
69
+ text: idx.text,
70
+ expire: idx.expire,
71
+ expireAfterSeconds: idx.expireAfterSeconds,
72
+ size: storage.value?.indexSizes[idx.name],
73
+ ops: usage.value.get(idx.name)?.ops,
74
+ since: usage.value.get(idx.name)?.since
75
+ }))
76
+ );
77
+ const sizeChart = computed(() => rows.value.filter((r) => typeof r.size === "number").map((r) => ({ name: shortenLabel(r.name), size: r.size })).sort((a, b) => b.size - a.size));
78
+ const usageChart = computed(() => rows.value.filter((r) => typeof r.ops === "number").map((r) => ({ name: shortenLabel(r.name), ops: r.ops })).sort((a, b) => b.ops - a.ops));
79
+ function withTooltip(text, node) {
80
+ return h(UTooltip, { text }, { default: () => node });
81
+ }
82
+ function dateText(iso) {
83
+ const date = iso ? new Date(iso) : void 0;
84
+ return date && !Number.isNaN(date.getTime()) ? date.toLocaleDateString() : "\u2014";
85
+ }
86
+ const columns = computed(() => [
87
+ { accessorKey: "name", header: t("nuxtUiMongocamp.collectionInfos.columnIndex") },
88
+ {
89
+ accessorKey: "keys",
90
+ header: t("nuxtUiMongocamp.collectionInfos.columnKeys"),
91
+ cell: ({ row }) => h("span", { class: "font-mono text-xs" }, row.original.keys)
92
+ },
93
+ {
94
+ id: "flags",
95
+ header: t("nuxtUiMongocamp.collectionInfos.columnType"),
96
+ cell: ({ row }) => {
97
+ const flags = [];
98
+ if (row.original.unique) flags.push({ label: "unique", color: "warning" });
99
+ if (row.original.text) flags.push({ label: "text", color: "info" });
100
+ if (row.original.expire) flags.push({ label: `expire ${row.original.expireAfterSeconds}s`, color: "secondary" });
101
+ const badges = flags.map((flag) => h(UBadge, { label: flag.label, color: flag.color, variant: "subtle", size: "sm" }));
102
+ if (badges.length === 0) badges.push(h(UBadge, { label: t("nuxtUiMongocamp.collectionInfos.typeStandard"), color: "neutral", variant: "subtle", size: "sm" }));
103
+ return h("div", { class: "flex flex-wrap gap-1" }, badges);
104
+ }
105
+ },
106
+ {
107
+ accessorKey: "size",
108
+ header: t("nuxtUiMongocamp.indexes.columnSize"),
109
+ cell: ({ row }) => h("span", row.original.size === void 0 ? "\u2014" : formatBytes(row.original.size))
110
+ },
111
+ {
112
+ id: "usage",
113
+ header: t("nuxtUiMongocamp.indexes.columnUsage"),
114
+ cell: ({ row }) => {
115
+ const { name, ops, since } = row.original;
116
+ if (ops === void 0) return h("span", { class: "text-dimmed", title: usageFailed.value ? t("nuxtUiMongocamp.indexes.usageUnavailable") : void 0 }, "\u2014");
117
+ if (isUnusedIndex(name, ops)) {
118
+ return withTooltip(t("nuxtUiMongocamp.indexes.neverUsedHint"), h(UBadge, {
119
+ label: t("nuxtUiMongocamp.indexes.neverUsed", { date: dateText(since) }),
120
+ color: "warning",
121
+ variant: "subtle",
122
+ size: "sm"
123
+ }));
124
+ }
125
+ return h("span", { class: "text-sm" }, [
126
+ t("nuxtUiMongocamp.indexes.usageOps", { count: ops }),
127
+ h("span", { class: "text-dimmed" }, ` ${t("nuxtUiMongocamp.indexes.usageSince", { date: dateText(since) })}`)
128
+ ]);
129
+ }
130
+ },
131
+ {
132
+ id: "actions",
133
+ header: "",
134
+ cell: ({ row }) => {
135
+ if (!props.canManage) return null;
136
+ if (!canDropIndex(row.original.name)) {
137
+ return h("div", { class: "flex justify-end" }, withTooltip(t("nuxtUiMongocamp.indexes.protectedHint"), h("span", { class: "text-dimmed text-xs" }, "\u2014")));
138
+ }
139
+ return h("div", { class: "flex justify-end" }, withTooltip(t("nuxtUiMongocamp.collectionInfos.deleteIndexTooltip"), h(UButton, {
140
+ "icon": "i-lucide-trash-2",
141
+ "color": "error",
142
+ "variant": "ghost",
143
+ "size": "sm",
144
+ "aria-label": t("nuxtUiMongocamp.collectionInfos.deleteIndexTooltip"),
145
+ "onClick": () => askDrop(row.original.name)
146
+ })));
147
+ }
148
+ }
149
+ ]);
150
+ const createOpen = ref(false);
151
+ const attempted = ref(false);
152
+ const createError = ref("");
153
+ const creating = ref(false);
154
+ const form = ref(blankForm());
155
+ function blankForm() {
156
+ return { kind: "standard", fields: [{ field: "", descending: false }], name: "", expireAfter: "3600s" };
157
+ }
158
+ const kindItems = computed(() => ["standard", "unique", "text", "expiring"].map((kind) => ({
159
+ value: kind,
160
+ label: t(`nuxtUiMongocamp.indexes.kind${kind.charAt(0).toUpperCase()}${kind.slice(1)}`)
161
+ })));
162
+ const singleField = computed(() => form.value.kind === "text" || form.value.kind === "expiring");
163
+ const shownFields = computed(() => singleField.value ? form.value.fields.slice(0, 1) : form.value.fields);
164
+ const problems = computed(() => validateIndexForm(form.value));
165
+ const problemText = (problem) => {
166
+ const key = { "no-field": "problemNoField", "empty-field": "problemEmptyField", "duplicate-field": "problemDuplicateField", "too-many-fields": "problemTooManyFields", "bad-duration": "problemBadDuration", "bad-name": "problemBadName" }[problem];
167
+ return t(`nuxtUiMongocamp.indexes.${key}`, { max: MAX_INDEX_FIELDS });
168
+ };
169
+ function openCreate() {
170
+ form.value = blankForm();
171
+ attempted.value = false;
172
+ createError.value = "";
173
+ createOpen.value = true;
174
+ }
175
+ function addField() {
176
+ if (form.value.fields.length < MAX_INDEX_FIELDS) form.value.fields.push({ field: "", descending: false });
177
+ }
178
+ function removeField(index) {
179
+ if (form.value.fields.length > 1) form.value.fields.splice(index, 1);
180
+ }
181
+ async function describeCreateError(error) {
182
+ const server = await readServerError(error);
183
+ const raw = `${server.message ?? ""} ${error instanceof Error ? error.message : ""}`;
184
+ const kind = classifyIndexError(raw);
185
+ if (kind === "duplicate-values") return t("nuxtUiMongocamp.indexes.errorDuplicate");
186
+ if (kind === "conflict") return t("nuxtUiMongocamp.indexes.errorConflict");
187
+ if (kind === "empty-keys") return t("nuxtUiMongocamp.indexes.errorEmptyKeys");
188
+ return (await describeServerError(error, "nuxtUiMongocamp.collectionInfos.errorCreateIndex")).message;
189
+ }
190
+ async function submitCreate() {
191
+ attempted.value = true;
192
+ createError.value = "";
193
+ if (problems.value.length > 0) return;
194
+ const request = buildIndexRequest(form.value);
195
+ creating.value = true;
196
+ try {
197
+ const result = request.call === "createIndex" ? await createIndex(props.collectionName, request.keys, request.options) : request.call === "createTextIndex" ? await createTextIndex(props.collectionName, request.field) : await createExpiringIndex(props.collectionName, request.field, request.duration);
198
+ createOpen.value = false;
199
+ toast.add({ title: t("nuxtUiMongocamp.indexes.created", { name: result.name }), color: "success" });
200
+ await load();
201
+ emit("changed");
202
+ } catch (e) {
203
+ createError.value = await describeCreateError(e);
204
+ } finally {
205
+ creating.value = false;
206
+ }
207
+ }
208
+ const dropOpen = ref(false);
209
+ const dropName = ref("");
210
+ function askDrop(name) {
211
+ if (!canDropIndex(name)) return;
212
+ dropName.value = name;
213
+ dropOpen.value = true;
214
+ }
215
+ async function runDrop() {
216
+ if (!canDropIndex(dropName.value)) return;
217
+ await deleteIndex(props.collectionName, dropName.value);
218
+ toast.add({ title: t("nuxtUiMongocamp.indexes.dropped", { name: dropName.value }), color: "success" });
219
+ await load();
220
+ emit("changed");
221
+ }
222
+ </script>
223
+
224
+ <template>
225
+ <UCard>
226
+ <template #header>
227
+ <div class="flex items-center justify-between gap-2">
228
+ <div class="flex items-center gap-2">
229
+ <UIcon
230
+ name="i-lucide-list-tree"
231
+ class="size-4 text-(--ui-primary)"
232
+ />
233
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.collectionInfos.indexes") }}</span>
234
+ <UBadge
235
+ :label="t('nuxtUiMongocamp.collectionInfos.indexesCount', { count: rows.length })"
236
+ variant="subtle"
237
+ color="neutral"
238
+ size="sm"
239
+ />
240
+ </div>
241
+ <UButton
242
+ v-if="canManage"
243
+ icon="i-lucide-plus"
244
+ :label="t('nuxtUiMongocamp.collectionInfos.createIndex')"
245
+ color="neutral"
246
+ variant="ghost"
247
+ size="sm"
248
+ @click="openCreate"
249
+ />
250
+ </div>
251
+ </template>
252
+
253
+ <MongocampErrorAlert
254
+ :error="loadError"
255
+ @retry="load"
256
+ />
257
+ <p
258
+ v-if="usageFailed && !loadError"
259
+ class="mb-2 text-xs text-dimmed"
260
+ >
261
+ {{ t("nuxtUiMongocamp.indexes.usageUnavailable") }}
262
+ </p>
263
+ <UTable
264
+ :data="rows"
265
+ :columns="columns"
266
+ :loading="loading"
267
+ />
268
+
269
+ <!-- secondary: collapsed, built from the sizes and usage already loaded -->
270
+ <details
271
+ v-if="sizeChart.length > 1 || usageChart.length > 1"
272
+ class="mt-3 text-sm"
273
+ data-testid="index-charts"
274
+ >
275
+ <summary class="cursor-pointer text-dimmed">
276
+ {{ t("nuxtUiMongocamp.indexes.chartsSummary") }}
277
+ </summary>
278
+ <div class="mt-2 grid gap-4 md:grid-cols-2">
279
+ <div v-if="sizeChart.length > 1">
280
+ <h4 class="mb-1 text-xs font-medium">
281
+ {{ t("nuxtUiMongocamp.indexes.chartSize") }}
282
+ </h4>
283
+ <MongocampChart
284
+ :data="sizeChart"
285
+ index="name"
286
+ :categories="[{ key: 'size', label: t('nuxtUiMongocamp.indexes.chartSize') }]"
287
+ :format="formatBytes"
288
+ :height="200"
289
+ :chart-label="t('nuxtUiMongocamp.indexes.chartSize')"
290
+ :chart-description="t('nuxtUiMongocamp.indexes.chartSizeDescription', { count: sizeChart.length })"
291
+ />
292
+ </div>
293
+ <div v-if="usageChart.length > 1">
294
+ <h4 class="mb-1 text-xs font-medium">
295
+ {{ t("nuxtUiMongocamp.indexes.chartUsage") }}
296
+ </h4>
297
+ <MongocampChart
298
+ :data="usageChart"
299
+ index="name"
300
+ :categories="[{ key: 'ops', label: t('nuxtUiMongocamp.indexes.chartUsage') }]"
301
+ :height="200"
302
+ :chart-label="t('nuxtUiMongocamp.indexes.chartUsage')"
303
+ :chart-description="t('nuxtUiMongocamp.indexes.chartUsageDescription', { count: usageChart.length })"
304
+ />
305
+ </div>
306
+ </div>
307
+ </details>
308
+
309
+ <UModal
310
+ v-model:open="createOpen"
311
+ :title="t('nuxtUiMongocamp.collectionInfos.createIndexTitle')"
312
+ >
313
+ <template #body>
314
+ <form
315
+ class="flex flex-col gap-4"
316
+ @submit.prevent="submitCreate"
317
+ >
318
+ <UFormField :label="t('nuxtUiMongocamp.indexes.kindLabel')">
319
+ <USelect
320
+ v-model="form.kind"
321
+ :items="kindItems"
322
+ class="w-full"
323
+ :aria-label="t('nuxtUiMongocamp.indexes.kindLabel')"
324
+ />
325
+ </UFormField>
326
+
327
+ <div class="flex flex-col gap-2">
328
+ <div
329
+ v-for="(row, index) in shownFields"
330
+ :key="index"
331
+ class="flex items-center gap-1"
332
+ >
333
+ <UInput
334
+ v-model="row.field"
335
+ class="min-w-0 flex-1"
336
+ :list="`index-fields-${collectionName}`"
337
+ :placeholder="t('nuxtUiMongocamp.indexes.fieldPlaceholder')"
338
+ :aria-label="t('nuxtUiMongocamp.indexes.fieldLabel', { position: index + 1 })"
339
+ />
340
+ <UButton
341
+ v-if="!singleField"
342
+ :icon="row.descending ? 'i-lucide-arrow-down-wide-narrow' : 'i-lucide-arrow-up-narrow-wide'"
343
+ color="neutral"
344
+ variant="ghost"
345
+ :label="row.descending ? t('nuxtUiMongocamp.indexes.directionDesc') : t('nuxtUiMongocamp.indexes.directionAsc')"
346
+ :aria-label="t('nuxtUiMongocamp.indexes.directionLabel', { position: index + 1 })"
347
+ @click="row.descending = !row.descending"
348
+ />
349
+ <UButton
350
+ v-if="!singleField && form.fields.length > 1"
351
+ icon="i-lucide-x"
352
+ color="neutral"
353
+ variant="ghost"
354
+ :aria-label="t('nuxtUiMongocamp.indexes.removeField', { position: index + 1 })"
355
+ @click="removeField(index)"
356
+ />
357
+ </div>
358
+ <datalist :id="`index-fields-${collectionName}`">
359
+ <option
360
+ v-for="field in fields"
361
+ :key="field"
362
+ :value="field"
363
+ />
364
+ </datalist>
365
+ <UButton
366
+ v-if="!singleField"
367
+ icon="i-lucide-plus"
368
+ color="neutral"
369
+ variant="soft"
370
+ size="sm"
371
+ class="self-start"
372
+ :label="t('nuxtUiMongocamp.indexes.addField')"
373
+ :disabled="form.fields.length >= MAX_INDEX_FIELDS"
374
+ @click="addField"
375
+ />
376
+ <p
377
+ v-if="!singleField && form.fields.length > 1"
378
+ class="text-xs text-dimmed"
379
+ >
380
+ {{ t("nuxtUiMongocamp.indexes.compoundNote") }}
381
+ </p>
382
+ <p
383
+ v-if="form.kind === 'text'"
384
+ class="text-xs text-dimmed"
385
+ >
386
+ {{ t("nuxtUiMongocamp.indexes.textNote") }}
387
+ </p>
388
+ </div>
389
+
390
+ <UFormField
391
+ v-if="form.kind === 'expiring'"
392
+ :label="t('nuxtUiMongocamp.indexes.expireLabel')"
393
+ :help="t('nuxtUiMongocamp.indexes.expireHelp')"
394
+ >
395
+ <UInput
396
+ v-model="form.expireAfter"
397
+ class="w-full"
398
+ :aria-label="t('nuxtUiMongocamp.indexes.expireLabel')"
399
+ />
400
+ </UFormField>
401
+
402
+ <UFormField
403
+ v-if="form.kind === 'standard' || form.kind === 'unique'"
404
+ :label="t('nuxtUiMongocamp.indexes.nameLabel')"
405
+ >
406
+ <UInput
407
+ v-model="form.name"
408
+ class="w-full"
409
+ :aria-label="t('nuxtUiMongocamp.indexes.nameLabel')"
410
+ />
411
+ </UFormField>
412
+
413
+ <ul
414
+ v-if="attempted && problems.length > 0"
415
+ class="list-disc pl-5 text-sm text-error"
416
+ role="alert"
417
+ >
418
+ <li
419
+ v-for="problem in problems"
420
+ :key="problem"
421
+ >
422
+ {{ problemText(problem) }}
423
+ </li>
424
+ </ul>
425
+ <p
426
+ v-if="createError"
427
+ class="text-sm text-error"
428
+ role="alert"
429
+ >
430
+ {{ createError }}
431
+ </p>
432
+
433
+ <div class="flex justify-end">
434
+ <UButton
435
+ type="submit"
436
+ icon="i-lucide-plus"
437
+ :label="t('nuxtUiMongocamp.indexes.create')"
438
+ :loading="creating"
439
+ />
440
+ </div>
441
+ </form>
442
+ </template>
443
+ </UModal>
444
+
445
+ <MongocampConfirmByName
446
+ v-if="dropName"
447
+ v-model:open="dropOpen"
448
+ :name="dropName"
449
+ :title="t('nuxtUiMongocamp.indexes.dropTitle')"
450
+ :description="t('nuxtUiMongocamp.indexes.dropDescription', { name: dropName })"
451
+ :confirm-label="t('nuxtUiMongocamp.indexes.dropConfirm')"
452
+ :on-confirm="runDrop"
453
+ />
454
+ </UCard>
455
+ </template>
@@ -0,0 +1,18 @@
1
+ type __VLS_Props = {
2
+ collectionName: string;
3
+ canManage?: boolean;
4
+ fields?: string[];
5
+ };
6
+ declare function load(): Promise<void>;
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
8
+ refresh: typeof load;
9
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ changed: () => any;
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ onChanged?: (() => any) | undefined;
13
+ }>, {
14
+ fields: string[];
15
+ canManage: boolean;
16
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -1,3 +1,8 @@
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
+ autoRefresh?: number;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
5
+ autoRefresh: number;
6
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
7
  declare const _default: typeof __VLS_export;
3
8
  export default _default;
@@ -1,8 +1,12 @@
1
1
  <script setup>
2
- import { computed, h, reactive, ref, resolveComponent } from "vue";
2
+ import { computed, h, onMounted, reactive, ref, resolveComponent, watch } from "vue";
3
3
  import { useI18n, useMongocampError, useMongocampJobs, useToast } from "#imports";
4
+ import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
5
+ const props = defineProps({
6
+ autoRefresh: { type: Number, required: false, default: 0 }
7
+ });
4
8
  const { t } = useI18n();
5
- const { describeError } = useMongocampError();
9
+ const { describeServerError } = useMongocampError();
6
10
  const { listJobs, listPossibleJobs, registerJob, updateJob, executeJob, deleteJob } = useMongocampJobs();
7
11
  const toast = useToast();
8
12
  const jobs = ref([]);
@@ -29,6 +33,22 @@ async function fetchJobs() {
29
33
  loading.value = false;
30
34
  }
31
35
  }
36
+ async function reloadQuietly() {
37
+ try {
38
+ jobs.value = await listJobs();
39
+ loadError.value = null;
40
+ } catch (e) {
41
+ loadError.value = e;
42
+ throw e;
43
+ }
44
+ }
45
+ const auto = useMongocampAutoRefresh(reloadQuietly, { intervalMs: () => props.autoRefresh * 1e3 });
46
+ function syncAutoRefresh() {
47
+ auto.stop();
48
+ if (props.autoRefresh > 0) auto.start();
49
+ }
50
+ onMounted(syncAutoRefresh);
51
+ watch(() => props.autoRefresh, syncAutoRefresh);
32
52
  const emptyJobConfig = () => ({ name: "", group: "", className: "", description: "", cronExpression: "", priority: 5 });
33
53
  const newJob = ref(emptyJobConfig());
34
54
  const editJobOriginal = ref({ group: "", name: "" });
@@ -134,7 +154,7 @@ function openEdit(job) {
134
154
  editJob.value = {
135
155
  name: job.name,
136
156
  group: job.group,
137
- description: job.description,
157
+ description: job.description ?? "",
138
158
  cronExpression: job.cronExpression,
139
159
  priority: job.priority
140
160
  };
@@ -167,7 +187,7 @@ async function handleDeleteJob() {
167
187
  isDeleteModalOpen.value = false;
168
188
  await fetchJobs();
169
189
  } catch (e) {
170
- deleteError.value = describeError(e, "nuxtUiMongocamp.jobs.errorDelete").message;
190
+ deleteError.value = (await describeServerError(e, "nuxtUiMongocamp.jobs.errorDelete")).message;
171
191
  } finally {
172
192
  deleting.value = false;
173
193
  }
@@ -1,3 +1,8 @@
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
+ autoRefresh?: number;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
5
+ autoRefresh: number;
6
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
7
  declare const _default: typeof __VLS_export;
3
8
  export default _default;
@@ -0,0 +1,12 @@
1
+ type __VLS_Props = {
2
+ grantsPath?: string;
3
+ maxCollections?: number;
4
+ maxUsers?: number;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
7
+ grantsPath: string;
8
+ maxCollections: number;
9
+ maxUsers: number;
10
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;