WIP - Persistent storage

This commit is contained in:
Andras Bacsai
2022-03-20 23:51:50 +01:00
parent 1281a0f7e4
commit 2320ab0dfc
19 changed files with 261 additions and 38 deletions

View File

@@ -0,0 +1,46 @@
<script lang="ts">
export let isNew = false;
export let storage = {
id: null,
path: null
};
import { del, post } from '$lib/api';
import { page } from '$app/stores';
import { errorNotification } from '$lib/form';
const { id } = $page.params;
async function saveStorage() {
try {
await post(`/applications/${id}/storage.json`, {
path: storage.path
});
} catch ({ error }) {
return errorNotification(error);
}
}
async function removeStorage() {
try {
await del(`/applications/${id}/storage.json`, { path: storage.path });
} catch ({ error }) {
return errorNotification(error);
}
}
</script>
<td>
<input
readonly={!isNew}
bind:value={storage.path}
required
placeholder="eg: /sqlite.db"
class=" border border-dashed border-coolgray-300"
/>
</td>
<td>
<div class="flex items-center justify-center px-2">
<button class="bg-green-600 hover:bg-green-500" on:click={saveStorage}>Add</button>
</div>
<div class="flex items-center justify-center px-2">
<button class="bg-green-600 hover:bg-green-500" on:click={removeStorage}>Remove</button>
</div>
</td>