From eecb19ecf64ef76035124d3ee0d69b5b58d21b55 Mon Sep 17 00:00:00 2001 From: Dale Price Date: Sat, 2 Mar 2013 22:56:58 -0600 Subject: [PATCH] store file sorting options in the browser's LocalStorage --- octoprint/static/js/ui.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/octoprint/static/js/ui.js b/octoprint/static/js/ui.js index b1c30ad..629b281 100644 --- a/octoprint/static/js/ui.js +++ b/octoprint/static/js/ui.js @@ -622,6 +622,15 @@ function GcodeFilesViewModel() { self.currentPage = ko.observable(0); self.currentSorting = ko.observable("name"); self.currentFilters = ko.observableArray([]); + + if( localStorage["currentSorting"] ) + self.currentSorting( localStorage["currentSorting"] ); + + if( localStorage["filterPrinted"] == 1 ) { + var filters = self.currentFilters(); + filters.push("printed"); + self.currentFilters(_.uniq(filters)); + } self.paginatedFiles = ko.dependentObservable(function() { if (self.files() == undefined) { @@ -742,6 +751,7 @@ function GcodeFilesViewModel() { return; self.currentSorting(sorting); + localStorage["currentSorting"] = self.currentSorting(); //store setting in local storage self._updateFiles(); } @@ -760,6 +770,7 @@ function GcodeFilesViewModel() { var filters = self.currentFilters(); filters.push(filter); self.currentFilters(_.uniq(filters)); + localStorage["filterPrinted"] = 1; self._updateFiles(); } @@ -768,6 +779,7 @@ function GcodeFilesViewModel() { return; self.currentFilters(_.without(self.currentFilters(), filter)); + localStorage["filterPrinted"] = 0; self._updateFiles(); }