Skip to content

Commit

Permalink
Add summary page button (#145)
Browse files Browse the repository at this point in the history
## Home page screenshot

See the button on top right

<img width="1539" alt="Screenshot 2023-08-14 at 16 53 41"
src="https://github.com/biopragmatics/biomappings/assets/5069736/2d2c5cd9-d216-4209-acac-205b033a275b">

## Summary page

<img width="1539" alt="Screenshot 2023-08-14 at 16 54 06"
src="https://github.com/biopragmatics/biomappings/assets/5069736/23f96cc8-ce29-450c-ae7f-559252a36e13">
  • Loading branch information
cthoyt authored Aug 14, 2023
1 parent bc79374 commit 8d4bd28
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 24 deletions.
8 changes: 7 additions & 1 deletion src/biomappings/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
{{ util.render_messages(dismissible=True, container=False) }}
<div class="row">
<div class="card">
<h5 class="card-header text-center">Biomappings Curation Interface</h5>
<h5 class="card-header text-center">
<a class="btn btn-primary btn-sm" style="float: right;"
href="{{ url_for_state(".summary", state=state) }}">
Summarize
</a>
Biomappings Curation Interface
</h5>
<div class="card-body">
{% if controller.total_curated %}
<a href="{{ url_for_state('.run_commit', state) }}">
Expand Down
51 changes: 29 additions & 22 deletions src/biomappings/templates/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,37 @@
{% block content %}
<div class="container" style="margin-top: 50px; margin-bottom: 50px">
{{ util.render_messages(dismissible=True, container=False) }}
<div class="row">
<div class="card">
<h5 class="card-header text-center">Biomappings Summary</h5>
<div class="card-body">
<p>Summary text.</p>
</div>
<table class="table table-hover">
<thead class="thead-light">
<tr>
<th scope="col">Source Prefix</th>
<th scope="col">Target Prefix</th>
<th scope="col">Count</th>
</tr>
</thead>
<tbody>
{% for (source_prefix, target_prefix), count in counter.most_common() %}
<div class="row justify-content-md-center">
<div class="col-lg-6">
<div class="card">
<h5 class="card-header text-center">Biomappings Summary</h5>
<div class="card-body">
<p>
This page creates a top-level summary of the current query,
broken down by source and target prefixes.
</p>
</div>
<table class="table table-hover">
<thead class="thead-light">
<tr>
<td>{{ source_prefix }}</td>
<td>{{ target_prefix }}</td>
<td style="text-align: right;">{{ "{:,d}".format(count) }}</td>
<th scope="col">Source Prefix</th>
<th scope="col">Target Prefix</th>
<th scope="col">Count</th>
<th scope="col">Link</th>
</tr>
{% endfor %}
</tbody>
</table>
</thead>
<tbody>
{% for source_prefix, target_prefix, count, link in rows %}
<tr>
<td>{{ source_prefix }}</td>
<td>{{ target_prefix }}</td>
<td style="text-align: right;">{{ "{:,d}".format(count) }}</td>
<td><a href="{{ link }}">Go!</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
Expand Down
10 changes: 9 additions & 1 deletion src/biomappings/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import getpass
import os
from collections import Counter, defaultdict
from copy import deepcopy
from pathlib import Path
from typing import (
Any,
Expand Down Expand Up @@ -513,10 +514,17 @@ def summary():
counter = Counter(
(mapping["source prefix"], mapping["target prefix"]) for _, mapping in predictions
)
rows = []
for (source_prefix, target_prefix), count in counter.most_common():
row_state = deepcopy(state)
row_state.source_prefix = source_prefix
row_state.target_prefix = target_prefix
rows.append((source_prefix, target_prefix, count, url_for_state(".home", row_state)))

return flask.render_template(
"summary.html",
counter=counter,
state=state,
rows=rows,
)


Expand Down

0 comments on commit 8d4bd28

Please sign in to comment.