Keep track of pan and zoom of layouts in metaUI data (no longer in user preferences).
Change-Id: I4a2c6941d5dd4586b732278c583974e85d9a9321
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2.js b/web/gui/src/main/webapp/app/view/topo2/topo2.js
index 77d0e0c3..775228c 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2.js
@@ -24,7 +24,7 @@
'use strict';
// references to injected services
- var $scope, $log, fs, mast, ks,
+ var $scope, $log, fs, mast, ks, wss,
gs, sus, ps, t2es, t2fs, t2is, t2bcs, t2kcs, t2ms, t2mcs, t2zs;
// DOM elements
@@ -65,15 +65,21 @@
function zoomCallback() {
var sc = zoomer.scale(),
tr = zoomer.translate(),
- sparse = {};
+ metaUi = isNaN(sc) ? {
+ useCfg: 1
+ } : {
+ scale: sc,
+ offsetX: tr[0],
+ offsetY: tr[1]
+ };
- sparse[currentLayoutId] = {
- zoomScale: sc,
- zoomPanX: tr[0],
- zoomPanY: tr[1]
- };
+ // Note: Meta data stored in the context of the current layout,
+ // automatically, by the server
- ps.mergePrefs('topo2_zoom', sparse);
+ wss.sendEvent('updateMeta2', {
+ id: 'layoutZoom',
+ memento: metaUi
+ });
}
function setUpZoom() {
@@ -128,6 +134,7 @@
fs = _fs_;
mast = _mast_;
ks = _ks_;
+ wss = _wss_;
gs = _gs_;
sus = _sus_;
ps = _ps_;
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Background.js b/web/gui/src/main/webapp/app/view/topo2/topo2Background.js
index 8fa9822..29c6a93 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Background.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Background.js
@@ -25,6 +25,24 @@
var instance;
+ function getZoom(z) {
+ var u = z.usr,
+ c = z.cfg;
+ return (u && !u.useCfg) ? u : c;
+ }
+
+ // returns the pan (offset) values as an array [x, y]
+ function zoomPan(z) {
+ var zoom = getZoom(z);
+ return [zoom.offsetX, zoom.offsetY];
+ }
+
+ // returns the scale value
+ function zoomScale(z) {
+ var zoom = getZoom(z);
+ return zoom.scale;
+ }
+
angular.module('ovTopo2')
.factory('Topo2BackgroundService', [
'$log', 'Topo2ViewController', 'Topo2SpriteLayerService', 'Topo2MapService',
@@ -49,9 +67,10 @@
this.background = data;
this.bgType = data.bgType;
+ this.zoomData = data.bgZoom;
var _this = this,
- pan = [this.background.bgZoomPanX, this.background.bgZoomPanY];
+ pan = zoomPan(this.zoomData);
if (this.bgType === 'geo') {
@@ -59,16 +78,12 @@
t2sls.hide();
t2ms.show();
- t2ms.setUpMap(data.bgId, data.bgFilePath, data.bgZoomScale)
+ t2ms.setUpMap(data.bgId, data.bgFilePath, zoomScale(data.bgZoom))
.then(function (proj) {
- // var z = ps.getPrefs('topo2_zoom', { tx: 0, ty: 0, sc: 1 });
- // zoomer.panZoom([z.tx, z.ty], z.sc);
-
t2mcs.projection(proj);
- // $log.debug('** Zoom restored:', z);
$log.debug('** We installed the projection:', proj);
_this.region.loaded('bgRendered', true);
- t2zs.panAndZoom(pan, _this.background.bgZoomScale, 1000);
+ t2zs.panAndZoom(pan, zoomScale(_this.zoomData), 1000);
});
} else if (this.bgType === 'grid') {
@@ -79,7 +94,7 @@
t2sls.loadLayout(data.bgId).then(function (spriteLayout) {
_this.background.layout = spriteLayout;
_this.region.loaded('bgRendered', true);
- t2zs.panAndZoom(pan, _this.background.bgZoomScale, 1000);
+ t2zs.panAndZoom(pan, zoomScale(_this.zoomData), 1000);
});
} else {
// No background type - Tell the region the background is ready for placing nodes
@@ -98,7 +113,7 @@
});
- return instance || new BackgroundView();;
+ return instance || new BackgroundView();
}
]);
})();
\ No newline at end of file