LP#1768947 Disable offline download button, improve logging
authorBill Erickson <berickxx@gmail.com>
Tue, 7 Aug 2018 16:10:17 +0000 (12:10 -0400)
committerKathy Lussier <klussier@masslnc.org>
Wed, 8 Aug 2018 14:31:15 +0000 (10:31 -0400)
Once the offline block list download button is clicked, it's disabled to
prevent any possibility of double-clicks.  The shared worker also
reports a more meaningful error in case a double-click sneaks past.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/offline-interface.tt2
Open-ILS/web/js/ui/default/staff/offline-db-worker.js
Open-ILS/web/js/ui/default/staff/offline.js

index 16424ce..fafc74e 100644 (file)
@@ -35,6 +35,7 @@
         </button>
         <button
           class="btn btn-default"
+          ng-disabled="buildingBlockList"
           ng-if="logged_in"
           ng-click="downloadBlockList()">
             [% l('Download block list') %]
index 6c2e1ad..3239900 100644 (file)
@@ -207,7 +207,11 @@ var buildingBlockList = false;
 // Fetches the offline block list and rebuilds the offline blocks
 // table from the new data.
 function populateBlockList(authtoken) {
-    if (buildingBlockList) return;
+
+    if (buildingBlockList) {
+        return Promise.reject('Block list download already in progress');
+    }
+
     buildingBlockList = true;
 
     var url = '/standalone/list.txt?ses=' + 
@@ -234,6 +238,7 @@ function populateBlockList(authtoken) {
                         }
                     );
                 } else {
+                    buildingBlockList = false;
                     reject('Error fetching offline block list');
                 }
             }
@@ -300,7 +305,7 @@ function insertOfflineBlocks(lines) {
 function insertOfflineChunks(chunks, offset, resolve, reject) {
     var chunk = chunks[offset];
     if (!chunk || chunk.length === 0) {
-        console.debug('Block list successfully stored');
+        console.debug('Block list store completed');
         return resolve();
     }
 
index 0e990a1..7ab361f 100644 (file)
@@ -393,7 +393,9 @@ function($routeProvider , $locationProvider , $compileProvider) {
             } 
         });
 
+        $scope.buildingBlockList = false;
         $scope.downloadBlockList = function () {
+            $scope.buildingBlockList = true;
             egProgressDialog.open();
             egLovefield.populateBlockList().then(
                 function(){
@@ -403,7 +405,10 @@ function($routeProvider , $locationProvider , $compileProvider) {
                     ngToast.warning(egCore.strings.OFFLINE_BLOCKLIST_FAIL);
                     egCore.audio.play('warning.offline.blocklist_fail');
                 }
-            )['finally'](egProgressDialog.close);
+            )['finally'](function() {
+                $scope.buildingBlockList = false;
+                egProgressDialog.close();
+            });
         }
 
         $scope.createOfflineXactBlob = function () {