projects
/
squid-reports.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
b6140f5
)
Подписи на осях + исключено двойное обновление графика.
author
Roman Bazalevsky
<rvb@rvb.name>
Fri, 13 Dec 2019 13:36:07 +0000
(16:36 +0300)
committer
Roman Bazalevsky
<rvb@rvb.name>
Fri, 13 Dec 2019 13:36:07 +0000
(16:36 +0300)
web/squid.js
patch
|
blob
|
history
diff --git
a/web/squid.js
b/web/squid.js
index dbcf25b9aafe0a6e3b1ce5cacbbbcf66bf9e0573..58a95420deab7eb50d6278f71d84e9169a180561 100644
(file)
--- a/
web/squid.js
+++ b/
web/squid.js
@@
-1,6
+1,6
@@
urlbase="./api.php"
urlbase="./api.php"
-refresh =
5
00
+refresh =
10
00
online_history = 60
graph_colors = [
online_history = 60
graph_colors = [
@@
-39,6
+39,9
@@
timer = null
assigned_colors = []
assigned_colors = []
+current_time = null
+time_labels = []
+
var d = new Date();
var curr_day = d.getDate();
var curr_month = d.getMonth() + 1;
var d = new Date();
var curr_day = d.getDate();
var curr_month = d.getMonth() + 1;
@@
-402,11
+405,18
@@
function AddTraffic(label,b) {
function ProduceOnline(res) {
if (!online_traffic) {
function ProduceOnline(res) {
if (!online_traffic) {
+ current_time = null
online_traffic = []
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: {
config = {
type: 'line',
data: {
- labels:
new Array(online_history).fill('*')
,
+ labels:
time_labels
,
datasets: online_traffic,
},
options: {
datasets: online_traffic,
},
options: {
@@
-416,6
+426,7
@@
function ProduceOnline(res) {
responsive: true,
scales: {
xAxes: [{
responsive: true,
scales: {
xAxes: [{
+ type: 'time',
scaleLabel: {
display: true,
}
scaleLabel: {
display: true,
}
@@
-427,6
+438,7
@@
function ProduceOnline(res) {
},
scaleLabel: {
display: true,
},
scaleLabel: {
display: true,
+ labelString: "Скорость, Кбит/c"
}
}]
}
}
}]
}
@@
-434,13
+446,23
@@
function ProduceOnline(res) {
}
DrawGraph(config)
}
}
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)
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"]
}
dictionary = res["dictionary"]
@@
-483,11
+505,17
@@
function ProduceOnline(res) {
new_online_connections[idx] = bytes
new_online_connections[idx] = bytes
- AddTraffic(username,
bytes-last_bytes
)
+ AddTraffic(username,
8*(bytes-last_bytes)/(1024*delta)
)
}
online_connections = new_online_connections
}
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})
headerHTML = Macro("header-row",{DATA:MergeTH(dictionary)})
reportHTML = Macro("report-table",{HEADER:headerHTML,LINES:innerHTML})
@@
-589,7
+617,7
@@
function Rerun() {
}
function Online() {
}
function Online() {
- timer = null
+ CancelRefresh()
RefreshFilterPane()
var header = document.getElementById("report-name")
header.innerText = "Активные соединения"
RefreshFilterPane()
var header = document.getElementById("report-name")
header.innerText = "Активные соединения"