Commit bc408845 authored by Daniele Venzano's avatar Daniele Venzano

Add checkbox to download JSON instead of starting ZApp, useful for command-line use

parent 2b1e3375
......@@ -180,6 +180,12 @@ form#zapp_start_form input {
font-family: "Lucida Console", Monaco, monospace;
}
form#zapp_start_form label.label-inline,
form#zapp_start_form label.label-inline input {
font-variant: normal;
display: inline;
}
/* footer */
div.status_line {
......
......@@ -37,11 +37,21 @@
<label>{{ param.readable_name }}:&nbsp;
<input name="{{ param.name }}" value="{{ param.default if param.default != None }}" required title="{{ param.description }}" size="128"/></label><br/>
{% endfor %}
<button type="submit">Start</button>
<label class="label-inline"><input type="checkbox" onchange="set_submit_text(this)" name="download_json"> Download JSON with these parameters for command-line execution</label>
<br><br>
<button id="submit" type="submit">Start</button>
</form>
<script>
$("#zapp_start_form").validate();
function set_submit_text(elem) {
if (elem.checked) {
$("#submit").text("Download JSON");
} else {
$("#submit").text("Start");
}
}
</script>
<p><a href="{{ reverse_url("zappshop") }}">Back to the ZApp shop</a></p>
......
......@@ -109,7 +109,15 @@ class ZAppStartWeb(ZoeRequestHandler):
app_descr = self._set_parameters(zapp.zoe_description, zapp.parameters)
new_id = self.api_endpoint.execution_start(uid, role, exec_name, app_descr)
download_json = self.get_argument('download_json')
if download_json:
self.set_header('Content-Type', 'application/json')
self.set_header('Content-Disposition', 'attachment; filename={}.json'.format(zapp_id))
self.write(app_descr)
self.finish()
return
else:
new_id = self.api_endpoint.execution_start(uid, role, exec_name, app_descr)
self.redirect(self.reverse_url('execution_inspect', new_id))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment