fix couple js errors, remove visitors notification

This commit is contained in:
Maxi Quoß
2022-01-14 18:55:16 +01:00
parent 79739dc1b3
commit 963a38bc8b
3 changed files with 8 additions and 11 deletions

View File

@@ -108,7 +108,7 @@ window.onload = () => {
(hour < 10 ? "0" + hour.toString() : hour) + ":" +
(minute < 10 ? "0" + minute.toString() : minute) +
utcString.substring(16, 19);
// prepare html elements
var datetimeFields = document.querySelectorAll('[id*=-input]');
for (let index = 0; index < datetimeFields.length; index++) {
@@ -200,10 +200,10 @@ function setDeviceDown(device) {
var statusDot = document.getElementById(device.id + "-dot");
var statusPorts = document.getElementById(device.id + "-ports");
var wakeButton = document.querySelector(`[id="btn-wake"][data-id="${device.id}"]`)
var scheduleModalButton = document.getElementById(device.id + "-btn-schedule");
var scheduleModalButton = document.getElementById(device.id + "-btn-schedule");
// check if device was up before
if (statusDot.classList.contains("dot-up") && enableNotifications ) {
if (statusDot.classList.contains("dot-up") && enableNotifications) {
notif.show("Device now down!", device.name + " is now down.", "is-danger", 5000);
}
@@ -287,9 +287,6 @@ socket.onmessage = function (event) {
document.getElementById("visitors").innerHTML = message.visitors + ' visitor';
} else {
document.getElementById("visitors").innerHTML = message.visitors + ' visitors';
if (enableNotifications) {
notif.show("Visitors updated", "There are currently " + message.visitors + " visitors", "is-info", 5000);
}
}
}
@@ -330,7 +327,7 @@ socket.onmessage = function (event) {
if ("reload" in message) {
window.location.reload(true);
}
}
socket.onclose = function (event) {
if (enableNotifications) {

View File

@@ -99,7 +99,7 @@ async function scan() {
const td2 = row.insertCell();
const td3 = row.insertCell();
const td4 = row.insertCell();
const deviceName = "Unknown";
let deviceName = "Unknown";
if (device.name != "") {
deviceName = device.name;
}
@@ -110,7 +110,7 @@ async function scan() {
button.classList.add("button", "is-primary", "is-small");
button.innerText = "Add";
button.addEventListener("click", function (event) {
update_device(JSON.stringify(device));
post_settings("/settings/update/", JSON.stringify(device));
event.target.disabled = true;
event.target.innerText = "Added";
});

View File

@@ -146,7 +146,7 @@
</span>
</button>
{% endif %}
<h3 class="title is-size-4 my-5">Add custom</h3>
<h3 class="title is-size-4 my-5">Add devices</h3>
<form action="/settings/custom_add/" method="post">
{% csrf_token %}
<table class="table is-fullwidth">
@@ -257,7 +257,7 @@
</div>
</div>
</section>
<section class="section py-3">
<section class="section py-3 mb-6">
<h2 class="title is-size-3 my-5">Info</h2>
<div class="box no-flex">
<div class="columns">