Merge lp:~makyo/juju-gui/bundle-zoomtofit into lp:juju-gui/experimental
Proposed by
Madison Scott-Clary
Status: | Merged |
---|---|
Merged at revision: | 1152 |
Proposed branch: | lp:~makyo/juju-gui/bundle-zoomtofit |
Merge into: | lp:juju-gui/experimental |
Diff against target: |
115 lines (+22/-17) 5 files modified
app/subapps/browser/views/bundle.js (+1/-1) app/views/topology/bundle.js (+11/-10) app/views/topology/topology.js (+5/-0) app/views/topology/utils.js (+3/-4) test/test_bundle_module.js (+2/-2) |
To merge this branch: | bzr merge lp:~makyo/juju-gui/bundle-zoomtofit |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju GUI Hackers | Pending | ||
Review via email:
|
Description of the change
Bundle topo preview fixes
Center bundle topo properly and size SVG to parent container. This incidentally fixes what appeared to be a bug of non-promulgated charms not being displayed (was off the canvas).
To post a comment you must log in.
Reviewers: mp+192363_ code.launchpad. net,
Message:
Please take a look.
Description:
Bundle topo preview fixes
Center bundle topo properly and size SVG to parent container. This
incidentally fixes what appeared to be a bug of non-promulgated charms
not being displayed (was off the canvas).
https:/ /code.launchpad .net/~makyo/ juju-gui/ bundle- zoomtofit/ +merge/ 192363
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/14930052/
Affected files (+15, -17 lines): browser/ views/bundle. js topology/ bundle. js topology/ utils.js bundle_ module. js
A [revision details]
M app/subapps/
M app/views/
M app/views/
M test/test_
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: test/test_ bundle_ module. js bundle_ module. js' bundle_ module. js 2013-10-10 00:05:02 +0000 bundle_ module. js 2013-10-22 10:52:27 +0000
assert. equal(
parseFloat( bundle. topology. get('scale' ), 10).toFixed(2), 'g').attr( 'transform' ); (([\d\. ]+)\)/. exec(scaleAttr) ; equal(parseFloa t(match[ 1]).toFixed( 2), 0.48); equal(parseFloa t(match[ 1]).toFixed( 2), 0.44);
}).then( undefined, done);
=== modified file 'test/test_
--- test/test_
+++ test/test_
@@ -113,11 +113,11 @@
// that we've scaled the canvas as expected. In the model.
- 0.48);
+ 0.44);
// and on the canvas.
var scaleAttr = svg.select(
var match = /scale\
- assert.
+ assert.
done();
});
Index: app/views/ topology/ bundle. js topology/ bundle. js' topology/ bundle. js 2013-10-18 16:47:34 +0000 topology/ bundle. js 2013-10-22 10:20:48 +0000 serviceBoxesToV ertices( topo.service_ boxes); centroid( vertices) ; topology. modules. PanZoomModule. panToPoint( {point: centroid});
=== modified file 'app/views/
--- app/views/
+++ app/views/
@@ -381,6 +381,9 @@
var topo = this.topology;
var vertices = topoUtils.
var centroid = topoUtils.
+ var scale = topo.get('scale');
+ centroid[0] += 96 * scale;
+ centroid[1] += 96 * scale;
this.
};
@@ -394,21 +397,15 @@ ogy.prototype. zoomToFit = function() { serviceBoxesToV ertices( topo.service_ boxes); getBoundingBox( vertices) ; getBoundingBox( vertices, 96, 96);
BundleTopol
var topo = this.topology;
var vertices = topoUtils.
- var bb = topoUtils.
+ var bb = topoUtils.
var width = topo.get('width'),
height = topo.get('height');
// Zoom to Fit
- // We are really only interested in scale down
- // here when the bundle is too large to
- // render in the space provided.
- var maxScale = 1.0;
- if (bb.w > width || bb.h > height) {
- maxScale = Math.min(bb.w / width, bb.h / height);
- maxScale -= 0.05; // Margin
- }
+ var maxScale = Math.min(width / bb.w, height / bb.h);
+ maxScale -= 0.05; // Margin
// Clamp Scale
- maxScale = Math.max(0.25 , Math.min(1...