format home.jinja2

This commit is contained in:
Robert Resch 2021-09-20 22:00:45 +02:00
parent aaf34097b4
commit a76d64429d
No known key found for this signature in database
GPG key ID: 6B360759EB2ACAEE

View file

@ -1,59 +1,54 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Bumper</title> <title>Bumper</title>
<meta http-equiv="refresh" content="5" /> <meta http-equiv="refresh" content="5"/>
<script> <script>
function restartService(service) { function restartService(service) {
console.log("restart service", service); console.log("restart service", service);
fetch('restart_' + service) fetch('restart_' + service)
.then((response) => { .then((response) => {
return response.json(); return response.json();
}) })
.then((myJson) => { .then((myJson) => {
alert("Restarting " + service + ": " + myJson["status"]) alert("Restarting " + service + ": " + myJson["status"])
console.log("restart",service,"-",myJson["status"]); console.log("restart", service, "-", myJson["status"]);
}); });
}
} function removeBot(did) {
console.log("remove bot", did);
function removeBot(did) { fetch('bot/remove/' + did)
console.log("remove bot",did); .then((response) => {
fetch('bot/remove/' + did) return response.json();
.then((response) => { })
return response.json(); .then((myJson) => {
}) alert("Removing Bot (DID) - " + did + " - " + myJson["status"])
.then((myJson) => { console.log("remove bot", did, myJson["status"]);
alert("Removing Bot (DID) - " + did + " - " + myJson["status"]) });
console.log("remove bot",did, myJson["status"]); }
});
}
function removeClient(resource) {
console.log("remove client",resource);
fetch('client/remove/' + resource)
.then((response) => {
return response.json();
})
.then((myJson) => {
alert("Removing Client - resource - " + resource + " - " + myJson["status"])
console.log("remove client",resource, myJson["status"]);
});
}
function removeClient(resource) {
console.log("remove client", resource);
fetch('client/remove/' + resource)
.then((response) => {
return response.json();
})
.then((myJson) => {
alert("Removing Client - resource - " + resource + " - " + myJson["status"])
console.log("remove client", resource, myJson["status"]);
});
}
</script> </script>
</head> </head>
<body> <body>
<ul id="navigation"> <ul id="navigation">
{% for item in navigation %} {% for item in navigation %}
<li><a href="{{ item.href }}">{{ item.caption }}</a></li> <li><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
<div class="col-8"> <div class="col-8">
<h1>Bumper</h1> <h1>Bumper</h1>
@ -65,77 +60,105 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="card border border-dark"> <div class="card border border-dark">
<div class="card card-header"> <div class="card card-header">
<h3 class="card-title">MQTT Server</h3> <h3 class="card-title">MQTT Server</h3>
<div>Action: <button type="button" class="btn btn-outline-danger btn-sm" onclick="restartService('MQTTServer');">Restart Service</button></div> <div>Action:
</div> <button type="button" class="btn btn-outline-danger btn-sm"
<div class="card-body"> onclick="restartService('MQTTServer');">Restart Service
Status: {% if mqtt_server[0].state == "started" %} <span class="badge badge-success">{{ mqtt_server[0].state }}</span> {% else %} <span class="badge badge-danger">{{ mqtt_server[0].state }}</span> {% endif %} </button>
Sessions: {{ mqtt_server[1].sessions[0].count }} </div>
</div>
<div class="card-body">
Status: {% if mqtt_server[0].state == "started" %}
<span class="badge badge-success">{{ mqtt_server[0].state }}</span> {% else %}
<span class="badge badge-danger">{{ mqtt_server[0].state }}</span> {% endif %}
Sessions: {{ mqtt_server[1].sessions[0].count }}
<table class="table table-striped table-bordered table-responsive-lg"> <table class="table table-striped table-bordered table-responsive-lg">
<thead class="thead-dark"> <thead class="thead-dark">
<TH>username</TH><TH>clientid</TH><TH>state</TH> <tr>
</thead> <th>username</th>
{% for sess in mqtt_server[1].sessions[1].clients %} <th>clientid</th>
<TR> <th>state</th>
<TD>{{ sess[0].username }}</TD> </tr>
<TD>{{ sess[0].client_id }}</TD> </thead>
<TD {% if sess[0].state == "connected" %} class="table-success" {% endif %}> {{ sess[0].state }} </TD> {% for sess in mqtt_server[1].sessions[1].clients %}
</TR> <tr>
{% endfor %} <td>{{ sess[0].username }}</td>
</table> <td>{{ sess[0].client_id }}</td>
<td {% if sess[0].state == "connected" %}
class="table-success" {% endif %}> {{ sess[0].state }} </td>
</tr>
{% endfor %}
</table>
</div> </div>
</div> </div>
</br> <br/>
<div class="card border border-dark"> <div class="card border border-dark">
<div class="card card-header"> <div class="card card-header">
<h3 class="card-title">XMPP Server</h3> <h3 class="card-title">XMPP Server</h3>
<div>Action: <button type="button" class="btn btn-outline-danger btn-sm" onclick="restartService('XMPPServer');">Restart Service</button></div> <div>Action:
</div> <button type="button" class="btn btn-outline-danger btn-sm"
<div class="card-body"> onclick="restartService('XMPPServer');">Restart Service
Status: {% if xmpp_server.server._serving == True %} <span class="badge badge-success">running</span> {% else %} <span class="badge badge-danger">not running</span> {% endif %} </button>
Clients: {{ xmpp_server.clients | length }} </div>
</div>
<div class="card-body">
Status: {% if xmpp_server.server._serving == True %}
<span class="badge badge-success">running</span> {% else %}
<span class="badge badge-danger">not running</span> {% endif %}
Clients: {{ xmpp_server.clients | length }}
<table class="table table-striped table-bordered table-responsive-lg"> <table class="table table-striped table-bordered table-responsive-lg">
<thead class="thead-dark"> <thead class="thead-dark">
<TH>uid</TH><TH>jid</TH><TH>state</TH> <tr>
</thead> <th>uid</th>
{% for client in xmpp_server.clients %} <th>jid</th>
<TR> <th>state</th>
<TD>{{ client.uid }}</TD> </tr>
<TD>{{ client.bumper_jid }}</TD> </thead>
<TD {% if client.state == 4 %} class="table-success" {% endif %}>{% if client.state == 4 %} connected {% else %} not connected {% endif %}</TD> {% for client in xmpp_server.clients %}
</TR> <tr>
{% endfor %} <td>{{ client.uid }}</td>
</table> <td>{{ client.bumper_jid }}</td>
<td {% if client.state == 4 %} class="table-success" {% endif %}>
{% if client.state == 4 %} connected {% else %} not connected {% endif %}</td>
</tr>
{% endfor %}
</table>
</div> </div>
</div> </div>
</br> <br/>
<div class="card border border-dark"> <div class="card border border-dark">
<div class="card card-header"> <div class="card card-header">
<h3 class="card-title">Helperbot</h3> <h3 class="card-title">Helperbot</h3>
<div>Action: <button type="button" class="btn btn-outline-danger btn-sm" onclick="restartService('Helperbot');">Restart Service</button></div> <div>Action:
<button type="button" class="btn btn-outline-danger btn-sm"
onclick="restartService('Helperbot');">Restart Service
</button>
</div>
</div> </div>
<div class="card-body"> <div class="card-body">
Status: {% if helperbot[0].state == "connected" %} <span class="badge badge-success">{{ helperbot[0].state }}</span> {% else %} <span class="badge badge-danger">{{ helperbot[0].state }}</span> {% endif %} Status: {% if helperbot[0].state == "connected" %}
<span class="badge badge-success">{{ helperbot[0].state }}</span> {% else %}
<span class="badge badge-danger">{{ helperbot[0].state }}</span> {% endif %}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</br> <br/>
<!-- Section Bots --> <!-- Section Bots -->
<div class="card border-dark"> <div class="card border-dark">
@ -143,29 +166,45 @@
<h2 class="card-title">Bots</h2> <h2 class="card-title">Bots</h2>
</div> </div>
<div class="card-body"> <div class="card-body">
<table class="table table-striped table-bordered table-responsive-lg"> <table class="table table-striped table-bordered table-responsive-lg">
<thead class="thead-dark"> <thead class="thead-dark">
<TH>SN</TH><TH>Nickname</TH><TH>Class</TH><TH>DID</TH><TH>Resource</TH><TH>Company</TH><TH>MQTT Connected</TH><TH>XMPP Connected</TH><TH>Action</TH> <tr>
</thead> <th>SN</th>
{% for bot in bots %} <th>Nickname</th>
<TR> <th>Class</th>
<TD>{{ bot.name }}</TD> <th>DID</th>
<TD>{{ bot.nick }}</TD> <th>Resource</th>
<TD>{{ bot.class }}</TD> <th>Company</th>
<TD>{{ bot.did }}</TD> <th>MQTT Connected</th>
<TD>{{ bot.resource }} </TD> <th>XMPP Connected</th>
<TD>{{ bot.company}} </TD> <th>Action</th>
</tr>
</thead>
{% for bot in bots %}
<tr>
<td>{{ bot.name }}</td>
<td>{{ bot.nick }}</td>
<td>{{ bot.class }}</td>
<td>{{ bot.did }}</td>
<td>{{ bot.resource }} </td>
<td>{{ bot.company }} </td>
<TD {% if bot.mqtt_connection == True %} class="table-success" {% endif %}> {{ bot.mqtt_connection }} </TD> <td {% if bot.mqtt_connection == True %}
<TD {% if bot.xmpp_connection == True %} class="table-success" {% endif %}> {{ bot.xmpp_connection }}</TD> class="table-success" {% endif %}> {{ bot.mqtt_connection }} </td>
<TD> <button type="button" class="btn btn-outline-danger btn-sm" onclick="removeBot('{{ bot.did }}');">Remove</button> </TD> <td {% if bot.xmpp_connection == True %}
</TR> class="table-success" {% endif %}> {{ bot.xmpp_connection }}</td>
{% endfor %} <td>
</table> <button type="button" class="btn btn-outline-danger btn-sm"
onclick="removeBot('{{ bot.did }}');">Remove
</button>
</td>
</tr>
{% endfor %}
</table>
</div> </div>
</div> </div>
</br> <br />
<!-- Section Clients --> <!-- Section Clients -->
<div class="card border-dark"> <div class="card border-dark">
@ -173,21 +212,34 @@
<h2 class="card-title">Clients</h2> <h2 class="card-title">Clients</h2>
</div> </div>
<div class="card-body"> <div class="card-body">
<table class="table table-striped table-bordered table-responsive-lg"> <table class="table table-striped table-bordered table-responsive-lg">
<thead class="thead-dark"> <thead class="thead-dark">
<TH>User ID</TH><TH>Realm</TH><TH>Resource</TH><TH>MQTT Connected</TH><TH>XMPP Connected</TH><TH>Action</TH> <tr>
</thead> <th>User ID</th>
{% for client in clients %} <th>Realm</th>
<TR> <th>Resource</th>
<TD>{{ client.userid }}</TD> <th>MQTT Connected</th>
<TD>{{ client.realm }}</TD> <th>XMPP Connected</th>
<TD>{{ client.resource }}</TD> <th>Action</th>
<TD {% if client.mqtt_connection == True %} class="table-success" {% endif %}> {{ client.mqtt_connection }} </TD> </tr>
<TD {% if client.xmpp_connection == True %} class="table-success" {% endif %}> {{ client.xmpp_connection }}</TD> </thead>
<TD> <button type="button" class="btn btn-outline-danger btn-sm" onclick="removeClient('{{ client.resource }}');">Remove</button> </TD> {% for client in clients %}
</TR> <tr>
{% endfor %} <td>{{ client.userid }}</td>
</table> <td>{{ client.realm }}</td>
<td>{{ client.resource }}</td>
<td {% if client.mqtt_connection == True %}
class="table-success" {% endif %}> {{ client.mqtt_connection }} </td>
<td {% if client.xmpp_connection == True %}
class="table-success" {% endif %}> {{ client.xmpp_connection }}</td>
<td>
<button type="button" class="btn btn-outline-danger btn-sm"
onclick="removeClient('{{ client.resource }}');">Remove
</button>
</td>
</tr>
{% endfor %}
</table>
</div> </div>
</div> </div>