@sfxcode/nuxt-ui-mongocamp 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/module.d.mts +12 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +18 -5
- package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +6 -0
- package/dist/runtime/components/MongocampAggregationBuilder.vue +390 -0
- package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +6 -0
- package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +11 -1
- package/dist/runtime/components/MongocampBulkDelete.vue +1 -0
- package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +11 -1
- package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +29 -0
- package/dist/runtime/components/MongocampBulkEdit.vue +138 -0
- package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +29 -0
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +4 -1
- package/dist/runtime/components/MongocampCollectionData.vue +167 -4
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +4 -1
- package/dist/runtime/components/MongocampCollectionInfos.vue +266 -8
- package/dist/runtime/components/MongocampCollections.d.vue.ts +8 -1
- package/dist/runtime/components/MongocampCollections.vue +84 -72
- package/dist/runtime/components/MongocampCollections.vue.d.ts +8 -1
- package/dist/runtime/components/MongocampConfirmByName.d.vue.ts +23 -0
- package/dist/runtime/components/MongocampConfirmByName.vue +92 -0
- package/dist/runtime/components/MongocampConfirmByName.vue.d.ts +23 -0
- package/dist/runtime/components/MongocampErrorAlert.vue +28 -5
- package/dist/runtime/components/MongocampFilterBuilder.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampFilterBuilder.vue +33 -2
- package/dist/runtime/components/MongocampFilterBuilder.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampGrantList.d.vue.ts +7 -0
- package/dist/runtime/components/MongocampGrantList.vue +38 -0
- package/dist/runtime/components/MongocampGrantList.vue.d.ts +7 -0
- package/dist/runtime/components/MongocampImport.d.vue.ts +10 -0
- package/dist/runtime/components/MongocampImport.vue +479 -0
- package/dist/runtime/components/MongocampImport.vue.d.ts +10 -0
- package/dist/runtime/components/MongocampRoles.vue +45 -0
- package/dist/runtime/components/MongocampSettings.d.vue.ts +3 -0
- package/dist/runtime/components/MongocampSettings.vue +179 -0
- package/dist/runtime/components/MongocampSettings.vue.d.ts +3 -0
- package/dist/runtime/components/MongocampUsers.vue +183 -3
- package/dist/runtime/composables/useMongocampAdmin.d.ts +7 -1
- package/dist/runtime/composables/useMongocampAdmin.js +24 -1
- package/dist/runtime/composables/useMongocampAggregation.d.ts +28 -0
- package/dist/runtime/composables/useMongocampAggregation.js +100 -0
- package/dist/runtime/composables/useMongocampBucket.js +1 -1
- package/dist/runtime/composables/useMongocampBulkDelete.d.ts +1 -1
- package/dist/runtime/composables/useMongocampImport.d.ts +14 -0
- package/dist/runtime/composables/useMongocampImport.js +25 -0
- package/dist/runtime/composables/useMongocampIndex.d.ts +1 -0
- package/dist/runtime/composables/useMongocampIndex.js +8 -1
- package/dist/runtime/composables/useMongocampRoles.d.ts +1 -0
- package/dist/runtime/composables/useMongocampRoles.js +3 -2
- package/dist/runtime/composables/useMongocampSession.d.ts +8 -0
- package/dist/runtime/composables/useMongocampSession.js +45 -0
- package/dist/runtime/composables/useMongocampSystem.d.ts +15 -3
- package/dist/runtime/composables/useMongocampSystem.js +19 -2
- package/dist/runtime/locales/de.json +200 -3
- package/dist/runtime/locales/en.json +200 -3
- package/dist/runtime/plugin.js +19 -0
- package/dist/runtime/utils/aggregationErrors.d.ts +10 -0
- package/dist/runtime/utils/aggregationErrors.js +17 -0
- package/dist/runtime/utils/aggregationPipeline.d.ts +42 -0
- package/dist/runtime/utils/aggregationPipeline.js +118 -0
- package/dist/runtime/utils/aggregationResult.d.ts +5 -0
- package/dist/runtime/utils/aggregationResult.js +17 -0
- package/dist/runtime/utils/analyzeSamples.d.ts +27 -0
- package/dist/runtime/utils/analyzeSamples.js +92 -0
- package/dist/runtime/utils/batchInsert.d.ts +22 -0
- package/dist/runtime/utils/batchInsert.js +24 -0
- package/dist/runtime/utils/bulkDelete.d.ts +6 -1
- package/dist/runtime/utils/bulkDelete.js +28 -4
- package/dist/runtime/utils/bulkEdit.d.ts +27 -0
- package/dist/runtime/utils/bulkEdit.js +45 -0
- package/dist/runtime/utils/collectionProtection.d.ts +3 -0
- package/dist/runtime/utils/collectionProtection.js +7 -0
- package/dist/runtime/utils/configRows.d.ts +11 -0
- package/dist/runtime/utils/configRows.js +53 -0
- package/dist/runtime/utils/failureKind.d.ts +3 -0
- package/dist/runtime/utils/failureKind.js +11 -0
- package/dist/runtime/utils/filterSuggestions.d.ts +8 -0
- package/dist/runtime/utils/filterSuggestions.js +15 -0
- package/dist/runtime/utils/importPipeline.d.ts +21 -0
- package/dist/runtime/utils/importPipeline.js +52 -0
- package/dist/runtime/utils/importRows.d.ts +36 -0
- package/dist/runtime/utils/importRows.js +228 -0
- package/dist/runtime/utils/jwtExpiry.d.ts +3 -0
- package/dist/runtime/utils/jwtExpiry.js +31 -0
- package/dist/runtime/utils/objectId.d.ts +1 -0
- package/dist/runtime/utils/objectId.js +4 -0
- package/dist/runtime/utils/serverProbe.d.ts +10 -0
- package/dist/runtime/utils/serverProbe.js +25 -0
- package/dist/runtime/utils/sessionGuard.d.ts +10 -0
- package/dist/runtime/utils/sessionGuard.js +10 -0
- package/dist/runtime/utils/throttled.d.ts +6 -0
- package/dist/runtime/utils/throttled.js +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ The `mongocamp` key is forwarded to `@sfxcode/nuxt-mongocamp-server`. Set `MONGO
|
|
|
52
52
|
|
|
53
53
|
## Components
|
|
54
54
|
|
|
55
|
-
All components are auto-imported. The sections below cover the main ones; the [component reference](https://sfxcode.github.io/nuxt-ui-mongocamp/components/) lists every component, including `MongocampDashboard` (admin landing page), `MongocampJobs`, `MongocampAccount`, `MongocampDatabases`, `MongocampBucketFiles`, and the building blocks `MongocampFilterBuilder`, `MongocampBulkDelete`, `MongocampErrorAlert` and `MongocampEmptyState`.
|
|
55
|
+
All components are auto-imported. The sections below cover the main ones; the [component reference](https://sfxcode.github.io/nuxt-ui-mongocamp/components/) lists every component, including `MongocampDashboard` (admin landing page), `MongocampJobs`, `MongocampAccount`, `MongocampDatabases`, `MongocampBucketFiles`, and the building blocks `MongocampFilterBuilder`, `MongocampBulkDelete`, `MongocampBulkEdit`, `MongocampImport`, `MongocampAggregationBuilder`, `MongocampConfirmByName`, `MongocampErrorAlert` and `MongocampEmptyState`.
|
|
56
56
|
|
|
57
57
|
### `<MongocampLogin />`
|
|
58
58
|
|
package/dist/module.d.mts
CHANGED
|
@@ -18,6 +18,18 @@ interface ModuleOptions {
|
|
|
18
18
|
* by the middleware itself, so it can never cause a redirect loop.
|
|
19
19
|
*/
|
|
20
20
|
logoutPath?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Opt-in dead-session guard: a route middleware that clears a session whose token says it has
|
|
23
|
+
* expired (the JWT `exp`, never verified) and sends the user to `loginPath` when the route they
|
|
24
|
+
* asked for needs a login. An unreadable token is never treated as expired. No effect in
|
|
25
|
+
* server proxy mode (there is no login).
|
|
26
|
+
*/
|
|
27
|
+
sessionGuard?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Path the session guard navigates to after clearing an expired session — e.g. '/login'. Always
|
|
30
|
+
* treated as allowed by the middleware itself, so it can never cause a redirect loop.
|
|
31
|
+
*/
|
|
32
|
+
loginPath?: string;
|
|
21
33
|
/**
|
|
22
34
|
* Roles with management access
|
|
23
35
|
*/
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,6 +2,21 @@ import { createResolver, defineNuxtModule, addPlugin, addComponentsDir, addImpor
|
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
import { consola } from 'consola';
|
|
4
4
|
|
|
5
|
+
function optionWarnings(options) {
|
|
6
|
+
const warnings = [];
|
|
7
|
+
if (options.useServerProxy && options.useGlobalAuthMiddleware) {
|
|
8
|
+
warnings.push(
|
|
9
|
+
"[nuxt-ui-mongocamp] `useServerProxy` and `useGlobalAuthMiddleware` are both enabled. Server proxy mode has no login/session, so `isLoggedIn`/`isAdmin`/`isManager` can never become true \u2014 every route matched by `securedRouteParts`, `managementRouteParts`, or `adminRouteParts` will be permanently unreachable."
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
if (options.useServerProxy && options.sessionGuard) {
|
|
13
|
+
warnings.push(
|
|
14
|
+
"[nuxt-ui-mongocamp] `sessionGuard` has no effect together with `useServerProxy`: server proxy mode has no login, token or session to guard."
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
return warnings;
|
|
18
|
+
}
|
|
19
|
+
|
|
5
20
|
const { resolve } = createResolver(import.meta.url);
|
|
6
21
|
const runtimeDir = resolve("./runtime");
|
|
7
22
|
const module$1 = defineNuxtModule({
|
|
@@ -18,6 +33,8 @@ const module$1 = defineNuxtModule({
|
|
|
18
33
|
notAllowedPath: "/",
|
|
19
34
|
logoutRedirectPath: "/",
|
|
20
35
|
logoutPath: "/logout",
|
|
36
|
+
sessionGuard: false,
|
|
37
|
+
loginPath: "/",
|
|
21
38
|
managerRoles: [],
|
|
22
39
|
securedRouteParts: [],
|
|
23
40
|
managementRouteParts: [],
|
|
@@ -65,11 +82,7 @@ const module$1 = defineNuxtModule({
|
|
|
65
82
|
]
|
|
66
83
|
});
|
|
67
84
|
});
|
|
68
|
-
|
|
69
|
-
consola.warn(
|
|
70
|
-
"[nuxt-ui-mongocamp] `useServerProxy` and `useGlobalAuthMiddleware` are both enabled. Server proxy mode has no login/session, so `isLoggedIn`/`isAdmin`/`isManager` can never become true \u2014 every route matched by `securedRouteParts`, `managementRouteParts`, or `adminRouteParts` will be permanently unreachable."
|
|
71
|
-
);
|
|
72
|
-
}
|
|
85
|
+
for (const warning of optionWarnings(options)) consola.warn(warning);
|
|
73
86
|
addPlugin(resolve(runtimeDir, "plugin"));
|
|
74
87
|
addComponentsDir({ path: resolve(runtimeDir, "components") });
|
|
75
88
|
addImportsDir(resolve(runtimeDir, "composables"));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
collectionName: string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, h, ref, watch } from "vue";
|
|
3
|
+
import { useI18n } from "#imports";
|
|
4
|
+
import { useMongocampAggregation } from "../composables/useMongocampAggregation";
|
|
5
|
+
import {
|
|
6
|
+
VISUAL_STAGE_TYPES,
|
|
7
|
+
buildPipeline,
|
|
8
|
+
findForbidden,
|
|
9
|
+
parsePipeline,
|
|
10
|
+
pipelineToText,
|
|
11
|
+
toVisualStages,
|
|
12
|
+
validateStages
|
|
13
|
+
} from "../utils/aggregationPipeline";
|
|
14
|
+
import { formatCell, resultColumns } from "../utils/aggregationResult";
|
|
15
|
+
import { downloadTextFile, rowsToCsv } from "../utils/exportRows";
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
collectionName: { type: String, required: true }
|
|
18
|
+
});
|
|
19
|
+
const PAGE_SIZES = [10, 20, 50, 100];
|
|
20
|
+
const JSON_PLACEHOLDER = '[ { "$match": { } }, { "$limit": 10 } ]';
|
|
21
|
+
const DEFAULT_TEXT = {
|
|
22
|
+
$match: "{}",
|
|
23
|
+
$group: '{ "_id": "$field", "count": { "$sum": 1 } }',
|
|
24
|
+
$sort: '{ "count": -1 }',
|
|
25
|
+
$project: "{}",
|
|
26
|
+
$limit: "10"
|
|
27
|
+
};
|
|
28
|
+
const { t } = useI18n();
|
|
29
|
+
const { runAggregation, describeAggregationError } = useMongocampAggregation();
|
|
30
|
+
let idCounter = 0;
|
|
31
|
+
function newId() {
|
|
32
|
+
return `stage-${idCounter++}`;
|
|
33
|
+
}
|
|
34
|
+
const mode = ref("visual");
|
|
35
|
+
const drafts = ref([{ id: newId(), type: "$match", text: DEFAULT_TEXT.$match }]);
|
|
36
|
+
const rawText = ref("[]");
|
|
37
|
+
const newStageType = ref("$group");
|
|
38
|
+
const modeError = ref("");
|
|
39
|
+
const rowsPerPage = ref(20);
|
|
40
|
+
const page = ref(1);
|
|
41
|
+
const running = ref(false);
|
|
42
|
+
const result = ref(null);
|
|
43
|
+
const runError = ref(null);
|
|
44
|
+
let lastPipeline = null;
|
|
45
|
+
let runCounter = 0;
|
|
46
|
+
const draftStates = computed(() => drafts.value.map((draft) => {
|
|
47
|
+
const stage = { id: draft.id, type: draft.type, value: void 0 };
|
|
48
|
+
if (draft.text.trim() === "") return { stage };
|
|
49
|
+
try {
|
|
50
|
+
stage.value = JSON.parse(draft.text);
|
|
51
|
+
} catch {
|
|
52
|
+
return { stage, error: t("nuxtUiMongocamp.aggregation.stageErrors.invalid-json") };
|
|
53
|
+
}
|
|
54
|
+
const issue = validateStages([stage])[0];
|
|
55
|
+
if (issue) return { stage, error: t(`nuxtUiMongocamp.aggregation.stageErrors.${issue.code}`) };
|
|
56
|
+
const forbidden = findForbidden(buildPipeline([stage]))[0];
|
|
57
|
+
if (forbidden) return { stage, error: t("nuxtUiMongocamp.aggregation.stageErrors.forbidden", { operator: forbidden.operator }) };
|
|
58
|
+
return { stage };
|
|
59
|
+
}));
|
|
60
|
+
function stageLabel(type) {
|
|
61
|
+
return t(`nuxtUiMongocamp.aggregation.stageTypes.${type}`);
|
|
62
|
+
}
|
|
63
|
+
const stageTypeItems = computed(() => VISUAL_STAGE_TYPES.map((type) => ({ label: stageLabel(type), value: type })));
|
|
64
|
+
function addStage() {
|
|
65
|
+
drafts.value = [...drafts.value, { id: newId(), type: newStageType.value, text: DEFAULT_TEXT[newStageType.value] }];
|
|
66
|
+
}
|
|
67
|
+
function removeStage(index) {
|
|
68
|
+
drafts.value = drafts.value.filter((_, i) => i !== index);
|
|
69
|
+
}
|
|
70
|
+
function moveStage(index, offset) {
|
|
71
|
+
const target = index + offset;
|
|
72
|
+
if (target < 0 || target >= drafts.value.length) return;
|
|
73
|
+
const next = [...drafts.value];
|
|
74
|
+
[next[index], next[target]] = [next[target], next[index]];
|
|
75
|
+
drafts.value = next;
|
|
76
|
+
}
|
|
77
|
+
function pipelineErrorText(error) {
|
|
78
|
+
const n = (error.stageIndex ?? 0) + 1;
|
|
79
|
+
return t(`nuxtUiMongocamp.aggregation.pipelineErrors.${error.code}`, { n, operator: error.operator ?? "" });
|
|
80
|
+
}
|
|
81
|
+
const pipelineState = computed(() => {
|
|
82
|
+
if (mode.value === "visual") {
|
|
83
|
+
if (draftStates.value.some((state) => state.error)) return { error: t("nuxtUiMongocamp.aggregation.fixStages") };
|
|
84
|
+
return { pipeline: buildPipeline(draftStates.value.map((state) => state.stage)) };
|
|
85
|
+
}
|
|
86
|
+
const parsed = parsePipeline(rawText.value);
|
|
87
|
+
return parsed.ok ? { pipeline: parsed.pipeline } : { error: pipelineErrorText(parsed.error) };
|
|
88
|
+
});
|
|
89
|
+
const canRun = computed(() => pipelineState.value.pipeline !== void 0 && !running.value);
|
|
90
|
+
function switchMode(next) {
|
|
91
|
+
modeError.value = "";
|
|
92
|
+
if (next === mode.value) return;
|
|
93
|
+
if (next === "json") {
|
|
94
|
+
if (draftStates.value.some((state) => state.error)) {
|
|
95
|
+
modeError.value = t("nuxtUiMongocamp.aggregation.fixStagesFirst");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
rawText.value = pipelineToText(buildPipeline(draftStates.value.map((state) => state.stage)));
|
|
99
|
+
mode.value = "json";
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const parsed = parsePipeline(rawText.value);
|
|
103
|
+
if (!parsed.ok) {
|
|
104
|
+
modeError.value = pipelineErrorText(parsed.error);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const stages = toVisualStages(parsed.pipeline, () => newId());
|
|
108
|
+
if (!stages) {
|
|
109
|
+
modeError.value = t("nuxtUiMongocamp.aggregation.cannotShowVisually");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
drafts.value = stages.map((stage) => ({ id: stage.id, type: stage.type, text: JSON.stringify(stage.value, null, 2) }));
|
|
113
|
+
mode.value = "visual";
|
|
114
|
+
}
|
|
115
|
+
async function execute(pageNumber) {
|
|
116
|
+
if (!lastPipeline) return;
|
|
117
|
+
const run = ++runCounter;
|
|
118
|
+
running.value = true;
|
|
119
|
+
runError.value = null;
|
|
120
|
+
try {
|
|
121
|
+
const outcome = await runAggregation(props.collectionName, lastPipeline, { page: pageNumber, rowsPerPage: rowsPerPage.value });
|
|
122
|
+
if (run !== runCounter) return;
|
|
123
|
+
result.value = outcome;
|
|
124
|
+
page.value = outcome.page;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
const described = await describeAggregationError(error);
|
|
127
|
+
if (run !== runCounter) return;
|
|
128
|
+
result.value = null;
|
|
129
|
+
runError.value = described;
|
|
130
|
+
} finally {
|
|
131
|
+
if (run === runCounter) running.value = false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async function runPipeline() {
|
|
135
|
+
const pipeline = pipelineState.value.pipeline;
|
|
136
|
+
if (!pipeline || running.value) return;
|
|
137
|
+
lastPipeline = pipeline;
|
|
138
|
+
await execute(1);
|
|
139
|
+
}
|
|
140
|
+
function onPageChange(next) {
|
|
141
|
+
page.value = next;
|
|
142
|
+
void execute(next);
|
|
143
|
+
}
|
|
144
|
+
function onPageSizeChange(size) {
|
|
145
|
+
rowsPerPage.value = size;
|
|
146
|
+
void execute(1);
|
|
147
|
+
}
|
|
148
|
+
watch(() => props.collectionName, () => {
|
|
149
|
+
runCounter++;
|
|
150
|
+
lastPipeline = null;
|
|
151
|
+
result.value = null;
|
|
152
|
+
runError.value = null;
|
|
153
|
+
running.value = false;
|
|
154
|
+
page.value = 1;
|
|
155
|
+
});
|
|
156
|
+
const columnKeys = computed(() => resultColumns(result.value?.rows ?? []));
|
|
157
|
+
const tableColumns = computed(() => columnKeys.value.map((key) => ({
|
|
158
|
+
id: key,
|
|
159
|
+
header: key,
|
|
160
|
+
// keys can contain dots, which an accessorKey would read as a path
|
|
161
|
+
accessorFn: (row) => row[key],
|
|
162
|
+
cell: ({ getValue }) => {
|
|
163
|
+
const { text, full } = formatCell(getValue());
|
|
164
|
+
return h("span", { title: full === text ? void 0 : full, class: "font-mono text-xs" }, text);
|
|
165
|
+
}
|
|
166
|
+
})));
|
|
167
|
+
function exportPage(format) {
|
|
168
|
+
const rows = result.value?.rows ?? [];
|
|
169
|
+
if (format === "json") {
|
|
170
|
+
downloadTextFile(`${props.collectionName}-aggregation.json`, JSON.stringify(rows, null, 2), "application/json");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
downloadTextFile(`${props.collectionName}-aggregation.csv`, rowsToCsv(rows, columnKeys.value), "text/csv");
|
|
174
|
+
}
|
|
175
|
+
const exportMenuItems = computed(() => [
|
|
176
|
+
{ label: t("nuxtUiMongocamp.aggregation.exportJson"), icon: "i-lucide-file-json", onSelect: () => exportPage("json") },
|
|
177
|
+
{ label: t("nuxtUiMongocamp.aggregation.exportCsv"), icon: "i-lucide-file-spreadsheet", onSelect: () => exportPage("csv") }
|
|
178
|
+
]);
|
|
179
|
+
</script>
|
|
180
|
+
|
|
181
|
+
<template>
|
|
182
|
+
<div class="flex flex-col gap-4">
|
|
183
|
+
<div class="flex flex-wrap items-center justify-between gap-2">
|
|
184
|
+
<div class="flex items-center gap-1">
|
|
185
|
+
<UButton
|
|
186
|
+
color="neutral"
|
|
187
|
+
size="sm"
|
|
188
|
+
:variant="mode === 'visual' ? 'subtle' : 'ghost'"
|
|
189
|
+
:aria-pressed="mode === 'visual'"
|
|
190
|
+
:label="t('nuxtUiMongocamp.aggregation.modeVisual')"
|
|
191
|
+
@click="switchMode('visual')"
|
|
192
|
+
/>
|
|
193
|
+
<UButton
|
|
194
|
+
color="neutral"
|
|
195
|
+
size="sm"
|
|
196
|
+
:variant="mode === 'json' ? 'subtle' : 'ghost'"
|
|
197
|
+
:aria-pressed="mode === 'json'"
|
|
198
|
+
:label="t('nuxtUiMongocamp.aggregation.modeJson')"
|
|
199
|
+
@click="switchMode('json')"
|
|
200
|
+
/>
|
|
201
|
+
</div>
|
|
202
|
+
<UButton
|
|
203
|
+
icon="i-lucide-play"
|
|
204
|
+
:label="t('nuxtUiMongocamp.aggregation.run')"
|
|
205
|
+
:loading="running"
|
|
206
|
+
:disabled="!canRun"
|
|
207
|
+
@click="runPipeline"
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<UAlert
|
|
212
|
+
v-if="modeError"
|
|
213
|
+
color="warning"
|
|
214
|
+
variant="subtle"
|
|
215
|
+
icon="i-lucide-triangle-alert"
|
|
216
|
+
:description="modeError"
|
|
217
|
+
/>
|
|
218
|
+
|
|
219
|
+
<div
|
|
220
|
+
v-if="mode === 'visual'"
|
|
221
|
+
class="flex flex-col gap-3"
|
|
222
|
+
>
|
|
223
|
+
<div
|
|
224
|
+
v-for="(draft, index) in drafts"
|
|
225
|
+
:key="draft.id"
|
|
226
|
+
class="flex flex-col gap-2 rounded-md border border-default p-3"
|
|
227
|
+
>
|
|
228
|
+
<div class="flex items-center justify-between gap-2">
|
|
229
|
+
<span class="text-sm font-medium">
|
|
230
|
+
{{ t("nuxtUiMongocamp.aggregation.stageTitle", { n: index + 1 }) }}
|
|
231
|
+
<code class="ml-1 font-mono text-xs">{{ draft.type }}</code>
|
|
232
|
+
</span>
|
|
233
|
+
<div class="flex items-center">
|
|
234
|
+
<UButton
|
|
235
|
+
icon="i-lucide-arrow-up"
|
|
236
|
+
color="neutral"
|
|
237
|
+
variant="ghost"
|
|
238
|
+
size="sm"
|
|
239
|
+
:disabled="index === 0"
|
|
240
|
+
:aria-label="t('nuxtUiMongocamp.aggregation.moveUp')"
|
|
241
|
+
@click="moveStage(index, -1)"
|
|
242
|
+
/>
|
|
243
|
+
<UButton
|
|
244
|
+
icon="i-lucide-arrow-down"
|
|
245
|
+
color="neutral"
|
|
246
|
+
variant="ghost"
|
|
247
|
+
size="sm"
|
|
248
|
+
:disabled="index === drafts.length - 1"
|
|
249
|
+
:aria-label="t('nuxtUiMongocamp.aggregation.moveDown')"
|
|
250
|
+
@click="moveStage(index, 1)"
|
|
251
|
+
/>
|
|
252
|
+
<UButton
|
|
253
|
+
icon="i-lucide-x"
|
|
254
|
+
color="neutral"
|
|
255
|
+
variant="ghost"
|
|
256
|
+
size="sm"
|
|
257
|
+
:aria-label="t('nuxtUiMongocamp.aggregation.removeStage')"
|
|
258
|
+
@click="removeStage(index)"
|
|
259
|
+
/>
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
<UTextarea
|
|
263
|
+
v-model="draft.text"
|
|
264
|
+
:rows="draft.type === '$limit' ? 1 : 3"
|
|
265
|
+
:color="draftStates[index]?.error ? 'error' : void 0"
|
|
266
|
+
class="w-full font-mono"
|
|
267
|
+
:aria-label="t('nuxtUiMongocamp.aggregation.stageValue', { type: draft.type })"
|
|
268
|
+
/>
|
|
269
|
+
<p
|
|
270
|
+
v-if="draftStates[index]?.error"
|
|
271
|
+
class="text-sm text-error"
|
|
272
|
+
>
|
|
273
|
+
{{ draftStates[index]?.error }}
|
|
274
|
+
</p>
|
|
275
|
+
</div>
|
|
276
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
277
|
+
<USelect
|
|
278
|
+
v-model="newStageType"
|
|
279
|
+
:items="stageTypeItems"
|
|
280
|
+
size="sm"
|
|
281
|
+
class="w-72"
|
|
282
|
+
:aria-label="t('nuxtUiMongocamp.aggregation.newStageType')"
|
|
283
|
+
/>
|
|
284
|
+
<UButton
|
|
285
|
+
icon="i-lucide-plus"
|
|
286
|
+
color="neutral"
|
|
287
|
+
variant="ghost"
|
|
288
|
+
size="sm"
|
|
289
|
+
:label="t('nuxtUiMongocamp.aggregation.addStage')"
|
|
290
|
+
@click="addStage"
|
|
291
|
+
/>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
|
|
295
|
+
<div
|
|
296
|
+
v-else
|
|
297
|
+
class="flex flex-col gap-2"
|
|
298
|
+
>
|
|
299
|
+
<UTextarea
|
|
300
|
+
v-model="rawText"
|
|
301
|
+
:rows="12"
|
|
302
|
+
:color="pipelineState.error ? 'error' : void 0"
|
|
303
|
+
class="w-full font-mono"
|
|
304
|
+
:placeholder="JSON_PLACEHOLDER"
|
|
305
|
+
:aria-label="t('nuxtUiMongocamp.aggregation.jsonLabel')"
|
|
306
|
+
/>
|
|
307
|
+
<p
|
|
308
|
+
v-if="pipelineState.error"
|
|
309
|
+
class="text-sm text-error"
|
|
310
|
+
>
|
|
311
|
+
{{ pipelineState.error }}
|
|
312
|
+
</p>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<UAlert
|
|
316
|
+
v-if="runError"
|
|
317
|
+
:color="runError.kind === 'retryable' ? 'warning' : 'error'"
|
|
318
|
+
variant="subtle"
|
|
319
|
+
icon="i-lucide-circle-alert"
|
|
320
|
+
:title="t('nuxtUiMongocamp.aggregation.runFailedTitle')"
|
|
321
|
+
:description="runError.message"
|
|
322
|
+
>
|
|
323
|
+
<template #actions>
|
|
324
|
+
<UButton
|
|
325
|
+
v-if="runError.kind === 'unauthorized'"
|
|
326
|
+
:label="t('nuxtUiMongocamp.errors.loginAgain')"
|
|
327
|
+
to="/"
|
|
328
|
+
color="error"
|
|
329
|
+
variant="subtle"
|
|
330
|
+
icon="i-lucide-log-in"
|
|
331
|
+
/>
|
|
332
|
+
<UButton
|
|
333
|
+
v-else-if="runError.kind !== 'forbidden'"
|
|
334
|
+
:label="t('nuxtUiMongocamp.common.retry')"
|
|
335
|
+
:color="runError.kind === 'retryable' ? 'warning' : 'error'"
|
|
336
|
+
variant="subtle"
|
|
337
|
+
icon="i-lucide-refresh-cw"
|
|
338
|
+
@click="execute(page)"
|
|
339
|
+
/>
|
|
340
|
+
</template>
|
|
341
|
+
</UAlert>
|
|
342
|
+
|
|
343
|
+
<template v-if="result">
|
|
344
|
+
<div class="flex flex-wrap items-center justify-between gap-2">
|
|
345
|
+
<span class="text-sm text-dimmed">
|
|
346
|
+
{{ t("nuxtUiMongocamp.aggregation.resultsCount", { count: result.total }, result.total) }}
|
|
347
|
+
</span>
|
|
348
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
349
|
+
<UDropdownMenu :items="exportMenuItems">
|
|
350
|
+
<UButton
|
|
351
|
+
icon="i-lucide-download"
|
|
352
|
+
color="neutral"
|
|
353
|
+
variant="ghost"
|
|
354
|
+
size="sm"
|
|
355
|
+
:disabled="result.rows.length === 0"
|
|
356
|
+
:aria-label="t('nuxtUiMongocamp.aggregation.exportTooltip')"
|
|
357
|
+
/>
|
|
358
|
+
</UDropdownMenu>
|
|
359
|
+
<USelect
|
|
360
|
+
:model-value="rowsPerPage"
|
|
361
|
+
:items="PAGE_SIZES"
|
|
362
|
+
size="sm"
|
|
363
|
+
class="w-20"
|
|
364
|
+
:aria-label="t('nuxtUiMongocamp.aggregation.pageSize')"
|
|
365
|
+
@update:model-value="onPageSizeChange"
|
|
366
|
+
/>
|
|
367
|
+
<UPagination
|
|
368
|
+
:page="page"
|
|
369
|
+
:total="result.total"
|
|
370
|
+
:items-per-page="rowsPerPage"
|
|
371
|
+
@update:page="onPageChange"
|
|
372
|
+
/>
|
|
373
|
+
</div>
|
|
374
|
+
</div>
|
|
375
|
+
|
|
376
|
+
<UTable
|
|
377
|
+
:data="result.rows"
|
|
378
|
+
:columns="tableColumns"
|
|
379
|
+
:loading="running"
|
|
380
|
+
>
|
|
381
|
+
<template #empty>
|
|
382
|
+
<MongocampEmptyState :title="t('nuxtUiMongocamp.aggregation.noResults')" />
|
|
383
|
+
</template>
|
|
384
|
+
</UTable>
|
|
385
|
+
<p class="text-xs text-dimmed">
|
|
386
|
+
{{ t("nuxtUiMongocamp.aggregation.precisionNote") }}
|
|
387
|
+
</p>
|
|
388
|
+
</template>
|
|
389
|
+
</div>
|
|
390
|
+
</template>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
collectionName: string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -3,7 +3,11 @@ type __VLS_Props = {
|
|
|
3
3
|
deleting?: boolean;
|
|
4
4
|
error?: string;
|
|
5
5
|
};
|
|
6
|
-
declare
|
|
6
|
+
declare var __VLS_8: {};
|
|
7
|
+
type __VLS_Slots = {} & {
|
|
8
|
+
actions?: (props: typeof __VLS_8) => any;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
11
|
open: () => any;
|
|
8
12
|
clear: () => any;
|
|
9
13
|
confirm: () => any;
|
|
@@ -12,5 +16,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
12
16
|
onClear?: (() => any) | undefined;
|
|
13
17
|
onConfirm?: (() => any) | undefined;
|
|
14
18
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
15
20
|
declare const _default: typeof __VLS_export;
|
|
16
21
|
export default _default;
|
|
22
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
23
|
+
new (): {
|
|
24
|
+
$slots: S;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -3,7 +3,11 @@ type __VLS_Props = {
|
|
|
3
3
|
deleting?: boolean;
|
|
4
4
|
error?: string;
|
|
5
5
|
};
|
|
6
|
-
declare
|
|
6
|
+
declare var __VLS_8: {};
|
|
7
|
+
type __VLS_Slots = {} & {
|
|
8
|
+
actions?: (props: typeof __VLS_8) => any;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
11
|
open: () => any;
|
|
8
12
|
clear: () => any;
|
|
9
13
|
confirm: () => any;
|
|
@@ -12,5 +16,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
12
16
|
onClear?: (() => any) | undefined;
|
|
13
17
|
onConfirm?: (() => any) | undefined;
|
|
14
18
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
15
20
|
declare const _default: typeof __VLS_export;
|
|
16
21
|
export default _default;
|
|
22
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
23
|
+
new (): {
|
|
24
|
+
$slots: S;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ImportColumnType } from '../utils/importRows.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
selected: number;
|
|
4
|
+
fields: {
|
|
5
|
+
key: string;
|
|
6
|
+
type: ImportColumnType;
|
|
7
|
+
}[];
|
|
8
|
+
saving?: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
};
|
|
11
|
+
type __VLS_ModelProps = {
|
|
12
|
+
'open'?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
15
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
16
|
+
"update:open": (value: boolean) => any;
|
|
17
|
+
apply: (edit: {
|
|
18
|
+
field: string;
|
|
19
|
+
value: unknown;
|
|
20
|
+
}) => any;
|
|
21
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
22
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
23
|
+
onApply?: ((edit: {
|
|
24
|
+
field: string;
|
|
25
|
+
value: unknown;
|
|
26
|
+
}) => any) | undefined;
|
|
27
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|