From 823133accebdf5f40aff0d1807389438a053423c Mon Sep 17 00:00:00 2001 From: Roman Bazalevsky Date: Mon, 16 Dec 2019 11:14:05 +0300 Subject: [PATCH 1/1] =?utf8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?utf8?q?=D1=81=20=D0=B4=D0=B0=D1=82=D0=B0=D0=BC=D0=B8.=20=D0=92=D0=BF?= =?utf8?q?=D0=B5=D1=80=D0=B5=D0=B4-=D0=BD=D0=B0=D0=B7=D0=B0=D0=B4,=20?= =?utf8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20=D0=BE=D0=B3?= =?utf8?q?=D1=80=D0=B0=D0=BD=D0=B8=D1=87=D0=B5=D0=BD=D0=B8=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- web/api.php | 2 ++ web/index.html | 1 + web/squid.js | 58 +++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/web/api.php b/web/api.php index 2b700e2..4da8707 100644 --- a/web/api.php +++ b/web/api.php @@ -78,6 +78,8 @@ $users = exec_query("select id,username as name,alias from users"); $hosts = exec_query("select id,hostname as name,alias from hosts"); $data["dictionaries"] = Array( "user_id" => $users, "host_id" => $hosts); + $data["online_refresh"] = $online_refresh; + $data["online_history"] = $online_history; break; diff --git a/web/index.html b/web/index.html index 39266c4..e3a8f40 100644 --- a/web/index.html +++ b/web/index.html @@ -26,6 +26,7 @@
Отчет с: по: + Фильтр: diff --git a/web/squid.js b/web/squid.js index 58a9542..0260b10 100644 --- a/web/squid.js +++ b/web/squid.js @@ -1,8 +1,5 @@ urlbase="./api.php" -refresh = 1000 -online_history = 60 - graph_colors = [ "salmon", "lightcoral", "crimson", "red", "darkred", "orangered", "gold", "orange", "yellow", "darkkhaki", "lime", "green", "greenyellow", @@ -42,11 +39,22 @@ assigned_colors = [] current_time = null time_labels = [] -var d = new Date(); -var curr_day = d.getDate(); -var curr_month = d.getMonth() + 1; -var curr_year = d.getFullYear(); -today = curr_year + "-" + curr_month + "-" + curr_day; +function toDate(d) { + var curr_day = d.getDate(); + if (curr_day<10) { curr_day = '0' + curr_day; } + var curr_month = d.getMonth() + 1; + if (curr_month<10) { curr_month = '0' + curr_month; } + var curr_year = d.getFullYear(); + return curr_year + "-" + curr_month + "-" + curr_day +} + +function Today() { + var dToday = new Date(); + dToday.setHours(0,0,0,0) + return dToday +} + +today = toDate(Today()); date_from = today date_to = today @@ -133,6 +141,9 @@ function UpdatePageProps(props) { var logo = document.getElementById("brand"); logo.innerText = props["site-header"]; + refresh = props["online_refresh"] + online_history = props["online_history"] + cats = props["cats"] for (var i in res["columns"]) { @@ -635,6 +646,37 @@ function UpdateDates() { } +function DateLeft() { + UpdateDates() + var dFrom = new Date(date_from) + var dTo = new Date(date_to) + var delta = Math.round(((dTo.getTime() - dFrom.getTime()))/(86400*1000)) + dTo.setDate(dTo.getDate() - (1 + delta)) + dFrom.setDate(dFrom.getDate() - (1 + delta)) + date_from = toDate(dFrom) + date_to = toDate(dTo) + SetDates() +} + +function DateRight() { + dToday = new Date(); + UpdateDates() + var dFrom = new Date(date_from) + var dTo = new Date(date_to) + var delta = Math.round(((dTo.getTime() - dFrom.getTime()))/(86400*1000)) + dFrom.setDate(dFrom.getDate() + 1 + delta) + dTo.setDate(dTo.getDate() + 1 + delta) + if (dTo>Today()) { + dTo = Today() + } + if (dFrom>Today()) { + dFrom = Today() + } + date_from = toDate(dFrom) + date_to = toDate(dTo) + SetDates() +} + function SetFilter(name,select) { current_filter[name] = select.value; } -- 2.34.1