@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,135 @@
1
+ <script setup>
2
+ import { computed, ref, watch } from "vue";
3
+ import { defineShortcuts, navigateTo, useI18n } from "#imports";
4
+ import useMongocampAdmin from "../composables/useMongocampAdmin";
5
+ import { useMongocampJobs } from "../composables/useMongocampJobs";
6
+ import { useMongocampPermissions } from "../composables/useMongocampPermissions";
7
+ import { useMongocampRoles } from "../composables/useMongocampRoles";
8
+ import { buildActions, buildEntries, isFresh } from "../utils/commandPalette";
9
+ const props = defineProps({
10
+ shortcut: { type: String, required: false, default: "meta_k" },
11
+ cacheMs: { type: Number, required: false, default: 6e4 },
12
+ navigate: { type: Boolean, required: false, default: true },
13
+ collectionPath: { type: String, required: false, default: "/secured/admin/collections" },
14
+ bucketPath: { type: String, required: false, default: "/secured/admin/buckets" },
15
+ usersPath: { type: String, required: false, default: "/secured/admin/users" },
16
+ rolePath: { type: String, required: false, default: "/secured/admin/roles" },
17
+ jobsPath: { type: String, required: false, default: "/secured/admin/jobs" },
18
+ settingsPath: { type: String, required: false, default: "/secured/admin/settings" },
19
+ accountPath: { type: String, required: false, default: "/secured/account" }
20
+ });
21
+ const emit = defineEmits(["select"]);
22
+ const open = defineModel("open", { type: Boolean, ...{ default: false } });
23
+ const { t } = useI18n();
24
+ const { listUsers, listRoles, listCollections } = useMongocampAdmin();
25
+ const { listJobs } = useMongocampJobs();
26
+ const { canRead } = useMongocampPermissions();
27
+ const { isAdmin, logoutPath } = useMongocampRoles();
28
+ const data = ref({});
29
+ const loadedAt = ref(void 0);
30
+ const loading = ref(false);
31
+ const failed = ref([]);
32
+ let generation = 0;
33
+ const paths = computed(() => ({
34
+ collectionPath: props.collectionPath,
35
+ bucketPath: props.bucketPath,
36
+ usersPath: props.usersPath,
37
+ rolePath: props.rolePath,
38
+ jobsPath: props.jobsPath,
39
+ settingsPath: props.settingsPath,
40
+ accountPath: props.accountPath
41
+ }));
42
+ async function load() {
43
+ const current = ++generation;
44
+ loading.value = true;
45
+ const admin = isAdmin.value;
46
+ const parts = {
47
+ collections: () => listCollections(),
48
+ users: async () => (await listUsers()).map((u) => u.user),
49
+ roles: async () => (await listRoles()).map((r) => r.name),
50
+ jobs: async () => (await listJobs()).map((j) => ({ name: j.name, group: j.group }))
51
+ };
52
+ const wanted = admin ? ["collections", "users", "roles", "jobs"] : ["collections"];
53
+ const results = await Promise.allSettled(wanted.map((key) => parts[key]()));
54
+ if (current !== generation) return;
55
+ const next = {};
56
+ const errors = [];
57
+ results.forEach((result, index) => {
58
+ const key = wanted[index];
59
+ if (result.status === "fulfilled") next[key] = result.value;
60
+ else errors.push(key);
61
+ });
62
+ data.value = next;
63
+ failed.value = errors;
64
+ loadedAt.value = Date.now();
65
+ loading.value = false;
66
+ }
67
+ watch(open, (isOpen) => {
68
+ if (isOpen && !isFresh(loadedAt.value, Date.now(), props.cacheMs) && !loading.value) load();
69
+ });
70
+ const GROUP_ORDER = ["collection", "bucket", "user", "role", "job", "action"];
71
+ function choose(entry) {
72
+ open.value = false;
73
+ emit("select", entry);
74
+ if (entry.action === "refresh") {
75
+ load();
76
+ return;
77
+ }
78
+ if (!props.navigate) return;
79
+ if (entry.action === "logout") navigateTo(logoutPath);
80
+ else if (entry.to) navigateTo(entry.to);
81
+ }
82
+ const groups = computed(() => {
83
+ const entries = [
84
+ ...buildEntries(data.value, paths.value, { canRead }),
85
+ ...buildActions(paths.value, { isAdmin: isAdmin.value })
86
+ ];
87
+ return GROUP_ORDER.map((kind) => {
88
+ const items = entries.filter((e) => e.kind === kind).map((entry) => ({
89
+ label: entry.kind === "action" ? t(`nuxtUiMongocamp.commandPalette.action.${entry.label}`) : entry.label,
90
+ suffix: entry.description,
91
+ icon: entry.icon,
92
+ onSelect: () => choose(entry)
93
+ }));
94
+ return { id: kind, label: t(`nuxtUiMongocamp.commandPalette.group.${kind}`), items };
95
+ }).filter((group) => group.items.length);
96
+ });
97
+ defineShortcuts(computed(() => props.shortcut ? { [props.shortcut]: { usingInput: true, handler: () => {
98
+ open.value = !open.value;
99
+ } } } : {}));
100
+ </script>
101
+
102
+ <template>
103
+ <UModal
104
+ v-model:open="open"
105
+ :title="t('nuxtUiMongocamp.commandPalette.title')"
106
+ :description="t('nuxtUiMongocamp.commandPalette.description')"
107
+ :ui="{ content: 'sm:max-w-xl' }"
108
+ >
109
+ <template #content>
110
+ <UCommandPalette
111
+ :groups="groups"
112
+ :loading="loading"
113
+ :placeholder="t('nuxtUiMongocamp.commandPalette.placeholder')"
114
+ class="h-96"
115
+ close
116
+ @update:open="open = $event"
117
+ >
118
+ <template #empty>
119
+ <span data-testid="palette-empty">{{ t("nuxtUiMongocamp.commandPalette.empty") }}</span>
120
+ </template>
121
+ <template
122
+ v-if="failed.length"
123
+ #footer
124
+ >
125
+ <p
126
+ class="px-3 py-2 text-xs text-dimmed"
127
+ data-testid="palette-failed"
128
+ >
129
+ {{ t("nuxtUiMongocamp.commandPalette.failed", { parts: failed.join(", ") }) }}
130
+ </p>
131
+ </template>
132
+ </UCommandPalette>
133
+ </template>
134
+ </UModal>
135
+ </template>
@@ -0,0 +1,40 @@
1
+ import type { PaletteEntry } from '../utils/commandPalette.js';
2
+ type __VLS_Props = {
3
+ /** Keyboard shortcut in Nuxt UI's notation (`meta_k`); empty = no shortcut */
4
+ shortcut?: string;
5
+ /** How long loaded lists are reused, in milliseconds */
6
+ cacheMs?: number;
7
+ /** Open the page of a chosen entry; false = only emit `select` */
8
+ navigate?: boolean;
9
+ collectionPath?: string;
10
+ bucketPath?: string;
11
+ usersPath?: string;
12
+ rolePath?: string;
13
+ jobsPath?: string;
14
+ settingsPath?: string;
15
+ accountPath?: string;
16
+ };
17
+ type __VLS_ModelProps = {
18
+ 'open'?: boolean;
19
+ };
20
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
21
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
+ "update:open": (value: boolean) => any;
23
+ select: (entry: PaletteEntry) => any;
24
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
25
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
26
+ onSelect?: ((entry: PaletteEntry) => any) | undefined;
27
+ }>, {
28
+ shortcut: string;
29
+ cacheMs: number;
30
+ navigate: boolean;
31
+ collectionPath: string;
32
+ bucketPath: string;
33
+ usersPath: string;
34
+ rolePath: string;
35
+ jobsPath: string;
36
+ settingsPath: string;
37
+ accountPath: string;
38
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
39
+ declare const _default: typeof __VLS_export;
40
+ export default _default;
@@ -12,7 +12,7 @@ const props = defineProps({
12
12
  });
13
13
  const open = defineModel("open", { type: Boolean, ...{ default: false } });
14
14
  const { t } = useI18n();
15
- const { describeError } = useMongocampError();
15
+ const { describeServerError } = useMongocampError();
16
16
  const typed = ref("");
17
17
  const busy = ref(false);
18
18
  const error = ref("");
@@ -33,7 +33,7 @@ async function handleConfirm() {
33
33
  await props.onConfirm();
34
34
  close();
35
35
  } catch (e) {
36
- error.value = describeError(e).message;
36
+ error.value = (await describeServerError(e)).message;
37
37
  } finally {
38
38
  busy.value = false;
39
39
  }
@@ -2,6 +2,7 @@ type __VLS_Props = {
2
2
  collectionsPath?: string;
3
3
  usersPath?: string;
4
4
  rolesPath?: string;
5
+ autoRefresh?: number;
5
6
  };
6
7
  declare function refresh(): Promise<void>;
7
8
  declare const __VLS_template: () => {
@@ -13,9 +14,10 @@ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
13
14
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
14
15
  refresh: typeof refresh;
15
16
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
- collectionsPath: string;
17
17
  usersPath: string;
18
+ collectionsPath: string;
18
19
  rolesPath: string;
20
+ autoRefresh: number;
19
21
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
22
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
21
23
  declare const _default: typeof __VLS_export;
@@ -1,12 +1,14 @@
1
1
  <script setup>
2
- import { computed, ref } from "vue";
2
+ import { computed, onMounted, ref, watch } from "vue";
3
3
  import { useI18n } from "#imports";
4
4
  import { useNuxtApp } from "#app";
5
5
  import useMongocampAdmin from "../composables/useMongocampAdmin";
6
+ import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
6
7
  const props = defineProps({
7
8
  collectionsPath: { type: String, required: false, default: "/secured/admin/collections" },
8
9
  usersPath: { type: String, required: false, default: "/secured/admin/users" },
9
- rolesPath: { type: String, required: false, default: "/secured/admin/roles" }
10
+ rolesPath: { type: String, required: false, default: "/secured/admin/roles" },
11
+ autoRefresh: { type: Number, required: false, default: 0 }
10
12
  });
11
13
  const { t } = useI18n();
12
14
  const { $mongocampVersion } = useNuxtApp();
@@ -28,6 +30,23 @@ async function refresh() {
28
30
  loading.value = false;
29
31
  }
30
32
  }
33
+ async function reloadQuietly() {
34
+ try {
35
+ const [users, roles, collections] = await Promise.all([listUsers(), listRoles(), listCollections()]);
36
+ stats.value = { users: users.length, roles: roles.length, collections: collections.length };
37
+ loadError.value = null;
38
+ } catch (e) {
39
+ loadError.value = e;
40
+ throw e;
41
+ }
42
+ }
43
+ const auto = useMongocampAutoRefresh(reloadQuietly, { intervalMs: () => props.autoRefresh * 1e3 });
44
+ function syncAutoRefresh() {
45
+ auto.stop();
46
+ if (props.autoRefresh > 0) auto.start();
47
+ }
48
+ onMounted(syncAutoRefresh);
49
+ watch(() => props.autoRefresh, syncAutoRefresh);
31
50
  const boxes = computed(() => [
32
51
  { key: "collections", label: t("nuxtUiMongocamp.dashboard.collections"), icon: "i-lucide-database", to: props.collectionsPath },
33
52
  { key: "users", label: t("nuxtUiMongocamp.dashboard.users"), icon: "i-lucide-users", to: props.usersPath },
@@ -2,6 +2,7 @@ type __VLS_Props = {
2
2
  collectionsPath?: string;
3
3
  usersPath?: string;
4
4
  rolesPath?: string;
5
+ autoRefresh?: number;
5
6
  };
6
7
  declare function refresh(): Promise<void>;
7
8
  declare const __VLS_template: () => {
@@ -13,9 +14,10 @@ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
13
14
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
14
15
  refresh: typeof refresh;
15
16
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
- collectionsPath: string;
17
17
  usersPath: string;
18
+ collectionsPath: string;
18
19
  rolesPath: string;
20
+ autoRefresh: number;
19
21
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
22
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
21
23
  declare const _default: typeof __VLS_export;
@@ -1,9 +1,12 @@
1
1
  <script setup>
2
2
  import { computed, h, ref, resolveComponent } from "vue";
3
3
  import { useI18n, useMongocampSystem } from "#imports";
4
+ import { formatBytes } from "../utils/formatBytes";
5
+ import { shortenLabel } from "../utils/chartData";
4
6
  const { t } = useI18n();
5
7
  const { getDatabaseInfos, listCollectionsByDatabase } = useMongocampSystem();
6
8
  const databases = ref([]);
9
+ const chartRows = computed(() => [...databases.value].sort((a, b) => b.sizeKb - a.sizeKb).map((d) => ({ name: shortenLabel(d.name), size: d.sizeKb * 1024 })));
7
10
  const loading = ref(false);
8
11
  const sorting = ref([]);
9
12
  const loadError = ref(null);
@@ -91,6 +94,25 @@ fetchDatabases();
91
94
  @retry="fetchDatabases"
92
95
  />
93
96
 
97
+ <details
98
+ v-if="chartRows.length > 1"
99
+ class="text-sm"
100
+ data-testid="databases-chart"
101
+ >
102
+ <summary class="cursor-pointer text-dimmed">
103
+ {{ t("nuxtUiMongocamp.databases.chartSummary") }}
104
+ </summary>
105
+ <MongocampChart
106
+ class="mt-2"
107
+ :data="chartRows"
108
+ index="name"
109
+ :categories="[{ key: 'size', label: t('nuxtUiMongocamp.databases.chartSize') }]"
110
+ :format="formatBytes"
111
+ :chart-label="t('nuxtUiMongocamp.databases.chartSize')"
112
+ :chart-description="t('nuxtUiMongocamp.databases.chartDescription', { count: chartRows.length })"
113
+ />
114
+ </details>
115
+
94
116
  <UTable
95
117
  v-model:sorting="sorting"
96
118
  :data="databases"
@@ -0,0 +1,20 @@
1
+ type __VLS_Props = {
2
+ left: unknown;
3
+ right: unknown;
4
+ leftLabel?: string;
5
+ rightLabel?: string;
6
+ };
7
+ type __VLS_ModelProps = {
8
+ 'onlyDifferences'?: boolean;
9
+ };
10
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
11
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
+ "update:onlyDifferences": (value: boolean) => any;
13
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
14
+ "onUpdate:onlyDifferences"?: ((value: boolean) => any) | undefined;
15
+ }>, {
16
+ leftLabel: string;
17
+ rightLabel: string;
18
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;
@@ -0,0 +1,146 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import { useI18n } from "#imports";
4
+ import { compareDocuments, compareText } from "../utils/documentCompare";
5
+ const props = defineProps({
6
+ left: { type: null, required: true },
7
+ right: { type: null, required: true },
8
+ leftLabel: { type: String, required: false, default: void 0 },
9
+ rightLabel: { type: String, required: false, default: void 0 }
10
+ });
11
+ const onlyDifferences = defineModel("onlyDifferences", { type: Boolean, ...{ default: false } });
12
+ const { t } = useI18n();
13
+ const result = computed(() => compareDocuments(props.left, props.right));
14
+ const visibleRows = computed(() => onlyDifferences.value ? result.value.rows.filter((r) => r.status !== "same") : result.value.rows);
15
+ const identical = computed(() => result.value.rows.every((r) => r.status === "same"));
16
+ const STATUS = {
17
+ same: { color: "neutral", icon: "i-lucide-equal", row: "" },
18
+ changed: { color: "warning", icon: "i-lucide-pencil", row: "bg-warning/10" },
19
+ added: { color: "success", icon: "i-lucide-plus", row: "bg-success/10" },
20
+ removed: { color: "error", icon: "i-lucide-minus", row: "bg-error/10" }
21
+ };
22
+ const statusLabel = (status) => t(`nuxtUiMongocamp.documentCompare.status.${status}`);
23
+ </script>
24
+
25
+ <template>
26
+ <div
27
+ class="flex flex-col gap-3"
28
+ data-testid="document-compare"
29
+ >
30
+ <div class="flex flex-wrap items-center justify-between gap-3">
31
+ <div
32
+ class="flex flex-wrap gap-2"
33
+ data-testid="compare-summary"
34
+ >
35
+ <UBadge
36
+ v-for="status in ['changed', 'added', 'removed', 'same']"
37
+ :key="status"
38
+ :color="STATUS[status].color"
39
+ variant="subtle"
40
+ :icon="STATUS[status].icon"
41
+ :label="`${result.counts[status]} ${statusLabel(status)}`"
42
+ />
43
+ </div>
44
+ <USwitch
45
+ v-model="onlyDifferences"
46
+ :label="t('nuxtUiMongocamp.documentCompare.onlyDifferences')"
47
+ data-testid="only-differences"
48
+ />
49
+ </div>
50
+
51
+ <UAlert
52
+ v-if="result.truncated"
53
+ color="warning"
54
+ variant="subtle"
55
+ icon="i-lucide-triangle-alert"
56
+ :title="t('nuxtUiMongocamp.documentCompare.truncated')"
57
+ />
58
+
59
+ <p
60
+ v-if="identical"
61
+ class="text-sm text-dimmed"
62
+ data-testid="compare-identical"
63
+ >
64
+ {{ t("nuxtUiMongocamp.documentCompare.identical") }}
65
+ </p>
66
+
67
+ <div class="overflow-auto max-h-[65vh] rounded border border-default">
68
+ <table class="w-full text-xs">
69
+ <thead class="sticky top-0 bg-elevated text-left">
70
+ <tr>
71
+ <th class="p-2 font-medium">
72
+ {{ t("nuxtUiMongocamp.documentCompare.path") }}
73
+ </th>
74
+ <th class="p-2 font-medium">
75
+ {{ leftLabel ?? t("nuxtUiMongocamp.documentCompare.left") }}
76
+ </th>
77
+ <th class="p-2 font-medium">
78
+ {{ rightLabel ?? t("nuxtUiMongocamp.documentCompare.right") }}
79
+ </th>
80
+ <th class="p-2 font-medium">
81
+ {{ t("nuxtUiMongocamp.documentCompare.state") }}
82
+ </th>
83
+ </tr>
84
+ </thead>
85
+ <tbody>
86
+ <tr
87
+ v-for="row in visibleRows"
88
+ :key="row.path"
89
+ :class="STATUS[row.status].row"
90
+ :data-path="row.path"
91
+ :data-status="row.status"
92
+ >
93
+ <td class="p-2 font-mono align-top break-all">
94
+ {{ row.path || t("nuxtUiMongocamp.documentCompare.root") }}
95
+ </td>
96
+ <td class="p-2 font-mono align-top break-all">
97
+ <template v-if="row.status === 'added'">
98
+ <span class="text-dimmed">—</span>
99
+ </template>
100
+ <template v-else>
101
+ {{ compareText(row.left) }}
102
+ <UBadge
103
+ v-if="row.typeDiffers"
104
+ :label="row.leftType"
105
+ color="neutral"
106
+ variant="outline"
107
+ size="sm"
108
+ />
109
+ </template>
110
+ </td>
111
+ <td class="p-2 font-mono align-top break-all">
112
+ <template v-if="row.status === 'removed'">
113
+ <span class="text-dimmed">—</span>
114
+ </template>
115
+ <template v-else>
116
+ {{ compareText(row.right) }}
117
+ <UBadge
118
+ v-if="row.typeDiffers"
119
+ :label="row.rightType"
120
+ color="neutral"
121
+ variant="outline"
122
+ size="sm"
123
+ />
124
+ </template>
125
+ </td>
126
+ <td class="p-2 align-top">
127
+ <UBadge
128
+ :color="STATUS[row.status].color"
129
+ variant="subtle"
130
+ :label="statusLabel(row.status)"
131
+ />
132
+ </td>
133
+ </tr>
134
+ <tr v-if="!visibleRows.length">
135
+ <td
136
+ colspan="4"
137
+ class="p-3 text-center text-dimmed"
138
+ >
139
+ {{ t("nuxtUiMongocamp.documentCompare.nothing") }}
140
+ </td>
141
+ </tr>
142
+ </tbody>
143
+ </table>
144
+ </div>
145
+ </div>
146
+ </template>
@@ -0,0 +1,20 @@
1
+ type __VLS_Props = {
2
+ left: unknown;
3
+ right: unknown;
4
+ leftLabel?: string;
5
+ rightLabel?: string;
6
+ };
7
+ type __VLS_ModelProps = {
8
+ 'onlyDifferences'?: boolean;
9
+ };
10
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
11
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
+ "update:onlyDifferences": (value: boolean) => any;
13
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
14
+ "onUpdate:onlyDifferences"?: ((value: boolean) => any) | undefined;
15
+ }>, {
16
+ leftLabel: string;
17
+ rightLabel: string;
18
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;
@@ -0,0 +1,22 @@
1
+ type __VLS_Props = {
2
+ document: Record<string, unknown> | null | undefined;
3
+ };
4
+ type __VLS_ModelProps = {
5
+ 'mode'?: 'tree' | 'json';
6
+ };
7
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ copy: (payload: {
10
+ kind: "path" | "value" | "document";
11
+ text: string;
12
+ }) => any;
13
+ "update:mode": (value: "json" | "tree") => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ onCopy?: ((payload: {
16
+ kind: "path" | "value" | "document";
17
+ text: string;
18
+ }) => any) | undefined;
19
+ "onUpdate:mode"?: ((value: "json" | "tree") => any) | undefined;
20
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
+ declare const _default: typeof __VLS_export;
22
+ export default _default;