{% extends 'layouts/default.html' %}
{% block title %}ExaFS - ApiKeys{% endblock %}
{% block content %}
    <h1>Your machines and ApiKeys</h1>
    <table class="table table-hover">
    <tr>
    <th>Machine address</th>
    <th>ApiKey</th>
    <th>Organization</th>
    <th>Expires</th>
    <th>Read only</th>
    <th>Action</th>
    </tr>
    {% for row in keys %}
        <tr>
        <td>
            {{ row.machine }}
        </td>
        <td>
            {{ row.key }}
        </td>
        <td>
            {{ row.org.name }}
        <td>
            {{ row.expires|strftime }}
        </td>
        <td>
            {% if row.readonly %}
            <button type="button" class="btn btn-success btn-sm" title="Read Only">
                <i class="bi bi-check-lg"></i>
            </button>
                
            {% endif %}
        </td>
        <td>
            <a class="btn btn-danger btn-sm" href="{{ url_for('api_keys.delete', key_id=row.id) }}" role="button">
                <i class="bi bi-x-lg"></i>
            </a>
            {% if row.comment %}
                <button type="button" class="btn btn-info btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="{{ row.comment }}">
                    <i class="bi bi-chat-left-text-fill"></i>
                </button>
            {% endif %}
        </td>    
        </tr>
    {% endfor %}
    </table>
    <a class="btn btn-primary" href="{{ url_for('api_keys.add') }}" role="button">
                         Add new ApiKey
                    </a>
{% endblock %}