WIP, to be cleaned and merged
This commit is contained in:
parent
314adbeb1d
commit
d1e3152a83
30 changed files with 1498 additions and 248 deletions
5
ed_lrr_gui/web/templates/admin/index.html
Normal file
5
ed_lrr_gui/web/templates/admin/index.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% extends 'admin/master.html' %}
|
||||
|
||||
{% block body %}
|
||||
<p>Hello world</p>
|
||||
{% endblock %}
|
48
ed_lrr_gui/web/templates/base.html
Normal file
48
ed_lrr_gui/web/templates/base.html
Normal file
|
@ -0,0 +1,48 @@
|
|||
{% extends "bootstrap/base.html" %}
|
||||
{% import "bootstrap/utils.html" as utils %}
|
||||
{% block title %}Elite: Dangerous Long Range Router{% endblock %}
|
||||
|
||||
{% block scrips %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block styles %}
|
||||
{{super()}}
|
||||
<link rel="stylesheet" href="{{url_for('static', filename='theme.css')}}">
|
||||
{% endblock %}
|
||||
|
||||
{% block navbar %}
|
||||
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #222;">
|
||||
<a class="navbar-brand" href="/">E:D LRR</a>
|
||||
<ul class="navbar-nav mr-auto">
|
||||
{{nav.left_nav.render(renderer='bootstrap4')}}
|
||||
</ul>
|
||||
|
||||
<ul class="navbar-nav ml-auto">
|
||||
{% if current_user.is_authenticated %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link">
|
||||
Logged in as {{current_user.name}}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{{nav.right_nav.render(renderer='bootstrap4')}}
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category,message in messages %}
|
||||
<div class="alert alert-{{category}}" role="{{category}}">{{ message }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{# application content needs to be provided in the app_content block #}
|
||||
{% block app_content %}{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
6
ed_lrr_gui/web/templates/error/404.html
Normal file
6
ed_lrr_gui/web/templates/error/404.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>404 Not Found</h1>
|
||||
<p><a href="{{ url_for('index') }}"><button type="button" class="btn btn-secondary">Back</button></a></p>
|
||||
{% endblock %}
|
16
ed_lrr_gui/web/templates/form.html
Normal file
16
ed_lrr_gui/web/templates/form.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
{% extends "base.html" %}
|
||||
{% import "bootstrap/wtf.html" as wtf %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>{{title}}</h1>
|
||||
{% for field in form %}
|
||||
{% for error in field.errors %}
|
||||
<div class="alert alert-danger" role="danger">{{error}}</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{{ wtf.quick_form(form) }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
10
ed_lrr_gui/web/templates/index.html
Normal file
10
ed_lrr_gui/web/templates/index.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>E:D LRR</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Number of Jobs: {{current_user.jobs|count}}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
131
ed_lrr_gui/web/templates/job.html
Normal file
131
ed_lrr_gui/web/templates/job.html
Normal file
|
@ -0,0 +1,131 @@
|
|||
{% extends "base.html" %}
|
||||
{% block app_content %}
|
||||
<h1>Job Status <span class="badge badge-{{job.status[0]}}">{{ job.status[1] }}</span></h1>
|
||||
<div class="row">
|
||||
<div class="col-lg-0">
|
||||
{% if job.state.error %}
|
||||
<ul>
|
||||
{% for err in job.state.error.args %}
|
||||
<li>{{err}}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if job.state.progress %}
|
||||
<p class="lead">Routing from <b>{{ job.state.progress.from }}</b> to <b>{{ job.state.progress.to }}</b> using
|
||||
{{ job.state.progress.mode }}</p>
|
||||
<p>Current system: <b>{{ job.state.progress.system }}</b></p>
|
||||
<p>Search queue size: <b>{{"{:,}".format(job.state.progress.queue_size) }}</b></p>
|
||||
<p>Number of systems checked: <b>{{"{:,}".format(job.state.progress.n_seen) }}
|
||||
({{job.state.progress.prc_seen|round(2)}} %)</b></p>
|
||||
<p>Estimated time remaining: <b>{{job.t_rem}}</b></p>
|
||||
<p>Search Depth: <b>{{job.state.progress.depth}}</b></p>
|
||||
<div class="progress" style="width: 100%;">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated"
|
||||
style="width: {{job.state.progress.prc_done}}%;" role="progressbar"
|
||||
aria-valuenow="{{job.state.progress.prc_done|round(2)}}" aria-valuemin="0" aria-valuemax="100">
|
||||
{{job.state.progress.prc_done|round(2)}} %
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if job.state.result %}
|
||||
<h2>Result</h2>
|
||||
|
||||
<h3>Map</h3>
|
||||
<div id="graph">
|
||||
</div>
|
||||
<script src="https://d3js.org/d3.v5.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
function dist(a, b) {
|
||||
var sum = 0;
|
||||
for (var i = 0; i < a.length; ++i) {
|
||||
sum += Math.pow(a[i] - b[i], 2)
|
||||
}
|
||||
return Math.pow(sum, 0.5);
|
||||
}
|
||||
var width = 512;
|
||||
var height = 512;
|
||||
var route = {{job.route | tojson}};
|
||||
var vis = d3.select("#graph")
|
||||
.append("svg").attr("viewBox", [0, 0, width, height]);
|
||||
|
||||
vis.attr("width", width)
|
||||
.attr("height", height);
|
||||
var g = vis.append("g");
|
||||
|
||||
vis.call(d3.zoom()
|
||||
.extent([
|
||||
[0, 0],
|
||||
[width, height]
|
||||
])
|
||||
.on("zoom", () => {
|
||||
g.attr("transform", d3.event.transform);
|
||||
}));
|
||||
|
||||
var lines = [];
|
||||
for (var i = 0; i < route.length - 1; ++i) {
|
||||
lines.push({
|
||||
x1: route[i].pos[1],
|
||||
x2: route[i + 1].pos[1],
|
||||
y1: -route[i].pos[2],
|
||||
y2: -route[i + 1].pos[2],
|
||||
dist: dist(route[i].pos, route[i + 1].pos),
|
||||
color: route[i].color || '#eee'
|
||||
})
|
||||
}
|
||||
|
||||
g.selectAll(".line")
|
||||
.data(lines)
|
||||
.enter()
|
||||
.append("line")
|
||||
.attr("x1", (l) => l.x1)
|
||||
.attr("y1", (l) => l.y1)
|
||||
.attr("x2", (l) => l.x2)
|
||||
.attr("y2", (l) => l.y2)
|
||||
.style("stroke", (l) => l.color)
|
||||
.style("stroke-width", 5)
|
||||
.append("title")
|
||||
.text((l) => Math.round(l.dist * 100) / 100 + " Ly");
|
||||
|
||||
g.selectAll("circle .nodes")
|
||||
.data(route)
|
||||
.enter()
|
||||
.append("svg:circle")
|
||||
.attr("class", "nodes")
|
||||
.attr("cx", (d) => d.pos[1])
|
||||
.attr("cy", (d) => -d.pos[2])
|
||||
.attr("r", 10)
|
||||
.attr("fill", (d) => d.color)
|
||||
.append("title")
|
||||
.text((d) => d.body + " (" + d.star_type + ")")
|
||||
</script>
|
||||
<h3>Jumps</h3>
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Num</th>
|
||||
<th scope="col">Body</th>
|
||||
<th scope="col">Type</th>
|
||||
<th scope="col">Distance from arrival</th>
|
||||
<th scope="col">Jump distance</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for sys in job.route %}
|
||||
<tr>
|
||||
<th scope="row">{{sys.num}}</td>
|
||||
<td>{{sys.body}}</td>
|
||||
<td style="color: {{sys.color}}">{{sys.star_type}}</td>
|
||||
<td>{{"{:,}".format(sys.distance)}} Ls</td>
|
||||
<td>{{"{:,}".format(sys.jump_dist|round(2))}} Ly</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<th scope="row" colspan=4>Total Distance</th>
|
||||
<td>{{"{:,}".format(job.route|sum(attribute='jump_dist')|round(2))}} Ly</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
87
ed_lrr_gui/web/templates/status.html
Normal file
87
ed_lrr_gui/web/templates/status.html
Normal file
|
@ -0,0 +1,87 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block app_content %}
|
||||
{% if current_user.has_role('admin') %}
|
||||
{% set jobs = Job.query.all() %}
|
||||
{% else %}
|
||||
{% set jobs = current_user.jobs %}
|
||||
{% endif %}
|
||||
<h1>System Status</h1>
|
||||
<div class="row">
|
||||
<h2>Overview</h2>
|
||||
</div>
|
||||
<div class="row">
|
||||
<table class="table table-striped table-bordered" style="width: 1px;">
|
||||
<tr>
|
||||
<th>Status</th>
|
||||
<th>Count</th>
|
||||
</tr>
|
||||
{% for group in (jobs|groupby('status')) %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="?state={{group.grouper[1]}}">
|
||||
<span class="badge badge-{{ group.grouper[0] }}">{{ group.grouper[1] }}</span>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{group.list|count}}
|
||||
</td>
|
||||
<tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="?">
|
||||
Total
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{jobs|count}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h2>Jobs</h2>
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- Next: {{Job.next().id}} -->
|
||||
<table class="table table-striped table-bordered" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">ID</th>
|
||||
<th scope="col">Systems</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">User</th>
|
||||
<th scope="col">Priority</th>
|
||||
<th scope="col">Progess</th>
|
||||
<th scope="col">ETC</th>
|
||||
<th scope="col">Created</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for job in (jobs|sort(attribute='sort_key')) %}
|
||||
{% if (state==None) or job.status[1]==state %}
|
||||
<tr>
|
||||
<td style="width: 1px; white-space: nowrap;"><a href="{{url_for('status',job_id=job.id)}}">{{job.id}}</a></td>
|
||||
<td style="width: 1px; white-space: nowrap;">{{job.args[0]|join(', ')}}</td>
|
||||
<td style="width: 1px; white-space: nowrap;"><span class="badge badge-{{job.status[0]}}">{{ job.status[1] }}</span></td>
|
||||
<td style="width: 1px; white-space: nowrap;">{{job.user.name}}</td>
|
||||
<td style="width: 1px; white-space: nowrap;">{{job.priority}}</td>
|
||||
{% if job.state.progress %}
|
||||
<td>
|
||||
<div class="progress" style="width: 100%;">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width: {{job.state.progress.prc_done}}%;" role="progressbar" aria-valuenow="{{job.state.progress.prc_done|round(2)}}" aria-valuemin="0" aria-valuemax="100">
|
||||
{{job.state.progress.prc_done|round(2)}} %
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
{% else %}
|
||||
<td>Unknown</td>
|
||||
{% endif %}
|
||||
<td style="width: 1px; white-space: nowrap;">{{job.t_rem}}</td>
|
||||
<td style="width: 1px; white-space: nowrap;">{{job.age}} ago</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
14
ed_lrr_gui/web/templates/workers.html
Normal file
14
ed_lrr_gui/web/templates/workers.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>Workers</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{% if current_user.is_authenticated %}
|
||||
Hello {{current_user.name}}!
|
||||
{% else %}
|
||||
Nothing to see here!
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue