Example #1
0
    success : function(result)
    {
      model = result;
      bookmarker = bookmark_manager.create(model.project, model._id);
      input_columns = model["artifact:input-columns"];
      output_columns = model["artifact:output-columns"];
      image_columns = model["artifact:image-columns"];
      rating_columns = model["artifact:rating-columns"] == undefined ? [] : model["artifact:rating-columns"];
      category_columns = model["artifact:category-columns"] == undefined ? [] : model["artifact:category-columns"];
      default_image = model["artifact:default-image"];

      if (default_image === null || default_image === undefined)
        default_image = 0;

      model_loaded();
    },
Example #2
0
      success : function(result)
      {
        model = result;
        bookmarker = bookmark_manager.create(model.project, model._id);

        input_columns = model["artifact:input-columns"];
        output_columns = model["artifact:output-columns"];
        image_columns = model["artifact:image-columns"];
        rating_columns = model["artifact:rating-columns"] == undefined ? [] : model["artifact:rating-columns"];
        category_columns = model["artifact:category-columns"] == undefined ? [] : model["artifact:category-columns"];
        filter_manager = new FilterManager(model_id, bookmarker, layout, input_columns, output_columns, image_columns, rating_columns, category_columns);
        if(filter_manager.active_filters_ready())
        {
          active_filters_ready();
        }
        else
        {
          filter_manager.active_filters_ready.subscribe(function(newValue) {
            if(newValue)
            {
              active_filters_ready();
              // Terminating subscription
              this.dispose();
            }
          });
        }
        if(model["state"] === "waiting" || model["state"] === "running") {
          setTimeout(doPoll, 5000);
          return;
        }
        if(model["state"] === "closed" && model["result"] === null)
          return;
        if(model["result"] === "failed")
          return;
        $('.slycat-navbar-alert').remove();
        model_loaded();
      },
Example #3
0
  component.finish = function() {
    var input_columns = [];
    var output_columns = [];
    var rating_columns = [];
    var category_columns = [];
    var image_columns = [];
    for(var i = 0; i != component.attributes().length; ++i) {
      if(component.attributes()[i].Classification() == 'Input')
        input_columns.push(i);
      if(component.attributes()[i].Classification() == 'Output')
        output_columns.push(i);
      if(component.attributes()[i].Categorical())
        category_columns.push(i);
      if(component.attributes()[i].Editable())
        rating_columns.push(i);
      if(component.attributes()[i].image())
        image_columns.push(i);
    }

    //dialog.ajax_error("Did you choose the correct file and filetype?  There was a problem parsing the file: ")();
    bookmark_manager;
    var bookmarker = bookmark_manager.create(params.projects()[0]._id(), component._id);
    bookmarker.getState(function(state){
      // Check if there are filters in the bookmark
      var filters = state.allFilters;
      if(filters != undefined)
      {
        // Iterate over all filters and find ones that no longer match their bookmarked categorical/numeric type
        var switchedVariables = [];
        var switchedVariableNames = [];
        for(var i=0; i < filters.length; i++)
        {
          var filter = filters[i];
          var switchedToCategorical = category_columns.indexOf(filter.index) > -1 && filter.type == 'numeric';
          var switchedToNumeric = category_columns.indexOf(filter.index) == -1 && filter.type == 'category';
          if(switchedToCategorical || switchedToNumeric)
          {
            switchedVariables.push(i);
            switchedVariableNames.push(filter.name);
          }
        }
        if(switchedVariables.length)
        {
          // Alert user
          var message = "You made changes to the Categorial attribute of the following variables: ";
          message += switchedVariableNames.join(", ");
          message +=  ". If you continue, filters for these variables will be reset. Do you want to continue?";
          dialog.confirm({
            title: "Reset Filters?",
            message: message,
            ok: function()
            {
              save_new_parameters();
            }
          });
        }
        else
        {
          save_new_parameters();
        }
      }
      else
      {
        save_new_parameters();
      }

      function save_new_parameters(){
        client.put_model_parameter({
          mid: component._id,
          aid: "input-columns",
          value: input_columns,
          input: true,
          success: function() {
            client.put_model_parameter({
              mid: component._id,
              aid: "output-columns",
              value: output_columns,
              input: true,
              success: function() {
                client.put_model_parameter({
                  mid: component._id,
                  aid: "rating-columns",
                  value: rating_columns,
                  input: true,
                  success: function() {
                    client.put_model_parameter({
                      mid: component._id,
                      aid: "category-columns",
                      value: category_columns,
                      input: true,
                      success: function() {
                        client.put_model_parameter({
                          mid: component._id,
                          aid: "image-columns",
                          value: image_columns,
                          input: true,
                          success: function() {
                            document.location.reload(true);
                          }
                        });
                      }
                    });
                  }
                });
              }
            });
          }
        });
      }

    });
  };