@sfxcode/nuxt-ui-mongocamp 1.1.3 → 1.2.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.
- package/README.md +31 -9
- 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.d.vue.ts +6 -0
- package/dist/runtime/components/MongocampBucketFiles.vue +364 -0
- package/dist/runtime/components/MongocampBucketFiles.vue.d.ts +6 -0
- package/dist/runtime/components/MongocampCollectionData.vue +36 -35
- package/dist/runtime/components/MongocampCollectionInfos.vue +37 -36
- package/dist/runtime/components/MongocampCollections.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampCollections.vue +38 -28
- package/dist/runtime/components/MongocampCollections.vue.d.ts +1 -0
- 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.d.ts +20 -1
- package/dist/runtime/composables/useMongocampBucket.js +62 -13
- 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 +13 -6
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { h, reactive, ref, resolveComponent } from "vue";
|
|
3
|
+
import { useI18n } from "#imports";
|
|
3
4
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
4
5
|
const props = defineProps({
|
|
5
6
|
grantsPath: { type: String, required: false }
|
|
6
7
|
});
|
|
8
|
+
const { t } = useI18n();
|
|
7
9
|
const { listRoles, addRole, updateRole, deleteRole } = useMongocampAdmin();
|
|
8
10
|
const roles = ref([]);
|
|
9
11
|
const loading = ref(false);
|
|
@@ -22,20 +24,20 @@ const addRoleSchema = reactive([
|
|
|
22
24
|
{
|
|
23
25
|
$formkit: "nuxtUIInput",
|
|
24
26
|
name: "name",
|
|
25
|
-
label: "
|
|
27
|
+
label: t("nuxtUiMongocamp.roles.roleName"),
|
|
26
28
|
validation: "required|length:2"
|
|
27
29
|
},
|
|
28
30
|
{
|
|
29
31
|
$formkit: "nuxtUISwitch",
|
|
30
32
|
name: "isAdmin",
|
|
31
|
-
label: "
|
|
33
|
+
label: t("nuxtUiMongocamp.roles.adminRole")
|
|
32
34
|
}
|
|
33
35
|
]);
|
|
34
36
|
const editRoleSchema = reactive([
|
|
35
37
|
{
|
|
36
38
|
$formkit: "nuxtUISwitch",
|
|
37
39
|
name: "isAdmin",
|
|
38
|
-
label: "
|
|
40
|
+
label: t("nuxtUiMongocamp.roles.adminRole")
|
|
39
41
|
}
|
|
40
42
|
]);
|
|
41
43
|
async function fetchRoles() {
|
|
@@ -58,7 +60,7 @@ async function handleAddRole() {
|
|
|
58
60
|
newRole.value = { name: "", isAdmin: false };
|
|
59
61
|
await fetchRoles();
|
|
60
62
|
} catch (e) {
|
|
61
|
-
errorMessage.value = e instanceof Error ? e.message : "
|
|
63
|
+
errorMessage.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.roles.errorAddRole");
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
function openEdit(role) {
|
|
@@ -73,7 +75,7 @@ async function handleEditRole() {
|
|
|
73
75
|
isEditModalOpen.value = false;
|
|
74
76
|
await fetchRoles();
|
|
75
77
|
} catch (e) {
|
|
76
|
-
errorMessage.value = e instanceof Error ? e.message : "
|
|
78
|
+
errorMessage.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.roles.errorEditRole");
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
function confirmDelete(roleName) {
|
|
@@ -105,20 +107,20 @@ function sortHeader(column, label) {
|
|
|
105
107
|
const columns = [
|
|
106
108
|
{
|
|
107
109
|
accessorKey: "name",
|
|
108
|
-
header: ({ column }) => sortHeader(column, "
|
|
110
|
+
header: ({ column }) => sortHeader(column, t("nuxtUiMongocamp.roles.columnRole"))
|
|
109
111
|
},
|
|
110
112
|
{
|
|
111
113
|
accessorKey: "isAdmin",
|
|
112
|
-
header: "
|
|
114
|
+
header: t("nuxtUiMongocamp.roles.columnAdmin"),
|
|
113
115
|
cell: ({ row }) => h(UBadge, {
|
|
114
|
-
label: row.original.isAdmin ? "
|
|
116
|
+
label: row.original.isAdmin ? t("nuxtUiMongocamp.common.admin") : t("nuxtUiMongocamp.common.standard"),
|
|
115
117
|
color: row.original.isAdmin ? "error" : "neutral",
|
|
116
118
|
variant: "subtle"
|
|
117
119
|
})
|
|
118
120
|
},
|
|
119
121
|
{
|
|
120
122
|
accessorKey: "collectionGrants",
|
|
121
|
-
header: "
|
|
123
|
+
header: t("nuxtUiMongocamp.roles.columnGrants"),
|
|
122
124
|
cell: ({ row }) => {
|
|
123
125
|
const count = row.original.collectionGrants?.length ?? 0;
|
|
124
126
|
return count ? h(UBadge, { label: String(count), color: "primary", variant: "subtle" }) : h("span", { class: "text-dimmed" }, "\u2014");
|
|
@@ -128,28 +130,28 @@ const columns = [
|
|
|
128
130
|
id: "actions",
|
|
129
131
|
header: "",
|
|
130
132
|
cell: ({ row }) => h("div", { class: "flex gap-1 justify-end" }, [
|
|
131
|
-
withTooltip("
|
|
133
|
+
withTooltip(t("nuxtUiMongocamp.roles.manageGrantsTooltip"), h(UButton, {
|
|
132
134
|
"icon": "i-lucide-key",
|
|
133
135
|
"color": "neutral",
|
|
134
136
|
"variant": "ghost",
|
|
135
137
|
"size": "sm",
|
|
136
|
-
"aria-label": "
|
|
138
|
+
"aria-label": t("nuxtUiMongocamp.roles.manageGrantsTooltip"),
|
|
137
139
|
"to": props.grantsPath ? `${props.grantsPath}/${row.original.name}` : `/secured/admin/roles/${row.original.name}`
|
|
138
140
|
})),
|
|
139
|
-
withTooltip("
|
|
141
|
+
withTooltip(t("nuxtUiMongocamp.roles.editRoleTooltip"), h(UButton, {
|
|
140
142
|
"icon": "i-lucide-pencil",
|
|
141
143
|
"color": "neutral",
|
|
142
144
|
"variant": "ghost",
|
|
143
145
|
"size": "sm",
|
|
144
|
-
"aria-label": "
|
|
146
|
+
"aria-label": t("nuxtUiMongocamp.roles.editRoleTooltip"),
|
|
145
147
|
"onClick": () => openEdit(row.original)
|
|
146
148
|
})),
|
|
147
|
-
withTooltip("
|
|
149
|
+
withTooltip(t("nuxtUiMongocamp.roles.deleteRoleTooltip"), h(UButton, {
|
|
148
150
|
"icon": "i-lucide-trash-2",
|
|
149
151
|
"color": "error",
|
|
150
152
|
"variant": "ghost",
|
|
151
153
|
"size": "sm",
|
|
152
|
-
"aria-label": "
|
|
154
|
+
"aria-label": t("nuxtUiMongocamp.roles.deleteRoleTooltip"),
|
|
153
155
|
"onClick": () => confirmDelete(row.original.name)
|
|
154
156
|
}))
|
|
155
157
|
])
|
|
@@ -162,30 +164,30 @@ fetchRoles();
|
|
|
162
164
|
<div class="flex flex-col gap-4">
|
|
163
165
|
<div class="flex items-center justify-between gap-4">
|
|
164
166
|
<h2 class="text-xl font-semibold">
|
|
165
|
-
|
|
167
|
+
{{ t("nuxtUiMongocamp.roles.heading") }}
|
|
166
168
|
</h2>
|
|
167
169
|
<div class="flex flex-1 items-center gap-2">
|
|
168
170
|
<UInput
|
|
169
171
|
v-model="filterText"
|
|
170
172
|
icon="i-lucide-search"
|
|
171
|
-
placeholder="
|
|
173
|
+
:placeholder="t('nuxtUiMongocamp.roles.searchPlaceholder')"
|
|
172
174
|
size="sm"
|
|
173
175
|
class="flex-1 max-w-xs"
|
|
174
176
|
@input="onFilterInput"
|
|
175
177
|
/>
|
|
176
|
-
<UTooltip text="
|
|
178
|
+
<UTooltip :text="t('nuxtUiMongocamp.common.refresh')">
|
|
177
179
|
<UButton
|
|
178
180
|
icon="i-lucide-refresh-cw"
|
|
179
181
|
color="neutral"
|
|
180
182
|
variant="ghost"
|
|
181
183
|
:loading="loading"
|
|
182
|
-
aria-label="
|
|
184
|
+
:aria-label="t('nuxtUiMongocamp.common.refresh')"
|
|
183
185
|
@click="fetchRoles"
|
|
184
186
|
/>
|
|
185
187
|
</UTooltip>
|
|
186
188
|
<UButton
|
|
187
189
|
icon="i-lucide-plus"
|
|
188
|
-
label="
|
|
190
|
+
:label="t('nuxtUiMongocamp.roles.addRole')"
|
|
189
191
|
@click="isAddModalOpen = true"
|
|
190
192
|
/>
|
|
191
193
|
</div>
|
|
@@ -201,13 +203,13 @@ fetchRoles();
|
|
|
201
203
|
<!-- Add Role Modal -->
|
|
202
204
|
<UModal
|
|
203
205
|
v-model:open="isAddModalOpen"
|
|
204
|
-
title="
|
|
206
|
+
:title="t('nuxtUiMongocamp.roles.addRole')"
|
|
205
207
|
>
|
|
206
208
|
<template #body>
|
|
207
209
|
<FUDataEdit
|
|
208
210
|
:data="newRole"
|
|
209
211
|
:schema="addRoleSchema"
|
|
210
|
-
submit-label="
|
|
212
|
+
:submit-label="t('nuxtUiMongocamp.roles.addRole')"
|
|
211
213
|
submit-icon="i-lucide-plus"
|
|
212
214
|
@data-saved="handleAddRole"
|
|
213
215
|
/>
|
|
@@ -223,13 +225,13 @@ fetchRoles();
|
|
|
223
225
|
<!-- Edit Role Modal -->
|
|
224
226
|
<UModal
|
|
225
227
|
v-model:open="isEditModalOpen"
|
|
226
|
-
:title="
|
|
228
|
+
:title="t('nuxtUiMongocamp.roles.editRoleTitle', { roleName: editRole.roleName })"
|
|
227
229
|
>
|
|
228
230
|
<template #body>
|
|
229
231
|
<FUDataEdit
|
|
230
232
|
:data="editRole"
|
|
231
233
|
:schema="editRoleSchema"
|
|
232
|
-
submit-label="
|
|
234
|
+
:submit-label="t('nuxtUiMongocamp.common.saveChanges')"
|
|
233
235
|
submit-icon="i-lucide-save"
|
|
234
236
|
@data-saved="handleEditRole"
|
|
235
237
|
/>
|
|
@@ -245,24 +247,21 @@ fetchRoles();
|
|
|
245
247
|
<!-- Delete Confirmation Modal -->
|
|
246
248
|
<UModal
|
|
247
249
|
v-model:open="isDeleteModalOpen"
|
|
248
|
-
title="
|
|
250
|
+
:title="t('nuxtUiMongocamp.roles.deleteRoleTitle')"
|
|
249
251
|
:ui="{ footer: 'justify-end' }"
|
|
250
252
|
>
|
|
251
253
|
<template #body>
|
|
252
|
-
<p>
|
|
253
|
-
Are you sure you want to delete role <strong>{{ roleToDelete }}</strong>?
|
|
254
|
-
This action cannot be undone.
|
|
255
|
-
</p>
|
|
254
|
+
<p>{{ t("nuxtUiMongocamp.roles.confirmDelete", { roleName: roleToDelete }) }}</p>
|
|
256
255
|
</template>
|
|
257
256
|
<template #footer>
|
|
258
257
|
<UButton
|
|
259
|
-
label="
|
|
258
|
+
:label="t('nuxtUiMongocamp.common.cancel')"
|
|
260
259
|
color="neutral"
|
|
261
260
|
variant="ghost"
|
|
262
261
|
@click="isDeleteModalOpen = false"
|
|
263
262
|
/>
|
|
264
263
|
<UButton
|
|
265
|
-
label="
|
|
264
|
+
:label="t('nuxtUiMongocamp.common.delete')"
|
|
266
265
|
color="error"
|
|
267
266
|
@click="handleDeleteRole"
|
|
268
267
|
/>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { h, reactive, ref, resolveComponent } from "vue";
|
|
3
|
+
import { useI18n } from "#imports";
|
|
3
4
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
5
|
+
const { t } = useI18n();
|
|
4
6
|
const { listUsers, addUser, deleteUser, updateUserRoles, updateUserPassword, listRoles } = useMongocampAdmin();
|
|
5
7
|
const users = ref([]);
|
|
6
8
|
const loading = ref(false);
|
|
@@ -26,51 +28,51 @@ const addUserSchema = reactive([
|
|
|
26
28
|
{
|
|
27
29
|
$formkit: "nuxtUIInput",
|
|
28
30
|
name: "userId",
|
|
29
|
-
label: "
|
|
31
|
+
label: t("nuxtUiMongocamp.users.email"),
|
|
30
32
|
validation: "required|email"
|
|
31
33
|
},
|
|
32
34
|
{
|
|
33
35
|
$formkit: "nuxtUIInput",
|
|
34
36
|
name: "password",
|
|
35
|
-
label: "
|
|
37
|
+
label: t("nuxtUiMongocamp.users.password"),
|
|
36
38
|
inputType: "password",
|
|
37
39
|
validation: "required|length:3"
|
|
38
40
|
},
|
|
39
41
|
{
|
|
40
42
|
$formkit: "nuxtUIListbox",
|
|
41
43
|
name: "roles",
|
|
42
|
-
label: "
|
|
44
|
+
label: t("nuxtUiMongocamp.users.roles"),
|
|
43
45
|
displayMode: "transfer",
|
|
44
46
|
options: [],
|
|
45
47
|
filter: true,
|
|
46
48
|
class: "h-60",
|
|
47
49
|
transferHeaderClass: "text-sm text-gray-500 font-medium",
|
|
48
50
|
transferAll: true,
|
|
49
|
-
transferLeftHeaderText: "
|
|
50
|
-
transferRightHeaderText: "
|
|
51
|
+
transferLeftHeaderText: t("nuxtUiMongocamp.users.available"),
|
|
52
|
+
transferRightHeaderText: t("nuxtUiMongocamp.users.assigned")
|
|
51
53
|
}
|
|
52
54
|
]);
|
|
53
55
|
const editUserSchema = reactive([
|
|
54
56
|
{
|
|
55
57
|
$formkit: "nuxtUIInput",
|
|
56
58
|
name: "password",
|
|
57
|
-
label: "
|
|
59
|
+
label: t("nuxtUiMongocamp.users.newPassword"),
|
|
58
60
|
inputType: "password",
|
|
59
61
|
validation: "length:3,100",
|
|
60
|
-
help: "
|
|
62
|
+
help: t("nuxtUiMongocamp.users.newPasswordHelp")
|
|
61
63
|
},
|
|
62
64
|
{
|
|
63
65
|
$formkit: "nuxtUIListbox",
|
|
64
66
|
name: "roles",
|
|
65
|
-
label: "
|
|
67
|
+
label: t("nuxtUiMongocamp.users.roles"),
|
|
66
68
|
displayMode: "transfer",
|
|
67
69
|
filter: true,
|
|
68
70
|
class: "h-60",
|
|
69
71
|
transferHeaderClass: "text-sm text-gray-500 font-medium",
|
|
70
72
|
options: [],
|
|
71
73
|
transferAll: true,
|
|
72
|
-
transferLeftHeaderText: "
|
|
73
|
-
transferRightHeaderText: "
|
|
74
|
+
transferLeftHeaderText: t("nuxtUiMongocamp.users.available"),
|
|
75
|
+
transferRightHeaderText: t("nuxtUiMongocamp.users.assigned")
|
|
74
76
|
}
|
|
75
77
|
]);
|
|
76
78
|
async function fetchUsers() {
|
|
@@ -100,7 +102,7 @@ async function handleAddUser() {
|
|
|
100
102
|
newUser.value = { userId: "", password: "", roles: [] };
|
|
101
103
|
await fetchUsers();
|
|
102
104
|
} catch (e) {
|
|
103
|
-
errorMessage.value = e instanceof Error ? e.message : "
|
|
105
|
+
errorMessage.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.users.errorAddUser");
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
function openEdit(user) {
|
|
@@ -122,7 +124,7 @@ async function handleEditUser() {
|
|
|
122
124
|
isEditModalOpen.value = false;
|
|
123
125
|
await fetchUsers();
|
|
124
126
|
} catch (e) {
|
|
125
|
-
errorMessage.value = e instanceof Error ? e.message : "
|
|
127
|
+
errorMessage.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.users.errorEditUser");
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
function confirmDelete(userId) {
|
|
@@ -154,20 +156,20 @@ function sortHeader(column, label) {
|
|
|
154
156
|
const columns = [
|
|
155
157
|
{
|
|
156
158
|
accessorKey: "user",
|
|
157
|
-
header: ({ column }) => sortHeader(column, "
|
|
159
|
+
header: ({ column }) => sortHeader(column, t("nuxtUiMongocamp.users.columnUser"))
|
|
158
160
|
},
|
|
159
161
|
{
|
|
160
162
|
accessorKey: "isAdmin",
|
|
161
|
-
header: ({ column }) => sortHeader(column, "
|
|
163
|
+
header: ({ column }) => sortHeader(column, t("nuxtUiMongocamp.users.columnAdmin")),
|
|
162
164
|
cell: ({ row }) => h(UBadge, {
|
|
163
|
-
label: row.original.isAdmin ? "
|
|
165
|
+
label: row.original.isAdmin ? t("nuxtUiMongocamp.users.roleAdmin") : t("nuxtUiMongocamp.users.roleUser"),
|
|
164
166
|
color: row.original.isAdmin ? "error" : "neutral",
|
|
165
167
|
variant: "subtle"
|
|
166
168
|
})
|
|
167
169
|
},
|
|
168
170
|
{
|
|
169
171
|
accessorKey: "roles",
|
|
170
|
-
header: "
|
|
172
|
+
header: t("nuxtUiMongocamp.users.columnRoles"),
|
|
171
173
|
cell: ({ row }) => {
|
|
172
174
|
const roles = row.original.roles ?? [];
|
|
173
175
|
if (!roles.length)
|
|
@@ -183,20 +185,20 @@ const columns = [
|
|
|
183
185
|
id: "actions",
|
|
184
186
|
header: "",
|
|
185
187
|
cell: ({ row }) => h("div", { class: "flex gap-1 justify-end" }, [
|
|
186
|
-
withTooltip("
|
|
188
|
+
withTooltip(t("nuxtUiMongocamp.users.editUserTooltip"), h(UButton, {
|
|
187
189
|
"icon": "i-lucide-pencil",
|
|
188
190
|
"color": "neutral",
|
|
189
191
|
"variant": "ghost",
|
|
190
192
|
"size": "sm",
|
|
191
|
-
"aria-label": "
|
|
193
|
+
"aria-label": t("nuxtUiMongocamp.users.editUserTooltip"),
|
|
192
194
|
"onClick": () => openEdit(row.original)
|
|
193
195
|
})),
|
|
194
|
-
withTooltip("
|
|
196
|
+
withTooltip(t("nuxtUiMongocamp.users.deleteUserTooltip"), h(UButton, {
|
|
195
197
|
"icon": "i-lucide-trash-2",
|
|
196
198
|
"color": "error",
|
|
197
199
|
"variant": "ghost",
|
|
198
200
|
"size": "sm",
|
|
199
|
-
"aria-label": "
|
|
201
|
+
"aria-label": t("nuxtUiMongocamp.users.deleteUserTooltip"),
|
|
200
202
|
"onClick": () => confirmDelete(row.original.user)
|
|
201
203
|
}))
|
|
202
204
|
])
|
|
@@ -210,30 +212,30 @@ fetchRoles();
|
|
|
210
212
|
<div class="flex flex-col gap-4">
|
|
211
213
|
<div class="flex items-center justify-between gap-4">
|
|
212
214
|
<h2 class="text-xl font-semibold">
|
|
213
|
-
|
|
215
|
+
{{ t("nuxtUiMongocamp.users.heading") }}
|
|
214
216
|
</h2>
|
|
215
217
|
<div class="flex flex-1 items-center gap-2">
|
|
216
218
|
<UInput
|
|
217
219
|
v-model="filterText"
|
|
218
220
|
icon="i-lucide-search"
|
|
219
|
-
placeholder="
|
|
221
|
+
:placeholder="t('nuxtUiMongocamp.users.searchPlaceholder')"
|
|
220
222
|
size="sm"
|
|
221
223
|
class="flex-1 max-w-xs"
|
|
222
224
|
@input="onFilterInput"
|
|
223
225
|
/>
|
|
224
|
-
<UTooltip text="
|
|
226
|
+
<UTooltip :text="t('nuxtUiMongocamp.common.refresh')">
|
|
225
227
|
<UButton
|
|
226
228
|
icon="i-lucide-refresh-cw"
|
|
227
229
|
color="neutral"
|
|
228
230
|
variant="ghost"
|
|
229
231
|
:loading="loading"
|
|
230
|
-
aria-label="
|
|
232
|
+
:aria-label="t('nuxtUiMongocamp.common.refresh')"
|
|
231
233
|
@click="fetchUsers"
|
|
232
234
|
/>
|
|
233
235
|
</UTooltip>
|
|
234
236
|
<UButton
|
|
235
237
|
icon="i-lucide-plus"
|
|
236
|
-
label="
|
|
238
|
+
:label="t('nuxtUiMongocamp.users.addUser')"
|
|
237
239
|
@click="isAddModalOpen = true"
|
|
238
240
|
/>
|
|
239
241
|
</div>
|
|
@@ -249,13 +251,13 @@ fetchRoles();
|
|
|
249
251
|
<!-- Add User Modal -->
|
|
250
252
|
<UModal
|
|
251
253
|
v-model:open="isAddModalOpen"
|
|
252
|
-
title="
|
|
254
|
+
:title="t('nuxtUiMongocamp.users.addUser')"
|
|
253
255
|
>
|
|
254
256
|
<template #body>
|
|
255
257
|
<FUDataEdit
|
|
256
258
|
:data="newUser"
|
|
257
259
|
:schema="addUserSchema"
|
|
258
|
-
submit-label="
|
|
260
|
+
:submit-label="t('nuxtUiMongocamp.users.addUser')"
|
|
259
261
|
submit-icon="i-lucide-plus"
|
|
260
262
|
@data-saved="handleAddUser"
|
|
261
263
|
/>
|
|
@@ -271,13 +273,13 @@ fetchRoles();
|
|
|
271
273
|
<!-- Edit User Modal -->
|
|
272
274
|
<UModal
|
|
273
275
|
v-model:open="isEditModalOpen"
|
|
274
|
-
:title="
|
|
276
|
+
:title="t('nuxtUiMongocamp.users.editUserTitle', { userId: editUser.userId })"
|
|
275
277
|
>
|
|
276
278
|
<template #body>
|
|
277
279
|
<FUDataEdit
|
|
278
280
|
:data="editUser"
|
|
279
281
|
:schema="editUserSchema"
|
|
280
|
-
submit-label="
|
|
282
|
+
:submit-label="t('nuxtUiMongocamp.common.saveChanges')"
|
|
281
283
|
submit-icon="i-lucide-save"
|
|
282
284
|
@data-saved="handleEditUser"
|
|
283
285
|
/>
|
|
@@ -293,24 +295,21 @@ fetchRoles();
|
|
|
293
295
|
<!-- Delete Confirmation Modal -->
|
|
294
296
|
<UModal
|
|
295
297
|
v-model:open="isDeleteModalOpen"
|
|
296
|
-
title="
|
|
298
|
+
:title="t('nuxtUiMongocamp.users.deleteUserTitle')"
|
|
297
299
|
:ui="{ footer: 'justify-end' }"
|
|
298
300
|
>
|
|
299
301
|
<template #body>
|
|
300
|
-
<p>
|
|
301
|
-
Are you sure you want to delete user <strong>{{ userToDelete }}</strong>?
|
|
302
|
-
This action cannot be undone.
|
|
303
|
-
</p>
|
|
302
|
+
<p>{{ t("nuxtUiMongocamp.users.confirmDelete", { userId: userToDelete }) }}</p>
|
|
304
303
|
</template>
|
|
305
304
|
<template #footer>
|
|
306
305
|
<UButton
|
|
307
|
-
label="
|
|
306
|
+
:label="t('nuxtUiMongocamp.common.cancel')"
|
|
308
307
|
color="neutral"
|
|
309
308
|
variant="ghost"
|
|
310
309
|
@click="isDeleteModalOpen = false"
|
|
311
310
|
/>
|
|
312
311
|
<UButton
|
|
313
|
-
label="
|
|
312
|
+
:label="t('nuxtUiMongocamp.common.delete')"
|
|
314
313
|
color="error"
|
|
315
314
|
@click="handleDeleteUser"
|
|
316
315
|
/>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
+
import { useI18n } from "#imports";
|
|
3
4
|
import { useNuxtApp } from "#app";
|
|
5
|
+
const { t } = useI18n();
|
|
4
6
|
const { $mongocampVersion } = useNuxtApp();
|
|
5
7
|
const version = computed(() => $mongocampVersion.value);
|
|
6
8
|
</script>
|
|
@@ -20,6 +22,6 @@ const version = computed(() => $mongocampVersion.value);
|
|
|
20
22
|
variant="subtle"
|
|
21
23
|
icon="i-lucide-database-zap"
|
|
22
24
|
>
|
|
23
|
-
|
|
25
|
+
{{ t("nuxtUiMongocamp.version.unavailable") }}
|
|
24
26
|
</UBadge>
|
|
25
27
|
</template>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ref } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { useI18n, useMongocampClientApi, useToast } from "#imports";
|
|
3
3
|
export function useMongocampAccount() {
|
|
4
|
-
const {
|
|
4
|
+
const { t } = useI18n();
|
|
5
|
+
const { authApi } = useMongocampClientApi();
|
|
5
6
|
const toast = useToast();
|
|
6
7
|
const changingPassword = ref(false);
|
|
7
8
|
async function fetchProfile() {
|
|
@@ -11,10 +12,10 @@ export function useMongocampAccount() {
|
|
|
11
12
|
changingPassword.value = true;
|
|
12
13
|
try {
|
|
13
14
|
const result = await authApi.updatePassword({ passwordUpdateRequest: { password } });
|
|
14
|
-
toast.add({ title: "
|
|
15
|
+
toast.add({ title: t("nuxtUiMongocamp.account.passwordChangedTitle"), description: t("nuxtUiMongocamp.account.passwordChangedDescription"), color: "success" });
|
|
15
16
|
return result.value;
|
|
16
|
-
} catch {
|
|
17
|
-
toast.add({ title: "
|
|
17
|
+
} catch (e) {
|
|
18
|
+
toast.add({ title: t("nuxtUiMongocamp.account.changeFailedTitle"), description: e instanceof Error ? e.message : t("nuxtUiMongocamp.account.changeFailedFallback"), color: "error" });
|
|
18
19
|
return false;
|
|
19
20
|
} finally {
|
|
20
21
|
changingPassword.value = false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMongocampClientApi } from "#imports";
|
|
2
2
|
export default () => {
|
|
3
|
-
const { adminApi, collectionApi } =
|
|
3
|
+
const { adminApi, collectionApi } = useMongocampClientApi();
|
|
4
4
|
async function listUsers(filter = "") {
|
|
5
5
|
return adminApi.listUsers({ filter });
|
|
6
6
|
}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import type { BucketInformation } from '@sfxcode/nuxt-mongocamp-server';
|
|
1
|
+
import type { BucketInformation, FileInformation } from '@sfxcode/nuxt-mongocamp-server';
|
|
2
|
+
export interface ListFilesOptions {
|
|
3
|
+
filter?: string;
|
|
4
|
+
sort?: string;
|
|
5
|
+
projection?: string;
|
|
6
|
+
page?: number;
|
|
7
|
+
rowsPerPage?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ListFilesResult {
|
|
10
|
+
files: FileInformation[];
|
|
11
|
+
total: number;
|
|
12
|
+
}
|
|
13
|
+
export interface UpdateFileInformationOptions {
|
|
14
|
+
filename?: string;
|
|
15
|
+
metadata?: Record<string, string>;
|
|
16
|
+
}
|
|
2
17
|
export declare function useMongocampBucket(): {
|
|
3
18
|
isBucketCollection: (collectionName: string) => boolean;
|
|
4
19
|
bucketNameFor: (collectionName: string) => string;
|
|
@@ -8,6 +23,10 @@ export declare function useMongocampBucket(): {
|
|
|
8
23
|
downloadFile: (collectionName: string, fileId: string) => Promise<void>;
|
|
9
24
|
uploadFile: (collectionName: string, file: File) => Promise<boolean>;
|
|
10
25
|
bucketActionInFlight: import("vue").Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
|
|
26
|
+
fileActionInFlight: import("vue").Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
|
|
27
|
+
listFiles: (bucketName: string, options?: ListFilesOptions) => Promise<ListFilesResult>;
|
|
28
|
+
deleteFile: (bucketName: string, fileId: string) => Promise<boolean>;
|
|
29
|
+
updateFileInformation: (bucketName: string, fileId: string, options: UpdateFileInformationOptions) => Promise<boolean>;
|
|
11
30
|
listBuckets: () => Promise<string[]>;
|
|
12
31
|
getBucketInfo: (bucketName: string) => Promise<BucketInformation>;
|
|
13
32
|
clearBucket: (bucketName: string) => Promise<boolean>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { useI18n, useMongocampClientApi, useToast } from "#imports";
|
|
3
3
|
const BUCKET_COLLECTION_SUFFIX = /\.(?:files|chunks)$/;
|
|
4
4
|
function unwrapId(value) {
|
|
5
5
|
if (typeof value === "string") return value;
|
|
@@ -19,11 +19,13 @@ function triggerBrowserDownload(blob, filename) {
|
|
|
19
19
|
URL.revokeObjectURL(url);
|
|
20
20
|
}
|
|
21
21
|
export function useMongocampBucket() {
|
|
22
|
-
const {
|
|
22
|
+
const { t } = useI18n();
|
|
23
|
+
const { fileApi, bucketApi } = useMongocampClientApi();
|
|
23
24
|
const toast = useToast();
|
|
24
25
|
const downloadingFileIds = ref(/* @__PURE__ */ new Set());
|
|
25
26
|
const uploading = ref(false);
|
|
26
27
|
const bucketActionInFlight = ref(/* @__PURE__ */ new Set());
|
|
28
|
+
const fileActionInFlight = ref(/* @__PURE__ */ new Set());
|
|
27
29
|
function isBucketCollection(collectionName) {
|
|
28
30
|
return BUCKET_COLLECTION_SUFFIX.test(collectionName);
|
|
29
31
|
}
|
|
@@ -40,8 +42,8 @@ export function useMongocampBucket() {
|
|
|
40
42
|
const info = await fileApi.getFileInformation({ bucketName, fileId });
|
|
41
43
|
const blob = await fileApi.getFile({ bucketName, fileId });
|
|
42
44
|
triggerBrowserDownload(blob, info.filename || fileId);
|
|
43
|
-
} catch {
|
|
44
|
-
toast.add({ title: "
|
|
45
|
+
} catch (e) {
|
|
46
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.downloadFailedTitle"), description: e instanceof Error ? e.message : t("nuxtUiMongocamp.bucket.downloadFailedFallback"), color: "error" });
|
|
45
47
|
} finally {
|
|
46
48
|
downloadingFileIds.value.delete(fileId);
|
|
47
49
|
}
|
|
@@ -51,15 +53,58 @@ export function useMongocampBucket() {
|
|
|
51
53
|
uploading.value = true;
|
|
52
54
|
try {
|
|
53
55
|
await fileApi.insertFile({ bucketName, file, fileName: file.name, metaData: "{}" });
|
|
54
|
-
toast.add({ title: "
|
|
56
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.uploadedTitle"), description: t("nuxtUiMongocamp.bucket.uploadedDescription", { fileName: file.name }), color: "success" });
|
|
55
57
|
return true;
|
|
56
|
-
} catch {
|
|
57
|
-
toast.add({ title: "
|
|
58
|
+
} catch (e) {
|
|
59
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.uploadFailedTitle"), description: e instanceof Error ? e.message : t("nuxtUiMongocamp.bucket.uploadFailedFallback"), color: "error" });
|
|
58
60
|
return false;
|
|
59
61
|
} finally {
|
|
60
62
|
uploading.value = false;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
65
|
+
async function listFiles(bucketName, options = {}) {
|
|
66
|
+
const res = await fileApi.listFilesRaw({
|
|
67
|
+
bucketName,
|
|
68
|
+
filter: options.filter,
|
|
69
|
+
sort: options.sort,
|
|
70
|
+
projection: options.projection,
|
|
71
|
+
page: options.page,
|
|
72
|
+
rowsPerPage: options.rowsPerPage
|
|
73
|
+
});
|
|
74
|
+
const total = +(res.raw.headers.get("x-pagination-count-rows") ?? 0);
|
|
75
|
+
const files = await res.value();
|
|
76
|
+
return { files, total };
|
|
77
|
+
}
|
|
78
|
+
async function deleteFile(bucketName, fileId) {
|
|
79
|
+
fileActionInFlight.value.add(fileId);
|
|
80
|
+
try {
|
|
81
|
+
const result = await fileApi.deleteFile({ bucketName, fileId });
|
|
82
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.deletedTitle"), description: t("nuxtUiMongocamp.bucket.deletedDescription"), color: "success" });
|
|
83
|
+
return result.wasAcknowledged;
|
|
84
|
+
} catch (e) {
|
|
85
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.deleteFailedTitle"), description: e instanceof Error ? e.message : t("nuxtUiMongocamp.bucket.deleteFailedFallback"), color: "error" });
|
|
86
|
+
return false;
|
|
87
|
+
} finally {
|
|
88
|
+
fileActionInFlight.value.delete(fileId);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function updateFileInformation(bucketName, fileId, options) {
|
|
92
|
+
fileActionInFlight.value.add(fileId);
|
|
93
|
+
try {
|
|
94
|
+
const result = await fileApi.updateFileInformation({
|
|
95
|
+
bucketName,
|
|
96
|
+
fileId,
|
|
97
|
+
updateFileInformationRequest: { filename: options.filename, metadata: options.metadata }
|
|
98
|
+
});
|
|
99
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.updatedTitle"), description: t("nuxtUiMongocamp.bucket.updatedDescription"), color: "success" });
|
|
100
|
+
return result.wasAcknowledged;
|
|
101
|
+
} catch (e) {
|
|
102
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.updateFailedTitle"), description: e instanceof Error ? e.message : t("nuxtUiMongocamp.bucket.updateFailedFallback"), color: "error" });
|
|
103
|
+
return false;
|
|
104
|
+
} finally {
|
|
105
|
+
fileActionInFlight.value.delete(fileId);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
63
108
|
async function listBuckets() {
|
|
64
109
|
return bucketApi.listBuckets();
|
|
65
110
|
}
|
|
@@ -70,10 +115,10 @@ export function useMongocampBucket() {
|
|
|
70
115
|
bucketActionInFlight.value.add(bucketName);
|
|
71
116
|
try {
|
|
72
117
|
const result = await bucketApi.clearBucket({ bucketName });
|
|
73
|
-
toast.add({ title: "
|
|
118
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.bucketClearedTitle"), description: t("nuxtUiMongocamp.bucket.bucketClearedDescription", { bucketName }), color: "success" });
|
|
74
119
|
return result.value;
|
|
75
|
-
} catch {
|
|
76
|
-
toast.add({ title: "
|
|
120
|
+
} catch (e) {
|
|
121
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.clearFailedTitle"), description: e instanceof Error ? e.message : t("nuxtUiMongocamp.bucket.clearFailedFallback", { bucketName }), color: "error" });
|
|
77
122
|
return false;
|
|
78
123
|
} finally {
|
|
79
124
|
bucketActionInFlight.value.delete(bucketName);
|
|
@@ -83,10 +128,10 @@ export function useMongocampBucket() {
|
|
|
83
128
|
bucketActionInFlight.value.add(bucketName);
|
|
84
129
|
try {
|
|
85
130
|
const result = await bucketApi.deleteBucket({ bucketName });
|
|
86
|
-
toast.add({ title: "
|
|
131
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.bucketDeletedTitle"), description: t("nuxtUiMongocamp.bucket.bucketDeletedDescription", { bucketName }), color: "success" });
|
|
87
132
|
return result.value;
|
|
88
|
-
} catch {
|
|
89
|
-
toast.add({ title: "
|
|
133
|
+
} catch (e) {
|
|
134
|
+
toast.add({ title: t("nuxtUiMongocamp.bucket.deleteFailedTitle"), description: e instanceof Error ? e.message : t("nuxtUiMongocamp.bucket.deleteFailedBucketFallback", { bucketName }), color: "error" });
|
|
90
135
|
return false;
|
|
91
136
|
} finally {
|
|
92
137
|
bucketActionInFlight.value.delete(bucketName);
|
|
@@ -101,6 +146,10 @@ export function useMongocampBucket() {
|
|
|
101
146
|
downloadFile,
|
|
102
147
|
uploadFile,
|
|
103
148
|
bucketActionInFlight,
|
|
149
|
+
fileActionInFlight,
|
|
150
|
+
listFiles,
|
|
151
|
+
deleteFile,
|
|
152
|
+
updateFileInformation,
|
|
104
153
|
listBuckets,
|
|
105
154
|
getBucketInfo,
|
|
106
155
|
clearBucket,
|