confserver revamp #88
4 changed files with 177 additions and 8 deletions
2
Pipfile
2
Pipfile
|
|
@ -11,6 +11,8 @@ pyyaml = "~=5.2"
|
||||||
atomicwrites = "~=1.3"
|
atomicwrites = "~=1.3"
|
||||||
yarl = "~=1.3.0"
|
yarl = "~=1.3.0"
|
||||||
multidict = "~=4.5.2"
|
multidict = "~=4.5.2"
|
||||||
|
aiohttp-jinja2 = "*"
|
||||||
|
jinja2 = "*"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
black = "*"
|
black = "*"
|
||||||
|
|
|
||||||
56
Pipfile.lock
generated
56
Pipfile.lock
generated
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "315b25b9f7d46a6ea88fb08170ad935b35aa2717743be4eca137e52e595066de"
|
"sha256": "740f61688ce679591a1b01f41abc1fa979f8fb1552d598e68868bc47712ba937"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {},
|
"requires": {},
|
||||||
|
|
@ -32,6 +32,14 @@
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==3.6.2"
|
"version": "==3.6.2"
|
||||||
},
|
},
|
||||||
|
"aiohttp-jinja2": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:2dfe29cfd278d07cd0a851afb98471bc8ce2a830968443e40d67636f3c035d79",
|
||||||
|
"sha256:3b4dfe1bfd5542e254a769c18cb58d62f7f92755fec127e38d0da3436900b240"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==1.2.0"
|
||||||
|
},
|
||||||
"async-timeout": {
|
"async-timeout": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f",
|
"sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f",
|
||||||
|
|
@ -82,6 +90,47 @@
|
||||||
],
|
],
|
||||||
"version": "==2.8"
|
"version": "==2.8"
|
||||||
},
|
},
|
||||||
|
"jinja2": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f",
|
||||||
|
"sha256:9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==2.10.3"
|
||||||
|
},
|
||||||
|
"markupsafe": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
|
||||||
|
"sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161",
|
||||||
|
"sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235",
|
||||||
|
"sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5",
|
||||||
|
"sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff",
|
||||||
|
"sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b",
|
||||||
|
"sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1",
|
||||||
|
"sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e",
|
||||||
|
"sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183",
|
||||||
|
"sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66",
|
||||||
|
"sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1",
|
||||||
|
"sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1",
|
||||||
|
"sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e",
|
||||||
|
"sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b",
|
||||||
|
"sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905",
|
||||||
|
"sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735",
|
||||||
|
"sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d",
|
||||||
|
"sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e",
|
||||||
|
"sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d",
|
||||||
|
"sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c",
|
||||||
|
"sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21",
|
||||||
|
"sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2",
|
||||||
|
"sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5",
|
||||||
|
"sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b",
|
||||||
|
"sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6",
|
||||||
|
"sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f",
|
||||||
|
"sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f",
|
||||||
|
"sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"
|
||||||
|
],
|
||||||
|
"version": "==1.1.1"
|
||||||
|
},
|
||||||
"multidict": {
|
"multidict": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:024b8129695a952ebd93373e45b5d341dbb87c17ce49637b34000093f243dd4f",
|
"sha256:024b8129695a952ebd93373e45b5d341dbb87c17ce49637b34000093f243dd4f",
|
||||||
|
|
@ -636,10 +685,9 @@
|
||||||
},
|
},
|
||||||
"wcwidth": {
|
"wcwidth": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
|
"sha256:8fd29383f539be45b20bd4df0dc29c20ba48654a41e661925e612311e9f3c603"
|
||||||
"sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c"
|
|
||||||
],
|
],
|
||||||
"version": "==0.1.7"
|
"version": "==0.1.8"
|
||||||
},
|
},
|
||||||
"wrapt": {
|
"wrapt": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ from bumper.models import *
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import asyncio
|
import asyncio
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
import aiohttp_jinja2
|
||||||
|
import jinja2
|
||||||
import uuid
|
import uuid
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
|
@ -50,7 +52,8 @@ class ConfServer:
|
||||||
return int(round(timetoconvert * 1000))
|
return int(round(timetoconvert * 1000))
|
||||||
|
|
||||||
def confserver_app(self):
|
def confserver_app(self):
|
||||||
self.app = web.Application(loop=asyncio.get_event_loop(), middlewares=[self.log_all_requests])
|
self.app = web.Application(loop=asyncio.get_event_loop())#, middlewares=[self.log_all_requests])
|
||||||
|
aiohttp_jinja2.setup(self.app, loader=jinja2.FileSystemLoader(os.path.join(bumper.data_dir, "web","templates")))
|
||||||
|
|
||||||
self.app.add_routes(
|
self.app.add_routes(
|
||||||
[
|
[
|
||||||
|
|
@ -201,6 +204,7 @@ class ConfServer:
|
||||||
clients = bumper.db_get().table("clients").all()
|
clients = bumper.db_get().table("clients").all()
|
||||||
helperbot = bumper.mqtt_helperbot.Client.session.transitions.state
|
helperbot = bumper.mqtt_helperbot.Client.session.transitions.state
|
||||||
mqttserver = bumper.mqtt_server.broker
|
mqttserver = bumper.mqtt_server.broker
|
||||||
|
xmppserver = bumper.xmpp_server
|
||||||
mq_sessions = []
|
mq_sessions = []
|
||||||
for sess in mqttserver._sessions:
|
for sess in mqttserver._sessions:
|
||||||
tmpsess = []
|
tmpsess = []
|
||||||
|
|
@ -224,9 +228,11 @@ class ConfServer:
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
"xmpp_server": xmppserver
|
||||||
|
}
|
||||||
return web.json_response(all)
|
resp = aiohttp_jinja2.render_template('home.jinja2', request, context=all)
|
||||||
|
#return web.json_response(all)
|
||||||
|
return resp
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
confserverlog.exception("{}".format(e))
|
confserverlog.exception("{}".format(e))
|
||||||
|
|
|
||||||
113
data/web/templates/home.jinja2
Normal file
113
data/web/templates/home.jinja2
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<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>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<ul id="navigation">
|
||||||
|
{% for item in navigation %}
|
||||||
|
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h1>Bumper</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Section Stats -->
|
||||||
|
<div class="card col-8">
|
||||||
|
<div>
|
||||||
|
<h2>Bumper Server Status</h2>
|
||||||
|
<h3>MQTT Server</h3>
|
||||||
|
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">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<TH>username</TH><TH>clientid</TH><TH>state</TH>
|
||||||
|
</thead>
|
||||||
|
{% for sess in mqtt_server[1].sessions[1].clients %}
|
||||||
|
<TR>
|
||||||
|
<TD>{{ sess[0].username }}</TD>
|
||||||
|
<TD>{{ sess[0].client_id }}</TD>
|
||||||
|
<TD {% if sess[0].state == "connected" %} class="table-success" {% endif %}> {{ sess[0].state }} </TD>
|
||||||
|
</TR>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>XMPP Server</h3>
|
||||||
|
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">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<TH>uid</TH><TH>jid</TH><TH>state</TH>
|
||||||
|
</thead>
|
||||||
|
{% for client in xmpp_server.clients %}
|
||||||
|
<TR>
|
||||||
|
<TD>{{ client.uid }}</TD>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Helperbot</h3>
|
||||||
|
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>
|
||||||
|
|
||||||
|
</br>
|
||||||
|
|
||||||
|
<!-- Section Bots -->
|
||||||
|
<div class="card col-8">
|
||||||
|
<div>
|
||||||
|
<h2>Bots</h2>
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<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>
|
||||||
|
</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.xmpp_connection == True %} class="table-success" {% endif %}> {{ bot.xmpp_connection }}</TD>
|
||||||
|
</TR>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</br>
|
||||||
|
|
||||||
|
<!-- Section Clients -->
|
||||||
|
<div class="card col-8">
|
||||||
|
<div>
|
||||||
|
<h2>Clients</h2>
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<TH>User ID</TH><TH>Realm</TH><TH>Resource</TH><TH>MQTT Connected</TH><TH>XMPP Connected</TH>
|
||||||
|
</thead>
|
||||||
|
{% for client in clients %}
|
||||||
|
<TR>
|
||||||
|
<TD>{{ client.userid }}</TD>
|
||||||
|
<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>
|
||||||
|
</TR>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue