From 965e649f8cd024dd054ed33dd2ba0f98b508c8ae Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Sat, 11 Jan 2025 22:20:56 +0200 Subject: switch update notification --- kvmd/apps/kvmd/switch/state.py | 3 +++ web/kvm/index.html | 14 ++++++++++++++ web/kvm/navbar-switch.pug | 4 ++++ web/share/js/kvm/switch.js | 4 ++++ 4 files changed, 25 insertions(+) diff --git a/kvmd/apps/kvmd/switch/state.py b/kvmd/apps/kvmd/switch/state.py index 626cdfe1..e49d0062 100644 --- a/kvmd/apps/kvmd/switch/state.py +++ b/kvmd/apps/kvmd/switch/state.py @@ -49,6 +49,8 @@ class _UnitInfo: # ===== class StateCache: # pylint: disable=too-many-instance-attributes + __FW_VERSION = 5 + __FULL = 0xFFFF __SUMMARY = 0x01 __EDIDS = 0x02 @@ -139,6 +141,7 @@ class StateCache: # pylint: disable=too-many-instance-attributes state: dict = {} if x_model: state["model"] = { + "firmware": {"version": self.__FW_VERSION}, "units": [], "ports": [], "limits": { diff --git a/web/kvm/index.html b/web/kvm/index.html index c6d3301d..713e1c84 100644 --- a/web/kvm/index.html +++ b/web/kvm/index.html @@ -904,6 +904,20 @@
+ diff --git a/web/kvm/navbar-switch.pug b/web/kvm/navbar-switch.pug index 455daa6f..ef8bfab4 100644 --- a/web/kvm/navbar-switch.pug +++ b/web/kvm/navbar-switch.pug @@ -14,6 +14,10 @@ li(id="switch-dropdown" class="right feature-disabled") div(class="text") button(data-force-hide-menu data-show-window="switch-window" class="small") • Settings hr + div(id="switch-message-update" class="hidden") + +menu_message("info", "Good news! Your switch is ready to get the firmware update") + | Please #[a(target="_blank" href="https://docs.pikvm.org/switch/#firmware-updating") follow the instructions] when you decide to install it. + hr +menu_switch("switch-atx-ask-switch", "Ask ATX click confirmation", true, true) hr table(id="switch-chain" class="kv") diff --git a/web/share/js/kvm/switch.js b/web/share/js/kvm/switch.js index 112d8f15..bd33a781 100644 --- a/web/share/js/kvm/switch.js +++ b/web/share/js/kvm/switch.js @@ -406,6 +406,10 @@ export function Switch() { } $("switch-chain").innerHTML = content; + if (model.units.length > 0) { + tools.hidden.setVisible($("switch-message-update"), (model.firmware.version > model.units[0].firmware.version)); + } + for (let unit = 0; unit < model.units.length; ++unit) { tools.el.setOnClick($(`__switch-beacon-button-u${unit}`), tools.partial(__switchUplinkBeacon, unit)); tools.el.setOnClick($(`__switch-beacon-button-d${unit}`), tools.partial(__switchDownlinkBeacon, unit)); -- cgit v1.2.3
Ask ATX click confirmation: