implemented storing of bookmarks
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
43
frontend/src/routes/bookmark/Index.svelte
Normal file
43
frontend/src/routes/bookmark/Index.svelte
Normal file
@@ -0,0 +1,43 @@
|
||||
<script>
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
import Editor from '../../Components/MarkdownEditor.svelte';
|
||||
|
||||
let comment = $state({source:null,rendered:null});
|
||||
let error = $state(null);
|
||||
let link = $state(null);
|
||||
|
||||
async function onclick(ev){
|
||||
let data = {
|
||||
url : link,
|
||||
comment : comment.source
|
||||
};
|
||||
const url = api('bookmark/save');
|
||||
const resp = await fetch(url,{
|
||||
credentials : 'include',
|
||||
method : 'POST',
|
||||
body : JSON.stringify(data)
|
||||
});
|
||||
if (resp.ok) {
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<fieldset>
|
||||
<legend>{t('Bookmarks')}</legend>
|
||||
{#if error}
|
||||
<span class="error">{error}</span>
|
||||
{/if}
|
||||
<label>
|
||||
{t('URL')}
|
||||
<input bind:value={link} />
|
||||
</label>
|
||||
<label>
|
||||
{t('Comment')}
|
||||
<Editor simple={true} bind:value={comment} />
|
||||
</label>
|
||||
<button {onclick}>{t('save')}</button>
|
||||
</fieldset>
|
||||
Reference in New Issue
Block a user