urlbase="./api.php"
-refresh = 500
+refresh = 1000
online_history = 60
graph_colors = [
assigned_colors = []
+current_time = null
+time_labels = []
+
var d = new Date();
var curr_day = d.getDate();
var curr_month = d.getMonth() + 1;
function ProduceOnline(res) {
if (!online_traffic) {
+ current_time = null
online_traffic = []
+ time_labels = []
+ cur = Date.now()
+ for (i = 1; i<=online_history; i++) {
+ cur = cur - refresh
+ time_labels.unshift(cur)
+ }
config = {
type: 'line',
data: {
- labels: new Array(online_history).fill('*'),
+ labels: time_labels,
datasets: online_traffic,
},
options: {
responsive: true,
scales: {
xAxes: [{
+ type: 'time',
scaleLabel: {
display: true,
}
},
scaleLabel: {
display: true,
+ labelString: "Скорость, Кбит/c"
}
}]
}
}
DrawGraph(config)
}
+
+ var delta
+
+ if (current_time) {
+ delta = (Date.now() - current_time)/1000
+ } else {
+ delta = 1
+ }
+
+ current_time = Date.now()
+
+ time_labels.shift()
+ time_labels.push(current_time)
for (i = online_traffic.length-1; i>=0; i--) {
online_traffic[i].data.shift()
online_traffic[i].data.push(0)
- if (Math.max.apply(null,online_traffic[i].data) == 0) {
- online_traffic.splice(i,1)
- }
}
dictionary = res["dictionary"]
new_online_connections[idx] = bytes
- AddTraffic(username,bytes-last_bytes)
+ AddTraffic(username,8*(bytes-last_bytes)/(1024*delta))
}
online_connections = new_online_connections
+ for (i = online_traffic.length-1; i>=0; i--) {
+ if (Math.max.apply(null,online_traffic[i].data) == 0) {
+ online_traffic.splice(i,1)
+ }
+ }
+
headerHTML = Macro("header-row",{DATA:MergeTH(dictionary)})
reportHTML = Macro("report-table",{HEADER:headerHTML,LINES:innerHTML})
}
function Online() {
- timer = null
+ CancelRefresh()
RefreshFilterPane()
var header = document.getElementById("report-name")
header.innerText = "Активные соединения"