mirror of
https://github.com/ershisan99/coolify.git
synced 2026-01-29 12:34:38 +00:00
WIP - Persistent storage
This commit is contained in:
46
src/routes/applications/[id]/storage/_Storage.svelte
Normal file
46
src/routes/applications/[id]/storage/_Storage.svelte
Normal 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>
|
||||
Reference in New Issue
Block a user