Major javascript update: Queues curves are now being set dynamically.

Now the javacript part is a little bit less disgusting than before.
pull/13/head
Starow 2014-08-12 11:41:56 +02:00
parent 60cfc9789f
commit ef6bece82c
1 changed files with 35 additions and 43 deletions

View File

@ -4,7 +4,6 @@ function initfunc( csvay, scroot) {
}; };
function update_values() { function update_values() {
//$SCRIPT_ROOT = {{request.script_root|tojson|safe}} ;
$SCRIPT_ROOT = window.scroot ; $SCRIPT_ROOT = window.scroot ;
$.getJSON($SCRIPT_ROOT+"/_stuff", $.getJSON($SCRIPT_ROOT+"/_stuff",
function(data) { function(data) {
@ -41,7 +40,7 @@ function create_log_table(obj_json) {
tr.className = "warning"; tr.className = "warning";
} }
else if ( chansplit[1] == "CRITICAL"){ else if ( chansplit[1] == "CRITICAL"){
tr.className = "critical" tr.className = "danger"
} }
source_link = document.createElement("A"); source_link = document.createElement("A");
@ -96,25 +95,6 @@ function create_log_table(obj_json) {
} }
} }
$(document).ready(function () {
var interval = 1000; //number of mili seconds between each call
var refresh = function() {
$.ajax({
url: "",
cache: false,
success: function(html) {
$('#server-name').html(html);
setTimeout(function() {
refresh();
update_values();
create_queue_table();
}, interval);
}
});
};
refresh();
});
function create_queue_table() { function create_queue_table() {
document.getElementById("queueing").innerHTML = ""; document.getElementById("queueing").innerHTML = "";
var Tablediv = document.getElementById("queueing") var Tablediv = document.getElementById("queueing")
@ -153,11 +133,10 @@ function create_queue_table() {
$(document).ready(function () { $(document).ready(function () {
var data = []; var data = [];
var x = new Date(); var x = new Date();
data.push([x, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
data.push([x, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
var g = new Dygraph(document.getElementById("Graph"), data, var g = new Dygraph(document.getElementById("Graph"), data,
{ {
labels: ["Time", "Duplicate", "CreditCard", "Words", "102", "Mails", "Lines", "Curve", "Onion", "Web", "Tokenize"],
drawPoints: false, drawPoints: false,
showRoller: true, showRoller: true,
rollPeriod: 10, rollPeriod: 10,
@ -169,24 +148,37 @@ $(document).ready(function () {
includeZero: true, includeZero: true,
}); });
// It sucks that these things aren't objects, and we need to store state in window. var interval = 1000; //number of mili seconds between each call
window.intervalId = setInterval(function() { var refresh = function() {
var x = new Date(); // current time
y = glob_tabvar.row1[0][1]; $.ajax({
a = glob_tabvar.row1[1][1]; url: "",
b = glob_tabvar.row1[2][1]; cache: false,
c = glob_tabvar.row1[3][1]; success: function(html) {
d = glob_tabvar.row1[4][1]; $('#server-name').html(html);
e = glob_tabvar.row1[5][1]; setTimeout(function() {
f = glob_tabvar.row1[6][1]; var x = new Date();
k = glob_tabvar.row1[7][1]; var youpi = [];
h = glob_tabvar.row1[8][1]; refresh();
i = glob_tabvar.row1[9][1]; update_values();
create_queue_table();
for (i = 0; i < (glob_tabvar.row1).length; i++){
youpi.push(glob_tabvar.row1[i][1]);
}
youpi.unshift(x);
data.push(youpi);
data.push([x, y, a, b, c, d, e, f, k, h, i]); if (data.length > 1800) {
if (data.length > 1800) { data.shift();
data.shift(); }
} g.updateOptions( { 'file': data } );
g.updateOptions( { 'file': data } );
}, 1000); }, interval);
}
});
};
refresh();
}); });