diff --git a/lib/galaxy/webapps/galaxy/api/folders.py b/lib/galaxy/webapps/galaxy/api/folders.py
index 2a70713f5f3..6c086334326 100644
--- a/lib/galaxy/webapps/galaxy/api/folders.py
+++ b/lib/galaxy/webapps/galaxy/api/folders.py
@@ -2,11 +2,12 @@
API operations on folders
"""
import logging, os, string, shutil, urllib, re, socket, traceback
-from cgi import escape, FieldStorage
-from galaxy import util, datatypes, jobs, web, util
-from galaxy.web.base.controller import *
+from galaxy import datatypes, jobs, web, security
+from galaxy.web.base.controller import BaseAPIController,UsesLibraryMixin,UsesLibraryMixinItems
from galaxy.util.sanitize_html import sanitize_html
-from galaxy.model.orm import *
+
+from cgi import escape, FieldStorage
+from paste.httpexceptions import HTTPBadRequest
log = logging.getLogger( __name__ )
@@ -24,8 +25,13 @@ class FoldersController( BaseAPIController, UsesLibraryMixin, UsesLibraryMixinIt
@web.expose_api
def show( self, trans, id, **kwd ):
"""
- GET /api/folders/{encoded_folder_id}
- Displays information about a folder
+ show( self, trans, id, **kwd )
+ *GET /api/folders/{encoded_folder_id}
+
+ Displays information about a folder.
+
+ :param encoded_parent_folder_id: the parent folder's id (required)
+ :type encoded_parent_folder_id: an encoded id string (should be prefixed by 'F')
"""
# Eliminate any 'F' in front of the folder id. Just take the
# last 16 characters:
@@ -38,59 +44,64 @@ class FoldersController( BaseAPIController, UsesLibraryMixin, UsesLibraryMixinIt
return self.encode_all_ids( trans, content.to_dict( view='element' ) )
@web.expose_api
- def create( self, trans, payload, **kwd ):
- """
- POST /api/folders/{encoded_folder_id}
- Create a new object underneath the one specified in the parameters.
- This will use the same parameters and semantics as
- /api/libraries/{LibID}/contents/{ContentId} for consistency.
- This means that datasets and folders can be generated. Note that
- /api/libraries/{LibID}/contents/{ContentId} did not need the library
- id to function properly, which is why this functionality has been
- moved here.
+ def create( self, trans, encoded_parent_folder_id, **kwd ):
- o payload's relevant params:
- - folder_id: This is the parent folder's id (required)
- """
-# log.debug( "FoldersController.create: enter" )
- # TODO: Create a single point of exit if possible. For now we only
- # exit at the end and on exceptions.
- if 'folder_id' not in payload:
- trans.response.status = 400
- return "Missing requred 'folder_id' parameter."
- else:
- folder_id = payload.pop( 'folder_id' )
- class_name, folder_id = self.__decode_library_content_id( trans, folder_id )
+ # is_admin = trans.user_is_admin()
+ # current_user_roles = trans.get_current_user_roles()
+ """
+ create( self, trans, encoded_parent_folder_id, **kwd )
+ *POST /api/folders/{encoded_parent_folder_id}
+
+ Create a new folder object underneath the one specified in the parameters.
+
+ :param encoded_parent_folder_id: the parent folder's id (required)
+ :type encoded_parent_folder_id: an encoded id string (should be prefixed by 'F')
+ :param name: the name of the new folder (required)
+ :type name: str
+ :param description: the description of the new folder
+ :type description: str
+
+ :rtype: dictionary
+ :returns: information about newly created folder, notably including ID
+
+ :raises: HTTPBadRequest, MessageException
+ """
+
+ payload = kwd.get('payload', None)
+ if payload == None:
+ raise HTTPBadRequest( detail="Missing required parameters 'encoded_parent_folder_id' and 'name'." )
+
+ name = payload.get('name', None)
+ description = payload.get('description', '')
+ if encoded_parent_folder_id == None:
+ raise HTTPBadRequest( detail="Missing required parameter 'encoded_parent_folder_id'." )
+ elif name == None:
+ raise HTTPBadRequest( detail="Missing required parameter 'name'." )
+
+ # encoded_parent_folder_id may be prefixed by 'F'
+ encoded_parent_folder_id = self.__cut_the_prefix( encoded_parent_folder_id )
+
+ # if ( len( encoded_parent_folder_id ) == 17 and encoded_parent_folder_id.startswith( 'F' ) ):
+ # encoded_parent_folder_id = encoded_parent_folder_id[-16:]
+
try:
- # security is checked in the downstream controller
- parent_folder = self.get_library_folder( trans, folder_id, check_ownership=False, check_accessible=False )
- except Exception, e:
- return str( e )
+ decoded_parent_folder_id = trans.security.decode_id( encoded_parent_folder_id )
+ except:
+ raise MessageException( "Malformed folder id ( %s ) specified, unable to decode" % ( str( id ) ), type='error' )
- real_parent_folder_id = trans.security.encode_id( parent_folder.id )
-
- # Note that this will only create a folder; the library_contents will
- # also allow files to be generated, though that encompasses generic
- # contents:
- # TODO: reference or change create_folder, which points to the
- # library browsing; we just want to point to the /api/folders URI.
- status, output = trans.webapp.controllers['library_common'].create_folder( trans, 'api', real_parent_folder_id, '', **payload )
+ # TODO: refactor the functionality for use here instead of calling another controller
+ params = dict( [ ( "name", name ), ( "description", description ) ] )
+ status, output = trans.webapp.controllers['library_common'].create_folder( trans, 'api', encoded_parent_folder_id, '', **params )
rval = []
-
- # SM: When a folder is successfully created:
- # - get all of the created folders. We know that they're
- # folders, so prepend an "F" to them.
if 200 == status:
for k, v in output.items():
if type( v ) == trans.app.model.LibraryDatasetDatasetAssociation:
v = v.library_dataset
encoded_id = 'F' + trans.security.encode_id( v.id )
rval.append( dict( id = encoded_id,
- name = v.name,
- url = url_for( 'folder', id=encoded_id ) ) )
+ name = v.name ) )
else:
-# log.debug( "Error creating folder; setting output and status" )
trans.response.status = status
rval = output
return rval
@@ -105,12 +116,9 @@ class FoldersController( BaseAPIController, UsesLibraryMixin, UsesLibraryMixinIt
"""
pass
- # TODO: Move this to library_common. This doesn't really belong in any
- # of the other base controllers.
- def __decode_library_content_id( self, trans, content_id ):
- if ( len( content_id ) % 16 == 0 ):
- return 'LibraryDataset', content_id
- elif ( content_id.startswith( 'F' ) ):
- return 'LibraryFolder', content_id[1:]
+ def __cut_the_prefix(self, encoded_id):
+ if ( len( encoded_id ) == 17 and encoded_id.startswith( 'F' ) ):
+ return encoded_id[-16:]
else:
- raise HTTPBadRequest( 'Malformed library content id ( %s ) specified, unable to decode.' % str( content_id ) )
+ return encoded_id
+
diff --git a/lib/galaxy/webapps/galaxy/api/libraries.py b/lib/galaxy/webapps/galaxy/api/libraries.py
index 96b2693b5cb..8552148b095 100644
--- a/lib/galaxy/webapps/galaxy/api/libraries.py
+++ b/lib/galaxy/webapps/galaxy/api/libraries.py
@@ -1,13 +1,13 @@
"""
-API operations on a library.
+API operations on a data library.
"""
-import logging
from galaxy import util
from galaxy import web
from galaxy.model.orm import and_, not_, or_
from galaxy.web.base.controller import BaseAPIController, url_for
from paste.httpexceptions import HTTPBadRequest, HTTPForbidden
+import logging
log = logging.getLogger( __name__ )
class LibrariesController( BaseAPIController ):
@@ -17,18 +17,17 @@ class LibrariesController( BaseAPIController ):
"""
index( self, trans, deleted='False', **kwd )
* GET /api/libraries:
- returns a list of summary data for libraries
+ Returns a list of summary data for all libraries that are ``non-deleted``
* GET /api/libraries/deleted:
- returns a list of summary data for deleted libraries
+ Returns a list of summary data for ``deleted`` libraries.
+ :param deleted: if True, show only deleted libraries, if False, ``non-deleted``
:type deleted: boolean
- :param deleted: if True, show only deleted libraries, if False, non-deleted
:rtype: list
:returns: list of dictionaries containing library information
.. seealso:: :attr:`galaxy.model.Library.dict_collection_visible_keys`
"""
-# log.debug( "LibrariesController.index: enter" )
query = trans.sa_session.query( trans.app.model.Library )
deleted = util.string_as_bool( deleted )
if deleted:
@@ -47,34 +46,33 @@ class LibrariesController( BaseAPIController ):
trans.model.LibraryPermissions.table.c.role_id.in_( current_user_role_ids ) ) ) ]
query = query.filter( or_( not_( trans.model.Library.table.c.id.in_( restricted_library_ids ) ),
trans.model.Library.table.c.id.in_( accessible_restricted_library_ids ) ) )
- rval = []
+ libraries = []
for library in query:
item = library.to_dict( view='element' )
item['url'] = url_for( route, id=trans.security.encode_id( library.id ) )
item['id'] = 'F' + trans.security.encode_id( item['id'] )
item['root_folder_id'] = 'F' + trans.security.encode_id( item['root_folder_id'] )
- rval.append( item )
- return rval
+ libraries.append( item )
+ return libraries
@web.expose_api
def show( self, trans, id, deleted='False', **kwd ):
"""
show( self, trans, id, deleted='False', **kwd )
- * GET /api/libraries/{id}:
+ * GET /api/libraries/{encoded_id}:
returns detailed information about a library
- * GET /api/libraries/deleted/{id}:
- returns detailed information about a deleted library
+ * GET /api/libraries/deleted/{encoded_id}:
+ returns detailed information about a ``deleted`` library
- :type id: an encoded id string
:param id: the encoded id of the library
+ :type id: an encoded id string
+ :param deleted: if True, allow information on a ``deleted`` library
:type deleted: boolean
- :param deleted: if True, allow information on a deleted library
:rtype: dictionary
:returns: detailed library information
.. seealso:: :attr:`galaxy.model.Library.dict_element_visible_keys`
"""
-# log.debug( "LibraryContentsController.show: enter" )
library_id = id
deleted = util.string_as_bool( deleted )
try:
@@ -89,7 +87,6 @@ class LibrariesController( BaseAPIController ):
if not library or not ( trans.user_is_admin() or trans.app.security_agent.can_access_library( trans.get_current_user_roles(), library ) ):
raise HTTPBadRequest( detail='Invalid library id ( %s ) specified.' % id )
item = library.to_dict( view='element' )
- #item['contents_url'] = url_for( 'contents', library_id=library_id )
item['contents_url'] = url_for( 'library_contents', library_id=library_id )
return item
@@ -98,18 +95,17 @@ class LibrariesController( BaseAPIController ):
"""
create( self, trans, payload, **kwd )
* POST /api/libraries:
- create a new library
+ Creates a new library. Only ``name`` parameter is required.
.. note:: Currently, only admin users can create libraries.
- :type payload: dict
:param payload: (optional) dictionary structure containing::
'name': the new library's name
'description': the new library's description
'synopsis': the new library's synopsis
+ :type payload: dict
:rtype: dict
- :returns: a dictionary containing the id, name, and 'show' url
- of the new library
+ :returns: a dictionary containing the encoded_id, name, description, synopsis, and 'show' url of the new library
"""
if not trans.user_is_admin():
raise HTTPForbidden( detail='You are not authorized to create a new library.' )
@@ -127,13 +123,30 @@ class LibrariesController( BaseAPIController ):
trans.sa_session.add_all( ( library, root_folder ) )
trans.sa_session.flush()
encoded_id = trans.security.encode_id( library.id )
- rval = {}
- rval['url'] = url_for( 'library', id=encoded_id )
- rval['name'] = name
- rval['id'] = encoded_id
- return rval
+ new_library = {}
+ new_library['url'] = url_for( 'library', id=encoded_id )
+ new_library['name'] = name
+ new_library['description'] = description
+ new_library['synopsis'] = synopsis
+ new_library['id'] = encoded_id
+ return new_library
- def edit( self, trans, payload, **kwd ):
+ def edit( self, trans, encoded_id, payload, **kwd ):
+ """
+ * PUT /api/libraries/{encoded_id}
+ Updates the library defined by an ``encoded_id`` with the data in the payload.
+
+ .. note:: Currently, only admin users can edit libraries.
+
+ :param payload: (required) dictionary structure containing::
+ 'name': new library's name
+ 'description': new library's description
+ 'synopsis': new library's synopsis
+ :type payload: dict
+
+ :rtype: dict
+ :returns: a dictionary containing the encoded_id, name, description, synopsis, and 'show' url of the updated library
+ """
return "Not implemented yet"
@web.expose_api
@@ -142,10 +155,11 @@ class LibrariesController( BaseAPIController ):
delete( self, trans, id, **kwd )
* DELETE /api/histories/{id}
mark the library with the given ``id`` as deleted
+
.. note:: Currently, only admin users can delete libraries.
- :type id: str
:param id: the encoded id of the library to delete
+ :type id: str
:rtype: dictionary
:returns: detailed library information
diff --git a/lib/galaxy/webapps/galaxy/buildapp.py b/lib/galaxy/webapps/galaxy/buildapp.py
index 2ceaaaada51..a94658e0217 100644
--- a/lib/galaxy/webapps/galaxy/buildapp.py
+++ b/lib/galaxy/webapps/galaxy/buildapp.py
@@ -184,6 +184,12 @@ def app_factory( global_conf, **kwargs ):
action='download',
conditions=dict( method=[ "POST", "GET" ] ) )
+ webapp.mapper.connect( 'create_folder',
+ '/api/folders/:encoded_parent_folder_id',
+ controller='folders',
+ action='create',
+ conditions=dict( method=[ "POST" ] ) )
+
webapp.mapper.resource_with_deleted( 'library',
'libraries',
path_prefix='/api' )
@@ -196,7 +202,8 @@ def app_factory( global_conf, **kwargs ):
controller='folder_contents',
name_prefix='folder_',
path_prefix='/api/folders/:folder_id',
- parent_resources=dict( member_name='folder', collection_name='folders' ) )
+ parent_resources=dict( member_name='folder', collection_name='folders' ),
+ conditions=dict( method=[ "GET" ] ) )
webapp.mapper.resource( 'content',
'contents',
diff --git a/static/scripts/galaxy.library.js b/static/scripts/galaxy.library.js
index 486bbfca88d..17817ddbb3c 100644
--- a/static/scripts/galaxy.library.js
+++ b/static/scripts/galaxy.library.js
@@ -23,6 +23,11 @@ define([
urlRoot: '/api/libraries'
});
+ // FOLDER AS MODEL
+ var FolderAsModel = Backbone.Model.extend({
+ urlRoot: '/api/folders'
+ });
+
// LIBRARIES
var Libraries = Backbone.Collection.extend({
url: '/api/libraries',
@@ -34,7 +39,7 @@ define([
urlRoot : '/api/libraries/datasets'
})
- // FOLDER
+ // FOLDER AS COLLECTION
var Folder = Backbone.Collection.extend({
model: Item
})
@@ -316,7 +321,7 @@ var FolderContentView = Backbone.View.extend({
'click #toolbtn_bulk_import' : 'modalBulkImport',
'click #toolbtn_dl' : 'bulkDownload',
'click .library-dataset' : 'showDatasetDetails',
- 'click #toolbtn_create_folder' : 'createFolderModal',
+ 'click #toolbtn_create_folder' : 'createFolderFromModal',
'click .btn_open_folder' : 'navigateToFolder'
},
@@ -407,15 +412,15 @@ var FolderContentView = Backbone.View.extend({
// make modal
var self = this;
this.modal = new mod_modal.GalaxyModal({
+ destructible : true,
title : 'Dataset Details',
body : template,
buttons : {
'Import' : function() { self.importCurrentIntoHistory() },
'Download' : function() { self.downloadCurrent() },
- 'Close' : function() { self.modal.hide(); $('.modal').remove(); self.modal = null; } // TODO refill nicely modal with data
+ 'Close' : function() { self.modal.hideOrDestroy; self.modal = null; }
}
});
- this.modal.bindEvents(event);
$(".peek").html(item.get("peek"));
var history_footer_tmpl = _.template(this.templateHistorySelectInModal(), {histories : histories.models});
@@ -426,6 +431,7 @@ var FolderContentView = Backbone.View.extend({
$(this.modal.elMain).find('#dataset_import_single').val(self.lastSelectedHistory);
}
+ this.modal.bindEvents();
// show the prepared modal
this.modal.show();
},
@@ -563,14 +569,15 @@ var FolderContentView = Backbone.View.extend({
// make modal
var history_modal_tmpl = _.template(self.templateBulkImportInModal(), {histories : histories.models});
self.modal = new mod_modal.GalaxyModal({
+ destructible : true,
title : 'Import into History',
body : history_modal_tmpl,
buttons : {
'Import' : function() {self.importAllIntoHistory()},
- 'Close' : function() {self.modal.hide(); $('.modal').remove(); self.modal = null;}
+ 'Close' : function() {self.modal.hideOrDestroy; self.modal = null;}
}
});
- self.modal.bindEvents(event);
+ self.modal.bindEvents();
// show the prepared modal
self.modal.show();
}
@@ -693,9 +700,75 @@ var FolderContentView = Backbone.View.extend({
},
// shows modal for creating folder
- createFolderModal: function(){
- mod_toastr.info('This will create folder...in the future');
- }
+ createFolderFromModal: function(){
+ event.preventDefault();
+ event.stopPropagation();
+
+ // create modal
+ var self = this;
+ this.modal = new mod_modal.GalaxyModal({
+ destructible : true,
+ title : 'Create New Folder',
+ body : this.template_new_folder(),
+ buttons : {
+ 'Create' : function() {self.create_new_folder_event()},
+ 'Close' : function() {self.modal.destroy(); self.modal = null;}
+ }
+ });
+ this.modal.bindEvents();
+ // show prepared modal
+ this.modal.show();
+ },
+
+ // create the new folder from modal
+ create_new_folder_event: function(){
+ var folderDetails = this.serialize_new_folder();
+ if (this.validate_new_folder(folderDetails)){
+ var folder = new FolderAsModel();
+ folder.url = folder.urlRoot + '/F2fdbd5c5858e78fb' //load real ID
+ var self = this;
+ folder.save(folderDetails, {
+ success: function (folder) {
+ self.modal.destroy();
+ mod_toastr.success('Folder created');
+ self.render({id: 'F2fdbd5c5858e78fb'}); //put real id
+ },
+ error: function(){
+ mod_toastr.error('An error occured :(');
+ }
+ });
+ } else {
+ mod_toastr.error('Folder\'s name is missing');
+ }
+ return false;
+ },
+
+ // serialize data from the form
+ serialize_new_folder : function(){
+ return {
+ name: $("input[name='Name']").val(),
+ description: $("input[name='Description']").val()
+ };
+ },
+
+ // validate new library info
+ validate_new_folder: function(folderDetails){
+ return folderDetails.name !== '';
+ },
+
+ // template for new library modal
+ template_new_folder: function(){
+ tmpl_array = [];
+
+ tmpl_array.push('
');
+ tmpl_array.push('');
+ tmpl_array.push('
');
+
+ return tmpl_array.join('');
+ }
});
@@ -786,16 +859,16 @@ var GalaxyLibraryview = Backbone.View.extend({
// create modal
var self = this;
- this.modal = new mod_modal.GalaxyModal(
- {
+ this.modal = new mod_modal.GalaxyModal({
+ destructible : true,
title : 'Create New Library',
body : this.template_new_library(),
buttons : {
'Create' : function() {self.create_new_library_event()},
- 'Close' : function() {self.modal.hide()}
+ 'Close' : function() {self.modal.hideOrDestroy(); self.modal = null;}
}
});
-
+ this.modal.bindEvents();
// show prepared modal
this.modal.show();
},
@@ -808,7 +881,7 @@ var GalaxyLibraryview = Backbone.View.extend({
var self = this;
library.save(libraryDetails, {
success: function (library) {
- self.modal.hide();
+ self.modal.destroy();
self.clear_library_modal();
self.render();
mod_toastr.success('Library created');
diff --git a/static/scripts/galaxy.modal.js b/static/scripts/galaxy.modal.js
index d43c385e4d2..81a7a26ab4b 100644
--- a/static/scripts/galaxy.modal.js
+++ b/static/scripts/galaxy.modal.js
@@ -18,7 +18,9 @@ var GalaxyModal = Backbone.View.extend(
},
// options
- options : {},
+ options : {
+ destructible: false // by default the modal cannot be removed by theself.destroy() method
+ },
// initialize
initialize : function(options) {
@@ -27,16 +29,23 @@ var GalaxyModal = Backbone.View.extend(
this.create(options);
},
- // bind the click-to-hide function
- bindEvents: function(event) {
- // bind the ESC key to hide() function
- $(document).on('keyup', function(event){
- if (event.keyCode == 27) { self.hide(); $('.modal').remove();}
- })
- // bind the 'click anywhere' to hide() function...
- $('html').on('click', function(event){
+ hideOrDestroy: function(){
+ if (this.options.destructible){
+ self.destroy();
+ } else {
self.hide();
- $('.modal').remove();
+ }
+ },
+
+ // bind the click-to-hide function
+ bindEvents: function() {
+ // bind the ESC key to hideOrDestroy() function
+ $(document).on('keyup', function(event){
+ if (event.keyCode == 27) { self.hideOrDestroy() }
+ })
+ // bind the 'click anywhere' to hideOrDestroy() function...
+ $('html').on('click', function(event){
+ self.hideOrDestroy()
})
// ...but don't hide if the click is on modal content
$('.modal-content').on('click', function(event){
@@ -45,28 +54,20 @@ var GalaxyModal = Backbone.View.extend(
},
// unbind the click-to-hide function
- unbindEvents: function(event){
- // bind the ESC key to hide() function
+ unbindEvents: function(){
+ // unbind the ESC key to hideOrDestroy() function
$(document).off('keyup', function(event){
- if (event.keyCode == 27) { self.hide(); $('.modal').remove();}
+ if (event.keyCode == 27) { self.hideOrDestroy() }
})
- // unbind the 'click anywhere' to hide() function...
+ // unbind the 'click anywhere' to hideOrDestroy() function...
$('html').off('click', function(event){
- self.hide();
- $('.modal').remove();
+ self.hideOrDestroy()
})
$('.modal-content').off('click', function(event){
event.stopPropagation();
})
},
- // destroy
- destroy : function(){
- this.hide();
- this.unbindEvents();
- $('.modal').remove();
- },
-
// adds and displays a new frame/window
show: function(options) {
// create
@@ -102,6 +103,16 @@ var GalaxyModal = Backbone.View.extend(
// set flag
this.visible = false;
this.unbindEvents();
+ },
+
+ // destroy modal
+ destroy: function(){
+ // set flag
+ this.visible = false;
+ this.unbindEvents();
+
+ // remove
+ this.$el.remove();
},
// create
diff --git a/static/scripts/packed/galaxy.library.js b/static/scripts/packed/galaxy.library.js
index b6b96e7c9bb..e42ee45b0a1 100644
--- a/static/scripts/packed/galaxy.library.js
+++ b/static/scripts/packed/galaxy.library.js
@@ -1 +1 @@
-var view=null;var library_router=null;var responses=[];define(["galaxy.modal","galaxy.masthead","utils/galaxy.utils","libs/toastr"],function(j,k,g,m){var e=Backbone.Model.extend({urlRoot:"/api/libraries"});var n=Backbone.Collection.extend({url:"/api/libraries",model:e});var h=Backbone.Model.extend({urlRoot:"/api/libraries/datasets"});var c=Backbone.Collection.extend({model:h});var d=Backbone.Model.extend({defaults:{folder:new c(),full_path:"unknown",urlRoot:"/api/folders/",id:"unknown"},parse:function(q){this.full_path=q[0].full_path;this.get("folder").reset(q[1].folder_contents);return q}});var b=Backbone.Model.extend({urlRoot:"/api/histories/"});var i=Backbone.Model.extend({url:"/api/histories/"});var o=Backbone.Collection.extend({url:"/api/histories",model:i});var p=Backbone.Router.extend({routes:{"":"libraries","folders/:id":"folder_content","folders/:folder_id/download/:format":"download"}});var l=Backbone.View.extend({el:"#center",progress:0,progressStep:1,lastSelectedHistory:"",modal:null,folders:null,initialize:function(){this.folders=[];this.queue=jQuery.Deferred();this.queue.resolve()},templateFolder:function(){var q=[];q.push('');q.push('
New Data Libraries. This is work in progress. Report problems & ideas to Marten . ');q.push('
");q.push('
');q.push('
Libraries | ');q.push("<% _.each(path, function(path_item) { %>");q.push("<% if (path_item[0] != id) { %>");q.push('
<%- path_item[1] %> | ');q.push("<% } else { %>");q.push('
<%- path_item[1] %> ');q.push("<% } %>");q.push("<% }); %>");q.push("
");q.push('
");q.push("
");return q.join("")},templateDatasetModal:function(){var q=[];q.push('');q.push('
');q.push(" ");q.push(' ">Name ');q.push(' <%= _.escape(item.get("name")) %> ');q.push(" ");q.push(" ");q.push(' Data type ');q.push(' <%= _.escape(item.get("data_type")) %> ');q.push(" ");q.push(" ");q.push(' Genome build ');q.push(' <%= _.escape(item.get("genome_build")) %> ');q.push(" ");q.push(' Size ');q.push(" <%= _.escape(size) %> ");q.push(" ");q.push(" ");q.push(' Date uploaded ');q.push(' <%= _.escape(item.get("date_uploaded")) %> ');q.push(" ");q.push(" ");q.push(' Uploaded by ');q.push(' <%= _.escape(item.get("uploaded_by")) %> ');q.push(" ");q.push(' ');q.push(' Data Lines ');q.push(' <%= _.escape(item.get("metadata_data_lines")) %> ');q.push(" ");q.push(' Comment Lines ');q.push(' <% if (item.get("metadata_comment_lines") === "") { %>');q.push(' <%= _.escape(item.get("metadata_comment_lines")) %> ');q.push(" <% } else { %>");q.push(' unknown ');q.push(" <% } %>");q.push(" ");q.push(" ");q.push(' Number of Columns ');q.push(' <%= _.escape(item.get("metadata_columns")) %> ');q.push(" ");q.push(" ");q.push(' Column Types ');q.push(' <%= _.escape(item.get("metadata_column_types")) %> ');q.push(" ");q.push(" ");q.push(' Miscellaneous information ');q.push(' <%= _.escape(item.get("misc_blurb")) %> ');q.push(" ");q.push("
");q.push('
');q.push(" ");q.push("
");return q.join("")},templateHistorySelectInModal:function(){var q=[];q.push('');q.push("Select history: ");q.push(' ');q.push(" <% _.each(histories, function(history) { %>");q.push(' "><%= _.escape(history.get("name")) %> ');q.push(" <% }); %>");q.push(" ");q.push(" ");return q.join("")},templateBulkImportInModal:function(){var q=[];q.push('');q.push("Select history: ");q.push(' ');q.push(" <% _.each(histories, function(history) { %>");q.push(' "><%= _.escape(history.get("name")) %> ');q.push(" <% }); %>");q.push(" ");q.push(" ");return q.join("")},size_to_string:function(q){var r="";if(q>=100000000000){q=q/100000000000;r="TB"}else{if(q>=100000000){q=q/100000000;r="GB"}else{if(q>=100000){q=q/100000;r="MB"}else{if(q>=100){q=q/100;r="KB"}else{q=q*10;r="b"}}}}return(Math.round(q)/10)+r},events:{"click #select-all-checkboxes":"selectAll","click .folder_row":"selectClickedRow","click #toolbtn_bulk_import":"modalBulkImport","click #toolbtn_dl":"bulkDownload","click .library-dataset":"showDatasetDetails","click #toolbtn_create_folder":"createFolderModal","click .btn_open_folder":"navigateToFolder"},render:function(q){$("#center").css("overflow","auto");view=this;var s=this;var r=new d({id:q.id});r.url=r.attributes.urlRoot+q.id+"/contents";r.fetch({success:function(t){for(var v=0;v0){$(this.modal.elMain).find("#dataset_import_single").val(r.lastSelectedHistory)}this.modal.show()},downloadCurrent:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var q=[];q.push($("#id_row").attr("data-id"));var r="/api/libraries/datasets/download/uncompressed";var s={ldda_ids:q};folderContentView.processDownload(r,s);this.modal.enableButton("Import");this.modal.enableButton("Download")},importCurrentIntoHistory:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var s=$(this.modal.elMain).find("select[name=dataset_import_single] option:selected").val();this.lastSelectedHistory=s;var q=$("#id_row").attr("data-id");var t=new b();var r=this;t.url=t.urlRoot+s+"/contents";t.save({content:q,source:"library"},{success:function(){m.success("Dataset imported");r.modal.enableButton("Import");r.modal.enableButton("Download")},error:function(){m.error("An error occured! Dataset not imported. Please try again.");r.modal.enableButton("Import");r.modal.enableButton("Download")}})},selectAll:function(r){var q=r.target.checked;that=this;$(":checkbox").each(function(){this.checked=q;$row=$(this.parentElement.parentElement);(q)?that.makeDarkRow($row):that.makeWhiteRow($row)});this.checkTools()},selectClickedRow:function(r){var t="";var q;var s;if(r.target.localName==="input"){t=r.target;q=$(r.target.parentElement.parentElement);s="input"}else{if(r.target.localName==="td"){t=$("#"+r.target.parentElement.id).find(":checkbox")[0];q=$(r.target.parentElement);s="td"}}if(t===""){r.stopPropagation();return}if(t===undefined){r.stopPropagation();return}if(t.checked){if(s==="td"){t.checked="";this.makeWhiteRow(q)}else{if(s==="input"){this.makeDarkRow(q)}}}else{if(s==="td"){t.checked="selected";this.makeDarkRow(q)}else{if(s==="input"){this.makeWhiteRow(q)}}}this.checkTools()},makeDarkRow:function(q){q.removeClass("light");q.find("a").removeClass("light");q.addClass("dark");q.find("a").addClass("dark")},makeWhiteRow:function(q){q.removeClass("dark");q.find("a").removeClass("dark");q.addClass("light");q.find("a").addClass("light")},checkTools:function(){var q=$("#folder_table").find(":checked");if(q.length>0){$("#toolbtn_bulk_import").show();$("#toolbtn_dl").show()}else{$("#toolbtn_bulk_import").hide();$("#toolbtn_dl").hide()}},modalBulkImport:function(){var r=this;var q=new o();q.fetch({success:function(s){var t=_.template(r.templateBulkImportInModal(),{histories:s.models});r.modal=new j.GalaxyModal({title:"Import into History",body:t,buttons:{Import:function(){r.importAllIntoHistory()},Close:function(){r.modal.hide();$(".modal").remove();r.modal=null}}});r.modal.bindEvents(event);r.modal.show()}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var s=$("select[name=dataset_import_bulk] option:selected").val();var w=$("select[name=dataset_import_bulk] option:selected").text();var y=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){y.push(this.parentElement.parentElement.id)}});var x=_.template(this.templateProgressBar(),{history_name:w});$(this.modal.elMain).find(".modal-body").html(x);var t=100/y.length;this.initProgress(t);var q=[];for(var r=y.length-1;r>=0;r--){library_dataset_id=y[r];var u=new b();var v=this;u.url=u.urlRoot+s+"/contents";u.content=library_dataset_id;u.source="library";q.push(u)}this.chainCall(q)},chainCall:function(r){var q=this;var s=r.pop();if(typeof s==="undefined"){m.success("All datasets imported");this.modal.destroy();return}var t=$.when(s.save({content:s.content,source:s.source})).done(function(u){q.updateProgress();responses.push(u);q.chainCall(r)})},initProgress:function(q){this.progress=0;this.progressStep=q},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},templateProgressBar:function(){var q=[];q.push('');q.push("Importing selected datasets to history <%= _.escape(history_name) %> ");q.push("
");q.push('');q.push('
');q.push(' 0% Complete ');q.push("
");q.push("
");q.push("");return q.join("")},download:function(q,u){var s=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){s.push(this.parentElement.parentElement.id)}});var r="/api/libraries/datasets/download/"+u;var t={ldda_ids:s};this.processDownload(r,t,"get")},processDownload:function(r,s,t){if(r&&s){s=typeof s=="string"?s:$.param(s);var q="";$.each(s.split("&"),function(){var u=this.split("=");q+=' '});$('").appendTo("body").submit().remove();m.info("Your download will begin soon")}},createFolderModal:function(){m.info("This will create folder...in the future")}});var a=Backbone.View.extend({el:"#center",events:{"click #create_new_library_btn":"show_library_modal"},initialize:function(){},template_library_list:function(){tmpl_array=[];tmpl_array.push('');tmpl_array.push("");tmpl_array.push('
New Data Libraries. This is work in progress. Report problems & ideas to Marten . ');tmpl_array.push('
New Library ');tmpl_array.push('
');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(" name ");tmpl_array.push(" description ");tmpl_array.push(" synopsis ");tmpl_array.push(" model type ");tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" <% _.each(libraries, function(library) { %>");tmpl_array.push(" ");tmpl_array.push(' " class="btn_open_folder btn btn-default btn-xs">');tmpl_array.push(' browse ');tmpl_array.push(' <%- library.get("name") %> ');tmpl_array.push(' <%= _.escape(library.get("description")) %> ');tmpl_array.push(' <%= _.escape(library.get("synopsis")) %> ');tmpl_array.push(' <%= _.escape(library.get("model_class")) %> ');tmpl_array.push(" ");tmpl_array.push(" <% }); %>");tmpl_array.push(" ");tmpl_array.push("
");tmpl_array.push("
");return tmpl_array.join("")},render:function(){$("#center").css("overflow","auto");var q=this;libraries=new n();libraries.fetch({success:function(r){var s=_.template(q.template_library_list(),{libraries:r.models});q.$el.html(s)},error:function(s,r){if(r.statusCode().status===403){m.error("Please log in first. Redirecting to login page in 3s.");setTimeout(q.redirectToLogin,3000)}else{m.error("An error occured. Please try again.")}}})},redirectToHome:function(){window.location="../"},redirectToLogin:function(){window.location="/user/login"},modal:null,show_library_modal:function(r){r.preventDefault();r.stopPropagation();var q=this;this.modal=new j.GalaxyModal({title:"Create New Library",body:this.template_new_library(),buttons:{Create:function(){q.create_new_library_event()},Close:function(){q.modal.hide()}}});this.modal.show()},create_new_library_event:function(){var s=this.serialize_new_library();if(this.validate_new_library(s)){var r=new e();var q=this;r.save(s,{success:function(t){q.modal.hide();q.clear_library_modal();q.render();m.success("Library created")},error:function(){m.error("An error occured :(")}})}else{m.error("Library's name is missing")}return false},clear_library_modal:function(){$("input[name='Name']").val("");$("input[name='Description']").val("");$("input[name='Synopsis']").val("")},serialize_new_library:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val(),synopsis:$("input[name='Synopsis']").val()}},validate_new_library:function(q){return q.name!==""},template_new_library:function(){tmpl_array=[];tmpl_array.push('');tmpl_array.push("");tmpl_array.push("
");return tmpl_array.join("")}});var f=Backbone.View.extend({folderContentView:null,galaxyLibraryview:null,initialize:function(){folderContentView=new l();galaxyLibraryview=new a();library_router=new p();library_router.on("route:libraries",function(){galaxyLibraryview.render()});library_router.on("route:folder_content",function(q){folderContentView.render({id:q})});library_router.on("route:download",function(q,r){if($("#center").find(":checked").length===0){library_router.navigate("folders/"+q,{trigger:true,replace:true})}else{folderContentView.download(q,r);library_router.navigate("folders/"+q,{trigger:false,replace:true})}});Backbone.history.start();return this}});return{GalaxyApp:f}});
\ No newline at end of file
+var view=null;var library_router=null;var responses=[];define(["galaxy.modal","galaxy.masthead","utils/galaxy.utils","libs/toastr"],function(k,l,h,n){var f=Backbone.Model.extend({urlRoot:"/api/libraries"});var c=Backbone.Model.extend({urlRoot:"/api/folders"});var o=Backbone.Collection.extend({url:"/api/libraries",model:f});var i=Backbone.Model.extend({urlRoot:"/api/libraries/datasets"});var d=Backbone.Collection.extend({model:i});var e=Backbone.Model.extend({defaults:{folder:new d(),full_path:"unknown",urlRoot:"/api/folders/",id:"unknown"},parse:function(r){this.full_path=r[0].full_path;this.get("folder").reset(r[1].folder_contents);return r}});var b=Backbone.Model.extend({urlRoot:"/api/histories/"});var j=Backbone.Model.extend({url:"/api/histories/"});var p=Backbone.Collection.extend({url:"/api/histories",model:j});var q=Backbone.Router.extend({routes:{"":"libraries","folders/:id":"folder_content","folders/:folder_id/download/:format":"download"}});var m=Backbone.View.extend({el:"#center",progress:0,progressStep:1,lastSelectedHistory:"",modal:null,folders:null,initialize:function(){this.folders=[];this.queue=jQuery.Deferred();this.queue.resolve()},templateFolder:function(){var r=[];r.push('');r.push('
New Data Libraries. This is work in progress. Report problems & ideas to Marten . ');r.push('
");r.push('
');r.push('
Libraries | ');r.push("<% _.each(path, function(path_item) { %>");r.push("<% if (path_item[0] != id) { %>");r.push('
<%- path_item[1] %> | ');r.push("<% } else { %>");r.push('
<%- path_item[1] %> ');r.push("<% } %>");r.push("<% }); %>");r.push("
");r.push('
");r.push("
");return r.join("")},templateDatasetModal:function(){var r=[];r.push('');r.push('
');r.push(" ");r.push(' ">Name ');r.push(' <%= _.escape(item.get("name")) %> ');r.push(" ");r.push(" ");r.push(' Data type ');r.push(' <%= _.escape(item.get("data_type")) %> ');r.push(" ");r.push(" ");r.push(' Genome build ');r.push(' <%= _.escape(item.get("genome_build")) %> ');r.push(" ");r.push(' Size ');r.push(" <%= _.escape(size) %> ");r.push(" ");r.push(" ");r.push(' Date uploaded ');r.push(' <%= _.escape(item.get("date_uploaded")) %> ');r.push(" ");r.push(" ");r.push(' Uploaded by ');r.push(' <%= _.escape(item.get("uploaded_by")) %> ');r.push(" ");r.push(' ');r.push(' Data Lines ');r.push(' <%= _.escape(item.get("metadata_data_lines")) %> ');r.push(" ");r.push(' Comment Lines ');r.push(' <% if (item.get("metadata_comment_lines") === "") { %>');r.push(' <%= _.escape(item.get("metadata_comment_lines")) %> ');r.push(" <% } else { %>");r.push(' unknown ');r.push(" <% } %>");r.push(" ");r.push(" ");r.push(' Number of Columns ');r.push(' <%= _.escape(item.get("metadata_columns")) %> ');r.push(" ");r.push(" ");r.push(' Column Types ');r.push(' <%= _.escape(item.get("metadata_column_types")) %> ');r.push(" ");r.push(" ");r.push(' Miscellaneous information ');r.push(' <%= _.escape(item.get("misc_blurb")) %> ');r.push(" ");r.push("
");r.push('
');r.push(" ");r.push("
");return r.join("")},templateHistorySelectInModal:function(){var r=[];r.push('');r.push("Select history: ");r.push(' ');r.push(" <% _.each(histories, function(history) { %>");r.push(' "><%= _.escape(history.get("name")) %> ');r.push(" <% }); %>");r.push(" ");r.push(" ");return r.join("")},templateBulkImportInModal:function(){var r=[];r.push('');r.push("Select history: ");r.push(' ');r.push(" <% _.each(histories, function(history) { %>");r.push(' "><%= _.escape(history.get("name")) %> ');r.push(" <% }); %>");r.push(" ");r.push(" ");return r.join("")},size_to_string:function(r){var s="";if(r>=100000000000){r=r/100000000000;s="TB"}else{if(r>=100000000){r=r/100000000;s="GB"}else{if(r>=100000){r=r/100000;s="MB"}else{if(r>=100){r=r/100;s="KB"}else{r=r*10;s="b"}}}}return(Math.round(r)/10)+s},events:{"click #select-all-checkboxes":"selectAll","click .folder_row":"selectClickedRow","click #toolbtn_bulk_import":"modalBulkImport","click #toolbtn_dl":"bulkDownload","click .library-dataset":"showDatasetDetails","click #toolbtn_create_folder":"createFolderFromModal","click .btn_open_folder":"navigateToFolder"},render:function(r){$("#center").css("overflow","auto");view=this;var t=this;var s=new e({id:r.id});s.url=s.attributes.urlRoot+r.id+"/contents";s.fetch({success:function(u){for(var w=0;w0){$(this.modal.elMain).find("#dataset_import_single").val(s.lastSelectedHistory)}this.modal.bindEvents();this.modal.show()},downloadCurrent:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var r=[];r.push($("#id_row").attr("data-id"));var s="/api/libraries/datasets/download/uncompressed";var t={ldda_ids:r};folderContentView.processDownload(s,t);this.modal.enableButton("Import");this.modal.enableButton("Download")},importCurrentIntoHistory:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var t=$(this.modal.elMain).find("select[name=dataset_import_single] option:selected").val();this.lastSelectedHistory=t;var r=$("#id_row").attr("data-id");var u=new b();var s=this;u.url=u.urlRoot+t+"/contents";u.save({content:r,source:"library"},{success:function(){n.success("Dataset imported");s.modal.enableButton("Import");s.modal.enableButton("Download")},error:function(){n.error("An error occured! Dataset not imported. Please try again.");s.modal.enableButton("Import");s.modal.enableButton("Download")}})},selectAll:function(s){var r=s.target.checked;that=this;$(":checkbox").each(function(){this.checked=r;$row=$(this.parentElement.parentElement);(r)?that.makeDarkRow($row):that.makeWhiteRow($row)});this.checkTools()},selectClickedRow:function(s){var u="";var r;var t;if(s.target.localName==="input"){u=s.target;r=$(s.target.parentElement.parentElement);t="input"}else{if(s.target.localName==="td"){u=$("#"+s.target.parentElement.id).find(":checkbox")[0];r=$(s.target.parentElement);t="td"}}if(u===""){s.stopPropagation();return}if(u===undefined){s.stopPropagation();return}if(u.checked){if(t==="td"){u.checked="";this.makeWhiteRow(r)}else{if(t==="input"){this.makeDarkRow(r)}}}else{if(t==="td"){u.checked="selected";this.makeDarkRow(r)}else{if(t==="input"){this.makeWhiteRow(r)}}}this.checkTools()},makeDarkRow:function(r){r.removeClass("light");r.find("a").removeClass("light");r.addClass("dark");r.find("a").addClass("dark")},makeWhiteRow:function(r){r.removeClass("dark");r.find("a").removeClass("dark");r.addClass("light");r.find("a").addClass("light")},checkTools:function(){var r=$("#folder_table").find(":checked");if(r.length>0){$("#toolbtn_bulk_import").show();$("#toolbtn_dl").show()}else{$("#toolbtn_bulk_import").hide();$("#toolbtn_dl").hide()}},modalBulkImport:function(){var s=this;var r=new p();r.fetch({success:function(t){var u=_.template(s.templateBulkImportInModal(),{histories:t.models});s.modal=new k.GalaxyModal({destructible:true,title:"Import into History",body:u,buttons:{Import:function(){s.importAllIntoHistory()},Close:function(){s.modal.hideOrDestroy;s.modal=null}}});s.modal.bindEvents();s.modal.show()}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var t=$("select[name=dataset_import_bulk] option:selected").val();var x=$("select[name=dataset_import_bulk] option:selected").text();var z=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){z.push(this.parentElement.parentElement.id)}});var y=_.template(this.templateProgressBar(),{history_name:x});$(this.modal.elMain).find(".modal-body").html(y);var u=100/z.length;this.initProgress(u);var r=[];for(var s=z.length-1;s>=0;s--){library_dataset_id=z[s];var v=new b();var w=this;v.url=v.urlRoot+t+"/contents";v.content=library_dataset_id;v.source="library";r.push(v)}this.chainCall(r)},chainCall:function(s){var r=this;var t=s.pop();if(typeof t==="undefined"){n.success("All datasets imported");this.modal.destroy();return}var u=$.when(t.save({content:t.content,source:t.source})).done(function(v){r.updateProgress();responses.push(v);r.chainCall(s)})},initProgress:function(r){this.progress=0;this.progressStep=r},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},templateProgressBar:function(){var r=[];r.push('');r.push("Importing selected datasets to history <%= _.escape(history_name) %> ");r.push("
");r.push('');r.push('
');r.push(' 0% Complete ');r.push("
");r.push("
");r.push("");return r.join("")},download:function(r,v){var t=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){t.push(this.parentElement.parentElement.id)}});var s="/api/libraries/datasets/download/"+v;var u={ldda_ids:t};this.processDownload(s,u,"get")},processDownload:function(s,t,u){if(s&&t){t=typeof t=="string"?t:$.param(t);var r="";$.each(t.split("&"),function(){var v=this.split("=");r+=' '});$('").appendTo("body").submit().remove();n.info("Your download will begin soon")}},createFolderFromModal:function(){event.preventDefault();event.stopPropagation();var r=this;this.modal=new k.GalaxyModal({destructible:true,title:"Create New Folder",body:this.template_new_folder(),buttons:{Create:function(){r.create_new_folder_event()},Close:function(){r.modal.destroy();r.modal=null}}});this.modal.bindEvents();this.modal.show()},create_new_folder_event:function(){var r=this.serialize_new_folder();if(this.validate_new_folder(r)){var t=new c();t.url=t.urlRoot+"/F2fdbd5c5858e78fb";var s=this;t.save(r,{success:function(u){s.modal.destroy();n.success("Folder created");s.render({id:"F2fdbd5c5858e78fb"})},error:function(){n.error("An error occured :(")}})}else{n.error("Folder's name is missing")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(r){return r.name!==""},template_new_folder:function(){tmpl_array=[];tmpl_array.push('');tmpl_array.push("");tmpl_array.push("
");return tmpl_array.join("")}});var a=Backbone.View.extend({el:"#center",events:{"click #create_new_library_btn":"show_library_modal"},initialize:function(){},template_library_list:function(){tmpl_array=[];tmpl_array.push('');tmpl_array.push("");tmpl_array.push('
New Data Libraries. This is work in progress. Report problems & ideas to Marten . ');tmpl_array.push('
New Library ');tmpl_array.push('
');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(" name ");tmpl_array.push(" description ");tmpl_array.push(" synopsis ");tmpl_array.push(" model type ");tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" <% _.each(libraries, function(library) { %>");tmpl_array.push(" ");tmpl_array.push(' " class="btn_open_folder btn btn-default btn-xs">');tmpl_array.push(' browse ');tmpl_array.push(' <%- library.get("name") %> ');tmpl_array.push(' <%= _.escape(library.get("description")) %> ');tmpl_array.push(' <%= _.escape(library.get("synopsis")) %> ');tmpl_array.push(' <%= _.escape(library.get("model_class")) %> ');tmpl_array.push(" ");tmpl_array.push(" <% }); %>");tmpl_array.push(" ");tmpl_array.push("
");tmpl_array.push("
");return tmpl_array.join("")},render:function(){$("#center").css("overflow","auto");var r=this;libraries=new o();libraries.fetch({success:function(s){var t=_.template(r.template_library_list(),{libraries:s.models});r.$el.html(t)},error:function(t,s){if(s.statusCode().status===403){n.error("Please log in first. Redirecting to login page in 3s.");setTimeout(r.redirectToLogin,3000)}else{n.error("An error occured. Please try again.")}}})},redirectToHome:function(){window.location="../"},redirectToLogin:function(){window.location="/user/login"},modal:null,show_library_modal:function(s){s.preventDefault();s.stopPropagation();var r=this;this.modal=new k.GalaxyModal({destructible:true,title:"Create New Library",body:this.template_new_library(),buttons:{Create:function(){r.create_new_library_event()},Close:function(){r.modal.hideOrDestroy();r.modal=null}}});this.modal.bindEvents();this.modal.show()},create_new_library_event:function(){var t=this.serialize_new_library();if(this.validate_new_library(t)){var s=new f();var r=this;s.save(t,{success:function(u){r.modal.destroy();r.clear_library_modal();r.render();n.success("Library created")},error:function(){n.error("An error occured :(")}})}else{n.error("Library's name is missing")}return false},clear_library_modal:function(){$("input[name='Name']").val("");$("input[name='Description']").val("");$("input[name='Synopsis']").val("")},serialize_new_library:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val(),synopsis:$("input[name='Synopsis']").val()}},validate_new_library:function(r){return r.name!==""},template_new_library:function(){tmpl_array=[];tmpl_array.push('');tmpl_array.push("");tmpl_array.push("
");return tmpl_array.join("")}});var g=Backbone.View.extend({folderContentView:null,galaxyLibraryview:null,initialize:function(){folderContentView=new m();galaxyLibraryview=new a();library_router=new q();library_router.on("route:libraries",function(){galaxyLibraryview.render()});library_router.on("route:folder_content",function(r){folderContentView.render({id:r})});library_router.on("route:download",function(r,s){if($("#center").find(":checked").length===0){library_router.navigate("folders/"+r,{trigger:true,replace:true})}else{folderContentView.download(r,s);library_router.navigate("folders/"+r,{trigger:false,replace:true})}});Backbone.history.start();return this}});return{GalaxyApp:g}});
\ No newline at end of file
diff --git a/static/scripts/packed/galaxy.modal.js b/static/scripts/packed/galaxy.modal.js
index 60cb0b59a2f..255976e571d 100644
--- a/static/scripts/packed/galaxy.modal.js
+++ b/static/scripts/packed/galaxy.modal.js
@@ -1 +1 @@
-define([],function(){var a=Backbone.View.extend({elMain:"#everything",optionsDefault:{title:"galaxy-modal",body:"",backdrop:true,height:null,width:null},options:{},initialize:function(b){self=this;if(b){this.create(b)}},bindEvents:function(b){$(document).on("keyup",function(c){if(c.keyCode==27){self.hide();$(".modal").remove()}});$("html").on("click",function(c){self.hide();$(".modal").remove()});$(".modal-content").on("click",function(c){c.stopPropagation()})},unbindEvents:function(b){$(document).off("keyup",function(c){if(c.keyCode==27){self.hide();$(".modal").remove()}});$("html").off("click",function(c){self.hide();$(".modal").remove()});$(".modal-content").off("click",function(c){c.stopPropagation()})},destroy:function(){this.hide();this.unbindEvents();$(".modal").remove()},show:function(b){this.initialize(b);if(this.options.height){this.$body.css("height",this.options.height);this.$body.css("overflow","hidden")}else{this.$body.css("max-height",$(window).height()/2)}if(this.options.width){this.$dialog.css("width",this.options.width)}if(this.visible){this.$el.show()}else{this.$el.fadeIn("fast")}this.visible=true},hide:function(){this.$el.fadeOut("fast");this.visible=false;this.unbindEvents()},create:function(c){this.options=_.defaults(c,this.optionsDefault);if(this.options.body=="progress"){this.options.body=$('')}if(this.$el){this.$el.remove()}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);if(!this.options.backdrop){this.$backdrop.removeClass("in")}if(this.options.buttons){var b=this;$.each(this.options.buttons,function(d,e){b.$buttons.append($(' ').text(d).click(e)).append(" ")})}else{this.$footer.hide()}$(this.elMain).append($(this.el))},enableButton:function(b){this.$buttons.find("#"+String(b).toLowerCase()).prop("disabled",false)},disableButton:function(b){this.$buttons.find("#"+String(b).toLowerCase()).prop("disabled",true)},hideButton:function(b){this.$buttons.find("#"+String(b).toLowerCase()).hide()},showButton:function(b){this.$buttons.find("#"+String(b).toLowerCase()).show()},scrollTop:function(){return this.$body.scrollTop()},template:function(b){return'
'}});return{GalaxyModal:a}});
\ No newline at end of file
+define([],function(){var a=Backbone.View.extend({elMain:"#everything",optionsDefault:{title:"galaxy-modal",body:"",backdrop:true,height:null,width:null},options:{destructible:false},initialize:function(b){self=this;if(b){this.create(b)}},hideOrDestroy:function(){if(this.options.destructible){self.destroy()}else{self.hide()}},bindEvents:function(){$(document).on("keyup",function(b){if(b.keyCode==27){self.hideOrDestroy()}});$("html").on("click",function(b){self.hideOrDestroy()});$(".modal-content").on("click",function(b){b.stopPropagation()})},unbindEvents:function(){$(document).off("keyup",function(b){if(b.keyCode==27){self.hideOrDestroy()}});$("html").off("click",function(b){self.hideOrDestroy()});$(".modal-content").off("click",function(b){b.stopPropagation()})},show:function(b){this.initialize(b);if(this.options.height){this.$body.css("height",this.options.height);this.$body.css("overflow","hidden")}else{this.$body.css("max-height",$(window).height()/2)}if(this.options.width){this.$dialog.css("width",this.options.width)}if(this.visible){this.$el.show()}else{this.$el.fadeIn("fast")}this.visible=true},hide:function(){this.$el.fadeOut("fast");this.visible=false;this.unbindEvents()},destroy:function(){this.visible=false;this.unbindEvents();this.$el.remove()},create:function(c){this.options=_.defaults(c,this.optionsDefault);if(this.options.body=="progress"){this.options.body=$('
')}if(this.$el){this.$el.remove()}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);if(!this.options.backdrop){this.$backdrop.removeClass("in")}if(this.options.buttons){var b=this;$.each(this.options.buttons,function(d,e){b.$buttons.append($('
').text(d).click(e)).append(" ")})}else{this.$footer.hide()}$(this.elMain).append($(this.el))},enableButton:function(b){this.$buttons.find("#"+String(b).toLowerCase()).prop("disabled",false)},disableButton:function(b){this.$buttons.find("#"+String(b).toLowerCase()).prop("disabled",true)},hideButton:function(b){this.$buttons.find("#"+String(b).toLowerCase()).hide()},showButton:function(b){this.$buttons.find("#"+String(b).toLowerCase()).show()},scrollTop:function(){return this.$body.scrollTop()},template:function(b){return'
'}});return{GalaxyModal:a}});
\ No newline at end of file