Skip to content

Commit

Permalink
Merge pull request #71 from iFargle/redo-routes-index
Browse files Browse the repository at this point in the history
Redo routes index
  • Loading branch information
iFargle authored Apr 2, 2023
2 parents 87d39e8 + 19a229c commit bd22ff6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "AGPL"
Expand Down
20 changes: 15 additions & 5 deletions renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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:
Expand All @@ -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"]
Expand Down

0 comments on commit bd22ff6

Please sign in to comment.