From 044c42dd1deefe387181ea4810d3d6b597ff24ad Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 26 Jan 2018 16:42:08 -0500 Subject: [PATCH] LP#1745499 De-Parallelify Item Status file upload Fetch copies in a series instead of in parallel when loading copy barcodes from a file in the Item Status interface. This helps avoid excessive pcrud process count. Since this causes the action to take a little longer, the commit also includes a progress dialog indicating copy retrieve progress. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- .../web/js/ui/default/staff/cat/item/app.js | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js index e58781851b..be8e797028 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js @@ -234,8 +234,13 @@ function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc) * List view - grid stuff */ .controller('ListCtrl', - ['$scope','$q','$routeParams','$location','$timeout','$window','egCore','egGridDataProvider','egItem','egUser','$uibModal','egCirc','egConfirmDialog', -function($scope , $q , $routeParams , $location , $timeout , $window , egCore , egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog) { + ['$scope','$q','$routeParams','$location','$timeout','$window','egCore', + 'egGridDataProvider','egItem','egUser','$uibModal','egCirc','egConfirmDialog', + 'egProgressDialog', +function($scope , $q , $routeParams , $location , $timeout , $window , egCore , + egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog, + egProgressDialog) { + var copyId = []; var cp_list = $routeParams.idList; if (cp_list) { @@ -282,18 +287,24 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore , barcodes.push(line); }); - if (barcodes.length > 0) { - var promises = []; - angular.forEach(barcodes, function (b) { - promises.push(itemSvc.fetch(b)); - }); + // Serialize copy retrieval since there may be many, many copies. + function fetch_next_copy() { + var barcode = barcodes.pop(); + egProgressDialog.increment(); - $q.all(promises).then( - function() { - copyGrid.refresh(); - copyGrid.selectItems([itemSvc.copies[0].index]); - } - ); + if (!barcode) { // All done here. + egProgressDialog.close(); + copyGrid.refresh(); + copyGrid.selectItems([itemSvc.copies[0].index]); + return; + } + + itemSvc.fetch(barcode).then(fetch_next_copy); + } + + if (barcodes.length) { + egProgressDialog.open({value: 0, max: barcodes.length}); + fetch_next_copy(); } } }); -- 2.43.2