Git Product home page Git Product logo

Comments (3)

hatched avatar hatched commented on September 23, 2024

I spent a considerable amount of time on this today, first setting up the necessary modifications to the delta so that the app would know when we receive the 'first' delta for the model (especially important for switching models) After doing that it was impossible to know when necessary elements were actually added to the canvas as they aren't done in the delta calls, or on the 'next' db update. But some time down the line.

I then attempted to panToCenter only when nodes were created but the createServiceNode method is not just called when creating new service nodes, sometimes it'll be called 16+ times simply when dragging a service.

The only 'fix' I could reliably get to work was a setTimeout after processing the 'first' delta but this is fraught with issues, as the 'time to ready' is heavily dependant on the size of the model and connection speeds.

from juju-gui.

hatched avatar hatched commented on September 23, 2024

The modifications I made are included below if anyone wants to take a look with fresh eyes

diff --git a/jujugui/static/gui/src/app/app.js b/jujugui/static/gui/src/app/app.js
index e44e6ea..7ed40d1 100644
--- a/jujugui/static/gui/src/app/app.js
+++ b/jujugui/static/gui/src/app/app.js
@@ -545,7 +545,7 @@ YUI.add('juju-gui', function(Y) {
       }

       // Feed environment changes directly into the database.
-      this.env.on('delta', this.db.onDelta, this.db);
+      this.env.on('delta', this._onDelta, this);

       // Handlers for adding and removing services to the service list.
       this.endpointsController = new juju.EndpointsController({
@@ -662,6 +662,10 @@ YUI.add('juju-gui', function(Y) {
       }, this);
     },

+    _onDelta: function(delta) {
+      this.db.onDelta.call(this.db, delta);
+    },
+
     /**
       Parses the application URL to populate the state object without
       dispatching
diff --git a/jujugui/static/gui/src/app/store/env/go.js b/jujugui/static/gui/src/app/store/env/go.js
index 5342dfb..f28ad2e 100644
--- a/jujugui/static/gui/src/app/store/env/go.js
+++ b/jujugui/static/gui/src/app/store/env/go.js
@@ -277,7 +277,7 @@ YUI.add('juju-env-go', function(Y) {
             console.log('aiiiiie!'); // retry and eventually alert user XXX
           } else {
             this._allWatcherId = data.Response.AllWatcherId;
-            this._next();
+            this._next(true);
           }
         }
       );
@@ -327,7 +327,10 @@ YUI.add('juju-env-go', function(Y) {
         if (b[1] === 'remove') { scoreB = -scoreB; }
         return scoreA - scoreB;
       });
-      this.fire('delta', {data: {result: deltas}});
+      this.fire('delta', {
+        initial: data.initialRequest,
+        data: {result: deltas}
+      });
     },

     /**
@@ -335,9 +338,13 @@ YUI.add('juju-env-go', function(Y) {

       @method _next
       @private
+      @param {Boolean} firstRequest If this is the first call to _next. This
+        is used to flag the response delta as the first response when
+        connecting to an environment so that we can perform actions only on
+        the first delta.
       @return {undefined} Sends a message to the server only.
      */
-    _next: function() {
+    _next: function(firstRequest) {
       this._send_rpc({
         Type: 'AllWatcher',
         Request: 'Next',
@@ -347,6 +354,7 @@ YUI.add('juju-env-go', function(Y) {
         if (data.Error) {
           console.log('aiiiiie!'); // XXX
         } else {
+          data.initialRequest = firstRequest || false;
           this.fire('_rpc_response', data);
         }
       });
diff --git a/jujugui/static/gui/src/app/views/topology/service.js b/jujugui/static/gui/src/app/views/topology/service.js
index 528b7f7..faf1933 100644
--- a/jujugui/static/gui/src/app/views/topology/service.js
+++ b/jujugui/static/gui/src/app/views/topology/service.js
@@ -1634,6 +1634,7 @@ YUI.add('juju-topology-service', function(Y) {
       node.each(function(data) {
         self.attachTouchstartEvents(data, this);
       });
+      self.get('component').fire('panToCenter');
     },

     /*

from juju-gui.

frankban avatar frankban commented on September 23, 2024

This is fixed.

from juju-gui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.