Skip to content

Commit

Permalink
Merge pull request #24 from guerler/remove_mako_preferences_revision
Browse files Browse the repository at this point in the history
Remove mako preferences revision
  • Loading branch information
bgruening committed Oct 19, 2016
2 parents 7832724 + 4fa9984 commit 1305b42
Show file tree
Hide file tree
Showing 27 changed files with 260 additions and 406 deletions.
58 changes: 32 additions & 26 deletions client/galaxy/scripts/mvc/user/change-api-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) {
var self = this;
this.model = options && options.model || new Backbone.Model( options );
this.form = new Form({
title: 'Web API Key',
inputs: [ { name: 'api-key',
type: 'text',
label: 'Current API key:',
value: options.user_api_key || 'Not available.',
readonly: true,
help: ' An API key will allow you to access ' + ( options.app_name === 'galaxy' ? 'Galaxy' : 'the Tool Shed' ) + ' via its web API. Please note that this key acts as an alternate means to access your account and should be treated with the same care as your login password.' } ],
title : 'Web API Key',
icon : 'fa-key',
inputs : [ { name : 'api-key',
type : 'text',
label : 'Current API key:',
value : options.api_key || 'Not available.',
readonly : true,
help : ' An API key will allow you to access ' + ( options.webapp === 'galaxy' ? 'Galaxy' : 'the Tool Shed' ) + ' via its web API. Please note that this key acts as an alternate means to access your account and should be treated with the same care as your login password.' } ],
operations: {
'back': new Ui.ButtonIcon({
icon: 'fa-caret-left',
tooltip: 'Return to user preferences',
title: 'Preferences',
onclick: function() { self.remove(); options.onclose(); }
icon : 'fa-caret-left',
tooltip : 'Return to user preferences',
title : 'Preferences',
onclick : function() { self.remove(); options.onclose(); }
})
},
buttons : {
'generatenewkey': new Ui.Button({
tooltip: 'Generate new key ' + ( options.user_api_key ? '(invalidates old key) ' : '' ),
title: 'Generate a new key',
cls: 'ui-button btn btn-primary',
floating: 'clear',
onclick: function() { self._submit() }
buttons: {
'submit': new Ui.Button({
tooltip : 'Generate new key ' + ( options.api_key ? '(invalidates old key) ' : '' ),
title : 'Generate a new key',
icon : 'fa-check',
cls : 'ui-button btn btn-primary',
floating : 'clear',
onclick : function() { self._submit() }
})
}
});
Expand All @@ -36,17 +38,21 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) {
/** Generate new API key */
_submit: function() {
var self = this;
$.getJSON( Galaxy.root + 'api/user_preferences/change_api_key', { 'new_api_key': true }, function( response ) {
if( response.user_api_key ) {
$.ajax( {
url : Galaxy.root + 'api/user_preferences/' + Galaxy.user.id + '/api_key',
type : 'PUT',
data : { new_api_key: true }
}).done( function( response ) {
if ( response.api_key ) {
var input_id = self.form.data.match( 'api-key' );
self.form.field_list[ input_id ].value( response.user_api_key );
self.form.message.update({
message: response.message,
status: response.status === 'error' ? 'danger' : 'success',
});
self.form.field_list[ input_id ].value( response.api_key );
self.form.message.update( { message: response.message, status: 'success' } );
} else {
self.form.message.update( { message: 'API key missing from response.', status: 'danger' } );
}
}).fail( function( response ) {
self.form.message.update( { message: response.responseJSON.err_msg, status: 'danger' } );
});
}
});
});

20 changes: 11 additions & 9 deletions client/galaxy/scripts/mvc/user/change-communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) {
var self = this;
this.model = options && options.model || new Backbone.Model( options );
this.form = new Form({
title: 'Enable real-time communication with other Galaxy users',
icon: 'fa-child',
inputs: [ { name: 'change-communication', type: 'boolean', label: 'Enable communication', value: options.activated } ],
title : 'Enable real-time communication with other Galaxy users',
icon : 'fa-child',
inputs : [ { name: 'enable', type: 'boolean', label: 'Enable communication', value: options.activated } ],
operations: {
'back': new Ui.ButtonIcon({
icon: 'fa-caret-left',
Expand All @@ -26,12 +26,14 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) {
/** Saves changes */
_save: function() {
var self = this;
var data = { 'enable_communication_server': self.form.data.create()[ 'change-communication' ] };
$.getJSON( Galaxy.root + 'api/user_preferences/change_communication', data, function( response ) {
self.form.message.update({
message: response.message,
status: response.status === 'error' ? 'danger' : 'success'
});
$.ajax({
url : Galaxy.root + 'api/user_preferences/' + Galaxy.user.id + '/communication',
type : 'PUT',
data : { enable: self.form.data.create()[ 'enable' ] }
}).done( function( response ) {
self.form.message.update( { message: response.message, status: 'success' } );
}).fail( function( response ) {
self.form.message.update( { message: response.responseJSON.err_msg, status: 'danger' } );
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) {
/** Saves changes */
_save: function() {
var self = this;
$.getJSON( Galaxy.root + 'api/user_preferences/set_information', self.form.data.create(), function( response ) {
self.form.message.update({
message: response.message,
status: response.status === 'error' ? 'danger' : 'success'
});
}).always( function() {
self.form.message.update({
message: 'Failed to contact server. Please wait and try again.', status: 'danger'
});
$.ajax( {
url : Galaxy.root + 'api/user_preferences/' + Galaxy.user.id + '/information',
type : 'PUT',
data : self.form.data.create()
}).done( function( response ) {
self.form.message.update( { message: response.message, status: 'success' } );
}).fail( function( response ) {
self.form.message.update( { message: response.responseJSON.err_msg, status: 'danger' } );
});
}
});
Expand Down
13 changes: 8 additions & 5 deletions client/galaxy/scripts/mvc/user/change-password.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) {
/** Saves the changed password */
_save: function() {
var self = this;
$.getJSON( Galaxy.root + 'api/user_preferences/change_password', this.form.data.create(), function( response ) {
self.form.message.update({
message: response.message,
status: response.status === 'error' ? 'danger' : 'success',
});
$.ajax({
url : Galaxy.root + 'api/user_preferences/' + Galaxy.user.id + '/password',
type : 'PUT',
data : { enable: self.form.data.create() }
}).done( function( response ) {
self.form.message.update( { message: response.message, status: 'success' } );
}).fail( function( response ) {
self.form.message.update( { message: response.responseJSON.err_msg, status: 'danger' } );
});
}
});
Expand Down
129 changes: 27 additions & 102 deletions client/galaxy/scripts/mvc/user/change-toolbox-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,119 +5,44 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) {
var self = this;
this.model = options && options.model || new Backbone.Model( options );
this.form = new Form({
title: 'Manage Toolbox Filters',
name: 'toolbox_filter',
id: 'toolbox_filter',
inputs: self._buildFormInputs( options ),
operations: {
'back': new Ui.ButtonIcon({
icon: 'fa-caret-left',
tooltip: 'Return to user preferences',
title: 'Preferences',
onclick: function() { self.remove(); options.onclose(); }
title : 'Manage Toolbox Filters',
name : 'toolbox_filter',
inputs : options.inputs,
icon : 'fa-filter',
operations : {
'back' : new Ui.ButtonIcon({
icon : 'fa-caret-left',
tooltip : 'Return to user preferences',
title : 'Preferences',
onclick : function() { self.remove(); options.onclose(); }
})
},
buttons: {
'savesfilterboxchanges': new Ui.Button({
tooltip: 'Save changes',
title: 'Save changes',
cls: 'ui-button btn btn-primary',
buttons : {
'save' : new Ui.Button({
tooltip : 'Save changes',
title : 'Save Filters',
icon : 'fa-save',
cls : 'ui-button btn btn-primary',
floating: 'clear',
onclick: function() { self._save() }
onclick : function() { self._save() }
})
}
});
this.setElement( this.form.$el );
},

/** Build the inputs for each filter */
_buildFormInputs: function( data ) {
var all_inputs = [],
tools = {},
sections = {},
labels = {},
tool_filters = JSON.parse( data["tool_filters"] ),
label_filters = JSON.parse( data["label_filters"] ),
section_filters = JSON.parse( data["section_filters"] );

if( tool_filters.length > 0 || section_filters.length > 0 || label_filters.length > 0 ) {
if( tool_filters.length > 0 ) {
tools = {
name: 'Edit ToolBox filters :: Tools',
type: 'section',
label: '',
inputs: [],
expanded: true
}
// build inputs for tool filter
for( var i = 0; i < tool_filters.length; i++ ) {
var filter = tool_filters[i],
helptext = filter['short_desc'] + " " + filter['desc'];
tools.inputs.push( { name: "t_" + filter['filterpath'],
type: 'boolean',
label: filter['filterpath'],
help: helptext,
value: filter['checked'] } );
}
all_inputs.push( tools );
}
if( section_filters.length > 0 ) {
sections = {
name: 'Edit ToolBox filters :: Sections',
type: 'section',
label: 'Edit ToolBox filters :: Sections',
inputs: [],
expanded: true
}
// build inputs for section filter
for( var i = 0; i < section_filters.length; i++ ) {
var filter = section_filters[i],
helptext = filter['short_desc'] + " " + filter['desc'];
sections.inputs.push( { name: "s_" + filter['filterpath'],
type: 'boolean',
label: filter['filterpath'],
help: helptext,
value: filter['checked'] } );
}
all_inputs.push( sections );
}
if( label_filters.length > 0 ) {
labels = {
name: 'Edit ToolBox filters :: Labels',
type: 'section',
label: 'Edit ToolBox filters :: Labels',
inputs: [],
expanded: true
}
// build inputs for label filters
for( var i = 0; i < label_filters.length; i++ ) {
var filter = label_filters[i],
helptext = filter['short_desc'] + " " + filter['desc'];
labels.inputs.push( { name: "l_" + filter['filterpath'],
type: 'boolean',
label: filter['filterpath'],
help: helptext,
value: filter['checked'] } );
}
all_inputs.push( labels );
}
}
return all_inputs;
},

/** Save the changes made to the filters */
_save: function() {
var url = Galaxy.root + 'api/user_preferences/change_toolbox_filters',
data = {},
self = this;
data = { 'edit_toolbox_filter': true, 'checked_filters': JSON.stringify( self.form.data.create() ) };
$.getJSON( url, data, function( response ) {
self.form.message.update({
message: response.message,
status: response.status === 'error' ? 'danger' : 'success',
});
var self = this;
$.ajax({
url : Galaxy.root + 'api/user_preferences/' + Galaxy.user.id + '/toolbox_filters',
type : 'PUT',
data : self.form.data.create(),
}).done( function( response ) {
self.form.message.update( { message: response.message, status: 'success' } );
}).fail( function( response ) {
self.form.message.update( { message: response.responseJSON.err_msg, status: 'danger' } );
});
}
});
});

});

0 comments on commit 1305b42

Please sign in to comment.