From 9fcbbe39bd958cee46a687e45aed884da5e86d17 Mon Sep 17 00:00:00 2001 From: Toshiyuki Hayashi Date: Mon, 11 Mar 2013 11:14:30 -0700 Subject: [PATCH] Display port link between router and extra network A port link between router and extra network was not displayed with demo account. This commit fixed the bug. Also remove dead link when port has no link. fixes bug 1131082 Change-Id: I50c469e55e0b8435b95f03b191a04e27017fc37e --- .../static/horizon/js/horizon.networktopology.js | 9 +++++++-- .../dashboards/project/network_topology/views.py | 16 +++++++--------- .../static/dashboard/less/horizon.less | 7 +++++++ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/horizon/static/horizon/js/horizon.networktopology.js b/horizon/static/horizon/js/horizon.networktopology.js index e88d54cad..b60cbd841 100644 --- a/horizon/static/horizon/js/horizon.networktopology.js +++ b/horizon/static/horizon/js/horizon.networktopology.js @@ -240,10 +240,15 @@ horizon.network_topology = { port_html .append(ip_html) .css({'background-color':self.network_color(port.network_id)}) - .click(function (e){ + .click(function (e) { e.stopPropagation(); - window.location.href = port.url; + if(port.url != undefined) { + window.location.href = port.url; + } }); + if(port.url == undefined) { + port_html.addClass("nourl"); + } return port_html; }, port_css: function(port_html, position, network_a, network_b){ diff --git a/openstack_dashboard/dashboards/project/network_topology/views.py b/openstack_dashboard/dashboards/project/network_topology/views.py index 507862a3c..b6e530888 100644 --- a/openstack_dashboard/dashboards/project/network_topology/views.py +++ b/openstack_dashboard/dashboards/project/network_topology/views.py @@ -40,9 +40,10 @@ class JSONView(View): continue resource['url'] = reverse(view, None, [str(resource['id'])]) - def _select_port_by_network_id(self, ports, network_id): + def _check_router_external_port(self, ports, router_id, network_id): for port in ports: - if port['network_id'] == network_id: + if (port['network_id'] == network_id + and port['device_id'] == router_id): return True return False @@ -72,7 +73,7 @@ class JSONView(View): self.add_resource_url('horizon:project:networks:ports:detail', data['ports']) data['routers'] = routers.get('routers', []) - # user can't see port on shared network. so we are + # user can't see port on external network. so we are # adding fake port based on router information for router in data['routers']: external_gateway_info = router.get('external_gateway_info') @@ -82,15 +83,12 @@ class JSONView(View): 'network_id') if not external_network: continue - if self._select_port_by_network_id(data['ports'], - external_network): + if self._check_router_external_port(data['ports'], + router['id'], + external_network): continue fake_port = {'id': 'fake%s' % external_network, 'network_id': external_network, - 'url': reverse( - 'horizon:project:networks:detail', - None, - [external_network]), 'device_id': router['id'], 'fixed_ips': []} data['ports'].append(fake_port) diff --git a/openstack_dashboard/static/dashboard/less/horizon.less b/openstack_dashboard/static/dashboard/less/horizon.less index ec445c736..775d2589a 100644 --- a/openstack_dashboard/static/dashboard/less/horizon.less +++ b/openstack_dashboard/static/dashboard/less/horizon.less @@ -2035,6 +2035,13 @@ div.network { -o-animation: progress-bar-stripes 0.3s linear infinite; animation: progress-bar-stripes 0.3s linear infinite; } + &.nourl { + cursor: auto; + background-image:none; + &:hover { + background-image:none; + } + } } border-color: #222; &:after {