|
a |
|
b/qiita_pet/templates/stats.html |
|
|
1 |
{% extends sitebase.html %} |
|
|
2 |
{% block head %} |
|
|
3 |
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/ol.css" type="text/css"> |
|
|
4 |
<style type="text/css"> |
|
|
5 |
#map-canvas { height: 500px; } |
|
|
6 |
|
|
|
7 |
.ol-popup { |
|
|
8 |
position: absolute; |
|
|
9 |
background-color: white; |
|
|
10 |
-webkit-filter: drop-shadow(0 1px 4px rgba(0,0,0,0.2)); |
|
|
11 |
filter: drop-shadow(0 1px 4px rgba(0,0,0,0.2)); |
|
|
12 |
padding: 15px; |
|
|
13 |
border-radius: 10px; |
|
|
14 |
border: 1px solid #cccccc; |
|
|
15 |
bottom: 12px; |
|
|
16 |
left: -50px; |
|
|
17 |
min-width: 180px; |
|
|
18 |
} |
|
|
19 |
.ol-popup:after, .ol-popup:before { |
|
|
20 |
top: 100%; |
|
|
21 |
border: solid transparent; |
|
|
22 |
content: " "; |
|
|
23 |
height: 0; |
|
|
24 |
width: 0; |
|
|
25 |
position: absolute; |
|
|
26 |
pointer-events: none; |
|
|
27 |
} |
|
|
28 |
.ol-popup:after { |
|
|
29 |
border-top-color: white; |
|
|
30 |
border-width: 10px; |
|
|
31 |
left: 48px; |
|
|
32 |
margin-left: -10px; |
|
|
33 |
} |
|
|
34 |
.ol-popup:before { |
|
|
35 |
border-top-color: #cccccc; |
|
|
36 |
border-width: 11px; |
|
|
37 |
left: 48px; |
|
|
38 |
margin-left: -11px; |
|
|
39 |
} |
|
|
40 |
.ol-popup-closer { |
|
|
41 |
text-decoration: none; |
|
|
42 |
position: absolute; |
|
|
43 |
top: 2px; |
|
|
44 |
right: 8px; |
|
|
45 |
} |
|
|
46 |
.ol-popup-closer:after { |
|
|
47 |
content: "✖"; |
|
|
48 |
} |
|
|
49 |
</style> |
|
|
50 |
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/ol.js"></script> |
|
|
51 |
|
|
|
52 |
<script type="text/javascript"> |
|
|
53 |
// -> Borrowed from https://stackoverflow.com/q/32102584 |
|
|
54 |
// internal function to avoid duplication of code |
|
|
55 |
function _generate_iconFeature(sid, lat, lng) { |
|
|
56 |
var iconFeature = new ol.Feature({ |
|
|
57 |
geometry: new ol.geom.Point(ol.proj.transform([lng, lat], 'EPSG:4326', 'EPSG:3857')), |
|
|
58 |
study_id: sid, |
|
|
59 |
}); |
|
|
60 |
return iconFeature; |
|
|
61 |
} |
|
|
62 |
// adding features via the lat/long |
|
|
63 |
var iconFeatures = []; |
|
|
64 |
{% for sid, lat, lng in lat_longs %} |
|
|
65 |
{% if lat > -90 and lat < 90 and lng > -180 and lng < 180 %} |
|
|
66 |
iconFeatures.push(_generate_iconFeature({% raw sid %}, {% raw lat %}, {% raw lng %})); |
|
|
67 |
{% end %} |
|
|
68 |
{% end %} |
|
|
69 |
// creating new verctor &layer for the markers |
|
|
70 |
var vectorSource = new ol.source.Vector({ features: iconFeatures }); |
|
|
71 |
var vectorLayer = new ol.layer.Vector({ source: vectorSource }); |
|
|
72 |
|
|
|
73 |
$( document ).ready(function() { |
|
|
74 |
// creating map |
|
|
75 |
var map = new ol.Map({ |
|
|
76 |
target: 'map-canvas', |
|
|
77 |
layers: [ |
|
|
78 |
new ol.layer.Tile({ |
|
|
79 |
source: new ol.source.OSM() |
|
|
80 |
}), |
|
|
81 |
vectorLayer |
|
|
82 |
], |
|
|
83 |
view: new ol.View({ |
|
|
84 |
center: ol.proj.fromLonLat([{% raw qiita_config.stats_map_center_longitude %}, {% raw qiita_config.stats_map_center_latitude %}]), |
|
|
85 |
zoom: 4 |
|
|
86 |
}) |
|
|
87 |
}); |
|
|
88 |
|
|
|
89 |
var closer = document.getElementById('map-canvas-popup-closer'); |
|
|
90 |
closer.onclick = function() { |
|
|
91 |
overlay.setPosition(undefined); |
|
|
92 |
closer.blur(); |
|
|
93 |
return false; |
|
|
94 |
}; |
|
|
95 |
var container = document.getElementById('map-canvas-popup'); |
|
|
96 |
var overlay = new ol.Overlay({ |
|
|
97 |
element: container, |
|
|
98 |
positioning: 'bottom-center', |
|
|
99 |
autoPan: true, |
|
|
100 |
offset: [0, 0], |
|
|
101 |
autoPanAnimation: { |
|
|
102 |
duration: 250 |
|
|
103 |
} |
|
|
104 |
}); |
|
|
105 |
map.addOverlay(overlay); |
|
|
106 |
|
|
|
107 |
map.on('click', function(evt) { |
|
|
108 |
var feature = map.forEachFeatureAtPixel(evt.pixel, |
|
|
109 |
function(feature) { |
|
|
110 |
return feature; |
|
|
111 |
}); |
|
|
112 |
if (feature) { |
|
|
113 |
var coordinates = feature.getGeometry().getCoordinates(); |
|
|
114 |
var content = document.getElementById('map-canvas-popup-content'); |
|
|
115 |
var study_id = feature.get('study_id'); |
|
|
116 |
var text = 'Sample from study: ' + study_id; |
|
|
117 |
{% if user is not None %} |
|
|
118 |
content.innerHTML = '<a target="_blank" href="{% raw qiita_config.portal_dir %}/study/description/' + study_id + '">' + text + '</a>'; |
|
|
119 |
{% else %} |
|
|
120 |
content.innerHTML = text; |
|
|
121 |
{% end %} |
|
|
122 |
overlay.setPosition(coordinates); |
|
|
123 |
} |
|
|
124 |
}); |
|
|
125 |
}); |
|
|
126 |
|
|
|
127 |
</script> |
|
|
128 |
|
|
|
129 |
{% end %} |
|
|
130 |
{% block content %} |
|
|
131 |
<div id="jumbotron" class="jumbotron"> |
|
|
132 |
<small>Generated on: {{time}}</small> |
|
|
133 |
<br/><br/> |
|
|
134 |
<table width="100%"> |
|
|
135 |
<thead> |
|
|
136 |
<tr> |
|
|
137 |
<th>Studies</th> |
|
|
138 |
<th>Unique Samples per Visibility Status</th> |
|
|
139 |
<th>Public Samples per Data Type</th> |
|
|
140 |
<th>Users</th> |
|
|
141 |
<th>Jobs</th> |
|
|
142 |
</tr> |
|
|
143 |
</thead> |
|
|
144 |
<tr> |
|
|
145 |
<td> |
|
|
146 |
{% for k in number_studies %} |
|
|
147 |
<i>{{k}}</i>: {{ "{:,}".format(int(number_studies[k])) }} <br/> |
|
|
148 |
{% end %} |
|
|
149 |
{% if num_studies_ebi and num_studies_ebi is not None %} |
|
|
150 |
<i>submitted to EBI</i>: {{ "{:,}".format(int(num_studies_ebi)) }} |
|
|
151 |
{% end %} |
|
|
152 |
</td> |
|
|
153 |
<td> |
|
|
154 |
{% for k, v in number_of_samples.items() %} |
|
|
155 |
<i>{{k}}</i>: {{ "{:,}".format(int(v)) }} <br/> |
|
|
156 |
{% end %} |
|
|
157 |
{% if num_samples_ebi and num_samples_ebi is not None %} |
|
|
158 |
<i>submitted to EBI</i>: {{ "{:,}".format(int(num_samples_ebi)) }} <br/> |
|
|
159 |
{% end %} |
|
|
160 |
{% if number_samples_ebi_prep and number_samples_ebi_prep is not None %} |
|
|
161 |
<i>submitted to EBI (prep)</i>: {{ "{:,}".format(int(number_samples_ebi_prep)) }} |
|
|
162 |
{% end %} |
|
|
163 |
</td> |
|
|
164 |
<td> |
|
|
165 |
{% for k, v in per_data_type_stats.items() %} |
|
|
166 |
<i>{{k}}</i>: {{ "{:,}".format(int(v)) }} <br/> |
|
|
167 |
{% end %} |
|
|
168 |
</td> |
|
|
169 |
|
|
|
170 |
{% if num_users and num_users is not None %} |
|
|
171 |
<td>{{ "{:,}".format(int(num_users)) }}</td> |
|
|
172 |
{% end %} |
|
|
173 |
|
|
|
174 |
{% if num_processing_jobs and num_processing_jobs is not None %} |
|
|
175 |
<td>{{ "{:,}".format(int(num_processing_jobs)) }}</td> |
|
|
176 |
{% end %} |
|
|
177 |
</tr> |
|
|
178 |
</table> |
|
|
179 |
</div> |
|
|
180 |
|
|
|
181 |
<div id="map-canvas"></div> |
|
|
182 |
<div id="map-canvas-popup" class="ol-popup"> |
|
|
183 |
<a href="#" id="map-canvas-popup-closer" class="ol-popup-closer"></a> |
|
|
184 |
<div id="map-canvas-popup-content"></div> |
|
|
185 |
</div> |
|
|
186 |
|
|
|
187 |
{% if random_study_id is not None %} |
|
|
188 |
<div id="jumbotron" class="jumbotron"> |
|
|
189 |
<h2>Check out this random public study from the database!</h2> |
|
|
190 |
<h3>{{ random_study_title }}</h3> |
|
|
191 |
<p align="justify">{{ random_study_info['study_abstract'] }}</p> |
|
|
192 |
<p> |
|
|
193 |
{% if user is not None %} |
|
|
194 |
<a href="{% raw qiita_config.portal_dir %}/study/description/{{ random_study_id }}">Go to the study <span class="glyphicon glyphicon-arrow-right"></span></a> |
|
|
195 |
{% else %} |
|
|
196 |
<h4>Log in above to see this and other public studies</h4> |
|
|
197 |
{% end %} |
|
|
198 |
</p> |
|
|
199 |
</div> |
|
|
200 |
{% end %} |
|
|
201 |
|
|
|
202 |
{% if img and img is not None %} |
|
|
203 |
<div> |
|
|
204 |
<h5>Data usage</h5> |
|
|
205 |
<img height="100%" width="100%" src="{% raw img %}"/> |
|
|
206 |
</div> |
|
|
207 |
{% end %} |
|
|
208 |
|
|
|
209 |
{% end %} |