Commit 52c6bed8 authored by Kento HASEGAWA's avatar Kento HASEGAWA
Browse files

Add support for local mode (clients other than localhost cannot control the system)

parent 43872a40
Loading
Loading
Loading
Loading
+6 −2
Changes for comm/server/main.py: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -135,7 +135,10 @@ def update_answer_list(qname):
def before_request():
    global app_args

    g.local_mode = (request.remote_addr == "127.0.0.1")
    if app_args["force_local_mode"]:
        g.local_mode = True
    else:
        g.local_mode = (request.remote_addr in ["127.0.0.1", "::1"])

@app.route("/post", methods=["POST"])
def post():
@@ -588,7 +591,7 @@ def question_status():
    update_answer_list(qname)
    qdata = questions[qname]

    return render_template("part_question_status.html", qname=qname, qdata=qdata, solvers=clients["solver"])
    return render_template("part_question_status.html", qname=qname, qdata=qdata, solvers=clients["solver"], localmode=g.local_mode)

@app.route('/ws')
def ws():
@@ -660,6 +663,7 @@ if __name__ == "__main__":
    parser.add_argument("-a", "--adccli", action="store", type=str, default="./adccli.json", help="Path to the ADCCLI configuration json file.")
    parser.add_argument("-q", "--question", action="store", type=str, default="./problems", help="Path to the question folder.")
    parser.add_argument("-o", "--out", action="store", type=str, default="./answers", help="Path to the output folder.")
    parser.add_argument("--force-local-mode", action="store_true", default=False, help="Apply local mode view to all clients.")
    parser.add_argument("--debug", action="store_true", default=False, help="Debug mode.")
    args = vars(parser.parse_args())
    app_args = args
+3 −2
Changes for comm/server/templates/part_client_table.html: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -9,12 +9,13 @@ Viewer Mode
{% endif %}
</p>

{% if local_mode %}
<h4>自動運営システム</h4>
<button type="button" class="btn btn-primary" id="adccli-login-button">Login</button>
<button type="button" class="btn btn-light" id="adccli-logout-button">Logout</button>
<span id="adccli-status"></span>
<br />
<button type="button" class="btn btn-info" id="adccli-get-all-q">問題DL</button>
<span id="adccli-status"></span>
{% endif %}

<h4>クライアント</h4>
<table class="table table-bordered" id="clients-table">
+4 −0
Changes for comm/server/templates/part_question_status.html: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
<div class="row">
    <div class="col-4">
        <h3> 【{{qname}}】</h3>
        {% if localmode %}
        <p>
            <button class="btn btn-primary btn-lg start-button" type="button" data-qname="{{qname}}">Start</button>
            <button class="btn btn-danger btn-lg stop-button" type="button" data-qname="all">Stop</button>
@@ -9,6 +10,9 @@
            <button class="btn btn-info btn-lg save-button" type="button" data-qname="{{qname}}">Save</button>
            <button class="btn btn-success btn-lg submit-button" type="button" data-qname="{{qname}}">Up</button>
        </p>
        {% else %}
        [View Only]
        {% endif %}
    </div>
    <div class="col-8">
        <p>処理結果</p>