{% extends "dash/base.html" %}

{% load static i18n dash_tags %}

{% block site-title %}{{ dashboard_settings.title }}{% endblock site-title %}

{% block stylesheets %}
<link href="{% static 'jquery-ui/css/smoothness/jquery-ui-1.10.3.custom.min.css' %}" rel="stylesheet" media="all" />
{#<link href="{% static 'colorbox/colorbox.css' %}" rel="stylesheet" type="text/css">#}
<link href="{% static 'css/dash_core.css' %}" rel="stylesheet" media="all" />
{% if css %}
<style type="text/css">
    {{ css|safe }}
</style>
{% endif %}
{% endblock stylesheets %}

{% block layout-stylesheets %}
{% for css_file in layout.get_media_css %}
<link href="{% static css_file %}" rel="stylesheet" media="all" />
{% endfor %}
{% endblock layout-stylesheets %}

{% block layout-javascripts %}
{% for js_file in layout.get_media_js %}
<script src="{% static js_file %}"></script>
{% endfor %}
{% endblock layout-javascripts %}

{% block content-before %}
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a href="/" class="navbar-brand">{{ dashboard_settings.title }}</a>
    </div>

      <div id="navbar" class="navbar-collapse collapse">
        <p class="navbar-text pull-right">
          {% blocktrans with request.user.get_full_name|default:request.user.username as user_full_name %}
          Logged in as <a class="navbar-link" href="#">{{ user_full_name }}</a>
          {% endblocktrans %}
        </p>
        <ul class="nav navbar-nav">
            <li class="menu-item">
                <a href="/" class="menu-dashboard-home" title="{% trans 'Home' %}">
                    {% trans 'Home' %}
                </a>
            </li>
            {% has_edit_dashboard_permissions as has_edit_dashboard_permissions %}
            {% if has_edit_dashboard_permissions %}
            <li class="menu-item{% if edit_mode %} active{% endif %}">
                <a href="{% if current_workspace %}{% url 'dash.edit_dashboard' current_workspace.slug %}{% else %}{% url 'dash.edit_dashboard' %}{% endif %}" class="menu-dashboard-edit" title="{% trans 'Edit dashboard' %}">
                    {% trans 'Edit dashboard' %}
                </a>
            </li>
            {% endif %}
            <li class="menu-item{% if not edit_mode %} active{% endif %}">
                <a href="{% if current_workspace %}{% url 'dash.dashboard' current_workspace.slug %}{% else %}{% url 'dash.dashboard' %}{% endif %}" class="menu-dashboard-home" title="{% trans 'View Dashboard' %}">
                    {% trans 'View dashboard' %}
                </a>
            </li>
        </ul>
      </div>
  </div>
</nav>

<div class="container-fluid">
    <div class="row">

{% endblock content-before %}

{% block workspaces-wrapper %}
{% endblock workspaces-wrapper %}

{% block top-nav-menu-wrapper %}
{% endblock top-nav-menu-wrapper %}

{% block messages-wrapper %}{% endblock messages-wrapper %}

{% block content %}
    {% block bootstrap2_sidebar_wrapper %}

        <div class="{#col-xs-2#}col-sm-2 col-md-2 col-lg-2 sidebar">
            {% block bootstrap2_sidebar_nav_wrapper %}
            <ul class="nav nav-sidebar">
                {% block bootstrap2_workspaces %}
                {% if workspaces %}
                <li class="nav-header">{% trans "Workspaces" %}</li>
                <li class="{% if not current_workspace %} active{% endif %}">
                    <a href="{% if edit_mode %}{% url 'dash.edit_dashboard' %}{% else %}{% url 'dash.dashboard' %}{% endif %}" title="{% trans 'Default' %}">
                        {% trans 'Default' %}
                    </a>
                </li>
                {% for ws in workspaces %}
                <li class="{% if ws == current_workspace %} active{% endif %}">
                    <a href="{% if edit_mode %}{% url 'dash.edit_dashboard' ws.slug %}{% else %}{% url 'dash.dashboard' ws.slug %}{% endif %}" title="{{ ws.name }}">
                        {{ ws.name }}
                    </a>
                </li>
                {% endfor %}
                {% endif %}
                {% endblock bootstrap2_workspaces %}

                {% block bootstrap2_settings %}
                <li class="nav-header">{% trans "Settings" %}</li>
                {% if 'dash.add_dashboardworkspace' in perms %}
                <li class="sub-menu-item">
                    <a href="{% url 'dash.create_dashboard_workspace' %}" class="menu-dashboard-create-workspace" title="{% trans 'Create a workspace' %}" data-toggle="modal" data-target="#dashBootstrap3Modal">
                        <span class="iconic glyphicon glyphicon-plus" aria-hidden="true"></span>
                        <span class="textonic">{% trans "Create a workspace" %}</span>
                    </a>
                </li>
                {% endif %}

                {% if 'dash.change_dashboardsettings' in perms %}
                <li class="sub-menu-item">
                    <a href="{% url 'dash.edit_dashboard_settings' %}" class="menu-dashboard-edit-settings" title="{% trans 'Dashboard settings' %}" data-toggle="modal" data-target="#dashBootstrap3Modal">
                        <span class="iconic glyphicon glyphicon-cog" aria-hidden="true"></span>
                        <span class="textonic">{% trans "Dashboard settings" %}</span>
                    </a>
                </li>
                {% endif %}

                {% if current_workspace %}
                    {% if 'dash.change_dashboardworkspace' in perms %}
                <li class="sub-menu-item">
                    <a href="{% url 'dash.edit_dashboard_workspace' current_workspace.pk %}" class="menu-dashboard-edit-workspace" title="{% trans 'Edit current workspace' %}" data-toggle="modal" data-target="#dashBootstrap3Modal">
                        <span class="iconic glyphicon glyphicon-edit" aria-hidden="true"></span>
                        <span class="textonic">{% trans "Edit current workspace" %}</span>
                    </a>
                </li>
                    {% endif %}

                    {% if 'dash.add_dashboardworkspace' in perms and 'dash.add_dashboardentry' in perms %}
                <li class="sub-menu-item">
                    <a href="{% url 'dash.clone_dashboard_workspace' current_workspace.pk %}" class="menu-dashboard-clone-workspace" title="{% trans 'Clone current workspace' %}" data-toggle="modal" data-target="#dashBootstrap3Modal">
                        <span class="iconic glyphicon glyphicon-duplicate" aria-hidden="true"></span>
                        <span class="textonic">{% trans "Clone current workspace" %}</span>
                    </a>
                </li>
                    {% endif %}

                    {% if 'dash.delete_dashboardworkspace' in perms %}
                <li class="sub-menu-item">
                    <a href="{% url 'dash.delete_dashboard_workspace' current_workspace.pk %}" class="menu-dashboard-delete-workspace" title="{% trans 'Delete current workspace' %}" data-toggle="modal" data-target="#dashBootstrap3Modal">
                        <span class="iconic glyphicon glyphicon-trash" aria-hidden="true"></span>
                        <span class="textonic">{% trans "Delete current workspace" %}</span>
                    </a>
                </li>
                    {% endif %}
                {% endif %}

                {% block bootstrap2_public_dashboard_url %}
                {% if public_dashboard_url %}
                <li class="sub-menu-item">
                    <a href="{{ public_dashboard_url }}" class="menu-public-dashboard">
                        <span class="iconic glyphicon glyphicon-user" aria-hidden="true"></span>
                        <span class="textonic">{% trans "Public dashboard" %}</span>
                    </a>
                </li>
                {% endif %}
                {% endblock bootstrap2_public_dashboard_url %}

                {% block bootstrap2_auth_url %}
                {% if request.user and request.user.is_authenticated %}
                    <li class="sub-menu-item">
                        <a href="{% url 'django.contrib.auth.views.logout' %}" class="menu-public-dashboard">
                            <span class="iconic glyphicon glyphicon-log-out" aria-hidden="true"></span>
                            <span class="textonic">{% trans "Log out" %}</span>
                        </a>
                    </li>
                {% else %}
                    <li class="sub-menu-item">
                        <a href="{% url 'django.contrib.auth.views.login' %}" class="menu-public-dashboard">
                            <span class="iconic glyphicon glyphicon-log-in" aria-hidden="true"></span>
                            <span class="textonic">{% trans "Log in" %}</span>
                        </a>
                    </li>
                {% endif %}
                {% endblock bootstrap2_auth_url %}

                {% endblock bootstrap2_settings %}
            </ul>
            {% endblock bootstrap2_sidebar_nav_wrapper %}
        </div>

    {% endblock bootstrap2_sidebar_wrapper %}
{% endblock content %}

{% block content-after %}
    </div>
</div>

<!-- Modal -->
<div class="modal fade" id="dashBootstrap3Modal" tabindex="-1" role="dialog" aria-labelledby="dashBootstrap3ModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

{% endblock content-after %}

{% block javascripts %}
{#<script src="{% static 'colorbox/jquery.colorbox-min.js' %}"></script>#}
{#<script src="{% static 'js/dash.js' %}"></script>#}
{% endblock javascripts %}