commit/galaxy-central: carlfeberhard: UI: move base-mvc, annotation and tag editors, user model and quotameter to AMD; fix loading order and currUser in masthead, view, history; remove loggable mixin from scatterplot
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7155334f5ec5/ Changeset: 7155334f5ec5 User: carlfeberhard Date: 2014-03-20 21:52:06 Summary: UI: move base-mvc, annotation and tag editors, user model and quotameter to AMD; fix loading order and currUser in masthead, view, history; remove loggable mixin from scatterplot Affected #: 33 files diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 config/plugins/visualizations/scatterplot/src/scatterplot-config-editor.js --- a/config/plugins/visualizations/scatterplot/src/scatterplot-config-editor.js +++ b/config/plugins/visualizations/scatterplot/src/scatterplot-config-editor.js @@ -29,7 +29,7 @@ * configuring which data will be used * configuring the plot display */ -var ScatterplotConfigEditor = Backbone.View.extend( LoggableMixin ).extend({ +var ScatterplotConfigEditor = Backbone.View.extend({ //TODO: !should be a view on a visualization model //logger : console, className : 'scatterplot-control-form', @@ -39,13 +39,13 @@ if( !this.model ){ this.model = new Visualization({ type: 'scatterplot' }); } - this.log( this + '.initialize, attributes:', attributes ); + //this.log( this + '.initialize, attributes:', attributes ); if( !attributes || !attributes.dataset ){ throw new Error( "ScatterplotConfigEditor requires a dataset" ); } this.dataset = attributes.dataset; - this.log( 'dataset:', this.dataset ); + //this.log( 'dataset:', this.dataset ); this.display = new ScatterplotDisplay({ dataset : attributes.dataset, diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 config/plugins/visualizations/scatterplot/static/scatterplot-edit.js --- a/config/plugins/visualizations/scatterplot/static/scatterplot-edit.js +++ b/config/plugins/visualizations/scatterplot/static/scatterplot-edit.js @@ -1,1 +1,1 @@ -function scatterplot(a,b,c){function d(){var a={v:{},h:{}};return a.v.lines=p.selectAll("line.v-grid-line").data(m.x.ticks(q.x.fn.ticks()[0])),a.v.lines.enter().append("svg:line").classed("grid-line v-grid-line",!0),a.v.lines.attr("x1",m.x).attr("x2",m.x).attr("y1",0).attr("y2",b.height),a.v.lines.exit().remove(),a.h.lines=p.selectAll("line.h-grid-line").data(m.y.ticks(q.y.fn.ticks()[0])),a.h.lines.enter().append("svg:line").classed("grid-line h-grid-line",!0),a.h.lines.attr("x1",0).attr("x2",b.width).attr("y1",m.y).attr("y2",m.y),a.h.lines.exit().remove(),a}function e(){return t.attr("cx",function(a,b){return m.x(j(a,b))}).attr("cy",function(a,b){return m.y(k(a,b))}).style("display","block").filter(function(){var a=d3.select(this).attr("cx"),c=d3.select(this).attr("cy");return 0>a||a>b.width?!0:0>c||c>b.height?!0:!1}).style("display","none")}function f(){$(".chart-info-box").remove(),q.redraw(),e(),s=d(),$(o.node()).trigger("zoom.scatterplot",{scale:n.scale(),translate:n.translate()})}function g(a,c,d){return c+=8,$(['<div class="chart-info-box" style="position: absolute">',void 0!==b.idColumn?"<div>"+d[b.idColumn]+"</div>":"","<div>",j(d),"</div>","<div>",k(d),"</div>","</div>"].join("")).css({top:a,left:c,"z-index":2})}var h=function(a,b){return"translate("+a+","+b+")"},i=function(a,b,c){return"rotate("+a+","+b+","+c+")"},j=function(a){return a[b.xColumn]},k=function(a){return a[b.yColumn]},l={x:{extent:d3.extent(c,j)},y:{extent:d3.extent(c,k)}},m={x:d3.scale.linear().domain(l.x.extent).range([0,b.width]),y:d3.scale.linear().domain(l.y.extent).range([b.height,0])},n=d3.behavior.zoom().x(m.x).y(m.y).scaleExtent([1,30]).scale(b.scale||1).translate(b.translate||[0,0]),o=d3.select(a).attr("class","scatterplot").attr("width","100%").attr("height",b.height+(b.margin.top+b.margin.bottom)),p=o.append("g").attr("class","content").attr("transform",h(b.margin.left,b.margin.top)).call(n);p.append("rect").attr("class","zoom-rect").attr("width",b.width).attr("height",b.height).style("fill","transparent");var q={x:{},y:{}};q.x.fn=d3.svg.axis().orient("bottom").scale(m.x).ticks(b.xTicks).tickFormat(d3.format("s")),q.y.fn=d3.svg.axis().orient("left").scale(m.y).ticks(b.yTicks).tickFormat(d3.format("s")),q.x.g=p.append("g").attr("class","x axis").attr("transform",h(0,b.height)).call(q.x.fn),q.y.g=p.append("g").attr("class","y axis").call(q.y.fn);var r=6;q.x.label=o.append("text").attr("id","x-axis-label").attr("class","axis-label").text(b.xLabel).attr("text-anchor","middle").attr("dominant-baseline","text-after-edge").attr("x",b.width/2+b.margin.left).attr("y",b.height+b.margin.bottom+b.margin.top-r),q.y.label=o.append("text").attr("id","y-axis-label").attr("class","axis-label").text(b.yLabel).attr("text-anchor","middle").attr("dominant-baseline","text-before-edge").attr("x",r).attr("y",b.height/2).attr("transform",i(-90,r,b.height/2)),q.redraw=function(){o.select(".x.axis").call(q.x.fn),o.select(".y.axis").call(q.y.fn)};var s=d(),t=p.selectAll(".glyph").data(c).enter().append("svg:circle").classed("glyph",!0).attr("cx",function(a,b){return m.x(j(a,b))}).attr("cy",function(a,b){return m.y(k(a,b))}).attr("r",0);t.transition().duration(b.animDuration).attr("r",b.datapointSize),e(),n.on("zoom",f),t.on("mouseover",function(a,c){var d=d3.select(this);d.classed("highlight",!0).style("fill","red").style("fill-opacity",1),p.append("line").attr("stroke","red").attr("stroke-width",1).attr("x1",d.attr("cx")-b.datapointSize).attr("y1",d.attr("cy")).attr("x2",0).attr("y2",d.attr("cy")).classed("hoverline",!0),d.attr("cy")<b.height&&p.append("line").attr("stroke","red").attr("stroke-width",1).attr("x1",d.attr("cx")).attr("y1",+d.attr("cy")+b.datapointSize).attr("x2",d.attr("cx")).attr("y2",b.height).classed("hoverline",!0);var e=this.getBoundingClientRect();$("body").append(g(e.top,e.right,a)),$(o.node()).trigger("mouseover-datapoint.scatterplot",[this,a,c])}),t.on("mouseout",function(){d3.select(this).classed("highlight",!1).style("fill","black").style("fill-opacity",.2),p.selectAll(".hoverline").remove(),$(".chart-info-box").remove()})}this.scatterplot=this.scatterplot||{},this.scatterplot.chartcontrol=Handlebars.template(function(a,b,c,d,e){this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var f,g="",h="function",i=this.escapeExpression;return g+='<p class="help-text">\n Use the following controls to how the chart is displayed.\n The slide controls can be moved by the mouse or, if the \'handle\' is in focus, your keyboard\'s arrow keys.\n Move the focus between controls by using the tab or shift+tab keys on your keyboard.\n Use the \'Draw\' button to render (or re-render) the chart with the current settings.\n</p>\n\n<div data-config-key="datapointSize" class="form-input numeric-slider-input">\n <label for="datapointSize">Size of data point: </label>\n <div class="slider-output">',(f=c.datapointSize)?f=f.call(b,{hash:{},data:e}):(f=b.datapointSize,f=typeof f===h?f.apply(b):f),g+=i(f)+'</div>\n <div class="slider"></div>\n <p class="form-help help-text-small">\n Size of the graphic representation of each data point\n </p>\n</div>\n\n<div data-config-key="width" class="form-input numeric-slider-input">\n <label for="width">Chart width: </label>\n <div class="slider-output">',(f=c.width)?f=f.call(b,{hash:{},data:e}):(f=b.width,f=typeof f===h?f.apply(b):f),g+=i(f)+'</div>\n <div class="slider"></div>\n <p class="form-help help-text-small">\n (not including chart margins and axes)\n </p>\n</div>\n\n<div data-config-key="height" class="form-input numeric-slider-input">\n <label for="height">Chart height: </label>\n <div class="slider-output">',(f=c.height)?f=f.call(b,{hash:{},data:e}):(f=b.height,f=typeof f===h?f.apply(b):f),g+=i(f)+'</div>\n <div class="slider"></div>\n <p class="form-help help-text-small">\n (not including chart margins and axes)\n </p>\n</div>\n\n<div data-config-key="X-axis-label"class="text-input form-input">\n <label for="X-axis-label">Re-label the X axis: </label>\n <input type="text" name="X-axis-label" id="X-axis-label" value="',(f=c.xLabel)?f=f.call(b,{hash:{},data:e}):(f=b.xLabel,f=typeof f===h?f.apply(b):f),g+=i(f)+'" />\n <p class="form-help help-text-small"></p>\n</div>\n\n<div data-config-key="Y-axis-label" class="text-input form-input">\n <label for="Y-axis-label">Re-label the Y axis: </label>\n <input type="text" name="Y-axis-label" id="Y-axis-label" value="',(f=c.yLabel)?f=f.call(b,{hash:{},data:e}):(f=b.yLabel,f=typeof f===h?f.apply(b):f),g+=i(f)+'" />\n <p class="form-help help-text-small"></p>\n</div>\n\n<button class="render-button btn btn-primary active">Draw</button>\n'}),this.scatterplot.datacontrol=Handlebars.template(function(a,b,c,d,e){this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var f,g="",h="function";return g+='<p class="help-text">\n Use the following control to change which columns are used by the chart. Click any cell\n from the last three rows of the table to select the column for the appropriate data.\n Use the \'Draw\' button to render (or re-render) the chart with the current settings.\n</p>\n\n<ul class="help-text" style="margin-left: 8px">\n <li><b>X Column</b>: which column values will be used for the x axis of the chart.</li>\n <li><b>Y Column</b>: which column values will be used for the y axis of the chart.</li>\n <li><b>ID Column</b>: an additional column value displayed when the user hovers over a data point.\n It may be useful to select unique or categorical identifiers here (such as gene ids).\n </li>\n</ul>\n\n<div class="column-selection">\n <pre class="peek">',(f=c.peek)?f=f.call(b,{hash:{},data:e}):(f=b.peek,f=typeof f===h?f.apply(b):f),(f||0===f)&&(g+=f),g+='</pre>\n</div>\n\n<p class="help-text help-text-small">\n <b>Note</b>: If it can be determined from the dataset\'s filetype that a column is not numeric,\n that column choice may be disabled for either the x or y axis.\n</p>\n\n<button class="render-button btn btn-primary active">Draw</button>\n'}),this.scatterplot.editor=Handlebars.template(function(a,b,c,d,e){this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var f="";return f+='<div class="scatterplot-editor tabbable tabs-left">\n \n <ul class="nav nav-tabs">\n \n <li class="active">\n <a title="Use this tab to change which data are used"\n href="#data-control" data-toggle="tab">Data Controls</a>\n </li>\n <li>\n <a title="Use this tab to change how the chart is drawn"\n href="#chart-control" data-toggle="tab" >Chart Controls</a>\n </li>\n \n <li class="disabled">\n <a title="This tab will display the chart"\n href="#chart-display" data-toggle="tab">Chart</a>\n </li>\n \n <li class="file-controls">\n<!-- <button class="copy-btn btn btn-default"\n title="Save this as a new visualization">Save to new</button>-->\n <button class="save-btn btn btn-default">Save</button>\n </li>\n </ul>\n\n \n <div class="tab-content">\n \n <div id="data-control" class="scatterplot-config-control tab-pane active">\n \n </div>\n \n \n <div id="chart-control" class="scatterplot-config-control tab-pane">\n \n </div>\n\n \n <div id="chart-display" class="scatterplot-display tab-pane"></div>\n\n </div>\n</div>\n'});var ScatterplotConfigEditor=Backbone.View.extend(LoggableMixin).extend({className:"scatterplot-control-form",initialize:function(a){if(this.model||(this.model=new Visualization({type:"scatterplot"})),this.log(this+".initialize, attributes:",a),!a||!a.dataset)throw new Error("ScatterplotConfigEditor requires a dataset");this.dataset=a.dataset,this.log("dataset:",this.dataset),this.display=new ScatterplotDisplay({dataset:a.dataset,model:this.model})},render:function(){this.$el.empty().append(ScatterplotConfigEditor.templates.mainLayout({})),this.model.id&&(this.$el.find(".copy-btn").show(),this.$el.find(".save-btn").text("Update saved")),this.$el.find("[title]").tooltip(),this._render_dataControl(),this._render_chartControls(),this._render_chartDisplay();var a=this.model.get("config");return this.model.id&&_.isFinite(a.xColumn)&&_.isFinite(a.yColumn)&&this.renderChart(),this},_getColumnIndecesByType:function(){var a={numeric:[],text:[],all:[]};return _.each(this.dataset.metadata_column_types||[],function(b,c){"int"===b||"float"===b?a.numeric.push(c):("str"===b||"list"===b)&&a.text.push(c),a.all.push(c)}),a.numeric.length<2&&(a.numeric=[]),a},_render_dataControl:function(a){a=a||this.$el;var b=this,c=this.model.get("config"),d=this._getColumnIndecesByType(),e=a.find(".tab-pane#data-control");return e.html(ScatterplotConfigEditor.templates.dataControl({peek:this.dataset.peek})),e.find(".peek").peekControl({controls:[{label:"X Column",id:"xColumn",selected:c.xColumn,disabled:d.text},{label:"Y Column",id:"yColumn",selected:c.yColumn,disabled:d.text},{label:"ID Column",id:"idColumn",selected:c.idColumn}]}).on("peek-control.change",function(a,c){b.model.set("config",c)}).on("peek-control.rename",function(){}),e.find("[title]").tooltip(),e},_render_chartControls:function(a){function b(){var a=$(this),b=a.slider("value");c.model.set("config",_.object([[a.parent().data("config-key"),b]])),a.siblings(".slider-output").text(b)}a=a||this.$el;var c=this,d=this.model.get("config"),e=a.find("#chart-control");e.html(ScatterplotConfigEditor.templates.chartControl(d));var f={datapointSize:{min:2,max:10,step:1},width:{min:200,max:800,step:20},height:{min:200,max:800,step:20}};e.find(".numeric-slider-input").each(function(){var a=$(this),c=a.attr("data-config-key"),e=_.extend(f[c],{value:d[c],change:b,slide:b});a.find(".slider").slider(e),a.children(".slider-output").text(d[c])});var g=this.dataset.metadata_column_names||[],h=d.xLabel||g[d.xColumn]||"X",i=d.yLabel||g[d.yColumn]||"Y";return e.find('input[name="X-axis-label"]').val(h).on("change",function(){c.model.set("config",{xLabel:$(this).val()})}),e.find('input[name="Y-axis-label"]').val(i).on("change",function(){c.model.set("config",{yLabel:$(this).val()})}),e.find("[title]").tooltip(),e},_render_chartDisplay:function(a){a=a||this.$el;var b=a.find(".tab-pane#chart-display");return this.display.setElement(b),this.display.render(),b.find("[title]").tooltip(),b},events:{"change #include-id-checkbox":"toggleThirdColumnSelector","click #data-control .render-button":"renderChart","click #chart-control .render-button":"renderChart","click .save-btn":"saveVisualization"},saveVisualization:function(){var a=this;this.model.save().fail(function(b,c,d){console.error(b,c,d),a.trigger("save:error",view),alert("Error loading data:\n"+b.responseText)}).then(function(){a.display.render()})},toggleThirdColumnSelector:function(){this.$el.find('select[name="idColumn"]').parent().toggle()},renderChart:function(){this.$el.find(".nav li.disabled").removeClass("disabled"),this.$el.find("ul.nav").find('a[href="#chart-display"]').tab("show"),this.display.fetchData()},toString:function(){return"ScatterplotConfigEditor("+(this.dataset?this.dataset.id:"")+")"}});ScatterplotConfigEditor.templates={mainLayout:scatterplot.editor,dataControl:scatterplot.datacontrol,chartControl:scatterplot.chartcontrol};var ScatterplotDisplay=Backbone.View.extend({initialize:function(a){this.data=null,this.dataset=a.dataset,this.lineCount=this.dataset.metadata_data_lines||null},fetchData:function(){this.showLoadingIndicator();var a=this,b=this.model.get("config"),c=jQuery.getJSON("/api/datasets/"+this.dataset.id,{data_type:"raw_data",provider:"dataset-column",limit:b.pagination.perPage,offset:b.pagination.currPage*b.pagination.perPage});return c.done(function(b){a.data=b.data,a.trigger("data:fetched",a),a.renderData()}),c.fail(function(b,c,d){console.error(b,c,d),a.trigger("data:error",a),alert("Error loading data:\n"+b.responseText)}),c},showLoadingIndicator:function(){this.$el.find(".scatterplot-data-info").html(['<div class="loading-indicator">','<span class="fa fa-spinner fa-spin"></span>','<span class="loading-indicator-message">loading...</span>',"</div>"].join(""))},template:function(){var a=['<div class="controls clear">','<div class="right">','<p class="scatterplot-data-info"></p>','<button class="stats-toggle-btn">Stats</button>','<button class="rerender-btn">Redraw</button>',"</div>",'<div class="left">','<div class="page-control"></div>',"</div>","</div>","<svg/>",'<div class="stats-display"></div>'].join("");return a},render:function(){return this.$el.addClass("scatterplot-display").html(this.template()),this.data&&this.renderData(),this},renderData:function(){this.renderLeftControls(),this.renderRightControls(),this.renderPlot(this.data),this.getStats()},renderLeftControls:function(){var a=this,b=this.model.get("config");return this.$el.find(".controls .left .page-control").pagination({startingPage:b.pagination.currPage,perPage:b.pagination.perPage,totalDataSize:this.lineCount,currDataSize:this.data.length}).off().on("pagination.page-change",function(c,d){b.pagination.currPage=d,a.model.set("config",{pagination:b.pagination}),a.resetZoom(),a.fetchData()}),this},renderRightControls:function(){var a=this;this.setLineInfo(this.data),this.$el.find(".stats-toggle-btn").off().click(function(){a.toggleStats()}),this.$el.find(".rerender-btn").off().click(function(){a.resetZoom(),a.renderPlot(this.data)})},renderPlot:function(){var a=this,b=this.$el.find("svg");this.toggleStats(!1),b.off().empty().show().on("zoom.scatterplot",function(b,c){a.model.set("config",c)}),scatterplot(b.get(0),this.model.get("config"),this.data)},setLineInfo:function(a,b){if(a){var c=this.model.get("config"),d=this.lineCount||"an unknown total",e=c.pagination.currPage*c.pagination.perPage,f=e+a.length;this.$el.find(".controls p.scatterplot-data-info").text([e+1,"to",f,"of",d].join(" "))}else this.$el.find(".controls p.scatterplot-data-info").html(b||"");return this},resetZoom:function(a,b){return a=void 0!==a?a:1,b=void 0!==b?b:[0,0],this.model.set("config",{scale:a,translate:b}),this},getStats:function(){if(this.data){var a=this,b=this.model.get("config"),c=new Worker("/plugins/visualizations/scatterplot/static/worker-stats.js");c.postMessage({data:this.data,keys:[b.xColumn,b.yColumn]}),c.onerror=function(){c.terminate()},c.onmessage=function(b){a.renderStats(b.data)}}},renderStats:function(a){var b=this.model.get("config"),c=this.$el.find(".stats-display"),d=b.xLabel,e=b.yLabel,f=$("<table/>").addClass("table").append(["<thead><th></th><th>",d,"</th><th>",e,"</th></thead>"].join("")).append(_.map(a,function(a,b){return $(["<tr><td>",b,"</td><td>",a[0],"</td><td>",a[1],"</td></tr>"].join(""))}));c.empty().append(f)},toggleStats:function(a){var b=this.$el.find(".stats-display");a=void 0===a?b.is(":hidden"):a,a?(this.$el.find("svg").hide(),b.show(),this.$el.find(".controls .stats-toggle-btn").text("Plot")):(b.hide(),this.$el.find("svg").show(),this.$el.find(".controls .stats-toggle-btn").text("Stats"))},toString:function(){return"ScatterplotView()"}}),ScatterplotModel=Visualization.extend({defaults:{type:"scatterplot",config:{pagination:{currPage:0,perPage:3e3},width:400,height:400,margin:{top:16,right:16,bottom:40,left:54},xTicks:10,xLabel:"X",yTicks:10,yLabel:"Y",datapointSize:4,animDuration:500,scale:1,translate:[0,0]}}}); \ No newline at end of file +function scatterplot(a,b,c){function d(){var a={v:{},h:{}};return a.v.lines=p.selectAll("line.v-grid-line").data(m.x.ticks(q.x.fn.ticks()[0])),a.v.lines.enter().append("svg:line").classed("grid-line v-grid-line",!0),a.v.lines.attr("x1",m.x).attr("x2",m.x).attr("y1",0).attr("y2",b.height),a.v.lines.exit().remove(),a.h.lines=p.selectAll("line.h-grid-line").data(m.y.ticks(q.y.fn.ticks()[0])),a.h.lines.enter().append("svg:line").classed("grid-line h-grid-line",!0),a.h.lines.attr("x1",0).attr("x2",b.width).attr("y1",m.y).attr("y2",m.y),a.h.lines.exit().remove(),a}function e(){return t.attr("cx",function(a,b){return m.x(j(a,b))}).attr("cy",function(a,b){return m.y(k(a,b))}).style("display","block").filter(function(){var a=d3.select(this).attr("cx"),c=d3.select(this).attr("cy");return 0>a||a>b.width?!0:0>c||c>b.height?!0:!1}).style("display","none")}function f(){$(".chart-info-box").remove(),q.redraw(),e(),s=d(),$(o.node()).trigger("zoom.scatterplot",{scale:n.scale(),translate:n.translate()})}function g(a,c,d){return c+=8,$(['<div class="chart-info-box" style="position: absolute">',void 0!==b.idColumn?"<div>"+d[b.idColumn]+"</div>":"","<div>",j(d),"</div>","<div>",k(d),"</div>","</div>"].join("")).css({top:a,left:c,"z-index":2})}var h=function(a,b){return"translate("+a+","+b+")"},i=function(a,b,c){return"rotate("+a+","+b+","+c+")"},j=function(a){return a[b.xColumn]},k=function(a){return a[b.yColumn]},l={x:{extent:d3.extent(c,j)},y:{extent:d3.extent(c,k)}},m={x:d3.scale.linear().domain(l.x.extent).range([0,b.width]),y:d3.scale.linear().domain(l.y.extent).range([b.height,0])},n=d3.behavior.zoom().x(m.x).y(m.y).scaleExtent([1,30]).scale(b.scale||1).translate(b.translate||[0,0]),o=d3.select(a).attr("class","scatterplot").attr("width","100%").attr("height",b.height+(b.margin.top+b.margin.bottom)),p=o.append("g").attr("class","content").attr("transform",h(b.margin.left,b.margin.top)).call(n);p.append("rect").attr("class","zoom-rect").attr("width",b.width).attr("height",b.height).style("fill","transparent");var q={x:{},y:{}};q.x.fn=d3.svg.axis().orient("bottom").scale(m.x).ticks(b.xTicks).tickFormat(d3.format("s")),q.y.fn=d3.svg.axis().orient("left").scale(m.y).ticks(b.yTicks).tickFormat(d3.format("s")),q.x.g=p.append("g").attr("class","x axis").attr("transform",h(0,b.height)).call(q.x.fn),q.y.g=p.append("g").attr("class","y axis").call(q.y.fn);var r=6;q.x.label=o.append("text").attr("id","x-axis-label").attr("class","axis-label").text(b.xLabel).attr("text-anchor","middle").attr("dominant-baseline","text-after-edge").attr("x",b.width/2+b.margin.left).attr("y",b.height+b.margin.bottom+b.margin.top-r),q.y.label=o.append("text").attr("id","y-axis-label").attr("class","axis-label").text(b.yLabel).attr("text-anchor","middle").attr("dominant-baseline","text-before-edge").attr("x",r).attr("y",b.height/2).attr("transform",i(-90,r,b.height/2)),q.redraw=function(){o.select(".x.axis").call(q.x.fn),o.select(".y.axis").call(q.y.fn)};var s=d(),t=p.selectAll(".glyph").data(c).enter().append("svg:circle").classed("glyph",!0).attr("cx",function(a,b){return m.x(j(a,b))}).attr("cy",function(a,b){return m.y(k(a,b))}).attr("r",0);t.transition().duration(b.animDuration).attr("r",b.datapointSize),e(),n.on("zoom",f),t.on("mouseover",function(a,c){var d=d3.select(this);d.classed("highlight",!0).style("fill","red").style("fill-opacity",1),p.append("line").attr("stroke","red").attr("stroke-width",1).attr("x1",d.attr("cx")-b.datapointSize).attr("y1",d.attr("cy")).attr("x2",0).attr("y2",d.attr("cy")).classed("hoverline",!0),d.attr("cy")<b.height&&p.append("line").attr("stroke","red").attr("stroke-width",1).attr("x1",d.attr("cx")).attr("y1",+d.attr("cy")+b.datapointSize).attr("x2",d.attr("cx")).attr("y2",b.height).classed("hoverline",!0);var e=this.getBoundingClientRect();$("body").append(g(e.top,e.right,a)),$(o.node()).trigger("mouseover-datapoint.scatterplot",[this,a,c])}),t.on("mouseout",function(){d3.select(this).classed("highlight",!1).style("fill","black").style("fill-opacity",.2),p.selectAll(".hoverline").remove(),$(".chart-info-box").remove()})}this.scatterplot=this.scatterplot||{},this.scatterplot.chartcontrol=Handlebars.template(function(a,b,c,d,e){this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var f,g="",h="function",i=this.escapeExpression;return g+='<p class="help-text">\n Use the following controls to how the chart is displayed.\n The slide controls can be moved by the mouse or, if the \'handle\' is in focus, your keyboard\'s arrow keys.\n Move the focus between controls by using the tab or shift+tab keys on your keyboard.\n Use the \'Draw\' button to render (or re-render) the chart with the current settings.\n</p>\n\n<div data-config-key="datapointSize" class="form-input numeric-slider-input">\n <label for="datapointSize">Size of data point: </label>\n <div class="slider-output">',(f=c.datapointSize)?f=f.call(b,{hash:{},data:e}):(f=b.datapointSize,f=typeof f===h?f.apply(b):f),g+=i(f)+'</div>\n <div class="slider"></div>\n <p class="form-help help-text-small">\n Size of the graphic representation of each data point\n </p>\n</div>\n\n<div data-config-key="width" class="form-input numeric-slider-input">\n <label for="width">Chart width: </label>\n <div class="slider-output">',(f=c.width)?f=f.call(b,{hash:{},data:e}):(f=b.width,f=typeof f===h?f.apply(b):f),g+=i(f)+'</div>\n <div class="slider"></div>\n <p class="form-help help-text-small">\n (not including chart margins and axes)\n </p>\n</div>\n\n<div data-config-key="height" class="form-input numeric-slider-input">\n <label for="height">Chart height: </label>\n <div class="slider-output">',(f=c.height)?f=f.call(b,{hash:{},data:e}):(f=b.height,f=typeof f===h?f.apply(b):f),g+=i(f)+'</div>\n <div class="slider"></div>\n <p class="form-help help-text-small">\n (not including chart margins and axes)\n </p>\n</div>\n\n<div data-config-key="X-axis-label"class="text-input form-input">\n <label for="X-axis-label">Re-label the X axis: </label>\n <input type="text" name="X-axis-label" id="X-axis-label" value="',(f=c.xLabel)?f=f.call(b,{hash:{},data:e}):(f=b.xLabel,f=typeof f===h?f.apply(b):f),g+=i(f)+'" />\n <p class="form-help help-text-small"></p>\n</div>\n\n<div data-config-key="Y-axis-label" class="text-input form-input">\n <label for="Y-axis-label">Re-label the Y axis: </label>\n <input type="text" name="Y-axis-label" id="Y-axis-label" value="',(f=c.yLabel)?f=f.call(b,{hash:{},data:e}):(f=b.yLabel,f=typeof f===h?f.apply(b):f),g+=i(f)+'" />\n <p class="form-help help-text-small"></p>\n</div>\n\n<button class="render-button btn btn-primary active">Draw</button>\n'}),this.scatterplot.datacontrol=Handlebars.template(function(a,b,c,d,e){this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var f,g="",h="function";return g+='<p class="help-text">\n Use the following control to change which columns are used by the chart. Click any cell\n from the last three rows of the table to select the column for the appropriate data.\n Use the \'Draw\' button to render (or re-render) the chart with the current settings.\n</p>\n\n<ul class="help-text" style="margin-left: 8px">\n <li><b>X Column</b>: which column values will be used for the x axis of the chart.</li>\n <li><b>Y Column</b>: which column values will be used for the y axis of the chart.</li>\n <li><b>ID Column</b>: an additional column value displayed when the user hovers over a data point.\n It may be useful to select unique or categorical identifiers here (such as gene ids).\n </li>\n</ul>\n\n<div class="column-selection">\n <pre class="peek">',(f=c.peek)?f=f.call(b,{hash:{},data:e}):(f=b.peek,f=typeof f===h?f.apply(b):f),(f||0===f)&&(g+=f),g+='</pre>\n</div>\n\n<p class="help-text help-text-small">\n <b>Note</b>: If it can be determined from the dataset\'s filetype that a column is not numeric,\n that column choice may be disabled for either the x or y axis.\n</p>\n\n<button class="render-button btn btn-primary active">Draw</button>\n'}),this.scatterplot.editor=Handlebars.template(function(a,b,c,d,e){this.compilerInfo=[4,">= 1.0.0"],c=this.merge(c,a.helpers),e=e||{};var f="";return f+='<div class="scatterplot-editor tabbable tabs-left">\n \n <ul class="nav nav-tabs">\n \n <li class="active">\n <a title="Use this tab to change which data are used"\n href="#data-control" data-toggle="tab">Data Controls</a>\n </li>\n <li>\n <a title="Use this tab to change how the chart is drawn"\n href="#chart-control" data-toggle="tab" >Chart Controls</a>\n </li>\n \n <li class="disabled">\n <a title="This tab will display the chart"\n href="#chart-display" data-toggle="tab">Chart</a>\n </li>\n \n <li class="file-controls">\n<!-- <button class="copy-btn btn btn-default"\n title="Save this as a new visualization">Save to new</button>-->\n <button class="save-btn btn btn-default">Save</button>\n </li>\n </ul>\n\n \n <div class="tab-content">\n \n <div id="data-control" class="scatterplot-config-control tab-pane active">\n \n </div>\n \n \n <div id="chart-control" class="scatterplot-config-control tab-pane">\n \n </div>\n\n \n <div id="chart-display" class="scatterplot-display tab-pane"></div>\n\n </div>\n</div>\n'});var ScatterplotConfigEditor=Backbone.View.extend({className:"scatterplot-control-form",initialize:function(a){if(this.model||(this.model=new Visualization({type:"scatterplot"})),!a||!a.dataset)throw new Error("ScatterplotConfigEditor requires a dataset");this.dataset=a.dataset,this.display=new ScatterplotDisplay({dataset:a.dataset,model:this.model})},render:function(){this.$el.empty().append(ScatterplotConfigEditor.templates.mainLayout({})),this.model.id&&(this.$el.find(".copy-btn").show(),this.$el.find(".save-btn").text("Update saved")),this.$el.find("[title]").tooltip(),this._render_dataControl(),this._render_chartControls(),this._render_chartDisplay();var a=this.model.get("config");return this.model.id&&_.isFinite(a.xColumn)&&_.isFinite(a.yColumn)&&this.renderChart(),this},_getColumnIndecesByType:function(){var a={numeric:[],text:[],all:[]};return _.each(this.dataset.metadata_column_types||[],function(b,c){"int"===b||"float"===b?a.numeric.push(c):("str"===b||"list"===b)&&a.text.push(c),a.all.push(c)}),a.numeric.length<2&&(a.numeric=[]),a},_render_dataControl:function(a){a=a||this.$el;var b=this,c=this.model.get("config"),d=this._getColumnIndecesByType(),e=a.find(".tab-pane#data-control");return e.html(ScatterplotConfigEditor.templates.dataControl({peek:this.dataset.peek})),e.find(".peek").peekControl({controls:[{label:"X Column",id:"xColumn",selected:c.xColumn,disabled:d.text},{label:"Y Column",id:"yColumn",selected:c.yColumn,disabled:d.text},{label:"ID Column",id:"idColumn",selected:c.idColumn}]}).on("peek-control.change",function(a,c){b.model.set("config",c)}).on("peek-control.rename",function(){}),e.find("[title]").tooltip(),e},_render_chartControls:function(a){function b(){var a=$(this),b=a.slider("value");c.model.set("config",_.object([[a.parent().data("config-key"),b]])),a.siblings(".slider-output").text(b)}a=a||this.$el;var c=this,d=this.model.get("config"),e=a.find("#chart-control");e.html(ScatterplotConfigEditor.templates.chartControl(d));var f={datapointSize:{min:2,max:10,step:1},width:{min:200,max:800,step:20},height:{min:200,max:800,step:20}};e.find(".numeric-slider-input").each(function(){var a=$(this),c=a.attr("data-config-key"),e=_.extend(f[c],{value:d[c],change:b,slide:b});a.find(".slider").slider(e),a.children(".slider-output").text(d[c])});var g=this.dataset.metadata_column_names||[],h=d.xLabel||g[d.xColumn]||"X",i=d.yLabel||g[d.yColumn]||"Y";return e.find('input[name="X-axis-label"]').val(h).on("change",function(){c.model.set("config",{xLabel:$(this).val()})}),e.find('input[name="Y-axis-label"]').val(i).on("change",function(){c.model.set("config",{yLabel:$(this).val()})}),e.find("[title]").tooltip(),e},_render_chartDisplay:function(a){a=a||this.$el;var b=a.find(".tab-pane#chart-display");return this.display.setElement(b),this.display.render(),b.find("[title]").tooltip(),b},events:{"change #include-id-checkbox":"toggleThirdColumnSelector","click #data-control .render-button":"renderChart","click #chart-control .render-button":"renderChart","click .save-btn":"saveVisualization"},saveVisualization:function(){var a=this;this.model.save().fail(function(b,c,d){console.error(b,c,d),a.trigger("save:error",view),alert("Error loading data:\n"+b.responseText)}).then(function(){a.display.render()})},toggleThirdColumnSelector:function(){this.$el.find('select[name="idColumn"]').parent().toggle()},renderChart:function(){this.$el.find(".nav li.disabled").removeClass("disabled"),this.$el.find("ul.nav").find('a[href="#chart-display"]').tab("show"),this.display.fetchData()},toString:function(){return"ScatterplotConfigEditor("+(this.dataset?this.dataset.id:"")+")"}});ScatterplotConfigEditor.templates={mainLayout:scatterplot.editor,dataControl:scatterplot.datacontrol,chartControl:scatterplot.chartcontrol};var ScatterplotDisplay=Backbone.View.extend({initialize:function(a){this.data=null,this.dataset=a.dataset,this.lineCount=this.dataset.metadata_data_lines||null},fetchData:function(){this.showLoadingIndicator();var a=this,b=this.model.get("config"),c=jQuery.getJSON("/api/datasets/"+this.dataset.id,{data_type:"raw_data",provider:"dataset-column",limit:b.pagination.perPage,offset:b.pagination.currPage*b.pagination.perPage});return c.done(function(b){a.data=b.data,a.trigger("data:fetched",a),a.renderData()}),c.fail(function(b,c,d){console.error(b,c,d),a.trigger("data:error",a),alert("Error loading data:\n"+b.responseText)}),c},showLoadingIndicator:function(){this.$el.find(".scatterplot-data-info").html(['<div class="loading-indicator">','<span class="fa fa-spinner fa-spin"></span>','<span class="loading-indicator-message">loading...</span>',"</div>"].join(""))},template:function(){var a=['<div class="controls clear">','<div class="right">','<p class="scatterplot-data-info"></p>','<button class="stats-toggle-btn">Stats</button>','<button class="rerender-btn">Redraw</button>',"</div>",'<div class="left">','<div class="page-control"></div>',"</div>","</div>","<svg/>",'<div class="stats-display"></div>'].join("");return a},render:function(){return this.$el.addClass("scatterplot-display").html(this.template()),this.data&&this.renderData(),this},renderData:function(){this.renderLeftControls(),this.renderRightControls(),this.renderPlot(this.data),this.getStats()},renderLeftControls:function(){var a=this,b=this.model.get("config");return this.$el.find(".controls .left .page-control").pagination({startingPage:b.pagination.currPage,perPage:b.pagination.perPage,totalDataSize:this.lineCount,currDataSize:this.data.length}).off().on("pagination.page-change",function(c,d){b.pagination.currPage=d,a.model.set("config",{pagination:b.pagination}),a.resetZoom(),a.fetchData()}),this},renderRightControls:function(){var a=this;this.setLineInfo(this.data),this.$el.find(".stats-toggle-btn").off().click(function(){a.toggleStats()}),this.$el.find(".rerender-btn").off().click(function(){a.resetZoom(),a.renderPlot(this.data)})},renderPlot:function(){var a=this,b=this.$el.find("svg");this.toggleStats(!1),b.off().empty().show().on("zoom.scatterplot",function(b,c){a.model.set("config",c)}),scatterplot(b.get(0),this.model.get("config"),this.data)},setLineInfo:function(a,b){if(a){var c=this.model.get("config"),d=this.lineCount||"an unknown total",e=c.pagination.currPage*c.pagination.perPage,f=e+a.length;this.$el.find(".controls p.scatterplot-data-info").text([e+1,"to",f,"of",d].join(" "))}else this.$el.find(".controls p.scatterplot-data-info").html(b||"");return this},resetZoom:function(a,b){return a=void 0!==a?a:1,b=void 0!==b?b:[0,0],this.model.set("config",{scale:a,translate:b}),this},getStats:function(){if(this.data){var a=this,b=this.model.get("config"),c=new Worker("/plugins/visualizations/scatterplot/static/worker-stats.js");c.postMessage({data:this.data,keys:[b.xColumn,b.yColumn]}),c.onerror=function(){c.terminate()},c.onmessage=function(b){a.renderStats(b.data)}}},renderStats:function(a){var b=this.model.get("config"),c=this.$el.find(".stats-display"),d=b.xLabel,e=b.yLabel,f=$("<table/>").addClass("table").append(["<thead><th></th><th>",d,"</th><th>",e,"</th></thead>"].join("")).append(_.map(a,function(a,b){return $(["<tr><td>",b,"</td><td>",a[0],"</td><td>",a[1],"</td></tr>"].join(""))}));c.empty().append(f)},toggleStats:function(a){var b=this.$el.find(".stats-display");a=void 0===a?b.is(":hidden"):a,a?(this.$el.find("svg").hide(),b.show(),this.$el.find(".controls .stats-toggle-btn").text("Plot")):(b.hide(),this.$el.find("svg").show(),this.$el.find(".controls .stats-toggle-btn").text("Stats"))},toString:function(){return"ScatterplotView()"}}),ScatterplotModel=Visualization.extend({defaults:{type:"scatterplot",config:{pagination:{currPage:0,perPage:3e3},width:400,height:400,margin:{top:16,right:16,bottom:40,left:54},xTicks:10,xLabel:"X",yTicks:10,yLabel:"Y",datapointSize:4,animDuration:500,scale:1,translate:[0,0]}}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 config/plugins/visualizations/scatterplot/templates/scatterplot.mako --- a/config/plugins/visualizations/scatterplot/templates/scatterplot.mako +++ b/config/plugins/visualizations/scatterplot/templates/scatterplot.mako @@ -32,7 +32,6 @@ 'libs/backbone/backbone', 'libs/d3', 'libs/handlebars.runtime', - 'mvc/base-mvc', 'mvc/ui', 'mvc/visualization/visualization-model' )} diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/annotations.js --- a/static/scripts/mvc/annotations.js +++ b/static/scripts/mvc/annotations.js @@ -1,9 +1,12 @@ define([ -], function(){ + "mvc/base-mvc" +], function( baseMVC ){ // ============================================================================= /** A view on any model that has a 'annotation' attribute */ -var AnnotationEditor = Backbone.View.extend( LoggableMixin ).extend( HiddenUntilActivatedViewMixin ).extend({ +var AnnotationEditor = Backbone.View + .extend( baseMVC.LoggableMixin ) + .extend( baseMVC.HiddenUntilActivatedViewMixin ).extend({ tagName : 'div', className : 'annotation-display', diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/base-mvc.js --- a/static/scripts/mvc/base-mvc.js +++ b/static/scripts/mvc/base-mvc.js @@ -1,3 +1,6 @@ +define([ +], function(){ +//ASSUMES: backbone //============================================================================== /** @class Mixin to add logging capabilities to an object. * Designed to allow switching an objects log output off/on at one central @@ -188,3 +191,10 @@ return this.HUAVOptions.showFn.apply( this.HUAVOptions.$elementShown, arguments ); } }; + +//============================================================================== +return { + LoggableMixin : LoggableMixin, + SessionStorageModel : SessionStorageModel, + HiddenUntilActivatedViewMixin : HiddenUntilActivatedViewMixin +};}); diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/dataset/hda-base.js --- a/static/scripts/mvc/dataset/hda-base.js +++ b/static/scripts/mvc/dataset/hda-base.js @@ -1,7 +1,8 @@ define([ - "mvc/dataset/hda-model" -], function( hdaModel ){ -/* global Backbone, LoggableMixin, HistoryDatasetAssociation, HDABaseView */ + "mvc/dataset/hda-model", + "mvc/base-mvc" +], function( hdaModel, baseMVC ){ +/* global Backbone */ //============================================================================== /** @class Read only view for HistoryDatasetAssociation. * @name HDABaseView @@ -11,7 +12,7 @@ * @borrows LoggableMixin#log as #log * @constructs */ -var HDABaseView = Backbone.View.extend( LoggableMixin ).extend( +var HDABaseView = Backbone.View.extend( baseMVC.LoggableMixin ).extend( /** @lends HDABaseView.prototype */{ ///** logger used to record this.log messages, commonly set to console */ diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/dataset/hda-edit.js --- a/static/scripts/mvc/dataset/hda-edit.js +++ b/static/scripts/mvc/dataset/hda-edit.js @@ -13,7 +13,7 @@ * @borrows LoggableMixin#log as #log * @constructs */ -var HDAEditView = hdaBase.HDABaseView.extend( LoggableMixin ).extend( +var HDAEditView = hdaBase.HDABaseView.extend( /** @lends HDAEditView.prototype */{ // ......................................................................... set up diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/dataset/hda-model.js --- a/static/scripts/mvc/dataset/hda-model.js +++ b/static/scripts/mvc/dataset/hda-model.js @@ -1,5 +1,6 @@ define([ -], function(){ + "mvc/base-mvc" +], function( baseMVC ){ //============================================================================== /** @class (HDA) model for a Galaxy dataset * related to a history. @@ -10,7 +11,7 @@ * @borrows LoggableMixin#log as #log * @constructs */ -var HistoryDatasetAssociation = Backbone.Model.extend( LoggableMixin ).extend( +var HistoryDatasetAssociation = Backbone.Model.extend( baseMVC.LoggableMixin ).extend( /** @lends HistoryDatasetAssociation.prototype */{ ///** logger used to record this.log messages, commonly set to console */ @@ -401,7 +402,7 @@ * @borrows LoggableMixin#log as #log * @constructs */ -var HDACollection = Backbone.Collection.extend( LoggableMixin ).extend( +var HDACollection = Backbone.Collection.extend( baseMVC.LoggableMixin ).extend( /** @lends HDACollection.prototype */{ model : HistoryDatasetAssociation, diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/history/current-history-panel.js --- a/static/scripts/mvc/history/current-history-panel.js +++ b/static/scripts/mvc/history/current-history-panel.js @@ -1,11 +1,12 @@ define([ "mvc/dataset/hda-edit", - "mvc/history/history-panel" -], function( hdaEdit, hpanel ){ + "mvc/history/history-panel", + "mvc/base-mvc" +], function( hdaEdit, hpanel, baseMVC ){ // ============================================================================ /** session storage for history panel preferences (and to maintain state) */ -var HistoryPanelPrefs = SessionStorageModel.extend({ +var HistoryPanelPrefs = baseMVC.SessionStorageModel.extend({ defaults : { /** is the panel currently showing the search/filter controls? */ searching : false, diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/history/history-model.js --- a/static/scripts/mvc/history/history-model.js +++ b/static/scripts/mvc/history/history-model.js @@ -1,6 +1,7 @@ define([ - "mvc/dataset/hda-model" -], function( hdaModel ){ + "mvc/dataset/hda-model", + "mvc/base-mvc" +], function( hdaModel, baseMVC ){ //============================================================================== /** @class Model for a Galaxy history resource - both a record of user * tool use and a collection of the datasets those tools produced. @@ -11,7 +12,7 @@ * @borrows LoggableMixin#log as #log * @constructs */ -var History = Backbone.Model.extend( LoggableMixin ).extend( +var History = Backbone.Model.extend( baseMVC.LoggableMixin ).extend( /** @lends History.prototype */{ ///** logger used to record this.log messages, commonly set to console */ @@ -114,13 +115,6 @@ }, // ........................................................................ common queries - /** is this model already associated with a user? */ -//TODO: remove - hasUser : function(){ - var user = this.get( 'user' ); - return !!( user && user.id ); - }, - /** T/F is this history owned by the current user (Galaxy.currUser) * Note: that this will return false for an anon user even if the history is theirs. */ @@ -295,7 +289,7 @@ * @borrows LoggableMixin#log as #log * @constructs */ -var HistoryCollection = Backbone.Collection.extend( LoggableMixin ).extend( +var HistoryCollection = Backbone.Collection.extend( baseMVC.LoggableMixin ).extend( /** @lends HistoryCollection.prototype */{ model : History, urlRoot : galaxy_config.root + 'api/histories' diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/history/history-panel.js --- a/static/scripts/mvc/history/history-panel.js +++ b/static/scripts/mvc/history/history-panel.js @@ -84,7 +84,7 @@ $newRender.append( HistoryPanel.templates.historyPanel( this.model.toJSON() ) ); this.$emptyMessage( $newRender ).text( this.emptyMsg ); - if( Galaxy.currUser.id && Galaxy.currUser.id === this.model.get( 'user_id' ) ){ + if( Galaxy && Galaxy.currUser && Galaxy.currUser.id && Galaxy.currUser.id === this.model.get( 'user_id' ) ){ this._renderTags( $newRender ); this._renderAnnotation( $newRender ); } diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/history/readonly-history-panel.js --- a/static/scripts/mvc/history/readonly-history-panel.js +++ b/static/scripts/mvc/history/readonly-history-panel.js @@ -1,10 +1,11 @@ define([ "mvc/history/history-model", - "mvc/dataset/hda-base" -], function( historyModel, hdaBase ){ + "mvc/dataset/hda-base", + "mvc/base-mvc" +], function( historyModel, hdaBase, baseMVC ){ // ============================================================================ /** session storage for individual history preferences */ -var HistoryPrefs = SessionStorageModel.extend({ +var HistoryPrefs = baseMVC.SessionStorageModel.extend({ defaults : { //TODO:?? expandedHdas to array? expandedHdas : {}, @@ -71,7 +72,7 @@ * @borrows LoggableMixin#log as #log * @constructs */ -var ReadOnlyHistoryPanel = Backbone.View.extend( LoggableMixin ).extend( +var ReadOnlyHistoryPanel = Backbone.View.extend( baseMVC.LoggableMixin ).extend( /** @lends ReadOnlyHistoryPanel.prototype */{ /** logger used to record this.log messages, commonly set to console */ @@ -311,11 +312,11 @@ attributes = attributes || {}; //this.log( 'JSONToModel:', newHistoryJSON, newHdaJSON.length, attributes ); - // set up the new model and render - if( Galaxy && Galaxy.currUser ){ -//TODO: global - newHistoryJSON.user = Galaxy.currUser.toJSON(); - } +// // set up the new model and render +// if( Galaxy && Galaxy.currUser ){ +////TODO: global +// newHistoryJSON.user = Galaxy.currUser.toJSON(); +// } var model = new historyModel.History( newHistoryJSON, newHdaJSON, attributes ); this.setModel( model ); return this; @@ -334,10 +335,10 @@ if( model ){ // set up the new model with user, logger, storage, events - if( Galaxy && Galaxy.currUser ){ -//TODO: global - model.user = Galaxy.currUser.toJSON(); - } +// if( Galaxy && Galaxy.currUser ){ +////TODO: global +// model.user = Galaxy.currUser.toJSON(); +// } this.model = model; if( this.logger ){ this.model.logger = this.logger; diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/tags.js --- a/static/scripts/mvc/tags.js +++ b/static/scripts/mvc/tags.js @@ -1,11 +1,12 @@ define([ -], function(){ + "mvc/base-mvc" +], function( baseMVC ){ // ============================================================================= /** A view on any model that has a 'tags' attribute (a list of tag strings) * Incorporates the select2 jQuery plugin for tags display/editing: * http://ivaynberg.github.io/select2/ */ -var TagsEditor = Backbone.View.extend( LoggableMixin ).extend( HiddenUntilActivatedViewMixin ).extend({ +var TagsEditor = Backbone.View.extend( baseMVC.LoggableMixin ).extend( baseMVC.HiddenUntilActivatedViewMixin ).extend({ tagName : 'div', className : 'tags-display', diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/user/user-model.js --- a/static/scripts/mvc/user/user-model.js +++ b/static/scripts/mvc/user/user-model.js @@ -1,3 +1,7 @@ +define([ + "mvc/base-mvc" +], function( baseMVC ){ +//============================================================================== /** @class Model for a Galaxy user (including anonymous users). * @name User * @@ -6,7 +10,7 @@ * @borrows LoggableMixin#log as #log * @constructs */ -var User = Backbone.Model.extend( LoggableMixin ).extend( +var User = Backbone.Model.extend( baseMVC.LoggableMixin ).extend( /** @lends User.prototype */{ ///** logger used to record this.log messages, commonly set to console */ @@ -107,8 +111,14 @@ }; // (stub) collection for users (shouldn't be common unless admin UI) -var UserCollection = Backbone.Collection.extend( LoggableMixin ).extend({ +var UserCollection = Backbone.Collection.extend( baseMVC.LoggableMixin ).extend({ model : User, urlRoot : galaxy_config.root + 'api/users' //logger : console, }); + + +//============================================================================== +return { + User : User +};}); diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/user/user-quotameter.js --- a/static/scripts/mvc/user/user-quotameter.js +++ b/static/scripts/mvc/user/user-quotameter.js @@ -1,3 +1,7 @@ +define([ + "mvc/base-mvc" +], function( baseMVC ){ +//============================================================================== /** @class View to display a user's disk/storage usage * either as a progress bar representing the percentage of a quota used * or a simple text element displaying the human readable size used. @@ -8,7 +12,7 @@ * @borrows LoggableMixin#log as #log * @constructs */ -var UserQuotaMeter = Backbone.View.extend( LoggableMixin ).extend( +var UserQuotaMeter = Backbone.View.extend( baseMVC.LoggableMixin ).extend( /** @lends UserQuotaMeter.prototype */{ ///** logger used to record this.log messages, commonly set to console */ @@ -149,3 +153,9 @@ return 'UserQuotaMeter(' + this.model + ')'; } }); + + +//============================================================================== +return { + UserQuotaMeter : UserQuotaMeter +};}); diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/mvc/visualization/visualization-model.js --- a/static/scripts/mvc/visualization/visualization-model.js +++ b/static/scripts/mvc/visualization/visualization-model.js @@ -5,11 +5,9 @@ /** @class Model for a saved Galaxy visualization. * * @augments Backbone.Model - * @borrows LoggableMixin#logger as #logger - * @borrows LoggableMixin#log as #log * @constructs */ -var Visualization = Backbone.Model.extend( LoggableMixin ).extend( +var Visualization = Backbone.Model.extend( /** @lends Visualization.prototype */{ ///** logger used to record this.log messages, commonly set to console */ @@ -31,7 +29,7 @@ * @see Backbone.Model#initialize */ initialize : function( data ){ - this.log( this + '.initialize', data, this.attributes ); + //this.log( this + '.initialize', data, this.attributes ); // munge config sub-object here since bbone won't handle defaults with this if( _.isObject( data.config ) && _.isObject( this.defaults.config ) ){ @@ -84,7 +82,7 @@ * @borrows LoggableMixin#log as #log * @constructs */ -var VisualizationCollection = Backbone.Collection.extend( LoggableMixin ).extend( +var VisualizationCollection = Backbone.Collection.extend( /** @lends VisualizationCollection.prototype */{ model : Visualization, diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/annotations.js --- a/static/scripts/packed/mvc/annotations.js +++ b/static/scripts/packed/mvc/annotations.js @@ -1,1 +1,1 @@ -define([],function(){var a=Backbone.View.extend(LoggableMixin).extend(HiddenUntilActivatedViewMixin).extend({tagName:"div",className:"annotation-display",initialize:function(b){b=b||{};this.tooltipConfig=b.tooltipConfig||{placement:"bottom"};this.listenTo(this.model,"change:annotation",function(){this.render()});this.hiddenUntilActivated(b.$activator,b)},render:function(){var b=this;this.$el.html(this._template());this.$el.find("[title]").tooltip(this.tooltipConfig);this.$annotation().make_text_editable({use_textarea:true,on_finish:function(c){b.$annotation().text(c);b.model.save({annotation:c},{silent:true}).fail(function(){b.$annotation().text(b.model.previous("annotation"))})}});return this},_template:function(){var b=this.model.get("annotation");return['<label class="prompt">',_l("Annotation"),"</label>",'<div class="annotation" title="',_l("Edit annotation"),'">',b,"</div>"].join("")},$annotation:function(){return this.$el.find(".annotation")},remove:function(){this.$annotation.off();this.stopListening(this.model);Backbone.View.prototype.remove.call(this)},toString:function(){return["AnnotationEditor(",this.model+"",")"].join("")}});return{AnnotationEditor:a}}); \ No newline at end of file +define(["mvc/base-mvc"],function(a){var b=Backbone.View.extend(a.LoggableMixin).extend(a.HiddenUntilActivatedViewMixin).extend({tagName:"div",className:"annotation-display",initialize:function(c){c=c||{};this.tooltipConfig=c.tooltipConfig||{placement:"bottom"};this.listenTo(this.model,"change:annotation",function(){this.render()});this.hiddenUntilActivated(c.$activator,c)},render:function(){var c=this;this.$el.html(this._template());this.$el.find("[title]").tooltip(this.tooltipConfig);this.$annotation().make_text_editable({use_textarea:true,on_finish:function(d){c.$annotation().text(d);c.model.save({annotation:d},{silent:true}).fail(function(){c.$annotation().text(c.model.previous("annotation"))})}});return this},_template:function(){var c=this.model.get("annotation");return['<label class="prompt">',_l("Annotation"),"</label>",'<div class="annotation" title="',_l("Edit annotation"),'">',c,"</div>"].join("")},$annotation:function(){return this.$el.find(".annotation")},remove:function(){this.$annotation.off();this.stopListening(this.model);Backbone.View.prototype.remove.call(this)},toString:function(){return["AnnotationEditor(",this.model+"",")"].join("")}});return{AnnotationEditor:b}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/base-mvc.js --- a/static/scripts/packed/mvc/base-mvc.js +++ b/static/scripts/packed/mvc/base-mvc.js @@ -1,1 +1,1 @@ -var LoggableMixin={logger:null,log:function(){if(this.logger){var a=this.logger.log;if(typeof this.logger.log==="object"){a=Function.prototype.bind.call(this.logger.log,this.logger)}return a.apply(this.logger,arguments)}return undefined}};var SessionStorageModel=Backbone.Model.extend({initialize:function(b){b.id=(!_.isString(b.id))?(_.uniqueId()):(b.id);this.id=b.id;var a=(!this.isNew())?(this._read(this)):({});this.clear({silent:true});this.save(_.extend({},this.defaults,a,b),{silent:true});this.on("change",function(){this.save()})},sync:function(d,b,a){if(!a.silent){b.trigger("request",b,{},a)}var c;switch(d){case"create":c=this._create(b);break;case"read":c=this._read(b);break;case"update":c=this._update(b);break;case"delete":c=this._delete(b);break}if(c!==undefined||c!==null){if(a.success){a.success()}}else{if(a.error){a.error()}}return c},_create:function(a){var b=a.toJSON(),c=sessionStorage.setItem(a.id,JSON.stringify(b));return(c===null)?(c):(b)},_read:function(a){return JSON.parse(sessionStorage.getItem(a.id))},_update:function(a){return a._create(a)},_delete:function(a){return sessionStorage.removeItem(a.id)},isNew:function(){return !sessionStorage.hasOwnProperty(this.id)},_log:function(){return JSON.stringify(this.toJSON(),null," ")},toString:function(){return"SessionStorageModel("+this.id+")"}});(function(){SessionStorageModel.prototype=_.omit(SessionStorageModel.prototype,"url","urlRoot")}());var HiddenUntilActivatedViewMixin={hiddenUntilActivated:function(a,c){c=c||{};this.HUAVOptions={$elementShown:this.$el,showFn:jQuery.prototype.toggle,showSpeed:"fast"};_.extend(this.HUAVOptions,c||{});this.HUAVOptions.hasBeenShown=this.HUAVOptions.$elementShown.is(":visible");this.hidden=this.isHidden();if(a){var b=this;a.on("click",function(d){b.toggle(b.HUAVOptions.showSpeed)})}},isHidden:function(){return(this.HUAVOptions.$elementShown.is(":hidden"))},toggle:function(){if(this.hidden){if(!this.HUAVOptions.hasBeenShown){if(_.isFunction(this.HUAVOptions.onshowFirstTime)){this.HUAVOptions.hasBeenShown=true;this.HUAVOptions.onshowFirstTime.call(this)}}if(_.isFunction(this.HUAVOptions.onshow)){this.HUAVOptions.onshow.call(this);this.trigger("hiddenUntilActivated:shown",this)}this.hidden=false}else{if(_.isFunction(this.HUAVOptions.onhide)){this.HUAVOptions.onhide.call(this);this.trigger("hiddenUntilActivated:hidden",this)}this.hidden=true}return this.HUAVOptions.showFn.apply(this.HUAVOptions.$elementShown,arguments)}}; \ No newline at end of file +define([],function(){var c={logger:null,log:function(){if(this.logger){var d=this.logger.log;if(typeof this.logger.log==="object"){d=Function.prototype.bind.call(this.logger.log,this.logger)}return d.apply(this.logger,arguments)}return undefined}};var a=Backbone.Model.extend({initialize:function(e){e.id=(!_.isString(e.id))?(_.uniqueId()):(e.id);this.id=e.id;var d=(!this.isNew())?(this._read(this)):({});this.clear({silent:true});this.save(_.extend({},this.defaults,d,e),{silent:true});this.on("change",function(){this.save()})},sync:function(g,e,d){if(!d.silent){e.trigger("request",e,{},d)}var f;switch(g){case"create":f=this._create(e);break;case"read":f=this._read(e);break;case"update":f=this._update(e);break;case"delete":f=this._delete(e);break}if(f!==undefined||f!==null){if(d.success){d.success()}}else{if(d.error){d.error()}}return f},_create:function(d){var e=d.toJSON(),f=sessionStorage.setItem(d.id,JSON.stringify(e));return(f===null)?(f):(e)},_read:function(d){return JSON.parse(sessionStorage.getItem(d.id))},_update:function(d){return d._create(d)},_delete:function(d){return sessionStorage.removeItem(d.id)},isNew:function(){return !sessionStorage.hasOwnProperty(this.id)},_log:function(){return JSON.stringify(this.toJSON(),null," ")},toString:function(){return"SessionStorageModel("+this.id+")"}});(function(){a.prototype=_.omit(a.prototype,"url","urlRoot")}());var b={hiddenUntilActivated:function(d,f){f=f||{};this.HUAVOptions={$elementShown:this.$el,showFn:jQuery.prototype.toggle,showSpeed:"fast"};_.extend(this.HUAVOptions,f||{});this.HUAVOptions.hasBeenShown=this.HUAVOptions.$elementShown.is(":visible");this.hidden=this.isHidden();if(d){var e=this;d.on("click",function(g){e.toggle(e.HUAVOptions.showSpeed)})}},isHidden:function(){return(this.HUAVOptions.$elementShown.is(":hidden"))},toggle:function(){if(this.hidden){if(!this.HUAVOptions.hasBeenShown){if(_.isFunction(this.HUAVOptions.onshowFirstTime)){this.HUAVOptions.hasBeenShown=true;this.HUAVOptions.onshowFirstTime.call(this)}}if(_.isFunction(this.HUAVOptions.onshow)){this.HUAVOptions.onshow.call(this);this.trigger("hiddenUntilActivated:shown",this)}this.hidden=false}else{if(_.isFunction(this.HUAVOptions.onhide)){this.HUAVOptions.onhide.call(this);this.trigger("hiddenUntilActivated:hidden",this)}this.hidden=true}return this.HUAVOptions.showFn.apply(this.HUAVOptions.$elementShown,arguments)}};return{LoggableMixin:c,SessionStorageModel:a,HiddenUntilActivatedViewMixin:b}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/dataset/hda-base.js --- a/static/scripts/packed/mvc/dataset/hda-base.js +++ b/static/scripts/packed/mvc/dataset/hda-base.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-model"],function(c){var b=Backbone.View.extend(LoggableMixin).extend({tagName:"div",className:"dataset hda history-panel-hda",id:function(){return"hda-"+this.model.get("id")},fxSpeed:"fast",initialize:function(e){if(e.logger){this.logger=this.model.logger=e.logger}this.log(this+".initialize:",e);this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton];this.linkTarget=e.linkTarget||"_blank";this.selectable=e.selectable||false;this.selected=e.selected||false;this.expanded=e.expanded||false;this.draggable=e.draggable||false;this._setUpListeners()},_setUpListeners:function(){this.model.on("change",function(f,e){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this)},render:function(g){g=(g===undefined)?(true):(g);var e=this;this.$el.find("[title]").tooltip("destroy");this.urls=this.model.urls();var f=this._buildNewRender();if(g){$(e).queue(function(h){this.$el.fadeOut(e.fxSpeed,h)})}$(e).queue(function(h){this.$el.empty().attr("class",e.className).addClass("state-"+e.model.get("state")).append(f.children());if(this.selectable){this.showSelector(0)}h()});if(g){$(e).queue(function(h){this.$el.fadeIn(e.fxSpeed,h)})}$(e).queue(function(h){this.trigger("rendered",e);if(this.model.inReadyState()){this.trigger("rendered:ready",e)}if(this.draggable){this.draggableOn()}h()});return this},_buildNewRender:function(){var e=$(b.templates.skeleton(this.model.toJSON()));e.find(".dataset-primary-actions").append(this._render_titleButtons());e.children(".dataset-body").replaceWith(this._render_body());this._setUpBehaviors(e);return e},_setUpBehaviors:function(e){e=e||this.$el;make_popup_menus(e);e.find("[title]").tooltip({placement:"bottom"})},_render_titleButtons:function(){return[this._render_displayButton()]},_render_displayButton:function(){if((this.model.get("state")===c.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(this.model.get("state")===c.HistoryDatasetAssociation.STATES.DISCARDED)||(this.model.get("state")===c.HistoryDatasetAssociation.STATES.NEW)||(!this.model.get("accessible"))){return null}var f={target:this.linkTarget,classes:"dataset-display"};if(this.model.get("purged")){f.disabled=true;f.title=_l("Cannot display datasets removed from disk")}else{if(this.model.get("state")===c.HistoryDatasetAssociation.STATES.UPLOAD){f.disabled=true;f.title=_l("This dataset must finish uploading before it can be viewed")}else{f.title=_l("View data");f.href=this.urls.display;var e=this;f.onclick=function(){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Data Viewer: "+e.model.get("name"),type:"url",content:e.urls.display})}}}}f.faIcon="fa-eye";return faIconButton(f)},_render_downloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}var f=this.urls,g=this.model.get("meta_files");if(_.isEmpty(g)){return $(['<a href="'+f.download+'" title="'+_l("Download")+'" ','class="icon-btn dataset-download-btn">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))}var h="dataset-"+this.model.get("id")+"-popup",e=['<div popupmenu="'+h+'">','<a href="'+f.download+'">',_l("Download Dataset"),"</a>","<a>"+_l("Additional Files")+"</a>",_.map(g,function(i){return['<a class="action-button" href="',f.meta_download+i.file_type,'">',_l("Download")," ",i.file_type,"</a>"].join("")}).join("\n"),"</div>",'<div class="icon-btn-group">','<a href="'+f.download+'" title="'+_l("Download")+'" ','class="icon-btn dataset-download-btn">','<span class="fa fa-floppy-o"></span>','</a><a class="icon-btn popup" id="'+h+'">','<span class="fa fa-caret-down"></span>',"</a>","</div>"].join("\n");return $(e)},_render_showParamsButton:function(){return faIconButton({title:_l("View details"),classes:"dataset-params-btn",href:this.urls.show_params,target:this.linkTarget,faIcon:"fa-info-circle"})},_render_body:function(){var f=$('<div>Error: unknown dataset state "'+this.model.get("state")+'".</div>'),e=this["_render_body_"+this.model.get("state")];if(_.isFunction(e)){f=e.call(this)}this._setUpBehaviors(f);if(this.expanded){f.show()}return f},_render_stateBodyHelper:function(e,h){h=h||[];var f=this,g=$(b.templates.body(_.extend(this.model.toJSON(),{body:e})));g.find(".dataset-actions .left").append(_.map(h,function(i){return i.call(f)}));return g},_render_body_new:function(){return this._render_stateBodyHelper("<div>"+_l("This is a new dataset and not all of its data are available yet")+"</div>")},_render_body_noPermission:function(){return this._render_stateBodyHelper("<div>"+_l("You do not have permission to view this dataset")+"</div>")},_render_body_discarded:function(){return this._render_stateBodyHelper("<div>"+_l("The job creating this dataset was cancelled before completion")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_queued:function(){return this._render_stateBodyHelper("<div>"+_l("This job is waiting to run")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_upload:function(){return this._render_stateBodyHelper("<div>"+_l("This dataset is currently uploading")+"</div>")},_render_body_setting_metadata:function(){return this._render_stateBodyHelper("<div>"+_l("Metadata is being auto-detected")+"</div>")},_render_body_running:function(){return this._render_stateBodyHelper("<div>"+_l("This job is currently running")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_paused:function(){return this._render_stateBodyHelper("<div>"+_l('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume')+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_error:function(){var e=['<span class="help-text">',_l("An error occurred with this dataset"),":</span>",'<div class="job-error-text">',$.trim(this.model.get("misc_info")),"</div>"].join("");if(!this.model.get("purged")){e="<div>"+this.model.get("misc_blurb")+"</div>"+e}return this._render_stateBodyHelper(e,[this._render_downloadButton].concat(this.defaultPrimaryActionButtonRenderers))},_render_body_empty:function(){return this._render_stateBodyHelper("<div>"+_l("No data")+": <i>"+this.model.get("misc_blurb")+"</i></div>",this.defaultPrimaryActionButtonRenderers)},_render_body_failed_metadata:function(){var e=$('<div class="warningmessagesmall"></div>').append($("<strong/>").text(_l("An error occurred setting the metadata for this dataset"))),f=this._render_body_ok();f.prepend(e);return f},_render_body_ok:function(){var e=this,g=$(b.templates.body(this.model.toJSON())),f=[this._render_downloadButton].concat(this.defaultPrimaryActionButtonRenderers);g.find(".dataset-actions .left").append(_.map(f,function(h){return h.call(e)}));if(this.model.isDeletedOrPurged()){return g}return g},events:{"click .dataset-title-bar":"toggleBodyVisibility","keydown .dataset-title-bar":"toggleBodyVisibility","click .dataset-selector":"toggleSelect"},toggleBodyVisibility:function(h,f){var e=32,g=13;if(h&&(h.type==="keydown")&&!(h.keyCode===e||h.keyCode===g)){return true}var i=this.$el.find(".dataset-body");f=(f===undefined)?(!i.is(":visible")):(f);if(f){this.expandBody()}else{this.collapseBody()}return false},expandBody:function(){var e=this;function f(){e.$el.children(".dataset-body").replaceWith(e._render_body());e.$el.children(".dataset-body").slideDown(e.fxSpeed,function(){e.expanded=true;e.trigger("body-expanded",e.model.get("id"))})}if(this.model.inReadyState()&&!this.model.hasDetails()){this.model.fetch({silent:true}).always(function(g){e.urls=e.model.urls();f()})}else{f()}},collapseBody:function(){var e=this;this.$el.children(".dataset-body").slideUp(e.fxSpeed,function(){e.expanded=false;e.trigger("body-collapsed",e.model.get("id"))})},showSelector:function(){if(this.selected){this.select(null,true)}this.selectable=true;this.trigger("selectable",true,this);this.$(".dataset-primary-actions").hide();this.$(".dataset-selector").show()},hideSelector:function(){this.selectable=false;this.trigger("selectable",false,this);this.$(".dataset-selector").hide();this.$(".dataset-primary-actions").show()},toggleSelector:function(){if(!this.$el.find(".dataset-selector").is(":visible")){this.showSelector()}else{this.hideSelector()}},select:function(e){this.$el.find(".dataset-selector span").removeClass("fa-square-o").addClass("fa-check-square-o");if(!this.selected){this.trigger("selected",this);this.selected=true}return false},deselect:function(e){this.$el.find(".dataset-selector span").removeClass("fa-check-square-o").addClass("fa-square-o");if(this.selected){this.trigger("de-selected",this);this.selected=false}return false},toggleSelect:function(e){if(this.selected){this.deselect(e)}else{this.select(e)}},draggableOn:function(){this.draggable=true;this.dragStartHandler=_.bind(this._dragStartHandler,this);this.dragEndHandler=_.bind(this._dragEndHandler,this);var e=this.$el.find(".dataset-title-bar").attr("draggable",true).get(0);e.addEventListener("dragstart",this.dragStartHandler,false);e.addEventListener("dragend",this.dragEndHandler,false)},draggableOff:function(){this.draggable=false;var e=this.$el.find(".dataset-title-bar").attr("draggable",false).get(0);e.removeEventListener("dragstart",this.dragStartHandler,false);e.removeEventListener("dragend",this.dragEndHandler,false)},toggleDraggable:function(){if(this.draggable){this.draggableOff()}else{this.draggableOn()}},_dragStartHandler:function(e){this.trigger("dragstart",this);e.dataTransfer.effectAllowed="move";e.dataTransfer.setData("text",JSON.stringify(this.model.toJSON()));return false},_dragEndHandler:function(e){this.trigger("dragend",this);return false},remove:function(f){var e=this;this.$el.fadeOut(e.fxSpeed,function(){e.$el.remove();e.off();if(f){f()}})},toString:function(){var e=(this.model)?(this.model+""):("(no model)");return"HDABaseView("+e+")"}});var a=['<div class="dataset hda">','<div class="dataset-warnings">',"<% if( hda.error ){ %>",'<div class="errormessagesmall">',_l("There was an error getting the data for this dataset"),":<%- hda.error %>","</div>","<% } %>","<% if( hda.deleted ){ %>","<% if( hda.purged ){ %>",'<div class="dataset-purged-msg warningmessagesmall"><strong>',_l("This dataset has been deleted and removed from disk."),"</strong></div>","<% } else { %>",'<div class="dataset-deleted-msg warningmessagesmall"><strong>',_l("This dataset has been deleted."),"</strong></div>","<% } %>","<% } %>","<% if( !hda.visible ){ %>",'<div class="dataset-hidden-msg warningmessagesmall"><strong>',_l("This dataset has been hidden."),"</strong></div>","<% } %>","</div>",'<div class="dataset-selector">','<span class="fa fa-2x fa-square-o"></span>',"</div>",'<div class="dataset-primary-actions"></div>','<div class="dataset-title-bar clear" tabindex="0">','<span class="dataset-state-icon state-icon"></span>','<div class="dataset-title">','<span class="hda-hid"><%- hda.hid %></span> ','<span class="dataset-name"><%- hda.name %></span>',"</div>","</div>",'<div class="dataset-body"></div>',"</div>"].join("");var d=['<div class="dataset-body">',"<% if( hda.body ){ %>",'<div class="dataset-summary">',"<%= hda.body %>","</div>",'<div class="dataset-actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% } else { %>",'<div class="dataset-summary">',"<% if( hda.misc_blurb ){ %>",'<div class="dataset-blurb">','<span class="value"><%- hda.misc_blurb %></span>',"</div>","<% } %>","<% if( hda.data_type ){ %>",'<div class="dataset-datatype">','<label class="prompt">',_l("format"),"</label>",'<span class="value"><%- hda.data_type %></span>',"</div>","<% } %>","<% if( hda.metadata_dbkey ){ %>",'<div class="dataset-dbkey">','<label class="prompt">',_l("database"),"</label>",'<span class="value">',"<%- hda.metadata_dbkey %>","</span>","</div>","<% } %>","<% if( hda.misc_info ){ %>",'<div class="dataset-info">','<span class="value"><%- hda.misc_info %></span>',"</div>","<% } %>","</div>",'<div class="dataset-actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% if( !hda.deleted ){ %>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="dataset-display-applications">',"<% _.each( hda.display_apps, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>","<% _.each( hda.display_types, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>","</div>",'<div class="dataset-peek">',"<% if( hda.peek ){ %>",'<pre class="peek"><%= hda.peek %></pre>',"<% } %>","</div>","<% } %>","<% } %>","</div>"].join("");b.templates={skeleton:function(e){return _.template(a,e,{variable:"hda"})},body:function(e){return _.template(d,e,{variable:"hda"})}};return{HDABaseView:b}}); \ No newline at end of file +define(["mvc/dataset/hda-model","mvc/base-mvc"],function(d,b){var c=Backbone.View.extend(b.LoggableMixin).extend({tagName:"div",className:"dataset hda history-panel-hda",id:function(){return"hda-"+this.model.get("id")},fxSpeed:"fast",initialize:function(f){if(f.logger){this.logger=this.model.logger=f.logger}this.log(this+".initialize:",f);this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton];this.linkTarget=f.linkTarget||"_blank";this.selectable=f.selectable||false;this.selected=f.selected||false;this.expanded=f.expanded||false;this.draggable=f.draggable||false;this._setUpListeners()},_setUpListeners:function(){this.model.on("change",function(g,f){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this)},render:function(h){h=(h===undefined)?(true):(h);var f=this;this.$el.find("[title]").tooltip("destroy");this.urls=this.model.urls();var g=this._buildNewRender();if(h){$(f).queue(function(i){this.$el.fadeOut(f.fxSpeed,i)})}$(f).queue(function(i){this.$el.empty().attr("class",f.className).addClass("state-"+f.model.get("state")).append(g.children());if(this.selectable){this.showSelector(0)}i()});if(h){$(f).queue(function(i){this.$el.fadeIn(f.fxSpeed,i)})}$(f).queue(function(i){this.trigger("rendered",f);if(this.model.inReadyState()){this.trigger("rendered:ready",f)}if(this.draggable){this.draggableOn()}i()});return this},_buildNewRender:function(){var f=$(c.templates.skeleton(this.model.toJSON()));f.find(".dataset-primary-actions").append(this._render_titleButtons());f.children(".dataset-body").replaceWith(this._render_body());this._setUpBehaviors(f);return f},_setUpBehaviors:function(f){f=f||this.$el;make_popup_menus(f);f.find("[title]").tooltip({placement:"bottom"})},_render_titleButtons:function(){return[this._render_displayButton()]},_render_displayButton:function(){if((this.model.get("state")===d.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(this.model.get("state")===d.HistoryDatasetAssociation.STATES.DISCARDED)||(this.model.get("state")===d.HistoryDatasetAssociation.STATES.NEW)||(!this.model.get("accessible"))){return null}var g={target:this.linkTarget,classes:"dataset-display"};if(this.model.get("purged")){g.disabled=true;g.title=_l("Cannot display datasets removed from disk")}else{if(this.model.get("state")===d.HistoryDatasetAssociation.STATES.UPLOAD){g.disabled=true;g.title=_l("This dataset must finish uploading before it can be viewed")}else{g.title=_l("View data");g.href=this.urls.display;var f=this;g.onclick=function(){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Data Viewer: "+f.model.get("name"),type:"url",content:f.urls.display})}}}}g.faIcon="fa-eye";return faIconButton(g)},_render_downloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}var g=this.urls,h=this.model.get("meta_files");if(_.isEmpty(h)){return $(['<a href="'+g.download+'" title="'+_l("Download")+'" ','class="icon-btn dataset-download-btn">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))}var i="dataset-"+this.model.get("id")+"-popup",f=['<div popupmenu="'+i+'">','<a href="'+g.download+'">',_l("Download Dataset"),"</a>","<a>"+_l("Additional Files")+"</a>",_.map(h,function(j){return['<a class="action-button" href="',g.meta_download+j.file_type,'">',_l("Download")," ",j.file_type,"</a>"].join("")}).join("\n"),"</div>",'<div class="icon-btn-group">','<a href="'+g.download+'" title="'+_l("Download")+'" ','class="icon-btn dataset-download-btn">','<span class="fa fa-floppy-o"></span>','</a><a class="icon-btn popup" id="'+i+'">','<span class="fa fa-caret-down"></span>',"</a>","</div>"].join("\n");return $(f)},_render_showParamsButton:function(){return faIconButton({title:_l("View details"),classes:"dataset-params-btn",href:this.urls.show_params,target:this.linkTarget,faIcon:"fa-info-circle"})},_render_body:function(){var g=$('<div>Error: unknown dataset state "'+this.model.get("state")+'".</div>'),f=this["_render_body_"+this.model.get("state")];if(_.isFunction(f)){g=f.call(this)}this._setUpBehaviors(g);if(this.expanded){g.show()}return g},_render_stateBodyHelper:function(f,i){i=i||[];var g=this,h=$(c.templates.body(_.extend(this.model.toJSON(),{body:f})));h.find(".dataset-actions .left").append(_.map(i,function(j){return j.call(g)}));return h},_render_body_new:function(){return this._render_stateBodyHelper("<div>"+_l("This is a new dataset and not all of its data are available yet")+"</div>")},_render_body_noPermission:function(){return this._render_stateBodyHelper("<div>"+_l("You do not have permission to view this dataset")+"</div>")},_render_body_discarded:function(){return this._render_stateBodyHelper("<div>"+_l("The job creating this dataset was cancelled before completion")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_queued:function(){return this._render_stateBodyHelper("<div>"+_l("This job is waiting to run")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_upload:function(){return this._render_stateBodyHelper("<div>"+_l("This dataset is currently uploading")+"</div>")},_render_body_setting_metadata:function(){return this._render_stateBodyHelper("<div>"+_l("Metadata is being auto-detected")+"</div>")},_render_body_running:function(){return this._render_stateBodyHelper("<div>"+_l("This job is currently running")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_paused:function(){return this._render_stateBodyHelper("<div>"+_l('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume')+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_error:function(){var f=['<span class="help-text">',_l("An error occurred with this dataset"),":</span>",'<div class="job-error-text">',$.trim(this.model.get("misc_info")),"</div>"].join("");if(!this.model.get("purged")){f="<div>"+this.model.get("misc_blurb")+"</div>"+f}return this._render_stateBodyHelper(f,[this._render_downloadButton].concat(this.defaultPrimaryActionButtonRenderers))},_render_body_empty:function(){return this._render_stateBodyHelper("<div>"+_l("No data")+": <i>"+this.model.get("misc_blurb")+"</i></div>",this.defaultPrimaryActionButtonRenderers)},_render_body_failed_metadata:function(){var f=$('<div class="warningmessagesmall"></div>').append($("<strong/>").text(_l("An error occurred setting the metadata for this dataset"))),g=this._render_body_ok();g.prepend(f);return g},_render_body_ok:function(){var f=this,h=$(c.templates.body(this.model.toJSON())),g=[this._render_downloadButton].concat(this.defaultPrimaryActionButtonRenderers);h.find(".dataset-actions .left").append(_.map(g,function(i){return i.call(f)}));if(this.model.isDeletedOrPurged()){return h}return h},events:{"click .dataset-title-bar":"toggleBodyVisibility","keydown .dataset-title-bar":"toggleBodyVisibility","click .dataset-selector":"toggleSelect"},toggleBodyVisibility:function(i,g){var f=32,h=13;if(i&&(i.type==="keydown")&&!(i.keyCode===f||i.keyCode===h)){return true}var j=this.$el.find(".dataset-body");g=(g===undefined)?(!j.is(":visible")):(g);if(g){this.expandBody()}else{this.collapseBody()}return false},expandBody:function(){var f=this;function g(){f.$el.children(".dataset-body").replaceWith(f._render_body());f.$el.children(".dataset-body").slideDown(f.fxSpeed,function(){f.expanded=true;f.trigger("body-expanded",f.model.get("id"))})}if(this.model.inReadyState()&&!this.model.hasDetails()){this.model.fetch({silent:true}).always(function(h){f.urls=f.model.urls();g()})}else{g()}},collapseBody:function(){var f=this;this.$el.children(".dataset-body").slideUp(f.fxSpeed,function(){f.expanded=false;f.trigger("body-collapsed",f.model.get("id"))})},showSelector:function(){if(this.selected){this.select(null,true)}this.selectable=true;this.trigger("selectable",true,this);this.$(".dataset-primary-actions").hide();this.$(".dataset-selector").show()},hideSelector:function(){this.selectable=false;this.trigger("selectable",false,this);this.$(".dataset-selector").hide();this.$(".dataset-primary-actions").show()},toggleSelector:function(){if(!this.$el.find(".dataset-selector").is(":visible")){this.showSelector()}else{this.hideSelector()}},select:function(f){this.$el.find(".dataset-selector span").removeClass("fa-square-o").addClass("fa-check-square-o");if(!this.selected){this.trigger("selected",this);this.selected=true}return false},deselect:function(f){this.$el.find(".dataset-selector span").removeClass("fa-check-square-o").addClass("fa-square-o");if(this.selected){this.trigger("de-selected",this);this.selected=false}return false},toggleSelect:function(f){if(this.selected){this.deselect(f)}else{this.select(f)}},draggableOn:function(){this.draggable=true;this.dragStartHandler=_.bind(this._dragStartHandler,this);this.dragEndHandler=_.bind(this._dragEndHandler,this);var f=this.$el.find(".dataset-title-bar").attr("draggable",true).get(0);f.addEventListener("dragstart",this.dragStartHandler,false);f.addEventListener("dragend",this.dragEndHandler,false)},draggableOff:function(){this.draggable=false;var f=this.$el.find(".dataset-title-bar").attr("draggable",false).get(0);f.removeEventListener("dragstart",this.dragStartHandler,false);f.removeEventListener("dragend",this.dragEndHandler,false)},toggleDraggable:function(){if(this.draggable){this.draggableOff()}else{this.draggableOn()}},_dragStartHandler:function(f){this.trigger("dragstart",this);f.dataTransfer.effectAllowed="move";f.dataTransfer.setData("text",JSON.stringify(this.model.toJSON()));return false},_dragEndHandler:function(f){this.trigger("dragend",this);return false},remove:function(g){var f=this;this.$el.fadeOut(f.fxSpeed,function(){f.$el.remove();f.off();if(g){g()}})},toString:function(){var f=(this.model)?(this.model+""):("(no model)");return"HDABaseView("+f+")"}});var a=['<div class="dataset hda">','<div class="dataset-warnings">',"<% if( hda.error ){ %>",'<div class="errormessagesmall">',_l("There was an error getting the data for this dataset"),":<%- hda.error %>","</div>","<% } %>","<% if( hda.deleted ){ %>","<% if( hda.purged ){ %>",'<div class="dataset-purged-msg warningmessagesmall"><strong>',_l("This dataset has been deleted and removed from disk."),"</strong></div>","<% } else { %>",'<div class="dataset-deleted-msg warningmessagesmall"><strong>',_l("This dataset has been deleted."),"</strong></div>","<% } %>","<% } %>","<% if( !hda.visible ){ %>",'<div class="dataset-hidden-msg warningmessagesmall"><strong>',_l("This dataset has been hidden."),"</strong></div>","<% } %>","</div>",'<div class="dataset-selector">','<span class="fa fa-2x fa-square-o"></span>',"</div>",'<div class="dataset-primary-actions"></div>','<div class="dataset-title-bar clear" tabindex="0">','<span class="dataset-state-icon state-icon"></span>','<div class="dataset-title">','<span class="hda-hid"><%- hda.hid %></span> ','<span class="dataset-name"><%- hda.name %></span>',"</div>","</div>",'<div class="dataset-body"></div>',"</div>"].join("");var e=['<div class="dataset-body">',"<% if( hda.body ){ %>",'<div class="dataset-summary">',"<%= hda.body %>","</div>",'<div class="dataset-actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% } else { %>",'<div class="dataset-summary">',"<% if( hda.misc_blurb ){ %>",'<div class="dataset-blurb">','<span class="value"><%- hda.misc_blurb %></span>',"</div>","<% } %>","<% if( hda.data_type ){ %>",'<div class="dataset-datatype">','<label class="prompt">',_l("format"),"</label>",'<span class="value"><%- hda.data_type %></span>',"</div>","<% } %>","<% if( hda.metadata_dbkey ){ %>",'<div class="dataset-dbkey">','<label class="prompt">',_l("database"),"</label>",'<span class="value">',"<%- hda.metadata_dbkey %>","</span>","</div>","<% } %>","<% if( hda.misc_info ){ %>",'<div class="dataset-info">','<span class="value"><%- hda.misc_info %></span>',"</div>","<% } %>","</div>",'<div class="dataset-actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% if( !hda.deleted ){ %>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="dataset-display-applications">',"<% _.each( hda.display_apps, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>","<% _.each( hda.display_types, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>","</div>",'<div class="dataset-peek">',"<% if( hda.peek ){ %>",'<pre class="peek"><%= hda.peek %></pre>',"<% } %>","</div>","<% } %>","<% } %>","</div>"].join("");c.templates={skeleton:function(f){return _.template(a,f,{variable:"hda"})},body:function(f){return _.template(e,f,{variable:"hda"})}};return{HDABaseView:c}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/dataset/hda-edit.js --- a/static/scripts/packed/mvc/dataset/hda-edit.js +++ b/static/scripts/packed/mvc/dataset/hda-edit.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-model","mvc/dataset/hda-base","mvc/tags","mvc/annotations"],function(f,b,a,e){var g=b.HDABaseView.extend(LoggableMixin).extend({initialize:function(h){b.HDABaseView.prototype.initialize.call(this,h);this.hasUser=h.hasUser;this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton,this._render_rerunButton];this.tagsEditorShown=h.tagsEditorShown||false;this.annotationEditorShown=h.annotationEditorShown||false},_render_titleButtons:function(){return b.HDABaseView.prototype._render_titleButtons.call(this).concat([this._render_editButton(),this._render_deleteButton()])},_render_editButton:function(){if((this.model.get("state")===f.HistoryDatasetAssociation.STATES.NEW)||(this.model.get("state")===f.HistoryDatasetAssociation.STATES.DISCARDED)||(this.model.get("state")===f.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var j=this.model.get("purged"),h=this.model.get("deleted"),i={title:_l("Edit attributes"),href:this.urls.edit,target:this.linkTarget,classes:"dataset-edit"};if(h||j){i.disabled=true;if(j){i.title=_l("Cannot edit attributes of datasets removed from disk")}else{if(h){i.title=_l("Undelete dataset to edit attributes")}}}else{if(this.model.get("state")===f.HistoryDatasetAssociation.STATES.UPLOAD){i.disabled=true;i.title=_l("This dataset must finish uploading before it can be edited")}}i.faIcon="fa-pencil";return faIconButton(i)},_render_deleteButton:function(){if((this.model.get("state")===f.HistoryDatasetAssociation.STATES.NEW)||(this.model.get("state")===f.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var h=this,i={title:_l("Delete"),classes:"dataset-delete",onclick:function(){h.$el.find(".icon-btn.dataset-delete").trigger("mouseout");h.model["delete"]()}};if(this.model.get("deleted")||this.model.get("purged")){i={title:_l("Dataset is already deleted"),disabled:true}}i.faIcon="fa-times";return faIconButton(i)},_render_errButton:function(){if(this.model.get("state")!==f.HistoryDatasetAssociation.STATES.ERROR){return null}return faIconButton({title:_l("View or report this error"),href:this.urls.report_error,classes:"dataset-report-error-btn",target:this.linkTarget,faIcon:"fa-bug"})},_render_rerunButton:function(){return faIconButton({title:_l("Run this job again"),href:this.urls.rerun,classes:"dataset-rerun-btn",target:this.linkTarget,faIcon:"fa-refresh"})},_render_visualizationsButton:function(){var h=this.model.get("visualizations");if((!this.hasUser)||(!this.model.hasData())||(_.isEmpty(h))){return null}if(_.isObject(h[0])){return this._render_visualizationsFrameworkButton(h)}if(!this.urls.visualization){return null}var j=this.model.get("dbkey"),n=this.urls.visualization,k={},o={dataset_id:this.model.get("id"),hda_ldda:"hda"};if(j){o.dbkey=j}var i=faIconButton({title:_l("Visualize"),classes:"dataset-visualize-btn",faIcon:"fa-bar-chart-o"});function l(p){if(p==="trackster"){return c(n,o,j)}return function(){Galaxy.frame.add({title:"Visualization",type:"url",content:n+"/"+p+"?"+$.param(o)})}}function m(p){return p.charAt(0).toUpperCase()+p.slice(1)}if(h.length===1){i.attr("data-original-title",_l("Visualize in ")+_l(m(h[0])));i.click(l(h[0]))}else{_.each(h,function(p){k[_l(m(p))]=l(p)});make_popupmenu(i,k)}return i},_render_visualizationsFrameworkButton:function(h){if(!(this.model.hasData())||!(h&&!_.isEmpty(h))){return null}var j=faIconButton({title:_l("Visualize"),classes:"dataset-visualize-btn",faIcon:"fa-bar-chart-o"});if(h.length===1){var i=h[0];j.attr("data-original-title",_l("Visualize in ")+i.html);j.attr("href",i.href)}else{var k=[];_.each(h,function(l){l.func=function(){if(Galaxy.frame.active){Galaxy.frame.add({title:"Visualization",type:"url",content:l.href});return false}return true};k.push(l);return false});PopupMenu.create(j,k)}return j},_buildNewRender:function(){var h=b.HDABaseView.prototype._buildNewRender.call(this);h.find(".dataset-deleted-msg").append(_l('Click <a href="javascript:void(0);" class="dataset-undelete">here</a> to undelete it or <a href="javascript:void(0);" class="dataset-purge">here</a> to immediately remove it from disk'));h.find(".dataset-hidden-msg").append(_l('Click <a href="javascript:void(0);" class="dataset-unhide">here</a> to unhide it'));return h},_render_body_failed_metadata:function(){var i=$("<a/>").attr({href:this.urls.edit,target:this.linkTarget}).text(_l("set it manually or retry auto-detection")),h=$("<span/>").text(". "+_l("You may be able to")+" ").append(i),j=b.HDABaseView.prototype._render_body_failed_metadata.call(this);j.find(".warningmessagesmall strong").append(h);return j},_render_body_error:function(){var h=b.HDABaseView.prototype._render_body_error.call(this);h.find(".dataset-actions .left").prepend(this._render_errButton());return h},_render_body_ok:function(){var h=b.HDABaseView.prototype._render_body_ok.call(this);if(this.model.isDeletedOrPurged()){return h}this.makeDbkeyEditLink(h);if(this.hasUser){h.find(".dataset-actions .left").append(this._render_visualizationsButton());this._renderTags(h);this._renderAnnotation(h)}return h},_renderTags:function(h){var i=this;this.tagsEditor=new a.TagsEditor({model:this.model,el:h.find(".tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){i.tagsEditorShown=true},onhide:function(){i.tagsEditorShown=false},$activator:faIconButton({title:_l("Edit dataset tags"),classes:"dataset-tag-btn",faIcon:"fa-tags"}).appendTo(h.find(".dataset-actions .right"))});if(this.tagsEditorShown){this.tagsEditor.toggle(true)}},_renderAnnotation:function(h){var i=this;this.annotationEditor=new e.AnnotationEditor({model:this.model,el:h.find(".annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){i.annotationEditorShown=true},onhide:function(){i.annotationEditorShown=false},$activator:faIconButton({title:_l("Edit dataset annotation"),classes:"dataset-annotate-btn",faIcon:"fa-comment"}).appendTo(h.find(".dataset-actions .right"))});if(this.annotationEditorShown){this.annotationEditor.toggle(true)}},makeDbkeyEditLink:function(i){if(this.model.get("metadata_dbkey")==="?"&&!this.model.isDeletedOrPurged()){var h=$('<a class="value">?</a>').attr("href",this.urls.edit).attr("target",this.linkTarget);i.find(".dataset-dbkey .value").replaceWith(h)}},events:_.extend(_.clone(b.HDABaseView.prototype.events),{"click .dataset-undelete":function(h){this.model.undelete();return false},"click .dataset-unhide":function(h){this.model.unhide();return false},"click .dataset-purge":"confirmPurge"}),confirmPurge:function d(h){this.model.purge();return false},toString:function(){var h=(this.model)?(this.model+""):("(no model)");return"HDAView("+h+")"}});function c(h,j,i){return function(){var k={};if(i){k["f-dbkey"]=i}$.ajax({url:h+"/list_tracks?"+$.param(k),dataType:"html",error:function(){alert(("Could not add this dataset to browser")+".")},success:function(l){var m=window.parent;m.Galaxy.modal.show({title:"View Data in a New or Saved Visualization",buttons:{Cancel:function(){m.Galaxy.modal.hide()},"View in saved visualization":function(){m.Galaxy.modal.show({title:"Add Data to Saved Visualization",body:l,buttons:{Cancel:function(){m.Galaxy.modal.hide()},"Add to visualization":function(){$(m.document).find("input[name=id]:checked").each(function(){m.Galaxy.modal.hide();var n=$(this).val();j.id=n;m.Galaxy.frame.add({title:"Trackster",type:"url",content:h+"/trackster?"+$.param(j)})})}}})},"View in new visualization":function(){m.Galaxy.modal.hide();var n=h+"/trackster?"+$.param(j);m.Galaxy.frame.add({title:"Trackster",type:"url",content:n})}}})}});return false}}return{HDAEditView:g}}); \ No newline at end of file +define(["mvc/dataset/hda-model","mvc/dataset/hda-base","mvc/tags","mvc/annotations"],function(f,b,a,e){var g=b.HDABaseView.extend({initialize:function(h){b.HDABaseView.prototype.initialize.call(this,h);this.hasUser=h.hasUser;this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton,this._render_rerunButton];this.tagsEditorShown=h.tagsEditorShown||false;this.annotationEditorShown=h.annotationEditorShown||false},_render_titleButtons:function(){return b.HDABaseView.prototype._render_titleButtons.call(this).concat([this._render_editButton(),this._render_deleteButton()])},_render_editButton:function(){if((this.model.get("state")===f.HistoryDatasetAssociation.STATES.NEW)||(this.model.get("state")===f.HistoryDatasetAssociation.STATES.DISCARDED)||(this.model.get("state")===f.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var j=this.model.get("purged"),h=this.model.get("deleted"),i={title:_l("Edit attributes"),href:this.urls.edit,target:this.linkTarget,classes:"dataset-edit"};if(h||j){i.disabled=true;if(j){i.title=_l("Cannot edit attributes of datasets removed from disk")}else{if(h){i.title=_l("Undelete dataset to edit attributes")}}}else{if(this.model.get("state")===f.HistoryDatasetAssociation.STATES.UPLOAD){i.disabled=true;i.title=_l("This dataset must finish uploading before it can be edited")}}i.faIcon="fa-pencil";return faIconButton(i)},_render_deleteButton:function(){if((this.model.get("state")===f.HistoryDatasetAssociation.STATES.NEW)||(this.model.get("state")===f.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var h=this,i={title:_l("Delete"),classes:"dataset-delete",onclick:function(){h.$el.find(".icon-btn.dataset-delete").trigger("mouseout");h.model["delete"]()}};if(this.model.get("deleted")||this.model.get("purged")){i={title:_l("Dataset is already deleted"),disabled:true}}i.faIcon="fa-times";return faIconButton(i)},_render_errButton:function(){if(this.model.get("state")!==f.HistoryDatasetAssociation.STATES.ERROR){return null}return faIconButton({title:_l("View or report this error"),href:this.urls.report_error,classes:"dataset-report-error-btn",target:this.linkTarget,faIcon:"fa-bug"})},_render_rerunButton:function(){return faIconButton({title:_l("Run this job again"),href:this.urls.rerun,classes:"dataset-rerun-btn",target:this.linkTarget,faIcon:"fa-refresh"})},_render_visualizationsButton:function(){var h=this.model.get("visualizations");if((!this.hasUser)||(!this.model.hasData())||(_.isEmpty(h))){return null}if(_.isObject(h[0])){return this._render_visualizationsFrameworkButton(h)}if(!this.urls.visualization){return null}var j=this.model.get("dbkey"),n=this.urls.visualization,k={},o={dataset_id:this.model.get("id"),hda_ldda:"hda"};if(j){o.dbkey=j}var i=faIconButton({title:_l("Visualize"),classes:"dataset-visualize-btn",faIcon:"fa-bar-chart-o"});function l(p){if(p==="trackster"){return c(n,o,j)}return function(){Galaxy.frame.add({title:"Visualization",type:"url",content:n+"/"+p+"?"+$.param(o)})}}function m(p){return p.charAt(0).toUpperCase()+p.slice(1)}if(h.length===1){i.attr("data-original-title",_l("Visualize in ")+_l(m(h[0])));i.click(l(h[0]))}else{_.each(h,function(p){k[_l(m(p))]=l(p)});make_popupmenu(i,k)}return i},_render_visualizationsFrameworkButton:function(h){if(!(this.model.hasData())||!(h&&!_.isEmpty(h))){return null}var j=faIconButton({title:_l("Visualize"),classes:"dataset-visualize-btn",faIcon:"fa-bar-chart-o"});if(h.length===1){var i=h[0];j.attr("data-original-title",_l("Visualize in ")+i.html);j.attr("href",i.href)}else{var k=[];_.each(h,function(l){l.func=function(){if(Galaxy.frame.active){Galaxy.frame.add({title:"Visualization",type:"url",content:l.href});return false}return true};k.push(l);return false});PopupMenu.create(j,k)}return j},_buildNewRender:function(){var h=b.HDABaseView.prototype._buildNewRender.call(this);h.find(".dataset-deleted-msg").append(_l('Click <a href="javascript:void(0);" class="dataset-undelete">here</a> to undelete it or <a href="javascript:void(0);" class="dataset-purge">here</a> to immediately remove it from disk'));h.find(".dataset-hidden-msg").append(_l('Click <a href="javascript:void(0);" class="dataset-unhide">here</a> to unhide it'));return h},_render_body_failed_metadata:function(){var i=$("<a/>").attr({href:this.urls.edit,target:this.linkTarget}).text(_l("set it manually or retry auto-detection")),h=$("<span/>").text(". "+_l("You may be able to")+" ").append(i),j=b.HDABaseView.prototype._render_body_failed_metadata.call(this);j.find(".warningmessagesmall strong").append(h);return j},_render_body_error:function(){var h=b.HDABaseView.prototype._render_body_error.call(this);h.find(".dataset-actions .left").prepend(this._render_errButton());return h},_render_body_ok:function(){var h=b.HDABaseView.prototype._render_body_ok.call(this);if(this.model.isDeletedOrPurged()){return h}this.makeDbkeyEditLink(h);if(this.hasUser){h.find(".dataset-actions .left").append(this._render_visualizationsButton());this._renderTags(h);this._renderAnnotation(h)}return h},_renderTags:function(h){var i=this;this.tagsEditor=new a.TagsEditor({model:this.model,el:h.find(".tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){i.tagsEditorShown=true},onhide:function(){i.tagsEditorShown=false},$activator:faIconButton({title:_l("Edit dataset tags"),classes:"dataset-tag-btn",faIcon:"fa-tags"}).appendTo(h.find(".dataset-actions .right"))});if(this.tagsEditorShown){this.tagsEditor.toggle(true)}},_renderAnnotation:function(h){var i=this;this.annotationEditor=new e.AnnotationEditor({model:this.model,el:h.find(".annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){i.annotationEditorShown=true},onhide:function(){i.annotationEditorShown=false},$activator:faIconButton({title:_l("Edit dataset annotation"),classes:"dataset-annotate-btn",faIcon:"fa-comment"}).appendTo(h.find(".dataset-actions .right"))});if(this.annotationEditorShown){this.annotationEditor.toggle(true)}},makeDbkeyEditLink:function(i){if(this.model.get("metadata_dbkey")==="?"&&!this.model.isDeletedOrPurged()){var h=$('<a class="value">?</a>').attr("href",this.urls.edit).attr("target",this.linkTarget);i.find(".dataset-dbkey .value").replaceWith(h)}},events:_.extend(_.clone(b.HDABaseView.prototype.events),{"click .dataset-undelete":function(h){this.model.undelete();return false},"click .dataset-unhide":function(h){this.model.unhide();return false},"click .dataset-purge":"confirmPurge"}),confirmPurge:function d(h){this.model.purge();return false},toString:function(){var h=(this.model)?(this.model+""):("(no model)");return"HDAView("+h+")"}});function c(h,j,i){return function(){var k={};if(i){k["f-dbkey"]=i}$.ajax({url:h+"/list_tracks?"+$.param(k),dataType:"html",error:function(){alert(("Could not add this dataset to browser")+".")},success:function(l){var m=window.parent;m.Galaxy.modal.show({title:"View Data in a New or Saved Visualization",buttons:{Cancel:function(){m.Galaxy.modal.hide()},"View in saved visualization":function(){m.Galaxy.modal.show({title:"Add Data to Saved Visualization",body:l,buttons:{Cancel:function(){m.Galaxy.modal.hide()},"Add to visualization":function(){$(m.document).find("input[name=id]:checked").each(function(){m.Galaxy.modal.hide();var n=$(this).val();j.id=n;m.Galaxy.frame.add({title:"Trackster",type:"url",content:h+"/trackster?"+$.param(j)})})}}})},"View in new visualization":function(){m.Galaxy.modal.hide();var n=h+"/trackster?"+$.param(j);m.Galaxy.frame.add({title:"Trackster",type:"url",content:n})}}})}});return false}}return{HDAEditView:g}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/dataset/hda-model.js --- a/static/scripts/packed/mvc/dataset/hda-model.js +++ b/static/scripts/packed/mvc/dataset/hda-model.js @@ -1,1 +1,1 @@ -define([],function(){var d=Backbone.Model.extend(LoggableMixin).extend({defaults:{history_id:null,model_class:"HistoryDatasetAssociation",hid:0,id:null,name:"(unnamed dataset)",state:"new",deleted:false,visible:true,accessible:true,purged:false,data_type:"",file_size:0,file_ext:"",meta_files:[],misc_blurb:"",misc_info:"",tags:[],annotation:""},urlRoot:galaxy_config.root+"api/histories/",url:function(){return this.urlRoot+this.get("history_id")+"/contents/"+this.get("id")},urls:function(){var i=this.get("id");if(!i){return{}}var h={purge:galaxy_config.root+"datasets/"+i+"/purge_async",display:galaxy_config.root+"datasets/"+i+"/display/?preview=True",edit:galaxy_config.root+"datasets/"+i+"/edit",download:galaxy_config.root+"datasets/"+i+"/display?to_ext="+this.get("file_ext"),report_error:galaxy_config.root+"dataset/errors?id="+i,rerun:galaxy_config.root+"tool_runner/rerun?id="+i,show_params:galaxy_config.root+"datasets/"+i+"/show_params",visualization:galaxy_config.root+"visualization",annotation:{get:galaxy_config.root+"dataset/get_annotation_async?id="+i,set:galaxy_config.root+"dataset/annotate_async?id="+i},meta_download:galaxy_config.root+"dataset/get_metadata_file?hda_id="+i+"&metadata_name="};return h},initialize:function(h){this.log(this+".initialize",this.attributes);this.log("\tparent history_id: "+this.get("history_id"));if(!this.get("accessible")){this.set("state",d.STATES.NOT_VIEWABLE)}this._setUpListeners()},_setUpListeners:function(){this.on("change:state",function(i,h){this.log(this+" has changed state:",i,h);if(this.inReadyState()){this.trigger("state:ready",i,h,this.previous("state"))}})},isDeletedOrPurged:function(){return(this.get("deleted")||this.get("purged"))},isVisible:function(i,j){var h=true;if((!i)&&(this.get("deleted")||this.get("purged"))){h=false}if((!j)&&(!this.get("visible"))){h=false}return h},hidden:function(){return !this.get("visible")},inReadyState:function(){var h=_.contains(d.READY_STATES,this.get("state"));return(this.isDeletedOrPurged()||h)},hasDetails:function(){return _.has(this.attributes,"genome_build")},hasData:function(){return(this.get("file_size")>0)},"delete":function c(h){if(this.get("deleted")){return jQuery.when()}return this.save({deleted:true},h)},undelete:function a(h){if(!this.get("deleted")||this.get("purged")){return jQuery.when()}return this.save({deleted:false},h)},hide:function b(h){if(!this.get("visible")){return jQuery.when()}return this.save({visible:false},h)},unhide:function g(h){if(this.get("visible")){return jQuery.when()}return this.save({visible:true},h)},purge:function f(h){if(this.get("purged")){return jQuery.when()}h=h||{};h.url=galaxy_config.root+"datasets/"+this.get("id")+"/purge_async";var i=this,j=jQuery.ajax(h);j.done(function(m,k,l){i.set({deleted:true,purged:true})});j.fail(function(o,k,n){var l=_l("Unable to purge dataset");var m=("Removal of datasets by users is not allowed in this Galaxy instance");if(o.responseJSON&&o.responseJSON.error){l=o.responseJSON.error}else{if(o.responseText.indexOf(m)!==-1){l=m}}o.responseText=l;i.trigger("error",i,o,h,_l(l),{error:l})});return j},searchAttributes:["name","file_ext","genome_build","misc_blurb","misc_info","annotation","tags"],searchAliases:{title:"name",format:"file_ext",database:"genome_build",blurb:"misc_blurb",description:"misc_blurb",info:"misc_info",tag:"tags"},searchAttribute:function(j,h){var i=this.get(j);if(!h||(i===undefined||i===null)){return false}if(_.isArray(i)){return this._searchArrayAttribute(i,h)}return(i.toString().toLowerCase().indexOf(h.toLowerCase())!==-1)},_searchArrayAttribute:function(i,h){h=h.toLowerCase();return _.any(i,function(j){return(j.toString().toLowerCase().indexOf(h.toLowerCase())!==-1)})},search:function(h){var i=this;return _.filter(this.searchAttributes,function(j){return i.searchAttribute(j,h)})},matches:function(i){var k="=",h=i.split(k);if(h.length>=2){var j=h[0];j=this.searchAliases[j]||j;return this.searchAttribute(j,h[1])}return !!this.search(i).length},matchesAll:function(i){var h=this;i=i.match(/(".*"|\w*=".*"|\S*)/g).filter(function(j){return !!j});return _.all(i,function(j){j=j.replace(/"/g,"");return h.matches(j)})},toString:function(){var h=this.get("id")||"";if(this.get("name")){h=this.get("hid")+' :"'+this.get("name")+'",'+h}return"HDA("+h+")"}});d.STATES={UPLOAD:"upload",QUEUED:"queued",RUNNING:"running",SETTING_METADATA:"setting_metadata",NEW:"new",EMPTY:"empty",OK:"ok",PAUSED:"paused",FAILED_METADATA:"failed_metadata",NOT_VIEWABLE:"noPermission",DISCARDED:"discarded",ERROR:"error"};d.READY_STATES=[d.STATES.NEW,d.STATES.OK,d.STATES.EMPTY,d.STATES.PAUSED,d.STATES.FAILED_METADATA,d.STATES.NOT_VIEWABLE,d.STATES.DISCARDED,d.STATES.ERROR];d.NOT_READY_STATES=[d.STATES.UPLOAD,d.STATES.QUEUED,d.STATES.RUNNING,d.STATES.SETTING_METADATA];var e=Backbone.Collection.extend(LoggableMixin).extend({model:d,urlRoot:galaxy_config.root+"api/histories",url:function(){return this.urlRoot+"/"+this.historyId+"/contents"},initialize:function(i,h){h=h||{};this.historyId=h.historyId},ids:function(){return this.map(function(h){return h.id})},notReady:function(){return this.filter(function(h){return !h.inReadyState()})},running:function(){var h=[];this.each(function(i){if(!i.inReadyState()){h.push(i.get("id"))}});return h},getByHid:function(h){return _.first(this.filter(function(i){return i.get("hid")===h}))},getVisible:function(h,k,j){j=j||[];var i=new e(this.filter(function(l){return l.isVisible(h,k)}));_.each(j,function(l){if(!_.isFunction(l)){return}i=new e(i.filter(l))});return i},haveDetails:function(){return this.all(function(h){return h.hasDetails()})},fetchAllDetails:function(i){i=i||{};var h={details:"all"};i.data=(i.data)?(_.extend(i.data,h)):(h);return this.fetch(i)},ajaxQueue:function(k,j){var i=jQuery.Deferred(),h=this.length,m=[];if(!h){i.resolve([]);return i}var l=this.chain().reverse().map(function(o,n){return function(){var p=k.call(o,j);p.done(function(q){i.notify({curr:n,total:h,response:q,model:o})});p.always(function(q){m.push(q);if(l.length){l.shift()()}else{i.resolve(m)}})}}).value();l.shift()();return i},matches:function(h){return this.filter(function(i){return i.matches(h)})},set:function(j,h){var i=this;j=_.map(j,function(l){var m=i.get(l.id);if(!m){return l}var k=m.toJSON();_.extend(k,l);return k});Backbone.Collection.prototype.set.call(this,j,h)},toString:function(){return(["HDACollection(",[this.historyId,this.length].join(),")"].join(""))}});return{HistoryDatasetAssociation:d,HDACollection:e}}); \ No newline at end of file +define(["mvc/base-mvc"],function(b){var e=Backbone.Model.extend(b.LoggableMixin).extend({defaults:{history_id:null,model_class:"HistoryDatasetAssociation",hid:0,id:null,name:"(unnamed dataset)",state:"new",deleted:false,visible:true,accessible:true,purged:false,data_type:"",file_size:0,file_ext:"",meta_files:[],misc_blurb:"",misc_info:"",tags:[],annotation:""},urlRoot:galaxy_config.root+"api/histories/",url:function(){return this.urlRoot+this.get("history_id")+"/contents/"+this.get("id")},urls:function(){var j=this.get("id");if(!j){return{}}var i={purge:galaxy_config.root+"datasets/"+j+"/purge_async",display:galaxy_config.root+"datasets/"+j+"/display/?preview=True",edit:galaxy_config.root+"datasets/"+j+"/edit",download:galaxy_config.root+"datasets/"+j+"/display?to_ext="+this.get("file_ext"),report_error:galaxy_config.root+"dataset/errors?id="+j,rerun:galaxy_config.root+"tool_runner/rerun?id="+j,show_params:galaxy_config.root+"datasets/"+j+"/show_params",visualization:galaxy_config.root+"visualization",annotation:{get:galaxy_config.root+"dataset/get_annotation_async?id="+j,set:galaxy_config.root+"dataset/annotate_async?id="+j},meta_download:galaxy_config.root+"dataset/get_metadata_file?hda_id="+j+"&metadata_name="};return i},initialize:function(i){this.log(this+".initialize",this.attributes);this.log("\tparent history_id: "+this.get("history_id"));if(!this.get("accessible")){this.set("state",e.STATES.NOT_VIEWABLE)}this._setUpListeners()},_setUpListeners:function(){this.on("change:state",function(j,i){this.log(this+" has changed state:",j,i);if(this.inReadyState()){this.trigger("state:ready",j,i,this.previous("state"))}})},isDeletedOrPurged:function(){return(this.get("deleted")||this.get("purged"))},isVisible:function(j,k){var i=true;if((!j)&&(this.get("deleted")||this.get("purged"))){i=false}if((!k)&&(!this.get("visible"))){i=false}return i},hidden:function(){return !this.get("visible")},inReadyState:function(){var i=_.contains(e.READY_STATES,this.get("state"));return(this.isDeletedOrPurged()||i)},hasDetails:function(){return _.has(this.attributes,"genome_build")},hasData:function(){return(this.get("file_size")>0)},"delete":function d(i){if(this.get("deleted")){return jQuery.when()}return this.save({deleted:true},i)},undelete:function a(i){if(!this.get("deleted")||this.get("purged")){return jQuery.when()}return this.save({deleted:false},i)},hide:function c(i){if(!this.get("visible")){return jQuery.when()}return this.save({visible:false},i)},unhide:function h(i){if(this.get("visible")){return jQuery.when()}return this.save({visible:true},i)},purge:function g(i){if(this.get("purged")){return jQuery.when()}i=i||{};i.url=galaxy_config.root+"datasets/"+this.get("id")+"/purge_async";var j=this,k=jQuery.ajax(i);k.done(function(n,l,m){j.set({deleted:true,purged:true})});k.fail(function(p,l,o){var m=_l("Unable to purge dataset");var n=("Removal of datasets by users is not allowed in this Galaxy instance");if(p.responseJSON&&p.responseJSON.error){m=p.responseJSON.error}else{if(p.responseText.indexOf(n)!==-1){m=n}}p.responseText=m;j.trigger("error",j,p,i,_l(m),{error:m})});return k},searchAttributes:["name","file_ext","genome_build","misc_blurb","misc_info","annotation","tags"],searchAliases:{title:"name",format:"file_ext",database:"genome_build",blurb:"misc_blurb",description:"misc_blurb",info:"misc_info",tag:"tags"},searchAttribute:function(k,i){var j=this.get(k);if(!i||(j===undefined||j===null)){return false}if(_.isArray(j)){return this._searchArrayAttribute(j,i)}return(j.toString().toLowerCase().indexOf(i.toLowerCase())!==-1)},_searchArrayAttribute:function(j,i){i=i.toLowerCase();return _.any(j,function(k){return(k.toString().toLowerCase().indexOf(i.toLowerCase())!==-1)})},search:function(i){var j=this;return _.filter(this.searchAttributes,function(k){return j.searchAttribute(k,i)})},matches:function(j){var l="=",i=j.split(l);if(i.length>=2){var k=i[0];k=this.searchAliases[k]||k;return this.searchAttribute(k,i[1])}return !!this.search(j).length},matchesAll:function(j){var i=this;j=j.match(/(".*"|\w*=".*"|\S*)/g).filter(function(k){return !!k});return _.all(j,function(k){k=k.replace(/"/g,"");return i.matches(k)})},toString:function(){var i=this.get("id")||"";if(this.get("name")){i=this.get("hid")+' :"'+this.get("name")+'",'+i}return"HDA("+i+")"}});e.STATES={UPLOAD:"upload",QUEUED:"queued",RUNNING:"running",SETTING_METADATA:"setting_metadata",NEW:"new",EMPTY:"empty",OK:"ok",PAUSED:"paused",FAILED_METADATA:"failed_metadata",NOT_VIEWABLE:"noPermission",DISCARDED:"discarded",ERROR:"error"};e.READY_STATES=[e.STATES.NEW,e.STATES.OK,e.STATES.EMPTY,e.STATES.PAUSED,e.STATES.FAILED_METADATA,e.STATES.NOT_VIEWABLE,e.STATES.DISCARDED,e.STATES.ERROR];e.NOT_READY_STATES=[e.STATES.UPLOAD,e.STATES.QUEUED,e.STATES.RUNNING,e.STATES.SETTING_METADATA];var f=Backbone.Collection.extend(b.LoggableMixin).extend({model:e,urlRoot:galaxy_config.root+"api/histories",url:function(){return this.urlRoot+"/"+this.historyId+"/contents"},initialize:function(j,i){i=i||{};this.historyId=i.historyId},ids:function(){return this.map(function(i){return i.id})},notReady:function(){return this.filter(function(i){return !i.inReadyState()})},running:function(){var i=[];this.each(function(j){if(!j.inReadyState()){i.push(j.get("id"))}});return i},getByHid:function(i){return _.first(this.filter(function(j){return j.get("hid")===i}))},getVisible:function(i,l,k){k=k||[];var j=new f(this.filter(function(m){return m.isVisible(i,l)}));_.each(k,function(m){if(!_.isFunction(m)){return}j=new f(j.filter(m))});return j},haveDetails:function(){return this.all(function(i){return i.hasDetails()})},fetchAllDetails:function(j){j=j||{};var i={details:"all"};j.data=(j.data)?(_.extend(j.data,i)):(i);return this.fetch(j)},ajaxQueue:function(l,k){var j=jQuery.Deferred(),i=this.length,n=[];if(!i){j.resolve([]);return j}var m=this.chain().reverse().map(function(p,o){return function(){var q=l.call(p,k);q.done(function(r){j.notify({curr:o,total:i,response:r,model:p})});q.always(function(r){n.push(r);if(m.length){m.shift()()}else{j.resolve(n)}})}}).value();m.shift()();return j},matches:function(i){return this.filter(function(j){return j.matches(i)})},set:function(k,i){var j=this;k=_.map(k,function(m){var n=j.get(m.id);if(!n){return m}var l=n.toJSON();_.extend(l,m);return l});Backbone.Collection.prototype.set.call(this,k,i)},toString:function(){return(["HDACollection(",[this.historyId,this.length].join(),")"].join(""))}});return{HistoryDatasetAssociation:e,HDACollection:f}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/history/current-history-panel.js --- a/static/scripts/packed/mvc/history/current-history-panel.js +++ b/static/scripts/packed/mvc/history/current-history-panel.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-edit","mvc/history/history-panel"],function(b,e){var c=SessionStorageModel.extend({defaults:{searching:false,tagsEditorShown:false,annotationEditorShown:false},toString:function(){return"HistoryPanelPrefs("+JSON.stringify(this.toJSON())+")"}});c.storageKey=function d(){return("history-panel")};var a=e.HistoryPanel.extend({HDAViewClass:b.HDAEditView,emptyMsg:_l("This history is empty. Click 'Get Data' on the left tool menu to start"),noneFoundMsg:_l("No matching datasets found"),initialize:function(f){f=f||{};this.preferences=new c(_.extend({id:c.storageKey()},_.pick(f,_.keys(c.prototype.defaults))));e.HistoryPanel.prototype.initialize.call(this,f)},loadCurrentHistory:function(g){var f=this;return this.loadHistoryWithHDADetails("current",g).then(function(i,h){f.trigger("current-history",f)})},switchToHistory:function(i,h){var f=this,g=function(){return jQuery.post(galaxy_config.root+"api/histories/"+i+"/set_as_current")};return this.loadHistoryWithHDADetails(i,h,g).then(function(k,j){f.trigger("switched-history",f)})},createNewHistory:function(h){if(!Galaxy||!Galaxy.currUser||Galaxy.currUser.isAnonymous()){this.displayMessage("error",_l("You must be logged in to create histories"));return $.when()}var f=this,g=function(){return jQuery.post(galaxy_config.root+"api/histories",{current:true})};return this.loadHistory(undefined,h,g).then(function(j,i){f.trigger("new-history",f)})},setModel:function(g,f,h){e.HistoryPanel.prototype.setModel.call(this,g,f,h);if(this.model){this.log("checking for updates");this.model.checkForUpdates()}return this},_setUpModelEventHandlers:function(){e.HistoryPanel.prototype._setUpModelEventHandlers.call(this);if(Galaxy&&Galaxy.quotaMeter){this.listenTo(this.model,"change:nice_size",function(){Galaxy.quotaMeter.update()})}this.model.hdas.on("state:ready",function(g,h,f){if((!g.get("visible"))&&(!this.storage.get("show_hidden"))){this.removeHdaView(this.hdaViews[g.id])}},this)},render:function(h,i){h=(h===undefined)?(this.fxSpeed):(h);var f=this,g;if(this.model){g=this.renderModel()}else{g=this.renderWithoutModel()}$(f).queue("fx",[function(j){if(h&&f.$el.is(":visible")){f.$el.fadeOut(h,j)}else{j()}},function(j){f.$el.empty();if(g){f.$el.append(g.children());f.renderBasedOnPrefs()}j()},function(j){if(h&&!f.$el.is(":visible")){f.$el.fadeIn(h,j)}else{j()}},function(j){if(i){i.call(this)}f.trigger("rendered",this);j()}]);return this},renderBasedOnPrefs:function(){if(this.preferences.get("searching")){this.toggleSearchControls(0,true)}},_renderEmptyMsg:function(h){var g=this,f=g.$emptyMessage(h),i=$(".toolMenuContainer");if((_.isEmpty(g.hdaViews)&&!g.searchFor)&&(Galaxy&&Galaxy.upload&&i.size())){f.empty();f.html([_l("This history is empty. "),_l("You can "),'<a class="uploader-link" href="javascript:void(0)">',_l("load your own data"),"</a>",_l(" or "),'<a class="get-data-link" href="javascript:void(0)">',_l("get data from an external source"),"</a>"].join(""));f.find(".uploader-link").click(function(j){Galaxy.upload._eventShow(j)});f.find(".get-data-link").click(function(j){i.parent().scrollTop(0);i.find('span:contains("Get Data")').click()});f.show()}else{e.HistoryPanel.prototype._renderEmptyMsg.call(this,h)}return this},toggleSearchControls:function(g,f){var h=e.HistoryPanel.prototype.toggleSearchControls.call(this,g,f);this.preferences.set("searching",h)},_renderTags:function(f){var g=this;e.HistoryPanel.prototype._renderTags.call(this,f);if(this.preferences.get("tagsEditorShown")){this.tagsEditor.toggle(true)}this.tagsEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(h){g.preferences.set("tagsEditorShown",h.hidden)})},_renderAnnotation:function(f){var g=this;e.HistoryPanel.prototype._renderAnnotation.call(this,f);if(this.preferences.get("annotationEditorShown")){this.annotationEditor.toggle(true)}this.annotationEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(h){g.preferences.set("annotationEditorShown",h.hidden)})},connectToQuotaMeter:function(f){if(!f){return this}this.listenTo(f,"quota:over",this.showQuotaMessage);this.listenTo(f,"quota:under",this.hideQuotaMessage);this.on("rendered rendered:initial",function(){if(f&&f.isOverQuota()){this.showQuotaMessage()}});return this},showQuotaMessage:function(){var f=this.$el.find(".quota-message");if(f.is(":hidden")){f.slideDown(this.fxSpeed)}},hideQuotaMessage:function(){var f=this.$el.find(".quota-message");if(!f.is(":hidden")){f.slideUp(this.fxSpeed)}},connectToOptionsMenu:function(f){if(!f){return this}this.on("new-storage",function(h,g){if(f&&h){f.findItemByHtml(_l("Include Deleted Datasets")).checked=h.get("show_deleted");f.findItemByHtml(_l("Include Hidden Datasets")).checked=h.get("show_hidden")}});return this},toString:function(){return"CurrentHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});return{CurrentHistoryPanel:a}}); \ No newline at end of file +define(["mvc/dataset/hda-edit","mvc/history/history-panel","mvc/base-mvc"],function(b,f,c){var d=c.SessionStorageModel.extend({defaults:{searching:false,tagsEditorShown:false,annotationEditorShown:false},toString:function(){return"HistoryPanelPrefs("+JSON.stringify(this.toJSON())+")"}});d.storageKey=function e(){return("history-panel")};var a=f.HistoryPanel.extend({HDAViewClass:b.HDAEditView,emptyMsg:_l("This history is empty. Click 'Get Data' on the left tool menu to start"),noneFoundMsg:_l("No matching datasets found"),initialize:function(g){g=g||{};this.preferences=new d(_.extend({id:d.storageKey()},_.pick(g,_.keys(d.prototype.defaults))));f.HistoryPanel.prototype.initialize.call(this,g)},loadCurrentHistory:function(h){var g=this;return this.loadHistoryWithHDADetails("current",h).then(function(j,i){g.trigger("current-history",g)})},switchToHistory:function(j,i){var g=this,h=function(){return jQuery.post(galaxy_config.root+"api/histories/"+j+"/set_as_current")};return this.loadHistoryWithHDADetails(j,i,h).then(function(l,k){g.trigger("switched-history",g)})},createNewHistory:function(i){if(!Galaxy||!Galaxy.currUser||Galaxy.currUser.isAnonymous()){this.displayMessage("error",_l("You must be logged in to create histories"));return $.when()}var g=this,h=function(){return jQuery.post(galaxy_config.root+"api/histories",{current:true})};return this.loadHistory(undefined,i,h).then(function(k,j){g.trigger("new-history",g)})},setModel:function(h,g,i){f.HistoryPanel.prototype.setModel.call(this,h,g,i);if(this.model){this.log("checking for updates");this.model.checkForUpdates()}return this},_setUpModelEventHandlers:function(){f.HistoryPanel.prototype._setUpModelEventHandlers.call(this);if(Galaxy&&Galaxy.quotaMeter){this.listenTo(this.model,"change:nice_size",function(){Galaxy.quotaMeter.update()})}this.model.hdas.on("state:ready",function(h,i,g){if((!h.get("visible"))&&(!this.storage.get("show_hidden"))){this.removeHdaView(this.hdaViews[h.id])}},this)},render:function(i,j){i=(i===undefined)?(this.fxSpeed):(i);var g=this,h;if(this.model){h=this.renderModel()}else{h=this.renderWithoutModel()}$(g).queue("fx",[function(k){if(i&&g.$el.is(":visible")){g.$el.fadeOut(i,k)}else{k()}},function(k){g.$el.empty();if(h){g.$el.append(h.children());g.renderBasedOnPrefs()}k()},function(k){if(i&&!g.$el.is(":visible")){g.$el.fadeIn(i,k)}else{k()}},function(k){if(j){j.call(this)}g.trigger("rendered",this);k()}]);return this},renderBasedOnPrefs:function(){if(this.preferences.get("searching")){this.toggleSearchControls(0,true)}},_renderEmptyMsg:function(i){var h=this,g=h.$emptyMessage(i),j=$(".toolMenuContainer");if((_.isEmpty(h.hdaViews)&&!h.searchFor)&&(Galaxy&&Galaxy.upload&&j.size())){g.empty();g.html([_l("This history is empty. "),_l("You can "),'<a class="uploader-link" href="javascript:void(0)">',_l("load your own data"),"</a>",_l(" or "),'<a class="get-data-link" href="javascript:void(0)">',_l("get data from an external source"),"</a>"].join(""));g.find(".uploader-link").click(function(k){Galaxy.upload._eventShow(k)});g.find(".get-data-link").click(function(k){j.parent().scrollTop(0);j.find('span:contains("Get Data")').click()});g.show()}else{f.HistoryPanel.prototype._renderEmptyMsg.call(this,i)}return this},toggleSearchControls:function(h,g){var i=f.HistoryPanel.prototype.toggleSearchControls.call(this,h,g);this.preferences.set("searching",i)},_renderTags:function(g){var h=this;f.HistoryPanel.prototype._renderTags.call(this,g);if(this.preferences.get("tagsEditorShown")){this.tagsEditor.toggle(true)}this.tagsEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(i){h.preferences.set("tagsEditorShown",i.hidden)})},_renderAnnotation:function(g){var h=this;f.HistoryPanel.prototype._renderAnnotation.call(this,g);if(this.preferences.get("annotationEditorShown")){this.annotationEditor.toggle(true)}this.annotationEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(i){h.preferences.set("annotationEditorShown",i.hidden)})},connectToQuotaMeter:function(g){if(!g){return this}this.listenTo(g,"quota:over",this.showQuotaMessage);this.listenTo(g,"quota:under",this.hideQuotaMessage);this.on("rendered rendered:initial",function(){if(g&&g.isOverQuota()){this.showQuotaMessage()}});return this},showQuotaMessage:function(){var g=this.$el.find(".quota-message");if(g.is(":hidden")){g.slideDown(this.fxSpeed)}},hideQuotaMessage:function(){var g=this.$el.find(".quota-message");if(!g.is(":hidden")){g.slideUp(this.fxSpeed)}},connectToOptionsMenu:function(g){if(!g){return this}this.on("new-storage",function(i,h){if(g&&i){g.findItemByHtml(_l("Include Deleted Datasets")).checked=i.get("show_deleted");g.findItemByHtml(_l("Include Hidden Datasets")).checked=i.get("show_hidden")}});return this},toString:function(){return"CurrentHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});return{CurrentHistoryPanel:a}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/history/history-model.js --- a/static/scripts/packed/mvc/history/history-model.js +++ b/static/scripts/packed/mvc/history/history-model.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-model"],function(a){var c=Backbone.Model.extend(LoggableMixin).extend({defaults:{model_class:"History",id:null,name:"Unnamed History",state:"new",diskSize:0,deleted:false},urlRoot:galaxy_config.root+"api/histories",renameUrl:function(){var e=this.get("id");if(!e){return undefined}return galaxy_config.root+"history/rename_async?id="+this.get("id")},annotateUrl:function(){var e=this.get("id");if(!e){return undefined}return galaxy_config.root+"history/annotate_async?id="+this.get("id")},tagUrl:function(){var e=this.get("id");if(!e){return undefined}return galaxy_config.root+"tag/get_tagging_elt_async?item_id="+this.get("id")+"&item_class=History"},initialize:function(f,g,e){e=e||{};this.logger=e.logger||null;this.log(this+".initialize:",f,g,e);this.hdas=new a.HDACollection(g||[],{historyId:this.get("id")});if(g&&_.isArray(g)){this.hdas.reset(g)}this._setUpListeners();this.updateTimeoutId=null},_setUpListeners:function(){this.on("error",function(f,i,e,h,g){this.errorHandler(f,i,e,h,g)});if(this.hdas){this.listenTo(this.hdas,"error",function(){this.trigger.apply(this,["error:hdas"].concat(jQuery.makeArray(arguments)))})}this.on("change:id",function(f,e){if(this.hdas){this.hdas.historyId=e}},this)},errorHandler:function(f,i,e,h,g){this.clearUpdateTimeout()},hasUser:function(){var e=this.get("user");return !!(e&&e.id)},ownedByCurrUser:function(){if(!Galaxy||!Galaxy.currUser){return false}if(Galaxy.currUser.isAnonymous()||Galaxy.currUser.id!==this.get("user_id")){return false}return true},hdaCount:function(){return _.reduce(_.values(this.get("state_details")),function(e,f){return e+f},0)},checkForUpdates:function(e){if(this.hdas.running().length){this.setUpdateTimeout()}else{this.trigger("ready");if(_.isFunction(e)){e.call(this)}}return this},setUpdateTimeout:function(e){e=e||c.UPDATE_DELAY;var f=this;this.clearUpdateTimeout();this.updateTimeoutId=setTimeout(function(){f.refresh()},e);return this.updateTimeoutId},clearUpdateTimeout:function(){if(this.updateTimeoutId){clearTimeout(this.updateTimeoutId);this.updateTimeoutId=null}},refresh:function(f,e){f=f||[];e=e||{};var g=this;e.data=e.data||{};if(f.length){e.data.details=f.join(",")}var h=this.hdas.fetch(e);h.done(function(i){g.checkForUpdates(function(){this.fetch()})});return h},toString:function(){return"History("+this.get("id")+","+this.get("name")+")"}});c.UPDATE_DELAY=4000;c.getHistoryData=function d(f,p){p=p||{};var j=p.hdaDetailIds||[];var l=jQuery.Deferred(),k=null;function g(q){return jQuery.ajax(galaxy_config.root+"api/histories/"+f)}function e(q){if(!q||!q.state_ids){return 0}return _.reduce(q.state_ids,function(r,t,s){return r+t.length},0)}function o(r){if(!e(r)){return[]}if(_.isFunction(j)){j=j(r)}var q=(j.length)?({details:j.join(",")}):({});return jQuery.ajax(galaxy_config.root+"api/histories/"+r.id+"/contents",{data:q})}var n=p.historyFn||g,m=p.hdaFn||o;var i=n(f);i.done(function(q){k=q;l.notify({status:"history data retrieved",historyJSON:k})});i.fail(function(s,q,r){l.reject(s,"loading the history")});var h=i.then(m);h.then(function(q){l.notify({status:"dataset data retrieved",historyJSON:k,hdaJSON:q});l.resolve(k,q)});h.fail(function(s,q,r){l.reject(s,"loading the datasets",{history:k})});return l};var b=Backbone.Collection.extend(LoggableMixin).extend({model:c,urlRoot:galaxy_config.root+"api/histories"});return{History:c,HistoryCollection:b}}); \ No newline at end of file +define(["mvc/dataset/hda-model","mvc/base-mvc"],function(b,a){var d=Backbone.Model.extend(a.LoggableMixin).extend({defaults:{model_class:"History",id:null,name:"Unnamed History",state:"new",diskSize:0,deleted:false},urlRoot:galaxy_config.root+"api/histories",renameUrl:function(){var f=this.get("id");if(!f){return undefined}return galaxy_config.root+"history/rename_async?id="+this.get("id")},annotateUrl:function(){var f=this.get("id");if(!f){return undefined}return galaxy_config.root+"history/annotate_async?id="+this.get("id")},tagUrl:function(){var f=this.get("id");if(!f){return undefined}return galaxy_config.root+"tag/get_tagging_elt_async?item_id="+this.get("id")+"&item_class=History"},initialize:function(g,h,f){f=f||{};this.logger=f.logger||null;this.log(this+".initialize:",g,h,f);this.hdas=new b.HDACollection(h||[],{historyId:this.get("id")});if(h&&_.isArray(h)){this.hdas.reset(h)}this._setUpListeners();this.updateTimeoutId=null},_setUpListeners:function(){this.on("error",function(g,j,f,i,h){this.errorHandler(g,j,f,i,h)});if(this.hdas){this.listenTo(this.hdas,"error",function(){this.trigger.apply(this,["error:hdas"].concat(jQuery.makeArray(arguments)))})}this.on("change:id",function(g,f){if(this.hdas){this.hdas.historyId=f}},this)},errorHandler:function(g,j,f,i,h){this.clearUpdateTimeout()},ownedByCurrUser:function(){if(!Galaxy||!Galaxy.currUser){return false}if(Galaxy.currUser.isAnonymous()||Galaxy.currUser.id!==this.get("user_id")){return false}return true},hdaCount:function(){return _.reduce(_.values(this.get("state_details")),function(f,g){return f+g},0)},checkForUpdates:function(f){if(this.hdas.running().length){this.setUpdateTimeout()}else{this.trigger("ready");if(_.isFunction(f)){f.call(this)}}return this},setUpdateTimeout:function(f){f=f||d.UPDATE_DELAY;var g=this;this.clearUpdateTimeout();this.updateTimeoutId=setTimeout(function(){g.refresh()},f);return this.updateTimeoutId},clearUpdateTimeout:function(){if(this.updateTimeoutId){clearTimeout(this.updateTimeoutId);this.updateTimeoutId=null}},refresh:function(g,f){g=g||[];f=f||{};var h=this;f.data=f.data||{};if(g.length){f.data.details=g.join(",")}var i=this.hdas.fetch(f);i.done(function(j){h.checkForUpdates(function(){this.fetch()})});return i},toString:function(){return"History("+this.get("id")+","+this.get("name")+")"}});d.UPDATE_DELAY=4000;d.getHistoryData=function e(g,q){q=q||{};var k=q.hdaDetailIds||[];var m=jQuery.Deferred(),l=null;function h(r){return jQuery.ajax(galaxy_config.root+"api/histories/"+g)}function f(r){if(!r||!r.state_ids){return 0}return _.reduce(r.state_ids,function(s,u,t){return s+u.length},0)}function p(s){if(!f(s)){return[]}if(_.isFunction(k)){k=k(s)}var r=(k.length)?({details:k.join(",")}):({});return jQuery.ajax(galaxy_config.root+"api/histories/"+s.id+"/contents",{data:r})}var o=q.historyFn||h,n=q.hdaFn||p;var j=o(g);j.done(function(r){l=r;m.notify({status:"history data retrieved",historyJSON:l})});j.fail(function(t,r,s){m.reject(t,"loading the history")});var i=j.then(n);i.then(function(r){m.notify({status:"dataset data retrieved",historyJSON:l,hdaJSON:r});m.resolve(l,r)});i.fail(function(t,r,s){m.reject(t,"loading the datasets",{history:l})});return m};var c=Backbone.Collection.extend(a.LoggableMixin).extend({model:d,urlRoot:galaxy_config.root+"api/histories"});return{History:d,HistoryCollection:c}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/history/history-panel.js --- a/static/scripts/packed/mvc/history/history-panel.js +++ b/static/scripts/packed/mvc/history/history-panel.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-model","mvc/dataset/hda-edit","mvc/history/readonly-history-panel","mvc/tags","mvc/annotations"],function(e,b,d,a,c){var f=d.ReadOnlyHistoryPanel.extend({HDAViewClass:b.HDAEditView,initialize:function(g){g=g||{};this.selectedHdaIds=[];this.tagsEditor=null;this.annotationEditor=null;this.selecting=g.selecting||false;this.annotationEditorShown=g.annotationEditorShown||false;this.tagsEditorShown=g.tagsEditorShown||false;d.ReadOnlyHistoryPanel.prototype.initialize.call(this,g)},_setUpModelEventHandlers:function(){d.ReadOnlyHistoryPanel.prototype._setUpModelEventHandlers.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);this.model.hdas.on("change:deleted",this._handleHdaDeletionChange,this);this.model.hdas.on("change:visible",this._handleHdaVisibleChange,this);this.model.hdas.on("change:purged",function(g){this.model.fetch()},this)},renderModel:function(){var g=$("<div/>");g.append(f.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(g).text(this.emptyMsg);if(Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(g);this._renderAnnotation(g)}g.find(".history-secondary-actions").prepend(this._renderSelectButton());g.find(".history-dataset-actions").toggle(this.selecting);g.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(g);this.renderHdas(g);return g},_renderTags:function(g){var h=this;this.tagsEditor=new a.TagsEditor({model:this.model,el:g.find(".history-controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){h.toggleHDATagEditors(true,h.fxSpeed)},onhide:function(){h.toggleHDATagEditors(false,h.fxSpeed)},$activator:faIconButton({title:_l("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(g.find(".history-secondary-actions"))})},_renderAnnotation:function(g){var h=this;this.annotationEditor=new c.AnnotationEditor({model:this.model,el:g.find(".history-controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){h.toggleHDAAnnotationEditors(true,h.fxSpeed)},onhide:function(){h.toggleHDAAnnotationEditors(false,h.fxSpeed)},$activator:faIconButton({title:_l("Edit history Annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(g.find(".history-secondary-actions"))})},_renderSelectButton:function(g){return faIconButton({title:_l("Operations on multiple datasets"),classes:"history-select-btn",faIcon:"fa-check-square-o"})},_setUpBehaviours:function(g){g=g||this.$el;d.ReadOnlyHistoryPanel.prototype._setUpBehaviours.call(this,g);if(!this.model){return}this._setUpDatasetActionsPopup(g);if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var h=this;g.find(".history-name").attr("title",_l("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(i){var j=h.model.get("name");if(i&&i!==j){h.$el.find(".history-name").text(i);h.model.save({name:i}).fail(function(){h.$el.find(".history-name").text(h.model.previous("name"))})}else{h.$el.find(".history-name").text(j)}}})},_setUpDatasetActionsPopup:function(g){var h=this;(new PopupMenu(g.find(".history-dataset-action-popup-btn"),[{html:_l("Hide datasets"),func:function(){var i=e.HistoryDatasetAssociation.prototype.hide;h.getSelectedHdaCollection().ajaxQueue(i)}},{html:_l("Unhide datasets"),func:function(){var i=e.HistoryDatasetAssociation.prototype.unhide;h.getSelectedHdaCollection().ajaxQueue(i)}},{html:_l("Delete datasets"),func:function(){var i=e.HistoryDatasetAssociation.prototype["delete"];h.getSelectedHdaCollection().ajaxQueue(i)}},{html:_l("Undelete datasets"),func:function(){var i=e.HistoryDatasetAssociation.prototype.undelete;h.getSelectedHdaCollection().ajaxQueue(i)}},{html:_l("Permanently delete datasets"),func:function(){if(confirm(_l("This will permanently remove the data in your datasets. Are you sure?"))){var i=e.HistoryDatasetAssociation.prototype.purge;h.getSelectedHdaCollection().ajaxQueue(i)}}}]))},_handleHdaDeletionChange:function(g){if(g.get("deleted")&&!this.storage.get("show_deleted")){this.removeHdaView(this.hdaViews[g.id])}},_handleHdaVisibleChange:function(g){if(g.hidden()&&!this.storage.get("show_hidden")){this.removeHdaView(this.hdaViews[g.id])}},_createHdaView:function(h){var g=h.get("id"),i=new this.HDAViewClass({model:h,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[g],selectable:this.selecting,hasUser:this.model.ownedByCurrUser(),logger:this.logger,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)});this._setUpHdaListeners(i);return i},_setUpHdaListeners:function(h){var g=this;d.ReadOnlyHistoryPanel.prototype._setUpHdaListeners.call(this,h);h.on("selected",function(i){var j=i.model.get("id");g.selectedHdaIds=_.union(g.selectedHdaIds,[j])});h.on("de-selected",function(i){var j=i.model.get("id");g.selectedHdaIds=_.without(g.selectedHdaIds,j)})},toggleHDATagEditors:function(g){var h=arguments;_.each(this.hdaViews,function(i){if(i.tagsEditor){i.tagsEditor.toggle.apply(i.tagsEditor,h)}})},toggleHDAAnnotationEditors:function(g){var h=arguments;_.each(this.hdaViews,function(i){if(i.annotationEditor){i.annotationEditor.toggle.apply(i.annotationEditor,h)}})},removeHdaView:function(h){if(!h){return}var g=this;h.$el.fadeOut(g.fxSpeed,function(){h.off();h.remove();delete g.hdaViews[h.model.id];if(_.isEmpty(g.hdaViews)){g.$emptyMessage().fadeIn(g.fxSpeed,function(){g.trigger("empty-history",g)})}})},events:_.extend(_.clone(d.ReadOnlyHistoryPanel.prototype.events),{"click .history-select-btn":"toggleSelectors","click .history-select-all-datasets-btn":"selectAllDatasets","click .history-deselect-all-datasets-btn":"deselectAllDatasets"}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},showSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=true;this.$(".history-dataset-actions").slideDown(g);_.each(this.hdaViews,function(h){h.showSelector()});this.selectedHdaIds=[]},hideSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=false;this.$(".history-dataset-actions").slideUp(g);_.each(this.hdaViews,function(h){h.hideSelector()});this.selectedHdaIds=[]},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAllDatasets:function(g){_.each(this.hdaViews,function(h){h.select(g)})},deselectAllDatasets:function(g){_.each(this.hdaViews,function(h){h.deselect(g)})},getSelectedHdaViews:function(){return _.filter(this.hdaViews,function(g){return g.selected})},getSelectedHdaCollection:function(){return new e.HDACollection(_.map(this.getSelectedHdaViews(),function(g){return g.model}),{historyId:this.model.id})},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanel:f}}); \ No newline at end of file +define(["mvc/dataset/hda-model","mvc/dataset/hda-edit","mvc/history/readonly-history-panel","mvc/tags","mvc/annotations"],function(e,b,d,a,c){var f=d.ReadOnlyHistoryPanel.extend({HDAViewClass:b.HDAEditView,initialize:function(g){g=g||{};this.selectedHdaIds=[];this.tagsEditor=null;this.annotationEditor=null;this.selecting=g.selecting||false;this.annotationEditorShown=g.annotationEditorShown||false;this.tagsEditorShown=g.tagsEditorShown||false;d.ReadOnlyHistoryPanel.prototype.initialize.call(this,g)},_setUpModelEventHandlers:function(){d.ReadOnlyHistoryPanel.prototype._setUpModelEventHandlers.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);this.model.hdas.on("change:deleted",this._handleHdaDeletionChange,this);this.model.hdas.on("change:visible",this._handleHdaVisibleChange,this);this.model.hdas.on("change:purged",function(g){this.model.fetch()},this)},renderModel:function(){var g=$("<div/>");g.append(f.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(g).text(this.emptyMsg);if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(g);this._renderAnnotation(g)}g.find(".history-secondary-actions").prepend(this._renderSelectButton());g.find(".history-dataset-actions").toggle(this.selecting);g.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(g);this.renderHdas(g);return g},_renderTags:function(g){var h=this;this.tagsEditor=new a.TagsEditor({model:this.model,el:g.find(".history-controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){h.toggleHDATagEditors(true,h.fxSpeed)},onhide:function(){h.toggleHDATagEditors(false,h.fxSpeed)},$activator:faIconButton({title:_l("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(g.find(".history-secondary-actions"))})},_renderAnnotation:function(g){var h=this;this.annotationEditor=new c.AnnotationEditor({model:this.model,el:g.find(".history-controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){h.toggleHDAAnnotationEditors(true,h.fxSpeed)},onhide:function(){h.toggleHDAAnnotationEditors(false,h.fxSpeed)},$activator:faIconButton({title:_l("Edit history Annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(g.find(".history-secondary-actions"))})},_renderSelectButton:function(g){return faIconButton({title:_l("Operations on multiple datasets"),classes:"history-select-btn",faIcon:"fa-check-square-o"})},_setUpBehaviours:function(g){g=g||this.$el;d.ReadOnlyHistoryPanel.prototype._setUpBehaviours.call(this,g);if(!this.model){return}this._setUpDatasetActionsPopup(g);if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var h=this;g.find(".history-name").attr("title",_l("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(i){var j=h.model.get("name");if(i&&i!==j){h.$el.find(".history-name").text(i);h.model.save({name:i}).fail(function(){h.$el.find(".history-name").text(h.model.previous("name"))})}else{h.$el.find(".history-name").text(j)}}})},_setUpDatasetActionsPopup:function(g){var h=this;(new PopupMenu(g.find(".history-dataset-action-popup-btn"),[{html:_l("Hide datasets"),func:function(){var i=e.HistoryDatasetAssociation.prototype.hide;h.getSelectedHdaCollection().ajaxQueue(i)}},{html:_l("Unhide datasets"),func:function(){var i=e.HistoryDatasetAssociation.prototype.unhide;h.getSelectedHdaCollection().ajaxQueue(i)}},{html:_l("Delete datasets"),func:function(){var i=e.HistoryDatasetAssociation.prototype["delete"];h.getSelectedHdaCollection().ajaxQueue(i)}},{html:_l("Undelete datasets"),func:function(){var i=e.HistoryDatasetAssociation.prototype.undelete;h.getSelectedHdaCollection().ajaxQueue(i)}},{html:_l("Permanently delete datasets"),func:function(){if(confirm(_l("This will permanently remove the data in your datasets. Are you sure?"))){var i=e.HistoryDatasetAssociation.prototype.purge;h.getSelectedHdaCollection().ajaxQueue(i)}}}]))},_handleHdaDeletionChange:function(g){if(g.get("deleted")&&!this.storage.get("show_deleted")){this.removeHdaView(this.hdaViews[g.id])}},_handleHdaVisibleChange:function(g){if(g.hidden()&&!this.storage.get("show_hidden")){this.removeHdaView(this.hdaViews[g.id])}},_createHdaView:function(h){var g=h.get("id"),i=new this.HDAViewClass({model:h,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[g],selectable:this.selecting,hasUser:this.model.ownedByCurrUser(),logger:this.logger,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)});this._setUpHdaListeners(i);return i},_setUpHdaListeners:function(h){var g=this;d.ReadOnlyHistoryPanel.prototype._setUpHdaListeners.call(this,h);h.on("selected",function(i){var j=i.model.get("id");g.selectedHdaIds=_.union(g.selectedHdaIds,[j])});h.on("de-selected",function(i){var j=i.model.get("id");g.selectedHdaIds=_.without(g.selectedHdaIds,j)})},toggleHDATagEditors:function(g){var h=arguments;_.each(this.hdaViews,function(i){if(i.tagsEditor){i.tagsEditor.toggle.apply(i.tagsEditor,h)}})},toggleHDAAnnotationEditors:function(g){var h=arguments;_.each(this.hdaViews,function(i){if(i.annotationEditor){i.annotationEditor.toggle.apply(i.annotationEditor,h)}})},removeHdaView:function(h){if(!h){return}var g=this;h.$el.fadeOut(g.fxSpeed,function(){h.off();h.remove();delete g.hdaViews[h.model.id];if(_.isEmpty(g.hdaViews)){g.$emptyMessage().fadeIn(g.fxSpeed,function(){g.trigger("empty-history",g)})}})},events:_.extend(_.clone(d.ReadOnlyHistoryPanel.prototype.events),{"click .history-select-btn":"toggleSelectors","click .history-select-all-datasets-btn":"selectAllDatasets","click .history-deselect-all-datasets-btn":"deselectAllDatasets"}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},showSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=true;this.$(".history-dataset-actions").slideDown(g);_.each(this.hdaViews,function(h){h.showSelector()});this.selectedHdaIds=[]},hideSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=false;this.$(".history-dataset-actions").slideUp(g);_.each(this.hdaViews,function(h){h.hideSelector()});this.selectedHdaIds=[]},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAllDatasets:function(g){_.each(this.hdaViews,function(h){h.select(g)})},deselectAllDatasets:function(g){_.each(this.hdaViews,function(h){h.deselect(g)})},getSelectedHdaViews:function(){return _.filter(this.hdaViews,function(g){return g.selected})},getSelectedHdaCollection:function(){return new e.HDACollection(_.map(this.getSelectedHdaViews(),function(g){return g.model}),{historyId:this.model.id})},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanel:f}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/history/readonly-history-panel.js --- a/static/scripts/packed/mvc/history/readonly-history-panel.js +++ b/static/scripts/packed/mvc/history/readonly-history-panel.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-model","mvc/dataset/hda-base"],function(h,a){var g=SessionStorageModel.extend({defaults:{expandedHdas:{},show_deleted:false,show_hidden:false},addExpandedHda:function(j){var i="expandedHdas";this.save(i,_.extend(this.get(i),_.object([j],[true])))},removeExpandedHda:function(j){var i="expandedHdas";this.save(i,_.omit(this.get(i),j))},toString:function(){return"HistoryPrefs("+this.id+")"}});g.storageKeyPrefix="history:";g.historyStorageKey=function f(i){if(!i){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+i)}return(g.storageKeyPrefix+i)};g.get=function d(i){return new g({id:g.historyStorageKey(i)})};g.clearAll=function c(j){for(var i in sessionStorage){if(i.indexOf(g.storageKeyPrefix)===0){sessionStorage.removeItem(i)}}};var b=Backbone.View.extend(LoggableMixin).extend({HDAViewClass:a.HDABaseView,tagName:"div",className:"history-panel",fxSpeed:"fast",emptyMsg:_l("This history is empty"),noneFoundMsg:_l("No matching datasets found"),initialize:function(i){i=i||{};if(i.logger){this.logger=i.logger}this.log(this+".initialize:",i);this.linkTarget=i.linkTarget||"_blank";this.fxSpeed=_.has(i,"fxSpeed")?(i.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor="";this.findContainerFn=i.findContainerFn;this.hdaViews={};this.indicator=new LoadingIndicator(this.$el);this._setUpListeners();var j=_.pick(i,"initiallyExpanded","show_deleted","show_hidden");this.setModel(this.model,j,false);if(i.onready){i.onready.call(this)}},_setUpListeners:function(){this.on("error",function(j,m,i,l,k){this.errorHandler(j,m,i,l,k)});this.on("loading-history",function(){this._showLoadingIndicator("loading history...",40)});this.on("loading-done",function(){this._hideLoadingIndicator(40);if(_.isEmpty(this.hdaViews)){this.trigger("empty-history",this)}});this.once("rendered",function(){this.trigger("rendered:initial",this);return false});if(this.logger){this.on("all",function(i){this.log(this+"",arguments)},this)}return this},errorHandler:function(k,n,j,m,l){console.error(k,n,j,m,l);if(n&&n.status===0&&n.readyState===0){}else{if(n&&n.status===502){}else{var i=this._parseErrorMessage(k,n,j,m,l);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",i.message,i.details)})}else{this.displayMessage("error",i.message,i.details)}}}},_parseErrorMessage:function(l,p,k,o,n){var j=Galaxy.currUser,i={message:this._bePolite(o),details:{user:(j instanceof User)?(j.toJSON()):(j+""),source:(l instanceof Backbone.Model)?(l.toJSON()):(l+""),xhr:p,options:(p)?(_.omit(k,"xhr")):(k)}};_.extend(i.details,n||{});if(p&&_.isFunction(p.getAllResponseHeaders)){var m=p.getAllResponseHeaders();m=_.compact(m.split("\n"));m=_.map(m,function(q){return q.split(": ")});i.details.xhr.responseHeaders=_.object(m)}return i},_bePolite:function(i){i=i||_l("An error occurred while getting updates from the server");return i+". "+_l("Please contact a Galaxy administrator if the problem persists.")},loadHistoryWithHDADetails:function(k,j,i,m){var l=function(n){return _.keys(g.get(n.id).get("expandedHdas"))};return this.loadHistory(k,j,i,m,l)},loadHistory:function(l,k,j,o,m){var i=this;k=k||{};i.trigger("loading-history",i);var n=h.History.getHistoryData(l,{historyFn:j,hdaFn:o,hdaDetailIds:k.initiallyExpanded||m});return i._loadHistoryFromXHR(n,k).fail(function(r,p,q){i.trigger("error",i,r,k,_l("An error was encountered while "+p),{historyId:l,history:q||{}})}).always(function(){i.trigger("loading-done",i)})},_loadHistoryFromXHR:function(k,j){var i=this;k.then(function(l,m){i.JSONToModel(l,m,j)});k.fail(function(m,l){i.render()});return k},JSONToModel:function(l,i,j){this.log("JSONToModel:",l,i,j);j=j||{};if(Galaxy&&Galaxy.currUser){l.user=Galaxy.currUser.toJSON()}var k=new h.History(l,i,j);this.setModel(k);return this},setModel:function(j,i,k){i=i||{};k=(k!==undefined)?(k):(true);this.log("setModel:",j,i,k);this.freeModel();this.selectedHdaIds=[];if(j){if(Galaxy&&Galaxy.currUser){j.user=Galaxy.currUser.toJSON()}this.model=j;if(this.logger){this.model.logger=this.logger}this._setUpWebStorage(i.initiallyExpanded,i.show_deleted,i.show_hidden);this._setUpModelEventHandlers();this.trigger("new-model",this)}if(k){this.render()}return this},freeModel:function(){if(this.model){this.model.clearUpdateTimeout();this.stopListening(this.model);this.stopListening(this.model.hdas)}this.freeHdaViews();return this},freeHdaViews:function(){this.hdaViews={};return this},_setUpWebStorage:function(j,i,k){this.storage=new g({id:g.historyStorageKey(this.model.get("id"))});if(_.isObject(j)){this.storage.set("exandedHdas",j)}if(_.isBoolean(i)){this.storage.set("show_deleted",i)}if(_.isBoolean(k)){this.storage.set("show_hidden",k)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());return this},_setUpModelEventHandlers:function(){this.model.hdas.on("add",this.addHdaView,this);this.model.on("error error:hdas",function(j,l,i,k){this.errorHandler(j,l,i,k)},this);return this},render:function(k,l){this.log("render:",k,l);k=(k===undefined)?(this.fxSpeed):(k);var i=this,j;if(this.model){j=this.renderModel()}else{j=this.renderWithoutModel()}$(i).queue("fx",[function(m){if(k&&i.$el.is(":visible")){i.$el.fadeOut(k,m)}else{m()}},function(m){i.$el.empty();if(j){i.$el.append(j.children())}m()},function(m){if(k&&!i.$el.is(":visible")){i.$el.fadeIn(k,m)}else{m()}},function(m){if(l){l.call(this)}i.trigger("rendered",this);m()}]);return this},renderWithoutModel:function(){var i=$("<div/>"),j=$("<div/>").addClass("message-container").css({"margin-left":"4px","margin-right":"4px"});return i.append(j)},renderModel:function(){var i=$("<div/>");i.append(b.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(i).text(this.emptyMsg);i.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(i);this.renderHdas(i);return i},_renderEmptyMsg:function(k){var j=this,i=j.$emptyMessage(k);if(!_.isEmpty(j.hdaViews)){i.hide()}else{if(j.searchFor){i.text(j.noneFoundMsg).show()}else{i.text(j.emptyMsg).show()}}return this},_renderSearchButton:function(i){return faIconButton({title:_l("Search datasets"),classes:"history-search-btn",faIcon:"fa-search"})},_setUpBehaviours:function(i){i=i||this.$el;i.find("[title]").tooltip({placement:"bottom"});this._setUpSearchInput(i.find(".history-search-controls .history-search-input"));return this},$container:function(){return(this.findContainerFn)?(this.findContainerFn.call(this)):(this.$el.parent())},$datasetsList:function(i){return(i||this.$el).find(".datasets-list")},$messages:function(i){return(i||this.$el).find(".message-container")},$emptyMessage:function(i){return(i||this.$el).find(".empty-history-message")},renderHdas:function(j){j=j||this.$el;var i=this,l={},k=this.model.hdas.getVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"),this.filters);this.$datasetsList(j).empty();if(k.length){k.each(function(n){var m=n.get("id"),o=i._createHdaView(n);l[m]=o;if(_.contains(i.selectedHdaIds,m)){o.selected=true}i.attachHdaView(o.render(),j)})}this.hdaViews=l;this._renderEmptyMsg(j);return this.hdaViews},_createHdaView:function(j){var i=j.get("id"),k=new this.HDAViewClass({model:j,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[i],hasUser:this.model.ownedByCurrUser(),logger:this.logger});this._setUpHdaListeners(k);return k},_setUpHdaListeners:function(j){var i=this;j.on("error",function(l,n,k,m){i.errorHandler(l,n,k,m)});j.on("body-expanded",function(k){i.storage.addExpandedHda(k)});j.on("body-collapsed",function(k){i.storage.removeExpandedHda(k)});return this},attachHdaView:function(k,j){j=j||this.$el;var i=this.$datasetsList(j);i.prepend(k.$el);return this},addHdaView:function(l){this.log("add."+this,l);var j=this;if(!l.isVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"))){return j}$({}).queue([function k(n){var m=j.$emptyMessage();if(m.is(":visible")){m.fadeOut(j.fxSpeed,n)}else{n()}},function i(m){var n=j._createHdaView(l);j.hdaViews[l.id]=n;n.render().$el.hide();j.scrollToTop();j.attachHdaView(n);n.$el.slideDown(j.fxSpeed)}]);return j},refreshHdas:function(j,i){if(this.model){return this.model.refresh(j,i)}return $.when()},events:{"click .message-container":"clearMessages","click .history-search-btn":"toggleSearchControls"},collapseAllHdaBodies:function(){_.each(this.hdaViews,function(i){i.toggleBodyVisibility(null,false)});this.storage.set("expandedHdas",{});return this},toggleShowDeleted:function(i){i=(i!==undefined)?(i):(!this.storage.get("show_deleted"));this.storage.set("show_deleted",i);this.renderHdas();return this.storage.get("show_deleted")},toggleShowHidden:function(i){i=(i!==undefined)?(i):(!this.storage.get("show_hidden"));this.storage.set("show_hidden",i);this.renderHdas();return this.storage.get("show_hidden")},_setUpSearchInput:function(j){var k=this,l=".history-search-input";function i(m){if(k.model.hdas.haveDetails()){k.searchHdas(m);return}k.$el.find(l).searchInput("toggle-loading");k.model.hdas.fetchAllDetails({silent:true}).always(function(){k.$el.find(l).searchInput("toggle-loading")}).done(function(){k.searchHdas(m)})}j.searchInput({initialVal:k.searchFor,name:"history-search",placeholder:"search datasets",classes:"history-search",onfirstsearch:i,onsearch:_.bind(this.searchHdas,this),onclear:_.bind(this.clearHdaSearch,this)});return j},toggleSearchControls:function(k,i){var j=this.$el.find(".history-search-controls"),l=(jQuery.type(k)==="number")?(k):(this.fxSpeed);i=(i!==undefined)?(i):(!j.is(":visible"));if(i){j.slideDown(l,function(){$(this).find("input").focus()})}else{j.slideUp(l)}return i},searchHdas:function(i){var j=this;this.searchFor=i;this.filters=[function(k){return k.matchesAll(j.searchFor)}];this.trigger("search:searching",i,this);this.renderHdas();return this},clearHdaSearch:function(i){this.searchFor="";this.filters=[];this.trigger("search:clear",this);this.renderHdas();return this},_showLoadingIndicator:function(j,i,k){i=(i!==undefined)?(i):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent())}if(!this.$el.is(":visible")){this.indicator.show(0,k)}else{this.$el.fadeOut(i);this.indicator.show(j,i,k)}},_hideLoadingIndicator:function(i,j){i=(i!==undefined)?(i):(this.fxSpeed);if(this.indicator){this.indicator.hide(i,j)}},displayMessage:function(n,o,m){var k=this;this.scrollToTop();var l=this.$messages(),i=$("<div/>").addClass(n+"message").html(o);if(!_.isEmpty(m)){var j=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(k._messageToModalOptions(n,o,m));return false});i.append(" ",j)}return l.html(i)},_messageToModalOptions:function(m,o,l){var i=this,n=$("<div/>"),k={title:"Details"};function j(p){p=_.omit(p,_.functions(p));return["<table>",_.map(p,function(r,q){r=(_.isObject(r))?(j(r)):(r);return'<tr><td style="vertical-align: top; color: grey">'+q+'</td><td style="padding-left: 8px">'+r+"</td></tr>"}).join(""),"</table>"].join("")}if(_.isObject(l)){k.body=n.append(j(l))}else{k.body=n.html(l)}k.buttons={Ok:function(){Galaxy.modal.hide();i.clearMessages()}};return k},clearMessages:function(){this.$messages().empty();return this},scrollPosition:function(){return this.$container().scrollTop()},scrollTo:function(i){this.$container().scrollTop(i);return this},scrollToTop:function(){this.$container().scrollTop(0);return this},scrollToId:function(j){if((!j)||(!this.hdaViews[j])){return this}var i=this.hdaViews[j];this.scrollTo(i.el.offsetTop);return this},scrollToHid:function(i){var j=this.model.hdas.getByHid(i);if(!j){return this}return this.scrollToId(j.id)},toString:function(){return"ReadOnlyHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});var e=['<div class="history-controls">','<div class="history-search-controls">','<div class="history-search-input"></div>',"</div>",'<div class="history-title">',"<% if( history.name ){ %>",'<div class="history-name"><%= history.name %></div>',"<% } %>","</div>",'<div class="history-subtitle clear">',"<% if( history.nice_size ){ %>",'<div class="history-size"><%= history.nice_size %></div>',"<% } %>",'<div class="history-secondary-actions"></div>',"</div>","<% if( history.deleted ){ %>",'<div class="warningmessagesmall"><strong>',_l("You are currently viewing a deleted history!"),"</strong></div>","<% } %>",'<div class="message-container">',"<% if( history.message ){ %>",'<div class="<%= history.status %>message"><%= history.message %></div>',"<% } %>","</div>",'<div class="quota-message errormessage">',_l("You are over your disk quota."),_l("Tool execution is on hold until your disk usage drops below your allocated quota."),"</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="history-dataset-actions">','<div class="btn-group">','<button class="history-select-all-datasets-btn btn btn-default"','data-mode="select">',_l("All"),"</button>",'<button class="history-deselect-all-datasets-btn btn btn-default"','data-mode="select">',_l("None"),"</button>","</div>",'<button class="history-dataset-action-popup-btn btn btn-default">',_l("For all selected"),"...</button>","</div>","</div>",'<div class="datasets-list"></div>','<div class="empty-history-message infomessagesmall">',_l("Your history is empty. Click 'Get Data' on the left pane to start"),"</div>"].join("");b.templates={historyPanel:function(i){return _.template(e,i,{variable:"history"})}};return{ReadOnlyHistoryPanel:b}}); \ No newline at end of file +define(["mvc/history/history-model","mvc/dataset/hda-base","mvc/base-mvc"],function(e,a,d){var g=d.SessionStorageModel.extend({defaults:{expandedHdas:{},show_deleted:false,show_hidden:false},addExpandedHda:function(k){var j="expandedHdas";this.save(j,_.extend(this.get(j),_.object([k],[true])))},removeExpandedHda:function(k){var j="expandedHdas";this.save(j,_.omit(this.get(j),k))},toString:function(){return"HistoryPrefs("+this.id+")"}});g.storageKeyPrefix="history:";g.historyStorageKey=function c(j){if(!j){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+j)}return(g.storageKeyPrefix+j)};g.get=function b(j){return new g({id:g.historyStorageKey(j)})};g.clearAll=function f(k){for(var j in sessionStorage){if(j.indexOf(g.storageKeyPrefix)===0){sessionStorage.removeItem(j)}}};var h=Backbone.View.extend(d.LoggableMixin).extend({HDAViewClass:a.HDABaseView,tagName:"div",className:"history-panel",fxSpeed:"fast",emptyMsg:_l("This history is empty"),noneFoundMsg:_l("No matching datasets found"),initialize:function(j){j=j||{};if(j.logger){this.logger=j.logger}this.log(this+".initialize:",j);this.linkTarget=j.linkTarget||"_blank";this.fxSpeed=_.has(j,"fxSpeed")?(j.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor="";this.findContainerFn=j.findContainerFn;this.hdaViews={};this.indicator=new LoadingIndicator(this.$el);this._setUpListeners();var k=_.pick(j,"initiallyExpanded","show_deleted","show_hidden");this.setModel(this.model,k,false);if(j.onready){j.onready.call(this)}},_setUpListeners:function(){this.on("error",function(k,n,j,m,l){this.errorHandler(k,n,j,m,l)});this.on("loading-history",function(){this._showLoadingIndicator("loading history...",40)});this.on("loading-done",function(){this._hideLoadingIndicator(40);if(_.isEmpty(this.hdaViews)){this.trigger("empty-history",this)}});this.once("rendered",function(){this.trigger("rendered:initial",this);return false});if(this.logger){this.on("all",function(j){this.log(this+"",arguments)},this)}return this},errorHandler:function(l,o,k,n,m){console.error(l,o,k,n,m);if(o&&o.status===0&&o.readyState===0){}else{if(o&&o.status===502){}else{var j=this._parseErrorMessage(l,o,k,n,m);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",j.message,j.details)})}else{this.displayMessage("error",j.message,j.details)}}}},_parseErrorMessage:function(m,q,l,p,o){var k=Galaxy.currUser,j={message:this._bePolite(p),details:{user:(k instanceof User)?(k.toJSON()):(k+""),source:(m instanceof Backbone.Model)?(m.toJSON()):(m+""),xhr:q,options:(q)?(_.omit(l,"xhr")):(l)}};_.extend(j.details,o||{});if(q&&_.isFunction(q.getAllResponseHeaders)){var n=q.getAllResponseHeaders();n=_.compact(n.split("\n"));n=_.map(n,function(r){return r.split(": ")});j.details.xhr.responseHeaders=_.object(n)}return j},_bePolite:function(j){j=j||_l("An error occurred while getting updates from the server");return j+". "+_l("Please contact a Galaxy administrator if the problem persists.")},loadHistoryWithHDADetails:function(l,k,j,n){var m=function(o){return _.keys(g.get(o.id).get("expandedHdas"))};return this.loadHistory(l,k,j,n,m)},loadHistory:function(m,l,k,p,n){var j=this;l=l||{};j.trigger("loading-history",j);var o=e.History.getHistoryData(m,{historyFn:k,hdaFn:p,hdaDetailIds:l.initiallyExpanded||n});return j._loadHistoryFromXHR(o,l).fail(function(s,q,r){j.trigger("error",j,s,l,_l("An error was encountered while "+q),{historyId:m,history:r||{}})}).always(function(){j.trigger("loading-done",j)})},_loadHistoryFromXHR:function(l,k){var j=this;l.then(function(m,n){j.JSONToModel(m,n,k)});l.fail(function(n,m){j.render()});return l},JSONToModel:function(m,j,k){this.log("JSONToModel:",m,j,k);k=k||{};var l=new e.History(m,j,k);this.setModel(l);return this},setModel:function(k,j,l){j=j||{};l=(l!==undefined)?(l):(true);this.log("setModel:",k,j,l);this.freeModel();this.selectedHdaIds=[];if(k){this.model=k;if(this.logger){this.model.logger=this.logger}this._setUpWebStorage(j.initiallyExpanded,j.show_deleted,j.show_hidden);this._setUpModelEventHandlers();this.trigger("new-model",this)}if(l){this.render()}return this},freeModel:function(){if(this.model){this.model.clearUpdateTimeout();this.stopListening(this.model);this.stopListening(this.model.hdas)}this.freeHdaViews();return this},freeHdaViews:function(){this.hdaViews={};return this},_setUpWebStorage:function(k,j,l){this.storage=new g({id:g.historyStorageKey(this.model.get("id"))});if(_.isObject(k)){this.storage.set("exandedHdas",k)}if(_.isBoolean(j)){this.storage.set("show_deleted",j)}if(_.isBoolean(l)){this.storage.set("show_hidden",l)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());return this},_setUpModelEventHandlers:function(){this.model.hdas.on("add",this.addHdaView,this);this.model.on("error error:hdas",function(k,m,j,l){this.errorHandler(k,m,j,l)},this);return this},render:function(l,m){this.log("render:",l,m);l=(l===undefined)?(this.fxSpeed):(l);var j=this,k;if(this.model){k=this.renderModel()}else{k=this.renderWithoutModel()}$(j).queue("fx",[function(n){if(l&&j.$el.is(":visible")){j.$el.fadeOut(l,n)}else{n()}},function(n){j.$el.empty();if(k){j.$el.append(k.children())}n()},function(n){if(l&&!j.$el.is(":visible")){j.$el.fadeIn(l,n)}else{n()}},function(n){if(m){m.call(this)}j.trigger("rendered",this);n()}]);return this},renderWithoutModel:function(){var j=$("<div/>"),k=$("<div/>").addClass("message-container").css({"margin-left":"4px","margin-right":"4px"});return j.append(k)},renderModel:function(){var j=$("<div/>");j.append(h.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(j).text(this.emptyMsg);j.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(j);this.renderHdas(j);return j},_renderEmptyMsg:function(l){var k=this,j=k.$emptyMessage(l);if(!_.isEmpty(k.hdaViews)){j.hide()}else{if(k.searchFor){j.text(k.noneFoundMsg).show()}else{j.text(k.emptyMsg).show()}}return this},_renderSearchButton:function(j){return faIconButton({title:_l("Search datasets"),classes:"history-search-btn",faIcon:"fa-search"})},_setUpBehaviours:function(j){j=j||this.$el;j.find("[title]").tooltip({placement:"bottom"});this._setUpSearchInput(j.find(".history-search-controls .history-search-input"));return this},$container:function(){return(this.findContainerFn)?(this.findContainerFn.call(this)):(this.$el.parent())},$datasetsList:function(j){return(j||this.$el).find(".datasets-list")},$messages:function(j){return(j||this.$el).find(".message-container")},$emptyMessage:function(j){return(j||this.$el).find(".empty-history-message")},renderHdas:function(k){k=k||this.$el;var j=this,m={},l=this.model.hdas.getVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"),this.filters);this.$datasetsList(k).empty();if(l.length){l.each(function(o){var n=o.get("id"),p=j._createHdaView(o);m[n]=p;if(_.contains(j.selectedHdaIds,n)){p.selected=true}j.attachHdaView(p.render(),k)})}this.hdaViews=m;this._renderEmptyMsg(k);return this.hdaViews},_createHdaView:function(k){var j=k.get("id"),l=new this.HDAViewClass({model:k,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[j],hasUser:this.model.ownedByCurrUser(),logger:this.logger});this._setUpHdaListeners(l);return l},_setUpHdaListeners:function(k){var j=this;k.on("error",function(m,o,l,n){j.errorHandler(m,o,l,n)});k.on("body-expanded",function(l){j.storage.addExpandedHda(l)});k.on("body-collapsed",function(l){j.storage.removeExpandedHda(l)});return this},attachHdaView:function(l,k){k=k||this.$el;var j=this.$datasetsList(k);j.prepend(l.$el);return this},addHdaView:function(m){this.log("add."+this,m);var k=this;if(!m.isVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"))){return k}$({}).queue([function l(o){var n=k.$emptyMessage();if(n.is(":visible")){n.fadeOut(k.fxSpeed,o)}else{o()}},function j(n){var o=k._createHdaView(m);k.hdaViews[m.id]=o;o.render().$el.hide();k.scrollToTop();k.attachHdaView(o);o.$el.slideDown(k.fxSpeed)}]);return k},refreshHdas:function(k,j){if(this.model){return this.model.refresh(k,j)}return $.when()},events:{"click .message-container":"clearMessages","click .history-search-btn":"toggleSearchControls"},collapseAllHdaBodies:function(){_.each(this.hdaViews,function(j){j.toggleBodyVisibility(null,false)});this.storage.set("expandedHdas",{});return this},toggleShowDeleted:function(j){j=(j!==undefined)?(j):(!this.storage.get("show_deleted"));this.storage.set("show_deleted",j);this.renderHdas();return this.storage.get("show_deleted")},toggleShowHidden:function(j){j=(j!==undefined)?(j):(!this.storage.get("show_hidden"));this.storage.set("show_hidden",j);this.renderHdas();return this.storage.get("show_hidden")},_setUpSearchInput:function(k){var l=this,m=".history-search-input";function j(n){if(l.model.hdas.haveDetails()){l.searchHdas(n);return}l.$el.find(m).searchInput("toggle-loading");l.model.hdas.fetchAllDetails({silent:true}).always(function(){l.$el.find(m).searchInput("toggle-loading")}).done(function(){l.searchHdas(n)})}k.searchInput({initialVal:l.searchFor,name:"history-search",placeholder:"search datasets",classes:"history-search",onfirstsearch:j,onsearch:_.bind(this.searchHdas,this),onclear:_.bind(this.clearHdaSearch,this)});return k},toggleSearchControls:function(l,j){var k=this.$el.find(".history-search-controls"),m=(jQuery.type(l)==="number")?(l):(this.fxSpeed);j=(j!==undefined)?(j):(!k.is(":visible"));if(j){k.slideDown(m,function(){$(this).find("input").focus()})}else{k.slideUp(m)}return j},searchHdas:function(j){var k=this;this.searchFor=j;this.filters=[function(l){return l.matchesAll(k.searchFor)}];this.trigger("search:searching",j,this);this.renderHdas();return this},clearHdaSearch:function(j){this.searchFor="";this.filters=[];this.trigger("search:clear",this);this.renderHdas();return this},_showLoadingIndicator:function(k,j,l){j=(j!==undefined)?(j):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent())}if(!this.$el.is(":visible")){this.indicator.show(0,l)}else{this.$el.fadeOut(j);this.indicator.show(k,j,l)}},_hideLoadingIndicator:function(j,k){j=(j!==undefined)?(j):(this.fxSpeed);if(this.indicator){this.indicator.hide(j,k)}},displayMessage:function(o,p,n){var l=this;this.scrollToTop();var m=this.$messages(),j=$("<div/>").addClass(o+"message").html(p);if(!_.isEmpty(n)){var k=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(l._messageToModalOptions(o,p,n));return false});j.append(" ",k)}return m.html(j)},_messageToModalOptions:function(n,p,m){var j=this,o=$("<div/>"),l={title:"Details"};function k(q){q=_.omit(q,_.functions(q));return["<table>",_.map(q,function(s,r){s=(_.isObject(s))?(k(s)):(s);return'<tr><td style="vertical-align: top; color: grey">'+r+'</td><td style="padding-left: 8px">'+s+"</td></tr>"}).join(""),"</table>"].join("")}if(_.isObject(m)){l.body=o.append(k(m))}else{l.body=o.html(m)}l.buttons={Ok:function(){Galaxy.modal.hide();j.clearMessages()}};return l},clearMessages:function(){this.$messages().empty();return this},scrollPosition:function(){return this.$container().scrollTop()},scrollTo:function(j){this.$container().scrollTop(j);return this},scrollToTop:function(){this.$container().scrollTop(0);return this},scrollToId:function(k){if((!k)||(!this.hdaViews[k])){return this}var j=this.hdaViews[k];this.scrollTo(j.el.offsetTop);return this},scrollToHid:function(j){var k=this.model.hdas.getByHid(j);if(!k){return this}return this.scrollToId(k.id)},toString:function(){return"ReadOnlyHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});var i=['<div class="history-controls">','<div class="history-search-controls">','<div class="history-search-input"></div>',"</div>",'<div class="history-title">',"<% if( history.name ){ %>",'<div class="history-name"><%= history.name %></div>',"<% } %>","</div>",'<div class="history-subtitle clear">',"<% if( history.nice_size ){ %>",'<div class="history-size"><%= history.nice_size %></div>',"<% } %>",'<div class="history-secondary-actions"></div>',"</div>","<% if( history.deleted ){ %>",'<div class="warningmessagesmall"><strong>',_l("You are currently viewing a deleted history!"),"</strong></div>","<% } %>",'<div class="message-container">',"<% if( history.message ){ %>",'<div class="<%= history.status %>message"><%= history.message %></div>',"<% } %>","</div>",'<div class="quota-message errormessage">',_l("You are over your disk quota."),_l("Tool execution is on hold until your disk usage drops below your allocated quota."),"</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="history-dataset-actions">','<div class="btn-group">','<button class="history-select-all-datasets-btn btn btn-default"','data-mode="select">',_l("All"),"</button>",'<button class="history-deselect-all-datasets-btn btn btn-default"','data-mode="select">',_l("None"),"</button>","</div>",'<button class="history-dataset-action-popup-btn btn btn-default">',_l("For all selected"),"...</button>","</div>","</div>",'<div class="datasets-list"></div>','<div class="empty-history-message infomessagesmall">',_l("Your history is empty. Click 'Get Data' on the left pane to start"),"</div>"].join("");h.templates={historyPanel:function(j){return _.template(i,j,{variable:"history"})}};return{ReadOnlyHistoryPanel:h}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/tags.js --- a/static/scripts/packed/mvc/tags.js +++ b/static/scripts/packed/mvc/tags.js @@ -1,1 +1,1 @@ -define([],function(){var a=Backbone.View.extend(LoggableMixin).extend(HiddenUntilActivatedViewMixin).extend({tagName:"div",className:"tags-display",initialize:function(b){this.listenTo(this.model,"change:tags",function(){this.render()});this.hiddenUntilActivated(b.$activator,b)},render:function(){var b=this;this.$el.html(this._template());this.$input().select2({placeholder:"Add tags",width:"100%",tags:function(){return b._getTagsUsed()}});this._setUpBehaviors();return this},_template:function(){return['<label class="prompt">',_l("Tags"),"</label>",'<input class="tags-input" value="',this.tagsToCSV(),'" />'].join("")},tagsToCSV:function(){var b=this.model.get("tags");if(!_.isArray(b)||_.isEmpty(b)){return""}return b.sort().join(",")},$input:function(){return this.$el.find("input.tags-input")},_getTagsUsed:function(){return Galaxy.currUser.get("tags_used")},_setUpBehaviors:function(){var b=this;this.$input().on("change",function(c){b.model.save({tags:c.val},{silent:true});if(c.added){b._addNewTagToTagsUsed(c.added.text+"")}})},_addNewTagToTagsUsed:function(b){var c=Galaxy.currUser.get("tags_used");if(!_.contains(c,b)){c.push(b);c.sort();Galaxy.currUser.set("tags_used",c)}},remove:function(){this.$input.off();this.stopListening(this.model);Backbone.View.prototype.remove.call(this)},toString:function(){return["TagsEditor(",this.model+"",")"].join("")}});return{TagsEditor:a}}); \ No newline at end of file +define(["mvc/base-mvc"],function(a){var b=Backbone.View.extend(a.LoggableMixin).extend(a.HiddenUntilActivatedViewMixin).extend({tagName:"div",className:"tags-display",initialize:function(c){this.listenTo(this.model,"change:tags",function(){this.render()});this.hiddenUntilActivated(c.$activator,c)},render:function(){var c=this;this.$el.html(this._template());this.$input().select2({placeholder:"Add tags",width:"100%",tags:function(){return c._getTagsUsed()}});this._setUpBehaviors();return this},_template:function(){return['<label class="prompt">',_l("Tags"),"</label>",'<input class="tags-input" value="',this.tagsToCSV(),'" />'].join("")},tagsToCSV:function(){var c=this.model.get("tags");if(!_.isArray(c)||_.isEmpty(c)){return""}return c.sort().join(",")},$input:function(){return this.$el.find("input.tags-input")},_getTagsUsed:function(){return Galaxy.currUser.get("tags_used")},_setUpBehaviors:function(){var c=this;this.$input().on("change",function(d){c.model.save({tags:d.val},{silent:true});if(d.added){c._addNewTagToTagsUsed(d.added.text+"")}})},_addNewTagToTagsUsed:function(c){var d=Galaxy.currUser.get("tags_used");if(!_.contains(d,c)){d.push(c);d.sort();Galaxy.currUser.set("tags_used",d)}},remove:function(){this.$input.off();this.stopListening(this.model);Backbone.View.prototype.remove.call(this)},toString:function(){return["TagsEditor(",this.model+"",")"].join("")}});return{TagsEditor:b}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/user/user-model.js --- a/static/scripts/packed/mvc/user/user-model.js +++ b/static/scripts/packed/mvc/user/user-model.js @@ -1,1 +1,1 @@ -var User=Backbone.Model.extend(LoggableMixin).extend({urlRoot:galaxy_config.root+"api/users",defaults:{id:null,username:"("+_l("anonymous user")+")",email:"",total_disk_usage:0,nice_total_disk_usage:"",quota_percent:null},initialize:function(a){this.log("User.initialize:",a);this.on("loaded",function(b,c){this.log(this+" has loaded:",b,c)});this.on("change",function(b,c){this.log(this+" has changed:",b,c.changes)})},isAnonymous:function(){return(!this.get("email"))},loadFromApi:function(d,b){d=d||User.CURRENT_ID_STR;b=b||{};var a=this,c=b.success;b.success=function(f,e){a.trigger("loaded",f,e);if(c){c(f,e)}};if(d===User.CURRENT_ID_STR){b.url=this.urlRoot+"/"+User.CURRENT_ID_STR}return Backbone.Model.prototype.fetch.call(this,b)},clearSessionStorage:function(){for(var a in sessionStorage){if(a.indexOf("history:")===0){sessionStorage.removeItem(a)}else{if(a==="history-panel"){sessionStorage.removeItem(a)}}}},toString:function(){var a=[this.get("username")];if(this.get("id")){a.unshift(this.get("id"));a.push(this.get("email"))}return"User("+a.join(":")+")"}});User.CURRENT_ID_STR="current";User.getCurrentUserFromApi=function(b){var a=new User();a.loadFromApi(User.CURRENT_ID_STR,b);return a};var UserCollection=Backbone.Collection.extend(LoggableMixin).extend({model:User,urlRoot:galaxy_config.root+"api/users"}); \ No newline at end of file +define(["mvc/base-mvc"],function(a){var c=Backbone.Model.extend(a.LoggableMixin).extend({urlRoot:galaxy_config.root+"api/users",defaults:{id:null,username:"("+_l("anonymous user")+")",email:"",total_disk_usage:0,nice_total_disk_usage:"",quota_percent:null},initialize:function(d){this.log("User.initialize:",d);this.on("loaded",function(e,f){this.log(this+" has loaded:",e,f)});this.on("change",function(e,f){this.log(this+" has changed:",e,f.changes)})},isAnonymous:function(){return(!this.get("email"))},loadFromApi:function(g,e){g=g||c.CURRENT_ID_STR;e=e||{};var d=this,f=e.success;e.success=function(i,h){d.trigger("loaded",i,h);if(f){f(i,h)}};if(g===c.CURRENT_ID_STR){e.url=this.urlRoot+"/"+c.CURRENT_ID_STR}return Backbone.Model.prototype.fetch.call(this,e)},clearSessionStorage:function(){for(var d in sessionStorage){if(d.indexOf("history:")===0){sessionStorage.removeItem(d)}else{if(d==="history-panel"){sessionStorage.removeItem(d)}}}},toString:function(){var d=[this.get("username")];if(this.get("id")){d.unshift(this.get("id"));d.push(this.get("email"))}return"User("+d.join(":")+")"}});c.CURRENT_ID_STR="current";c.getCurrentUserFromApi=function(e){var d=new c();d.loadFromApi(c.CURRENT_ID_STR,e);return d};var b=Backbone.Collection.extend(a.LoggableMixin).extend({model:c,urlRoot:galaxy_config.root+"api/users"});return{User:c}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/user/user-quotameter.js --- a/static/scripts/packed/mvc/user/user-quotameter.js +++ b/static/scripts/packed/mvc/user/user-quotameter.js @@ -1,1 +1,1 @@ -var UserQuotaMeter=Backbone.View.extend(LoggableMixin).extend({options:{warnAtPercent:85,errorAtPercent:100},initialize:function(a){this.log(this+".initialize:",a);_.extend(this.options,a);this.model.bind("change:quota_percent change:total_disk_usage",this.render,this)},update:function(a){this.log(this+" updating user data...",a);this.model.loadFromApi(this.model.get("id"),a);return this},isOverQuota:function(){return(this.model.get("quota_percent")!==null&&this.model.get("quota_percent")>=this.options.errorAtPercent)},_render_quota:function(){var a=this.model.toJSON(),c=a.quota_percent,b=$(this._templateQuotaMeter(a)),d=b.find(".progress-bar");if(this.isOverQuota()){d.attr("class","progress-bar progress-bar-danger");b.find(".quota-meter-text").css("color","white");this.trigger("quota:over",a)}else{if(c>=this.options.warnAtPercent){d.attr("class","progress-bar progress-bar-warning");this.trigger("quota:under quota:under:approaching",a)}else{d.attr("class","progress-bar progress-bar-success");this.trigger("quota:under quota:under:ok",a)}}return b},_render_usage:function(){var a=$(this._templateUsage(this.model.toJSON()));this.log(this+".rendering usage:",a);return a},render:function(){var a=null;this.log(this+".model.quota_percent:",this.model.get("quota_percent"));if((this.model.get("quota_percent")===null)||(this.model.get("quota_percent")===undefined)){a=this._render_usage()}else{a=this._render_quota()}this.$el.html(a);this.$el.find(".quota-meter-text").tooltip();return this},_templateQuotaMeter:function(a){return['<div id="quota-meter" class="quota-meter progress">','<div class="progress-bar" style="width: ',a.quota_percent,'%"></div>','<div class="quota-meter-text" style="top: 6px"',((a.nice_total_disk_usage)?(' title="Using '+a.nice_total_disk_usage+'">'):(">")),_l("Using")," ",a.quota_percent,"%","</div>","</div>"].join("")},_templateUsage:function(a){return['<div id="quota-meter" class="quota-meter" style="background-color: transparent">','<div class="quota-meter-text" style="top: 6px; color: white">',((a.nice_total_disk_usage)?(_l("Using ")+a.nice_total_disk_usage):("")),"</div>","</div>"].join("")},toString:function(){return"UserQuotaMeter("+this.model+")"}}); \ No newline at end of file +define(["mvc/base-mvc"],function(a){var b=Backbone.View.extend(a.LoggableMixin).extend({options:{warnAtPercent:85,errorAtPercent:100},initialize:function(c){this.log(this+".initialize:",c);_.extend(this.options,c);this.model.bind("change:quota_percent change:total_disk_usage",this.render,this)},update:function(c){this.log(this+" updating user data...",c);this.model.loadFromApi(this.model.get("id"),c);return this},isOverQuota:function(){return(this.model.get("quota_percent")!==null&&this.model.get("quota_percent")>=this.options.errorAtPercent)},_render_quota:function(){var c=this.model.toJSON(),e=c.quota_percent,d=$(this._templateQuotaMeter(c)),f=d.find(".progress-bar");if(this.isOverQuota()){f.attr("class","progress-bar progress-bar-danger");d.find(".quota-meter-text").css("color","white");this.trigger("quota:over",c)}else{if(e>=this.options.warnAtPercent){f.attr("class","progress-bar progress-bar-warning");this.trigger("quota:under quota:under:approaching",c)}else{f.attr("class","progress-bar progress-bar-success");this.trigger("quota:under quota:under:ok",c)}}return d},_render_usage:function(){var c=$(this._templateUsage(this.model.toJSON()));this.log(this+".rendering usage:",c);return c},render:function(){var c=null;this.log(this+".model.quota_percent:",this.model.get("quota_percent"));if((this.model.get("quota_percent")===null)||(this.model.get("quota_percent")===undefined)){c=this._render_usage()}else{c=this._render_quota()}this.$el.html(c);this.$el.find(".quota-meter-text").tooltip();return this},_templateQuotaMeter:function(c){return['<div id="quota-meter" class="quota-meter progress">','<div class="progress-bar" style="width: ',c.quota_percent,'%"></div>','<div class="quota-meter-text" style="top: 6px"',((c.nice_total_disk_usage)?(' title="Using '+c.nice_total_disk_usage+'">'):(">")),_l("Using")," ",c.quota_percent,"%","</div>","</div>"].join("")},_templateUsage:function(c){return['<div id="quota-meter" class="quota-meter" style="background-color: transparent">','<div class="quota-meter-text" style="top: 6px; color: white">',((c.nice_total_disk_usage)?(_l("Using ")+c.nice_total_disk_usage):("")),"</div>","</div>"].join("")},toString:function(){return"UserQuotaMeter("+this.model+")"}});return{UserQuotaMeter:b}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 static/scripts/packed/mvc/visualization/visualization-model.js --- a/static/scripts/packed/mvc/visualization/visualization-model.js +++ b/static/scripts/packed/mvc/visualization/visualization-model.js @@ -1,1 +1,1 @@ -var Visualization=Backbone.Model.extend(LoggableMixin).extend({defaults:{config:{}},urlRoot:function(){var a="/api/visualizations";return((window.galaxy_config&&galaxy_config.root)?(galaxy_config.root+a):(a))},initialize:function(a){this.log(this+".initialize",a,this.attributes);if(_.isObject(a.config)&&_.isObject(this.defaults.config)){_.defaults(a.config,this.defaults.config)}this._setUpListeners()},_setUpListeners:function(){},set:function(b,c){if(b==="config"){var a=this.get("config");if(_.isObject(a)){c=_.extend(_.clone(a),c)}}Backbone.Model.prototype.set.call(this,b,c);return this},toString:function(){var a=this.get("id")||"";if(this.get("title")){a+=":"+this.get("title")}return"Visualization("+a+")"}});var VisualizationCollection=Backbone.Collection.extend(LoggableMixin).extend({model:Visualization,url:function(){return galaxy_config.root+"api/visualizations"},initialize:function(b,a){a=a||{}},set:function(c,a){var b=this;c=_.map(c,function(e){var f=b.get(e.id);if(!f){return e}var d=f.toJSON();_.extend(d,e);return d});Backbone.Collection.prototype.set.call(this,c,a)},toString:function(){return(["VisualizationCollection(",[this.historyId,this.length].join(),")"].join(""))}}); \ No newline at end of file +var Visualization=Backbone.Model.extend({defaults:{config:{}},urlRoot:function(){var a="/api/visualizations";return((window.galaxy_config&&galaxy_config.root)?(galaxy_config.root+a):(a))},initialize:function(a){if(_.isObject(a.config)&&_.isObject(this.defaults.config)){_.defaults(a.config,this.defaults.config)}this._setUpListeners()},_setUpListeners:function(){},set:function(b,c){if(b==="config"){var a=this.get("config");if(_.isObject(a)){c=_.extend(_.clone(a),c)}}Backbone.Model.prototype.set.call(this,b,c);return this},toString:function(){var a=this.get("id")||"";if(this.get("title")){a+=":"+this.get("title")}return"Visualization("+a+")"}});var VisualizationCollection=Backbone.Collection.extend({model:Visualization,url:function(){return galaxy_config.root+"api/visualizations"},initialize:function(b,a){a=a||{}},set:function(c,a){var b=this;c=_.map(c,function(e){var f=b.get(e.id);if(!f){return e}var d=f.toJSON();_.extend(d,e);return d});Backbone.Collection.prototype.set.call(this,c,a)},toString:function(){return(["VisualizationCollection(",[this.historyId,this.length].join(),")"].join(""))}}); \ No newline at end of file diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 templates/webapps/galaxy/galaxy.masthead.mako --- a/templates/webapps/galaxy/galaxy.masthead.mako +++ b/templates/webapps/galaxy/galaxy.masthead.mako @@ -66,25 +66,28 @@ } %> - ${h.js( "mvc/base-mvc", "utils/localization", "mvc/user/user-model", "mvc/user/user-quotameter" )} + ##${h.js( "mvc/base-mvc", "utils/localization", "mvc/user/user-model", "mvc/user/user-quotameter" )} + ${h.js( "utils/localization" )} ## load the frame manager <script type="text/javascript"> if( !window.Galaxy ){ - window.Galaxy = {}; + Galaxy = {}; } - ## fetch the current user data from trans - Galaxy.currUser = new User(${ h.to_json_string( get_user_json(), indent=2 ) }); ## load additional style sheet - if (window != window.top) - $('<link href="' + galaxy_config.root + 'static/style/galaxy.frame.masthead.css" rel="stylesheet">').appendTo('head'); + if (window != window.top){ + $('<link href="' + galaxy_config.root + 'static/style/galaxy.frame.masthead.css" rel="stylesheet">') + .appendTo('head'); + } ## load galaxy js-modules - $(function() { - require(['galaxy.masthead', 'galaxy.menu', 'mvc/ui/ui-modal', 'galaxy.frame', 'mvc/upload/upload-view'], - function(mod_masthead, mod_menu, mod_modal, mod_frame, GalaxyUpload) - { + require([ + 'galaxy.masthead', 'galaxy.menu', 'mvc/ui/ui-modal', 'galaxy.frame', 'mvc/upload/upload-view', + 'mvc/user/user-model', + 'mvc/user/user-quotameter' + ], function( mod_masthead, mod_menu, mod_modal, mod_frame, GalaxyUpload, user, quotameter ){ + $(function() { ## check if masthead is available if (Galaxy.masthead) return; @@ -106,11 +109,14 @@ ## add upload plugin Galaxy.upload = new GalaxyUpload(masthead_config); + if( !Galaxy.currUser ){ + Galaxy.currUser = new user.User(${ h.to_json_string( get_user_json(), indent=2 ) }); + } ## set up the quota meter (And fetch the current user data from trans) ## add quota meter to masthead - Galaxy.quotaMeter = new UserQuotaMeter({ + Galaxy.quotaMeter = new quotameter.UserQuotaMeter({ model : Galaxy.currUser, - el : $(Galaxy.masthead.el).find('.quota-meter-container') + el : Galaxy.masthead.$('.quota-meter-container') }).render(); }); }); diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 templates/webapps/galaxy/history/history_panel.mako --- a/templates/webapps/galaxy/history/history_panel.mako +++ b/templates/webapps/galaxy/history/history_panel.mako @@ -16,7 +16,8 @@ linkTarget : 'galaxy_main', onready : function loadAsCurrentHistoryPanel(){ var panel = this; - this.connectToQuotaMeter( Galaxy.quotaMeter ).connectToOptionsMenu( Galaxy.historyOptionsMenu ); + this.connectToQuotaMeter( Galaxy.quotaMeter ) + .connectToOptionsMenu( Galaxy.historyOptionsMenu ); this.loadCurrentHistory() .fail( function(){ panel.render(); @@ -92,7 +93,6 @@ <%def name="history_panel_javascripts()"> ${h.js( "utils/localization", - "mvc/base-mvc" )} ${localize_js_strings([ diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 templates/webapps/galaxy/history/view.mako --- a/templates/webapps/galaxy/history/view.mako +++ b/templates/webapps/galaxy/history/view.mako @@ -73,17 +73,11 @@ ${history_panel_javascripts()} %if not use_panels: - ${h.js( 'mvc/user/user-model' )} +<script type="text/javascript"> +window.Galaxy = {}; +</script> %endif -<script type="text/javascript"> - ##TODO: remove when Galaxy is either ensured or removed from the history panel - var using_panels = ${ 'false' if not use_panels else 'true' }; - %if not use_panels: - window.Galaxy = {}; - Galaxy.currUser = new User(${h.to_json_string( get_user_json() )}); - %endif -</script></%def> ## ---------------------------------------------------------------------------- @@ -163,8 +157,12 @@ require.config({ baseUrl : "${h.url_for( '/static/scripts' )}" - })([ panelToUse.location ], function( panelMod ){ + })([ 'mvc/user/user-model', panelToUse.location ], function( user, panelMod ){ $(function(){ + if( !Galaxy.currUser ){ + Galaxy.currUser = new user.User( ${h.to_json_string( get_user_json() )} ); + } + var panelClass = panelMod[ panelToUse.className ], // history module is already in the dpn chain from the panel. We can re-scope it here. historyModel = require( 'mvc/history/history-model' ), diff -r 08f389432f6876a5af1ad54ef2f25e4d06310999 -r 7155334f5ec5743188f90053a54ac851be3e2d58 templates/webapps/galaxy/root/history.mako --- a/templates/webapps/galaxy/root/history.mako +++ b/templates/webapps/galaxy/root/history.mako @@ -22,47 +22,45 @@ <%def name="javascripts()"> ${parent.javascripts()} ${history_panel_javascripts()} -${h.js( - "mvc/user/user-model" -)} <script type="text/javascript"> - if( !window.Galaxy ){ - window.Galaxy = {}; - Galaxy.currUser = new User(${h.to_json_string( get_user_json() )}); - } +if( !window.Galaxy ){ + window.Galaxy = {}; +} +$(function(){ + $( 'body' ).addClass( 'historyPage' ).addClass( 'history-panel' ); +}); +require([ + 'mvc/user/user-model', + 'mvc/history/current-history-panel' +], function( user, historyPanel ){ $(function(){ - $( 'body' ).addClass( 'historyPage' ).addClass( 'history-panel' ); + Galaxy.currUser = new user.User( ${h.to_json_string( get_user_json() )} ); + // history module is already in the dpn chain from the panel. We can re-scope it here. + var historyModel = require( 'mvc/history/history-model' ), + debugging = JSON.parse( sessionStorage.getItem( 'debugging' ) ) || false, + historyJSON = ${h.to_json_string( history )}, + hdaJSON = ${h.to_json_string( hdas )}; + + var history = new historyModel.History( historyJSON, hdaJSON, { + logger: ( debugging )?( console ):( null ) + }); + + var panel = new historyPanel.CurrentHistoryPanel({ + show_deleted : ${ 'true' if show_deleted == True else ( 'null' if show_deleted == None else 'false' ) }, + show_hidden : ${ 'true' if show_hidden == True else ( 'null' if show_hidden == None else 'false' ) }, + el : $( "body.historyPage" ), + model : history, + onready : function(){ + this.render(); + if( Galaxy ){ + Galaxy.currHistoryPanel = this; + } + } + }); }); -</script> - -<script type="text/javascript"> -onhistoryready.done( function( historyPanel ){ - - // history module is already in the dpn chain from the panel. We can re-scope it here. - var historyModel = require( 'mvc/history/history-model' ), - debugging = JSON.parse( sessionStorage.getItem( 'debugging' ) ) || false, - historyJSON = ${h.to_json_string( history )}, - hdaJSON = ${h.to_json_string( hdas )}; - - var history = new historyModel.History( historyJSON, hdaJSON, { - logger: ( debugging )?( console ):( null ) - }); - - var panel = new historyPanel.HistoryPanel({ - show_deleted : ${ 'true' if show_deleted == True else ( 'null' if show_deleted == None else 'false' ) }, - show_hidden : ${ 'true' if show_hidden == True else ( 'null' if show_hidden == None else 'false' ) }, - el : $( "body.historyPage" ), - model : history, - onready : function(){ - this.render(); - if( Galaxy ){ - Galaxy.currHistoryPanel = this; - } - } - }); -}) +}); </script></%def> Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org