mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
show all parts in msd menu
This commit is contained in:
parent
4f70060d5e
commit
2392aa2330
@ -498,9 +498,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="text">
|
<div id="msd-storages"></div>
|
||||||
<div class="progress" id="msd-storage-progress"><span class="progress-value" id="msd-storage-progress-value"></span></div>
|
|
||||||
</div>
|
|
||||||
<hr>
|
<hr>
|
||||||
<div class="buttons buttons-row">
|
<div class="buttons buttons-row">
|
||||||
<button class="row50" disabled id="msd-select-new-button">Select image to upload</button>
|
<button class="row50" disabled id="msd-select-new-button">Select image to upload</button>
|
||||||
|
|||||||
@ -51,9 +51,7 @@ li(id="msd-dropdown" class="right feature-disabled")
|
|||||||
td
|
td
|
||||||
+menu_switch_notable("msd-rw-switch", "Writable", false, false)
|
+menu_switch_notable("msd-rw-switch", "Writable", false, false)
|
||||||
hr
|
hr
|
||||||
div(class="text")
|
div(id="msd-storages")
|
||||||
div(id="msd-storage-progress" class="progress")
|
|
||||||
span(id="msd-storage-progress-value" class="progress-value")
|
|
||||||
hr
|
hr
|
||||||
div(class="buttons buttons-row")
|
div(class="buttons buttons-row")
|
||||||
button(disabled id="msd-select-new-button" class="row50") Select image to upload
|
button(disabled id="msd-select-new-button" class="row50") Select image to upload
|
||||||
|
|||||||
@ -35,6 +35,10 @@ export function Msd() {
|
|||||||
var __state = null;
|
var __state = null;
|
||||||
var __http = null;
|
var __http = null;
|
||||||
|
|
||||||
|
var __parts_json = "";
|
||||||
|
var __parts = {};
|
||||||
|
var __parts_len = 0;
|
||||||
|
|
||||||
var __init__ = function() {
|
var __init__ = function() {
|
||||||
$("msd-led").title = "Unknown state";
|
$("msd-led").title = "Unknown state";
|
||||||
|
|
||||||
@ -243,9 +247,34 @@ export function Msd() {
|
|||||||
tools.hidden.setVisible($("msd-message-downloads"), (online && s.storage.downloading));
|
tools.hidden.setVisible($("msd-message-downloads"), (online && s.storage.downloading));
|
||||||
|
|
||||||
if (online) {
|
if (online) {
|
||||||
tools.progress.setSizeOf($("msd-storage-progress"), "Storage: %s", s.storage.parts[""].size, s.storage.parts[""].free);
|
let names = Object.keys(s.storage.parts).sort();
|
||||||
} else {
|
let parts_json = JSON.stringify(names);
|
||||||
tools.progress.setValue($("msd-storage-progress"), "Storage: unavailable", 0);
|
if (__parts_json !== parts_json) {
|
||||||
|
$("msd-storages").innerHTML = names.map(name => `
|
||||||
|
<div class="text">
|
||||||
|
<div id="msd-storage-${tools.makeIdByText(name)}-progress" class="progress">
|
||||||
|
<span class="progress-value"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`).join("<hr>");
|
||||||
|
__parts_json = parts_json;
|
||||||
|
__parts = s.storage.parts;
|
||||||
|
__parts_len = names.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let name in __parts) {
|
||||||
|
let part = __parts[name];
|
||||||
|
let title = (
|
||||||
|
name.length === 0
|
||||||
|
? `${__parts_len === 1 ? "Storage: %s" : "Internal storage: %s"}` // eslint-disable-line
|
||||||
|
: `Storage [${name}${part.writable ? "]" : ", read-only]"}: %s` // eslint-disable-line
|
||||||
|
);
|
||||||
|
let id = `msd-storage-${tools.makeIdByText(name)}-progress`;
|
||||||
|
if (online) {
|
||||||
|
tools.progress.setSizeOf($(id), title, part.size, part.free);
|
||||||
|
} else {
|
||||||
|
tools.progress.setValue($(id), title.replace("%s", "unavailable"), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tools.el.setEnabled($("msd-image-selector"), (online && !s.drive.connected && !s.busy));
|
tools.el.setEnabled($("msd-image-selector"), (online && !s.drive.connected && !s.busy));
|
||||||
|
|||||||
@ -66,6 +66,10 @@ export var tools = new function() {
|
|||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.makeIdByText = function(text) {
|
||||||
|
return btoa(text).replace("=", "_");
|
||||||
|
};
|
||||||
|
|
||||||
self.formatSize = function(size) {
|
self.formatSize = function(size) {
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
let index = Math.floor( Math.log(size) / Math.log(1024) );
|
let index = Math.floor( Math.log(size) / Math.log(1024) );
|
||||||
@ -298,7 +302,7 @@ export var tools = new function() {
|
|||||||
return {
|
return {
|
||||||
"setValue": function(el, title, percent) {
|
"setValue": function(el, title, percent) {
|
||||||
el.setAttribute("data-label", title);
|
el.setAttribute("data-label", title);
|
||||||
$(`${el.id}-value`).style.width = `${percent}%`;
|
el.querySelector(".progress-value").style.width = `${percent}%`;
|
||||||
},
|
},
|
||||||
"setPercentOf": function(el, max, value) {
|
"setPercentOf": function(el, max, value) {
|
||||||
let percent = Math.round(value * 100 / max);
|
let percent = Math.round(value * 100 / max);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user