Skip to content

Commit

Permalink
fix js error
Browse files Browse the repository at this point in the history
  • Loading branch information
nanhantianyi committed Jan 8, 2024
1 parent 893a1ac commit 15f84de
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
36 changes: 2 additions & 34 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
</div>
<div class="form-group form-group-sm">
<select name="status-selector" id="status-selector" class="custom-select form-control-navbar" style="margin-left: 0.5em; height: 90%; font-size: 14px;">
<!-- THIS SECTION IS OVERRIDDEN BY JS. SEE updateSearchList() function BEFORE EDITING -->
<!-- THIS SECTION IS OVERRIDDEN BY JS. SEE updateSearchList() function in clients.html BEFORE EDITING -->
<option value="All">All</option>
<option value="Enabled">Enabled</option>
<option value="Disabled">Disabled</option>
<option value="Connected">Connected</option>
<option value="Disconnected">Disconnected</option>
<!-- THIS SECTION IS OVERRIDDEN BY JS. SEE updateSearchList() function BEFORE EDITING -->
<!-- THIS SECTION IS OVERRIDDEN BY JS. SEE updateSearchList() function in clients.html BEFORE EDITING -->
</select>
</div>
</form>
Expand Down Expand Up @@ -397,8 +397,6 @@ <h1>{{template "page_title" .}}</h1>

updateApplyConfigVisibility()

updateSearchList()

});

function addGlobalStyle(css, id) {
Expand Down Expand Up @@ -435,36 +433,6 @@ <h1>{{template "page_title" .}}</h1>
}
});
}

function updateSearchList() {
$.getJSON("{{.basePath}}/api/subnet-ranges", null, function(data) {
$("#status-selector option").remove();
$("#status-selector").append(
$("<option></option>")
.text("All")
.val("All"),
$("<option></option>")
.text("Enabled")
.val("Enabled"),
$("<option></option>")
.text("Disabled")
.val("Disabled"),
$("<option></option>")
.text("Connected")
.val("Connected"),
$("<option></option>")
.text("Disconnected")
.val("Disconnected")
);
$.each(data, function(index, item) {
$("#status-selector").append(
$("<option></option>")
.text(item)
.val(item)
);
});
});
}

// populateClient function for render new client info
// on the client page.
Expand Down
31 changes: 31 additions & 0 deletions templates/clients.html
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,41 @@ <h4 class="modal-title">Remove</h4>
});
});
}

function updateSearchList() {
$.getJSON("{{.basePath}}/api/subnet-ranges", null, function(data) {
$("#status-selector option").remove();
$("#status-selector").append(
$("<option></option>")
.text("All")
.val("All"),
$("<option></option>")
.text("Enabled")
.val("Enabled"),
$("<option></option>")
.text("Disabled")
.val("Disabled"),
$("<option></option>")
.text("Connected")
.val("Connected"),
$("<option></option>")
.text("Disconnected")
.val("Disconnected")
);
$.each(data, function(index, item) {
$("#status-selector").append(
$("<option></option>")
.text(item)
.val(item)
);
});
});
}
</script>
<script>
// load client list
$(document).ready(function () {
updateSearchList();
populateClientList();
})

Expand Down

0 comments on commit 15f84de

Please sign in to comment.