{% extends 'base.html' %}
{% load common_tags %}
{% load static %}
{% load i18n %}
{% block content %}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="panel-options">
                        <ul class="nav nav-tabs">
                            <li>
                                <a href="{% url 'assets:asset-detail' pk=asset.id %}" class="text-center"><i class="fa fa-laptop"></i> {% trans 'Asset detail' %}</a>
                            </li>
                            <li class="active">
                                <a href="{% url 'assets:asset-user-list' pk=asset.id %}" class="text-center"><i class="fa fa-bar-chart-o"></i> {% trans 'Asset user list' %}</a>
                            </li>
                        </ul>
                    </div>
                    <div class="tab-content">
                        <div class="col-sm-8" style="padding-left: 0;">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <span style="float: left">{% trans 'Asset users of' %} <b>{{ asset.hostname }} </b></span>
                                    <div class="ibox-tools">
                                        <a class="collapse-link">
                                            <i class="fa fa-chevron-up"></i>
                                        </a>
                                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                            <i class="fa fa-wrench"></i>
                                        </a>
                                        <ul class="dropdown-menu dropdown-user">
                                        </ul>
                                        <a class="close-link">
                                            <i class="fa fa-times"></i>
                                        </a>
                                    </div>
                                </div>
                                <div class="ibox-content">
                                    {% include 'assets/_asset_user_list.html' %}
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-4" style="padding-left: 0;padding-right: 0">
                            <div class="panel panel-primary">
                                <div class="panel-heading">
                                    <i class="fa fa-info-circle"></i> {% trans 'Quick modify' %}
                                </div>
                                <div class="panel-body">
                                    <table class="table">
                                        <tbody>
                                        {% if asset.is_support_ansible %}
                                            <tr class="no-borders-tr">
                                                <td>{% trans 'Test connective' %}:</td>
                                                <td>
                                                    <span class="pull-right">
                                                        <button type="button" class="btn btn-primary btn-xs" id="btn-bulk-test-connective" style="width: 54px">{% trans 'Test' %}</button>
                                                    </span>
                                                </td>
                                            </tr>
                                        {% endif %}
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block custom_foot_js %}
<script>
$(document).ready(function () {
    assetUserListUrl = setUrlParam(assetUserListUrl, "asset_id", "{{ asset.id }}");
    initAssetUserTable()
})

.on('click', '#btn-bulk-test-connective', function () {
    var the_url = "{% url 'api-assets:asset-user-connective' %}" + "?asset_id={{ asset.id }}";
    var success = function (data) {
        var task_id = data.task;
        showCeleryTaskLog(task_id);
    };
    requestApi({
        url: the_url,
        method: 'GET',
        success: success,
        flash_message: false
    });
})
</script>
{% endblock %}
