@sfxcode/nuxt-ui-mongocamp 1.5.4 → 1.5.6
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/dist/module.json +1 -1
- package/dist/runtime/components/MongocampBucketFiles.vue +4 -2
- package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +2 -2
- package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +2 -2
- package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +2 -2
- package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +2 -2
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +4 -0
- package/dist/runtime/components/MongocampCollectionData.vue +12 -5
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +4 -0
- package/dist/runtime/components/MongocampCollectionInfos.d.vue.ts +4 -1
- package/dist/runtime/components/MongocampCollectionInfos.vue +1 -0
- package/dist/runtime/components/MongocampCollectionInfos.vue.d.ts +4 -1
- package/dist/runtime/components/MongocampCollectionRename.d.vue.ts +2 -2
- package/dist/runtime/components/MongocampCollectionRename.vue.d.ts +2 -2
- package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +2 -2
- package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +2 -2
- package/dist/runtime/components/MongocampJobs.vue +14 -0
- package/dist/runtime/components/MongocampRoleGrants.vue +28 -5
- package/dist/runtime/components/MongocampRoles.vue +20 -3
- package/dist/runtime/components/MongocampServerStatus.vue +5 -1
- package/dist/runtime/components/MongocampSettings.d.vue.ts +16 -1
- package/dist/runtime/components/MongocampSettings.vue +7 -1
- package/dist/runtime/components/MongocampSettings.vue.d.ts +16 -1
- package/dist/runtime/components/MongocampUsers.vue +20 -3
- package/dist/runtime/composables/useMongocampAdmin.d.ts +4 -4
- package/dist/runtime/composables/useMongocampClientApi.d.ts +1 -13
- package/dist/runtime/composables/useMongocampPermissions.d.ts +5 -3
- package/dist/runtime/composables/useMongocampPermissions.js +9 -10
- package/dist/runtime/composables/useMongocampRoles.d.ts +5 -5
- package/dist/runtime/locales/de.json +10 -3
- package/dist/runtime/locales/en.json +10 -3
- package/dist/runtime/plugin.d.ts +1 -5
- package/dist/runtime/utils/listPagination.d.ts +29 -0
- package/dist/runtime/utils/listPagination.js +26 -0
- package/package.json +6 -5
package/dist/module.json
CHANGED
|
@@ -148,13 +148,15 @@ function makeMetadataCell() {
|
|
|
148
148
|
const metadata = row.original.metadata ?? {};
|
|
149
149
|
const keys = Object.keys(metadata);
|
|
150
150
|
if (keys.length === 0) return h("span", { class: "text-dimmed" }, "\u2014");
|
|
151
|
+
const label = keys.length === 1 ? t("nuxtUiMongocamp.bucketFiles.keyCount") : t("nuxtUiMongocamp.bucketFiles.keysCount", { count: keys.length });
|
|
151
152
|
return withTooltip(t("nuxtUiMongocamp.bucketFiles.viewMetadataTooltip"), h(UButton, {
|
|
152
153
|
"icon": "i-lucide-braces",
|
|
153
154
|
"color": "neutral",
|
|
154
155
|
"variant": "ghost",
|
|
155
156
|
"size": "xs",
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
label,
|
|
158
|
+
// Starts with the visible text, so voice control ("click 1 key") still finds it
|
|
159
|
+
"aria-label": `${label}: ${t("nuxtUiMongocamp.bucketFiles.viewMetadataTooltip")}`,
|
|
158
160
|
"onClick": () => openMetadataDetail(metadata)
|
|
159
161
|
}));
|
|
160
162
|
};
|
|
@@ -17,13 +17,13 @@ declare const __VLS_template: () => {
|
|
|
17
17
|
};
|
|
18
18
|
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
19
19
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
-
open: () => any;
|
|
21
20
|
clear: () => any;
|
|
21
|
+
open: () => any;
|
|
22
22
|
confirm: () => any;
|
|
23
23
|
selectAll: () => any;
|
|
24
24
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
25
|
-
onOpen?: (() => any) | undefined;
|
|
26
25
|
onClear?: (() => any) | undefined;
|
|
26
|
+
onOpen?: (() => any) | undefined;
|
|
27
27
|
onConfirm?: (() => any) | undefined;
|
|
28
28
|
onSelectAll?: (() => any) | undefined;
|
|
29
29
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -17,13 +17,13 @@ declare const __VLS_template: () => {
|
|
|
17
17
|
};
|
|
18
18
|
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
19
19
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
-
open: () => any;
|
|
21
20
|
clear: () => any;
|
|
21
|
+
open: () => any;
|
|
22
22
|
confirm: () => any;
|
|
23
23
|
selectAll: () => any;
|
|
24
24
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
25
|
-
onOpen?: (() => any) | undefined;
|
|
26
25
|
onClear?: (() => any) | undefined;
|
|
26
|
+
onOpen?: (() => any) | undefined;
|
|
27
27
|
onConfirm?: (() => any) | undefined;
|
|
28
28
|
onSelectAll?: (() => any) | undefined;
|
|
29
29
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -7,17 +7,17 @@ type __VLS_ModelProps = {
|
|
|
7
7
|
};
|
|
8
8
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
9
9
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
-
"update:open": (value: boolean) => any;
|
|
11
10
|
done: (payload: {
|
|
12
11
|
target: string;
|
|
13
12
|
copied: number;
|
|
14
13
|
}) => any;
|
|
14
|
+
"update:open": (value: boolean) => any;
|
|
15
15
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
16
|
-
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
17
16
|
onDone?: ((payload: {
|
|
18
17
|
target: string;
|
|
19
18
|
copied: number;
|
|
20
19
|
}) => any) | undefined;
|
|
20
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
21
21
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
22
|
declare const _default: typeof __VLS_export;
|
|
23
23
|
export default _default;
|
|
@@ -7,17 +7,17 @@ type __VLS_ModelProps = {
|
|
|
7
7
|
};
|
|
8
8
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
9
9
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
-
"update:open": (value: boolean) => any;
|
|
11
10
|
done: (payload: {
|
|
12
11
|
target: string;
|
|
13
12
|
copied: number;
|
|
14
13
|
}) => any;
|
|
14
|
+
"update:open": (value: boolean) => any;
|
|
15
15
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
16
|
-
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
17
16
|
onDone?: ((payload: {
|
|
18
17
|
target: string;
|
|
19
18
|
copied: number;
|
|
20
19
|
}) => any) | undefined;
|
|
20
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
21
21
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
22
|
declare const _default: typeof __VLS_export;
|
|
23
23
|
export default _default;
|
|
@@ -7,6 +7,8 @@ type __VLS_Props = {
|
|
|
7
7
|
hideRefresh?: boolean;
|
|
8
8
|
stickyActions?: boolean;
|
|
9
9
|
stickyId?: boolean;
|
|
10
|
+
pageSizes?: number[];
|
|
11
|
+
defaultPageSize?: number;
|
|
10
12
|
};
|
|
11
13
|
declare function init(): Promise<void>;
|
|
12
14
|
declare const __VLS_template: () => {
|
|
@@ -28,6 +30,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
28
30
|
stateKey: string;
|
|
29
31
|
stickyActions: boolean;
|
|
30
32
|
stickyId: boolean;
|
|
33
|
+
pageSizes: number[];
|
|
34
|
+
defaultPageSize: number;
|
|
31
35
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
32
36
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
33
37
|
declare const _default: typeof __VLS_export;
|
|
@@ -36,7 +36,9 @@ const props = defineProps({
|
|
|
36
36
|
stateKey: { type: String, required: false, default: "" },
|
|
37
37
|
hideRefresh: { type: Boolean, required: false, default: false },
|
|
38
38
|
stickyActions: { type: Boolean, required: false, default: true },
|
|
39
|
-
stickyId: { type: Boolean, required: false, default: false }
|
|
39
|
+
stickyId: { type: Boolean, required: false, default: false },
|
|
40
|
+
pageSizes: { type: Array, required: false, default: () => [10, 20, 50, 100] },
|
|
41
|
+
defaultPageSize: { type: Number, required: false, default: 20 }
|
|
40
42
|
});
|
|
41
43
|
const emit = defineEmits(["changed"]);
|
|
42
44
|
const { t } = useI18n();
|
|
@@ -45,7 +47,8 @@ const { documentApi } = useMongocampClientApi();
|
|
|
45
47
|
const { pagination, total } = useMongocampCollection();
|
|
46
48
|
const { state: persisted } = useMongocampPersistedState(
|
|
47
49
|
() => `collectionData:${props.collectionName}${props.stateKey ? `:${props.stateKey}` : ""}`,
|
|
48
|
-
|
|
50
|
+
// pageSize 0 = nothing remembered yet, so the collection opens with `defaultPageSize`
|
|
51
|
+
{ pageSize: 0, sort: [], hidden: [] },
|
|
49
52
|
{ storage: props.persistState ? void 0 : null }
|
|
50
53
|
);
|
|
51
54
|
const { isBucketCollection, fileIdForRow, downloadingFileIds, uploading, downloadFile, uploadFile } = useMongocampBucket();
|
|
@@ -353,7 +356,11 @@ const filterFields = computed(() => {
|
|
|
353
356
|
});
|
|
354
357
|
const sorting = ref([]);
|
|
355
358
|
const columnVisibility = ref({});
|
|
356
|
-
const
|
|
359
|
+
const pageSizeOptions = computed(() => {
|
|
360
|
+
const sizes = [...new Set(props.pageSizes.filter((size) => Number.isInteger(size) && size > 0))].sort((a, b) => a - b);
|
|
361
|
+
return sizes.length > 0 ? sizes : [10, 20, 50, 100];
|
|
362
|
+
});
|
|
363
|
+
const startPageSize = computed(() => pageSizeOptions.value.includes(props.defaultPageSize) ? props.defaultPageSize : pageSizeOptions.value[Math.min(1, pageSizeOptions.value.length - 1)]);
|
|
357
364
|
const isInitializing = ref(false);
|
|
358
365
|
const detailOpen = ref(false);
|
|
359
366
|
const compareOpen = ref(false);
|
|
@@ -796,7 +803,7 @@ async function onImported() {
|
|
|
796
803
|
async function init() {
|
|
797
804
|
distinctCache = /* @__PURE__ */ new Map();
|
|
798
805
|
isInitializing.value = true;
|
|
799
|
-
const rememberedSize =
|
|
806
|
+
const rememberedSize = pageSizeOptions.value.includes(persisted.value.pageSize) ? persisted.value.pageSize : startPageSize.value;
|
|
800
807
|
pagination.value.pageSize = rememberedSize;
|
|
801
808
|
sorting.value = (Array.isArray(persisted.value.sort) ? persisted.value.sort : []).filter((e) => typeof e?.id === "string" && e.id !== "" && typeof e.desc === "boolean");
|
|
802
809
|
pagination.value.pageIndex = 1;
|
|
@@ -955,7 +962,7 @@ defineExpose({ refresh: init });
|
|
|
955
962
|
</UDropdownMenu>
|
|
956
963
|
<USelect
|
|
957
964
|
v-model="pagination.pageSize"
|
|
958
|
-
:items="
|
|
965
|
+
:items="pageSizeOptions"
|
|
959
966
|
size="sm"
|
|
960
967
|
class="w-20"
|
|
961
968
|
:aria-label="t('nuxtUiMongocamp.collectionData.pageSizeLabel')"
|
|
@@ -7,6 +7,8 @@ type __VLS_Props = {
|
|
|
7
7
|
hideRefresh?: boolean;
|
|
8
8
|
stickyActions?: boolean;
|
|
9
9
|
stickyId?: boolean;
|
|
10
|
+
pageSizes?: number[];
|
|
11
|
+
defaultPageSize?: number;
|
|
10
12
|
};
|
|
11
13
|
declare function init(): Promise<void>;
|
|
12
14
|
declare const __VLS_template: () => {
|
|
@@ -28,6 +30,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
28
30
|
stateKey: string;
|
|
29
31
|
stickyActions: boolean;
|
|
30
32
|
stickyId: boolean;
|
|
33
|
+
pageSizes: number[];
|
|
34
|
+
defaultPageSize: number;
|
|
31
35
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
32
36
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
33
37
|
declare const _default: typeof __VLS_export;
|
|
@@ -2,7 +2,10 @@ type __VLS_Props = {
|
|
|
2
2
|
collectionName: string;
|
|
3
3
|
sampleSize?: number;
|
|
4
4
|
};
|
|
5
|
-
declare
|
|
5
|
+
declare function fetchInfo(): Promise<void>;
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
7
|
+
refresh: typeof fetchInfo;
|
|
8
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
6
9
|
sampleSize: number;
|
|
7
10
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
11
|
declare const _default: typeof __VLS_export;
|
|
@@ -223,6 +223,7 @@ const chartFieldItems = computed(() => columnDefinitions.value.filter((c) => c.c
|
|
|
223
223
|
async function refreshInfo() {
|
|
224
224
|
info.value = await collectionApi.getCollectionInformation({ collectionName: props.collectionName });
|
|
225
225
|
}
|
|
226
|
+
defineExpose({ refresh: fetchInfo });
|
|
226
227
|
</script>
|
|
227
228
|
|
|
228
229
|
<template>
|
|
@@ -2,7 +2,10 @@ type __VLS_Props = {
|
|
|
2
2
|
collectionName: string;
|
|
3
3
|
sampleSize?: number;
|
|
4
4
|
};
|
|
5
|
-
declare
|
|
5
|
+
declare function fetchInfo(): Promise<void>;
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
7
|
+
refresh: typeof fetchInfo;
|
|
8
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
6
9
|
sampleSize: number;
|
|
7
10
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
11
|
declare const _default: typeof __VLS_export;
|
|
@@ -6,17 +6,17 @@ type __VLS_ModelProps = {
|
|
|
6
6
|
};
|
|
7
7
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
8
8
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
-
"update:open": (value: boolean) => any;
|
|
10
9
|
done: (payload: {
|
|
11
10
|
source: string;
|
|
12
11
|
target: string;
|
|
13
12
|
}) => any;
|
|
13
|
+
"update:open": (value: boolean) => any;
|
|
14
14
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
15
|
-
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
16
15
|
onDone?: ((payload: {
|
|
17
16
|
source: string;
|
|
18
17
|
target: string;
|
|
19
18
|
}) => any) | undefined;
|
|
19
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
20
20
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
21
|
declare const _default: typeof __VLS_export;
|
|
22
22
|
export default _default;
|
|
@@ -6,17 +6,17 @@ type __VLS_ModelProps = {
|
|
|
6
6
|
};
|
|
7
7
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
8
8
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
-
"update:open": (value: boolean) => any;
|
|
10
9
|
done: (payload: {
|
|
11
10
|
source: string;
|
|
12
11
|
target: string;
|
|
13
12
|
}) => any;
|
|
13
|
+
"update:open": (value: boolean) => any;
|
|
14
14
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
15
|
-
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
16
15
|
onDone?: ((payload: {
|
|
17
16
|
source: string;
|
|
18
17
|
target: string;
|
|
19
18
|
}) => any) | undefined;
|
|
19
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
20
20
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
21
|
declare const _default: typeof __VLS_export;
|
|
22
22
|
export default _default;
|
|
@@ -19,11 +19,11 @@ type __VLS_ModelProps = {
|
|
|
19
19
|
};
|
|
20
20
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
21
21
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
22
|
-
"update:open": (value: boolean) => any;
|
|
23
22
|
select: (entry: PaletteEntry) => any;
|
|
23
|
+
"update:open": (value: boolean) => any;
|
|
24
24
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
25
|
-
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
26
25
|
onSelect?: ((entry: PaletteEntry) => any) | undefined;
|
|
26
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
27
27
|
}>, {
|
|
28
28
|
shortcut: string;
|
|
29
29
|
cacheMs: number;
|
|
@@ -19,11 +19,11 @@ type __VLS_ModelProps = {
|
|
|
19
19
|
};
|
|
20
20
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
21
21
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
22
|
-
"update:open": (value: boolean) => any;
|
|
23
22
|
select: (entry: PaletteEntry) => any;
|
|
23
|
+
"update:open": (value: boolean) => any;
|
|
24
24
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
25
|
-
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
26
25
|
onSelect?: ((entry: PaletteEntry) => any) | undefined;
|
|
26
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
27
27
|
}>, {
|
|
28
28
|
shortcut: string;
|
|
29
29
|
cacheMs: number;
|
|
@@ -3,6 +3,7 @@ import { computed, h, onMounted, reactive, ref, resolveComponent, watch } from "
|
|
|
3
3
|
import { useI18n, useMongocampError, useMongocampJobs, useToast } from "#imports";
|
|
4
4
|
import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
|
|
5
5
|
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
6
|
+
import { createListPagination } from "../utils/listPagination";
|
|
6
7
|
const props = defineProps({
|
|
7
8
|
autoRefresh: { type: Number, required: false, default: 0 },
|
|
8
9
|
hideHeading: { type: Boolean, required: false, default: false },
|
|
@@ -16,6 +17,7 @@ const toast = useToast();
|
|
|
16
17
|
const jobs = ref([]);
|
|
17
18
|
const loading = ref(false);
|
|
18
19
|
const sorting = ref([]);
|
|
20
|
+
const { pagination, options: paginationOptions, page, paged, pageSize } = createListPagination(() => jobs.value.length);
|
|
19
21
|
const isAddModalOpen = ref(false);
|
|
20
22
|
const isEditModalOpen = ref(false);
|
|
21
23
|
const isDeleteModalOpen = ref(false);
|
|
@@ -342,6 +344,8 @@ defineExpose({ refresh: fetchJobs });
|
|
|
342
344
|
|
|
343
345
|
<UTable
|
|
344
346
|
v-model:sorting="sorting"
|
|
347
|
+
v-model:pagination="pagination"
|
|
348
|
+
:pagination-options="paginationOptions"
|
|
345
349
|
:data="jobs"
|
|
346
350
|
:columns="columns"
|
|
347
351
|
:loading="loading"
|
|
@@ -350,6 +354,16 @@ defineExpose({ refresh: fetchJobs });
|
|
|
350
354
|
<MongocampEmptyState :title="t('nuxtUiMongocamp.empty.jobs')" />
|
|
351
355
|
</template>
|
|
352
356
|
</UTable>
|
|
357
|
+
<div
|
|
358
|
+
v-if="paged"
|
|
359
|
+
class="flex justify-end"
|
|
360
|
+
>
|
|
361
|
+
<UPagination
|
|
362
|
+
v-model:page="page"
|
|
363
|
+
:total="jobs.length"
|
|
364
|
+
:items-per-page="pageSize"
|
|
365
|
+
/>
|
|
366
|
+
</div>
|
|
353
367
|
|
|
354
368
|
<!-- Add Job Modal -->
|
|
355
369
|
<UModal
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, h, reactive, ref, resolveComponent } from "vue";
|
|
3
|
-
import { useI18n, useMongocampError } from "#imports";
|
|
3
|
+
import { useI18n, useMongocampError, useToast } from "#imports";
|
|
4
4
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
5
5
|
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
6
6
|
const props = defineProps({
|
|
@@ -67,6 +67,8 @@ const editGrantSchema = reactive([
|
|
|
67
67
|
}
|
|
68
68
|
]);
|
|
69
69
|
const loadError = ref(null);
|
|
70
|
+
const notFound = ref(false);
|
|
71
|
+
const toast = useToast();
|
|
70
72
|
const { blocked, message } = useMongocampAdminGate();
|
|
71
73
|
async function fetchRole() {
|
|
72
74
|
loading.value = true;
|
|
@@ -75,9 +77,12 @@ async function fetchRole() {
|
|
|
75
77
|
try {
|
|
76
78
|
const roles = await listRoles();
|
|
77
79
|
const role = roles.find((r) => r.name === props.roleName);
|
|
80
|
+
notFound.value = !role;
|
|
78
81
|
if (role) {
|
|
79
82
|
isAdmin.value = role.isAdmin;
|
|
80
83
|
grants.value = (role.collectionGrants ?? []).map((g) => ({ ...g }));
|
|
84
|
+
} else {
|
|
85
|
+
grants.value = [];
|
|
81
86
|
}
|
|
82
87
|
} catch (e) {
|
|
83
88
|
loadError.value = e;
|
|
@@ -130,7 +135,10 @@ async function handleEditGrant() {
|
|
|
130
135
|
if (await saveGrants(next)) isEditModalOpen.value = false;
|
|
131
136
|
}
|
|
132
137
|
async function removeGrant(index) {
|
|
133
|
-
|
|
138
|
+
const name = grants.value[index]?.name;
|
|
139
|
+
if (await saveGrants(grants.value.filter((_, i) => i !== index))) {
|
|
140
|
+
toast.add({ title: t("nuxtUiMongocamp.roleGrants.removedTitle"), description: t("nuxtUiMongocamp.roleGrants.removedDescription", { name, roleName: props.roleName }), color: "success" });
|
|
141
|
+
}
|
|
134
142
|
}
|
|
135
143
|
const missingReadCollections = computed(() => {
|
|
136
144
|
const grantedNames = new Set(grants.value.map((g) => g.name));
|
|
@@ -145,7 +153,9 @@ async function addAllReadGrants() {
|
|
|
145
153
|
grantType: "COLLECTION"
|
|
146
154
|
}));
|
|
147
155
|
if (!added.length) return;
|
|
148
|
-
await saveGrants([...grants.value, ...added])
|
|
156
|
+
if (await saveGrants([...grants.value, ...added])) {
|
|
157
|
+
toast.add({ title: t("nuxtUiMongocamp.roleGrants.addedAllReadTitle"), description: t("nuxtUiMongocamp.roleGrants.addedAllReadDescription", { count: added.length, roleName: props.roleName }, added.length), color: "success" });
|
|
158
|
+
}
|
|
149
159
|
}
|
|
150
160
|
function openAdd() {
|
|
151
161
|
const grantedNames = new Set(grants.value.map((g) => g.name));
|
|
@@ -197,7 +207,7 @@ const columns = computed(() => [
|
|
|
197
207
|
header: t("nuxtUiMongocamp.roleGrants.columnAdmin"),
|
|
198
208
|
cell: ({ row }) => h(UBadge, {
|
|
199
209
|
label: row.original.administrate ? t("nuxtUiMongocamp.common.yes") : t("nuxtUiMongocamp.common.no"),
|
|
200
|
-
color: row.original.administrate ? "
|
|
210
|
+
color: row.original.administrate ? "primary" : "neutral",
|
|
201
211
|
variant: "subtle"
|
|
202
212
|
})
|
|
203
213
|
},
|
|
@@ -266,7 +276,10 @@ defineExpose({ refresh: fetchRole });
|
|
|
266
276
|
/>
|
|
267
277
|
</UTooltip>
|
|
268
278
|
<slot name="toolbar" />
|
|
269
|
-
<UTooltip
|
|
279
|
+
<UTooltip
|
|
280
|
+
v-if="!notFound"
|
|
281
|
+
:text="t('nuxtUiMongocamp.roleGrants.addAllReadTooltip')"
|
|
282
|
+
>
|
|
270
283
|
<UButton
|
|
271
284
|
icon="i-lucide-eye"
|
|
272
285
|
color="neutral"
|
|
@@ -277,6 +290,7 @@ defineExpose({ refresh: fetchRole });
|
|
|
277
290
|
/>
|
|
278
291
|
</UTooltip>
|
|
279
292
|
<UButton
|
|
293
|
+
v-if="!notFound"
|
|
280
294
|
icon="i-lucide-plus"
|
|
281
295
|
:label="t('nuxtUiMongocamp.roleGrants.addGrant')"
|
|
282
296
|
@click="openAdd"
|
|
@@ -299,7 +313,16 @@ defineExpose({ refresh: fetchRole });
|
|
|
299
313
|
:description="saveError"
|
|
300
314
|
/>
|
|
301
315
|
|
|
316
|
+
<MongocampEmptyState
|
|
317
|
+
v-if="notFound && !loadError"
|
|
318
|
+
icon="i-lucide-shield-question"
|
|
319
|
+
:title="t('nuxtUiMongocamp.roleGrants.notFoundTitle', { roleName })"
|
|
320
|
+
:description="t('nuxtUiMongocamp.roleGrants.notFoundText')"
|
|
321
|
+
data-test="role-not-found"
|
|
322
|
+
/>
|
|
323
|
+
|
|
302
324
|
<UTable
|
|
325
|
+
v-else
|
|
303
326
|
:data="grants"
|
|
304
327
|
:columns="columns"
|
|
305
328
|
:loading="loading"
|
|
@@ -4,6 +4,7 @@ import { useI18n, useMongocampError, useMongocampPaths } from "#imports";
|
|
|
4
4
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
5
5
|
import { runBulkDelete } from "../utils/bulkDelete";
|
|
6
6
|
import { createSelectColumn } from "../utils/createSelectColumn";
|
|
7
|
+
import { createListPagination } from "../utils/listPagination";
|
|
7
8
|
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
8
9
|
const props = defineProps({
|
|
9
10
|
grantsPath: { type: String, required: false },
|
|
@@ -18,6 +19,7 @@ const roles = ref([]);
|
|
|
18
19
|
const loading = ref(false);
|
|
19
20
|
const filterText = ref("");
|
|
20
21
|
const sorting = ref([]);
|
|
22
|
+
const { pagination, options: paginationOptions, page, paged, reset: resetPage, pageSize } = createListPagination(() => roles.value.length);
|
|
21
23
|
let filterTimer;
|
|
22
24
|
const isAddModalOpen = ref(false);
|
|
23
25
|
const isEditModalOpen = ref(false);
|
|
@@ -104,7 +106,10 @@ async function fetchRoles() {
|
|
|
104
106
|
}
|
|
105
107
|
function onFilterInput() {
|
|
106
108
|
clearTimeout(filterTimer);
|
|
107
|
-
filterTimer = setTimeout(() =>
|
|
109
|
+
filterTimer = setTimeout(() => {
|
|
110
|
+
resetPage();
|
|
111
|
+
fetchRoles();
|
|
112
|
+
}, 300);
|
|
108
113
|
}
|
|
109
114
|
async function handleAddRole() {
|
|
110
115
|
errorMessage.value = "";
|
|
@@ -215,7 +220,7 @@ const columns = computed(() => [
|
|
|
215
220
|
header: t("nuxtUiMongocamp.roles.columnAdmin"),
|
|
216
221
|
cell: ({ row }) => h(UBadge, {
|
|
217
222
|
label: row.original.isAdmin ? t("nuxtUiMongocamp.common.admin") : t("nuxtUiMongocamp.common.standard"),
|
|
218
|
-
color: row.original.isAdmin ? "
|
|
223
|
+
color: row.original.isAdmin ? "primary" : "neutral",
|
|
219
224
|
variant: "subtle"
|
|
220
225
|
})
|
|
221
226
|
},
|
|
@@ -344,6 +349,8 @@ defineExpose({ refresh: fetchRoles });
|
|
|
344
349
|
<UTable
|
|
345
350
|
v-model:sorting="sorting"
|
|
346
351
|
v-model:row-selection="rowSelection"
|
|
352
|
+
v-model:pagination="pagination"
|
|
353
|
+
:pagination-options="paginationOptions"
|
|
347
354
|
:get-row-id="(row) => row.name"
|
|
348
355
|
:data="roles"
|
|
349
356
|
:columns="columns"
|
|
@@ -353,6 +360,16 @@ defineExpose({ refresh: fetchRoles });
|
|
|
353
360
|
<MongocampEmptyState :title="t('nuxtUiMongocamp.empty.roles')" />
|
|
354
361
|
</template>
|
|
355
362
|
</UTable>
|
|
363
|
+
<div
|
|
364
|
+
v-if="paged"
|
|
365
|
+
class="flex justify-end"
|
|
366
|
+
>
|
|
367
|
+
<UPagination
|
|
368
|
+
v-model:page="page"
|
|
369
|
+
:total="roles.length"
|
|
370
|
+
:items-per-page="pageSize"
|
|
371
|
+
/>
|
|
372
|
+
</div>
|
|
356
373
|
|
|
357
374
|
<!-- Add Role Modal -->
|
|
358
375
|
<UModal
|
|
@@ -472,7 +489,7 @@ defineExpose({ refresh: fetchRoles });
|
|
|
472
489
|
<div class="flex items-center gap-2">
|
|
473
490
|
<UBadge
|
|
474
491
|
:label="detail.isAdmin ? t('nuxtUiMongocamp.common.admin') : t('nuxtUiMongocamp.common.standard')"
|
|
475
|
-
:color="detail.isAdmin ? '
|
|
492
|
+
:color="detail.isAdmin ? 'primary' : 'neutral'"
|
|
476
493
|
variant="subtle"
|
|
477
494
|
/>
|
|
478
495
|
</div>
|
|
@@ -92,7 +92,6 @@ defineExpose({ refresh: quietRefresh });
|
|
|
92
92
|
:to="linkTarget || void 0"
|
|
93
93
|
class="flex flex-col gap-1.5 rounded-md text-xs"
|
|
94
94
|
:class="linkTarget ? 'hover:bg-elevated' : ''"
|
|
95
|
-
:aria-label="linkTarget ? t('nuxtUiMongocamp.serverStatus.details') : void 0"
|
|
96
95
|
data-test="server-status"
|
|
97
96
|
:data-health="health"
|
|
98
97
|
>
|
|
@@ -143,5 +142,10 @@ defineExpose({ refresh: quietRefresh });
|
|
|
143
142
|
>
|
|
144
143
|
{{ t("nuxtUiMongocamp.serverStatus.uptime", { time: formatUptime(uptimeSeconds) }) }}
|
|
145
144
|
</div>
|
|
145
|
+
<!-- The visible text names the link (an aria-label would hide it from voice control); this says where it goes -->
|
|
146
|
+
<span
|
|
147
|
+
v-if="linkTarget"
|
|
148
|
+
class="sr-only"
|
|
149
|
+
>{{ t("nuxtUiMongocamp.serverStatus.details") }}</span>
|
|
146
150
|
</component>
|
|
147
151
|
</template>
|
|
@@ -16,7 +16,16 @@ type __VLS_Props = {
|
|
|
16
16
|
/** Hide the hint that the server answers a missing grant with 401 (`AUTH_GRANT_DENIED_STATUS`). */
|
|
17
17
|
hideGrantHint?: boolean;
|
|
18
18
|
};
|
|
19
|
-
declare
|
|
19
|
+
declare function fetchSettings(): Promise<void>;
|
|
20
|
+
declare const __VLS_template: () => {
|
|
21
|
+
__VLS_Slots: {
|
|
22
|
+
toolbar?: (props: {}) => any;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
26
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
27
|
+
refresh: typeof fetchSettings;
|
|
28
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
20
29
|
hideRefresh: boolean;
|
|
21
30
|
hideHeading: boolean;
|
|
22
31
|
hidePlugins: boolean;
|
|
@@ -26,5 +35,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
26
35
|
hideMaskedNote: boolean;
|
|
27
36
|
hideGrantHint: boolean;
|
|
28
37
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
38
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
29
39
|
declare const _default: typeof __VLS_export;
|
|
30
40
|
export default _default;
|
|
41
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
42
|
+
new (): {
|
|
43
|
+
$slots: S;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -86,12 +86,13 @@ const pluginGroups = computed(() => [
|
|
|
86
86
|
{ key: "ignored", label: t("nuxtUiMongocamp.settings.ignoredPlugins"), items: plugins.value?.ignoredPlugins ?? [] }
|
|
87
87
|
]);
|
|
88
88
|
fetchSettings();
|
|
89
|
+
defineExpose({ refresh: fetchSettings });
|
|
89
90
|
</script>
|
|
90
91
|
|
|
91
92
|
<template>
|
|
92
93
|
<div class="flex flex-col gap-4">
|
|
93
94
|
<div
|
|
94
|
-
v-if="!hideHeading || isAdmin && !hideRefresh"
|
|
95
|
+
v-if="!hideHeading || isAdmin && !hideRefresh || $slots.toolbar"
|
|
95
96
|
class="flex items-center justify-between gap-4"
|
|
96
97
|
>
|
|
97
98
|
<h2
|
|
@@ -114,6 +115,7 @@ fetchSettings();
|
|
|
114
115
|
@click="fetchSettings"
|
|
115
116
|
/>
|
|
116
117
|
</UTooltip>
|
|
118
|
+
<slot name="toolbar" />
|
|
117
119
|
</div>
|
|
118
120
|
|
|
119
121
|
<UAlert
|
|
@@ -226,11 +228,15 @@ fetchSettings();
|
|
|
226
228
|
data-test="grant-hint"
|
|
227
229
|
/>
|
|
228
230
|
|
|
231
|
+
<!-- Long values make it scroll sideways: focusable and named so a keyboard can scroll it too -->
|
|
229
232
|
<UTable
|
|
230
233
|
v-if="!hideConfigurations"
|
|
231
234
|
:data="pageRows"
|
|
232
235
|
:columns="columns"
|
|
233
236
|
:loading="loading"
|
|
237
|
+
tabindex="0"
|
|
238
|
+
role="region"
|
|
239
|
+
:aria-label="t('nuxtUiMongocamp.settings.configurationsLabel')"
|
|
234
240
|
>
|
|
235
241
|
<template #empty>
|
|
236
242
|
<MongocampEmptyState :title="t('nuxtUiMongocamp.settings.empty')" />
|
|
@@ -16,7 +16,16 @@ type __VLS_Props = {
|
|
|
16
16
|
/** Hide the hint that the server answers a missing grant with 401 (`AUTH_GRANT_DENIED_STATUS`). */
|
|
17
17
|
hideGrantHint?: boolean;
|
|
18
18
|
};
|
|
19
|
-
declare
|
|
19
|
+
declare function fetchSettings(): Promise<void>;
|
|
20
|
+
declare const __VLS_template: () => {
|
|
21
|
+
__VLS_Slots: {
|
|
22
|
+
toolbar?: (props: {}) => any;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
26
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
27
|
+
refresh: typeof fetchSettings;
|
|
28
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
20
29
|
hideRefresh: boolean;
|
|
21
30
|
hideHeading: boolean;
|
|
22
31
|
hidePlugins: boolean;
|
|
@@ -26,5 +35,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
26
35
|
hideMaskedNote: boolean;
|
|
27
36
|
hideGrantHint: boolean;
|
|
28
37
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
38
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
29
39
|
declare const _default: typeof __VLS_export;
|
|
30
40
|
export default _default;
|
|
41
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
42
|
+
new (): {
|
|
43
|
+
$slots: S;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -4,6 +4,7 @@ import { useI18n, useMongocampError, useMongocampStorage, useToast } from "#impo
|
|
|
4
4
|
import useMongocampAdmin from "../composables/useMongocampAdmin";
|
|
5
5
|
import { runBulkDelete } from "../utils/bulkDelete";
|
|
6
6
|
import { createSelectColumn } from "../utils/createSelectColumn";
|
|
7
|
+
import { createListPagination } from "../utils/listPagination";
|
|
7
8
|
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
8
9
|
defineProps({
|
|
9
10
|
hideHeading: { type: Boolean, required: false },
|
|
@@ -17,6 +18,7 @@ const users = ref([]);
|
|
|
17
18
|
const loading = ref(false);
|
|
18
19
|
const filterText = ref("");
|
|
19
20
|
const sorting = ref([]);
|
|
21
|
+
const { pagination, options: paginationOptions, page, paged, reset: resetPage, pageSize } = createListPagination(() => users.value.length);
|
|
20
22
|
let filterTimer;
|
|
21
23
|
const isAddModalOpen = ref(false);
|
|
22
24
|
const isEditModalOpen = ref(false);
|
|
@@ -130,7 +132,10 @@ async function fetchUsers() {
|
|
|
130
132
|
}
|
|
131
133
|
function onFilterInput() {
|
|
132
134
|
clearTimeout(filterTimer);
|
|
133
|
-
filterTimer = setTimeout(() =>
|
|
135
|
+
filterTimer = setTimeout(() => {
|
|
136
|
+
resetPage();
|
|
137
|
+
fetchUsers();
|
|
138
|
+
}, 300);
|
|
134
139
|
}
|
|
135
140
|
async function fetchRoles() {
|
|
136
141
|
const roles = await listRoles();
|
|
@@ -289,7 +294,7 @@ const columns = computed(() => [
|
|
|
289
294
|
header: ({ column }) => sortHeader(column, t("nuxtUiMongocamp.users.columnAdmin")),
|
|
290
295
|
cell: ({ row }) => h(UBadge, {
|
|
291
296
|
label: row.original.isAdmin ? t("nuxtUiMongocamp.users.roleAdmin") : t("nuxtUiMongocamp.users.roleUser"),
|
|
292
|
-
color: row.original.isAdmin ? "
|
|
297
|
+
color: row.original.isAdmin ? "primary" : "neutral",
|
|
293
298
|
variant: "subtle"
|
|
294
299
|
})
|
|
295
300
|
},
|
|
@@ -412,6 +417,8 @@ defineExpose({ refresh: fetchUsers });
|
|
|
412
417
|
<UTable
|
|
413
418
|
v-model:sorting="sorting"
|
|
414
419
|
v-model:row-selection="rowSelection"
|
|
420
|
+
v-model:pagination="pagination"
|
|
421
|
+
:pagination-options="paginationOptions"
|
|
415
422
|
:get-row-id="(row) => row.user"
|
|
416
423
|
:row-selection-options="{ enableRowSelection: canSelectUser }"
|
|
417
424
|
:data="users"
|
|
@@ -422,6 +429,16 @@ defineExpose({ refresh: fetchUsers });
|
|
|
422
429
|
<MongocampEmptyState :title="t('nuxtUiMongocamp.empty.users')" />
|
|
423
430
|
</template>
|
|
424
431
|
</UTable>
|
|
432
|
+
<div
|
|
433
|
+
v-if="paged"
|
|
434
|
+
class="flex justify-end"
|
|
435
|
+
>
|
|
436
|
+
<UPagination
|
|
437
|
+
v-model:page="page"
|
|
438
|
+
:total="users.length"
|
|
439
|
+
:items-per-page="pageSize"
|
|
440
|
+
/>
|
|
441
|
+
</div>
|
|
425
442
|
|
|
426
443
|
<!-- Add User Modal -->
|
|
427
444
|
<UModal
|
|
@@ -582,7 +599,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
582
599
|
<div class="flex items-center gap-2">
|
|
583
600
|
<UBadge
|
|
584
601
|
:label="detail.isAdmin ? t('nuxtUiMongocamp.users.roleAdmin') : t('nuxtUiMongocamp.users.roleUser')"
|
|
585
|
-
:color="detail.isAdmin ? '
|
|
602
|
+
:color="detail.isAdmin ? 'primary' : 'neutral'"
|
|
586
603
|
variant="subtle"
|
|
587
604
|
/>
|
|
588
605
|
</div>
|
|
@@ -2,15 +2,15 @@ import type { Grant, JsonSchema, JsonValueBoolean, Role, SchemaAnalysis, UserPro
|
|
|
2
2
|
declare const _default: () => {
|
|
3
3
|
listUsers: (filter?: string) => Promise<UserProfile[]>;
|
|
4
4
|
addUser: (userId: string, password: string, apiKey?: string, roles?: string[]) => Promise<UserProfile>;
|
|
5
|
-
deleteUser: (userId: string) => Promise<
|
|
5
|
+
deleteUser: (userId: string) => Promise<any>;
|
|
6
6
|
updateUserRoles: (userId: string, roles: string[]) => Promise<UserProfile>;
|
|
7
|
-
updateUserPassword: (userId: string, password: string) => Promise<
|
|
7
|
+
updateUserPassword: (userId: string, password: string) => Promise<any>;
|
|
8
8
|
listRoles: (filter?: string) => Promise<Role[]>;
|
|
9
9
|
addRole: (name: string, isAdmin?: boolean, collectionGrants?: Grant[]) => Promise<Role>;
|
|
10
10
|
updateRole: (roleName: string, isAdmin: boolean, collectionGrants?: Grant[]) => Promise<Role>;
|
|
11
|
-
deleteRole: (roleName: string) => Promise<
|
|
11
|
+
deleteRole: (roleName: string) => Promise<any>;
|
|
12
12
|
listCollections: () => Promise<string[]>;
|
|
13
|
-
clearCollection: (collectionName: string) => Promise<
|
|
13
|
+
clearCollection: (collectionName: string) => Promise<any>;
|
|
14
14
|
deleteCollection: (collectionName: string) => Promise<JsonValueBoolean>;
|
|
15
15
|
getJsonSchema: (collectionName: string) => Promise<JsonSchema>;
|
|
16
16
|
getSchemaAnalysis: (collectionName: string, documents: number, depth?: number) => Promise<SchemaAnalysis>;
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
export declare function useMongocampClientApi():
|
|
2
|
-
adminApi: import("@sfxcode/nuxt-mongocamp-server").AdminApi;
|
|
3
|
-
applicationApi: import("@sfxcode/nuxt-mongocamp-server").ApplicationApi;
|
|
4
|
-
authApi: import("@sfxcode/nuxt-mongocamp-server").AuthApi;
|
|
5
|
-
bucketApi: import("@sfxcode/nuxt-mongocamp-server").BucketApi;
|
|
6
|
-
collectionApi: import("@sfxcode/nuxt-mongocamp-server").CollectionApi;
|
|
7
|
-
databaseApi: import("@sfxcode/nuxt-mongocamp-server").DatabaseApi;
|
|
8
|
-
documentApi: import("@sfxcode/nuxt-mongocamp-server").DocumentApi;
|
|
9
|
-
fileApi: import("@sfxcode/nuxt-mongocamp-server").FileApi;
|
|
10
|
-
indexApi: import("@sfxcode/nuxt-mongocamp-server").IndexApi;
|
|
11
|
-
systemApi: import("@sfxcode/nuxt-mongocamp-server").SystemApi;
|
|
12
|
-
jobApi: import("@sfxcode/nuxt-mongocamp-server").JobsApi;
|
|
13
|
-
};
|
|
1
|
+
export declare function useMongocampClientApi(): any;
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* `load()` asks the server (`GET /auth/permissions`, server 1.7.0), which resolves roles, grants and the signed-in
|
|
6
6
|
* user's rights itself — and also works in server proxy mode, where there is no profile. `canRead` / `canWrite` /
|
|
7
|
-
* `canAdminister` stay synchronous: they answer from what was loaded
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* `canAdminister` stay synchronous: they answer from what was loaded. After a full `load()` (no argument) a collection the
|
|
8
|
+
* server did not list has no grant ("no"); before any answer, or when it failed, they answer "yes" (fail-open — the server
|
|
9
|
+
* refuses). Admin, proxy mode, no profile and GridFS bucket members are "yes" too. **Grants are never read from the
|
|
10
|
+
* session** — neither from the token (server 1.9: only `user`/`isAdmin` are in it) nor from the stored profile, which the
|
|
11
|
+
* session cookie must not carry (4 KB cookie limit). Administrators are never asked: everything is allowed.
|
|
10
12
|
*/
|
|
11
13
|
export declare function useMongocampPermissions(): {
|
|
12
14
|
canRead: (collectionName: string) => boolean;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { useMongocampClientApi, useMongocampStorage, useState } from "#imports";
|
|
2
|
-
import {
|
|
2
|
+
import { isBucketMemberCollection } from "../utils/collectionProtection.js";
|
|
3
3
|
import { useMongocampProxyMode } from "./useMongocampProxyMode.js";
|
|
4
4
|
const REQUEST_TIMEOUT_MS = 15e3;
|
|
5
5
|
export function useMongocampPermissions() {
|
|
6
6
|
const state = useMongocampStorage();
|
|
7
|
-
const cache = useState("mongocamp-permissions", () => ({ user: "", byName: {} }));
|
|
7
|
+
const cache = useState("mongocamp-permissions", () => ({ user: "", byName: {}, complete: false }));
|
|
8
8
|
const isProxyMode = useMongocampProxyMode();
|
|
9
9
|
const currentUser = () => state.value?.profile?.user ?? "";
|
|
10
10
|
const key = (name) => name.trim().toLowerCase();
|
|
11
|
-
|
|
12
|
-
if (cache.value.user !== currentUser()) return void 0;
|
|
13
|
-
return cache.value.byName[key(collectionName)];
|
|
14
|
-
}
|
|
11
|
+
const ownCache = () => cache.value.user === currentUser();
|
|
15
12
|
function allowed(collectionName, permission) {
|
|
16
|
-
const answered =
|
|
13
|
+
const answered = ownCache() ? cache.value.byName[key(collectionName)] : void 0;
|
|
17
14
|
if (answered) return answered[permission];
|
|
18
15
|
if (isProxyMode) return true;
|
|
19
16
|
const profile = state.value?.profile;
|
|
20
17
|
if (!profile || profile.isAdmin) return true;
|
|
21
|
-
|
|
18
|
+
if (isBucketMemberCollection(collectionName)) return true;
|
|
19
|
+
return !(ownCache() && cache.value.complete);
|
|
22
20
|
}
|
|
23
21
|
const canRead = (collectionName) => allowed(collectionName, "read");
|
|
24
22
|
const canWrite = (collectionName) => allowed(collectionName, "write");
|
|
@@ -32,9 +30,10 @@ export function useMongocampPermissions() {
|
|
|
32
30
|
const { authApi } = useMongocampClientApi();
|
|
33
31
|
const rows = await authApi.userPermissions(collectionName ? { collection: collectionName } : {}, { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
|
|
34
32
|
const user = currentUser();
|
|
35
|
-
const
|
|
33
|
+
const same = cache.value.user === user;
|
|
34
|
+
const byName = same ? { ...cache.value.byName } : {};
|
|
36
35
|
for (const row of rows) byName[key(row.name)] = { read: row.read, write: row.write, administrate: row.administrate };
|
|
37
|
-
cache.value = { user, byName };
|
|
36
|
+
cache.value = { user, byName, complete: !collectionName || same && cache.value.complete };
|
|
38
37
|
} catch {
|
|
39
38
|
}
|
|
40
39
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare function useMongocampRoles(): {
|
|
2
|
-
isLoggedIn:
|
|
3
|
-
isAdmin: import("vue").ComputedRef<
|
|
4
|
-
isManager: import("vue").ComputedRef<
|
|
2
|
+
isLoggedIn: any;
|
|
3
|
+
isAdmin: import("vue").ComputedRef<any>;
|
|
4
|
+
isManager: import("vue").ComputedRef<any>;
|
|
5
5
|
isProxyMode: boolean;
|
|
6
|
-
canSeeAdmin: import("vue").ComputedRef<
|
|
7
|
-
canSeeManagement: import("vue").ComputedRef<
|
|
6
|
+
canSeeAdmin: import("vue").ComputedRef<any>;
|
|
7
|
+
canSeeManagement: import("vue").ComputedRef<any>;
|
|
8
8
|
notAllowedPath: string;
|
|
9
9
|
logoutRedirectPath: string;
|
|
10
10
|
logoutPath: string;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"adminOnly": "Dieser Bereich ist nur für Administratoren."
|
|
20
20
|
},
|
|
21
21
|
"login": {
|
|
22
|
-
"heading": "
|
|
22
|
+
"heading": "MongoCamp-Anmeldung",
|
|
23
23
|
"email": "E-Mail",
|
|
24
24
|
"password": "Passwort",
|
|
25
25
|
"submit": "Anmelden",
|
|
@@ -103,7 +103,13 @@
|
|
|
103
103
|
"columnAdmin": "Admin",
|
|
104
104
|
"editGrantTooltip": "Berechtigung bearbeiten",
|
|
105
105
|
"removeGrantTooltip": "Berechtigung entfernen",
|
|
106
|
-
"errorSave": "Berechtigungen konnten nicht gespeichert werden"
|
|
106
|
+
"errorSave": "Berechtigungen konnten nicht gespeichert werden",
|
|
107
|
+
"notFoundTitle": "Es gibt keine Rolle {roleName}",
|
|
108
|
+
"notFoundText": "Sie wurde vielleicht umbenannt oder gelöscht. Wählen Sie sie in der Rollenliste erneut aus.",
|
|
109
|
+
"removedTitle": "Recht entfernt",
|
|
110
|
+
"removedDescription": "{roleName} hat kein Recht mehr für {name}.",
|
|
111
|
+
"addedAllReadTitle": "Leserechte hinzugefügt",
|
|
112
|
+
"addedAllReadDescription": "{roleName} wurde keine Collection hinzugefügt. | {roleName} kann jetzt eine weitere Collection lesen. | {roleName} kann jetzt {count} weitere Collections lesen."
|
|
107
113
|
},
|
|
108
114
|
"collections": {
|
|
109
115
|
"heading": "Collections",
|
|
@@ -355,7 +361,8 @@
|
|
|
355
361
|
"restartNeeded": "Neustart nötig",
|
|
356
362
|
"empty": "Keine Einstellungen gefunden",
|
|
357
363
|
"grantHintTitle": "Ein fehlendes Recht wird mit 401 beantwortet",
|
|
358
|
-
"grantHint": "AUTH_GRANT_DENIED_STATUS ist 401 (der Standard). Der generierte Client hält ein 401 für eine abgelaufene Sitzung, deshalb macht dieses Modul daraus selbst ein 403 und niemand wird abgemeldet. Mit AUTH_GRANT_DENIED_STATUS=403 am Server wird 403 die eigene Antwort des Servers."
|
|
364
|
+
"grantHint": "AUTH_GRANT_DENIED_STATUS ist 401 (der Standard). Der generierte Client hält ein 401 für eine abgelaufene Sitzung, deshalb macht dieses Modul daraus selbst ein 403 und niemand wird abgemeldet. Mit AUTH_GRANT_DENIED_STATUS=403 am Server wird 403 die eigene Antwort des Servers.",
|
|
365
|
+
"configurationsLabel": "Serverkonfiguration"
|
|
359
366
|
},
|
|
360
367
|
"databases": {
|
|
361
368
|
"heading": "Datenbanken",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"adminOnly": "This area is for administrators only."
|
|
20
20
|
},
|
|
21
21
|
"login": {
|
|
22
|
-
"heading": "
|
|
22
|
+
"heading": "MongoCamp Login",
|
|
23
23
|
"email": "Email",
|
|
24
24
|
"password": "Password",
|
|
25
25
|
"submit": "Login",
|
|
@@ -103,7 +103,13 @@
|
|
|
103
103
|
"columnAdmin": "Admin",
|
|
104
104
|
"editGrantTooltip": "Edit grant",
|
|
105
105
|
"removeGrantTooltip": "Remove grant",
|
|
106
|
-
"errorSave": "Failed to save grants"
|
|
106
|
+
"errorSave": "Failed to save grants",
|
|
107
|
+
"notFoundTitle": "There is no role {roleName}",
|
|
108
|
+
"notFoundText": "It may have been renamed or deleted. Pick it again from the roles list.",
|
|
109
|
+
"removedTitle": "Grant removed",
|
|
110
|
+
"removedDescription": "{roleName} no longer has a grant for {name}.",
|
|
111
|
+
"addedAllReadTitle": "Read grants added",
|
|
112
|
+
"addedAllReadDescription": "No collection was added to {roleName}. | {roleName} can now read one more collection. | {roleName} can now read {count} more collections."
|
|
107
113
|
},
|
|
108
114
|
"collections": {
|
|
109
115
|
"heading": "Collections",
|
|
@@ -355,7 +361,8 @@
|
|
|
355
361
|
"restartNeeded": "needs restart",
|
|
356
362
|
"empty": "No settings found",
|
|
357
363
|
"grantHintTitle": "A missing grant is answered with 401",
|
|
358
|
-
"grantHint": "AUTH_GRANT_DENIED_STATUS is 401 (the default). The generated client treats a 401 as a dead session, so this module turns that answer into a 403 itself and nobody is logged out. Set AUTH_GRANT_DENIED_STATUS to 403 on the server to make 403 the server's own answer."
|
|
364
|
+
"grantHint": "AUTH_GRANT_DENIED_STATUS is 401 (the default). The generated client treats a 401 as a dead session, so this module turns that answer into a 403 itself and nobody is logged out. Set AUTH_GRANT_DENIED_STATUS to 403 on the server to make 403 the server's own answer.",
|
|
365
|
+
"configurationsLabel": "Server configuration"
|
|
359
366
|
},
|
|
360
367
|
"databases": {
|
|
361
368
|
"heading": "Databases",
|
package/dist/runtime/plugin.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
2
|
-
mongocampVersion: import("vue").Ref<import("@sfxcode/nuxt-mongocamp-server").Version | undefined, import("@sfxcode/nuxt-mongocamp-server").Version | undefined>;
|
|
3
|
-
}> & import("nuxt/app").ObjectPlugin<{
|
|
4
|
-
mongocampVersion: import("vue").Ref<import("@sfxcode/nuxt-mongocamp-server").Version | undefined, import("@sfxcode/nuxt-mongocamp-server").Version | undefined>;
|
|
5
|
-
}>;
|
|
1
|
+
declare const _default: any;
|
|
6
2
|
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Rows per page of the users, roles and jobs tables. */
|
|
2
|
+
export declare const LIST_PAGE_SIZE = 25;
|
|
3
|
+
/**
|
|
4
|
+
* Client-side paging for a `UTable` whose rows are all loaded (users, roles, jobs). The table pages its *sorted*
|
|
5
|
+
* rows, so a header sort still orders the whole list; row selection is kept by row id across pages, and the
|
|
6
|
+
* select-all box selects the page on screen. `total` is the row count after any search: a new search starts at the
|
|
7
|
+
* first page, and a shorter list (after a delete) never leaves the page past the end.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createListPagination(total: () => number, pageSize?: number): {
|
|
10
|
+
pagination: import("vue").Ref<{
|
|
11
|
+
pageIndex: number;
|
|
12
|
+
pageSize: number;
|
|
13
|
+
}, {
|
|
14
|
+
pageIndex: number;
|
|
15
|
+
pageSize: number;
|
|
16
|
+
} | {
|
|
17
|
+
pageIndex: number;
|
|
18
|
+
pageSize: number;
|
|
19
|
+
}>;
|
|
20
|
+
options: {
|
|
21
|
+
getPaginationRowModel: (table: import("@tanstack/table-core").Table<unknown>) => () => import("@tanstack/table-core").RowModel<unknown>;
|
|
22
|
+
};
|
|
23
|
+
/** 1-based, for `UPagination` */
|
|
24
|
+
page: import("vue").WritableComputedRef<number, number>;
|
|
25
|
+
/** Whether a pager is worth showing */
|
|
26
|
+
paged: import("vue").ComputedRef<boolean>;
|
|
27
|
+
reset: () => void;
|
|
28
|
+
pageSize: number;
|
|
29
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { computed, ref, watch } from "vue";
|
|
2
|
+
import { getPaginationRowModel } from "@tanstack/vue-table";
|
|
3
|
+
export const LIST_PAGE_SIZE = 25;
|
|
4
|
+
export function createListPagination(total, pageSize = LIST_PAGE_SIZE) {
|
|
5
|
+
const pagination = ref({ pageIndex: 0, pageSize });
|
|
6
|
+
const pageCount = computed(() => Math.max(1, Math.ceil(total() / pageSize)));
|
|
7
|
+
const goTo = (pageIndex) => {
|
|
8
|
+
pagination.value = { pageIndex, pageSize };
|
|
9
|
+
};
|
|
10
|
+
watch(total, (count, before) => {
|
|
11
|
+
if (count !== before && pagination.value.pageIndex >= pageCount.value) goTo(pageCount.value - 1);
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
pagination,
|
|
15
|
+
options: { getPaginationRowModel: getPaginationRowModel() },
|
|
16
|
+
/** 1-based, for `UPagination` */
|
|
17
|
+
page: computed({
|
|
18
|
+
get: () => pagination.value.pageIndex + 1,
|
|
19
|
+
set: (value) => goTo(Math.min(Math.max(value, 1), pageCount.value) - 1)
|
|
20
|
+
}),
|
|
21
|
+
/** Whether a pager is worth showing */
|
|
22
|
+
paged: computed(() => total() > pageSize),
|
|
23
|
+
reset: () => goTo(0),
|
|
24
|
+
pageSize
|
|
25
|
+
};
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfxcode/nuxt-ui-mongocamp",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.6",
|
|
4
4
|
"description": "A Nuxt module that wraps @sfxcode/nuxt-mongocamp-server with ready-made UI components, composables, and a runtime plugin",
|
|
5
5
|
"repository": "sfxcode/nuxt-ui-mongocamp",
|
|
6
6
|
"homepage": "https://sfxcode.github.io/nuxt-ui-mongocamp/",
|
|
@@ -66,17 +66,18 @@
|
|
|
66
66
|
"@internationalized/date": "^3.12.4",
|
|
67
67
|
"@nuxt/ui": "^4.12.0",
|
|
68
68
|
"@nuxtjs/i18n": "^10.6.0",
|
|
69
|
-
"@sfxcode/nuxt-mongocamp-server": "^1.9.
|
|
69
|
+
"@sfxcode/nuxt-mongocamp-server": "^1.9.2",
|
|
70
70
|
"@sfxcode/nuxt-ui-formkit": "^1.4.2",
|
|
71
71
|
"@tanstack/charts": "^1.5.0",
|
|
72
|
+
"@tanstack/vue-table": "^8.21.3",
|
|
72
73
|
"consola": "^3.4.2",
|
|
73
74
|
"defu": "^6.1.7",
|
|
74
75
|
"minimatch": "^11.0.8",
|
|
75
76
|
"unocss-nuxt-ui": "^1.3.0"
|
|
76
77
|
},
|
|
77
78
|
"devDependencies": {
|
|
78
|
-
"@iconify-json/lucide": "^1.2.
|
|
79
|
-
"@nuxt/devtools": "^4.
|
|
79
|
+
"@iconify-json/lucide": "^1.2.155",
|
|
80
|
+
"@nuxt/devtools": "^4.2.0",
|
|
80
81
|
"@nuxt/eslint-config": "^1.17.0",
|
|
81
82
|
"@nuxt/kit": "^4.6.4",
|
|
82
83
|
"@nuxt/module-builder": "^1.0.4",
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
"@playwright/test": "^1.65.1",
|
|
86
87
|
"@types/node": "latest",
|
|
87
88
|
"@unhead/vue": "^3.4.3",
|
|
88
|
-
"@vue/test-utils": "^2.
|
|
89
|
+
"@vue/test-utils": "^2.6.0",
|
|
89
90
|
"changelogen": "^0.6.2",
|
|
90
91
|
"eslint": "^10.15.0",
|
|
91
92
|
"happy-dom": "^21.0.4",
|