Skip to content
Snippets Groups Projects
Commit 8a106bc1 authored by Trirst's avatar Trirst
Browse files

Delete action

parent 7f32d45d
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { fetchAPI } from "@/static/js/helper"; import { fetchAPI } from "@/static/js/helper";
import { paths } from "@/static/js/paths"; import { paths } from "@/static/js/paths";
import { user } from "@/stores"; import { user } from "@/stores";
import { push } from "svelte-spa-router";
export let params = {}; export let params = {};
let imageMetadata = {}; let imageMetadata = {};
...@@ -51,6 +52,18 @@ ...@@ -51,6 +52,18 @@
}; };
fetchAPI(paths.ImageField(snowflake), options); fetchAPI(paths.ImageField(snowflake), options);
} }
// Delete the image then reroute back to /browse?p=1
// I don't know why the fuck this works but just leave it here
async function deleteImage(snowflake) {
if (confirm("Delete image?")) {
const options = {
method: "DELETE",
headers: { secret: $user.secret },
};
fetchAPI(paths.ImageField(snowflake), options);
push("#/browse?p=1");
}
}
</script> </script>
<svelte:head> <svelte:head>
...@@ -58,6 +71,7 @@ ...@@ -58,6 +71,7 @@
</svelte:head> </svelte:head>
<div class="flex flex-row space-x-12"> <div class="flex flex-row space-x-12">
<!-- Image metatadata side -->
<div class="pl-2"> <div class="pl-2">
<ul> <ul>
<li><strong>Snowflake: </strong> {imageMetadata.snowflake}</li> <li><strong>Snowflake: </strong> {imageMetadata.snowflake}</li>
...@@ -68,6 +82,7 @@ ...@@ -68,6 +82,7 @@
<li><strong>Image type: </strong> {imageMetadata.type}</li> <li><strong>Image type: </strong> {imageMetadata.type}</li>
<li><strong>Uploaded by: </strong> {imageMetadata.user}</li> <li><strong>Uploaded by: </strong> {imageMetadata.user}</li>
</ul> </ul>
<!-- Actions -->
<div><button on:click={() => (edit = !edit)}>Edit</button></div> <div><button on:click={() => (edit = !edit)}>Edit</button></div>
<div><button on:click={() => (addTag = !addTag)}>Add tag</button></div> <div><button on:click={() => (addTag = !addTag)}>Add tag</button></div>
{#if addTag} {#if addTag}
...@@ -76,7 +91,16 @@ ...@@ -76,7 +91,16 @@
<button on:click={imageTagAdd}>Add</button> <button on:click={imageTagAdd}>Add</button>
</div> </div>
{/if} {/if}
<div>
<button
on:click={() => {
deleteImage(params.snowflake);
}}>Delete</button
>
</div>
</div> </div>
<!-- Image side -->
<!-- Image family -->
<div class="w-full"> <div class="w-full">
<div class="flex flex-row flex-wrap m-4"> <div class="flex flex-row flex-wrap m-4">
{#each imageFamily as snowflake} {#each imageFamily as snowflake}
...@@ -90,6 +114,7 @@ ...@@ -90,6 +114,7 @@
{/each} {/each}
</div> </div>
<img src={paths.ImageFile(params.snowflake)} alt="" class="max-w-2xl" /> <img src={paths.ImageFile(params.snowflake)} alt="" class="max-w-2xl" />
<!-- Commentary -->
{#if imageMetadata.commentary || imageMetadata.commentary_translation} {#if imageMetadata.commentary || imageMetadata.commentary_translation}
<div class="bg-gray-200 p-4 m-4"> <div class="bg-gray-200 p-4 m-4">
<div><strong>Artist's commentary</strong></div> <div><strong>Artist's commentary</strong></div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment