0
0
Fork 0
mirror of https://github.com/alerta/alerta.git synced 2025-01-30 19:46:21 +00:00
alerta_alerta/alerta/dashboard/v2/templates/widgets/status.html
2013-09-30 10:41:06 +01:00

87 lines
No EOL
2.8 KiB
HTML

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<!-- link href='http://fonts.googleapis.com/css?family=Sintony:400,700' rel='stylesheet' type='text/css' -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" language="javascript" src="/alerta/dashboard/v2/assets/DataTables/media/js/jquery.js"></script>
<link href="/alerta/dashboard/v2/assets/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="/alerta/dashboard/v2/assets/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<link href="/alerta/dashboard/v2/assets/css/custom.css" rel="stylesheet">
</head>
<body class="widget">
<div class="row show-grid">
<div class="span1">
<!-- a href="./details{% if query %}?{{ query|safe }}{% endif %}" target="_blank" -->
<table class="table table-bordered table-condensed status-indicator" id="widget" data-label="widget">
<!-- thead id="widget-overall" class="status-indicator-overall">
<tr>
<th colspan="1" id="widget-status">{{ label }}</th>
</tr>
</thead -->
<tbody>
<tr>
<td id="widget-status-label"><b>{% if label %}{{ label }}{% else %}...{% endif %}</b></td>
<td id="widget-status-value"><b>...</b></td>
</tr>
</tbody>
</table>
</a>
</div>
</div>
<script>
var api_host = "{{ config['api_host'] }}";
var api_port = {{ config['api_port'] }};
</script>
<script>
var API_HOST = document.domain + ':' + window.api_port;
var REFRESH_INTERVAL = 30; // seconds
var filter = '{{ query|safe }}';
var status = ''; //'&status=open';
var limit = '&limit=1';
var from = '';
var timer;
function updateStatusIndicator(filter, refresh) {
$.getJSON('http://' + API_HOST + '/alerta/api/v2/alerts?callback=?&'
+ filter + status + limit + from, function (data) {
var more = '';
if (data.response.more) {
more = ' *';
}
$.each(data.response.alerts.alertDetails, function (i, alert) {
{% if not label %}
$('#widget-status-label').html('<b>' + alert.event + '</b>');
{% endif %}
$('#widget-status-value').html('<b>' + alert.value + more + '</b>');
$('#widget-status-value').addClass("severity-" + alert.severity);
});
if (refresh) {
timer = setTimeout(function () {
updateStatusIndicator(filter, refresh);
}, REFRESH_INTERVAL * 1000);
}
});
}
$(document).ready(function() {
updateStatusIndicator(filter, true);
});
</script>
</body>
</html>