Skip to content

Commit

Permalink
Update state handling (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt authored Jul 4, 2023
1 parent 76f5f01 commit 85d37f1
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 82 deletions.
39 changes: 16 additions & 23 deletions src/biomappings/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
{% import "bootstrap4/form.html" as wtf %}
{% import "bootstrap4/utils.html" as util %}

{% set remaining_rows = controller.count_predictions(query=query, source_query=source_query, target_query=target_query, prefix=prefix, same_text=same_text, provenance=provenance) %}

{% block title %}Biomappings ({{ "{:,d}".format(remaining_rows) }}){% endblock %}

{% macro progress_color(confidence) -%}
Expand All @@ -17,8 +15,6 @@
{% endif %}
{%- endmacro %}

{% set remaining_rows = controller.count_predictions(query=query, source_query=source_query, target_query=target_query, prefix=prefix, source_prefix=source_prefix, target_prefix=target_prefix, same_text=same_text) %}

{% block content %}
<div class="container" style="margin-top: 50px; margin-bottom: 50px">
{{ util.render_messages(dismissible=True, container=False) }}
Expand All @@ -27,7 +23,7 @@
<h5 class="card-header text-center">Biomappings Curation Interface</h5>
<div class="card-body">
{% if controller.total_curated %}
<a href="{{ url_for('.run_commit', limit=limit, offset=offset, query=query, source_query=source_query, target_query=target_query, prefix=prefix, source_prefix=source_prefix, target_prefix=target_prefix, same_text=same_text, sort=sort) }}">
<a href="{{ url_for_state('.run_commit', state) }}">
<button class="btn btn-sm btn-outline-dark">Commit ({{ controller.total_curated }}) and Push
<span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>
</button>
Expand All @@ -37,19 +33,16 @@ <h5 class="card-header text-center">Biomappings Curation Interface</h5>
<span class="btn btn-sm btn-outline-dark">
Query: <code>{{ query }}</code> ({{ "{:,d}".format(remaining_rows) }} Results)
</span>
<a href="{{ url_for('.home', limit=limit, offset=offset, prefix=prefix) }}">
<a href="{{ url_for('.home') }}">
<button class="btn btn-sm btn-outline-dark">Clear</button>
</a>
{% else %}
<form class="form" method="GET" role="form" action="{{ url_for('.home', prefix=prefix) }}">
<form class="form" method="GET" role="form" action="{{ url_for('.home') }}">
<div class="input-group">
<div class="input-group-prepend">
<button type="submit" class="btn btn-outline-secondary">Go!</button>
</div>
<input type="text" class="form-control" placeholder="Search for..." name="query">
{% if prefix %}
<input type="hidden" name="prefix" value="{{ prefix }}">
{% endif %}
</div>
</form>
{% endif %}
Expand All @@ -74,7 +67,7 @@ <h5 class="card-header text-center">Biomappings Curation Interface</h5>
</tr>
</thead>
<tbody>
{% for line, p in controller.predictions(query=query, source_query=source_query, target_query=target_query, offset=offset, limit=limit, prefix=prefix, source_prefix=source_prefix, target_prefix=target_prefix, same_text=same_text, sort=sort, provenance=provenance) %}
{% for line, p in predictions %}
<tr>
{% if show_lines %}
<td class="text-right">{{ 1 + line }}</td>
Expand Down Expand Up @@ -108,21 +101,21 @@ <h5 class="card-header text-center">Biomappings Curation Interface</h5>
</td>
<td>
<a data-toggle="tooltip" title="The {{ p['relation'] }} relationship is correct."
href="{{ url_for('.mark', line=line, value='yup', limit=limit, offset=offset, query=query, source_query=source_query, target_query=target_query, prefix=prefix, source_prefix=source_prefix, target_prefix=target_prefix, same_text=same_text, sort=sort, provenance=provenance) }}">
href="{{ url_for_state('.mark', state, line=line, value='yup') }}">
<i class="far fa-thumbs-up"></i>
</a>
</td>
<td>
<a data-toggle="tooltip"
title="These two entities do not have the {{ p['relation'] }} relationship. You should still click this even if you think there could be a different relationship."
href="{{ url_for('.mark', line=line, value='nope', limit=limit, offset=offset, query=query, source_query=source_query, target_query=target_query, prefix=prefix, source_prefix=source_prefix, target_prefix=target_prefix, same_text=same_text, sort=sort, provenance=provenance) }}">
href="{{ url_for_state('.mark', state, line=line, value='nope') }}">
<i class="far fa-thumbs-down"></i>
</a>
</td>
<td>
<a style="color: darkgoldenrod;" data-toggle="tooltip"
title="I'm not sure if this is correct or not"
href="{{ url_for('.mark', line=line, value='idk', limit=limit, offset=offset, query=query, source_query=source_query, target_query=target_query, prefix=prefix, source_prefix=source_prefix, target_prefix=target_prefix, same_text=same_text, sort=sort, provenance=provenance) }}">
href="{{ url_for_state('.mark', state, line=line, value='idk') }}">
<i class="far fa-question-circle"></i>
</a>
</td>
Expand All @@ -131,7 +124,7 @@ <h5 class="card-header text-center">Biomappings Curation Interface</h5>
</tbody>
</table>

<form class="form" method="POST" role="form" action="{{ url_for('.add_mapping') }}">
<form class="form" method="POST" role="form" action="{{ url_for_state('.add_mapping', state) }}">
<table class="table" style="margin-bottom: 0">
<tr>
<td>{{ wtf.render_field(form.source_prefix) }}</td>
Expand All @@ -148,24 +141,24 @@ <h5 class="card-header text-center">Biomappings Curation Interface</h5>
</form>

<div class="card-footer text-center">
{% if 0 <= offset - limit %}
<a href="{{ url_for('.home', limit=limit, offset=0, query=query, source_query=source_query, target_query=target_query, prefix=prefix, source_prefix=source_prefix, target_prefix=target_prefix, same_text=same_text, sort=sort, provenance=provenance) }}">
{% if 0 <= state.offset - state.limit %}
<a href="{{ url_for_state('.home', state, offset=0) }}">
<i class="fas fa-angle-double-left"></i>
First
</a> &nbsp;|&nbsp;
<a href="{{ url_for('.home', limit=limit, offset=offset - limit, query=query, source_query=source_query, target_query=target_query, prefix=prefix, source_prefix=source_prefix, target_prefix=target_prefix, same_text=same_text, sort=sort, provenance=provenance) }}">
<a href="{{ url_for_state('.home', state, offset=state.offset - state.limit) }}">
<i class="fas fa-angle-left"></i>
Previous {{ limit }}
Previous {{ state.limit }}
</a> &nbsp;|&nbsp;
{% endif %}
{% if offset < remaining_rows - limit %}
<a href="{{ url_for('.home', limit=limit, offset=offset + limit, query=query, source_query=source_query, target_query=target_query, prefix=prefix, source_prefix=source_prefix, target_prefix=target_prefix,same_text=same_text, sort=sort, provenance=provenance) }}">
{% if state.offset < remaining_rows - state.limit %}
<a href="{{ url_for_state('.home', state, offset=state.offset + state.limit) }}">
Next {{ limit }}
<i class="fas fa-angle-right"></i>
</a> &nbsp;|&nbsp;
{% endif %}
{% if offset < remaining_rows - limit %}
<a href="{{ url_for('.home', limit=limit, offset=remaining_rows - limit, query=query, source_query=source_query, target_query=target_query, prefix=prefix, source_prefix=source_prefix, target_prefix=target_prefix, same_text=same_text, sort=sort, provenance=provenance) }}">
{% if state.offset < remaining_rows - state.limit %}
<a href="{{ url_for_state('.home', state, offset=remaining_rows - state.limit) }}">
Last ({{ "{:,d}".format(remaining_rows) }})
<i class="fas fa-angle-double-right"></i>
</a>
Expand Down
38 changes: 38 additions & 0 deletions src/biomappings/templates/summary.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% extends "base.html" %}

{% import "bootstrap4/form.html" as wtf %}
{% import "bootstrap4/utils.html" as util %}

{% block title %}Biomappings Summary{% endblock %}

{% 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 Su</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() %}
<tr>
<td>{{ source_prefix }}</td>
<td>{{ target_prefix }}</td>
<td style="text-align: right;">{{ "{:,d}".format(count) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}
Loading

0 comments on commit 85d37f1

Please sign in to comment.