diff options
author | Maxim Devaev <[email protected]> | 2023-03-18 03:40:57 +0200 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2023-03-18 03:40:57 +0200 |
commit | 03ce7bfd2c5823d623cae0f6d9dc2b712869583a (patch) | |
tree | c49ab52ab0dff7751a006c8840bc2177ca92d835 | |
parent | 18a8e5c9efadf4d95b06a5dbf08fa49182237b48 (diff) |
removed some msd api legacy
-rw-r--r-- | kvmd/plugins/msd/disabled.py | 5 | ||||
-rw-r--r-- | kvmd/plugins/msd/otg/__init__.py | 8 | ||||
-rw-r--r-- | web/kvm/index.html | 6 | ||||
-rw-r--r-- | web/kvm/navbar-msd.pug | 4 | ||||
-rw-r--r-- | web/share/js/kvm/msd.js | 28 |
5 files changed, 19 insertions, 32 deletions
diff --git a/kvmd/plugins/msd/disabled.py b/kvmd/plugins/msd/disabled.py index 1c96f077..3bfcd3c6 100644 --- a/kvmd/plugins/msd/disabled.py +++ b/kvmd/plugins/msd/disabled.py @@ -47,11 +47,6 @@ class Plugin(BaseMsd): "busy": False, "storage": None, "drive": None, - "features": { - "multi": False, - "cdrom": False, - "rw": False, - }, } async def poll_state(self) -> AsyncGenerator[dict, None]: diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py index 1f082480..9e759f54 100644 --- a/kvmd/plugins/msd/otg/__init__.py +++ b/kvmd/plugins/msd/otg/__init__.py @@ -173,8 +173,11 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes storage = dataclasses.asdict(self.__state.storage) for name in list(storage["images"]): + del storage["images"][name]["name"] del storage["images"][name]["path"] del storage["images"][name]["in_storage"] + for name in list(storage["parts"]): + del storage["parts"][name]["name"] storage["downloading"] = (self.__reader.get_state() if self.__reader else None) storage["uploading"] = (self.__writer.get_state() if self.__writer else None) @@ -191,11 +194,6 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes "busy": self.__state.is_busy(), "storage": storage, "drive": vd, - "features": { - "multi": True, - "cdrom": True, - "rw": True, - }, } async def poll_state(self) -> AsyncGenerator[dict, None]: diff --git a/web/kvm/index.html b/web/kvm/index.html index 568da0ec..b4dbb70b 100644 --- a/web/kvm/index.html +++ b/web/kvm/index.html @@ -476,7 +476,7 @@ </td> </tr> </table> - <table class="kv msd-cdrom-emulation feature-disabled"> + <table class="kv"> <tr> <td>Drive <a target="_blank" href="https://docs.pikvm.org/msd">mode</a>:</td> <td> @@ -488,8 +488,8 @@ </div> </td> <td> </td> - <td class="msd-rw feature-disabled">Writable:</td> - <td class="msd-rw feature-disabled" align="right"> + <td>Writable:</td> + <td align="right"> <div class="switch-box"> <input disabled type="checkbox" id="msd-rw-switch"> <label for="msd-rw-switch"><span class="switch-inner"></span><span class="switch"></span></label> diff --git a/web/kvm/navbar-msd.pug b/web/kvm/navbar-msd.pug index f668ae32..47ebcccb 100644 --- a/web/kvm/navbar-msd.pug +++ b/web/kvm/navbar-msd.pug @@ -39,7 +39,7 @@ li(id="msd-dropdown" class="right feature-disabled") td(width="100%") #[select(disabled id="msd-image-selector")] td #[button(disabled id="msd-download-button" title="Download image") 🖪 ] td #[button(disabled id="msd-remove-button" title="Remove image") #[b × ]] - table(class="kv msd-cdrom-emulation feature-disabled") + table(class="kv") tr td Drive #[a(target="_blank" href="https://docs.pikvm.org/msd") mode]: td @@ -49,7 +49,7 @@ li(id="msd-dropdown" class="right feature-disabled") input(type="radio" id="msd-mode-radio-flash" name="msd-mode-radio" value="0") label(for="msd-mode-radio-flash") Flash td - +menu_switch_notable("msd-rw-switch", "Writable", false, false, "msd-rw feature-disabled") + +menu_switch_notable("msd-rw-switch", "Writable", false, false) hr div(class="text") div(id="msd-storage-progress" class="progress") diff --git a/web/share/js/kvm/msd.js b/web/share/js/kvm/msd.js index 6b8d33b2..75fa6dfb 100644 --- a/web/share/js/kvm/msd.js +++ b/web/share/js/kvm/msd.js @@ -215,8 +215,8 @@ export function Msd() { let file = tools.input.getFile($("msd-new-file")); if (file) { $("msd-new-url").value = ""; - if (file.size > __state.storage.size) { - wm.error("New image is too big for your Mass Storage Drive.<br>Maximum:", tools.formatSize(__state.storage.size)); + if (file.size > __state.storage.parts[""].size) { + wm.error("New image is too big for your Mass Storage Drive.<br>Maximum:", tools.formatSize(__state.storage.parts[""].size)); el_input.value = ""; } } @@ -238,10 +238,10 @@ export function Msd() { let online = (s && s.online); if (online) { - let size_str = tools.formatSize(s.storage.size); - let used = s.storage.size - s.storage.free; + let size_str = tools.formatSize(s.storage.parts[""].size); + let used = s.storage.parts[""].size - s.storage.parts[""].free; let used_str = tools.formatSize(used); - let percent = used / s.storage.size * 100; + let percent = used / s.storage.parts[""].size * 100; tools.progress.setValue($("msd-storage-progress"), `Storage: ${used_str} of ${size_str}`, percent); } else { tools.progress.setValue($("msd-storage-progress"), "Storage: unavailable", 0); @@ -252,11 +252,11 @@ export function Msd() { tools.el.setEnabled($("msd-download-button"), (online && s.drive.image && !s.drive.connected && !s.busy)); tools.el.setEnabled($("msd-remove-button"), (online && s.drive.image && s.drive.image.removable && !s.drive.connected && !s.busy)); - tools.radio.setEnabled("msd-mode-radio", (online && s.features.cdrom && !s.drive.connected && !s.busy)); - tools.radio.setValue("msd-mode-radio", `${Number(online && s.features.cdrom && s.drive.cdrom)}`); + tools.radio.setEnabled("msd-mode-radio", (online && !s.drive.connected && !s.busy)); + tools.radio.setValue("msd-mode-radio", `${Number(online && s.drive.cdrom)}`); - tools.el.setEnabled($("msd-rw-switch"), (online && s.features.rw && !s.drive.connected && !s.busy)); - $("msd-rw-switch").checked = (online && s.features.rw && s.drive.rw); + tools.el.setEnabled($("msd-rw-switch"), (online && !s.drive.connected && !s.busy)); + $("msd-rw-switch").checked = (online && s.drive.rw); tools.el.setEnabled($("msd-connect-button"), (online && s.drive.image && !s.drive.connected && !s.busy)); tools.el.setEnabled($("msd-disconnect-button"), (online && s.drive.connected && !s.busy)); @@ -295,23 +295,17 @@ export function Msd() { if (s) { tools.feature.setEnabled($("msd-dropdown"), s.enabled); tools.feature.setEnabled($("msd-reset-button"), s.enabled); - for (let el of $$$(".msd-cdrom-emulation")) { - tools.feature.setEnabled(el, s.features.cdrom); - } - for (let el of $$$(".msd-rw")) { - tools.feature.setEnabled(el, s.features.rw); - } } tools.hidden.setVisible($("msd-message-offline"), (s && !s.online)); tools.hidden.setVisible($("msd-message-image-broken"), (online && s.drive.image && !s.drive.image.complete && !s.storage.uploading)); tools.hidden.setVisible($("msd-message-too-big-for-cdrom"), - (online && s.features.cdrom && s.drive.cdrom && s.drive.image && s.drive.image.size >= 2359296000)); + (online && s.drive.cdrom && s.drive.image && s.drive.image.size >= 2359296000)); tools.hidden.setVisible($("msd-message-out-of-storage"), (online && s.drive.image && !s.drive.image.in_storage)); tools.hidden.setVisible($("msd-message-rw-enabled"), - (online && s.features.rw && s.drive.rw)); + (online && s.drive.rw)); tools.hidden.setVisible($("msd-message-another-user-uploads"), (online && s.storage.uploading && !__http)); tools.hidden.setVisible($("msd-message-downloads"), |