<!doctype html>
<html lang="{{ env["locale"] }}">
<head>
    <title>{{ page_title }} [{{ env["host"] }}]</title>

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="apple-touch-icon" sizes="57x57" href="/pwa/apple-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="/pwa/apple-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="/pwa/apple-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="76x76" href="/pwa/apple-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="114x114" href="/pwa/apple-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="120x120" href="/pwa/apple-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="144x144" href="/pwa/apple-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="152x152" href="/pwa/apple-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="/pwa/apple-icon-180x180.png">
    <link rel="icon" type="image/png" sizes="192x192"  href="/pwa/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/pwa/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="96x96" href="/pwa/favicon-96x96.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/pwa/favicon-16x16.png">
    <link rel="manifest" href="/pwa/manifest.json">
    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="msapplication-TileImage" content="/pwa/ms-icon-144x144.png">
    <meta name="theme-color" content="#ffffff">

    <link rel="stylesheet" href="{{ url_for('static', filename=current_theme_stylesheet) }}">
</head>

<body class="{{ body_classes|join(' ') }}">
    <div class="header">
        {% if env["logged_in"] or not env["auth_active"] %}
        <div align="center" class="login-status logged-in">
            {% if env["logged_in"] %}
            <span class="logged-in-as-text">{{ _("Logged in as <em>%(username)s</em>", username=env["username"]) }}</span>
            <span class="separator">-</span>
            <span class="log-out-button"><a href="/logout">{{ _("Log Out") }}</a></span>
            <span class="separator">-</span>
            {% endif %}
            <span class="admin-button"><a href="/sys/admin">{{ _("Settings") }}</a></span>
        </div>
        {% else %}
        <div align="center" class="login-status logged-out">
            <form method="POST" action="/login">
                <div class="login-form-title">{{ _("Log in to use Web Interface") }}</div>
                <span>
                    <label for="username">{{ _("Username:") }}</label>
                    <input type="text" name="username" id="username">
                </span>
                <span>
                    <label for="password">{{ _("Password:") }}</label>
                    <input type="password" name="password" id="password">
                </span>
                <input type="submit" value="Login">
            </form>
        </div>
        {% endif %}

        <div align="center" class="title">
            <a href="/">
                <h1>
                    <span>{{ _("PiSCSI") }}</span>
                    <span class="subtitle">{{ _("Control Page") }}</span>
                </h1>
            </a>
        </div>

        <div class="hostname">
            <span class="label">{{ _("System Name:") }}</span>
            <span>{{ env['system_name'] }}</span>
        </div>
    </div>

    <div class="throttle-notice">
        {% if (env["throttle_status"]|length > 0) %}
        {% for category, response in env["throttle_status"] %}
        <div class="{{ category }}">
        <span class="message" title="{{ response['msg'] }}"><a
                href="https://www.raspberrypi.com/documentation/computers/configuration.html#undervoltage-warning">{{ response['msg'] }}</a></span>
        </div>
        {% endfor %}
        {% endif %}
    </div>

    <div class="flash" id="flash">
        {% if get_flashed_messages(): %}
            {% for category, message in get_flashed_messages(with_categories=true) %}
                <div class="{{ category }}">
                    {% if category == "stdout" or category == "stderr" %}
                        <pre>{{ message }}</pre>
                    {% else %}
                        <div>{{ message }}</div>
                    {% endif %}
                    <a href="/"></a>
                </div>
            {% endfor %}
        {% endif %}
    </div>

    <div class="content">
        {{ content_class }}
        {% block content %}{% endblock content %}
    </div>
    {% if not is_root_page %}
    <div class="content">
        <a class="back" href="/"><span class="separator">&lt;&lt; </span>{{ _("Go to Home") }}</a>
    </div>
    {% endif %}
    <div align="center" class="footer">
        <div>
            <a href="/sys/manpage?app=piscsi">{{ _("Read the PiSCSI Manual") }}</a>
        </div>
        <div>
            {{ _("PiSCSI software version:") }} <b>{{ env["version"] }}</b>
        </div>
        <div>
            {{ _("Hardware and OS:") }} {{ env["running_env"]["env"] }}
        </div>
        <div>
            {{ _("Network Address:") }} {{ env["host"] }} ({{ env["ip_addr"] }})
        </div>
    </div>
</body>
