This commit is contained in:
iFargle
2023-03-29 18:15:13 +09:00
parent b10799a5e6
commit c481bd979f
2 changed files with 4 additions and 23 deletions

View File

@@ -822,33 +822,12 @@ 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 = []
# Is there a better way to do this??
for item in route_id_list: payload.append(int(item))
app.logger.debug("[%s] Machine: [%s] %s : %s / %s", str(route_id), str(machine_id), str(machine), str(is_enabled), str(is_primary))
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_routespage("+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_routespage("+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>"
enabled_display_enabled = "<i id='"+str(route_id)+"' onclick='toggle_failover_route_routespage("+str(route_id)+", \"True\", \""+str(route_prefix)+"\", "+str(route_id_list)+")' 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_routespage("+str(route_id)+", \"False\", \""+str(route_prefix)+"\", "+str(route_id_list)+")' 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>"

View File

@@ -902,6 +902,8 @@ function toggle_failover_route_routespage(route_id, current_state, prefix, route
// Next, get the information for the primary route and the failover route status:
console.log("Getting info for prefix "+prefix)
var routes = get_routes()
console.log(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]