diff --git a/o_manager.py b/o_manager.py index 197e7bf..9caef7d 100644 --- a/o_manager.py +++ b/o_manager.py @@ -118,11 +118,15 @@ class OManager: time, value = line.split(",") time = datetime.utcfromtimestamp(float(time)) value = float(value) - ping_tas.add(time, delta) + ping_tas.add(time, value) def ping_mean(x): x = numpy.array(x) - return numpy.mean(x[x > 0]) + x = x[x > 0] + if len(x): + return numpy.mean(x) + else: + return numpy.nan def ping_rate(x): x = numpy.array(x) diff --git a/tabler/index.html b/tabler/index.html index 3f32aff..236a44e 100644 --- a/tabler/index.html +++ b/tabler/index.html @@ -359,8 +359,16 @@ - + + + + + @@ -408,6 +416,7 @@ labelString: 'Time' }, ticks: { + source: "auto", major: { fontStyle: 'bold', fontColor: '#FF0000' @@ -480,24 +489,38 @@ ovpn_table.append($(` Connection name - Visitors - Unique + Status + Weight Alive + Actions `)) data.instances.forEach((instance, index) => { - var tr = ` + var tr = $(` ${instance.name} - - + ${instance.status} + ${instance.weight}
- ` - + + + + + + `); ovpn_table.append(tr); + tr.find(`#delete_button_${instance.idx}`).click(() => { + $.get(`/remove?i=${instance.idx}`, update_stat); + }) + tr.find(`#start_button_${instance.idx}`).click(() => { + $.get(`/start?i=${instance.idx}`, update_stat); + }) + tr.find(`#stop_button_${instance.idx}`).click(() => { + $.get(`/stop?i=${instance.idx}`, update_stat); + }) $().peity && $(`#sparkline-${index}`).text(instance.ping_rate.join(", ")).peity("line", { width: 64, height: 40, @@ -506,6 +529,7 @@ fill: ["#d2e1f3"], padding: .2, }); + $('[data-toggle="tooltip"]').tooltip() });