mirror of
https://github.com/iFargle/headscale-webui.git
synced 2025-12-20 09:10:23 +01:00
test
This commit is contained in:
@@ -251,6 +251,10 @@ def thread_machine_content(machine, machine_content, idx, all_routes):
|
|||||||
# Test if the machine is an exit node:
|
# Test if the machine is an exit node:
|
||||||
exit_route_found = False
|
exit_route_found = False
|
||||||
exit_route_enabled = False
|
exit_route_enabled = False
|
||||||
|
# If the device has enabled Failover routes (High Availability routes)
|
||||||
|
ha_routes = False
|
||||||
|
ha_color = ""
|
||||||
|
|
||||||
# If the length of "routes" is NULL/0, there are no routes, enabled or disabled:
|
# If the length of "routes" is NULL/0, there are no routes, enabled or disabled:
|
||||||
if len(pulled_routes["routes"]) > 0:
|
if len(pulled_routes["routes"]) > 0:
|
||||||
advertised_routes = False
|
advertised_routes = False
|
||||||
@@ -306,6 +310,7 @@ def thread_machine_content(machine, machine_content, idx, all_routes):
|
|||||||
if str(route_info["prefix"]) == str(route["prefix"]) and (route["prefix"] != "0.0.0.0/0" and route["prefix"] != "::/0"):
|
if str(route_info["prefix"]) == str(route["prefix"]) and (route["prefix"] != "0.0.0.0/0" and route["prefix"] != "::/0"):
|
||||||
if route_info["id"] != route["id"]:
|
if route_info["id"] != route["id"]:
|
||||||
app.logger.info("HA pair found: %s", str(route["prefix"]))
|
app.logger.info("HA pair found: %s", str(route["prefix"]))
|
||||||
|
ha_routes = True
|
||||||
failover_pair_prefixes = str(route["prefix"])
|
failover_pair_prefixes = str(route["prefix"])
|
||||||
if route["prefix"] != "0.0.0.0/0" and route["prefix"] != "::/0" and route["prefix"] in failover_pair_prefixes:
|
if route["prefix"] != "0.0.0.0/0" and route["prefix"] != "::/0" and route["prefix"] in failover_pair_prefixes:
|
||||||
route_enabled = "red"
|
route_enabled = "red"
|
||||||
@@ -313,6 +318,7 @@ def thread_machine_content(machine, machine_content, idx, all_routes):
|
|||||||
if route["enabled"]:
|
if route["enabled"]:
|
||||||
color_index = failover_pair_prefixes.index(str(route["prefix"]))
|
color_index = failover_pair_prefixes.index(str(route["prefix"]))
|
||||||
route_enabled = helper.get_color(color_index, "failover")
|
route_enabled = helper.get_color(color_index, "failover")
|
||||||
|
ha_color = helper.get_color(color_index, "failover")
|
||||||
route_tooltip = 'disable'
|
route_tooltip = 'disable'
|
||||||
routes = routes+""" <p
|
routes = routes+""" <p
|
||||||
class='waves-effect waves-light btn-small """+route_enabled+""" lighten-2 tooltipped'
|
class='waves-effect waves-light btn-small """+route_enabled+""" lighten-2 tooltipped'
|
||||||
@@ -427,6 +433,7 @@ def thread_machine_content(machine, machine_content, idx, all_routes):
|
|||||||
status_badge = "<i class='material-icons left tooltipped " + text_color + "' data-position='top' data-tooltip='Last Seen: "+last_seen_print+"' id='"+machine["id"]+"-status'>fiber_manual_record</i>"
|
status_badge = "<i class='material-icons left tooltipped " + text_color + "' data-position='top' data-tooltip='Last Seen: "+last_seen_print+"' id='"+machine["id"]+"-status'>fiber_manual_record</i>"
|
||||||
user_badge = "<span class='badge ipinfo " + user_color + " white-text hide-on-small-only' id='"+machine["id"]+"-ns-badge'>"+machine["user"]["name"]+"</span>"
|
user_badge = "<span class='badge ipinfo " + user_color + " white-text hide-on-small-only' id='"+machine["id"]+"-ns-badge'>"+machine["user"]["name"]+"</span>"
|
||||||
exit_node_badge = "" if not exit_route_enabled else "<span class='badge grey white-text text-lighten-4 tooltipped' data-position='left' data-tooltip='This machine has an enabled exit route.'>Exit Node</span>"
|
exit_node_badge = "" if not exit_route_enabled else "<span class='badge grey white-text text-lighten-4 tooltipped' data-position='left' data-tooltip='This machine has an enabled exit route.'>Exit Node</span>"
|
||||||
|
ha_route_badge = "" if not ha_routes else "<span class='badge "+ha_color+" white-text text-lighten-4 tooltipped' data-position='left' data-tooltip='This machine has an enabled HA route.'>HA</span>"
|
||||||
expiration_badge = "" if not expiring_soon else "<span class='badge red white-text text-lighten-4 tooltipped' data-position='left' data-tooltip='This machine expires soon.'>Expiring!</span>"
|
expiration_badge = "" if not expiring_soon else "<span class='badge red white-text text-lighten-4 tooltipped' data-position='left' data-tooltip='This machine expires soon.'>Expiring!</span>"
|
||||||
|
|
||||||
machine_content[idx] = (str(render_template(
|
machine_content[idx] = (str(render_template(
|
||||||
@@ -442,6 +449,7 @@ def thread_machine_content(machine, machine_content, idx, all_routes):
|
|||||||
machine_ips = Markup(machine_ips),
|
machine_ips = Markup(machine_ips),
|
||||||
advertised_routes = Markup(routes),
|
advertised_routes = Markup(routes),
|
||||||
exit_node_badge = Markup(exit_node_badge),
|
exit_node_badge = Markup(exit_node_badge),
|
||||||
|
ha_route_badge = Markup(ha_route_badge),
|
||||||
status_badge = Markup(status_badge),
|
status_badge = Markup(status_badge),
|
||||||
user_badge = Markup(user_badge),
|
user_badge = Markup(user_badge),
|
||||||
last_update_time = str(last_update_time),
|
last_update_time = str(last_update_time),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
{{ user_badge }}
|
{{ user_badge }}
|
||||||
{{ exit_node_badge }}
|
{{ exit_node_badge }}
|
||||||
{{ expiration_badge }}
|
{{ expiration_badge }}
|
||||||
{{ failover_badge }}
|
{{ ha_route_badge }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="collapsible-body">
|
<div class="collapsible-body">
|
||||||
|
|||||||
Reference in New Issue
Block a user