{% extends 'base.html' %}
{% load mytags %}

{% block content %}
    {% include 'nav_cat_bar.html' %}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-4">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>授权主机/组</h5>
                        <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">
                                <li><a href="#">Config option 1</a>
                                </li>
                                <li><a href="#">Config option 2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content ibox-heading">
                        <h3>用户</h3>
                        <small><i class="fa fa-map-marker"></i> 组下用户.</small>
                    </div>
                    <div class="ibox-content inspinia-timeline">
                        <div class="timeline-item">
                            <div class="row">
                                <div class="col-xs-3 date">
                                    <i class="fa fa-users"></i>
                                    <b>{{ user_group.name }}</b>
                                    <br>
                                    <small class="text-navy">共: {{ group_user_num }} 用户</small>
                                </div>
                                <div class="col-xs-7 content no-top-border">
                                    <p class="m-b-xs"><strong>{{ user_group.comment }}</strong></p>
                                    <p>
                                        {% for user in users %}
                                            {{ user.name }}<br>
                                        {% endfor %}
                                    </p>
                                    <p></p>
                                </div>
                            </div>
                        </div>
                        {% if not users %}
                            (暂无)
                        {% endif %}
                    </div>
                </div>
            </div>

            <div class="col-lg-4">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>授权主机/组</h5>
                        <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">
                                <li><a href="#">Config option 1</a>
                                </li>
                                <li><a href="#">Config option 2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content ibox-heading">
                        <h3>授权主机/组</h3>
                        <small><i class="fa fa-map-marker"></i> 这里包含了sudo授权所有的主机组和组下的主机.</small>
                    </div>
                    <div class="ibox-content inspinia-timeline">
                        {% for group in asset_groups %}
                            <div class="timeline-item">
                                <div class="row">
                                    <div class="col-xs-3 date">
                                        <i class="fa fa-repeat"></i>
                                        <b>{{ group.name }}</b>
                                        <br>
                                        <small class="text-navy">共: {{ group | group_asset_list_count }}台</small>
                                    </div>
                                    <div class="col-xs-7 content no-top-border">
                                        <p class="m-b-xs"><strong>{{ group.comment }}</strong></p>
                                        <p>
                                            {% for asset in group|group_asset_list %}
                                                {{ asset.ip }}<br>
                                            {% endfor %}
                                        </p>
                                        <p></p>
                                    </div>
                                </div>
                            </div>
                        {% endfor %}
                        {% if not asset_groups %}
                            (暂无)
                        {% endif %}
                    </div>
                </div>
            </div>

            <div class="col-lg-4">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>授权命令/组</h5>
                        <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">
                                <li><a href="#">Config option 1</a>
                                </li>
                                <li><a href="#">Config option 2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content inspinia-timeline">
                        {% for cmd_group in cmd_groups %}
                            <div class="timeline-item">
                                <div class="row">
                                    <div class="col-xs-3 date">
                                        <i class="fa fa-linux"></i>
                                        <b>{{ cmd_group.name }}</b>
                                        <br>
                                        <small class="text-navy">共: {{ cmd_group.id|sudo_cmd_count }} 个</small>
                                    </div>
                                    <div class="col-xs-7 content no-top-border">
                                        <p class="m-b-xs"><strong>{{ group.comment }}</strong></p>
                                        <p>
                                            {% for cmd in cmd_group|cmd_group_split %}
                                                {{ cmd }}<br>
                                            {% endfor %}
                                        </p>
                                        <p></p>
                                    </div>
                                </div>
                            </div>
                        {% endfor %}
                        {% if not cmd_groups %}
                            (暂无)
                        {% endif %}
                    </div>
                </div>
            </div>

        </div>
    </div>

{% endblock %}