diff --git a/account.html b/account.html index 462da7a..a9a37df 100644 --- a/account.html +++ b/account.html @@ -53,7 +53,7 @@
-
+

Account

Account Details

diff --git a/config.html b/config.html index 86ab3b6..0db964d 100644 --- a/config.html +++ b/config.html @@ -26,7 +26,7 @@
-
+

Instances / %{vmname}

diff --git a/css/style.css b/css/style.css index d0fa8ac..3fe69bb 100644 --- a/css/style.css +++ b/css/style.css @@ -43,6 +43,10 @@ main, dialog { color: var(--main-text-color); } +main { + padding: 0 16px 16px 16px; +} + .w3-card { background-color: var(--main-card-bg-color); box-shadow: var(--main-card-box-shadow); diff --git a/index.html b/index.html index 2db2ff1..ef1382a 100644 --- a/index.html +++ b/index.html @@ -56,7 +56,7 @@
-
+

Instances

diff --git a/scripts/utils.js b/scripts/utils.js index cb9ede5..1df55e2 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -207,27 +207,31 @@ export async function requestAPI (path, method, body = null) { } async function request (url, content) { - const response = await fetch(url, content); - const contentType = response.headers.get("Content-Type"); - let data = null; - if (contentType.includes("application/json")) { - data = await response.json(); - data.status = response.status; + try { + const response = await fetch(url, content); + const contentType = response.headers.get("Content-Type"); + let data = null; + if (contentType.includes("application/json")) { + data = await response.json(); + data.status = response.status; + } + else if (contentType.includes("text/html")) { + data = { data: await response.text() }; + data.status = response.status; + } + else { + data = response; + } + if (!response.ok) { + return { status: response.status, error: data ? data.error : response.status }; + } + else { + data.status = response.status; + return data || response; + } } - else if (contentType.includes("text/html")) { - data = { data: await response.text() }; - data.status = response.status; - } - else { - data = response; - } - - if (!response.ok) { - return { status: response.status, error: data ? data.error : response.status }; - } - else { - data.status = response.status; - return data || response; + catch (error) { + return {status: 400, error: error}; } }