Skip to content
Snippets Groups Projects
Commit f3aa1a3f authored by Branson Craig Stephens's avatar Branson Craig Stephens
Browse files

Added a JS button for viewing skymap.json files in the skymapViewer hosted externally.

parent 96bfb21b
No related branches found
No related tags found
No related merge requests found
......@@ -624,7 +624,11 @@ def neighbors(request, graceid, delta1, delta2=None):
context,
context_instance=RequestContext(request))
import logging
def view(request, graceid):
logger = logging.getLogger(__name__)
logger.debug("Hi from inside the view.")
context = {}
try:
a = Event.getByGraceid(graceid)
......@@ -639,6 +643,8 @@ def view(request, graceid):
context['blessed_tags'] = settings.BLESSED_TAGS
context['single_inspiral_events'] = list(a.singleinspiral_set.all())
context['neighbor_delta'] = "[%+d,%+d]" % (-5,5)
context['SKYMAP_VIEWER_SERVICE_URL'] = settings.SKYMAP_VIEWER_SERVICE_URL
return render_to_response(
[ 'gracedb/event_detail_{0}.html'.format(a.analysisType),
'gracedb/event_detail.html'],
......
......@@ -40,6 +40,8 @@ XMPP_ALERT_CHANNELS = [
'external_grb',
]
SKYMAP_VIEWER_SERVICE_URL = "https://losc-gracedb.ligo.org/cgi-bin/skymapViewer"
BLESSED_TAGS = [
'analyst_comments',
'psd',
......
......@@ -93,6 +93,10 @@
dc += ' <td>{{log.comment|sanitize|escapejs}} \n';
{% if log.fileurl %}
dc += ' <a href="{{log.fileurl}}">{{log.filename}}</a> \n';
// If this is a skymap.json file, we want a button.
{% if log.filename == "skymap.json" %}
dc += ' <button type="button" data-dojo-type="dijit/form/Button" id="sV_button" class="modButtonClass">View in skymapViewer!</button> \n';
{% endif %}
{% endif %}
dc += ' </td> \n';
dc += ' </tr> \n';
......@@ -491,6 +495,28 @@
new Tooltip({ connectId: tag.button_id, label: "delete this tag"});
}
// Handle the post to skymapViewer button.
var sV_button = dom.byId("sV_button");
if (sV_button) {
on(sV_button, "click", function() {
// construct skymap.json url.
var skymap_json_url = "{% url "file" object.graceid "skymap.json" %}"
// fetch JSON content.
dojo.xhrGet({
url: skymap_json_url,
load: function(result) {
// Find the form and set its value to the appropriate JSON
sV_form = dom.byId("sV_form");
// Shove the skymap.json contents into the value for the second form field.
sV_form.elements[1].value = result;
// Submit the form, which takes the user to the skymapViewer server.
sV_form.submit();
}
});
});
}
});
</script>
......@@ -596,6 +622,18 @@
{% endblock %}
</div>
{# Enable post to skymap viewer #}
<div id="sV_form_div" style="display: none">
<!-- <form action="https://losc-gracedb.ligo.org/cgi-bin/skymapViewer" id="sV_form" method="post"> -->
<form action="{{ SKYMAP_VIEWER_SERVICE_URL }}" id="sV_form" method="post">
<input type="hidden" name="skymapid" value="{{ object.graceid }}">
<!-- <input type="hidden" name="json" value="{{ skymap_json }}"> -->
<input type="hidden" name="json" value="blaargh">
<input type="submit" value="View in skymapViewer!">
</form>
</div>
<!-- Neighbors Support refresh_neighbors() function -->
<script type="text/javascript">
var refresh_neighbors= function() { alert("NOT SET YET"); };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment