You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ea...@apache.org on 2016/09/09 15:28:46 UTC
qpid-dispatch git commit: DISPATCH-453 - Limit topology svg width to
take into account the legend
Repository: qpid-dispatch
Updated Branches:
refs/heads/master 6e9c24e95 -> d441abbde
DISPATCH-453 - Limit topology svg width to take into account the legend
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/d441abbd
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/d441abbd
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/d441abbd
Branch: refs/heads/master
Commit: d441abbdeaafb8c6b06e0bf18d77111419b975f2
Parents: 6e9c24e
Author: Ernest Allen <ea...@redhat.com>
Authored: Fri Sep 9 11:28:31 2016 -0400
Committer: Ernest Allen <ea...@redhat.com>
Committed: Fri Sep 9 11:28:31 2016 -0400
----------------------------------------------------------------------
console/stand-alone/plugin/js/qdrTopology.js | 47 ++++++++++++++++-------
1 file changed, 34 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d441abbd/console/stand-alone/plugin/js/qdrTopology.js
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/js/qdrTopology.js b/console/stand-alone/plugin/js/qdrTopology.js
index 8c69376..223ebe9 100644
--- a/console/stand-alone/plugin/js/qdrTopology.js
+++ b/console/stand-alone/plugin/js/qdrTopology.js
@@ -462,29 +462,49 @@ var QDR = (function (QDR) {
});
// set up SVG for D3
- var width, height;
- var tpdiv = $('#topology');
var colors = {'inter-router': "#EAEAEA", 'normal': "#F0F000", 'on-demand': '#00F000'};
- var gap = 5;
var radii = {'inter-router': 25, 'normal': 15, 'on-demand': 15};
var radius = 25;
var radiusNormal = 15;
- width = tpdiv.width() - gap;
- var top = tpdiv.offset().top
- var tpform = $('#topologyForm')
- var tpformHeight = tpform.height()
- height = Math.max(window.innerHeight, tpformHeight + top) - top - gap;
- if (width < 10) {
- QDR.log.info("page width and height are abynormal: returning before very bad things happen")
- return;
- }
-
var svg, lsvg;
var force;
var animate = false; // should the force graph organize itself when it is displayed
var path, circle;
var savedKeys = {};
var dblckickPos = [0,0];
+ var width = 0;
+ var height = 0;
+
+ var getSizes = function () {
+ var legendWidth = 196;
+ var gap = 5;
+ var width = $('#topology').width() - gap - legendWidth;
+ var top = $('#topology').offset().top
+ var tpformHeight = $('#topologyForm').height()
+ var height = Math.max(window.innerHeight, tpformHeight + top) - top - gap;
+ if (width < 10) {
+ QDR.log.info("page width and height are abnormal w:" + width + " height:" + height)
+ return [0,0];
+ }
+ return [width, height]
+ }
+ var resize = function () {
+ var sizes = getSizes();
+ width = sizes[0]
+ height = sizes[1]
+ if (width > 0) {
+ // set attrs and 'resume' force
+ svg.attr('width', width);
+ svg.attr('height', height);
+ force.size(sizes).resume();
+ }
+ }
+ window.addEventListener('resize', resize);
+ var sizes = getSizes()
+ width = sizes[0]
+ height = sizes[1]
+ if (width <= 0 || height <= 0)
+ return
// set up initial nodes and links
// - nodes are known by 'id', not by index in array.
@@ -1715,6 +1735,7 @@ var QDR = (function (QDR) {
QDRService.stopUpdating();
QDRService.delUpdatedAction("topology");
d3.select("#SVG_ID").remove();
+ window.removeEventListener('resize', resize);
});
initForceGraph();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org