From aa9fda93c0eb8f506167cfc6307282366013ad04 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Mon, 11 Jul 2016 22:15:23 +0200 Subject: [PATCH] statistics 3rd --- app/rollerverbrauch/templates/statistics.html | 274 +++++++++--------- 1 file changed, 134 insertions(+), 140 deletions(-) diff --git a/app/rollerverbrauch/templates/statistics.html b/app/rollerverbrauch/templates/statistics.html index 0b3ceb4..f559fec 100644 --- a/app/rollerverbrauch/templates/statistics.html +++ b/app/rollerverbrauch/templates/statistics.html @@ -23,159 +23,153 @@ zoom_chart_{{ hash }}() {% endmacro %} -{% macro chart(data, baseId, unit, link, active)%} - {% set chartID = 'chart_' + baseId %} -
- {% if data|length > 0 %} -
- - {% else %} - - {% endif %} +{% macro nav_tab(id, text, active) %} + {# + + #} +
  • + + {{ text }} + +
  • +{% endmacro %} + +{% macro tab_pane(id, content, active) %} +
    + {{ content }} +
    +{% endmacro %} + +{% macro chart(data, baseId, unit, link) %} + {% if data|length > 0 %} + {% set chartID = 'chart_' + baseId %} +
    + + {% else %} + + {% endif %} +{% endmacro %} + +{% macro print_consumable_table(consumable) %} + + + + + + + + + + + + + + + + + +
    Average Distance:{{ consumable.average_distance | round(2) }} km
    Amount fuelled:{{ consumable.overall_amount | round(2) }} {{ consumable.unit }}
    Average Amount fuelled:{{ consumable.average_amount_fuelled | round(2) }} {{ consumable.unit }}
    Average Amount used:{{ consumable.average_amount_used | round(2) }} {{ consumable.unit }}/100km
    +{% endmacro %} + +{% macro print_vehicle_table(vehicle) %} +

    {{vehicle.name}}

    +
    + + + + + + + + + +
    Logged Distance:{{ vehicle.overall_distance | round(2) }} km
    Logged Costs:{{ vehicle.overall_costs | round(2) }} €
    {% endmacro %} +{% macro tab_script(id) %} + +{% endmacro %} + {% block body %}
    {% for vehicle in data %} -
    -

    {{vehicle.name}}

    -
    - - - - - - - - - -
    Logged Distance:{{ vehicle.overall_distance | round(2) }} km
    Logged Costs:{{ vehicle.overall_costs | round(2) }} €
    -
    - - -
    - {% for consumable in vehicle.consumables %} -
    - - - - - - - - - - - - - - - - - -
    Average Distance:{{ consumable.average_distance | round(2) }} km
    Amount fuelled:{{ consumable.overall_amount | round(2) }} {{ consumable.unit }}
    Average Amount fuelled:{{ consumable.average_amount_fuelled | round(2) }} {{ consumable.unit }}
    Average Amount used:{{ consumable.average_amount_used | round(2) }} {{ consumable.unit }}/100km
    - -{% set ID = vehicle.id|string + '_c' + consumable.id|string %} -{% set odometerID = ID + '_odometer' %} -{% set consumptionID = ID + '_consumption' %} -{% set amountID = ID + '_amount' %} - -
    - {% set baseId = 'v' + odometerID %} - {% set link = url_for('select_consumable_for_new_pitstop', vid=vehicle.id) %} - {{ chart(vehicle.odometers, baseId, 'km', link, true) }} - - - {% set baseId = 'v' + consumptionID %} - {% set link = url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id) %} - {{ chart(consumable.average_amount, baseId, consumable.unit + '/100km', link, false) }} - - - {% set baseId = 'v' + amountID %} - {% set link = url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id) %} - {{ chart(consumable.amounts, baseId, consumable.unit, link, false) }} -
    - - -
    - {% endfor %} -
    - - +
    + {{ print_vehicle_table(vehicle) }} + +
    + {{ tab_pane( + vehicle.id|string + '_odometer', + chart( + vehicle.odometers, + 'ref_' + vehicle.id|string + '_odometer', + 'km', + url_for('select_consumable_for_new_pitstop', vid=vehicle.id) + ), + true + ) + }} + {% for consumable in vehicle.consumables %} +
    + {{ print_consumable_table(consumable) }} + +
    + {{ tab_pane( + vehicle.id|string + '_' + consumable.id|string + '_consumption', + chart( + consumable.average_amount, + 'ref_' + vehicle.id|string + '_' + consumable.id|string + '_consumption', + consumable.unit + '/100km', + url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id) + ), + true + ) + }} + {{ tab_pane( + vehicle.id|string + '_' + consumable.id|string + '_amount', + chart( + consumable.amounts, + 'ref_' + vehicle.id|string + '_' + consumable.id|string + '_amount', + consumable.unit, + url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id) + ), + false + ) + }} +
    + {{ tab_script('vehicle_' + vehicle.id + '_' + consumable.id + '_tabs') }} +
    + {% endfor %} +
    + {{ tab_script('vehicle_' + vehicle.id + '_tabs') }}
    {% endfor %}
    + {{ tab_script('vehicle_tabs') }}
    - - - - - - {% endblock %}