Commit 82dbef98 authored by Felipe Fonseca's avatar Felipe Fonseca
Browse files

Implemented auto selection for VLANs

parent 70751f3c
......@@ -355,6 +355,7 @@ function update_schedules() {
} else {
$(':button[type="submit"]').prop('disabled', true);
}
autoSelectVlans(schedules);
}
}
......@@ -366,14 +367,17 @@ function updateNetworkTab(schedules) {
html = ''
$.each(schedules, function(index, schedule) {
availableVlans = ''
$.each(schedule["availableVlans"], function(index, vlan) {
availableVlans += `<option value="${vlan}">${vlan}</option>`
$.each(schedule["availableVlans"], function(indexVlan, vlan) {
if (indexVlan == 0) {
availableVlans += `<option value="${vlan}" selected>${vlan}</option>`;
} else {
availableVlans += `<option value="${vlan}">${vlan}</option>`;
}
});
html += `<div class="row">
<div class="col-sm-12 vlan-container">
<label for="vlans">"Schedule ${index + 1}: VLAN ID"</label>
<select class="form-control" name="vlans" onchange="updateScheduleVlan(${index}, this.value)">
<option value="-1" disabled selected>"Select a vlan"</option>
${availableVlans}
</select>
</div>
......@@ -385,4 +389,10 @@ function updateNetworkTab(schedules) {
function updateScheduleVlan(index, value) {
window.selected_schedules[index]["vlan"] = value
$("input[name=schedules]").val(JSON.stringify(window.selected_schedules));
}
function autoSelectVlans(schedules) {
$.each(schedules, function(index, schedule) {
updateScheduleVlan(index, schedule["availableVlans"][0]);
});
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment