1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00
maloja/website/admin.pyhp
2019-11-20 22:46:20 +01:00

104 lines
2.9 KiB
Plaintext

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Maloja</title>
<script src="javascript/cookies.js"></script>
<pyhp include="common/header.html" />
<script>
neo.xhttprequest("https://maloja.krateng.ch/api/serverinfo",{},"GET",json=true).then((response)=>{
result = JSON.parse(response.responseText);
latestvers = result.version;
neo.xhttprequest("/api/serverinfo",{},"GET",json=true).then((response)=>{
result = JSON.parse(response.responseText);
thisvers = result.version;
document.getElementById("latestversion").innerHTML = latestvers.join(".");
document.getElementById("currentversion").innerHTML = thisvers.join(".");
if (latestvers <= thisvers) {
document.getElementById("currentversion").style.color = "green";
}
else {
document.getElementById("currentversion").style.color = "red";
document.getElementById("updatestatus").innerHTML = "Consider updating to take advantage of new features";
}
});
});
function activate() {
neo.setCookie("adminmode","true");
window.location.reload(true);
}
function deactivate() {
neo.setCookie("adminmode","false");
window.location.reload(true);
}
function buttonlock() {
button = document.getElementById("adminmodebutton")
if (apikeycorrect) {
button.classList.remove("locked");
if (button.innerHTML == "Activate") { button.onclick = activate; }
else { button.onclick = deactivate; }
// ugh
}
else {
button.classList.add("locked");
button.onclick = null;
}
}
window.addEventListener("load",function(){checkAPIkey(buttonlock)});
// we do this twice, but this one ensures that the button is correctly locked / unlocked after the api key has been checked
</script>
</head>
<body>
<table class="top_info">
<tr>
<td class="image">
<div style="background-image:url('/favicon.png')"></div>
</td>
<td class="text">
<h1>Admin Panel</h1><br/>
<br/><br/>
API Key: <input id='apikey' onchange='checkAPIkey(buttonlock);' style='width:300px;'/><br/><br/>
</td>
</tr>
</table>
<h2>Update</h2>
Currently installed Maloja version: <span id="currentversion">Loading...</span><br/>
Latest recommended Maloja version: <span id="latestversion">Loading...</span><br/>
<span id="updatestatus"></span>
<h2>Admin Mode</h2>
Admin Mode allows you to manually scrobble from various places on the web interface instead of just the dedicated page.<br/><br/>
<pyhp if="adminmode"><span id="adminmodebutton" class="button locked">Deactivate</span></pyhp>
<pyhp if="not adminmode"><span id="adminmodebutton" class="button locked">Activate</span></pyhp>
<h2>Links</h2>
<a class="textlink" href="/setup">Server Setup</a><br/>
<a class="textlink" href="/manual">Manual Scrobbling</a>
<pyhp include="common/footer.html" />
</body>
</html>