Merge pull request #71 from iFargle/redo-routes-index

Redo routes index
This commit is contained in:
Albert Copeland
2023-04-03 08:18:33 +09:00
committed by GitHub
3 changed files with 17 additions and 7 deletions

2
Jenkinsfile vendored
View File

@@ -3,7 +3,7 @@ pipeline {
label 'linux-x64'
}
environment {
APP_VERSION = 'v0.6.0'
APP_VERSION = 'v0.6.1'
HS_VERSION = "v0.21.0" // Version of Headscale this is compatible with
BUILD_DATE = ''
BUILDER_NAME = "multiarch-${env.BUILD_TAG}"

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "headscale-webui"
version = "v0.6.0"
version = "v0.6.1"
description = "A simple web UI for small-scale Headscale deployments."
authors = ["Albert Copeland <albert@sysctl.io>"]
license = "AGPL"

View File

@@ -679,7 +679,15 @@ def render_routes():
# If there are no routes, just exit:
if len(all_routes) == 0: return Markup("<br><br><br><center>There are no routes to display!</center>")
# Testing...
# Get a list of all Route ID's to iterate through:
all_routes_id_list = []
for route in all_routes["routes"]:
all_routes_id_list.append(route["id"])
if route["machine"]["name"]:
app.logger.info("Found route %s / machine: %s", str(route["id"]), route["machine"]["name"])
else:
app.logger.info("Route id %s has no machine associated.", str(route["id"]))
route_content = ""
failover_content = ""
@@ -744,7 +752,7 @@ def render_routes():
if route["id"] != route_check["id"]:
is_failover = True
if not is_exit and not is_failover:
if not is_exit and not is_failover and machine != "":
# Build a simple table for all non-exit routes:
route_content += """
<tr>
@@ -796,7 +804,9 @@ def render_routes():
failover_display = failover_disabled
for route_id in route_id_list:
if all_routes["routes"][int(route_id) - 1]["enabled"]: failover_display = failover_enabled
# Get the routes index:
current_route_index = all_routes_id_list.index(route_id)
if all_routes["routes"][current_route_index]["enabled"]: failover_display = failover_enabled
# Get all route_id's associated with the route prefix:
@@ -815,8 +825,8 @@ def render_routes():
# Build the display:
for route_id in route_id_list:
idx = int(route_id) - 1
# Get info on every route in the list: route_id-1 is the positiond in the array starting 0
idx = all_routes_id_list.index(route_id)
machine = all_routes["routes"][idx]["machine"]["givenName"]
machine_id = all_routes["routes"][idx]["machine"]["id"]
is_primary = all_routes["routes"][idx]["isPrimary"]