From d8a8c635041fb3e68b2ef71535aefae1548d35cb Mon Sep 17 00:00:00 2001 From: gifrerenom <lluis.gifre@cttc.es> Date: Mon, 23 Jan 2023 09:58:33 +0000 Subject: [PATCH] WebUI component: - added human-readable names to Topology graph --- src/webui/service/main/routes.py | 6 ++++-- src/webui/service/templates/js/topology.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/webui/service/main/routes.py b/src/webui/service/main/routes.py index 02706c858..30ed52911 100644 --- a/src/webui/service/main/routes.py +++ b/src/webui/service/main/routes.py @@ -136,7 +136,7 @@ def topology(): if device.device_id.device_uuid.uuid not in topo_device_uuids: continue devices.append({ 'id': device.device_id.device_uuid.uuid, - 'name': device.device_id.device_uuid.uuid, + 'name': device.name, 'type': device.device_type, }) @@ -150,13 +150,15 @@ def topology(): continue links.append({ 'id': link.link_id.link_uuid.uuid, + 'name': link.name, 'source': link.link_endpoint_ids[0].device_id.device_uuid.uuid, 'target': link.link_endpoint_ids[1].device_id.device_uuid.uuid, }) return jsonify({'devices': devices, 'links': links}) - except: + except: # pylint: disable=bare-except LOGGER.exception('Error retrieving topology') + return jsonify({'devices': [], 'links': []}) finally: context_client.close() diff --git a/src/webui/service/templates/js/topology.js b/src/webui/service/templates/js/topology.js index 29156224d..adcabf62c 100644 --- a/src/webui/service/templates/js/topology.js +++ b/src/webui/service/templates/js/topology.js @@ -88,9 +88,9 @@ d3.json("{{ url_for('main.topology') }}", function(data) { .call(d3.drag().on("start", dragstarted).on("drag", dragged).on("end", dragended)); // node tooltip - node.append("title").text(function(d) { return d.id; }); + node.append("title").text(function(n) { return n.name + ' (' + n.id + ')'; }); // link tooltip - link.append("title").text(function(d) { return d.id; }); + link.append("title").text(function(l) { return l.name + ' (' + l.id + ')'; }); // link style link -- GitLab