@sfxcode/nuxt-ui-mongocamp 1.5.1 → 1.5.3

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 (90) hide show
  1. package/dist/module.d.mts +15 -0
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +25 -4
  4. package/dist/runtime/assets/formkit.css +1 -0
  5. package/dist/runtime/components/MongocampAccount.vue +4 -4
  6. package/dist/runtime/components/MongocampBucketFiles.d.vue.ts +21 -1
  7. package/dist/runtime/components/MongocampBucketFiles.vue +17 -5
  8. package/dist/runtime/components/MongocampBucketFiles.vue.d.ts +21 -1
  9. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +22 -2
  10. package/dist/runtime/components/MongocampCollectionData.vue +31 -9
  11. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +22 -2
  12. package/dist/runtime/components/MongocampCollectionInfos.vue +12 -12
  13. package/dist/runtime/components/MongocampCollections.d.vue.ts +19 -1
  14. package/dist/runtime/components/MongocampCollections.vue +20 -7
  15. package/dist/runtime/components/MongocampCollections.vue.d.ts +19 -1
  16. package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +0 -7
  17. package/dist/runtime/components/MongocampCommandPalette.vue +16 -15
  18. package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +0 -7
  19. package/dist/runtime/components/MongocampDashboard.d.vue.ts +3 -3
  20. package/dist/runtime/components/MongocampDashboard.vue +19 -12
  21. package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -3
  22. package/dist/runtime/components/MongocampDatabases.d.vue.ts +20 -1
  23. package/dist/runtime/components/MongocampDatabases.vue +15 -2
  24. package/dist/runtime/components/MongocampDatabases.vue.d.ts +20 -1
  25. package/dist/runtime/components/MongocampIndexes.vue +1 -1
  26. package/dist/runtime/components/MongocampJobs.d.vue.ts +23 -1
  27. package/dist/runtime/components/MongocampJobs.vue +18 -4
  28. package/dist/runtime/components/MongocampJobs.vue.d.ts +23 -1
  29. package/dist/runtime/components/MongocampLogin.d.vue.ts +16 -1
  30. package/dist/runtime/components/MongocampLogin.vue +13 -5
  31. package/dist/runtime/components/MongocampLogin.vue.d.ts +16 -1
  32. package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +19 -2
  33. package/dist/runtime/components/MongocampPermissionMatrix.vue +15 -6
  34. package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +19 -2
  35. package/dist/runtime/components/MongocampRoleGrants.d.vue.ts +22 -1
  36. package/dist/runtime/components/MongocampRoleGrants.vue +16 -4
  37. package/dist/runtime/components/MongocampRoleGrants.vue.d.ts +22 -1
  38. package/dist/runtime/components/MongocampRoles.d.vue.ts +22 -1
  39. package/dist/runtime/components/MongocampRoles.vue +22 -5
  40. package/dist/runtime/components/MongocampRoles.vue.d.ts +22 -1
  41. package/dist/runtime/components/MongocampServerInfo.d.vue.ts +2 -2
  42. package/dist/runtime/components/MongocampServerInfo.vue +14 -4
  43. package/dist/runtime/components/MongocampServerInfo.vue.d.ts +2 -2
  44. package/dist/runtime/components/MongocampServerOverview.d.vue.ts +18 -4
  45. package/dist/runtime/components/MongocampServerOverview.vue +33 -22
  46. package/dist/runtime/components/MongocampServerOverview.vue.d.ts +18 -4
  47. package/dist/runtime/components/MongocampServerStatus.d.vue.ts +13 -0
  48. package/dist/runtime/components/MongocampServerStatus.vue +147 -0
  49. package/dist/runtime/components/MongocampServerStatus.vue.d.ts +13 -0
  50. package/dist/runtime/components/MongocampSettings.d.vue.ts +1 -1
  51. package/dist/runtime/components/MongocampSettings.vue.d.ts +1 -1
  52. package/dist/runtime/components/MongocampUserAccess.d.vue.ts +27 -0
  53. package/dist/runtime/components/MongocampUserAccess.vue +168 -0
  54. package/dist/runtime/components/MongocampUserAccess.vue.d.ts +27 -0
  55. package/dist/runtime/components/MongocampUsers.d.vue.ts +24 -1
  56. package/dist/runtime/components/MongocampUsers.vue +22 -4
  57. package/dist/runtime/components/MongocampUsers.vue.d.ts +24 -1
  58. package/dist/runtime/components/MongocampVersion.vue +3 -3
  59. package/dist/runtime/composables/useMongocampAdminGate.js +2 -3
  60. package/dist/runtime/composables/useMongocampBreadcrumbs.d.ts +12 -0
  61. package/dist/runtime/composables/useMongocampBreadcrumbs.js +13 -0
  62. package/dist/runtime/composables/useMongocampCollectionNames.d.ts +21 -0
  63. package/dist/runtime/composables/useMongocampCollectionNames.js +46 -0
  64. package/dist/runtime/composables/useMongocampNavigation.d.ts +32 -0
  65. package/dist/runtime/composables/useMongocampNavigation.js +15 -0
  66. package/dist/runtime/composables/useMongocampPaths.d.ts +6 -0
  67. package/dist/runtime/composables/useMongocampPaths.js +6 -0
  68. package/dist/runtime/composables/useMongocampPermissions.js +2 -3
  69. package/dist/runtime/composables/useMongocampProxyMode.d.ts +5 -0
  70. package/dist/runtime/composables/useMongocampProxyMode.js +4 -0
  71. package/dist/runtime/composables/useMongocampRoles.d.ts +3 -0
  72. package/dist/runtime/composables/useMongocampRoles.js +5 -1
  73. package/dist/runtime/composables/useMongocampSession.js +2 -3
  74. package/dist/runtime/formkit.config.d.ts +3 -0
  75. package/dist/runtime/formkit.config.js +9 -0
  76. package/dist/runtime/locales/de.json +42 -0
  77. package/dist/runtime/locales/en.json +42 -0
  78. package/dist/runtime/publicUtils.d.ts +4 -0
  79. package/dist/runtime/publicUtils.js +4 -0
  80. package/dist/runtime/utils/collectionNames.d.ts +13 -0
  81. package/dist/runtime/utils/collectionNames.js +14 -0
  82. package/dist/runtime/utils/collectionProtection.d.ts +2 -0
  83. package/dist/runtime/utils/collectionProtection.js +3 -0
  84. package/dist/runtime/utils/navigation.d.ts +39 -0
  85. package/dist/runtime/utils/navigation.js +65 -0
  86. package/dist/runtime/utils/paths.d.ts +32 -0
  87. package/dist/runtime/utils/paths.js +24 -0
  88. package/dist/runtime/utils/serverStatus.d.ts +20 -0
  89. package/dist/runtime/utils/serverStatus.js +11 -0
  90. package/package.json +8 -1
package/dist/module.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
+ import { MongocampPaths } from '../dist/runtime/utils/paths.js';
2
3
 
3
4
  interface ModuleOptions {
4
5
  useGlobalAuthMiddleware?: boolean;
@@ -66,6 +67,20 @@ interface ModuleOptions {
66
67
  * Local route prefix the proxy listens on when `useServerProxy` is enabled.
67
68
  */
68
69
  serverProxyPath?: string;
70
+ /**
71
+ * Base routes of the app's MongoCamp pages. Every `*Path` prop of the components falls back to
72
+ * these (and `useMongocampPaths()` returns them), so an app with other routes sets them once
73
+ * instead of a prop per component. Keys: `home`, `account`, `collections`, `buckets`, `users`,
74
+ * `roles`, `permissions`, `jobs`, `databases`, `overview`, `server`, `settings`; a key left out
75
+ * keeps its default (`/secured`, `/secured/account`, `/secured/admin/<key>`).
76
+ */
77
+ paths?: Partial<MongocampPaths>;
78
+ /**
79
+ * Load the module's default styles for FormKit's label, help text, validation message and form
80
+ * spacing (`runtime/assets/formkit.css`, built on Nuxt UI's `--ui-*` tokens). It is loaded before
81
+ * the app's own stylesheets, so any rule of the app overrides it. Default `true`.
82
+ */
83
+ formkitStyles?: boolean;
69
84
  }
70
85
  interface ModulePublicRuntimeConfig {
71
86
  nuxtUiMongocampOptions: ModuleOptions;
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "1.5.1",
7
+ "version": "1.5.3",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.4",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { existsSync } from 'node:fs';
1
2
  import { createResolver, defineNuxtModule, addPlugin, addComponentsDir, addImportsDir, addServerHandler } from '@nuxt/kit';
2
3
  import { defu } from 'defu';
3
4
  import { consola } from 'consola';
@@ -22,8 +23,20 @@ function optionWarnings(options) {
22
23
  return warnings;
23
24
  }
24
25
 
26
+ const EXTENSIONS = ["ts", "mjs", "js"];
27
+ function defaultFormkitConfigFile(rootDir, configuredFile, defaultFile, exists) {
28
+ if (configuredFile) return void 0;
29
+ const base = `${rootDir.replace(/[\\/]+$/, "")}/formkit.config`;
30
+ if (EXTENSIONS.some((extension) => exists(`${base}.${extension}`))) return void 0;
31
+ return defaultFile;
32
+ }
33
+
25
34
  const { resolve } = createResolver(import.meta.url);
26
35
  const runtimeDir = resolve("./runtime");
36
+ function formkitDefaults(rootDir, configuredFile) {
37
+ const configFile = defaultFormkitConfigFile(rootDir, configuredFile, resolve(runtimeDir, "formkit.config"), existsSync);
38
+ return configFile ? { configFile } : {};
39
+ }
27
40
  const module$1 = defineNuxtModule({
28
41
  meta: {
29
42
  name: "nuxt-ui-mongocamp",
@@ -46,12 +59,19 @@ const module$1 = defineNuxtModule({
46
59
  managementRouteParts: [],
47
60
  adminRouteParts: [],
48
61
  useServerProxy: false,
49
- serverProxyPath: "/api/_mongocamp"
62
+ serverProxyPath: "/api/_mongocamp",
63
+ formkitStyles: true
64
+ // `paths` has no entry here: `useMongocampPaths()` fills in the defaults at runtime (`utils/paths.ts`).
50
65
  },
51
- moduleDependencies: {
66
+ // A function, not an object: the FormKit entry depends on the app (does it bring its own config?).
67
+ // It has to be decided here — `@formkit/nuxt` is set up before this module's `setup()` runs, the
68
+ // same ordering trap as the i18n locales below.
69
+ moduleDependencies: (nuxt) => ({
52
70
  "@nuxt/ui": {},
53
71
  "unocss-nuxt-ui": {},
54
- "@formkit/nuxt": {},
72
+ "@formkit/nuxt": {
73
+ defaults: formkitDefaults(nuxt.options.rootDir, nuxt.options.formkit?.configFile)
74
+ },
55
75
  "@sfxcode/nuxt-ui-formkit": {},
56
76
  "@sfxcode/nuxt-mongocamp-server": {
57
77
  defaults: {
@@ -72,7 +92,7 @@ const module$1 = defineNuxtModule({
72
92
  defaultLocale: "en"
73
93
  }
74
94
  }
75
- },
95
+ }),
76
96
  setup(options, nuxt) {
77
97
  options.serverProxyPath = (options.serverProxyPath ?? "/api/_mongocamp").replace(/\/+$/, "") || "/api/_mongocamp";
78
98
  nuxt.options.runtimeConfig.public.nuxtUiMongocampOptions = defu(
@@ -89,6 +109,7 @@ const module$1 = defineNuxtModule({
89
109
  });
90
110
  });
91
111
  for (const warning of optionWarnings(options)) consola.warn(warning);
112
+ if (options.formkitStyles) nuxt.options.css.unshift(resolve(runtimeDir, "assets/formkit.css"));
92
113
  addPlugin(resolve(runtimeDir, "plugin"));
93
114
  addComponentsDir({ path: resolve(runtimeDir, "components") });
94
115
  addImportsDir(resolve(runtimeDir, "composables"));
@@ -0,0 +1 @@
1
+ .formkit-form>*+*{margin-top:.75rem}.formkit-label{color:var(--ui-text-muted);font-size:.8125rem;font-weight:500}.formkit-help{color:var(--ui-text-dimmed);font-size:.75rem}.formkit-message{color:var(--ui-error);font-size:.75rem}.formkit-debug{font-size:.75rem;padding-top:.5rem}
@@ -77,7 +77,7 @@ loadProfile();
77
77
  </template>
78
78
  <div class="flex flex-col gap-3">
79
79
  <div>
80
- <div class="text-sm text-gray-500 dark:text-gray-400">
80
+ <div class="text-sm text-muted">
81
81
  {{ t("nuxtUiMongocamp.account.user") }}
82
82
  </div>
83
83
  <div class="text-lg font-medium">
@@ -85,7 +85,7 @@ loadProfile();
85
85
  </div>
86
86
  </div>
87
87
  <div>
88
- <div class="text-sm text-gray-500 dark:text-gray-400 mb-1">
88
+ <div class="text-sm text-muted mb-1">
89
89
  {{ t("nuxtUiMongocamp.account.role") }}
90
90
  </div>
91
91
  <UBadge
@@ -95,7 +95,7 @@ loadProfile();
95
95
  />
96
96
  </div>
97
97
  <div>
98
- <div class="text-sm text-gray-500 dark:text-gray-400 mb-1">
98
+ <div class="text-sm text-muted mb-1">
99
99
  {{ t("nuxtUiMongocamp.account.roles") }}
100
100
  </div>
101
101
  <div
@@ -168,7 +168,7 @@ loadProfile();
168
168
  v-else
169
169
  class="flex items-center justify-between gap-4"
170
170
  >
171
- <p class="text-sm text-gray-500 dark:text-gray-400">
171
+ <p class="text-sm text-muted">
172
172
  {{ t("nuxtUiMongocamp.account.regenerateWarning") }}
173
173
  </p>
174
174
  <UButton
@@ -1,6 +1,26 @@
1
1
  type __VLS_Props = {
2
2
  bucketName: string;
3
+ hideRefresh?: boolean;
3
4
  };
4
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare function init(): Promise<void>;
6
+ declare const __VLS_template: () => {
7
+ __VLS_Slots: {
8
+ toolbar?: (props: {}) => any;
9
+ };
10
+ };
11
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
12
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
13
+ refresh: typeof init;
14
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
15
+ changed: () => any;
16
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
17
+ onChanged?: (() => any) | undefined;
18
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
5
20
  declare const _default: typeof __VLS_export;
6
21
  export default _default;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -9,8 +9,10 @@ import MongocampCollectionCharts from "./MongocampCollectionCharts.vue";
9
9
  import { useMongocampQuery } from "../composables/useMongocampQuery";
10
10
  import { parseMetadataJson } from "../utils/filePreview";
11
11
  const props = defineProps({
12
- bucketName: { type: String, required: true }
12
+ bucketName: { type: String, required: true },
13
+ hideRefresh: { type: Boolean, required: false }
13
14
  });
15
+ const emit = defineEmits(["changed"]);
14
16
  const { t } = useI18n();
15
17
  const { pagination, total } = useMongocampCollection();
16
18
  const {
@@ -65,7 +67,10 @@ async function handleFiles(list) {
65
67
  }
66
68
  });
67
69
  uploadResult.value = { uploaded: result.uploaded.length, failed: result.failed };
68
- if (result.uploaded.length) await fetchFiles();
70
+ if (result.uploaded.length) {
71
+ await fetchFiles();
72
+ emit("changed");
73
+ }
69
74
  } finally {
70
75
  uploadProgress.value = null;
71
76
  }
@@ -184,6 +189,7 @@ async function handleRenameSave() {
184
189
  if (success) {
185
190
  isRenameModalOpen.value = false;
186
191
  await fetchFiles();
192
+ emit("changed");
187
193
  }
188
194
  } finally {
189
195
  renameSaving.value = false;
@@ -201,6 +207,7 @@ async function handleDeleteFile() {
201
207
  if (success) {
202
208
  isDeleteModalOpen.value = false;
203
209
  await fetchFiles();
210
+ emit("changed");
204
211
  }
205
212
  }
206
213
  function makeActionsColumn() {
@@ -258,7 +265,7 @@ const columns = computed(() => [
258
265
  {
259
266
  accessorKey: "length",
260
267
  header: ({ column }) => sortHeader(column, t("nuxtUiMongocamp.bucketFiles.columnSize")),
261
- cell: ({ row }) => h("span", formatBytes(row.original.length))
268
+ cell: ({ row }) => h("span", { class: "tabular-nums" }, formatBytes(row.original.length))
262
269
  },
263
270
  {
264
271
  accessorKey: "uploadDate",
@@ -325,6 +332,7 @@ async function init() {
325
332
  isInitializing.value = false;
326
333
  }
327
334
  watch(() => props.bucketName, init, { immediate: true });
335
+ defineExpose({ refresh: init });
328
336
  </script>
329
337
 
330
338
  <template>
@@ -352,7 +360,7 @@ watch(() => props.bucketName, init, { immediate: true });
352
360
  @input="onFilterInput"
353
361
  />
354
362
  <div class="flex items-center gap-2">
355
- <span class="text-sm text-gray-500 dark:text-gray-400 shrink-0">
363
+ <span class="text-sm text-muted shrink-0">
356
364
  {{ t("nuxtUiMongocamp.bucketFiles.filesCount", { count: total }) }}
357
365
  </span>
358
366
  <UTooltip :text="t('nuxtUiMongocamp.bucketFiles.uploadFileTooltip')">
@@ -373,7 +381,10 @@ watch(() => props.bucketName, init, { immediate: true });
373
381
  class="hidden"
374
382
  @change="handleFileSelected"
375
383
  >
376
- <UTooltip :text="t('nuxtUiMongocamp.bucketFiles.reloadTooltip')">
384
+ <UTooltip
385
+ v-if="!hideRefresh"
386
+ :text="t('nuxtUiMongocamp.bucketFiles.reloadTooltip')"
387
+ >
377
388
  <UButton
378
389
  icon="i-lucide-refresh-cw"
379
390
  color="neutral"
@@ -383,6 +394,7 @@ watch(() => props.bucketName, init, { immediate: true });
383
394
  @click="init"
384
395
  />
385
396
  </UTooltip>
397
+ <slot name="toolbar" />
386
398
  <UPagination
387
399
  v-model:page="pagination.pageIndex"
388
400
  :total="total"
@@ -1,6 +1,26 @@
1
1
  type __VLS_Props = {
2
2
  bucketName: string;
3
+ hideRefresh?: boolean;
3
4
  };
4
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare function init(): Promise<void>;
6
+ declare const __VLS_template: () => {
7
+ __VLS_Slots: {
8
+ toolbar?: (props: {}) => any;
9
+ };
10
+ };
11
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
12
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
13
+ refresh: typeof init;
14
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
15
+ changed: () => any;
16
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
17
+ onChanged?: (() => any) | undefined;
18
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
5
20
  declare const _default: typeof __VLS_export;
6
21
  export default _default;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -4,12 +4,32 @@ type __VLS_Props = {
4
4
  aggregatePath?: string;
5
5
  persistState?: boolean;
6
6
  stateKey?: string;
7
+ hideRefresh?: boolean;
7
8
  };
8
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
9
- infoPath: string;
9
+ declare function init(): Promise<void>;
10
+ declare const __VLS_template: () => {
11
+ __VLS_Slots: {
12
+ toolbar?: (props: {}) => any;
13
+ };
14
+ };
15
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
16
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
17
+ refresh: typeof init;
18
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ changed: () => any;
20
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
21
+ onChanged?: (() => any) | undefined;
22
+ }>, {
23
+ hideRefresh: boolean;
10
24
  aggregatePath: string;
11
25
  persistState: boolean;
12
26
  stateKey: string;
13
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
29
  declare const _default: typeof __VLS_export;
15
30
  export default _default;
31
+ type __VLS_WithSlots<T, S> = T & {
32
+ new (): {
33
+ $slots: S;
34
+ };
35
+ };
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { computed, h, ref, resolveComponent, watch } from "vue";
3
- import { useI18n, useMongocampClientApi, useMongocampError, useMongocampPermissions, useMongocampRoles, useMongocampSchema, useToast } from "#imports";
3
+ import { useI18n, useMongocampClientApi, useMongocampError, useMongocampPermissions, useMongocampRoles, useMongocampSchema, useToast, useMongocampPaths } from "#imports";
4
4
  import useMongocampCollection from "../composables/useMongocampCollection";
5
5
  import { useMongocampBucket } from "../composables/useMongocampBucket";
6
6
  import { useMongocampIndex } from "../composables/useMongocampIndex";
@@ -30,12 +30,15 @@ import MongocampCollectionCharts from "./MongocampCollectionCharts.vue";
30
30
  import { isFilterTooLong } from "../utils/requestLimits";
31
31
  const props = defineProps({
32
32
  collectionName: { type: String, required: true },
33
- infoPath: { type: String, required: false, default: "/secured/admin/collections" },
33
+ infoPath: { type: String, required: false },
34
34
  aggregatePath: { type: String, required: false, default: "" },
35
35
  persistState: { type: Boolean, required: false, default: true },
36
- stateKey: { type: String, required: false, default: "" }
36
+ stateKey: { type: String, required: false, default: "" },
37
+ hideRefresh: { type: Boolean, required: false, default: false }
37
38
  });
39
+ const emit = defineEmits(["changed"]);
38
40
  const { t } = useI18n();
41
+ const paths = useMongocampPaths();
39
42
  const { documentApi } = useMongocampClientApi();
40
43
  const { pagination, total } = useMongocampCollection();
41
44
  const { state: persisted } = useMongocampPersistedState(
@@ -64,7 +67,10 @@ async function handleFileSelected(event) {
64
67
  input.value = "";
65
68
  if (!file) return;
66
69
  const success = await uploadFile(props.collectionName, file);
67
- if (success) await fetchDocuments();
70
+ if (success) {
71
+ await fetchDocuments();
72
+ emit("changed");
73
+ }
68
74
  }
69
75
  const UButton = resolveComponent("UButton");
70
76
  const UTooltip = resolveComponent("UTooltip");
@@ -182,6 +188,7 @@ async function handleSave() {
182
188
  if (result.matchedCount === 0) throw new Error(t("nuxtUiMongocamp.collectionData.documentGone"));
183
189
  isEditModalOpen.value = false;
184
190
  await fetchDocuments();
191
+ emit("changed");
185
192
  return;
186
193
  }
187
194
  const body = { ...payload };
@@ -190,6 +197,7 @@ async function handleSave() {
190
197
  }
191
198
  isEditModalOpen.value = false;
192
199
  await fetchDocuments();
200
+ emit("changed");
193
201
  } catch (e) {
194
202
  editError.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.collectionData.errorSave");
195
203
  }
@@ -201,6 +209,7 @@ async function handleDelete() {
201
209
  await documentApi._delete({ collectionName: props.collectionName, documentId: docToDelete.value });
202
210
  isDeleteModalOpen.value = false;
203
211
  await fetchDocuments();
212
+ emit("changed");
204
213
  } catch (e) {
205
214
  deleteError.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.collectionData.errorDelete");
206
215
  }
@@ -283,7 +292,7 @@ async function indexField(key, ascending) {
283
292
  title: t("nuxtUiMongocamp.collectionData.indexCreatedTitle"),
284
293
  description: t("nuxtUiMongocamp.collectionData.indexCreatedDescription", { name: created.name, collection: props.collectionName }),
285
294
  color: "success",
286
- actions: [{ label: t("nuxtUiMongocamp.collectionData.viewIndexes"), to: `${props.infoPath}/${props.collectionName}` }]
295
+ actions: [{ label: t("nuxtUiMongocamp.collectionData.viewIndexes"), to: `${props.infoPath ?? paths.collections}/${props.collectionName}` }]
287
296
  });
288
297
  } catch (e) {
289
298
  toast.add({ title: t("nuxtUiMongocamp.collectionData.indexFailedTitle", { field: key }), description: await indexFailureMessage(e), color: "error" });
@@ -552,6 +561,7 @@ async function handleBulkDelete() {
552
561
  const deleted = await deleteByFilter(props.collectionName, filter);
553
562
  clearMatching();
554
563
  await fetchDocuments();
564
+ emit("changed");
555
565
  toast.add({ title: t("nuxtUiMongocamp.bulk.matchingDeleted", { deleted, total: count }), color: "success" });
556
566
  return;
557
567
  }
@@ -571,6 +581,7 @@ async function handleBulkDelete() {
571
581
  }
572
582
  );
573
583
  await fetchDocuments();
584
+ emit("changed");
574
585
  if (failed.length > 0) {
575
586
  rowSelection.value = Object.fromEntries(failed.map((f) => [f.item, true]));
576
587
  bulkError.value = t("nuxtUiMongocamp.bulk.partialFailure", { failed: failed.length, total: ids.length, reason: describeError(failed[0].error).message });
@@ -604,6 +615,7 @@ async function handleBulkEdit(edit) {
604
615
  const { modified } = await updateByFilter(props.collectionName, filter, document);
605
616
  clearMatching();
606
617
  await fetchDocuments();
618
+ emit("changed");
607
619
  toast.add({ title: t("nuxtUiMongocamp.bulk.matchingUpdated", { updated: modified, total: count }), color: "success" });
608
620
  return;
609
621
  }
@@ -616,6 +628,7 @@ async function handleBulkEdit(edit) {
616
628
  })
617
629
  );
618
630
  await fetchDocuments();
631
+ emit("changed");
619
632
  if (failed.length > 0) {
620
633
  const failedIds = failed.flatMap((f) => f.ids);
621
634
  const onScreen = new Set(documents.value.map((row) => getDocId(row)));
@@ -765,6 +778,10 @@ async function loadDistinctSuggestions(field) {
765
778
  if (cache === distinctCache && collection === props.collectionName) cache.set(field, suggestions);
766
779
  return suggestions;
767
780
  }
781
+ async function onImported() {
782
+ await init();
783
+ emit("changed");
784
+ }
768
785
  async function init() {
769
786
  distinctCache = /* @__PURE__ */ new Map();
770
787
  isInitializing.value = true;
@@ -796,6 +813,7 @@ watch(columnVisibility, (visibility) => {
796
813
  if (!isInitializing.value) persisted.value = { ...persisted.value, hidden: Object.keys(visibility).filter((k) => visibility[k] === false) };
797
814
  }, { deep: true });
798
815
  watch(() => props.collectionName, init, { immediate: true });
816
+ defineExpose({ refresh: init });
799
817
  </script>
800
818
 
801
819
  <template>
@@ -811,7 +829,7 @@ watch(() => props.collectionName, init, { immediate: true });
811
829
  @input="onFilterInput"
812
830
  />
813
831
  <div class="flex flex-wrap items-center gap-2">
814
- <span class="text-sm text-gray-500 dark:text-gray-400 shrink-0">
832
+ <span class="text-sm text-muted shrink-0">
815
833
  {{ t("nuxtUiMongocamp.collectionData.documentsCount", { count: total }) }}
816
834
  </span>
817
835
  <UTooltip
@@ -850,9 +868,12 @@ watch(() => props.collectionName, init, { immediate: true });
850
868
  <MongocampImport
851
869
  v-if="writable && !isBucketCollection(collectionName)"
852
870
  :collection-name="collectionName"
853
- @imported="init"
871
+ @imported="onImported"
854
872
  />
855
- <UTooltip :text="t('nuxtUiMongocamp.collectionData.reloadTooltip')">
873
+ <UTooltip
874
+ v-if="!hideRefresh"
875
+ :text="t('nuxtUiMongocamp.collectionData.reloadTooltip')"
876
+ >
856
877
  <UButton
857
878
  icon="i-lucide-refresh-cw"
858
879
  color="neutral"
@@ -862,6 +883,7 @@ watch(() => props.collectionName, init, { immediate: true });
862
883
  @click="init"
863
884
  />
864
885
  </UTooltip>
886
+ <slot name="toolbar" />
865
887
  <div
866
888
  class="inline-flex rounded-md border border-default p-0.5"
867
889
  role="group"
@@ -1138,7 +1160,7 @@ watch(() => props.collectionName, init, { immediate: true });
1138
1160
  <textarea
1139
1161
  v-else
1140
1162
  v-model="editJson"
1141
- class="w-full h-80 font-mono text-xs p-2 border rounded bg-gray-50 dark:bg-gray-900 border-gray-200 dark:border-gray-700 focus:outline-none resize-y"
1163
+ class="w-full h-80 font-mono text-xs p-2 border rounded bg-muted border-default focus:outline-none resize-y"
1142
1164
  spellcheck="false"
1143
1165
  />
1144
1166
  <p
@@ -4,12 +4,32 @@ type __VLS_Props = {
4
4
  aggregatePath?: string;
5
5
  persistState?: boolean;
6
6
  stateKey?: string;
7
+ hideRefresh?: boolean;
7
8
  };
8
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
9
- infoPath: string;
9
+ declare function init(): Promise<void>;
10
+ declare const __VLS_template: () => {
11
+ __VLS_Slots: {
12
+ toolbar?: (props: {}) => any;
13
+ };
14
+ };
15
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
16
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
17
+ refresh: typeof init;
18
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ changed: () => any;
20
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
21
+ onChanged?: (() => any) | undefined;
22
+ }>, {
23
+ hideRefresh: boolean;
10
24
  aggregatePath: string;
11
25
  persistState: boolean;
12
26
  stateKey: string;
13
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
29
  declare const _default: typeof __VLS_export;
15
30
  export default _default;
31
+ type __VLS_WithSlots<T, S> = T & {
32
+ new (): {
33
+ $slots: S;
34
+ };
35
+ };
@@ -236,50 +236,50 @@ async function refreshInfo() {
236
236
  class="grid grid-cols-2 gap-3 sm:grid-cols-3"
237
237
  >
238
238
  <UCard>
239
- <div class="text-sm text-gray-500 dark:text-gray-400">
239
+ <div class="text-sm text-muted">
240
240
  {{ t("nuxtUiMongocamp.collectionInfos.documents") }}
241
241
  </div>
242
- <div class="text-2xl font-semibold">
242
+ <div class="tabular-nums text-2xl font-semibold">
243
243
  {{ info.count }}
244
244
  </div>
245
245
  </UCard>
246
246
  <UCard>
247
- <div class="text-sm text-gray-500 dark:text-gray-400">
247
+ <div class="text-sm text-muted">
248
248
  {{ t("nuxtUiMongocamp.collectionInfos.dataSize") }}
249
249
  </div>
250
- <div class="text-2xl font-semibold">
250
+ <div class="tabular-nums text-2xl font-semibold">
251
251
  {{ Math.round(info.size / 1024) }} KB
252
252
  </div>
253
253
  </UCard>
254
254
  <UCard>
255
- <div class="text-sm text-gray-500 dark:text-gray-400">
255
+ <div class="text-sm text-muted">
256
256
  {{ t("nuxtUiMongocamp.collectionInfos.storageSize") }}
257
257
  </div>
258
- <div class="text-2xl font-semibold">
258
+ <div class="tabular-nums text-2xl font-semibold">
259
259
  {{ Math.round(info.storageSize / 1024) }} KB
260
260
  </div>
261
261
  </UCard>
262
262
  <UCard>
263
- <div class="text-sm text-gray-500 dark:text-gray-400">
263
+ <div class="text-sm text-muted">
264
264
  {{ t("nuxtUiMongocamp.collectionInfos.avgDocSize") }}
265
265
  </div>
266
- <div class="text-2xl font-semibold">
266
+ <div class="tabular-nums text-2xl font-semibold">
267
267
  {{ Math.round(info.avgObjSize) }} B
268
268
  </div>
269
269
  </UCard>
270
270
  <UCard>
271
- <div class="text-sm text-gray-500 dark:text-gray-400">
271
+ <div class="text-sm text-muted">
272
272
  {{ t("nuxtUiMongocamp.collectionInfos.indexes") }}
273
273
  </div>
274
- <div class="text-2xl font-semibold">
274
+ <div class="tabular-nums text-2xl font-semibold">
275
275
  {{ info.nindexes }}
276
276
  </div>
277
277
  </UCard>
278
278
  <UCard>
279
- <div class="text-sm text-gray-500 dark:text-gray-400">
279
+ <div class="text-sm text-muted">
280
280
  {{ t("nuxtUiMongocamp.collectionInfos.indexSize") }}
281
281
  </div>
282
- <div class="text-2xl font-semibold">
282
+ <div class="tabular-nums text-2xl font-semibold">
283
283
  {{ Math.round(info.totalIndexSize / 1024) }} KB
284
284
  </div>
285
285
  </UCard>
@@ -3,13 +3,31 @@ type __VLS_Props = {
3
3
  dataPath?: string;
4
4
  bucketFilesPath?: string;
5
5
  canManage?: boolean;
6
+ hideHeading?: boolean;
7
+ hideRefresh?: boolean;
6
8
  };
7
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ declare function fetchCollections(): Promise<void>;
10
+ declare const __VLS_template: () => {
11
+ __VLS_Slots: {
12
+ toolbar?: (props: {}) => any;
13
+ };
14
+ };
15
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
16
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
17
+ refresh: typeof fetchCollections;
18
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
19
  changed: () => any;
9
20
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
10
21
  onChanged?: (() => any) | undefined;
11
22
  }>, {
12
23
  canManage: boolean;
24
+ hideHeading: boolean;
13
25
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
27
  declare const _default: typeof __VLS_export;
15
28
  export default _default;
29
+ type __VLS_WithSlots<T, S> = T & {
30
+ new (): {
31
+ $slots: S;
32
+ };
33
+ };