Changed frontend

pull/78/head
Konstantin Gründger 2019-03-23 12:25:21 +01:00
rodzic da188b69f9
commit 4979e26ab7
11 zmienionych plików z 134 dodań i 110 usunięć

Wyświetl plik

@ -10,5 +10,5 @@ nav.register_element('top_menubar', Navbar(
View('Receivers', 'receivers'),
View('Airports', 'airports'),
View('Logbook', 'logbook'),
View('Records', 'records'),
View('Statistics', 'statistics'),
))

Wyświetl plik

@ -8,26 +8,31 @@ from ogn_python.model import *
@app.route('/')
@app.route('/index')
@app.route('/index.html')
def index():
return render_template('base.html')
@app.route('/devices', methods=['GET', 'POST'])
@app.route('/devices.html', methods=['GET', 'POST'])
def devices():
devices = db.session.query(Device) \
.limit(100)
return render_template('devices.html', devices=devices)
@app.route('/device.html', methods=['GET', 'POST'])
def device():
device_id = request.args.get('id')
if device_id:
device = db.session.query(Device) \
.filter(Device.id == device_id)
device = db.session.query(Device) \
.filter(Device.id == device_id) \
.one()
return render_template('device_detail.html', device=device)
else:
devices = db.session.query(Device) \
.limit(100)
return render_template('devices.html', devices=devices)
return render_template('device_detail.html',
title='Device',
device=device)
@app.route('/receivers')
@app.route('/receivers.html')
def receivers():
sel_country = request.args.get('country')
@ -45,15 +50,20 @@ def receivers():
receivers = db.session.query(Receiver) \
.order_by(Receiver.name)
return render_template('receivers.html', sel_country=sel_country, countries=countries_in_receivers, receivers=receivers)
return render_template('receivers.html',
title='Receivers',
sel_country=sel_country,
countries=countries_in_receivers,
receivers=receivers)
@app.route('/receiver')
def receiver():
@app.route('/receiver_detail.html')
def receiver_detail():
sel_receiver_id = request.args.get('receiver_id')
receiver = db.session.query(Receiver) \
.filter(Receiver.id == sel_receiver_id)
.filter(Receiver.id == sel_receiver_id) \
.one()
near_airports = db.session.query(Airport, func.st_distancesphere(Airport.location_wkt, Receiver.location_wkt).label('distance')) \
.filter(and_(Receiver.id == sel_receiver_id), func.st_contains(func.st_buffer(Receiver.location_wkt, 0.5), Airport.location_wkt)) \
@ -61,10 +71,13 @@ def receiver():
.order_by(func.st_distancesphere(Airport.location_wkt, Receiver.location_wkt)) \
.limit(10)
return render_template('receiver.html', receiver=receiver, near_airports=near_airports)
return render_template('receiver_detail.html',
title='Receiver Detail',
receiver=receiver,
near_airports=near_airports)
@app.route('/airports', methods=['GET', 'POST'])
@app.route('/airports.html', methods=['GET', 'POST'])
def airports():
sel_country = request.args.get('country')
@ -75,7 +88,7 @@ def airports():
if sel_country:
airports = db.session.query(Airport) \
.filter(and_(or_(Logbook.takeoff_airport_id == Airport.id, Logbook.landing_airport_id == Airport.id), Country.iso2 == Airport.country_code)) \
.filter(and_(or_(Logbook.takeoff_airport_id == Airport.id, Logbook.landing_airport_id == Airport.id), Airport.country_code == sel_country)) \
.group_by(Airport.id) \
.order_by(Airport.name)
else:
@ -88,11 +101,13 @@ def airports():
return render_template('airports.html', sel_country=sel_country, countries=countries_in_logbook, airports=airports)
@app.route('/airport')
@app.route('/airport.html')
def airport():
pass
@app.route('/logbook', methods=['GET', 'POST'])
@app.route('/logbook.html', methods=['GET', 'POST'])
def logbook():
sel_country = request.args.get('country')
sel_airport = request.args.get('airport')
@ -151,31 +166,32 @@ def logbook():
filters.append(Logbook.device_id == sel_device_id)
if len(filters) > 0:
logbook = db.session.query(Logbook.takeoff_timestamp,
db.func.round(Logbook.takeoff_track/10).label('takeoff_track'),
Logbook.landing_timestamp,
db.func.round(Logbook.landing_track/10).label('landing_track'),
Logbook.max_altitude,
DeviceInfo.aircraft,
DeviceInfo.registration,
DeviceInfo.competition) \
entries = db.session.query(Logbook, Device, DeviceInfo) \
.filter(*filters) \
.filter(db.and_(Logbook.device_id == Device.id, Device.address == DeviceInfo.address)) \
.order_by(Logbook.reftime)
else:
logbook = None
entries = None
return render_template('logbook.html', sel_country=sel_country, countries=countries_avail, sel_airport=sel_airport, airports=airports, sel_date=sel_date, dates=dates, logbook=logbook)
return render_template('logbook.html',
title='Logbook',
sel_country=sel_country,
countries=countries_avail,
sel_airport=sel_airport,
airports=airports,
sel_date=sel_date,
dates=dates,
entries=entries)
@app.route('/live')
def live():
return render_template('ogn_live.jinja')
@app.route('/records')
def records():
@app.route('/statistics.html')
def statistics():
receiverstats = db.session.query(ReceiverStats) \
.limit(10)
return render_template('records.html', receiverstats=receiverstats)
return render_template('statistics.html', receiverstats=receiverstats)
# Backend routes for other sites
@app.route('/live.html')
def live():
return render_template('ogn_live.jinja')

Wyświetl plik

@ -30,7 +30,7 @@
{% for airport in airports %}
<tr>
<td>{{ loop.index }}
<td><a href="{{ url_for('airport', id=airport.id) }}">{{ airport.name }}</a></td>
<td><a href="{{ url_for('logbook', airport=airport.id) }}">{{ airport.name }}</a></td>
<td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ airport.country_code|lower }}" alt="{{ airport.country_code }}"/></td>
</tr>
{% endfor %}

Wyświetl plik

@ -5,7 +5,7 @@
{% endblock %}
{% block navbar %}
{{ nav.top_menubar.render() }}
{{ nav.top_menubar.render() }}
{% endblock %}
{% block content %}

Wyświetl plik

@ -2,33 +2,23 @@
{% block content %}
<div class="container-fluid">
<div class="panel panel-success" id="asdf">
<div class="panel-heading"><h3 class="panel-title">Devices</h3></div>
<div class="panel-body">
{{ device.address }}
<div class="container">
<div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-title">Device Details</h3></div>
<table class="datatable table table-striped table-bordered">
<tr>
<th>Nr.</th>
<th colspan="2">Takeoff</th>
<th colspan="2">Landing</th>
<th>AGL</th>
</tr>
{% for entry in device.logbook %}
<tr>
<td>{{ loop.index }}</td>
<td>{% if entry.takeoff_timestamp is not none %} {{ entry.takeoff_timestamp.strftime('%H:%M') }} {% endif %}</td>
<td>{% if entry.takeoff_track is not none %} {{ '%02d' | format(entry.takeoff_track) }} {% endif %}</td>
<td>{% if entry.landing_timestamp is not none %} {{ entry.landing_timestamp.strftime('%H:%M') }} {% endif %}</td>
<td>{% if entry.landing_track is not none %} {{ '%02d' | format(entry.landing_track) }} {% endif %}</td>
<td>{% if entry.max_altitude is not none %} {{ entry.max_altitude }} {% endif %}</td>
</tr>
{% endfor %}
<tr><td>Name:</td><td>{{ device.name }}</td></tr>
<tr><td>Address:</td><td>{{ device.address }}</td></tr>
<tr><td>Real Address:</td><td>{{ device.real_address }}</td></tr>
<tr><td>Stealth:</td><td>{{ device.stealth }}</td></tr>
<tr><td>Aircraft Type:</td><td>{{ device.aircraft_type }}</td></tr>
<tr><td>Software Version:</td><td>{{ device.software_version }}</td></tr>
<tr><td>Hardware Version:</td><td>{{ device.hardware_version }}</td></tr>
<tr><td>First seen:</td><td>{{ device.firstseen }}</td></tr>
<tr><td>Last seen:</td><td>{{ device.lastseen }}</td></tr>
</table>
</div>
</div>
{% endblock %}

Wyświetl plik

@ -17,7 +17,7 @@
{% for device in devices %}
<tr>
<td><a href="?id={{ device.id }}">{{ device.address }}</a></td>
<td><a href="{{ url_for('device', id=device.id) }}">{{ device.address }}</a></td>
<td>{% if device.takeoff_landings %}{% set last_action = device.takeoff_landings|last %}{{ last_action.airport.name }}{% endif %}
<td>{% if device.takeoff_landings %}{% set last_action = device.takeoff_landings|last %}{% if last_action.is_takeoff == True %}↗{% else %}↘{% endif %} @ {{ last_action.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}{% endif %}
<td>{% if device.infos %}{% set info = device.infos|first %}{{ info.registration }} {% else %} - {% endif %}</td>

Wyświetl plik

@ -31,7 +31,7 @@
</form>
{% if logbook is not none %}
{% if entries is not none %}
<table class="datatable table table-striped table-bordered">
<tr>
<th>Nr.</th>
@ -41,16 +41,19 @@
<th colspan="2">Landing</th>
<th>AGL</th>
</tr>
{% for entry in logbook %}
{% for entry in entries %}
{% set logbook = entry[0] %}
{% set device = entry[1] %}
{% set device_info = entry[2] %}
<tr>
<td>{{ loop.index }}</td>
<td>{{ entry.registration }}</td>
<td>{{ entry.aircraft }}</td>
<td>{% if entry.takeoff_timestamp is not none %} {{ entry.takeoff_timestamp.strftime('%H:%M') }} {% endif %}</td>
<td>{% if entry.takeoff_track is not none %} {{ '%02d' | format(entry.takeoff_track) }} {% endif %}</td>
<td>{% if entry.landing_timestamp is not none %} {{ entry.landing_timestamp.strftime('%H:%M') }} {% endif %}</td>
<td>{% if entry.landing_track is not none %} {{ '%02d' | format(entry.landing_track) }} {% endif %}</td>
<td>{% if entry.max_altitude is not none %} {{ entry.max_altitude }} {% endif %}</td>
<td><a href="{{ url_for('device', id=device.id) }}">{{ device_info.registration }}</a></td>
<td>{{ device_info.aircraft }}</td>
<td>{% if logbook.takeoff_timestamp is not none %} {{ logbook.takeoff_timestamp.strftime('%H:%M') }} {% endif %}</td>
<td>{% if logbook.takeoff_track is not none %} {{ '%02d' | format(logbook.takeoff_track/10) }} {% endif %}</td>
<td>{% if logbook.landing_timestamp is not none %} {{ logbook.landing_timestamp.strftime('%H:%M') }} {% endif %}</td>
<td>{% if logbook.landing_track is not none %} {{ '%02d' | format(logbook.landing_track/10) }} {% endif %}</td>
<td>{% if logbook.max_altitude is not none %} {{ logbook.max_altitude }} {% endif %}</td>
</tr>
{% endfor %}
</table>

Wyświetl plik

@ -1,31 +0,0 @@
{% extends "base.html" %}
{% block content %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/flags/flags.css') }}"/>
<div class="container">
<div class="panel panel-success" id="asdf">
<div class="panel-heading"><h3 class="panel-title">Receiver</h3></div>
<div class="panel-body">
<table class="datatable table table-striped table-bordered">
<tr>
<th>Name</th>
<th>Country</th>
<th>Distance</th>
</tr>
{% for tupel in near_airports %}
{% set airport = tupel[0] %}
{% set distance = tupel[1] %}
<tr>
<td>{% if airport.takeoff_landings %}<a href="{{ url_for('logbook', airport=airport.id) }}">{{ airport.name }}</a>{% else %}{{ airport.name }}{% endif %}</td>
<td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ airport.country_code|lower }}" alt="{{ airport.country_code }}"/></td>
<td>{{ '%0.1f'|format(distance/1000) }} km</td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endblock %}

Wyświetl plik

@ -0,0 +1,48 @@
{% extends "base.html" %}
{% block content %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/flags/flags.css') }}"/>
<div class="container">
<div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-title">Receiver Details</h3></div>
<table class="datatable table table-striped table-bordered">
<tr><td>Name:</td><td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ receiver.country.iso2|lower }}" alt="{{ receiver.country.iso2 }}"/> {{ receiver.name }}</td></tr>
<tr><td>Version:</td><td>{{ receiver.version }}</td></tr>
<tr><td>Platform:</td><td>{{ receiver.platform }}</td></tr>
<tr><td>First seen:</td><td>{{ receiver.firstseen }}</td></tr>
<tr><td>Last seen:</td><td>{{ receiver.lastseen }}</td></tr>
</table>
</div>
<div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-title">Nearby Airports</h3></div>
<table class="datatable table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Distance</th>
</tr>
</thead>
<tbody>
{% for tupel in near_airports %}
{% set airport = tupel[0] %}
{% set distance = tupel[1] %}
<tr>
<td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ airport.country_code|lower }}" alt="{{ airport.country_code }}"/> {% if airport.takeoff_landings %}<a href="{{ url_for('logbook', airport=airport.id) }}">{{ airport.name }}</a>{% else %}{{ airport.name }}{% endif %}</td>
<td>{{ '%0.1f'|format(distance/1000) }} km</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}

Wyświetl plik

@ -23,15 +23,13 @@
<table class="datatable table table-striped table-bordered">
<tr>
<th>Name</th>
<th>Country</th>
<th>Altitude</th>
</tr>
{% for receiver in receivers %}
<tr>
<td><a href="{{ url_for('receiver', receiver_id=receiver.id) }}">{{ receiver.name }}</a></td>
<td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ receiver.country.iso2|lower }}" alt="{{ receiver.country.iso2 }}"/></td>
<td>{{ receiver.altitude|int }}</td>
<td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ receiver.country.iso2|lower }}" alt="{{ receiver.country.iso2 }}"/> <a href="{{ url_for('receiver_detail', receiver_id=receiver.id) }}">{{ receiver.name }}</a></td>
<td>{{ receiver.altitude|int }} m</td>
</tr>
{% endfor %}
</table>