{% 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 'applications:database-detail' pk=database.id %}" class="text-center"><i class="fa fa-laptop"></i> {% trans 'Detail' %} </a>
                            </li>
                            <li class="pull-right">
                                <a class="btn btn-outline btn-default" href="{% url 'applications:database-update' pk=database.id %}"><i class="fa fa-edit"></i>{% trans 'Update' %}</a>
                            </li>
                            <li class="pull-right">
                                <a class="btn btn-outline btn-danger btn-delete">
                                    <i class="fa fa-trash-o"></i>{% trans '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>{{ database.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>{{ database.name }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Login mode' %}:</td>
                                            <td><b>{{ database.get_login_mode_display }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Type' %}:</td>
                                            <td><b>{{ database.get_type_display }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Host' %}:</td>
                                            <td><b>{{ database.host }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'User' %}:</td>
                                            <td><b>{{ database.user }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Database' %}:</td>
                                            <td><b>{{ database.database }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Created by' %}:</td>
                                            <td><b>{{ database.created_by }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Date created' %}:</td>
                                            <td><b>{{ database.date_created }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Date updated' %}:</td>
                                            <td><b>{{ database.date_updated }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Comment' %}:</td>
                                            <td><b>{{ database.comment }}</b></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block custom_foot_js %}
<script>
$(document).ready(function () {
})
.on('click', '.btn-delete', function () {
    var $this = $(this);
    var name = "{{ database.name }}";
    var rid = "{{ database.id }}";
    var the_url = '{% url "api-applications:database-detail" pk=DEFAULT_PK %}'.replace('{{ DEFAULT_PK }}', rid);
    var redirect_url = "{% url 'applications:database-list' %}";
    objectDelete($this, name, the_url, redirect_url);
})
</script>
{% endblock %}
