Skip to content

Commit

Permalink
show version in bmds desktop table
Browse files Browse the repository at this point in the history
  • Loading branch information
shapiromatron committed Aug 1, 2024
1 parent 062d8e1 commit dc6d22c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
11 changes: 8 additions & 3 deletions bmds_ui/analysis/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from io import BytesIO

import pandas as pd
import pydantic
import reversion
from django.conf import settings
from django.core.cache import cache
Expand All @@ -21,6 +22,7 @@
from pybmds.recommender.recommender import RecommenderSettings
from pybmds.types.session import VersionSchema

from .. import __version__
from ..common.utils import random_string
from . import constants, tasks, validators
from .executor import AnalysisSession, MultiTumorSession, Session, deserialize
Expand Down Expand Up @@ -316,7 +318,7 @@ def execute(self):
# get prepare complete output object
analysis_output = AnalysisOutput(
analysis_id=str(self.id),
bmds_ui_version=settings.COMMIT.sha,
bmds_ui_version=__version__,
bmds_python_version=bmds_python_version,
outputs=[output.model_dump(by_alias=True) for output in outputs],
)
Expand Down Expand Up @@ -356,9 +358,12 @@ def renew(self):
self.deletion_date = get_deletion_date(self.deletion_date)

def get_bmds_version(self) -> VersionSchema | None:
if not self.is_finished or self.has_errors:
if not self.is_finished or self.has_errors or self.outputs is None:
return None
try:
return VersionSchema.model_validate(self.outputs["bmds_python_version"])
except pydantic.ValidationError:
return None
return AnalysisOutput.model_validate(self.outputs).bmds_python_version

@property
def deletion_date_str(self) -> str | None:
Expand Down
20 changes: 15 additions & 5 deletions bmds_ui/analysis/templates/analysis/desktop_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ <h3 class="flex-grow-1">Analyses</h3>

</div>

<form class="form-row align-items-center bg-light py-3" hx-get="{% url 'home' %}" hx-sync="this:replace" hx-select="#analysis-list" hx-target="#analysis-list" hx-swap="outerHTML" hx-trigger="change,keyup from:.typeahead changed delay:0.5s">
<div class="col-auto">
<form class="shadow-sm form-row align-items-center bg-lightblue p-3" hx-get="{% url 'home' %}" hx-sync="this:replace" hx-select="#analysis-list" hx-target="#analysis-list" hx-swap="outerHTML" hx-trigger="change,keyup from:.typeahead changed delay:0.5s">
<div class="col">
<input class="form-control typeahead" name="q" value="{{q}}" type="text" placeholder="Search"/>
</div>
<div class="col-auto">
Expand Down Expand Up @@ -68,7 +68,14 @@ <h3 class="flex-grow-1">Analyses</h3>
<col />
<col width="150px" />
<col width="100px" />
<col width="100px" />
</colgroup>
<thead>
<th colspan="2">Analysis</th>
<th>Type</th>
<th>Version</th>
<th>Last Updated</th>
</thead>
<tbody>
{% for object in objects %}
<tr>
Expand All @@ -78,14 +85,17 @@ <h3 class="flex-grow-1">Analyses</h3>
<a class="text-dark stretched-link" href="{{object.get_edit_url}}">{{object}}</a>
</td>
<td>{{object.model_class_label}}</td>
<td>{{object.get_bmds_version.python|default:"-"}}</td>
<td>{% table_time now object.timestamp %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% include "includes/pagination.html" %}
{% else %}
<p class="text-muted">No analyses found.</p>
{% elif has_query %}
<div class="px-3 py-4 text-muted">
<p class="h4">No analyses available.</p>
</div>
{% endif %}
{% endwith %}
</div>
Expand All @@ -99,7 +109,7 @@ <h4 class="mb-0 text-white text-center">Support</h4>
<ul class="mb-0">
<li><a href="https://www.epa.gov/bmds" target="_blank" rel="noopener noreferrer">BMDS Home Page</a></li>
<li><a href="https://www.epa.gov/bmds/how-modeling-dichotomous-data-bmds-online" target="_blank" rel="noopener noreferrer">BMDS Online Tutorial</a></li>
<li><a href="https://www.epa.gov/bmds/benchmark-dose-software-bmds-version-32-download" target="_blank" rel="noopener noreferrer">BMDS Downloads</a></li>
<li><a href="https://www.epa.gov/bmds/download-bmds" target="_blank" rel="noopener noreferrer">BMDS Downloads</a></li>
<li><a href="https://ecomments.epa.gov/bmds/" target="_blank" rel="noopener noreferrer">BMDS Support</a></li>
</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions bmds_ui/analysis/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def get_context_data(self, **kwargs):
collections=models.Collection.opts(),
model_types=constants.model_types,
now=now(),
has_query=len(self.request.GET) > 0,
)
return context

Expand Down
4 changes: 4 additions & 0 deletions bmds_ui/static/css/epa/bmdsonline.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ a.dropdown-toggle:not([href])::after {
border-right: 0px;
border-color: #dddddd
}
.analysis-list th {
border: 0px;
background-color: white;
}

/* Expand width of footer column since there is only one column */
.bmds-desktop,.footer__column{
Expand Down
3 changes: 3 additions & 0 deletions bmds_ui/static/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ input[type=number] {
.bg-custom {
background-color: #b8daff;
}
.bg-lightblue {
background-color: #eaf6ff;
}

/* always above toast container */
.toast-container {
Expand Down

0 comments on commit dc6d22c

Please sign in to comment.