mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-11-29 05:06:09 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ddece6786 | |||
| 53e2beaf52 |
@@ -284,3 +284,4 @@ $RECYCLE.BIN/
|
||||
# End of https://www.toptal.com/developers/gitignore/api/windows,linux,macos,python,django
|
||||
|
||||
.vscode
|
||||
app/staticfiles
|
||||
|
||||
@@ -166,4 +166,4 @@ STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
|
||||
VERSION = "v1.3.0"
|
||||
VERSION = "v1.4.0"
|
||||
|
||||
@@ -16,4 +16,5 @@ class SettingsForm(forms.Form):
|
||||
class AddCustomDevice(forms.Form):
|
||||
custom_add_name = forms.CharField(label="custom_add_name")
|
||||
custom_add_ip = forms.CharField(label="custom_add_ip")
|
||||
custom_add_netmask = forms.CharField(label="custom_add_netmask")
|
||||
custom_add_mac = forms.CharField(label="custom_add_mac")
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
color: var(--waiting-gray);
|
||||
}
|
||||
|
||||
.dot-up {
|
||||
.do>t-up {
|
||||
color: var(--up-green);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,14 @@
|
||||
flex-direction: unset;
|
||||
}
|
||||
|
||||
.w-20 {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.w-30 {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.box {
|
||||
background-color: var(--box-bg);
|
||||
@@ -102,7 +110,7 @@
|
||||
.navbar-menu.is-active {
|
||||
box-shadow: 0 5px 5px rgba(0, 0, 0, 0.2)
|
||||
}
|
||||
|
||||
|
||||
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
|
||||
filter: invert(1);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ window.onload = () => {
|
||||
const devIpInputContainer = document.querySelector(`[id=dev-ip-input-container][data-id="${element.dataset.id}"]`)
|
||||
const devIpInput = document.querySelector(`[id=dev-ip-input][data-id="${element.dataset.id}"]`)
|
||||
|
||||
const devNetmaskLabelContainer = document.querySelector(`[id=dev-netmask-label-container][data-id="${element.dataset.id}"]`)
|
||||
const devNetmaskInputContainer = document.querySelector(`[id=dev-netmask-input-container][data-id="${element.dataset.id}"]`)
|
||||
const devNetmaskInput = document.querySelector(`[id=dev-netmask-input][data-id="${element.dataset.id}"]`)
|
||||
|
||||
const devMacLabel = document.querySelector(`[id=dev-mac][data-id="${element.dataset.id}"]`)
|
||||
|
||||
devNameLabelContainer.innerText = devNameInput.value;
|
||||
@@ -28,9 +32,14 @@ window.onload = () => {
|
||||
devIpInputContainer.classList.toggle("is-hidden");
|
||||
devIpLabelContainer.classList.toggle("is-hidden");
|
||||
|
||||
devNetmaskLabelContainer.innerText = devNetmaskInput.value;
|
||||
devNetmaskInputContainer.classList.toggle("is-hidden");
|
||||
devNetmaskLabelContainer.classList.toggle("is-hidden");
|
||||
|
||||
post_settings("/settings/update/", JSON.stringify({
|
||||
"name": devNameInput.value,
|
||||
"ip": devIpInput.value,
|
||||
"netmask": devNetmaskInput.value,
|
||||
"mac": devMacLabel.innerText
|
||||
}));
|
||||
element.classList.toggle("is-hidden");
|
||||
@@ -58,6 +67,11 @@ window.onload = () => {
|
||||
devIpLabelContainer.classList.toggle("is-hidden");
|
||||
const devIpInputContainer = document.querySelector(`[id=dev-ip-input-container][data-id="${element.dataset.id}"]`)
|
||||
devIpInputContainer.classList.toggle("is-hidden");
|
||||
|
||||
const devINetmaskLabelContainer = document.querySelector(`[id=dev-netmask-label-container][data-id="${element.dataset.id}"]`)
|
||||
devINetmaskLabelContainer.classList.toggle("is-hidden");
|
||||
const devNetmaskInputContainer = document.querySelector(`[id=dev-netmask-input-container][data-id="${element.dataset.id}"]`)
|
||||
devNetmaskInputContainer.classList.toggle("is-hidden");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,13 +113,15 @@ async function scan() {
|
||||
const td2 = row.insertCell();
|
||||
const td3 = row.insertCell();
|
||||
const td4 = row.insertCell();
|
||||
const td5 = row.insertCell();
|
||||
let deviceName = "Unknown";
|
||||
if (device.name != "") {
|
||||
deviceName = device.name;
|
||||
}
|
||||
td1.appendChild(document.createTextNode(deviceName));
|
||||
td2.appendChild(document.createTextNode(device.ip));
|
||||
td3.appendChild(document.createTextNode(device.mac));
|
||||
td3.appendChild(document.createTextNode(device.netmask));
|
||||
td4.appendChild(document.createTextNode(device.mac));
|
||||
const button = document.createElement("button");
|
||||
button.classList.add("button", "is-primary", "is-small");
|
||||
button.innerText = "Add";
|
||||
@@ -114,7 +130,12 @@ async function scan() {
|
||||
event.target.disabled = true;
|
||||
event.target.innerText = "Added";
|
||||
});
|
||||
td4.appendChild(button);
|
||||
td5.appendChild(button);
|
||||
td1.classList.add("is-vcentered", "w-20");
|
||||
td2.classList.add("is-vcentered", "w-20");
|
||||
td3.classList.add("is-vcentered", "w-20");
|
||||
td4.classList.add("is-vcentered", "w-20");
|
||||
td5.classList.add("is-vcentered", "w-20");
|
||||
}
|
||||
document.getElementById("scan-button").classList.remove("is-loading");
|
||||
tableContainer.classList.remove("is-hidden");
|
||||
|
||||
@@ -151,15 +151,25 @@
|
||||
{% csrf_token %}
|
||||
<table class="table is-fullwidth">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>IP</th>
|
||||
<th>MAC</th>
|
||||
<th>Action</th>
|
||||
<th class="w-20">Name</th>
|
||||
<th class="w-20">IP</th>
|
||||
<th class="w-20">Netmask</th>
|
||||
<th class="w-20">MAC</th>
|
||||
<th class="w-20">Action</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<td><input type="text" class="input" name="custom_add_name"></td>
|
||||
<td><input type="text" class="input" name="custom_add_ip"></td>
|
||||
<td><input type="text" class="input" name="custom_add_mac"></td>
|
||||
<td class="is-vcentered">
|
||||
<input type="text" class="input" name="custom_add_name">
|
||||
</td>
|
||||
<td class="is-vcentered">
|
||||
<input type="text" class="input" name="custom_add_ip">
|
||||
</td>
|
||||
<td class="is-vcentered">
|
||||
<input type="text" class="input" name="custom_add_netmask" value="{{ netmask }}">
|
||||
</td>
|
||||
<td class="is-vcentered">
|
||||
<input type="text" class="input" name="custom_add_mac">
|
||||
</td>
|
||||
<td class="is-vcentered">
|
||||
<button id="btn-custom-add" class="button is-primary is-small" type="submit">Add</button>
|
||||
</td>
|
||||
@@ -168,28 +178,24 @@
|
||||
</form>
|
||||
<div id="scan-table-container" class="table-container is-hidden">
|
||||
<table id="scan-table" class="table is-fullwidth">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>IP</th>
|
||||
<th>MAC</th>
|
||||
<th>Action</th>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% if devices %}
|
||||
<h3 class="title is-size-4 my-5">Edit devices</h3>
|
||||
<div class="table-container">
|
||||
<table class="table is-fullwidth">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>IP</th>
|
||||
<th>MAC</th>
|
||||
<th>Action</th>
|
||||
<th class="w-20">Name</th>
|
||||
<th class="w-20">IP</th>
|
||||
<th class="w-20">Netmask</th>
|
||||
<th class="w-20">MAC</th>
|
||||
<th class="w-20">Action</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for dev in devices %}
|
||||
<tr>
|
||||
<td id="dev-name" data-id="{{ dev.id }}">
|
||||
<td id="dev-name" data-id="{{ dev.id }}" class="is-vcentered">
|
||||
<div id="dev-name-label-container" data-id="{{ dev.id }}">
|
||||
{{ dev.name }}
|
||||
</div>
|
||||
@@ -197,7 +203,7 @@
|
||||
<input id="dev-name-input" data-id="{{ dev.id }}" type="text" class="input" value="{{ dev.name }}">
|
||||
</div>
|
||||
</td>
|
||||
<td id="dev-ip" data-id="{{ dev.id }}">
|
||||
<td id="dev-ip" data-id="{{ dev.id }}" class="is-vcentered">
|
||||
<div id="dev-ip-label-container" data-id="{{ dev.id }}">
|
||||
{{ dev.ip }}
|
||||
</div>
|
||||
@@ -205,7 +211,15 @@
|
||||
<input id="dev-ip-input" data-id="{{ dev.id }}" type="text" class="input" value="{{ dev.ip }}">
|
||||
</div>
|
||||
</td>
|
||||
<td id="dev-mac" data-id="{{ dev.id }}">
|
||||
<td id="dev-netmask" data-id="{{ dev.id }}" class="is-vcentered">
|
||||
<div id="dev-netmask-label-container" data-id="{{ dev.id }}">
|
||||
{{ dev.netmask }}
|
||||
</div>
|
||||
<div id="dev-netmask-input-container" data-id="{{ dev.id }}" class="is-hidden">
|
||||
<input id="dev-netmask-input" data-id="{{ dev.id }}" type="text" class="input" value="{{ dev.netmask }}">
|
||||
</div>
|
||||
</td>
|
||||
<td id="dev-mac" data-id="{{ dev.id }}" class="is-vcentered">
|
||||
{{ dev.mac }}
|
||||
</td>
|
||||
<td>
|
||||
@@ -226,6 +240,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
<h3 class="title is-size-4 my-5">Backup / Restore</h3>
|
||||
<div class="columns is-tablet">
|
||||
<div class="column is-narrow">
|
||||
|
||||
+12
-2
@@ -1,3 +1,4 @@
|
||||
import ipaddress
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
@@ -36,11 +37,16 @@ def index(request):
|
||||
|
||||
def settings(request):
|
||||
conf = Settings.objects.first()
|
||||
if conf.scan_address:
|
||||
netmask = str(ipaddress.ip_network(conf.scan_address).netmask)
|
||||
else:
|
||||
netmask = ""
|
||||
devices = Device.objects.all().order_by(conf.sort_by)
|
||||
visitors = Websocket.objects.first().visitors
|
||||
|
||||
context = {
|
||||
"settings": conf,
|
||||
"netmask": netmask,
|
||||
"ping_interval": os.getenv("PING_INTERVAL"),
|
||||
"devices": devices,
|
||||
"platform": platform.uname(),
|
||||
@@ -74,6 +80,7 @@ def settings_scan(request):
|
||||
}
|
||||
|
||||
conf = Settings.objects.filter(id=1).get()
|
||||
netmask = str(ipaddress.ip_network(conf.scan_address).netmask)
|
||||
|
||||
if not conf.scan_address:
|
||||
return JsonResponse(data=data)
|
||||
@@ -102,6 +109,7 @@ def settings_scan(request):
|
||||
data["devices"].append({
|
||||
"name": name,
|
||||
"ip": ip,
|
||||
"netmask": netmask,
|
||||
"mac": mac
|
||||
})
|
||||
|
||||
@@ -116,7 +124,8 @@ def settings_custom_add(request):
|
||||
mac=form.cleaned_data["custom_add_mac"],
|
||||
defaults={
|
||||
"name": form.cleaned_data["custom_add_name"],
|
||||
"ip": form.cleaned_data["custom_add_ip"]
|
||||
"ip": form.cleaned_data["custom_add_ip"],
|
||||
"netmask": form.cleaned_data["custom_add_netmask"]
|
||||
}
|
||||
)
|
||||
return HttpResponseRedirect("/settings/")
|
||||
@@ -135,7 +144,8 @@ def settings_update(request):
|
||||
mac=post_body["mac"],
|
||||
defaults={
|
||||
"name": name,
|
||||
"ip": post_body["ip"]
|
||||
"ip": post_body["ip"],
|
||||
"netmask": post_body["netmask"]
|
||||
}
|
||||
)
|
||||
data["status"] = 200
|
||||
|
||||
Reference in New Issue
Block a user