{% extends 'base.html' %}
{% load static %}
{% load i18n %}

{% block custom_head_css_js %}
    <link href="{% static "css/plugins/select2/select2.min.css" %}" rel="stylesheet">
    <link href="{% static "css/plugins/sweetalert/sweetalert.css" %}" rel="stylesheet">
    <script src="{% static "js/plugins/select2/select2.full.min.js" %}"></script>
    <script src="{% static "js/plugins/sweetalert/sweetalert.min.js" %}"></script>
{% endblock %}
{% 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 class="active">
                                <a href="" class="text-center"><i class="fa fa-laptop"></i> {% trans 'Task record detail' %} </a>
                            </li>
                        </ul>
                    </div>
                    <div class="tab-content">
                        <div class="col-sm-7" style="padding-left: 0">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <span class="label"><b>{{ object.name }}</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">
                                    <table class="table">
                                        <tbody>
                                        <tr class="no-borders-tr">
                                            <td width="20%">{% trans 'UUID' %}:</td>
                                            <td><b>{{ object.uuid }}</b></td>
                                        </tr>
                                        <tr>
                                            <td width="20%">{% trans 'Name' %}:</td>
                                            <td><b>{{ object.name }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Date start' %}:</td>
                                            <td><b>{{ object.date_start }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Date finished' %}:</td>
                                            <td><b>{{ object.date_finished }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Time delta' %}:</td>
                                            <td><b>{{ object.timedelta}} s</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Is finished' %}:</td>
                                            <td><b>{{ object.is_finished|yesno:"Yes,No,Unkown" }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Is success ' %}:</td>
                                            {% if object.is_finished %}
                                            <td><b>{{ object.is_success|yesno:"Yes,No,Unkown" }}</b></td>
                                            {% else %}
                                            <td>
                                                <div class="progress progress-striped active">
                                                    <div style="width: 50%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="75" role="progressbar" class="progress-bar progress-bar-danger">
                                                        <span class="sr-only">40% Complete (success)</span>
                                                    </div>
                                                </div>
                                            </td>
                                            {% endif %}
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Assets ' %}:</td>
                                            <td>
                                            <b>
                                            {% for asset in object.total_assets %}
                                            {{ asset }} <br/>
                                            {% endfor %}
                                            </b>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>

                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <span><b>Result</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">
                                    <pre>
{{ object.result }}
                                    </pre>
                                </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-5" style="padding-left: 0;padding-right: 0">
                            <div class="panel panel-danger">
                                <div class="panel-heading">
                                    <i class="fa fa-info-circle"></i> {% trans 'Failed assets' %}
                                </div>
                                <div class="panel-body">
                                    <table class="table">
                                        <tbody>
                                        {% for host, msg in results.failed %}
                                        {% if forloop.first %}
                                        <tr class="no-borders-tr">
                                        {% else %}
                                        <tr>
                                            {% endif %}
                                            <td>{{ host }}: </td>
                                            <td>{{ msg }}</td>
                                        </tr>
                                        {% empty %}
                                            <tr class="no-borders-tr">
                                                <td>{% trans 'No assets' %}</td>
                                            </tr>
                                        {% endfor %}
                                        </tbody>
                                    </table>
                                </div>
                            </div>

                            <div class="panel panel-primary">
                                <div class="panel-heading">
                                    <i class="fa fa-info-circle"></i> {% trans 'Success assets' %}
                                </div>
                                <div class="panel-body">
                                    <table class="table">
                                        <tbody>
                                        {% for host in results.success %}
                                        {% if forloop.first %}
                                        <tr class="no-borders-tr">
                                        {% else %}
                                        <tr>
                                        {% endif %}
                                            <td>{{ host }}</td>
                                        </tr>
                                        {% empty %}
                                        <tr class="no-borders-tr">
                                            <td>{% trans 'No assets' %}</td>
                                        </tr>
                                        {% endfor %}
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {% include 'users/_user_update_pk_modal.html' %}
{% endblock %}

