/
slides.html
155 lines (111 loc) · 4.32 KB
/
slides.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
---
layout: tutorial_slides
logo: "GTN"
title: "Galaxy Webhooks"
questions:
- "What are Galaxy Webhooks?"
- "How to create them?"
objectives:
- "Discover what Galaxy Webhooks are"
- "Be able to create Webhooks"
- "Be able to add a Galaxy Webhook in a Galaxy instance"
time_estimation: "1h"
key_points:
- "A Galaxy Webhook provides an easy way to customize the Galaxy UI with plugins"
- "Right now there are 4 entry points: tool, workflow, masthead, history-menu"
- "With a minimal amount of code you can extend Galaxy's user-interace."
contributors:
- blankclemens
- martenson
- bgruening
subtopic: advanced
---
### What are Galaxy Webhooks?
A system which can be used to attach new functionalities to predefined entry points in the Galaxy interface.
An accessible way to make isolated customisations to a Galaxy instance.
---
### Entry point: masthead
![A person shaped icon in the Galaxy masthead is being hovered over and the popup reads "Show Username", presumably a custom webhook from a tutorial.](../../images/webhook_masthead.png)
Adds item to the top menu.
---
### Entry point: tool/workflow submission
![Screenshot of Galaxy with the job completion screen shown and a PhD comic image shown below.](../../images/webhook_tool.png)
Shown after tool or workflow execution.
---
### Entry point: tool-menu
Adds an entry to the tool form menu.
---
### Entry point: history-menu
![A section of the history menu is labelled Webhooks and shows a custom menu entry.](../../images/webhook_history.png)
Adds an entry to the history menu.
---
### What is a webhook made of?
- a config file in YAML format: `config/<NAME>.yml`
- optional: A Python helper file with access to the Galaxy `trans` object
- `helper/__init__.py`
- provides an API call at `/api/webhooks/<WEBHOOK_NAME>/get_data`
- optional: Additional `JS` and `CSS` code
- `static/script.js`
- `static/styles.css`
---
### Example configuration YAML
```yaml
name: trans_object
type:
- masthead
activate: true
icon: fa-user
tooltip: Show Username
function: >
$.getJSON("/api/webhooks/trans_object/get_data", function(data) {
alert('Username: ' + data.username);
});
```
---
### Definition of the configuration options
Argument | Description
--- | ---
`name` | Name of the Webhook (and API call)
`type` | Entry point. `tool/workflow/masthead/history-menu`. More might be available in future
`activate` | (De-)Activates the Webhook. `true/false`
`icon` | Icon to show for a `masthead` plugin. Full list of available icons [here](https://fontawesome.com/icons)
`tooltip` | Tooltip to show for `masthead` plugins
`function` | JavaScript code to run when `masthead` button is clicked
---
### Example `__init__.py`
```python
def main(trans, webhook):
if trans.user:
user = trans.user.username
else:
user = 'No user is logged in.'
return {'username': user}
```
The return value can be read with a call to `/api/webhooks/WEBHOOK_NAME/get_data`
---
### Want to integrate Webhooks in your Galaxy instance?
- Copy your Webhook to your Webhook directory on your Galaxy instance
- default: `config/plugins/webhooks`
- configurable via `webhooks_dir` in `galaxy.yml`
- Restart Galaxy. While developing, changes at the `__init__.py` file will be active immediately
---
### Want to contribute?
- Create Webhooks and share them with the world!
- on the [main Galaxy repository](https://github.com/galaxyproject/galaxy)
- Improve the Webhooks implementation
- enhance existing entry points
- add additional ones ...
- Improve the documentation or training material
- [Documentation](https://docs.galaxyproject.org/en/latest/admin/special_topics/webhooks.html)
- [Galaxy Training Network]({{site.url}}]{{site.baseurl}})
---
### Developing the Webhooks implementation
- Webhooks initialisation: `lib/galaxy/webhooks/__init__.py`
- JavaScript logic: `client/galaxy/scripts/mvc/webhooks.js`
- Entry points
- `client/galaxy/scripts/mvc/tool/tool-form.js`
- `client/galaxy/scripts/mvc/tool/tool-form-composite.js`
- `client/galaxy/scripts/mvc/history/options-menu.js`
- `client/galaxy/scripts/layout/menu-js`
- API: `lib/galaxy/webapps/galaxy/api/webhooks.py`
- `lib/galaxy/webapps/galaxy/buildapp.py`