{% extends "generic/object.html" %}
{% load render_table from django_tables2 %}
{% load plugins %}
{% load i18n %}
{% load helpers %}
{% block content %}
    <div class="row mb-3">
        <div class="col col-md-6">
            <div class="card">
                <h5 class="card-header">Credential Details</h5>
                <div class="card-body">
                    <table class="table table-hover attr-table">
                        <tr>
                            <th scope="row">Type</th>
                            <td>
                                {% badge object.get_credential_type_display bg_color=object.get_credential_type_color %}
                            </td>
                        </tr>
                        <tr>
                            <th scope="row">Username / Service Account</th>
                            <td>{{ object.username }}</td>
                        </tr>
                        <tr>
                            <th scope="row">Owner</th>
                            <td>{{ object.owner }}</td>
                        </tr>
                        <tr>
                            <th scope="row">Used By</th>
                            <td>{{ object.used_by }}</td>
                        </tr>
                    </table>
                </div>
            </div>
            {% if object.credential_storage %}
                <div class="card">
                    <h5 class="card-header">Credential Storage</h5>
                    <div class="card-body">
                        <pre class="fingerprint"
                             style="white-space: pre-wrap;
                                    word-break: break-all;
                                    font-family: monospace">{{ object.credential_storage }}</pre>
                    </div>
                </div>
            {% endif %}
            <div class="card">
                <h5 class="card-header">Description</h5>
                <div class="card-body">
                    {% if object.description %}
                        {{ object.description|markdown }}
                    {% else %}
                        <span class="text-muted">{% trans "None" %}</span>
                    {% endif %}
                </div>
            </div>
            {% include "inc/panels/custom_fields.html" %}
            {% plugin_left_page object %}
        </div>
        <div class="col col-md-6">
            {% include "inc/panels/tags.html" %}
            {% include "inc/panels/comments.html" %}
            {% plugin_right_page object %}
        </div>
    </div>
    <div class="row">
        <div class="col col-md-12">
            <div class="card">
                <h5 class="card-header">{% trans "Devices" %}</h5>
                {% if device_ids %}
                    {% htmx_table 'dcim:device_list' id=device_ids %}
                {% else %}
                    <div class="card-body">
                        <p>{% trans "No devices available." %}</p>
                    </div>
                {% endif %}
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col col-md-12">
            <div class="card">
                <h5 class="card-header">{% trans "Virtual Machines" %}</h5>
                {% if virtual_machine_ids %}
                    {% htmx_table 'virtualization:virtualmachine_list' id=virtual_machine_ids %}
                {% else %}
                    <div class="card-body">
                        <p>{% trans "No Virtual Machines available." %}</p>
                    </div>
                {% endif %}
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col col-md-12">{% plugin_full_width_page object %}</div>
    </div>
{% endblock content %}
