Skip to content

Commit 97e0d94

Browse files
committed
add clickable link for devices, close #13
1 parent 35df275 commit 97e0d94

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

app/backend/wol/consumers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def get_all_devices(self):
140140
"ip": dev.ip,
141141
"mac": dev.mac,
142142
"netmask": dev.netmask,
143+
"link": dev.link,
143144
"ports": [],
144145
"wake": {
145146
"enabled": False,
@@ -186,6 +187,7 @@ def update_device(self, data):
186187
"name": data["name"],
187188
"ip": data["ip"],
188189
"netmask": data["netmask"],
190+
"link": data["link"],
189191
"shutdown_cmd": data["shutdown"]["command"] if data.get("shutdown") else ""
190192
}
191193
)
@@ -309,6 +311,7 @@ def scan_network(self):
309311
"ip": ip,
310312
"netmask": netmask,
311313
"mac": mac,
314+
"link": "",
312315
"ports": [],
313316
"wake": {
314317
"enabled": False,

app/backend/wol/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Device(models.Model):
1313
ip = models.GenericIPAddressField()
1414
mac = models.CharField(max_length=17)
1515
netmask = models.CharField(max_length=15, default="255.255.255.0", blank=False, null=False)
16+
link = models.URLField(blank=True, null=True)
1617
port = models.ManyToManyField(Port, blank=True)
1718
shutdown_cmd = models.TextField(null=True, blank=True)
1819

app/backend/wol/tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def start(self, dev):
3737
"mac": dev.mac,
3838
"netmask": dev.netmask,
3939
"up": False,
40+
"link": dev.link,
4041
"ports": [],
4142
"wake": {
4243
"enabled": False,

app/frontend/src/components/DeviceCard.svelte

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@
113113
<i class="fa-solid fa-ellipsis-vertical fa-2x"></i>
114114
</div>
115115
</div>
116-
<h5 class="card-title fw-bold my-2">{device.name}</h5>
116+
{#if device.link}
117+
<h5 class="card-title fw-bold my-2"><a class="inherit-color" href={device.link}>{device.name}</a></h5>
118+
{:else}
119+
<h5 class="card-title fw-bold my-2">{device.name}</h5>
120+
{/if}
117121
<h6 class="card-subtitle mb-2 text-muted">{device.ip}</h6>
118122
<ul class="list-group">
119123
{#each device.ports as port}
@@ -149,7 +153,7 @@
149153
<input type="text" class="form-control" id="inputMac{modalDevice.mac}" bind:value="{modalDevice.mac}" required>
150154
</div>
151155
</div>
152-
<div class="row">
156+
<div class="row mb-2">
153157
<div class="col-sm">
154158
<label for="inputIp{modalDevice.id}" class="form-label">IP address</label>
155159
<input type="text" class="form-control" id="inputIp{modalDevice.id}" bind:value="{modalDevice.ip}" pattern="^([01]?\d\d?|2[0-4]\d|25[0-5])(?:\.(?:[01]?\d\d?|2[0-4]\d|25[0-5])){'{'}3{'}'}$" required>
@@ -159,6 +163,14 @@
159163
<input type="text" class="form-control" id="inputNetmask{modalDevice.id}" bind:value="{modalDevice.netmask}" pattern="^(((255\.){'{'}3{'}'}(255|254|252|248|240|224|192|128|0+))|((255\.){'{'}2{'}'}(255|254|252|248|240|224|192|128|0+)\.0)|((255\.)(255|254|252|248|240|224|192|128|0+)(\.0+){'{'}2{'}'})|((255|254|252|248|240|224|192|128|0+)(\.0+){'{'}3{'}'}))$" required>
160164
</div>
161165
</div>
166+
<div class="row">
167+
<div class="col">
168+
<div class="mb-3">
169+
<label for="inputLinkAddDevice" class="form-label">Web link</label>
170+
<input type="text" class="form-control" id="inputILinkAddDevice" placeholder="http://...." bind:value="{modalDevice.link}">
171+
</div>
172+
</div>
173+
</div>
162174
<!-- ports -->
163175
<h5 class="fw-bold mt-4">Ports</h5>
164176
<p class="mb-2">Select ports to check if they are open.</p>
@@ -327,4 +339,8 @@
327339
.list-group-item {
328340
color: var(--color-text);
329341
}
342+
343+
.inherit-color {
344+
color: inherit;
345+
}
330346
</style>

app/frontend/src/components/Navbar.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@
161161
<input type="text" class="form-control" id="inputNetmaskAddDevice" placeholder="255.255.255.0" bind:value="{addDevice.netmask}" pattern="^(((255\.){'{'}3{'}'}(255|254|252|248|240|224|192|128|0+))|((255\.){'{'}2{'}'}(255|254|252|248|240|224|192|128|0+)\.0)|((255\.)(255|254|252|248|240|224|192|128|0+)(\.0+){'{'}2{'}'})|((255|254|252|248|240|224|192|128|0+)(\.0+){'{'}3{'}'}))$" required>
162162
</div>
163163
</div>
164+
<div class="row">
165+
<div class="col">
166+
<div class="mb-3">
167+
<label for="inputLinkAddDevice" class="form-label">Web link</label>
168+
<input type="text" class="form-control" id="inputILinkAddDevice" placeholder="http://...." bind:value="{addDevice.link}">
169+
</div>
170+
</div>
164171
</div>
165172
<div class="row">
166173
<div class="col-auto ms-auto">

0 commit comments

Comments
 (0)