development #1
@@ -6,6 +6,7 @@
|
||||
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
/**
|
||||
* @type any[]
|
||||
@@ -61,7 +62,41 @@
|
||||
/>
|
||||
</svg>
|
||||
<div class="min-w-0 flex-auto">
|
||||
<p class="text-sm font-semibold leading-6 text-gray-900">{item.name}</p>
|
||||
<span class="text-sm font-semibold leading-6 text-gray-900">{item.name}</span>
|
||||
<!-- Delete button -->
|
||||
<button
|
||||
style="padding: 2px"
|
||||
id="del__{item.name}"
|
||||
on:click|preventDefault={async (ev) => {
|
||||
let delete_item = window.confirm("Bist du sicher?");
|
||||
|
||||
if (delete_item) {
|
||||
let filename = event.currentTarget.id.split('del__')[1]
|
||||
|
||||
// delete request
|
||||
// --------------
|
||||
|
||||
let url = `/api/list/${filename}`
|
||||
|
||||
console.log(`--- ${filename} + ${url}`)
|
||||
try {
|
||||
const response = await fetch(url,
|
||||
{method: 'DELETE'}
|
||||
)
|
||||
if (response.status == 204) {
|
||||
setTimeout(() => {window.location.reload()}, 500)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error.message)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
height="20" width="20" xmlns="http://www.w3.org/2000/svg"><path d="m8 3v1 1h1v-1h4v1h1v-1-1zm-4 3v1h14v-1zm2 2v11h1 9v-1-10h-1v10h-8v-10z" fill="#373737" transform="translate(1 1)"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden sm:flex sm:flex-col sm:items-end">
|
||||
|
||||
@@ -33,3 +33,31 @@ export async function GET({ params }) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export async function DELETE({ params }) {
|
||||
const vorgang = params.vorgang
|
||||
|
||||
const object_list = await new Promise((resolve, reject) => {
|
||||
|
||||
const res = []
|
||||
const items_str = client.listObjects('tatort', vorgang, true)
|
||||
|
||||
items_str.on('data', (obj) => {
|
||||
res.push(obj.name)
|
||||
})
|
||||
|
||||
items_str.on('error', reject)
|
||||
|
||||
items_str.on('end', async () => {
|
||||
resolve(res)
|
||||
})
|
||||
|
||||
console.log(`+++ ${vorgang}`)
|
||||
|
||||
})
|
||||
|
||||
await client.removeObjects('tatort', object_list)
|
||||
|
||||
return new Response(null, { status: 204 });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user