Removing the view for configure workflow menu

This commit is contained in:
anuprulez
2017-07-28 13:33:13 +02:00
parent 6d3b11f3e7
commit 8010cd351d
10 changed files with 36 additions and 203 deletions
+1 -8
View File
@@ -13,7 +13,6 @@ var jQuery = require( 'jquery' ),
GridShared = require( 'mvc/grid/grid-shared' ),
Workflows = require( 'mvc/workflow/workflow' ),
HistoryList = require( 'mvc/history/history-list' ),
WorkflowsConfigureMenu = require( 'mvc/workflow/workflow-configure-menu' ),
ToolFormComposite = require( 'mvc/tool/tool-form-composite' ),
Utils = require( 'utils/utils' ),
Ui = require( 'mvc/ui/ui-misc' );
@@ -92,7 +91,6 @@ window.app = function app( options, bootstrapped ){
'(/)workflows/list_published(/)' : 'show_workflows_published',
'(/)histories(/)(:action_id)' : 'show_histories',
'(/)datasets(/)list(/)' : 'show_datasets',
'(/)workflow/configure_menu(/)' : 'show_configure_menu',
'(/)workflow/import_workflow' : 'show_import_workflow',
'(/)custom_builds' : 'show_custom_builds'
},
@@ -100,8 +98,7 @@ window.app = function app( options, bootstrapped ){
require_login: [
'show_user',
'show_user_form',
'show_workflows',
'show_configure_menu'
'show_workflows'
],
loginRequired: function() {
@@ -160,10 +157,6 @@ window.app = function app( options, bootstrapped ){
this.page.display( new Workflows.ImportWorkflowView() );
},
show_configure_menu : function(){
this.page.display( new WorkflowsConfigureMenu.View() );
},
show_custom_builds : function() {
var self = this;
var historyPanel = this.page.historyPanel.historyView;
@@ -1,153 +0,0 @@
/** Configure Workflow Menu View */
define( [], function() {
var View = Backbone.View.extend({
initialize: function( options ) {
this.setElement( '<div/>' );
this.render();
},
render: function() {
var self = this;
$.getJSON( Galaxy.root + 'api/workflows/menu/', function( response ) {
var workflows = response.workflows,
ids_in_menu = response.ids_in_menu,
$el_config_worflow = null;
// Add configure workflow header
self.$el.empty().append( self._templateConfigWorkflowHeader() );
$el_config_worflow = self.$el.find( '.configure-workflows' );
$el_config_worflow.append( self._templateActionButtons() );
if( workflows.length > 0 ) {
$el_config_worflow.append( self._templateConfigureWorkflow( self, workflows, ids_in_menu ) );
self.save_workflow_menu( self );
self.make_checked( self, ids_in_menu );
self.register_check_uncheck_all( self );
}
else {
$el_config_worflow.append( self._templateNoWorkflow() );
}
});
},
/** Register check and uncheck all callbacks*/
register_check_uncheck_all: function( self ) {
var $el_check_all = self.$el.find( '.check-all-wf' ),
$el_uncheck_all = self.$el.find( '.uncheck-all-wf' );
$el_check_all.click(function( e ) {
self.check_uncheck_all( self, true );
});
$el_uncheck_all.click(function( e ) {
self.check_uncheck_all( self, false );
});
},
/** Check or uncheck all workflows */
check_uncheck_all: function( self, checked ) {
$.each(self.$el.find( '.wf-config-item' ), function() {
var wf_checkbox = $( this )[0];
wf_checkbox.checked = checked;
});
},
/** Make the worflows as checked if present in the menu */
make_checked: function( self, ids_in_menu ) {
$.each(self.$el.find( '.wf-config-item' ), function() {
var wf_checkbox = $( this )[0];
_.each( ids_in_menu, function( id ) {
if ( parseInt( wf_checkbox.value ) === id ) {
wf_checkbox.checked = true;
}
});
});
},
/** Save the changes for workflow menu */
save_workflow_menu: function( self ) {
var $el_save_workflow_menu = self.$el.find( '.wf-save-menu' );
$el_save_workflow_menu.click( function( e ) {
var ids = [];
$.each(self.$el.find( '.wf-config-item' ), function() {
var wf_checkbox = $( this )[0];
if( wf_checkbox.checked || wf_checkbox.checked === 'true' ) {
ids.push( parseInt( wf_checkbox.value ) );
}
});
$.ajax({
type: 'PUT',
url: Galaxy.root + 'api/workflows/menu/',
data: JSON.stringify( { 'workflow_ids': ids } ),
contentType : 'application/json'
}).done( function( response ) {
window.location = Galaxy.root + 'user';
});
});
},
/** Template for actions buttons */
_templateActionButtons: function() {
return '<ul class="manage-table-actions">' +
'<li>' +
'<a class="fa fa-check-square-o wf-action check-all-wf" title="Select all workflows" href="#">' +
'</a>' +
'</li>' +
'<li>' +
'<a class="fa fa-square-o wf-action uncheck-all-wf" title="Unselect all workflows" href="#">' +
'</a>' +
'</li>' +
'</ul>';
},
/** Template for configure workflow table */
_templateConfigureWorkflow: function( self, workflows, ids_in_menu ) {
var tableHtml = "", trHtml = "";
tableHtml = tableHtml + '<table class="table colored"><thead>' +
'<tr class="header">' +
'<th class="wf-td">Name</th>' +
'<th class="wf-td">Owner</th>' +
'<th class="wf-td"># of Steps</th>' +
'<th class="wf-td">Show in menu</th>' +
'</tr></thead>';
_.each( workflows, function( wf ) {
trHtml = trHtml + '<tr>' +
'<td class="wf-td">' + _.escape( wf.name ) +'</td>' +
'<td>' + ( wf.owner === Galaxy.user.attributes.username ? "You" : wf.owner ) +'</td>' +
'<td class="wf-td">' + wf.number_of_steps + '</td>' +
'<td class="wf-td">' + self._templateInputCheckbox( self, wf, ids_in_menu ) + '</td>' +
'</tr>';
});
tableHtml = tableHtml + '<tbody class="workflow-config-menu">' + trHtml + '</tbody></table>';
tableHtml = tableHtml + '<a class="action-button wf-save-menu wf-action fa fa-floppy-o" href="#" title="Save">' +
'<span>Save</span>' +
'</a>' +
'<a class="action-button wf-back wf-action fa fa-arrow-left" href="'+ Galaxy.root +'user" title="Back to User Preferences">' +
'<span>Back to User Preferences</span>' +
'</a>';
return tableHtml;
},
/** Template for no workflow */
_templateNoWorkflow: function() {
return '<div class="wf-nodata"> You do not have any accessible workflows. </div>';
},
/** Template for checkboxes */
_templateInputCheckbox: function( self, wf ) {
return '<input type="checkbox" class="wf-config-item" name="workflow_ids" value="'+ wf.id +'" />';
},
/** Template for main config workflow menu */
_templateConfigWorkflowHeader: function() {
return '<div class="page-container">' +
'<div class="configure-workflows wf">' +
'<h2>Configure workflow menu</h2>' +
'</div>'+
'</div>';
}
});
return {
View : View
};
});
+1 -1
View File
@@ -1812,6 +1812,6 @@ div.toolTitleNoSection
margin-left: 0.5%;
}
.other-options, .configure-workflows {
.other-options {
margin-bottom: 2%;
}
+13 -19
View File
@@ -54,7 +54,7 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn
"""
GET /api/workflows
"""
return self.get_workflows_list( trans, False, kwd )
return self.get_workflows_list( trans, kwd )
@expose_api
def get_workflow_menu( self, trans, **kwd ):
@@ -66,7 +66,7 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn
ids_in_menu = [ x.stored_workflow_id for x in user.stored_workflow_menu_entries ]
return {
'ids_in_menu': ids_in_menu,
'workflows': self.get_workflows_list( trans, True, kwd )
'workflows': self.get_workflows_list( trans, kwd )
}
@expose_api
@@ -104,7 +104,7 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn
trans.set_message( message )
return { 'message': message, 'status': 'done' }
def get_workflows_list( self, trans, for_menu, kwd ):
def get_workflows_list( self, trans, kwd ):
"""
Displays a collection of workflows.
@@ -123,37 +123,31 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn
for wf in trans.sa_session.query( trans.app.model.StoredWorkflow ).filter(
filter1, trans.app.model.StoredWorkflow.table.c.deleted == false() ).order_by(
desc( trans.app.model.StoredWorkflow.table.c.update_time ) ).all():
if for_menu:
item = wf.to_dict()
else:
item = wf.to_dict( value_mapper={ 'id': trans.security.encode_id } )
encoded_id = trans.security.encode_id(wf.id)
item['url'] = url_for('workflow', id=encoded_id)
item = wf.to_dict( value_mapper={ 'id': trans.security.encode_id } )
encoded_id = trans.security.encode_id(wf.id)
item['url'] = url_for('workflow', id=encoded_id)
item['owner'] = wf.user.username
item['number_of_steps'] = len( wf.latest_workflow.steps )
item['wf_id'] = wf.id
item['show_in_tool_panel'] = False
item['wf_id'] = wf.id
for x in user.stored_workflow_menu_entries:
if x.stored_workflow_id == wf.id:
item['show_in_tool_panel'] = True
break
rval.append(item)
for wf_sa in trans.sa_session.query( trans.app.model.StoredWorkflowUserShareAssociation ).filter_by(
user=trans.user ).join( 'stored_workflow' ).filter(
trans.app.model.StoredWorkflow.deleted == false() ).order_by(
desc( trans.app.model.StoredWorkflow.update_time ) ).all():
if for_menu:
item = wf_sa.stored_workflow.to_dict()
else:
item = wf_sa.stored_workflow.to_dict( value_mapper={ 'id': trans.security.encode_id } )
encoded_id = trans.security.encode_id(wf_sa.stored_workflow.id)
item['url'] = url_for( 'workflow', id=encoded_id )
item['slug'] = wf_sa.stored_workflow.slug
item = wf_sa.stored_workflow.to_dict( value_mapper={ 'id': trans.security.encode_id } )
encoded_id = trans.security.encode_id(wf_sa.stored_workflow.id)
item['url'] = url_for( 'workflow', id=encoded_id )
item['slug'] = wf_sa.stored_workflow.slug
item['owner'] = wf_sa.stored_workflow.user.username
item['number_of_steps'] = len( wf_sa.stored_workflow.latest_workflow.steps )
item['wf_id'] = wf_sa.id
item['show_in_tool_panel'] = False
item['wf_id'] = wf_sa.id
for x in user.stored_workflow_menu_entries:
if x.stored_workflow_id == wf_sa.id:
item['show_in_tool_panel'] = True
-1
View File
@@ -119,7 +119,6 @@ def paste_app_factory( global_conf, **kwargs ):
webapp.add_client_route( '/datasets/list' )
webapp.add_client_route( '/workflow/run' )
webapp.add_client_route( '/workflow/import_workflow' )
webapp.add_client_route( '/workflow/configure_menu' )
webapp.add_client_route( '/custom_builds' )
# ==== Done
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long