@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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
|
3
|
+
import { useI18n } from "#imports";
|
|
4
|
+
import { useMongocampAggregation } from "../composables/useMongocampAggregation";
|
|
5
|
+
import { PREVIEW_DEBOUNCE_MS, PREVIEW_LIMIT, pipelineKey } from "../utils/aggregationPreview";
|
|
6
|
+
import { formatCell, resultColumns } from "../utils/aggregationResult";
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
collectionName: { type: String, required: true },
|
|
9
|
+
pipeline: { type: null, required: true },
|
|
10
|
+
stageNumber: { type: Number, required: true },
|
|
11
|
+
filter: { type: String, required: false }
|
|
12
|
+
});
|
|
13
|
+
const { t } = useI18n();
|
|
14
|
+
const { runAggregation, describeAggregationError } = useMongocampAggregation();
|
|
15
|
+
const loading = ref(false);
|
|
16
|
+
const rows = ref([]);
|
|
17
|
+
const error = ref(null);
|
|
18
|
+
let timer;
|
|
19
|
+
let controller;
|
|
20
|
+
let run = 0;
|
|
21
|
+
function cancel() {
|
|
22
|
+
clearTimeout(timer);
|
|
23
|
+
controller?.abort();
|
|
24
|
+
controller = void 0;
|
|
25
|
+
}
|
|
26
|
+
async function execute(pipeline) {
|
|
27
|
+
cancel();
|
|
28
|
+
const mine = ++run;
|
|
29
|
+
const own = new AbortController();
|
|
30
|
+
controller = own;
|
|
31
|
+
loading.value = true;
|
|
32
|
+
error.value = null;
|
|
33
|
+
try {
|
|
34
|
+
const result = await runAggregation(props.collectionName, pipeline, { page: 1, rowsPerPage: PREVIEW_LIMIT }, { signal: own.signal, filter: props.filter });
|
|
35
|
+
if (mine !== run) return;
|
|
36
|
+
rows.value = result.rows;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
if (mine !== run || own.signal.aborted) return;
|
|
39
|
+
rows.value = [];
|
|
40
|
+
error.value = await describeAggregationError(e);
|
|
41
|
+
} finally {
|
|
42
|
+
if (mine === run) loading.value = false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const key = computed(() => props.pipeline ? `${props.filter ?? ""}\0${pipelineKey(props.pipeline)}` : "");
|
|
46
|
+
let first = true;
|
|
47
|
+
watch(key, () => {
|
|
48
|
+
if (!props.pipeline) {
|
|
49
|
+
cancel();
|
|
50
|
+
run++;
|
|
51
|
+
loading.value = false;
|
|
52
|
+
rows.value = [];
|
|
53
|
+
error.value = null;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const pipeline = props.pipeline;
|
|
57
|
+
if (first) {
|
|
58
|
+
first = false;
|
|
59
|
+
void execute(pipeline);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
cancel();
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
loading.value = true;
|
|
65
|
+
timer = setTimeout(() => void execute(pipeline), PREVIEW_DEBOUNCE_MS);
|
|
66
|
+
}, { immediate: true });
|
|
67
|
+
onBeforeUnmount(() => {
|
|
68
|
+
cancel();
|
|
69
|
+
run++;
|
|
70
|
+
});
|
|
71
|
+
const columns = computed(() => resultColumns(rows.value));
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<div
|
|
76
|
+
class="flex flex-col gap-1 rounded-md bg-elevated/50 p-2"
|
|
77
|
+
data-test="stage-preview"
|
|
78
|
+
>
|
|
79
|
+
<p class="text-xs text-dimmed">
|
|
80
|
+
{{ t("nuxtUiMongocamp.aggregation.previewTitle", { count: PREVIEW_LIMIT, n: stageNumber }) }}
|
|
81
|
+
</p>
|
|
82
|
+
<p
|
|
83
|
+
v-if="!pipeline"
|
|
84
|
+
class="text-sm text-dimmed"
|
|
85
|
+
data-test="preview-blocked"
|
|
86
|
+
>
|
|
87
|
+
{{ t("nuxtUiMongocamp.aggregation.previewBlocked") }}
|
|
88
|
+
</p>
|
|
89
|
+
<p
|
|
90
|
+
v-else-if="loading"
|
|
91
|
+
class="text-sm text-dimmed"
|
|
92
|
+
role="status"
|
|
93
|
+
data-test="preview-loading"
|
|
94
|
+
>
|
|
95
|
+
{{ t("nuxtUiMongocamp.aggregation.previewLoading") }}
|
|
96
|
+
</p>
|
|
97
|
+
<p
|
|
98
|
+
v-else-if="error"
|
|
99
|
+
class="text-sm text-error"
|
|
100
|
+
role="alert"
|
|
101
|
+
data-test="preview-error"
|
|
102
|
+
>
|
|
103
|
+
{{ error.message }}
|
|
104
|
+
</p>
|
|
105
|
+
<p
|
|
106
|
+
v-else-if="rows.length === 0"
|
|
107
|
+
class="text-sm text-dimmed"
|
|
108
|
+
data-test="preview-empty"
|
|
109
|
+
>
|
|
110
|
+
{{ t("nuxtUiMongocamp.aggregation.previewEmpty") }}
|
|
111
|
+
</p>
|
|
112
|
+
<div
|
|
113
|
+
v-else
|
|
114
|
+
class="overflow-x-auto"
|
|
115
|
+
>
|
|
116
|
+
<table
|
|
117
|
+
class="w-full text-left font-mono text-xs"
|
|
118
|
+
data-test="preview-table"
|
|
119
|
+
>
|
|
120
|
+
<thead>
|
|
121
|
+
<tr>
|
|
122
|
+
<th
|
|
123
|
+
v-for="column in columns"
|
|
124
|
+
:key="column"
|
|
125
|
+
class="pr-3 font-medium"
|
|
126
|
+
>
|
|
127
|
+
{{ column }}
|
|
128
|
+
</th>
|
|
129
|
+
</tr>
|
|
130
|
+
</thead>
|
|
131
|
+
<tbody>
|
|
132
|
+
<tr
|
|
133
|
+
v-for="(row, index) in rows"
|
|
134
|
+
:key="index"
|
|
135
|
+
>
|
|
136
|
+
<td
|
|
137
|
+
v-for="column in columns"
|
|
138
|
+
:key="column"
|
|
139
|
+
class="max-w-64 truncate pr-3"
|
|
140
|
+
:title="formatCell(row[column]).full"
|
|
141
|
+
>
|
|
142
|
+
{{ formatCell(row[column]).text }}
|
|
143
|
+
</td>
|
|
144
|
+
</tr>
|
|
145
|
+
</tbody>
|
|
146
|
+
</table>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</template>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RequestStage } from '../utils/aggregationPipeline.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
collectionName: string;
|
|
4
|
+
pipeline: RequestStage[] | undefined;
|
|
5
|
+
stageNumber: number;
|
|
6
|
+
filter?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed, h,
|
|
2
|
+
import { computed, h, ref, resolveComponent, watch } from "vue";
|
|
3
3
|
import { useI18n } from "#imports";
|
|
4
4
|
import useMongocampCollection from "../composables/useMongocampCollection";
|
|
5
5
|
import { useMongocampBucket } from "../composables/useMongocampBucket";
|
|
6
|
+
import { useMongocampFieldTypes } from "../composables/useMongocampFieldTypes";
|
|
7
|
+
import { useMongocampPermissions } from "../composables/useMongocampPermissions";
|
|
8
|
+
import MongocampCollectionCharts from "./MongocampCollectionCharts.vue";
|
|
6
9
|
import { useMongocampQuery } from "../composables/useMongocampQuery";
|
|
10
|
+
import { parseMetadataJson } from "../utils/filePreview";
|
|
7
11
|
const props = defineProps({
|
|
8
12
|
bucketName: { type: String, required: true }
|
|
9
13
|
});
|
|
@@ -15,22 +19,85 @@ const {
|
|
|
15
19
|
updateFileInformation,
|
|
16
20
|
downloadFile,
|
|
17
21
|
downloadingFileIds,
|
|
18
|
-
|
|
22
|
+
uploadFiles,
|
|
19
23
|
uploading,
|
|
20
24
|
fileActionInFlight
|
|
21
25
|
} = useMongocampBucket();
|
|
22
26
|
const { like } = useMongocampQuery();
|
|
23
27
|
const fileInputRef = ref(null);
|
|
28
|
+
const filesCollection = computed(() => `${props.bucketName}.files`);
|
|
29
|
+
const fieldTypes = useMongocampFieldTypes(() => filesCollection.value);
|
|
30
|
+
const { canRead, load: loadPermissions } = useMongocampPermissions();
|
|
31
|
+
const showDistribution = computed(() => canRead(filesCollection.value));
|
|
32
|
+
const distributionOpen = ref(false);
|
|
33
|
+
const distributionField = ref("");
|
|
34
|
+
const distributionFields = computed(() => fieldTypes.filterFields().filter((f) => f.type === "string" || f.type === "number" || f.type === "date-time" || f.type === "boolean").map((f) => f.key));
|
|
35
|
+
const distributionItems = computed(() => distributionFields.value.map((key) => ({ label: key, value: key })));
|
|
36
|
+
function defaultDistributionField(fields) {
|
|
37
|
+
return ["contentType", "metadata.contentType", "uploadDate"].find((key) => fields.includes(key)) ?? fields[0] ?? "";
|
|
38
|
+
}
|
|
39
|
+
async function onDistributionToggle(event) {
|
|
40
|
+
distributionOpen.value = event.target.open;
|
|
41
|
+
if (!distributionOpen.value) return;
|
|
42
|
+
await fieldTypes.load();
|
|
43
|
+
if (!distributionFields.value.includes(distributionField.value)) distributionField.value = defaultDistributionField(distributionFields.value);
|
|
44
|
+
}
|
|
45
|
+
void loadPermissions(filesCollection.value);
|
|
46
|
+
watch(filesCollection, (name) => {
|
|
47
|
+
distributionField.value = "";
|
|
48
|
+
void loadPermissions(name);
|
|
49
|
+
});
|
|
24
50
|
function openFilePicker() {
|
|
25
51
|
fileInputRef.value?.click();
|
|
26
52
|
}
|
|
27
|
-
|
|
53
|
+
const uploadProgress = ref(null);
|
|
54
|
+
const uploadResult = ref(null);
|
|
55
|
+
const dragging = ref(false);
|
|
56
|
+
let dragDepth = 0;
|
|
57
|
+
async function handleFiles(list) {
|
|
58
|
+
if (!list.length || uploading.value) return;
|
|
59
|
+
uploadResult.value = null;
|
|
60
|
+
uploadProgress.value = { done: 0, total: list.length };
|
|
61
|
+
try {
|
|
62
|
+
const result = await uploadFiles(props.bucketName, list, {
|
|
63
|
+
onProgress: (done, total2, current) => {
|
|
64
|
+
uploadProgress.value = { done, total: total2, current };
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
uploadResult.value = { uploaded: result.uploaded.length, failed: result.failed };
|
|
68
|
+
if (result.uploaded.length) await fetchFiles();
|
|
69
|
+
} finally {
|
|
70
|
+
uploadProgress.value = null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function handleFileSelected(event) {
|
|
28
74
|
const input = event.target;
|
|
29
|
-
const
|
|
75
|
+
const list = Array.from(input.files ?? []);
|
|
30
76
|
input.value = "";
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
77
|
+
return handleFiles(list);
|
|
78
|
+
}
|
|
79
|
+
function hasFiles(event) {
|
|
80
|
+
return Array.from(event.dataTransfer?.types ?? []).includes("Files");
|
|
81
|
+
}
|
|
82
|
+
function onDragEnter(event) {
|
|
83
|
+
if (!hasFiles(event)) return;
|
|
84
|
+
dragDepth++;
|
|
85
|
+
dragging.value = true;
|
|
86
|
+
}
|
|
87
|
+
function onDragLeave() {
|
|
88
|
+
dragDepth = Math.max(0, dragDepth - 1);
|
|
89
|
+
if (!dragDepth) dragging.value = false;
|
|
90
|
+
}
|
|
91
|
+
function onDrop(event) {
|
|
92
|
+
dragDepth = 0;
|
|
93
|
+
dragging.value = false;
|
|
94
|
+
return handleFiles(Array.from(event.dataTransfer?.files ?? []));
|
|
95
|
+
}
|
|
96
|
+
const previewOpen = ref(false);
|
|
97
|
+
const fileToPreview = ref(void 0);
|
|
98
|
+
function openPreview(file) {
|
|
99
|
+
fileToPreview.value = file;
|
|
100
|
+
previewOpen.value = true;
|
|
34
101
|
}
|
|
35
102
|
const UButton = resolveComponent("UButton");
|
|
36
103
|
const UTooltip = resolveComponent("UTooltip");
|
|
@@ -89,45 +156,37 @@ function makeMetadataCell() {
|
|
|
89
156
|
}
|
|
90
157
|
const isRenameModalOpen = ref(false);
|
|
91
158
|
const fileToRename = ref(void 0);
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
name: "metadata",
|
|
103
|
-
label: t("nuxtUiMongocamp.bucketFiles.columnMetadata"),
|
|
104
|
-
children: [
|
|
105
|
-
{ $formkit: "nuxtUIInput", name: "key", label: t("nuxtUiMongocamp.bucketFiles.metadataKey") },
|
|
106
|
-
{ $formkit: "nuxtUIInput", name: "value", label: t("nuxtUiMongocamp.bucketFiles.metadataValue") }
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
]);
|
|
159
|
+
const renameFilename = ref("");
|
|
160
|
+
const renameMetadata = ref("");
|
|
161
|
+
const renameSaving = ref(false);
|
|
162
|
+
const metadataParse = computed(() => parseMetadataJson(renameMetadata.value));
|
|
163
|
+
const metadataError = computed(() => {
|
|
164
|
+
const parsed = metadataParse.value;
|
|
165
|
+
if (parsed.ok) return "";
|
|
166
|
+
return parsed.reason === "invalid-json" ? t("nuxtUiMongocamp.bucketFiles.metadataInvalidJson") : t("nuxtUiMongocamp.bucketFiles.metadataNotObject");
|
|
167
|
+
});
|
|
168
|
+
const canSaveRename = computed(() => !!renameFilename.value.trim() && metadataParse.value.ok);
|
|
110
169
|
function openRename(file) {
|
|
111
170
|
fileToRename.value = file;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
metadata: Object.entries(file.metadata ?? {}).map(([key, value]) => ({ key, value }))
|
|
115
|
-
};
|
|
171
|
+
renameFilename.value = file.filename;
|
|
172
|
+
renameMetadata.value = Object.keys(file.metadata ?? {}).length ? JSON.stringify(file.metadata, null, 2) : "";
|
|
116
173
|
isRenameModalOpen.value = true;
|
|
117
174
|
}
|
|
118
175
|
async function handleRenameSave() {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
176
|
+
const parsed = metadataParse.value;
|
|
177
|
+
if (!fileToRename.value || !parsed.ok || !renameFilename.value.trim()) return;
|
|
178
|
+
renameSaving.value = true;
|
|
179
|
+
try {
|
|
180
|
+
const success = await updateFileInformation(props.bucketName, fileToRename.value.id, {
|
|
181
|
+
filename: renameFilename.value.trim(),
|
|
182
|
+
metadata: parsed.value
|
|
183
|
+
});
|
|
184
|
+
if (success) {
|
|
185
|
+
isRenameModalOpen.value = false;
|
|
186
|
+
await fetchFiles();
|
|
187
|
+
}
|
|
188
|
+
} finally {
|
|
189
|
+
renameSaving.value = false;
|
|
131
190
|
}
|
|
132
191
|
}
|
|
133
192
|
const isDeleteModalOpen = ref(false);
|
|
@@ -151,6 +210,14 @@ function makeActionsColumn() {
|
|
|
151
210
|
cell: ({ row }) => {
|
|
152
211
|
const file = row.original;
|
|
153
212
|
return h("div", { class: "flex gap-1 justify-end" }, [
|
|
213
|
+
withTooltip(t("nuxtUiMongocamp.bucketFiles.previewTooltip"), h(UButton, {
|
|
214
|
+
"icon": "i-lucide-eye",
|
|
215
|
+
"color": "neutral",
|
|
216
|
+
"variant": "ghost",
|
|
217
|
+
"size": "sm",
|
|
218
|
+
"aria-label": t("nuxtUiMongocamp.bucketFiles.previewTooltip"),
|
|
219
|
+
"onClick": () => openPreview(file)
|
|
220
|
+
})),
|
|
154
221
|
withTooltip(t("nuxtUiMongocamp.bucketFiles.downloadFileTooltip"), h(UButton, {
|
|
155
222
|
"icon": "i-lucide-download",
|
|
156
223
|
"color": "neutral",
|
|
@@ -261,7 +328,20 @@ watch(() => props.bucketName, init, { immediate: true });
|
|
|
261
328
|
</script>
|
|
262
329
|
|
|
263
330
|
<template>
|
|
264
|
-
<div
|
|
331
|
+
<div
|
|
332
|
+
class="relative flex flex-col gap-4"
|
|
333
|
+
@dragenter.prevent="onDragEnter"
|
|
334
|
+
@dragover.prevent
|
|
335
|
+
@dragleave.prevent="onDragLeave"
|
|
336
|
+
@drop.prevent="onDrop"
|
|
337
|
+
>
|
|
338
|
+
<div
|
|
339
|
+
v-if="dragging"
|
|
340
|
+
class="absolute inset-0 z-10 flex items-center justify-center rounded border-2 border-dashed border-primary bg-default/80 text-sm font-medium pointer-events-none"
|
|
341
|
+
data-testid="drop-overlay"
|
|
342
|
+
>
|
|
343
|
+
{{ t("nuxtUiMongocamp.bucketFiles.dropHere") }}
|
|
344
|
+
</div>
|
|
265
345
|
<div class="flex items-center justify-between gap-4">
|
|
266
346
|
<UInput
|
|
267
347
|
v-model="filterText"
|
|
@@ -289,6 +369,7 @@ watch(() => props.bucketName, init, { immediate: true });
|
|
|
289
369
|
<input
|
|
290
370
|
ref="fileInputRef"
|
|
291
371
|
type="file"
|
|
372
|
+
multiple
|
|
292
373
|
class="hidden"
|
|
293
374
|
@change="handleFileSelected"
|
|
294
375
|
>
|
|
@@ -310,6 +391,37 @@ watch(() => props.bucketName, init, { immediate: true });
|
|
|
310
391
|
/>
|
|
311
392
|
</div>
|
|
312
393
|
</div>
|
|
394
|
+
<UAlert
|
|
395
|
+
v-if="uploadProgress"
|
|
396
|
+
color="neutral"
|
|
397
|
+
variant="subtle"
|
|
398
|
+
icon="i-lucide-upload"
|
|
399
|
+
:title="t('nuxtUiMongocamp.bucketFiles.uploadProgress', { done: uploadProgress.done, total: uploadProgress.total })"
|
|
400
|
+
:description="uploadProgress.current"
|
|
401
|
+
/>
|
|
402
|
+
<UAlert
|
|
403
|
+
v-else-if="uploadResult"
|
|
404
|
+
:color="uploadResult.failed.length ? 'warning' : 'success'"
|
|
405
|
+
variant="subtle"
|
|
406
|
+
:icon="uploadResult.failed.length ? 'i-lucide-triangle-alert' : 'i-lucide-circle-check'"
|
|
407
|
+
:title="t('nuxtUiMongocamp.bucketFiles.uploadSummary', { uploaded: uploadResult.uploaded, failed: uploadResult.failed.length })"
|
|
408
|
+
close
|
|
409
|
+
@update:open="uploadResult = null"
|
|
410
|
+
>
|
|
411
|
+
<template
|
|
412
|
+
v-if="uploadResult.failed.length"
|
|
413
|
+
#description
|
|
414
|
+
>
|
|
415
|
+
<ul class="list-disc pl-4 text-xs">
|
|
416
|
+
<li
|
|
417
|
+
v-for="item in uploadResult.failed"
|
|
418
|
+
:key="item.name"
|
|
419
|
+
>
|
|
420
|
+
{{ item.name }}: {{ item.message }}
|
|
421
|
+
</li>
|
|
422
|
+
</ul>
|
|
423
|
+
</template>
|
|
424
|
+
</UAlert>
|
|
313
425
|
<MongocampErrorAlert
|
|
314
426
|
:error="loadError"
|
|
315
427
|
@retry="fetchFiles"
|
|
@@ -342,16 +454,86 @@ watch(() => props.bucketName, init, { immediate: true });
|
|
|
342
454
|
:ui="{ footer: 'justify-end' }"
|
|
343
455
|
>
|
|
344
456
|
<template #body>
|
|
345
|
-
<
|
|
346
|
-
:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
457
|
+
<div class="flex flex-col gap-4">
|
|
458
|
+
<UFormField :label="t('nuxtUiMongocamp.bucketFiles.filename')">
|
|
459
|
+
<UInput
|
|
460
|
+
v-model="renameFilename"
|
|
461
|
+
class="w-full"
|
|
462
|
+
/>
|
|
463
|
+
</UFormField>
|
|
464
|
+
<UFormField
|
|
465
|
+
:label="t('nuxtUiMongocamp.bucketFiles.columnMetadata')"
|
|
466
|
+
:help="t('nuxtUiMongocamp.bucketFiles.metadataHelp')"
|
|
467
|
+
:error="metadataError || void 0"
|
|
468
|
+
>
|
|
469
|
+
<UTextarea
|
|
470
|
+
v-model="renameMetadata"
|
|
471
|
+
:rows="8"
|
|
472
|
+
class="w-full font-mono"
|
|
473
|
+
data-testid="metadata-json"
|
|
474
|
+
/>
|
|
475
|
+
</UFormField>
|
|
476
|
+
</div>
|
|
477
|
+
</template>
|
|
478
|
+
<template #footer>
|
|
479
|
+
<UButton
|
|
480
|
+
:label="t('nuxtUiMongocamp.common.cancel')"
|
|
481
|
+
color="neutral"
|
|
482
|
+
variant="ghost"
|
|
483
|
+
@click="isRenameModalOpen = false"
|
|
484
|
+
/>
|
|
485
|
+
<UButton
|
|
486
|
+
:label="t('nuxtUiMongocamp.common.save')"
|
|
487
|
+
icon="i-lucide-save"
|
|
488
|
+
:disabled="!canSaveRename"
|
|
489
|
+
:loading="renameSaving"
|
|
490
|
+
@click="handleRenameSave"
|
|
351
491
|
/>
|
|
352
492
|
</template>
|
|
353
493
|
</UModal>
|
|
354
494
|
|
|
495
|
+
<details
|
|
496
|
+
v-if="showDistribution"
|
|
497
|
+
class="text-sm"
|
|
498
|
+
data-test="bucket-distribution"
|
|
499
|
+
@toggle="onDistributionToggle"
|
|
500
|
+
>
|
|
501
|
+
<summary class="cursor-pointer text-dimmed">
|
|
502
|
+
{{ t("nuxtUiMongocamp.bucketFiles.distribution") }}
|
|
503
|
+
</summary>
|
|
504
|
+
<div class="mt-3 flex flex-col gap-3">
|
|
505
|
+
<UFormField
|
|
506
|
+
v-if="distributionItems.length > 0"
|
|
507
|
+
:label="t('nuxtUiMongocamp.bucketFiles.distributionField')"
|
|
508
|
+
>
|
|
509
|
+
<USelect
|
|
510
|
+
v-model="distributionField"
|
|
511
|
+
:items="distributionItems"
|
|
512
|
+
class="w-full sm:w-64"
|
|
513
|
+
:aria-label="t('nuxtUiMongocamp.bucketFiles.distributionField')"
|
|
514
|
+
/>
|
|
515
|
+
</UFormField>
|
|
516
|
+
<p
|
|
517
|
+
v-else-if="fieldTypes.status() === 'ready' || fieldTypes.status() === 'failed'"
|
|
518
|
+
class="text-dimmed"
|
|
519
|
+
data-test="distribution-empty"
|
|
520
|
+
>
|
|
521
|
+
{{ t("nuxtUiMongocamp.bucketFiles.distributionNone") }}
|
|
522
|
+
</p>
|
|
523
|
+
<MongocampCollectionCharts
|
|
524
|
+
v-if="distributionOpen && distributionField"
|
|
525
|
+
:collection-name="filesCollection"
|
|
526
|
+
:field="distributionField"
|
|
527
|
+
/>
|
|
528
|
+
</div>
|
|
529
|
+
</details>
|
|
530
|
+
|
|
531
|
+
<MongocampFilePreview
|
|
532
|
+
v-model:open="previewOpen"
|
|
533
|
+
:bucket-name="bucketName"
|
|
534
|
+
:file="fileToPreview"
|
|
535
|
+
/>
|
|
536
|
+
|
|
355
537
|
<UModal
|
|
356
538
|
v-model:open="isDeleteModalOpen"
|
|
357
539
|
:title="t('nuxtUiMongocamp.bucketFiles.deleteFileTitle')"
|
|
@@ -2,6 +2,13 @@ type __VLS_Props = {
|
|
|
2
2
|
selected: string[];
|
|
3
3
|
deleting?: boolean;
|
|
4
4
|
error?: string;
|
|
5
|
+
pageCount?: number;
|
|
6
|
+
total?: number;
|
|
7
|
+
allMatching?: boolean;
|
|
8
|
+
counting?: boolean;
|
|
9
|
+
selectedCount?: number;
|
|
10
|
+
note?: string;
|
|
11
|
+
confirmName?: string;
|
|
5
12
|
};
|
|
6
13
|
declare const __VLS_template: () => {
|
|
7
14
|
__VLS_Slots: {
|
|
@@ -13,10 +20,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
13
20
|
open: () => any;
|
|
14
21
|
clear: () => any;
|
|
15
22
|
confirm: () => any;
|
|
23
|
+
selectAll: () => any;
|
|
16
24
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
17
25
|
onOpen?: (() => any) | undefined;
|
|
18
26
|
onClear?: (() => any) | undefined;
|
|
19
27
|
onConfirm?: (() => any) | undefined;
|
|
28
|
+
onSelectAll?: (() => any) | undefined;
|
|
20
29
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
30
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
22
31
|
declare const _default: typeof __VLS_export;
|