Files
galaxy/static/scripts/mvc/workflow/workflow.js
T

3 lines
9.3 KiB
JavaScript

define("mvc/workflow/workflow",["exports","libs/toastr","mvc/tag","mvc/workflow/workflow-model","utils/query-string-parsing","utils/localization","ui/loading-indicator"],function(o,e,t,r,l,i,a){"use strict";function n(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(o,"__esModule",{value:!0});var s=function(o){if(o&&o.__esModule)return o;var e={};if(null!=o)for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t]);return e.default=o,e}(e),d=n(t),c=n(r),w=n(l),f=n(i),u=n(a),h=Backbone.View.extend({tagName:"tr",initialize:function(){_.bindAll(this,"render","_rowTemplate","renderTagEditor","_templateActions","removeWorkflow","copyWorkflow"),s.options.timeOut=1500},events:{"click #show-in-tool-panel":"showInToolPanel","click #delete-workflow":"removeWorkflow","click #rename-workflow":"renameWorkflow","click #copy-workflow":"copyWorkflow"},render:function(){return $(this.el).html(this._rowTemplate()),this},showInToolPanel:function(){this.model.save({show_in_tool_panel:!this.model.get("show_in_tool_panel")},{success:function(){window.location=Galaxy.root+"workflows/list"}})},removeWorkflow:function(){var o=this.model.get("name");window.confirm("Are you sure you want to delete workflow '"+o+"'?")&&(this.model.destroy({success:function(){s.success("Successfully deleted workflow '"+o+"'")}}),this.remove())},renameWorkflow:function(){var o=this.model.get("name"),e=window.prompt("Enter a new Name for workflow '"+o+"'",o);e&&(this.model.save({name:e},{success:function(){s.success("Successfully renamed workflow '"+o+"' to '"+e+"'")}}),this.render())},copyWorkflow:function(){var o=this,e=this.model.get("name");$.getJSON(this.model.urlRoot+"/"+this.model.id+"/download",function(t){var r="Copy of "+e,l=o.model.get("owner");l!=Galaxy.user.attributes.username&&(r+=" shared by user "+l),t.name=r,o.collection.create(t,{at:0,wait:!0,success:function(){s.success("Successfully copied workflow '"+e+"' to '"+r+"'")},error:function(o,e,t){s.error(t.errorThrown)}})}).error(function(o,e,t){s.error(o.responseJSON.err_msg)})},_rowTemplate:function(){var o=this.model.get("show_in_tool_panel"),e=this.model.id,t='<input id="show-in-tool-panel" type="checkbox" class="show-in-tool-panel" '+(o?'checked="'+o+'"':"")+' value="'+e+'">';return'<td><div class="dropdown"><button class="menubutton" type="button" data-toggle="dropdown">'+_.escape(this.model.get("name"))+'<span class="caret"></span></button>'+this._templateActions()+'</div></td><td><span><div class="'+e+' tags-display"></div></td><td>'+(this.model.get("owner")===Galaxy.user.attributes.username?"You":this.model.get("owner"))+"</span></td><td>"+this.model.get("number_of_steps")+"</td><td>"+(this.model.get("published")?"Yes":"No")+"</td><td>"+t+"</td>"},renderTagEditor:function(){var o=new d.default.TagsEditor({model:this.model,el:$.find("."+this.model.id+".tags-display"),workflow_mode:!0});o.toggle(!0),o.render()},_templateActions:function(){return this.model.get("owner")===Galaxy.user.attributes.username?'<ul class="dropdown-menu action-dpd"><li><a href="'+Galaxy.root+"workflow/editor?id="+this.model.id+'">Edit</a></li><li><a href="'+Galaxy.root+"workflows/run?id="+this.model.id+'">Run</a></li><li><a href="'+Galaxy.root+"workflow/sharing?id="+this.model.id+'">Share</a></li><li><a href="'+Galaxy.root+"api/workflows/"+this.model.id+'/download?format=json-download">Download</a></li><li><a id="copy-workflow" style="cursor: pointer;">Copy</a></li><li><a id="rename-workflow" style="cursor: pointer;">Rename</a></li><li><a href="'+Galaxy.root+"workflow/display_by_id?id="+this.model.id+'">View</a></li><li><a id="delete-workflow" style="cursor: pointer;">Delete</a></li></ul>':'<ul class="dropdown-menu action-dpd"><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+"workflows/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></ul>'}}),m=Backbone.View.extend({title:(0,f.default)("Workflows"),initialize:function(){u.default.markViewAsLoading(this),_.bindAll(this,"adjustActiondropdown"),this.collection=new c.default.WorkflowCollection,this.collection.fetch().done(this.render()),this.collection.bind("add",this.appendItem),this.collection.on("sync",this.render,this)},events:{dragleave:"unhighlightDropZone",drop:"drop",dragover:function(o){$(".hidden_description_layer").addClass("dragover"),$(".menubutton").addClass("background-none"),o.preventDefault()}},unhighlightDropZone:function(){$(".hidden_description_layer").removeClass("dragover"),$(".menubutton").removeClass("background-none")},drop:function(o){this.unhighlightDropZone(),o.preventDefault();for(var e,t=o.dataTransfer.files,r=0;e=t[r];r++)this.readWorkflowFiles(e)},readWorkflowFiles:function(o){var e=this,t=new FileReader;t.onload=function(r){var l=void 0;try{l=JSON.parse(t.result)}catch(e){s.error("Could not read file '"+o.name+"'. Verify it is a valid Galaxy workflow"),l=null}l&&e.collection.create(l,{at:0,wait:!0,success:function(){s.success("Successfully imported workflow '"+l.name+"'")},error:function(o,e,t){s.error(t.errorThrown)}})},t.readAsText(o,"utf-8")},_showArgErrors:_.once(function(){var o=w.default.get("message");"error"===w.default.get("status")?s.error(_.escape(o||"Unknown Error, please report this to an administrator.")):o&&s.info(_.escape(o))}),render:function(){var o=this,e=this._templateHeader(),t=this._templateActionButtons(),r=this._templateWorkflowTable();this.$el.html(e+t+r),_(this.collection.models).each(function(e){o.appendItem(e),o.confirmDelete(e)},this);return this.searchWorkflow(this.$(".search-wf"),this.$(".workflow-search tr"),3),this.adjustActiondropdown(),this._showArgErrors(),this},appendItem:function(o){var e=new h({model:o,collection:this.collection});$(".workflow-search").append(e.render().el),e.renderTagEditor()},confirmDelete:function(o){this.$(".link-confirm-shared-"+o.id).click(function(){return window.confirm("Are you sure you want to remove the shared workflow '"+o.attributes.name+"'?")})},searchWorkflow:function(o,e,t){o.on("keyup",function(){var o=$(this).val();if(o.length>=t){var r=new RegExp(o,"i");e.hide(),e.filter(function(){return r.test($(this).text())}).show()}else e.show()})},adjustActiondropdown:function(){$(this.el).on("show.bs.dropdown",function(){$(this.el).css("overflow","inherit")}),$(this.el).on("hide.bs.dropdown",function(){$(this.el).css("overflow","auto")})},_templateNoWorkflow:function(){return'<div class="wf-nodata"> You have no workflows. </div>'},_templateActionButtons:function(){return'<ul class="manage-table-actions"><li><input class="search-wf form-control" type="text" autocomplete="off" placeholder="search for workflow..."></li><li><a class="action-button fa fa-plus wf-action" id="new-workflow" title="Create new workflow" href="'+Galaxy.root+'workflows/create"></a></li><li><a class="action-button fa fa-upload wf-action" id="import-workflow" title="Upload or import workflow" href="'+Galaxy.root+'workflows/import_workflow"></a></li></ul>'},_templateWorkflowTable:function(){return'<table class="table colored"><thead><tr class="header"><th>Name</th><th>Tags</th><th>Owner</th><th># of Steps</th><th>Published</th><th>Show in tools panel</th></tr></thead><tbody class="workflow-search "><div class="hidden_description_layer"><p>Drop workflow files here to import</p></tbody></table></div>'},_templateHeader:function(){return'<div class="page-container"><div class="user-workflows wf"><div class="response-message"></div><h2>'+(0,f.default)("Your workflows")+"</h2></div></div>"}}),p=Backbone.View.extend({initialize:function(){this.setElement("<div/>"),this.render()},render:function(){var o=this;$.getJSON(Galaxy.root+"workflow/upload_import_workflow",function(e){o.$el.empty().append(o._mainTemplate(e))})},_mainTemplate:function(o){return"<div class='toolForm'><div class='toolFormTitle'>Import Galaxy workflow</div><div class='toolFormBody'><form name='import_workflow' id='import_workflow' action='"+Galaxy.root+"workflow/upload_import_workflow' enctype='multipart/form-data' method='POST'><div class='form-row'><label>Galaxy workflow URL:</label><input type='text' name='url' class='input-url' value='"+o.url+"' size='40'><div class='toolParamHelp' style='clear: both;'>If the workflow is accessible via a URL, enter the URL above and click <b>Import</b>.</div><div style='clear: both'></div></div><div class='form-row'><label>Galaxy workflow file:</label><div class='form-row-input'><input type='file' name='file_data' class='input-file'/></div><div class='toolParamHelp' style='clear: both;'>If the workflow is in a file on your computer, choose it and then click <b>Import</b>.</div><div style='clear: both'></div></div><div class='form-row'><input type='submit' class='primary-button wf-import' name='import_button' value='Import'></div></form><hr/><div class='form-row'><label>Import a Galaxy workflow from myExperiment:</label><div class='form-row-input'><a href='"+o.myexperiment_target_url+"'> Visit myExperiment</a></div><div class='toolParamHelp' style='clear: both;'>Click the link above to visit myExperiment and browse for Galaxy workflows.</div><div style='clear: both'></div></div></div></div>"}});o.default={View:m,ImportWorkflowView:p}});
//# sourceMappingURL=../../../maps/mvc/workflow/workflow.js.map