Browse Source

Add station info

dependabot/npm_and_yarn/jquery-3.5.0
clerie 2 years ago
parent
commit
b3c5a0bec2
  1. 2
      wetter/models.py
  2. 2
      wetter/templates/index.html
  3. 20
      wetter/templates/station.html
  4. 2
      wetter/templates/stations.html
  5. 1
      wetter/views.py

2
wetter/models.py

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

2
wetter/templates/index.html

@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
mymap.setView([stations[0]["lat"], stations[0]["lon"]], 6);
}
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>

20
wetter/templates/station.html

@ -20,14 +20,28 @@ @@ -20,14 +20,28 @@
<div class="card-group">
<div class="card">
<div class="card-body">
<h5 class="card-title">Ort</h5>
<p class="card-text"></p>
<h5 class="card-title">Latitude</h5>
<p class="card-text">{{ station.lat }}°</p>
</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-body">
<h5 class="card-title">Bundesland</h5>
<p class="card-text"></p>
<p class="card-text">{{ station.state }}</p>
</div>
</div>
<div class="card">

2
wetter/templates/stations.html

@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
<thead>
<tr>
<th>Name</th>
<th>Bundesland</th>
<th></th>
</tr>
</thead>
@ -21,6 +22,7 @@ @@ -21,6 +22,7 @@
{% for station in stations %}
<tr>
<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>
</tr>
{% endfor %}

1
wetter/views.py

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

Loading…
Cancel
Save