UI fixes
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
import { getUserDetails } from '$lib/common';
|
||||
import * as db from '$lib/database';
|
||||
import { ErrorHandler } from '$lib/database';
|
||||
import type { RequestHandler } from '@sveltejs/kit';
|
||||
|
||||
export const post: RequestHandler = async (event) => {
|
||||
const { teamId, status, body } = await getUserDetails(event);
|
||||
if (status === 401) return { status, body };
|
||||
|
||||
let { name, fqdn, port, buildCommand, startCommand, installCommand } = await event.request.json();
|
||||
|
||||
if (fqdn) fqdn = fqdn.toLowerCase();
|
||||
if (port) port = Number(port);
|
||||
|
||||
try {
|
||||
const { id } = await db.importApplication({
|
||||
name,
|
||||
teamId,
|
||||
fqdn,
|
||||
port,
|
||||
buildCommand,
|
||||
startCommand,
|
||||
installCommand
|
||||
});
|
||||
return { status: 201, body: { id } };
|
||||
} catch (error) {
|
||||
return ErrorHandler(error);
|
||||
}
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
import { getUserDetails, uniqueName } from '$lib/common';
|
||||
import * as db from '$lib/database';
|
||||
import { ErrorHandler } from '$lib/database';
|
||||
import type { RequestHandler } from '@sveltejs/kit';
|
||||
|
||||
export const post: RequestHandler = async (event) => {
|
||||
const { teamId, status, body } = await getUserDetails(event);
|
||||
if (status === 401) return { status, body };
|
||||
|
||||
const { name } = await event.request.json();
|
||||
if (!name) return { status: 400, body: { error: 'Missing name.' } };
|
||||
|
||||
try {
|
||||
const { id } = await db.newApplication({ name, teamId });
|
||||
return { status: 201, body: { id } };
|
||||
} catch (error) {
|
||||
return ErrorHandler(error);
|
||||
}
|
||||
};
|
||||
@@ -1,53 +0,0 @@
|
||||
<script context="module" lang="ts">
|
||||
import type { Load } from '@sveltejs/kit';
|
||||
export const load: Load = async ({ fetch }) => {
|
||||
const url = `/common/getUniqueName.json`;
|
||||
const res = await fetch(url);
|
||||
|
||||
if (res.ok) {
|
||||
return {
|
||||
props: {
|
||||
...(await res.json())
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: res.status,
|
||||
error: new Error(`Could not load ${url}`)
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export let name;
|
||||
import { onMount } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { post } from '$lib/api';
|
||||
import { errorNotification } from '$lib/form';
|
||||
|
||||
let nameEl: HTMLInputElement;
|
||||
onMount(() => {
|
||||
nameEl.focus();
|
||||
});
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const { id } = await post('/new/application.json', { name });
|
||||
return await goto(`/applications/${id}`);
|
||||
} catch ({ error }) {
|
||||
return errorNotification(error);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex space-x-1 p-6 font-bold">
|
||||
<div class="mr-4 text-2xl tracking-tight">Add New Application</div>
|
||||
</div>
|
||||
<div class="pt-10">
|
||||
<form on:submit|preventDefault={handleSubmit}>
|
||||
<div class="flex flex-col items-center space-y-4">
|
||||
<input name="name" placeholder="Application name" bind:this={nameEl} bind:value={name} />
|
||||
<button type="submit" class="bg-green-600 hover:bg-green-500">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,18 +0,0 @@
|
||||
import { getUserDetails } from '$lib/common';
|
||||
import * as db from '$lib/database';
|
||||
import { ErrorHandler } from '$lib/database';
|
||||
import type { RequestHandler } from '@sveltejs/kit';
|
||||
|
||||
export const post: RequestHandler = async (event) => {
|
||||
const { teamId, status, body } = await getUserDetails(event);
|
||||
if (status === 401) return { status, body };
|
||||
|
||||
const { name } = await event.request.json();
|
||||
|
||||
try {
|
||||
const { id } = await db.newDatabase({ name, teamId });
|
||||
return { status: 201, body: { id } };
|
||||
} catch (error) {
|
||||
return ErrorHandler(error);
|
||||
}
|
||||
};
|
||||
@@ -1,59 +0,0 @@
|
||||
<script context="module" lang="ts">
|
||||
import type { Load } from '@sveltejs/kit';
|
||||
export const load: Load = async ({ fetch, session }) => {
|
||||
const url = `/common/getUniqueName.json`;
|
||||
const res = await fetch(url);
|
||||
|
||||
if (res.ok) {
|
||||
return {
|
||||
props: {
|
||||
...(await res.json())
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: res.status,
|
||||
error: new Error(`Could not load ${url}`)
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export let name;
|
||||
import { errorNotification } from '$lib/form';
|
||||
import { onMount } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { post } from '$lib/api';
|
||||
let autofocus;
|
||||
|
||||
onMount(() => {
|
||||
autofocus.focus();
|
||||
});
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const { id } = await post('/new/database.json', { name });
|
||||
return await goto(`/databases/${id}`);
|
||||
} catch ({ error }) {
|
||||
return errorNotification(error);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex space-x-1 p-6 font-bold">
|
||||
<div class="mr-4 text-2xl tracking-tight">Add New Database</div>
|
||||
</div>
|
||||
<div class="pt-10">
|
||||
<form on:submit|preventDefault={handleSubmit}>
|
||||
<div class="flex flex-col items-center space-y-4">
|
||||
<input
|
||||
name="name"
|
||||
placeholder="Database name"
|
||||
required
|
||||
bind:this={autofocus}
|
||||
bind:value={name}
|
||||
/>
|
||||
<button type="submit" class="bg-purple-600 hover:bg-purple-500">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,18 +0,0 @@
|
||||
import { getUserDetails, uniqueName } from '$lib/common';
|
||||
import * as db from '$lib/database';
|
||||
import { ErrorHandler } from '$lib/database';
|
||||
import type { RequestHandler } from '@sveltejs/kit';
|
||||
|
||||
export const post: RequestHandler = async (event) => {
|
||||
const { teamId, status, body } = await getUserDetails(event);
|
||||
if (status === 401) return { status, body };
|
||||
|
||||
const { name } = await event.request.json();
|
||||
|
||||
try {
|
||||
const { id } = await db.newService({ name, teamId });
|
||||
return { status: 201, body: { id } };
|
||||
} catch (error) {
|
||||
return ErrorHandler(error);
|
||||
}
|
||||
};
|
||||
@@ -1,59 +0,0 @@
|
||||
<script context="module" lang="ts">
|
||||
import type { Load } from '@sveltejs/kit';
|
||||
export const load: Load = async ({ fetch, session }) => {
|
||||
const url = `/common/getUniqueName.json`;
|
||||
const res = await fetch(url);
|
||||
|
||||
if (res.ok) {
|
||||
return {
|
||||
props: {
|
||||
...(await res.json())
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: res.status,
|
||||
error: new Error(`Could not load ${url}`)
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export let name;
|
||||
import { enhance, errorNotification } from '$lib/form';
|
||||
import { onMount } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { post } from '$lib/api';
|
||||
let autofocus;
|
||||
|
||||
onMount(() => {
|
||||
autofocus.focus();
|
||||
});
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const { id } = await post(`/new/service.json`, { name });
|
||||
return await goto(`/services/${id}`);
|
||||
} catch ({ error }) {
|
||||
return errorNotification(error);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex space-x-1 p-6 font-bold">
|
||||
<div class="mr-4 text-2xl tracking-tight">Add New Service</div>
|
||||
</div>
|
||||
<div class="pt-10">
|
||||
<form on:submit|preventDefault={handleSubmit}>
|
||||
<div class="flex flex-col items-center space-y-4">
|
||||
<input
|
||||
name="name"
|
||||
placeholder="Service name"
|
||||
required
|
||||
bind:this={autofocus}
|
||||
bind:value={name}
|
||||
/>
|
||||
<button type="submit" class="bg-pink-600 hover:bg-pink-500">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user