summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kvmd/.bumpversion.cfg4
-rw-r--r--kvmd/kvmd/__init__.py4
-rw-r--r--kvmd/kvmd/server.py22
-rw-r--r--kvmd/web/css/main.css24
-rw-r--r--kvmd/web/index.html5
-rw-r--r--kvmd/web/js/main.js1
-rw-r--r--kvmd/web/js/session.js12
7 files changed, 72 insertions, 0 deletions
diff --git a/kvmd/.bumpversion.cfg b/kvmd/.bumpversion.cfg
index 3ac4ae73..9ec65f2c 100644
--- a/kvmd/.bumpversion.cfg
+++ b/kvmd/.bumpversion.cfg
@@ -6,6 +6,10 @@ parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?)
serialize =
{major}.{minor}
+[bumpversion:file:kvmd/server.py]
+search = __version__ = "{current_version}"
+replace = __version__ = "{new_version}"
+
[bumpversion:file:setup.py]
search = version="{current_version}"
replace = version="{new_version}"
diff --git a/kvmd/kvmd/__init__.py b/kvmd/kvmd/__init__.py
index f21c1d90..c1e3dc3d 100644
--- a/kvmd/kvmd/__init__.py
+++ b/kvmd/kvmd/__init__.py
@@ -13,6 +13,10 @@ from . import gpio
# =====
+from .server import __version__ # noqa: F401
+
+
+# =====
def main() -> None:
config = init()
with gpio.bcm():
diff --git a/kvmd/kvmd/server.py b/kvmd/kvmd/server.py
index 5eaaaba6..d20ef9b9 100644
--- a/kvmd/kvmd/server.py
+++ b/kvmd/kvmd/server.py
@@ -1,6 +1,8 @@
import os
import signal
import asyncio
+import platform
+import functools
import json
import time
@@ -27,6 +29,21 @@ from .logging import get_logger
# =====
+__version__ = "0.37"
+
+
+def _get_system_info() -> Dict[str, Dict[str, str]]:
+ return {
+ "version": {
+ "platform": platform.platform(),
+ "python": platform.python_version(),
+ "kvmd": __version__,
+ },
+ }
+
+
+# =====
def _system_task(method: Callable) -> Callable:
async def wrap(self: "Server") -> None:
try:
@@ -116,6 +133,8 @@ class Server: # pylint: disable=too-many-instance-attributes
app = aiohttp.web.Application(loop=self.__loop)
+ app.router.add_get("/info", self.__info_handler)
+
app.router.add_get("/ws", self.__ws_handler)
app.router.add_get("/hid", self.__hid_state_handler)
@@ -142,6 +161,9 @@ class Server: # pylint: disable=too-many-instance-attributes
aiohttp.web.run_app(app, host=host, port=port, print=self.__run_app_print)
+ async def __info_handler(self, _: aiohttp.web.Request) -> aiohttp.web.WebSocketResponse:
+ return _json(_get_system_info())
+
async def __ws_handler(self, request: aiohttp.web.Request) -> aiohttp.web.WebSocketResponse:
logger = get_logger(0)
ws = aiohttp.web.WebSocketResponse(heartbeat=self.__heartbeat)
diff --git a/kvmd/web/css/main.css b/kvmd/web/css/main.css
index e0d1d91b..11bd14a2 100644
--- a/kvmd/web/css/main.css
+++ b/kvmd/web/css/main.css
@@ -258,3 +258,27 @@ div#msd-progress span#msd-progress-value {
display: inline-block;
height: 100%;
}
+
+ul#bottom {
+ list-style-type: none;
+ bottom: 0;
+ position: fixed;
+ width: 100%;
+ padding: 0;
+ font-size: 0.7em;
+ color: var(--fg-color-inactive);
+ z-index: -1;
+}
+ul#bottom li {
+ padding: 0 10px;
+}
+ul#bottom li.bottom-left {
+ float: left;
+}
+ul#bottom li.bottom-right {
+ float: right;
+}
+ul#bottom li a {
+ text-decoration: underline dotted;
+ color: var(--fg-color-inactive);
+}
diff --git a/kvmd/web/index.html b/kvmd/web/index.html
index 17538d2b..1e65ec78 100644
--- a/kvmd/web/index.html
+++ b/kvmd/web/index.html
@@ -160,5 +160,10 @@
<img src="/streamer/?action=stream" id="stream-image" class="stream-image-inactive" alt="Loading..." />
</div>
</div>
+
+ <ul id="bottom">
+ <li id="kvmd-version" class="bottom-left"></li>
+ <li class="bottom-right"><a target="_blank" href="https://github.com/mdevaev/pi-kvm">Pi-KVM Project</a></li>
+ </ul>
</body>
</html>
diff --git a/kvmd/web/js/main.js b/kvmd/web/js/main.js
index 51c6eae7..f33c7203 100644
--- a/kvmd/web/js/main.js
+++ b/kvmd/web/js/main.js
@@ -1,5 +1,6 @@
function main () {
window.onclick = ui.windowClickHandler;
+ session.loadKvmdVersion();
session.startPoller();
stream.startPoller();
}
diff --git a/kvmd/web/js/session.js b/kvmd/web/js/session.js
index 33c8af60..de2bd2a9 100644
--- a/kvmd/web/js/session.js
+++ b/kvmd/web/js/session.js
@@ -3,6 +3,18 @@ var session = new function() {
var __ping_timer = null;
var __missed_heartbeats = 0;
+ this.loadKvmdVersion = function() {
+ var http = tools.makeRequest("GET", "/kvmd/info", function() {
+ if (http.readyState === 4) {
+ if (http.status === 200) {
+ $("kvmd-version").innerHTML = "kvmd " + JSON.parse(http.responseText).result.version.kvmd;
+ } else {
+ setTimeout(session.loadKvmdVersion, 1000);
+ }
+ }
+ });
+ };
+
this.startPoller = function() {
__ws = new WebSocket("ws://" + location.host + "/kvmd/ws");
__ws.onopen = __wsOpenHandler;