Add station info

This commit is contained in:
clerie 2020-04-08 18:02:02 +02:00
parent b6da7dc2ce
commit b3c5a0bec2
5 changed files with 23 additions and 4 deletions

View File

@ -10,6 +10,8 @@ class Stations(db.Model):
lon = db.Column(db.Integer) lon = db.Column(db.Integer)
dwd_id = db.Column(db.String) dwd_id = db.Column(db.String)
dwd_last_update = db.Column(db.TIMESTAMP) dwd_last_update = db.Column(db.TIMESTAMP)
state = db.Column(db.String)
sea_level = db.Column(db.Integer)
class Climate(db.Model): class Climate(db.Model):
__tablename__ = 'climate' __tablename__ = 'climate'

View File

@ -45,7 +45,7 @@
mymap.setView([stations[0]["lat"], stations[0]["lon"]], 6); mymap.setView([stations[0]["lat"], stations[0]["lon"]], 6);
} }
stations.forEach((station, i, j) => { stations.forEach((station, i, j) => {
L.marker([station["lat"], station["lon"]]).addTo(mymap).bindPopup("<h3>" + station["name"] + "</h3><a href=\"/station/" + station["dwd_id"] + "/export/\" class=\"btn btn-secondary\">Export</a> <a href=\"/station/" + station["dwd_id"] + "/\" class=\"btn btn-primary\">Info</a>"); L.marker([station["lat"], station["lon"]]).addTo(mymap).bindPopup("<h3>" + station["name"] + "</h3><p>" + station["state"] + "</p><a href=\"/station/" + station["dwd_id"] + "/export/\" class=\"btn btn-secondary\">Export</a> <a href=\"/station/" + station["dwd_id"] + "/\" class=\"btn btn-primary\">Info</a>");
}) })
}); });
</script> </script>

View File

@ -20,14 +20,28 @@
<div class="card-group"> <div class="card-group">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">Ort</h5> <h5 class="card-title">Latitude</h5>
<p class="card-text"></p> <p class="card-text">{{ station.lat }}°</p>
</div> </div>
</div> </div>
<div class="card">
<div class="card-body">
<h5 class="card-title">Longitude</h5>
<p class="card-text">{{ station.lon}}°</p>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title">Höhe über nn</h5>
<p class="card-text">{{ station.sea_level }}m</p>
</div>
</div>
</div>
<div class="card-group">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">Bundesland</h5> <h5 class="card-title">Bundesland</h5>
<p class="card-text"></p> <p class="card-text">{{ station.state }}</p>
</div> </div>
</div> </div>
<div class="card"> <div class="card">

View File

@ -14,6 +14,7 @@
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Bundesland</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@ -21,6 +22,7 @@
{% for station in stations %} {% for station in stations %}
<tr> <tr>
<td>{{ station.name }}</td> <td>{{ station.name }}</td>
<td>{{ station.state }}</td>
<td><a href="/station/{{ station.dwd_id }}/export/" class="btn btn-secondary">Export</a> <a href="/station/{{ station.dwd_id }}/" class="btn btn-primary">Info</a></td> <td><a href="/station/{{ station.dwd_id }}/export/" class="btn btn-secondary">Export</a> <a href="/station/{{ station.dwd_id }}/" class="btn btn-primary">Info</a></td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@ -156,6 +156,7 @@ def api_station():
"lat": float(s.lat), "lat": float(s.lat),
"lon": float(s.lon), "lon": float(s.lon),
"dwd_id": str(s.dwd_id), "dwd_id": str(s.dwd_id),
"state": str(s.state),
}) })
return jsonify(out) return jsonify(out)