{% extends "defaults.jinja" %}

{% block base %}

<!DOCTYPE html>
<html lang="en">

<head>
    {% block head %}
    <title>{% block title %}{% endblock %} - {{ FLEXMEASURES_PLATFORM_NAME }}
    </title>
    {% endblock head %}
    <meta charset="windows-1252">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" href="favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    {% block styles %}
    <!-- Leaflet -->
    <link href="https://cdn.jsdelivr.net/npm/leaflet@1.7.1/dist/leaflet.css" rel="stylesheet" />
    <link href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.css" rel="stylesheet" />
    <link href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.Default.css" rel="stylesheet" />
    <!-- Bootstrap -->
    <link href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    {% if show_datepicker %}
    <link href="https://cdn.jsdelivr.net/npm/daterangepicker@3.1.0/daterangepicker.css"
        rel="stylesheet" />
    {% endif %}
    <!-- Fonts -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
        rel="stylesheet" />
    <link href="{{ url_for('flexmeasures_ui.static', filename='css/external/weather-icons.min.css') }}"
        rel="stylesheet" />
    <!-- Ion range slider -->
    <link href="https://cdn.jsdelivr.net/npm/ion-rangeslider@2.3.1/css/ion.rangeSlider.css"
        rel="stylesheet" />
    <!-- Custom CSS -->
    <link href="{{ url_for('flexmeasures_ui.static', filename='css/flexmeasures.css') }}" rel="stylesheet" />
    {% if contains_plots %}
    {{ bokeh_css_resources|indent(4)|safe }}
    {{ bokeh_js_resources|indent(4)|safe }}
    {% endif %}
    {% if active_page == "tasks" %}
    <link href="{{ url_for('flexmeasures_ui.static', filename='css/external/rq-dashboard-bootstrap.min.css') }}"
        rel="stylesheet" />
    {% elif active_page in ("assets", "users", "portfolio") %}
    <link href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.min.css" rel="stylesheet" />
    {% endif %}
    {% if extra_css %}
    <link href="{{ extra_css }}" rel="stylesheet" />
    {% endif %}
    {% endblock %}
</head>

<body>

    {% block body %}

    {% block nav %}

    <nav class="navbar navbar-default navbar-fixed-top" id="topnavbar">
        <div id="navbar-container" class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <span class="navbar-brand">
                    <a href="/">
                        <span class="navbar-tool-name">
                        {% if menu_logo %}
                            <img id="navbar-logo" src="{{menu_logo}}"/>
                        {% else %}
                            <img src="https://artwork.lfenergy.org/projects/flexmeasures/horizontal/white/flexmeasures-horizontal-white.svg" alt="FlexMeasures"/>
                        {% endif %}
                        </span>
                    </a>
                </span>
            </div>
            <div class="collapse navbar-collapse  navbar-right" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    {% for href, id, caption, tooltip, icon in navigation_bar %}
                    {% if id == "tasks" %}
                    <li {% if id == active_page %} class="active" {% endif %} class="dropdown">
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="fa fa-tasks"
                                aria-hidden="true"></span>
                            Tasks
                            <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li {% if current_user.has_role('anonymous') %}class="disabled" {% endif %}><a
                                    {% if not current_user.has_role('anonymous') %}href="/tasks/forecasting"
                                    {% endif %}>Forecasts</a></li>
                            <li {% if current_user.has_role('anonymous') %}class="disabled" {% endif %}><a
                                    {% if not current_user.has_role('anonymous') %}href="/tasks/scheduling"
                                    {% endif %}>Schedules</a></li>
                            <li {% if current_user.has_role('anonymous') %}class="disabled" {% endif %}><a
                                    {% if not current_user.has_role('anonymous') %}href="/tasks/labelling"
                                    {% endif %}>Labels</a></li>
                            <li {% if current_user.has_role('anonymous') %}class="disabled" {% endif %}><a
                                    {% if not current_user.has_role('anonymous') %}href="/tasks/alerting"
                                    {% endif %}>Alerts</a></li>
                            <li {% if current_user.has_role('anonymous') %}class="disabled" {% endif %}><a
                                    {% if not current_user.has_role('anonymous') %}href="/tasks/reporting"
                                    {% endif %}>Reports</a></li>
                        </ul>
                    </li>
                    {% else %}
                    <li {% if id == active_page %} class="active" {% endif %} data-toggle="tooltip" title="{{ tooltip }}" data-placement="bottom"
                        {% if id == 'upload' or (current_user.has_role('anonymous') and id in ('tasks', 'users', 'control', 'portfolio')) %}
                        class="disabled" {% endif %}>
                        <a {% if not ( id == 'upload' or (current_user.has_role('anonymous') and id in ('tasks', 'users', 'control', 'portfolio')) ) %}href="/{{ href|e }}"
                            {% endif %}{% if id == 'docs' %} target="_blank" {% endif %}>
                            <span class="fa fa-{{ icon }}" aria-hidden="true"></span>
                            {{ caption|e }}

                            {# use tooltip as caption for small screens #}
                            {% if not caption %}
                            <span class="visible-xs-inline">{{ tooltip }}</span>
                            {% endif %}

                        </a>
                    </li>
                    {% endif %}
                    {% endfor %}
                </ul>
            </div>
        </div>
    </nav>

    {% endblock nav %}

    {% if message and message != "" %}
    <div class="col-sm-12 alert alert-info">{{ message}} </div>
    {% endif %}
    {% if (msg is defined) and msg %}
    <div class="col-sm-12 alert alert-info">{{ msg }}</div>
    {% endif %}

    <!-- loading this earlier so templates can use it -->
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.5.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/floatthead/2.2.1/jquery.floatThead.min.js"></script>

    <!-- This should always be there, even on error pages  -->
    <script type="text/javascript">
        var timerangeStart = "{{ start_time }}";
        var timerangeEnd = "{{ end_time }}";
    </script>

    {# Div blocks that child pages can reference #}
    {% block divs %}


    {% block datetimepicker %}

    <div class="form-group row datetimepicker">
        <div class="col-sm-2">
            <div class="col-sm-1"><i class="icon-time center-icon"></i></div>
        </div>
        <div class="col-sm-10">
            <label class="control-label">Time window</label>
            <div class="btn-group btn-group-justified">
                <input type="text" name="daterange" value="01/01/2015 1:30 PM - 01/01/2015 2:00 PM" />
            </div>
        </div>
    </div>
    <!-- form to refresh page -->
    <form style="display: hidden" action="" method="POST" id="datepicker_form">
        <input type="hidden" id="datepicker_form_start_time" name="start_time" value="{{ start_time }}" />
        <input type="hidden" id="datepicker_form_end_time" name="end_time" value="{{ end_time }}" />
    </form>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
    {% endblock datetimepicker %}

    {% block forecastpicker %}

    <div class="form-group row">
        <div class="col-sm-2">
            <div class="col-sm-1"><i class="icon-binoculars center-icon"></i></div>
        </div>
        <div class="col-sm-10">
            <label class="control-label">Forecast (rolling)</label>
            <!--<div class="btn-group btn-group-justified" role="group" aria-label="...">-->
            <!--<a role="button" href="#" class="btn btn-default forecast-toggle active" forecast-type="rolling">Rolling</a>-->
            <!--<a role="button" href="#" class="btn btn-default forecast-toggle" forecast-type="static">Static</a>-->
            <!--</div>-->
            <div>
                <form action="" method="POST" id="forecast_horizon_form">
                    <select class="form-control" id="forecast_horizon" name="forecast_horizon"
                        onchange="this.form.submit()">
                        {% for horizon in forecast_horizons %}
                        <option value="{{ horizon }}" {% if horizon == active_forecast_horizon %} selected="selected"
                            {% endif %}>with a horizon of {{ horizon }}</option>
                        {% endfor %}
                    </select>
                </form>
            </div>
        </div>
    </div>

    {% endblock forecastpicker %}

    {% block attributions %}
    <div id="att-text" style="display: none;">
        <ul>
            <li>Plots made with <a href="https://bokeh.pydata.org">Bokeh</a>.</li>
            <li>Icons made by <a href="https://freepik.com">Freepik</a>, <a
                    href="https://www.flaticon.com/authors/tomas-knop" title="Tomas Knop">Tomas Knop</a>, <a
                    href="https://www.flaticon.com/authors/gregor-cresnar" title="Gregor Cresnar">Gregor Cresnar</a> and
                <a href="https://www.flaticon.com/authors/those-icons" title="Those Icons">Those Icons</a> from <a
                    href="https://flaticon.com">www.flaticon.com</a>.</li>
        </ul>
    </div>
    {% endblock attributions %}

    {% endblock divs %}


    {#- Scripts used by all views (e.g. by navigation menu) -#}
    <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"></script>

    {% block scripts %}

    <!-- External scripts -->
    <script src="https://cdn.jsdelivr.net/npm/ion-rangeslider@2.3.1/js/ion.rangeSlider.min.js"></script>

    <!-- Custom scripts -->
    <script src="{{ url_for('flexmeasures_ui.static', filename='js/flexmeasures.js') }}"></script>
    {% if show_datepicker %}
    <script src="{{ url_for('flexmeasures_ui.static', filename='js/daterangepicker-init.js') }}"></script>
    {% endif %}

    <!-- External scripts that should run after custom scripts -->
    {% if show_datepicker %}
    <script src="https://cdn.jsdelivr.net/npm/daterangepicker@3.1.0/daterangepicker.min.js"></script>
    {% endif %}

    {% endblock scripts %}

    {% block paginate_tables_script %}
    <script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
    <script
        src="https://cdn.datatables.net/plug-ins/1.10.22/features/conditionalPaging/dataTables.conditionalPaging.js"></script>
    {% endblock paginate_tables_script %}

    <footer class="page-footer font-small pt-4 mt-4">
        <div class="footer text-center">
            <div class="container-fluid">
                {% block copyright_notice %}
                FlexMeasures technology is created by <a href="https://seita.nl/">Seita Energy Flexibility</a>,
                in cooperation with <a href="https://aoneeng.com/">A1 Engineering</a>
                &copy
                <script>var CurrentYear = new Date().getFullYear(); document.write(CurrentYear)</script>.
                {% endblock copyright_notice %}

                {% block about %}
                <a href="#" data-toggle="modal" data-target="#About">About FlexMeasures</a>.
                <!-- The modal -->
                <div class="modal fade" id="About" tabindex="-1" role="dialog" aria-labelledby="modalLabelLarge" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="modalLabelLarge">About FlexMeasures</h4>
                </div>

                <div class="modal-body">

                    <div class="justify">
                        <p>
                            In a world with renewable energy, flexibility is crucial for cost and CO₂ reduction.
                            Planning ahead allows flexible devices to profit from scheduling the best flexible
                            actions (such as shifting or curtailing energy use).
                        </p>
                        <p>
                            The {{ FLEXMEASURES_PLATFORM_NAME }} Platform is a tool for businesses operating energy devices.
                            Its purpose is to realise the best value for device owners by scheduling balancing actions.
                            For instance, if the devices draw from or supply to the power grid, {{ FLEXMEASURES_PLATFORM_NAME }} can assist in
                            selling balancing services to energy markets.
                            It fulfills this purpose with three services: Monitoring, forecasting and scheduling.
                            {{ FLEXMEASURES_PLATFORM_NAME }} is designed as open-source software to empower energy service companies while they
                            maintain autonomy over their operations and their technology roadmap.
                            Read more <a href="https://flexmeasures.readthedocs.io">here</a>.

                        </p>
                        <p>
                            {{ FLEXMEASURES_PLATFORM_NAME }} is compliant with the Universal Smart Energy Framework (<a
                                href="https://www.usef.energy/download-the-framework/a-flexibility-market-design/">USEF</a>), a
                            “flexibility market design for the trading and commoditisation of energy flexibility and the
                            architecture, tools and rules to make it work effectively.
                            USEF fits on top of most market models and is already being adopted across Europe to accelerate and
                            future-proof smart energy projects.”
                        </p>
                        {% if current_user.has_role('anonymous') and current_user.has_role('CPO') %}
                        <p>
                            This demo is tuned to operators of charge points for electric vehicles (EVs).
                            The terminology used follows the Open Charge Point Interface (<a
                                href="https://ocpi-protocol.org/">OCPI</a>).
                            This dashboard shows you the locations of all charge points connected to the platform and how they
                            are doing.
                            Each charge point contains multiple chargers&mdash;called Electric Vehicle Supply Equipment (EVSE)
                            in OCPI&mdash;which are monitored individually (click on a charge point location to reveal its
                            EVSE).
                        </p>
                        <p>
                            {{ FLEXMEASURES_PLATFORM_NAME }} supports automated scheduling of charging profiles through its API.
                            Charging profiles are optimised against applicable market conditions like wholesale prices and
                            contracted (time-of-use) tariffs.
                            Charging preferences can be set to reflect whether EV owners are in a hurry or parking for some
                            time.
                        </p>
                        {% endif %}
                    </div>
                </div>
                
                </div>
                </div>
                </div>

                {% endblock about %}

                {% block credits %}
                <a href="#" data-toggle="modal" data-target="#Credits">Credits</a>.

                <!-- The modal -->
                <div class="modal fade" id="Credits" tabindex="-1" role="dialog" aria-labelledby="modalLabelLarge" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="modalLabelLarge">Credits</h4>
                </div>

                <div class="modal-body">
                    <div class="row">
                        <div class="col-sm-6">
                            <h3>Images from <a href="https://seita.nl">Seita</a></h3>
                            <div>FlexMeasures on laptop - image by <a href="https://drakemultimedia.nl/" title="Bobby Drake">Bobby Drake</a></div>
                            <h3>Images from <a href="https://unsplash.com/" title="Unsplash">Unsplash</a></h3>
                            <div>Tesla charging station - image by <a href="https://www.chasealewis.com/" title="Chase Lewis">Chase Lewis</a></div>
                            <div>Wind turbines on top of mountain - image by <a href="https://www.tbk-f.com/" title="TJ K.">TJ K.</a></div>
                        </div>
                        <div class="col-sm-6">
                            <h3>Icons from <a href="https://www.flaticon.com/" title="Flaticon">Flaticon</a></h3>
                            <div><a href="https://www.flaticon.com/free-icon/wind-power_1085695">Wind turbine</a> - icon by <a href="https://www.flaticon.com/authors/good-ware" title="Good Ware">Good Ware</a> (made to spin by Seita)</div>
                            <div><a href="https://www.flaticon.com/search?word=currency&author_id=258">Coins</a> - icons by <a href="https://www.flaticon.com/authors/pixelmeetup" title="Pixelmeetup">Pixelmeetup</a></div>
                            <div>Other icons by <a href="https://www.freepik.com" title="Freepik">Freepik</a></div>
                        </div>
                    </div>
                </div>
                <div class="modal-header">
                    We did our best to give credit to the original photographers and illustrators for the images included on this website. If we have not properly credited an original photographer or illustrator, please notifiy us and we will make the appropriate changes necessary.
                </div>

                </div>
                </div>
                </div>
                {% endblock credits %}

                {% block technical_info %}
                {# We might render templates from plugins, where this meta info is not available #}
                {% if app_running_since %}
                    This app is running since {{ app_running_since }}
                {% endif %}
                {% if (flexmeasures_version or git_version) and not current_user.has_role('anonymous') %}
                    {% if flexmeasures_version %}
                        on version {{ flexmeasures_version }}.
                    {% else %}
                        {% if git_version != "Unknown" %}
                        on version {{ git_version }}+{{ git_commits_since }}.
                        {% else %}
                        on revision {{ git_hash }}.
                        {% endif %}
                    {% endif %}
                {% endif %}
                {% if loaded_plugins %}
                    Loaded plugins: {{ loaded_plugins }}.
                {% endif %}
                {% endblock technical_info %}
            </div>
            <div>
                <a href="https://flexmeasures.io/"><img src="https://artwork.lfenergy.org/projects/flexmeasures/icon/white/flexmeasures-icon-white.svg" alt="FlexMeasures" class="footer-logo"></a>
            </div>
        </div>
    </footer>
    {% endblock body %}
</body>

</html>

{% endblock base %}
