From 8209ee2eb0bd411c74d7d7dbf7b1b79e46dd79c0 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Mon, 23 Sep 2024 02:32:38 +0300 Subject: improved wm dialogs --- web/share/js/kvm/msd.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'web/share/js/kvm/msd.js') diff --git a/web/share/js/kvm/msd.js b/web/share/js/kvm/msd.js index 88491a23..3885bd50 100644 --- a/web/share/js/kvm/msd.js +++ b/web/share/js/kvm/msd.js @@ -86,11 +86,11 @@ export function Msd() { var __clickRemoveButton = function() { let name = $("msd-image-selector").value; - wm.confirm(`Are you sure you want to remove the image
${tools.escape(name)} from PiKVM?`).then(function(ok) { + wm.confirm("Are you sure you want to remove this image?", name).then(function(ok) { if (ok) { tools.httpPost("/api/msd/remove", {"image": name}, function(http) { if (http.status !== 200) { - wm.error("Can't remove image:
", http.responseText); + wm.error("Can't remove image", http.responseText); } }); } @@ -100,7 +100,7 @@ export function Msd() { var __sendParam = function(name, value) { tools.httpPost("/api/msd/set_params", {[name]: value}, function(http) { if (http.status !== 200) { - wm.error("Can't configure MSD:
", http.responseText); + wm.error("Can't configure Mass Storage", http.responseText); } }); }; @@ -124,8 +124,9 @@ export function Msd() { var __httpStateChange = function() { if (__http.readyState === 4) { if (__http.status !== 200) { - wm.error("Can't upload image to the Mass Storage Drive:
", __http.responseText); + wm.error("Can't upload image", __http.responseText); } else if ($("msd-new-url").value.length > 0) { + let html = ""; let msg = ""; try { let end = __http.responseText.lastIndexOf("\r\n"); @@ -139,13 +140,15 @@ export function Msd() { let result_str = __http.responseText.slice(begin, end); let result = JSON.parse(result_str); if (!result.ok) { - msg = `Can't upload image to the Mass Storage Drive:
${result_str}`; + html = "Can't upload image"; + msg = result_str; } } catch (ex) { - msg = `Can't parse upload result:
${ex}`; + html = "Can't parse upload result"; + msg = `${ex}`; } - if (msg.length > 0) { - wm.error(msg); + if (html.length > 0) { + wm.error(html, msg); } } tools.hidden.setVisible($("msd-new-sub"), false); @@ -166,7 +169,7 @@ export function Msd() { var __clickConnectButton = function(connected) { tools.httpPost("/api/msd/set_connected", {"connected": connected}, function(http) { if (http.status !== 200) { - wm.error("Switch error:
", http.responseText); + wm.error("Can't switch Mass Storage", http.responseText); } __applyState(); }); @@ -175,11 +178,11 @@ export function Msd() { }; var __clickResetButton = function() { - wm.confirm("Are you sure you want to reset Mass Storage Drive?").then(function(ok) { + wm.confirm("Are you sure you want to reset Mass Storage?").then(function(ok) { if (ok) { tools.httpPost("/api/msd/reset", null, function(http) { if (http.status !== 200) { - wm.error("MSD reset error:
", http.responseText); + wm.error("Mass Storage reset error", http.responseText); } __applyState(); }); @@ -206,7 +209,7 @@ export function Msd() { $("msd-new-url").value = ""; let part = __state.storage.parts[$("msd-new-part-selector").value]; if (file.size > part.size) { - wm.error("New image is too big for the MSD partition.
Maximum:", tools.formatSize(part.size)); + wm.error(`New image is too big for the Mass Storage partition.
Maximum: ${tools.formatSize(part.size)}`); el_input.value = ""; } } -- cgit v1.2.3