diff --git a/src/kener.css b/src/kener.css index 9f88244..7baab0e 100644 --- a/src/kener.css +++ b/src/kener.css @@ -99,8 +99,8 @@ section { } /*Needed overlay content on top of dotted bg*/ .blurry-bg { - background-color: var(--background-kener-rgba); - box-shadow: 0 0 64px 64px var(--background-kener-rgba); + /* background-color: var(--background-kener-rgba); + box-shadow: 0 0 64px 64px var(--background-kener-rgba); */ } :root { diff --git a/src/lib/components/incident.svelte b/src/lib/components/incident.svelte index d1461d6..9591bd7 100644 --- a/src/lib/components/incident.svelte +++ b/src/lib/components/incident.svelte @@ -107,7 +107,7 @@ /> {/if} -
+
{#if variant.includes("monitor")} {monitor.name} - @@ -138,7 +138,7 @@
{/if} - + {moment(incidentCreatedAt * 1000).format("MMMM Do YYYY, h:mm:ss a")}

@@ -167,7 +167,7 @@ {#if (variant.includes("body") || variant.includes("comments")) && state == "open"} - + {#if variant.includes("body")}

+ import { onMount } from "svelte"; + import { base } from "$app/paths"; + import moment from "moment"; + import { Button } from "$lib/components/ui/button"; + import { Plus, X, Settings, Bell, Loader, Copy, Check } from "lucide-svelte"; + import { Input } from "$lib/components/ui/input"; + import { Label } from "$lib/components/ui/label"; + + let apiKeys = []; + let loaderLoadingAll = false; + let loaderCreateNew = false; + let newAPIKeyName = ""; + let newKeyResp = {}; + let showCreateModal = false; + + async function loadAPIKeys() { + loaderLoadingAll = true; + try { + let apiResp = await fetch(base + "/manage/api/", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + action: "getAPIKeys", + data: {} + }) + }); + let resp = await apiResp.json(); + apiKeys = resp; + } catch (error) { + alert("Error: " + error); + } finally { + loaderLoadingAll = false; + } + } + + async function createNew() { + newKeyResp = {}; + loaderCreateNew = true; + try { + let apiResp = await fetch(base + "/manage/api/", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + action: "createNewApiKey", + data: { + name: newAPIKeyName + } + }) + }); + newKeyResp = await apiResp.json(); + loadAPIKeys(); + showCreateModal = false; + } catch (error) { + alert("Error: " + error); + } finally { + loaderCreateNew = false; + } + } + + onMount(() => { + loadAPIKeys(); + }); + + function copyKey() { + navigator.clipboard.writeText(newKeyResp.apiKey); + } + + function updateStatus(apiKey) { + apiKey.status = apiKey.status == "ACTIVE" ? "INACTIVE" : "ACTIVE"; + fetch(base + "/manage/api/", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + action: "updateApiKeyStatus", + data: { + id: apiKey.id, + status: apiKey.status + } + }) + }); + } + + +
+
+
+ {#if loaderLoadingAll} + + {/if} +
+
+ +
+
+
+{#if !!newKeyResp && !!newKeyResp.apiKey} +
+

+ + + 🎉 + + API Key Created +

+

+ {newKeyResp.apiKey} + + +

+

+ Your new API key has been created. It will be not shown again, so make sure to save it. +

+
+{/if} +
+
+
+
+ + + + + + + + + + + {#each apiKeys as apiKey} + + + + + + + {/each} + +
NameKeyCreated At
+ {apiKey.name} + + {apiKey.maskedKey.slice(-32)} + + {moment(apiKey.createdAt).format("YYYY-MM-DD HH:mm:ss")} + + +
+
+
+
+
+{#if showCreateModal} +
+
+ +
+

Create a new API Key

+

+ API keys are used to authenticate your requests to the API. They are unique to + your account and should be kept secret. +

+
+
+
+
+ + +
+
+
+ +
+
+
+
+
+{/if} diff --git a/src/lib/components/manage/monitorsAdd.svelte b/src/lib/components/manage/monitorsAdd.svelte index d03ac9f..0e842b7 100644 --- a/src/lib/components/manage/monitorsAdd.svelte +++ b/src/lib/components/manage/monitorsAdd.svelte @@ -10,6 +10,8 @@ import * as Select from "$lib/components/ui/select"; export let categories = []; + export let colorDown = "#777"; + export let colorDegraded = "#777"; let monitors = []; let status = "ACTIVE"; let showAddMonitor = false; @@ -313,8 +315,11 @@
{#each Object.entries(monitorTriggers) as [key, data]}
-

- {data.triggerType} +

+ If Monitor {data.triggerType}

{#each triggers as trigger} -
+
diff --git a/src/routes/(manage)/manage/api/+server.js b/src/routes/(manage)/manage/api/+server.js index 4846765..e13016f 100644 --- a/src/routes/(manage)/manage/api/+server.js +++ b/src/routes/(manage)/manage/api/+server.js @@ -8,12 +8,15 @@ import { CreateUpdateTrigger, GetAllTriggers, UpdateTriggerData, - GetAllAlertsPaginated + GetAllAlertsPaginated, + GetAllAPIKeys, + CreateNewAPIKey, + UpdateApiKeyStatus } from "$lib/server/controllers/controller.js"; export async function POST({ request }) { const payload = await request.json(); let action = payload.action; - let data = payload.data; + let data = payload.data || {}; let resp = {}; try { if (action === "storeSiteData") { @@ -30,6 +33,12 @@ export async function POST({ request }) { resp = await UpdateTriggerData(data); } else if (action == "getAllAlertsPaginated") { resp = await GetAllAlertsPaginated(data); + } else if (action == "getAPIKeys") { + resp = await GetAllAPIKeys(); + } else if (action == "createNewApiKey") { + resp = await CreateNewAPIKey(data); + } else if (action == "updateApiKeyStatus") { + resp = await UpdateApiKeyStatus(data); } } catch (error) { resp = { error: error.message };