diff --git a/app/app.vue b/app/app.vue index c607ce3..14e5fde 100644 --- a/app/app.vue +++ b/app/app.vue @@ -28,6 +28,25 @@
+
+ {{ selectedKeys.size }} ausgewählt + + +
search @@ -81,6 +103,7 @@ import { ref, computed, watch, onMounted } from 'vue' import { Popup, PopupSize } from '~/utils/popup' import UploadPopup from '~/components/popup/UploadPopup.vue' +import MoveObjectsPopup, { type MoveObjectsPayload } from '~/components/popup/MoveObjectsPopup.vue' import type { S3Bucket, S3Object } from '~/utils/s3xml' useHead({ title: 'r9t · Object Storage' }) @@ -99,6 +122,7 @@ const loadingObjects = ref(false) const errorMessage = ref(null) const objectsError = ref(null) const toastMessage = ref(null) +const selectedKeys = ref>(new Set()) const filteredObjects = computed(() => { if (!search.value) { @@ -111,6 +135,28 @@ const filteredObjects = computed(() => { function selectBucket(name: string) { selectedBucket.value = name selectedObject.value = null + clearSelection() +} + +function toggleSelection(key: string) { + const next = new Set(selectedKeys.value) + if (next.has(key)) { + next.delete(key) + } + else { + next.add(key) + } + selectedKeys.value = next +} + +function toggleSelectAll() { + const allSelected = filteredObjects.value.length > 0 + && filteredObjects.value.every((object) => selectedKeys.value.has(object.key)) + selectedKeys.value = allSelected ? new Set() : new Set(filteredObjects.value.map((object) => object.key)) +} + +function clearSelection() { + selectedKeys.value = new Set() } function notify(message: string) { @@ -141,6 +187,34 @@ function openUploadPopup() { ) } +function openMovePopup() { + if (!selectedBucket.value || !selectedKeys.value.size) { + return + } + usePopup().open( + Popup.component(MoveObjectsPopup) + .setConfig({ + heading: 'Objekte verschieben', + size: PopupSize.MEDIUM, + closeOnOverlayClick: false, + callback: (payload) => handleObjectsMoved(payload as string[]), + }) + .setPayload({ sourceBucket: selectedBucket.value, keys: [...selectedKeys.value], buckets: buckets.value }), + ) +} + +function handleObjectsMoved(movedKeys: string[]) { + const next = new Set(selectedKeys.value) + for (const key of movedKeys) { + next.delete(key) + } + selectedKeys.value = next + notify(movedKeys.length === 1 ? 'Objekt verschoben.' : `${movedKeys.length} Objekte verschoben.`) + if (selectedBucket.value) { + loadObjects(selectedBucket.value) + } +} + async function loadBuckets() { errorMessage.value = null try { diff --git a/app/components/ObjectTable.vue b/app/components/ObjectTable.vue index 855c756..41a2903 100644 --- a/app/components/ObjectTable.vue +++ b/app/components/ObjectTable.vue @@ -3,6 +3,16 @@ + @@ -17,7 +27,7 @@
+ + KEY