Merge Upload UI Enhancements from JCabral

This commit is contained in:
Dannon Baker
2015-01-23 10:59:45 -05:00
8 changed files with 213 additions and 20 deletions
+80 -11
View File
@@ -35,6 +35,7 @@ return Backbone.View.extend({
// fill table
_fill: function(ftp_files) {
var self = this;
if (ftp_files && ftp_files.length > 0) {
// add table
this.$el.find('#upload-ftp-content').html($(this._templateTable()));
@@ -49,11 +50,43 @@ return Backbone.View.extend({
// update stats
this.$el.find('#upload-ftp-number').html(ftp_files.length + ' files');
this.$el.find('#upload-ftp-disk').html(Utils.bytesToString (size, true));
var selectAll = this.$el.find('#selectAll');
// call method to determine and set selectAll status on loading
this._updateSelectAll(selectAll);
// selectAll checkbox has been clicked
selectAll.on('click', function() {
var checkboxes=$(this).parents().find('tr.upload-ftp-row>td>div');
var len = checkboxes.length;
$this = $(this);
var allChecked = !($this.hasClass('fa-check-square-o'));
// change state of the sub-checkboxes
for(i = 0; i < len; i++) {
if(allChecked) {
// all checkboxes should be checked
if(checkboxes.eq(i).hasClass('fa-square-o')) {
// if they are not checked, check them
checkboxes.eq(i).trigger('updateUpBox');
}
} else {
// no checkboxes should be checked
if(checkboxes.eq(i).hasClass('fa-check-square-o')) {
// if they are checked, uncheck them
checkboxes.eq(i).trigger('updateUpBox');
}
}
}
self._updateSelectAll(selectAll);
});
} else {
// add info
this.$el.find('#upload-ftp-content').html($(this._templateInfo()));
}
// hide spinner
this.$el.find('#upload-ftp-wait').hide();
},
@@ -79,18 +112,18 @@ return Backbone.View.extend({
} else {
icon_class = this.options.class_add;
}
// add icon class
$icon.addClass(icon_class);
// click to add ftp files
$it.on('click', function() {
// add files to the uploadbox
$it.on('updateUpBox', function() {
// find model
var model_index = self._find(ftp_file);
// update icon
$icon.removeClass();
// add model
if (!model_index) {
// add to uploadbox
@@ -100,19 +133,55 @@ return Backbone.View.extend({
size : ftp_file.size,
path : ftp_file.path
}]);
// add new icon class
$icon.addClass(self.options.class_remove);
} else {
// remove
self.app.collection.remove(model_index);
// add new icon class
$icon.addClass(self.options.class_add);
}
});
// click to add ftp files
$it.on('click', function() {
//trigger my new event
$icon.trigger('updateUpBox');
// click to add ftp files
// modify selectAll box based on number of checkboxes checked
var selectBox=$icon.parents().find('#selectAll');
// determine and set state of selectAll after sub-checkbox clicked
self._updateSelectAll(selectBox);
});
},
_updateSelectAll: function(selectBox) {
// array of all checkboxes
var checkboxes=selectBox.parents().find('tr.upload-ftp-row>td>div');
// array of only checked checkboxes
var checkedCheckboxes=selectBox.parents().find('tr.upload-ftp-row>td>div.fa-check-square-o');
var lenAll = checkboxes.length;
var lenChecked = checkedCheckboxes.length;
// determine which state the selectAll checkbox needs to be and setting it
if(lenChecked > 0 && lenChecked !== lenAll) {
// indeterminate state
selectBox.removeClass('fa-square-o fa-check-square-o');
selectBox.addClass('fa-minus-square-o');
} else if(lenChecked === lenAll) {
// checked state
selectBox.removeClass('fa-square-o fa-minus-square-o');
selectBox.addClass('fa-check-square-o');
} else if(lenChecked === 0) {
// unchecked state
selectBox.removeClass('fa-check-square-o fa-minus-square-o');
selectBox.addClass('fa-square-o');
}
},
// get model index
_find: function(ftp_file) {
// check if exists already
@@ -149,7 +218,7 @@ return Backbone.View.extend({
'<table class="grid" style="float: left;">' +
'<thead>' +
'<tr>' +
'<th></th>' +
'<th><div id="selectAll" class="upload-icon-button fa fa-square-o" ></th>' +
'<th>Name</th>' +
'<th>Size</th>' +
'<th>Created</th>' +
@@ -14,6 +14,7 @@ var Model = Backbone.Model.extend({
file_type : null,
file_path : '',
percentage : 0,
row : null,
// settings
space_to_tabs : false,
+18 -1
View File
@@ -42,6 +42,9 @@ return Backbone.View.extend({
// link app
this.app = app;
// default value for extension of files
var default_ext = 'Auto-detect';
// link this
var self = this;
@@ -75,15 +78,28 @@ return Backbone.View.extend({
// initialize genome
this.model.set('genome', self.select_genome.value());
// ensure files added after an individual row has changed
// default to Auto-detect instead of ---
if(!(this.app.select_extension.value() === '---')){
this.default_ext = this.app.select_extension.value();
}
// select extension
this.select_extension = new Select.View({
css: 'extension',
onchange : function() {
self.model.set('extension', self.select_extension.value());
// if user has changed individual row type, then change "set all"
// type to '---'
if(!(self.select_extension.value() === app.select_extension.value()))
{
var newExte = '---';
app.select_extension.value(newExte);
}
},
data: self.app.list_extensions,
container: it.find('#extension'),
value: self.model.get('extension')
value: self.default_ext
});
// initialize extension
@@ -139,6 +155,7 @@ return Backbone.View.extend({
this.app.collection.on('reset', function() {
self.remove();
});
self.model.set('row', self);
},
// render
+104 -4
View File
@@ -6,6 +6,7 @@ define(["utils/utils",
"mvc/upload/upload-ftp",
"mvc/ui/ui-popover",
"mvc/ui/ui-modal",
"mvc/ui/ui-select",
"utils/uploadbox"],
function( Utils,
@@ -14,7 +15,8 @@ define(["utils/utils",
UploadItem,
UploadFtp,
Popover,
Modal
Modal,
Select
) {
// galaxy upload
@@ -35,6 +37,9 @@ return Backbone.View.extend({
// current history
current_history: null,
// extension selector
select_extension : null,
// current upload size
upload_size: 0,
@@ -119,11 +124,19 @@ return Backbone.View.extend({
description_url : datatypes[key].description_url
});
}
// sort
self.list_extensions.sort(function(a, b) {
return a.id > b.id ? 1 : a.id < b.id ? -1 : 0;
});
// add the '---' extension for use when the row types are changed individually
self.list_extensions.push({
id : "---",
text : "---",
description : "",
description_url : ""
});
// add auto field
if (!self.options.datatypes_disable_auto) {
@@ -218,6 +231,29 @@ return Backbone.View.extend({
title : 'FTP files',
container : button
});
// select extension
this.select_extension = new Select.View({
css: 'extension',
onchange : function() {
var newExten = self.select_extension.value()
var len = self.collection.models.length;
// Only trigger changing the rows if the "set all" isn't set to '---'
// Prevents recursively changing the rows after an individual row has been changed
if(!(newExten === '---')){
for(i = 0; i < len; i++){
self.collection.models[i].attributes['row'].select_extension.value(newExten);
}
}
},
data: self.list_extensions,
container: self.$el.parents().find('#extension'),
value: self.list_extensions[0]
});
// handle extension info popover
self.$el.parents().find('#extension-info_out').on('click' , function(e) { self._showExtensionInfo(); })
.on('mousedown', function(e) { e.preventDefault(); });
}
// show modal
@@ -230,6 +266,60 @@ return Backbone.View.extend({
this._updateScreen();
},
_showExtensionInfo : function() {
// initialize
var self = this;
var $el = $(this.el).parents().find('#extension-info_out');
var extension = self.select_extension.value();
var title = this.select_extension.text();
var description = _.findWhere(self.list_extensions, {'id': extension});
// create popup
if (!this.extension_popup) {
this.extension_popup = new Popover.View({
placement: 'bottom',
container: $el
});
}
// show / hide popup
if (!this.extension_popup.visible) {
this.extension_popup.title(title);
this.extension_popup.empty();
this.extension_popup.append(this._templateDescription(description));
this.extension_popup.show();
} else {
this.extension_popup.hide();
}
},
_showSettings : function() {
// check if popover is visible
if (!this.settings.visible) {
// show popover
this.settings.empty();
this.settings.append((new UploadSettings(this)).$el);
this.settings.show();
} else {
// hide popover
this.settings.hide();
}
},
_templateDescription: function(options) {
if (options.description) {
var tmpl = options.description;
if (options.description_url) {
tmpl += '&nbsp;(<a href="' + options.description_url + '" target="_blank">read more</a>)';
}
return tmpl;
} else {
return 'There is no description available for this file extension.';
}
},
//
// events triggered by collection
//
@@ -513,6 +603,9 @@ return Backbone.View.extend({
// remove from queue
this.uploadbox.reset();
// reset value for universal type drop-down
this.select_extension.value(this.list_extensions[0]);
// reset button
this.ui_button.set('percentage', 0);
@@ -606,7 +699,12 @@ return Backbone.View.extend({
// load html template
_template: function(id, idInfo) {
return '<div id="' + id + '" class="upload-box">' +
return '<div id="uploadhead" class="uploadhead">' +
'<span class="fftext">"Set All" Types:&nbsp;&nbsp</span>' +
'<span id="extension" class="extension"/>&nbsp;&nbsp' +
'<span id="extension-info_out" class="upload-icon-button fa fa-search"/> ' +
'</div>' +
'<div id="' + id + '" class="upload-box">' +
'<table id="upload-table" class="table table-striped" style="display: none;">' +
'<thead>' +
'<tr>' +
@@ -622,7 +720,9 @@ return Backbone.View.extend({
'<tbody></tbody>' +
'</table>' +
'</div>' +
'<h6 id="' + idInfo + '" class="upload-info"></h6>';
'<div class="uploadfoot">' +
'<h6 id="' + idInfo + '" class="upload-info"></h6>' +
'</div>' ;
}
});
@@ -1 +1 @@
define(["utils/utils"],function(a){return Backbone.View.extend({options:{class_add:"upload-icon-button fa fa-square-o",class_remove:"upload-icon-button fa fa-check-square-o"},initialize:function(c){this.app=c;var b=this;this.setElement(this._template());a.get({url:galaxy_config.root+"api/ftp_files",success:function(d){b._fill(d)},error:function(){b._fill()}})},events:{mousedown:function(b){b.preventDefault()}},_fill:function(c){if(c&&c.length>0){this.$el.find("#upload-ftp-content").html($(this._templateTable()));var b=0;for(key in c){this.add(c[key]);b+=c[key].size}this.$el.find("#upload-ftp-number").html(c.length+" files");this.$el.find("#upload-ftp-disk").html(a.bytesToString(b,true))}else{this.$el.find("#upload-ftp-content").html($(this._templateInfo()))}this.$el.find("#upload-ftp-wait").hide()},add:function(f){var d=this;var e=$(this._templateRow(f));var b=e.find(".icon");$(this.el).find("tbody").append(e);var c="";if(this._find(f)){c=this.options.class_remove}else{c=this.options.class_add}b.addClass(c);e.on("click",function(){var g=d._find(f);b.removeClass();if(!g){d.app.uploadbox.add([{mode:"ftp",name:f.path,size:f.size,path:f.path}]);b.addClass(d.options.class_remove)}else{d.app.collection.remove(g);b.addClass(d.options.class_add)}})},_find:function(f){var c=this.app.collection.where({file_path:f.path});var b=null;for(var d in c){var e=c[d];if(e.get("status")=="init"&&e.get("file_mode")=="ftp"){b=e.get("id")}}return b},_templateRow:function(b){return'<tr class="upload-ftp-row" style="cursor: pointer;"><td><div class="icon"/></td><td style="width: 200px"><p style="width: inherit; word-wrap: break-word;">'+b.path+'</p></td><td style="white-space: nowrap;">'+a.bytesToString(b.size)+'</td><td style="white-space: nowrap;">'+b.ctime+"</td></tr>"},_templateTable:function(){return'<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 id="upload-ftp-number"/>&nbsp;&nbsp;<span class="upload-icon fa fa-hdd-o"/><span id="upload-ftp-disk"/></span><table class="grid" style="float: left;"><thead><tr><th></th><th>Name</th><th>Size</th><th>Created</th></tr></thead><tbody></tbody></table>'},_templateInfo:function(){return'<div class="upload-ftp-warning warningmessage">Your FTP directory does not contain any files.</div>'},_template:function(){return'<div class="upload-ftp"><div id="upload-ftp-wait" 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.app.options.ftp_upload_site+'</strong> using your Galaxy credentials (email address and password).</div><div id="upload-ftp-content"></div><div>'}})});
define(["utils/utils"],function(e){return Backbone.View.extend({options:{class_add:"upload-icon-button fa fa-square-o",class_remove:"upload-icon-button fa fa-check-square-o"},initialize:function(t){this.app=t;var n=this;this.setElement(this._template()),e.get({url:galaxy_config.root+"api/ftp_files",success:function(e){n._fill(e)},error:function(){n._fill()}})},events:{mousedown:function(e){e.preventDefault()}},_fill:function(t){var n=this;if(t&&t.length>0){this.$el.find("#upload-ftp-content").html($(this._templateTable()));var r=0;for(key in t)this.add(t[key]),r+=t[key].size;this.$el.find("#upload-ftp-number").html(t.length+" files"),this.$el.find("#upload-ftp-disk").html(e.bytesToString(r,!0));var s=this.$el.find("#selectAll");this._updateSelectAll(s),s.on("click",function(){var e=$(this).parents().find("tr.upload-ftp-row>td>div"),t=e.length;$this=$(this);var r=!$this.hasClass("fa-check-square-o");for(i=0;i<t;i++)r?e.eq(i).hasClass("fa-square-o")&&e.eq(i).trigger("updateUpBox"):e.eq(i).hasClass("fa-check-square-o")&&e.eq(i).trigger("updateUpBox");n._updateSelectAll(s)})}else this.$el.find("#upload-ftp-content").html($(this._templateInfo()));this.$el.find("#upload-ftp-wait").hide()},add:function(e){var t=this,n=$(this._templateRow(e)),r=n.find(".icon");$(this.el).find("tbody").append(n);var i="";this._find(e)?i=this.options.class_remove:i=this.options.class_add,r.addClass(i),n.on("updateUpBox",function(){var n=t._find(e);r.removeClass(),n?(t.app.collection.remove(n),r.addClass(t.options.class_add)):(t.app.uploadbox.add([{mode:"ftp",name:e.path,size:e.size,path:e.path}]),r.addClass(t.options.class_remove))}),n.on("click",function(){r.trigger("updateUpBox");var e=r.parents().find("#selectAll");t._updateSelectAll(e)})},_updateSelectAll:function(e){var t=e.parents().find("tr.upload-ftp-row>td>div"),n=e.parents().find("tr.upload-ftp-row>td>div.fa-check-square-o"),r=t.length,i=n.length;i>0&&i!==r?(e.removeClass("fa-square-o fa-check-square-o"),e.addClass("fa-minus-square-o")):i===r?(e.removeClass("fa-square-o fa-minus-square-o"),e.addClass("fa-check-square-o")):i===0&&(e.removeClass("fa-check-square-o fa-minus-square-o"),e.addClass("fa-square-o"))},_find:function(e){var t=this.app.collection.where({file_path:e.path}),n=null;for(var r in t){var i=t[r];i.get("status")=="init"&&i.get("file_mode")=="ftp"&&(n=i.get("id"))}return n},_templateRow:function(t){return'<tr class="upload-ftp-row" style="cursor: pointer;"><td><div class="icon"/></td><td style="width: 200px"><p style="width: inherit; word-wrap: break-word;">'+t.path+"</p></td>"+'<td style="white-space: nowrap;">'+e.bytesToString(t.size)+"</td>"+'<td style="white-space: nowrap;">'+t.ctime+"</td>"+"</tr>"},_templateTable:function(){return'<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 id="upload-ftp-number"/>&nbsp;&nbsp;<span class="upload-icon fa fa-hdd-o"/><span id="upload-ftp-disk"/></span><table class="grid" style="float: left;"><thead><tr><th><div id="selectAll" class="upload-icon-button fa fa-square-o" ></th><th>Name</th><th>Size</th><th>Created</th></tr></thead><tbody></tbody></table>'},_templateInfo:function(){return'<div class="upload-ftp-warning warningmessage">Your FTP directory does not contain any files.</div>'},_template:function(){return'<div class="upload-ftp"><div id="upload-ftp-wait" 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.app.options.ftp_upload_site+"</strong> using your Galaxy credentials (email address and password).</div>"+'<div id="upload-ftp-content"></div>'+"<div>"}})});
@@ -1 +1 @@
define([],function(){var b=Backbone.Model.extend({defaults:{extension:"auto",genome:"?",url_paste:"",status:"init",info:null,file_mode:"local",file_size:0,file_type:null,file_path:"",percentage:0,space_to_tabs:false,to_posix_lines:true}});var a=Backbone.Collection.extend({model:b});return{Model:b,Collection:a}});
define([],function(){var e=Backbone.Model.extend({defaults:{extension:"auto",genome:"?",url_paste:"",status:"init",info:null,file_mode:"local",file_size:0,file_type:null,file_path:"",percentage:0,row:null,space_to_tabs:!1,to_posix_lines:!0}}),t=Backbone.Collection.extend({model:e});return{Model:e,Collection:t}});
File diff suppressed because one or more lines are too long
+7 -1
View File
@@ -119,6 +119,12 @@ th{text-align:left}
.table caption+thead tr:first-child th,.table colgroup+thead tr:first-child th,.table thead:first-child tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child td{border-top:0}
.table tbody+tbody{border-top:2px solid #d6b161}
.table .table{background-color:#fff}
.uploadhead{height:10%; text-align:left; max-height:20px; line-height:18px; margin-bottom: 5px;}
.uploadfoot{height:5%; text-align:center;}
.uploadhead .fftext{font-weight: bold;}
.uploadhead .select2-container .select2-choice .select2-arrow b{background-position:0 -3px}
.uploadhead .extension{width:100px;min-width:100px;font-size:11px}
.uploadhead .select2-container .select2-choice{max-height:20px;line-height:18px;text-align:center; font-weight: normal;}
.table-condensed thead>tr>th,.table-condensed tbody>tr>th,.table-condensed tfoot>tr>th,.table-condensed thead>tr>td,.table-condensed tbody>tr>td,.table-condensed tfoot>tr>td{padding:5px}
.table-bordered{border:1px solid #d6b161}.table-bordered>thead>tr>th,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>tbody>tr>td,.table-bordered>tfoot>tr>td{border:1px solid #d6b161}
.table-bordered>thead>tr>th,.table-bordered>thead>tr>td{border-bottom-width:2px}
@@ -1370,7 +1376,7 @@ label{font-weight:normal}
.upload-icon{font-size:1.2em;width:1.2em}
.upload-icon-button{font-size:1.2em;width:1.2em;cursor:pointer}
.upload-info{font-weight:normal;text-align:center}
.upload-box{width:100%;height:95%;text-align:center;overflow:scroll;font-size:12px;line-height:1.33;-moz-border-radius:5px;border-radius:5px;border:1px dashed #bfbfbf;padding:10px;overflow-x:hidden;-ms-overflow-style:none}.upload-box .table{width:100%}
.upload-box{width:100%;height:85%;text-align:center;overflow:scroll;font-size:12px;line-height:1.33;-moz-border-radius:5px;border-radius:5px;border:1px dashed #bfbfbf;padding:10px;overflow-x:hidden;-ms-overflow-style:none}.upload-box .table{width:100%}
.upload-box .table th{text-align:center;white-space:nowrap}
.upload-box .table td{margin:0px}
.upload-box .upload-item .select2-arrow b{background-position:0 -3px}