reading images api

This commit is contained in:
Maxim Devaev
2022-07-23 18:34:58 +03:00
parent de14053725
commit 0e3ebac362
10 changed files with 145 additions and 2 deletions

View File

@@ -419,6 +419,9 @@
<td width="100%">
<select disabled id="msd-image-selector"></select>
</td>
<td>
<button disabled id="msd-download-button" title="Download image">&nbsp;&nbsp;&#128426;&nbsp;&nbsp;</button>
</td>
<td>
<button disabled id="msd-remove-button" title="Remove image"><b>&nbsp;&nbsp;&times;&nbsp;&nbsp;</b></button>
</td>

View File

@@ -37,6 +37,7 @@ li(id="msd-dropdown" class="right feature-disabled")
tr
td Image:
td(width="100%") #[select(disabled id="msd-image-selector")]
td #[button(disabled id="msd-download-button" title="Download image") &nbsp;&nbsp;&#128426;&nbsp;&nbsp;]
td #[button(disabled id="msd-remove-button" title="Remove image") #[b &nbsp;&nbsp;&times;&nbsp;&nbsp;]]
table(class="kv msd-cdrom-emulation feature-disabled")
tr

View File

@@ -39,6 +39,7 @@ export function Msd() {
$("msd-led").title = "Unknown state";
$("msd-image-selector").onchange = __selectImage;
tools.el.setOnClick($("msd-download-button"), __clickDownloadButton);
tools.el.setOnClick($("msd-remove-button"), __clickRemoveButton);
tools.radio.setOnClick("msd-mode-radio", __clickModeRadio);
@@ -67,10 +68,16 @@ export function Msd() {
var __selectImage = function() {
tools.el.setEnabled($("msd-image-selector"), false);
tools.el.setEnabled($("msd-download-button"), false);
tools.el.setEnabled($("msd-remove-button"), false);
__sendParam("image", $("msd-image-selector").value);
};
var __clickDownloadButton = function() {
let name = $("msd-image-selector").value;
window.open(`/api/msd/read?image=${name}`);
};
var __clickRemoveButton = function() {
let name = $("msd-image-selector").value;
wm.confirm(`Are you sure you want to remove the image<br><b>${name}</b> from PiKVM?`).then(function(ok) {
@@ -244,6 +251,7 @@ export function Msd() {
tools.el.setEnabled($("msd-image-selector"), (online && s.features.multi && !s.drive.connected && !s.busy));
__applyStateImageSelector();
tools.el.setEnabled($("msd-download-button"), (online && s.features.multi && s.drive.image && !s.drive.connected && !s.busy));
tools.el.setEnabled($("msd-remove-button"), (online && s.features.multi && s.drive.image && !s.drive.connected && !s.busy));
tools.radio.setEnabled("msd-mode-radio", (online && s.features.cdrom && !s.drive.connected && !s.busy));