From d8e1a9bdad05734f1c7eee228727b6f83e5262e9 Mon Sep 17 00:00:00 2001 From: iFargle Date: Sun, 2 Apr 2023 08:27:35 +0900 Subject: [PATCH 1/5] breakin' things --- renderer.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/renderer.py b/renderer.py index 882a8d6..82ddee8 100644 --- a/renderer.py +++ b/renderer.py @@ -679,7 +679,15 @@ def render_routes(): # If there are no routes, just exit: if len(all_routes) == 0: return Markup("


There are no routes to display!
") - # Testing... + # Get a list of all Route ID's to iterate through: + all_routes_id_list = [] + for route in all_routes["routes"]: + if route["machine"]["name"]: + all_routes_id_list.append(route["id"]) + 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. Skipping", str(route["id"])) + route_content = "" failover_content = "" @@ -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.indexof(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.indexof(route_id) + machine = all_routes["routes"][idx]["machine"]["givenName"] machine_id = all_routes["routes"][idx]["machine"]["id"] is_primary = all_routes["routes"][idx]["isPrimary"] From bc2f920805383210e36d6e7057ac05cc25856edf Mon Sep 17 00:00:00 2001 From: iFargle Date: Sun, 2 Apr 2023 08:35:13 +0900 Subject: [PATCH 2/5] test --- renderer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/renderer.py b/renderer.py index 82ddee8..d628b3e 100644 --- a/renderer.py +++ b/renderer.py @@ -805,7 +805,7 @@ def render_routes(): failover_display = failover_disabled for route_id in route_id_list: # Get the routes index: - current_route_index = all_routes_id_list.indexof(route_id) + current_route_index = all_routes_id_list.indexOf(route_id) if all_routes["routes"][current_route_index]["enabled"]: failover_display = failover_enabled @@ -825,8 +825,8 @@ def render_routes(): # Build the display: for route_id in route_id_list: - idx = all_routes_id_list.indexof(route_id) - + idx = all_routes_id_list.indexOf(route_id) + machine = all_routes["routes"][idx]["machine"]["givenName"] machine_id = all_routes["routes"][idx]["machine"]["id"] is_primary = all_routes["routes"][idx]["isPrimary"] From 35c8dda9ef356de0ffda37528e6ae98a5f9ca954 Mon Sep 17 00:00:00 2001 From: iFargle Date: Sun, 2 Apr 2023 08:39:43 +0900 Subject: [PATCH 3/5] test --- renderer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/renderer.py b/renderer.py index d628b3e..c4e7017 100644 --- a/renderer.py +++ b/renderer.py @@ -805,7 +805,7 @@ def render_routes(): failover_display = failover_disabled for route_id in route_id_list: # Get the routes index: - current_route_index = all_routes_id_list.indexOf(route_id) + current_route_index = all_routes_id_list.index(route_id) if all_routes["routes"][current_route_index]["enabled"]: failover_display = failover_enabled @@ -825,7 +825,7 @@ def render_routes(): # Build the display: for route_id in route_id_list: - idx = all_routes_id_list.indexOf(route_id) + idx = all_routes_id_list.index(route_id) machine = all_routes["routes"][idx]["machine"]["givenName"] machine_id = all_routes["routes"][idx]["machine"]["id"] From 04deed6b73e99f03795d6bfede17706568f13716 Mon Sep 17 00:00:00 2001 From: iFargle Date: Sun, 2 Apr 2023 08:50:36 +0900 Subject: [PATCH 4/5] Update app versions --- Jenkinsfile | 2 +- pyproject.toml | 2 +- renderer.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c587df6..ac40d60 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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}" diff --git a/pyproject.toml b/pyproject.toml index ceda49f..33a9da2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "AGPL" diff --git a/renderer.py b/renderer.py index c4e7017..a0a807d 100644 --- a/renderer.py +++ b/renderer.py @@ -752,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 += """ From 19a229c595e486e69eeeaf373e52d6c884fa1aff Mon Sep 17 00:00:00 2001 From: iFargle Date: Sun, 2 Apr 2023 10:05:29 +0900 Subject: [PATCH 5/5] test --- renderer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/renderer.py b/renderer.py index a0a807d..d2ea6fa 100644 --- a/renderer.py +++ b/renderer.py @@ -682,11 +682,11 @@ def render_routes(): # 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"]: - all_routes_id_list.append(route["id"]) 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. Skipping", str(route["id"])) + app.logger.info("Route id %s has no machine associated.", str(route["id"])) route_content = ""