🐛 Persist file list style in local storage
It's not a regular sorting option, so it so far got skipped. See https://community.octoprint.org/t/file-list-sort-by-defaults/18938
This commit is contained in:
1 parent
a96167729c
commit
d97fdb5ce8
1 file changed
+28
-1
@@ -82,10 +82,37 @@ $(function() {
|
||||
});
|
||||
|
||||
self.allItems = ko.observable(undefined);
|
||||
self.listStyle = ko.observable("folders_files");
|
||||
self.currentPath = ko.observable("");
|
||||
self.uploadProgressText = ko.observable();
|
||||
|
||||
// list style incl. persistence
|
||||
var listStyleStorageKey = "gcodeFiles.currentListStyle";
|
||||
var defaultListStyle = "folders_files";
|
||||
var saveListStyleToLocalStorage = function() {
|
||||
if (initListStyleLocalStorage()) {
|
||||
localStorage[listStyleStorageKey] = self.listStyle();
|
||||
}
|
||||
};
|
||||
var loadListStyleFromLocalStorage = function() {
|
||||
if (initListStyleLocalStorage()) {
|
||||
self.listStyle(localStorage[listStyleStorageKey]);
|
||||
}
|
||||
};
|
||||
var initListStyleLocalStorage = function() {
|
||||
if (!Modernizr.localstorage)
|
||||
return false;
|
||||
|
||||
if (localStorage[listStyleStorageKey] !== undefined)
|
||||
return true;
|
||||
|
||||
localStorage[listStyleStorageKey] = defaultListStyle;
|
||||
return true;
|
||||
};
|
||||
|
||||
self.listStyle = ko.observable(defaultListStyle);
|
||||
self.listStyle.subscribe(saveListStyleToLocalStorage);
|
||||
loadListStyleFromLocalStorage();
|
||||
|
||||
// initialize list helper
|
||||
var listHelperFilters = {
|
||||
"printed": function(data) {
|
||||
|
||||
Reference in new issue
Block a user