mirror of
https://github.com/iFargle/headscale-webui.git
synced 2026-01-04 19:53:27 +01:00
test
This commit is contained in:
21
renderer.py
21
renderer.py
@@ -791,8 +791,8 @@ def render_routes():
|
||||
route_id_list.append(route["id"])
|
||||
|
||||
# Set up the display code:
|
||||
failover_enabled = "<i class='material-icons small left green-text text-lighten-2'>fiber_manual_record</i>"
|
||||
failover_disabled = "<i class='material-icons small left red-text text-lighten-2'>fiber_manual_record</i>"
|
||||
failover_enabled = "<i id='"+str(route_prefix)+"' class='material-icons small left green-text text-lighten-2'>fiber_manual_record</i>"
|
||||
failover_disabled = "<i id='"+str(route_prefix)+"' class='material-icons small left red-text text-lighten-2'>fiber_manual_record</i>"
|
||||
|
||||
failover_display = failover_disabled
|
||||
for route_id in route_id_list:
|
||||
@@ -822,23 +822,6 @@ def render_routes():
|
||||
is_primary = all_routes["routes"][idx]["isPrimary"]
|
||||
is_enabled = all_routes["routes"][idx]["enabled"]
|
||||
|
||||
# route_id_list contains all routes associated with that prefix.
|
||||
# To toggle which is primary, we need to transfer all routes
|
||||
# and which route ID to make primary. We then toggle each route
|
||||
# in order, with the primary route being toggled last
|
||||
# Step 1: Create an array of all route_id's
|
||||
# payload = "{"
|
||||
# index = 0
|
||||
|
||||
# Is there a better way to do this??
|
||||
# for item in route_id_list:
|
||||
# payload += "\""+str(index)+"\": \""+str(item)+"\""
|
||||
# index += 1
|
||||
# if index != len(route_id_list): payload += ", "
|
||||
# payload+="}"
|
||||
# app.logger.debug("JSON: %s", str(payload))
|
||||
# json_payload = json.loads(payload)
|
||||
|
||||
payload = []
|
||||
for item in route_id_list: payload.append(int(item))
|
||||
|
||||
|
||||
@@ -861,8 +861,7 @@ function get_routes() {
|
||||
contentType: "application/json",
|
||||
success: function(response) {
|
||||
console.log("Got all routes. ")
|
||||
console.log("Headscale response: "+JSON.stringify(response))
|
||||
return JSON.stringify(response.message)
|
||||
return JSON.stringify(response)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -905,17 +904,27 @@ function toggle_failover_route_routespage(routeid, current_state, prefix, route_
|
||||
}
|
||||
M.toast({html: 'Route '+action_taken});
|
||||
|
||||
// Next, get the information for the primary route and the failover route status:
|
||||
// Get all route info:
|
||||
console.log("Getting info for prefix "+prefix)
|
||||
var routes = get_routes()
|
||||
var enabled_status = "False"
|
||||
|
||||
// Debug.
|
||||
console.log("Routes: "+routes)
|
||||
|
||||
// Second, set the primary and enabled displays for the prefix:
|
||||
// Get 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:
|
||||
// Set the Primary class:
|
||||
var primary_element = document.getElementById(routeid+"-primary")
|
||||
var primary_status = routes["route"][route_id_list[i]]["isPrimary"]
|
||||
if (primary_status == "True") {
|
||||
primary_element.className = enabledClass
|
||||
} else if (primary_status == "False") {
|
||||
primary_element.className = disabledClass
|
||||
}
|
||||
// Determine if any route is enabled:
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user