Add plugin name to bus registration and debug app
authorBenjamin Braatz <bb@bbraatz.eu>
Tue, 9 Mar 2021 19:13:22 +0000 (20:13 +0100)
committerBenjamin Braatz <bb@bbraatz.eu>
Tue, 9 Mar 2021 19:13:22 +0000 (20:13 +0100)
controlpi-plugins/wsserver.py
web/controlpi-debug.css
web/controlpi-debug.js
web/index.css

index 0dcc0152a1252536804b18e060cabc85e663d81e..c19126b3e3629f77eb6a39022240c16888fd196f 100644 (file)
@@ -24,7 +24,8 @@ class Connection:
         self._name = f"{self._address}:{self._port}"
         if path != '/':
             self._name = path[1:]
-        self._bus.register(self._name, [{}], [{}], self._receive)
+        self._bus.register(self._name, 'WSServer-Connection',
+                           [{}], [{}], self._receive)
 
     async def _receive(self, message: Message) -> None:
         json_message = json.dumps(message)
@@ -89,17 +90,20 @@ class WSServer(BasePlugin):
         return HTTPStatus.OK, response_headers, body
 
     def _process_conf(self, conf: PluginConfiguration) -> None:
-        if 'port' not in conf:
+        self._port = 80
+        if 'port' in conf:
+            self._port = conf['port']
+        else:
             print(f"'port' not configured for WSServer '{self._name}'."
                   " Using 80.")
-            conf['port'] = 80
-        self._port = conf['port']
-        if 'web root' not in conf:
+        web_root = 'web'
+        if 'web root' in conf:
+            web_root = conf['web root']
+        else:
             print(f"'web root' not configured for WSServer '{self._name}'."
                   " Using 'web'.")
-            conf['web root'] = 'web'
         self._web_root = os.path.realpath(os.path.join(os.getcwd(),
-                                                       conf['web root']))
+                                                       web_root))
         super()._process_conf(conf)
 
     async def run(self) -> None:
index 959ac31ed7599a542c13f68a9a237ac64b3528b5..1fca3c620b652779da1ade59700d3571b4d4df96 100644 (file)
     background-color: #bcdaf8;
 }
 
-.client > h2 {
+.client > header {
+    display: flex;
+    justify-content: space-between;
+}
+
+.client > header > h2 {
+    vertical-align: top;
     font-size: 1.2rem;
     font-weight: bold;
 }
 
+.client > header > h3 {
+    vertical-align: top;
+    font-size: 0.8rem;
+    font-weight: bold;
+}
+
 .interfacecontainer {
     white-space: nowrap;
 }
index 5ae170a89a276dcb6f9d4d2f15ba1a662117b156..9c4dd77365cb7cec58dbd384f0716b28236f81bb 100644 (file)
@@ -1,10 +1,15 @@
 // Create section for client:
-function createForClient(client) {
+function createForClient(client, plugin) {
     const section = document.createElement('section')
     section.setAttribute('id', client)
     section.setAttribute('class', 'client')
-    const heading = document.createElement('h2')
-    heading.appendChild(document.createTextNode(client))
+    const heading = document.createElement('header')
+    const headingH2 = document.createElement('h2')
+    headingH2.appendChild(document.createTextNode(client))
+    heading.appendChild(headingH2)
+    const headingH3 = document.createElement('h3')
+    headingH3.appendChild(document.createTextNode(plugin))
+    heading.appendChild(headingH3)
     section.appendChild(heading)
     const receiveOuter = document.createElement('div')
     receiveOuter.setAttribute('class', 'interfacecontainer')
@@ -247,7 +252,8 @@ function processBusMessage(message) {
         if (clientElement == null) {
             // Create element for client if not existent:
             const main = document.getElementById('ControlPi Debug')
-            main.appendChild(createForClient(message['client']))
+            main.appendChild(createForClient(message['client'],
+                                             message['plugin']))
         }
         // Crate message elements for receives interface:
         const receiveContainer = document.getElementById(message['client'] + ' Receives')
@@ -316,7 +322,7 @@ function processClientMessage(message) {
     if (clientElement == null) {
         // Create section for client if not existent:
         const main = document.getElementById('ControlPi Debug')
-        main.appendChild(createForClient(message.sender))
+        main.appendChild(createForClient(message.sender, ''))
     }
     // Update last received message:
     const lastContainer = document.getElementById(message['sender'] + ' Last')
index e33bc744b3acd468ec33a84e7dca9102793717ca..e0f29d10ddda68e06f79fef15583552834dc053e 100644 (file)
@@ -22,32 +22,32 @@ body {
     color: black;
 }
 
-header {
+body > header {
     padding: 10px;
     background-color: #2c343b;
 }
 
-header * {
+body > header * {
     vertical-align: middle;
 }
 
-header svg {
+body > header svg {
     height: 40px;
 }
 
-header span {
+body > header span {
     font-family: "Michroma", sans-serif;
     font-weight: bold;
     font-size: 20px;
     text-transform: uppercase;
 }
 
-header span.Graph {
+body > header span.Graph {
     margin-left: 10px;
     color: white;
 }
 
-header span.IT {
+body > header span.IT {
     margin-right: 10px;
     color: #83a1b4;
 }