Select to view content in your preferred language

Geoprocessing Widget help

3021
23
Jump to solution
10-03-2016 08:24 AM
JamesCrandall
MVP Frequent Contributor

Geoprocessing Widget "hangs" if nothing is selected before hitting "Execute" button.

Sorry for cross-post, I'm not getting any response in the other forum https://community.esri.com/thread/183807-gp-widget-hangs

The current implementation is actually working just fine!  However, I am not sure where to look or if it's possible to make an adjustment in the GP widget itself to help alleviate this problem.  If the user doesn't select any features before hitting "Execute" on the widget, it seems to become unresponsive, however it does finally clear itself and returns to normal after a couple of minutes.

This behavior will confuse users who will be very click-happy and exclaim the application is broken.  I am hoping that there is a simple tweak I can apply to the widget itself to account for nothing being selected and perform a quick exit out of process.

This is the standard Geoprocessing widget that acquires a Feature Set (the selection) and uses that as an input parameter.

Tags (1)
0 Kudos
23 Replies
RobertScheitlin__GISP
MVP Emeritus

James,

   You have a dropdown and a draw toolbar?.. When I configure the widget using your service I get the option to choose one or the other.

0 Kudos
JamesCrandall
MVP Frequent Contributor

Yes!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

James,

  Seems how I can not get the same UI you are using this is what I can come up with:

Open the apps Geoprocessing widgets folder and edit the Widget.js. Make this change to the executeGP function (lines 5 - 12):

    executeGP: function(){
      this._clearLastResult();
      html.addClass(this.exeNode, 'jimu-state-disabled');
      this._getInputParamValues().then(lang.hitch(this, function(inputValues){
        if(!inputValues || !inputValues.inFS || !inputValues.inFS.features || inputValues.inFS.features.length === 0){
          var errorMessage = "Some message you want to tell your user";
          new Message({
            message: errorMessage
          });
          html.removeClass(this.exeNode, 'jimu-state-disabled');
          return;
        }
        this._showLoading();

        if(this.config.isSynchronous){
          this.gp.execute(inputValues);
        }else{
          this.gp.submitJob(inputValues);
        }
        this.tab.selectTab(this.nls.output);
      }), lang.hitch(this, function() {
        html.removeClass(this.exeNode, 'jimu-state-disabled');
      }));
    },
JamesCrandall
MVP Frequent Contributor

I will implement that suggestion!

Also: I think if you add a map service to your WAB source web map and make that service layer visible with the Legend Widget, you will then get both the drop-down and the draw/trash can tools to show!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nope tried that.

JamesCrandall
MVP Frequent Contributor

Thanks again Robert!

I'm still experiencing the unresponsiveness of the widget as described.  Do you think there is some other condition that's not included in your suggestion that isn't causing it to be invoked?

if (!inputValues || !inputValues.inFS || !inputValues.inFS.features || inputValues.inFS.features.length === 0)

I'll dabble as well even though I'm not fully involved in this level of dev, I can make some additional attempts with the suggestion you provided.  Greatly appreciate it!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

James,

  It is hard to say without being able to exactly reproduce your GP widgets UI. Is the GP service url you sent missing some input parameter requirement that yours uses? I need to be able to reproduce your widget UI as the code I provided is working fine for preventing un-reponsiveness on my end with the service url you provided.

JamesCrandall
MVP Frequent Contributor

Hi Robert -- that test GP service I sent you has the same input/output params as the real one I have pointing to the app.  It's very simple: an input FeatureSet and an output string.  I even reset the widget in my test WAB to point to the same service I send you and I get the same behavior.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

James,

   OK, I see the issue now. I had to select a point layer from the map then I get the rectangle draw tool. If you do not select any points on the map then the whole layer is sent as the input. So it looks like I need to find a way to verify that there is a selection on the chosen layer from the drop down. I'll get back to on this.

RobertScheitlin__GISP
MVP Emeritus

James,

    here is the solution:

Geoprocessing\editors\SelectFeatureSetFromLayer.js (comment out lines 8 - 19 and add 20):

    getGPValue: function(){
      var def = new Deferred();

      this.spatialFilterByFeatures.getFeatureSet(true).then(lang.hitch(this, function(featureSet){
        def.resolve(featureSet);
      }), lang.hitch(this, function(err){
        if(err && err.type === SpatialFilterByFeatures.NONE_SELECTED_FEATURES_NOT_DRAW_SHAPES){
          // var layer = this.spatialFilterByFeatures.getSelectedLayer();
          // if(layer && layer.url){
          //   var query = new Query();
          //   query.where = '1=1';
          //   layer.queryFeatures(query).then(lang.hitch(this, function(response){
          //     def.resolve(response);
          //   }), lang.hitch(this, function(error){
          //     def.reject(error);
          //   }));
          // }else{
          //   def.reject(err);
          // }
          def.resolve(null);
        }else{
          def.reject(err);
        }
      }));

      return def;
    };‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍