Repository: qpid-dispatch Updated Branches: refs/heads/master 9ec4c43bc -> 4d1748ae1
DISPATCH-433 Fix console refresh and navigating to urls not in console's namespace Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/4d1748ae Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/4d1748ae Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/4d1748ae Branch: refs/heads/master Commit: 4d1748ae1b1f024ddeace2a4d35872d0fe96bcad Parents: 9ec4c43 Author: Ernest Allen <[email protected]> Authored: Tue Aug 2 12:38:18 2016 -0400 Committer: Ernest Allen <[email protected]> Committed: Tue Aug 2 12:38:18 2016 -0400 ---------------------------------------------------------------------- .../src/main/webapp/plugin/js/dispatchPlugin.js | 46 +++++++++++--------- .../hawtio/src/main/webapp/plugin/js/navbar.js | 3 ++ .../hawtio/src/main/webapp/plugin/js/qdrList.js | 29 ++++++------ .../src/main/webapp/plugin/js/qdrOverview.js | 5 --- .../src/main/webapp/plugin/js/qdrService.js | 23 +++++----- .../src/main/webapp/plugin/js/qdrTopology.js | 25 ++++++++--- 6 files changed, 75 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/4d1748ae/console/hawtio/src/main/webapp/plugin/js/dispatchPlugin.js ---------------------------------------------------------------------- diff --git a/console/hawtio/src/main/webapp/plugin/js/dispatchPlugin.js b/console/hawtio/src/main/webapp/plugin/js/dispatchPlugin.js index 7176be2..80c2c9d 100644 --- a/console/hawtio/src/main/webapp/plugin/js/dispatchPlugin.js +++ b/console/hawtio/src/main/webapp/plugin/js/dispatchPlugin.js @@ -79,25 +79,25 @@ var QDR = (function(QDR) { * routeProvider has been configured with. */ $routeProvider - .when('/' + QDR.pluginName, { + .when(QDR.pluginRoot, { templateUrl: QDR.templatePath + 'qdrConnect.html' }) - .when('/' + QDR.pluginName + '/overview', { + .when(QDR.pluginRoot + '/overview', { templateUrl: QDR.templatePath + 'qdrOverview.html' }) - .when('/' + QDR.pluginName + '/topology', { + .when(QDR.pluginRoot + '/topology', { templateUrl: QDR.templatePath + 'qdrTopology.html' }) - .when('/' + QDR.pluginName + '/list', { + .when(QDR.pluginRoot + '/list', { templateUrl: QDR.templatePath + 'qdrList.html' }) - .when('/' + QDR.pluginName + '/schema', { + .when(QDR.pluginRoot + '/schema', { templateUrl: QDR.templatePath + 'qdrSchema.html' }) - .when('/' + QDR.pluginName + '/charts', { + .when(QDR.pluginRoot + '/charts', { templateUrl: QDR.templatePath + 'qdrCharts.html' }) - .when('/' + QDR.pluginName + '/connect', { + .when(QDR.pluginRoot + '/connect', { templateUrl: QDR.templatePath + 'qdrConnect.html' }) }) @@ -168,17 +168,22 @@ var QDR = (function(QDR) { QDR.module.run(function(workspace, viewRegistry, layoutFull, $rootScope, $location, localStorage, QDRService, QDRChartService) { QDR.log.info("*************creating Dispatch Console************"); var curPath = $location.path() - if (curPath !== '/' + QDR.pluginName) { - var toPath = QDR.pluginRoot + "/connect"; - $location.path(toPath); - if (curPath.startsWith(QDR.pluginRoot)) { - var org = curPath.substr(QDR.pluginRoot.length + 1) - if (org !== "connect") - $location.search('org', org) - } - $location.replace(); + var lastLocation = localStorage[QDR.LAST_LOCATION]; + if (!angular.isDefined(lastLocation)) { + lastLocation = "connect"; + } + if (lastLocation.startsWith(QDR.pluginRoot)) { + lastLocation = lastLocation.substr(QDR.pluginRoot.length+1) + } + if (curPath.startsWith(QDR.pluginRoot)) { + var org = curPath.substr(QDR.pluginRoot.length + 1) + if (curPath === QDR.pluginRoot && (!org || org.length===0 || org !== 'connect')) { + org = lastLocation + } + if (org && org.length > 0) { + $location.search('org', org) + } } - Core.addCSS(QDR.contextPath + "plugin/css/dispatch.css"); Core.addCSS(QDR.contextPath + "plugin/css/plugin.css"); @@ -230,15 +235,16 @@ var QDR = (function(QDR) { }); $rootScope.$on( "$routeChangeStart", function(event, next, current) { - if (next.templateUrl == QDR.templatePath + "qdrConnect.html" && QDRService.connected) { + if (next && next.templateUrl == QDR.templatePath + "qdrConnect.html" && QDRService.connected) { // clicked connect from another dispatch page - if (current.loadedTemplateUrl.startsWith(QDR.contextPath)) { + if (current && current.loadedTemplateUrl.startsWith(QDR.contextPath)) { return; } // clicked the Dispatch Router top level tab from a different plugin var lastLocation = localStorage[QDR.LAST_LOCATION]; - if (!angular.isDefined(lastLocation)) + if (!angular.isDefined(lastLocation)) { lastLocation = QDR.pluginRoot + "/overview"; + } // show the last page visited $location.path(lastLocation) } http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/4d1748ae/console/hawtio/src/main/webapp/plugin/js/navbar.js ---------------------------------------------------------------------- diff --git a/console/hawtio/src/main/webapp/plugin/js/navbar.js b/console/hawtio/src/main/webapp/plugin/js/navbar.js index dfdcb3a..74cc5a6 100644 --- a/console/hawtio/src/main/webapp/plugin/js/navbar.js +++ b/console/hawtio/src/main/webapp/plugin/js/navbar.js @@ -79,6 +79,9 @@ QDR.NavBarController = function($scope, QDRService, QDRChartService, $location, }; $scope.isActive = function(href) { + // highlight the connect tab if we are on the root page + if (($location.path() === QDR.pluginRoot) && (href.split("#")[1] === QDR.pluginRoot + "/connect")) + return true return href.split("#")[1] == $location.path(); }; http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/4d1748ae/console/hawtio/src/main/webapp/plugin/js/qdrList.js ---------------------------------------------------------------------- diff --git a/console/hawtio/src/main/webapp/plugin/js/qdrList.js b/console/hawtio/src/main/webapp/plugin/js/qdrList.js index a666472..7aa808e 100644 --- a/console/hawtio/src/main/webapp/plugin/js/qdrList.js +++ b/console/hawtio/src/main/webapp/plugin/js/qdrList.js @@ -35,22 +35,13 @@ var QDR = (function(QDR) { var updateInterval = 5000; var ListExpandedKey = "QDRListExpanded"; $scope.details = {}; - if (!QDRService.connected) { - // we are not connected. we probably got here from a bookmark or manual page reload - QDRService.redirectWhenConnected("list"); - return; - } - // we are currently connected. setup a handler to get notified if we are ever disconnected - QDRService.addDisconnectAction( function () { - QDRService.redirectWhenConnected("list") - $scope.$apply(); - }) - $scope.selectedEntity = localStorage['QDRSelectedEntity']; + $scope.selectedEntity = localStorage['QDRSelectedEntity'] || "address"; $scope.selectedNode = localStorage['QDRSelectedNode']; $scope.selectedNodeId = localStorage['QDRSelectedNodeId']; $scope.selectedRecordName = localStorage['QDRSelectedRecordName']; - + $scope.nodes = [] + $scope.currentNode = undefined; $scope.modes = [{ content: '<a><i class="icon-list"></i> Attributes</a>', id: 'attributes', @@ -127,6 +118,17 @@ var QDR = (function(QDR) { return mode.isValid() } + if (!QDRService.connected) { + // we are not connected. we probably got here from a bookmark or manual page reload + QDRService.redirectWhenConnected("list"); + return; + } + // we are currently connected. setup a handler to get notified if we are ever disconnected + QDRService.addDisconnectAction( function () { + QDRService.redirectWhenConnected("list") + $scope.$apply(); + }) + $scope.nodes = QDRService.nodeList().sort(function (a, b) { return a.name.toLowerCase() > b.name.toLowerCase()}); // unable to get node list? Bail. if ($scope.nodes.length == 0) { @@ -141,7 +143,6 @@ var QDR = (function(QDR) { //QDR.log.debug("forcing selectedNode to " + $scope.selectedNode); } } - $scope.currentNode = undefined; var setCurrentNode = function () { $scope.nodes.some( function (node, i) { if (node.name === $scope.selectedNode) { @@ -807,4 +808,4 @@ var QDR = (function(QDR) { return QDR; } (QDR || {})); -// messaging-ci-01.mw.lab.eng.bos.redhat.com \ No newline at end of file +// messaging-ci-01.mw.lab.eng.bos.redhat.com http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/4d1748ae/console/hawtio/src/main/webapp/plugin/js/qdrOverview.js ---------------------------------------------------------------------- diff --git a/console/hawtio/src/main/webapp/plugin/js/qdrOverview.js b/console/hawtio/src/main/webapp/plugin/js/qdrOverview.js index a9a76ec..aad0cdf 100644 --- a/console/hawtio/src/main/webapp/plugin/js/qdrOverview.js +++ b/console/hawtio/src/main/webapp/plugin/js/qdrOverview.js @@ -68,7 +68,6 @@ var QDR = (function (QDR) { } $scope.linkFields = [] $scope.link = null; - var currentTimer; var refreshInterval = 5000 $scope.modes = [ {title: 'Overview', name: 'Overview', right: false} @@ -1417,10 +1416,6 @@ var QDR = (function (QDR) { $scope.$on("$destroy", function( event ) { QDRService.stopUpdating() QDRService.delUpdatedAction("overview") - if (currentTimer) { - clearTimeout(currentTimer) - currentTimer = null; - } }); }]); http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/4d1748ae/console/hawtio/src/main/webapp/plugin/js/qdrService.js ---------------------------------------------------------------------- diff --git a/console/hawtio/src/main/webapp/plugin/js/qdrService.js b/console/hawtio/src/main/webapp/plugin/js/qdrService.js index 3004f79..09c3b92 100644 --- a/console/hawtio/src/main/webapp/plugin/js/qdrService.js +++ b/console/hawtio/src/main/webapp/plugin/js/qdrService.js @@ -64,15 +64,18 @@ var QDR = (function(QDR) { } }); self.connectActions = []; - $timeout( function () { - var searchObject = $location.search(); - var goto = "overview"; - if (searchObject.org) { - goto = searchObject.org; - } - $location.search('org', null) - $location.path(QDR.pluginRoot +"/" + goto); - }) + if ($location.path().startsWith(QDR.pluginRoot)) { + $timeout( function () { + + var searchObject = $location.search(); + var goto = "overview"; + if (searchObject.org) { + goto = searchObject.org; + } + $location.search('org', null) + $location.path(QDR.pluginRoot +"/" + goto); + }) + } }, executeDisconnectActions: function() { @@ -179,8 +182,8 @@ var QDR = (function(QDR) { }, startUpdating: function () { - QDR.log.info("startUpdating called") self.stopUpdating(); + QDR.log.info("startUpdating called") self.topology.get(); self.stop = setInterval(function() { self.topology.get(); http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/4d1748ae/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js ---------------------------------------------------------------------- diff --git a/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js b/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js index 3b69c31..567a494 100644 --- a/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js +++ b/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js @@ -463,7 +463,6 @@ var QDR = (function (QDR) { $(".contextMenu").fadeOut(200); }); - // set up SVG for D3 var width, height; var tpdiv = $('#topology'); @@ -474,6 +473,10 @@ var QDR = (function (QDR) { var radiusNormal = 15; width = tpdiv.width() - gap; height = $('#main').height() - $('#topology').position().top - gap; + if (width < 10 && height < 10) { + QDR.log.info("page width and height are abynormal: returning before very bad things happen") + return; + } var svg, lsvg; var force; @@ -537,7 +540,6 @@ var QDR = (function (QDR) { // initialize the nodes and links array from the QDRService.topology._nodeInfo object var initForceGraph = function () { - //QDR.log.debug("initForceGraph called"); nodes = []; links = []; @@ -1178,7 +1180,6 @@ var QDR = (function (QDR) { svgg.transition().attr("transform", "translate(2,2) scale(1)") }) - // remove old links path.exit().remove(); @@ -1383,6 +1384,7 @@ var QDR = (function (QDR) { return d.name.length>7 ? d.name.substr(0,6)+'...' : d.name; }); } + appendContent(g) var appendTitle = function (g) { @@ -1444,6 +1446,7 @@ var QDR = (function (QDR) { // 45px between lines and add 10px space after 1st line return "translate(0, "+(45*i+(i>0?10:0))+")" }) + appendCircle(lg) appendContent(lg) appendTitle(lg) @@ -1453,10 +1456,18 @@ var QDR = (function (QDR) { .attr('class', "label") .text(function (d) {return d.key }) lsvg.exit().remove(); - var svgEl = document.getElementById("svglegend"), - bb = svgEl.getBBox(); - svgEl.style.height = (bb.y + bb.height) + 'px'; - svgEl.style.width = (bb.x + bb.width) + 'px'; + var svgEl = document.getElementById('svglegend') + if (svgEl) { + var bb; + // firefox can throw an exception on getBBox on an svg element + try { + bb = svgEl.getBBox(); + } catch (e) { + bb = {y: 0, height: 200, x: 0, width: 200} + } + svgEl.style.height = (bb.y + bb.height) + 'px'; + svgEl.style.width = (bb.x + bb.width) + 'px'; + } if (!mousedown_node || !selected_node) return; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
