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

{% block custom_head_css_js %}
    <link href="{% static "css/plugins/select2/select2.min.css" %}" rel="stylesheet">
    <script src="{% static "js/plugins/select2/select2.full.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="{% url 'assets:system-user-detail' pk=system_user.id %}" class="text-center"><i class="fa fa-laptop"></i> {% trans 'Detail' %} </a>
                            </li>
                            <li>
                                <a href="{% url 'assets:system-user-asset' pk=system_user.id %}" class="text-center">
                                <i class="fa fa-bar-chart-o"></i> {% trans 'Attached assets' %}
                                </a>
                            </li>
                            <li class="pull-right">
                                <a class="btn btn-outline btn-default" href="{% url 'assets:system-user-update' pk=system_user.id %}"><i class="fa fa-edit"></i>Update</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>{{ system_user.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>{% trans 'Name' %}:</td>
                                            <td><b>{{ system_user.name }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Username' %}:</td>
                                            <td><b>{{ system_user.username }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Protocol' %}:</td>
                                            <td><b>{{ system_user.protocol }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Auto push' %}:</td>
                                            <td><b>{{ system_user.auto_push|yesno:"Yes,No,Unknown" }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Sudo' %}:</td>
                                            <td><b>{{ system_user.sudo }}</b></td>
                                        </tr>
                                        {% if system_user.shell %}
                                        <tr>
                                            <td>{% trans 'Shell' %}:</td>
                                            <td><b>{{ system_user.shell }}</b></td>
                                        </tr>
                                        {% endif %}
                                        {% if system_user.home %}
                                        <tr>
                                            <td>{% trans 'Home' %}:</td>
                                            <td><b>{{ system_user.home }}</b></td>
                                        </tr>
                                        {% endif %}
                                        {% if system_user.uid %}
                                            <tr>
                                                <td>{% trans 'Uid' %}:</td>
                                                <td><b>{{ system_user.uid }}</b></td>
                                            </tr>
                                        {% endif %}
                                        <tr>
                                            <td>{% trans 'Date created' %}:</td>
                                            <td><b>{{ system_user.date_created }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Created by' %}:</td>
                                            <td><b>{{ asset_group.created_by  }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Comment' %}:</td>
                                            <td><b>{{ system_user.comment }}</b></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>

                        <div class="col-sm-5" 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 update' %}
                                </div>
                                <div class="panel-body">
                                    <table class="table">
                                        <tbody>
                                        <tr class="no-borders-tr">
                                            <td width="50%">{% trans 'Get manual install script' %}:</td>
                                            <td>
                                                <span style="float: right">
                                                    <button type="button" class="btn btn-primary btn-xs" style="width: 54px">{% trans 'Get' %}</button>
                                                </span>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td width="50%">{% trans 'Retest asset connectivity' %}:</td>
                                            <td>
                                                <span style="float: right">
                                                    <button type="button" class="btn btn-primary btn-xs" style="width: 54px">{% trans 'Start' %}</button>
                                                </span>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td width="50%">{% trans 'Reset private key' %}:</td>
                                            <td>
                                                <span style="float: right">
                                                    <button type="button" class="btn btn-primary btn-xs" style="width: 54px">{% trans 'Reset' %}</button>
                                                </span>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>

{% endblock %}
{% block custom_foot_js %}
    <script>
{#        function switch_user_status(obj) {#}
{#            var status = $(obj).prop('checked');#}
{##}
{#            $.ajax({#}
{#                url: "{% url 'users:user-active-api' pk=user.id %}",#}
{#                type: "PUT",#}
{#                data: {#}
{#                    'is_active': status#}
{#                },#}
{#                success: function (data, status) {#}
{#                    console.log(data)#}
{#                },#}
{#                error: function () {#}
{#                    console.log('error')#}
{#                }#}
{#            })#}
{#        }#}
        $(document).ready(function () {
            $('.select2').select2();
        });
    </script>
{% endblock %}
