{% extends "main/layout.html" %}
{% from 'global_macros.html' import input, button, select %}
{% from 'main/tcdrop.html' import tcdrop %}
{% from 'settings_system/user.html' import UserTab with context %}
{% from 'settings_system/files.html' import FilesTab with context %}
{% block page_vendor_css %}
{% endblock page_vendor_css %}

{% block page_lvl_css %}
    {{ process_css_sources(src="settings_system/settings.css")|safe }}
    {% if settings.background and settings.background != 'None' %}
        <style>
            #main {
                background-image: url("{{ settings.background }}");
                background-size: cover;
                background-attachment: fixed;
                min-height: 100vh;
            }
        </style>
    {% endif %}
{% endblock page_lvl_css %}

{% block content %}

    <div id="main" class="main-full">
        <div class="container">
            <div class="row">
                <div class="col s12 m12 l6">
                    <div class="card scrollbar settings-page-card">
                        <div class="card-content">
                                <div class="row">
                                    <div class="col s12">
                                        <h5>Config.ini</h5>
                                        {{ button(
                                        icon="save",
                                        id="save-config-btn",
                                        float="left",
                                        class="ml-0 mt-1 mb-1",
                                        data={'url': url_for('settings_system.save_config')},
                                        text="save"
                                        ) }}
                                    </div>

                                    <div class="divider"></div>
                                    <form id="config-form">
                                        {{ input(
                                        size="s12",
                                        class="materialize-textarea code",
                                        form_obj=config_form.config,
                                        id="config-textarea"
                                        ) }}
                                    </form>
                                </div>
                        </div>
                    </div>
                </div>

                <div class="col s12 m12 l6">
                    <div class="card scrollbar settings-page-card">
                        <div class="card-content">

                            <div class="row">
                                <div class="col s12 mb-2">
                                    <ul class="tabs tabs-fixed-width">
                                        <li class="tab col s3"><a href="#config-readme">
                                            <i class="material-icons-outlined">info</i>
                                        </a></li>

                                        <li class="tab col s3"><a href="#images">
                                            <i class="material-icons-outlined">photo_library</i>
                                        </a></li>

                                        <li class="tab col s3"><a href="#apps">
                                            <i class="material-icons-outlined">apps</i>
                                        </a></li>

                                        <li class="tab col s3"><a href="#user">
                                            <i class="material-icons-outlined">person</i>
                                        </a></li>
                                    </ul>
                                </div>

                                <div id="images" class="col s12">
                                    {{ FilesTab() }}
                                </div>

                                <div id="apps" class="col s12">
                                    <h5>App Templates</h5>
                                    <div class="row card-filter-container">
                                        <div class="col s12 input-field">
                                            <span>
                                                <i class="material-icons prefix card-search-icon">search</i>
                                                <input type="text" id="templates-filter"
                                                       class="card-filter theme-surface-1 autocomplete"
                                                       data-url="{{ url_for('settings_system.get_app_template') }}"
                                                       data-template_apps="{{ template_apps }}"
                                                       placeholder="Search for app (e.g. Nextcloud)">
                                            </span>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col s12">
                                            <div id="template-div" class="selectable-all code"></div>
                                        </div>
                                    </div>

                                </div>

                                <div id="config-readme" class="col s12">
                                    {{ config_readme|safe }}
                                </div>

                                <div id="user" class="col s12">
                                    {{ UserTab() }}
                                </div>

                            </div>

                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
{% endblock content %}

{% block page_vendor_js %}
{% endblock page_vendor_js %}

{% block page_lvl_js %}
{{ process_js_sources(src="settings_system/settings.js")|safe }}
{% endblock page_lvl_js %}
