{#
  OTS Signage Theme override
  Based on Xibo CMS default authed-sidebar.twig (master branch)
  Applied OTS sidebar styling
#}
<div id="sidebar-wrapper" class="ots-sidebar" role="navigation" aria-label="{% trans "Main navigation" %}">
    <div class="sidebar-header">
        <a class="brand-link" href="{{ url_for("home") }}">
            <span class="brand-icon">
                <img class="brand-logo" src="{{ theme.uri("img/xibologo.png") }}" alt="{% trans "Logo" %}">
            </span>
            <span class="brand-text">OTS Signs</span>
        </a>
        <button class="sidebar-expand-btn" type="button" aria-label="{% trans "Expand sidebar" %}">
            <i class="fa fa-chevron-right" aria-hidden="true"></i>
        </button>
        <button class="sidebar-collapse-btn sidebar-collapse-btn-visible" type="button" aria-label="{% trans "Collapse sidebar" %}">
            <i class="fa fa-chevron-left" aria-hidden="true"></i>
        </button>
    </div>

    <div class="sidebar-content">
        <ul class="sidebar ots-sidebar-nav">
        <li class="sidebar-list">
            <a href="{{ url_for("home") }}" data-tooltip="Dashboard">
                <span class="ots-nav-icon fa fa-home" aria-hidden="true"></span>
                <span class="ots-nav-text">{% trans "Dashboard" %}</span>
            </a>
        </li>

        {% set scheduleCount = currentUser.featureEnabledCount(["schedule.view", "daypart.view"]) %}
        {% if scheduleCount > 0 %}
            <li class="sidebar-group">
                <a class="sidebar-group-toggle" href="#" aria-expanded="false" aria-controls="submenu-scheduling" data-group="scheduling">
                    <span class="ots-nav-icon fa fa-calendar" aria-hidden="true"></span>
                    <span class="ots-nav-text">{% trans "Scheduling" %}</span>
                    <span class="sidebar-group-caret fa fa-chevron-down" aria-hidden="true"></span>
                </a>
                <ul class="sidebar-submenu" id="submenu-scheduling">
                    {% if currentUser.featureEnabled("daypart.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("daypart.view") }}">
                                <span class="ots-nav-icon fa fa-clock-o" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Dayparts" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("schedule.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("schedule.view") }}">
                                <span class="ots-nav-icon fa fa-calendar-check-o" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Schedules" %}</span>
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </li>
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["library.view", "playlist.view", "dataset.view", "menuBoard.view"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-group">
                <a class="sidebar-group-toggle" href="#" aria-expanded="false" aria-controls="submenu-media" data-group="media">
                    <span class="ots-nav-icon fa fa-picture-o" aria-hidden="true"></span>
                    <span class="ots-nav-text">{% trans "Media" %}</span>
                    <span class="sidebar-group-caret fa fa-chevron-down" aria-hidden="true"></span>
                </a>
                <ul class="sidebar-submenu" id="submenu-media">
                    {% if currentUser.featureEnabled("library.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("library.view") }}">
                                <span class="ots-nav-icon fa fa-image" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Library" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("playlist.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("playlist.view") }}">
                                <span class="ots-nav-icon fa fa-list" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Playlists" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("dataset.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("dataset.view") }}">
                                <span class="ots-nav-icon fa fa-database" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "DataSets" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("menuBoard.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("menuBoard.view") }}">
                                <span class="ots-nav-icon fa fa-cutlery" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Menu Boards" %}</span>
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </li>
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["campaign.view", "layout.view", "template.view", "resolution.view"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-group">
                <a class="sidebar-group-toggle" href="#" aria-expanded="false" aria-controls="submenu-design" data-group="design">
                    <span class="ots-nav-icon fa fa-paint-brush" aria-hidden="true"></span>
                    <span class="ots-nav-text">{% trans "Design" %}</span>
                    <span class="sidebar-group-caret fa fa-chevron-down" aria-hidden="true"></span>
                </a>
                <ul class="sidebar-submenu" id="submenu-design">
                    {% if currentUser.featureEnabled("campaign.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("campaign.view") }}">
                                <span class="ots-nav-icon fa fa-bullhorn" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Campaigns" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("layout.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("layout.view") }}">
                                <span class="ots-nav-icon fa fa-columns" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Layouts" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("template.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("template.view") }}">
                                <span class="ots-nav-icon fa fa-clone" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Templates" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("resolution.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("resolution.view") }}">
                                <span class="ots-nav-icon fa fa-expand" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Resolutions" %}</span>
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </li>
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["displays.view", "displaygroup.view", "displayprofile.view", "playersoftware.view", "command.view", "display.syncView"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-group">
                <a class="sidebar-group-toggle" href="#" aria-expanded="false" aria-controls="submenu-displays" data-group="displays">
                    <span class="ots-nav-icon fa fa-desktop" aria-hidden="true"></span>
                    <span class="ots-nav-text">{% trans "Displays" %}</span>
                    <span class="sidebar-group-caret fa fa-chevron-down" aria-hidden="true"></span>
                </a>
                <ul class="sidebar-submenu" id="submenu-displays">
                    {% if currentUser.featureEnabled("displays.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("display.view") }}">
                                <span class="ots-nav-icon fa fa-desktop" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "All Displays" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("displaygroup.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("displaygroup.view") }}">
                                <span class="ots-nav-icon fa fa-object-group" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Screen Groups" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("display.syncView") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("syncgroup.view") }}">
                                <span class="ots-nav-icon fa fa-link" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Sync Groups" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("displayprofile.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("displayprofile.view") }}">
                                <span class="ots-nav-icon fa fa-cog" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Display Settings" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("playersoftware.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("playersoftware.view") }}">
                                <span class="ots-nav-icon fa fa-download" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Player Versions" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("command.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("command.view") }}">
                                <span class="ots-nav-icon fa fa-terminal" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Commands" %}</span>
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </li>
        {% endif %}

        {% if currentUser.featureEnabled("users.view") and (currentUser.isGroupAdmin() or currentUser.isSuperAdmin()) %}
            {% set userMenuViewable = true %}
        {% else %}
            {% set userMenuViewable = false %}
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["usergroup.view", "module.view", "transition.view", "task.view", "tag.view", "font.view"]) %}
        {% if countViewable > 0 or userMenuViewable %}
            <li class="sidebar-group">
                <a class="sidebar-group-toggle" href="#" aria-expanded="false" aria-controls="submenu-settings" data-group="settings">
                    <span class="ots-nav-icon fa fa-cog" aria-hidden="true"></span>
                    <span class="ots-nav-text">{% trans "Settings" %}</span>
                    <span class="sidebar-group-caret fa fa-chevron-down" aria-hidden="true"></span>
                </a>
                <ul class="sidebar-submenu" id="submenu-settings">
                    {% if userMenuViewable %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("user.view") }}">
                                <span class="ots-nav-icon fa fa-user" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Users" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("usergroup.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("group.view") }}">
                                <span class="ots-nav-icon fa fa-users" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "User Groups" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.isSuperAdmin() %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("admin.view") }}">
                                <span class="ots-nav-icon fa fa-sliders" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Settings" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.isSuperAdmin() %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("application.view") }}">
                                <span class="ots-nav-icon fa fa-puzzle-piece" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Applications" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("module.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("module.view") }}">
                                <span class="ots-nav-icon fa fa-cubes" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Modules" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("transition.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("transition.view") }}">
                                <span class="ots-nav-icon fa fa-random" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Transitions" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("task.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("task.view") }}">
                                <span class="ots-nav-icon fa fa-tasks" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Tasks" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("tag.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("tag.view") }}">
                                <span class="ots-nav-icon fa fa-tags" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Tags" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.isSuperAdmin() %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("folders.view") }}">
                                <span class="ots-nav-icon fa fa-folder-open" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Folders" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("font.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("font.view") }}">
                                <span class="ots-nav-icon fa fa-font" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Fonts" %}</span>
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </li>
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["report.view", "report.scheduling", "report.saving"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-group">
                <a class="sidebar-group-toggle" href="#" aria-expanded="false" data-group="reporting">
                    <span class="ots-nav-icon fa fa-bar-chart" aria-hidden="true"></span>
                    <span class="ots-nav-text">{% trans "Reporting" %}</span>
                    <span class="sidebar-group-caret fa fa-chevron-down" aria-hidden="true"></span>
                </a>
                <ul class="sidebar-submenu">
                    {% if currentUser.featureEnabled("report.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("report.view") }}">
                                <span class="ots-nav-icon fa fa-file-text-o" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "All Reports" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("report.scheduling") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("reportschedule.view") }}">
                                <span class="ots-nav-icon fa fa-calendar" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Report Schedules" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("report.saving") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("savedreport.view") }}">
                                <span class="ots-nav-icon fa fa-floppy-o" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Saved Reports" %}</span>
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </li>
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["log.view", "sessions.view", "auditlog.view", "fault.view"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-group">
                <a class="sidebar-group-toggle" href="#" aria-expanded="false" data-group="advanced">
                    <span class="ots-nav-icon fa fa-shield" aria-hidden="true"></span>
                    <span class="ots-nav-text">{% trans "Advanced" %}</span>
                    <span class="sidebar-group-caret fa fa-chevron-down" aria-hidden="true"></span>
                </a>
                <ul class="sidebar-submenu">
                    {% if currentUser.featureEnabled("log.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("log.view") }}">
                                <span class="ots-nav-icon fa fa-list-alt" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Log" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("sessions.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("sessions.view") }}">
                                <span class="ots-nav-icon fa fa-user-secret" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Sessions" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("auditlog.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("auditlog.view") }}">
                                <span class="ots-nav-icon fa fa-clipboard" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Audit Trail" %}</span>
                            </a>
                        </li>
                    {% endif %}

                    {% if currentUser.featureEnabled("fault.view") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("fault.view") }}">
                                <span class="ots-nav-icon fa fa-exclamation-triangle" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Report Fault" %}</span>
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </li>
        {% endif %}

        {% set countViewable = currentUser.featureEnabledCount(["developer.edit"]) %}
        {% if countViewable > 0 %}
            <li class="sidebar-group">
                <a class="sidebar-group-toggle" href="#" aria-expanded="false" data-group="developer">
                    <span class="ots-nav-icon fa fa-code" aria-hidden="true"></span>
                    <span class="ots-nav-text">{% trans "Developer" %}</span>
                    <span class="sidebar-group-caret fa fa-chevron-down" aria-hidden="true"></span>
                </a>
                <ul class="sidebar-submenu">
                    {% if currentUser.featureEnabled("developer.edit") %}
                        <li class="sidebar-list">
                            <a href="{{ url_for("developer.templates.view") }}">
                                <span class="ots-nav-icon fa fa-code" aria-hidden="true"></span>
                                <span class="ots-nav-text">{% trans "Module Templates" %}</span>
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </li>
        {% endif %}
        </ul>
    </div>

</div>
