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