diff --git a/src/assets/css/filesystem.css b/src/assets/css/filesystem.css
index 260cf0ad0fe4aa7288487c9f4585ffef2e5dbb40..f3c7e8dd26988c43ab2c47afc0464686411848ed 100644
--- a/src/assets/css/filesystem.css
+++ b/src/assets/css/filesystem.css
@@ -30,6 +30,7 @@ div#fs_disp_container {
grid-template-columns: repeat(auto-fill, minmax(8.5vh, 1fr));
grid-auto-rows: 8.5vh;
grid-gap: 1vh;
+ box-sizing: border-box;
}
div#fs_disp_container > * {
@@ -76,8 +77,21 @@ div#fs_disp_container > * > h3 {
overflow: hidden;
}
-div.fs_disp_up > svg {
+div#fs_disp_container.disks {
+ display: flex;
+ align-items: center;
+ justify-content: space-evenly;
+ border: 0.4vh double rgba(var(--color_r), var(--color_g), var(--color_b), 0.8);
+}
+div#fs_disp_container.disks > * {
+ width: auto;
+ max-width: 8vw;
+}
+
+div.fs_disp_showDisks > svg, div.fs_disp_up > svg {
width: 4vh !important;
+ margin-bottom: 0.5vh;
+ margin-top: 0.5vh;
}
div.fs_disp_file > h3 {
@@ -97,6 +111,33 @@ div#fs_space_bar {
left: .15vw;
}
+div#fs_space_bar > h1 {
+ display: none;
+
+ background: rgba(var(--color_r), var(--color_g), var(--color_b), 0.1);
+ height: 3.2vh;
+ width: 100%;
+ position: relative;
+ bottom: .7vh;
+ left: .3vh;
+ align-items: center;
+ justify-content: center;
+ box-sizing: border-box;
+ border: 2px solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.5);
+ border-radius: 2px;
+ font-family: var(--font_main);
+ font-weight: bold;
+ font-size: 1.5vh;
+ cursor: pointer;
+}
+
+div#fs_disp_container.disks+div#fs_space_bar > h1 {
+ display: flex;
+}
+div#fs_disp_container.disks+div#fs_space_bar > *:not(h1) {
+ display: none;
+}
+
div#fs_space_bar > h3 {
width: 30%;
margin: 0;
diff --git a/src/classes/filesystem.class.js b/src/classes/filesystem.class.js
index c613d69216128f2112e0c6e85d52b310daf88a06..549a6236872ef3ccebca957da06b1577348d2474 100644
--- a/src/classes/filesystem.class.js
+++ b/src/classes/filesystem.class.js
@@ -7,11 +7,15 @@ class FilesystemDisplay {
this.cwd = [];
this.iconcolor = `rgb(${window.theme.r}, ${window.theme.g}, ${window.theme.b})`;
this.icons = {
+ showDisks: ``,
up: ``,
dir: ``,
symlink: ``,
file: ``,
other: ``,
+ disk: ``,
+ rom: ``,
+ usb: ``,
edex: {
theme: ``,
themesDir: ``,
@@ -27,6 +31,7 @@ class FilesystemDisplay {
+
EXIT DISPLAY
Calculating available space...
`;
this.filesContainer = document.getElementById("fs_disp_container");
@@ -123,9 +128,14 @@ class FilesystemDisplay {
i++;
if (i === content.length) {
+ this.cwd.push({
+ name: "Show disks",
+ type: "showDisks"
+ });
+
if (tcwd !== "/" && tcwd !== "\\") {
this.cwd.push({
- name: "..",
+ name: "Go up",
type: "up"
});
}
@@ -192,7 +202,7 @@ class FilesystemDisplay {
});
this.dirpath = tcwd;
- this.render();
+ this.render(this.cwd);
});
}
}
@@ -202,16 +212,40 @@ class FilesystemDisplay {
});
};
- this.render = () => {
+ this.readDevices = () => {
+ if (this.failed === true) return false;
+ window.si.blockDevices().then(blocks => {
+ let devices = [];
+ blocks.forEach(block => {
+ if (fs.existsSync(block.mount)) {
+ let type = (block.type === "rom") ? "rom" : "disk";
+ if (block.removable && block.type !== "rom") {
+ type = "usb";
+ }
+
+ devices.push({
+ name: (block.label !== "") ? `${block.label} (${block.name})` : `${block.mount} (${block.name})`,
+ type,
+ path: block.mount
+ });
+ }
+ });
+
+ this.render(devices);
+ });
+ };
+
+ this.render = (blockList) => {
if (this.failed === true) return false;
document.getElementById("fs_disp_title_dir").innerText = this.dirpath;
+ this.filesContainer.setAttribute("class", "");
if (this._noTracking) {
document.querySelector("section#filesystem > h3.title > p:first-of-type").innerText = "FILESYSTEM - TRACKING FAILED, RUNNING DETACHED FROM TTY";
}
let filesDOM = ``;
- this.cwd.forEach(e => {
+ blockList.forEach(e => {
let hidden = "";
if (e.name.startsWith(".")) {
hidden = " hidden";
@@ -222,6 +256,10 @@ class FilesystemDisplay {
cmd = `window.term[window.currentTerm].writelr('cd \\'${e.name.replace("\\", "\\\\")}\\'')`;
}
+ if (e.type === "up") {
+ cmd = `window.term[window.currentTerm].writelr('cd ..')`;
+ }
+
if (e.type === "up" && this._noTracking) {
cmd = `window.fsDisp.readFS('${path.resolve(this.dirpath, '..').replace(/\\/g, '\\\\')}')`;
}
@@ -229,6 +267,21 @@ class FilesystemDisplay {
cmd = `window.fsDisp.readFS('${path.resolve(this.dirpath, e.name).replace(/\\/g, '\\\\')}')`;
}
+ if (e.type === "showDisks") {
+ cmd = `window.fsDisp.readDevices()`;
+ }
+
+ if (e.type === "disk" || e.type === "rom" || e.type === "usb") {
+ let extraSwitch = (process.platform === "win32") ? " /D" : "";
+ cmd = `window.term[window.currentTerm].writelr('cd${extraSwitch} \\'${e.path.replace("\\", "\\\\")}\\'')`;
+
+ document.getElementById("fs_disp_title_dir").innerText = "Showing available block devices";
+ this.filesContainer.setAttribute("class", "disks");
+ }
+ if ((e.type === "disk" || e.type === "rom" || e.type === "usb") && this._noTracking) {
+ cmd = `window.fsDisp.readFS('${e.path.replace(/\\/g, '\\\\')}')`;
+ }
+
if (e.type === "edex-theme") {
cmd = `window.themeChanger('${e.name.slice(0, -5)}')`;
}
@@ -241,6 +294,9 @@ class FilesystemDisplay {
let icon = "";
switch(e.type) {
+ case "showDisks":
+ icon = this.icons.showDisks;
+ break;
case "up":
icon = this.icons.up;
break;
@@ -253,6 +309,15 @@ class FilesystemDisplay {
case "file":
icon = this.icons.file;
break;
+ case "disk":
+ icon = this.icons.disk;
+ break;
+ case "rom":
+ icon = this.icons.rom;
+ break;
+ case "usb":
+ icon = this.icons.usb;
+ break;
case "edex-theme":
icon = this.icons.edex.theme;
break;
@@ -280,18 +345,27 @@ class FilesystemDisplay {
});
this.filesContainer.innerHTML = filesDOM;
- // See #226
- if (!isNaN(this.fsBlock.use)) {
- this.space_bar.text.innerHTML = `Mount ${this.fsBlock.mount} used ${Math.round(this.fsBlock.use)}%`;
- this.space_bar.bar.value = Math.round(this.fsBlock.use);
- } else if (!isNaN((this.fsBlock.size / this.fsBlock.used) * 100)) {
- let usage = Math.round((this.fsBlock.size / this.fsBlock.used) * 100);
-
- this.space_bar.text.innerHTML = `Mount ${this.fsBlock.mount} used ${usage}%`;
- this.space_bar.bar.value = usage;
+ if (this.filesContainer.getAttribute("class").endsWith("disks")) {
+ document.getElementById("fs_space_bar").setAttribute("onclick", "window.fsDisp.render(window.fsDisp.cwd)");
} else {
- this.space_bar.text.innerHTML = "Could not calculate mountpoint usage.";
- this.space_bar.bar.value = 100;
+ document.getElementById("fs_space_bar").setAttribute("onclick", "");
+
+ let splitter = (process.platform === "win32") ? "\\" : "/";
+ let displayMount = (this.fsBlock.mount.length < 18) ? this.fsBlock.mount : "..."+splitter+this.fsBlock.mount.split(splitter).pop();
+
+ // See #226
+ if (!isNaN(this.fsBlock.use)) {
+ this.space_bar.text.innerHTML = `Mount ${displayMount} used ${Math.round(this.fsBlock.use)}%`;
+ this.space_bar.bar.value = Math.round(this.fsBlock.use);
+ } else if (!isNaN((this.fsBlock.size / this.fsBlock.used) * 100)) {
+ let usage = Math.round((this.fsBlock.size / this.fsBlock.used) * 100);
+
+ this.space_bar.text.innerHTML = `Mount ${displayMount} used ${usage}%`;
+ this.space_bar.bar.value = usage;
+ } else {
+ this.space_bar.text.innerHTML = "Could not calculate mountpoint usage.";
+ this.space_bar.bar.value = 100;
+ }
}
};
}