-
Notifications
You must be signed in to change notification settings - Fork 42
/
photometry_datalist_for_target.html
121 lines (120 loc) · 5.11 KB
/
photometry_datalist_for_target.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
{% load bootstrap4 %}
{% load tom_common_extras %}
<form method="POST" action="{% url 'tom_dataproducts:share_all' tg_pk=target.id %}" enctype="multipart/form-data" id="photometry-data-share-form">
{% csrf_token %}
{% for hidden in target_data_share_form.hidden_fields %}
{{ hidden }}
{% endfor %}
<div class="card">
<div class="card-header">
Photometry Data
</div>
<table id="photData" class="table table-striped table-hover table-sm" cellspacing="0" width="100%">
<thead>
<tr><th><div class="form-check">
<input type="checkbox" class="form-check-input" id="share-all" onclick="select_all()" value=""/>
<label class="form-check-label" for="share-all">Share</label>
</div></th>
<th>Timestamp</th>
<th>Telescope</th>
<th>Filter</th>
<th>Magnitude</th>
<th>Error</th>
<th>Source</th>
</tr>
</thead>
<tbody>
{% for datum in data %}
<tr>
<td><input type="checkbox" class="phot-row" id="phot-row-{{ datum.id }}" name="share-box" value="{{ datum.id }}" onchange="check_selected()"></td>
<td>{{ datum.timestamp }}</td>
<td>{{ datum.telescope }}</td>
<td>{{ datum.filter }}</td>
<td>
<!-- prepend greater-than sign if this is a magnitude limit -->
{% if datum.limit %}>{% endif %}
{{ datum.magnitude|truncate_number }}
</td>
<td>{{ datum.magnitude_error }}</td>
<td>{{ datum.source }}</td>
</tr>
{% empty %}
<tr>
<td colspan="2">No Photometry Data.</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if not target_share %}
<div class="card">
<div class="card-header">
Share Selected Data
</div>
{% if sharing_destinations %}
<div class="form-row" style="padding-inline:1rem">
<div class="col-sm-12">
{% bootstrap_field target_data_share_form.share_title %}
</div>
</div>
<div class="form-row" style="padding-inline:1rem">
<div class="col-sm-12">
{% bootstrap_field target_data_share_form.share_message %}
</div>
</div>
<div class="form-row" style="padding-inline:1rem">
<div class="col-sm-4">
{% bootstrap_field target_data_share_form.share_destination %}
</div>
<div class="col-sm-2 offset-sm-1">
<input type="submit" class="btn btn-primary" id="submit_selected" value="Submit" name="share_targetdata_form" style="position:absolute; bottom:1rem" disabled onclick="setTargetOnPhotometryForm('')">
</div>
{% if hermes_sharing %}
<div class="col-sm-1">
<b style="position:absolute; bottom:1.2rem">or</b>
</div>
<div class="col-sm-4">
<button class="btn btn-info" type="submit" formaction="{% url 'tom_targets:hermes-preload' pk=target.id %}" onclick="setTargetOnPhotometryForm('_blank')" style="position:absolute; bottom:1rem">Open in Hermes 🗗</button>
</div>
{% endif %}
</div>
{% else %}
<em style="padding-inline:1rem">Not Configured. See
<a href="https://tom-toolkit.readthedocs.io/en/stable/managing_data/tom_direct_sharing.html"
target="_blank">Documentation</a>.</em>
{% endif %}
</div>
{% endif %}
</div>
</form>
<script>
const photometryShareForm = document.getElementById('photometry-data-share-form');
function setTargetOnPhotometryForm(val) {
if (val && val != '') {
photometryShareForm.setAttribute('target', val);
}
else{
photometryShareForm.removeAttribute('target');
}
return true;
};
function select_all() {
var share_all = document.getElementById("share-all");
if(share_all.checked == true){
$('input[name=share-box]').prop('checked', true);
} else {
$('input[name=share-box]').prop('checked', false);
}
check_selected()
}
function check_selected() {
var share_boxes = document.getElementsByName("share-box");
var submit_btn = document.getElementById('submit_selected');
for (const box of share_boxes) {
if(box.checked == true) {
submit_btn.disabled = false;
return;
}
}
submit_btn.disabled = true;
}
</script>