|
|
|
|
@ -12,8 +12,8 @@
@@ -12,8 +12,8 @@
|
|
|
|
|
let files = $state(); |
|
|
|
|
let parent = $state(false); |
|
|
|
|
let form = $state(false); |
|
|
|
|
let path = $state(null) |
|
|
|
|
|
|
|
|
|
let path = $state(null); |
|
|
|
|
let delete_allowed = $state(false); |
|
|
|
|
let available = $derived.by(isAvailable); |
|
|
|
|
|
|
|
|
|
function isAvailable(){ |
|
|
|
|
@ -50,11 +50,33 @@
@@ -50,11 +50,33 @@
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function dropDir(p,name){ |
|
|
|
|
if (confirm(t('confirm_delete',{element:name})+"\n\n"+t('deletes_nested'))) dropElement(p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function dropElement(url){ |
|
|
|
|
const res = await fetch(url,{ |
|
|
|
|
credentials: 'include', |
|
|
|
|
method: 'DELETE' |
|
|
|
|
}); |
|
|
|
|
if (res.ok) { |
|
|
|
|
handleDirectory(res); |
|
|
|
|
} else { |
|
|
|
|
error(res); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function dropFile(p,name){ |
|
|
|
|
if (confirm(t('confirm_delete',{element:name}))) dropElement(p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function handleDirectory(res){ |
|
|
|
|
let json = await res.json(); |
|
|
|
|
if (json.dirs) children.dirs = json.dirs; |
|
|
|
|
if (json.files) children.files = json.files; |
|
|
|
|
if (json.title) children.title = json.title; |
|
|
|
|
delete_allowed = json.delete; |
|
|
|
|
yikes(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -136,7 +158,9 @@
@@ -136,7 +158,9 @@
|
|
|
|
|
<li class="dir"> |
|
|
|
|
<span class="symbol"></span> |
|
|
|
|
<a href={'/files'+k} {onclick}>{v}</a> |
|
|
|
|
<button class="symbol">x</button> |
|
|
|
|
{#if delete_allowed} |
|
|
|
|
<button class="symbol" onclick={e => dropDir(`/api/files${k}`,v)}></button> |
|
|
|
|
{/if} |
|
|
|
|
</li> |
|
|
|
|
{/each} |
|
|
|
|
{/if} |
|
|
|
|
@ -153,7 +177,10 @@
@@ -153,7 +177,10 @@
|
|
|
|
|
{#each Object.entries(children.files) as [k,v]} |
|
|
|
|
<li class="file"> |
|
|
|
|
<span class="symbol"></span> |
|
|
|
|
<a href={'/api/files'+k} target="_blank">{v}</a> |
|
|
|
|
<a href={`/api/files${k}`} target="_blank">{v}</a> |
|
|
|
|
{#if delete_allowed} |
|
|
|
|
<button class="symbol" onclick={e => dropFile(`/api/files${k}`,v)}></button> |
|
|
|
|
{/if} |
|
|
|
|
</li> |
|
|
|
|
{/each} |
|
|
|
|
{/if} |
|
|
|
|
|