Make app view tags and domain filter persistent

This is only stored in the browser's localStorage to survive a reload,
but is not stored on the server to be preserved across different clients
This commit is contained in:
Johannes Zellner
2020-01-06 16:23:31 +01:00
parent bc75a8e7b8
commit 129f67c9f8

View File

@@ -16,6 +16,19 @@ angular.module('Application').controller('AppsController', ['$scope', '$timeout'
$scope.domains = [];
$scope.appSearch = '';
$scope.$watch('selectedTags', function (newVal, oldVal) {
if (newVal === oldVal) return;
localStorage.selectedTags = newVal.join(',');
});
$scope.$watch('selectedDomain', function (newVal, oldVal) {
if (newVal === oldVal) return;
if (newVal._alldomains) localStorage.removeItem('selectedDomain');
else localStorage.selectedDomain = newVal.domain;
});
$scope.appPostInstallConfirm = {
app: {},
message: '',
@@ -61,6 +74,10 @@ angular.module('Application').controller('AppsController', ['$scope', '$timeout'
$scope.domains = result;
$scope.filterDomains = [ALL_DOMAINS_DOMAIN].concat(result);
// load local settings and apply
if (localStorage.selectedTags) $scope.selectedTags = localStorage.selectedTags.split(',');
if (localStorage.selectedDomain) $scope.selectedDomain = $scope.filterDomains.find(function (d) { return d.domain === localStorage.selectedDomain; }) || ALL_DOMAINS_DOMAIN;
setTimeout(function () { $('#appSearch').focus(); }, 1000);
});
});