Skip to content

Commit

Permalink
improve frontend script + bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anatskiy committed Apr 7, 2017
1 parent bef2e2f commit c7f3de9
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 71 deletions.
3 changes: 1 addition & 2 deletions client/galaxy/scripts/onload.js
Expand Up @@ -19,8 +19,7 @@ var POPUPMENU = require( 'ui/popupmenu' );
window.make_popupmenu = POPUPMENU.make_popupmenu;
window.make_popup_menus = POPUPMENU.make_popup_menus;
window.init_tag_click_function = require( 'ui/autocom_tagging' );
window.utils = require('utils/utils');
window.toolform = require('mvc/tool/tool-form');
window.toolform = require( 'mvc/tool/tool-form' );
var TOURS = require( 'mvc/tours' );
var QUERY_STRING = require( 'utils/query-string-parsing' );
// console.debug( 'galaxy globals loaded' );
Expand Down
Expand Up @@ -8,7 +8,7 @@


def upload_test_data(trans, tests):
result = {'errors': []}
result = {'hid': '', 'errors': []}

if not tests:
raise ValueError('Tests are not defined.')
Expand Down Expand Up @@ -66,6 +66,8 @@ def upload_test_data(trans, tests):
job_errors = vars.get('job_errors', [])
if job_errors:
result['errors'] = job_errors
else:
result['hid'] = vars['out_data'][0][1].hid

return result

Expand Down Expand Up @@ -166,11 +168,12 @@ def main(trans, webhook, params):

tests = tool.tests
upload_result = upload_test_data(trans, tests)
data['hid'] = upload_result['hid']
if upload_result['errors']:
raise ValueError(str(upload_result['errors']))

# Generate Tour
data = generate_tour(tool)
data['tour'] = generate_tour(tool)

except Exception as e:
error = str(e)
Expand Down
95 changes: 33 additions & 62 deletions config/plugins/webhooks/demo/tour_generator/static/script.js
@@ -1,6 +1,5 @@
$(document).ready(function() {
var ToolForm = window.toolform,
Utils = window.utils;
var ToolForm = window.toolform;

var TourGenerator = Backbone.View.extend({
initialize: function(options) {
Expand All @@ -17,76 +16,48 @@ $(document).ready(function() {
$.getJSON(url, function(obj) {
if (obj.success) {
$('#history-refresh-button').click(); // Refresh history panel
// me._renderForm(obj);

var tour = me._generateTour(obj.data);

// Clean tour run
tour.init();
tour.goTo(0);
tour.restart();
// Create a tour only when the uploaded dataset is ready
setTimeout(function() {
var dataset = Galaxy.currHistoryPanel.collection.where({
hid: obj.data.hid
})[0];

if (dataset) {
dataset.on('change:state', function(model) {
if (model.get('state') === 'ok') {
me._main(obj.data);
}
});
}
}, 500);
} else {
console.error('Tour Generator: ' + obj.error);
console.error(obj);
}
});
},

// _renderForm: function(obj) {
// var me = this,
// tool = Galaxy.toolPanel.get('tools').get({
// id: this.toolId
// });

// // Method #1
// // var toolForm = Galaxy.page.center.prev.form;

// // Method #2
// var toolForm = new ToolForm.View({
// id: tool.get('id'),
// version: tool.get('version')
// });

// // Show form
// toolForm.deferred.execute(function() {
// Galaxy.app.display(toolForm);
// });

// // Update form model
// var form = toolForm.form;
// form.deferred.reset();
// form.deferred.execute(function(process) {
// me._updateModel(form, process);
// });
// },
_main: function(data) {
var tool = Galaxy.toolPanel.get('tools').get({
id: this.toolId
});

// _updateModel: function(form, process) {
// var formData = form.data.create();
// Create tool form
var toolForm = new ToolForm.View({
id: tool.get('id'),
version: tool.get('version')
});

// var currentState = {
// tool_id: this.toolId,
// tool_version: '1.0.2',
// inputs: $.extend(true, {}, form.data.create())
// };
// form.wait(true);
// currentState.inputs.columnList = 'c3';
// Show the form
Galaxy.app.display(toolForm);

// Utils.request({
// url: Galaxy.root + 'api/tools/' + this.toolId + '/build',
// type: 'POST',
// data: currentState,
// success: function(newModel) {
// form.update(newModel['tool_model'] || newModel);
// form.options.update && form.options.update(newModel);
// form.wait(false);
// Galaxy.emit.debug('tool-form-base::_updateModel()', 'Received new model.', newModel);
// process.resolve();
// },
// error: function(response) {
// Galaxy.emit.debug('tool-form-base::_updateModel()', 'Refresh request failed.', response);
// process.reject();
// }
// });
// },
// Generate and run the tour
var tour = this._generateTour(data.tour);
tour.init();
tour.goTo(0);
tour.restart();
},

_generateTour: function(data) {
var tourData = Tours.hooked_tour_from_data(data);
Expand Down
2 changes: 1 addition & 1 deletion static/maps/onload.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/scripts/bundled/libs.bundled.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/libs.bundled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/onload.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c7f3de9

Please sign in to comment.