Skip to content

Commit 88790bd

Browse files
authored
Merge pull request #43 from common-workflow-language/suggested-workflows
Add suggested workflows from cwl/workflows repository
2 parents 7818a9c + 981092c commit 88790bd

File tree

5 files changed

+171
-118
lines changed

5 files changed

+171
-118
lines changed

src/main/resources/static/css/main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ body {
3434
margin-top: -61px;
3535
}
3636

37+
.alert-grey {
38+
color: #7d7d7d;
39+
background-color: #f8f8f8;
40+
}
41+
3742
#logo {
3843
height: 61px;
3944
margin-top: -20px;

src/main/resources/static/js/main.js

Lines changed: 6 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -23,128 +23,17 @@
2323
requirejs.config({
2424
baseUrl: '/bower_components',
2525
paths: {
26-
d3: 'd3/d3',
27-
'dot-checker': 'graphviz-d3-renderer/dist/dot-checker',
28-
'layout-worker': 'graphviz-d3-renderer/dist/layout-worker',
29-
worker: 'requirejs-web-workers/src/worker',
30-
renderer: 'graphviz-d3-renderer/dist/renderer',
3126
jquery: 'jquery/dist/jquery.min',
32-
'bootstrap.modal': 'bootstrap/js/modal',
33-
'svg-pan-zoom': 'svg-pan-zoom/dist/svg-pan-zoom.min'
34-
},
35-
shim: {
36-
'bootstrap.modal': {
37-
deps: ['jquery']
38-
}
3927
}
4028
});
4129

4230
/**
43-
* Main rendering code for the graphs on a workflow page
44-
*/
45-
require(['jquery', 'bootstrap.modal', 'renderer', 'svg-pan-zoom'],
46-
function ($, modal, renderer, svgPanZoom) {
47-
// Load dot graph from the page
48-
var dotGraph = $("#dot").val();
49-
50-
// Initialise graph
51-
renderer.init("#graph");
52-
53-
// Update stage with new dot source
54-
renderer.render(dotGraph);
55-
56-
// Fade the loading and show graph when graph is drawn
57-
renderer.renderHandler(function() {
58-
$("#loading").fadeOut();
59-
60-
// Enable svg-pan-zoom on the graph after load transition
61-
setTimeout(function() {
62-
svgPanZoom('svg', {
63-
zoomEnabled: true,
64-
controlIconsEnabled: true
65-
});
66-
}, 1000);
67-
});
68-
69-
/**
70-
* Download the rendered graph as a png
71-
*/
72-
$('#download-graph').click(function (event) {
73-
// Get the image data
74-
var img = renderer.stage.getImage(false);
75-
76-
// Once it is loaded
77-
img.onload = function () {
78-
// Set hidden download link href to contents and click it
79-
var downloadLink = $("#download-link-graph");
80-
downloadLink.attr("href", img.src);
81-
downloadLink[0].click();
82-
};
83-
84-
// Stop default button action
85-
event.preventDefault();
86-
});
87-
88-
/**
89-
* DOT graph modal textarea automatically focuses when opened
90-
*/
91-
$('#dotGraph').on('shown.bs.modal', function () {
92-
$('#dot').focus();
93-
})
94-
95-
/**
96-
* DOT graph textarea focus selects all
97-
*/
98-
$("#dot").focus(function() {
99-
$(this).select();
100-
});
101-
102-
/**
103-
* Downloading of the DOT graph as a .gv file
104-
*/
105-
$('#download-dot').click(function (event) {
106-
// Generate download link src
107-
var dotGraph = $("#dot").val();
108-
var src = "data:text/plain;charset=utf-8," + encodeURIComponent(dotGraph);
109-
110-
// Set hidden download link href to contents and click it
111-
var downloadLink = $("#download-link-dot");
112-
downloadLink.attr("href", src);
113-
downloadLink[0].click();
114-
115-
// Stop default button action
116-
event.preventDefault();
117-
});
118-
});
119-
120-
/**
121-
* Code for including the link to the Research Object Bundle download
122-
* without refresh once generated
31+
* Handles suggestions on the main page
12332
*/
12433
require(['jquery'],
12534
function ($) {
126-
// AJAX function to add download link to page if generated
127-
function getDownloadLink() {
128-
$.ajax({
129-
type: 'HEAD',
130-
url: $('#download').attr('href'),
131-
dataType: "json",
132-
success: function (data) {
133-
$("#generating").addClass("hide");
134-
$("#generated").removeClass("hide");
135-
},
136-
error: function () {
137-
// Retry in 5 seconds if still not generated
138-
setTimeout(function () {
139-
getDownloadLink();
140-
}, 5000)
141-
}
142-
});
143-
}
144-
145-
// If ajaxRequired exists on the page the RO bundle link is not generated
146-
// at time of page load
147-
if ($("#ajaxRequired").length) {
148-
getDownloadLink();
149-
}
150-
});
35+
$(".example").click(function(e) {
36+
$("#githubURL").val($(this).attr("href"));
37+
e.preventDefault();
38+
});
39+
});
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* RequireJS configuration with all possible dependencies
22+
*/
23+
requirejs.config({
24+
baseUrl: '/bower_components',
25+
paths: {
26+
d3: 'd3/d3',
27+
'dot-checker': 'graphviz-d3-renderer/dist/dot-checker',
28+
'layout-worker': 'graphviz-d3-renderer/dist/layout-worker',
29+
worker: 'requirejs-web-workers/src/worker',
30+
renderer: 'graphviz-d3-renderer/dist/renderer',
31+
jquery: 'jquery/dist/jquery.min',
32+
'bootstrap.modal': 'bootstrap/js/modal',
33+
'svg-pan-zoom': 'svg-pan-zoom/dist/svg-pan-zoom.min'
34+
},
35+
shim: {
36+
'bootstrap.modal': {
37+
deps: ['jquery']
38+
}
39+
}
40+
});
41+
42+
/**
43+
* Main rendering code for the graphs on a workflow page
44+
*/
45+
require(['jquery', 'bootstrap.modal', 'renderer', 'svg-pan-zoom'],
46+
function ($, modal, renderer, svgPanZoom) {
47+
// Load dot graph from the page
48+
var dotGraph = $("#dot").val();
49+
50+
// Initialise graph
51+
renderer.init("#graph");
52+
53+
// Update stage with new dot source
54+
renderer.render(dotGraph);
55+
56+
// Fade the loading and show graph when graph is drawn
57+
renderer.renderHandler(function() {
58+
$("#loading").fadeOut();
59+
60+
// Enable svg-pan-zoom on the graph after load transition
61+
setTimeout(function() {
62+
svgPanZoom('svg', {
63+
zoomEnabled: true,
64+
controlIconsEnabled: true
65+
});
66+
}, 1000);
67+
});
68+
69+
/**
70+
* Download the rendered graph as a png
71+
*/
72+
$('#download-graph').click(function (event) {
73+
// Get the image data
74+
var img = renderer.stage.getImage(false);
75+
76+
// Once it is loaded
77+
img.onload = function () {
78+
// Set hidden download link href to contents and click it
79+
var downloadLink = $("#download-link-graph");
80+
downloadLink.attr("href", img.src);
81+
downloadLink[0].click();
82+
};
83+
84+
// Stop default button action
85+
event.preventDefault();
86+
});
87+
88+
/**
89+
* DOT graph modal textarea automatically focuses when opened
90+
*/
91+
$('#dotGraph').on('shown.bs.modal', function () {
92+
$('#dot').focus();
93+
})
94+
95+
/**
96+
* DOT graph textarea focus selects all
97+
*/
98+
$("#dot").focus(function() {
99+
$(this).select();
100+
});
101+
102+
/**
103+
* Downloading of the DOT graph as a .gv file
104+
*/
105+
$('#download-dot').click(function (event) {
106+
// Generate download link src
107+
var dotGraph = $("#dot").val();
108+
var src = "data:text/plain;charset=utf-8," + encodeURIComponent(dotGraph);
109+
110+
// Set hidden download link href to contents and click it
111+
var downloadLink = $("#download-link-dot");
112+
downloadLink.attr("href", src);
113+
downloadLink[0].click();
114+
115+
// Stop default button action
116+
event.preventDefault();
117+
});
118+
});
119+
120+
/**
121+
* Code for including the link to the Research Object Bundle download
122+
* without refresh once generated
123+
*/
124+
require(['jquery'],
125+
function ($) {
126+
// AJAX function to add download link to page if generated
127+
function getDownloadLink() {
128+
$.ajax({
129+
type: 'HEAD',
130+
url: $('#download').attr('href'),
131+
dataType: "json",
132+
success: function (data) {
133+
$("#generating").addClass("hide");
134+
$("#generated").removeClass("hide");
135+
},
136+
error: function () {
137+
// Retry in 5 seconds if still not generated
138+
setTimeout(function () {
139+
getDownloadLink();
140+
}, 5000)
141+
}
142+
});
143+
}
144+
145+
// If ajaxRequired exists on the page the RO bundle link is not generated
146+
// at time of page load
147+
if ($("#ajaxRequired").length) {
148+
getDownloadLink();
149+
}
150+
});

src/main/resources/templates/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ <h2>Workflow from Github URL</h2>
4949
<div class="alert alert-danger" th:if="${#fields.hasErrors('githubURL')}">
5050
<strong>Error:</strong> <span th:errors="*{githubURL}">Error message here</span>
5151
</div>
52+
<div class="alert alert-grey">
53+
<strong>Don't know what to view?</strong> Try these from <i>common-workflow-language/workflows</i>:
54+
<a class="example" href="https://github.com/common-workflow-language/workflows/tree/master/workflows/compile">compile</a>,
55+
<a class="example" href="https://github.com/common-workflow-language/workflows/tree/master/workflows/make-to-cwl">make-to-cwl</a>,
56+
<a class="example" href="https://github.com/common-workflow-language/workflows/tree/master/workflows/lobSTR">lobSTR</a>,
57+
<a class="example" href="https://github.com/common-workflow-language/workflows/tree/master/workflows/scidap">scidap</a>
58+
</div>
5259
<div class="input-group">
5360
<input type="text" class="form-control" placeholder="Github URL" id="githubURL" name="githubURL" th:field="*{githubURL}" th:value="${formURL}" />
5461
<span class="input-group-btn">
@@ -61,5 +68,7 @@ <h2>Workflow from Github URL</h2>
6168
</div>
6269

6370
<div th:replace="fragments/footer :: copy"></div>
71+
72+
<script src="/bower_components/requirejs/require.js" data-main="/js/main.js"></script>
6473
</body>
6574
</html>

src/main/resources/templates/workflow.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,6 @@ <h2>Steps</h2>
189189

190190
<div th:replace="fragments/footer :: copy"></div>
191191

192-
<script src="/bower_components/requirejs/require.js" data-main="/js/main.js"></script>
192+
<script src="/bower_components/requirejs/require.js" data-main="/js/workflow.js"></script>
193193
</body>
194194
</html>

0 commit comments

Comments
 (0)