Skip to content

Commit 059888d

Browse files
nwahtschak909
authored andcommitted
[webui] add edit button to host slots
1 parent 1d73914 commit 059888d

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

data/webui/template/www/index.tmpl.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@ <h3 style="text-align: center;">Need help? Go to the <a href="https://github.com
281281
<header class="module-header">HOSTS<span class="logowob"></span>LIST</header>
282282
{% for hs in range(1, 9) %}
283283
<div class="{{ loop.cycle('detline', 'detline alt') }}">
284-
<div class="deth detlinecol">Host {{ hs }}</div>
284+
<div class="deth detlinecol">
285+
Host {{ hs }}
286+
<a href="#" class="edit-host" data-hostslot="{{ hs }}" data-hostname="<%FN_HOST{{ hs }}%>">[EDIT]</a>
287+
</div>
285288
{% if tweaks.fujinet_pc %}
286289
<div class="det detlinecol"><a href="/browse/host/{{ hs }}"><%FN_HOST{{ hs }}%> :: <%FN_HOST{{ hs }}PREFIX%></a></div>
287290
{% else %}

data/webui/template/www/js/settings.tmpl.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,32 @@ function toggleExperimental(evt) {
1414
localStorage.setItem('fujinet.experimental', evt.target.checked);
1515
}
1616

17+
function setupHostEditing() {
18+
const editLinks = document.querySelectorAll('a.edit-host');
19+
editLinks.forEach(link => {
20+
link.addEventListener('click', e => {
21+
e.preventDefault();
22+
const hs = Number(link.dataset.hostslot) - 1;
23+
const currentHostname = link.dataset.hostname;
24+
25+
const updatedHostname = prompt(`Enter hostname for slot ${hs + 1}`, currentHostname);
26+
27+
// Abort on [Cancel]
28+
if (updatedHostname === null) {
29+
return;
30+
}
31+
32+
fetch(`/hosts?hostslot=${hs}&hostname=${updatedHostname}`, { method: 'POST' })
33+
.then(() => {
34+
location.reload();
35+
})
36+
.catch(e => {
37+
alert("Error: Could not update host");
38+
});
39+
});
40+
});
41+
}
42+
1743
function changeTz() {
1844
const selElement = document.getElementById("select_tz");
1945
const setElement = document.getElementById("txt_timezone")
@@ -170,3 +196,4 @@ setInputValue(current_pclink == 1, "pclink-yes", "pclink-no");
170196
{% endif %}
171197

172198
setupExperimentalToggle();
199+
setupHostEditing();

lib/device/sio/fuji.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,6 +2781,7 @@ std::string sioFuji::get_host_prefix(int host_slot)
27812781
fujiHost *sioFuji::set_slot_hostname(int host_slot, char *hostname)
27822782
{
27832783
_fnHosts[host_slot].set_hostname(hostname);
2784+
_populate_config_from_slots();
27842785
return &_fnHosts[host_slot];
27852786
}
27862787

0 commit comments

Comments
 (0)