This is an automated email from the ASF dual-hosted git repository.

eallen pushed a commit to branch eallen-DISPATCH-1385
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/eallen-DISPATCH-1385 by this 
push:
     new c8040be  Added background map
c8040be is described below

commit c8040beacd1795330942420a9b383d83209d4a11
Author: Ernest Allen <[email protected]>
AuthorDate: Mon Sep 23 19:02:16 2019 -0400

    Added background map
---
 console/react/package.json                |  1 +
 console/react/src/topology/map.js         | 16 +++++++++----
 console/react/src/topology/qdrTopology.js | 39 +++++++++++++++++++++----------
 console/react/yarn.lock                   | 17 ++++++++++----
 4 files changed, 51 insertions(+), 22 deletions(-)

diff --git a/console/react/package.json b/console/react/package.json
index 434e2da..52deca4 100644
--- a/console/react/package.json
+++ b/console/react/package.json
@@ -23,6 +23,7 @@
     "react-scripts": "3.0.1",
     "redux": "^4.0.1",
     "rhea": "^1.0.8",
+    "topojson-client": "^3.0.1",
     "typescript": "^3.5.2"
   },
   "scripts": {
diff --git a/console/react/src/topology/map.js 
b/console/react/src/topology/map.js
index 2fd498b..91942ed 100644
--- a/console/react/src/topology/map.js
+++ b/console/react/src/topology/map.js
@@ -17,7 +17,9 @@ specific language governing permissions and limitations
 under the License.
 */
 
-/* global angular d3 topojson Promise */
+import * as d3 from "d3";
+import * as topojson from "topojson-client";
+
 const maxnorth = 84;
 const maxsouth = 60;
 const MAPOPTIONSKEY = "QDRMapOptions";
@@ -31,10 +33,14 @@ export class BackgroundMap {
     this.$scope = $scope;
     this.initialized = false;
     this.notify = notifyFn;
-    $scope.mapOptions = angular.fromJson(localStorage[MAPOPTIONSKEY]) || {
-      areaColor: defaultLandColor,
-      oceanColor: defaultOceanColor
-    };
+
+    let savedOptions = localStorage.getItem(MAPOPTIONSKEY);
+    this.mapOptions = savedOptions
+      ? JSON.parse(savedOptions)
+      : {
+          areaColor: defaultLandColor,
+          oceanColor: defaultOceanColor
+        };
     this.last = {
       translate: [0, 0],
       scale: null
diff --git a/console/react/src/topology/qdrTopology.js 
b/console/react/src/topology/qdrTopology.js
index 13542a0..15b1b3a 100644
--- a/console/react/src/topology/qdrTopology.js
+++ b/console/react/src/topology/qdrTopology.js
@@ -94,6 +94,21 @@ class TopologyPage extends Component {
       this.forceData,
       ["dots", "congestion"].filter(t => this.state.legendOptions.traffic[t])
     );
+    this.backgroundMap = new BackgroundMap(this, () => {});
+    this.backgroundMap = new BackgroundMap(
+      this,
+      // notify: called each time a pan/zoom is performed
+      () => {
+        if (this.legendOptions.map.open) {
+          // set all the nodes' x,y position based on their saved lon,lat
+          this.forceData.nodes.setXY(this.backgroundMap);
+          this.forceData.nodes.savePositions();
+          // redraw the nodes in their x,y position and let non-fixed nodes 
bungie
+          this.force.start();
+          this.clearPopups();
+        }
+      }
+    );
   }
 
   // called only once when the component is initialized
@@ -133,13 +148,13 @@ class TopologyPage extends Component {
         .attr("width", this.width)
         .attr("height", this.height)
         .on("click", this.clearPopups);
-      /*
-        // read the map data from the data file and build the map layer
-      backgroundMap.init($scope, svg, width, height).then(function() {
-        forceData.nodes.saveLonLat(backgroundMap);
-        backgroundMap.setMapOpacity($scope.legendOptions.map.open);
-      });
-      */
+      // read the map data from the data file and build the map layer
+      this.backgroundMap
+        .init(this, this.svg, this.width, this.height)
+        .then(() => {
+          this.forceData.nodes.saveLonLat(this.backgroundMap);
+          this.backgroundMap.setMapOpacity(this.legendOptions.map.open);
+        });
       addDefs(this.svg);
       addGradient(this.svg);
     }
@@ -211,7 +226,7 @@ class TopologyPage extends Component {
       .on("tick", this.tick)
       .on("end", () => {
         this.forceData.nodes.savePositions();
-        //this.forceData.nodes.saveLonLat(backgroundMap);
+        this.forceData.nodes.saveLonLat(this.backgroundMap);
       })
       .start();
     for (let i = 0; i < this.forceData.nodes.nodes.length; i++) {
@@ -313,7 +328,7 @@ class TopologyPage extends Component {
           .nodes(this.forceData.nodes.nodes)
           .links(this.forceData.links.links)
           .start();
-        //this.forceData.nodes.saveLonLat(backgroundMap);
+        this.forceData.nodes.saveLonLat(this.backgroundMap);
         this.restart();
         this.updateLegend();
       }
@@ -546,7 +561,7 @@ class TopologyPage extends Component {
       })
       .on("mousedown", d => {
         // mouse down for circle
-        //backgroundMap.cancelZoom();
+        this.backgroundMap.cancelZoom();
         this.current_node = d;
         if (d3.event.button !== 0) {
           // ignore all but left button
@@ -560,7 +575,7 @@ class TopologyPage extends Component {
       })
       .on("mouseup", function(d) {
         // mouse up for circle
-        //backgroundMap.restartZoom();
+        this.backgroundMap.restartZoom();
         if (!self.mousedown_node) return;
 
         // unenlarge target node
@@ -577,7 +592,7 @@ class TopologyPage extends Component {
         ) {
           self.forceData.nodes.setFixed(d, true);
           self.forceData.nodes.savePositions();
-          //self.forceData.nodes.saveLonLat(backgroundMap);
+          self.forceData.nodes.saveLonLat(this.backgroundMap);
           self.resetMouseVars();
           self.restart();
           return;
diff --git a/console/react/yarn.lock b/console/react/yarn.lock
index 0f7a249..bfa6cdb 100644
--- a/console/react/yarn.lock
+++ b/console/react/yarn.lock
@@ -3618,16 +3618,16 @@ comma-separated-tokens@^1.0.0:
   resolved 
"https://registry.yarnpkg.com/comma-separated-tokens/-/comma-separated-tokens-1.0.6.tgz#3cd3d8adc725ab473843db338bcdfd4a7bb087bf";
   integrity 
sha512-f20oA7jsrrmERTS70r3tmRSxR8IJV2MTN7qe6hzgX+3ARfXrdMJFvGWvWQK0xpcBurg9j9eO2MiqzZ8Y+/UPCA==
 
+commander@2, commander@^2.11.0, commander@^2.19.0, commander@~2.20.0:
+  version "2.20.0"
+  resolved 
"https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422";
+  integrity 
sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==
+
 [email protected]:
   version "2.17.1"
   resolved 
"https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf";
   integrity 
sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==
 
-commander@^2.11.0, commander@^2.19.0, commander@~2.20.0:
-  version "2.20.0"
-  resolved 
"https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422";
-  integrity 
sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==
-
 commander@~2.19.0:
   version "2.19.0"
   resolved 
"https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a";
@@ -11385,6 +11385,13 @@ [email protected]:
   resolved 
"https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553";
   integrity 
sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
 
+topojson-client@^3.0.1:
+  version "3.0.1"
+  resolved 
"https://registry.yarnpkg.com/topojson-client/-/topojson-client-3.0.1.tgz#774c0343b44fc4ec29c3a2274d7a1a9c3b213cd9";
+  integrity 
sha512-rfGGzyqefpxOaxvV9OTF9t+1g+WhjGEbAIuCcmKYrQkxr0nttjMMyzZsK+NhLW4cTl2g1bz2jQczPUtEshpbVQ==
+  dependencies:
+    commander "2"
+
 touch@^2.0.1:
   version "2.0.2"
   resolved 
"https://registry.yarnpkg.com/touch/-/touch-2.0.2.tgz#ca0b2a3ae3211246a61b16ba9e6cbf1596287164";


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to