@sfxcode/nuxt-ui-mongocamp 1.3.5 → 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.d.mts +8 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +6 -0
- package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampAggregationBuilder.vue +331 -5
- package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampAggregationChart.d.vue.ts +6 -0
- package/dist/runtime/components/MongocampAggregationChart.vue +93 -0
- package/dist/runtime/components/MongocampAggregationChart.vue.d.ts +6 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +10 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.vue +149 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +10 -0
- package/dist/runtime/components/MongocampBucketFiles.vue +230 -48
- package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +9 -0
- package/dist/runtime/components/MongocampBulkDelete.vue +94 -25
- package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +9 -0
- package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +5 -0
- package/dist/runtime/components/MongocampBulkEdit.vue +41 -3
- package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +5 -0
- package/dist/runtime/components/MongocampChart.d.vue.ts +29 -0
- package/dist/runtime/components/MongocampChart.vue +129 -0
- package/dist/runtime/components/MongocampChart.vue.d.ts +29 -0
- package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +17 -0
- package/dist/runtime/components/MongocampCollectionCharts.vue +200 -0
- package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +17 -0
- package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +23 -0
- package/dist/runtime/components/MongocampCollectionCopy.vue +206 -0
- package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +23 -0
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +6 -0
- package/dist/runtime/components/MongocampCollectionData.vue +423 -138
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +6 -0
- package/dist/runtime/components/MongocampCollectionInfos.vue +106 -238
- 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 +93 -12
- package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +40 -0
- package/dist/runtime/components/MongocampCommandPalette.vue +135 -0
- package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +40 -0
- package/dist/runtime/components/MongocampConfirmByName.vue +2 -2
- package/dist/runtime/components/MongocampDashboard.d.vue.ts +3 -1
- package/dist/runtime/components/MongocampDashboard.vue +39 -5
- package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -1
- package/dist/runtime/components/MongocampDatabases.vue +35 -2
- package/dist/runtime/components/MongocampDocumentCompare.d.vue.ts +20 -0
- package/dist/runtime/components/MongocampDocumentCompare.vue +146 -0
- package/dist/runtime/components/MongocampDocumentCompare.vue.d.ts +20 -0
- package/dist/runtime/components/MongocampDocumentView.d.vue.ts +22 -0
- package/dist/runtime/components/MongocampDocumentView.vue +202 -0
- package/dist/runtime/components/MongocampDocumentView.vue.d.ts +22 -0
- package/dist/runtime/components/MongocampErrorAlert.vue +12 -4
- package/dist/runtime/components/MongocampExportAll.d.vue.ts +18 -0
- package/dist/runtime/components/MongocampExportAll.vue +191 -0
- package/dist/runtime/components/MongocampExportAll.vue.d.ts +18 -0
- package/dist/runtime/components/MongocampFilePreview.d.vue.ts +16 -0
- package/dist/runtime/components/MongocampFilePreview.vue +162 -0
- package/dist/runtime/components/MongocampFilePreview.vue.d.ts +16 -0
- package/dist/runtime/components/MongocampFilterBuilder.vue +11 -0
- package/dist/runtime/components/MongocampImport.vue +171 -13
- package/dist/runtime/components/MongocampIndexes.d.vue.ts +18 -0
- package/dist/runtime/components/MongocampIndexes.vue +496 -0
- package/dist/runtime/components/MongocampIndexes.vue.d.ts +18 -0
- package/dist/runtime/components/MongocampJobs.d.vue.ts +6 -1
- package/dist/runtime/components/MongocampJobs.vue +36 -5
- package/dist/runtime/components/MongocampJobs.vue.d.ts +6 -1
- package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +12 -0
- package/dist/runtime/components/MongocampPermissionMatrix.vue +301 -0
- package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +12 -0
- package/dist/runtime/components/MongocampQueryBar.d.vue.ts +26 -0
- package/dist/runtime/components/MongocampQueryBar.vue +398 -0
- package/dist/runtime/components/MongocampQueryBar.vue.d.ts +26 -0
- package/dist/runtime/components/MongocampRoleGrants.vue +18 -5
- package/dist/runtime/components/MongocampRoles.vue +16 -5
- package/dist/runtime/components/MongocampServerOverview.d.vue.ts +20 -0
- package/dist/runtime/components/MongocampServerOverview.vue +420 -0
- package/dist/runtime/components/MongocampServerOverview.vue.d.ts +20 -0
- package/dist/runtime/components/MongocampSettings.d.vue.ts +28 -1
- package/dist/runtime/components/MongocampSettings.vue +83 -10
- package/dist/runtime/components/MongocampSettings.vue.d.ts +28 -1
- package/dist/runtime/components/MongocampUsers.vue +19 -6
- package/dist/runtime/composables/useMongocampAdmin.d.ts +2 -1
- package/dist/runtime/composables/useMongocampAdmin.js +6 -1
- package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
- package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
- package/dist/runtime/composables/useMongocampAggregation.d.ts +23 -1
- package/dist/runtime/composables/useMongocampAggregation.js +41 -26
- package/dist/runtime/composables/useMongocampAutoRefresh.d.ts +26 -0
- package/dist/runtime/composables/useMongocampAutoRefresh.js +78 -0
- package/dist/runtime/composables/useMongocampBucket.d.ts +13 -1
- package/dist/runtime/composables/useMongocampBucket.js +34 -0
- package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
- package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
- package/dist/runtime/composables/useMongocampClientApi.js +2 -1
- package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +45 -0
- package/dist/runtime/composables/useMongocampCollectionCopy.js +48 -0
- package/dist/runtime/composables/useMongocampCollectionStats.d.ts +10 -0
- package/dist/runtime/composables/useMongocampCollectionStats.js +17 -0
- package/dist/runtime/composables/useMongocampError.d.ts +2 -1
- package/dist/runtime/composables/useMongocampError.js +16 -1
- package/dist/runtime/composables/useMongocampExportAll.d.ts +53 -0
- package/dist/runtime/composables/useMongocampExportAll.js +57 -0
- package/dist/runtime/composables/useMongocampExtendedJson.d.ts +7 -2
- package/dist/runtime/composables/useMongocampExtendedJson.js +44 -11
- package/dist/runtime/composables/useMongocampFetchAll.d.ts +25 -0
- package/dist/runtime/composables/useMongocampFetchAll.js +27 -0
- 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 +17 -0
- package/dist/runtime/composables/useMongocampPermissions.js +43 -0
- package/dist/runtime/composables/useMongocampPersistedState.d.ts +15 -0
- package/dist/runtime/composables/useMongocampPersistedState.js +21 -0
- package/dist/runtime/composables/useMongocampProxyApi.js +2 -1
- package/dist/runtime/composables/useMongocampQuery.d.ts +50 -2
- package/dist/runtime/composables/useMongocampQuery.js +72 -1
- package/dist/runtime/composables/useMongocampSavedPipelines.d.ts +25 -0
- package/dist/runtime/composables/useMongocampSavedPipelines.js +23 -0
- package/dist/runtime/composables/useMongocampSavedQueries.d.ts +37 -0
- package/dist/runtime/composables/useMongocampSavedQueries.js +50 -0
- package/dist/runtime/composables/useMongocampServerOverview.d.ts +35 -0
- package/dist/runtime/composables/useMongocampServerOverview.js +51 -0
- package/dist/runtime/composables/useMongocampSession.d.ts +2 -0
- package/dist/runtime/composables/useMongocampSession.js +16 -2
- package/dist/runtime/composables/useMongocampSystem.d.ts +7 -2
- package/dist/runtime/composables/useMongocampSystem.js +6 -2
- package/dist/runtime/locales/de.json +509 -25
- package/dist/runtime/locales/en.json +509 -25
- package/dist/runtime/plugin.js +6 -3
- package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
- package/dist/runtime/utils/aggregationErrors.js +7 -0
- package/dist/runtime/utils/aggregationPipeline.d.ts +5 -4
- package/dist/runtime/utils/aggregationPipeline.js +23 -9
- package/dist/runtime/utils/aggregationPreview.d.ts +13 -0
- package/dist/runtime/utils/aggregationPreview.js +10 -0
- package/dist/runtime/utils/aggregationResult.d.ts +5 -0
- package/dist/runtime/utils/aggregationResult.js +4 -0
- package/dist/runtime/utils/aggregationTemplates.d.ts +34 -0
- package/dist/runtime/utils/aggregationTemplates.js +47 -0
- package/dist/runtime/utils/analyzeSamples.d.ts +1 -0
- package/dist/runtime/utils/analyzeSamples.js +1 -1
- package/dist/runtime/utils/autoRefresh.d.ts +14 -0
- package/dist/runtime/utils/autoRefresh.js +15 -0
- package/dist/runtime/utils/batchInsert.d.ts +6 -0
- package/dist/runtime/utils/batchInsert.js +31 -3
- package/dist/runtime/utils/bigIntJson.d.ts +15 -0
- package/dist/runtime/utils/bigIntJson.js +55 -0
- package/dist/runtime/utils/bsonTypes.d.ts +10 -0
- package/dist/runtime/utils/bsonTypes.js +42 -0
- package/dist/runtime/utils/bulkDelete.d.ts +9 -1
- package/dist/runtime/utils/bulkDelete.js +15 -3
- package/dist/runtime/utils/bulkEdit.d.ts +6 -0
- package/dist/runtime/utils/bulkEdit.js +7 -0
- package/dist/runtime/utils/chartData.d.ts +11 -0
- package/dist/runtime/utils/chartData.js +9 -0
- package/dist/runtime/utils/collectionChart.d.ts +36 -0
- package/dist/runtime/utils/collectionChart.js +73 -0
- package/dist/runtime/utils/collectionCopy.d.ts +24 -0
- package/dist/runtime/utils/collectionCopy.js +37 -0
- package/dist/runtime/utils/collectionStats.d.ts +31 -0
- package/dist/runtime/utils/collectionStats.js +42 -0
- package/dist/runtime/utils/commandPalette.d.ts +48 -0
- package/dist/runtime/utils/commandPalette.js +39 -0
- package/dist/runtime/utils/configRows.d.ts +7 -0
- package/dist/runtime/utils/configRows.js +4 -0
- package/dist/runtime/utils/documentCompare.d.ts +31 -0
- package/dist/runtime/utils/documentCompare.js +71 -0
- package/dist/runtime/utils/documentDiff.d.ts +19 -0
- package/dist/runtime/utils/documentDiff.js +71 -0
- package/dist/runtime/utils/documentPaths.d.ts +41 -0
- package/dist/runtime/utils/documentPaths.js +139 -0
- package/dist/runtime/utils/documentTree.d.ts +40 -0
- package/dist/runtime/utils/documentTree.js +102 -0
- package/dist/runtime/utils/exportDocuments.d.ts +33 -0
- package/dist/runtime/utils/exportDocuments.js +53 -0
- package/dist/runtime/utils/exportRows.d.ts +2 -0
- package/dist/runtime/utils/exportRows.js +6 -3
- package/dist/runtime/utils/fieldDetails.d.ts +51 -0
- package/dist/runtime/utils/fieldDetails.js +113 -0
- package/dist/runtime/utils/filePreview.d.ts +27 -0
- package/dist/runtime/utils/filePreview.js +50 -0
- package/dist/runtime/utils/filterBuilder.d.ts +6 -1
- package/dist/runtime/utils/filterBuilder.js +6 -5
- package/dist/runtime/utils/formatBytes.d.ts +2 -0
- package/dist/runtime/utils/formatBytes.js +11 -0
- package/dist/runtime/utils/grantMatching.d.ts +8 -0
- package/dist/runtime/utils/grantMatching.js +15 -0
- package/dist/runtime/utils/importRows.js +12 -2
- package/dist/runtime/utils/indexForm.d.ts +83 -0
- package/dist/runtime/utils/indexForm.js +74 -0
- package/dist/runtime/utils/luceneExpression.d.ts +15 -0
- package/dist/runtime/utils/luceneExpression.js +74 -0
- package/dist/runtime/utils/pagedFetch.d.ts +46 -0
- package/dist/runtime/utils/pagedFetch.js +58 -0
- package/dist/runtime/utils/paginationHeaders.d.ts +4 -0
- package/dist/runtime/utils/paginationHeaders.js +4 -0
- package/dist/runtime/utils/permissionDenied.d.ts +10 -0
- package/dist/runtime/utils/permissionDenied.js +23 -0
- package/dist/runtime/utils/permissionMatrix.d.ts +55 -0
- package/dist/runtime/utils/permissionMatrix.js +85 -0
- package/dist/runtime/utils/persistedState.d.ts +25 -0
- package/dist/runtime/utils/persistedState.js +47 -0
- package/dist/runtime/utils/queryState.d.ts +45 -0
- package/dist/runtime/utils/queryState.js +75 -0
- package/dist/runtime/utils/requestLimits.d.ts +2 -0
- package/dist/runtime/utils/requestLimits.js +4 -0
- package/dist/runtime/utils/resultChart.d.ts +32 -0
- package/dist/runtime/utils/resultChart.js +59 -0
- package/dist/runtime/utils/savedPipelines.d.ts +22 -0
- package/dist/runtime/utils/savedPipelines.js +46 -0
- package/dist/runtime/utils/savedQueries.d.ts +60 -0
- package/dist/runtime/utils/savedQueries.js +143 -0
- package/dist/runtime/utils/schemaAnalysis.d.ts +16 -0
- package/dist/runtime/utils/schemaAnalysis.js +57 -0
- package/dist/runtime/utils/serverError.d.ts +19 -0
- package/dist/runtime/utils/serverError.js +19 -0
- package/dist/runtime/utils/serverOverview.d.ts +47 -0
- package/dist/runtime/utils/serverOverview.js +40 -0
- package/dist/runtime/utils/sessionGuard.d.ts +3 -0
- package/dist/runtime/utils/sessionGuard.js +18 -1
- package/package.json +15 -14
|
@@ -1,36 +1,48 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, h, ref, resolveComponent, watch } from "vue";
|
|
3
|
-
import { useI18n, useMongocampClientApi, useMongocampError, useMongocampRoles, useMongocampSchema, useToast } from "#imports";
|
|
3
|
+
import { useI18n, useMongocampClientApi, useMongocampError, useMongocampPermissions, useMongocampRoles, useMongocampSchema, useToast } from "#imports";
|
|
4
4
|
import useMongocampCollection from "../composables/useMongocampCollection";
|
|
5
5
|
import { useMongocampBucket } from "../composables/useMongocampBucket";
|
|
6
6
|
import { useMongocampIndex } from "../composables/useMongocampIndex";
|
|
7
7
|
import { unwrapExtendedJson, wrapExtendedJson } from "../composables/useMongocampExtendedJson";
|
|
8
|
+
import { readJsonKeepingLongs } from "../utils/bigIntJson";
|
|
9
|
+
import { buildPartialBody, diffDocument, hasChanges } from "../utils/documentDiff";
|
|
8
10
|
import { isIsoDateTimeString } from "../utils/isoDate";
|
|
9
|
-
import {
|
|
11
|
+
import { formatDocuments, toExportRow, valueToJson } from "../utils/exportDocuments";
|
|
10
12
|
import { downloadTextFile, rowsToCsv } from "../utils/exportRows";
|
|
11
13
|
import { runBulkDelete } from "../utils/bulkDelete";
|
|
12
14
|
import { BulkMatchShortfall, BulkUnaddressableId, buildIdFilter, isEditableField, runBulkUpdate } from "../utils/bulkEdit";
|
|
13
15
|
import { isObjectIdHex } from "../utils/objectId";
|
|
14
16
|
import { createSelectColumn } from "../utils/createSelectColumn";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
buildFilterQuery,
|
|
18
|
-
conditionValueText,
|
|
19
|
-
countActiveConditions,
|
|
20
|
-
operatorLabelKey,
|
|
21
|
-
operatorsFor,
|
|
22
|
-
toFilterFieldType
|
|
23
|
-
} from "../utils/filterBuilder";
|
|
17
|
+
import { operatorsFor, toFilterFieldType } from "../utils/filterBuilder";
|
|
18
|
+
import { emptyGroup, emptyQueryState, parseSortEntry, usableProjection } from "../utils/queryState";
|
|
24
19
|
import useMongocampDocument from "../composables/useMongocampDocument";
|
|
25
20
|
import { useMongocampQuery } from "../composables/useMongocampQuery";
|
|
26
21
|
import { useMongocampAggregation } from "../composables/useMongocampAggregation";
|
|
22
|
+
import { useMongocampPersistedState } from "../composables/useMongocampPersistedState";
|
|
23
|
+
import { useMongocampBulkByFilter } from "../composables/useMongocampBulkByFilter";
|
|
24
|
+
import { useMongocampFieldTypes } from "../composables/useMongocampFieldTypes";
|
|
25
|
+
import { wireValue } from "../utils/bsonTypes";
|
|
26
|
+
import MongocampDocumentView from "./MongocampDocumentView.vue";
|
|
27
|
+
import MongocampQueryBar from "./MongocampQueryBar.vue";
|
|
28
|
+
import MongocampExportAll from "./MongocampExportAll.vue";
|
|
29
|
+
import MongocampCollectionCharts from "./MongocampCollectionCharts.vue";
|
|
30
|
+
import { isFilterTooLong } from "../utils/requestLimits";
|
|
27
31
|
const props = defineProps({
|
|
28
32
|
collectionName: { type: String, required: true },
|
|
29
|
-
infoPath: { type: String, required: false, default: "/secured/admin/collections" }
|
|
33
|
+
infoPath: { type: String, required: false, default: "/secured/admin/collections" },
|
|
34
|
+
aggregatePath: { type: String, required: false, default: "" },
|
|
35
|
+
persistState: { type: Boolean, required: false, default: true },
|
|
36
|
+
stateKey: { type: String, required: false, default: "" }
|
|
30
37
|
});
|
|
31
38
|
const { t } = useI18n();
|
|
32
39
|
const { documentApi } = useMongocampClientApi();
|
|
33
40
|
const { pagination, total } = useMongocampCollection();
|
|
41
|
+
const { state: persisted } = useMongocampPersistedState(
|
|
42
|
+
() => `collectionData:${props.collectionName}${props.stateKey ? `:${props.stateKey}` : ""}`,
|
|
43
|
+
{ pageSize: pagination.value.pageSize, sort: [], hidden: [] },
|
|
44
|
+
{ storage: props.persistState ? void 0 : null }
|
|
45
|
+
);
|
|
34
46
|
const { isBucketCollection, fileIdForRow, downloadingFileIds, uploading, downloadFile, uploadFile } = useMongocampBucket();
|
|
35
47
|
const { ensureMetaData } = useMongocampDocument();
|
|
36
48
|
const { and, like, or } = useMongocampQuery();
|
|
@@ -38,6 +50,9 @@ const { schemaFromSamples } = useMongocampSchema();
|
|
|
38
50
|
const { listDistinct } = useMongocampAggregation();
|
|
39
51
|
const { createIndexForField } = useMongocampIndex();
|
|
40
52
|
const { isManager } = useMongocampRoles();
|
|
53
|
+
const { canWrite, load: loadPermissions } = useMongocampPermissions();
|
|
54
|
+
watch(() => props.collectionName, (name) => loadPermissions(name), { immediate: true });
|
|
55
|
+
const writable = computed(() => canWrite(props.collectionName));
|
|
41
56
|
const toast = useToast();
|
|
42
57
|
const fileInputRef = ref(null);
|
|
43
58
|
function openFilePicker() {
|
|
@@ -94,16 +109,32 @@ function openInsert() {
|
|
|
94
109
|
}
|
|
95
110
|
isEditModalOpen.value = true;
|
|
96
111
|
}
|
|
97
|
-
function
|
|
112
|
+
async function loadTypedRow(row) {
|
|
113
|
+
const id = getDocId(row);
|
|
114
|
+
if (!id) return void 0;
|
|
115
|
+
const res = await documentApi.getDocumentRaw({ collectionName: props.collectionName, documentId: id, extendedJson: "canonical" });
|
|
116
|
+
return await readJsonKeepingLongs(res);
|
|
117
|
+
}
|
|
118
|
+
async function openEdit(row) {
|
|
119
|
+
const projected = activeProjection.value.length > 0;
|
|
120
|
+
let source;
|
|
121
|
+
try {
|
|
122
|
+
const typed = await loadTypedRow(row);
|
|
123
|
+
if (!typed) throw new Error("no id");
|
|
124
|
+
source = typed;
|
|
125
|
+
} catch {
|
|
126
|
+
toast.add({ title: t("nuxtUiMongocamp.collectionData.editLoadFailed"), color: "error" });
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
98
129
|
editMode.value = "update";
|
|
99
|
-
editDocId.value = getDocId(
|
|
130
|
+
editDocId.value = getDocId(source);
|
|
100
131
|
editError.value = "";
|
|
101
|
-
originalRow.value =
|
|
102
|
-
editSamples.value = documents.value.map((r) => omitId(unwrapExtendedJson(r)));
|
|
132
|
+
originalRow.value = source;
|
|
133
|
+
editSamples.value = projected ? [omitId(unwrapExtendedJson(source))] : documents.value.map((r) => omitId(unwrapExtendedJson(r)));
|
|
103
134
|
if (editSamples.value.length > 0) {
|
|
104
|
-
editFormData.value = omitId(unwrapExtendedJson(
|
|
135
|
+
editFormData.value = omitId(unwrapExtendedJson(source));
|
|
105
136
|
} else {
|
|
106
|
-
editJson.value = JSON.stringify(
|
|
137
|
+
editJson.value = JSON.stringify(source, null, 2);
|
|
107
138
|
}
|
|
108
139
|
isEditModalOpen.value = true;
|
|
109
140
|
}
|
|
@@ -116,7 +147,8 @@ async function handleSave() {
|
|
|
116
147
|
editError.value = "";
|
|
117
148
|
let payload;
|
|
118
149
|
if (editSamples.value.length > 0) {
|
|
119
|
-
|
|
150
|
+
const { slots: _slots, ...formValues } = editFormData.value;
|
|
151
|
+
payload = wrapExtendedJson(formValues, editMode.value === "update" ? originalRow.value : void 0, fieldTypes.hints());
|
|
120
152
|
} else {
|
|
121
153
|
try {
|
|
122
154
|
payload = JSON.parse(editJson.value);
|
|
@@ -125,12 +157,33 @@ async function handleSave() {
|
|
|
125
157
|
return;
|
|
126
158
|
}
|
|
127
159
|
}
|
|
160
|
+
const original = editMode.value === "update" ? originalRow.value : void 0;
|
|
161
|
+
if (original && editDocId.value) {
|
|
162
|
+
const unchanged = diffDocument(original, payload);
|
|
163
|
+
if (unchanged && !hasChanges(unchanged)) {
|
|
164
|
+
isEditModalOpen.value = false;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
128
168
|
ensureMetaData(payload);
|
|
129
169
|
try {
|
|
130
170
|
if (editMode.value === "insert") {
|
|
131
171
|
await documentApi.insert({ collectionName: props.collectionName, requestBody: payload });
|
|
172
|
+
void fieldTypes.load(true);
|
|
132
173
|
} else {
|
|
133
174
|
if (!editDocId.value) return;
|
|
175
|
+
const changes = original ? diffDocument(original, payload) : null;
|
|
176
|
+
if (changes && hasChanges(changes)) {
|
|
177
|
+
const result = await documentApi.updateDocumentPartial({
|
|
178
|
+
collectionName: props.collectionName,
|
|
179
|
+
documentId: editDocId.value,
|
|
180
|
+
requestBody: buildPartialBody(changes)
|
|
181
|
+
});
|
|
182
|
+
if (result.matchedCount === 0) throw new Error(t("nuxtUiMongocamp.collectionData.documentGone"));
|
|
183
|
+
isEditModalOpen.value = false;
|
|
184
|
+
await fetchDocuments();
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
134
187
|
const body = { ...payload };
|
|
135
188
|
delete body._id;
|
|
136
189
|
await documentApi.update({ collectionName: props.collectionName, documentId: editDocId.value, requestBody: body });
|
|
@@ -172,6 +225,15 @@ function makeActionsColumn() {
|
|
|
172
225
|
})));
|
|
173
226
|
}
|
|
174
227
|
}
|
|
228
|
+
buttons.push(withTooltip(t("nuxtUiMongocamp.collectionData.viewDocumentTooltip"), h(UButton, {
|
|
229
|
+
"icon": "i-lucide-eye",
|
|
230
|
+
"color": "neutral",
|
|
231
|
+
"variant": "ghost",
|
|
232
|
+
"size": "sm",
|
|
233
|
+
"aria-label": t("nuxtUiMongocamp.collectionData.viewDocumentTooltip"),
|
|
234
|
+
"onClick": () => openView(row.original)
|
|
235
|
+
})));
|
|
236
|
+
if (!writable.value) return h("div", { class: "flex gap-1 justify-end" }, buttons);
|
|
175
237
|
buttons.push(
|
|
176
238
|
withTooltip(t("nuxtUiMongocamp.collectionData.editDocumentTooltip"), h(UButton, {
|
|
177
239
|
"icon": "i-lucide-pencil",
|
|
@@ -210,15 +272,7 @@ function canIndexField(key) {
|
|
|
210
272
|
return isManager.value && !isBucketCollection(props.collectionName) && key !== "_id" && key !== "metaData";
|
|
211
273
|
}
|
|
212
274
|
async function indexFailureMessage(error) {
|
|
213
|
-
|
|
214
|
-
const body = await error?.response?.clone().json();
|
|
215
|
-
if (typeof body?.msg === "string" && body.msg) {
|
|
216
|
-
const message = parseServerError(body.msg).message;
|
|
217
|
-
if (message) return message;
|
|
218
|
-
}
|
|
219
|
-
} catch {
|
|
220
|
-
}
|
|
221
|
-
return describeError(error).message;
|
|
275
|
+
return (await describeServerError(error)).message;
|
|
222
276
|
}
|
|
223
277
|
async function indexField(key, ascending) {
|
|
224
278
|
if (indexing.value.has(key)) return;
|
|
@@ -267,27 +321,44 @@ const documents = ref([]);
|
|
|
267
321
|
const loading = ref(false);
|
|
268
322
|
const filterText = ref("");
|
|
269
323
|
const filterableColumns = ref([]);
|
|
270
|
-
const
|
|
271
|
-
const
|
|
272
|
-
const
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const filterChips = computed(
|
|
279
|
-
() => appliedFilterGroup.value.conditions.filter((c) => buildCondition(c, filterFieldTypes.value[c.field] ?? "string") !== "").map((c) => ({
|
|
280
|
-
id: c.id,
|
|
281
|
-
label: [c.field, t(operatorLabelKey(c.operator, filterFieldTypes.value[c.field] ?? "string")), conditionValueText(c)].filter(Boolean).join(" ")
|
|
282
|
-
}))
|
|
283
|
-
);
|
|
324
|
+
const query = ref(emptyQueryState());
|
|
325
|
+
const queryBar = ref(null);
|
|
326
|
+
const fieldTypes = useMongocampFieldTypes(() => props.collectionName);
|
|
327
|
+
const pageFilterFields = ref([]);
|
|
328
|
+
const filterFields = computed(() => {
|
|
329
|
+
const fromServer = fieldTypes.filterFields().filter((f) => operatorsFor(f.type).length > 0);
|
|
330
|
+
return fromServer.length > 0 ? fromServer : pageFilterFields.value;
|
|
331
|
+
});
|
|
284
332
|
const sorting = ref([]);
|
|
285
333
|
const columnVisibility = ref({});
|
|
286
334
|
const PAGE_SIZES = [10, 20, 50, 100];
|
|
287
335
|
const isInitializing = ref(false);
|
|
288
336
|
const detailOpen = ref(false);
|
|
337
|
+
const compareOpen = ref(false);
|
|
338
|
+
const compareState = ref("loading");
|
|
339
|
+
const typedPair = ref(null);
|
|
340
|
+
const compareRows = computed(() => {
|
|
341
|
+
const ticked = documents.value.filter((row, index) => rowSelection.value[rowId(row, index)]);
|
|
342
|
+
return ticked.length === 2 && selectedDocIds.value.length === 2 ? ticked : [];
|
|
343
|
+
});
|
|
344
|
+
const viewDoc = ref(null);
|
|
345
|
+
const viewOpen = ref(false);
|
|
346
|
+
const viewMode = ref("table");
|
|
289
347
|
const detailContent = ref("");
|
|
290
348
|
let filterTimer;
|
|
349
|
+
function openView(row) {
|
|
350
|
+
viewDoc.value = row;
|
|
351
|
+
viewOpen.value = true;
|
|
352
|
+
void showTyped(row);
|
|
353
|
+
}
|
|
354
|
+
async function showTyped(row) {
|
|
355
|
+
try {
|
|
356
|
+
const typed = await loadTypedRow(row);
|
|
357
|
+
if (typed && viewDoc.value === row) viewDoc.value = typed;
|
|
358
|
+
} catch {
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const pageJson = computed(() => valueToJson(documents.value, true));
|
|
291
362
|
function openDetail(value) {
|
|
292
363
|
detailContent.value = JSON.stringify(value, null, 2);
|
|
293
364
|
detailOpen.value = true;
|
|
@@ -295,7 +366,7 @@ function openDetail(value) {
|
|
|
295
366
|
function buildLuceneFilter(term) {
|
|
296
367
|
const trimmed = term.trim();
|
|
297
368
|
const quick = trimmed && filterableColumns.value.length > 0 ? or(...filterableColumns.value.map((col) => like(col, trimmed))) : "";
|
|
298
|
-
return and(quick,
|
|
369
|
+
return and(quick, query.value.lucene) || void 0;
|
|
299
370
|
}
|
|
300
371
|
function onFilterInput() {
|
|
301
372
|
clearTimeout(filterTimer);
|
|
@@ -307,8 +378,9 @@ function onFilterInput() {
|
|
|
307
378
|
function sortingToMongoSort(s) {
|
|
308
379
|
return s.map((col) => col.desc ? `-${col.id}` : col.id);
|
|
309
380
|
}
|
|
310
|
-
watch(sorting, () => {
|
|
381
|
+
watch(sorting, (sort) => {
|
|
311
382
|
if (isInitializing.value) return;
|
|
383
|
+
query.value = { ...query.value, sort: sortingToMongoSort(sort) };
|
|
312
384
|
pagination.value.pageIndex = 1;
|
|
313
385
|
fetchDocuments();
|
|
314
386
|
});
|
|
@@ -364,6 +436,8 @@ function makeCell(key, type) {
|
|
|
364
436
|
if (!Array.isArray(raw)) {
|
|
365
437
|
const obj = raw;
|
|
366
438
|
if ("$oid" in obj) return h("span", { class: "font-mono text-xs" }, String(obj.$oid));
|
|
439
|
+
const numberKey = Object.keys(obj).find((k) => k === "$numberLong" || k === "$numberDecimal" || k === "$numberInt" || k === "$numberDouble");
|
|
440
|
+
if (numberKey && Object.keys(obj).length === 1) return h("span", { class: "font-mono text-xs" }, String(obj[numberKey]));
|
|
367
441
|
if ("$date" in obj) return h("span", toDateDisplay(obj));
|
|
368
442
|
if (isMetaData(obj)) {
|
|
369
443
|
const rows = [];
|
|
@@ -408,7 +482,7 @@ function makeCell(key, type) {
|
|
|
408
482
|
}
|
|
409
483
|
const loadError = ref(null);
|
|
410
484
|
const filterRejected = ref(false);
|
|
411
|
-
const { describeError } = useMongocampError();
|
|
485
|
+
const { describeError, describeServerError } = useMongocampError();
|
|
412
486
|
const rowSelection = ref({});
|
|
413
487
|
const selectedDocIds = computed(() => Object.keys(rowSelection.value).filter((id) => rowSelection.value[id]));
|
|
414
488
|
const bulkDeleting = ref(false);
|
|
@@ -416,6 +490,52 @@ const bulkError = ref("");
|
|
|
416
490
|
const bulkEditing = ref(false);
|
|
417
491
|
const bulkEditError = ref("");
|
|
418
492
|
const bulkEditOpen = ref(false);
|
|
493
|
+
const { countDocuments, deleteByFilter, updateByFilter } = useMongocampBulkByFilter();
|
|
494
|
+
const matching = ref(null);
|
|
495
|
+
const counting = ref(false);
|
|
496
|
+
const bulkNote = ref("");
|
|
497
|
+
const bulkIds = computed(() => matching.value ? [] : selectedDocIds.value);
|
|
498
|
+
const bulkCount = computed(() => matching.value?.count ?? bulkIds.value.length);
|
|
499
|
+
const selectablePageCount = computed(() => writable.value && !isBucketCollection(props.collectionName) ? documents.value.length : 0);
|
|
500
|
+
function clearMatching() {
|
|
501
|
+
matching.value = null;
|
|
502
|
+
bulkNote.value = "";
|
|
503
|
+
}
|
|
504
|
+
async function collectMatching() {
|
|
505
|
+
clearMatching();
|
|
506
|
+
const filter = buildLuceneFilter(filterText.value);
|
|
507
|
+
counting.value = true;
|
|
508
|
+
try {
|
|
509
|
+
const count = await countDocuments(props.collectionName, filter);
|
|
510
|
+
matching.value = { filter, count };
|
|
511
|
+
rowSelection.value = {};
|
|
512
|
+
if (count !== total.value) bulkNote.value = t("nuxtUiMongocamp.bulk.matchingDrift", { counted: count, reported: total.value });
|
|
513
|
+
} catch (e) {
|
|
514
|
+
bulkNote.value = (await describeServerError(e)).message;
|
|
515
|
+
} finally {
|
|
516
|
+
counting.value = false;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function clearBulkSelection() {
|
|
520
|
+
rowSelection.value = {};
|
|
521
|
+
clearMatching();
|
|
522
|
+
}
|
|
523
|
+
async function openCompare() {
|
|
524
|
+
const [left, right] = compareRows.value;
|
|
525
|
+
if (!left || !right) return;
|
|
526
|
+
compareOpen.value = true;
|
|
527
|
+
compareState.value = "loading";
|
|
528
|
+
typedPair.value = null;
|
|
529
|
+
try {
|
|
530
|
+
const [typedLeft, typedRight] = await Promise.all([loadTypedRow(left), loadTypedRow(right)]);
|
|
531
|
+
if (!typedLeft || !typedRight) throw new Error("no id");
|
|
532
|
+
if (!compareOpen.value) return;
|
|
533
|
+
typedPair.value = [typedLeft, typedRight];
|
|
534
|
+
compareState.value = "typed";
|
|
535
|
+
} catch {
|
|
536
|
+
compareState.value = "untyped";
|
|
537
|
+
}
|
|
538
|
+
}
|
|
419
539
|
function openBulkEdit() {
|
|
420
540
|
bulkEditError.value = "";
|
|
421
541
|
bulkEditOpen.value = true;
|
|
@@ -426,8 +546,16 @@ function rowId(row, index) {
|
|
|
426
546
|
async function handleBulkDelete() {
|
|
427
547
|
bulkDeleting.value = true;
|
|
428
548
|
bulkError.value = "";
|
|
429
|
-
const ids = [...selectedDocIds.value];
|
|
430
549
|
try {
|
|
550
|
+
if (matching.value) {
|
|
551
|
+
const { filter, count } = matching.value;
|
|
552
|
+
const deleted = await deleteByFilter(props.collectionName, filter);
|
|
553
|
+
clearMatching();
|
|
554
|
+
await fetchDocuments();
|
|
555
|
+
toast.add({ title: t("nuxtUiMongocamp.bulk.matchingDeleted", { deleted, total: count }), color: "success" });
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
const ids = [...bulkIds.value];
|
|
431
559
|
const { failed } = await runBulkDelete(
|
|
432
560
|
ids,
|
|
433
561
|
(documentId) => documentApi._delete({ collectionName: props.collectionName, documentId }),
|
|
@@ -447,12 +575,18 @@ async function handleBulkDelete() {
|
|
|
447
575
|
rowSelection.value = Object.fromEntries(failed.map((f) => [f.item, true]));
|
|
448
576
|
bulkError.value = t("nuxtUiMongocamp.bulk.partialFailure", { failed: failed.length, total: ids.length, reason: describeError(failed[0].error).message });
|
|
449
577
|
}
|
|
578
|
+
} catch (e) {
|
|
579
|
+
bulkError.value = (await describeServerError(e)).message;
|
|
450
580
|
} finally {
|
|
451
581
|
bulkDeleting.value = false;
|
|
452
582
|
}
|
|
453
583
|
}
|
|
454
584
|
const editableFields = computed(
|
|
455
|
-
() => filterFields.value.filter((f) => f.key !== "metaData" && isEditableField(f.key)).flatMap((f) =>
|
|
585
|
+
() => filterFields.value.filter((f) => f.key !== "metaData" && isEditableField(f.key)).flatMap((f) => {
|
|
586
|
+
if (f.type === "objectId") return [];
|
|
587
|
+
const info = fieldTypes.typeOf(f.key);
|
|
588
|
+
return [{ key: f.key, type: f.type === "array" || f.type === "object" ? "json" : f.type, bson: info?.dominant, mixed: info?.mixed }];
|
|
589
|
+
})
|
|
456
590
|
);
|
|
457
591
|
function bulkEditFailureReason(error) {
|
|
458
592
|
if (error instanceof BulkMatchShortfall) return t("nuxtUiMongocamp.bulk.editShortfall", { matched: error.matched, expected: error.expected });
|
|
@@ -462,9 +596,18 @@ function bulkEditFailureReason(error) {
|
|
|
462
596
|
async function handleBulkEdit(edit) {
|
|
463
597
|
bulkEditing.value = true;
|
|
464
598
|
bulkEditError.value = "";
|
|
465
|
-
const
|
|
466
|
-
const document = { [edit.field]:
|
|
599
|
+
const value = edit.bson ? wireValue(edit.bson, edit.value) : edit.value;
|
|
600
|
+
const document = { [edit.field]: value };
|
|
467
601
|
try {
|
|
602
|
+
if (matching.value) {
|
|
603
|
+
const { filter, count } = matching.value;
|
|
604
|
+
const { modified } = await updateByFilter(props.collectionName, filter, document);
|
|
605
|
+
clearMatching();
|
|
606
|
+
await fetchDocuments();
|
|
607
|
+
toast.add({ title: t("nuxtUiMongocamp.bulk.matchingUpdated", { updated: modified, total: count }), color: "success" });
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
const ids = [...bulkIds.value];
|
|
468
611
|
const { failed } = await runBulkUpdate(
|
|
469
612
|
ids,
|
|
470
613
|
(chunk) => documentApi.updateMany({
|
|
@@ -474,31 +617,40 @@ async function handleBulkEdit(edit) {
|
|
|
474
617
|
);
|
|
475
618
|
await fetchDocuments();
|
|
476
619
|
if (failed.length > 0) {
|
|
477
|
-
const onScreen = new Set(documents.value.map((row) => getDocId(row)));
|
|
478
620
|
const failedIds = failed.flatMap((f) => f.ids);
|
|
621
|
+
const onScreen = new Set(documents.value.map((row) => getDocId(row)));
|
|
479
622
|
rowSelection.value = Object.fromEntries(failedIds.filter((id) => onScreen.has(id)).map((id) => [id, true]));
|
|
480
623
|
bulkEditError.value = t("nuxtUiMongocamp.bulk.editPartialFailure", { failed: failedIds.length, total: ids.length, reason: bulkEditFailureReason(failed[0].error) });
|
|
481
624
|
}
|
|
625
|
+
} catch (e) {
|
|
626
|
+
bulkEditError.value = (await describeServerError(e)).message;
|
|
482
627
|
} finally {
|
|
483
628
|
bulkEditing.value = false;
|
|
484
629
|
}
|
|
485
630
|
}
|
|
631
|
+
const projectableKeys = computed(() => dataColumnKeys.value.filter((k) => k !== "_id"));
|
|
632
|
+
const activeProjection = computed(() => columns.value.length === 0 ? [] : usableProjection(query.value.projection, projectableKeys.value));
|
|
486
633
|
async function fetchDocuments() {
|
|
487
634
|
loading.value = true;
|
|
488
635
|
loadError.value = null;
|
|
489
636
|
rowSelection.value = {};
|
|
637
|
+
clearMatching();
|
|
490
638
|
filterRejected.value = false;
|
|
491
639
|
const filter = buildLuceneFilter(filterText.value);
|
|
492
640
|
try {
|
|
493
|
-
const res = await documentApi.
|
|
641
|
+
const res = await documentApi.searchDocumentsRaw({
|
|
494
642
|
collectionName: props.collectionName,
|
|
495
643
|
rowsPerPage: pagination.value.pageSize,
|
|
496
644
|
page: pagination.value.pageIndex,
|
|
497
|
-
|
|
498
|
-
|
|
645
|
+
searchRequest: {
|
|
646
|
+
filter,
|
|
647
|
+
sort: sorting.value.length ? sortingToMongoSort(sorting.value) : void 0,
|
|
648
|
+
// only the fields asked for are loaded (the server always adds `_id`); never an empty list, which is a 500
|
|
649
|
+
projection: activeProjection.value.length > 0 ? activeProjection.value : void 0
|
|
650
|
+
}
|
|
499
651
|
});
|
|
500
652
|
total.value = +(res.raw.headers.get("x-pagination-count-rows") ?? 0);
|
|
501
|
-
const rows = await res
|
|
653
|
+
const rows = await readJsonKeepingLongs(res);
|
|
502
654
|
documents.value = rows;
|
|
503
655
|
const firstRow = rows[0];
|
|
504
656
|
if (columns.value.length === 0 && firstRow) {
|
|
@@ -516,8 +668,8 @@ async function fetchDocuments() {
|
|
|
516
668
|
...index === 0 ? { meta: { class: { th: "sticky left-0 z-10 bg-default", td: "sticky left-0 z-10 bg-default" } } } : {}
|
|
517
669
|
}));
|
|
518
670
|
filterableColumns.value = orderedKeys.filter((k) => k !== "_id" && k !== "metaData" && typeof firstRow[k] === "string");
|
|
519
|
-
|
|
520
|
-
if (!isBucketCollection(props.collectionName)) {
|
|
671
|
+
pageFilterFields.value = schemaFromSamples(rows.map((row) => unwrapExtendedJson(row, { exactLongs: false }))).map((c) => ({ key: c.columnKey, type: c.columnKey === "_id" ? "objectId" : toFilterFieldType(c.columnType) })).filter((f) => operatorsFor(f.type).length > 0);
|
|
672
|
+
if (!isBucketCollection(props.collectionName) && writable.value) {
|
|
521
673
|
columns.value.unshift(createSelectColumn(UCheckbox, { selectAll: t("nuxtUiMongocamp.bulk.selectAll"), selectRow: t("nuxtUiMongocamp.bulk.selectRow") }));
|
|
522
674
|
}
|
|
523
675
|
columns.value.push(makeActionsColumn());
|
|
@@ -533,25 +685,23 @@ async function fetchDocuments() {
|
|
|
533
685
|
}
|
|
534
686
|
function clearAllFilters() {
|
|
535
687
|
filterText.value = "";
|
|
536
|
-
|
|
537
|
-
onFilterApply("");
|
|
538
|
-
}
|
|
539
|
-
function onFilterApply(query) {
|
|
540
|
-
appliedFilterGroup.value = { match: filterDraft.value.match, conditions: filterDraft.value.conditions.map((c) => ({ ...c })) };
|
|
541
|
-
appliedFilterQuery.value = query;
|
|
688
|
+
query.value = { ...query.value, filterGroup: emptyGroup(), lucene: "" };
|
|
542
689
|
pagination.value.pageIndex = 1;
|
|
543
690
|
fetchDocuments();
|
|
544
691
|
}
|
|
545
|
-
function
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
692
|
+
function onQueryApply(next) {
|
|
693
|
+
query.value = next;
|
|
694
|
+
const wanted = next.sort.map((entry) => {
|
|
695
|
+
const { field, desc } = parseSortEntry(entry);
|
|
696
|
+
return { id: field, desc };
|
|
697
|
+
});
|
|
698
|
+
const same = wanted.length === sorting.value.length && wanted.every((w, i) => w.id === sorting.value[i].id && w.desc === sorting.value[i].desc);
|
|
699
|
+
if (same) {
|
|
700
|
+
pagination.value.pageIndex = 1;
|
|
701
|
+
fetchDocuments();
|
|
702
|
+
} else {
|
|
703
|
+
sorting.value = wanted;
|
|
704
|
+
}
|
|
555
705
|
}
|
|
556
706
|
function onPageSizeChange() {
|
|
557
707
|
pagination.value.pageIndex = 1;
|
|
@@ -560,11 +710,14 @@ function onPageSizeChange() {
|
|
|
560
710
|
const dataColumnKeys = computed(
|
|
561
711
|
() => columns.value.flatMap((column) => "accessorKey" in column && typeof column.accessorKey === "string" ? [column.accessorKey] : [])
|
|
562
712
|
);
|
|
713
|
+
const projectedOut = computed(() => new Set(activeProjection.value.length > 0 ? dataColumnKeys.value.filter((k) => k !== "_id" && !activeProjection.value.includes(k)) : []));
|
|
714
|
+
const effectiveVisibility = computed(() => ({ ...columnVisibility.value, ...Object.fromEntries([...projectedOut.value].map((k) => [k, false])) }));
|
|
563
715
|
const columnMenuItems = computed(
|
|
564
716
|
() => dataColumnKeys.value.map((key) => ({
|
|
565
717
|
label: key,
|
|
566
718
|
type: "checkbox",
|
|
567
|
-
|
|
719
|
+
disabled: projectedOut.value.has(key),
|
|
720
|
+
checked: columnVisibility.value[key] !== false && !projectedOut.value.has(key),
|
|
568
721
|
onUpdateChecked: (checked) => {
|
|
569
722
|
columnVisibility.value = { ...columnVisibility.value, [key]: checked };
|
|
570
723
|
},
|
|
@@ -572,17 +725,29 @@ const columnMenuItems = computed(
|
|
|
572
725
|
}))
|
|
573
726
|
);
|
|
574
727
|
function exportPage(format) {
|
|
575
|
-
const rows = documents.value.map((row) =>
|
|
728
|
+
const rows = documents.value.map((row) => toExportRow(row));
|
|
576
729
|
if (format === "json") {
|
|
577
|
-
downloadTextFile(`${props.collectionName}.json`,
|
|
730
|
+
downloadTextFile(`${props.collectionName}.json`, formatDocuments(rows, "json", { pretty: true }), "application/json");
|
|
578
731
|
return;
|
|
579
732
|
}
|
|
580
|
-
const keys = dataColumnKeys.value.filter((key) =>
|
|
733
|
+
const keys = dataColumnKeys.value.filter((key) => effectiveVisibility.value[key] !== false);
|
|
581
734
|
downloadTextFile(`${props.collectionName}.csv`, rowsToCsv(rows, keys), "text/csv");
|
|
582
735
|
}
|
|
736
|
+
const chartOpen = ref(false);
|
|
737
|
+
const chartField = ref("");
|
|
738
|
+
const chartFields = computed(() => filterFields.value.filter((f) => f.type === "string" || f.type === "number" || f.type === "date-time" || f.type === "boolean").map((f) => f.key));
|
|
739
|
+
const chartItems = computed(() => chartFields.value.map((key) => ({ label: key, value: key })));
|
|
740
|
+
const chartFilter = computed(() => buildLuceneFilter(filterText.value));
|
|
741
|
+
const chartFilterTooLong = computed(() => isFilterTooLong(chartFilter.value));
|
|
742
|
+
function openChart() {
|
|
743
|
+
if (!chartFields.value.includes(chartField.value)) chartField.value = chartFields.value[0] ?? "";
|
|
744
|
+
chartOpen.value = true;
|
|
745
|
+
}
|
|
746
|
+
const exportAllOpen = ref(false);
|
|
583
747
|
const exportMenuItems = computed(() => [
|
|
584
748
|
{ label: t("nuxtUiMongocamp.collectionData.exportJson"), icon: "i-lucide-file-json", onSelect: () => exportPage("json") },
|
|
585
|
-
{ label: t("nuxtUiMongocamp.collectionData.exportCsv"), icon: "i-lucide-file-spreadsheet", onSelect: () => exportPage("csv") }
|
|
749
|
+
{ label: t("nuxtUiMongocamp.collectionData.exportCsv"), icon: "i-lucide-file-spreadsheet", onSelect: () => exportPage("csv") },
|
|
750
|
+
{ label: t("nuxtUiMongocamp.exportAll.menuItem"), icon: "i-lucide-download-cloud", onSelect: () => exportAllOpen.value = true }
|
|
586
751
|
]);
|
|
587
752
|
const DISTINCT_SUGGESTION_LIMIT = 100;
|
|
588
753
|
let distinctCache = /* @__PURE__ */ new Map();
|
|
@@ -603,21 +768,33 @@ async function loadDistinctSuggestions(field) {
|
|
|
603
768
|
async function init() {
|
|
604
769
|
distinctCache = /* @__PURE__ */ new Map();
|
|
605
770
|
isInitializing.value = true;
|
|
606
|
-
|
|
771
|
+
const rememberedSize = PAGE_SIZES.includes(persisted.value.pageSize) ? persisted.value.pageSize : PAGE_SIZES[1];
|
|
772
|
+
pagination.value.pageSize = rememberedSize;
|
|
773
|
+
sorting.value = (Array.isArray(persisted.value.sort) ? persisted.value.sort : []).filter((e) => typeof e?.id === "string" && e.id !== "" && typeof e.desc === "boolean");
|
|
607
774
|
pagination.value.pageIndex = 1;
|
|
608
775
|
filterText.value = "";
|
|
609
776
|
filterableColumns.value = [];
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
777
|
+
pageFilterFields.value = [];
|
|
778
|
+
void fieldTypes.load(true);
|
|
779
|
+
query.value = { ...emptyQueryState(), sort: sorting.value.map((e) => e.desc ? `-${e.id}` : e.id) };
|
|
780
|
+
queryBar.value?.closePanel();
|
|
781
|
+
columnVisibility.value = Object.fromEntries(
|
|
782
|
+
(Array.isArray(persisted.value.hidden) ? persisted.value.hidden : []).filter((k) => typeof k === "string").map((k) => [k, false])
|
|
783
|
+
);
|
|
616
784
|
columns.value = [];
|
|
617
785
|
documents.value = [];
|
|
618
786
|
await fetchDocuments();
|
|
619
787
|
isInitializing.value = false;
|
|
620
788
|
}
|
|
789
|
+
watch(() => pagination.value.pageSize, (size) => {
|
|
790
|
+
if (!isInitializing.value) persisted.value = { ...persisted.value, pageSize: size };
|
|
791
|
+
});
|
|
792
|
+
watch(sorting, (sort) => {
|
|
793
|
+
if (!isInitializing.value) persisted.value = { ...persisted.value, sort: sort.map((e) => ({ id: e.id, desc: e.desc })) };
|
|
794
|
+
}, { deep: true });
|
|
795
|
+
watch(columnVisibility, (visibility) => {
|
|
796
|
+
if (!isInitializing.value) persisted.value = { ...persisted.value, hidden: Object.keys(visibility).filter((k) => visibility[k] === false) };
|
|
797
|
+
}, { deep: true });
|
|
621
798
|
watch(() => props.collectionName, init, { immediate: true });
|
|
622
799
|
</script>
|
|
623
800
|
|
|
@@ -638,7 +815,7 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
638
815
|
{{ t("nuxtUiMongocamp.collectionData.documentsCount", { count: total }) }}
|
|
639
816
|
</span>
|
|
640
817
|
<UTooltip
|
|
641
|
-
v-if="isBucketCollection(collectionName)"
|
|
818
|
+
v-if="writable && isBucketCollection(collectionName)"
|
|
642
819
|
:text="t('nuxtUiMongocamp.collectionData.uploadFileTooltip')"
|
|
643
820
|
>
|
|
644
821
|
<UButton
|
|
@@ -652,7 +829,7 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
652
829
|
/>
|
|
653
830
|
</UTooltip>
|
|
654
831
|
<UTooltip
|
|
655
|
-
v-else
|
|
832
|
+
v-else-if="writable"
|
|
656
833
|
:text="t('nuxtUiMongocamp.collectionData.insertDocumentTooltip')"
|
|
657
834
|
>
|
|
658
835
|
<UButton
|
|
@@ -671,7 +848,7 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
671
848
|
@change="handleFileSelected"
|
|
672
849
|
>
|
|
673
850
|
<MongocampImport
|
|
674
|
-
v-if="!isBucketCollection(collectionName)"
|
|
851
|
+
v-if="writable && !isBucketCollection(collectionName)"
|
|
675
852
|
:collection-name="collectionName"
|
|
676
853
|
@imported="init"
|
|
677
854
|
/>
|
|
@@ -685,22 +862,23 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
685
862
|
@click="init"
|
|
686
863
|
/>
|
|
687
864
|
</UTooltip>
|
|
688
|
-
<
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
865
|
+
<div
|
|
866
|
+
class="inline-flex rounded-md border border-default p-0.5"
|
|
867
|
+
role="group"
|
|
868
|
+
:aria-label="t('nuxtUiMongocamp.collectionData.viewModeLabel')"
|
|
692
869
|
>
|
|
693
870
|
<UButton
|
|
694
|
-
|
|
871
|
+
v-for="m in ['table', 'json']"
|
|
872
|
+
:key="m"
|
|
873
|
+
:label="m === 'table' ? t('nuxtUiMongocamp.collectionData.viewTable') : t('nuxtUiMongocamp.collectionData.viewJson')"
|
|
874
|
+
:icon="m === 'table' ? 'i-lucide-table' : 'i-lucide-braces'"
|
|
875
|
+
size="xs"
|
|
695
876
|
color="neutral"
|
|
696
|
-
:variant="
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
:aria-pressed="filtersOpen"
|
|
700
|
-
:aria-label="t('nuxtUiMongocamp.collectionData.filtersTooltip')"
|
|
701
|
-
@click="filtersOpen = !filtersOpen"
|
|
877
|
+
:variant="viewMode === m ? 'subtle' : 'ghost'"
|
|
878
|
+
:aria-pressed="viewMode === m"
|
|
879
|
+
@click="viewMode = m"
|
|
702
880
|
/>
|
|
703
|
-
</
|
|
881
|
+
</div>
|
|
704
882
|
<UDropdownMenu :items="columnMenuItems">
|
|
705
883
|
<UButton
|
|
706
884
|
icon="i-lucide-columns-3"
|
|
@@ -711,6 +889,27 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
711
889
|
:aria-label="t('nuxtUiMongocamp.collectionData.columnsTooltip')"
|
|
712
890
|
/>
|
|
713
891
|
</UDropdownMenu>
|
|
892
|
+
<UButton
|
|
893
|
+
v-if="aggregatePath && !isBucketCollection(collectionName)"
|
|
894
|
+
icon="i-lucide-sigma"
|
|
895
|
+
color="neutral"
|
|
896
|
+
variant="ghost"
|
|
897
|
+
size="sm"
|
|
898
|
+
:disabled="chartFilterTooLong"
|
|
899
|
+
:to="{ path: `${aggregatePath}/${collectionName}/aggregate`, query: chartFilter ? { filter: chartFilter } : {} }"
|
|
900
|
+
:aria-label="t('nuxtUiMongocamp.collectionData.aggregateTooltip')"
|
|
901
|
+
data-test="aggregate-link"
|
|
902
|
+
/>
|
|
903
|
+
<UButton
|
|
904
|
+
v-if="!isBucketCollection(collectionName)"
|
|
905
|
+
icon="i-lucide-chart-column"
|
|
906
|
+
color="neutral"
|
|
907
|
+
variant="ghost"
|
|
908
|
+
size="sm"
|
|
909
|
+
:disabled="chartFields.length === 0 || documents.length === 0"
|
|
910
|
+
:aria-label="t('nuxtUiMongocamp.collectionData.chartTooltip')"
|
|
911
|
+
@click="openChart"
|
|
912
|
+
/>
|
|
714
913
|
<UDropdownMenu :items="exportMenuItems">
|
|
715
914
|
<UButton
|
|
716
915
|
icon="i-lucide-download"
|
|
@@ -737,45 +936,16 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
737
936
|
/>
|
|
738
937
|
</div>
|
|
739
938
|
</div>
|
|
740
|
-
<
|
|
741
|
-
|
|
742
|
-
v-model="
|
|
939
|
+
<MongocampQueryBar
|
|
940
|
+
ref="queryBar"
|
|
941
|
+
v-model="query"
|
|
743
942
|
:fields="filterFields"
|
|
943
|
+
:columns="dataColumnKeys"
|
|
944
|
+
:collection="collectionName"
|
|
744
945
|
:load-distinct="loadDistinctSuggestions"
|
|
745
|
-
@apply="
|
|
946
|
+
@apply="onQueryApply"
|
|
746
947
|
/>
|
|
747
948
|
|
|
748
|
-
<div
|
|
749
|
-
v-if="filterChips.length > 0"
|
|
750
|
-
class="flex flex-wrap items-center gap-2"
|
|
751
|
-
>
|
|
752
|
-
<UBadge
|
|
753
|
-
v-for="chip in filterChips"
|
|
754
|
-
:key="chip.id"
|
|
755
|
-
color="neutral"
|
|
756
|
-
variant="subtle"
|
|
757
|
-
class="gap-1"
|
|
758
|
-
>
|
|
759
|
-
{{ chip.label }}
|
|
760
|
-
<UButton
|
|
761
|
-
icon="i-lucide-x"
|
|
762
|
-
color="neutral"
|
|
763
|
-
variant="link"
|
|
764
|
-
size="xs"
|
|
765
|
-
class="p-0"
|
|
766
|
-
:aria-label="t('nuxtUiMongocamp.collectionData.removeFilter', { filter: chip.label })"
|
|
767
|
-
@click="removeFilterChip(chip.id)"
|
|
768
|
-
/>
|
|
769
|
-
</UBadge>
|
|
770
|
-
<UButton
|
|
771
|
-
color="neutral"
|
|
772
|
-
variant="link"
|
|
773
|
-
size="xs"
|
|
774
|
-
:label="t('nuxtUiMongocamp.collectionData.clearFilters')"
|
|
775
|
-
@click="clearFilterChips"
|
|
776
|
-
/>
|
|
777
|
-
</div>
|
|
778
|
-
|
|
779
949
|
<MongocampErrorAlert
|
|
780
950
|
:error="loadError"
|
|
781
951
|
:filter-rejected="filterRejected"
|
|
@@ -784,14 +954,32 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
784
954
|
/>
|
|
785
955
|
|
|
786
956
|
<MongocampBulkDelete
|
|
787
|
-
:selected="
|
|
957
|
+
:selected="bulkIds"
|
|
958
|
+
:selected-count="bulkCount"
|
|
959
|
+
:page-count="selectablePageCount"
|
|
960
|
+
:total="total"
|
|
961
|
+
:all-matching="matching !== null"
|
|
962
|
+
:counting="counting"
|
|
963
|
+
:note="bulkNote"
|
|
964
|
+
:confirm-name="matching ? collectionName : void 0"
|
|
788
965
|
:deleting="bulkDeleting"
|
|
789
966
|
:error="bulkError"
|
|
790
967
|
@open="bulkError = ''"
|
|
791
|
-
@clear="
|
|
968
|
+
@clear="clearBulkSelection"
|
|
969
|
+
@select-all="collectMatching"
|
|
792
970
|
@confirm="handleBulkDelete"
|
|
793
971
|
>
|
|
794
972
|
<template #actions>
|
|
973
|
+
<UButton
|
|
974
|
+
v-if="compareRows.length === 2"
|
|
975
|
+
icon="i-lucide-git-compare"
|
|
976
|
+
color="neutral"
|
|
977
|
+
variant="subtle"
|
|
978
|
+
size="sm"
|
|
979
|
+
:label="t('nuxtUiMongocamp.bulk.compareSelected')"
|
|
980
|
+
data-testid="compare-selected"
|
|
981
|
+
@click="openCompare"
|
|
982
|
+
/>
|
|
795
983
|
<UButton
|
|
796
984
|
v-if="editableFields.length > 0"
|
|
797
985
|
icon="i-lucide-pencil"
|
|
@@ -805,17 +993,24 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
805
993
|
</MongocampBulkDelete>
|
|
806
994
|
<MongocampBulkEdit
|
|
807
995
|
v-model:open="bulkEditOpen"
|
|
808
|
-
:selected="
|
|
996
|
+
:selected="bulkCount"
|
|
809
997
|
:fields="editableFields"
|
|
810
998
|
:saving="bulkEditing"
|
|
811
999
|
:error="bulkEditError"
|
|
812
1000
|
@apply="handleBulkEdit"
|
|
813
1001
|
/>
|
|
814
1002
|
|
|
1003
|
+
<pre
|
|
1004
|
+
v-if="viewMode === 'json'"
|
|
1005
|
+
class="max-h-[70vh] overflow-auto rounded-md bg-elevated p-3 text-xs whitespace-pre-wrap break-all"
|
|
1006
|
+
data-test="page-json"
|
|
1007
|
+
>{{ pageJson }}</pre>
|
|
1008
|
+
|
|
815
1009
|
<UTable
|
|
1010
|
+
v-else
|
|
816
1011
|
v-model:sorting="sorting"
|
|
817
|
-
v-model:column-visibility="columnVisibility"
|
|
818
1012
|
v-model:row-selection="rowSelection"
|
|
1013
|
+
:column-visibility="effectiveVisibility"
|
|
819
1014
|
:get-row-id="rowId"
|
|
820
1015
|
:sorting-options="{ manualSorting: true }"
|
|
821
1016
|
:data="documents"
|
|
@@ -827,6 +1022,96 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
827
1022
|
</template>
|
|
828
1023
|
</UTable>
|
|
829
1024
|
|
|
1025
|
+
<MongocampExportAll
|
|
1026
|
+
v-model:open="exportAllOpen"
|
|
1027
|
+
:collection="collectionName"
|
|
1028
|
+
:filter="buildLuceneFilter(filterText)"
|
|
1029
|
+
:sort="sortingToMongoSort(sorting)"
|
|
1030
|
+
:projection="activeProjection"
|
|
1031
|
+
:total="total"
|
|
1032
|
+
/>
|
|
1033
|
+
|
|
1034
|
+
<UModal
|
|
1035
|
+
v-model:open="chartOpen"
|
|
1036
|
+
:title="t('nuxtUiMongocamp.collectionData.chartTitle')"
|
|
1037
|
+
:ui="{ content: 'sm:max-w-3xl' }"
|
|
1038
|
+
>
|
|
1039
|
+
<template #body>
|
|
1040
|
+
<div
|
|
1041
|
+
class="flex flex-col gap-3"
|
|
1042
|
+
data-test="chart-dialog"
|
|
1043
|
+
>
|
|
1044
|
+
<p class="text-sm text-dimmed">
|
|
1045
|
+
{{ chartFilter ? t("nuxtUiMongocamp.collectionData.chartScopeFiltered", { count: total }, total) : t("nuxtUiMongocamp.collectionData.chartScopeAll", { count: total }, total) }}
|
|
1046
|
+
</p>
|
|
1047
|
+
<UFormField :label="t('nuxtUiMongocamp.collectionData.chartField')">
|
|
1048
|
+
<USelect
|
|
1049
|
+
v-model="chartField"
|
|
1050
|
+
:items="chartItems"
|
|
1051
|
+
class="w-full"
|
|
1052
|
+
:aria-label="t('nuxtUiMongocamp.collectionData.chartField')"
|
|
1053
|
+
/>
|
|
1054
|
+
</UFormField>
|
|
1055
|
+
<UAlert
|
|
1056
|
+
v-if="chartFilterTooLong"
|
|
1057
|
+
color="warning"
|
|
1058
|
+
variant="subtle"
|
|
1059
|
+
icon="i-lucide-triangle-alert"
|
|
1060
|
+
:description="t('nuxtUiMongocamp.collectionData.chartTooLong')"
|
|
1061
|
+
data-test="chart-too-long"
|
|
1062
|
+
/>
|
|
1063
|
+
<MongocampCollectionCharts
|
|
1064
|
+
v-else-if="chartOpen && chartField"
|
|
1065
|
+
:collection-name="collectionName"
|
|
1066
|
+
:field="chartField"
|
|
1067
|
+
:filter="chartFilter"
|
|
1068
|
+
/>
|
|
1069
|
+
</div>
|
|
1070
|
+
</template>
|
|
1071
|
+
</UModal>
|
|
1072
|
+
|
|
1073
|
+
<UModal
|
|
1074
|
+
v-model:open="compareOpen"
|
|
1075
|
+
:title="t('nuxtUiMongocamp.documentCompare.title')"
|
|
1076
|
+
:ui="{ content: 'sm:max-w-5xl' }"
|
|
1077
|
+
>
|
|
1078
|
+
<template #body>
|
|
1079
|
+
<p
|
|
1080
|
+
v-if="compareState === 'loading'"
|
|
1081
|
+
class="text-sm text-dimmed"
|
|
1082
|
+
role="status"
|
|
1083
|
+
data-test="compare-loading"
|
|
1084
|
+
>
|
|
1085
|
+
{{ t("nuxtUiMongocamp.collectionData.compareLoading") }}
|
|
1086
|
+
</p>
|
|
1087
|
+
<template v-else-if="compareRows.length === 2">
|
|
1088
|
+
<p
|
|
1089
|
+
v-if="compareState === 'untyped'"
|
|
1090
|
+
class="mb-2 text-sm text-warning"
|
|
1091
|
+
data-test="compare-untyped"
|
|
1092
|
+
>
|
|
1093
|
+
{{ t("nuxtUiMongocamp.collectionData.compareUntyped") }}
|
|
1094
|
+
</p>
|
|
1095
|
+
<MongocampDocumentCompare
|
|
1096
|
+
:left="typedPair?.[0] ?? compareRows[0]"
|
|
1097
|
+
:right="typedPair?.[1] ?? compareRows[1]"
|
|
1098
|
+
:left-label="String(compareRows[0]._id ?? '')"
|
|
1099
|
+
:right-label="String(compareRows[1]._id ?? '')"
|
|
1100
|
+
/>
|
|
1101
|
+
</template>
|
|
1102
|
+
</template>
|
|
1103
|
+
</UModal>
|
|
1104
|
+
|
|
1105
|
+
<USlideover
|
|
1106
|
+
v-model:open="viewOpen"
|
|
1107
|
+
:title="t('nuxtUiMongocamp.collectionData.viewDocumentTitle')"
|
|
1108
|
+
:ui="{ content: 'sm:max-w-xl' }"
|
|
1109
|
+
>
|
|
1110
|
+
<template #body>
|
|
1111
|
+
<MongocampDocumentView :document="viewDoc" />
|
|
1112
|
+
</template>
|
|
1113
|
+
</USlideover>
|
|
1114
|
+
|
|
830
1115
|
<UModal
|
|
831
1116
|
v-model:open="detailOpen"
|
|
832
1117
|
:title="t('nuxtUiMongocamp.collectionData.detailsTitle')"
|