bug fixes and improvements

This commit is contained in:
Evgeny Anatskiy
2016-10-09 21:29:27 +02:00
parent f3b1232bdb
commit 578bdf679f
11 changed files with 85 additions and 49 deletions
@@ -141,30 +141,9 @@ var menu = [
}
];
// Webhooks
Webhooks.addToHistoryMenu(_l, menu);
var webhooks = new Webhooks.Webhooks();
webhooks.url = Galaxy.root + 'api/webhooks/history-menu/all';
webhooks.fetch({
async: false, // slows down History Panel loading
success: function() {
if (webhooks.length > 0) {
menu.push({
html : _l( 'Webhooks' ),
header : true
});
$.each(webhooks.models, function(index, model) {
var webhook = model.toJSON();
menu.push({
html : _l( webhook.config.title ),
anon : true
});
});
}
}
});
function buildMenu( isAnon, purgeAllowed, urlRoot ){
return _.clone( menu ).filter( function( menuOption ){
+1 -1
View File
@@ -85,7 +85,7 @@ define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form
if ( response.jobs && response.jobs.length > 0 ) {
self.$el.append( $( '<div/>', { id: 'webhook-view' } ) );
var WebhookApp = new Webhooks.WebhookView({
urlRoot: Galaxy.root + 'api/webhooks/tools'
urlRoot: Galaxy.root + 'api/webhooks/tool'
});
}
+62 -18
View File
@@ -5,7 +5,7 @@ define([], function() {
var WebhookModel = Backbone.Model.extend({
defaults: {
activate: true
activate: false
}
});
@@ -30,29 +30,73 @@ define([], function() {
render: function() {
var webhook = this.model.toJSON();
if (webhook.type == 'masthead' && webhook.activate) {
// There must be a better way to make sure Galaxy is fully loaded
$(document).ready(function() {
Galaxy.page.masthead.collection.add({
id : webhook.name,
icon : (typeof webhook.config.icon != 'undefined') ? webhook.config.icon : '',
url : (typeof webhook.config.url != 'undefined') ? webhook.config.url : '',
tooltip : (typeof webhook.config.tooltip != 'undefined') ? webhook.config.tooltip : '',
// visible : webhook.activate
});
});
if (webhook.activate) {
this.$el.html('<div id="' + webhook.name + '"></div>');
if (webhook.styles) $('<style/>', {type: 'text/css'}).text(webhook.styles).appendTo('head');
if (webhook.script) $('<script/>', {type: 'text/javascript'}).text(webhook.script).appendTo('head');
}
this.$el.html('<div id="' + webhook.name + '"></div>');
if (webhook.styles) $('<style/>', {type: 'text/css'}).text(webhook.styles).appendTo('head');
if (webhook.script) $('<script/>', {type: 'text/javascript'}).text(webhook.script).appendTo('head');
return this;
}
});
var addToMastheadMenu = function() {
var webhooks = new Webhooks();
webhooks.url = Galaxy.root + 'api/webhooks/masthead/all';
webhooks.fetch({
success: function() {
$(document).ready(function() {
$.each(webhooks.models, function(index, model) {
var webhook = model.toJSON();
if (webhook.activate) {
Galaxy.page.masthead.collection.add({
id : webhook.name,
icon : (typeof webhook.config.icon != 'undefined') ? webhook.config.icon : '',
url : (typeof webhook.config.url != 'undefined') ? webhook.config.url : '',
tooltip : (typeof webhook.config.tooltip != 'undefined') ? webhook.config.tooltip : '',
// onclick : function() {},
// visible : webhook.activate
});
}
});
});
}
});
};
var addToHistoryMenu = function(_l, menu) {
var webhooks = new Webhooks();
webhooks.url = Galaxy.root + 'api/webhooks/history-menu/all';
webhooks.fetch({
async: false, // slows down History Panel loading
success: function() {
var webhooks_menu = [];
$.each(webhooks.models, function(index, model) {
var webhook = model.toJSON();
if (webhook.activate) {
webhooks_menu.push({
html : _l( webhook.config.title ),
// func: function() {},
anon : true
});
}
});
if (webhooks_menu.length > 0) {
webhooks_menu.unshift({
html : _l( 'Webhooks' ),
header : true
});
$.merge(menu, webhooks_menu);
}
}
});
};
return {
Webhooks: Webhooks,
WebhookView: WebhookView
WebhookView: WebhookView,
addToMastheadMenu: addToMastheadMenu,
addToHistoryMenu: addToHistoryMenu
};
});
@@ -2,3 +2,4 @@ name: history_test1
title: History Menu Webhook Item 1
type:
- history-menu
activate: false
@@ -2,3 +2,4 @@ name: history_test2
title: History Menu Webhook Item 2
type:
- history-menu
activate: false
@@ -1,6 +1,8 @@
name: masthead_test
icon: fa-repeat
type:
- masthead
activate: false
icon: fa-repeat
tooltip: Masthead Plugin Test
activate: true
@@ -1,4 +1,5 @@
name: phdcomics
type:
- tools
- tool
- workflow
activate: false
+2 -1
View File
@@ -1,4 +1,5 @@
name: xkcd
type:
- tools
- tool
- workflow
activate: true
+9 -2
View File
@@ -13,9 +13,10 @@ log = logging.getLogger(__name__)
<<<<<<< HEAD
class Webhook(object):
def __init__(self, w_name, w_type, w_path):
def __init__(self, w_name, w_type, w_activate, w_path):
self.name = w_name
self.type = w_type
self.activate = w_activate
self.path = w_path
self.styles = ''
self.script = ''
@@ -26,6 +27,7 @@ class Webhook(object):
return {
'name': self.name,
'type': self.type,
'activate': self.activate,
'styles': self.styles,
'script': self.script,
'config': self.config
@@ -67,7 +69,12 @@ class WebhooksRegistry(object):
with open(os.path.join(config_dir, config_file)) as f:
config = yaml.load(f)
path = os.path.normpath(os.path.join(config_dir, '..'))
webhook = Webhook(config['name'], config['type'], path)
webhook = Webhook(
config['name'],
config['type'],
config['activate'],
path,
)
# Read styles into a string, assuming all styles are in a
# single file
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"webhooks.js","sources":["../../src/mvc/webhooks.js"],"names":["define","WebhookModel","Backbone","Model","extend","defaults","activate","Webhooks","Collection","model","WebhookView","View","el","initialize","options","me","this","urlRoot","fetch","success","render","webhook","toJSON","type","$","document","ready","Galaxy","page","masthead","collection","add","id","name","icon","config","url","tooltip","$el","html","styles","text","appendTo","script"],"mappings":"AAGAA,UAAW,WAEP,GAAIC,GAAeC,SAASC,MAAMC,QAC9BC,UACIC,UAAU,KAIdC,EAAWL,SAASM,WAAWJ,QAC/BK,MAAOR,IAGPS,EAAcR,SAASS,KAAKP,QAC5BQ,GAAI,gBAEJC,WAAY,SAASC,GACjB,GAAIC,GAAKC,IAETA,MAAKP,MAAQ,GAAIR,GACjBe,KAAKP,MAAMQ,QAAUH,EAAQG,QAC7BD,KAAKP,MAAMS,OACPC,QAAS,WACLJ,EAAGK,aAKfA,OAAQ,WACJ,GAAIC,GAAUL,KAAKP,MAAMa,QAkBzB,OAhBoB,YAAhBD,EAAQE,MAAsBF,EAAQf,UAEtCkB,EAAEC,UAAUC,MAAM,WACdC,OAAOC,KAAKC,SAASC,WAAWC,KAC5BC,GAAUX,EAAQY,KAClBC,KAAyC,mBAAvBb,GAAQc,OAAOD,KAAuBb,EAAQc,OAAOD,KAAO,GAC9EE,IAAwC,mBAAtBf,GAAQc,OAAOC,IAAsBf,EAAQc,OAAOC,IAAM,GAC5EC,QAA4C,mBAA1BhB,GAAQc,OAAOE,QAA0BhB,EAAQc,OAAOE,QAAU,OAMhGrB,KAAKsB,IAAIC,KAAK,YAAclB,EAAQY,KAAO,YACvCZ,EAAQmB,QAAQhB,EAAE,YAAaD,KAAM,aAAakB,KAAKpB,EAAQmB,QAAQE,SAAS,QAChFrB,EAAQsB,QAAQnB,EAAE,aAAcD,KAAM,oBAAoBkB,KAAKpB,EAAQsB,QAAQD,SAAS,QACrF1B,OAIf,QACIT,SAAUA,EACVG,YAAaA"}
{"version":3,"file":"webhooks.js","sources":["../../src/mvc/webhooks.js"],"names":["define","WebhookModel","Backbone","Model","extend","defaults","activate","Webhooks","Collection","model","WebhookView","View","el","initialize","options","me","this","urlRoot","fetch","success","render","webhook","toJSON","$el","html","name","styles","$","type","text","appendTo","script","addToMastheadMenu","webhooks","url","Galaxy","root","document","ready","each","models","index","page","masthead","collection","add","id","icon","config","tooltip","addToHistoryMenu","_l","menu","async","webhooks_menu","push","title","anon","length","unshift","header","merge"],"mappings":"AAGAA,UAAW,WAEP,GAAIC,GAAeC,SAASC,MAAMC,QAC9BC,UACIC,UAAU,KAIdC,EAAWL,SAASM,WAAWJ,QAC/BK,MAAOR,IAGPS,EAAcR,SAASS,KAAKP,QAC5BQ,GAAI,gBAEJC,WAAY,SAASC,GACjB,GAAIC,GAAKC,IAETA,MAAKP,MAAQ,GAAIR,GACjBe,KAAKP,MAAMQ,QAAUH,EAAQG,QAC7BD,KAAKP,MAAMS,OACPC,QAAS,WACLJ,EAAGK,aAKfA,OAAQ,WACJ,GAAIC,GAAUL,KAAKP,MAAMa,QAoB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
View File
@@ -1,2 +1,2 @@
define([],function(){var a=Backbone.Model.extend({defaults:{activate:!0}}),b=Backbone.Collection.extend({model:a}),c=Backbone.View.extend({el:"#webhook-view",initialize:function(b){var c=this;this.model=new a,this.model.urlRoot=b.urlRoot,this.model.fetch({success:function(){c.render()}})},render:function(){var a=this.model.toJSON();return"masthead"==a.type&&a.activate&&$(document).ready(function(){Galaxy.page.masthead.collection.add({id:a.name,icon:"undefined"!=typeof a.config.icon?a.config.icon:"",url:"undefined"!=typeof a.config.url?a.config.url:"",tooltip:"undefined"!=typeof a.config.tooltip?a.config.tooltip:""})}),this.$el.html('<div id="'+a.name+'"></div>'),a.styles&&$("<style/>",{type:"text/css"}).text(a.styles).appendTo("head"),a.script&&$("<script/>",{type:"text/javascript"}).text(a.script).appendTo("head"),this}});return{Webhooks:b,WebhookView:c}});
define([],function(){var a=Backbone.Model.extend({defaults:{activate:!1}}),b=Backbone.Collection.extend({model:a}),c=Backbone.View.extend({el:"#webhook-view",initialize:function(b){var c=this;this.model=new a,this.model.urlRoot=b.urlRoot,this.model.fetch({success:function(){c.render()}})},render:function(){var a=this.model.toJSON();return a.activate&&(this.$el.html('<div id="'+a.name+'"></div>'),a.styles&&$("<style/>",{type:"text/css"}).text(a.styles).appendTo("head"),a.script&&$("<script/>",{type:"text/javascript"}).text(a.script).appendTo("head")),this}}),d=function(){var a=new b;a.url=Galaxy.root+"api/webhooks/masthead/all",a.fetch({success:function(){$(document).ready(function(){$.each(a.models,function(a,b){var c=b.toJSON();c.activate&&Galaxy.page.masthead.collection.add({id:c.name,icon:"undefined"!=typeof c.config.icon?c.config.icon:"",url:"undefined"!=typeof c.config.url?c.config.url:"",tooltip:"undefined"!=typeof c.config.tooltip?c.config.tooltip:""})})})}})},e=function(a,c){var d=new b;d.url=Galaxy.root+"api/webhooks/history-menu/all",d.fetch({async:!1,success:function(){var b=[];$.each(d.models,function(c,d){var e=d.toJSON();e.activate&&b.push({html:a(e.config.title),anon:!0})}),b.length>0&&(b.unshift({html:a("Webhooks"),header:!0}),$.merge(c,b))}})};return{Webhooks:b,WebhookView:c,addToMastheadMenu:d,addToHistoryMenu:e}});
//# sourceMappingURL=../../maps/mvc/webhooks.js.map