Files
galaxy/static/scripts/mvc/upload/upload-ftp.js
T

2 lines
3.7 KiB
JavaScript

define(["utils/utils"],function(a){return Backbone.View.extend({initialize:function(b){this.options=a.merge(b,{css:"upload-ftp",class_add:"upload-icon-button fa fa-square-o",class_remove:"upload-icon-button fa fa-check-square-o",class_partial:"upload-icon-button fa fa-minus-square-o",collection:null,onchange:function(){},onadd:function(){},onremove:function(){}}),this.collection=this.options.collection,this.setElement(this._template()),this.$content=this.$(".upload-ftp-content"),this.$wait=this.$(".upload-ftp-wait"),this.$help=this.$(".upload-ftp-help"),this.$number=this.$(".upload-ftp-number"),this.$disk=this.$(".upload-ftp-disk"),this.$body=this.$(".upload-ftp-body"),this.$warning=this.$(".upload-ftp-warning"),this.$select=this.$(".upload-ftp-select-all"),this.render()},render:function(){var a=this;this.$wait.show(),this.$content.hide(),this.$warning.hide(),this.$help.hide(),$.ajax({url:Galaxy.root+"api/remote_files",method:"GET",success:function(b){a._renderTable(b)},error:function(){a._renderTable()}})},_renderTable:function(b){if(this.rows=[],b&&b.length>0){this.$body.empty();var c=0;for(var d in b)this.rows.push(this._add(b[d])),c+=b[d].size;if(this.$number.html(b.length+" files"),this.$disk.html(a.bytesToString(c,!0)),this.collection){var e=this;this.$("._has_collection").show(),this.$select.addClass(this.options.class_add).on("click",function(){var a=e.$select.hasClass(e.options.class_add);for(var c in b){var d=b[c],f=e._find(d);(!f&&a||f&&!a)&&e.rows[c].trigger("click")}}),this._refresh()}this.$content.show()}else this.$warning.show();this.$help.show(),this.$wait.hide()},_add:function(a){var b=this,c=$(this._templateRow(a)),d=c.find(".icon");return this.$body.append(c),this.collection?(d.addClass(this._find(a)?this.options.class_remove:this.options.class_add),c.on("click",function(){var c=b._find(a);d.removeClass(),c?(b.options.onremove(c),d.addClass(b.options.class_add)):(b.options.onadd(a),d.addClass(b.options.class_remove)),b._refresh()})):c.on("click",function(){b.options.onchange(a)}),c},_refresh:function(){var a=this.collection.where({file_mode:"ftp",enabled:!0});this.$select.removeClass(),this.$select.addClass(0==a.length?this.options.class_add:a.length==this.rows.length?this.options.class_remove:this.options.class_partial)},_find:function(a){var b=this.collection.findWhere({file_path:a.path,file_mode:"ftp",enabled:!0});return b&&b.get("id")},_templateRow:function(b){return'<tr class="upload-ftp-row"><td class="_has_collection" style="display: none;"><div class="icon"/></td><td class="ftp-name">'+_.escape(b.path)+'</td><td class="ftp-size">'+a.bytesToString(b.size)+'</td><td class="ftp-time">'+b.ctime+"</td></tr>"},_template:function(){return'<div class="'+this.options.css+'"><div class="upload-ftp-wait fa fa-spinner fa-spin"/><div class="upload-ftp-help">This Galaxy server allows you to upload files via FTP. To upload some files, log in to the FTP server at <strong>'+this.options.ftp_upload_site+'</strong> using your Galaxy credentials (email address and password).</div><div class="upload-ftp-content"><span style="whitespace: nowrap; float: left;">Available files: </span><span style="whitespace: nowrap; float: right;"><span class="upload-icon fa fa-file-text-o"/><span class="upload-ftp-number"/>&nbsp;&nbsp;<span class="upload-icon fa fa-hdd-o"/><span class="upload-ftp-disk"/></span><table class="grid" style="float: left;"><thead><tr><th class="_has_collection" style="display: none;"><div class="upload-ftp-select-all"></th><th>Name</th><th>Size</th><th>Created</th></tr></thead><tbody class="upload-ftp-body"/></table></div><div class="upload-ftp-warning warningmessage">Your FTP directory does not contain any files.</div>'}})});
//# sourceMappingURL=../../../maps/mvc/upload/upload-ftp.js.map