@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
|
@@ -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
|
roleName: { type: String, required: true }
|
|
6
7
|
});
|
|
8
|
+
const { t } = useI18n();
|
|
7
9
|
const { listRoles, updateRole, listCollections } = useMongocampAdmin();
|
|
8
10
|
const grants = ref([]);
|
|
9
11
|
const allCollections = ref([]);
|
|
@@ -20,7 +22,7 @@ const addGrantSchema = reactive([
|
|
|
20
22
|
{
|
|
21
23
|
$formkit: "nuxtUISelectMenu",
|
|
22
24
|
name: "collectionName",
|
|
23
|
-
label: "
|
|
25
|
+
label: t("nuxtUiMongocamp.roleGrants.collection"),
|
|
24
26
|
class: "w-full",
|
|
25
27
|
options: [],
|
|
26
28
|
validation: "required"
|
|
@@ -28,34 +30,34 @@ const addGrantSchema = reactive([
|
|
|
28
30
|
{
|
|
29
31
|
$formkit: "nuxtUISwitch",
|
|
30
32
|
name: "read",
|
|
31
|
-
label: "
|
|
33
|
+
label: t("nuxtUiMongocamp.roleGrants.read")
|
|
32
34
|
},
|
|
33
35
|
{
|
|
34
36
|
$formkit: "nuxtUISwitch",
|
|
35
37
|
name: "write",
|
|
36
|
-
label: "
|
|
38
|
+
label: t("nuxtUiMongocamp.roleGrants.write")
|
|
37
39
|
},
|
|
38
40
|
{
|
|
39
41
|
$formkit: "nuxtUISwitch",
|
|
40
42
|
name: "administrate",
|
|
41
|
-
label: "
|
|
43
|
+
label: t("nuxtUiMongocamp.roleGrants.administrate")
|
|
42
44
|
}
|
|
43
45
|
]);
|
|
44
46
|
const editGrantSchema = reactive([
|
|
45
47
|
{
|
|
46
48
|
$formkit: "nuxtUISwitch",
|
|
47
49
|
name: "read",
|
|
48
|
-
label: "
|
|
50
|
+
label: t("nuxtUiMongocamp.roleGrants.read")
|
|
49
51
|
},
|
|
50
52
|
{
|
|
51
53
|
$formkit: "nuxtUISwitch",
|
|
52
54
|
name: "write",
|
|
53
|
-
label: "
|
|
55
|
+
label: t("nuxtUiMongocamp.roleGrants.write")
|
|
54
56
|
},
|
|
55
57
|
{
|
|
56
58
|
$formkit: "nuxtUISwitch",
|
|
57
59
|
name: "administrate",
|
|
58
|
-
label: "
|
|
60
|
+
label: t("nuxtUiMongocamp.roleGrants.administrate")
|
|
59
61
|
}
|
|
60
62
|
]);
|
|
61
63
|
async function fetchRole() {
|
|
@@ -80,7 +82,7 @@ async function saveGrants() {
|
|
|
80
82
|
await updateRole(props.roleName, isAdmin.value, grants.value);
|
|
81
83
|
await fetchRole();
|
|
82
84
|
} catch (e) {
|
|
83
|
-
errorMessage.value = e instanceof Error ? e.message : "
|
|
85
|
+
errorMessage.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.roleGrants.errorSave");
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
async function handleAddGrant() {
|
|
@@ -133,11 +135,11 @@ function withTooltip(text, node) {
|
|
|
133
135
|
const columns = [
|
|
134
136
|
{
|
|
135
137
|
accessorKey: "name",
|
|
136
|
-
header: "
|
|
138
|
+
header: t("nuxtUiMongocamp.roleGrants.columnCollection")
|
|
137
139
|
},
|
|
138
140
|
{
|
|
139
141
|
accessorKey: "grantType",
|
|
140
|
-
header: "
|
|
142
|
+
header: t("nuxtUiMongocamp.roleGrants.columnType"),
|
|
141
143
|
cell: ({ row }) => h(UBadge, {
|
|
142
144
|
label: row.original.grantType,
|
|
143
145
|
color: "neutral",
|
|
@@ -146,27 +148,27 @@ const columns = [
|
|
|
146
148
|
},
|
|
147
149
|
{
|
|
148
150
|
accessorKey: "read",
|
|
149
|
-
header: "
|
|
151
|
+
header: t("nuxtUiMongocamp.roleGrants.columnRead"),
|
|
150
152
|
cell: ({ row }) => h(UBadge, {
|
|
151
|
-
label: row.original.read ? "
|
|
153
|
+
label: row.original.read ? t("nuxtUiMongocamp.common.yes") : t("nuxtUiMongocamp.common.no"),
|
|
152
154
|
color: row.original.read ? "success" : "neutral",
|
|
153
155
|
variant: "subtle"
|
|
154
156
|
})
|
|
155
157
|
},
|
|
156
158
|
{
|
|
157
159
|
accessorKey: "write",
|
|
158
|
-
header: "
|
|
160
|
+
header: t("nuxtUiMongocamp.roleGrants.columnWrite"),
|
|
159
161
|
cell: ({ row }) => h(UBadge, {
|
|
160
|
-
label: row.original.write ? "
|
|
162
|
+
label: row.original.write ? t("nuxtUiMongocamp.common.yes") : t("nuxtUiMongocamp.common.no"),
|
|
161
163
|
color: row.original.write ? "success" : "neutral",
|
|
162
164
|
variant: "subtle"
|
|
163
165
|
})
|
|
164
166
|
},
|
|
165
167
|
{
|
|
166
168
|
accessorKey: "administrate",
|
|
167
|
-
header: "
|
|
169
|
+
header: t("nuxtUiMongocamp.roleGrants.columnAdmin"),
|
|
168
170
|
cell: ({ row }) => h(UBadge, {
|
|
169
|
-
label: row.original.administrate ? "
|
|
171
|
+
label: row.original.administrate ? t("nuxtUiMongocamp.common.yes") : t("nuxtUiMongocamp.common.no"),
|
|
170
172
|
color: row.original.administrate ? "error" : "neutral",
|
|
171
173
|
variant: "subtle"
|
|
172
174
|
})
|
|
@@ -175,20 +177,20 @@ const columns = [
|
|
|
175
177
|
id: "actions",
|
|
176
178
|
header: "",
|
|
177
179
|
cell: ({ row }) => h("div", { class: "flex gap-1 justify-end" }, [
|
|
178
|
-
withTooltip("
|
|
180
|
+
withTooltip(t("nuxtUiMongocamp.roleGrants.editGrantTooltip"), h(UButton, {
|
|
179
181
|
"icon": "i-lucide-pencil",
|
|
180
182
|
"color": "neutral",
|
|
181
183
|
"variant": "ghost",
|
|
182
184
|
"size": "sm",
|
|
183
|
-
"aria-label": "
|
|
185
|
+
"aria-label": t("nuxtUiMongocamp.roleGrants.editGrantTooltip"),
|
|
184
186
|
"onClick": () => openEdit(row.index)
|
|
185
187
|
})),
|
|
186
|
-
withTooltip("
|
|
188
|
+
withTooltip(t("nuxtUiMongocamp.roleGrants.removeGrantTooltip"), h(UButton, {
|
|
187
189
|
"icon": "i-lucide-trash-2",
|
|
188
190
|
"color": "error",
|
|
189
191
|
"variant": "ghost",
|
|
190
192
|
"size": "sm",
|
|
191
|
-
"aria-label": "
|
|
193
|
+
"aria-label": t("nuxtUiMongocamp.roleGrants.removeGrantTooltip"),
|
|
192
194
|
"onClick": () => removeGrant(row.index)
|
|
193
195
|
}))
|
|
194
196
|
])
|
|
@@ -202,22 +204,22 @@ fetchCollections();
|
|
|
202
204
|
<div class="flex flex-col gap-4">
|
|
203
205
|
<div class="flex items-center justify-between">
|
|
204
206
|
<h2 class="text-xl font-semibold">
|
|
205
|
-
|
|
207
|
+
{{ t("nuxtUiMongocamp.roleGrants.heading", { roleName }) }}
|
|
206
208
|
</h2>
|
|
207
209
|
<div class="flex gap-2">
|
|
208
|
-
<UTooltip text="
|
|
210
|
+
<UTooltip :text="t('nuxtUiMongocamp.common.refresh')">
|
|
209
211
|
<UButton
|
|
210
212
|
icon="i-lucide-refresh-cw"
|
|
211
213
|
color="neutral"
|
|
212
214
|
variant="ghost"
|
|
213
215
|
:loading="loading"
|
|
214
|
-
aria-label="
|
|
216
|
+
:aria-label="t('nuxtUiMongocamp.common.refresh')"
|
|
215
217
|
@click="fetchRole"
|
|
216
218
|
/>
|
|
217
219
|
</UTooltip>
|
|
218
220
|
<UButton
|
|
219
221
|
icon="i-lucide-plus"
|
|
220
|
-
label="
|
|
222
|
+
:label="t('nuxtUiMongocamp.roleGrants.addGrant')"
|
|
221
223
|
@click="openAdd"
|
|
222
224
|
/>
|
|
223
225
|
</div>
|
|
@@ -232,13 +234,13 @@ fetchCollections();
|
|
|
232
234
|
<!-- Add Grant Modal -->
|
|
233
235
|
<UModal
|
|
234
236
|
v-model:open="isAddModalOpen"
|
|
235
|
-
title="
|
|
237
|
+
:title="t('nuxtUiMongocamp.roleGrants.addGrant')"
|
|
236
238
|
>
|
|
237
239
|
<template #body>
|
|
238
240
|
<FUDataEdit
|
|
239
241
|
:data="newGrant"
|
|
240
242
|
:schema="addGrantSchema"
|
|
241
|
-
submit-label="
|
|
243
|
+
:submit-label="t('nuxtUiMongocamp.roleGrants.addGrant')"
|
|
242
244
|
submit-icon="i-lucide-plus"
|
|
243
245
|
@data-saved="handleAddGrant"
|
|
244
246
|
/>
|
|
@@ -254,13 +256,13 @@ fetchCollections();
|
|
|
254
256
|
<!-- Edit Grant Modal -->
|
|
255
257
|
<UModal
|
|
256
258
|
v-model:open="isEditModalOpen"
|
|
257
|
-
:title="
|
|
259
|
+
:title="t('nuxtUiMongocamp.roleGrants.editGrantTitle', { name: editGrantName })"
|
|
258
260
|
>
|
|
259
261
|
<template #body>
|
|
260
262
|
<FUDataEdit
|
|
261
263
|
:data="editGrant"
|
|
262
264
|
:schema="editGrantSchema"
|
|
263
|
-
submit-label="
|
|
265
|
+
:submit-label="t('nuxtUiMongocamp.common.saveChanges')"
|
|
264
266
|
submit-icon="i-lucide-save"
|
|
265
267
|
@data-saved="handleEditGrant"
|
|
266
268
|
/>
|
|
@@ -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>
|