preparing for directory creation
This commit is contained in:
@@ -8,8 +8,18 @@
|
|||||||
|
|
||||||
const router = useTinyRouter();
|
const router = useTinyRouter();
|
||||||
let children = $state({});
|
let children = $state({});
|
||||||
|
let new_dir = $state(null);
|
||||||
|
let parent = $state(false);
|
||||||
let path = $state(router.path)
|
let path = $state(router.path)
|
||||||
|
|
||||||
|
async function createDir(ev){
|
||||||
|
console.log(ev);
|
||||||
|
ev.stopPropagation();
|
||||||
|
ev.preventDefault();
|
||||||
|
alert(new_dir);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
async function loadChildren(p){
|
async function loadChildren(p){
|
||||||
p = p.substring(6);
|
p = p.substring(6);
|
||||||
if (p == '') p = '/';
|
if (p == '') p = '/';
|
||||||
@@ -19,6 +29,7 @@
|
|||||||
children.dirs[`/user/${user.id}`] = t('my_files');
|
children.dirs[`/user/${user.id}`] = t('my_files');
|
||||||
children.dirs['/project'] = t('projects')
|
children.dirs['/project'] = t('projects')
|
||||||
children.dirs['/company'] = t('companies');
|
children.dirs['/company'] = t('companies');
|
||||||
|
parent = false;
|
||||||
} else {
|
} else {
|
||||||
const url = api(`files${p}`);
|
const url = api(`files${p}`);
|
||||||
const res = await fetch(url,{credentials:'include'});
|
const res = await fetch(url,{credentials:'include'});
|
||||||
@@ -27,6 +38,8 @@
|
|||||||
if (json.dirs) children.dirs = json.dirs;
|
if (json.dirs) children.dirs = json.dirs;
|
||||||
if (json.files) children.files = json.files;
|
if (json.files) children.files = json.files;
|
||||||
if (json.title) children.title = json.title;
|
if (json.title) children.title = json.title;
|
||||||
|
parent = p.substring(0, p.lastIndexOf("/"));
|
||||||
|
if (parent == '/user'||p=='/project'||p=='/company') parent = '/';
|
||||||
yikes();
|
yikes();
|
||||||
} else {
|
} else {
|
||||||
error(res);
|
error(res);
|
||||||
@@ -55,6 +68,12 @@
|
|||||||
<h1>{t('files')} – {children?.title}</h1>
|
<h1>{t('files')} – {children?.title}</h1>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
{#if parent}
|
||||||
|
<li class="dir parent">
|
||||||
|
<span class="symbol"></span>
|
||||||
|
<a href={'/files'+parent} {onclick}>..</a>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
{#if children?.dirs}
|
{#if children?.dirs}
|
||||||
{#each Object.entries(children.dirs) as [k,v]}
|
{#each Object.entries(children.dirs) as [k,v]}
|
||||||
<li class="dir">
|
<li class="dir">
|
||||||
@@ -62,7 +81,16 @@
|
|||||||
<a href={'/files'+k} {onclick}>{v}</a>
|
<a href={'/files'+k} {onclick}>{v}</a>
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if parent}
|
||||||
|
<li class="action">
|
||||||
|
<form onsubmit={create_dir}>
|
||||||
|
<span class="symbol">+</span>
|
||||||
|
<input type="text" bind:value={new_dir} />
|
||||||
|
<button type="submit" disabled={!new_dir}>{t('create_directory')}</button>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
{#if children.files}
|
{#if children.files}
|
||||||
{#each Object.entries(children.files) as [k,v]}
|
{#each Object.entries(children.files) as [k,v]}
|
||||||
<li class="file">
|
<li class="file">
|
||||||
@@ -71,5 +99,14 @@
|
|||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if parent}
|
||||||
|
<li class="action">
|
||||||
|
<form>
|
||||||
|
<span class="symbol">+</span>
|
||||||
|
<input type="file" />
|
||||||
|
<button>{t('upload_file')}</button>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user