working on search

This commit is contained in:
2025-07-04 23:03:33 +02:00
parent c934e19837
commit b07533eaa9
6 changed files with 161 additions and 141 deletions

View File

@@ -8,6 +8,7 @@
import Footer from "./Components/Footer.svelte";
import Login from "./Components/Login.svelte";
import Menu from "./Components/Menu.svelte";
import Search from "./routes/search/Search.svelte";
import User from "./routes/user/User.svelte";
import UserEdit from "./routes/user/Edit.svelte";
@@ -31,10 +32,11 @@
{#if user.name }
<!-- https://github.com/notnotsamuel/svelte-tiny-router -->
<Menu />
<Route path="/user" component={User} />
<Route path="/user/login" component={User} />
<Route path="/user/:user_id/edit" component={UserEdit} />
<Route path="/user/oidc/add" component={EditService} />
<Route path="/search" component={Search} />
<Route path="/user" component={User} />
<Route path="/user/login" component={User} />
<Route path="/user/:user_id/edit" component={UserEdit} />
<Route path="/user/oidc/add" component={EditService} />
<Route path="/user/oidc/edit/:serviceName" component={EditService} />
<Route>
<p>Page not found</p>

View File

@@ -0,0 +1,44 @@
<script>
import {t} from '../../translations.svelte.js';
let key = "";
let fulltext = false;
let html = "";
async function doSearch(ev){
ev.preventDefault();
const params = new URLSearchParams()
params.set('key', key);
if (fulltext) params.set('fulltext',true);
const url = `${location.protocol}//${location.host.replace('5173','8080')}/legacy/search?${params.toString()}`;
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
html = await resp.text();
if (!html) html = t('search.nothing_found');
}
}
</script>
<fieldset class="search">
<legend>{t('search.search')}</legend>
<form onsubmit={doSearch}>
<label>
{t('search.key')}
<input type="text" bind:value={key} />
</label>
<label>
<input type="checkbox" bind:checked={fulltext} />
{t('search.fulltext')}
</label>
<button type="submit">{t('search.go')}</button>
</form>
</fieldset>
{#if html}
<fieldset>
<legend>
{t('search.results')}
</legend>
{@html html}
</fieldset>
{/if}