158 lines
6.2 KiB
HTML
158 lines
6.2 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Kwapi monitoring</title>
|
|
<meta charset="utf-8">
|
|
<link rel="stylesheet" href="{{ url_for('v1.static', filename='design.css') }}"/>
|
|
<link rel="stylesheet" href="{{ url_for('v1.static', filename='select2/select2.css') }}"/>
|
|
<link rel="icon" type="image/png" href="{{ url_for('v1.static', filename='favicon.png') }}" />
|
|
<script src="{{ url_for('v1.static', filename='jquery-1.9.1.min.js') }}"></script>
|
|
<script src="{{ url_for('v1.static', filename='jquery.cookie-1.4.0.min.js') }}"></script>
|
|
<script src="{{ url_for('v1.static', filename='select2/select2.min.js') }}"></script>
|
|
<script type="text/javascript">
|
|
// <![CDATA[
|
|
function reloadImage(img) {
|
|
var src = img.attr('src');
|
|
src = src.split('#')[0];
|
|
src += '#' + Date.now();
|
|
img.attr('src', src);
|
|
}
|
|
|
|
function reloadAllImages() {
|
|
$('.graph').each(function() {
|
|
reloadImage($(this));
|
|
});
|
|
}
|
|
|
|
function selectAll() {
|
|
deselectAll();
|
|
var selected = [];
|
|
$('select option').each(function(i, e) {
|
|
selected[selected.length] = $(e).attr('value');
|
|
$('select').trigger({
|
|
type: 'select2-selecting',
|
|
val: $(e).attr('value')
|
|
});
|
|
});
|
|
$('select').select2('val', selected);
|
|
reloadAllImages();
|
|
}
|
|
|
|
function deselectAll() {
|
|
$('select').each(function () {
|
|
$(this).select2('val', '');
|
|
});
|
|
var selected = [];
|
|
$('select option').each(function(i, e) {
|
|
selected[selected.length] = $(e).attr('value');
|
|
$('select').trigger({
|
|
type: 'select2-removing',
|
|
val: $(e).attr('value')
|
|
});
|
|
});
|
|
}
|
|
|
|
$(document).ready(function () {
|
|
setInterval('reloadAllImages()', {{ refresh*1000 }});
|
|
|
|
// Init select probe list
|
|
var cookie = $.cookie('probes');
|
|
if(!cookie) {
|
|
var probes = [];
|
|
} else {
|
|
var probes = JSON.parse(cookie);
|
|
}
|
|
$('select').select2({
|
|
placeholder: 'Select probes'
|
|
});
|
|
$('select').select2('val', probes);
|
|
|
|
// Event handler for adding a probe
|
|
$(document.body).on('select2-selecting', 'select', function(e) {
|
|
var probe = '<a href="/probe/' + e.val + '"><img class="graph" id="' + e.val + '" src="/graph/{{ scale }}/' + e.val + '/" alt="Graph ' + e.val + '"/></a>';
|
|
$('#probes').append(probe);
|
|
reloadAllImages();
|
|
});
|
|
|
|
// Event handler for deleting a probe
|
|
$(document.body).on('select2-removing', 'select', function(e) {
|
|
$('#' + e.val).parent().remove();
|
|
});
|
|
|
|
// Bind buttons to event handlers
|
|
$('#select-all').click(selectAll);
|
|
$('#deselect-all').click(deselectAll);
|
|
|
|
// Display the graph for each preselected probes
|
|
$.each(probes, function(index, value) {
|
|
$('select').trigger({
|
|
type: 'select2-selecting',
|
|
val: value
|
|
});
|
|
});
|
|
|
|
{% if view == 'scale' %}
|
|
// Set a cookie storing the probe list
|
|
$(window).unload(function() {
|
|
var value = $('select').val();
|
|
if(value == null) {
|
|
$.removeCookie('probes', {path: '/'});
|
|
} else {
|
|
$.cookie('probes', JSON.stringify(value), {path: '/'});
|
|
}
|
|
});
|
|
{% endif %}
|
|
});
|
|
// ]]>
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="header"><h1>Kwapi energy monitoring</h1></div>
|
|
<!-- Horizontal menu bar -->
|
|
<div class="menu">
|
|
<ul>
|
|
{% for label in scales %}
|
|
{% if label == scale %}
|
|
<li><a class="active" href="/last/{{ label }}/">{{ label }}</a></li>
|
|
{% else %}
|
|
<li><a href="/last/{{ label }}/">{{ label }}</a></li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
|
|
<div id="inner">
|
|
<!-- Scale view (all probes for one scale) -->
|
|
{% if view == 'scale' %}
|
|
{% if probes|count > 0 %}
|
|
<h2>Summary</h2>
|
|
<!-- Display summary graph -->
|
|
<img class="graph" id="summary" src="/graph/{{ scale }}/" alt="Summary graph"/>
|
|
<h2>Details</h2>
|
|
<!-- Display all probe graphs -->
|
|
<div class="select-bar">
|
|
<select multiple>
|
|
{% for probe in probes %}
|
|
<option value="{{ probe }}">{{ probe }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<button type="button" id="select-all">All</button>
|
|
<button type="button" id="deselect-all">Clear</button>
|
|
</div>
|
|
<div id="probes"></div>
|
|
{% else %}
|
|
<p>No probes found.</p>
|
|
{% endif %}
|
|
|
|
<!-- Probe view (all scales for one probe) -->
|
|
{% elif view == 'probe' %}
|
|
<h2>{{ probe }}</h2>
|
|
{% for scale in scales %}
|
|
<img class="graph" src="/graph/{{ scale }}/{{ probe }}/" alt="Graph {{ probe }}"/>
|
|
{% endfor %}
|
|
<p style="text-align:center"><a href="/rrd/{{ probe }}/">Download RRD</a></p>
|
|
{% endif %}
|
|
</div>
|
|
</body>
|
|
</html>
|