snorklerjoe/CubeServer

View on GitHub
src/CubeServer-app/cubeserver_app/blueprints/admin/templates/console.html.jinja2

Summary

Maintainability
Test Coverage
{% extends "base.html.jinja2" %}
{% block title %}Admin{% endblock %}

{% block header %}
    <h4>Admin Console</h4>
{% endblock %}

{% block content %}
    <h3>Data:</h3>
    <a href={{ url_for('admin.data_table') }} class="btn bg-info">See All Logged Data</a>
    <br><br><br>
    <h3>Teams:</h3>
    <div>
        {{teams_table}}
    </div>
{% endblock %}

{% block body %}
{{ super() }}
    <div class="justify-content-md-center container container-fluid text-center">
        <div class="row">
            <div class="col">
            {{macros.startbox("Users")}}
                <p>
                    <a href={{ url_for('admin.edit_users') }} class="btn">Edit/delete users</a>
                </p>
                <hr>
                <p>
                    Invite a new user:
                </p>
                <form method="POST" action="useradd" class="form">
                    {{ user_form.hidden_tag() }}
                    {{ wtf.form_errors(user_form, hiddens="only") }}

                    {{ wtf.form_field(user_form.level) }}
                    {{ wtf.form_field(user_form.submit) }}
                </form>
            {{macros.endbox()}}

            {{macros.startbox("Email")}}
                <a href={{ url_for('admin.email') }} class="btn">Send Custom Email</a>
                <br>
                <div class="btn-group" role="group">
                    {% for group, mailing_list in email_groups %}
                        <a href={{ url_for('admin.email', recipients=mailing_list) }} class="btn">Email {{ group }}</a>
                    {% endfor %}
                </div>
                <br>
                <a href={{ url_for('admin.sent_email') }} class="btn bg-info">Review Sent Mail</a>
            {{macros.endbox()}}
            </div>

            {{macros.startbox("Beacon", "col")}}
                <a href={{ url_for('admin.beacon_table') }} class="btn">Manage Message Queue</a>
                <hr>

                <br>

                <u>Beacon Status-</u><br><br>

                <b>Statistics- 24 hrs-</b>
                <ul>
                    <li>Messages Transmitted: <code style="float:right;">{{ beacon_stats['transmitted_today'] }}</code></li>
                    <li>Messages Scheduled: <code style="float:right;">{{ beacon_stats['scheduled_today'] }}</code></li>
                    <li>Messages Missed: <code style="float:right;">{{ beacon_stats['missed_today'] }}</code></li>
                </ul>
                <b>All time-</b>
                <ul>
                    <li>Messages Queued: <code style="float:right;">{{ beacon_stats['queued'] }}</code></li>
                    <li>Messages Transmitted: <code style="float:right;">{{ beacon_stats['transmitted'] }}</code></li>
                    <li>Messages Missed: <code style="float:right;">{{ beacon_stats['missed'] }}</code></li>
                </ul>
            {{macros.endbox()}}

        </div>
        <div class="row">
            {{macros.startbox("Global Configuration", "col")}}
                <p>
                    Note: It may take up to 30 seconds for all server threads to sync their configuration after a change.
                </p>
                <p>
                    An asterisk (*) indicates that the change will not take effect until a restart of all containers.
                </p>
                <br>
                <form method="POST" action="configchange" class="form">
                    {{ config_form.hidden_tag() }}
                    <h4>General Settings:</h4>
                    <div class="form-group">
                        {{ config_form.competition_on.label }}
                        {{ config_form.competition_on(class_="form-control") }}
                    </div>
                    {{ wtf.form_field(config_form.registration_open) }}
                    {{ wtf.form_field(config_form.notify_teams) }}
                    {{ wtf.form_field(config_form.banner_message) }}
                    {{ wtf.form_field(config_form.home_description, rows=5, cols=20) }}
                    {{ wtf.form_field(config_form.reg_confirmation, rows=5, cols=20) }}
                    {{ wtf.form_field(config_form.beacon_polling_period) }}
                    <br>
                    <h4>Email Settings:</h4>
                    {{ wtf.form_field(config_form.email_domain) }}
                    {{ wtf.form_field(config_form.smtp_server) }}
                    {{ wtf.form_field(config_form.smtp_credentials) }}
                    {{ wtf.form_field(config_form.team_email_quota) }}
                    {{ wtf.form_field(config_form.quota_reset_hour) }}
                    <br><br>
                    {{ wtf.form_field(config_form.submit) }}
                </form>
                <br>
                <a href={{ url_for('admin.game_settings') }} class="btn">More Game Rules/Settings</a>
            {{macros.endbox()}}
        </div>

        <div class="row">
            {{macros.startbox("Internal API \"Team\"s", "col")}}
                <b>Reserved team names </b> (click to generate)<b>:</b> 
                <ul>
                    {% for name, url, url2 in reserved_names %}
                        {% if url == None %}
                            <li>{{name}} {% if url2 != None %}<a href={{url2}}>Test</a>{% endif %}</li>
                        {% else %}
                            <li><a href={{url}}>{{name}}</a></li>
                        {% endif %}
                    {% endfor %}
                </ul>

                <b>Generated Certicicates: </b>
                <ul>
                    <li>API Server Certificate <a href={{url_for('config.api_cert')}}>cert.pem</a></li>
                </ul>
            {{macros.endbox()}}
            {{macros.startbox("System", "col")}}
                <b>Uptime: </b>
                <p id="uptime_counter">LOADING...</p>

                <hr>

                <b>Database Repair: </b>
                <p>
                    This version of CubeServer is equipped with an emergency database repair tool.
                    Please consult documentation for more information.
                </p>
            {{macros.endbox()}}
<div style="display:none">
            {{macros.startbox("Box #10", "col")}}
                <pre>
Hello Mama and Dad, I had to call collect
'Cause I ain't got a cent to my name
Well I'm sleepin' in the hotel doorway
And tonight they say it's gonna rain
And if you'd only send me some money
I'll be back on my feet again
Send it in care of the Sunday Mission
Box number ten.
                </pre>
                <b>RIP</b> Jim Croce & Maury Muehleisen
            {{macros.endbox()}}
</div>
        </div>

    </div>
{% endblock %}

{% block scripts %}
{{ super() }}
    <script src="{{ url_for('static', filename='/js/admin.js') }}"></script>

    <script>
        // TODO: Uptime could be incremented without calling back to the server each second to see if a second has really gone by:
        function updateUptimeCounter(){
            $.get("/admin/uptime", function(data) {
                $("#uptime_counter").html(data);
                //setTimeout(updateUptimeCounter, 1000);
            });
        }
        updateUptimeCounter();
    </script>
{% endblock %}