=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-cache-cleaner/i18n/i18n_app.properties' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-cache-cleaner/i18n/i18n_app.properties 2015-01-20 13:24:53 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-cache-cleaner/i18n/i18n_app.properties 2015-03-27 14:04:01 +0000 @@ -9,6 +9,7 @@ account=Account log_out=Log out about_dhis2=About DHIS 2 +session_storage=Session Storage local_storage=Local Storage indexed_db=IndexedDB clearing_dhis2_browser_cache=DHIS 2 browser cache cleaner @@ -19,5 +20,6 @@ clearing_cache=Clearing cache proceed=Proceed select_all=Select all +unselect_all=Unselect all cancel=Cancel clear=Clear \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-cache-cleaner/index.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-cache-cleaner/index.html 2015-02-02 13:42:37 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-cache-cleaner/index.html 2015-03-27 14:04:01 +0000 @@ -20,32 +20,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -86,7 +61,19 @@ -
+
+

{{'session_storage'| translate}}

+ + + + + +
+ {{ssKey.id}} + + +
+

{{'local_storage'| translate}}

@@ -99,8 +86,8 @@
-

{{'indexed_db'| translate}}

- +

{{'indexed_db'| translate}}

+
{{dbKey.id}} @@ -113,10 +100,10 @@ {{'clear'| translate}} - {{'select_all'| translate}} + {{ (ssKeys | filter: {remove: true}).length > 0 || (lsKeys | filter: {remove: true}).length > 0 || (dbKeys | filter: {remove: true}).length > 0 ? 'unselect_all' : 'select_all' | translate}} -
+
{{ afterClearing ? 'cache_cleared' : 'nothing_to_clear' | translate}}
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-cache-cleaner/scripts/controllers.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-cache-cleaner/scripts/controllers.js 2015-02-03 15:59:38 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-cache-cleaner/scripts/controllers.js 2015-03-27 14:04:01 +0000 @@ -1,3 +1,5 @@ +/* global angular */ + 'use strict'; /* Controllers */ @@ -11,12 +13,19 @@ var getItemsToClear = function(){ $scope.lsCacheExists = false; - $scope.idxCacheExists = false; - - $scope.lsKeys = [], $scope.dbKeys = []; - - var reservedLocalStorageKeys = ['key', 'getItem', 'setItem', 'removeItem', 'clear', 'length']; - + $scope.ssCacheExists = false; + $scope.idCacheExists = false; + + $scope.lsKeys = []; + $scope.dbKeys = []; + $scope.ssKeys = []; + + for(var key in $window.sessionStorage){ + $scope.ssKeys.push({id: key, remove: false}); + $scope.ssCacheExists = true; + } + + var reservedLocalStorageKeys = ['key', 'getItem', 'setItem', 'removeItem', 'clear', 'length']; for(var key in $window.localStorage){ if(reservedLocalStorageKeys.indexOf(key) === -1) { @@ -30,7 +39,7 @@ idbStorageService.dbExists(db).then(function(res){ if( res ){ $scope.dbKeys.push({id: db, remove: false}); - $scope.idxCacheExists = true; + $scope.idCacheExists = true; } }); }); @@ -48,6 +57,14 @@ }; ModalService.showModal({}, modalOptions).then(function(){ + + angular.forEach($scope.ssKeys, function(ssKey){ + if(ssKey.remove){ + $window.sessionStorage.removeItem(ssKey.id); + console.log('removed from session storage: ', ssKey.id); + } + }); + angular.forEach($scope.lsKeys, function(lsKey){ if(lsKey.remove){ storage.remove(lsKey.id); @@ -63,23 +80,26 @@ } else{ console.log('failed to remove from indexeddb: ', dbKey.id); - } - + } }); } - }); + }); $scope.afterClearing = true; getItemsToClear(); }); }; $scope.selectAll = function(){ + angular.forEach($scope.ssKeys, function(ssKey){ + ssKey.remove = !ssKey.remove; + }); + angular.forEach($scope.lsKeys, function(lsKey){ - lsKey.remove = true; + lsKey.remove = !lsKey.remove; }); angular.forEach($scope.dbKeys, function(dbKey){ - dbKey.remove = true; + dbKey.remove = !dbKey.remove; }); }; }); \ No newline at end of file