{% extends "base.html" %}

{% set active_page = "assets" %}

{% block title %} Asset listing {% endblock %}

{% block divs %}

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12">

            <h2>All assets</h2>
            <table class="table table-striped table-responsive paginate">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th class="text-right no-sort">Location</th>
                        <th class="text-right">Capacity</th>
                        <th class="text-right">Resolution</th>
                        <th class="text-right">Asset id</th>
                        <th class="text-right">Owner id</th>
                        <th class="text-right no-sort">Entity address</th>
                        <th class="text-right no-sort">Old entity address (API v1)</th>
                        <th class="text-right no-sort">
                            {% if user_is_admin %}
                            <form action="/assets/new" method="get">
                                <button class="btn btn-sm btn-responsive btn-success" type="submit">Create new
                                    asset</button>
                            </form>
                            {% endif %}
                        </th>
                    </tr>
                </thead>
                <tbody>
                    {% for asset in assets: %}
                    <tr>
                        <td>
                            <i class="{{ asset.asset_type_name | asset_icon }} left-icon"><a
                                    href="/assets/{{ asset.id }}" alt="Edit this asset">{{ asset.display_name }}</a></i>
                        </td>
                        <td class="text-right">
                            LAT: {{ "{:,.4f}".format( asset.latitude ) }} LONG:
                            {{ "{:,.4f}".format( asset.longitude ) }}
                        </td>
                        <td class="text-right">
                            {{ "{:,.3f}".format( asset.capacity_in_mw ) }} MW
                        </td>
                        <td class="text-right">
                            {{ asset.event_resolution | naturalized_timedelta }}
                        </td>
                        <td class="text-right">
                            {{ asset.id }}
                        </td>
                        <td class="text-right">
                            {{ asset.owner_id }}
                        </td>
                        <td class="text-right">
                            {{ asset.entity_address }}
                        </td>
                        <td class="text-right">
                            {{ asset.entity_address_fm0 }}
                        </td>
                        <td class="text-right">
                            <form action="../../analytics" method="get">
                                <input type="hidden" name="resource" value="{{ asset.name }}">
                                <button class="btn btn-sm btn-responsive btn-info" type="submit">Analyse this
                                    asset</button>
                            </form>
                        </td>

                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>

{% block paginate_tables_script %} {{ super() }} {% endblock %}

{% endblock%}