Refresh ui-node

@dceejay,
Very clever that you have thought about that!!!!!!!!!!

Indeed the last message is stored (in the replayMessages array) and send to any dashboard that needs initial state (e.g. refresh existing dashboard or open new dashboard). So for our Contextmenu-node that is very unwanted behaviour.

Did a quick test: when second dashboard is refreshed, it will get the last contextmenu of the previous dashboard. Here is a demo with two dashboards for interested readers:

Your suggestion is indeed very simple to implement, and it seems to work (both for refreshing a dasbhoard and in combination with a second dashboard). Thanks a lot for helping us with this!!!

Here it is, in case anybody ever needs it:

$scope.init = function (config) {
   // Ignore all input messages that arrive within 1 second after creation of this widget.
   // This way we can avoid the last old message being resend from server to the client...
   $scope.acceptMessages = false;
   setTimeout(function() { 
      $scope.acceptMessages = true; 
   } , 1000);
}

$scope.$watch('msg', function(msg) {
   // Ignore undefined messages.
   if (!msg) {
      return;
   }
                    
   if (!$scope.acceptMessages) {
      return;
   }

   // Process the input message ...

Only the time interval of 1 second is a bit of a trial-and-error:

  • If I use a larger interval, then I don't get a context menu when I immediately click on a shape.
  • If I use a smaller interval, then the old messages might be replayed.

So in my case 1 second works fine. But I could image that this isn't the case in some other setups, e.g. due to a slow internet connection? And adding an extra input field to our config screen (to make the time adjustable by the user) might confuse users, since it is a rather technical issue ...

1 Like