diff --git a/config/site.example.yaml b/config/site.example.yaml index 507f8b9..6eed298 100644 --- a/config/site.example.yaml +++ b/config/site.example.yaml @@ -27,4 +27,10 @@ nav: hero: title: Kener is a Open-Source Status Page System subtitle: Let your users know what's going on. +footerHTML: | + Made using + + Kener + + an open source status page system built with Svelte and TailwindCSS. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 56c37ac..5dab22f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kener", - "version": "0.0.4", + "version": "0.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kener", - "version": "0.0.4", + "version": "0.0.5", "license": "MIT", "dependencies": { "axios": "^1.6.2", diff --git a/scripts/github.js b/scripts/github.js index 9caff26..a23accb 100644 --- a/scripts/github.js +++ b/scripts/github.js @@ -51,7 +51,7 @@ const GetAllGHLabels = async function (owner, repo) { console.log(GhnotconfireguredMsg); return []; } - const options = getAxiosOptions(`https://api.github.com/repos/${owner}/${repo}/labels`); + const options = getAxiosOptions(`https://api.github.com/repos/${owner}/${repo}/labels?per_page=1000`); let labels = []; try { @@ -231,7 +231,7 @@ async function CreateIssue(githubConfig, issueTitle, issueBody, issueLabels) { return null; } } -async function UpdateIssue(githubConfig, incidentNumber, issueTitle, issueBody, issueLabels) { +async function UpdateIssue(githubConfig, incidentNumber, issueTitle, issueBody, issueLabels, state = "open") { if (githubConfig.owner === undefined || githubConfig.repo === undefined || GH_TOKEN === undefined) { console.log(GhnotconfireguredMsg); return null; @@ -242,6 +242,7 @@ async function UpdateIssue(githubConfig, incidentNumber, issueTitle, issueBody, title: issueTitle, body: issueBody, labels: issueLabels, + state: state, }; const response = await axios.request(patchAxiosOptions(url, payload)); return response.data; @@ -285,7 +286,7 @@ async function AddComment(githubConfig, incidentNumber, commentBody) { } } //update issue labels -async function UpdateIssueLabels(githubConfig, incidentNumber, issueLabels, body) { +async function UpdateIssueLabels(githubConfig, incidentNumber, issueLabels, body, state = "open") { if (githubConfig.owner === undefined || githubConfig.repo === undefined || GH_TOKEN === undefined) { console.log(GhnotconfireguredMsg); return null; @@ -295,8 +296,9 @@ async function UpdateIssueLabels(githubConfig, incidentNumber, issueLabels, body const payload = { labels: issueLabels, body: body, + state: state, }; - const response = await axios.request(postAxiosOptions(url, payload)); + const response = await axios.request(patchAxiosOptions(url, payload)); return response.data; } catch (error) { console.log(error.response.data); diff --git a/scripts/sitemap.js b/scripts/sitemap.js index 9531d28..696bf36 100644 --- a/scripts/sitemap.js +++ b/scripts/sitemap.js @@ -23,6 +23,16 @@ if(site.siteURL !== undefined && site.siteURL !== null && site.siteURL !== ""){ `; }) .join("\n")} + ${monitors + .map((monitor) => { + return ` + ${site.siteURL}/monitor-${encodeURIComponent(monitor.folderName)} + ${new Date().toISOString()} + daily + 0.8 + `; + }) + .join("\n")} `; } diff --git a/src/lib/components/incident.svelte b/src/lib/components/incident.svelte index f4d64d3..dc1a719 100644 --- a/src/lib/components/incident.svelte +++ b/src/lib/components/incident.svelte @@ -13,7 +13,8 @@ export let state = "open"; export let monitor; let blinker = "bg-transparent" - let incidentPriority = "" + let incidentPriority = ""; + let incidentDuration = 0; if(incident.labels.includes("incident-down")){ blinker = "bg-red-500"; incidentPriority = "DOWN" @@ -26,17 +27,14 @@ let incidentCreatedAt = incident.incident_start_time; let incidentMessage = ""; if(!!incidentClosedAt && !!incidentCreatedAt){ - //diff between closed_at and created_at - let diff = moment(incidentClosedAt * 1000).add(1, "minutes").diff(moment(incidentCreatedAt * 1000), 'minutes'); + //incidentDuration between closed_at and created_at + incidentDuration = moment(incidentClosedAt * 1000).add(1, "minutes").diff(moment(incidentCreatedAt * 1000), 'minutes'); - if(diff > 0) { - incidentMessage = `. Was ${incidentPriority} for ${diff} minutes`; - } + } else if(!!incidentCreatedAt){ - //diff between now and created_at - let diff = moment().diff(moment(incidentCreatedAt * 1000), 'minutes'); - incidentMessage = `. Has been ${incidentPriority} for ${diff} minutes`; + //incidentDuration between now and created_at + incidentDuration = moment().diff(moment(incidentCreatedAt * 1000), 'minutes'); } //find a replace /\[start_datetime:(\d+)\]/ empty in incident.body @@ -49,7 +47,7 @@
- + {#if variant.includes("monitor")}
@@ -107,7 +105,16 @@ {moment(incidentCreatedAt * 1000).format("MMMM Do YYYY, h:mm:ss a")} - {@html incidentMessage} + {#if incidentPriority != "" && incidentDuration > 0} +

+ + {incidentPriority} for {incidentDuration} minute{incidentDuration > 1 ? "s" : ""} + +

+ + {/if} + +

{#if incident.labels.includes("identified")} Identified @@ -115,6 +122,9 @@ {#if incident.labels.includes("resolved")} Resolved {/if} + {#if incident.labels.includes("maintenance")} + Maintenance + {/if}

diff --git a/src/lib/components/monitor.svelte b/src/lib/components/monitor.svelte index 70b4bfa..38057c8 100644 --- a/src/lib/components/monitor.svelte +++ b/src/lib/components/monitor.svelte @@ -1,7 +1,7 @@ + + + + diff --git a/src/lib/server/page.js b/src/lib/server/page.js index a7cc2e8..66e2718 100644 --- a/src/lib/server/page.js +++ b/src/lib/server/page.js @@ -36,11 +36,11 @@ function getDayData(day0, startTime, endTime) { if (dayData.DEGRADED > 0) { cssClass = StatusObj.DEGRADED; - message = "Degraded for " + dayData.DEGRADED + " minutes"; + message = "Degraded for " + dayData.DEGRADED + " minute" + (dayData.DEGRADED > 1 ? "s" : ""); } if (dayData.DOWN > 0) { cssClass = StatusObj.DOWN; - message = "Down for " + dayData.DOWN + " minutes"; + message = "Down for " + dayData.DOWN + " minute" + (dayData.DOWN > 1 ? "s" : ""); } if(dayData.DEGRADED + dayData.DOWN + dayData.UP > 0){ dayData.message = message; @@ -74,7 +74,7 @@ const FetchData = async function (monitor, localTz) { index: (i - midnight) / 60, }; } - + let day0 = JSON.parse(fs.readFileSync(monitor.path0Day, "utf8")); for (const timestamp in day0) { diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 53a1560..f3423a2 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -2,15 +2,15 @@ import "../app.postcss"; import "../kener.css"; import Nav from "$lib/components/nav.svelte"; - import { onMount } from "svelte"; - export let data; - function getCookie(name) { - const value = `; ${document.cookie}`; - const parts = value.split(`; ${name}=`); - if (parts.length === 2) return parts.pop().split(';').shift(); - } - onMount(() => { - let localTz = Intl.DateTimeFormat().resolvedOptions().timeZone; + import { onMount } from "svelte"; + export let data; + function getCookie(name) { + const value = `; ${document.cookie}`; + const parts = value.split(`; ${name}=`); + if (parts.length === 2) return parts.pop().split(";").shift(); + } + onMount(() => { + let localTz = Intl.DateTimeFormat().resolvedOptions().timeZone; if (localTz != data.localTz) { document.cookie = "localTz=" + localTz + ";max-age=" + 60 * 60 * 24 * 365 * 30; location.reload(); @@ -18,13 +18,24 @@ }); {#if data.showNav} -
-
+

Active Incidents @@ -42,7 +42,7 @@

-
+

Recent Incidents