working on file module
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -85,7 +85,7 @@
|
||||
<Route path="/document/add" component={AddDoc} />
|
||||
<Route path="/document/:id/send" component={SendDoc} />
|
||||
<Route path="/document/:id/view" component={ViewDoc} />
|
||||
<Route path="/files" component={FileIndex} />
|
||||
<Route path="/files/*" component={FileIndex} />
|
||||
<Route path="/message/settings" component={Messages} />
|
||||
<Route path="/notes" component={Notes} />
|
||||
<Route path="/project" component={ProjectList} />
|
||||
|
||||
@@ -1,5 +1,58 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { api } from '../../urls.svelte';
|
||||
import { error } from '../../warn.svelte';
|
||||
import { t } from '../../translations.svelte';
|
||||
import { user } from '../../user.svelte';
|
||||
|
||||
const router = useTinyRouter();
|
||||
let children = $state({});
|
||||
|
||||
async function loadChildren(path){
|
||||
path = path.substring(6);
|
||||
if (path == '') path = '/';
|
||||
children = { dirs : {}};
|
||||
if (path == '/'){
|
||||
children.dirs[t('my_files')] = `user/${user.id}`;
|
||||
children.dirs[t('projects')] = `projects`;
|
||||
children.dirs[t('companies')] = `company`;
|
||||
} else {
|
||||
const url = api(`files${path}`);
|
||||
const res = await fetch(url,{credentials:'include'});
|
||||
if (res.ok){
|
||||
} else {
|
||||
error(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onclick(ev){
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
var target = ev.target;
|
||||
while (target && !target.href) target=target.parentNode;
|
||||
let href = target.getAttribute('href');
|
||||
if (href) {
|
||||
router.navigate(href);
|
||||
loadChildren(href);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
onMount(() => loadChildren(window.location.pathname));
|
||||
</script>
|
||||
|
||||
<h1>{t('files')}</h1>
|
||||
<h1>{t('files')} – {router.path}</h1>
|
||||
|
||||
{#if children?.dirs}
|
||||
<ul>
|
||||
{#each Object.entries(children.dirs) as [k,v]}
|
||||
<li>
|
||||
<a href={router.fullPath+'/'+v} {onclick}>{k}</a>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user