Skip to content

Commit

Permalink
Merge pull request #4 from dannon/auto_tour_generation
Browse files Browse the repository at this point in the history
Toastr Loading fixes.
  • Loading branch information
bgruening committed May 5, 2017
2 parents ce017c3 + c42941d commit d90a30f
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 105 deletions.
1 change: 0 additions & 1 deletion client/galaxy/scripts/onload.js
Expand Up @@ -19,7 +19,6 @@ 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.Toastr = require( 'libs/toastr' );
var TOURS = require( 'mvc/tours' );
var QUERY_STRING = require( 'utils/query-string-parsing' );
// console.debug( 'galaxy globals loaded' );
Expand Down
Expand Up @@ -8,10 +8,12 @@ icon: fa-puzzle-piece
title: Generate Tour

function: >
if (typeof TourGenerator !== 'undefined') {
new TourGenerator({toolId: options.id});
} else if (typeof Toastr !== 'undefined') {
Toastr.warning('Tour Generator is not loaded.');
} else {
alert('Tour Generator is not loaded.');
}
require(["libs/toastr"], function(Toastr) {
if (typeof TourGenerator !== 'undefined') {
new TourGenerator({toolId: options.id});
} else if (typeof Toastr !== 'undefined') {
Toastr.warning('Tour Generator is not loaded.');
} else {
alert('Tour Generator is not loaded.');
}
})
130 changes: 66 additions & 64 deletions config/plugins/webhooks/demo/tour_generator/static/script.js
@@ -1,77 +1,79 @@
$(document).ready(function() {
window.TourGenerator = Backbone.View.extend({
initialize: function(options) {
var me = this;
this.toolId = options.toolId;
require(['libs/toastr'], function(Toastr){
window.TourGenerator = Backbone.View.extend({
initialize: function(options) {
var me = this;
this.toolId = options.toolId;

// Add attribute 'tour_id' to the execution button
$('#execute').attr('tour_id', 'execute');
// Add attribute 'tour_id' to the execution button
$('#execute').attr('tour_id', 'execute');

Toastr.info('Tour generation might take some time.');
$.getJSON('/api/webhooks/tour_generator/get_data/', {
tool_id: this.toolId
}, function(obj) {
if (obj.success) {
if (obj.data.useDatasets) {
Galaxy.currHistoryPanel.refreshContents(); // Refresh history panel
Toastr.info('Tour generation might take some time.');
$.getJSON('/api/webhooks/tour_generator/get_data/', {
tool_id: this.toolId
}, function(obj) {
if (obj.success) {
if (obj.data.useDatasets) {
Galaxy.currHistoryPanel.refreshContents(); // Refresh history panel

// Add a delay because of the history panel refreshing
setTimeout(function () {
var datasets = [],
numUploadedDatasets = 0;
// Add a delay because of the history panel refreshing
setTimeout(function () {
var datasets = [],
numUploadedDatasets = 0;

_.each(obj.data.hids, function (hid) {
var dataset = Galaxy.currHistoryPanel.collection.where({
hid: hid
})[0];
if (dataset) datasets.push(dataset);
});

if (datasets.length === obj.data.hids.length) {
_.each(datasets, function (dataset) {
if (dataset.get('state') === 'ok') {
numUploadedDatasets++;
} else {
dataset.on('change:state', function (model) {
if (model.get('state') === 'ok') numUploadedDatasets++;
// Make sure that all test datasets have been successfully uploaded
if (numUploadedDatasets === datasets.length) me._generateTour(obj.data.tour);
});
}
_.each(obj.data.hids, function (hid) {
var dataset = Galaxy.currHistoryPanel.collection.where({
hid: hid
})[0];
if (dataset) datasets.push(dataset);
});
} else {
Toastr.warning('Cannot generate a tour.');
console.error('Some of the test datasets cannot be found in the history.');
}
}, 1500);

if (datasets.length === obj.data.hids.length) {
_.each(datasets, function (dataset) {
if (dataset.get('state') === 'ok') {
numUploadedDatasets++;
} else {
dataset.on('change:state', function (model) {
if (model.get('state') === 'ok') numUploadedDatasets++;
// Make sure that all test datasets have been successfully uploaded
if (numUploadedDatasets === datasets.length) me._generateTour(obj.data.tour);
});
}
});
} else {
Toastr.warning('Cannot generate a tour.');
console.error('Some of the test datasets cannot be found in the history.');
}
}, 1500);
} else {
me._generateTour(obj.data.tour);
}
} else {
me._generateTour(obj.data.tour);
Toastr.warning('Cannot generate a tour.');
console.error('Tour Generator: ' + obj.error);
}
} else {
Toastr.warning('Cannot generate a tour.');
console.error('Tour Generator: ' + obj.error);
}
});
},
});
},

_generateTour: function(data) {
var tourData = Tours.hooked_tour_from_data(data);
sessionStorage.setItem('activeGalaxyTour', JSON.stringify(data));
_generateTour: function(data) {
var tourData = Tours.hooked_tour_from_data(data);
sessionStorage.setItem('activeGalaxyTour', JSON.stringify(data));

// Generate and run the tour
var tour = new Tour(_.extend({
steps: tourData.steps
}));
tour.init();
tour.goTo(0);
tour.restart();
// Generate and run the tour
var tour = new Tour(_.extend({
steps: tourData.steps
}));
tour.init();
tour.goTo(0);
tour.restart();

// Force ending the tour when pressing the Execute button
$('#execute').on('mousedown', function() {
if (tour) {
tour.end();
}
});
}
// Force ending the tour when pressing the Execute button
$('#execute').on('mousedown', function() {
if (tour) {
tour.end();
}
});
}
});
});
});
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.

24 changes: 12 additions & 12 deletions static/scripts/bundled/analysis.bundled.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

32 changes: 16 additions & 16 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.

0 comments on commit d90a30f

Please sign in to comment.