Assign polling numbers to variables and add comments

This commit is contained in:
Matt-Yorkley
2018-12-21 20:01:16 +00:00
parent e624faaacb
commit e7e208061f

View File

@@ -5,13 +5,15 @@ angular.module("admin.orders").controller "bulkInvoiceCtrl", ($scope, $http, $ti
$scope.loading = true
$scope.message = null
$scope.error = null
$scope.poll_wait = 5 # 5 Seconds between each check
$scope.poll_retries = 80 # Maximum checks before stopping
$http.post('/admin/orders/invoices', {order_ids: $scope.selected_orders}).success (data) ->
$scope.invoice_id = data
$scope.pollBulkInvoice()
$scope.pollBulkInvoice = ->
$timeout($scope.nextPoll, 5000)
$timeout($scope.nextPoll, $scope.poll_wait * 1000)
$scope.nextPoll = ->
$http.get('/admin/orders/invoices/'+$scope.invoice_id+'/poll').success (data) ->
@@ -21,7 +23,7 @@ angular.module("admin.orders").controller "bulkInvoiceCtrl", ($scope, $http, $ti
.error (data) ->
$scope.poll++
if $scope.poll > 30
if $scope.poll > $scope.poll_retries
$scope.loading = false
$scope.error = t('js.admin.orders.index.bulk_invoice_failed')
return