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

{% block header %}
    <div class="row noprint">
        <div class="col-sm-8 col-md-9">
            <ol class="breadcrumb">
                <li><a href="{% url 'extras:configcontext_list' %}">Config Contexts</a></li>
                <li>{{ configcontext }}</li>
            </ol>
        </div>
        <div class="col-sm-4 col-md-3">
            <form action="{% url 'extras:configcontext_list' %}" method="get">
                <div class="input-group">
                    <input type="text" name="q" class="form-control" />
                    <span class="input-group-btn">
                        <button type="submit" class="btn btn-primary">
                            <span class="fa fa-search" aria-hidden="true"></span>
                        </button>
                    </span>
                </div>
            </form>
        </div>
    </div>
    <div class="pull-right noprint">
        {% if perms.extras.change_configcontext %}
            <a href="{% url 'extras:configcontext_edit' pk=configcontext.pk %}" class="btn btn-warning">
                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                Edit this config context
            </a>
        {% endif %}
    </div>
    <h1>{% block title %}{{ configcontext }}{% endblock %}</h1>
{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-md-5">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Config Context</strong>
                </div>
                <table class="table table-hover panel-body attr-table">
                    <tr>
                        <td>Name</td>
                        <td>
                            {{ configcontext.name }}
                        </td>
                    </tr>
                    <tr>
                        <td>Weight</td>
                        <td>
                            {{ configcontext.weight }}
                        </td>
                    </tr>
                    <tr>
                        <td>Description</td>
                        <td>{{ configcontext.description|placeholder }}</td>
                    </tr>
                    <tr>
                        <td>Active</td>
                        <td>
                            {% if configcontext.is_active %}
                                <span class="text-success">
                                    <i class="fa fa-check"></i>
                                </span>
                            {% else %}
                                <span class="text-danger">
                                    <i class="fa fa-close"></i>
                                </span>
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Assignment</strong>
                </div>
                <table class="table table-hover panel-body attr-table">
                    <tr>
                        <td>Regions</td>
                        <td>
                            {% if configcontext.regions.all %}
                                <ul>
                                    {% for region in configcontext.regions.all %}
                                        <li><a href="{{ region.get_absolute_url }}">{{ region }}</a></li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Sites</td>
                        <td>
                            {% if configcontext.sites.all %}
                                <ul>
                                    {% for site in configcontext.sites.all %}
                                        <li><a href="{{ site.get_absolute_url }}">{{ site }}</a></li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Roles</td>
                        <td>
                            {% if configcontext.roles.all %}
                                <ul>
                                    {% for role in configcontext.roles.all %}
                                        <li><a href="{% url 'dcim:device_list' %}?role={{ role.slug }}">{{ role }}</a></li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Platforms</td>
                        <td>
                            {% if configcontext.platforms.all %}
                                <ul>
                                    {% for platform in configcontext.platforms.all %}
                                        <li><a href="{{ platform.get_absolute_url }}">{{ platform }}</a></li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Cluster Groups</td>
                        <td>
                            {% if configcontext.cluster_groups.all %}
                                <ul>
                                    {% for cluster_group in configcontext.cluster_groups.all %}
                                        <li><a href="{{ cluster_group.get_absolute_url }}">{{ cluster_group }}</a></li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Clusters</td>
                        <td>
                            {% if configcontext.clusters.all %}
                                <ul>
                                    {% for cluster in configcontext.clusters.all %}
                                        <li><a href="{{ cluster.get_absolute_url }}">{{ cluster }}</a></li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Tenant Groups</td>
                        <td>
                            {% if configcontext.tenant_groups.all %}
                                <ul>
                                    {% for tenant_group in configcontext.tenant_groups.all %}
                                        <li><a href="{{ tenant_group.get_absolute_url }}">{{ tenant_group }}</a></li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Tenants</td>
                        <td>
                            {% if configcontext.tenants.all %}
                                <ul>
                                    {% for tenant in configcontext.tenants.all %}
                                        <li><a href="{{ tenant.get_absolute_url }}">{{ tenant }}</a></li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Tags</td>
                        <td>
                            {% if configcontext.tags.all %}
                                <ul>
                                    {% for tag in configcontext.tags.all %}
                                        <li><a href="{{ tag.get_absolute_url }}">{{ tag }}</a></li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="col-md-7">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Data</strong>
                    {% include 'extras/inc/configcontext_format.html' %}
                </div>
                <div class="panel-body">
                    {% include 'extras/inc/configcontext_data.html' with data=configcontext.data format=format %}
                </div>
            </div>
        </div>
    </div>
{% endblock %}
