2019-12-06 12:24:44 +01:00
|
|
|
$(document).ready(function () {
|
2020-02-10 11:16:44 +01:00
|
|
|
new AdminPanel();
|
|
|
|
});
|
2019-12-06 12:24:44 +01:00
|
|
|
|
2020-02-10 11:16:44 +01:00
|
|
|
class AdminPanel {
|
|
|
|
constructor() {
|
|
|
|
this.checkLoginState();
|
|
|
|
this.addClickListeners();
|
|
|
|
}
|
2019-12-06 12:24:44 +01:00
|
|
|
|
2020-02-10 11:16:44 +01:00
|
|
|
checkLoginState(){
|
|
|
|
$.post('/senddata/checkloginstate', 'action=getloginstate', function (data) {
|
2019-12-06 12:24:44 +01:00
|
|
|
console.log(data);
|
2020-02-10 11:16:44 +01:00
|
|
|
if (data.loggedin == true) {
|
|
|
|
$("#userlabel").html(" " + data.username);
|
|
|
|
if (data.permission > 0) {
|
|
|
|
$("#adminpanel").show();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("#userlabel").html(" not logged in!!");
|
|
|
|
}
|
2019-12-06 12:24:44 +01:00
|
|
|
}, 'json');
|
2020-02-10 11:16:44 +01:00
|
|
|
}
|
2019-12-06 12:24:44 +01:00
|
|
|
|
2020-02-10 11:16:44 +01:00
|
|
|
addClickListeners(){
|
|
|
|
$("#btn-shutdown").click(function (event) {
|
|
|
|
console.log("shutting down server");
|
2019-12-06 12:24:44 +01:00
|
|
|
|
2020-02-10 11:16:44 +01:00
|
|
|
$.post('/senddata/admindata', 'action=shutdownserver', function (data) {
|
|
|
|
console.log(data);
|
2019-12-06 12:24:44 +01:00
|
|
|
|
2020-02-10 11:16:44 +01:00
|
|
|
}, 'json');
|
2019-12-06 12:24:44 +01:00
|
|
|
|
2020-02-10 11:16:44 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#btn-restart").click(function (event) {
|
|
|
|
console.log("restarting server");
|
|
|
|
|
|
|
|
$.post('/senddata/admindata', 'action=restartserver', function (data) {
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
}, 'json');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|