← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18708: cache-cleaner: option to clear session storage

 

------------------------------------------------------------
revno: 18708
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-03-27 15:04:01 +0100
message:
  cache-cleaner: option to clear session storage
modified:
  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/index.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-cache-cleaner/scripts/controllers.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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 @@
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/angular-cookies.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/angular-animate.js"></script>  
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/ui-bootstrap-tpls-0.10.0-draggable-modal.js"></script>
-
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/moment/moment-with-langs.min.js"></script>       
-
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/underscore.min.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.util.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/commons.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/commons.ajax.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/lists.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/periodType.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/date.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/json2.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/validationRules.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.array.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.select.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.comparator.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.availability.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.trigger.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.sharing.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.validation.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.ss.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.ls.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>
 
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angularLocalStorage.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angular-translate.min.js"></script>
@@ -86,7 +61,19 @@
             <!-- top bar ends -->
 
 
-            <div class="row col-sm-4" ng-if="lsCacheExists || idxCacheExists">
+            <div class="row col-sm-6" ng-if="ssCacheExists || lsCacheExists || idCacheExists">
+                <h3 ng-if="ssCacheExists">{{'session_storage'| translate}}</h3>
+                <table class="table table-bordered table-striped" ng-if="ssCacheExists">
+                    <tr ng-repeat="ssKey in ssKeys">
+                        <td>
+                            {{ssKey.id}}
+                        </td>
+                        <td>
+                            <input type="checkbox" ng-model="ssKey.remove">
+                        </td>
+                    </tr>                                    
+                </table>
+                
                 <h3 ng-if="lsCacheExists">{{'local_storage'| translate}}</h3>
                 <table class="table table-bordered table-striped" ng-if="lsCacheExists">
                     <tr ng-repeat="lsKey in lsKeys">
@@ -99,8 +86,8 @@
                     </tr>                                    
                 </table>
 
-                <h3 ng-if="idxCacheExists">{{'indexed_db'| translate}}</h3>
-                <table class="table table-bordered table-striped" ng-if="idxCacheExists">
+                <h3 ng-if="idCacheExists">{{'indexed_db'| translate}}</h3>
+                <table class="table table-bordered table-striped" ng-if="idCacheExists">
                     <tr ng-repeat="dbKey in dbKeys">
                         <td>
                             {{dbKey.id}}
@@ -113,10 +100,10 @@
                 
                 <!--<span class="alert alert-warning">{{'clears_local_cache'| translate}}</span>-->
                 <a href ng-click="clearCache()" class="btn btn-danger">{{'clear'| translate}}</a>
-                <a href ng-click="selectAll()" class="btn btn-primary">{{'select_all'| translate}}</a>
+                <a href ng-click="selectAll()" class="btn btn-primary">{{ (ssKeys  | filter: {remove: true}).length > 0 || (lsKeys  | filter: {remove: true}).length > 0 || (dbKeys  | filter: {remove: true}).length > 0 ? 'unselect_all' : 'select_all' | translate}}</a>                
             </div>
             
-            <div class="row col-sm-4" ng-if="!lsCacheExists && !idxCacheExists">                
+            <div class="row col-sm-6" ng-if="!lsCacheExists && !idCacheExists">                
                 <div class="alert alert-info">{{ afterClearing ? 'cache_cleared' : 'nothing_to_clear' | translate}}</div>                
             </div>
             

=== 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