Commit 92200c70 authored by Nelso Jost's avatar Nelso Jost

FIX board links on main map and main menu

parent 13bc6aba
......@@ -35,7 +35,7 @@ MEASUREMENTS:
label_br: Umidade relativa do ar
short_br: U.AR
unities: ["%", "u.a."]
- name: ATMOSPHERIC_PRESSURE
label_en: Atmospheric Pressure
label_br: Pressão atmosférica
......@@ -49,6 +49,17 @@ MEASUREMENTS:
unities: ["u.a.", "lux"]
SENSORS:
- name: DHT11_TEMP
measurement_name: ATMOSPHERIC_TEMPERATURE
unity_label: "ºC"
description: |
https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf
- name: DHT11_AH
measurement_name: AIR_RELATIVE_HUMIDITY
unity_label: "%"
description: |
https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf
- name: DHT22_TEMP
measurement_name: ATMOSPHERIC_TEMPERATURE
......@@ -67,7 +78,43 @@ SENSORS:
unity_label: "Pa"
description: |
http://www.adafruit.com/datasheets/BMP085_DataSheet_Rev.1.0_01July2008.pdf
- name: BMP085_TEMP
measurement_name: ATMOSPHERIC_TEMPERATURE
unity_label: "ºC"
description: |
http://www.adafruit.com/datasheets/BMP085_DataSheet_Rev.1.0_01July2008.pdf
- name: BMP180_PRESSURE
measurement_name: ATMOSPHERIC_PRESSURE
unity_label: "Pa"
description: |
http://www.adafruit.com/datasheets/BMP085_DataSheet_Rev.1.0_01July2008.pdf
- name: BMP180_TEMP
measurement_name: ATMOSPHERIC_TEMPERATURE
unity_label: "ºC"
description: |
http://www.adafruit.com/datasheets/BMP085_DataSheet_Rev.1.0_01July2008.pdf
- name: BME280_PRESSURE
measurement_name: ATMOSPHERIC_PRESSURE
unity_label: "Pa"
description: |
http://www.adafruit.com/datasheets/BMP085_DataSheet_Rev.1.0_01July2008.pdf
- name: BME280_TEMP
measurement_name: ATMOSPHERIC_TEMPERATURE
unity_label: "ºC"
description: |
http://www.adafruit.com/datasheets/BMP085_DataSheet_Rev.1.0_01July2008.pdf
- name: BME280_AH
measurement_name: AIR_RELATIVE_HUMIDITY
unity_label: "%"
description: |
https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf
- name: LDR
measurement_name: LUMINOSITY
unity_label: "u.a."
......@@ -75,4 +122,4 @@ SENSORS:
http://www.biltek.tubitak.gov.tr/gelisim/elektronik/dosyalar/40/LDR_NSL19_M51.pdf
DEFAULT_SENSORS: [DHT22_TEMP, DHT22_AH, BMP085_PRESSURE, LDR]
DEFAULT_SENSORS: [DHT22_TEMP, DHT22_AH, BMP180_PRESSURE, LDR]
......@@ -104,7 +104,7 @@ var map = new ol.Map({
collapsible: false
})
}).extend([mousePositionControl]),
// present map window contents
view: new ol.View({
center: ol.proj.fromLonLat([-51.1528, -30.0525]),
......@@ -113,7 +113,7 @@ var map = new ol.Map({
});
// http://stackoverflow.com/questions/26022029/how-to-change-the-cursor-on-hover-in-openlayers-3
// http://stackoverflow.com/questions/26022029/how-to-change-the-cursor-on-hover-in-openlayers-3
// change mouse cursor when over marker
var target = map.getTarget();
var jTarget = typeof target === "string" ? $("#" + target) : $(target);
......@@ -135,33 +135,39 @@ $(map.getViewport()).on('mousemove', function (e) {
/* Renders the HTML inside the label overlay, which basically is a summary
* of all sensor data for the most recent datetime.
*
* @param {ol.Feature} feature
* @param {ol.Feature} feature
*/
var setup_label_content = function(feature)
{
var d = feature.board.last_rawdata_json;
var res = String(feature.board.id) + ':' + String(feature.board.nickname)
+ '<table>';
var res = String(feature.board.nickname) + ' (ID='
+ String(feature.board.id)
+ ') <hr style="margin:0em"> <table>';
d.sensors.forEach(
function (s) {
val = (d.data != null ? d.data.sensor_values[s.id] : null);
res += ('<tr>' +
res += ('<tr>' +
'<td>{ms}</td><td>{sp}={sp}</td><td>{val}</td>' +
'</tr>').supplant({
ms: s.measurement.short_br,
ms: s.name,
sp : sp,
val: (val != null ? String(val) + sp + s.unity.label
: '(null)')
val: String(val) + sp + s.unity.label
//val: (val != null ? String(val) + sp + s.unity.label
//: '(null)')
})});
res += '</table>';
res += '<hr style="margin:0em">';
if (d.data != null) {
res += '<tr><td colspan="3">{dt}</td></tr>'.supplant({
dt: d.data.datetime.replace(' ', sp).replace('T', sp)});
}
res += '</table>';
res += ' (last data)';
label_content.innerHTML = res;
}
......@@ -169,35 +175,35 @@ var setup_label_content = function(feature)
var setup_popup_content = function(feature)
{
var res = '';
var d = feature.board.last_rawdata_json;
res += '{id}:{nickname}'.supplant({
id: feature.board.id,
nickname: feature.board.nickname});
var d = feature.board.last_rawdata_json;
res += '<table class="table">';
if (d.data != null) {
res += '<tr><td colspan="2" class="popup-dt-col"><b>{dt}</b></td></tr>'
.supplant({
dt: d.data.datetime.replace(' ', sp).replace('T', sp)});
}
d.sensors.forEach(
function (s) {
function (s) {
val = (d.data != null ? d.data.sensor_values[s.id] : null);
res += ('<tr class="tr">' +
res += ('<tr class="tr">' +
'<td class="td"><a href="{url}">{measurement}</a></td>' +
'<td class="td"><code>{value}</code></td>' +
'</tr>').supplant({
sp: sp,
url: s.url,
url: s.url,
measurement: s.measurement.label_br.replace(' ', sp),
value: (val == null ? '(null)' : val + sp + s.unity.label)
});
}
);
);
if (d.data != null) {
res += '<tr><td colspan="2" class="popup-dt-col"><b>{dt}</b></td></tr>'
.supplant({
dt: d.data.datetime.replace(' ', sp).replace('T', sp)});
}
res += '<a href="/board/{id}">{nickname} (ID={id})</a>'.supplant({
id: feature.board.id,
nickname: feature.board.nickname});
res += '</table>';
popup_content.innerHTML = res;
......@@ -207,16 +213,16 @@ var setup_popup_content = function(feature)
map.on('singleclick', function(evt) {
// if (evt.dragging) {
// return;
// }
// }
var pixel = map.getEventPixel(evt.originalEvent);
var feature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
return feature;
});
});
if (feature) {
setup_popup_content(feature);
setup_popup_content(feature);
popup_overlay.setPosition(feature.getGeometry().getCoordinates());
}
else {
......@@ -229,7 +235,7 @@ var populate_map = function(){
var b = boards[i];
if (b.latitude != null) {
var coordinate_xy = [Number(b.longitude), Number(b.latitude)];
var coordinate = ol.proj.transform(coordinate_xy, 'EPSG:4326',
var coordinate = ol.proj.transform(coordinate_xy, 'EPSG:4326',
'EPSG:3857');
var iconFeature = new ol.Feature({
......
......@@ -31,7 +31,7 @@
{% endblock %}
<!-- ===================================================================== -->
{% block navbar %}
<div class="navbar navbar-default" role="navigation">
<div class="container">
......@@ -48,47 +48,50 @@
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
{% if 'current_board' in session %}
{% if 'current_board' in session %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
role="button" aria-haspopup="true" aria-expanded="false"
>Estação {{ session['current_board']['username'] }}:{{
>Estação {{ session['current_board']['username'] }}:{{
session['current_board']['nickname'] }}
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Exportar dados</a></li>
{% if current_user.is_authenticated() and
<li><a href="{{ url_for('api.get_rawsensordata_all',
board_id=session['current_board']['id']) }}">Exportar dados</a></li>
{% if current_user.is_authenticated() and
session['current_board']['user_id'] == current_user.id %}
<li><a href="#">Importar dados</a></li>
<!--<li><a href="#">Importar dados</a></li>-->
<li role="separator" class="divider"></li>
<li><a href={{ url_for('board.manage', id=session['current_board']['id']) }}>Gerenciar</a></li>
<li><a href={{ url_for('board.manage',
id=session['current_board']['id']) }}>
Gerenciar</a></li>
{% endif %}
</ul>
</li>
</ul>
</li>
{% endif %}
{% if current_user.is_authenticated() %}
{% if current_user.is_authenticated() %}
<li><a href={{ url_for('board.insert') }}
>Cadastrar Estação</a></li>
{% endif %}
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% if current_user.is_authenticated() %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
role="button" aria-haspopup="true" aria-expanded="false"
>[ {{ current_user.username }} ]<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href={{ url_for('auth.show_user_data') }}
>Meus dados</a></li>
<li role="separator" class="divider"></li>
<li role="separator" class="divider"></li>
<li><a href="{{ url_for('auth.change_email') }}"
>Alterar e-mail</a></li>
<li><a href="{{ url_for('auth.change_password') }}"
>Alterar senha</a></li>
<li role="separator" class="divider"></li>
<li><a href="javascript:void(0)"
onclick="javascript:bb_confirm('{{ config.MESSAGES.CONFIRM_DELETE_BOARD }}',
<li><a href="javascript:void(0)"
onclick="javascript:bb_confirm('{{ config.MESSAGES.CONFIRM_DELETE_BOARD }}',
'{{ url_for('main.index') }}')">Encerrar conta</a></li>
<li role="separator" class="divider"></li>
<li><a href="{{ url_for('auth.logout') }}"
......@@ -99,7 +102,7 @@
<li><a href="{{ url_for('auth.login') }}">Entrar/Registrar-se</a></li>
{% endif %}
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
......
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