Skip to content

fileman 0.04: Add submenu to display free space and to allow quick navigation with many files #3874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/fileman/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.01: New app!
0.02: Improve handling of large amounts of files (fix #579)
0.03: Update RegExp use (Was using backreference instead of character code)
0.04: Add submenu to display free space and to allow quick navigation with many files

37 changes: 32 additions & 5 deletions apps/fileman/fileman.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function delete_file(fn) {
}
else STOR.erase(fn);
}
}).then(function() { filed=[];files=get_pruned_file_list(); }).then(drawMenu);
}).then(function() { files=get_pruned_file_list(); }).then(drawMenu);
}

function get_length(fn) {
Expand Down Expand Up @@ -65,6 +65,30 @@ function visit_file(fn) {
E.showMenu(menu);
}

function showFree() {
var free = (require("Storage").getFree() / (1024*1024)).toFixed(2) + " MB\n";
E.showAlert(free).then( function() { drawMenu(); } );
}

function jumpTo(v) {
nstart = Math.round((v/100)*files.length);
if (nstart >= files.length) { nstart = 0; }
drawMenu();
}

function drawUtilMenu() {
var menu = {
'' : {'title' : "Utils"}
};
menu['Show free'] = showFree;
for (let i=0; i<10; i++) {
let v = i*10;
menu['Jump to '+v+'%'] = function() { jumpTo(v); };
}
menu['< Back'] = drawMenu;
E.showMenu(menu);
}

function drawMenu() {
nend = (nstart+n<files.length)?nstart+n : files.length;
var menu = {
Expand All @@ -75,16 +99,19 @@ function drawMenu() {
if (nstart<0) nstart = files.length-n>0 ? files.length-n : 0;
menu = {};
drawMenu();
}
for (var i=nstart; i<nend; ++i) {
menu[files[i]] = visit_file.bind(null, files[i]);
}
};
menu["> next"] = function() {
if (nstart+n<files.length) nstart += n;
else nstart = 0;
menu = {};
drawMenu();
m.move(-1);
};
menu["[utils...]"] = function() {
drawUtilMenu();
};
for (var i=nstart; i<nend; ++i) {
menu[files[i]] = visit_file.bind(null, files[i]);
}
m = E.showMenu(menu);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/fileman/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "fileman",
"name": "File manager",
"shortName": "FileManager",
"version": "0.03",
"version": "0.04",
"description": "Simple file manager, allows user to examine watch storage and display, load or delete individual files",
"icon": "icons8-filing-cabinet-48.png",
"tags": "tools",
Expand Down