mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 17:19:42 +00:00
Add progressbars for recipe specs
This commit is contained in:
parent
95e5a35295
commit
c3bce202c1
3 changed files with 89 additions and 27 deletions
|
|
@ -35,3 +35,8 @@ body {
|
||||||
.above-footer {
|
.above-footer {
|
||||||
padding-bottom: 14rem;
|
padding-bottom: 14rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spec-progress {
|
||||||
|
height: 1.5rem;
|
||||||
|
font-size: 1.125rem;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,3 +77,30 @@
|
||||||
{% macro moment(timestamp, format="llll") %}
|
{% macro moment(timestamp, format="llll") %}
|
||||||
<script>document.write(moment.utc("{{ timestamp }}").local().format("llll"));</script>
|
<script>document.write(moment.utc("{{ timestamp }}").local().format("llll"));</script>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
{#
|
||||||
|
Render a bootstrap progressbar
|
||||||
|
#}
|
||||||
|
{% macro render_progressbar(value, min, max, unit='', class='') %}
|
||||||
|
{#
|
||||||
|
Determine percentage. Coerce to between 0 and 100.
|
||||||
|
Set an appropriate background.
|
||||||
|
#}
|
||||||
|
{% set pct = (100*(value-min))/(max-min) %}
|
||||||
|
{% if pct > 85 %}
|
||||||
|
{% set color = 'bg-danger' %}
|
||||||
|
{% if pct > 100 %}
|
||||||
|
{% set pct = 100 %}
|
||||||
|
{% endif %}
|
||||||
|
{% elif pct > 15 %}
|
||||||
|
{% set color = 'bg-success' %}
|
||||||
|
{% else %}
|
||||||
|
{% set color = 'bg-warning' %}
|
||||||
|
{% if pct <= 0 %}
|
||||||
|
{% set pct = 5 %} {# we want a little bit of the bar showing. #}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
<div class="progress {{ class }}">
|
||||||
|
<div class="progress-bar {{ color }}" role="progressbar" style="width: {{ pct|int }}%;" aria-valuenow="{{ value }}" aria-valuemin="{{ min }}" aria-valuemax="{{ max }}">{{ value }}{{ unit }}</div>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-#}
|
-#}
|
||||||
{% from "_macros.html" import render_field_with_errors, render_delete_button, render_delete_modal, moment %}
|
{% import '_macros.html' as macros %}
|
||||||
|
|
||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
{% block title %}{{ recipe.name }}{% endblock %}
|
{% block title %}{{ recipe.name }}{% endblock %}
|
||||||
|
|
@ -44,11 +44,11 @@
|
||||||
<dl>
|
<dl>
|
||||||
{% if 'created' in recipe %}
|
{% if 'created' in recipe %}
|
||||||
<dt>Created</dt>
|
<dt>Created</dt>
|
||||||
<dd>{{ moment(recipe.created) }}</dd>
|
<dd>{{ macros.moment(recipe.created) }}</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if 'updated' in recipe %}
|
{% if 'updated' in recipe %}
|
||||||
<dt>Updated</dt>
|
<dt>Updated</dt>
|
||||||
<dd>{{ moment(recipe.updated) }}</dd>
|
<dd>{{ macros.moment(recipe.updated) }}</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -58,21 +58,51 @@
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Original Gravity</dt>
|
<dt>Original Gravity</dt>
|
||||||
<dd>{{ recipe|recipe_og }}</dd>
|
<dd>
|
||||||
|
{% if style %}
|
||||||
|
{{ macros.render_progressbar(recipe|recipe_og|float, style.og.low|float, style.og.high|float, class='spec-progress') }}
|
||||||
|
{% else %}
|
||||||
|
{{ recipe|recipe_og }}
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
<dt>Final Gravity</dt>
|
<dt>Final Gravity</dt>
|
||||||
<dd>{{ recipe|recipe_fg }}</dd>
|
<dd>
|
||||||
|
{% if style %}
|
||||||
|
{{ macros.render_progressbar(recipe|recipe_fg|float, style.fg.low|float, style.fg.high|float, class='spec-progress') }}
|
||||||
|
{% else %}
|
||||||
|
{{ recipe|recipe_fg }}
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
<dt>Alcohol</dt>
|
<dt>Alcohol</dt>
|
||||||
<dd>{{ recipe|recipe_abv }} %/vol.</dd>
|
<dd>
|
||||||
|
{% if style %}
|
||||||
|
{{ macros.render_progressbar(recipe|recipe_abv|float, style.abv.low|float, style.abv.high|float, unit=' %/vol', class='spec-progress') }}
|
||||||
|
{% else %}
|
||||||
|
{{ recipe|recipe_abv }} %/vol.
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Bitterness</dt>
|
<dt>Bitterness</dt>
|
||||||
<dd>{{ recipe|recipe_ibu }} IBU</dd>
|
<dd>
|
||||||
|
{% if style %}
|
||||||
|
{{ macros.render_progressbar(recipe|recipe_ibu|float, style.ibu.low|float, style.ibu.high|float, unit=' IBU', class='spec-progress') }}
|
||||||
|
{% else %}
|
||||||
|
{{ recipe|recipe_ibu }} IBU
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
<dt>Bitterness Ratio</dt>
|
<dt>Bitterness Ratio</dt>
|
||||||
<dd>{{ recipe|recipe_ibu_ratio }} IBU/OG</dd>
|
<dd>{{ recipe|recipe_ibu_ratio }} IBU/OG</dd>
|
||||||
<dt>Color</dt>
|
<dt>Color</dt>
|
||||||
<dd>{{ recipe|recipe_srm }} SRM</dd>
|
<dd>
|
||||||
|
{% if style %}
|
||||||
|
{{ macros.render_progressbar(recipe|recipe_srm|float, style.srm.low|float, style.srm.high|float, unit=' SRM', class='spec-progress') }}
|
||||||
|
{% else %}
|
||||||
|
{{ recipe|recipe_srm }} SRM
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -175,9 +205,9 @@
|
||||||
{% if session.logged_in %}
|
{% if session.logged_in %}
|
||||||
<div class="row mt-4 pt-1 border-top">
|
<div class="row mt-4 pt-1 border-top">
|
||||||
<a class="btn btn-secondary mr-1" href="{{ url_for('recipes.update', id=recipe._id) }}">Update Recipe</a>
|
<a class="btn btn-secondary mr-1" href="{{ url_for('recipes.update', id=recipe._id) }}">Update Recipe</a>
|
||||||
{{ render_delete_button('Delete Recipe', 'deleteRecipe', 'btn-danger') }}
|
{{ macros.render_delete_button('Delete Recipe', 'deleteRecipe', 'btn-danger') }}
|
||||||
</div>
|
</div>
|
||||||
{{ render_delete_modal(url_for('recipes.delete', id=recipe._id), 'deleteRecipe', recipe.name) }}
|
{{ macros.render_delete_modal(url_for('recipes.delete', id=recipe._id), 'deleteRecipe', recipe.name) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="row mt-4"><a href="{{ url_for('recipes.info_json', id=recipe._id) }}">Export JSON</a></div>
|
<div class="row mt-4"><a href="{{ url_for('recipes.info_json', id=recipe._id) }}">Export JSON</a></div>
|
||||||
<div class="row">Recipe revision: {{ recipe._rev }}</div>
|
<div class="row">Recipe revision: {{ recipe._rev }}</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue