net refactor

This commit is contained in:
jokob-sk
2025-07-14 11:01:16 +10:00
parent e27af88690
commit 61de54bc34
28 changed files with 126 additions and 364 deletions

View File

@@ -1192,22 +1192,46 @@ function generateFormHtml(settingsData, set, overrideValue, overrideOptions, ori
const eventsList = createArray(set['setEvents']);
// inline buttons events
if (eventsList.length > 0) {
eventsList.forEach(event => {
let eventIcon = "fa-play";
if (eventsList.length > 0) {
eventsList.forEach(event => {
switch (event) {
case "add_icon":
case "add_option":
eventIcon = "fa-square-plus";
break;
case "copy_icons":
eventIcon = "fa-copy";
break;
case "go_to_device":
eventIcon = "fa-square-up-right";
break;
case "go_to_node":
eventIcon = "fa-network-wired";
break;
case "run":
eventIcon = "fa-play";
break;
case "test":
eventIcon = "fa-vial-circle-check";
break;
default:
eventIcon = "fa-play";
break;
}
eventsHtml += `<span class="input-group-addon pointer"
id="${`${event}_${setKey}`}"
data-myparam-setkey="${setKey}"
data-myparam="${setKey}"
data-myparam-plugin="${setKey.split('_')[0] || ''}"
data-myevent="${event}"
onclick="execute_settingEvent(this)">
<i title="${getString(event + "_event_tooltip")}" class="fa ${getString(event + "_event_icon")}"></i>
</span>`;
});
}
eventsHtml += `<span class="input-group-addon pointer"
id="${`${event}_${setKey}`}"
data-myparam-setkey="${setKey}"
data-myparam="${setKey}"
data-myparam-plugin="${setKey.split('_')[0] || ''}"
data-myevent="${event}"
onclick="execute_settingEvent(this)">
<i title="${getString(event + "_event_tooltip")}" class="fa ${eventIcon}"></i>
</span>`;
});
}
// Combine and return the final HTML
return inputHtml + eventsHtml;

View File

@@ -339,6 +339,7 @@ function execute_settingEvent(element) {
feSetKey = $(element).attr('data-myparam-setkey');
feParam = $(element).attr('data-myparam');
feSourceId = $(element).attr('id');
feValue = $("#"+feSetKey).val();
if (["test", "run"].includes(feEvent)) {
// Calls a backend function to add a front-end event (specified by the attributes 'data-myevent' and 'data-myparam-plugin' on the passed element) to an execution queue
@@ -391,9 +392,12 @@ function execute_settingEvent(element) {
getString('Gen_Okay'),
'overwriteIconType'
);
} else if (["go_to_node"].includes(feEvent)) {
} else if (["go_to_device"].includes(feEvent)) {
goToNetworkNode('NEWDEV_devParentMAC');
goToDevice(feValue);
} else if (["go_to_node"].includes(feEvent)) {
goToNetworkNode(feValue);
} else {
console.warn(`🔺Not implemented: ${feEvent}`)
@@ -405,12 +409,19 @@ function execute_settingEvent(element) {
// -----------------------------------------------------------------------------
// Go to the correct network node in the Network section
function goToNetworkNode(dropdownId)
{
setCache('activeNetworkTab', $('#'+dropdownId).val().replaceAll(":","_")+'_id');
function goToNetworkNode(mac)
{
setCache('activeNetworkTab', mac.replaceAll(":","_")+'_id');
window.location.href = './network.php';
}
// -----------------------------------------------------------------------------
// Go to the device
function goToDevice(mac)
{
window.location.href = './deviceDetails.php?mac=' + mac;
}
// --------------------------------------------------------
@@ -677,9 +688,6 @@ function initSelect2() {
)
$(container).addClass(badge.cssClass);
// Custom HTML
const html = $(`
@@ -693,7 +701,6 @@ function initSelect2() {
</span>
</a>
`);
return html;
},
@@ -732,7 +739,7 @@ function initSelect2() {
{
setTimeout(() => {
initSelect2()
}, 500);
}, 700);
}
}