monit-dashboard/templates/index.html
2020-03-08 16:47:59 +04:00

139 lines
4.6 KiB
HTML

$def with (output, now)
$def row_error(check):
<tr>
<td><a href="$output[server]['url']/$env-$check"
target="_blank" style="text-decoration:none;">$check</a></td>
<td><img src="static/img/error.png"></td>
</tr>
$def row_ok(check):
<tr>
<td><a href="$output[server]['url']/$env-$check"
target="_blank" style="text-decoration:none; color:black;">$check</a></td>
<td><img src="static/img/ok.png"></td>
</tr>
<body onload="draw($output[0]['s_rate']);">
$ errors = 0
$ color = "green"
<div>
<div class="download-header">
<button class="download-button" onclick="window.location.href = 'download';">Download Report</button>
</div>
<div style="height: 100%;border-right:2px solid #ccc; padding:5px;overflow-x: hidden; float:left; width:48%">
$for server in range(len(output)):
$code:
errors = 0
color = "green"
$for _,v in output[server]['result'].items():
$for check in v.keys():
$ isError = v.get(check)
$if isError != 0:
$code:
errors=errors+1
$if errors > 0:
$code:
color = "red"
<button class="accordion ${color}" onmouseenter="draw($output[server]['s_rate'])">$output[server]['name']: $errors error(s)</button>
<div class="panel">
<br>
<table width=100%>
<thead class="server-link">
<tr><th colspan="2">
<a href="$output[server]['url']" target="_blank">$output[server]['name']</a>
</th></tr>
</thead>
$for env, services in output[server]['result'].items():
$ errors = 0
$for check in services.keys():
$ isError = services.get(check)
$if isError != 0:
$ errors=errors+1
$if errors > 0:
$ color = "red"
<thead class="inner-rows">
<tr><th class="th-custom ${color}" colspan="2">
<a style="color: white">$env</a>
</th></tr>
</thead>
<tbody class="toggle-id">
$for check in services.keys():
$ isError = services.get(check)
$if isError != 0:
$:row_error(check)
$else:
$:row_ok(check)
</tbody>
$else:
$ color = "green"
<thead class="inner-rows">
<tr><th class="th-custom ${color}" colspan="2">
<a style="color: white">$env</a>
</th></tr>
</thead>
<tbody class="toggle-id">
$for check in services.keys():
$ isError = services.get(check)
$if isError != 0:
$:row_error(check)
$else:
$:row_ok(check)
</tbody>
</table>
</div>
$else:
$code:
color = "green"
<button class="accordion ${color}" onmouseenter="draw($output[server]['s_rate'])">$output[server]['name']</button>
<div class="panel">
<br>
<table width=100%>
<thead class="server-link">
<tr><th colspan="2">
<a href="$output[server]['url']" target="_blank">$output[server]['name']</a>
</th></tr>
</thead>
$for env, services in output[server]['result'].items():
<thead class="server-link">
<tr><th colspan="2">
<a href="$output[server]['url']" target="_blank">$env</a>
</th></tr>
</thead>
$for check in services.keys():
$ isError = services.get(check)
$if isError != 0:
$:row_error(check)
$else:
$:row_ok(check)
</table>
</div>
</div>
<div class="canvas-container">
<div class="canvas-graph">
<div class="canvas-header">
<h2 style="margin: 0">Hosts status</h2>
</div>
<canvas id="canvas" width="400" height="400"></canvas>
</div>
</div>
<div style="height: 10%; float:right">
<br><br><br>
Latest update: $now.day/$now.month/$now.year, $now.hour:$now.minute:$now.second
<br><br>
<a href="/">Home</a> | <a href="/help">Help</a>
</div>
</div>
</body>
<script src="static/monit-dashboard.js" type="text/javascript"></script>