@sfxcode/nuxt-ui-mongocamp 1.1.4 → 1.2.1
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.
- package/README.md +8 -4
- package/dist/module.d.mts +22 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +41 -5
- package/dist/runtime/components/MongocampAccount.vue +21 -20
- package/dist/runtime/components/MongocampBucketFiles.vue +34 -32
- package/dist/runtime/components/MongocampCollectionData.vue +36 -35
- package/dist/runtime/components/MongocampCollectionInfos.vue +37 -36
- package/dist/runtime/components/MongocampCollections.vue +30 -29
- package/dist/runtime/components/MongocampDatabases.vue +13 -12
- package/dist/runtime/components/MongocampJobs.vue +43 -45
- package/dist/runtime/components/MongocampLogin.d.vue.ts +4 -1
- package/dist/runtime/components/MongocampLogin.vue +13 -9
- package/dist/runtime/components/MongocampLogin.vue.d.ts +4 -1
- package/dist/runtime/components/MongocampRoleGrants.vue +30 -28
- package/dist/runtime/components/MongocampRoles.vue +30 -31
- package/dist/runtime/components/MongocampUsers.vue +35 -36
- package/dist/runtime/components/MongocampVersion.vue +3 -1
- package/dist/runtime/composables/useMongocampAccount.js +6 -5
- package/dist/runtime/composables/useMongocampAdmin.js +2 -2
- package/dist/runtime/composables/useMongocampBucket.js +20 -19
- package/dist/runtime/composables/useMongocampClientApi.d.ts +13 -0
- package/dist/runtime/composables/useMongocampClientApi.js +8 -0
- package/dist/runtime/composables/useMongocampIndex.js +2 -2
- package/dist/runtime/composables/useMongocampJobs.js +2 -2
- package/dist/runtime/composables/useMongocampProxyApi.d.ts +13 -0
- package/dist/runtime/composables/useMongocampProxyApi.js +9 -0
- package/dist/runtime/composables/useMongocampRoles.d.ts +2 -0
- package/dist/runtime/composables/useMongocampRoles.js +4 -2
- package/dist/runtime/composables/useMongocampSystem.js +2 -2
- package/dist/runtime/locales/de.json +265 -0
- package/dist/runtime/locales/en.json +265 -0
- package/dist/runtime/plugin.js +8 -8
- package/dist/runtime/server/handlers/mongocampProxy.d.ts +2 -0
- package/dist/runtime/server/handlers/mongocampProxy.js +45 -0
- package/dist/runtime/utils/createProxyMongocampApis.d.ts +15 -0
- package/dist/runtime/utils/createProxyMongocampApis.js +28 -0
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -222,7 +222,7 @@ Route protection is opt-in and config-driven via `useMongocampRoles()`. Set `use
|
|
|
222
222
|
| Matches `adminRouteParts` | User must be an admin |
|
|
223
223
|
| `/logout` | Calls `logout()` |
|
|
224
224
|
|
|
225
|
-
On any unmet requirement
|
|
225
|
+
On any unmet requirement, the middleware redirects to `notAllowedPath` (default `'/'`); `/logout` redirects to the separate `logoutRedirectPath` instead (also default `'/'`). Both are always themselves allowed, so neither can ever cause a redirect loop.
|
|
226
226
|
|
|
227
227
|
## Runtime Plugin
|
|
228
228
|
|
|
@@ -242,23 +242,27 @@ The module's own config key is `nuxtUiMongocamp` — it configures the route mid
|
|
|
242
242
|
nuxtUiMongocamp: {
|
|
243
243
|
useGlobalAuthMiddleware: true, // default: false
|
|
244
244
|
notAllowedPath: '/login', // default: '/'
|
|
245
|
+
logoutRedirectPath: '/', // default: '/'
|
|
245
246
|
managerRoles: ['support'], // default: []
|
|
246
247
|
securedRouteParts: ['/secured/**'], // default: []
|
|
247
248
|
managementRouteParts: ['/secured/manage/**'], // default: []
|
|
248
249
|
adminRouteParts: ['/secured/admin/**'], // default: []
|
|
250
|
+
useServerProxy: false, // default: false — see Server Proxy Auth below
|
|
251
|
+
serverProxyPath: '/api/_mongocamp', // default shown
|
|
249
252
|
}
|
|
250
253
|
```
|
|
251
254
|
|
|
252
|
-
See [Configuration](https://sfxcode.github.io/nuxt-ui-mongocamp/guide/configuration) for details on each option.
|
|
255
|
+
See [Configuration](https://sfxcode.github.io/nuxt-ui-mongocamp/guide/configuration) for details on each option, and [Server Proxy Auth](https://sfxcode.github.io/nuxt-ui-mongocamp/guide/server-proxy-auth) for the api-key-only, no-login mode `useServerProxy` enables.
|
|
253
256
|
|
|
254
257
|
The MongoCamp server is configured separately, under the `mongocamp` key (provided by `@sfxcode/nuxt-mongocamp-server`):
|
|
255
258
|
|
|
256
259
|
```ts
|
|
257
260
|
mongocamp: {
|
|
258
261
|
url: 'https://your-mongocamp-server',
|
|
262
|
+
apiKey: process.env.MONGOCAMP_API_KEY, // optional, server-side only — required for server proxy auth mode
|
|
259
263
|
paginationSize: 500, // default: 500
|
|
260
264
|
refreshToken: true, // default: true
|
|
261
|
-
|
|
265
|
+
tokenRefreshInterval: 5000, // ms, default: 5000
|
|
262
266
|
}
|
|
263
267
|
```
|
|
264
268
|
|
|
@@ -288,7 +292,7 @@ pnpm run test:types
|
|
|
288
292
|
pnpm run prepack
|
|
289
293
|
```
|
|
290
294
|
|
|
291
|
-
The playground reads `playground/.env` for `MONGOCAMP_URL`, `MONGOCAMP_ADMIN_USER`, and `MONGOCAMP_ADMIN_PASSWORD`.
|
|
295
|
+
The playground reads `playground/.env` for `MONGOCAMP_URL`, `MONGOCAMP_ADMIN_USER`, and `MONGOCAMP_ADMIN_PASSWORD`. Optional vars demo [server proxy auth mode](https://sfxcode.github.io/nuxt-ui-mongocamp/guide/server-proxy-auth): `MONGOCAMP_API_KEY`, `MONGOCAMP_USE_SERVER_PROXY=true`, and `MONGOCAMP_PROXY_SHARED_SECRET` (activates the example guard hook in `playground/server/plugins/mongocamp-proxy-guard.ts`).
|
|
292
296
|
|
|
293
297
|
## Documentation
|
|
294
298
|
|
package/dist/module.d.mts
CHANGED
|
@@ -8,6 +8,16 @@ interface ModuleOptions {
|
|
|
8
8
|
* Always treated as allowed by the middleware itself, so it can never cause a redirect loop.
|
|
9
9
|
*/
|
|
10
10
|
notAllowedPath?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Path the global auth middleware navigates to after `/logout` — e.g. '/goodbye'.
|
|
13
|
+
* Always treated as allowed by the middleware itself, so it can never cause a redirect loop.
|
|
14
|
+
*/
|
|
15
|
+
logoutRedirectPath?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Path that triggers logout when navigated to — e.g. '/signout'. Always treated as allowed
|
|
18
|
+
* by the middleware itself, so it can never cause a redirect loop.
|
|
19
|
+
*/
|
|
20
|
+
logoutPath?: string;
|
|
11
21
|
/**
|
|
12
22
|
* Roles with management access
|
|
13
23
|
*/
|
|
@@ -24,6 +34,18 @@ interface ModuleOptions {
|
|
|
24
34
|
* Routes that can only be accessed by admin users
|
|
25
35
|
*/
|
|
26
36
|
adminRouteParts: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Opt-in "server proxy" auth mode: the browser calls a local Nuxt server
|
|
39
|
+
* route instead of MongoCamp directly, which forwards the request with
|
|
40
|
+
* the MongoCamp api key (the dependency's own `mongocamp.apiKey` option)
|
|
41
|
+
* injected server-side. There is no login/session in this mode, so it is
|
|
42
|
+
* not meant to be combined with `useGlobalAuthMiddleware`'s route protection.
|
|
43
|
+
*/
|
|
44
|
+
useServerProxy?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Local route prefix the proxy listens on when `useServerProxy` is enabled.
|
|
47
|
+
*/
|
|
48
|
+
serverProxyPath?: string;
|
|
27
49
|
}
|
|
28
50
|
interface ModulePublicRuntimeConfig {
|
|
29
51
|
nuxtUiMongocampOptions: ModuleOptions;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createResolver, defineNuxtModule, addPlugin, addComponentsDir, addImportsDir, addServerHandler } from '@nuxt/kit';
|
|
2
2
|
import { defu } from 'defu';
|
|
3
|
+
import { consola } from 'consola';
|
|
3
4
|
|
|
5
|
+
const { resolve } = createResolver(import.meta.url);
|
|
6
|
+
const runtimeDir = resolve("./runtime");
|
|
4
7
|
const module$1 = defineNuxtModule({
|
|
5
8
|
meta: {
|
|
6
9
|
name: "nuxt-ui-mongocamp",
|
|
@@ -13,10 +16,14 @@ const module$1 = defineNuxtModule({
|
|
|
13
16
|
defaults: {
|
|
14
17
|
useGlobalAuthMiddleware: false,
|
|
15
18
|
notAllowedPath: "/",
|
|
19
|
+
logoutRedirectPath: "/",
|
|
20
|
+
logoutPath: "/logout",
|
|
16
21
|
managerRoles: [],
|
|
17
22
|
securedRouteParts: [],
|
|
18
23
|
managementRouteParts: [],
|
|
19
|
-
adminRouteParts: []
|
|
24
|
+
adminRouteParts: [],
|
|
25
|
+
useServerProxy: false,
|
|
26
|
+
serverProxyPath: "/api/_mongocamp"
|
|
20
27
|
},
|
|
21
28
|
moduleDependencies: {
|
|
22
29
|
"@nuxt/ui": {},
|
|
@@ -27,20 +34,49 @@ const module$1 = defineNuxtModule({
|
|
|
27
34
|
defaults: {
|
|
28
35
|
paginationSize: 500,
|
|
29
36
|
refreshToken: true,
|
|
30
|
-
|
|
37
|
+
tokenRefreshInterval: 5e3
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
// English (default) and German translations for every string this module's own
|
|
41
|
+
// components render. Registered as a moduleDependency (like @nuxt/ui) rather than left
|
|
42
|
+
// optional, since the components ship no non-translated fallback markup. Only flat,
|
|
43
|
+
// top-level options (like `defaultLocale`) actually merge through this `defaults` field —
|
|
44
|
+
// `locales`/`langDir` need the `i18n:registerModule` hook in setup() below instead, since
|
|
45
|
+
// they're resolved through @nuxtjs/i18n's own multi-layer locale-merging logic, not a
|
|
46
|
+
// plain defu merge.
|
|
47
|
+
"@nuxtjs/i18n": {
|
|
48
|
+
defaults: {
|
|
49
|
+
defaultLocale: "en"
|
|
31
50
|
}
|
|
32
51
|
}
|
|
33
52
|
},
|
|
34
53
|
setup(options, nuxt) {
|
|
54
|
+
options.serverProxyPath = (options.serverProxyPath ?? "/api/_mongocamp").replace(/\/+$/, "") || "/api/_mongocamp";
|
|
35
55
|
nuxt.options.runtimeConfig.public.nuxtUiMongocampOptions = defu(
|
|
36
56
|
nuxt.options.runtimeConfig.public.nuxtUiMongocampOptions,
|
|
37
57
|
options
|
|
38
58
|
);
|
|
39
|
-
|
|
40
|
-
|
|
59
|
+
nuxt.hook("i18n:registerModule", (register) => {
|
|
60
|
+
register({
|
|
61
|
+
langDir: resolve(runtimeDir, "locales"),
|
|
62
|
+
locales: [
|
|
63
|
+
{ code: "en", file: "en.json" },
|
|
64
|
+
{ code: "de", file: "de.json" }
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
if (options.useServerProxy && options.useGlobalAuthMiddleware) {
|
|
69
|
+
consola.warn(
|
|
70
|
+
"[nuxt-ui-mongocamp] `useServerProxy` and `useGlobalAuthMiddleware` are both enabled. Server proxy mode has no login/session, so `isLoggedIn`/`isAdmin`/`isManager` can never become true \u2014 every route matched by `securedRouteParts`, `managementRouteParts`, or `adminRouteParts` will be permanently unreachable."
|
|
71
|
+
);
|
|
72
|
+
}
|
|
41
73
|
addPlugin(resolve(runtimeDir, "plugin"));
|
|
42
74
|
addComponentsDir({ path: resolve(runtimeDir, "components") });
|
|
43
75
|
addImportsDir(resolve(runtimeDir, "composables"));
|
|
76
|
+
addServerHandler({
|
|
77
|
+
route: `${options.serverProxyPath}/**`,
|
|
78
|
+
handler: resolve(runtimeDir, "server/handlers/mongocampProxy")
|
|
79
|
+
});
|
|
44
80
|
}
|
|
45
81
|
});
|
|
46
82
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { reactive, ref, resolveComponent } from "vue";
|
|
3
|
-
import { useMongocampAccount, useToast } from "#imports";
|
|
3
|
+
import { useI18n, useMongocampAccount, useToast } from "#imports";
|
|
4
|
+
const { t } = useI18n();
|
|
4
5
|
const { fetchProfile, changePassword, regenerateApiKey } = useMongocampAccount();
|
|
5
6
|
const toast = useToast();
|
|
6
7
|
const UBadge = resolveComponent("UBadge");
|
|
@@ -19,7 +20,7 @@ const passwordSchema = reactive([
|
|
|
19
20
|
{
|
|
20
21
|
$formkit: "nuxtUIInput",
|
|
21
22
|
name: "password",
|
|
22
|
-
label: "
|
|
23
|
+
label: t("nuxtUiMongocamp.account.newPassword"),
|
|
23
24
|
inputType: "password",
|
|
24
25
|
validation: "required|length:3"
|
|
25
26
|
}
|
|
@@ -45,7 +46,7 @@ async function handleRegenerateApiKey() {
|
|
|
45
46
|
async function copyApiKey() {
|
|
46
47
|
if (!newApiKey.value) return;
|
|
47
48
|
await navigator.clipboard.writeText(newApiKey.value);
|
|
48
|
-
toast.add({ title: "
|
|
49
|
+
toast.add({ title: t("nuxtUiMongocamp.account.copiedTitle"), description: t("nuxtUiMongocamp.account.copiedDescription"), color: "success" });
|
|
49
50
|
}
|
|
50
51
|
function dismissApiKey() {
|
|
51
52
|
newApiKey.value = null;
|
|
@@ -62,12 +63,12 @@ loadProfile();
|
|
|
62
63
|
|
|
63
64
|
<UCard v-else-if="profile">
|
|
64
65
|
<template #header>
|
|
65
|
-
<span class="font-semibold">
|
|
66
|
+
<span class="font-semibold">{{ t("nuxtUiMongocamp.account.heading") }}</span>
|
|
66
67
|
</template>
|
|
67
68
|
<div class="flex flex-col gap-3">
|
|
68
69
|
<div>
|
|
69
70
|
<div class="text-sm text-gray-500 dark:text-gray-400">
|
|
70
|
-
|
|
71
|
+
{{ t("nuxtUiMongocamp.account.user") }}
|
|
71
72
|
</div>
|
|
72
73
|
<div class="text-lg font-medium">
|
|
73
74
|
{{ profile.user }}
|
|
@@ -75,17 +76,17 @@ loadProfile();
|
|
|
75
76
|
</div>
|
|
76
77
|
<div>
|
|
77
78
|
<div class="text-sm text-gray-500 dark:text-gray-400 mb-1">
|
|
78
|
-
|
|
79
|
+
{{ t("nuxtUiMongocamp.account.role") }}
|
|
79
80
|
</div>
|
|
80
81
|
<UBadge
|
|
81
|
-
:label="profile.isAdmin ? '
|
|
82
|
+
:label="profile.isAdmin ? t('nuxtUiMongocamp.common.admin') : t('nuxtUiMongocamp.common.standard')"
|
|
82
83
|
:color="profile.isAdmin ? 'error' : 'neutral'"
|
|
83
84
|
variant="subtle"
|
|
84
85
|
/>
|
|
85
86
|
</div>
|
|
86
87
|
<div>
|
|
87
88
|
<div class="text-sm text-gray-500 dark:text-gray-400 mb-1">
|
|
88
|
-
|
|
89
|
+
{{ t("nuxtUiMongocamp.account.roles") }}
|
|
89
90
|
</div>
|
|
90
91
|
<div
|
|
91
92
|
v-if="profile.roles?.length"
|
|
@@ -109,12 +110,12 @@ loadProfile();
|
|
|
109
110
|
|
|
110
111
|
<UCard>
|
|
111
112
|
<template #header>
|
|
112
|
-
<span class="font-semibold">
|
|
113
|
+
<span class="font-semibold">{{ t("nuxtUiMongocamp.account.changePasswordHeading") }}</span>
|
|
113
114
|
</template>
|
|
114
115
|
<FUDataEdit
|
|
115
116
|
:data="passwordData"
|
|
116
117
|
:schema="passwordSchema"
|
|
117
|
-
submit-label="
|
|
118
|
+
:submit-label="t('nuxtUiMongocamp.account.changePassword')"
|
|
118
119
|
submit-icon="i-lucide-save"
|
|
119
120
|
@data-saved="handleChangePassword"
|
|
120
121
|
/>
|
|
@@ -122,14 +123,14 @@ loadProfile();
|
|
|
122
123
|
|
|
123
124
|
<UCard>
|
|
124
125
|
<template #header>
|
|
125
|
-
<span class="font-semibold">
|
|
126
|
+
<span class="font-semibold">{{ t("nuxtUiMongocamp.account.apiKeyHeading") }}</span>
|
|
126
127
|
</template>
|
|
127
128
|
<div
|
|
128
129
|
v-if="newApiKey"
|
|
129
130
|
class="flex flex-col gap-2"
|
|
130
131
|
>
|
|
131
132
|
<p class="text-sm text-warning-500">
|
|
132
|
-
|
|
133
|
+
{{ t("nuxtUiMongocamp.account.apiKeyOnceWarning") }}
|
|
133
134
|
</p>
|
|
134
135
|
<div class="flex items-center gap-2">
|
|
135
136
|
<UInput
|
|
@@ -139,14 +140,14 @@ loadProfile();
|
|
|
139
140
|
/>
|
|
140
141
|
<UButton
|
|
141
142
|
icon="i-lucide-copy"
|
|
142
|
-
label="
|
|
143
|
+
:label="t('nuxtUiMongocamp.common.copy')"
|
|
143
144
|
color="neutral"
|
|
144
145
|
variant="subtle"
|
|
145
146
|
@click="copyApiKey"
|
|
146
147
|
/>
|
|
147
148
|
</div>
|
|
148
149
|
<UButton
|
|
149
|
-
label="
|
|
150
|
+
:label="t('nuxtUiMongocamp.common.dismiss')"
|
|
150
151
|
color="neutral"
|
|
151
152
|
variant="ghost"
|
|
152
153
|
class="self-start"
|
|
@@ -158,10 +159,10 @@ loadProfile();
|
|
|
158
159
|
class="flex items-center justify-between gap-4"
|
|
159
160
|
>
|
|
160
161
|
<p class="text-sm text-gray-500 dark:text-gray-400">
|
|
161
|
-
|
|
162
|
+
{{ t("nuxtUiMongocamp.account.regenerateWarning") }}
|
|
162
163
|
</p>
|
|
163
164
|
<UButton
|
|
164
|
-
label="
|
|
165
|
+
:label="t('nuxtUiMongocamp.account.regenerateApiKey')"
|
|
165
166
|
color="error"
|
|
166
167
|
variant="subtle"
|
|
167
168
|
icon="i-lucide-key-round"
|
|
@@ -172,21 +173,21 @@ loadProfile();
|
|
|
172
173
|
|
|
173
174
|
<UModal
|
|
174
175
|
v-model:open="isRegenerateModalOpen"
|
|
175
|
-
title="
|
|
176
|
+
:title="t('nuxtUiMongocamp.account.regenerateApiKey')"
|
|
176
177
|
:ui="{ footer: 'justify-end' }"
|
|
177
178
|
>
|
|
178
179
|
<template #body>
|
|
179
|
-
<p>
|
|
180
|
+
<p>{{ t("nuxtUiMongocamp.account.confirmRegenerate") }}</p>
|
|
180
181
|
</template>
|
|
181
182
|
<template #footer>
|
|
182
183
|
<UButton
|
|
183
|
-
label="
|
|
184
|
+
:label="t('nuxtUiMongocamp.common.cancel')"
|
|
184
185
|
color="neutral"
|
|
185
186
|
variant="ghost"
|
|
186
187
|
@click="closeRegenerateModal"
|
|
187
188
|
/>
|
|
188
189
|
<UButton
|
|
189
|
-
label="
|
|
190
|
+
:label="t('nuxtUiMongocamp.account.regenerate')"
|
|
190
191
|
color="error"
|
|
191
192
|
icon="i-lucide-key-round"
|
|
192
193
|
@click="handleRegenerateApiKey"
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { h, reactive, ref, resolveComponent, watch } from "vue";
|
|
3
|
+
import { useI18n } from "#imports";
|
|
3
4
|
import useMongocampCollection from "../composables/useMongocampCollection";
|
|
4
5
|
import { useMongocampBucket } from "../composables/useMongocampBucket";
|
|
5
6
|
import { useMongocampQuery } from "../composables/useMongocampQuery";
|
|
6
7
|
const props = defineProps({
|
|
7
8
|
bucketName: { type: String, required: true }
|
|
8
9
|
});
|
|
10
|
+
const { t } = useI18n();
|
|
9
11
|
const { pagination, total } = useMongocampCollection();
|
|
10
12
|
const {
|
|
11
13
|
listFiles,
|
|
@@ -74,13 +76,13 @@ function makeMetadataCell() {
|
|
|
74
76
|
const metadata = row.original.metadata ?? {};
|
|
75
77
|
const keys = Object.keys(metadata);
|
|
76
78
|
if (keys.length === 0) return h("span", { class: "text-dimmed" }, "\u2014");
|
|
77
|
-
return withTooltip("
|
|
79
|
+
return withTooltip(t("nuxtUiMongocamp.bucketFiles.viewMetadataTooltip"), h(UButton, {
|
|
78
80
|
"icon": "i-lucide-braces",
|
|
79
81
|
"color": "neutral",
|
|
80
82
|
"variant": "ghost",
|
|
81
83
|
"size": "xs",
|
|
82
|
-
"label":
|
|
83
|
-
"aria-label": "
|
|
84
|
+
"label": keys.length === 1 ? t("nuxtUiMongocamp.bucketFiles.keyCount") : t("nuxtUiMongocamp.bucketFiles.keysCount", { count: keys.length }),
|
|
85
|
+
"aria-label": t("nuxtUiMongocamp.bucketFiles.viewMetadataTooltip"),
|
|
84
86
|
"onClick": () => openMetadataDetail(metadata)
|
|
85
87
|
}));
|
|
86
88
|
};
|
|
@@ -92,16 +94,16 @@ const renameSchema = reactive([
|
|
|
92
94
|
{
|
|
93
95
|
$formkit: "nuxtUIInput",
|
|
94
96
|
name: "filename",
|
|
95
|
-
label: "
|
|
97
|
+
label: t("nuxtUiMongocamp.bucketFiles.filename"),
|
|
96
98
|
validation: "required"
|
|
97
99
|
},
|
|
98
100
|
{
|
|
99
101
|
$formkit: "nuxtUIRepeater",
|
|
100
102
|
name: "metadata",
|
|
101
|
-
label: "
|
|
103
|
+
label: t("nuxtUiMongocamp.bucketFiles.columnMetadata"),
|
|
102
104
|
children: [
|
|
103
|
-
{ $formkit: "nuxtUIInput", name: "key", label: "
|
|
104
|
-
{ $formkit: "nuxtUIInput", name: "value", label: "
|
|
105
|
+
{ $formkit: "nuxtUIInput", name: "key", label: t("nuxtUiMongocamp.bucketFiles.metadataKey") },
|
|
106
|
+
{ $formkit: "nuxtUIInput", name: "value", label: t("nuxtUiMongocamp.bucketFiles.metadataValue") }
|
|
105
107
|
]
|
|
106
108
|
}
|
|
107
109
|
]);
|
|
@@ -149,30 +151,30 @@ function makeActionsColumn() {
|
|
|
149
151
|
cell: ({ row }) => {
|
|
150
152
|
const file = row.original;
|
|
151
153
|
return h("div", { class: "flex gap-1 justify-end" }, [
|
|
152
|
-
withTooltip("
|
|
154
|
+
withTooltip(t("nuxtUiMongocamp.bucketFiles.downloadFileTooltip"), h(UButton, {
|
|
153
155
|
"icon": "i-lucide-download",
|
|
154
156
|
"color": "neutral",
|
|
155
157
|
"variant": "ghost",
|
|
156
158
|
"size": "sm",
|
|
157
|
-
"aria-label": "
|
|
159
|
+
"aria-label": t("nuxtUiMongocamp.bucketFiles.downloadFileTooltip"),
|
|
158
160
|
"loading": downloadingFileIds.value.has(file.id),
|
|
159
161
|
"onClick": () => downloadFile(props.bucketName, file.id)
|
|
160
162
|
})),
|
|
161
|
-
withTooltip("
|
|
163
|
+
withTooltip(t("nuxtUiMongocamp.bucketFiles.renameTooltip"), h(UButton, {
|
|
162
164
|
"icon": "i-lucide-pencil",
|
|
163
165
|
"color": "neutral",
|
|
164
166
|
"variant": "ghost",
|
|
165
167
|
"size": "sm",
|
|
166
|
-
"aria-label": "
|
|
168
|
+
"aria-label": t("nuxtUiMongocamp.bucketFiles.renameTooltip"),
|
|
167
169
|
"loading": fileActionInFlight.value.has(file.id),
|
|
168
170
|
"onClick": () => openRename(file)
|
|
169
171
|
})),
|
|
170
|
-
withTooltip("
|
|
172
|
+
withTooltip(t("nuxtUiMongocamp.bucketFiles.deleteFileTooltip"), h(UButton, {
|
|
171
173
|
"icon": "i-lucide-trash-2",
|
|
172
174
|
"color": "error",
|
|
173
175
|
"variant": "ghost",
|
|
174
176
|
"size": "sm",
|
|
175
|
-
"aria-label": "
|
|
177
|
+
"aria-label": t("nuxtUiMongocamp.bucketFiles.deleteFileTooltip"),
|
|
176
178
|
"loading": fileActionInFlight.value.has(file.id),
|
|
177
179
|
"onClick": () => confirmDeleteFile(file)
|
|
178
180
|
}))
|
|
@@ -183,22 +185,22 @@ function makeActionsColumn() {
|
|
|
183
185
|
const columns = ref([
|
|
184
186
|
{
|
|
185
187
|
accessorKey: "filename",
|
|
186
|
-
header: ({ column }) => sortHeader(column, "
|
|
188
|
+
header: ({ column }) => sortHeader(column, t("nuxtUiMongocamp.bucketFiles.columnFilename")),
|
|
187
189
|
cell: ({ row }) => h("span", row.original.filename)
|
|
188
190
|
},
|
|
189
191
|
{
|
|
190
192
|
accessorKey: "length",
|
|
191
|
-
header: ({ column }) => sortHeader(column, "
|
|
193
|
+
header: ({ column }) => sortHeader(column, t("nuxtUiMongocamp.bucketFiles.columnSize")),
|
|
192
194
|
cell: ({ row }) => h("span", formatBytes(row.original.length))
|
|
193
195
|
},
|
|
194
196
|
{
|
|
195
197
|
accessorKey: "uploadDate",
|
|
196
|
-
header: ({ column }) => sortHeader(column, "
|
|
198
|
+
header: ({ column }) => sortHeader(column, t("nuxtUiMongocamp.bucketFiles.columnUploaded")),
|
|
197
199
|
cell: ({ row }) => h("span", formatDate(row.original.uploadDate))
|
|
198
200
|
},
|
|
199
201
|
{
|
|
200
202
|
id: "metadata",
|
|
201
|
-
header: "
|
|
203
|
+
header: t("nuxtUiMongocamp.bucketFiles.columnMetadata"),
|
|
202
204
|
cell: makeMetadataCell()
|
|
203
205
|
},
|
|
204
206
|
makeActionsColumn()
|
|
@@ -210,8 +212,8 @@ const sorting = ref([]);
|
|
|
210
212
|
const isInitializing = ref(false);
|
|
211
213
|
let filterTimer;
|
|
212
214
|
function buildLuceneFilter(term) {
|
|
213
|
-
const
|
|
214
|
-
return
|
|
215
|
+
const trimmed = term.trim();
|
|
216
|
+
return trimmed ? like("filename", trimmed) : void 0;
|
|
215
217
|
}
|
|
216
218
|
function onFilterInput() {
|
|
217
219
|
clearTimeout(filterTimer);
|
|
@@ -258,23 +260,23 @@ watch(() => props.bucketName, init, { immediate: true });
|
|
|
258
260
|
<UInput
|
|
259
261
|
v-model="filterText"
|
|
260
262
|
icon="i-lucide-search"
|
|
261
|
-
placeholder="
|
|
263
|
+
:placeholder="t('nuxtUiMongocamp.bucketFiles.filterPlaceholder')"
|
|
262
264
|
size="sm"
|
|
263
265
|
class="flex-1 max-w-xs"
|
|
264
266
|
@input="onFilterInput"
|
|
265
267
|
/>
|
|
266
268
|
<div class="flex items-center gap-2">
|
|
267
269
|
<span class="text-sm text-gray-500 dark:text-gray-400 shrink-0">
|
|
268
|
-
{{ total }}
|
|
270
|
+
{{ t("nuxtUiMongocamp.bucketFiles.filesCount", { count: total }) }}
|
|
269
271
|
</span>
|
|
270
|
-
<UTooltip text="
|
|
272
|
+
<UTooltip :text="t('nuxtUiMongocamp.bucketFiles.uploadFileTooltip')">
|
|
271
273
|
<UButton
|
|
272
274
|
icon="i-lucide-upload"
|
|
273
275
|
color="primary"
|
|
274
276
|
variant="ghost"
|
|
275
277
|
size="sm"
|
|
276
278
|
:loading="uploading"
|
|
277
|
-
aria-label="
|
|
279
|
+
:aria-label="t('nuxtUiMongocamp.bucketFiles.uploadFileTooltip')"
|
|
278
280
|
@click="openFilePicker"
|
|
279
281
|
/>
|
|
280
282
|
</UTooltip>
|
|
@@ -284,13 +286,13 @@ watch(() => props.bucketName, init, { immediate: true });
|
|
|
284
286
|
class="hidden"
|
|
285
287
|
@change="handleFileSelected"
|
|
286
288
|
>
|
|
287
|
-
<UTooltip text="
|
|
289
|
+
<UTooltip :text="t('nuxtUiMongocamp.bucketFiles.reloadTooltip')">
|
|
288
290
|
<UButton
|
|
289
291
|
icon="i-lucide-refresh-cw"
|
|
290
292
|
color="neutral"
|
|
291
293
|
variant="ghost"
|
|
292
294
|
:loading="loading"
|
|
293
|
-
aria-label="
|
|
295
|
+
:aria-label="t('nuxtUiMongocamp.bucketFiles.reloadTooltip')"
|
|
294
296
|
@click="init"
|
|
295
297
|
/>
|
|
296
298
|
</UTooltip>
|
|
@@ -312,7 +314,7 @@ watch(() => props.bucketName, init, { immediate: true });
|
|
|
312
314
|
|
|
313
315
|
<UModal
|
|
314
316
|
v-model:open="detailOpen"
|
|
315
|
-
title="
|
|
317
|
+
:title="t('nuxtUiMongocamp.bucketFiles.metadataTitle')"
|
|
316
318
|
>
|
|
317
319
|
<template #body>
|
|
318
320
|
<pre class="text-xs overflow-auto max-h-[60vh] whitespace-pre-wrap break-all">{{ detailContent }}</pre>
|
|
@@ -321,14 +323,14 @@ watch(() => props.bucketName, init, { immediate: true });
|
|
|
321
323
|
|
|
322
324
|
<UModal
|
|
323
325
|
v-model:open="isRenameModalOpen"
|
|
324
|
-
title="
|
|
326
|
+
:title="t('nuxtUiMongocamp.bucketFiles.renameTitle')"
|
|
325
327
|
:ui="{ footer: 'justify-end' }"
|
|
326
328
|
>
|
|
327
329
|
<template #body>
|
|
328
330
|
<FUDataEdit
|
|
329
331
|
:data="renameData"
|
|
330
332
|
:schema="renameSchema"
|
|
331
|
-
submit-label="
|
|
333
|
+
:submit-label="t('nuxtUiMongocamp.common.save')"
|
|
332
334
|
submit-icon="i-lucide-save"
|
|
333
335
|
@data-saved="handleRenameSave"
|
|
334
336
|
/>
|
|
@@ -337,21 +339,21 @@ watch(() => props.bucketName, init, { immediate: true });
|
|
|
337
339
|
|
|
338
340
|
<UModal
|
|
339
341
|
v-model:open="isDeleteModalOpen"
|
|
340
|
-
title="
|
|
342
|
+
:title="t('nuxtUiMongocamp.bucketFiles.deleteFileTitle')"
|
|
341
343
|
:ui="{ footer: 'justify-end' }"
|
|
342
344
|
>
|
|
343
345
|
<template #body>
|
|
344
|
-
<p>
|
|
346
|
+
<p>{{ t("nuxtUiMongocamp.bucketFiles.confirmDeleteFile") }}</p>
|
|
345
347
|
</template>
|
|
346
348
|
<template #footer>
|
|
347
349
|
<UButton
|
|
348
|
-
label="
|
|
350
|
+
:label="t('nuxtUiMongocamp.common.cancel')"
|
|
349
351
|
color="neutral"
|
|
350
352
|
variant="ghost"
|
|
351
353
|
@click="isDeleteModalOpen = false"
|
|
352
354
|
/>
|
|
353
355
|
<UButton
|
|
354
|
-
label="
|
|
356
|
+
:label="t('nuxtUiMongocamp.common.delete')"
|
|
355
357
|
color="error"
|
|
356
358
|
icon="i-lucide-trash-2"
|
|
357
359
|
@click="handleDeleteFile"
|