Redesign landing page, JSON caller response, shared email shell
- docs.htm: dark single-page redesign in plain CSS, live URL builder, all four parsers documented, Bootstrap CDN dependency dropped - index.php: respond with pretty-printed JSON (success and 400 error); email "Parsed Variables" block uses JSON instead of print_r - parsers/helpers.php: emailShell() provides one stylesheet, header and footer for every email template; five duplicated stylesheets removed
This commit is contained in:
+6
-135
@@ -76,7 +76,7 @@ HTML;
|
||||
$alertSummary .= <<<HTML
|
||||
<div class="metadata-row">
|
||||
<div class="metadata-label">Alertmanager URL</div>
|
||||
<div class="metadata-value"><a href="$externalURLSafe" style="color: #0066cc;">$externalURLSafe</a></div>
|
||||
<div class="metadata-value"><a href="$externalURLSafe" style="color: #7c3aed;">$externalURLSafe</a></div>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
@@ -233,7 +233,7 @@ HTML;
|
||||
$alertsContent .= <<<HTML
|
||||
<div class="metadata-row">
|
||||
<div class="metadata-label">Generator URL</div>
|
||||
<div class="metadata-value"><a href="$generatorURLSafe" style="color: #0066cc;">$generatorURLSafe</a></div>
|
||||
<div class="metadata-value"><a href="$generatorURLSafe" style="color: #7c3aed;">$generatorURLSafe</a></div>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
@@ -254,132 +254,9 @@ HTML;
|
||||
$alertsContent .= '</div>';
|
||||
}
|
||||
|
||||
$html = <<<HTML
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-GB">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Grafana Alert - $statusSafe</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #ffffff;
|
||||
color: #1a1a1a;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.container {
|
||||
max-width: 700px;
|
||||
margin: 0 auto;
|
||||
padding: 40px 20px;
|
||||
}
|
||||
.header {
|
||||
text-align: center;
|
||||
padding-bottom: 30px;
|
||||
border-bottom: 3px solid #000000;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
.header h1 {
|
||||
color: #000000;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
margin: 0 0 10px 0;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
.header .timestamp {
|
||||
color: #666666;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
margin: 0;
|
||||
}
|
||||
.section {
|
||||
margin-bottom: 35px;
|
||||
}
|
||||
.section-title {
|
||||
color: #000000;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
margin: 0 0 12px 0;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 2px solid #e0e0e0;
|
||||
letter-spacing: -0.3px;
|
||||
}
|
||||
.metadata {
|
||||
display: table;
|
||||
width: 100%;
|
||||
border: 1px solid #d0d0d0;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.08);
|
||||
}
|
||||
.metadata-row {
|
||||
display: table-row;
|
||||
}
|
||||
.metadata-row:not(:last-child) .metadata-label,
|
||||
.metadata-row:not(:last-child) .metadata-value {
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
}
|
||||
.metadata-label {
|
||||
display: table-cell;
|
||||
padding: 12px 16px;
|
||||
font-weight: 600;
|
||||
color: #000000;
|
||||
width: 35%;
|
||||
vertical-align: top;
|
||||
font-size: 14px;
|
||||
}
|
||||
.metadata-value {
|
||||
display: table-cell;
|
||||
padding: 12px 16px;
|
||||
color: #333333;
|
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
|
||||
font-size: 13px;
|
||||
vertical-align: top;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.subsection-title {
|
||||
color: #000000;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin: 15px 0 10px 0;
|
||||
padding: 8px 12px;
|
||||
background: #f0f0f0;
|
||||
border-left: 4px solid #666666;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.array-item {
|
||||
margin-bottom: 20px;
|
||||
padding: 12px;
|
||||
background: #fafafa;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.array-item-title {
|
||||
font-weight: 600;
|
||||
color: #000000;
|
||||
margin-bottom: 10px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 2px solid #d0d0d0;
|
||||
font-size: 16px;
|
||||
}
|
||||
.footer {
|
||||
margin-top: 50px;
|
||||
padding-top: 25px;
|
||||
border-top: 2px solid #e0e0e0;
|
||||
text-align: center;
|
||||
color: #888888;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>$statusIcon Grafana Alert: $statusSafe</h1>
|
||||
<p class="timestamp">$dateSafe</p>
|
||||
</div>
|
||||
$emailTitle = "$statusIcon Grafana Alert: $statusSafe";
|
||||
$emailStamp = "$dateSafe";
|
||||
$body = <<<HTML
|
||||
|
||||
$alertSummary
|
||||
|
||||
@@ -402,14 +279,8 @@ HTML;
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<p>This Grafana/Prometheus alert was automatically forwarded to your email address.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
$html = emailShell($emailTitle, $emailStamp, $body, "This Grafana/Prometheus alert was automatically forwarded to your email address.");
|
||||
|
||||
// Create subject line
|
||||
$alertCountText = $alertCount === 1 ? '1 alert' : "$alertCount alerts";
|
||||
|
||||
Reference in New Issue
Block a user