Skip to content

Commit b423520

Browse files
authored
Merge pull request #6693 from RetiredWizard/sort_filemanager
Add filename sort to web workflow file manager
2 parents 7a5d2e8 + 0b286b7 commit b423520

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

supervisor/shared/web_workflow/static/directory.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ var current_path;
66
var editable = undefined;
77

88
async function refresh_list() {
9+
10+
function compareValues(a, b) {
11+
if (a.directory == b.directory && a.name.toLowerCase() === b.name.toLowerCase()) {
12+
return 0;
13+
} else {
14+
return a.directory.toString().substring(3,4)+a.name.toLowerCase() < b.directory.toString().substring(3,4)+b.name.toLowerCase() ? -1 : 1;
15+
}
16+
}
17+
918
current_path = window.location.hash.substr(1);
1019
if (current_path == "") {
1120
current_path = "/";
@@ -56,6 +65,8 @@ async function refresh_list() {
5665
new_children.push(clone);
5766
}
5867

68+
data.sort(compareValues);
69+
5970
for (const f of data) {
6071
// Clone the new row and insert it into the table
6172
var clone = template.content.cloneNode(true);
@@ -92,9 +103,11 @@ async function refresh_list() {
92103
delete_button.disabled = !editable;
93104
delete_button.onclick = del;
94105

95-
edit_url = new URL(edit_url, url_base);
96-
let edit_link = clone.querySelector(".edit_link");
97-
edit_link.href = edit_url
106+
if (editable && !f.directory) {
107+
edit_url = new URL(edit_url, url_base);
108+
let edit_link = clone.querySelector(".edit_link");
109+
edit_link.href = edit_url
110+
}
98111

99112
new_children.push(clone);
100113
}

0 commit comments

Comments
 (0)