Finish select benchmark

This commit is contained in:
2023-06-05 17:33:20 +02:00
parent b4ced47b52
commit 11bef3d7f4
9 changed files with 51 additions and 29 deletions

Binary file not shown.

View File

@@ -32,6 +32,9 @@ def index():
@main.route("/set_benchmark/<benchmark_id>") @main.route("/set_benchmark/<benchmark_id>")
@login_required @login_required
def set_benchmark(benchmark_id): def set_benchmark(benchmark_id):
if int(benchmark_id) == current_user.benchmark_id:
flash("Benchmark already selected.")
return redirect(url_for(INDEX))
if current_user.admin: if current_user.admin:
benchmark = Benchmark.query.filter_by(id=benchmark_id).first() benchmark = Benchmark.query.filter_by(id=benchmark_id).first()
if benchmark is None: if benchmark is None:

View File

@@ -5,7 +5,7 @@
<table id="file-table" <table id="file-table"
class="table table-striped table-hover table-bordered"> class="table table-striped table-hover table-bordered">
<thead> <thead>
<tr> <tr class="table-primary">
<th>Model</th> <th>Model</th>
<th>Metric</th> <th>Metric</th>
<th>Platform</th> <th>Platform</th>

View File

@@ -1,9 +1,16 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block styles %}
{{ super() }}
<link rel="stylesheet"
href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
{% endblock %}
{% block content %} {% block content %}
{% include "_table_select.html" %} {% include "_table_select.html" %}
{% endblock %} {% endblock %}
{% block jscript %} {% block jscript %}
{{ super() }} {{ super() }}
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
<script rel="stylesheet"
href="https://cdn.datatables.net/1.13.4/js/dataTables.bootstrap5.min.js"></script>
<script src="{{ url_for('static', filename="js/select.js") }}"></script> <script src="{{ url_for('static', filename="js/select.js") }}"></script>
{% endblock %} {% endblock %}

View File

@@ -0,0 +1,9 @@
<div class="container col-md-4 col-sm-4 col-lg-offset-4">
<h5>Benchmarks</h5>
<div class="list-group">
{% for benchmark in benchmarks %}
<a href="{{ url_for('main.set_benchmark', benchmark_id=benchmark.id) }}"
class="list-group-item list-group-item-action {% if benchmark == current_user.benchmark %}active{% endif %}">{{ benchmark.name + " - " + benchmark.description }}</a>
{% endfor %}
</div>
</div>

View File

@@ -1,30 +1,35 @@
{% from 'bootstrap5/nav.html' import render_nav_item %} {% from 'bootstrap5/nav.html' import render_nav_item %}
<nav class="navbar navbar-expand-sm navbar-dark bg-dark mb-4 justify-content-end"> <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container"> <div class="container-fluid">
<a class="navbar-brand" href="{{ url_for("main.index") }}">Benchmark</a>
<button class="navbar-toggler" <button class="navbar-toggler"
type="button" type="button"
data-bs-toggle="collapse" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" data-bs-target="#navbarToggler"
aria-controls="navbarSupportedContent" aria-controls="navbarToggler"
aria-expanded="false" aria-expanded="false"
aria-label="Toggle navigation"> aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="collapse navbar-collapse" id="navbarToggler">
<!-- Left side of navbar --> <ul class="navbar-nav me-auto mb-2 mb-lg-0">
<ul class="navbar-nav me-auto">
{{ render_nav_item('main.index', 'Home') }}
</ul>
<ul class="navbar-nav justify-content-end">
{{ render_nav_item('results.select', 'Results') }}
{{ render_nav_item('results.datasets', 'Datasets') }}
{{ render_nav_item('main.config', 'Config') }}
{% if current_user.is_authenticated %} {% if current_user.is_authenticated %}
{{ render_nav_item('main.logout', current_user.username + '(Logout) ') }} <li>{{ render_nav_item('main.index', "on " + current_user.benchmark.name) }}</li>
{% endif %}
<li>{{ render_nav_item('results.select', 'Results') }}</li>
<li>{{ render_nav_item('results.datasets', 'Datasets') }}</li>
<li>{{ render_nav_item('main.config', 'Config') }}</li>
</ul>
<div class="navbar-nav justify-content-end">
{% if current_user.is_authenticated %}
<img src='{{ current_user.avatar(40) }}' height=35 alt="gravatar" />
{{ render_nav_item('main.logout',
current_user.username + '(Logout) ')|safe }}
{% else %} {% else %}
{{ render_nav_item('main.login', 'Login') }} {{ render_nav_item('main.login', 'Login') }}
{% endif %} {% endif %}
</ul> </ul>
</div> </div>
</div> </div>
</div>
</nav> </nav>

View File

@@ -7,6 +7,11 @@
content="width=device-width, initial-scale=1, shrink-to-fit=no"> content="width=device-width, initial-scale=1, shrink-to-fit=no">
{% block styles %} {% block styles %}
{{ bootstrap.load_css() }} {{ bootstrap.load_css() }}
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/7.1.96/css/materialdesignicons.css"
integrity="sha512-lD1LHcZ8tFHvMFNeo6qOLY/HjzSPCasPJOAoir22byDxlZI1R71S5lZel8zRL2TZ+Dut1wOHfYgSU2lHXuL00w=="
crossorigin="anonymous"
referrerpolicy="no-referrer" />
<link rel="stylesheet" <link rel="stylesheet"
href="{{ url_for('static', filename='css/main.css') }}"> href="{{ url_for('static', filename='css/main.css') }}">
{% endblock %} {% endblock %}
@@ -14,7 +19,7 @@
{% endblock %} {% endblock %}
</head> </head>
<body> <body>
{% include "_nav.html" %} <div class="container-fluid">{% include "_nav.html" %}</div>
{% with messages = get_flashed_messages(with_categories=true) %} {% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %} {% if messages %}
{% for category, message in messages %} {% for category, message in messages %}
@@ -25,7 +30,7 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endwith %} {% endwith %}
<div class="container"> <div class="container-fluid">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
</body> </body>

View File

@@ -1,16 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
{% if benchmarks %} {% if benchmarks %}
<h5>Benchmarks</h5> {% include "_benchmarks.html" %}
<ul>
{% for benchmark in benchmarks %}
<li>
<a href="{{ url_for('main.set_benchmark', benchmark_id=benchmark.id) }}">{{ benchmark.name }}
{% if benchmark == current_user.benchmark %}*{% endif %}
</a>
</li>
{% endfor %}
</ul>
{% else %} {% else %}
<img src="{{ url_for('static', filename='img/robert-lukeman-_RBcxo9AU-U-unsplash.jpg') }}" <img src="{{ url_for('static', filename='img/robert-lukeman-_RBcxo9AU-U-unsplash.jpg') }}"
class="img-fluid" class="img-fluid"

View File

@@ -1,6 +1,8 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% from 'bootstrap5/form.html' import render_form %} {% from 'bootstrap5/form.html' import render_form %}
{% block content %} {% block content %}
<h2>Login</h2> <div class="col-md-3 col-lg-offset-4">
{{ render_form(form) }} <h2>Login</h2>
{{ render_form(form) }}
</div>
{% endblock content %} {% endblock content %}