@sfxcode/nuxt-ui-mongocamp 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampAggregationBuilder.vue +29 -2
- package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.vue +4 -3
- package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampBucketFiles.vue +61 -0
- package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +2 -12
- package/dist/runtime/components/MongocampBulkDelete.vue +14 -40
- package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +2 -12
- package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +5 -6
- package/dist/runtime/components/MongocampBulkEdit.vue +43 -26
- package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +5 -6
- package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +2 -0
- package/dist/runtime/components/MongocampCollectionCharts.vue +9 -8
- package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +2 -0
- package/dist/runtime/components/MongocampCollectionCopy.vue +19 -258
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +2 -0
- package/dist/runtime/components/MongocampCollectionData.vue +206 -126
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +2 -0
- package/dist/runtime/components/MongocampCollectionRename.d.vue.ts +22 -0
- package/dist/runtime/components/MongocampCollectionRename.vue +116 -0
- package/dist/runtime/components/MongocampCollectionRename.vue.d.ts +22 -0
- package/dist/runtime/components/MongocampCollections.vue +31 -12
- package/dist/runtime/components/MongocampCommandPalette.vue +2 -2
- package/dist/runtime/components/MongocampDashboard.vue +19 -4
- package/dist/runtime/components/MongocampDatabases.vue +13 -2
- package/dist/runtime/components/MongocampExportAll.vue +13 -26
- package/dist/runtime/components/MongocampImport.vue +169 -3
- package/dist/runtime/components/MongocampIndexes.vue +54 -13
- package/dist/runtime/components/MongocampJobs.vue +14 -3
- package/dist/runtime/components/MongocampRoleGrants.vue +16 -3
- package/dist/runtime/components/MongocampRoles.vue +13 -2
- package/dist/runtime/components/MongocampServerOverview.vue +16 -39
- package/dist/runtime/components/MongocampSettings.d.vue.ts +3 -0
- package/dist/runtime/components/MongocampSettings.vue +14 -2
- package/dist/runtime/components/MongocampSettings.vue.d.ts +3 -0
- package/dist/runtime/components/MongocampUsers.vue +16 -3
- package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
- package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
- package/dist/runtime/composables/useMongocampAggregation.d.ts +11 -0
- package/dist/runtime/composables/useMongocampAggregation.js +12 -5
- package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
- package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
- package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +25 -65
- package/dist/runtime/composables/useMongocampCollectionCopy.js +27 -84
- package/dist/runtime/composables/useMongocampExportAll.d.ts +27 -21
- package/dist/runtime/composables/useMongocampExportAll.js +51 -21
- package/dist/runtime/composables/useMongocampExtendedJson.d.ts +2 -1
- package/dist/runtime/composables/useMongocampExtendedJson.js +32 -5
- package/dist/runtime/composables/useMongocampFetchAll.js +1 -1
- package/dist/runtime/composables/useMongocampFieldTypes.d.ts +24 -0
- package/dist/runtime/composables/useMongocampFieldTypes.js +44 -0
- package/dist/runtime/composables/useMongocampImport.d.ts +4 -0
- package/dist/runtime/composables/useMongocampImport.js +5 -2
- package/dist/runtime/composables/useMongocampIndex.d.ts +6 -1
- package/dist/runtime/composables/useMongocampIndex.js +7 -1
- package/dist/runtime/composables/useMongocampPermissions.d.ts +8 -5
- package/dist/runtime/composables/useMongocampPermissions.js +24 -2
- package/dist/runtime/composables/useMongocampQuery.d.ts +3 -3
- package/dist/runtime/composables/useMongocampServerOverview.d.ts +4 -11
- package/dist/runtime/composables/useMongocampServerOverview.js +12 -22
- package/dist/runtime/locales/de.json +69 -71
- package/dist/runtime/locales/en.json +69 -71
- package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
- package/dist/runtime/utils/aggregationErrors.js +7 -0
- package/dist/runtime/utils/batchInsert.d.ts +6 -0
- package/dist/runtime/utils/batchInsert.js +31 -3
- package/dist/runtime/utils/bsonTypes.d.ts +10 -0
- package/dist/runtime/utils/bsonTypes.js +42 -0
- package/dist/runtime/utils/collectionCopy.d.ts +0 -2
- package/dist/runtime/utils/collectionCopy.js +0 -1
- package/dist/runtime/utils/configRows.d.ts +7 -0
- package/dist/runtime/utils/configRows.js +4 -0
- package/dist/runtime/utils/documentCompare.js +2 -1
- package/dist/runtime/utils/documentPaths.d.ts +5 -8
- package/dist/runtime/utils/documentPaths.js +5 -10
- package/dist/runtime/utils/documentTree.js +9 -1
- package/dist/runtime/utils/exportDocuments.d.ts +0 -2
- package/dist/runtime/utils/exportDocuments.js +0 -1
- package/dist/runtime/utils/exportRows.d.ts +2 -0
- package/dist/runtime/utils/exportRows.js +5 -2
- package/dist/runtime/utils/fieldDetails.d.ts +51 -0
- package/dist/runtime/utils/fieldDetails.js +113 -0
- package/dist/runtime/utils/indexForm.d.ts +47 -33
- package/dist/runtime/utils/indexForm.js +32 -21
- package/package.json +8 -8
- package/dist/runtime/utils/indexCopy.d.ts +0 -26
- package/dist/runtime/utils/indexCopy.js +0 -22
- package/dist/runtime/utils/limitedMap.d.ts +0 -17
- package/dist/runtime/utils/limitedMap.js +0 -19
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A Nuxt module that wraps [`@sfxcode/nuxt-mongocamp-server`](https://www.npmjs.co
|
|
|
12
12
|
|
|
13
13
|
## Requirements
|
|
14
14
|
|
|
15
|
-
MongoCamp server **1.
|
|
15
|
+
MongoCamp server **1.8.1 or later** (with `@sfxcode/nuxt-mongocamp-server` ^1.8.0). Older servers are not supported — the module uses the 1.7/1.8 endpoints directly (counts, search, batch info, copy/rename, ordered indexes, typed reads, streaming export/import). See [Server 1.8](/guide/server-1-8).
|
|
16
16
|
|
|
17
17
|
## Features
|
|
18
18
|
|
package/dist/module.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
2
|
collectionName: string;
|
|
3
|
+
filter?: string;
|
|
3
4
|
};
|
|
4
5
|
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
6
|
declare const _default: typeof __VLS_export;
|
|
@@ -17,7 +17,12 @@ import { DEFAULT_TOP, MAX_TOP, templateStages, TEMPLATES, validateTemplateInput
|
|
|
17
17
|
import { formatCell, resultColumns } from "../utils/aggregationResult";
|
|
18
18
|
import { downloadTextFile, rowsToCsv } from "../utils/exportRows";
|
|
19
19
|
const props = defineProps({
|
|
20
|
-
collectionName: { type: String, required: true }
|
|
20
|
+
collectionName: { type: String, required: true },
|
|
21
|
+
filter: { type: String, required: false }
|
|
22
|
+
});
|
|
23
|
+
const appliedFilter = ref(props.filter);
|
|
24
|
+
watch(() => props.filter, (next) => {
|
|
25
|
+
appliedFilter.value = next;
|
|
21
26
|
});
|
|
22
27
|
const PAGE_SIZES = [10, 20, 50, 100];
|
|
23
28
|
const JSON_PLACEHOLDER = '[ { "$match": { } }, { "$limit": 10 } ]';
|
|
@@ -204,7 +209,7 @@ async function execute(pageNumber) {
|
|
|
204
209
|
running.value = true;
|
|
205
210
|
runError.value = null;
|
|
206
211
|
try {
|
|
207
|
-
const outcome = await runAggregation(props.collectionName, lastPipeline, { page: pageNumber, rowsPerPage: rowsPerPage.value });
|
|
212
|
+
const outcome = await runAggregation(props.collectionName, lastPipeline, { page: pageNumber, rowsPerPage: rowsPerPage.value }, { filter: appliedFilter.value });
|
|
208
213
|
if (run !== runCounter) return;
|
|
209
214
|
result.value = outcome;
|
|
210
215
|
page.value = outcome.page;
|
|
@@ -266,6 +271,27 @@ const exportMenuItems = computed(() => [
|
|
|
266
271
|
|
|
267
272
|
<template>
|
|
268
273
|
<div class="flex flex-col gap-4">
|
|
274
|
+
<div
|
|
275
|
+
v-if="appliedFilter"
|
|
276
|
+
class="flex flex-wrap items-center gap-2 text-sm"
|
|
277
|
+
data-test="applied-filter"
|
|
278
|
+
>
|
|
279
|
+
<span class="text-dimmed">{{ t("nuxtUiMongocamp.aggregation.appliesTo") }}</span>
|
|
280
|
+
<UBadge
|
|
281
|
+
:label="appliedFilter"
|
|
282
|
+
color="neutral"
|
|
283
|
+
variant="subtle"
|
|
284
|
+
class="font-mono"
|
|
285
|
+
/>
|
|
286
|
+
<UButton
|
|
287
|
+
icon="i-lucide-x"
|
|
288
|
+
color="neutral"
|
|
289
|
+
variant="ghost"
|
|
290
|
+
size="xs"
|
|
291
|
+
:aria-label="t('nuxtUiMongocamp.aggregation.removeFilter')"
|
|
292
|
+
@click="appliedFilter = void 0"
|
|
293
|
+
/>
|
|
294
|
+
</div>
|
|
269
295
|
<div class="flex flex-wrap items-center justify-between gap-2">
|
|
270
296
|
<div class="flex items-center gap-1">
|
|
271
297
|
<UButton
|
|
@@ -545,6 +571,7 @@ const exportMenuItems = computed(() => [
|
|
|
545
571
|
:collection-name="collectionName"
|
|
546
572
|
:pipeline="previewFor(index)"
|
|
547
573
|
:stage-number="index + 1"
|
|
574
|
+
:filter="appliedFilter"
|
|
548
575
|
/>
|
|
549
576
|
</div>
|
|
550
577
|
</div>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
2
|
collectionName: string;
|
|
3
|
+
filter?: string;
|
|
3
4
|
};
|
|
4
5
|
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
6
|
declare const _default: typeof __VLS_export;
|
|
@@ -3,6 +3,7 @@ type __VLS_Props = {
|
|
|
3
3
|
collectionName: string;
|
|
4
4
|
pipeline: RequestStage[] | undefined;
|
|
5
5
|
stageNumber: number;
|
|
6
|
+
filter?: string;
|
|
6
7
|
};
|
|
7
8
|
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>;
|
|
8
9
|
declare const _default: typeof __VLS_export;
|
|
@@ -7,7 +7,8 @@ import { formatCell, resultColumns } from "../utils/aggregationResult";
|
|
|
7
7
|
const props = defineProps({
|
|
8
8
|
collectionName: { type: String, required: true },
|
|
9
9
|
pipeline: { type: null, required: true },
|
|
10
|
-
stageNumber: { type: Number, required: true }
|
|
10
|
+
stageNumber: { type: Number, required: true },
|
|
11
|
+
filter: { type: String, required: false }
|
|
11
12
|
});
|
|
12
13
|
const { t } = useI18n();
|
|
13
14
|
const { runAggregation, describeAggregationError } = useMongocampAggregation();
|
|
@@ -30,7 +31,7 @@ async function execute(pipeline) {
|
|
|
30
31
|
loading.value = true;
|
|
31
32
|
error.value = null;
|
|
32
33
|
try {
|
|
33
|
-
const result = await runAggregation(props.collectionName, pipeline, { page: 1, rowsPerPage: PREVIEW_LIMIT }, { signal: own.signal });
|
|
34
|
+
const result = await runAggregation(props.collectionName, pipeline, { page: 1, rowsPerPage: PREVIEW_LIMIT }, { signal: own.signal, filter: props.filter });
|
|
34
35
|
if (mine !== run) return;
|
|
35
36
|
rows.value = result.rows;
|
|
36
37
|
} catch (e) {
|
|
@@ -41,7 +42,7 @@ async function execute(pipeline) {
|
|
|
41
42
|
if (mine === run) loading.value = false;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
const key = computed(() => props.pipeline ? pipelineKey(props.pipeline) : "");
|
|
45
|
+
const key = computed(() => props.pipeline ? `${props.filter ?? ""}\0${pipelineKey(props.pipeline)}` : "");
|
|
45
46
|
let first = true;
|
|
46
47
|
watch(key, () => {
|
|
47
48
|
if (!props.pipeline) {
|
|
@@ -3,6 +3,7 @@ type __VLS_Props = {
|
|
|
3
3
|
collectionName: string;
|
|
4
4
|
pipeline: RequestStage[] | undefined;
|
|
5
5
|
stageNumber: number;
|
|
6
|
+
filter?: string;
|
|
6
7
|
};
|
|
7
8
|
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>;
|
|
8
9
|
declare const _default: typeof __VLS_export;
|
|
@@ -3,6 +3,9 @@ import { computed, h, ref, resolveComponent, watch } from "vue";
|
|
|
3
3
|
import { useI18n } from "#imports";
|
|
4
4
|
import useMongocampCollection from "../composables/useMongocampCollection";
|
|
5
5
|
import { useMongocampBucket } from "../composables/useMongocampBucket";
|
|
6
|
+
import { useMongocampFieldTypes } from "../composables/useMongocampFieldTypes";
|
|
7
|
+
import { useMongocampPermissions } from "../composables/useMongocampPermissions";
|
|
8
|
+
import MongocampCollectionCharts from "./MongocampCollectionCharts.vue";
|
|
6
9
|
import { useMongocampQuery } from "../composables/useMongocampQuery";
|
|
7
10
|
import { parseMetadataJson } from "../utils/filePreview";
|
|
8
11
|
const props = defineProps({
|
|
@@ -22,6 +25,28 @@ const {
|
|
|
22
25
|
} = useMongocampBucket();
|
|
23
26
|
const { like } = useMongocampQuery();
|
|
24
27
|
const fileInputRef = ref(null);
|
|
28
|
+
const filesCollection = computed(() => `${props.bucketName}.files`);
|
|
29
|
+
const fieldTypes = useMongocampFieldTypes(() => filesCollection.value);
|
|
30
|
+
const { canRead, load: loadPermissions } = useMongocampPermissions();
|
|
31
|
+
const showDistribution = computed(() => canRead(filesCollection.value));
|
|
32
|
+
const distributionOpen = ref(false);
|
|
33
|
+
const distributionField = ref("");
|
|
34
|
+
const distributionFields = computed(() => fieldTypes.filterFields().filter((f) => f.type === "string" || f.type === "number" || f.type === "date-time" || f.type === "boolean").map((f) => f.key));
|
|
35
|
+
const distributionItems = computed(() => distributionFields.value.map((key) => ({ label: key, value: key })));
|
|
36
|
+
function defaultDistributionField(fields) {
|
|
37
|
+
return ["contentType", "metadata.contentType", "uploadDate"].find((key) => fields.includes(key)) ?? fields[0] ?? "";
|
|
38
|
+
}
|
|
39
|
+
async function onDistributionToggle(event) {
|
|
40
|
+
distributionOpen.value = event.target.open;
|
|
41
|
+
if (!distributionOpen.value) return;
|
|
42
|
+
await fieldTypes.load();
|
|
43
|
+
if (!distributionFields.value.includes(distributionField.value)) distributionField.value = defaultDistributionField(distributionFields.value);
|
|
44
|
+
}
|
|
45
|
+
void loadPermissions(filesCollection.value);
|
|
46
|
+
watch(filesCollection, (name) => {
|
|
47
|
+
distributionField.value = "";
|
|
48
|
+
void loadPermissions(name);
|
|
49
|
+
});
|
|
25
50
|
function openFilePicker() {
|
|
26
51
|
fileInputRef.value?.click();
|
|
27
52
|
}
|
|
@@ -467,6 +492,42 @@ watch(() => props.bucketName, init, { immediate: true });
|
|
|
467
492
|
</template>
|
|
468
493
|
</UModal>
|
|
469
494
|
|
|
495
|
+
<details
|
|
496
|
+
v-if="showDistribution"
|
|
497
|
+
class="text-sm"
|
|
498
|
+
data-test="bucket-distribution"
|
|
499
|
+
@toggle="onDistributionToggle"
|
|
500
|
+
>
|
|
501
|
+
<summary class="cursor-pointer text-dimmed">
|
|
502
|
+
{{ t("nuxtUiMongocamp.bucketFiles.distribution") }}
|
|
503
|
+
</summary>
|
|
504
|
+
<div class="mt-3 flex flex-col gap-3">
|
|
505
|
+
<UFormField
|
|
506
|
+
v-if="distributionItems.length > 0"
|
|
507
|
+
:label="t('nuxtUiMongocamp.bucketFiles.distributionField')"
|
|
508
|
+
>
|
|
509
|
+
<USelect
|
|
510
|
+
v-model="distributionField"
|
|
511
|
+
:items="distributionItems"
|
|
512
|
+
class="w-full sm:w-64"
|
|
513
|
+
:aria-label="t('nuxtUiMongocamp.bucketFiles.distributionField')"
|
|
514
|
+
/>
|
|
515
|
+
</UFormField>
|
|
516
|
+
<p
|
|
517
|
+
v-else-if="fieldTypes.status() === 'ready' || fieldTypes.status() === 'failed'"
|
|
518
|
+
class="text-dimmed"
|
|
519
|
+
data-test="distribution-empty"
|
|
520
|
+
>
|
|
521
|
+
{{ t("nuxtUiMongocamp.bucketFiles.distributionNone") }}
|
|
522
|
+
</p>
|
|
523
|
+
<MongocampCollectionCharts
|
|
524
|
+
v-if="distributionOpen && distributionField"
|
|
525
|
+
:collection-name="filesCollection"
|
|
526
|
+
:field="distributionField"
|
|
527
|
+
/>
|
|
528
|
+
</div>
|
|
529
|
+
</details>
|
|
530
|
+
|
|
470
531
|
<MongocampFilePreview
|
|
471
532
|
v-model:open="previewOpen"
|
|
472
533
|
:bucket-name="bucketName"
|
|
@@ -5,16 +5,10 @@ type __VLS_Props = {
|
|
|
5
5
|
pageCount?: number;
|
|
6
6
|
total?: number;
|
|
7
7
|
allMatching?: boolean;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
target?: number;
|
|
11
|
-
} | null;
|
|
8
|
+
counting?: boolean;
|
|
9
|
+
selectedCount?: number;
|
|
12
10
|
note?: string;
|
|
13
11
|
confirmName?: string;
|
|
14
|
-
progress?: {
|
|
15
|
-
done: number;
|
|
16
|
-
total: number;
|
|
17
|
-
} | null;
|
|
18
12
|
};
|
|
19
13
|
declare const __VLS_template: () => {
|
|
20
14
|
__VLS_Slots: {
|
|
@@ -25,17 +19,13 @@ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
|
25
19
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
26
20
|
open: () => any;
|
|
27
21
|
clear: () => any;
|
|
28
|
-
stop: () => any;
|
|
29
22
|
confirm: () => any;
|
|
30
23
|
selectAll: () => any;
|
|
31
|
-
cancelCollect: () => any;
|
|
32
24
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
33
25
|
onOpen?: (() => any) | undefined;
|
|
34
26
|
onClear?: (() => any) | undefined;
|
|
35
|
-
onStop?: (() => any) | undefined;
|
|
36
27
|
onConfirm?: (() => any) | undefined;
|
|
37
28
|
onSelectAll?: (() => any) | undefined;
|
|
38
|
-
onCancelCollect?: (() => any) | undefined;
|
|
39
29
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
40
30
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
41
31
|
declare const _default: typeof __VLS_export;
|
|
@@ -9,18 +9,19 @@ const props = defineProps({
|
|
|
9
9
|
pageCount: { type: Number, required: false },
|
|
10
10
|
total: { type: Number, required: false },
|
|
11
11
|
allMatching: { type: Boolean, required: false },
|
|
12
|
-
|
|
12
|
+
counting: { type: Boolean, required: false },
|
|
13
|
+
selectedCount: { type: Number, required: false },
|
|
13
14
|
note: { type: String, required: false },
|
|
14
|
-
confirmName: { type: String, required: false }
|
|
15
|
-
progress: { type: [Object, null], required: false }
|
|
15
|
+
confirmName: { type: String, required: false }
|
|
16
16
|
});
|
|
17
|
-
const emit = defineEmits(["confirm", "clear", "open", "selectAll"
|
|
17
|
+
const emit = defineEmits(["confirm", "clear", "open", "selectAll"]);
|
|
18
18
|
const { t } = useI18n();
|
|
19
19
|
const isOpen = ref(false);
|
|
20
20
|
const typed = ref("");
|
|
21
21
|
const confirmed = computed(() => !props.confirmName || typed.value.trim() === props.confirmName);
|
|
22
|
+
const count = computed(() => props.selectedCount ?? props.selected.length);
|
|
22
23
|
const offerSelectAll = computed(
|
|
23
|
-
() => !props.allMatching && !props.
|
|
24
|
+
() => !props.allMatching && !props.counting && props.total !== void 0 && props.pageCount !== void 0 && props.pageCount > 0 && props.selected.length === props.pageCount && props.total > props.pageCount
|
|
24
25
|
);
|
|
25
26
|
function openModal() {
|
|
26
27
|
emit("open");
|
|
@@ -36,15 +37,15 @@ watch(() => props.deleting, (now, before) => {
|
|
|
36
37
|
|
|
37
38
|
<template>
|
|
38
39
|
<div
|
|
39
|
-
v-if="
|
|
40
|
+
v-if="count > 0 || counting || note"
|
|
40
41
|
class="flex flex-col gap-1"
|
|
41
42
|
>
|
|
42
43
|
<div
|
|
43
|
-
v-if="
|
|
44
|
+
v-if="count > 0"
|
|
44
45
|
class="flex flex-wrap items-center gap-3 rounded-md border border-default bg-elevated/50 px-3 py-2"
|
|
45
46
|
>
|
|
46
47
|
<span class="text-sm font-medium">
|
|
47
|
-
{{ allMatching ? t("nuxtUiMongocamp.bulk.allMatchingSelected", { count
|
|
48
|
+
{{ allMatching ? t("nuxtUiMongocamp.bulk.allMatchingSelected", { count }) : t("nuxtUiMongocamp.bulk.selectedCount", { count }) }}
|
|
48
49
|
</span>
|
|
49
50
|
<UButton
|
|
50
51
|
icon="i-lucide-trash-2"
|
|
@@ -79,23 +80,16 @@ watch(() => props.deleting, (now, before) => {
|
|
|
79
80
|
/>
|
|
80
81
|
</div>
|
|
81
82
|
<div
|
|
82
|
-
v-if="
|
|
83
|
+
v-if="counting"
|
|
83
84
|
class="flex items-center gap-2 px-3 text-sm"
|
|
84
85
|
role="status"
|
|
85
|
-
data-test="
|
|
86
|
+
data-test="counting"
|
|
86
87
|
>
|
|
87
88
|
<UIcon
|
|
88
89
|
name="i-lucide-loader-circle"
|
|
89
90
|
class="size-4 animate-spin"
|
|
90
91
|
/>
|
|
91
|
-
<span>{{
|
|
92
|
-
<UButton
|
|
93
|
-
color="neutral"
|
|
94
|
-
variant="ghost"
|
|
95
|
-
size="sm"
|
|
96
|
-
:label="t('nuxtUiMongocamp.bulk.cancelCollecting')"
|
|
97
|
-
@click="emit('cancelCollect')"
|
|
98
|
-
/>
|
|
92
|
+
<span>{{ t("nuxtUiMongocamp.bulk.counting") }}</span>
|
|
99
93
|
</div>
|
|
100
94
|
<p
|
|
101
95
|
v-if="note"
|
|
@@ -109,7 +103,7 @@ watch(() => props.deleting, (now, before) => {
|
|
|
109
103
|
|
|
110
104
|
<UModal
|
|
111
105
|
v-model:open="isOpen"
|
|
112
|
-
:title="t('nuxtUiMongocamp.bulk.deleteTitle', { count
|
|
106
|
+
:title="t('nuxtUiMongocamp.bulk.deleteTitle', { count }, count)"
|
|
113
107
|
:ui="{ footer: 'justify-end' }"
|
|
114
108
|
>
|
|
115
109
|
<template #body>
|
|
@@ -143,18 +137,6 @@ watch(() => props.deleting, (now, before) => {
|
|
|
143
137
|
:aria-label="t('nuxtUiMongocamp.bulk.typeToConfirmLabel')"
|
|
144
138
|
/>
|
|
145
139
|
</UFormField>
|
|
146
|
-
<div
|
|
147
|
-
v-if="deleting && progress"
|
|
148
|
-
class="mt-3 flex flex-col gap-1"
|
|
149
|
-
role="status"
|
|
150
|
-
data-test="delete-progress"
|
|
151
|
-
>
|
|
152
|
-
<UProgress
|
|
153
|
-
:model-value="progress.done"
|
|
154
|
-
:max="progress.total"
|
|
155
|
-
/>
|
|
156
|
-
<span class="text-sm text-dimmed">{{ t("nuxtUiMongocamp.bulk.progressDelete", progress) }}</span>
|
|
157
|
-
</div>
|
|
158
140
|
<UAlert
|
|
159
141
|
v-if="error"
|
|
160
142
|
class="mt-3"
|
|
@@ -166,14 +148,6 @@ watch(() => props.deleting, (now, before) => {
|
|
|
166
148
|
</template>
|
|
167
149
|
<template #footer>
|
|
168
150
|
<UButton
|
|
169
|
-
v-if="deleting && progress"
|
|
170
|
-
:label="t('nuxtUiMongocamp.bulk.stop')"
|
|
171
|
-
color="neutral"
|
|
172
|
-
variant="soft"
|
|
173
|
-
@click="emit('stop')"
|
|
174
|
-
/>
|
|
175
|
-
<UButton
|
|
176
|
-
v-else
|
|
177
151
|
:label="t('nuxtUiMongocamp.common.cancel')"
|
|
178
152
|
color="neutral"
|
|
179
153
|
variant="ghost"
|
|
@@ -181,7 +155,7 @@ watch(() => props.deleting, (now, before) => {
|
|
|
181
155
|
@click="isOpen = false"
|
|
182
156
|
/>
|
|
183
157
|
<UButton
|
|
184
|
-
:label="t('nuxtUiMongocamp.bulk.confirmDelete', { count
|
|
158
|
+
:label="t('nuxtUiMongocamp.bulk.confirmDelete', { count })"
|
|
185
159
|
color="error"
|
|
186
160
|
:loading="deleting"
|
|
187
161
|
:disabled="!confirmed"
|
|
@@ -5,16 +5,10 @@ type __VLS_Props = {
|
|
|
5
5
|
pageCount?: number;
|
|
6
6
|
total?: number;
|
|
7
7
|
allMatching?: boolean;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
target?: number;
|
|
11
|
-
} | null;
|
|
8
|
+
counting?: boolean;
|
|
9
|
+
selectedCount?: number;
|
|
12
10
|
note?: string;
|
|
13
11
|
confirmName?: string;
|
|
14
|
-
progress?: {
|
|
15
|
-
done: number;
|
|
16
|
-
total: number;
|
|
17
|
-
} | null;
|
|
18
12
|
};
|
|
19
13
|
declare const __VLS_template: () => {
|
|
20
14
|
__VLS_Slots: {
|
|
@@ -25,17 +19,13 @@ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
|
25
19
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
26
20
|
open: () => any;
|
|
27
21
|
clear: () => any;
|
|
28
|
-
stop: () => any;
|
|
29
22
|
confirm: () => any;
|
|
30
23
|
selectAll: () => any;
|
|
31
|
-
cancelCollect: () => any;
|
|
32
24
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
33
25
|
onOpen?: (() => any) | undefined;
|
|
34
26
|
onClear?: (() => any) | undefined;
|
|
35
|
-
onStop?: (() => any) | undefined;
|
|
36
27
|
onConfirm?: (() => any) | undefined;
|
|
37
28
|
onSelectAll?: (() => any) | undefined;
|
|
38
|
-
onCancelCollect?: (() => any) | undefined;
|
|
39
29
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
40
30
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
41
31
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { ImportColumnType } from '../utils/importRows.js';
|
|
2
|
+
import type { BsonType } from '../utils/bsonTypes.js';
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
selected: number;
|
|
4
5
|
fields: {
|
|
5
6
|
key: string;
|
|
6
7
|
type: ImportColumnType;
|
|
8
|
+
bson?: BsonType;
|
|
9
|
+
mixed?: boolean;
|
|
7
10
|
}[];
|
|
8
11
|
saving?: boolean;
|
|
9
12
|
error?: string;
|
|
10
|
-
progress?: {
|
|
11
|
-
done: number;
|
|
12
|
-
total: number;
|
|
13
|
-
} | null;
|
|
14
13
|
};
|
|
15
14
|
type __VLS_ModelProps = {
|
|
16
15
|
'open'?: boolean;
|
|
@@ -18,17 +17,17 @@ type __VLS_ModelProps = {
|
|
|
18
17
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
19
18
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
19
|
"update:open": (value: boolean) => any;
|
|
21
|
-
stop: () => any;
|
|
22
20
|
apply: (edit: {
|
|
23
21
|
field: string;
|
|
24
22
|
value: unknown;
|
|
23
|
+
bson?: BsonType;
|
|
25
24
|
}) => any;
|
|
26
25
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
27
26
|
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
28
|
-
onStop?: (() => any) | undefined;
|
|
29
27
|
onApply?: ((edit: {
|
|
30
28
|
field: string;
|
|
31
29
|
value: unknown;
|
|
30
|
+
bson?: BsonType;
|
|
32
31
|
}) => any) | undefined;
|
|
33
32
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
33
|
declare const _default: typeof __VLS_export;
|
|
@@ -6,20 +6,31 @@ const props = defineProps({
|
|
|
6
6
|
selected: { type: Number, required: true },
|
|
7
7
|
fields: { type: Array, required: true },
|
|
8
8
|
saving: { type: Boolean, required: false },
|
|
9
|
-
error: { type: String, required: false }
|
|
10
|
-
progress: { type: [Object, null], required: false }
|
|
9
|
+
error: { type: String, required: false }
|
|
11
10
|
});
|
|
12
|
-
const emit = defineEmits(["apply"
|
|
11
|
+
const emit = defineEmits(["apply"]);
|
|
13
12
|
const isOpen = defineModel("open", { type: Boolean, ...{ default: false } });
|
|
14
13
|
const { t } = useI18n();
|
|
15
14
|
const field = ref("");
|
|
16
15
|
const type = ref("string");
|
|
17
16
|
const text = ref("");
|
|
18
17
|
const booleanValue = ref("true");
|
|
18
|
+
function startType(key) {
|
|
19
|
+
const info = props.fields.find((f) => f.key === key);
|
|
20
|
+
switch (info?.bson) {
|
|
21
|
+
case "int":
|
|
22
|
+
case "long":
|
|
23
|
+
case "double":
|
|
24
|
+
case "decimal":
|
|
25
|
+
return info.bson;
|
|
26
|
+
default:
|
|
27
|
+
return info?.type ?? "string";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
19
30
|
watch(isOpen, (open) => {
|
|
20
31
|
if (!open) return;
|
|
21
32
|
field.value = props.fields[0]?.key ?? "";
|
|
22
|
-
type.value =
|
|
33
|
+
type.value = startType(field.value);
|
|
23
34
|
text.value = "";
|
|
24
35
|
booleanValue.value = "true";
|
|
25
36
|
});
|
|
@@ -27,6 +38,10 @@ const fieldItems = computed(() => props.fields.map((f) => ({ label: f.key, value
|
|
|
27
38
|
const typeItems = computed(() => [
|
|
28
39
|
{ label: t("nuxtUiMongocamp.import.typeString"), value: "string" },
|
|
29
40
|
{ label: t("nuxtUiMongocamp.import.typeNumber"), value: "number" },
|
|
41
|
+
{ label: t("nuxtUiMongocamp.bulk.typeInt"), value: "int" },
|
|
42
|
+
{ label: t("nuxtUiMongocamp.bulk.typeLong"), value: "long" },
|
|
43
|
+
{ label: t("nuxtUiMongocamp.bulk.typeDouble"), value: "double" },
|
|
44
|
+
{ label: t("nuxtUiMongocamp.bulk.typeDecimal"), value: "decimal" },
|
|
30
45
|
{ label: t("nuxtUiMongocamp.import.typeBoolean"), value: "boolean" },
|
|
31
46
|
{ label: t("nuxtUiMongocamp.import.typeDate"), value: "date-time" },
|
|
32
47
|
{ label: t("nuxtUiMongocamp.import.typeJson"), value: "json" }
|
|
@@ -37,12 +52,27 @@ const booleanItems = computed(() => [
|
|
|
37
52
|
]);
|
|
38
53
|
function onFieldChange(key) {
|
|
39
54
|
field.value = key;
|
|
40
|
-
type.value =
|
|
55
|
+
type.value = startType(key);
|
|
41
56
|
text.value = "";
|
|
42
57
|
}
|
|
58
|
+
const mixedField = computed(() => props.fields.find((f) => f.key === field.value)?.mixed === true);
|
|
59
|
+
const INT32_MIN = -(2 ** 31);
|
|
60
|
+
const INT32_MAX = 2 ** 31 - 1;
|
|
61
|
+
const INTEGER_TEXT = /^-?\d+$/;
|
|
62
|
+
const DECIMAL_TEXT = /^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i;
|
|
63
|
+
function parseExact(kind, raw) {
|
|
64
|
+
const trimmed = raw.trim();
|
|
65
|
+
const invalid = { error: t("nuxtUiMongocamp.import.error.invalid-number") };
|
|
66
|
+
if (kind === "long") return INTEGER_TEXT.test(trimmed) ? { value: trimmed } : invalid;
|
|
67
|
+
if (kind === "int") return INTEGER_TEXT.test(trimmed) && Number(trimmed) >= INT32_MIN && Number(trimmed) <= INT32_MAX ? { value: trimmed } : invalid;
|
|
68
|
+
if (kind === "decimal") return DECIMAL_TEXT.test(trimmed) ? { value: trimmed } : invalid;
|
|
69
|
+
return DECIMAL_TEXT.test(trimmed) && Number.isFinite(Number(trimmed)) ? { value: trimmed } : invalid;
|
|
70
|
+
}
|
|
71
|
+
const BSON_OF_EDIT_TYPE = { "string": "string", "int": "int", "long": "long", "double": "double", "decimal": "decimal", "date-time": "date" };
|
|
43
72
|
const parsed = computed(() => {
|
|
44
73
|
if (type.value === "boolean") return { value: booleanValue.value === "true" };
|
|
45
74
|
if (text.value.trim() === "" && type.value !== "string") return { error: t("nuxtUiMongocamp.bulk.editValueRequired") };
|
|
75
|
+
if (type.value === "int" || type.value === "long" || type.value === "double" || type.value === "decimal") return parseExact(type.value, text.value);
|
|
46
76
|
const { row, errors } = coerceRow({ value: text.value }, { value: type.value }, { emptyCells: "empty-string" });
|
|
47
77
|
if (errors.length > 0) return { error: t(`nuxtUiMongocamp.import.error.${errors[0].code}`) };
|
|
48
78
|
return { value: row.value };
|
|
@@ -51,7 +81,7 @@ const showTextError = computed(() => text.value !== "" && parsed.value.error !==
|
|
|
51
81
|
const canApply = computed(() => field.value !== "" && parsed.value.error === void 0 && !props.saving);
|
|
52
82
|
function apply() {
|
|
53
83
|
if (!canApply.value) return;
|
|
54
|
-
emit("apply", { field: field.value, value: parsed.value.value });
|
|
84
|
+
emit("apply", { field: field.value, value: parsed.value.value, bson: BSON_OF_EDIT_TYPE[type.value] });
|
|
55
85
|
}
|
|
56
86
|
watch(() => props.saving, (now, before) => {
|
|
57
87
|
if (before && !now && !props.error) isOpen.value = false;
|
|
@@ -105,6 +135,13 @@ watch(() => props.saving, (now, before) => {
|
|
|
105
135
|
>
|
|
106
136
|
{{ parsed.error }}
|
|
107
137
|
</p>
|
|
138
|
+
<p
|
|
139
|
+
v-if="mixedField"
|
|
140
|
+
class="text-sm text-warning"
|
|
141
|
+
data-test="mixed-note"
|
|
142
|
+
>
|
|
143
|
+
{{ t("nuxtUiMongocamp.bulk.editMixed") }}
|
|
144
|
+
</p>
|
|
108
145
|
<p
|
|
109
146
|
v-if="field"
|
|
110
147
|
class="text-sm text-dimmed"
|
|
@@ -119,29 +156,9 @@ watch(() => props.saving, (now, before) => {
|
|
|
119
156
|
:description="error"
|
|
120
157
|
/>
|
|
121
158
|
</div>
|
|
122
|
-
<div
|
|
123
|
-
v-if="saving && progress"
|
|
124
|
-
class="mt-3 flex flex-col gap-1"
|
|
125
|
-
role="status"
|
|
126
|
-
data-test="edit-progress"
|
|
127
|
-
>
|
|
128
|
-
<UProgress
|
|
129
|
-
:model-value="progress.done"
|
|
130
|
-
:max="progress.total"
|
|
131
|
-
/>
|
|
132
|
-
<span class="text-sm text-dimmed">{{ t("nuxtUiMongocamp.bulk.progressEdit", progress) }}</span>
|
|
133
|
-
</div>
|
|
134
159
|
</template>
|
|
135
160
|
<template #footer>
|
|
136
161
|
<UButton
|
|
137
|
-
v-if="saving && progress"
|
|
138
|
-
:label="t('nuxtUiMongocamp.bulk.stop')"
|
|
139
|
-
color="neutral"
|
|
140
|
-
variant="soft"
|
|
141
|
-
@click="emit('stop')"
|
|
142
|
-
/>
|
|
143
|
-
<UButton
|
|
144
|
-
v-else
|
|
145
162
|
:label="t('nuxtUiMongocamp.common.cancel')"
|
|
146
163
|
color="neutral"
|
|
147
164
|
variant="ghost"
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { ImportColumnType } from '../utils/importRows.js';
|
|
2
|
+
import type { BsonType } from '../utils/bsonTypes.js';
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
selected: number;
|
|
4
5
|
fields: {
|
|
5
6
|
key: string;
|
|
6
7
|
type: ImportColumnType;
|
|
8
|
+
bson?: BsonType;
|
|
9
|
+
mixed?: boolean;
|
|
7
10
|
}[];
|
|
8
11
|
saving?: boolean;
|
|
9
12
|
error?: string;
|
|
10
|
-
progress?: {
|
|
11
|
-
done: number;
|
|
12
|
-
total: number;
|
|
13
|
-
} | null;
|
|
14
13
|
};
|
|
15
14
|
type __VLS_ModelProps = {
|
|
16
15
|
'open'?: boolean;
|
|
@@ -18,17 +17,17 @@ type __VLS_ModelProps = {
|
|
|
18
17
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
19
18
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
19
|
"update:open": (value: boolean) => any;
|
|
21
|
-
stop: () => any;
|
|
22
20
|
apply: (edit: {
|
|
23
21
|
field: string;
|
|
24
22
|
value: unknown;
|
|
23
|
+
bson?: BsonType;
|
|
25
24
|
}) => any;
|
|
26
25
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
27
26
|
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
28
|
-
onStop?: (() => any) | undefined;
|
|
29
27
|
onApply?: ((edit: {
|
|
30
28
|
field: string;
|
|
31
29
|
value: unknown;
|
|
30
|
+
bson?: BsonType;
|
|
32
31
|
}) => any) | undefined;
|
|
33
32
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
33
|
declare const _default: typeof __VLS_export;
|
|
@@ -5,8 +5,10 @@ type __VLS_Props = {
|
|
|
5
5
|
kind?: ChartKind;
|
|
6
6
|
top?: number;
|
|
7
7
|
buckets?: number;
|
|
8
|
+
filter?: string;
|
|
8
9
|
};
|
|
9
10
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
11
|
+
filter: string;
|
|
10
12
|
kind: ChartKind;
|
|
11
13
|
buckets: number;
|
|
12
14
|
top: number;
|