mirror of
https://github.com/iFargle/headscale-webui.git
synced 2025-12-19 00:30:11 +01:00
test
This commit is contained in:
@@ -847,8 +847,8 @@ def render_routes():
|
||||
app.logger.debug(str(all_routes["routes"][idx]))
|
||||
|
||||
# Set up the display code:
|
||||
enabled_display_enabled = "<i id='"+str(route_id)+"' onclick='toggle_failover_route("+str(route_id)+", \"True\", \"routes\" , \""+str(route_prefix)+"\", "+str(payload)+")' class='material-icons green-text text-lighten-2 tooltipped' data-tooltip='Click to disable'>fiber_manual_record</i>"
|
||||
enabled_display_disabled = "<i id='"+str(route_id)+"' onclick='toggle_failover_route("+str(route_id)+", \"False\", \"routes\", \""+str(route_prefix)+"\", "+str(payload)+")' class='material-icons red-text text-lighten-2 tooltipped' data-tooltip='Click to enable'>fiber_manual_record</i>"
|
||||
enabled_display_enabled = "<i id='"+str(route_id)+"' onclick='toggle_failover_route("+str(route_id)+", \"True\", \""+str(route_prefix)+"\", "+str(payload)+")' class='material-icons green-text text-lighten-2 tooltipped' data-tooltip='Click to disable'>fiber_manual_record</i>"
|
||||
enabled_display_disabled = "<i id='"+str(route_id)+"' onclick='toggle_failover_route("+str(route_id)+", \"False\", \""+str(route_prefix)+"\", "+str(payload)+")' class='material-icons red-text text-lighten-2 tooltipped' data-tooltip='Click to enable'>fiber_manual_record</i>"
|
||||
primary_display_enabled = "<i id='"+str(route_id)+"-primary' class='material-icons green-text text-lighten-2'>fiber_manual_record</i>"
|
||||
primary_display_disabled = "<i id='"+str(route_id)+"-primary' class='material-icons red-text text-lighten-2'>fiber_manual_record</i>"
|
||||
|
||||
|
||||
@@ -865,18 +865,53 @@ function get_routes() {
|
||||
})
|
||||
}
|
||||
|
||||
function toggle_failover_route(route_id, current_state, page, prefix, route_id_list) {
|
||||
function toggle_failover_route(route_id, current_state, prefix, route_id_list) {
|
||||
// First, toggle the route:
|
||||
toggle_route(route_id, current_state, page)
|
||||
// toggle_route(route_id, current_state, page)
|
||||
|
||||
var data = {"route_id": route_id, "current_state": current_state}
|
||||
var element = document.getElementById(route_id);
|
||||
|
||||
var disabledClass = "material-icons red-text text-lighten-2 tooltipped";
|
||||
var enabledClass = "material-icons green-text text-lighten-2 tooltipped";
|
||||
|
||||
var disabledTooltip = "Click to enable"
|
||||
var enabledTooltip = "Click to disable"
|
||||
var disableState = "False"
|
||||
var enableState = "True"
|
||||
var action_taken = "unchanged. See logs.";
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url: "api/update_route",
|
||||
data: JSON.stringify(data),
|
||||
contentType: "application/json",
|
||||
success: function(response) {
|
||||
if (element.className == disabledClass) {
|
||||
element.className = enabledClass
|
||||
action_taken = "enabled."
|
||||
element.setAttribute('data-tooltip', enabledTooltip)
|
||||
element.setAttribute('onclick', 'toggle_failover_route('+route_id+', "'+enableState+'", "'+prefix+'", "'+route_id_list+'")')
|
||||
} else if (element.className == enabledClass) {
|
||||
element.className = disabledClass
|
||||
action_taken = "disabled."
|
||||
element.setAttribute('data-tooltip', disabledTooltip)
|
||||
element.setAttribute('onclick', 'toggle_failover_route('+route_id+', "'+disableState+'", "'+prefix+'", "'+route_id_list+'")')
|
||||
}
|
||||
M.toast({html: 'Route '+action_taken});
|
||||
|
||||
// Next, get the information for the primary route and the failover route status:
|
||||
console.log("Getting info for prefix "+prefix)
|
||||
var routes = get_Routes()
|
||||
var routes = get_routes()
|
||||
// Second, set the primary and enabled displays for the prefix:
|
||||
for (let i=0; i < route_id_list.length; i++) {
|
||||
var route_id = route_id_list[i]
|
||||
console.log("route_id_list["+i+"]: "+route_id_list[i])
|
||||
// If one of the two routes is enabled, keep the prefix's route green.
|
||||
// Step 1: Get info for these routes:
|
||||
}}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function toggle_failover_route(route_id, current_state, color) {
|
||||
var data = {"route_id": route_id, "current_state": current_state}
|
||||
|
||||
Reference in New Issue
Block a user