@sfxcode/nuxt-ui-mongocamp 1.3.5 → 1.4.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/dist/module.d.mts +8 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +6 -0
- package/dist/runtime/components/MongocampAggregationBuilder.vue +302 -3
- 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 +9 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.vue +148 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +9 -0
- package/dist/runtime/components/MongocampBucketFiles.vue +169 -48
- package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +19 -0
- package/dist/runtime/components/MongocampBulkDelete.vue +118 -23
- package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +19 -0
- package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +6 -0
- package/dist/runtime/components/MongocampBulkEdit.vue +23 -2
- package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +6 -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 +15 -0
- package/dist/runtime/components/MongocampCollectionCharts.vue +199 -0
- package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +15 -0
- package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +23 -0
- package/dist/runtime/components/MongocampCollectionCopy.vue +445 -0
- package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +23 -0
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +4 -0
- package/dist/runtime/components/MongocampCollectionData.vue +342 -137
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +4 -0
- package/dist/runtime/components/MongocampCollectionInfos.vue +106 -238
- package/dist/runtime/components/MongocampCollections.vue +62 -0
- 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 +21 -2
- package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -1
- package/dist/runtime/components/MongocampDatabases.vue +22 -0
- 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 +204 -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 +2 -10
- package/dist/runtime/components/MongocampIndexes.d.vue.ts +18 -0
- package/dist/runtime/components/MongocampIndexes.vue +455 -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 +23 -3
- 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 +2 -2
- package/dist/runtime/components/MongocampRoles.vue +3 -3
- package/dist/runtime/components/MongocampServerOverview.d.vue.ts +20 -0
- package/dist/runtime/components/MongocampServerOverview.vue +443 -0
- package/dist/runtime/components/MongocampServerOverview.vue.d.ts +20 -0
- package/dist/runtime/components/MongocampSettings.d.vue.ts +25 -1
- package/dist/runtime/components/MongocampSettings.vue +70 -9
- package/dist/runtime/components/MongocampSettings.vue.d.ts +25 -1
- package/dist/runtime/components/MongocampUsers.vue +3 -3
- package/dist/runtime/composables/useMongocampAdmin.d.ts +2 -1
- package/dist/runtime/composables/useMongocampAdmin.js +6 -1
- package/dist/runtime/composables/useMongocampAggregation.d.ts +12 -1
- package/dist/runtime/composables/useMongocampAggregation.js +33 -25
- 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/useMongocampClientApi.js +2 -1
- package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +85 -0
- package/dist/runtime/composables/useMongocampCollectionCopy.js +105 -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 +47 -0
- package/dist/runtime/composables/useMongocampExportAll.js +27 -0
- package/dist/runtime/composables/useMongocampExtendedJson.d.ts +5 -1
- package/dist/runtime/composables/useMongocampExtendedJson.js +12 -6
- package/dist/runtime/composables/useMongocampFetchAll.d.ts +25 -0
- package/dist/runtime/composables/useMongocampFetchAll.js +27 -0
- package/dist/runtime/composables/useMongocampPermissions.d.ts +14 -0
- package/dist/runtime/composables/useMongocampPermissions.js +21 -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 +48 -0
- 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 +42 -0
- package/dist/runtime/composables/useMongocampServerOverview.js +61 -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 +495 -9
- package/dist/runtime/locales/en.json +495 -9
- package/dist/runtime/plugin.js +6 -3
- 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/bigIntJson.d.ts +15 -0
- package/dist/runtime/utils/bigIntJson.js +55 -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 +26 -0
- package/dist/runtime/utils/collectionCopy.js +38 -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/documentCompare.d.ts +31 -0
- package/dist/runtime/utils/documentCompare.js +70 -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 +44 -0
- package/dist/runtime/utils/documentPaths.js +144 -0
- package/dist/runtime/utils/documentTree.d.ts +40 -0
- package/dist/runtime/utils/documentTree.js +94 -0
- package/dist/runtime/utils/exportDocuments.d.ts +35 -0
- package/dist/runtime/utils/exportDocuments.js +54 -0
- package/dist/runtime/utils/exportRows.js +1 -1
- 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/indexCopy.d.ts +26 -0
- package/dist/runtime/utils/indexCopy.js +22 -0
- package/dist/runtime/utils/indexForm.d.ts +69 -0
- package/dist/runtime/utils/indexForm.js +63 -0
- package/dist/runtime/utils/limitedMap.d.ts +17 -0
- package/dist/runtime/utils/limitedMap.js +19 -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 +12 -11
|
@@ -1,36 +1,43 @@
|
|
|
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 { useMongocampFetchAll } from "../composables/useMongocampFetchAll";
|
|
24
|
+
import MongocampDocumentView from "./MongocampDocumentView.vue";
|
|
25
|
+
import MongocampQueryBar from "./MongocampQueryBar.vue";
|
|
26
|
+
import MongocampExportAll from "./MongocampExportAll.vue";
|
|
27
27
|
const props = defineProps({
|
|
28
28
|
collectionName: { type: String, required: true },
|
|
29
|
-
infoPath: { type: String, required: false, default: "/secured/admin/collections" }
|
|
29
|
+
infoPath: { type: String, required: false, default: "/secured/admin/collections" },
|
|
30
|
+
persistState: { type: Boolean, required: false, default: true },
|
|
31
|
+
stateKey: { type: String, required: false, default: "" }
|
|
30
32
|
});
|
|
31
33
|
const { t } = useI18n();
|
|
32
34
|
const { documentApi } = useMongocampClientApi();
|
|
33
35
|
const { pagination, total } = useMongocampCollection();
|
|
36
|
+
const { state: persisted } = useMongocampPersistedState(
|
|
37
|
+
() => `collectionData:${props.collectionName}${props.stateKey ? `:${props.stateKey}` : ""}`,
|
|
38
|
+
{ pageSize: pagination.value.pageSize, sort: [], hidden: [] },
|
|
39
|
+
{ storage: props.persistState ? void 0 : null }
|
|
40
|
+
);
|
|
34
41
|
const { isBucketCollection, fileIdForRow, downloadingFileIds, uploading, downloadFile, uploadFile } = useMongocampBucket();
|
|
35
42
|
const { ensureMetaData } = useMongocampDocument();
|
|
36
43
|
const { and, like, or } = useMongocampQuery();
|
|
@@ -38,6 +45,8 @@ const { schemaFromSamples } = useMongocampSchema();
|
|
|
38
45
|
const { listDistinct } = useMongocampAggregation();
|
|
39
46
|
const { createIndexForField } = useMongocampIndex();
|
|
40
47
|
const { isManager } = useMongocampRoles();
|
|
48
|
+
const { canWrite } = useMongocampPermissions();
|
|
49
|
+
const writable = computed(() => canWrite(props.collectionName));
|
|
41
50
|
const toast = useToast();
|
|
42
51
|
const fileInputRef = ref(null);
|
|
43
52
|
function openFilePicker() {
|
|
@@ -94,16 +103,34 @@ function openInsert() {
|
|
|
94
103
|
}
|
|
95
104
|
isEditModalOpen.value = true;
|
|
96
105
|
}
|
|
97
|
-
function
|
|
106
|
+
async function loadFullRow(row) {
|
|
107
|
+
const id = getDocId(row);
|
|
108
|
+
if (!id) return void 0;
|
|
109
|
+
const res = await documentApi.getDocumentRaw({ collectionName: props.collectionName, documentId: id });
|
|
110
|
+
return await readJsonKeepingLongs(res);
|
|
111
|
+
}
|
|
112
|
+
async function openEdit(row) {
|
|
113
|
+
const projected = activeProjection.value.length > 0;
|
|
114
|
+
let source = row;
|
|
115
|
+
if (projected) {
|
|
116
|
+
try {
|
|
117
|
+
const full = await loadFullRow(row);
|
|
118
|
+
if (!full) throw new Error("no id");
|
|
119
|
+
source = full;
|
|
120
|
+
} catch {
|
|
121
|
+
toast.add({ title: t("nuxtUiMongocamp.collectionData.editLoadFailed"), color: "error" });
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
98
125
|
editMode.value = "update";
|
|
99
|
-
editDocId.value = getDocId(
|
|
126
|
+
editDocId.value = getDocId(source);
|
|
100
127
|
editError.value = "";
|
|
101
|
-
originalRow.value =
|
|
102
|
-
editSamples.value = documents.value.map((r) => omitId(unwrapExtendedJson(r)));
|
|
128
|
+
originalRow.value = source;
|
|
129
|
+
editSamples.value = projected ? [omitId(unwrapExtendedJson(source))] : documents.value.map((r) => omitId(unwrapExtendedJson(r)));
|
|
103
130
|
if (editSamples.value.length > 0) {
|
|
104
|
-
editFormData.value = omitId(unwrapExtendedJson(
|
|
131
|
+
editFormData.value = omitId(unwrapExtendedJson(source));
|
|
105
132
|
} else {
|
|
106
|
-
editJson.value = JSON.stringify(
|
|
133
|
+
editJson.value = JSON.stringify(source, null, 2);
|
|
107
134
|
}
|
|
108
135
|
isEditModalOpen.value = true;
|
|
109
136
|
}
|
|
@@ -116,7 +143,8 @@ async function handleSave() {
|
|
|
116
143
|
editError.value = "";
|
|
117
144
|
let payload;
|
|
118
145
|
if (editSamples.value.length > 0) {
|
|
119
|
-
|
|
146
|
+
const { slots: _slots, ...formValues } = editFormData.value;
|
|
147
|
+
payload = wrapExtendedJson(formValues, editMode.value === "update" ? originalRow.value : void 0);
|
|
120
148
|
} else {
|
|
121
149
|
try {
|
|
122
150
|
payload = JSON.parse(editJson.value);
|
|
@@ -125,12 +153,32 @@ async function handleSave() {
|
|
|
125
153
|
return;
|
|
126
154
|
}
|
|
127
155
|
}
|
|
156
|
+
const original = editMode.value === "update" ? originalRow.value : void 0;
|
|
157
|
+
if (original && editDocId.value) {
|
|
158
|
+
const unchanged = diffDocument(original, payload);
|
|
159
|
+
if (unchanged && !hasChanges(unchanged)) {
|
|
160
|
+
isEditModalOpen.value = false;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
128
164
|
ensureMetaData(payload);
|
|
129
165
|
try {
|
|
130
166
|
if (editMode.value === "insert") {
|
|
131
167
|
await documentApi.insert({ collectionName: props.collectionName, requestBody: payload });
|
|
132
168
|
} else {
|
|
133
169
|
if (!editDocId.value) return;
|
|
170
|
+
const changes = original ? diffDocument(original, payload) : null;
|
|
171
|
+
if (changes && hasChanges(changes)) {
|
|
172
|
+
const result = await documentApi.updateDocumentPartial({
|
|
173
|
+
collectionName: props.collectionName,
|
|
174
|
+
documentId: editDocId.value,
|
|
175
|
+
requestBody: buildPartialBody(changes)
|
|
176
|
+
});
|
|
177
|
+
if (result.matchedCount === 0) throw new Error(t("nuxtUiMongocamp.collectionData.documentGone"));
|
|
178
|
+
isEditModalOpen.value = false;
|
|
179
|
+
await fetchDocuments();
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
134
182
|
const body = { ...payload };
|
|
135
183
|
delete body._id;
|
|
136
184
|
await documentApi.update({ collectionName: props.collectionName, documentId: editDocId.value, requestBody: body });
|
|
@@ -172,6 +220,15 @@ function makeActionsColumn() {
|
|
|
172
220
|
})));
|
|
173
221
|
}
|
|
174
222
|
}
|
|
223
|
+
buttons.push(withTooltip(t("nuxtUiMongocamp.collectionData.viewDocumentTooltip"), h(UButton, {
|
|
224
|
+
"icon": "i-lucide-eye",
|
|
225
|
+
"color": "neutral",
|
|
226
|
+
"variant": "ghost",
|
|
227
|
+
"size": "sm",
|
|
228
|
+
"aria-label": t("nuxtUiMongocamp.collectionData.viewDocumentTooltip"),
|
|
229
|
+
"onClick": () => openView(row.original)
|
|
230
|
+
})));
|
|
231
|
+
if (!writable.value) return h("div", { class: "flex gap-1 justify-end" }, buttons);
|
|
175
232
|
buttons.push(
|
|
176
233
|
withTooltip(t("nuxtUiMongocamp.collectionData.editDocumentTooltip"), h(UButton, {
|
|
177
234
|
"icon": "i-lucide-pencil",
|
|
@@ -210,15 +267,7 @@ function canIndexField(key) {
|
|
|
210
267
|
return isManager.value && !isBucketCollection(props.collectionName) && key !== "_id" && key !== "metaData";
|
|
211
268
|
}
|
|
212
269
|
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;
|
|
270
|
+
return (await describeServerError(error)).message;
|
|
222
271
|
}
|
|
223
272
|
async function indexField(key, ascending) {
|
|
224
273
|
if (indexing.value.has(key)) return;
|
|
@@ -267,27 +316,29 @@ const documents = ref([]);
|
|
|
267
316
|
const loading = ref(false);
|
|
268
317
|
const filterText = ref("");
|
|
269
318
|
const filterableColumns = ref([]);
|
|
270
|
-
const
|
|
271
|
-
const
|
|
272
|
-
const filterDraft = ref(emptyFilterGroup());
|
|
273
|
-
const appliedFilterGroup = ref(emptyFilterGroup());
|
|
274
|
-
const appliedFilterQuery = ref("");
|
|
319
|
+
const query = ref(emptyQueryState());
|
|
320
|
+
const queryBar = ref(null);
|
|
275
321
|
const filterFields = ref([]);
|
|
276
|
-
const filterFieldTypes = computed(() => Object.fromEntries(filterFields.value.map((f) => [f.key, f.type])));
|
|
277
|
-
const activeFilterCount = computed(() => countActiveConditions(appliedFilterGroup.value, filterFieldTypes.value));
|
|
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
|
-
);
|
|
284
322
|
const sorting = ref([]);
|
|
285
323
|
const columnVisibility = ref({});
|
|
286
324
|
const PAGE_SIZES = [10, 20, 50, 100];
|
|
287
325
|
const isInitializing = ref(false);
|
|
288
326
|
const detailOpen = ref(false);
|
|
327
|
+
const compareOpen = ref(false);
|
|
328
|
+
const compareRows = computed(() => {
|
|
329
|
+
const ticked = documents.value.filter((row, index) => rowSelection.value[rowId(row, index)]);
|
|
330
|
+
return ticked.length === 2 && selectedDocIds.value.length === 2 ? ticked : [];
|
|
331
|
+
});
|
|
332
|
+
const viewDoc = ref(null);
|
|
333
|
+
const viewOpen = ref(false);
|
|
334
|
+
const viewMode = ref("table");
|
|
289
335
|
const detailContent = ref("");
|
|
290
336
|
let filterTimer;
|
|
337
|
+
function openView(row) {
|
|
338
|
+
viewDoc.value = row;
|
|
339
|
+
viewOpen.value = true;
|
|
340
|
+
}
|
|
341
|
+
const pageJson = computed(() => valueToJson(documents.value, true));
|
|
291
342
|
function openDetail(value) {
|
|
292
343
|
detailContent.value = JSON.stringify(value, null, 2);
|
|
293
344
|
detailOpen.value = true;
|
|
@@ -295,7 +346,7 @@ function openDetail(value) {
|
|
|
295
346
|
function buildLuceneFilter(term) {
|
|
296
347
|
const trimmed = term.trim();
|
|
297
348
|
const quick = trimmed && filterableColumns.value.length > 0 ? or(...filterableColumns.value.map((col) => like(col, trimmed))) : "";
|
|
298
|
-
return and(quick,
|
|
349
|
+
return and(quick, query.value.lucene) || void 0;
|
|
299
350
|
}
|
|
300
351
|
function onFilterInput() {
|
|
301
352
|
clearTimeout(filterTimer);
|
|
@@ -307,8 +358,9 @@ function onFilterInput() {
|
|
|
307
358
|
function sortingToMongoSort(s) {
|
|
308
359
|
return s.map((col) => col.desc ? `-${col.id}` : col.id);
|
|
309
360
|
}
|
|
310
|
-
watch(sorting, () => {
|
|
361
|
+
watch(sorting, (sort) => {
|
|
311
362
|
if (isInitializing.value) return;
|
|
363
|
+
query.value = { ...query.value, sort: sortingToMongoSort(sort) };
|
|
312
364
|
pagination.value.pageIndex = 1;
|
|
313
365
|
fetchDocuments();
|
|
314
366
|
});
|
|
@@ -364,6 +416,8 @@ function makeCell(key, type) {
|
|
|
364
416
|
if (!Array.isArray(raw)) {
|
|
365
417
|
const obj = raw;
|
|
366
418
|
if ("$oid" in obj) return h("span", { class: "font-mono text-xs" }, String(obj.$oid));
|
|
419
|
+
const numberKey = Object.keys(obj).find((k) => k === "$numberLong" || k === "$numberDecimal" || k === "$numberInt" || k === "$numberDouble");
|
|
420
|
+
if (numberKey && Object.keys(obj).length === 1) return h("span", { class: "font-mono text-xs" }, String(obj[numberKey]));
|
|
367
421
|
if ("$date" in obj) return h("span", toDateDisplay(obj));
|
|
368
422
|
if (isMetaData(obj)) {
|
|
369
423
|
const rows = [];
|
|
@@ -408,7 +462,7 @@ function makeCell(key, type) {
|
|
|
408
462
|
}
|
|
409
463
|
const loadError = ref(null);
|
|
410
464
|
const filterRejected = ref(false);
|
|
411
|
-
const { describeError } = useMongocampError();
|
|
465
|
+
const { describeError, describeServerError } = useMongocampError();
|
|
412
466
|
const rowSelection = ref({});
|
|
413
467
|
const selectedDocIds = computed(() => Object.keys(rowSelection.value).filter((id) => rowSelection.value[id]));
|
|
414
468
|
const bulkDeleting = ref(false);
|
|
@@ -416,6 +470,75 @@ const bulkError = ref("");
|
|
|
416
470
|
const bulkEditing = ref(false);
|
|
417
471
|
const bulkEditError = ref("");
|
|
418
472
|
const bulkEditOpen = ref(false);
|
|
473
|
+
const MAX_MATCHING = 1e4;
|
|
474
|
+
const { fetchAllDocuments } = useMongocampFetchAll();
|
|
475
|
+
const matching = ref(null);
|
|
476
|
+
const collecting = ref(null);
|
|
477
|
+
const bulkNote = ref("");
|
|
478
|
+
const bulkProgress = ref(null);
|
|
479
|
+
let collectController;
|
|
480
|
+
let bulkController;
|
|
481
|
+
const bulkIds = computed(() => matching.value?.ids ?? selectedDocIds.value);
|
|
482
|
+
const selectablePageCount = computed(() => writable.value && !isBucketCollection(props.collectionName) ? documents.value.length : 0);
|
|
483
|
+
function clearMatching() {
|
|
484
|
+
matching.value = null;
|
|
485
|
+
bulkNote.value = "";
|
|
486
|
+
}
|
|
487
|
+
function isAbort(error) {
|
|
488
|
+
return error?.name === "AbortError";
|
|
489
|
+
}
|
|
490
|
+
async function collectMatching() {
|
|
491
|
+
clearMatching();
|
|
492
|
+
const target = total.value;
|
|
493
|
+
if (target > MAX_MATCHING) {
|
|
494
|
+
bulkNote.value = t("nuxtUiMongocamp.bulk.matchingTooMany", { total: target, cap: MAX_MATCHING });
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const controller = new AbortController();
|
|
498
|
+
collectController = controller;
|
|
499
|
+
collecting.value = { loaded: 0, target };
|
|
500
|
+
try {
|
|
501
|
+
const result = await fetchAllDocuments(props.collectionName, {
|
|
502
|
+
filter: buildLuceneFilter(filterText.value),
|
|
503
|
+
projection: ["_id"],
|
|
504
|
+
pageSize: 1e3,
|
|
505
|
+
maxRows: MAX_MATCHING,
|
|
506
|
+
signal: controller.signal,
|
|
507
|
+
keyOf: (row) => String(getDocId(row) ?? ""),
|
|
508
|
+
onProgress: (p) => collecting.value = { loaded: p.loaded, target: p.target }
|
|
509
|
+
});
|
|
510
|
+
if (result.truncated) {
|
|
511
|
+
bulkNote.value = t("nuxtUiMongocamp.bulk.matchingChanged");
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const ids = result.rows.flatMap((row) => {
|
|
515
|
+
const id = getDocId(row);
|
|
516
|
+
return id ? [id] : [];
|
|
517
|
+
});
|
|
518
|
+
const reported = result.total ?? ids.length;
|
|
519
|
+
matching.value = { ids, reported };
|
|
520
|
+
rowSelection.value = {};
|
|
521
|
+
if (ids.length !== reported || result.totalChanged) {
|
|
522
|
+
bulkNote.value = t("nuxtUiMongocamp.bulk.matchingDrift", { collected: ids.length, reported });
|
|
523
|
+
}
|
|
524
|
+
} catch (e) {
|
|
525
|
+
if (!isAbort(e)) bulkNote.value = (await describeServerError(e)).message;
|
|
526
|
+
} finally {
|
|
527
|
+
collecting.value = null;
|
|
528
|
+
if (collectController === controller) collectController = void 0;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function cancelCollect() {
|
|
532
|
+
collectController?.abort();
|
|
533
|
+
}
|
|
534
|
+
function stopBulk() {
|
|
535
|
+
bulkController?.abort();
|
|
536
|
+
}
|
|
537
|
+
function clearBulkSelection() {
|
|
538
|
+
collectController?.abort();
|
|
539
|
+
rowSelection.value = {};
|
|
540
|
+
clearMatching();
|
|
541
|
+
}
|
|
419
542
|
function openBulkEdit() {
|
|
420
543
|
bulkEditError.value = "";
|
|
421
544
|
bulkEditOpen.value = true;
|
|
@@ -426,9 +549,13 @@ function rowId(row, index) {
|
|
|
426
549
|
async function handleBulkDelete() {
|
|
427
550
|
bulkDeleting.value = true;
|
|
428
551
|
bulkError.value = "";
|
|
429
|
-
const ids = [...
|
|
552
|
+
const ids = [...bulkIds.value];
|
|
553
|
+
const all = matching.value !== null;
|
|
554
|
+
const controller = new AbortController();
|
|
555
|
+
bulkController = controller;
|
|
556
|
+
bulkProgress.value = all ? { done: 0, total: ids.length } : null;
|
|
430
557
|
try {
|
|
431
|
-
const { failed } = await runBulkDelete(
|
|
558
|
+
const { deleted, failed, notAttempted } = await runBulkDelete(
|
|
432
559
|
ids,
|
|
433
560
|
(documentId) => documentApi._delete({ collectionName: props.collectionName, documentId }),
|
|
434
561
|
void 0,
|
|
@@ -440,15 +567,24 @@ async function handleBulkDelete() {
|
|
|
440
567
|
collectionName: props.collectionName,
|
|
441
568
|
requestBody: buildIdFilter(chunk)
|
|
442
569
|
})).deletedCount
|
|
443
|
-
}
|
|
570
|
+
},
|
|
571
|
+
{ signal: controller.signal, onProgress: (done, totalIds) => bulkProgress.value = all ? { done, total: totalIds } : null }
|
|
444
572
|
);
|
|
445
573
|
await fetchDocuments();
|
|
446
|
-
|
|
574
|
+
const left = [...failed.map((f) => f.item), ...notAttempted ?? []];
|
|
575
|
+
if (all) {
|
|
576
|
+
if (left.length > 0) matching.value = { ids: left, reported: left.length };
|
|
577
|
+
if (notAttempted?.length) bulkError.value = t("nuxtUiMongocamp.bulk.stoppedDelete", { done: deleted.length, total: ids.length, left: notAttempted.length });
|
|
578
|
+
else if (failed.length > 0) bulkError.value = t("nuxtUiMongocamp.bulk.partialFailure", { failed: failed.length, total: ids.length, reason: describeError(failed[0].error).message });
|
|
579
|
+
else toast.add({ title: t("nuxtUiMongocamp.bulk.matchingDeleted", { deleted: deleted.length, total: ids.length }), color: "success" });
|
|
580
|
+
} else if (failed.length > 0) {
|
|
447
581
|
rowSelection.value = Object.fromEntries(failed.map((f) => [f.item, true]));
|
|
448
582
|
bulkError.value = t("nuxtUiMongocamp.bulk.partialFailure", { failed: failed.length, total: ids.length, reason: describeError(failed[0].error).message });
|
|
449
583
|
}
|
|
450
584
|
} finally {
|
|
451
585
|
bulkDeleting.value = false;
|
|
586
|
+
bulkProgress.value = null;
|
|
587
|
+
if (bulkController === controller) bulkController = void 0;
|
|
452
588
|
}
|
|
453
589
|
}
|
|
454
590
|
const editableFields = computed(
|
|
@@ -462,31 +598,48 @@ function bulkEditFailureReason(error) {
|
|
|
462
598
|
async function handleBulkEdit(edit) {
|
|
463
599
|
bulkEditing.value = true;
|
|
464
600
|
bulkEditError.value = "";
|
|
465
|
-
const ids = [...
|
|
601
|
+
const ids = [...bulkIds.value];
|
|
602
|
+
const all = matching.value !== null;
|
|
603
|
+
const controller = new AbortController();
|
|
604
|
+
bulkController = controller;
|
|
605
|
+
bulkProgress.value = all ? { done: 0, total: ids.length } : null;
|
|
466
606
|
const document = { [edit.field]: edit.value };
|
|
467
607
|
try {
|
|
468
|
-
const { failed } = await runBulkUpdate(
|
|
608
|
+
const { updated, failed, notAttempted } = await runBulkUpdate(
|
|
469
609
|
ids,
|
|
470
610
|
(chunk) => documentApi.updateMany({
|
|
471
611
|
collectionName: props.collectionName,
|
|
472
612
|
updateRequest: { filter: buildIdFilter(chunk), document }
|
|
473
|
-
})
|
|
613
|
+
}),
|
|
614
|
+
{ signal: controller.signal, onProgress: (done, totalIds) => bulkProgress.value = all ? { done, total: totalIds } : null }
|
|
474
615
|
);
|
|
475
616
|
await fetchDocuments();
|
|
476
|
-
|
|
617
|
+
const failedIds = failed.flatMap((f) => f.ids);
|
|
618
|
+
if (all) {
|
|
619
|
+
const left = [...failedIds, ...notAttempted ?? []];
|
|
620
|
+
if (left.length > 0) matching.value = { ids: left, reported: left.length };
|
|
621
|
+
if (notAttempted?.length) bulkEditError.value = t("nuxtUiMongocamp.bulk.stoppedEdit", { done: updated.length, total: ids.length, left: notAttempted.length });
|
|
622
|
+
else if (failedIds.length > 0) bulkEditError.value = t("nuxtUiMongocamp.bulk.editPartialFailure", { failed: failedIds.length, total: ids.length, reason: bulkEditFailureReason(failed[0].error) });
|
|
623
|
+
else toast.add({ title: t("nuxtUiMongocamp.bulk.matchingUpdated", { updated: updated.length, total: ids.length }), color: "success" });
|
|
624
|
+
} else if (failed.length > 0) {
|
|
477
625
|
const onScreen = new Set(documents.value.map((row) => getDocId(row)));
|
|
478
|
-
const failedIds = failed.flatMap((f) => f.ids);
|
|
479
626
|
rowSelection.value = Object.fromEntries(failedIds.filter((id) => onScreen.has(id)).map((id) => [id, true]));
|
|
480
627
|
bulkEditError.value = t("nuxtUiMongocamp.bulk.editPartialFailure", { failed: failedIds.length, total: ids.length, reason: bulkEditFailureReason(failed[0].error) });
|
|
481
628
|
}
|
|
482
629
|
} finally {
|
|
483
630
|
bulkEditing.value = false;
|
|
631
|
+
bulkProgress.value = null;
|
|
632
|
+
if (bulkController === controller) bulkController = void 0;
|
|
484
633
|
}
|
|
485
634
|
}
|
|
635
|
+
const projectableKeys = computed(() => dataColumnKeys.value.filter((k) => k !== "_id"));
|
|
636
|
+
const activeProjection = computed(() => columns.value.length === 0 ? [] : usableProjection(query.value.projection, projectableKeys.value));
|
|
486
637
|
async function fetchDocuments() {
|
|
487
638
|
loading.value = true;
|
|
488
639
|
loadError.value = null;
|
|
489
640
|
rowSelection.value = {};
|
|
641
|
+
collectController?.abort();
|
|
642
|
+
clearMatching();
|
|
490
643
|
filterRejected.value = false;
|
|
491
644
|
const filter = buildLuceneFilter(filterText.value);
|
|
492
645
|
try {
|
|
@@ -495,10 +648,12 @@ async function fetchDocuments() {
|
|
|
495
648
|
rowsPerPage: pagination.value.pageSize,
|
|
496
649
|
page: pagination.value.pageIndex,
|
|
497
650
|
sort: sorting.value.length ? sortingToMongoSort(sorting.value) : void 0,
|
|
651
|
+
// only the fields asked for are loaded (the server always adds `_id`); never an empty list, which is a 500
|
|
652
|
+
projection: activeProjection.value.length > 0 ? activeProjection.value : void 0,
|
|
498
653
|
filter
|
|
499
654
|
});
|
|
500
655
|
total.value = +(res.raw.headers.get("x-pagination-count-rows") ?? 0);
|
|
501
|
-
const rows = await res
|
|
656
|
+
const rows = await readJsonKeepingLongs(res);
|
|
502
657
|
documents.value = rows;
|
|
503
658
|
const firstRow = rows[0];
|
|
504
659
|
if (columns.value.length === 0 && firstRow) {
|
|
@@ -516,8 +671,8 @@ async function fetchDocuments() {
|
|
|
516
671
|
...index === 0 ? { meta: { class: { th: "sticky left-0 z-10 bg-default", td: "sticky left-0 z-10 bg-default" } } } : {}
|
|
517
672
|
}));
|
|
518
673
|
filterableColumns.value = orderedKeys.filter((k) => k !== "_id" && k !== "metaData" && typeof firstRow[k] === "string");
|
|
519
|
-
filterFields.value = schemaFromSamples(rows).map((c) => ({ key: c.columnKey, type: c.columnKey === "_id" ? "objectId" : toFilterFieldType(c.columnType) })).filter((f) => operatorsFor(f.type).length > 0);
|
|
520
|
-
if (!isBucketCollection(props.collectionName)) {
|
|
674
|
+
filterFields.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);
|
|
675
|
+
if (!isBucketCollection(props.collectionName) && writable.value) {
|
|
521
676
|
columns.value.unshift(createSelectColumn(UCheckbox, { selectAll: t("nuxtUiMongocamp.bulk.selectAll"), selectRow: t("nuxtUiMongocamp.bulk.selectRow") }));
|
|
522
677
|
}
|
|
523
678
|
columns.value.push(makeActionsColumn());
|
|
@@ -533,25 +688,23 @@ async function fetchDocuments() {
|
|
|
533
688
|
}
|
|
534
689
|
function clearAllFilters() {
|
|
535
690
|
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;
|
|
542
|
-
pagination.value.pageIndex = 1;
|
|
543
|
-
fetchDocuments();
|
|
544
|
-
}
|
|
545
|
-
function removeFilterChip(id) {
|
|
546
|
-
filterDraft.value = { ...filterDraft.value, conditions: filterDraft.value.conditions.filter((c) => c.id !== id) };
|
|
547
|
-
appliedFilterGroup.value = { ...appliedFilterGroup.value, conditions: appliedFilterGroup.value.conditions.filter((c) => c.id !== id) };
|
|
548
|
-
appliedFilterQuery.value = buildFilterQuery(appliedFilterGroup.value, filterFieldTypes.value);
|
|
691
|
+
query.value = { ...query.value, filterGroup: emptyGroup(), lucene: "" };
|
|
549
692
|
pagination.value.pageIndex = 1;
|
|
550
693
|
fetchDocuments();
|
|
551
694
|
}
|
|
552
|
-
function
|
|
553
|
-
|
|
554
|
-
|
|
695
|
+
function onQueryApply(next) {
|
|
696
|
+
query.value = next;
|
|
697
|
+
const wanted = next.sort.map((entry) => {
|
|
698
|
+
const { field, desc } = parseSortEntry(entry);
|
|
699
|
+
return { id: field, desc };
|
|
700
|
+
});
|
|
701
|
+
const same = wanted.length === sorting.value.length && wanted.every((w, i) => w.id === sorting.value[i].id && w.desc === sorting.value[i].desc);
|
|
702
|
+
if (same) {
|
|
703
|
+
pagination.value.pageIndex = 1;
|
|
704
|
+
fetchDocuments();
|
|
705
|
+
} else {
|
|
706
|
+
sorting.value = wanted;
|
|
707
|
+
}
|
|
555
708
|
}
|
|
556
709
|
function onPageSizeChange() {
|
|
557
710
|
pagination.value.pageIndex = 1;
|
|
@@ -560,11 +713,14 @@ function onPageSizeChange() {
|
|
|
560
713
|
const dataColumnKeys = computed(
|
|
561
714
|
() => columns.value.flatMap((column) => "accessorKey" in column && typeof column.accessorKey === "string" ? [column.accessorKey] : [])
|
|
562
715
|
);
|
|
716
|
+
const projectedOut = computed(() => new Set(activeProjection.value.length > 0 ? dataColumnKeys.value.filter((k) => k !== "_id" && !activeProjection.value.includes(k)) : []));
|
|
717
|
+
const effectiveVisibility = computed(() => ({ ...columnVisibility.value, ...Object.fromEntries([...projectedOut.value].map((k) => [k, false])) }));
|
|
563
718
|
const columnMenuItems = computed(
|
|
564
719
|
() => dataColumnKeys.value.map((key) => ({
|
|
565
720
|
label: key,
|
|
566
721
|
type: "checkbox",
|
|
567
|
-
|
|
722
|
+
disabled: projectedOut.value.has(key),
|
|
723
|
+
checked: columnVisibility.value[key] !== false && !projectedOut.value.has(key),
|
|
568
724
|
onUpdateChecked: (checked) => {
|
|
569
725
|
columnVisibility.value = { ...columnVisibility.value, [key]: checked };
|
|
570
726
|
},
|
|
@@ -572,17 +728,19 @@ const columnMenuItems = computed(
|
|
|
572
728
|
}))
|
|
573
729
|
);
|
|
574
730
|
function exportPage(format) {
|
|
575
|
-
const rows = documents.value.map((row) =>
|
|
731
|
+
const rows = documents.value.map((row) => toExportRow(row));
|
|
576
732
|
if (format === "json") {
|
|
577
|
-
downloadTextFile(`${props.collectionName}.json`,
|
|
733
|
+
downloadTextFile(`${props.collectionName}.json`, formatDocuments(rows, "json", { pretty: true }), "application/json");
|
|
578
734
|
return;
|
|
579
735
|
}
|
|
580
|
-
const keys = dataColumnKeys.value.filter((key) =>
|
|
736
|
+
const keys = dataColumnKeys.value.filter((key) => effectiveVisibility.value[key] !== false);
|
|
581
737
|
downloadTextFile(`${props.collectionName}.csv`, rowsToCsv(rows, keys), "text/csv");
|
|
582
738
|
}
|
|
739
|
+
const exportAllOpen = ref(false);
|
|
583
740
|
const exportMenuItems = computed(() => [
|
|
584
741
|
{ 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") }
|
|
742
|
+
{ label: t("nuxtUiMongocamp.collectionData.exportCsv"), icon: "i-lucide-file-spreadsheet", onSelect: () => exportPage("csv") },
|
|
743
|
+
{ label: t("nuxtUiMongocamp.exportAll.menuItem"), icon: "i-lucide-download-cloud", onSelect: () => exportAllOpen.value = true }
|
|
586
744
|
]);
|
|
587
745
|
const DISTINCT_SUGGESTION_LIMIT = 100;
|
|
588
746
|
let distinctCache = /* @__PURE__ */ new Map();
|
|
@@ -603,21 +761,32 @@ async function loadDistinctSuggestions(field) {
|
|
|
603
761
|
async function init() {
|
|
604
762
|
distinctCache = /* @__PURE__ */ new Map();
|
|
605
763
|
isInitializing.value = true;
|
|
606
|
-
|
|
764
|
+
const rememberedSize = PAGE_SIZES.includes(persisted.value.pageSize) ? persisted.value.pageSize : PAGE_SIZES[1];
|
|
765
|
+
pagination.value.pageSize = rememberedSize;
|
|
766
|
+
sorting.value = (Array.isArray(persisted.value.sort) ? persisted.value.sort : []).filter((e) => typeof e?.id === "string" && e.id !== "" && typeof e.desc === "boolean");
|
|
607
767
|
pagination.value.pageIndex = 1;
|
|
608
768
|
filterText.value = "";
|
|
609
769
|
filterableColumns.value = [];
|
|
610
770
|
filterFields.value = [];
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
771
|
+
query.value = { ...emptyQueryState(), sort: sorting.value.map((e) => e.desc ? `-${e.id}` : e.id) };
|
|
772
|
+
queryBar.value?.closePanel();
|
|
773
|
+
columnVisibility.value = Object.fromEntries(
|
|
774
|
+
(Array.isArray(persisted.value.hidden) ? persisted.value.hidden : []).filter((k) => typeof k === "string").map((k) => [k, false])
|
|
775
|
+
);
|
|
616
776
|
columns.value = [];
|
|
617
777
|
documents.value = [];
|
|
618
778
|
await fetchDocuments();
|
|
619
779
|
isInitializing.value = false;
|
|
620
780
|
}
|
|
781
|
+
watch(() => pagination.value.pageSize, (size) => {
|
|
782
|
+
if (!isInitializing.value) persisted.value = { ...persisted.value, pageSize: size };
|
|
783
|
+
});
|
|
784
|
+
watch(sorting, (sort) => {
|
|
785
|
+
if (!isInitializing.value) persisted.value = { ...persisted.value, sort: sort.map((e) => ({ id: e.id, desc: e.desc })) };
|
|
786
|
+
}, { deep: true });
|
|
787
|
+
watch(columnVisibility, (visibility) => {
|
|
788
|
+
if (!isInitializing.value) persisted.value = { ...persisted.value, hidden: Object.keys(visibility).filter((k) => visibility[k] === false) };
|
|
789
|
+
}, { deep: true });
|
|
621
790
|
watch(() => props.collectionName, init, { immediate: true });
|
|
622
791
|
</script>
|
|
623
792
|
|
|
@@ -638,7 +807,7 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
638
807
|
{{ t("nuxtUiMongocamp.collectionData.documentsCount", { count: total }) }}
|
|
639
808
|
</span>
|
|
640
809
|
<UTooltip
|
|
641
|
-
v-if="isBucketCollection(collectionName)"
|
|
810
|
+
v-if="writable && isBucketCollection(collectionName)"
|
|
642
811
|
:text="t('nuxtUiMongocamp.collectionData.uploadFileTooltip')"
|
|
643
812
|
>
|
|
644
813
|
<UButton
|
|
@@ -652,7 +821,7 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
652
821
|
/>
|
|
653
822
|
</UTooltip>
|
|
654
823
|
<UTooltip
|
|
655
|
-
v-else
|
|
824
|
+
v-else-if="writable"
|
|
656
825
|
:text="t('nuxtUiMongocamp.collectionData.insertDocumentTooltip')"
|
|
657
826
|
>
|
|
658
827
|
<UButton
|
|
@@ -671,7 +840,7 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
671
840
|
@change="handleFileSelected"
|
|
672
841
|
>
|
|
673
842
|
<MongocampImport
|
|
674
|
-
v-if="!isBucketCollection(collectionName)"
|
|
843
|
+
v-if="writable && !isBucketCollection(collectionName)"
|
|
675
844
|
:collection-name="collectionName"
|
|
676
845
|
@imported="init"
|
|
677
846
|
/>
|
|
@@ -685,22 +854,23 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
685
854
|
@click="init"
|
|
686
855
|
/>
|
|
687
856
|
</UTooltip>
|
|
688
|
-
<
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
857
|
+
<div
|
|
858
|
+
class="inline-flex rounded-md border border-default p-0.5"
|
|
859
|
+
role="group"
|
|
860
|
+
:aria-label="t('nuxtUiMongocamp.collectionData.viewModeLabel')"
|
|
692
861
|
>
|
|
693
862
|
<UButton
|
|
694
|
-
|
|
863
|
+
v-for="m in ['table', 'json']"
|
|
864
|
+
:key="m"
|
|
865
|
+
:label="m === 'table' ? t('nuxtUiMongocamp.collectionData.viewTable') : t('nuxtUiMongocamp.collectionData.viewJson')"
|
|
866
|
+
:icon="m === 'table' ? 'i-lucide-table' : 'i-lucide-braces'"
|
|
867
|
+
size="xs"
|
|
695
868
|
color="neutral"
|
|
696
|
-
:variant="
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
:aria-pressed="filtersOpen"
|
|
700
|
-
:aria-label="t('nuxtUiMongocamp.collectionData.filtersTooltip')"
|
|
701
|
-
@click="filtersOpen = !filtersOpen"
|
|
869
|
+
:variant="viewMode === m ? 'subtle' : 'ghost'"
|
|
870
|
+
:aria-pressed="viewMode === m"
|
|
871
|
+
@click="viewMode = m"
|
|
702
872
|
/>
|
|
703
|
-
</
|
|
873
|
+
</div>
|
|
704
874
|
<UDropdownMenu :items="columnMenuItems">
|
|
705
875
|
<UButton
|
|
706
876
|
icon="i-lucide-columns-3"
|
|
@@ -737,45 +907,16 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
737
907
|
/>
|
|
738
908
|
</div>
|
|
739
909
|
</div>
|
|
740
|
-
<
|
|
741
|
-
|
|
742
|
-
v-model="
|
|
910
|
+
<MongocampQueryBar
|
|
911
|
+
ref="queryBar"
|
|
912
|
+
v-model="query"
|
|
743
913
|
:fields="filterFields"
|
|
914
|
+
:columns="dataColumnKeys"
|
|
915
|
+
:collection="collectionName"
|
|
744
916
|
:load-distinct="loadDistinctSuggestions"
|
|
745
|
-
@apply="
|
|
917
|
+
@apply="onQueryApply"
|
|
746
918
|
/>
|
|
747
919
|
|
|
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
920
|
<MongocampErrorAlert
|
|
780
921
|
:error="loadError"
|
|
781
922
|
:filter-rejected="filterRejected"
|
|
@@ -784,14 +925,34 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
784
925
|
/>
|
|
785
926
|
|
|
786
927
|
<MongocampBulkDelete
|
|
787
|
-
:selected="
|
|
928
|
+
:selected="bulkIds"
|
|
929
|
+
:page-count="selectablePageCount"
|
|
930
|
+
:total="total"
|
|
931
|
+
:all-matching="matching !== null"
|
|
932
|
+
:collecting="collecting"
|
|
933
|
+
:note="bulkNote"
|
|
934
|
+
:confirm-name="matching ? collectionName : void 0"
|
|
788
935
|
:deleting="bulkDeleting"
|
|
936
|
+
:progress="bulkProgress"
|
|
789
937
|
:error="bulkError"
|
|
790
938
|
@open="bulkError = ''"
|
|
791
|
-
@clear="
|
|
939
|
+
@clear="clearBulkSelection"
|
|
940
|
+
@select-all="collectMatching"
|
|
941
|
+
@cancel-collect="cancelCollect"
|
|
942
|
+
@stop="stopBulk"
|
|
792
943
|
@confirm="handleBulkDelete"
|
|
793
944
|
>
|
|
794
945
|
<template #actions>
|
|
946
|
+
<UButton
|
|
947
|
+
v-if="compareRows.length === 2"
|
|
948
|
+
icon="i-lucide-git-compare"
|
|
949
|
+
color="neutral"
|
|
950
|
+
variant="subtle"
|
|
951
|
+
size="sm"
|
|
952
|
+
:label="t('nuxtUiMongocamp.bulk.compareSelected')"
|
|
953
|
+
data-testid="compare-selected"
|
|
954
|
+
@click="compareOpen = true"
|
|
955
|
+
/>
|
|
795
956
|
<UButton
|
|
796
957
|
v-if="editableFields.length > 0"
|
|
797
958
|
icon="i-lucide-pencil"
|
|
@@ -805,17 +966,26 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
805
966
|
</MongocampBulkDelete>
|
|
806
967
|
<MongocampBulkEdit
|
|
807
968
|
v-model:open="bulkEditOpen"
|
|
808
|
-
:selected="
|
|
969
|
+
:selected="bulkIds.length"
|
|
809
970
|
:fields="editableFields"
|
|
810
971
|
:saving="bulkEditing"
|
|
972
|
+
:progress="bulkProgress"
|
|
811
973
|
:error="bulkEditError"
|
|
812
974
|
@apply="handleBulkEdit"
|
|
975
|
+
@stop="stopBulk"
|
|
813
976
|
/>
|
|
814
977
|
|
|
978
|
+
<pre
|
|
979
|
+
v-if="viewMode === 'json'"
|
|
980
|
+
class="max-h-[70vh] overflow-auto rounded-md bg-elevated p-3 text-xs whitespace-pre-wrap break-all"
|
|
981
|
+
data-test="page-json"
|
|
982
|
+
>{{ pageJson }}</pre>
|
|
983
|
+
|
|
815
984
|
<UTable
|
|
985
|
+
v-else
|
|
816
986
|
v-model:sorting="sorting"
|
|
817
|
-
v-model:column-visibility="columnVisibility"
|
|
818
987
|
v-model:row-selection="rowSelection"
|
|
988
|
+
:column-visibility="effectiveVisibility"
|
|
819
989
|
:get-row-id="rowId"
|
|
820
990
|
:sorting-options="{ manualSorting: true }"
|
|
821
991
|
:data="documents"
|
|
@@ -827,6 +997,41 @@ watch(() => props.collectionName, init, { immediate: true });
|
|
|
827
997
|
</template>
|
|
828
998
|
</UTable>
|
|
829
999
|
|
|
1000
|
+
<MongocampExportAll
|
|
1001
|
+
v-model:open="exportAllOpen"
|
|
1002
|
+
:collection="collectionName"
|
|
1003
|
+
:filter="buildLuceneFilter(filterText)"
|
|
1004
|
+
:sort="sortingToMongoSort(sorting)"
|
|
1005
|
+
:projection="activeProjection"
|
|
1006
|
+
:total="total"
|
|
1007
|
+
/>
|
|
1008
|
+
|
|
1009
|
+
<UModal
|
|
1010
|
+
v-model:open="compareOpen"
|
|
1011
|
+
:title="t('nuxtUiMongocamp.documentCompare.title')"
|
|
1012
|
+
:ui="{ content: 'sm:max-w-5xl' }"
|
|
1013
|
+
>
|
|
1014
|
+
<template #body>
|
|
1015
|
+
<MongocampDocumentCompare
|
|
1016
|
+
v-if="compareRows.length === 2"
|
|
1017
|
+
:left="compareRows[0]"
|
|
1018
|
+
:right="compareRows[1]"
|
|
1019
|
+
:left-label="String(compareRows[0]._id ?? '')"
|
|
1020
|
+
:right-label="String(compareRows[1]._id ?? '')"
|
|
1021
|
+
/>
|
|
1022
|
+
</template>
|
|
1023
|
+
</UModal>
|
|
1024
|
+
|
|
1025
|
+
<USlideover
|
|
1026
|
+
v-model:open="viewOpen"
|
|
1027
|
+
:title="t('nuxtUiMongocamp.collectionData.viewDocumentTitle')"
|
|
1028
|
+
:ui="{ content: 'sm:max-w-xl' }"
|
|
1029
|
+
>
|
|
1030
|
+
<template #body>
|
|
1031
|
+
<MongocampDocumentView :document="viewDoc" />
|
|
1032
|
+
</template>
|
|
1033
|
+
</USlideover>
|
|
1034
|
+
|
|
830
1035
|
<UModal
|
|
831
1036
|
v-model:open="detailOpen"
|
|
832
1037
|
:title="t('nuxtUiMongocamp.collectionData.detailsTitle')"
|