generated from pabio/template
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce9fa58
commit ca13c83
Showing
5 changed files
with
260 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<script> | ||
import Loading from "../components/Loading.svelte"; | ||
import { onMount } from "svelte"; | ||
import config from "../data/config.json"; | ||
import { cachedResponse, createOctokit, handleError } from "../utils/createOctokit"; | ||
let loading = true; | ||
const octokit = createOctokit(); | ||
const owner = config.owner; | ||
const repo = config.repo; | ||
let incidents = []; | ||
onMount(async () => { | ||
try { | ||
incidents = ( | ||
await cachedResponse(`scheduled-current-${owner}-${repo}`, () => | ||
octokit.issues.listForRepo({ | ||
owner, | ||
repo, | ||
state: "open", | ||
filter: "all", | ||
sort: "created", | ||
direction: "desc", | ||
labels: "maintenance", | ||
}) | ||
) | ||
).data; | ||
incidents = incidents.map((incident, index) => { | ||
incident.showHeading = | ||
index === 0 || | ||
new Date(incidents[index - 1].created_at).toLocaleDateString() !== | ||
new Date(incident.created_at).toLocaleDateString(); | ||
incident.metadata = {}; | ||
if (incident.body.includes("<!--")) { | ||
const summary = incident.body.split("<!--")[1].split("-->")[0]; | ||
const lines = summary | ||
.split("\n") | ||
.filter((i) => i.trim()) | ||
.filter((i) => i.includes(":")); | ||
lines.forEach((i) => { | ||
incident.metadata[i.split(/:(.+)/)[0].trim()] = i.split(/:(.+)/)[1].trim(); | ||
}); | ||
} | ||
return incident; | ||
}); | ||
} catch (error) { | ||
handleError(error); | ||
} | ||
loading = false; | ||
}); | ||
</script> | ||
|
||
{#if !incidents.length && !loading} | ||
<article class="up">✅ {config.i18n.allSystemsOperational}</article> | ||
{/if} | ||
|
||
<section> | ||
{#if loading} | ||
<Loading /> | ||
{:else if incidents.length} | ||
<h2>{config.i18n.scheduledMaintenance}</h2> | ||
{#each incidents as incident} | ||
<article class="degraded degraded-active link"> | ||
<div class="f"> | ||
<div> | ||
<h4>{incident.title.replace("🛑", "").replace("⚠️", "").trim()}</h4> | ||
{#if incident.metadata.start && incident.metadata.end} | ||
<div> | ||
{(new Date(incident.metadata.start).getTime() < new Date().getTime() | ||
? config.i18n.scheduledMaintenanceSummaryStarted | ||
: config.i18n.scheduledMaintenanceSummaryStarts | ||
) | ||
.replace(/\$DATE/g, new Date(incident.metadata.start).toLocaleString()) | ||
.replace( | ||
/\$DURATION/g, | ||
Math.floor( | ||
(new Date(incident.metadata.end).getTime() - | ||
new Date(incident.metadata.start).getTime()) / | ||
60000 | ||
) | ||
)} | ||
</div> | ||
{/if} | ||
</div> | ||
<div class="f r"> | ||
<a href={`${config.path}/incident/${incident.number}`}> | ||
{config.i18n.incidentReport.replace(/\$NUMBER/g, incident.number)} | ||
</a> | ||
</div> | ||
</div> | ||
</article> | ||
{/each} | ||
{/if} | ||
</section> | ||
|
||
<style> | ||
section { | ||
margin-bottom: 2rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<script> | ||
import Loading from "../components/Loading.svelte"; | ||
import { onMount } from "svelte"; | ||
import config from "../data/config.json"; | ||
import { cachedResponse, createOctokit, handleError } from "../utils/createOctokit"; | ||
let loading = true; | ||
const octokit = createOctokit(); | ||
const owner = config.owner; | ||
const repo = config.repo; | ||
let incidents = []; | ||
onMount(async () => { | ||
try { | ||
incidents = ( | ||
await cachedResponse(`maintenance-issues-${owner}-${repo}`, () => | ||
octokit.issues.listForRepo({ | ||
owner, | ||
repo, | ||
state: "closed", | ||
filter: "all", | ||
sort: "created", | ||
direction: "desc", | ||
labels: "maintenance", | ||
}) | ||
) | ||
).data; | ||
} catch (error) { | ||
handleError(error); | ||
} | ||
incidents = incidents.map((incident, index) => { | ||
incident.showHeading = | ||
index === 0 || | ||
new Date(incidents[index - 1].created_at).toLocaleDateString() !== | ||
new Date(incident.created_at).toLocaleDateString(); | ||
return incident; | ||
}); | ||
loading = false; | ||
}); | ||
</script> | ||
|
||
<section> | ||
{#if loading} | ||
<Loading /> | ||
{:else if incidents.length} | ||
<h2>{config.i18n.pastScheduledMaintenance}</h2> | ||
{#each incidents as incident} | ||
{#if incident.showHeading} | ||
<h3>{new Date(incident.created_at).toLocaleDateString()}</h3> | ||
{/if} | ||
<article class="link degraded"> | ||
<div class="f"> | ||
<div> | ||
<h4>{incident.title.replace("🛑", "").replace("⚠️", "").trim()}</h4> | ||
<div>Completed</div> | ||
</div> | ||
<div class="f r"> | ||
<a href={`${config.path}/incident/${incident.number}`}> | ||
{config.i18n.incidentReport.replace(/\$NUMBER/g, incident.number)} | ||
</a> | ||
</div> | ||
</div> | ||
</article> | ||
{/each} | ||
{/if} | ||
</section> | ||
|
||
<style> | ||
h2 { | ||
margin-top: 2rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,48 @@ | ||
<script> | ||
import snarkdown from "snarkdown"; | ||
import ActiveIncidents from "../components/ActiveIncidents.svelte"; | ||
import LiveStatus from "../components/LiveStatus.svelte"; | ||
import ActiveScheduled from "../components/ActiveScheduled.svelte"; | ||
import Incidents from "../components/Incidents.svelte"; | ||
import LiveStatus from "../components/LiveStatus.svelte"; | ||
import Scheduled from "../components/Scheduled.svelte"; | ||
import config from "../data/config.json"; | ||
import snarkdown from "snarkdown"; | ||
let title = "Status"; | ||
try { | ||
title = config["status-website"].name; | ||
} catch (error) {} | ||
</script> | ||
|
||
<style> | ||
p.lead { | ||
font-size: 110%; | ||
} | ||
header { | ||
margin-bottom: 2rem; | ||
} | ||
</style> | ||
|
||
<svelte:head> | ||
<title>{title}</title> | ||
</svelte:head> | ||
|
||
<header> | ||
{#if config['status-website']} | ||
{#if config['status-website'].introTitle} | ||
{#if config["status-website"]} | ||
{#if config["status-website"].introTitle} | ||
<h1> | ||
{@html snarkdown(config['status-website'].introTitle)} | ||
{@html snarkdown(config["status-website"].introTitle)} | ||
</h1> | ||
{/if} | ||
{#if config['status-website'].introMessage} | ||
{#if config["status-website"].introMessage} | ||
<p class="lead"> | ||
{@html snarkdown(config['status-website'].introMessage)} | ||
{@html snarkdown(config["status-website"].introMessage)} | ||
</p> | ||
{/if} | ||
{/if} | ||
</header> | ||
|
||
<ActiveIncidents /> | ||
<ActiveScheduled /> | ||
<LiveStatus /> | ||
<Scheduled /> | ||
<Incidents /> | ||
|
||
<style> | ||
p.lead { | ||
font-size: 110%; | ||
} | ||
header { | ||
margin-bottom: 2rem; | ||
} | ||
</style> |