Skip to content
Permalink
Browse files

Merge pull request #4716 from dannon/workflow_list_messaging

[17.09] Add message (error and info) display to workflows display list.
  • Loading branch information...
guerler committed Sep 27, 2017
2 parents d41f4ce + 958d917 commit 407da92f88ac859d3f9b259be83640516159fe15
@@ -176,14 +176,13 @@ window.app = function app( options, bootstrapped ){
_loadWorkflow: function() {
var self = this;
Utils.get({
url: Galaxy.root + 'api/workflows/' + Utils.getQueryString( 'id' ) + '/download',
data: { 'style': 'run' },
url: Galaxy.root + 'api/workflows/' + Utils.getQueryString( 'id' ) + '/download?style=run',
success: function( response ) {
self.page.display( new ToolFormComposite.View( response ) );
},
error: function( response ) {
var error_msg = "Error occurred while loading the resource.",
options = { 'message': error_msg, 'status': 'error', 'persistent': true, 'cls': 'errormessage' };
var error_msg = response.err_msg || 'Error occurred while loading the resource.';
var options = { 'message': error_msg, 'status': 'danger', 'persistent': true };
self.page.display( new Ui.Message( options ) );
}
});
@@ -1,5 +1,5 @@
/** Workflow view */
define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function( mod_toastr, TAGS, WORKFLOWS ) {
define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model", "utils/query-string-parsing" ], function( mod_toastr, TAGS, WORKFLOWS, QueryStringParsing ) {

/** View of the individual workflows */
var WorkflowItemView = Backbone.View.extend({
@@ -31,32 +31,32 @@ define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function(

removeWorkflow: function(){
var wfName = this.model.get('name');
if (confirm( "Are you sure you want to delete workflow '" + wfName + "'?" )) {
if (window.confirm( "Are you sure you want to delete workflow '" + wfName + "'?" )) {
this.model.destroy({
success: function() {
mod_toastr.success("Successfully deleted workflow '" + wfName + "'");
}
});
this.remove();
};
}
},

renameWorkflow: function(){
var oldName = this.model.get('name');
var newName = prompt("Enter a new Name for workflow '" + oldName + "'", oldName );
var newName = window.prompt("Enter a new Name for workflow '" + oldName + "'", oldName );
if (newName) {
this.model.save(
{ 'name': newName },
{ success: function() {
mod_toastr.success("Successfully renamed workflow '" + oldName + "' to '" + newName + "'")
mod_toastr.success("Successfully renamed workflow '" + oldName + "' to '" + newName + "'");
}
});
this.render();
}
},

copyWorkflow: function(){
self = this;
var self = this;
var oldName = this.model.get('name');
$.getJSON(this.model.urlRoot + '/' + this.model.id + '/download', function(wfJson) {
var newName = 'Copy of ' + oldName;
@@ -68,7 +68,7 @@ define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function(
self.collection.create(wfJson, { at: 0,
wait: true,
success: function() {
mod_toastr.success("Successfully copied workflow '" + oldName + "' to '" + newName + "'")
mod_toastr.success("Successfully copied workflow '" + oldName + "' to '" + newName + "'");
},
error : function(model, resp, options) {
// signature seems to have changed over the course of backbone dev
@@ -78,7 +78,7 @@ define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function(
});
}).error(function(jqXHR, textStatus, errorThrown) {
mod_toastr.error(jqXHR.responseJSON.err_msg);
})
});
},

_rowTemplate: function() {
@@ -126,7 +126,7 @@ define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function(
}
else {
return '<ul class="dropdown-menu action-dpd">' +
'<li><a href="'+ Galaxy.root +'workflow/display_by_username_and_slug?username='+ workflow.owner +'&slug='+ workflow.slug +'">View</a></li>' +
'<li><a href="'+ Galaxy.root +'workflow/display_by_username_and_slug?username='+ this.model.get("owner") +'&slug='+ this.model.get("slug") +'">View</a></li>' +
'<li><a href="'+ Galaxy.root +'workflow/run?id='+ this.model.id +'">Run</a></li>' +
'<li><a id="copy-workflow" style="cursor: pointer;">Copy</a></li>' +
'<li><a class="link-confirm-shared-'+ this.model.id +'" href="'+ Galaxy.root +'workflow/sharing?unshare_me=True&id='+ this.model.id +'">Remove</a></li>' +
@@ -140,7 +140,7 @@ define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function(
title: "Workflows",
initialize: function() {
this.setElement( '<div/>' );
_.bindAll(this, 'adjustActiondropdown')
_.bindAll(this, 'adjustActiondropdown');
this.collection = new WORKFLOWS.WorkflowCollection();
this.collection.fetch().done(this.render());
this.collection.bind('add', this.appendItem);
@@ -177,8 +177,9 @@ define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function(
var self = this;
var reader = new FileReader();
reader.onload = function(theFile) {
var wf_json;
try {
var wf_json = JSON.parse(reader.result);
wf_json = JSON.parse(reader.result);
} catch(e) {
mod_toastr.error("Could not read file '" + f.name + "'. Verify it is a valid Galaxy workflow");
wf_json = null;
@@ -188,7 +189,7 @@ define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function(
at: 0,
wait: true,
success: function() {
mod_toastr.success("Successfully imported workflow '" + wf_json.name + "'")
mod_toastr.success("Successfully imported workflow '" + wf_json.name + "'");
},
error : function(model, resp, options) {
mod_toastr.error(options.errorThrown);
@@ -199,6 +200,17 @@ define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function(
reader.readAsText(f, 'utf-8');
},

_showArgErrors: _.once(function(){
// Parse args out of params, display if there's a message.
var msg_text = QueryStringParsing.get('message');
var msg_status = QueryStringParsing.get('status');
if (msg_status === "error"){
mod_toastr.error(_.escape(msg_text || "Unknown Error, please report this to an administrator."));
} else if (msg_text){
mod_toastr.info(_.escape(msg_text));
}
}),

render: function() {
// Add workflow header
var header = this._templateHeader();
@@ -214,6 +226,7 @@ define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function(
var minQueryLength = 3;
this.searchWorkflow( this.$( '.search-wf' ), this.$( '.workflow-search tr' ), minQueryLength );
this.adjustActiondropdown();
this._showArgErrors();
return this;
},

@@ -230,7 +243,7 @@ define( [ "libs/toastr", "mvc/tag", "mvc/workflow/workflow-model" ], function(
confirmDelete: function( workflow ) {
var $el_shared_wf_link = this.$( '.link-confirm-shared-' + workflow.id );
$el_shared_wf_link.click( function() {
return confirm( "Are you sure you want to remove the shared workflow '" + workflow.attributes.name + "'?" );
return window.confirm( "Are you sure you want to remove the shared workflow '" + workflow.attributes.name + "'?" );
});
},

0 comments on commit 407da92

Please sign in to comment.
You can’t perform that action at this time.