2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/bf48c28d0e1a/ Changeset: bf48c28d0e1a User: dcnorris Date: 2014-04-07 22:29:17 Summary: removed dataset hash from the bookmark generated urls since they are not needed and make for ugly track names Affected #: 5 files diff -r 1768cbdd144df553f1173b22ea1961ec5054f1c0 -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 display_applications/igb/bam.xml --- a/display_applications/igb/bam.xml +++ b/display_applications/igb/bam.xml @@ -7,8 +7,8 @@ #set nm=$bam_file_for_name.name ${re.sub('\W',"_",nm)} </param> - <param type="data" name="bai_file" url="${niceName}_${DATASET_HASH}.bam.bai" metadata="bam_index" strip_https="True" /> - <param type="data" name="bam_file" url="${niceName}_${DATASET_HASH}.bam" strip_https="True" /> + <param type="data" name="bai_file" url="${niceName}.bam.bai" metadata="bam_index" strip_https="True" /> + <param type="data" name="bam_file" url="${niceName}.bam" strip_https="True" /></link></display> diff -r 1768cbdd144df553f1173b22ea1961ec5054f1c0 -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 display_applications/igb/bb.xml --- a/display_applications/igb/bb.xml +++ b/display_applications/igb/bb.xml @@ -8,7 +8,7 @@ #set nm=$bigbed_file_for_name.name ${re.sub('\W',"_",nm)} </param> - <param type="data" name="bigbed_file" url="${niceName}_${DATASET_HASH}.bigbed" strip_https="True" /> + <param type="data" name="bigbed_file" url="${niceName}.bigbed" strip_https="True" /></link></display> diff -r 1768cbdd144df553f1173b22ea1961ec5054f1c0 -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 display_applications/igb/bed.xml --- a/display_applications/igb/bed.xml +++ b/display_applications/igb/bed.xml @@ -8,7 +8,7 @@ #set nm=$bed_file_for_name.name ${re.sub('\W',"_",nm)} </param> - <param type="data" name="bed_file" url="${niceName}_${DATASET_HASH}.bed" strip_https="True" /> + <param type="data" name="bed_file" url="${niceName}.bed" strip_https="True" /><param type="template" name="bioviz" strip="True" > http://bioviz.org/igb/galaxy.html?version=${bed_file.dbkey}&loadresidues=false&feature_url_0=${bed_file.url}&sym_name_0=${niceName}&sym_method_0=${bed_file.url}&query_url=${bed_file.url}&server_url=galaxy diff -r 1768cbdd144df553f1173b22ea1961ec5054f1c0 -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 display_applications/igb/bigwig.xml --- a/display_applications/igb/bigwig.xml +++ b/display_applications/igb/bigwig.xml @@ -8,7 +8,7 @@ #set nm=$bigwig_file_for_name.name ${re.sub('\W',"_",nm)} </param> - <param type="data" name="bigwig_file" url="${niceName}_${DATASET_HASH}.bigwig" strip_https="True" /> + <param type="data" name="bigwig_file" url="${niceName}.bigwig" strip_https="True" /><!--<param type="template" name="position" strip="True" > #set chrom, start, end = $bigwig_file.datatype.get_estimated_display_viewport( $bigwig_file ) #if $chrom is not None: diff -r 1768cbdd144df553f1173b22ea1961ec5054f1c0 -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 display_applications/igb/wig.xml --- a/display_applications/igb/wig.xml +++ b/display_applications/igb/wig.xml @@ -8,7 +8,7 @@ #set nm=$wig_file_for_name.name ${re.sub('\W',"_",nm)} </param> - <param type="data" name="wig_file" url="${niceName}_${DATASET_HASH}.wig" strip_https="True" /> + <param type="data" name="wig_file" url="${niceName}.wig" strip_https="True" /><param type="template" name="position" strip="True" > #set chrom, start, end = $wig_file.datatype.get_estimated_display_viewport( $wig_file ) #if $chrom is not None: https://bitbucket.org/galaxy/galaxy-central/commits/b7d3d55c5ee8/ Changeset: b7d3d55c5ee8 User: hillrunner2008 Date: 2014-04-07 22:31:01 Summary: Merged galaxy/galaxy-central into default Affected #: 29 files diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 config/plugins/visualizations/charts/static/build-app.js --- a/config/plugins/visualizations/charts/static/build-app.js +++ b/config/plugins/visualizations/charts/static/build-app.js @@ -3,4 +3,4 @@ // (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc. // Underscore may be freely distributed under the MIT license. -(function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=i.toString,l=i.hasOwnProperty,c=r.forEach,h=r.map,p=r.reduce,d=r.reduceRight,v=r.filter,m=r.every,g=r.some,y=r.indexOf,b=r.lastIndexOf,w=Array.isArray,E=Object.keys,S=s.bind,x=function(e){if(e instanceof x)return e;if(!(this instanceof x))return new x(e);this._wrapped=e};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=x),exports._=x):e._=x,x.VERSION="1.4.4";var T=x.each=x.forEach=function(e,t,r){if(e==null)return;if(c&&e.forEach===c)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i<s;i++)if(t.call(r,e[i],i,e)===n)return}else for(var o in e)if(x.has(e,o)&&t.call(r,e[o],o,e)===n)return};x.map=x.collect=function(e,t,n){var r=[];return e==null?r:h&&e.map===h?e.map(t,n):(T(e,function(e,i,s){r.push(t.call(n,e,i,s))}),r)};var N="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(p&&e.reduce===p)return r&&(t=x.bind(t,r)),i?e.reduce(t,n):e.reduce(t);T(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError(N);return n},x.reduceRight=x.foldr=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(d&&e.reduceRight===d)return r&&(t=x.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=x.keys(e);s=o.length}T(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)throw new TypeError(N);return n},x.find=x.detect=function(e,t,n){var r;return C(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},x.filter=x.select=function(e,t,n){var r=[];return e==null?r:v&&e.filter===v?e.filter(t,n):(T(e,function(e,i,s){t.call(n,e,i,s)&&r.push(e)}),r)},x.reject=function(e,t,n){return x.filter(e,function(e,r,i){return!t.call(n,e,r,i)},n)},x.every=x.all=function(e,t,r){t||(t=x.identity);var i=!0;return e==null?i:m&&e.every===m?e.every(t,r):(T(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))return n}),!!i)};var C=x.some=x.any=function(e,t,r){t||(t=x.identity);var i=!1;return e==null?i:g&&e.some===g?e.some(t,r):(T(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))return n}),!!i)};x.contains=x.include=function(e,t){return e==null?!1:y&&e.indexOf===y?e.indexOf(t)!=-1:C(e,function(e){return e===t})},x.invoke=function(e,t){var n=u.call(arguments,2),r=x.isFunction(t);return x.map(e,function(e){return(r?t:e[t]).apply(e,n)})},x.pluck=function(e,t){return x.map(e,function(e){return e[t]})},x.where=function(e,t,n){return x.isEmpty(t)?n?void 0:[]:x[n?"find":"filter"](e,function(e){for(var n in t)if(t[n]!==e[n])return!1;return!0})},x.findWhere=function(e,t){return x.where(e,t,!0)},x.max=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.max.apply(Math,e);if(!t&&x.isEmpty(e))return-Infinity;var r={computed:-Infinity,value:-Infinity};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o>=r.computed&&(r={value:e,computed:o})}),r.value},x.min=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);if(!t&&x.isEmpty(e))return Infinity;var r={computed:Infinity,value:Infinity};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o<r.computed&&(r={value:e,computed:o})}),r.value},x.shuffle=function(e){var t,n=0,r=[];return T(e,function(e){t=x.random(n++),r[n-1]=r[t],r[t]=e}),r};var k=function(e){return x.isFunction(e)?e:function(t){return t[e]}};x.sortBy=function(e,t,n){var r=k(t);return x.pluck(x.map(e,function(e,t,i){return{value:e,index:t,criteria:r.call(n,e,t,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(n<r||r===void 0)return-1}return e.index<t.index?-1:1}),"value")};var L=function(e,t,n,r){var i={},s=k(t==null?x.identity:t);return T(e,function(t,o){var u=s.call(n,t,o,e);r(i,u,t)}),i};x.groupBy=function(e,t,n){return L(e,t,n,function(e,t,n){(x.has(e,t)?e[t]:e[t]=[]).push(n)})},x.countBy=function(e,t,n){return L(e,t,n,function(e,t){x.has(e,t)||(e[t]=0),e[t]++})},x.sortedIndex=function(e,t,n,r){n=n==null?x.identity:k(n);var i=n.call(r,t),s=0,o=e.length;while(s<o){var u=s+o>>>1;n.call(r,e[u])<i?s=u+1:o=u}return s},x.toArray=function(e){return e?x.isArray(e)?u.call(e):e.length===+e.length?x.map(e,x.identity):x.values(e):[]},x.size=function(e){return e==null?0:e.length===+e.length?e.length:x.keys(e).length},x.first=x.head=x.take=function(e,t,n){return e==null?void 0:t!=null&&!n?u.call(e,0,t):e[0]},x.initial=function(e,t,n){return u.call(e,0,e.length-(t==null||n?1:t))},x.last=function(e,t,n){return e==null?void 0:t!=null&&!n?u.call(e,Math.max(e.length-t,0)):e[e.length-1]},x.rest=x.tail=x.drop=function(e,t,n){return u.call(e,t==null||n?1:t)},x.compact=function(e){return x.filter(e,x.identity)};var A=function(e,t,n){return T(e,function(e){x.isArray(e)?t?o.apply(n,e):A(e,t,n):n.push(e)}),n};x.flatten=function(e,t){return A(e,t,[])},x.without=function(e){return x.difference(e,u.call(arguments,1))},x.uniq=x.unique=function(e,t,n,r){x.isFunction(t)&&(r=n,n=t,t=!1);var i=n?x.map(e,n,r):e,s=[],o=[];return T(i,function(n,r){if(t?!r||o[o.length-1]!==n:!x.contains(o,n))o.push(n),s.push(e[r])}),s},x.union=function(){return x.uniq(a.apply(r,arguments))},x.intersection=function(e){var t=u.call(arguments,1);return x.filter(x.uniq(e),function(e){return x.every(t,function(t){return x.indexOf(t,e)>=0})})},x.difference=function(e){var t=a.apply(r,u.call(arguments,1));return x.filter(e,function(e){return!x.contains(t,e)})},x.zip=function(){var e=u.call(arguments),t=x.max(x.pluck(e,"length")),n=new Array(t);for(var r=0;r<t;r++)n[r]=x.pluck(e,""+r);return n},x.unzip=function(e){var t=[];return x.each(e,function(e,n){x.each(e,function(e,r){t.length<=r&&(t[r]=[]),t[r][n]=e})}),t},x.object=function(e,t){if(e==null)return{};var n={};for(var r=0,i=e.length;r<i;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},x.indexOf=function(e,t,n){if(e==null)return-1;var r=0,i=e.length;if(n){if(typeof n!="number")return r=x.sortedIndex(e,t),e[r]===t?r:-1;r=n<0?Math.max(0,i+n):n}if(y&&e.indexOf===y)return e.indexOf(t,n);for(;r<i;r++)if(e[r]===t)return r;return-1},x.lastIndexOf=function(e,t,n){if(e==null)return-1;var r=n!=null;if(b&&e.lastIndexOf===b)return r?e.lastIndexOf(t,n):e.lastIndexOf(t);var i=r?n:e.length;while(i--)if(e[i]===t)return i;return-1},x.range=function(e,t,n){arguments.length<=1&&(t=e||0,e=0),n=arguments[2]||1;var r=Math.max(Math.ceil((t-e)/n),0),i=0,s=new Array(r);while(i<r)s[i++]=e,e+=n;return s};var O=function(){};x.bind=function(e,t){var n,r;if(e.bind===S&&S)return S.apply(e,u.call(arguments,1));if(!x.isFunction(e))throw new TypeError;return n=u.call(arguments,2),r=function(){if(this instanceof r){O.prototype=e.prototype;var i=new O;O.prototype=null;var s=e.apply(i,n.concat(u.call(arguments)));return Object(s)===s?s:i}return e.apply(t,n.concat(u.call(arguments)))}},x.partial=function(e){var t=u.call(arguments,1);return function(){return e.apply(this,t.concat(u.call(arguments)))}},x.bindAll=function(e){var t=u.call(arguments,1);if(t.length===0)throw new Error("bindAll must be passed function names");return T(t,function(t){e[t]=x.bind(e[t],e)}),e},x.memoize=function(e,t){var n={};return t||(t=x.identity),function(){var r=t.apply(this,arguments);return x.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},x.delay=function(e,t){var n=u.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},x.defer=function(e){return x.delay.apply(x,[e,1].concat(u.call(arguments,1)))},x.throttle=function(e,t,n){var r,i,s,o,u=0,a=function(){u=new Date,s=null,o=e.apply(r,i)};return function(){var f=new Date;!u&&n===!1&&(u=f);var l=t-(f-u);return r=this,i=arguments,l<=0?(clearTimeout(s),s=null,u=f,o=e.apply(r,i)):s||(s=setTimeout(a,l)),o}},x.debounce=function(e,t,n){var r,i;return function(){var s=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;return clearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},x.once=function(e){var t=!1,n;return function(){return t?n:(t=!0,n=e.apply(this,arguments),e=null,n)}},x.wrap=function(e,t){return function(){var n=[e];return o.apply(n,arguments),t.apply(this,n)}},x.compose=function(){var e=arguments;return function(){var t=arguments;for(var n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},x.after=function(e,t){return e<=0?t():function(){if(--e<1)return t.apply(this,arguments)}},x.keys=E||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var n in e)x.has(e,n)&&t.push(n);return t},x.values=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push(e[n]);return t},x.pairs=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push([n,e[n]]);return t},x.invert=function(e){var t={};for(var n in e)x.has(e,n)&&(t[e[n]]=n);return t},x.functions=x.methods=function(e){var t=[];for(var n in e)x.isFunction(e[n])&&t.push(n);return t.sort()},x.extend=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]=t[n]}),e},x.pick=function(e){var t={},n=a.apply(r,u.call(arguments,1));return T(n,function(n){n in e&&(t[n]=e[n])}),t},x.omit=function(e){var t={},n=a.apply(r,u.call(arguments,1));for(var i in e)x.contains(n,i)||(t[i]=e[i]);return t},x.defaults=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e},x.clone=function(e){return x.isObject(e)?x.isArray(e)?e.slice():x.extend({},e):e},x.tap=function(e,t){return t(e),e};var M=function(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;e instanceof x&&(e=e._wrapped),t instanceof x&&(t=t._wrapped);var i=f.call(e);if(i!=f.call(t))return!1;switch(i){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeof e!="object"||typeof t!="object")return!1;var s=n.length;while(s--)if(n[s]==e)return r[s]==t;n.push(e),r.push(t);var o=0,u=!0;if(i=="[object Array]"){o=e.length,u=o==t.length;if(u)while(o--)if(!(u=M(e[o],t[o],n,r)))break}else{var a=e.constructor,l=t.constructor;if(a!==l&&!(x.isFunction(a)&&a instanceof a&&x.isFunction(l)&&l instanceof l))return!1;for(var c in e)if(x.has(e,c)){o++;if(!(u=x.has(t,c)&&M(e[c],t[c],n,r)))break}if(u){for(c in t)if(x.has(t,c)&&!(o--))break;u=!o}}return n.pop(),r.pop(),u};x.isEqual=function(e,t){return M(e,t,[],[])},x.isEmpty=function(e){if(e==null)return!0;if(x.isArray(e)||x.isString(e))return e.length===0;for(var t in e)if(x.has(e,t))return!1;return!0},x.isElement=function(e){return!!e&&e.nodeType===1},x.isArray=w||function(e){return f.call(e)=="[object Array]"},x.isObject=function(e){return e===Object(e)},T(["Arguments","Function","String","Number","Date","RegExp"],function(e){x["is"+e]=function(t){return f.call(t)=="[object "+e+"]"}}),x.isArguments(arguments)||(x.isArguments=function(e){return!!e&&!!x.has(e,"callee")}),typeof /./!="function"&&(x.isFunction=function(e){return typeof e=="function"}),x.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},x.isNaN=function(e){return x.isNumber(e)&&e!=+e},x.isBoolean=function(e){return e===!0||e===!1||f.call(e)=="[object Boolean]"},x.isNull=function(e){return e===null},x.isUndefined=function(e){return e===void 0},x.has=function(e,t){return l.call(e,t)},x.noConflict=function(){return e._=t,this},x.identity=function(e){return e},x.times=function(e,t,n){var r=Array(e);for(var i=0;i<e;i++)r[i]=t.call(n,i);return r},x.random=function(e,t){return t==null&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))};var _={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};_.unescape=x.invert(_.escape);var D={escape:new RegExp("["+x.keys(_.escape).join("")+"]","g"),unescape:new RegExp("("+x.keys(_.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(e){x[e]=function(t){return t==null?"":(""+t).replace(D[e],function(t){return _[e][t]})}}),x.result=function(e,t){if(e==null)return void 0;var n=e[t];return x.isFunction(n)?n.call(e):n},x.mixin=function(e){T(x.functions(e),function(t){var n=x[t]=e[t];x.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),F.call(this,n.apply(x,e))}})};var P=0;x.uniqueId=function(e){var t=++P+"";return e?e+t:t},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},j=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(e,t,n){var r;n=x.defaults({},n,x.templateSettings);var i=new RegExp([(n.escape||H).source,(n.interpolate||H).source,(n.evaluate||H).source].join("|")+"|$","g"),s=0,o="__p+='";e.replace(i,function(t,n,r,i,u){return o+=e.slice(s,u).replace(j,function(e){return"\\"+B[e]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),s=u+t.length,t}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=new Function(n.variable||"obj","_",o)}catch(u){throw u.source=o,u}if(t)return r(t,x);var a=function(e){return r.call(this,e,x)};return a.source="function("+(n.variable||"obj")+"){\n"+o+"}",a},x.chain=function(e){return x(e).chain()};var F=function(e){return this._chain?x(e).chain():e};x.mixin(x),T(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];x.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&delete n[0],F.call(this,n)}}),T(["concat","join","slice"],function(e){var t=r[e];x.prototype[e]=function(){return F.call(this,t.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this),define("libs/underscore",function(e){return function(){var t,n;return t||e._}}(this)),define("utils/utils",["libs/underscore"],function(e){function t(e,t,r){n("GET",e,{},t,r)}function n(e,t,n,r,i){if(e=="GET"||e=="DELETE")t.indexOf("?")==-1?t+="?":t+="&",t+=$.param(n);var s=new XMLHttpRequest;s.open(e,t,!0),s.setRequestHeader("Accept","application/json"),s.setRequestHeader("Cache-Control","no-cache"),s.setRequestHeader("X-Requested-With","XMLHttpRequest"),s.setRequestHeader("Content-Type","application/json"),s.onloadend=function(){var e=s.status;try{response=jQuery.parseJSON(s.responseText)}catch(t){response=s.responseText}e==200?r&&r(response):i&&i(response)},e=="GET"||e=="DELETE"?s.send():s.send(JSON.stringify(n))}function r(e,t){var n=$('<div class="'+e+'"></div>');n.appendTo(":eq(0)");var r=n.css(t);return n.remove(),r}function i(e){$('link[href^="'+e+'"]').length||$('<link href="'+galaxy_config.root+e+'" rel="stylesheet">').appendTo("head")}function s(t,n){return t?e.defaults(t,n):n}function o(e,t){var n="";if(e>=1e11)e/=1e11,n="TB";else if(e>=1e8)e/=1e8,n="GB";else if(e>=1e5)e/=1e5,n="MB";else if(e>=100)e/=100,n="KB";else{if(!(e>0))return"<strong>-</strong>";e*=10,n="b"}var r=Math.round(e)/10;return t?r+" "+n:"<strong>"+r+"</strong> "+n}function u(){return(new Date).getTime().toString(36)}function a(e){var t=$("<p></p>");return t.append(e),t}function f(){var e=new Date,t=(e.getHours()<10?"0":"")+e.getHours(),n=(e.getMinutes()<10?"0":"")+e.getMinutes(),r=e.getDate()+"/"+(e.getMonth()+1)+"/"+e.getFullYear()+", "+t+":"+n;return r}return{cssLoadFile:i,cssGetAttribute:r,get:t,merge:s,bytesToString:o,uuid:u,time:f,wrap:a,request:n}}),define("mvc/ui/ui-modal",["utils/utils"],function(e){var t=Backbone.View.extend({elMain:"body",optionsDefault:{title:"ui-modal",body:"",backdrop:!0,height:null,width:null,closing_events:!1},buttonList:{},initialize:function(e){e&&this._create(e)},show:function(e){this.initialize(e),this.options.height?(this.$body.css("height",this.options.height),this.$body.css("overflow","hidden")):this.$body.css("max-height",$(window).height()/2),this.options.width&&this.$dialog.css("width",this.options.width),this.visible?this.$el.show():this.$el.fadeIn("fast"),this.visible=!0},hide:function(){this.visible=!1,this.$el.fadeOut("fast")},enableButton:function(e){var t=this.buttonList[e];this.$buttons.find("#"+t).prop("disabled",!1)},disableButton:function(e){var t=this.buttonList[e];this.$buttons.find("#"+t).prop("disabled",!0)},showButton:function(e){var t=this.buttonList[e];this.$buttons.find("#"+t).show()},hideButton:function(e){var t=this.buttonList[e];this.$buttons.find("#"+t).hide()},getButton:function(e){var t=this.buttonList[e];return this.$buttons.find("#"+t)},scrollTop:function(){return this.$body.scrollTop()},_create:function(e){var t=this;this.options=_.defaults(e,this.optionsDefault),this.options.body=="progress"&&(this.options.body=$('<div class="progress progress-striped active"><div class="progress-bar progress-bar-info" style="width:100%"></div></div>')),this.$el&&(this.$el.remove(),$(document).off("keyup.ui-modal")),this.setElement(this._template(this.options.title)),this.$dialog=this.$el.find(".modal-dialog"),this.$body=this.$el.find(".modal-body"),this.$footer=this.$el.find(".modal-footer"),this.$buttons=this.$el.find(".buttons"),this.$backdrop=this.$el.find(".modal-backdrop"),this.$body.html(this.options.body),this.options.backdrop||this.$backdrop.removeClass("in");if(this.options.buttons){this.buttonList={};var n=0;$.each(this.options.buttons,function(e,r){var i="button-"+n++;t.$buttons.append($('<button id="'+i+'"></button>').text(e).click(r)).append(" "),t.buttonList[e]=i})}else this.$footer.hide();$(this.elMain).append($(this.el)),this.options.closing_events&&($(document).on("keyup.ui-modal",function(e){e.keyCode==27&&t.hide()}),this.$el.find(".modal-backdrop").on("click",function(){t.hide()}))},_template:function(e){return'<div class="modal"><div class="modal-backdrop fade in" style="z-index: -1;"></div><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" style="display: none;">×</button><h4 class="title">'+e+"</h4>"+"</div>"+'<div class="modal-body" style="position: static;"></div>'+'<div class="modal-footer">'+'<div class="buttons" style="float: right;"></div>'+"</div>"+"</div"+"</div>"+"</div>"}});return{View:t}}),define("mvc/ui/ui-portlet",["utils/utils"],function(e){var t=Backbone.View.extend({visible:!1,optionsDefault:{title:"",icon:"",buttons:null,body:null,height:null,operations:null,placement:"bottom",overflow:"auto"},$title:null,$content:null,$buttons:null,$operations:null,initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),this.$content=this.$el.find("#content"),this.$title=this.$el.find("#title-text"),this.options.height&&(this.$el.find("#body").css("height",this.options.height),this.$el.find("#content").css("overflow",this.options.overflow)),this.$buttons=$(this.el).find("#buttons");if(this.options.buttons){var n=this;$.each(this.options.buttons,function(e,t){t.$el.prop("id",e),n.$buttons.append(t.$el)})}else this.$buttons.remove();this.$operations=$(this.el).find("#operations");if(this.options.operations){var n=this;$.each(this.options.operations,function(e,t){t.$el.prop("id",e),n.$operations.append(t.$el)})}this.options.body&&this.append(this.options.body)},append:function(t){this.$content.append(e.wrap(t))},content:function(){return this.$content},show:function(){this.$el.fadeIn("fast"),this.visible=!0},hide:function(){this.$el.fadeOut("fast"),this.visible=!1},enableButton:function(e){this.$buttons.find("#"+e).prop("disabled",!1)},disableButton:function(e){this.$buttons.find("#"+e).prop("disabled",!0)},hideOperation:function(e){this.$operations.find("#"+e).hide()},showOperation:function(e){this.$operations.find("#"+e).show()},setOperation:function(e,t){var n=this.$operations.find("#"+e);n.off("click"),n.on("click",t)},title:function(e){var t=this.$title;return e&&t.html(e),t.html()},_template:function(e){var t='<div class="toolForm portlet-view no-highlight">';if(e.title||e.icon)t+='<div id="title" class="toolFormTitle portlet-title"><div id="operations" class="portlet-operations"/><div style="overflow: hidden;">',e.icon&&(t+='<div class="portlet-title-icon fa '+e.icon+'"> </div>'),t+='<div id="title-text" class="portlet-title-text">'+e.title+"</div>",t+="</div></div>";return t+='<div id="body" class="toolFormBody portlet-body">',e.placement=="top"&&(t+='<div id="buttons" class="portlet-buttons"/>'),t+='<div id="content" class="portlet-content"/>',e.placement=="bottom"&&(t+='<div id="buttons" class="portlet-buttons"/>'),t+="</div></div>",t}});return{View:t}}),define("plugin/library/ui-select",["utils/utils"],function(e){var t=Backbone.View.extend({optionsDefault:{id:"",cls:"",empty:"No data available",visible:!0,wait:!1},selected:null,initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),this.$select=this.$el.find("#select"),this.$icon=this.$el.find("#icon"),this.selected=this.options.value;var n=this;this.options.onchange&&this.$select.on("change",function(){n.value(n.$select.val())}),this._refresh(),this.options.visible||this.hide(),this.options.wait?this.wait():this.show()},value:function(e){var t=this.selected;e!==undefined&&(this.selected=e,this.$select.val(e));var n=this.selected;return n&&n!=t&&this.options.onchange&&this.options.onchange(n),n},text:function(){return this.$select.find("option:selected").text()},show:function(){this.$icon.removeClass(),this.$icon.addClass("fa fa-caret-down"),this.$select.show(),this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass(),this.$icon.addClass("fa fa-spinner fa-spin"),this.$select.hide()},disabled:function(){return this.$select.is(":disabled")},enable:function(){this.$select.prop("disabled",!1)},disable:function(){this.$select.prop("disabled",!0)},add:function(e){this.$select.append(this._templateOption(e)),this._refresh()},del:function(e){this.$select.find("option[value="+e+"]").remove(),this.$select.trigger("change"),this._refresh()},update:function(e){this.$select.find("option").remove();for(var t in e)this.$select.append(this._templateOption(e[t]));!this.selected&&e.length>0&&this.value(e[0].value),this._refresh()},_refresh:function(){this.$select.find("option[value=null]").remove();var e=this.$select.find("option").length;e==0?(this.$select.append(this._templateOption({value:"null",label:this.options.empty})),this.disable()):(this.enable(),this.selected&&this.$select.val(this.selected))},_exists:function(e){return 0!=this.$select.find("option[value="+e+"]").length},_templateOption:function(e){return'<option value="'+e.value+'">'+e.label+"</option>"},_template:function(e){var t='<div id="'+e.id+'" class="styled-select">'+'<div class="button">'+'<i id="icon"/>'+"</div>"+'<select id="select" class="select '+e.cls+" "+e.id+'">';for(key in e.data){var n=e.data[key],r="";if(n.value==e.value||n.value=="")r="selected";t+='<option value="'+n.value+'" '+r+">"+n.label+"</option>"}return t+="</select></div>",t}});return{View:t}}),define("plugin/library/ui",["utils/utils","plugin/library/ui-select"],function(e,t){var n=Backbone.View.extend({optionsDefault:{title:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options))},title:function(e){this.$el.find("b").html(e)},_template:function(e){return"<label><b>"+e.title+"</b></label>"},value:function(){return options.title}}),r=Backbone.View.extend({optionsDefault:{id:null,title:"","float":"right",cls:"btn-default",icon:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),$(this.el).on("click",t.onclick),$(this.el).tooltip({title:t.tooltip,placement:"bottom"})},_template:function(e){var t='<button id="'+e.id+'" type="submit" style="margin-right: 5px; float: '+e.float+';" type="button" class="btn '+e.cls+'">';return e.icon&&(t+='<i class="icon fa '+e.icon+'"></i> '),t+=e.title+"</button>",t}}),i=Backbone.View.extend({optionsDefault:{"float":"right",icon:"",tooltip:"",placement:"bottom",title:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),$(this.el).tooltip({title:t.tooltip,placement:"bottom"})},_template:function(e){return'<div><span class="fa '+e.icon+'" style="font-size: 1.2em;"/> '+e.title+"</div>"}}),s=Backbone.View.extend({optionsDefault:{title:"",id:null,"float":"right",cls:"icon-btn",icon:"",tooltip:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),$(this.el).on("click",t.onclick),$(this.el).tooltip({title:t.tooltip,placement:"bottom"})},_template:function(e){var t="";e.title&&(t="width: auto;");var n='<div id="'+e.id+'" style="margin-right: 5px; float: '+e.float+"; "+t+'" class="'+e.cls+'">';return e.title?n+='<div style="margin-right: 5px; margin-left: 5px;"><i class="icon fa '+e.icon+'"/> '+'<span style="position: relative; font-size: 0.8em; font-weight: normal; top: -1px;">'+e.title+"</span>"+"</div>":n+='<i class="icon fa '+e.icon+'"/>',n+="</div>",n}}),o=Backbone.View.extend({optionsDefault:{title:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),$(this.el).on("click",t.onclick)},_template:function(e){return'<div><a href="javascript:void(0)">'+e.title+"</a></div>"}}),u=Backbone.View.extend({optionsDefault:{message:"",status:"info",persistent:!1},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement("<div></div>")},update:function(t){this.options=e.merge(t,this.optionsDefault);if(t.message!=""){this.$el.html(this._template(this.options)),this.$el.fadeIn();if(!t.persistent){var n=this;window.setTimeout(function(){n.$el.is(":visible")?n.$el.fadeOut():n.$el.hide()},3e3)}}else this.$el.fadeOut()},_template:function(e){return'<div class="alert alert-'+e.status+'" style="padding: 2px 2px 2px 10px;">'+e.message+"</div>"}}),a=Backbone.View.extend({optionsDefault:{onclick:null,searchword:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options));var n=this;this.options.onclick&&this.$el.on("submit",function(e){var t=n.$el.find("#search");n.options.onclick(t.val())})},_template:function(e){return'<div class="search"><form onsubmit="return false;"><input id="search" class="form-control input-sm" type="text" name="search" placeholder="Search..." value="'+e.searchword+'">'+'<button type="submit" class="btn search-btn">'+'<i class="fa fa-search"></i>'+"</button>"+"</form>"+"</div>"}}),f=Backbone.View.extend({optionsDefault:{title:"Unlabeled",body:null},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),this.options.body&&this.$el.find(".body").append(this.options.body)},_template:function(e){return'<div id="title" class="title">'+e.title+":"+"</div>"}}),l=Backbone.View.extend({optionsDefault:{id:"",title:"",target:"",href:"",onunload:null,onclick:null,visible:!0,icon:null,tag:""},$menu:null,initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement($(this._template(this.options)));var n=$(this.el).find(".root"),r=this;n.on("click",function(e){e.preventDefault(),r.options.onclick&&r.options.onclick()}),this.options.visible||this.hide()},show:function(){$(this.el).show()},hide:function(){$(this.el).hide()},addMenu:function(t){var n={title:"",target:"",href:"",onclick:null,divider:!1,icon:null};n=e.merge(t,n),this.$menu||($(this.el).append(this._templateMenu()),this.$menu=$(this.el).find(".menu"));var r=$(this._templateMenuItem(n));r.on("click",function(e){e.preventDefault(),n.onclick&&n.onclick()}),this.$menu.append(r),n.divider&&this.$menu.append($(this._templateDivider()))},_templateMenuItem:function(e){var t='<li><a href="'+e.href+'" target="'+e.target+'">';return e.icon&&(t+='<i class="fa '+e.icon+'"></i>'),t+=" "+e.title+"</a>"+"</li>",t},_templateMenu:function(){return'<ul class="menu dropdown-menu pull-right" role="menu"></ul>'},_templateDivider:function(){return'<li class="divider"></li>'},_template:function(e){var t='<div id="'+e.id+'" class="button-menu btn-group">'+'<button type="button" class="root btn btn-default dropdown-toggle" data-toggle="dropdown">';return e.icon&&(t+='<i class="fa '+e.icon+'"></i>'),"</button></div>",t}}),c=Backbone.View.extend({optionsDefault:{value:"",type:"text",placeholder:"",disabled:!1,visible:!0},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),this.options.disabled&&this.$el.prop("disabled",!0),this.options.visible||this.$el.hide();var n=this;this.options.onchange&&this.$el.on("input",function(){n.options.onchange()})},value:function(e){return e!==undefined&&this.$el.val(e),this.$el.val()},_template:function(e){return'<input id="'+e.id+'" type="'+e.type+'" value="'+e.value+'" placeholder="'+e.placeholder+'" class="form-control">'}});return{Label:n,Button:r,Icon:i,ButtonIcon:s,Input:c,Anchor:o,Message:u,Searchbox:a,Title:f,Select:t,ButtonMenu:l}}),define("plugin/library/jobs",["utils/utils"],function(e){return Backbone.Model.extend({initialize:function(t,n){this.app=t,this.options=e.merge(n,this.optionsDefault)},cleanup:function(t){var n=t.get("dataset_id_job");if(n!=""){var r=this;e.request("PUT",config.root+"api/histories/none/contents/"+n,{deleted:!0},function(){r._refreshHdas()}),t.set("dataset_id_job","")}},submit:function(t,n,r,i,s){var o=this,u=t.id,a=t.get("type"),f=this.app.types.get(a);data={tool_id:"chartskit",inputs:{input:{id:t.get("dataset_id"),src:"hda"},module:a,columns:r,settings:n}},t.state("wait","Sending job request..."),e.request("POST",config.root+"api/tools",data,function(e){if(!e.outputs||e.outputs.length==0)t.state("failed","Job submission failed. No response."),s&&s();else{o._refreshHdas();var n=e.outputs[0];t.state("wait","Job has been queued..."),t.set("dataset_id_job",n.id),this.app.storage.save(),o._loop(n.id,function(e){switch(e.state){case"ok":return t.state("wait","Job completed successfully..."),i(e),!0;case"error":return t.state("failed","Job has failed. Please check the history for details."),s&&s(),!0;case"running":return t.state("wait","Job is running..."),!1}})}},function(e){var n="";e&&e.message&&e.message.data&&e.message.data.input&&(n=e.message.data.input+"."),t.state("failed","This visualization requires the Charts-Kit. Please make sure it is installed. "+n),s&&s()})},_loop:function(t,n){var r=this;e.request("GET",config.root+"api/jobs/"+t,{},function(e){n(e)||setTimeout(function(){r._loop(t,n)},r.app.config.get("query_timeout"))})},_refreshHdas:function(){Galaxy&&Galaxy.currHistoryPanel&&Galaxy.currHistoryPanel.refreshHdas()}})}),define("plugin/library/datasets",["utils/utils"],function(e){return Backbone.Collection.extend({list:{},initialize:function(t,n){this.app=t,this.options=e.merge(n,this.optionsDefault)},request:function(t,n,r){var i=this;if(t.groups)this._fetch(t,n);else{var s=this.list[t.id];if(s){n(s);return}e.request("GET",config.root+"api/datasets/"+t.id,{},function(e){switch(e.state){case"error":r&&r(e);break;default:i.list[t.id]=e,n(e)}})}},_fetch:function(t,n){var r=t.start?t.start:0,i=Math.abs(t.end-t.start),s=this.app.config.get("query_limit");if(!i||i>s)i=s;var o="",u={},a=0;for(var f in t.groups){var l=t.groups[f];for(var c in l.columns){var h=l.columns[c];o+=h+",",u[h]=a,a++}}if(a==0){n({});return}o=o.substring(0,o.length-1);var p=t.groups.slice(0);for(var f in p)p[f].values=[];var d=this;e.request("GET",config.root+"api/datasets/"+t.id,{data_type:"raw_data",provider:"dataset-column",limit:i,offset:r,indeces:o},function(e){for(var i in e.data){var s=e.data[i];for(var o in t.groups){var a=t.groups[o],f={x:parseInt(i)+r};for(var l in a.columns){var c=a.columns[l],h=u[c],d=s[h];if(isNaN(d)||!d)d=0;f[l]=d}p[o].values.push(f)}}n(p)})}})}),define("plugin/models/group",[],function(){return Backbone.Model.extend({defaults:{key:"Data label",date:""},reset:function(){this.clear({silent:!0}).set(this.defaults),this.trigger("reset",this)}})}),define("plugin/models/groups",["plugin/models/group"],function(e){return Backbone.Collection.extend({model:e})}),define("plugin/library/deferred",["utils/utils"],function(e){return Backbone.Model.extend({queue:[],process:{},counter:0,initialize:function(){this.on("refresh",function(){if(this.counter==0)for(var e in this.queue)this.queue[e](),this.queue.splice(e,1)})},execute:function(e){this.queue.push(e),this.trigger("refresh")},register:function(){var t=e.uuid();return this.process[t]=!0,this.counter++,console.debug("Deferred:register() - Registering "+t),t},done:function(e){delete this.process[e],this.counter--,console.debug("Deferred:done() - Unregistering "+e),this.trigger("refresh")},ready:function(){return this.counter==0?!0:!1}})});var Visualization=Backbone.Model.extend({defaults:{config:{}},urlRoot:function(){var e="/api/visualizations";return window.galaxy_config&&galaxy_config.root?galaxy_config.root+e:e},initialize:function(e){_.isObject(e.config)&&_.isObject(this.defaults.config)&&_.defaults(e.config,this.defaults.config),this._setUpListeners()},_setUpListeners:function(){},set:function(e,t){if(e==="config"){var n=this.get("config");_.isObject(n)&&(t=_.extend(_.clone(n),t))}return Backbone.Model.prototype.set.call(this,e,t),this},toString:function(){var e=this.get("id")||"";return this.get("title")&&(e+=":"+this.get("title")),"Visualization("+e+")"}}),VisualizationCollection=Backbone.Collection.extend({model:Visualization,url:function(){return galaxy_config.root+"api/visualizations"},initialize:function(e,t){t=t||{}},set:function(e,t){var n=this;e=_.map(e,function(e){var t=n.get(e.id);if(!t)return e;var r=t.toJSON();return _.extend(r,e),r}),Backbone.Collection.prototype.set.call(this,e,t)},toString:function(){return["VisualizationCollection(",[this.historyId,this.length].join(),")"].join("")}});define("mvc/visualization/visualization-model",function(){}),define("plugin/models/chart",["plugin/models/groups","plugin/library/deferred","mvc/visualization/visualization-model"],function(e,t){return Backbone.Model.extend({defaults:{id:null,title:"",type:"",date:null,state:"",state_info:"",modified:!1,dataset_id:"",dataset_id_job:""},initialize:function(n){this.groups=new e,this.settings=new Backbone.Model,this.deferred=new t},reset:function(){this.clear({silent:!0}).set(this.defaults),this.groups.reset(),this.settings.clear(),this.trigger("reset",this)},copy:function(e){var t=this;t.clear({silent:!0}).set(this.defaults),t.set(e.attributes),t.settings=e.settings.clone(),t.groups.reset(),e.groups.each(function(e){t.groups.add(e.clone())}),t.trigger("change",t)},state:function(e,t){this.set("state",e),this.set("state_info",t),this.trigger("set:state"),console.debug("Chart:state() - "+t+" ("+e+")")}})}),define("plugin/library/storage",["utils/utils","plugin/models/chart","plugin/models/group"],function(e,t,n){return Backbone.Model.extend({vis:null,initialize:function(e){this.app=e,this.chart=this.app.chart,this.options=this.app.options,this.id=this.options.id,this.vis=new Visualization({type:"charts",config:{dataset_id:this.options.config.dataset_id,chart_dict:{}}}),this.id&&(this.vis.id=this.id);var t=this.options.config.chart_dict;t&&(this.vis.get("config").chart_dict=t)},save:function(){var e=this.app.chart;this.vis.get("config").chart_dict={};var t=e.get("title");t!=""&&this.vis.set("title",t);var n={attributes:e.attributes,settings:e.settings.attributes,groups:[]};e.groups.each(function(e){n.groups.push(e.attributes)}),this.vis.get("config").chart_dict=n;var r=this;this.vis.save().fail(function(e,t,n){console.error(e,t,n)}).then(function(e){e&&e.id&&(r.id=e.id)})},load:function(){var e=this.vis.get("config").chart_dict;if(!e.attributes)return!1;this.chart.set(e.attributes),this.chart.state("ok","Loading saved visualization..."),this.chart.settings.set(e.settings);for(var t in e.groups)this.chart.groups.add(new n(e.groups[t]));return this.chart.set("modified",!1),!0}})}),define("plugin/views/viewport",["mvc/ui/ui-portlet","plugin/library/ui","utils/utils"],function(e,t,n){return Backbone.View.extend({initialize:function(e,t){this.app=e,this.chart=this.app.chart,this.options=n.merge(t,this.optionsDefault),this.setElement($(this._template())),this._create_svg();var r=this;this.chart.on("redraw",function(){r._draw(r.chart)}),this.chart.on("set:state",function(){var e=r.$el.find("#info"),t=e.find("#icon");t.removeClass(),e.show(),e.find("#text").html(r.chart.get("state_info"));var n=r.chart.get("state");switch(n){case"ok":e.hide();break;case"failed":t.addClass("fa fa-warning");break;default:t.addClass("fa fa-spinner fa-spin")}})},show:function(){this.$el.show()},hide:function(){this.$el.hide()},_create_svg:function(){this.svg&&this.svg.remove(),this.$el.append($(this._template_svg())),this.svg_el=this.$el.find("svg"),this.svg=d3.select(this.svg_el[0])},_draw:function(e){var t=this;this._create_svg(),e.state("wait","Please wait...");var n=e.deferred.register(),r=e.get("type"),i=this.app.types.get(r);if(!i.execute||i.execute&&e.get("modified"))this.app.jobs.cleanup(e),e.set("modified",!1);var t=this;require(["plugin/charts/"+r+"/"+r],function(r){var s=new r(t.app,{svg:t.svg});i.execute?e.get("dataset_id_job")==""?t.app.jobs.submit(e,t._defaultSettingsString(e),t._defaultRequestString(e),function(){s.draw(n,e,t._defaultRequestDictionary(e))},function(){e.deferred.done(n)}):s.draw(n,e,t._defaultRequestDictionary(e)):s.draw(n,e,t._defaultRequestDictionary(e))})},_defaultRequestString:function(e){var t=this.app.types.get(e.get("type")),n="",r=0;return e.groups.each(function(e){for(var i in t.columns)n+=i+"_"+ ++r+":"+(parseInt(e.get(i))+1)+", "}),n.substring(0,n.length-2)},_defaultSettingsString:function(e){var t="";for(key in e.settings.attributes)t+=key+":"+e.settings.get(key)+", ";return t.substring(0,t.length-2)},_defaultRequestDictionary:function(e){var t=this.app.types.get(e.get("type")),n={groups:[]};t.execute?n.id=e.get("dataset_id_job"):n.id=e.get("dataset_id");var r=0;return e.groups.each(function(e){var i={};for(var s in t.columns)i[s]=e.get(s);n.groups.push({key:++r+":"+e.get("key"),columns:i})}),n},_template:function(){return'<div style="height: 100%; min-height: 50px;"><div id="info" style="position: absolute; margin-left: 10px; margin-top: 10px; margin-bottom: 50px;"><span id="icon" style="font-size: 1.2em; display: inline-block;"/><span id="text" style="position: relative; margin-left: 5px; top: -1px; font-size: 1.0em;"/></div></div>'},_template_svg:function(){return'<svg style="height: calc(100% - 80px)"/>'}})}),define("plugin/views/viewer",["utils/utils","plugin/library/ui","mvc/ui/ui-portlet","plugin/models/group","plugin/views/viewport"],function(e,t,n,r,i){return Backbone.View.extend({initialize:function(e,r){this.app=e,this.chart=this.app.chart,this.viewport_view=new i(e);var s=this;this.portlet=new n.View({icon:"fa-bar-chart-o",title:"Viewport",operations:{edit_button:new t.ButtonIcon({icon:"fa-edit",tooltip:"Customize this chart",title:"Customize",onclick:function(){s._wait(s.chart,function(){s.app.go("editor")})}})}}),this.portlet.append(this.viewport_view.$el),this.setElement(this.portlet.$el);var s=this;this.chart.on("change:title",function(){s._refreshTitle()})},show:function(){this.$el.show(),$(window).trigger("resize")},hide:function(){this.$el.hide()},_refreshTitle:function(){var e=this.chart.get("title");this.portlet.title(e)},_screenshot:function(){var e=new XMLSerializer,t=e.serializeToString(this.viewport_view.svg.node()),n="data:image/svg+xml;base64,"+btoa(t);window.location.href="data:application/x-download/;charset=utf-8,"+encodeURIComponent(t)},_wait:function(e,t){if(e.deferred.ready())t();else{var n=this;this.app.modal.show({title:"Please wait!",body:"Your chart is currently being processed. Please wait and try again.",buttons:{Close:function(){n.app.modal.hide()},Retry:function(){n.app.modal.hide(),setTimeout(function(){n._wait(e,t)},n.app.config.get("query_timeout"))}}})}}})}),define("mvc/ui/ui-tabs",["utils/utils"],function(e){var t=Backbone.View.extend({visible:!1,list:{},$nav:null,$content:null,first_tab:null,optionsDefault:{title_new:"",operations:null,onnew:null},initialize:function(t){this.options=e.merge(t,this.optionsDefault);var n=$(this._template(this.options));this.$nav=n.find(".tab-navigation"),this.$content=n.find(".tab-content"),this.setElement(n),this.list={};var r=this;this.options.operations&&$.each(this.options.operations,function(e,t){t.$el.prop("id",e),r.$nav.find(".operations").append(t.$el)});if(this.options.onnew){var i=$(this._template_tab_new(this.options));this.$nav.append(i),i.tooltip({title:"Add a new tab",placement:"bottom",container:r.$el}),i.on("click",function(e){i.tooltip("hide"),r.options.onnew()})}},add:function(e){var t=e.id,n={$title:$(this._template_tab(e)),$content:$(this._template_tab_content(e)),removable:e.ondel?!0:!1};this.list[t]=n,this.options.onnew?this.$nav.find("#new-tab").before(n.$title):this.$nav.append(n.$title),n.$content.append(e.$el),this.$content.append(n.$content),_.size(this.list)==1&&(n.$title.addClass("active"),n.$content.addClass("active"),this.first_tab=t);if(e.ondel){var r=this,i=n.$title.find("#delete");i.tooltip({title:"Delete this tab",placement:"bottom",container:r.$el}),i.on("click",function(){return i.tooltip("destroy"),r.$el.find(".tooltip").remove(),e.ondel(),!1})}e.onclick&&n.$title.on("click",function(){e.onclick()})},del:function(e){var t=this.list[e];t.$title.remove(),t.$content.remove(),delete t,this.first_tab==e&&(this.first_tab=null),this.first_tab!=null&&this.show(this.first_tab)},delRemovable:function(){for(var e in this.list){var t=this.list[e];t.removable&&this.del(e)}},show:function(e){this.$el.fadeIn("fast"),this.visible=!0,e&&this.list[e].$title.find("a").tab("show")},hide:function(){this.$el.fadeOut("fast"),this.visible=!1},hideOperation:function(e){this.$nav.find("#"+e).hide()},showOperation:function(e){this.$nav.find("#"+e).show()},setOperation:function(e,t){var n=this.$nav.find("#"+e);n.off("click"),n.on("click",t)},title:function(e,t){var n=this.list[e].$title.find("#text");return t&&n.html(t),n.html()},_template:function(e){return'<div class="tabbable tabs-left"><ul class="tab-navigation nav nav-tabs"><div class="operations" style="float: right; margin-bottom: 4px;"></div></ul><div class="tab-content"/></div>'},_template_tab_new:function(e){return'<li id="new-tab"><a href="javascript:void(0);"><i style="font-size: 0.8em; margin-right: 5px;" class="fa fa-plus-circle"/>'+e.title_new+"</a>"+"</li>"},_template_tab:function(e){var t='<li id="title-'+e.id+'">'+'<a title="" href="#tab-'+e.id+'" data-toggle="tab" data-original-title="">'+'<span id="text">'+e.title+"</span>";return e.ondel&&(t+='<i id="delete" style="font-size: 0.8em; margin-left: 5px; cursor: pointer;" class="fa fa-minus-circle"/>'),t+="</a></li>",t},_template_tab_content:function(e){return'<div id="tab-'+e.id+'" class="tab-pane"/>'}});return{View:t}}),define("plugin/library/ui-table",["utils/utils"],function(e){var t=Backbone.View.extend({row:null,row_count:0,optionsDefault:{content:"No content available.",onchange:null,ondblclick:null,onconfirm:null},events:{click:"_onclick",dblclick:"_ondblclick"},first:!0,initialize:function(t){this.options=e.merge(t,this.optionsDefault);var n=$(this._template(t));this.$thead=n.find("thead"),this.$tbody=n.find("tbody"),this.$tmessage=n.find("tmessage"),this.setElement(n),this.row=$("<tr></tr>")},addHeader:function(e){var t=$("<th></th>");t.append(e),this.row.append(t)},appendHeader:function(){this.$thead.append(this.row),this.row=$("<tr></tr>")},add:function(e,t){var n=$("<td></td>");t&&n.css("width",t),n.append(e),this.row.append(n)},append:function(e){this._commit(e)},prepend:function(e){this._commit(e,!0)},remove:function(e){var t=this.$tbody.find("#"+e);t.length>0&&(t.remove(),this.row_count--,this._refresh())},removeAll:function(){this.$tbody.html(""),this.row_count=0,this._refresh()},value:function(e){this.before=this.$tbody.find(".current").attr("id"),e!==undefined&&(this.$tbody.find("tr").removeClass("current"),e&&this.$tbody.find("#"+e).addClass("current"));var t=this.$tbody.find(".current").attr("id");return t===undefined?null:(t!=this.before&&this.options.onchange&&this.options.onchange(e),t)},size:function(){return this.$tbody.find("tr").length},_commit:function(e,t){this.remove(e),this.row.attr("id",e),t?this.$tbody.prepend(this.row):this.$tbody.append(this.row),this.row=$("<tr></tr>"),this.row_count++,this._refresh()},_onclick:function(e){var t=this.value(),n=$(e.target).closest("tr").attr("id");n&&t!=n&&(this.options.onconfirm?this.options.onconfirm(n):this.value(n))},_ondblclick:function(e){var t=this.value();t&&this.options.ondblclick&&this.options.ondblclick(t)},_refresh:function(){this.row_count==0?this.$tmessage.show():this.$tmessage.hide()},_template:function(e){return'<div><table class="grid"><thead></thead><tbody style="cursor: pointer;"></tbody></table><tmessage>'+e.content+"</tmessage>"+"<div>"}});return{View:t}}),define("plugin/views/group",["plugin/library/ui-table","plugin/library/ui","utils/utils"],function(e,t,n){return Backbone.View.extend({columns:[],initialize:function(r,i){this.app=r;var s=this;this.chart=this.app.chart,this.group=i.group,this.group_key=new t.Input({placeholder:"Data label",onchange:function(){s.group.set("key",s.group_key.value())}}),this.table=new e.View({content:"No data column."});var o=$("<div/>");o.append(n.wrap((new t.Label({title:"Provide a label:"})).$el)),o.append(n.wrap(this.group_key.$el)),o.append(n.wrap((new t.Label({title:"Select columns:"})).$el)),o.append(n.wrap(this.table.$el)),this.setElement(o);var s=this;this.chart.on("change:dataset_id",function(){s._refreshTable()}),this.chart.on("change:type",function(){s._refreshTable()}),this.group.on("change:key",function(){s._refreshGroupKey()}),this.group.on("change",function(){s._refreshGroup()}),this._refreshTable(),this._refreshGroupKey(),this._refreshGroup()},_refreshTable:function(){var e=this.chart.get("dataset_id"),n=this.chart.get("type");if(!e||!n)return;var r=this,i=this.app.types.get(n);this.table.removeAll();var s={};for(var o in i.columns){var u=this.group.get(o);u||this.group.set(o,0);var a=i.columns[o],f=new t.Select.View({id:"select_"+o,gid:o,onchange:function(e){r.group.set(this.gid,e),r.chart.set("modified",!0)},value:u,wait:!0});this.table.add(a.title,"25%"),this.table.add(f.$el),this.table.append(o),s[o]=f}this.chart.state("wait","Loading metadata...");var l=this.chart.deferred.register();this.app.datasets.request({id:e},function(e){r.columns=[];var t=e.metadata_column_types;for(var n in t)(t[n]=="int"||t[n]=="float")&&r.columns.push({label:"Column: "+(parseInt(n)+1)+" ["+t[n]+"]",value:n});for(var n in s)s[n].update(r.columns),s[n].show();r.chart.state("wait","Metadata initialized..."),r.chart.deferred.done(l)})},_refreshGroup:function(){this.group.set("date",n.time())},_refreshGroupKey:function(){var e=this.group.get("key");e===undefined&&(e=""),this.group_key.value(e)}})}),define("plugin/library/ui-table-form",["plugin/library/ui-table","plugin/library/ui","utils/utils"],function(e,t,n){var r=Backbone.View.extend({list:[],initialize:function(r){this.table_title=new t.Label({title:r.title}),this.table=new e.View({content:r.content});var i=$("<div/>");i.append(n.wrap(this.table_title.$el)),i.append(n.wrap(this.table.$el)),this.setElement(i)},title:function(e){this.table_title.title(e)},update:function(e,t){this.table.removeAll(),this.list=[];for(var n in e)this._add(n,e[n],t);for(var n in this.list){var r=this.list[n].options.onchange;r&&r()}},_add:function(e,n,r){var i=this,s=null,o=n.type;switch(o){case"text":s=new t.Input({id:e,placeholder:n.placeholder,onchange:function(){r.set(e,s.value())}});break;case"select":s=new t.Select.View({id:e,data:n.data,onchange:function(){var t=s.value();r.set(e,t);var o=_.findWhere(n.data,{value:t});o&&(o.show&&i.$el.find("#"+o.show).fadeIn("fast"),o.hide&&i.$el.find("#"+o.hide).fadeOut("fast"))}});break;case"separator":s=$("<div/>");break;default:console.log("ui-table-form:_add","Unknown setting type ("+n.type+")");return}if(o!="separator"){r.get(e)||r.set(e,n.init),s.value(r.get(e)),this.list[e]=s;var u=$("<div/>");u.append(s.$el),u.append('<div class="toolParamHelp" style="font-size: 0.9em;">'+n.info+"</div>"),this.table.add('<span style="white-space: nowrap;">'+n.title+"</span>","25%"),this.table.add(u)}else this.table.add('<h6 style="white-space: nowrap;">'+n.title+":<h6/>"),this.table.add($("<div/>"));this.table.append(e)}});return{View:r}}),define("plugin/views/settings",["plugin/library/ui","plugin/library/ui-table-form","utils/utils"],function(e,t,n){return Backbone.View.extend({initialize:function(e,n){this.app=e;var r=this;this.chart=this.app.chart,this.form=new t.View({title:"Chart options:",content:"This chart type does not provide any options."}),this.setElement(this.form.$el);var r=this;this.chart.on("change",function(){r._refreshTable()})},_refreshTable:function(){var e=this.chart.get("type");if(!e)return;var t=this.app.types.get(e);this.form.title(t.title+":"),this.form.update(t.settings,this.chart.settings)}})}),define("plugin/views/editor",["mvc/ui/ui-tabs","plugin/library/ui-table","plugin/library/ui","mvc/ui/ui-portlet","utils/utils","plugin/models/chart","plugin/models/group","plugin/views/group","plugin/views/settings"],function(e,t,n,r,i,s,o,u,a){return Backbone.View.extend({optionsDefault:{header:!0,content:"No content available."},initialize:function(s,o){var u=this;this.app=s,this.chart=this.app.chart,this.options=i.merge(o,this.optionsDefault),this.portlet=new r.View({icon:"fa-bar-chart-o",title:"Editor",operations:{save:new n.ButtonIcon({icon:"fa-save",tooltip:"Draw Chart",title:"Draw",onclick:function(){u.app.go("viewer"),u._saveChart()}}),back:new n.ButtonIcon({icon:"fa-caret-left",tooltip:"Return to Viewer",title:"Return",onclick:function(){u.app.go("viewer"),u.app.storage.load()}})}}),this.table=new t.View({header:!1,onconfirm:function(e){u.chart.groups.length>0?u.app.modal.show({title:"Switching to another chart type?",body:"If you continue your settings and selections will be cleared.",buttons:{Cancel:function(){u.app.modal.hide()},Continue:function(){u.app.modal.hide(),u.table.value(e)}}}):u.table.value(e)},onchange:function(e){u.chart.groups.reset(),u.chart.settings.clear(),u.chart.set({type:e})},ondblclick:function(e){u.tabs.show("settings")},content:"No chart types available"});var f=0,l=s.types.attributes;for(var c in l){var h=l[c];this.table.add(++f+"."),h.execute?this.table.add(h.title+" (requires processing)"):this.table.add(h.title),this.table.append(c)}this.tabs=new e.View({title_new:"Add Data",onnew:function(){var e=u._addGroupModel();u.tabs.show(e.id)}}),this.title=new n.Input({placeholder:"Chart title",onchange:function(){u.chart.set("title",u.title.value())}});var p=$("<div/>");p.append(i.wrap((new n.Label({title:"Provide a chart title:"})).$el)),p.append(i.wrap(this.title.$el)),p.append(i.wrap((new n.Label({title:"Select a chart type:"})).$el)),p.append(i.wrap(this.table.$el)),this.tabs.add({id:"main",title:"Start",$el:p}),this.settings=new a(this.app),this.tabs.add({id:"settings",title:"Configuration",$el:this.settings.$el}),this.portlet.append(this.tabs.$el),this.setElement(this.portlet.$el),this.tabs.hideOperation("back");var u=this;this.chart.on("change:title",function(e){u._refreshTitle()}),this.chart.on("change:type",function(e){u.table.value(e.get("type"))}),this.chart.on("reset",function(e){u._resetChart()}),this.app.chart.on("redraw",function(e){u.portlet.showOperation("back")}),this.app.chart.groups.on("add",function(e){u._addGroup(e)}),this.app.chart.groups.on("remove",function(e){u._removeGroup(e)}),this.app.chart.groups.on("reset",function(e){u._removeAllGroups()}),this.app.chart.groups.on("change:key",function(e){u._refreshGroupKey()}),this._resetChart()},show:function(){this.$el.show()},hide:function(){this.$el.hide()},_refreshTitle:function(){var e=this.chart.get("title");this.portlet.title(e),this.title.value(e)},_refreshGroupKey:function(){var e=this,t=0;this.chart.groups.each(function(n){var r=n.get("key","");r==""&&(r="Chart data"),e.tabs.title(n.id,++t+": "+r)})},_addGroupModel:function(){var e=new o({id:i.uuid()});return this.chart.groups.add(e),e},_addGroup:function(e){var t=this,n=new u(this.app,{group:e}),r=t.chart.groups.length;this.tabs.add({id:e.id,$el:n.$el,ondel:function(){t.chart.groups.remove(e.id)}}),this._refreshGroupKey()},_removeGroup:function(e){this.tabs.del(e.id),this._refreshGroupKey(),this.chart.set("modified",!0)},_removeAllGroups:function(e){this.tabs.delRemovable()},_resetChart:function(){this.chart.set("id",i.uuid()),this.chart.set("type","bardiagram"),this.chart.set("dataset_id",this.app.options.config.dataset_id),this.chart.set("title","New Chart"),this.portlet.hideOperation("back")},_saveChart:function(){this.chart.set({type:this.table.value(),title:this.title.value(),date:i.time()}),this.chart.groups.length==0&&this._addGroupModel();var e=this;this.chart.deferred.execute(function(){e.app.storage.save(),e.chart.trigger("redraw")})}})}),define("plugin/models/config",[],function(){return Backbone.Model.extend({defaults:{query_limit:1e3,query_timeout:500}})}),define("plugin/charts/_nvd3/config",[],function(){return{title:"",columns:{y:{title:"Values for y-axis"}},settings:{separator_label:{title:"X axis",type:"separator"},x_axis_label:{title:"Axis label",info:"Provide a label for the axis.",type:"text",init:"X-axis",placeholder:"Axis label"},x_axis_type:{title:"Axis value type",info:"Select the value type of the axis.",type:"select",init:"auto",data:[{label:"-- Do not show values --",value:"hide",hide:"x_axis_tick"},{label:"Auto",value:"auto",hide:"x_axis_tick"},{label:"Float",value:"f",show:"x_axis_tick"},{label:"Exponent",value:"e",show:"x_axis_tick"},{label:"Integer",value:"d",hide:"x_axis_tick"},{label:"Percentage",value:"p",show:"x_axis_tick"},{label:"Rounded",value:"r",show:"x_axis_tick"},{label:"SI-prefix",value:"s",show:"x_axis_tick"}]},x_axis_tick:{title:"Axis tick format",info:"Select the tick format for the axis.",type:"select",init:".1",data:[{label:"0.00001",value:".5"},{label:"0.0001",value:".4"},{label:"0.001",value:".3"},{label:"0.01",value:".2"},{label:"0.1",value:".1"},{label:"1",value:"1"}]},separator_tick:{title:"Y axis",type:"separator"},y_axis_label:{title:"Axis label",info:"Provide a label for the axis.",type:"text",init:"Y-axis",placeholder:"Axis label"},y_axis_type:{title:"Axis value type",info:"Select the value type of the axis.",type:"select",init:"auto",data:[{label:"-- Do not show values --",value:"hide",hide:"y_axis_tick"},{label:"Auto",value:"auto",hide:"y_axis_tick"},{label:"Float",value:"f",show:"y_axis_tick"},{label:"Exponent",value:"e",show:"y_axis_tick"},{label:"Integer",value:"d",hide:"y_axis_tick"},{label:"Percentage",value:"p",show:"y_axis_tick"},{label:"Rounded",value:"r",show:"y_axis_tick"},{label:"SI-prefix",value:"s",show:"y_axis_tick"}]},y_axis_tick:{title:"Axis tick format",info:"Select the tick format for the axis.",type:"select",init:".1",data:[{label:"0.00001",value:".5"},{label:"0.0001",value:".4"},{label:"0.001",value:".3"},{label:"0.01",value:".2"},{label:"0.1",value:".1"},{label:"1",value:"1"}]},separator_legend:{title:"Others",type:"separator"},show_legend:{title:"Show legend",info:"Would you like to add a legend?",type:"select",init:"true",data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]}}}}),define("plugin/charts/bardiagram/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Bar diagram"})}),define("plugin/charts/histogram/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Histogram",execute:!0,columns:{y:{title:"Observations"}},settings:{x_axis_label:{init:"Breaks"},y_axis_label:{init:"Density"}}})}),define("plugin/charts/horizontal/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Bar diagram (horizontal)",settings:{x_axis_type:{init:"hide"}}})}),define("plugin/charts/line/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Line chart"})}),define("plugin/charts/linewithfocus/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Line with focus"})}),define("plugin/charts/piechart/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Pie chart"})}),define("plugin/charts/scatterplot/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Scatter plot",columns:{x:{title:"Values for x-axis"}}})}),define("plugin/charts/stackedarea/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Stacked area"})}),define("plugin/charts/types",["plugin/charts/bardiagram/config","plugin/charts/histogram/config","plugin/charts/horizontal/config","plugin/charts/line/config","plugin/charts/linewithfocus/config","plugin/charts/piechart/config","plugin/charts/scatterplot/config","plugin/charts/stackedarea/config"],function(e,t,n,r,i,s,o,u){return Backbone.Model.extend({defaults:{bardiagram:e,horizontal:n,histogram:t,line:r,linewithfocus:i,piechart:s,scatterplot:o,stackedarea:u}})}),define("plugin/app",["mvc/ui/ui-modal","mvc/ui/ui-portlet","plugin/library/ui","utils/utils","plugin/library/jobs","plugin/library/datasets","plugin/library/storage","plugin/views/viewer","plugin/views/editor","plugin/models/config","plugin/models/chart","plugin/charts/types"],function(e,t,n,r,i,s,o,u,a,f,l,c){return Backbone.View.extend({initialize:function(t){this.options=t,Galaxy&&Galaxy.modal?this.modal=Galaxy.modal:this.modal=new e.View,this.config=new f,this.types=new c,this.chart=new l,this.jobs=new i(this),this.datasets=new s(this),this.storage=new o(this),this.viewer_view=new u(this),this.editor_view=new a(this),this.$el.append(this.viewer_view.$el),this.$el.append(this.editor_view.$el);if(!this.storage.load())this.go("editor");else{this.go("viewer");var n=this;this.chart.deferred.execute(function(){n.chart.trigger("redraw")})}},go:function(e){$(".tooltip").hide();switch(e){case"editor":this.editor_view.show(),this.viewer_view.hide();break;case"viewer":this.editor_view.hide(),this.viewer_view.show()}},execute:function(e){},onunload:function(){},log:function(e,t){console.log(e+" "+t)}})}); \ No newline at end of file +(function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=i.toString,l=i.hasOwnProperty,c=r.forEach,h=r.map,p=r.reduce,d=r.reduceRight,v=r.filter,m=r.every,g=r.some,y=r.indexOf,b=r.lastIndexOf,w=Array.isArray,E=Object.keys,S=s.bind,x=function(e){if(e instanceof x)return e;if(!(this instanceof x))return new x(e);this._wrapped=e};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=x),exports._=x):e._=x,x.VERSION="1.4.4";var T=x.each=x.forEach=function(e,t,r){if(e==null)return;if(c&&e.forEach===c)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i<s;i++)if(t.call(r,e[i],i,e)===n)return}else for(var o in e)if(x.has(e,o)&&t.call(r,e[o],o,e)===n)return};x.map=x.collect=function(e,t,n){var r=[];return e==null?r:h&&e.map===h?e.map(t,n):(T(e,function(e,i,s){r.push(t.call(n,e,i,s))}),r)};var N="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(p&&e.reduce===p)return r&&(t=x.bind(t,r)),i?e.reduce(t,n):e.reduce(t);T(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError(N);return n},x.reduceRight=x.foldr=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(d&&e.reduceRight===d)return r&&(t=x.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=x.keys(e);s=o.length}T(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)throw new TypeError(N);return n},x.find=x.detect=function(e,t,n){var r;return C(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},x.filter=x.select=function(e,t,n){var r=[];return e==null?r:v&&e.filter===v?e.filter(t,n):(T(e,function(e,i,s){t.call(n,e,i,s)&&r.push(e)}),r)},x.reject=function(e,t,n){return x.filter(e,function(e,r,i){return!t.call(n,e,r,i)},n)},x.every=x.all=function(e,t,r){t||(t=x.identity);var i=!0;return e==null?i:m&&e.every===m?e.every(t,r):(T(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))return n}),!!i)};var C=x.some=x.any=function(e,t,r){t||(t=x.identity);var i=!1;return e==null?i:g&&e.some===g?e.some(t,r):(T(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))return n}),!!i)};x.contains=x.include=function(e,t){return e==null?!1:y&&e.indexOf===y?e.indexOf(t)!=-1:C(e,function(e){return e===t})},x.invoke=function(e,t){var n=u.call(arguments,2),r=x.isFunction(t);return x.map(e,function(e){return(r?t:e[t]).apply(e,n)})},x.pluck=function(e,t){return x.map(e,function(e){return e[t]})},x.where=function(e,t,n){return x.isEmpty(t)?n?void 0:[]:x[n?"find":"filter"](e,function(e){for(var n in t)if(t[n]!==e[n])return!1;return!0})},x.findWhere=function(e,t){return x.where(e,t,!0)},x.max=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.max.apply(Math,e);if(!t&&x.isEmpty(e))return-Infinity;var r={computed:-Infinity,value:-Infinity};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o>=r.computed&&(r={value:e,computed:o})}),r.value},x.min=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);if(!t&&x.isEmpty(e))return Infinity;var r={computed:Infinity,value:Infinity};return T(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o<r.computed&&(r={value:e,computed:o})}),r.value},x.shuffle=function(e){var t,n=0,r=[];return T(e,function(e){t=x.random(n++),r[n-1]=r[t],r[t]=e}),r};var k=function(e){return x.isFunction(e)?e:function(t){return t[e]}};x.sortBy=function(e,t,n){var r=k(t);return x.pluck(x.map(e,function(e,t,i){return{value:e,index:t,criteria:r.call(n,e,t,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(n<r||r===void 0)return-1}return e.index<t.index?-1:1}),"value")};var L=function(e,t,n,r){var i={},s=k(t==null?x.identity:t);return T(e,function(t,o){var u=s.call(n,t,o,e);r(i,u,t)}),i};x.groupBy=function(e,t,n){return L(e,t,n,function(e,t,n){(x.has(e,t)?e[t]:e[t]=[]).push(n)})},x.countBy=function(e,t,n){return L(e,t,n,function(e,t){x.has(e,t)||(e[t]=0),e[t]++})},x.sortedIndex=function(e,t,n,r){n=n==null?x.identity:k(n);var i=n.call(r,t),s=0,o=e.length;while(s<o){var u=s+o>>>1;n.call(r,e[u])<i?s=u+1:o=u}return s},x.toArray=function(e){return e?x.isArray(e)?u.call(e):e.length===+e.length?x.map(e,x.identity):x.values(e):[]},x.size=function(e){return e==null?0:e.length===+e.length?e.length:x.keys(e).length},x.first=x.head=x.take=function(e,t,n){return e==null?void 0:t!=null&&!n?u.call(e,0,t):e[0]},x.initial=function(e,t,n){return u.call(e,0,e.length-(t==null||n?1:t))},x.last=function(e,t,n){return e==null?void 0:t!=null&&!n?u.call(e,Math.max(e.length-t,0)):e[e.length-1]},x.rest=x.tail=x.drop=function(e,t,n){return u.call(e,t==null||n?1:t)},x.compact=function(e){return x.filter(e,x.identity)};var A=function(e,t,n){return T(e,function(e){x.isArray(e)?t?o.apply(n,e):A(e,t,n):n.push(e)}),n};x.flatten=function(e,t){return A(e,t,[])},x.without=function(e){return x.difference(e,u.call(arguments,1))},x.uniq=x.unique=function(e,t,n,r){x.isFunction(t)&&(r=n,n=t,t=!1);var i=n?x.map(e,n,r):e,s=[],o=[];return T(i,function(n,r){if(t?!r||o[o.length-1]!==n:!x.contains(o,n))o.push(n),s.push(e[r])}),s},x.union=function(){return x.uniq(a.apply(r,arguments))},x.intersection=function(e){var t=u.call(arguments,1);return x.filter(x.uniq(e),function(e){return x.every(t,function(t){return x.indexOf(t,e)>=0})})},x.difference=function(e){var t=a.apply(r,u.call(arguments,1));return x.filter(e,function(e){return!x.contains(t,e)})},x.zip=function(){var e=u.call(arguments),t=x.max(x.pluck(e,"length")),n=new Array(t);for(var r=0;r<t;r++)n[r]=x.pluck(e,""+r);return n},x.unzip=function(e){var t=[];return x.each(e,function(e,n){x.each(e,function(e,r){t.length<=r&&(t[r]=[]),t[r][n]=e})}),t},x.object=function(e,t){if(e==null)return{};var n={};for(var r=0,i=e.length;r<i;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},x.indexOf=function(e,t,n){if(e==null)return-1;var r=0,i=e.length;if(n){if(typeof n!="number")return r=x.sortedIndex(e,t),e[r]===t?r:-1;r=n<0?Math.max(0,i+n):n}if(y&&e.indexOf===y)return e.indexOf(t,n);for(;r<i;r++)if(e[r]===t)return r;return-1},x.lastIndexOf=function(e,t,n){if(e==null)return-1;var r=n!=null;if(b&&e.lastIndexOf===b)return r?e.lastIndexOf(t,n):e.lastIndexOf(t);var i=r?n:e.length;while(i--)if(e[i]===t)return i;return-1},x.range=function(e,t,n){arguments.length<=1&&(t=e||0,e=0),n=arguments[2]||1;var r=Math.max(Math.ceil((t-e)/n),0),i=0,s=new Array(r);while(i<r)s[i++]=e,e+=n;return s};var O=function(){};x.bind=function(e,t){var n,r;if(e.bind===S&&S)return S.apply(e,u.call(arguments,1));if(!x.isFunction(e))throw new TypeError;return n=u.call(arguments,2),r=function(){if(this instanceof r){O.prototype=e.prototype;var i=new O;O.prototype=null;var s=e.apply(i,n.concat(u.call(arguments)));return Object(s)===s?s:i}return e.apply(t,n.concat(u.call(arguments)))}},x.partial=function(e){var t=u.call(arguments,1);return function(){return e.apply(this,t.concat(u.call(arguments)))}},x.bindAll=function(e){var t=u.call(arguments,1);if(t.length===0)throw new Error("bindAll must be passed function names");return T(t,function(t){e[t]=x.bind(e[t],e)}),e},x.memoize=function(e,t){var n={};return t||(t=x.identity),function(){var r=t.apply(this,arguments);return x.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},x.delay=function(e,t){var n=u.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},x.defer=function(e){return x.delay.apply(x,[e,1].concat(u.call(arguments,1)))},x.throttle=function(e,t,n){var r,i,s,o,u=0,a=function(){u=new Date,s=null,o=e.apply(r,i)};return function(){var f=new Date;!u&&n===!1&&(u=f);var l=t-(f-u);return r=this,i=arguments,l<=0?(clearTimeout(s),s=null,u=f,o=e.apply(r,i)):s||(s=setTimeout(a,l)),o}},x.debounce=function(e,t,n){var r,i;return function(){var s=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;return clearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},x.once=function(e){var t=!1,n;return function(){return t?n:(t=!0,n=e.apply(this,arguments),e=null,n)}},x.wrap=function(e,t){return function(){var n=[e];return o.apply(n,arguments),t.apply(this,n)}},x.compose=function(){var e=arguments;return function(){var t=arguments;for(var n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},x.after=function(e,t){return e<=0?t():function(){if(--e<1)return t.apply(this,arguments)}},x.keys=E||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var n in e)x.has(e,n)&&t.push(n);return t},x.values=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push(e[n]);return t},x.pairs=function(e){var t=[];for(var n in e)x.has(e,n)&&t.push([n,e[n]]);return t},x.invert=function(e){var t={};for(var n in e)x.has(e,n)&&(t[e[n]]=n);return t},x.functions=x.methods=function(e){var t=[];for(var n in e)x.isFunction(e[n])&&t.push(n);return t.sort()},x.extend=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]=t[n]}),e},x.pick=function(e){var t={},n=a.apply(r,u.call(arguments,1));return T(n,function(n){n in e&&(t[n]=e[n])}),t},x.omit=function(e){var t={},n=a.apply(r,u.call(arguments,1));for(var i in e)x.contains(n,i)||(t[i]=e[i]);return t},x.defaults=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e},x.clone=function(e){return x.isObject(e)?x.isArray(e)?e.slice():x.extend({},e):e},x.tap=function(e,t){return t(e),e};var M=function(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;e instanceof x&&(e=e._wrapped),t instanceof x&&(t=t._wrapped);var i=f.call(e);if(i!=f.call(t))return!1;switch(i){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeof e!="object"||typeof t!="object")return!1;var s=n.length;while(s--)if(n[s]==e)return r[s]==t;n.push(e),r.push(t);var o=0,u=!0;if(i=="[object Array]"){o=e.length,u=o==t.length;if(u)while(o--)if(!(u=M(e[o],t[o],n,r)))break}else{var a=e.constructor,l=t.constructor;if(a!==l&&!(x.isFunction(a)&&a instanceof a&&x.isFunction(l)&&l instanceof l))return!1;for(var c in e)if(x.has(e,c)){o++;if(!(u=x.has(t,c)&&M(e[c],t[c],n,r)))break}if(u){for(c in t)if(x.has(t,c)&&!(o--))break;u=!o}}return n.pop(),r.pop(),u};x.isEqual=function(e,t){return M(e,t,[],[])},x.isEmpty=function(e){if(e==null)return!0;if(x.isArray(e)||x.isString(e))return e.length===0;for(var t in e)if(x.has(e,t))return!1;return!0},x.isElement=function(e){return!!e&&e.nodeType===1},x.isArray=w||function(e){return f.call(e)=="[object Array]"},x.isObject=function(e){return e===Object(e)},T(["Arguments","Function","String","Number","Date","RegExp"],function(e){x["is"+e]=function(t){return f.call(t)=="[object "+e+"]"}}),x.isArguments(arguments)||(x.isArguments=function(e){return!!e&&!!x.has(e,"callee")}),typeof /./!="function"&&(x.isFunction=function(e){return typeof e=="function"}),x.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},x.isNaN=function(e){return x.isNumber(e)&&e!=+e},x.isBoolean=function(e){return e===!0||e===!1||f.call(e)=="[object Boolean]"},x.isNull=function(e){return e===null},x.isUndefined=function(e){return e===void 0},x.has=function(e,t){return l.call(e,t)},x.noConflict=function(){return e._=t,this},x.identity=function(e){return e},x.times=function(e,t,n){var r=Array(e);for(var i=0;i<e;i++)r[i]=t.call(n,i);return r},x.random=function(e,t){return t==null&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))};var _={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};_.unescape=x.invert(_.escape);var D={escape:new RegExp("["+x.keys(_.escape).join("")+"]","g"),unescape:new RegExp("("+x.keys(_.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(e){x[e]=function(t){return t==null?"":(""+t).replace(D[e],function(t){return _[e][t]})}}),x.result=function(e,t){if(e==null)return void 0;var n=e[t];return x.isFunction(n)?n.call(e):n},x.mixin=function(e){T(x.functions(e),function(t){var n=x[t]=e[t];x.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),F.call(this,n.apply(x,e))}})};var P=0;x.uniqueId=function(e){var t=++P+"";return e?e+t:t},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},j=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(e,t,n){var r;n=x.defaults({},n,x.templateSettings);var i=new RegExp([(n.escape||H).source,(n.interpolate||H).source,(n.evaluate||H).source].join("|")+"|$","g"),s=0,o="__p+='";e.replace(i,function(t,n,r,i,u){return o+=e.slice(s,u).replace(j,function(e){return"\\"+B[e]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),s=u+t.length,t}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=new Function(n.variable||"obj","_",o)}catch(u){throw u.source=o,u}if(t)return r(t,x);var a=function(e){return r.call(this,e,x)};return a.source="function("+(n.variable||"obj")+"){\n"+o+"}",a},x.chain=function(e){return x(e).chain()};var F=function(e){return this._chain?x(e).chain():e};x.mixin(x),T(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];x.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&delete n[0],F.call(this,n)}}),T(["concat","join","slice"],function(e){var t=r[e];x.prototype[e]=function(){return F.call(this,t.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this),define("libs/underscore",function(e){return function(){var t,n;return t||e._}}(this)),define("utils/utils",["libs/underscore"],function(e){function t(e,t,r){n("GET",e,{},t,r)}function n(e,t,n,r,i){if(e=="GET"||e=="DELETE")t.indexOf("?")==-1?t+="?":t+="&",t+=$.param(n);var s=new XMLHttpRequest;s.open(e,t,!0),s.setRequestHeader("Accept","application/json"),s.setRequestHeader("Cache-Control","no-cache"),s.setRequestHeader("X-Requested-With","XMLHttpRequest"),s.setRequestHeader("Content-Type","application/json"),s.onloadend=function(){var e=s.status;try{response=jQuery.parseJSON(s.responseText)}catch(t){response=s.responseText}e==200?r&&r(response):i&&i(response)},e=="GET"||e=="DELETE"?s.send():s.send(JSON.stringify(n))}function r(e,t){var n=$('<div class="'+e+'"></div>');n.appendTo(":eq(0)");var r=n.css(t);return n.remove(),r}function i(e){$('link[href^="'+e+'"]').length||$('<link href="'+galaxy_config.root+e+'" rel="stylesheet">').appendTo("head")}function s(t,n){return t?e.defaults(t,n):n}function o(e,t){var n="";if(e>=1e11)e/=1e11,n="TB";else if(e>=1e8)e/=1e8,n="GB";else if(e>=1e5)e/=1e5,n="MB";else if(e>=100)e/=100,n="KB";else{if(!(e>0))return"<strong>-</strong>";e*=10,n="b"}var r=Math.round(e)/10;return t?r+" "+n:"<strong>"+r+"</strong> "+n}function u(){return(new Date).getTime().toString(36)}function a(e){var t=$("<p></p>");return t.append(e),t}function f(){var e=new Date,t=(e.getHours()<10?"0":"")+e.getHours(),n=(e.getMinutes()<10?"0":"")+e.getMinutes(),r=e.getDate()+"/"+(e.getMonth()+1)+"/"+e.getFullYear()+", "+t+":"+n;return r}return{cssLoadFile:i,cssGetAttribute:r,get:t,merge:s,bytesToString:o,uuid:u,time:f,wrap:a,request:n}}),define("mvc/ui/ui-modal",["utils/utils"],function(e){var t=Backbone.View.extend({elMain:"body",optionsDefault:{title:"ui-modal",body:"",backdrop:!0,height:null,width:null,closing_events:!1},buttonList:{},initialize:function(e){e&&this._create(e)},show:function(e){this.initialize(e),this.options.height?(this.$body.css("height",this.options.height),this.$body.css("overflow","hidden")):this.$body.css("max-height",$(window).height()/2),this.options.width&&this.$dialog.css("width",this.options.width),this.visible?this.$el.show():this.$el.fadeIn("fast"),this.visible=!0},hide:function(){this.visible=!1,this.$el.fadeOut("fast")},enableButton:function(e){var t=this.buttonList[e];this.$buttons.find("#"+t).prop("disabled",!1)},disableButton:function(e){var t=this.buttonList[e];this.$buttons.find("#"+t).prop("disabled",!0)},showButton:function(e){var t=this.buttonList[e];this.$buttons.find("#"+t).show()},hideButton:function(e){var t=this.buttonList[e];this.$buttons.find("#"+t).hide()},getButton:function(e){var t=this.buttonList[e];return this.$buttons.find("#"+t)},scrollTop:function(){return this.$body.scrollTop()},_create:function(e){var t=this;this.options=_.defaults(e,this.optionsDefault),this.options.body=="progress"&&(this.options.body=$('<div class="progress progress-striped active"><div class="progress-bar progress-bar-info" style="width:100%"></div></div>')),this.$el&&(this.$el.remove(),$(document).off("keyup.ui-modal")),this.setElement(this._template(this.options.title)),this.$dialog=this.$el.find(".modal-dialog"),this.$body=this.$el.find(".modal-body"),this.$footer=this.$el.find(".modal-footer"),this.$buttons=this.$el.find(".buttons"),this.$backdrop=this.$el.find(".modal-backdrop"),this.$body.html(this.options.body),this.options.backdrop||this.$backdrop.removeClass("in");if(this.options.buttons){this.buttonList={};var n=0;$.each(this.options.buttons,function(e,r){var i="button-"+n++;t.$buttons.append($('<button id="'+i+'"></button>').text(e).click(r)).append(" "),t.buttonList[e]=i})}else this.$footer.hide();$(this.elMain).append($(this.el)),this.options.closing_events&&($(document).on("keyup.ui-modal",function(e){e.keyCode==27&&t.hide()}),this.$el.find(".modal-backdrop").on("click",function(){t.hide()}))},_template:function(e){return'<div class="modal"><div class="modal-backdrop fade in" style="z-index: -1;"></div><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" style="display: none;">×</button><h4 class="title">'+e+"</h4>"+"</div>"+'<div class="modal-body" style="position: static;"></div>'+'<div class="modal-footer">'+'<div class="buttons" style="float: right;"></div>'+"</div>"+"</div"+"</div>"+"</div>"}});return{View:t}}),define("mvc/ui/ui-portlet",["utils/utils"],function(e){var t=Backbone.View.extend({visible:!1,optionsDefault:{title:"",icon:"",buttons:null,body:null,height:null,operations:null,placement:"bottom",overflow:"auto"},$title:null,$content:null,$buttons:null,$operations:null,initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),this.$content=this.$el.find("#content"),this.$title=this.$el.find("#title-text"),this.options.height&&(this.$el.find("#body").css("height",this.options.height),this.$el.find("#content").css("overflow",this.options.overflow)),this.$buttons=$(this.el).find("#buttons");if(this.options.buttons){var n=this;$.each(this.options.buttons,function(e,t){t.$el.prop("id",e),n.$buttons.append(t.$el)})}else this.$buttons.remove();this.$operations=$(this.el).find("#operations");if(this.options.operations){var n=this;$.each(this.options.operations,function(e,t){t.$el.prop("id",e),n.$operations.append(t.$el)})}this.options.body&&this.append(this.options.body)},append:function(t){this.$content.append(e.wrap(t))},content:function(){return this.$content},show:function(){this.$el.fadeIn("fast"),this.visible=!0},hide:function(){this.$el.fadeOut("fast"),this.visible=!1},enableButton:function(e){this.$buttons.find("#"+e).prop("disabled",!1)},disableButton:function(e){this.$buttons.find("#"+e).prop("disabled",!0)},hideOperation:function(e){this.$operations.find("#"+e).hide()},showOperation:function(e){this.$operations.find("#"+e).show()},setOperation:function(e,t){var n=this.$operations.find("#"+e);n.off("click"),n.on("click",t)},title:function(e){var t=this.$title;return e&&t.html(e),t.html()},_template:function(e){var t='<div class="toolForm portlet-view no-highlight">';if(e.title||e.icon)t+='<div id="title" class="toolFormTitle portlet-title"><div id="operations" class="portlet-operations"/><div style="overflow: hidden;">',e.icon&&(t+='<div class="portlet-title-icon fa '+e.icon+'"> </div>'),t+='<div id="title-text" class="portlet-title-text">'+e.title+"</div>",t+="</div></div>";return t+='<div id="body" class="toolFormBody portlet-body">',e.placement=="top"&&(t+='<div id="buttons" class="portlet-buttons"/>'),t+='<div id="content" class="portlet-content"/>',e.placement=="bottom"&&(t+='<div id="buttons" class="portlet-buttons"/>'),t+="</div></div>",t}});return{View:t}}),define("plugin/library/ui-select",["utils/utils"],function(e){var t=Backbone.View.extend({optionsDefault:{id:"",cls:"",empty:"No data available",visible:!0,wait:!1},selected:null,initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),this.$select=this.$el.find("#select"),this.$icon=this.$el.find("#icon"),this.selected=this.options.value;var n=this;this.options.onchange&&this.$select.on("change",function(){n.value(n.$select.val())}),this._refresh(),this.options.visible||this.hide(),this.options.wait?this.wait():this.show()},value:function(e){var t=this.selected;e!==undefined&&(this.selected=e,this.$select.val(e));var n=this.selected;return n&&n!=t&&this.options.onchange&&this.options.onchange(n),n},text:function(){return this.$select.find("option:selected").text()},show:function(){this.$icon.removeClass(),this.$icon.addClass("fa fa-caret-down"),this.$select.show(),this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass(),this.$icon.addClass("fa fa-spinner fa-spin"),this.$select.hide()},disabled:function(){return this.$select.is(":disabled")},enable:function(){this.$select.prop("disabled",!1)},disable:function(){this.$select.prop("disabled",!0)},add:function(e){this.$select.append(this._templateOption(e)),this._refresh()},del:function(e){this.$select.find("option[value="+e+"]").remove(),this.$select.trigger("change"),this._refresh()},update:function(e){this.$select.find("option").remove();for(var t in e)this.$select.append(this._templateOption(e[t]));!this.selected&&e.length>0&&this.value(e[0].value),this._refresh()},_refresh:function(){this.$select.find("option[value=null]").remove();var e=this.$select.find("option").length;e==0?(this.$select.append(this._templateOption({value:"null",label:this.options.empty})),this.disable()):(this.enable(),this.selected&&this.$select.val(this.selected))},_exists:function(e){return 0!=this.$select.find("option[value="+e+"]").length},_templateOption:function(e){return'<option value="'+e.value+'">'+e.label+"</option>"},_template:function(e){var t='<div id="'+e.id+'" class="styled-select">'+'<div class="button">'+'<i id="icon"/>'+"</div>"+'<select id="select" class="select '+e.cls+" "+e.id+'">';for(key in e.data){var n=e.data[key],r="";if(n.value==e.value||n.value=="")r="selected";t+='<option value="'+n.value+'" '+r+">"+n.label+"</option>"}return t+="</select></div>",t}});return{View:t}}),define("plugin/library/ui",["utils/utils","plugin/library/ui-select"],function(e,t){var n=Backbone.View.extend({optionsDefault:{title:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options))},title:function(e){this.$el.find("b").html(e)},_template:function(e){return"<label><b>"+e.title+"</b></label>"},value:function(){return options.title}}),r=Backbone.View.extend({optionsDefault:{id:null,title:"","float":"right",cls:"btn-default",icon:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),$(this.el).on("click",t.onclick),$(this.el).tooltip({title:t.tooltip,placement:"bottom"})},_template:function(e){var t='<button id="'+e.id+'" type="submit" style="margin-right: 5px; float: '+e.float+';" type="button" class="btn '+e.cls+'">';return e.icon&&(t+='<i class="icon fa '+e.icon+'"></i> '),t+=e.title+"</button>",t}}),i=Backbone.View.extend({optionsDefault:{"float":"right",icon:"",tooltip:"",placement:"bottom",title:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),$(this.el).tooltip({title:t.tooltip,placement:"bottom"})},_template:function(e){return'<div><span class="fa '+e.icon+'" style="font-size: 1.2em;"/> '+e.title+"</div>"}}),s=Backbone.View.extend({optionsDefault:{title:"",id:null,"float":"right",cls:"icon-btn",icon:"",tooltip:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),$(this.el).on("click",t.onclick),$(this.el).tooltip({title:t.tooltip,placement:"bottom"})},_template:function(e){var t="";e.title&&(t="width: auto;");var n='<div id="'+e.id+'" style="margin-right: 5px; float: '+e.float+"; "+t+'" class="'+e.cls+'">';return e.title?n+='<div style="margin-right: 5px; margin-left: 5px;"><i class="icon fa '+e.icon+'"/> '+'<span style="position: relative; font-size: 0.8em; font-weight: normal; top: -1px;">'+e.title+"</span>"+"</div>":n+='<i class="icon fa '+e.icon+'"/>',n+="</div>",n}}),o=Backbone.View.extend({optionsDefault:{title:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),$(this.el).on("click",t.onclick)},_template:function(e){return'<div><a href="javascript:void(0)">'+e.title+"</a></div>"}}),u=Backbone.View.extend({optionsDefault:{message:"",status:"info",persistent:!1},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement("<div></div>")},update:function(t){this.options=e.merge(t,this.optionsDefault);if(t.message!=""){this.$el.html(this._template(this.options)),this.$el.fadeIn();if(!t.persistent){var n=this;window.setTimeout(function(){n.$el.is(":visible")?n.$el.fadeOut():n.$el.hide()},3e3)}}else this.$el.fadeOut()},_template:function(e){return'<div class="alert alert-'+e.status+'" style="padding: 2px 2px 2px 10px;">'+e.message+"</div>"}}),a=Backbone.View.extend({optionsDefault:{onclick:null,searchword:""},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options));var n=this;this.options.onclick&&this.$el.on("submit",function(e){var t=n.$el.find("#search");n.options.onclick(t.val())})},_template:function(e){return'<div class="search"><form onsubmit="return false;"><input id="search" class="form-control input-sm" type="text" name="search" placeholder="Search..." value="'+e.searchword+'">'+'<button type="submit" class="btn search-btn">'+'<i class="fa fa-search"></i>'+"</button>"+"</form>"+"</div>"}}),f=Backbone.View.extend({optionsDefault:{title:"Unlabeled",body:null},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),this.options.body&&this.$el.find(".body").append(this.options.body)},_template:function(e){return'<div id="title" class="title">'+e.title+":"+"</div>"}}),l=Backbone.View.extend({optionsDefault:{id:"",title:"",target:"",href:"",onunload:null,onclick:null,visible:!0,icon:null,tag:""},$menu:null,initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement($(this._template(this.options)));var n=$(this.el).find(".root"),r=this;n.on("click",function(e){e.preventDefault(),r.options.onclick&&r.options.onclick()}),this.options.visible||this.hide()},show:function(){$(this.el).show()},hide:function(){$(this.el).hide()},addMenu:function(t){var n={title:"",target:"",href:"",onclick:null,divider:!1,icon:null};n=e.merge(t,n),this.$menu||($(this.el).append(this._templateMenu()),this.$menu=$(this.el).find(".menu"));var r=$(this._templateMenuItem(n));r.on("click",function(e){e.preventDefault(),n.onclick&&n.onclick()}),this.$menu.append(r),n.divider&&this.$menu.append($(this._templateDivider()))},_templateMenuItem:function(e){var t='<li><a href="'+e.href+'" target="'+e.target+'">';return e.icon&&(t+='<i class="fa '+e.icon+'"></i>'),t+=" "+e.title+"</a>"+"</li>",t},_templateMenu:function(){return'<ul class="menu dropdown-menu pull-right" role="menu"></ul>'},_templateDivider:function(){return'<li class="divider"></li>'},_template:function(e){var t='<div id="'+e.id+'" class="button-menu btn-group">'+'<button type="button" class="root btn btn-default dropdown-toggle" data-toggle="dropdown">';return e.icon&&(t+='<i class="fa '+e.icon+'"></i>'),"</button></div>",t}}),c=Backbone.View.extend({optionsDefault:{value:"",type:"text",placeholder:"",disabled:!1,visible:!0},initialize:function(t){this.options=e.merge(t,this.optionsDefault),this.setElement(this._template(this.options)),this.options.disabled&&this.$el.prop("disabled",!0),this.options.visible||this.$el.hide();var n=this;this.options.onchange&&this.$el.on("input",function(){n.options.onchange()})},value:function(e){return e!==undefined&&this.$el.val(e),this.$el.val()},_template:function(e){return'<input id="'+e.id+'" type="'+e.type+'" value="'+e.value+'" placeholder="'+e.placeholder+'" class="form-control">'}});return{Label:n,Button:r,Icon:i,ButtonIcon:s,Input:c,Anchor:o,Message:u,Searchbox:a,Title:f,Select:t,ButtonMenu:l}}),define("plugin/library/jobs",["utils/utils"],function(e){return Backbone.Model.extend({initialize:function(t,n){this.app=t,this.options=e.merge(n,this.optionsDefault)},cleanup:function(t){var n=t.get("dataset_id_job");if(n!=""){var r=this;e.request("PUT",config.root+"api/histories/none/contents/"+n,{deleted:!0},function(){r._refreshHdas()}),t.set("dataset_id_job","")}},submit:function(t,n,r,i,s){var o=this,u=t.id,a=t.get("type"),f=this.app.types.get(a);data={tool_id:"chartskit",inputs:{input:{id:t.get("dataset_id"),src:"hda"},module:a,columns:r,settings:n}},t.state("wait","Sending job request..."),e.request("POST",config.root+"api/tools",data,function(e){if(!e.outputs||e.outputs.length==0)t.state("failed","Job submission failed. No response."),s&&s();else{o._refreshHdas();var n=e.outputs[0];t.state("wait","Job has been queued..."),t.set("dataset_id_job",n.id),this.app.storage.save(),o._loop(n.id,function(e){switch(e.state){case"ok":return t.state("wait","Job completed successfully..."),i(e),!0;case"error":return t.state("failed","Job has failed. Please check the history for details."),s&&s(),!0;case"running":return t.state("wait","Job is running..."),!1}})}},function(e){var n="";e&&e.message&&e.message.data&&e.message.data.input&&(n=e.message.data.input+"."),t.state("failed","This visualization requires the Charts-Kit. Please make sure it is installed. "+n),s&&s()})},_loop:function(t,n){var r=this;e.request("GET",config.root+"api/datasets/"+t,{},function(e){n(e)||setTimeout(function(){r._loop(t,n)},r.app.config.get("query_timeout"))})},_refreshHdas:function(){Galaxy&&Galaxy.currHistoryPanel&&Galaxy.currHistoryPanel.refreshHdas()}})}),define("plugin/library/datasets",["utils/utils"],function(e){return Backbone.Collection.extend({list:{},initialize:function(t,n){this.app=t,this.options=e.merge(n,this.optionsDefault)},request:function(t,n,r){var i=this;if(t.groups)this._fetch(t,n);else{var s=this.list[t.id];if(s){n(s);return}e.request("GET",config.root+"api/datasets/"+t.id,{},function(e){switch(e.state){case"error":r&&r(e);break;default:i.list[t.id]=e,n(e)}})}},_fetch:function(t,n){var r=t.start?t.start:0,i=Math.abs(t.end-t.start),s=this.app.config.get("query_limit");if(!i||i>s)i=s;var o="",u={},a=0;for(var f in t.groups){var l=t.groups[f];for(var c in l.columns){var h=l.columns[c];o+=h+",",u[h]=a,a++}}if(a==0){n({});return}o=o.substring(0,o.length-1);var p=t.groups.slice(0);for(var f in p)p[f].values=[];var d=this;e.request("GET",config.root+"api/datasets/"+t.id,{data_type:"raw_data",provider:"dataset-column",limit:i,offset:r,indeces:o},function(e){for(var i in e.data){var s=e.data[i];for(var o in t.groups){var a=t.groups[o],f={x:parseInt(i)+r};for(var l in a.columns){var c=a.columns[l],h=u[c],d=s[h];if(isNaN(d)||!d)d=0;f[l]=d}p[o].values.push(f)}}n(p)})}})}),define("plugin/models/group",[],function(){return Backbone.Model.extend({defaults:{key:"Data label",date:""},reset:function(){this.clear({silent:!0}).set(this.defaults),this.trigger("reset",this)}})}),define("plugin/models/groups",["plugin/models/group"],function(e){return Backbone.Collection.extend({model:e})}),define("plugin/library/deferred",["utils/utils"],function(e){return Backbone.Model.extend({queue:[],process:{},counter:0,initialize:function(){this.on("refresh",function(){if(this.counter==0)for(var e in this.queue)this.queue[e](),this.queue.splice(e,1)})},execute:function(e){this.queue.push(e),this.trigger("refresh")},register:function(){var t=e.uuid();return this.process[t]=!0,this.counter++,console.debug("Deferred:register() - Registering "+t),t},done:function(e){delete this.process[e],this.counter--,console.debug("Deferred:done() - Unregistering "+e),this.trigger("refresh")},ready:function(){return this.counter==0?!0:!1}})});var Visualization=Backbone.Model.extend({defaults:{config:{}},urlRoot:function(){var e="/api/visualizations";return window.galaxy_config&&galaxy_config.root?galaxy_config.root+e:e},initialize:function(e){_.isObject(e.config)&&_.isObject(this.defaults.config)&&_.defaults(e.config,this.defaults.config),this._setUpListeners()},_setUpListeners:function(){},set:function(e,t){if(e==="config"){var n=this.get("config");_.isObject(n)&&(t=_.extend(_.clone(n),t))}return Backbone.Model.prototype.set.call(this,e,t),this},toString:function(){var e=this.get("id")||"";return this.get("title")&&(e+=":"+this.get("title")),"Visualization("+e+")"}}),VisualizationCollection=Backbone.Collection.extend({model:Visualization,url:function(){return galaxy_config.root+"api/visualizations"},initialize:function(e,t){t=t||{}},set:function(e,t){var n=this;e=_.map(e,function(e){var t=n.get(e.id);if(!t)return e;var r=t.toJSON();return _.extend(r,e),r}),Backbone.Collection.prototype.set.call(this,e,t)},toString:function(){return["VisualizationCollection(",[this.historyId,this.length].join(),")"].join("")}});define("mvc/visualization/visualization-model",function(){}),define("plugin/models/chart",["plugin/models/groups","plugin/library/deferred","mvc/visualization/visualization-model"],function(e,t){return Backbone.Model.extend({defaults:{id:null,title:"",type:"",date:null,state:"",state_info:"",modified:!1,dataset_id:"",dataset_id_job:""},initialize:function(n){this.groups=new e,this.settings=new Backbone.Model,this.deferred=new t},reset:function(){this.clear({silent:!0}).set(this.defaults),this.groups.reset(),this.settings.clear(),this.trigger("reset",this)},copy:function(e){var t=this;t.clear({silent:!0}).set(this.defaults),t.set(e.attributes),t.settings=e.settings.clone(),t.groups.reset(),e.groups.each(function(e){t.groups.add(e.clone())}),t.trigger("change",t)},state:function(e,t){this.set("state",e),this.set("state_info",t),this.trigger("set:state"),console.debug("Chart:state() - "+t+" ("+e+")")}})}),define("plugin/library/storage",["utils/utils","plugin/models/chart","plugin/models/group"],function(e,t,n){return Backbone.Model.extend({vis:null,initialize:function(e){this.app=e,this.chart=this.app.chart,this.options=this.app.options,this.id=this.options.id,this.vis=new Visualization({type:"charts",config:{dataset_id:this.options.config.dataset_id,chart_dict:{}}}),this.id&&(this.vis.id=this.id);var t=this.options.config.chart_dict;t&&(this.vis.get("config").chart_dict=t)},save:function(){var e=this.app.chart;this.vis.get("config").chart_dict={};var t=e.get("title");t!=""&&this.vis.set("title",t);var n={attributes:e.attributes,settings:e.settings.attributes,groups:[]};e.groups.each(function(e){n.groups.push(e.attributes)}),this.vis.get("config").chart_dict=n;var r=this;this.vis.save().fail(function(e,t,n){console.error(e,t,n)}).then(function(e){e&&e.id&&(r.id=e.id)})},load:function(){var e=this.vis.get("config").chart_dict;if(!e.attributes)return!1;this.chart.set(e.attributes),this.chart.state("ok","Loading saved visualization..."),this.chart.settings.set(e.settings);for(var t in e.groups)this.chart.groups.add(new n(e.groups[t]));return this.chart.set("modified",!1),!0}})}),define("plugin/views/viewport",["mvc/ui/ui-portlet","plugin/library/ui","utils/utils"],function(e,t,n){return Backbone.View.extend({initialize:function(e,t){this.app=e,this.chart=this.app.chart,this.options=n.merge(t,this.optionsDefault),this.setElement($(this._template())),this._create_svg();var r=this;this.chart.on("redraw",function(){r._draw(r.chart)}),this.chart.on("set:state",function(){var e=r.$el.find("#info"),t=e.find("#icon");t.removeClass(),e.show(),e.find("#text").html(r.chart.get("state_info"));var n=r.chart.get("state");switch(n){case"ok":e.hide();break;case"failed":t.addClass("fa fa-warning");break;default:t.addClass("fa fa-spinner fa-spin")}})},show:function(){this.$el.show()},hide:function(){this.$el.hide()},_create_svg:function(){this.svg&&this.svg.remove(),this.$el.append($(this._template_svg())),this.svg_el=this.$el.find("svg"),this.svg=d3.select(this.svg_el[0])},_draw:function(e){var t=this;this._create_svg(),e.state("wait","Please wait...");var n=e.deferred.register(),r=e.get("type"),i=this.app.types.get(r);if(!i.execute||i.execute&&e.get("modified"))this.app.jobs.cleanup(e),e.set("modified",!1);var t=this;require(["plugin/charts/"+r+"/"+r],function(r){var s=new r(t.app,{svg:t.svg});i.execute?e.get("dataset_id_job")==""?t.app.jobs.submit(e,t._defaultSettingsString(e),t._defaultRequestString(e),function(){s.draw(n,e,t._defaultRequestDictionary(e))},function(){e.deferred.done(n)}):s.draw(n,e,t._defaultRequestDictionary(e)):s.draw(n,e,t._defaultRequestDictionary(e))})},_defaultRequestString:function(e){var t=this.app.types.get(e.get("type")),n="",r=0;return e.groups.each(function(e){for(var i in t.columns)n+=i+"_"+ ++r+":"+(parseInt(e.get(i))+1)+", "}),n.substring(0,n.length-2)},_defaultSettingsString:function(e){var t="";for(key in e.settings.attributes)t+=key+":"+e.settings.get(key)+", ";return t.substring(0,t.length-2)},_defaultRequestDictionary:function(e){var t=this.app.types.get(e.get("type")),n={groups:[]};t.execute?n.id=e.get("dataset_id_job"):n.id=e.get("dataset_id");var r=0;return e.groups.each(function(e){var i={};for(var s in t.columns)i[s]=e.get(s);n.groups.push({key:++r+":"+e.get("key"),columns:i})}),n},_template:function(){return'<div style="height: 100%; min-height: 50px;"><div id="info" style="position: absolute; margin-left: 10px; margin-top: 10px; margin-bottom: 50px;"><span id="icon" style="font-size: 1.2em; display: inline-block;"/><span id="text" style="position: relative; margin-left: 5px; top: -1px; font-size: 1.0em;"/></div></div>'},_template_svg:function(){return'<svg style="height: calc(100% - 80px)"/>'}})}),define("plugin/views/viewer",["utils/utils","plugin/library/ui","mvc/ui/ui-portlet","plugin/models/group","plugin/views/viewport"],function(e,t,n,r,i){return Backbone.View.extend({initialize:function(e,r){this.app=e,this.chart=this.app.chart,this.viewport_view=new i(e);var s=this;this.portlet=new n.View({icon:"fa-bar-chart-o",title:"Viewport",operations:{edit_button:new t.ButtonIcon({icon:"fa-edit",tooltip:"Customize this chart",title:"Customize",onclick:function(){s._wait(s.chart,function(){s.app.go("editor")})}})}}),this.portlet.append(this.viewport_view.$el),this.setElement(this.portlet.$el);var s=this;this.chart.on("change:title",function(){s._refreshTitle()})},show:function(){this.$el.show(),$(window).trigger("resize")},hide:function(){this.$el.hide()},_refreshTitle:function(){var e=this.chart.get("title");this.portlet.title(e)},_screenshot:function(){var e=new XMLSerializer,t=e.serializeToString(this.viewport_view.svg.node()),n="data:image/svg+xml;base64,"+btoa(t);window.location.href="data:application/x-download/;charset=utf-8,"+encodeURIComponent(t)},_wait:function(e,t){if(e.deferred.ready())t();else{var n=this;this.app.modal.show({title:"Please wait!",body:"Your chart is currently being processed. Please wait and try again.",buttons:{Close:function(){n.app.modal.hide()},Retry:function(){n.app.modal.hide(),setTimeout(function(){n._wait(e,t)},n.app.config.get("query_timeout"))}}})}}})}),define("mvc/ui/ui-tabs",["utils/utils"],function(e){var t=Backbone.View.extend({visible:!1,list:{},$nav:null,$content:null,first_tab:null,optionsDefault:{title_new:"",operations:null,onnew:null},initialize:function(t){this.options=e.merge(t,this.optionsDefault);var n=$(this._template(this.options));this.$nav=n.find(".tab-navigation"),this.$content=n.find(".tab-content"),this.setElement(n),this.list={};var r=this;this.options.operations&&$.each(this.options.operations,function(e,t){t.$el.prop("id",e),r.$nav.find(".operations").append(t.$el)});if(this.options.onnew){var i=$(this._template_tab_new(this.options));this.$nav.append(i),i.tooltip({title:"Add a new tab",placement:"bottom",container:r.$el}),i.on("click",function(e){i.tooltip("hide"),r.options.onnew()})}},add:function(e){var t=e.id,n={$title:$(this._template_tab(e)),$content:$(this._template_tab_content(e)),removable:e.ondel?!0:!1};this.list[t]=n,this.options.onnew?this.$nav.find("#new-tab").before(n.$title):this.$nav.append(n.$title),n.$content.append(e.$el),this.$content.append(n.$content),_.size(this.list)==1&&(n.$title.addClass("active"),n.$content.addClass("active"),this.first_tab=t);if(e.ondel){var r=this,i=n.$title.find("#delete");i.tooltip({title:"Delete this tab",placement:"bottom",container:r.$el}),i.on("click",function(){return i.tooltip("destroy"),r.$el.find(".tooltip").remove(),e.ondel(),!1})}e.onclick&&n.$title.on("click",function(){e.onclick()})},del:function(e){var t=this.list[e];t.$title.remove(),t.$content.remove(),delete t,this.first_tab==e&&(this.first_tab=null),this.first_tab!=null&&this.show(this.first_tab)},delRemovable:function(){for(var e in this.list){var t=this.list[e];t.removable&&this.del(e)}},show:function(e){this.$el.fadeIn("fast"),this.visible=!0,e&&this.list[e].$title.find("a").tab("show")},hide:function(){this.$el.fadeOut("fast"),this.visible=!1},hideOperation:function(e){this.$nav.find("#"+e).hide()},showOperation:function(e){this.$nav.find("#"+e).show()},setOperation:function(e,t){var n=this.$nav.find("#"+e);n.off("click"),n.on("click",t)},title:function(e,t){var n=this.list[e].$title.find("#text");return t&&n.html(t),n.html()},_template:function(e){return'<div class="tabbable tabs-left"><ul class="tab-navigation nav nav-tabs"><div class="operations" style="float: right; margin-bottom: 4px;"></div></ul><div class="tab-content"/></div>'},_template_tab_new:function(e){return'<li id="new-tab"><a href="javascript:void(0);"><i style="font-size: 0.8em; margin-right: 5px;" class="fa fa-plus-circle"/>'+e.title_new+"</a>"+"</li>"},_template_tab:function(e){var t='<li id="title-'+e.id+'">'+'<a title="" href="#tab-'+e.id+'" data-toggle="tab" data-original-title="">'+'<span id="text">'+e.title+"</span>";return e.ondel&&(t+='<i id="delete" style="font-size: 0.8em; margin-left: 5px; cursor: pointer;" class="fa fa-minus-circle"/>'),t+="</a></li>",t},_template_tab_content:function(e){return'<div id="tab-'+e.id+'" class="tab-pane"/>'}});return{View:t}}),define("plugin/library/ui-table",["utils/utils"],function(e){var t=Backbone.View.extend({row:null,row_count:0,optionsDefault:{content:"No content available.",onchange:null,ondblclick:null,onconfirm:null},events:{click:"_onclick",dblclick:"_ondblclick"},first:!0,initialize:function(t){this.options=e.merge(t,this.optionsDefault);var n=$(this._template(t));this.$thead=n.find("thead"),this.$tbody=n.find("tbody"),this.$tmessage=n.find("tmessage"),this.setElement(n),this.row=$("<tr></tr>")},addHeader:function(e){var t=$("<th></th>");t.append(e),this.row.append(t)},appendHeader:function(){this.$thead.append(this.row),this.row=$("<tr></tr>")},add:function(e,t){var n=$("<td></td>");t&&n.css("width",t),n.append(e),this.row.append(n)},append:function(e){this._commit(e)},prepend:function(e){this._commit(e,!0)},remove:function(e){var t=this.$tbody.find("#"+e);t.length>0&&(t.remove(),this.row_count--,this._refresh())},removeAll:function(){this.$tbody.html(""),this.row_count=0,this._refresh()},value:function(e){this.before=this.$tbody.find(".current").attr("id"),e!==undefined&&(this.$tbody.find("tr").removeClass("current"),e&&this.$tbody.find("#"+e).addClass("current"));var t=this.$tbody.find(".current").attr("id");return t===undefined?null:(t!=this.before&&this.options.onchange&&this.options.onchange(e),t)},size:function(){return this.$tbody.find("tr").length},_commit:function(e,t){this.remove(e),this.row.attr("id",e),t?this.$tbody.prepend(this.row):this.$tbody.append(this.row),this.row=$("<tr></tr>"),this.row_count++,this._refresh()},_onclick:function(e){var t=this.value(),n=$(e.target).closest("tr").attr("id");n&&t!=n&&(this.options.onconfirm?this.options.onconfirm(n):this.value(n))},_ondblclick:function(e){var t=this.value();t&&this.options.ondblclick&&this.options.ondblclick(t)},_refresh:function(){this.row_count==0?this.$tmessage.show():this.$tmessage.hide()},_template:function(e){return'<div><table class="grid"><thead></thead><tbody style="cursor: pointer;"></tbody></table><tmessage>'+e.content+"</tmessage>"+"<div>"}});return{View:t}}),define("plugin/views/group",["plugin/library/ui-table","plugin/library/ui","utils/utils"],function(e,t,n){return Backbone.View.extend({columns:[],initialize:function(r,i){this.app=r;var s=this;this.chart=this.app.chart,this.group=i.group,this.group_key=new t.Input({placeholder:"Data label",onchange:function(){s.group.set("key",s.group_key.value())}}),this.table=new e.View({content:"No data column."});var o=$("<div/>");o.append(n.wrap((new t.Label({title:"Provide a label:"})).$el)),o.append(n.wrap(this.group_key.$el)),o.append(n.wrap((new t.Label({title:"Select columns:"})).$el)),o.append(n.wrap(this.table.$el)),this.setElement(o);var s=this;this.chart.on("change:dataset_id",function(){s._refreshTable()}),this.chart.on("change:type",function(){s._refreshTable()}),this.group.on("change:key",function(){s._refreshGroupKey()}),this.group.on("change",function(){s._refreshGroup()}),this._refreshTable(),this._refreshGroupKey(),this._refreshGroup()},_refreshTable:function(){var e=this.chart.get("dataset_id"),n=this.chart.get("type");if(!e||!n)return;var r=this,i=this.app.types.get(n);this.table.removeAll();var s={};for(var o in i.columns){var u=this.group.get(o);u||this.group.set(o,0);var a=i.columns[o],f=new t.Select.View({id:"select_"+o,gid:o,onchange:function(e){r.group.set(this.gid,e),r.chart.set("modified",!0)},value:u,wait:!0});this.table.add(a.title,"25%"),this.table.add(f.$el),this.table.append(o),s[o]=f}this.chart.state("wait","Loading metadata...");var l=this.chart.deferred.register();this.app.datasets.request({id:e},function(e){r.columns=[];var t=e.metadata_column_types;for(var n in t)(t[n]=="int"||t[n]=="float")&&r.columns.push({label:"Column: "+(parseInt(n)+1)+" ["+t[n]+"]",value:n});for(var n in s)s[n].update(r.columns),s[n].show();r.chart.state("wait","Metadata initialized..."),r.chart.deferred.done(l)})},_refreshGroup:function(){this.group.set("date",n.time())},_refreshGroupKey:function(){var e=this.group.get("key");e===undefined&&(e=""),this.group_key.value(e)}})}),define("plugin/library/ui-table-form",["plugin/library/ui-table","plugin/library/ui","utils/utils"],function(e,t,n){var r=Backbone.View.extend({list:[],initialize:function(r){this.table_title=new t.Label({title:r.title}),this.table=new e.View({content:r.content});var i=$("<div/>");i.append(n.wrap(this.table_title.$el)),i.append(n.wrap(this.table.$el)),this.setElement(i)},title:function(e){this.table_title.title(e)},update:function(e,t){this.table.removeAll(),this.list=[];for(var n in e)this._add(n,e[n],t);for(var n in this.list){var r=this.list[n].options.onchange;r&&r()}},_add:function(e,n,r){var i=this,s=null,o=n.type;switch(o){case"text":s=new t.Input({id:e,placeholder:n.placeholder,onchange:function(){r.set(e,s.value())}});break;case"select":s=new t.Select.View({id:e,data:n.data,onchange:function(){var t=s.value();r.set(e,t);var o=_.findWhere(n.data,{value:t});o&&(o.show&&i.$el.find("#"+o.show).fadeIn("fast"),o.hide&&i.$el.find("#"+o.hide).fadeOut("fast"))}});break;case"separator":s=$("<div/>");break;default:console.log("ui-table-form:_add","Unknown setting type ("+n.type+")");return}if(o!="separator"){r.get(e)||r.set(e,n.init),s.value(r.get(e)),this.list[e]=s;var u=$("<div/>");u.append(s.$el),u.append('<div class="toolParamHelp" style="font-size: 0.9em;">'+n.info+"</div>"),this.table.add('<span style="white-space: nowrap;">'+n.title+"</span>","25%"),this.table.add(u)}else this.table.add('<h6 style="white-space: nowrap;">'+n.title+":<h6/>"),this.table.add($("<div/>"));this.table.append(e)}});return{View:r}}),define("plugin/views/settings",["plugin/library/ui","plugin/library/ui-table-form","utils/utils"],function(e,t,n){return Backbone.View.extend({initialize:function(e,n){this.app=e;var r=this;this.chart=this.app.chart,this.form=new t.View({title:"Chart options:",content:"This chart type does not provide any options."}),this.setElement(this.form.$el);var r=this;this.chart.on("change",function(){r._refreshTable()})},_refreshTable:function(){var e=this.chart.get("type");if(!e)return;var t=this.app.types.get(e);this.form.title(t.title+":"),this.form.update(t.settings,this.chart.settings)}})}),define("plugin/views/editor",["mvc/ui/ui-tabs","plugin/library/ui-table","plugin/library/ui","mvc/ui/ui-portlet","utils/utils","plugin/models/chart","plugin/models/group","plugin/views/group","plugin/views/settings"],function(e,t,n,r,i,s,o,u,a){return Backbone.View.extend({optionsDefault:{header:!0,content:"No content available."},initialize:function(s,o){var u=this;this.app=s,this.chart=this.app.chart,this.options=i.merge(o,this.optionsDefault),this.portlet=new r.View({icon:"fa-bar-chart-o",title:"Editor",operations:{save:new n.ButtonIcon({icon:"fa-save",tooltip:"Draw Chart",title:"Draw",onclick:function(){u.app.go("viewer"),u._saveChart()}}),back:new n.ButtonIcon({icon:"fa-caret-left",tooltip:"Return to Viewer",title:"Return",onclick:function(){u.app.go("viewer"),u.app.storage.load()}})}}),this.table=new t.View({header:!1,onconfirm:function(e){u.chart.groups.length>0?u.app.modal.show({title:"Switching to another chart type?",body:"If you continue your settings and selections will be cleared.",buttons:{Cancel:function(){u.app.modal.hide()},Continue:function(){u.app.modal.hide(),u.table.value(e)}}}):u.table.value(e)},onchange:function(e){u.chart.groups.reset(),u.chart.settings.clear(),u.chart.set({type:e})},ondblclick:function(e){u.tabs.show("settings")},content:"No chart types available"});var f=0,l=s.types.attributes;for(var c in l){var h=l[c];this.table.add(++f+"."),h.execute?this.table.add(h.title+" (requires processing)"):this.table.add(h.title),this.table.append(c)}this.tabs=new e.View({title_new:"Add Data",onnew:function(){var e=u._addGroupModel();u.tabs.show(e.id)}}),this.title=new n.Input({placeholder:"Chart title",onchange:function(){u.chart.set("title",u.title.value())}});var p=$("<div/>");p.append(i.wrap((new n.Label({title:"Provide a chart title:"})).$el)),p.append(i.wrap(this.title.$el)),p.append(i.wrap((new n.Label({title:"Select a chart type:"})).$el)),p.append(i.wrap(this.table.$el)),this.tabs.add({id:"main",title:"Start",$el:p}),this.settings=new a(this.app),this.tabs.add({id:"settings",title:"Configuration",$el:this.settings.$el}),this.portlet.append(this.tabs.$el),this.setElement(this.portlet.$el),this.tabs.hideOperation("back");var u=this;this.chart.on("change:title",function(e){u._refreshTitle()}),this.chart.on("change:type",function(e){u.table.value(e.get("type"))}),this.chart.on("reset",function(e){u._resetChart()}),this.app.chart.on("redraw",function(e){u.portlet.showOperation("back")}),this.app.chart.groups.on("add",function(e){u._addGroup(e)}),this.app.chart.groups.on("remove",function(e){u._removeGroup(e)}),this.app.chart.groups.on("reset",function(e){u._removeAllGroups()}),this.app.chart.groups.on("change:key",function(e){u._refreshGroupKey()}),this._resetChart()},show:function(){this.$el.show()},hide:function(){this.$el.hide()},_refreshTitle:function(){var e=this.chart.get("title");this.portlet.title(e),this.title.value(e)},_refreshGroupKey:function(){var e=this,t=0;this.chart.groups.each(function(n){var r=n.get("key","");r==""&&(r="Chart data"),e.tabs.title(n.id,++t+": "+r)})},_addGroupModel:function(){var e=new o({id:i.uuid()});return this.chart.groups.add(e),e},_addGroup:function(e){var t=this,n=new u(this.app,{group:e}),r=t.chart.groups.length;this.tabs.add({id:e.id,$el:n.$el,ondel:function(){t.chart.groups.remove(e.id)}}),this._refreshGroupKey()},_removeGroup:function(e){this.tabs.del(e.id),this._refreshGroupKey(),this.chart.set("modified",!0)},_removeAllGroups:function(e){this.tabs.delRemovable()},_resetChart:function(){this.chart.set("id",i.uuid()),this.chart.set("type","bardiagram"),this.chart.set("dataset_id",this.app.options.config.dataset_id),this.chart.set("title","New Chart"),this.portlet.hideOperation("back")},_saveChart:function(){this.chart.set({type:this.table.value(),title:this.title.value(),date:i.time()}),this.chart.groups.length==0&&this._addGroupModel();var e=this;this.chart.deferred.execute(function(){e.app.storage.save(),e.chart.trigger("redraw")})}})}),define("plugin/models/config",[],function(){return Backbone.Model.extend({defaults:{query_limit:1e3,query_timeout:500}})}),define("plugin/charts/_nvd3/config",[],function(){return{title:"",columns:{y:{title:"Values for y-axis"}},settings:{separator_label:{title:"X axis",type:"separator"},x_axis_label:{title:"Axis label",info:"Provide a label for the axis.",type:"text",init:"X-axis",placeholder:"Axis label"},x_axis_type:{title:"Axis value type",info:"Select the value type of the axis.",type:"select",init:"auto",data:[{label:"-- Do not show values --",value:"hide",hide:"x_axis_tick"},{label:"Auto",value:"auto",hide:"x_axis_tick"},{label:"Float",value:"f",show:"x_axis_tick"},{label:"Exponent",value:"e",show:"x_axis_tick"},{label:"Integer",value:"d",hide:"x_axis_tick"},{label:"Percentage",value:"p",show:"x_axis_tick"},{label:"Rounded",value:"r",show:"x_axis_tick"},{label:"SI-prefix",value:"s",show:"x_axis_tick"}]},x_axis_tick:{title:"Axis tick format",info:"Select the tick format for the axis.",type:"select",init:".1",data:[{label:"0.00001",value:".5"},{label:"0.0001",value:".4"},{label:"0.001",value:".3"},{label:"0.01",value:".2"},{label:"0.1",value:".1"},{label:"1",value:"1"}]},separator_tick:{title:"Y axis",type:"separator"},y_axis_label:{title:"Axis label",info:"Provide a label for the axis.",type:"text",init:"Y-axis",placeholder:"Axis label"},y_axis_type:{title:"Axis value type",info:"Select the value type of the axis.",type:"select",init:"auto",data:[{label:"-- Do not show values --",value:"hide",hide:"y_axis_tick"},{label:"Auto",value:"auto",hide:"y_axis_tick"},{label:"Float",value:"f",show:"y_axis_tick"},{label:"Exponent",value:"e",show:"y_axis_tick"},{label:"Integer",value:"d",hide:"y_axis_tick"},{label:"Percentage",value:"p",show:"y_axis_tick"},{label:"Rounded",value:"r",show:"y_axis_tick"},{label:"SI-prefix",value:"s",show:"y_axis_tick"}]},y_axis_tick:{title:"Axis tick format",info:"Select the tick format for the axis.",type:"select",init:".1",data:[{label:"0.00001",value:".5"},{label:"0.0001",value:".4"},{label:"0.001",value:".3"},{label:"0.01",value:".2"},{label:"0.1",value:".1"},{label:"1",value:"1"}]},separator_legend:{title:"Others",type:"separator"},show_legend:{title:"Show legend",info:"Would you like to add a legend?",type:"select",init:"true",data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]}}}}),define("plugin/charts/bardiagram/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Bar diagram"})}),define("plugin/charts/histogram/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Histogram",execute:!0,columns:{y:{title:"Observations"}},settings:{x_axis_label:{init:"Breaks"},y_axis_label:{init:"Density"}}})}),define("plugin/charts/horizontal/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Bar diagram (horizontal)",settings:{x_axis_type:{init:"hide"}}})}),define("plugin/charts/line/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Line chart"})}),define("plugin/charts/linewithfocus/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Line with focus"})}),define("plugin/charts/piechart/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Pie chart"})}),define("plugin/charts/scatterplot/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Scatter plot",columns:{x:{title:"Values for x-axis"}}})}),define("plugin/charts/stackedarea/config",["plugin/charts/_nvd3/config"],function(e){return $.extend(!0,{},e,{title:"Stacked area"})}),define("plugin/charts/types",["plugin/charts/bardiagram/config","plugin/charts/histogram/config","plugin/charts/horizontal/config","plugin/charts/line/config","plugin/charts/linewithfocus/config","plugin/charts/piechart/config","plugin/charts/scatterplot/config","plugin/charts/stackedarea/config"],function(e,t,n,r,i,s,o,u){return Backbone.Model.extend({defaults:{bardiagram:e,horizontal:n,histogram:t,line:r,linewithfocus:i,piechart:s,scatterplot:o,stackedarea:u}})}),define("plugin/app",["mvc/ui/ui-modal","mvc/ui/ui-portlet","plugin/library/ui","utils/utils","plugin/library/jobs","plugin/library/datasets","plugin/library/storage","plugin/views/viewer","plugin/views/editor","plugin/models/config","plugin/models/chart","plugin/charts/types"],function(e,t,n,r,i,s,o,u,a,f,l,c){return Backbone.View.extend({initialize:function(t){this.options=t,Galaxy&&Galaxy.modal?this.modal=Galaxy.modal:this.modal=new e.View,this.config=new f,this.types=new c,this.chart=new l,this.jobs=new i(this),this.datasets=new s(this),this.storage=new o(this),this.viewer_view=new u(this),this.editor_view=new a(this),this.$el.append(this.viewer_view.$el),this.$el.append(this.editor_view.$el);if(!this.storage.load())this.go("editor");else{this.go("viewer");var n=this;this.chart.deferred.execute(function(){n.chart.trigger("redraw")})}},go:function(e){$(".tooltip").hide();switch(e){case"editor":this.editor_view.show(),this.viewer_view.hide();break;case"viewer":this.editor_view.hide(),this.viewer_view.show()}},execute:function(e){},onunload:function(){},log:function(e,t){console.log(e+" "+t)}})}); \ No newline at end of file diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 config/plugins/visualizations/charts/static/library/jobs.js --- a/config/plugins/visualizations/charts/static/library/jobs.js +++ b/config/plugins/visualizations/charts/static/library/jobs.js @@ -133,7 +133,7 @@ // request job details _loop: function(id, callback) { var self = this; - Utils.request('GET', config.root + 'api/jobs/' + id, {}, function(job) { + Utils.request('GET', config.root + 'api/datasets/' + id, {}, function(job) { if (!callback(job)) { setTimeout(function() { self._loop(id, callback); }, self.app.config.get('query_timeout')); } diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 lib/galaxy/webapps/galaxy/api/history_contents.py --- a/lib/galaxy/webapps/galaxy/api/history_contents.py +++ b/lib/galaxy/webapps/galaxy/api/history_contents.py @@ -254,7 +254,13 @@ hda = history.add_dataset( data_copy ) trans.sa_session.flush() - return hda.to_dict() if hda else None + if not hda: + return None + #TODO: duplicate code - use a serializer with a view + hda_dict = self.get_hda_dict( trans, hda ) + hda_dict[ 'display_types' ] = self.get_old_display_applications( trans, hda ) + hda_dict[ 'display_apps' ] = self.get_display_apps( trans, hda ) + return hda_dict @expose_api_anonymous def update( self, trans, history_id, id, payload, **kwd ): diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 static/scripts/packed/viz/visualization.js --- a/static/scripts/packed/viz/visualization.js +++ b/static/scripts/packed/viz/visualization.js @@ -1,1 +1,1 @@ -define(["libs/underscore","mvc/data","viz/trackster/util","utils/config"],function(t,k,m,p){var f={toJSON:function(){var v=this,w={};t.each(v.constructor.to_json_keys,function(x){var y=v.get(x);if(x in v.constructor.to_json_mappers){y=v.constructor.to_json_mappers[x](y,v)}w[x]=y});return w}};var a=function(v,y,x,w){$.ajax({url:v,data:x,error:function(){alert("Grid failed")},success:function(z){Galaxy.modal.show({title:"Select datasets for new tracks",body:z,buttons:{Cancel:function(){Galaxy.modal.hide()},Add:function(){var A=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var B={data_type:"track_config",hda_ldda:"hda"},C=$(this).val();if($(this).attr("name")!=="id"){B.hda_ldda="ldda"}A[A.length]=$.ajax({url:y+"/"+C,data:B,dataType:"json"})});$.when.apply($,A).then(function(){var B=(arguments[0] instanceof Array?$.map(arguments,function(C){return C[0]}):[arguments[0]]);w(B)});Galaxy.modal.hide()}}})}})};var g=function(v){this.default_font=v!==undefined?v:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};t.extend(g.prototype,{load_pattern:function(v,z){var w=this.patterns,x=this.dummy_context,y=new Image();y.src=galaxy_config.root+"static/images"+z;y.onload=function(){w[v]=x.createPattern(y,"repeat")}},get_pattern:function(v){return this.patterns[v]},new_canvas:function(){var v=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(v)}v.manager=this;return v}});var r=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(v){this.clear()},get_elt:function(x){var y=this.attributes.obj_cache,z=this.attributes.key_ary,w=x.toString(),v=t.indexOf(z,function(A){return A.toString()===w});if(v!==-1){if(y[w].stale){z.splice(v,1);delete y[w]}else{this.move_key_to_end(x,v)}}return y[w]},set_elt:function(x,z){var A=this.attributes.obj_cache,B=this.attributes.key_ary,w=x.toString(),y=this.attributes.num_elements;if(!A[w]){if(B.length>=y){var v=B.shift();delete A[v.toString()]}B.push(x)}A[w]=z;return z},move_key_to_end:function(w,v){this.attributes.key_ary.splice(v,1);this.attributes.key_ary.push(w)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length},most_recently_added:function(){return this.size()===0?null:this.attributes.key_ary[this.attributes.key_ary.length-1]}});var d=r.extend({defaults:t.extend({},r.prototype.defaults,{dataset:null,genome:null,init_data:null,min_region_size:200,filters_manager:null,data_type:"data",data_mode_compatible:function(v,w){return true},can_subset:function(v){return false}}),initialize:function(v){r.prototype.initialize.call(this);var w=this.get("init_data");if(w){this.add_data(w)}},add_data:function(v){if(this.get("num_elements")<v.length){this.set("num_elements",v.length)}var w=this;t.each(v,function(x){w.set_data(x.region,x)})},data_is_ready:function(){var y=this.get("dataset"),x=$.Deferred(),v=(this.get("data_type")==="raw_data"?"state":this.get("data_type")==="data"?"converted_datasets_state":"error"),w=new m.ServerStateDeferred({ajax_settings:{url:this.get("dataset").url(),data:{hda_ldda:y.get("hda_ldda"),data_type:v},dataType:"json"},interval:5000,success_fn:function(z){return z!=="pending"}});$.when(w.go()).then(function(z){x.resolve(z==="ok"||z==="data")});return x},search_features:function(v){var w=this.get("dataset"),x={query:v,hda_ldda:w.get("hda_ldda"),data_type:"features"};return $.getJSON(w.url(),x)},load_data:function(D,C,w,B){var z=this.get("dataset"),y={data_type:this.get("data_type"),chrom:D.get("chrom"),low:D.get("start"),high:D.get("end"),mode:C,resolution:w,hda_ldda:z.get("hda_ldda")};$.extend(y,B);var F=this.get("filters_manager");if(F){var G=[];var v=F.filters;for(var A=0;A<v.length;A++){G.push(v[A].name)}y.filter_cols=JSON.stringify(G)}var x=this,E=$.getJSON(z.url(),y,function(H){H.region=D;x.set_data(D,H)});this.set_data(D,E);return E},get_data:function(C,B,x,z){var D=this.get_elt(C);if(D&&(m.is_deferred(D)||this.get("data_mode_compatible")(D,B))){return D}var E=this.get("key_ary"),v=this.get("obj_cache"),w,A;for(var y=0;y<E.length;y++){w=E[y];if(w.contains(C)){A=true;D=v[w.toString()];if(m.is_deferred(D)||(this.get("data_mode_compatible")(D,B)&&this.get("can_subset")(D))){this.move_key_to_end(w,y);if(!m.is_deferred(D)){var G=this.subset_entry(D,C);this.set_data(C,G);D=G}return D}}}if(!A&&C.length()<this.attributes.min_region_size){C=C.copy();var F=this.most_recently_added();if(!F||(C.get("start")>F.get("start"))){C.set("end",C.get("start")+this.attributes.min_region_size)}else{C.set("start",C.get("end")-this.attributes.min_region_size)}C.set("genome",this.attributes.genome);C.trim()}return this.load_data(C,B,x,z)},set_data:function(w,v){this.set_elt(w,v)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(D,C,y,B,z){var F=this._mark_stale(D);if(!(F&&this.get("data_mode_compatible")(F,C))){console.log("ERROR: problem with getting more data: current data is not compatible");return}var x=D.get("start");if(z===this.DEEP_DATA_REQ){$.extend(B,{start_val:F.data.length+1})}else{if(z===this.BROAD_DATA_REQ){x=(F.max_high?F.max_high:F.data[F.data.length-1][2])+1}}var E=D.copy().set("start",x);var w=this,A=this.load_data(E,C,y,B),v=$.Deferred();this.set_data(D,v);$.when(A).then(function(G){if(G.data){G.data=F.data.concat(G.data);if(G.max_low){G.max_low=F.max_low}if(G.message){G.message=G.message.replace(/[0-9]+/,G.data.length)}}w.set_data(D,G);v.resolve(G)});return v},can_get_more_detailed_data:function(w){var v=this.get_elt(w);return(v.dataset_type==="bigwig"&&v.data.length<8000)},get_more_detailed_data:function(y,A,w,z,x){var v=this._mark_stale(y);if(!v){console.log("ERROR getting more detailed data: no current data");return}if(!x){x={}}if(v.dataset_type==="bigwig"){x.num_samples=1000*z}return this.load_data(y,A,w,x)},_mark_stale:function(w){var v=this.get_elt(w);if(!v){console.log("ERROR: no data to mark as stale: ",this.get("dataset"),w.toString())}v.stale=true;return v},get_genome_wide_data:function(v){var x=this,z=true,y=t.map(v.get("chroms_info").chrom_info,function(B){var A=x.get_elt(new h({chrom:B.chrom,start:0,end:B.len}));if(!A){z=false}return A});if(z){return y}var w=$.Deferred();$.getJSON(this.get("dataset").url(),{data_type:"genome_data"},function(A){x.add_data(A.data);w.resolve(A.data)});return w},subset_entry:function(x,y){var v={bigwig:function(z,A){return t.filter(z,function(B){return B[0]>=A.get("start")&&B[0]<=A.get("end")})},refseq:function(A,B){var C=B.get("start")-x.region.get("start"),z=x.data.length-(x.region.get("end")-B.get("end"));return x.data.slice(C,z)}};var w=x.data;if(!x.region.same(y)&&x.dataset_type in v){w=v[x.dataset_type](x.data,y)}return{region:y,data:w,dataset_type:x.dataset_type}}});var q=d.extend({initialize:function(v){var w=new Backbone.Model();w.urlRoot=v.data_url;this.set("dataset",w)},load_data:function(x,y,v,w){return(x.length()<=100000?d.prototype.load_data.call(this,x,y,v,w):{data:null,region:x})}});var c=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},initialize:function(v){this.id=v.dbkey},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info},get_chrom_region:function(v){var w=t.find(this.get_chroms_info(),function(x){return x.chrom===v});return new h({chrom:w.chrom,end:w.len})},get_chrom_len:function(v){return t.find(this.get_chroms_info(),function(w){return w.chrom===v}).len}});var h=Backbone.Model.extend({defaults:{chrom:null,start:0,end:0,str_val:null,genome:null},same:function(v){return this.attributes.chrom===v.get("chrom")&&this.attributes.start===v.get("start")&&this.attributes.end===v.get("end")},initialize:function(w){if(w.from_str){var y=w.from_str.split(":"),x=y[0],v=y[1].split("-");this.set({chrom:x,start:parseInt(v[0],10),end:parseInt(v[1],10)})}this.attributes.str_val=this.get("chrom")+":"+this.get("start")+"-"+this.get("end");this.on("change",function(){this.attributes.str_val=this.get("chrom")+":"+this.get("start")+"-"+this.get("end")},this)},copy:function(){return new h({chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")})},length:function(){return this.get("end")-this.get("start")},toString:function(){return this.attributes.str_val},toJSON:function(){return{chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")}},compute_overlap:function(C){var w=this.get("chrom"),B=C.get("chrom"),A=this.get("start"),y=C.get("start"),z=this.get("end"),x=C.get("end"),v;if(w&&B&&w!==B){return h.overlap_results.DIF_CHROMS}if(A<y){if(z<y){v=h.overlap_results.BEFORE}else{if(z<x){v=h.overlap_results.OVERLAP_START}else{v=h.overlap_results.CONTAINS}}}else{if(A>y){if(A>x){v=h.overlap_results.AFTER}else{if(z<=x){v=h.overlap_results.CONTAINED_BY}else{v=h.overlap_results.OVERLAP_END}}}else{v=(z>=x?h.overlap_results.CONTAINS:h.overlap_results.CONTAINED_BY)}}return v},trim:function(v){if(this.attributes.start<0){this.attributes.start=0}if(this.attributes.genome){var w=this.attributes.genome.get_chrom_len(this.attributes.chrom);if(this.attributes.end>w){this.attributes.end=w-1}}return this},contains:function(v){return this.compute_overlap(v)===h.overlap_results.CONTAINS},overlaps:function(v){return t.intersection([this.compute_overlap(v)],[h.overlap_results.DIF_CHROMS,h.overlap_results.BEFORE,h.overlap_results.AFTER]).length===0}},{overlap_results:{DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006}});var n=Backbone.Collection.extend({model:h});var e=Backbone.Model.extend({defaults:{region:null,note:""},initialize:function(v){this.set("region",new h(v.region))}});var s=Backbone.Collection.extend({model:e});var u=Backbone.Model.extend(f).extend({defaults:{mode:"Auto"},initialize:function(v){this.set("dataset",new k.Dataset(v.dataset));var x=[{key:"name",value:this.get("dataset").get("name")},{key:"color"}];this.set("config",p.ConfigSettingCollection.from_models_and_saved_values(x,v.prefs));var w=this.get("preloaded_data");if(w){w=w.data}else{w=[]}this.set("data_manager",new d({dataset:this.get("dataset"),init_data:w}))}},{to_json_keys:["track_type","dataset","prefs","mode","filters","tool_state"],to_json_mappers:{prefs:function(w,v){if(t.size(w)===0){w={name:v.get("config").get("name").get("value"),color:v.get("config").get("color").get("value")}}return w},dataset:function(v){return{id:v.id,hda_ldda:v.get("hda_ldda")}}}});var j=Backbone.Collection.extend({model:u});var o=Backbone.Model.extend({defaults:{title:"",type:""},url:galaxy_config.root+"visualization/save",save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var l=o.extend(f).extend({defaults:t.extend({},o.prototype.defaults,{dbkey:"",drawables:null,bookmarks:null,viewport:null}),initialize:function(v){this.set("drawables",new j(v.tracks));var w=[];this.set("config",p.ConfigSettingCollection.from_models_and_saved_values(w,v.prefs));this.unset("tracks");this.get("drawables").each(function(x){x.unset("preloaded_data")})},add_tracks:function(v){this.get("drawables").add(v)}},{to_json_keys:["view","viewport","bookmarks"],to_json_mappers:{view:function(w,v){return{obj_type:"View",prefs:{name:v.get("title"),content_visible:true},drawables:v.get("drawables")}}}});var b=Backbone.Model.extend({});var i=Backbone.Router.extend({initialize:function(w){this.view=w.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var v=this;v.view.on("navigate",function(x){v.navigate(x)})},change_location:function(v){this.view.go_to(v)}});return{BackboneTrack:u,BrowserBookmark:e,BrowserBookmarkCollection:s,Cache:r,CanvasManager:g,Genome:c,GenomeDataManager:d,GenomeRegion:h,GenomeRegionCollection:n,GenomeVisualization:l,GenomeReferenceDataManager:q,TrackBrowserRouter:i,TrackConfig:b,Visualization:o,select_datasets:a}}); \ No newline at end of file +define(["libs/underscore","mvc/data","viz/trackster/util","utils/config"],function(t,k,m,p){var f={toJSON:function(){var v=this,w={};t.each(v.constructor.to_json_keys,function(x){var y=v.get(x);if(x in v.constructor.to_json_mappers){y=v.constructor.to_json_mappers[x](y,v)}w[x]=y});return w}};var a=function(v,y,x,w){$.ajax({url:v,data:x,error:function(){alert("Grid failed")},success:function(z){Galaxy.modal.show({title:"Select datasets for new tracks",body:z,buttons:{Cancel:function(){Galaxy.modal.hide()},Add:function(){var A=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var B={data_type:"track_config",hda_ldda:"hda"},C=$(this).val();if($(this).attr("name")!=="id"){B.hda_ldda="ldda"}A[A.length]=$.ajax({url:y+"/"+C,data:B,dataType:"json"})});$.when.apply($,A).then(function(){var B=(arguments[0] instanceof Array?$.map(arguments,function(C){return C[0]}):[arguments[0]]);w(B)});Galaxy.modal.hide()}}})}})};var g=function(v){this.default_font=v!==undefined?v:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};t.extend(g.prototype,{load_pattern:function(v,z){var w=this.patterns,x=this.dummy_context,y=new Image();y.src=galaxy_config.root+"static/images"+z;y.onload=function(){w[v]=x.createPattern(y,"repeat")}},get_pattern:function(v){return this.patterns[v]},new_canvas:function(){var v=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(v)}v.manager=this;return v}});var r=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(v){this.clear()},get_elt:function(x){var y=this.attributes.obj_cache,z=this.attributes.key_ary,w=x.toString(),v=t.indexOf(z,function(A){return A.toString()===w});if(v!==-1){if(y[w].stale){z.splice(v,1);delete y[w]}else{this.move_key_to_end(x,v)}}return y[w]},set_elt:function(x,z){var A=this.attributes.obj_cache,B=this.attributes.key_ary,w=x.toString(),y=this.attributes.num_elements;if(!A[w]){if(B.length>=y){var v=B.shift();delete A[v.toString()]}B.push(x)}A[w]=z;return z},move_key_to_end:function(w,v){this.attributes.key_ary.splice(v,1);this.attributes.key_ary.push(w)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length},most_recently_added:function(){return this.size()===0?null:this.attributes.key_ary[this.attributes.key_ary.length-1]}});var d=r.extend({defaults:t.extend({},r.prototype.defaults,{dataset:null,genome:null,init_data:null,min_region_size:200,filters_manager:null,data_type:"data",data_mode_compatible:function(v,w){return true},can_subset:function(v){return false}}),initialize:function(v){r.prototype.initialize.call(this);var w=this.get("init_data");if(w){this.add_data(w)}},add_data:function(v){if(this.get("num_elements")<v.length){this.set("num_elements",v.length)}var w=this;t.each(v,function(x){w.set_data(x.region,x)})},data_is_ready:function(){var y=this.get("dataset"),x=$.Deferred(),v=(this.get("data_type")==="raw_data"?"state":this.get("data_type")==="data"?"converted_datasets_state":"error"),w=new m.ServerStateDeferred({ajax_settings:{url:this.get("dataset").url(),data:{hda_ldda:y.get("hda_ldda"),data_type:v},dataType:"json"},interval:5000,success_fn:function(z){return z!=="pending"}});$.when(w.go()).then(function(z){x.resolve(z==="ok"||z==="data")});return x},search_features:function(v){var w=this.get("dataset"),x={query:v,hda_ldda:w.get("hda_ldda"),data_type:"features"};return $.getJSON(w.url(),x)},load_data:function(D,C,w,B){var z=this.get("dataset"),y={data_type:this.get("data_type"),chrom:D.get("chrom"),low:D.get("start"),high:D.get("end"),mode:C,resolution:w,hda_ldda:z.get("hda_ldda")};$.extend(y,B);var F=this.get("filters_manager");if(F){var G=[];var v=F.filters;for(var A=0;A<v.length;A++){G.push(v[A].name)}y.filter_cols=JSON.stringify(G)}var x=this,E=$.getJSON(z.url(),y,function(H){H.region=D;x.set_data(D,H)});this.set_data(D,E);return E},get_data:function(C,B,x,z){var D=this.get_elt(C);if(D&&(m.is_deferred(D)||this.get("data_mode_compatible")(D,B))){return D}var E=this.get("key_ary"),v=this.get("obj_cache"),w,A;for(var y=0;y<E.length;y++){w=E[y];if(w.contains(C)){A=true;D=v[w.toString()];if(m.is_deferred(D)||(this.get("data_mode_compatible")(D,B)&&this.get("can_subset")(D))){this.move_key_to_end(w,y);if(!m.is_deferred(D)){var G=this.subset_entry(D,C);this.set_data(C,G);D=G}return D}}}if(!A&&C.length()<this.attributes.min_region_size){C=C.copy();var F=this.most_recently_added();if(!F||(C.get("start")>F.get("start"))){C.set("end",C.get("start")+this.attributes.min_region_size)}else{C.set("start",C.get("end")-this.attributes.min_region_size)}C.set("genome",this.attributes.genome);C.trim()}return this.load_data(C,B,x,z)},set_data:function(w,v){this.set_elt(w,v)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(D,C,y,B,z){var F=this._mark_stale(D);if(!(F&&this.get("data_mode_compatible")(F,C))){console.log("ERROR: problem with getting more data: current data is not compatible");return}var x=D.get("start");if(z===this.DEEP_DATA_REQ){$.extend(B,{start_val:F.data.length+1})}else{if(z===this.BROAD_DATA_REQ){x=(F.max_high?F.max_high:F.data[F.data.length-1][2])+1}}var E=D.copy().set("start",x);var w=this,A=this.load_data(E,C,y,B),v=$.Deferred();this.set_data(D,v);$.when(A).then(function(G){if(G.data){G.data=F.data.concat(G.data);if(G.max_low){G.max_low=F.max_low}if(G.message){G.message=G.message.replace(/[0-9]+/,G.data.length)}}w.set_data(D,G);v.resolve(G)});return v},can_get_more_detailed_data:function(w){var v=this.get_elt(w);return(v.dataset_type==="bigwig"&&v.data.length<8000)},get_more_detailed_data:function(y,A,w,z,x){var v=this._mark_stale(y);if(!v){console.log("ERROR getting more detailed data: no current data");return}if(!x){x={}}if(v.dataset_type==="bigwig"){x.num_samples=1000*z}return this.load_data(y,A,w,x)},_mark_stale:function(w){var v=this.get_elt(w);if(!v){console.log("ERROR: no data to mark as stale: ",this.get("dataset"),w.toString())}v.stale=true;return v},get_genome_wide_data:function(v){var x=this,z=true,y=t.map(v.get("chroms_info").chrom_info,function(B){var A=x.get_elt(new h({chrom:B.chrom,start:0,end:B.len}));if(!A){z=false}return A});if(z){return y}var w=$.Deferred();$.getJSON(this.get("dataset").url(),{data_type:"genome_data"},function(A){x.add_data(A.data);w.resolve(A.data)});return w},subset_entry:function(x,y){var v={bigwig:function(z,A){return t.filter(z,function(B){return B[0]>=A.get("start")&&B[0]<=A.get("end")})},refseq:function(z,A){var B=A.get("start")-x.region.get("start");return x.data.slice(B,B+A.length())}};var w=x.data;if(!x.region.same(y)&&x.dataset_type in v){w=v[x.dataset_type](x.data,y)}return{region:y,data:w,dataset_type:x.dataset_type}}});var q=d.extend({initialize:function(v){var w=new Backbone.Model();w.urlRoot=v.data_url;this.set("dataset",w)},load_data:function(x,y,v,w){return(x.length()<=100000?d.prototype.load_data.call(this,x,y,v,w):{data:null,region:x})}});var c=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},initialize:function(v){this.id=v.dbkey},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info},get_chrom_region:function(v){var w=t.find(this.get_chroms_info(),function(x){return x.chrom===v});return new h({chrom:w.chrom,end:w.len})},get_chrom_len:function(v){return t.find(this.get_chroms_info(),function(w){return w.chrom===v}).len}});var h=Backbone.Model.extend({defaults:{chrom:null,start:0,end:0,str_val:null,genome:null},same:function(v){return this.attributes.chrom===v.get("chrom")&&this.attributes.start===v.get("start")&&this.attributes.end===v.get("end")},initialize:function(w){if(w.from_str){var y=w.from_str.split(":"),x=y[0],v=y[1].split("-");this.set({chrom:x,start:parseInt(v[0],10),end:parseInt(v[1],10)})}this.attributes.str_val=this.get("chrom")+":"+this.get("start")+"-"+this.get("end");this.on("change",function(){this.attributes.str_val=this.get("chrom")+":"+this.get("start")+"-"+this.get("end")},this)},copy:function(){return new h({chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")})},length:function(){return this.get("end")-this.get("start")},toString:function(){return this.attributes.str_val},toJSON:function(){return{chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")}},compute_overlap:function(C){var w=this.get("chrom"),B=C.get("chrom"),A=this.get("start"),y=C.get("start"),z=this.get("end"),x=C.get("end"),v;if(w&&B&&w!==B){return h.overlap_results.DIF_CHROMS}if(A<y){if(z<y){v=h.overlap_results.BEFORE}else{if(z<x){v=h.overlap_results.OVERLAP_START}else{v=h.overlap_results.CONTAINS}}}else{if(A>y){if(A>x){v=h.overlap_results.AFTER}else{if(z<=x){v=h.overlap_results.CONTAINED_BY}else{v=h.overlap_results.OVERLAP_END}}}else{v=(z>=x?h.overlap_results.CONTAINS:h.overlap_results.CONTAINED_BY)}}return v},trim:function(v){if(this.attributes.start<0){this.attributes.start=0}if(this.attributes.genome){var w=this.attributes.genome.get_chrom_len(this.attributes.chrom);if(this.attributes.end>w){this.attributes.end=w-1}}return this},contains:function(v){return this.compute_overlap(v)===h.overlap_results.CONTAINS},overlaps:function(v){return t.intersection([this.compute_overlap(v)],[h.overlap_results.DIF_CHROMS,h.overlap_results.BEFORE,h.overlap_results.AFTER]).length===0}},{overlap_results:{DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006}});var n=Backbone.Collection.extend({model:h});var e=Backbone.Model.extend({defaults:{region:null,note:""},initialize:function(v){this.set("region",new h(v.region))}});var s=Backbone.Collection.extend({model:e});var u=Backbone.Model.extend(f).extend({defaults:{mode:"Auto"},initialize:function(v){this.set("dataset",new k.Dataset(v.dataset));var x=[{key:"name",value:this.get("dataset").get("name")},{key:"color"}];this.set("config",p.ConfigSettingCollection.from_models_and_saved_values(x,v.prefs));var w=this.get("preloaded_data");if(w){w=w.data}else{w=[]}this.set("data_manager",new d({dataset:this.get("dataset"),init_data:w}))}},{to_json_keys:["track_type","dataset","prefs","mode","filters","tool_state"],to_json_mappers:{prefs:function(w,v){if(t.size(w)===0){w={name:v.get("config").get("name").get("value"),color:v.get("config").get("color").get("value")}}return w},dataset:function(v){return{id:v.id,hda_ldda:v.get("hda_ldda")}}}});var j=Backbone.Collection.extend({model:u});var o=Backbone.Model.extend({defaults:{title:"",type:""},url:galaxy_config.root+"visualization/save",save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var l=o.extend(f).extend({defaults:t.extend({},o.prototype.defaults,{dbkey:"",drawables:null,bookmarks:null,viewport:null}),initialize:function(v){this.set("drawables",new j(v.tracks));var w=[];this.set("config",p.ConfigSettingCollection.from_models_and_saved_values(w,v.prefs));this.unset("tracks");this.get("drawables").each(function(x){x.unset("preloaded_data")})},add_tracks:function(v){this.get("drawables").add(v)}},{to_json_keys:["view","viewport","bookmarks"],to_json_mappers:{view:function(w,v){return{obj_type:"View",prefs:{name:v.get("title"),content_visible:true},drawables:v.get("drawables")}}}});var b=Backbone.Model.extend({});var i=Backbone.Router.extend({initialize:function(w){this.view=w.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var v=this;v.view.on("navigate",function(x){v.navigate(x)})},change_location:function(v){this.view.go_to(v)}});return{BackboneTrack:u,BrowserBookmark:e,BrowserBookmarkCollection:s,Cache:r,CanvasManager:g,Genome:c,GenomeDataManager:d,GenomeRegion:h,GenomeRegionCollection:n,GenomeVisualization:l,GenomeReferenceDataManager:q,TrackBrowserRouter:i,TrackConfig:b,Visualization:o,select_datasets:a}}); \ No newline at end of file diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 static/scripts/viz/visualization.js --- a/static/scripts/viz/visualization.js +++ b/static/scripts/viz/visualization.js @@ -610,9 +610,8 @@ }); }, refseq: function(data, subregion) { - var seq_start = subregion.get('start') - entry.region.get('start'), - seq_end = entry.data.length - ( entry.region.get('end') - subregion.get('end') ); - return entry.data.slice(seq_start, seq_end); + var seq_start = subregion.get('start') - entry.region.get('start'); + return entry.data.slice(seq_start, seq_start + subregion.length()); } }; diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/anon-history-tests.js --- a/test/casperjs/anon-history-tests.js +++ b/test/casperjs/anon-history-tests.js @@ -1,36 +1,14 @@ -// have to handle errors here - or phantom/casper won't bail but _HANG_ -try { - var utils = require( 'utils' ), - xpath = require( 'casper' ).selectXPath, - format = utils.format, +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; - //...if there's a better way - please let me know, universe - scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); - +spaceghost.test.begin( 'Testing histories for anonymous users', 0, function suite( test ){ spaceghost.start(); -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} +// =================================================================== - -// ------------------------------------------------------------------- -/* TODO: - run a tool - -*/ -// =================================================================== globals and helpers var email = spaceghost.user.getRandomEmail(), password = '123456'; if( spaceghost.fixtureData.testUser ){ @@ -141,6 +119,5 @@ }); // =================================================================== -spaceghost.run( function(){ - this.test.done(); + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/api-anon-history-permission-tests.js --- a/test/casperjs/api-anon-history-permission-tests.js +++ b/test/casperjs/api-anon-history-permission-tests.js @@ -1,30 +1,14 @@ -/* Utility to load a specific page and output html, page text, or a screenshot - * Optionally wait for some time, text, or dom selector - */ -try { - //...if there's a better way - please let me know, universe - var scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} -spaceghost.start(); - +spaceghost.test.begin( 'Test permissions for accessible, published, and inaccessible histories ' + + 'with anonymous users over the API', 0, function suite( test ){ + spaceghost.start(); // =================================================================== SET UP -var utils = require( 'utils' ); - var email = spaceghost.user.getRandomEmail(), password = '123456'; if( spaceghost.fixtureData.testUser ){ @@ -63,9 +47,9 @@ //// ------------------------------------------------------------------------------------------- upload some files spaceghost.then( function(){ - this.api.tools.thenUpload( inaccessibleHistory.id, { filepath: this.options.scriptDir + '/../../test-data/1.bed' }); - this.api.tools.thenUpload( accessibleHistory.id, { filepath: this.options.scriptDir + '/../../test-data/1.bed' }); - this.api.tools.thenUpload( publishedHistory.id, { filepath: this.options.scriptDir + '/../../test-data/1.bed' }); + this.api.tools.thenUpload( inaccessibleHistory.id, { filepath: '../../test-data/1.bed' }); + this.api.tools.thenUpload( accessibleHistory.id, { filepath: '../../test-data/1.bed' }); + this.api.tools.thenUpload( publishedHistory.id, { filepath: '../../test-data/1.bed' }); }); spaceghost.then( function(){ // check that they're there @@ -220,5 +204,5 @@ // =================================================================== -spaceghost.run( function(){ + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/api-anon-history-tests.js --- a/test/casperjs/api-anon-history-tests.js +++ b/test/casperjs/api-anon-history-tests.js @@ -1,29 +1,11 @@ -/* Utility to load a specific page and output html, page text, or a screenshot - * Optionally wait for some time, text, or dom selector - */ -try { - //...if there's a better way - please let me know, universe - var scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} -spaceghost.start(); - - -// =================================================================== SET UP -var utils = require( 'utils' ); +spaceghost.test.begin( 'Test API functions for histories with an anonymous user', 0, function suite( test ){ + spaceghost.start(); // =================================================================== TESTS spaceghost.thenOpen( spaceghost.baseUrl ).waitForSelector( '.history-name' ); @@ -98,7 +80,7 @@ //TODO: can't use this - get a 400 when tools checks for history: 'logged in to manage' //spaceghost.then( function(){ // this.api.tools.thenUpload( spaceghost.api.histories.show( 'current' ).id, { -// filepath: this.options.scriptDir + '/../../test-data/1.sam' +// filepath: '../../test-data/1.sam' // }); //}); spaceghost.then( function(){ @@ -155,5 +137,6 @@ }); // =================================================================== -spaceghost.run( function(){ + spaceghost.run( function(){ test.done(); }); }); + diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/api-configuration-tests.js --- a/test/casperjs/api-configuration-tests.js +++ b/test/casperjs/api-configuration-tests.js @@ -1,29 +1,13 @@ -/* Utility to load a specific page and output html, page text, or a screenshot - * Optionally wait for some time, text, or dom selector - */ -try { - //...if there's a better way - please let me know, universe - var scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} -spaceghost.start(); +spaceghost.test.begin( 'Test the Galaxy configuration API', 0, function suite( test ){ + spaceghost.start(); // =================================================================== SET UP -var utils = require( 'utils' ); - var email = spaceghost.user.getRandomEmail(), password = '123456'; if( spaceghost.fixtureData.testUser ){ @@ -32,35 +16,6 @@ } spaceghost.user.loginOrRegisterUser( email, password ); -function hasKeys( object, keysArray ){ - if( !utils.isObject( object ) ){ return false; } - for( var i=0; i<keysArray.length; i += 1 ){ - if( !object.hasOwnProperty( keysArray[i] ) ){ - spaceghost.debug( 'key not found: ' + keysArray[i] ); - return false; - } - } - return true; -} - -function compareObjs( obj1, where ){ - for( var key in where ){ - if( where.hasOwnProperty( key ) ){ - if( !obj1.hasOwnProperty( key ) ){ return false; } - if( obj1[ key ] !== where[ key ] ){ return false; } - } - } - return true; -} - -function findObject( objectArray, where, start ){ - start = start || 0; - for( var i=start; i<objectArray.length; i += 1 ){ - if( compareObjs( objectArray[i], where ) ){ return objectArray[i]; } - } - return null; -} - // =================================================================== TESTS var normKeys = [ 'enable_unique_workflow_defaults', @@ -89,7 +44,7 @@ var configIndex = this.api.configuration.index(); this.debug( this.jsonStr( configIndex ) ); this.test.assert( utils.isObject( configIndex ), "index returned an object" ); - this.test.assert( hasKeys( configIndex, normKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( configIndex, normKeys ), 'Has the proper keys' ); }); spaceghost.user.logout(); @@ -97,7 +52,7 @@ // ------------------------------------------------------------------------------------------- INDEX (admin) spaceghost.tryStepsCatch( function tryAdminLogin(){ spaceghost.user.loginAdmin(); -}); +}, function(){} ); //}, function failedLoginRegister(){ // this.info( 'Admin level configuration API tests not run: no admin account available' ); @@ -109,7 +64,7 @@ configIndex = this.api.configuration.index(); this.debug( this.jsonStr( configIndex ) ); this.test.assert( utils.isObject( configIndex ), "index returned an object" ); - this.test.assert( hasKeys( configIndex, adminKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( configIndex, adminKeys ), 'Has the proper keys' ); } else { this.info( 'Admin level configuration API tests not run: no admin account available' ); @@ -118,5 +73,6 @@ }); // =================================================================== -spaceghost.run( function(){ + spaceghost.run( function(){ test.done(); }); }); + diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/api-hda-tests.js --- a/test/casperjs/api-hda-tests.js +++ b/test/casperjs/api-hda-tests.js @@ -1,29 +1,13 @@ -/* Utility to load a specific page and output html, page text, or a screenshot - * Optionally wait for some time, text, or dom selector - */ -try { - //...if there's a better way - please let me know, universe - var scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} -spaceghost.start(); +spaceghost.test.begin( 'Test the HDA API', 0, function suite( test ){ + spaceghost.start(); // =================================================================== SET UP -var utils = require( 'utils' ); - var email = spaceghost.user.getRandomEmail(), password = '123456'; if( spaceghost.fixtureData.testUser ){ @@ -34,12 +18,12 @@ spaceghost.thenOpen( spaceghost.baseUrl, function(){ this.api.tools.thenUpload( spaceghost.api.histories.show( 'current' ).id, { - filepath: this.options.scriptDir + '/../../test-data/1.sam' + filepath: '../../test-data/1.sam' }); }); // =================================================================== TESTS -var summaryKeys = [ 'id', 'name', 'type', 'url' ], +var summaryKeys = [ 'id', 'name', 'history_id', 'state', 'deleted', 'purged', 'visible', 'url', 'type' ], detailKeys = [ // the following are always present regardless of datatype 'id', 'name', 'api_type', 'model_class', @@ -100,6 +84,18 @@ // ------------------------------------------------------------------------------------------- CREATE //TODO: create from_ld_id + this.test.comment( 'create should allow copying an accessible hda' ); + hdaShow = this.api.hdas.show( lastHistory.id, firstHda.id ); + var returned = this.api.hdas.create( lastHistory.id, { + source : 'hda', + content : hdaShow.id + }); + //this.debug( 'returned:' + this.jsonStr( returned ) ); + this.test.assert( this.hasKeys( returned, detailKeys ), 'Has the proper keys' ); + this.test.assert( typeof returned.id !== 'number' && isNaN( Number( returned.id ) ), + 'id seems to be encoded: ' + returned.id ); + this.test.assert( typeof returned.history_id !== 'number' && isNaN( Number( returned.history_id ) ), + 'history_id seems to be encoded: ' + returned.history_id ); // ------------------------------------------------------------------------------------------- UPDATE @@ -367,5 +363,6 @@ // =================================================================== -spaceghost.run( function(){ + spaceghost.run( function(){ test.done(); }); }); + diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/api-history-permission-tests.js --- a/test/casperjs/api-history-permission-tests.js +++ b/test/casperjs/api-history-permission-tests.js @@ -1,30 +1,14 @@ -/* Utility to load a specific page and output html, page text, or a screenshot - * Optionally wait for some time, text, or dom selector - */ -try { - //...if there's a better way - please let me know, universe - var scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} -spaceghost.start(); - +spaceghost.test.begin( 'Test permissions for accessible, published, and inaccessible histories ' + + 'over the API', 0, function suite( test ){ + spaceghost.start(); // =================================================================== SET UP -var utils = require( 'utils' ); - var email = spaceghost.user.getRandomEmail(), password = '123456'; if( spaceghost.fixtureData.testUser ){ @@ -102,9 +86,9 @@ //// ------------------------------------------------------------------------------------------- upload some files spaceghost.then( function(){ - this.api.tools.thenUpload( inaccessibleHistory.id, { filepath: this.options.scriptDir + '/../../test-data/1.bed' }); - this.api.tools.thenUpload( accessibleHistory.id, { filepath: this.options.scriptDir + '/../../test-data/1.bed' }); - this.api.tools.thenUpload( publishedHistory.id, { filepath: this.options.scriptDir + '/../../test-data/1.bed' }); + this.api.tools.thenUpload( inaccessibleHistory.id, { filepath: '../../test-data/1.bed' }); + this.api.tools.thenUpload( accessibleHistory.id, { filepath: '../../test-data/1.bed' }); + this.api.tools.thenUpload( publishedHistory.id, { filepath: '../../test-data/1.bed' }); }); spaceghost.then( function(){ // check that they're there @@ -273,5 +257,5 @@ // =================================================================== -spaceghost.run( function(){ + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/api-history-tests.js --- a/test/casperjs/api-history-tests.js +++ b/test/casperjs/api-history-tests.js @@ -1,30 +1,13 @@ -/* Utility to load a specific page and output html, page text, or a screenshot - * Optionally wait for some time, text, or dom selector - */ -try { - //...if there's a better way - please let me know, universe - var scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} -spaceghost.start(); - +spaceghost.test.begin( 'Test the history API', 0, function suite( test ){ + spaceghost.start(); // =================================================================== SET UP -var utils = require( 'utils' ); - var email = spaceghost.user.getRandomEmail(), password = '123456'; if( spaceghost.fixtureData.testUser ){ @@ -361,5 +344,5 @@ }); // =================================================================== -spaceghost.run( function(){ + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/api-tool-tests.js --- a/test/casperjs/api-tool-tests.js +++ b/test/casperjs/api-tool-tests.js @@ -1,29 +1,13 @@ -/* Utility to load a specific page and output html, page text, or a screenshot - * Optionally wait for some time, text, or dom selector - */ -try { - //...if there's a better way - please let me know, universe - var scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} -spaceghost.start(); +spaceghost.test.begin( 'Test the tools API', 0, function suite( test ){ + spaceghost.start(); // =================================================================== SET UP -var utils = require( 'utils' ); - var email = spaceghost.user.getRandomEmail(), password = '123456'; if( spaceghost.fixtureData.testUser ){ @@ -32,17 +16,6 @@ } spaceghost.user.loginOrRegisterUser( email, password ); -function hasKeys( object, keysArray ){ - if( !utils.isObject( object ) ){ return false; } - for( var i=0; i<keysArray.length; i += 1 ){ - if( !object.hasOwnProperty( keysArray[i] ) ){ - spaceghost.debug( 'key not found: ' + keysArray[i] ); - return false; - } - } - return true; -} - function compareObjs( obj1, where ){ for( var key in where ){ if( where.hasOwnProperty( key ) ){ @@ -132,7 +105,7 @@ this.test.comment( 'index panel form should be separated into sections (by default)' ); var firstSection = toolIndex[0]; // get data //this.debug( this.jsonStr( firstSection ) ); - this.test.assert( hasKeys( firstSection, panelSectionKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( firstSection, panelSectionKeys ), 'Has the proper keys' ); //TODO: test form of indiv. keys this.test.comment( 'index sections have a list of tool "elems"' ); @@ -142,7 +115,7 @@ var firstTool = firstSection.elems[0]; // get data //this.debug( this.jsonStr( firstTool ) ); - this.test.assert( hasKeys( firstTool, panelToolKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( firstTool, panelToolKeys ), 'Has the proper keys' ); // ........................................................................................... in_panel=False this.test.comment( 'index should get a list of all tools when in_panel=false' ); @@ -154,7 +127,7 @@ this.test.comment( 'index non-panel form should be a simple list of tool summaries' ); firstSection = toolIndex[0]; //this.debug( this.jsonStr( firstSection ) ); - this.test.assert( hasKeys( firstSection, toolSummaryKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( firstSection, toolSummaryKeys ), 'Has the proper keys' ); //TODO: test uniqueness of ids //TODO: test form of indiv. keys @@ -169,7 +142,7 @@ this.test.comment( 'index with trackster=True should be separated into sections (by default)' ); firstSection = toolIndex[0]; // get data //this.debug( this.jsonStr( firstSection ) ); - this.test.assert( hasKeys( firstSection, panelSectionKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( firstSection, panelSectionKeys ), 'Has the proper keys' ); //TODO: test form of indiv. keys this.test.comment( 'index sections with trackster=True have a list of tool "elems"' ); @@ -179,7 +152,7 @@ firstTool = firstSection.elems[0]; // get data //this.debug( this.jsonStr( firstTool ) ); - this.test.assert( hasKeys( firstTool, panelToolKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( firstTool, panelToolKeys ), 'Has the proper keys' ); // ............................................................................ trackster=True, in_panel=False // this yields the same as in_panel=False... @@ -195,7 +168,7 @@ var toolShow = this.api.tools.show( selectFirst.id ); //this.debug( this.jsonStr( toolShow ) ); this.test.assert( utils.isObject( toolShow ), "show returned an object" ); - this.test.assert( hasKeys( toolShow, toolDetailKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( toolShow, toolDetailKeys ), 'Has the proper keys' ); this.test.comment( 'show data should include an array of input objects' ); this.test.assert( utils.isArray( toolShow.inputs ), "inputs is an array: " @@ -205,7 +178,7 @@ var input = toolShow.inputs[i]; this.test.comment( 'checking input #' + i + ': ' + ( input.name || '(no name)' ) ); this.test.assert( utils.isObject( input ), "input is an object" ); - this.test.assert( hasKeys( input, toolInputKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( input, toolInputKeys ), 'Has the proper keys' ); } //TODO: test form of indiv. keys @@ -226,20 +199,21 @@ 'upload_type': 'upload_dataset', }; var toolCreate = this.api.tools.create( payload ); - this.test.assert( hasKeys( toolCreate, ['outputs'] ), 'Has outputs' ); + this.test.assert( this.hasKeys( toolCreate, ['outputs'] ), 'Has outputs' ); var outputs = toolCreate['outputs']; this.test.assert( utils.isArray( outputs ), 'outputs is an array' ); this.test.assert( outputs.length == 1, 'one dataset is created' ); var output = outputs[0] this.test.assert( utils.isObject( output ), 'output0 is an array' ); - this.test.assert( hasKeys( output, ['data_type', 'deleted', 'hid', 'history_id', 'id', 'name' ] ), 'Dataset information defined' ); - this.test.assert( hasKeys( output, ['output_name' ] ), 'Output name labelled' ); + this.test.assert( this.hasKeys( output, ['data_type', 'deleted', 'hid', 'history_id', 'id', 'name' ] ), + 'Dataset information defined' ); + this.test.assert( this.hasKeys( output, ['output_name' ] ), 'Output name labelled' ); // ------------------------------------------------------------------------------------------- MISC //attemptShowOnAllTools.call( spaceghost ); }); // =================================================================== -spaceghost.run( function(){ + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/api-user-tests.js --- a/test/casperjs/api-user-tests.js +++ b/test/casperjs/api-user-tests.js @@ -1,29 +1,13 @@ -/* Utility to load a specific page and output html, page text, or a screenshot - * Optionally wait for some time, text, or dom selector - */ -try { - //...if there's a better way - please let me know, universe - var scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} -spaceghost.start(); +spaceghost.test.begin( 'Test the user API', 0, function suite( test ){ + spaceghost.start(); // =================================================================== SET UP -var utils = require( 'utils' ); - var email = spaceghost.user.getRandomEmail(), password = '123456'; if( spaceghost.fixtureData.testUser ){ @@ -32,44 +16,7 @@ } spaceghost.user.loginOrRegisterUser( email, password ); -function hasKeys( object, keysArray ){ - if( !utils.isObject( object ) ){ return false; } - for( var i=0; i<keysArray.length; i += 1 ){ - if( !object.hasOwnProperty( keysArray[i] ) ){ - spaceghost.debug( 'key not found: ' + keysArray[i] ); - return false; - } - } - return true; -} - -function compareObjs( obj1, where ){ - for( var key in where ){ - if( where.hasOwnProperty( key ) ){ - if( !obj1.hasOwnProperty( key ) ){ return false; } - if( obj1[ key ] !== where[ key ] ){ return false; } - } - } - return true; -} - -function findObject( objectArray, where, start ){ - start = start || 0; - for( var i=start; i<objectArray.length; i += 1 ){ - if( compareObjs( objectArray[i], where ) ){ return objectArray[i]; } - } - return null; -} - // =================================================================== TESTS -var workflowSummaryKeys = [ - 'id', 'model_class', 'name', 'published', 'tags', 'url' - ], - workflowDetailKeys = workflowSummaryKeys.concat([ - 'inputs', 'steps' - ]); - - spaceghost.thenOpen( spaceghost.baseUrl ).then( function(){ // ------------------------------------------------------------------------------------------- INDEX @@ -101,5 +48,5 @@ }); // =================================================================== -spaceghost.run( function(){ + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/api-visualizations-tests.js --- a/test/casperjs/api-visualizations-tests.js +++ b/test/casperjs/api-visualizations-tests.js @@ -1,30 +1,13 @@ -/* Utility to load a specific page and output html, page text, or a screenshot - * Optionally wait for some time, text, or dom selector - */ -try { - //...if there's a better way - please let me know, universe - var scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} -spaceghost.start(); - +spaceghost.test.begin( 'Test the visualizations API', 0, function suite( test ){ + spaceghost.start(); // =================================================================== SET UP -var utils = require( 'utils' ); - var email = spaceghost.user.getRandomEmail(), password = '123456'; if( spaceghost.fixtureData.testUser ){ @@ -33,76 +16,6 @@ } spaceghost.user.loginOrRegisterUser( email, password ); -function hasKeys( object, keysArray ){ - if( !utils.isObject( object ) ){ return false; } - for( var i=0; i<keysArray.length; i += 1 ){ - if( !object.hasOwnProperty( keysArray[i] ) ){ - spaceghost.debug( 'object missing key: ' + keysArray[i] ); - return false; - } - } - return true; -} - -function countKeys( object ){ - if( !utils.isObject( object ) ){ return 0; } - var count = 0; - for( var key in object ){ - if( object.hasOwnProperty( key ) ){ count += 1; } - } - return count; -} - -function compareObjs( obj, compare_to, exclusionList ){ - exclusionList = exclusionList || []; - for( var key in compare_to ){ - if( compare_to.hasOwnProperty( key ) && exclusionList.indexOf( key ) === -1 ){ - if( !obj.hasOwnProperty( key ) ){ - spaceghost.debug( 'obj missing key: ' + key ); - return false; - } - if( obj[ key ] !== compare_to[ key ] ){ - spaceghost.debug( 'obj value not equal. obj: ' + obj[ key ] + ', v.: ' + compare_to[ key ] ); - return false; - } - } - } - return true; -} - -function assertRaises( fn, expectedCode, errMsgShouldContain, assertionMsg, debug ){ - //TODO: errMsgShouldContain optional, any old error - assertionMsg = assertionMsg || 'create returned error'; - debug = debug || false; - var errorReturned = {}; - try { - fn.call( spaceghost ); - } catch( error ){ - errorReturned = error; - } - if( errorReturned ){ - if( debug ){ spaceghost.debug( 'error:\n' + spaceghost.jsonStr( errorReturned ) ); } - var errorMsg = errorReturned.message || ''; - if( errorMsg ){ - try { - errorMsg = JSON.parse( errorReturned.message ).error; - } catch( parseErr ){ - spaceghost.warn( 'error parsing error.message' ); - } - } - var properCode = errorReturned.status === expectedCode, - properMsg = errorMsg.indexOf( errMsgShouldContain ) !== -1; - spaceghost.test.assert( properCode && properMsg, - assertionMsg + ': (' + errorReturned.status + ') "' + errorMsg + '"' ); - if( !( properCode && properMsg ) ){ - throw errorReturned; - } - } else { - spaceghost.test.fail( assertionMsg + ': (no error)' ); - } -} - - // =================================================================== TESTS spaceghost.thenOpen( spaceghost.baseUrl ).then( function(){ var ALWAYS_CREATE = true, @@ -145,7 +58,7 @@ this.test.assert( visualizationIndex.length >= 1, 'Has at least one visualization' ); var firstVisualization = visualizationIndex[0]; - this.test.assert( hasKeys( firstVisualization, indexKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( firstVisualization, indexKeys ), 'Has the proper keys' ); this.test.assert( this.api.isEncodedId( firstVisualization.id ), 'Id appears well-formed' ); //TODO: index searching @@ -156,7 +69,7 @@ this.test.comment( 'show should get a visualization details object' ); var visualizationShow = this.api.visualizations.show( firstVisualization.id ); this.debug( this.jsonStr( visualizationShow ) ); - this.test.assert( hasKeys( visualizationShow, showKeys ), 'Has the proper keys' ); + this.test.assert( this.hasKeys( visualizationShow, showKeys ), 'Has the proper keys' ); this.test.assert( visualizationShow.model_class === 'Visualization', 'Has the proper model_class: ' + visualizationShow.model_class ); @@ -173,7 +86,7 @@ this.test.comment( 'a visualization details object should contain a subobject of the latest revision' ); var latestRevision = visualizationShow.latest_revision; this.test.assert( utils.isObject( latestRevision ), 'latestRevision is an object' ); - this.test.assert( hasKeys( latestRevision, revisionKeys ), 'latestRevision has the proper keys' ); + this.test.assert( this.hasKeys( latestRevision, revisionKeys ), 'latestRevision has the proper keys' ); this.test.assert( latestRevision.model_class === 'VisualizationRevision', 'Has the proper model_class: ' + latestRevision.model_class ); this.test.assert( latestRevision.visualization_id === visualizationShow.id, @@ -212,18 +125,18 @@ visualizationShow = this.api.visualizations.show( created.id ); this.debug( 'visualizationShow:\n' + this.jsonStr( visualizationShow ) ); // config is re-located into a revision and won't be there - this.test.assert( compareObjs( visualizationShow, visualizationData, [ 'config' ] ), - "show results seem to match create data" ); + //this.test.assert( compareObjs( visualizationShow, visualizationData, [ 'config' ] ), + // "show results seem to match create data" ); // the following errors are produced within base.controller.UsesVisualizationsMixin._create_visualization this.test.comment( 'Calling create with a non-unique slug will cause an API error' ); - assertRaises( function(){ + this.api.assertRaises( function(){ created = this.api.visualizations.create( visualizationData ); }, 400, 'visualization identifier must be unique' ); this.test.comment( 'Calling create with no title will cause an API error' ); visualizationData.title = ''; - assertRaises( function(){ + this.api.assertRaises( function(){ created = this.api.visualizations.create( visualizationData ); }, 400, 'visualization name is required' ); visualizationData.title = 'Created Visualization'; @@ -231,33 +144,33 @@ this.test.comment( 'Calling create with improper characters in the slug will cause an API error' ); var oldSlug = visualizationData.slug; visualizationData.slug = '123_()'; - assertRaises( function(){ + this.api.assertRaises( function(){ created = this.api.visualizations.create( visualizationData ); }, 400, "visualization identifier must consist of only lowercase letters, numbers, and the '-' character" ); visualizationData.slug = oldSlug; this.test.comment( 'Calling create with an unrecognized key will cause an API error' ); visualizationData.bler = 'blah'; - assertRaises( function(){ + this.api.assertRaises( function(){ created = this.api.visualizations.create( visualizationData ); }, 400, 'unknown key: bler' ); delete visualizationData.bler; this.test.comment( 'Calling create with an unparsable JSON config will cause an API error' ); visualizationData.config = '3 = nime'; - assertRaises( function(){ + this.api.assertRaises( function(){ created = this.api.visualizations.create( visualizationData ); }, 400, 'config must be a dictionary (JSON)' ); // ------------------------------------------------------------------------------------------ UPDATE // ........................................................................................... idiot proofing this.test.comment( 'updating using a nonsense key should fail with an error' ); - assertRaises( function(){ + this.api.assertRaises( function(){ returned = this.api.visualizations.update( created.id, { bler : 'blah' }); }, 400, 'unknown key: bler' ); this.test.comment( 'updating by attempting to change type should cause an error' ); - assertRaises( function(){ + this.api.assertRaises( function(){ returned = this.api.visualizations.update( created.id, { title : 30 }); }, 400, 'title must be a string or unicode' ); //TODO: the other types... @@ -278,5 +191,5 @@ }); // =================================================================== -spaceghost.run( function(){ + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/api-workflow-tests.js --- a/test/casperjs/api-workflow-tests.js +++ b/test/casperjs/api-workflow-tests.js @@ -1,29 +1,13 @@ -/* Utility to load a specific page and output html, page text, or a screenshot - * Optionally wait for some time, text, or dom selector - */ -try { - //...if there's a better way - please let me know, universe - var scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} -spaceghost.start(); +spaceghost.test.begin( 'Test the workflows API', 0, function suite( test ){ + spaceghost.start(); // =================================================================== SET UP -var utils = require( 'utils' ); - var email = spaceghost.user.getRandomEmail(), password = '123456'; if( spaceghost.fixtureData.testUser ){ @@ -32,26 +16,6 @@ } spaceghost.user.loginOrRegisterUser( email, password ); -function hasKeys( object, keysArray ){ - if( !utils.isObject( object ) ){ return false; } - for( var i=0; i<keysArray.length; i += 1 ){ - if( !object.hasOwnProperty( keysArray[i] ) ){ - spaceghost.debug( 'key not found: ' + keysArray[i] ); - return false; - } - } - return true; -} - -function countKeys( object ){ - if( !utils.isObject( object ) ){ return 0; } - var count = 0; - for( var key in object ){ - if( object.hasOwnProperty( key ) ){ count += 1; } - } - return count; -} - // =================================================================== TESTS var workflowJSONFilepath = 'test-data/Bed_interval_lengths.ga', workflowModelClass = 'StoredWorkflow', @@ -81,7 +45,7 @@ this.test.comment( 'upload should return a summary object of what we uploaded' ); //this.debug( this.jsonStr( returned ) ); this.test.assert( utils.isObject( returned ), "upload returned an object" ); - this.test.assert( hasKeys( returned, workflowSummaryKeys ), "upload's return has the proper keys" ); + this.test.assert( this.hasKeys( returned, workflowSummaryKeys ), "upload's return has the proper keys" ); this.test.assert( this.api.isEncodedId( returned.id ), "id is of the proper form: " + returned.id ); this.test.assert( returned.model_class === workflowModelClass, @@ -105,7 +69,7 @@ this.test.comment( 'index should have returned an object matching the workflow uploaded' ); var firstWorkflow = workflowIndex[0]; - this.test.assert( hasKeys( firstWorkflow, workflowSummaryKeys ), "index has the proper keys" ); + this.test.assert( this.hasKeys( firstWorkflow, workflowSummaryKeys ), "index has the proper keys" ); this.test.assert( this.api.isEncodedId( firstWorkflow.id ), "id is of the proper form: " + firstWorkflow.id ); this.test.assert( firstWorkflow.model_class === workflowModelClass, @@ -125,7 +89,7 @@ var workflowShow = this.api.workflows.show( firstWorkflow.id ); this.debug( this.jsonStr( workflowShow ) ); this.test.assert( utils.isObject( workflowShow ), "show returned an object" ); - this.test.assert( hasKeys( workflowShow, workflowDetailKeys ), "show has the proper keys" ); + this.test.assert( this.hasKeys( workflowShow, workflowDetailKeys ), "show has the proper keys" ); this.test.assert( this.api.isEncodedId( workflowShow.id ), "id is of the proper form: " + workflowShow.id ); this.test.assert( workflowShow.model_class === workflowModelClass, @@ -147,7 +111,7 @@ // if( inputs.hasOwnProperty( inputKey ) ){ // } //} - this.test.assert( countKeys( workflowShow.inputs ) === 0, "inputs is empty" ); + this.test.assert( this.countKeys( workflowShow.inputs ) === 0, "inputs is empty" ); this.test.comment( 'steps from show should be an object containing each tool defined as a step' ); var steps = workflowShow.steps; @@ -161,7 +125,7 @@ this.test.assert( utils.isString( stepKey ), "step key is a string: " + stepKey ); var step = steps[ stepKey ]; this.debug( 'step:\n' + this.jsonStr( step ) ); - this.test.assert( hasKeys( step, stepKeys ), "step has the proper keys" ); + this.test.assert( this.hasKeys( step, stepKeys ), "step has the proper keys" ); this.test.assert( utils.isNumber( step.id ), "step id is a number: " + step.id ); @@ -173,8 +137,8 @@ } this.test.assert( utils.isObject( step.input_steps ), "input_steps is an object" ); - if( countKeys( step.input_steps ) !== 0 ){ - this.test.assert( hasKeys( step.input_steps, [ 'input' ] ), "input_steps has the proper keys" ); + if( this.countKeys( step.input_steps ) !== 0 ){ + this.test.assert( this.hasKeys( step.input_steps, [ 'input' ] ), "input_steps has the proper keys" ); } this.test.assert( step.type === 'tool', @@ -185,7 +149,7 @@ "step tool_id is a string: " + step.tool_id ); var tool_used = this.api.tools.show( step.tool_id ); //this.debug( this.jsonStr( tool_used ) ) - this.test.assert( countKeys( step.input_steps ) !== 0, "found tool in api.tools for: " + step.tool_id ); + this.test.assert( this.countKeys( step.input_steps ) !== 0, "found tool in api.tools for: " + step.tool_id ); // trace the path through input_steps, source_steps } @@ -215,7 +179,7 @@ for( var stepKey in firstWorkflow.steps ){ if( firstWorkflow.steps.hasOwnProperty( stepKey ) ){ var step = firstWorkflow.steps[ stepKey ]; - if( countKeys( step.input_steps ) === 0 ){ + if( this.countKeys( step.input_steps ) === 0 ){ input_step = stepKey; this.debug( 'input step: ' + this.jsonStr( step ) ) break; @@ -238,7 +202,7 @@ var returned = this.api.workflows.create( executionData ); this.debug( this.jsonStr( returned ) ); this.test.assert( utils.isObject( returned ), "create returned an object" ); - this.test.assert( hasKeys( returned, workflowCreateKeys ), "create returned the proper keys" ); + this.test.assert( this.hasKeys( returned, workflowCreateKeys ), "create returned the proper keys" ); this.test.assert( this.api.isEncodedId( returned.history ), "history id is proper: " + returned.history ); this.test.assert( utils.isArray( returned.outputs ), @@ -285,5 +249,5 @@ }); // =================================================================== -spaceghost.run( function(){ + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/casperjs_runner.py --- a/test/casperjs/casperjs_runner.py +++ b/test/casperjs/casperjs_runner.py @@ -3,26 +3,34 @@ Allows integration of casperjs tests with buildbot, run_functional_tests.sh Tests can be run in any of the following ways: -* casperjs mytests.js --url='http://localhost:8080' +* casperjs test mytests.js --url='http://localhost:8080' * python casperjs_runner.py * nosetests * sh run_functional_tests.sh test/casperjs/test_runner * sh run_functional_tests.sh Note: that you can enable (lots of) debugging info using cli options: -* casperjs usertests.js --url='http://localhost:8080' --verbose=true --logLevel=debug +* casperjs test usertests.js --url='http://localhost:8080' --verbose=true --logLevel=debug (see casperjs.org for more information) Note: This seems to not work with CasperJS 1.1 (and PhantomJS 1.9) - Casper 1.0.xx and PhantomJS 1.8 work for me (John). -Note: Example of specifing user and admin user credentials. +Note: You can pass in extra data using --data='<some JSON object>' + and it will be available in your script as spaceghost.fixtureData. -casperjs api-configuration-tests.js --url="http://localhost:8080" \ - --admin='{"email": "foo@example.com", "password": "123456" }' \ - '{ "testUser": { "email": "foo@example.com", "password": "123456" } }' + Example using a specific user account: + casperjs test api-history-tests.js --url="http://localhost:8080" \ + --data='{ "testUser": { "email": "foo@example.com", "password": "123456" } }' + // ...then, in script: + spaceghost.user.loginOrRegisterUser( + spaceghost.fixtureData.testUser.email, + spaceghost.fixtureData.testUser.password ); + Example of specifing user and admin user credentials: + casperjs test api-configuration-tests.js --url="http://localhost:8080" \ + --admin='{"email": "foo@example.com", "password": "123456" }' \ """ # -------------------------------------------------------------------- can't do 2.5 import sys @@ -120,6 +128,11 @@ #log.debug( '%s stderr output:\n%s', rel_script_path, stderr_output ) log.debug( 'process.returncode: %d', process.returncode ) + + # 1.1 has an annoying info bar that happens before it gets to our stuff, so... + stdout_output = '\n'.join( stdout_output.split( '\n' )[1:] ) + #log.debug( 'stdout_output:\n' + stdout_output ) + if process.returncode == 1: #TODO: this is a fail on first effect raise self.browser_error_to_exception( rel_script_path, stdout_output ) @@ -140,6 +153,9 @@ """ command_line_list = [ self.exec_path ] + # as of casperjs 1.1, we always need to use the 'test' command + command_line_list.append( 'test' ) + # make rel_script_path an absolute path (when this is not run from it's dir - i.e. run_functional_tests.sh) curr_dir = os.path.dirname( __file__ ) script_path = os.path.join( curr_dir, rel_script_path ) @@ -163,7 +179,8 @@ command_line_list.extend( args ) # send extra data - encode kwargs as json to pass to casper for decoding - command_line_list.append( json.dumps( kwargs ) ) + # as of 1.1, we need to pass this under a opt + command_line_list.append( '--data=' + json.dumps( kwargs ) ) return command_line_list def strip_escape_codes( self, msg ): @@ -220,6 +237,7 @@ """Handle the results of the js tests by either converting them with the results adapter or checking for a failure list. """ + # if given an adapter - use it if self.results_adapter: self.results_adapter.convert( results, self ) @@ -227,7 +245,7 @@ # - otherwise, assert no failures found else: js_test_results = json.loads( results ) - failures = js_test_results[ 'testResults' ][ 'failures' ] + failures = js_test_results[ 'failures' ] assert len( failures ) == 0, ( "%d assertions failed in the headless browser tests" % ( len( failures ) ) + " (see the log for details)" ) diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/hda-state-tests.js --- a/test/casperjs/hda-state-tests.js +++ b/test/casperjs/hda-state-tests.js @@ -1,29 +1,13 @@ -// have to handle errors here - or phantom/casper won't bail but _HANG_ -try { - var utils = require( 'utils' ), - xpath = require( 'casper' ).selectXPath, - format = utils.format, +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; - //...if there's a better way - please let me know, universe - scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); - +spaceghost.test.begin( 'Test the form of various HDA states', 0, function suite( test ){ spaceghost.start(); - -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} - + spaceghost.openHomePage().then( function(){ + }); // =================================================================== /* TODO: @@ -40,19 +24,7 @@ spaceghost.info( 'Will use fixtureData.testUser: ' + email ); } -var tooltipSelector = spaceghost.data.selectors.tooltipBalloon; - -var utils = require( 'utils' ), - historyFrameInfo = {}, - filepathToUpload = '../../test-data/1.bam', - testUploadInfo = {}, - //TODO: get from the api module - that doesn't exist yet - - //summaryShouldBeArray = [ '3.5 KB', 'format: bam' ], - //infoShouldBe = 'uploaded bam file', - //metadataFiles = [ 'bam_index' ], - //peekShouldBeArray = []; - +var tooltipSelector = spaceghost.data.selectors.tooltipBalloon, filepathToUpload = '../../test-data/1.txt', testUploadInfo = {}, //TODO: get from the api module - that doesn't exist yet @@ -420,6 +392,5 @@ */ // =================================================================== -spaceghost.run( function(){ - this.test.done(); + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/history-options-tests.js --- a/test/casperjs/history-options-tests.js +++ b/test/casperjs/history-options-tests.js @@ -1,28 +1,13 @@ -// have to handle errors here - or phantom/casper won't bail but _HANG_ -try { - var utils = require( 'utils' ), - xpath = require( 'casper' ).selectXPath, - format = utils.format, +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; - //...if there's a better way - please let me know, universe - scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); - +spaceghost.test.begin( 'Testing the history options menu', 0, function suite( test ){ spaceghost.start(); - -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} + spaceghost.openHomePage().then( function(){ + }); // =================================================================== /* TODO: @@ -144,6 +129,5 @@ }); // =================================================================== -spaceghost.run( function(){ - this.test.done(); + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/history-panel-tests.js --- a/test/casperjs/history-panel-tests.js +++ b/test/casperjs/history-panel-tests.js @@ -1,29 +1,12 @@ -// have to handle errors here - or phantom/casper won't bail but _HANG_ -try { - var utils = require( 'utils' ), - xpath = require( 'casper' ).selectXPath, - format = utils.format, +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + xpath = require( 'casper' ).selectXPath, + utils = require( 'utils' ), + format = utils.format; - //...if there's a better way - please let me know, universe - scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); - +spaceghost.test.begin( 'Testing the form of the main/current history panel', 0, function suite( test ){ spaceghost.start(); -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} - // =================================================================== /* TODO: possibly break this file up @@ -157,11 +140,11 @@ spaceghost.tools.uploadFile( filepathToUpload, function uploadCallback( _uploadInfo ){ this.test.comment( 'uploaded file should appear in history' ); - //this.debug( 'uploaded HDA info: ' + this.jsonStr( _uploadInfo ) ); + this.debug( 'uploaded HDA info: ' + this.jsonStr( _uploadInfo ) ); var hasHda = _uploadInfo.hdaElement, hasClass = _uploadInfo.hdaElement.attributes[ 'class' ], hasOkClass = _uploadInfo.hdaElement.attributes[ 'class' ].indexOf( wrapperOkClassName ) !== -1; - this.test.assert( ( hasHda && hasClass && hasOkClass ), "Uploaded file: " + _uploadInfo.name ); + this.test.assert( ( hasHda && hasClass && hasOkClass ), "Uploaded file: " + _uploadInfo.filename ); testUploadInfo = _uploadInfo; }); @@ -173,7 +156,7 @@ this.test.assertVisible( nameSelector, 'History name is visible' ); this.test.assertSelectorHasText( nameSelector, newHistoryName, 'History name is ' + newHistoryName ); - var onetxtFilesize = require( 'fs' ).size( this.options.scriptDir + filepathToUpload ), + var onetxtFilesize = require( 'fs' ).size( filepathToUpload ), expectedSubtitle = onetxtFilesize + ' bytes'; this.test.comment( "history subtitle should display size and size should be " + onetxtFilesize + " bytes" ); this.test.assertExists( subtitleSelector, 'Found ' + subtitleSelector ); @@ -292,8 +275,8 @@ "Body for uploaded file is not visible" ); }); }); - +/* +*/ // =================================================================== -spaceghost.run( function(){ - this.test.done(); + spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/login-tests.js --- a/test/casperjs/login-tests.js +++ b/test/casperjs/login-tests.js @@ -1,27 +1,13 @@ -try { - var utils = require( 'utils' ), - xpath = require( 'casper' ).selectXPath, - format = utils.format, +var require = patchRequire( require ), + spaceghost = require( 'spaceghost' ).fromCasper( casper ), + utils = require( 'utils' ), + xpath = require( 'casper' ).selectXPath, + format = utils.format; - //...if there's a better way - please let me know, universe - scriptDir = require( 'system' ).args[3] - // remove the script filename - .replace( /[\w|\.|\-|_]*$/, '' ) - // if given rel. path, prepend the curr dir - .replace( /^(?!\/)/, './' ), - spaceghost = require( scriptDir + 'spaceghost' ).create({ - // script options here (can be overridden by CLI) - //verbose: true, - //logLevel: debug, - scriptDir: scriptDir - }); +spaceghost.test.begin( 'Testing logging in and logging out', 0, function suite( test ){ + spaceghost.start(); + //console.debug( 'suiteResults: ' + test.suiteResults ); - spaceghost.start(); - -} catch( error ){ - console.debug( error ); - phantom.exit( 1 ); -} // =================================================================== globals and helpers var email = spaceghost.user.getRandomEmail(), @@ -86,7 +72,7 @@ // ------------------------------------------------------------------- test yoself // these versions are for conv. use in other tests, they should throw errors if used improperly spaceghost.then( function(){ - this.assertStepsRaise( 'GalaxyError: LoginError', function(){ + this.assertStepsRaise( 'LoginError', function(){ this.then( function(){ this.test.comment( 'testing (js) error thrown on bad email' ); this.user.login( 'nihilist', '1234' ); @@ -95,7 +81,7 @@ }); spaceghost.then( function(){ - this.assertStepsRaise( 'GalaxyError: LoginError', function(){ + this.assertStepsRaise( 'LoginError', function(){ this.then( function(){ this.test.comment( 'testing (js) error thrown on bad password' ); this.user.login( email, '1234' ); @@ -105,6 +91,5 @@ /* */ // =================================================================== -spaceghost.run( function(){ - this.test.done(); +spaceghost.run( function(){ test.done(); }); }); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/modules/api.js --- a/test/casperjs/modules/api.js +++ b/test/casperjs/modules/api.js @@ -52,7 +52,8 @@ */ // =================================================================== INTERNAL -var utils = require( 'utils' ); +var require = patchRequire( require ), + utils = require( 'utils' ); API.prototype._ajax = function _ajax( url, options ){ options = options || {}; @@ -167,7 +168,7 @@ API.prototype.ensureJQuery = function ensureJQuery(){ if( !this.hasJQuery() ){ - var absLoc = this.spaceghost.options.scriptDir + this.jQueryLocation, + var absLoc = this.jQueryLocation, injected = this.spaceghost.page.injectJs( absLoc ); if( !injected ){ throw new APIError( 'Could not inject jQuery' ); diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/modules/historyoptions.js --- a/test/casperjs/modules/historyoptions.js +++ b/test/casperjs/modules/historyoptions.js @@ -26,7 +26,8 @@ */ // =================================================================== internal -var xpath = require( 'casper' ).selectXPath; +var require = patchRequire( require ), + xpath = require( 'casper' ).selectXPath; // =================================================================== API (external) /** Just open the menu diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/modules/historypanel.js --- a/test/casperjs/modules/historypanel.js +++ b/test/casperjs/modules/historypanel.js @@ -28,8 +28,8 @@ */ // =================================================================== INTERNAL -var xpath = require( 'casper' ).selectXPath; - //utils = require( 'utils' ); +var require = patchRequire( require ), + xpath = require( 'casper' ).selectXPath; // =================================================================== API (external) // ------------------------------------------------------------------- frame control @@ -91,20 +91,6 @@ }; // ------------------------------------------------------------------- step functions -///** Version of Casper#withFrame for the history iframe. -// * Hopefully will allow easier test transition if/when frames are removed -// * (i.e. -> just call the function). -// * NOTE: is more than one Casper step. -// * @param {Function} then function called when in the history frame -// */ -//HistoryPanel.prototype.then = function then( thenFn ){ -// if( this.inFrame() ){ -// thenFn.call( this.spaceghost ); -// } else { -// this.spaceghost.withHistoryPanel( thenFn ); -// } -//}; -// /** Moves into history iframe and waits until hdas are visible or empty message is. * NOTE: is more than one Casper step. * @see Casper@waitFor @@ -127,51 +113,44 @@ return spaceghost; }; -/** Expands or collapses an HDA by clicking the title (does nothing if already in desired state). +/** Moves into history iframe and waits until hdas are visible or empty message is. * NOTE: is more than one Casper step. - * @param {String} hdaSelector a css or xpath selector for an historyItemWrapper - * @param {Function} then function called when the change is made - * @param {Boolean} desiredClosed true if you want to collapse, false if you want open - * @private + * @see Casper@waitFor */ -HistoryPanel.prototype._thenExpandOrCollapseHda = function _thenExpandOrCollapseHda( hdaSelector, then, desiredClosed ){ - // using a step here (instead of a jump) bc we need the wait for function - this.spaceghost.then( function checkingHda(){ - this.info( (( desiredClosed )?( 'collapsing' ):( 'expanding' )) + ' hda: ' + hdaSelector ); +HistoryPanel.prototype.waitForHda = function waitForHda( hdaName, then, timeout, maxWait ){ + //TODO:?? should this wait until the seletors are in AND they are opaque? + var spaceghost = this.spaceghost, + hdaElement = null, + previousState = null; + spaceghost.then( function waitingForHda(){ + this.waitFor( + function checkHpanel(){ + var wrapperXpath = xpath( '//span[contains(text(),"' + hdaName + '")]/../../..' ); + hdaElement = this.elementInfoOrNull( wrapperXpath ); + //NOTE: this will probably fail if the name was used on a previous HDA + if( !hdaElement ){ return false; } + + var state = hdaElement.attributes[ "class" ].match( /state\-([\w\-_]*)/ )[1]; + if( state !== previousState ){ + spaceghost.info( 'state: ' + state ); + previousState = state; + } + if( state !== 'ok' ){ return false; } - // click to open if the body isn't visible and call wait to account for opening animation - if( this.visible( hdaSelector + ' ' + this.historypanel.data.selectors.hda.body ) === desiredClosed ){ - this.click( hdaSelector + ' ' + this.historypanel.data.selectors.hda.title ); - //NOTE: then is executed in the top frame - //TODO: magic number - this.wait( 500, then ); - - // otherwise, just call then - } else if( then ){ - then.call( this ); - } + var hdaOpacity = this.evaluate( function( name ){ + return $( '.dataset-name:contains("' + name + '")' ).parents( '.hda' ).css( 'opacity' ); + }, hdaName ); + this.debug( 'fading in: ' + hdaOpacity ); + return hdaOpacity >= 1; + }, + function _then(){ then.call( this, hdaElement ); }, + function _timeout(){ timeout.call( this, hdaElement ); }, + maxWait ); }); - return this.spaceghost; + return spaceghost; }; -/** Collapses an HDA by clicking the title (does nothing if already collapsed). - * NOTE: is more than one Casper step. - * @param {String} hdaSelector a css or xpath selector for an historyItemWrapper - * @param {Function} then function called when the change is made - */ -HistoryPanel.prototype.thenCollapseHda = function thenCollapseHda( hdaSelector, then ){ - return this._thenExpandOrCollapseHda( hdaSelector, then, true ); -}; - -/** Expands an HDA by clicking the title (does nothing if already expanded). - * NOTE: is more than one Casper step. - * @param {String} hdaSelector a css or xpath selector for an historyItemWrapper - * @param {Function} then function called when the change is made - */ -HistoryPanel.prototype.thenExpandHda = function thenExpandHda( hdaSelector, then ){ - return this._thenExpandOrCollapseHda( hdaSelector, then, false ); -}; - +//TODO: combine with above /** Wait for the hda with given id to move into the given state. * whenInStateFn and timeoutFn will be passed the hda element info (see Casper#getElementInfo) * NOTE: is more than one Casper step. @@ -233,6 +212,51 @@ return spaceghost; }; +/** Expands or collapses an HDA by clicking the title (does nothing if already in desired state). + * NOTE: is more than one Casper step. + * @param {String} hdaSelector a css or xpath selector for an historyItemWrapper + * @param {Function} then function called when the change is made + * @param {Boolean} desiredClosed true if you want to collapse, false if you want open + * @private + */ +HistoryPanel.prototype._thenExpandOrCollapseHda = function _thenExpandOrCollapseHda( hdaSelector, then, desiredClosed ){ + // using a step here (instead of a jump) bc we need the wait for function + this.spaceghost.then( function checkingHda(){ + this.info( (( desiredClosed )?( 'collapsing' ):( 'expanding' )) + ' hda: ' + hdaSelector ); + + // click to open if the body isn't visible and call wait to account for opening animation + if( this.visible( hdaSelector + ' ' + this.historypanel.data.selectors.hda.body ) === desiredClosed ){ + this.click( hdaSelector + ' ' + this.historypanel.data.selectors.hda.title ); + //NOTE: then is executed in the top frame + //TODO: magic number + this.wait( 500, then ); + + // otherwise, just call then + } else if( then ){ + then.call( this ); + } + }); + return this.spaceghost; +}; + +/** Collapses an HDA by clicking the title (does nothing if already collapsed). + * NOTE: is more than one Casper step. + * @param {String} hdaSelector a css or xpath selector for an historyItemWrapper + * @param {Function} then function called when the change is made + */ +HistoryPanel.prototype.thenCollapseHda = function thenCollapseHda( hdaSelector, then ){ + return this._thenExpandOrCollapseHda( hdaSelector, then, true ); +}; + +/** Expands an HDA by clicking the title (does nothing if already expanded). + * NOTE: is more than one Casper step. + * @param {String} hdaSelector a css or xpath selector for an historyItemWrapper + * @param {Function} then function called when the change is made + */ +HistoryPanel.prototype.thenExpandHda = function thenExpandHda( hdaSelector, then ){ + return this._thenExpandOrCollapseHda( hdaSelector, then, false ); +}; + /** Deletes an hda by finding an hda with the given title and clicking on the delete icon. * NOTE: if more than one is found, the first found will be deleted. * NOTE: is more than one Casper step. diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/modules/tools.js --- a/test/casperjs/modules/tools.js +++ b/test/casperjs/modules/tools.js @@ -29,7 +29,8 @@ */ // =================================================================== INTERNAL -var xpath = require( 'casper' ).selectXPath; +var require = patchRequire( require ), + xpath = require( 'casper' ).selectXPath; // ------------------------------------------------------------------- get avail. tools // list available tools @@ -158,9 +159,6 @@ filename = this.filenameFromFilepath( filepath ), uploadInfo = {}; - // precondition: filepath is relative to scriptDir - filepath = spaceghost.options.scriptDir + filepath; - spaceghost.info( 'uploading file: ' + filepath + ' (timeout after ' + timeoutAfterMs + ')' ); this._uploadFile( filepath ); @@ -183,31 +181,22 @@ // the hpanel should refresh and display the uploading file, wait for that to go into the ok state // throw if uploaded HDA doesn't appear, or it doesn't move to 'ok' after allotted time - spaceghost.historypanel.waitForHdas( function afterHpanelRefresh(){ + //spaceghost.historypanel.waitForHdas() + spaceghost.historypanel.waitForHda( filename, + // success: update the upload info and run callback + function whenInStateFn( newHdaInfo ){ + this.info( 'Upload complete: ' + newHdaInfo.text ); + uploadInfo.hdaElement = newHdaInfo; + callback.call( spaceghost, uploadInfo ); + }, + function timeoutFn( newHdaInfo ){ + this.warning( 'timeout waiting for upload: ' + filename + ', ' + this.jsonStr( newHdaInfo ) ); + throw new spaceghost.GalaxyError( 'Upload Error: timeout waiting for ok state: ' + + '"' + uploadInfo.filepath + '" (waited ' + timeoutAfterMs + ' ms)' ); + }, + timeoutAfterMs + ); - var hdaElement = this.historypanel.hdaElementInfoByTitle( uploadInfo.filename ); - if( hdaElement === null ){ - var hdaContainer = this.historypanel.data.selectors.hdaContainer; - this.warning( 'Upload Error: ' + hdaContainer + ':\n' + this.getHTML( hdaContainer ) ); - throw new this.GalaxyError( 'Upload Error: uploaded file HDA not found: ' + uploadInfo.filename ); - } - this.debug( 'uploaded HDA element: ' + this.jsonStr( this.quickInfo( hdaElement ) ) ); - uploadInfo.hdaElement = hdaElement; - - this.historypanel.waitForHdaState( '#' + uploadInfo.hdaElement.attributes.id, 'ok', - // success: update the upload info and run callback - function whenInStateFn( newHdaInfo ){ - this.info( 'Upload complete: ' + newHdaInfo.text ); - uploadInfo.hdaElement = newHdaInfo; - callback.call( spaceghost, uploadInfo ); - - }, function timeoutFn( newHdaInfo ){ - this.warning( 'timeout waiting for upload:\n' + this.jsonStr( this.quickInfo( newHdaInfo ) ) ); - throw new spaceghost.GalaxyError( 'Upload Error: timeout waiting for ok state: ' - + '"' + uploadInfo.filepath + '" (waited ' + timeoutAfterMs + ' ms)' ); - - }, timeoutAfterMs ); - }); return spaceghost; }; //TODO: upload via url diff -r bf48c28d0e1adcd7d0faa229d2d50f980c9167b6 -r b7d3d55c5ee80d4d092093b3d694ff9a4c23db41 test/casperjs/modules/user.js --- a/test/casperjs/modules/user.js +++ b/test/casperjs/modules/user.js @@ -21,7 +21,8 @@ // =================================================================== INTERNAL -var xpath = require( 'casper' ).selectXPath; +var require = patchRequire( require ), + xpath = require( 'casper' ).selectXPath; /** Tests registering a new user on the Galaxy instance by submitting the registration form. * NOTE: this version does NOT throw an error on a bad registration. This diff is so big that we needed to truncate the remainder. 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.