diff options
Diffstat (limited to 'static')
-rw-r--r-- | static/scripts.js | 83 | ||||
-rw-r--r-- | static/style.css | 133 |
2 files changed, 0 insertions, 216 deletions
diff --git a/static/scripts.js b/static/scripts.js deleted file mode 100644 index 10facc4..0000000 --- a/static/scripts.js +++ /dev/null @@ -1,83 +0,0 @@ -$(document).ready(function() { - fetch("/api/mikrotik_plug").then((resp) => { - resp.json().then((body) => { - const MIKROTIK_PARENT = body["parent"]; - - const parent_elem = document.getElementById("tr_" + MIKROTIK_PARENT); - - fetch("/api/mikrotik_devices").then((resp) => { - resp.json().then((body) => { - Object.keys(body).reverse().forEach((interface, i) => { - let tr_elem = document.createElement("tr"); - tr_elem.classList.add("mikrotik_tr") - tr_elem.id = "mikrotik_tr_" + interface; - // console.log(interface, body[interface]); - parent_elem.parentNode.insertBefore(tr_elem, parent_elem.nextSibling); - - for (let i = 0; i <= 4; i++) { - let td_elem = document.createElement("td"); - if (i === 0) { - td_elem.innerHTML = interface; - td_elem.classList.add("mikrotik_interface_name") - } else if (i === 1) { - td_elem.innerHTML = body[interface]; - } else if (i === 2) { - td_elem.id = "mikrotik_td_" + interface + "_watts_now"; - } else if (i === 3) { - td_elem.id = "mikrotik_td_" + interface + "_watts_yesterday"; - } - tr_elem.appendChild(td_elem); - } - }); - - get_mikrotik_table(Object.keys(body)); - }); - }); - }); - }); - - get_main_table(); -}) - -function get_mikrotik_table(interfaces) { - interfaces.forEach((interface) => { - fetch("/api/mikrotik_interface/" + interface).then((resp) => { - resp.json().then((body) => { - console.log(body["poe_status"]); - // TODO: Add a delay if it was cached - }); - }); - }); - - setTimeout(function() {get_mikrotik_table(interfaces);}, 1000) -} - -function get_main_table() { - fetch("/api/plugs").then((resp) => { - resp.json().then((body) => { - let watts_sum = 0; - let kwh_sum = 0; - Object.keys(body).forEach((host, i) => { - watts = body[host]["watts"]; - kwh = body[host]["kWh"]; - document.getElementById(host + "_watts_now").innerHTML = watts[1]; - document.getElementById(host + "_watts_yesterday").innerHTML = kwh[1]; - watts_sum += watts[1]; - kwh_sum += kwh[1]; - - document.getElementById("watts_last_updated").innerHTML = "Current power usage last updated at " + watts[0]; - document.getElementById("kwh_last_updated").innerHTML = "Yesterday's power usage last updated at " + kwh[0]; - - console.log(host, watts[0], watts[1], kwh[1]) - }); - document.getElementById("sum_watts_now").innerHTML = watts_sum; - document.getElementById("sum_watts_yesterday").innerHTML = kwh_sum; - }); - }); - - setTimeout(get_main_table, 10000); -} - -function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -}
\ No newline at end of file diff --git a/static/style.css b/static/style.css deleted file mode 100644 index 0ab4e82..0000000 --- a/static/style.css +++ /dev/null @@ -1,133 +0,0 @@ -body { - font-family: Helvetica, sans-serif; -} - -header { - font-size: large; - padding-left: 1%; -} - -a { - color: black; - font-weight: bold; - padding-top: 1px; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -header nav { - flex-grow: 1; - display: inline; -} - -#externallinks { - background-color: black; - text-align: left; -} - -#externallinks nav ul li a { - color: #f1f3f3; - font-size: smaller; -} - -header div { - padding-left: 20px; - /* padding-bottom: 10px; */ -} - -nav ul { - margin: 0; - padding: 0; -} - -nav li { - display: inline-block; - list-style-type: none; -} - -nav a { - text-decoration: none; - display: block; - padding: 5px 6px 5px 6px; - color: black; -} - -footer { - padding-top: 100px; - font-size: x-small; -} - -#main_content { - padding-left: 2.5%; - padding-right: 2.5; -} - - -#multicharts ul li { - list-style-type: none; - width: 45%; - display: inline-flex; - background-color: pink; - min-height: 350px; - margin-bottom: 7px; - overflow: hidden; - flex-direction: column; - justify-content: space-between; - /* border-color: black; - border-width: 2px; - border-radius: 1; - border-style: ridge; */ -} - -.chart_container { - display: flex; - flex-direction: row-reverse; -} - -#power_table { - width: 90%; -} - -#header_row { - background-color: black; -} - -#header_row td { - color: #f1f3f3; - font-weight: bold; -} - -#power_table tr { - margin-bottom: 3px; -} - -#last_updated_ul { - font-size: small; -} - -#sum_row { - background-color: gainsboro; -} - -.mikrotik_tr { - font-size: x-small; - padding-bottom: 1em; - padding-top: 1em; - border-spacing:0 5px; -} - -.mikrotik_interface_name { - text-align: right; - padding-right: 15px; -} - -@media screen and (max-width: 1200px) { - #multicharts ul li { - width: 100%; - min-height: 500px; - height: 100%; - } -}
\ No newline at end of file |