{#
/**
 * Copyright (C) 2020-2024 Xibo Signage Ltd
 *
 * Xibo - Digital Signage - https://xibosignage.com
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */
#}
{% extends "base.twig" %}

{% block content %}
    {% set horizontalNav = currentUser.getOptionValue("navigationMenuPosition", theme.getSetting("NAVIGATION_MENU_POSITION", "vertical")) == "horizontal" %}

    {% if not hideNavigation %}
        {% set hideNavigation = currentUser.getOptionValue("hideNavigation", "0") %}
    {% endif %}

    <div {% if hideNavigation == "0" and not horizontalNav and not forceHide %}id="page-wrapper"{% endif %} class="active">

        {% if hideNavigation == "0" and not forceHide %}
            {% if horizontalNav %}
                <nav class="navbar navbar-default navbar-expand-lg">
                    <a class="navbar-brand xibo-logo-container" href="#">
                        <img class="xibo-logo" src="{{ theme.uri("img/xibologo.png") }}">
                    </a>

                    <!-- Brand and toggle get grouped for better mobile display -->
                    <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbar-collapse-1" aria-controls="navbarNav" aria-expanded="false">
                        <span class="fa fa-bars"></span>
                    </button>

                    <!-- Collect the nav links, forms, and other content for toggling -->
                    <div class="navbar-collapse collapse justify-content-between" id="navbar-collapse-1">
                        {% include "authed-topbar.twig" %}

                        <ul class="nav navbar-nav navbar-right">
                            {% include "authed-theme-topbar.twig" ignore missing %}
                            {% if currentUser.featureEnabled("drawer") %}
                                {% include "authed-notification-drawer.twig" %}
                            {% endif %}
                            {% include "authed-user-menu.twig" %}
                        </ul>
                    </div><!-- /.navbar-collapse -->
                </nav>
            {% else %}
                <div class="navbar-collapse navbar-collapse-side collapse" id="navbar-collapse-1">
                    {% include "authed-sidebar.twig" %}
                </div>
            {% endif %}
        {% endif %}

        <div id="content-wrapper">
            <div class="page-content">
                {% if not horizontalNav or hideNavigation == "1" or forceHide %}
                <div class="row header header-side">
                    <div class="col-sm-12">
                        <div class="meta pull-left xibo-logo-container">
                            <div class="page"><img class="xibo-logo" src="{{ theme.uri("img/xibologo.png") }}"></div>
                        </div>
                        {% if not forceHide %}
                            {% if not hideNavigation == "1" %}
                                <button type="button" class="pull-right navbar-toggler navbar-toggler-side" data-toggle="collapse" data-target="#navbar-collapse-1" aria-controls="navbarNav" aria-expanded="false">
                                    <span class="fa fa-bars"></span>
                                </button>
                            {% endif %}
                            <div class="user pull-right">
                                {% include "authed-user-menu.twig" %}
                            </div>
                            {% if currentUser.featureEnabled("drawer") %}
                            <div class="user user-notif pull-right">
                                {% include "authed-notification-drawer.twig" %}
                            </div>
                            {% endif %}
                            {% include "authed-theme-topbar.twig" ignore missing %}
                        {% endif %}
                    </div>
                </div>
                {% endif %}
                <div class="row">
                    <div class="col-sm-12">
                        {% block actionMenu %}{% endblock %}
                        {% block pageContent %}{% endblock %}
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        {% block pageFooter %}{% endblock %}
                    </div>
                </div>
            </div>
        </div>
    </div>

    {% set helpLinks = helpService.getLinksForPage(route) %}
    {% set isXiboThemed = theme.getThemeConfig("app_name") == "Xibo" %}
    {% if helpLinks|length > 0 %}
        {# Hide in mobile view (sm/<768px)  #}
        <div id="help-pane" class="d-none d-md-block help-pane">
            <div class="card help-pane-card border-dark" style="display: none;">
                <div class="card-header">{{ "Help"|trans }} <i class="close-icon fa fa-times"></i></div>
                <ul class="list-group list-group-flush">
                    {% for link in helpLinks %}
                        {% if link.isAllowWhiteLabel or isXiboThemed %}
                            <li class="list-group-item">
                                <a href="{{ link.url }}" target="_blank">{{ link.title }}</a>
                                {% if link.summary %}
                                    <br/>
                                    {{ link.summary|raw }}
                                {% endif %}
                            </li>
                        {% endif %}
                    {% endfor %}
                </ul>
                <div class="card-footer">
                    <a href="{{ helpService.getLandingPage() }}" target="_blank">{{ "Visit the user manual"|trans }}</a>
                </div>
            </div>
            <div class="help-pane-icon">
                <i class="fa fa-question-circle"></i>
            </div>
        </div>
    {% endif %}
{% endblock %}

{% block javaScriptTemplates %}
    {# File upload templates and scripts #}
    {% include "include-file-upload.twig" %}
{% endblock %}