{% 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:cluster-detail' pk=cluster.id %}" class="text-center"><i class="fa fa-laptop"></i> {% trans 'Detail' %} </a>
                            </li>
                            <li>
                                <a href="{% url 'assets:cluster-assets' pk=cluster.id %}" class="text-center">
                                <i class="fa fa-bar-chart-o"></i> {% trans 'Cluster assets' %}
                                </a>
                            </li>
                            <li class="pull-right">
                                <a class="btn btn-outline btn-default" href="{% url 'assets:cluster-update' pk=cluster.id %}"><i class="fa fa-edit"></i>Update</a>
                            </li>
                            <li class="pull-right">
                                <a class="btn btn-outline btn-danger btn-delete-cluster">
                                    <i class="fa fa-edit"></i>Delete
                                </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 class="label"><b>{{ cluster.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 'Name' %}:</td>
                                            <td><b>{{ cluster.name }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Bandwidth' %}:</td>
                                            <td><b>{{ cluster.bandwidth }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Contact' %}:</td>
                                            <td><b>{{ cluster.contact }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Phone' %}:</td>
                                            <td><b>{{ cluster.phone }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Address' %}:</td>
                                            <td><b>{{ cluster.address }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Intranet' %}:</td>
                                            <td><b>{{ cluster.Intranet }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Extranet' %}:</td>
                                            <td><b>{{ cluster.extranet }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Operator' %}:</td>
                                            <td><b>{{ cluster.operator }}</b></td>
                                        </tr>
                                        <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-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 'Update admin user' %}#}
{#                                </div>#}
{#                                <div class="panel-body">#}
{#                                    <table class="table cluster_edit" id="add-asset2group">#}
{#                                        <tbody>#}
{#                                        <form>#}
{#                                            <tr>#}
{#                                                <td colspan="2" class="no-borders">#}
{#                                                    <select data-placeholder="{% trans 'Select admin user' %}" id="cluster_selected" class="select2" style="width: 100%"  tabindex="4">#}
{#                                                        {% for admin_user in admin_user_list %}#}
{#                                                        <option value="{{ admin_user.id }}" id="opt_{{ admin_user.id }}" {% if admin_user.id == cluster.admin_user.id %} selected {% endif %} >{{ admin_user.name }}</option>#}
{#                                                        {% endfor %}#}
{#                                                    </select>#}
{#                                                </td>#}
{#                                            </tr>#}
{#                                            <tr>#}
{#                                                <td colspan="2" class="no-borders">#}
{#                                                    <button type="button" class="btn btn-primary btn-sm" id="btn-add-to-cluster">{% trans 'Confirm' %}</button>#}
{#                                                </td>#}
{#                                            </tr>#}
{#                                        </form>#}
{##}
{#                                        {% for cluster in system_user.cluster.all %}#}
{#                                        <tr>#}
{#                                          <td ><b class="bdg_cluster" data-gid={{ cluster.id }}>{{ cluster.name }}</b></td>#}
{#                                          <td>#}
{#                                              <button class="btn btn-danger pull-right btn-xs btn-remove-from-cluster" type="button"><i class="fa fa-minus"></i></button>#}
{#                                          </td>#}
{#                                        </tr>#}
{#                                        {% endfor %}#}
{#                                        </tbody>#}
{#                                    </table>#}
{#                                </div>#}
{#                            </div>#}
{#                        </div>#}
                    </div>
                </div>
            </div>
        </div>
    </div>

{% endblock %}
{% block custom_foot_js %}
<script>

$(document).ready(function () {
	$('.select2').select2();
})
.on('click', '.btn-delete-cluster', function () {
	var name = "{{ cluster.name }}";
	var id = "{{ cluster.id }}";
	var the_url = '{% url "api-assets:cluster-detail" pk=DEFAULT_PK %}'.replace("{{ DEFAULT_PK }}", id);
	var redirect_url = "{% url 'assets:cluster-list' %}";
	objectDelete(this, name, the_url, redirect_url);
});
</script>
{% endblock %}
