add admin pages

This commit is contained in:
Thomas Rubini 2023-03-11 18:15:22 +01:00
parent 1f52c7c98c
commit 5d79915829
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
6 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import flask
routes_admin = flask.Blueprint("admin", __name__)
@routes_admin.route("/")
def index():
return flask.render_template("admin/index.html")
@routes_admin.route("/npc/<npc_id>")
def npc(npc_id):
return flask.render_template("admin/npc.html")
@routes_admin.route("/questions")
def questions():
return flask.render_template("admin/questions.html", langs=["FR", "EN"])
@routes_admin.route("/places")
def places():
return flask.render_template("admin/places.html")

View File

@ -0,0 +1,13 @@
<a href="/admin/questions"> Questions </a>
<br>
<a href="/admin/places"> Places </a>
<br>
<a href="/admin/reactions"> Reactions </a>
<section>
<p> NPC list :</p>
<a href="/admin/npc/1"> Diva </a>
<br>
<a href="/admin/npc/2"> Barron </a>
<br>
<a href="/admin/npc/3"> Machin </a>
</section>

View File

View File

View File

@ -0,0 +1,53 @@
<select id="langs" onchange="langChangedEvent()">
{%for lang in langs%}
<option value="{{lang}}">{{lang}}</option>
{%endfor%}
</select>
<section id="questionsTag">
</section>
<style>
.questionTypeTag{
border: thin solid red;
}
</style>
<script src="/static/js/api.js"></script>
<script>
function save(){
console.log("Saving")
}
async function changeLang(newLang){
console.log("Changing language to "+newLang);
resp = await makeAPIRequest("admin/getQuestions", {"lang": newLang});
questionsTag.innerHTML = '';
for(let questionType of resp){
let questionTypeTag = document.createElement("section")
questionTypeTag.className = 'questionTypeTag';
questionsTag.appendChild(questionTypeTag);
for(let question of questionType){
let questionTag = document.createElement("h1");
questionTypeTag.appendChild(questionTag);
questionTag.innerHTML = question.text;
}
}
}
function langChangedEvent(){
save();
changeLang(langs.value)
}
changeLang(langs.value);
</script>