@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,398 @@
1
+ <script setup>
2
+ import { computed, ref, watch } from "vue";
3
+ import { useI18n } from "#imports";
4
+ import MongocampFilterBuilder from "./MongocampFilterBuilder.vue";
5
+ import { useMongocampSavedQueries } from "../composables/useMongocampSavedQueries";
6
+ import { buildCondition, buildFilterQuery, conditionValueText, countActiveConditions, operatorLabelKey } from "../utils/filterBuilder";
7
+ import {
8
+ addSort,
9
+ describeQuery,
10
+ emptyGroup,
11
+ fromSavedQuery,
12
+ isEmptyQuery,
13
+ MAX_SORT_ENTRIES,
14
+ parseSortEntry,
15
+ removeSort,
16
+ setSortField,
17
+ toggleProjectionField,
18
+ toggleSortDirection,
19
+ toSavedQuery,
20
+ usableProjection
21
+ } from "../utils/queryState";
22
+ const props = defineProps({
23
+ fields: { type: Array, required: true },
24
+ columns: { type: Array, required: true },
25
+ collection: { type: String, required: true },
26
+ loadDistinct: { type: Function, required: false }
27
+ });
28
+ const model = defineModel({ type: Object, ...{ required: true } });
29
+ const emit = defineEmits(["apply"]);
30
+ const { t } = useI18n();
31
+ const { saved, recent, save, remove, record, clearRecent } = useMongocampSavedQueries(() => props.collection);
32
+ const fieldTypes = computed(() => Object.fromEntries(props.fields.map((f) => [f.key, f.type])));
33
+ const projectable = computed(() => props.columns.filter((c) => c !== "_id"));
34
+ const filtersOpen = ref(false);
35
+ const draft = ref(emptyGroup());
36
+ const cloneGroup = (g) => ({ match: g.match, negate: g.negate, conditions: g.conditions.map((c) => ({ ...c })) });
37
+ watch(() => model.value.filterGroup, (g) => draft.value = cloneGroup(g), { immediate: true });
38
+ watch(() => props.collection, () => filtersOpen.value = false);
39
+ defineExpose({ closePanel: () => filtersOpen.value = false });
40
+ function commit(next, options = {}) {
41
+ model.value = next;
42
+ emit("apply", next);
43
+ if (options.remember !== false && !isEmptyQuery(next)) record(toSavedQuery(next));
44
+ }
45
+ function onBuilderApply(lucene) {
46
+ commit({ ...model.value, filterGroup: cloneGroup(draft.value), lucene });
47
+ }
48
+ const activeFilterCount = computed(() => {
49
+ const count = countActiveConditions(model.value.filterGroup, fieldTypes.value);
50
+ return count > 0 ? count : model.value.lucene !== "" ? 1 : 0;
51
+ });
52
+ const filterChips = computed(() => {
53
+ const chips = model.value.filterGroup.conditions.filter((c) => buildCondition(c, fieldTypes.value[c.field] ?? "string") !== "").map((c) => ({
54
+ id: c.id,
55
+ label: [c.field, t(operatorLabelKey(c.operator, fieldTypes.value[c.field] ?? "string")), conditionValueText(c)].filter(Boolean).join(" ")
56
+ }));
57
+ if (chips.length === 0 && model.value.lucene !== "") chips.push({ id: "__lucene", label: t("nuxtUiMongocamp.queryBar.customFilter", { query: model.value.lucene }) });
58
+ return chips;
59
+ });
60
+ function removeChip(id) {
61
+ if (id === "__lucene") return clearFilter();
62
+ const group = { ...model.value.filterGroup, conditions: model.value.filterGroup.conditions.filter((c) => c.id !== id) };
63
+ commit({ ...model.value, filterGroup: group, lucene: buildFilterQuery(group, fieldTypes.value) });
64
+ }
65
+ function clearFilter() {
66
+ commit({ ...model.value, filterGroup: emptyGroup(), lucene: "" }, { remember: false });
67
+ }
68
+ const sortFieldItems = computed(() => props.columns.map((c) => ({ label: c, value: c })));
69
+ const sortEntries = computed(() => model.value.sort.map(parseSortEntry));
70
+ const canAddSort = computed(() => model.value.sort.length < MAX_SORT_ENTRIES && props.columns.some((c) => !sortEntries.value.some((e) => e.field === c)));
71
+ function setSort(sort) {
72
+ commit({ ...model.value, sort });
73
+ }
74
+ function addSortRow() {
75
+ const next = props.columns.find((c) => !sortEntries.value.some((e) => e.field === c));
76
+ if (next) setSort(addSort(model.value.sort, next));
77
+ }
78
+ const projection = computed(() => usableProjection(model.value.projection, projectable.value));
79
+ const fieldMenuItems = computed(() => {
80
+ const chosen = projection.value.length > 0 ? projection.value : projectable.value;
81
+ return projectable.value.map((key) => ({
82
+ label: key,
83
+ type: "checkbox",
84
+ checked: chosen.includes(key),
85
+ onUpdateChecked: () => commit({ ...model.value, projection: toggleProjectionField(projection.value, key, projectable.value) }),
86
+ onSelect: (e) => e.preventDefault()
87
+ }));
88
+ });
89
+ const labels = computed(() => ({
90
+ filter: t("nuxtUiMongocamp.queryBar.wordFilter"),
91
+ sort: t("nuxtUiMongocamp.queryBar.wordSort"),
92
+ fields: t("nuxtUiMongocamp.queryBar.wordFields")
93
+ }));
94
+ const describe = (q) => describeQuery(q, labels.value, fieldTypes.value) || "\u2014";
95
+ const saveName = ref("");
96
+ const saveError = ref("");
97
+ const canSave = computed(() => !isEmptyQuery(model.value));
98
+ function restore(query) {
99
+ const state = fromSavedQuery(query, fieldTypes.value);
100
+ state.projection = usableProjection(state.projection, projectable.value);
101
+ commit(state);
102
+ }
103
+ function saveCurrent() {
104
+ saveError.value = "";
105
+ const result = save(saveName.value, toSavedQuery(model.value));
106
+ if (result.ok) {
107
+ saveName.value = "";
108
+ return;
109
+ }
110
+ const key = { "invalid-name": "saveFailedName", "invalid-query": "saveFailedQuery", "limit": "saveFailedLimit", "too-large": "saveFailedSize" }[result.reason];
111
+ saveError.value = t(`nuxtUiMongocamp.queryBar.${key}`);
112
+ }
113
+ </script>
114
+
115
+ <template>
116
+ <div class="flex flex-col gap-3">
117
+ <div class="flex flex-wrap items-center gap-1">
118
+ <UChip
119
+ :text="activeFilterCount"
120
+ :show="activeFilterCount > 0"
121
+ size="sm"
122
+ >
123
+ <UButton
124
+ icon="i-lucide-list-filter"
125
+ color="neutral"
126
+ :variant="filtersOpen ? 'subtle' : 'ghost'"
127
+ size="sm"
128
+ :disabled="fields.length === 0"
129
+ :aria-pressed="filtersOpen"
130
+ :aria-label="t('nuxtUiMongocamp.collectionData.filtersTooltip')"
131
+ @click="filtersOpen = !filtersOpen"
132
+ />
133
+ </UChip>
134
+
135
+ <UPopover>
136
+ <UChip
137
+ :text="model.sort.length"
138
+ :show="model.sort.length > 0"
139
+ size="sm"
140
+ >
141
+ <UButton
142
+ icon="i-lucide-arrow-up-down"
143
+ color="neutral"
144
+ variant="ghost"
145
+ size="sm"
146
+ :disabled="columns.length === 0"
147
+ :aria-label="t('nuxtUiMongocamp.queryBar.sortButton')"
148
+ />
149
+ </UChip>
150
+ <template #content>
151
+ <div
152
+ class="flex w-80 flex-col gap-2 p-3"
153
+ data-test="sort-panel"
154
+ >
155
+ <p class="text-sm font-semibold">
156
+ {{ t("nuxtUiMongocamp.queryBar.sortTitle") }}
157
+ </p>
158
+ <p
159
+ v-if="model.sort.length === 0"
160
+ class="text-sm text-dimmed"
161
+ >
162
+ {{ t("nuxtUiMongocamp.queryBar.sortNone") }}
163
+ </p>
164
+ <div
165
+ v-for="(entry, index) in sortEntries"
166
+ :key="entry.field"
167
+ class="flex items-center gap-1"
168
+ >
169
+ <USelect
170
+ :model-value="entry.field"
171
+ :items="sortFieldItems"
172
+ size="sm"
173
+ class="min-w-0 flex-1"
174
+ :aria-label="t('nuxtUiMongocamp.queryBar.sortField', { position: index + 1 })"
175
+ @update:model-value="(v) => setSort(setSortField(model.sort, index, v))"
176
+ />
177
+ <UButton
178
+ :icon="entry.desc ? 'i-lucide-arrow-down-wide-narrow' : 'i-lucide-arrow-up-narrow-wide'"
179
+ color="neutral"
180
+ variant="ghost"
181
+ size="sm"
182
+ :label="entry.desc ? t('nuxtUiMongocamp.queryBar.sortDescending') : t('nuxtUiMongocamp.queryBar.sortAscending')"
183
+ :aria-label="t('nuxtUiMongocamp.queryBar.toggleSortDirection', { field: entry.field })"
184
+ @click="setSort(toggleSortDirection(model.sort, index))"
185
+ />
186
+ <UButton
187
+ icon="i-lucide-x"
188
+ color="neutral"
189
+ variant="ghost"
190
+ size="sm"
191
+ :aria-label="t('nuxtUiMongocamp.queryBar.removeSort', { field: entry.field })"
192
+ @click="setSort(removeSort(model.sort, index))"
193
+ />
194
+ </div>
195
+ <UButton
196
+ icon="i-lucide-plus"
197
+ color="neutral"
198
+ variant="soft"
199
+ size="sm"
200
+ :label="t('nuxtUiMongocamp.queryBar.addSort')"
201
+ :disabled="!canAddSort"
202
+ @click="addSortRow"
203
+ />
204
+ </div>
205
+ </template>
206
+ </UPopover>
207
+
208
+ <UDropdownMenu :items="fieldMenuItems">
209
+ <UChip
210
+ :text="projection.length"
211
+ :show="projection.length > 0"
212
+ size="sm"
213
+ >
214
+ <UButton
215
+ icon="i-lucide-columns-3"
216
+ color="neutral"
217
+ variant="ghost"
218
+ size="sm"
219
+ :disabled="projectable.length === 0"
220
+ :title="projection.length > 0 ? t('nuxtUiMongocamp.queryBar.fieldsSome', { count: projection.length, total: projectable.length }) : t('nuxtUiMongocamp.queryBar.fieldsAll')"
221
+ :aria-label="t('nuxtUiMongocamp.queryBar.fieldsButton')"
222
+ />
223
+ </UChip>
224
+ </UDropdownMenu>
225
+
226
+ <UPopover>
227
+ <UButton
228
+ icon="i-lucide-history"
229
+ color="neutral"
230
+ variant="ghost"
231
+ size="sm"
232
+ :aria-label="t('nuxtUiMongocamp.queryBar.historyButton')"
233
+ />
234
+ <template #content>
235
+ <div
236
+ class="flex w-96 max-w-[90vw] flex-col gap-3 p-3"
237
+ data-test="history-panel"
238
+ >
239
+ <section class="flex flex-col gap-1">
240
+ <h3 class="text-sm font-semibold">
241
+ {{ t("nuxtUiMongocamp.queryBar.saved") }}
242
+ </h3>
243
+ <p
244
+ v-if="saved.length === 0"
245
+ class="text-sm text-dimmed"
246
+ >
247
+ {{ t("nuxtUiMongocamp.queryBar.noSaved") }}
248
+ </p>
249
+ <div
250
+ v-for="entry in saved"
251
+ :key="entry.name"
252
+ class="flex items-center gap-1"
253
+ >
254
+ <UButton
255
+ color="neutral"
256
+ variant="ghost"
257
+ size="sm"
258
+ class="min-w-0 flex-1 justify-start"
259
+ :title="describe(entry.query)"
260
+ @click="restore(entry.query)"
261
+ >
262
+ <span class="truncate font-medium">{{ entry.name }}</span>
263
+ <span class="truncate text-xs text-dimmed">{{ describe(entry.query) }}</span>
264
+ </UButton>
265
+ <UButton
266
+ icon="i-lucide-trash-2"
267
+ color="error"
268
+ variant="ghost"
269
+ size="sm"
270
+ :aria-label="t('nuxtUiMongocamp.queryBar.deleteSaved', { name: entry.name })"
271
+ @click="remove(entry.name)"
272
+ />
273
+ </div>
274
+ <form
275
+ class="mt-1 flex items-center gap-1"
276
+ @submit.prevent="saveCurrent"
277
+ >
278
+ <UInput
279
+ v-model="saveName"
280
+ size="sm"
281
+ class="min-w-0 flex-1"
282
+ :placeholder="t('nuxtUiMongocamp.queryBar.saveNamePlaceholder')"
283
+ :aria-label="t('nuxtUiMongocamp.queryBar.saveName')"
284
+ maxlength="80"
285
+ />
286
+ <UButton
287
+ type="submit"
288
+ icon="i-lucide-save"
289
+ size="sm"
290
+ :label="t('nuxtUiMongocamp.queryBar.save')"
291
+ :disabled="!canSave || saveName.trim() === ''"
292
+ :title="canSave ? void 0 : t('nuxtUiMongocamp.queryBar.nothingToSave')"
293
+ />
294
+ </form>
295
+ <p
296
+ v-if="saveError"
297
+ class="text-xs text-error"
298
+ role="alert"
299
+ >
300
+ {{ saveError }}
301
+ </p>
302
+ </section>
303
+ <section class="flex flex-col gap-1">
304
+ <div class="flex items-center justify-between">
305
+ <h3 class="text-sm font-semibold">
306
+ {{ t("nuxtUiMongocamp.queryBar.recent") }}
307
+ </h3>
308
+ <UButton
309
+ v-if="recent.length > 0"
310
+ color="neutral"
311
+ variant="link"
312
+ size="xs"
313
+ :label="t('nuxtUiMongocamp.queryBar.clearHistory')"
314
+ @click="clearRecent"
315
+ />
316
+ </div>
317
+ <p
318
+ v-if="recent.length === 0"
319
+ class="text-sm text-dimmed"
320
+ >
321
+ {{ t("nuxtUiMongocamp.queryBar.noRecent") }}
322
+ </p>
323
+ <UButton
324
+ v-for="(query, index) in recent"
325
+ :key="index"
326
+ color="neutral"
327
+ variant="ghost"
328
+ size="sm"
329
+ class="justify-start"
330
+ :label="describe(query)"
331
+ data-test="recent-query"
332
+ @click="restore(query)"
333
+ />
334
+ </section>
335
+ </div>
336
+ </template>
337
+ </UPopover>
338
+ </div>
339
+
340
+ <MongocampFilterBuilder
341
+ v-if="filtersOpen"
342
+ v-model="draft"
343
+ :fields="fields"
344
+ :load-distinct="loadDistinct"
345
+ @apply="onBuilderApply"
346
+ />
347
+
348
+ <div
349
+ v-if="filterChips.length > 0"
350
+ class="flex flex-wrap items-center gap-2"
351
+ >
352
+ <UBadge
353
+ v-if="model.filterGroup.negate"
354
+ color="warning"
355
+ variant="subtle"
356
+ :label="t('nuxtUiMongocamp.collectionData.filterExcluding')"
357
+ />
358
+ <UBadge
359
+ v-for="chip in filterChips"
360
+ :key="chip.id"
361
+ color="neutral"
362
+ variant="subtle"
363
+ class="gap-1"
364
+ >
365
+ {{ chip.label }}
366
+ <UButton
367
+ icon="i-lucide-x"
368
+ color="neutral"
369
+ variant="link"
370
+ size="xs"
371
+ class="p-0"
372
+ :aria-label="t('nuxtUiMongocamp.collectionData.removeFilter', { filter: chip.label })"
373
+ @click="removeChip(chip.id)"
374
+ />
375
+ </UBadge>
376
+ <UButton
377
+ color="neutral"
378
+ variant="link"
379
+ size="xs"
380
+ :label="t('nuxtUiMongocamp.collectionData.clearFilters')"
381
+ @click="clearFilter"
382
+ />
383
+ </div>
384
+ <p
385
+ v-if="projection.length > 0"
386
+ class="text-xs text-dimmed"
387
+ >
388
+ {{ t("nuxtUiMongocamp.queryBar.fieldsSome", { count: projection.length, total: projectable.length }) }}.
389
+ <UButton
390
+ color="neutral"
391
+ variant="link"
392
+ size="xs"
393
+ :label="t('nuxtUiMongocamp.queryBar.fieldsReset')"
394
+ @click="commit({ ...model, projection: [] })"
395
+ />
396
+ </p>
397
+ </div>
398
+ </template>
@@ -0,0 +1,26 @@
1
+ import type { FilterFieldType } from '../utils/filterBuilder.js';
2
+ import type { QueryState } from '../utils/queryState.js';
3
+ type __VLS_Props = {
4
+ fields: {
5
+ key: string;
6
+ type: FilterFieldType;
7
+ }[];
8
+ columns: string[];
9
+ collection: string;
10
+ loadDistinct?: (field: string) => Promise<string[]>;
11
+ };
12
+ type __VLS_ModelProps = {
13
+ modelValue: QueryState;
14
+ };
15
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
16
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
17
+ closePanel: () => boolean;
18
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ "update:modelValue": (value: QueryState) => any;
20
+ apply: (state: QueryState) => any;
21
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
22
+ "onUpdate:modelValue"?: ((value: QueryState) => any) | undefined;
23
+ onApply?: ((state: QueryState) => any) | undefined;
24
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
+ declare const _default: typeof __VLS_export;
26
+ export default _default;
@@ -2,11 +2,12 @@
2
2
  import { computed, h, reactive, ref, resolveComponent } from "vue";
3
3
  import { useI18n, useMongocampError } from "#imports";
4
4
  import useMongocampAdmin from "../composables/useMongocampAdmin";
5
+ import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
5
6
  const props = defineProps({
6
7
  roleName: { type: String, required: true }
7
8
  });
8
9
  const { t } = useI18n();
9
- const { describeError } = useMongocampError();
10
+ const { describeServerError } = useMongocampError();
10
11
  const { listRoles, updateRole, listCollections } = useMongocampAdmin();
11
12
  const grants = ref([]);
12
13
  const allCollections = ref([]);
@@ -63,6 +64,7 @@ const editGrantSchema = reactive([
63
64
  }
64
65
  ]);
65
66
  const loadError = ref(null);
67
+ const { blocked, message } = useMongocampAdminGate();
66
68
  async function fetchRole() {
67
69
  loading.value = true;
68
70
  loadError.value = null;
@@ -91,7 +93,7 @@ async function saveGrants(next) {
91
93
  try {
92
94
  await updateRole(props.roleName, isAdmin.value, next);
93
95
  } catch (e) {
94
- saveError.value = describeError(e, "nuxtUiMongocamp.roleGrants.errorSave").message;
96
+ saveError.value = (await describeServerError(e, "nuxtUiMongocamp.roleGrants.errorSave")).message;
95
97
  return false;
96
98
  } finally {
97
99
  saving.value = false;
@@ -220,12 +222,23 @@ const columns = computed(() => [
220
222
  ])
221
223
  }
222
224
  ]);
223
- fetchRole();
224
- fetchCollections();
225
+ if (!blocked.value) {
226
+ fetchRole();
227
+ fetchCollections();
228
+ }
225
229
  </script>
226
230
 
227
231
  <template>
228
- <div class="flex flex-col gap-4">
232
+ <MongocampEmptyState
233
+ v-if="blocked"
234
+ icon="i-lucide-shield-alert"
235
+ :title="message"
236
+ data-test="admin-only"
237
+ />
238
+ <div
239
+ v-else
240
+ class="flex flex-col gap-4"
241
+ >
229
242
  <div class="flex items-center justify-between">
230
243
  <h2 class="text-xl font-semibold">
231
244
  {{ t("nuxtUiMongocamp.roleGrants.heading", { roleName }) }}
@@ -4,6 +4,7 @@ import { useI18n, useMongocampError } from "#imports";
4
4
  import useMongocampAdmin from "../composables/useMongocampAdmin";
5
5
  import { runBulkDelete } from "../utils/bulkDelete";
6
6
  import { createSelectColumn } from "../utils/createSelectColumn";
7
+ import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
7
8
  const props = defineProps({
8
9
  grantsPath: { type: String, required: false }
9
10
  });
@@ -62,7 +63,7 @@ const cloneRoleSchema = reactive([
62
63
  }
63
64
  ]);
64
65
  const loadError = ref(null);
65
- const { describeError } = useMongocampError();
66
+ const { describeError, describeServerError } = useMongocampError();
66
67
  const rowSelection = ref({});
67
68
  const selectedRoleNames = computed(() => Object.keys(rowSelection.value).filter((name) => rowSelection.value[name]));
68
69
  const bulkDeleting = ref(false);
@@ -82,6 +83,7 @@ async function handleBulkDelete() {
82
83
  bulkDeleting.value = false;
83
84
  }
84
85
  }
86
+ const { blocked, message } = useMongocampAdminGate();
85
87
  async function fetchRoles() {
86
88
  loading.value = true;
87
89
  loadError.value = null;
@@ -140,7 +142,7 @@ async function handleCloneRole() {
140
142
  isCloneModalOpen.value = false;
141
143
  await fetchRoles();
142
144
  } catch (e) {
143
- cloneError.value = describeError(e, "nuxtUiMongocamp.roles.errorClone").message;
145
+ cloneError.value = (await describeServerError(e, "nuxtUiMongocamp.roles.errorClone")).message;
144
146
  } finally {
145
147
  cloning.value = false;
146
148
  }
@@ -160,7 +162,7 @@ async function handleDeleteRole() {
160
162
  isDeleteModalOpen.value = false;
161
163
  await fetchRoles();
162
164
  } catch (e) {
163
- deleteError.value = describeError(e, "nuxtUiMongocamp.roles.errorDelete").message;
165
+ deleteError.value = (await describeServerError(e, "nuxtUiMongocamp.roles.errorDelete")).message;
164
166
  } finally {
165
167
  deleting.value = false;
166
168
  }
@@ -263,11 +265,20 @@ const columns = computed(() => [
263
265
  ])
264
266
  }
265
267
  ]);
266
- fetchRoles();
268
+ if (!blocked.value) fetchRoles();
267
269
  </script>
268
270
 
269
271
  <template>
270
- <div class="flex flex-col gap-4">
272
+ <MongocampEmptyState
273
+ v-if="blocked"
274
+ icon="i-lucide-shield-alert"
275
+ :title="message"
276
+ data-test="admin-only"
277
+ />
278
+ <div
279
+ v-else
280
+ class="flex flex-col gap-4"
281
+ >
271
282
  <div class="flex items-center justify-between gap-4">
272
283
  <h2 class="text-xl font-semibold">
273
284
  {{ t("nuxtUiMongocamp.roles.heading") }}
@@ -0,0 +1,20 @@
1
+ type __VLS_Props = {
2
+ infoPath?: string;
3
+ dataPath?: string;
4
+ jobsPath?: string;
5
+ topN?: number;
6
+ maxCollections?: number;
7
+ autoRefresh?: number;
8
+ hideCharts?: boolean;
9
+ };
10
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
11
+ infoPath: string;
12
+ dataPath: string;
13
+ jobsPath: string;
14
+ autoRefresh: number;
15
+ maxCollections: number;
16
+ topN: number;
17
+ hideCharts: boolean;
18
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;