Skip to content

Commit

Permalink
Merge pull request #579 from jembi/PLAT-249-remove-limit-on-bulk-rerun
Browse files Browse the repository at this point in the history
Plat 249 remove limit on bulk rerun
  • Loading branch information
michaelloosen authored Nov 3, 2022
2 parents d0addb1 + 1a35e79 commit 092e563
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 31 deletions.
19 changes: 10 additions & 9 deletions app/scripts/controllers/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,18 +413,23 @@ export function TransactionsCtrl ($scope, $uibModal, $location, $timeout, $inter

const refreshSuccess = function (transactions) {
// on success
$scope.transactions = transactions
if (transactions.count) {
$scope.transactions = []
$scope.transactionsCount = transactions.count
} else {
$scope.transactions = transactions
}

// save latest returned transaction to session storage for use in transaction
// details paging.
const idList = transactions.map(function (tx) { return tx._id })
const idList = $scope.transactions.map(function (tx) { return tx._id })
sessionStorage.setItem('currTxList', angular.toJson(idList))
sessionStorage.setItem('currFilterURL', `!${$location.url()}`)

if (transactions.length < $scope.settings.filter.limit) {
if ($scope.transactions.length < $scope.settings.filter.limit) {
$scope.loadMoreBtn = false

if (transactions.length === 0) {
if ($scope.transactions.length === 0 && !transactions.count) {
Alerting.AlertAddMsg('bottom', 'warning', 'There are no transactions for the current filters')
}
} else {
Expand Down Expand Up @@ -611,13 +616,9 @@ export function TransactionsCtrl ($scope, $uibModal, $location, $timeout, $inter
// set filter limit to default defaultBulkRerunLimit
returnFilters.filterLimit = $scope.defaultBulkRerunLimit

// remove filterPage because no pagination needed
delete returnFilters.filterPage

// set bulkrerunActive true to show rerun information
$scope.bulkRerunActive = true

Api.Transactions.query(returnFilters, refreshSuccess, refreshError)
Api.Transactions.get(returnFilters, refreshSuccess, refreshError)
} else {
// do normal transaction API call for transactions
Api.Transactions.query($scope.returnFilters(), refreshSuccess, refreshError)
Expand Down
21 changes: 18 additions & 3 deletions app/scripts/controllers/transactionsRerunModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export function TransactionsRerunModalCtrl ($scope, $uibModalInstance, Api, Noti
$scope.taskSetup = {}
$scope.taskSetup.batchSize = 1
$scope.taskSetup.paused = false
$scope.batchSizes = Array.from(getBatchSizes(transactionsSelected.length))
$scope.batchSizes = Array.from(
getBatchSizes($scope.transactionsCount ? $scope.transactionsCount : transactionsSelected.length)
)

if (rerunTransactionsSelected === 1 && transactionsSelected.length === 1) {
Alerting.AlertAddMsg('rerun', 'warning', 'This transaction has already been rerun')
Expand All @@ -32,12 +34,25 @@ export function TransactionsRerunModalCtrl ($scope, $uibModalInstance, Api, Noti
$scope.$emit('transactionRerunSuccess')
};

$scope.confirmRerun = function () {
const tIds = $scope.transactionsSelected
function createTask (tIds, onSuccess) {
$scope.task = new Api.Tasks({ tids: tIds, batchSize: $scope.taskSetup.batchSize, paused: $scope.taskSetup.paused })
$scope.task.$save({}, onSuccess)
}

$scope.confirmRerun = function () {
if ($scope.bulkRerunActive) {
const filters = $scope.returnFilters()
filters.pauseQueue = $scope.taskSetup.paused
filters.batchSize = $scope.taskSetup.batchSize

$scope.rerunTasks = new Api.BulkReruns(filters)
$scope.rerunTasks.$save({}, onSuccess)
} else {
createTask($scope.transactionsSelected, onSuccess)
}
$scope.rerunSuccess = true
}

$scope.cancel = function () {
$uibModalInstance.dismiss('cancel')
}
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/services/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export function Api ($rootScope, $resource, config) {

Transactions: $resource(server + '/transactions/:transactionId', { transactionId: '@_id' }),

BulkReruns: $resource(server + '/bulkrerun'),

Mediators: $resource(server + '/mediators/:urn', { urn: '@urn' }, {
update: { method: 'PUT' }
}),
Expand Down
15 changes: 5 additions & 10 deletions app/views/transactions.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,12 @@ <h2><i class="glyphicon glyphicon-list-alt"></i>&nbsp;&nbsp;Transactions Log <sp
<h2 style="margin: 5px;">You have opted to do a Bulk Rerun!</h2>
<h3 ng-show="NoDateRange" style="margin: 20px;">No date range has been supplied, querying all transactions with the defined filters.</h3>

<h3 style="margin: 20px;" ng-if="transactionsSelected.length == defaultBulkRerunLimit">
A default limit of <strong><u>{{defaultBulkRerunLimit}}</u></strong> has been set on Bulk Rerun transactions. <br />
Would you like to proceed with the first <strong><u>{{defaultBulkRerunLimit}}</u></strong> transactions matched?
</h3>

<h3 style="margin: 20px;" ng-if="transactionsSelected.length < defaultBulkRerunLimit">
Your filters returned a total of <strong><u>{{transactionsSelected.length}}</u></strong> transactions that can be re-run
<h3 style="margin: 20px;">
Your filters returned a total of <strong><u>{{transactionsCount}}</u></strong> transactions that can be re-run
</h3>
</div>
<div ng-if="transactionsSelected.length > 0">
<button class="btn btn-primary btn-lg" ng-click="bulkRerunContinue()" style="margin: 0px 5px;">Continue...</button>
<div>
<button ng-if="bulkRerunActive" class="btn btn-primary btn-lg" ng-click="bulkRerunContinue()" style="margin: 0px 5px;">Continue...</button>
<button class="btn btn-danger btn-lg" ng-click="bulkRerunCancel()" style="margin: 0px 5px;">Cancel</button>
</div>
</div>
Expand All @@ -72,7 +67,7 @@ <h3 style="margin: 20px;" ng-if="transactionsSelected.length < defaultBulkRerunL
</button>

<button class="btn btn-primary" ng-click="bulkRerunInitiate();" style="float: left; margin-left: 15px;">
<i class="glyphicon glyphicon-repeat"></i> Re-run all transaction that match current filters
<i class="glyphicon glyphicon-repeat"></i> Re-run all transactions that match current filters
</button>
</div>

Expand Down
16 changes: 8 additions & 8 deletions app/views/transactionsRerunModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ <h3 class="modal-title"><i class="glyphicon glyphicon-repeat"></i>&nbsp;&nbsp;Tr
<div class="modal-body">

<div ng-if="rerunSuccess != true">
<h4 ng-show="transactionsSelected.length === 0">You have not selected any transactions to be rerun. <br /><br />
<h4 ng-show="transactionsSelected.length === 0 && transactionsCount === 0">You have not selected any transactions to be rerun. <br /><br />
Please select the transactions you wish to rerun by ticking the boxes on the left and try again</h4>

<h4 ng-show="transactionsSelected.length > 0">
<h4 ng-show="transactionsSelected.length > 0 || transactionsCount > 0">
<div ng-show="transactionsSelected.length === 1" style="margin-bottom: 15px;">You have selected that transaction <strong>#{{transactionsSelected[0]}}</strong> should be rerun. </div>
<div ng-show="transactionsSelected.length > 1" style="margin-bottom: 15px;">You have selected a total of <strong>{{transactionsSelected.length}}</strong> transactions to be rerun. </div>
<div ng-show="transactionsSelected.length > 1 || transactionsCount" style="margin-bottom: 15px;">You have selected a total of <strong>{{bulkRerunActive ? transactionsCount : transactionsSelected.length}}</strong> transactions to be rerun. </div>

<!-- Rerun Alerts -->
<div uib-alert ng-repeat="alert in alerts.rerun" ng-class="'alert-' + (alert.type || 'warning')">{{alert.msg}}</div>
Expand All @@ -23,12 +23,12 @@ <h4 ng-show="transactionsSelected.length > 0">

<div ng-if="rerunSuccess === true">
<h4 ng-show="transactionsSelected.length === 1">Your selected transaction has been added to the queue to be rerun.</h4>
<h4 ng-show="transactionsSelected.length > 1">Your selected transactions have been added to the queue to be rerun.</h4>
</div>
<h4 ng-show="transactionsSelected.length > 1 || transactionsCount > 0">Your selected transactions have been added to the queue to be rerun.</h4>
</div>

</div>
<div class="modal-footer">
<div ng-show="transactionsSelected.length > 1" ng-if="rerunSuccess != true" style="float: left;">
<div ng-show="transactionsSelected.length > 1 || transactionsCount > 0" ng-if="rerunSuccess != true" style="float: left;">
<label style="float: left; margin: 10px 10px 0px 0px;">
Batch size
<i style="right: -20px;" ng-show="uiSettings.showTooltips" tooltip-placement="top" uib-tooltip="The number of transactions that the task processor should run concurrently" class="glyphicon glyphicon-question-sign tooltip-wide"></i>
Expand All @@ -38,7 +38,7 @@ <h4 ng-show="transactionsSelected.length > 1">Your selected transactions have be
ng-options="batch.value as batch.label for batch in batchSizes">
</select>
</div>
<div ng-show="transactionsSelected.length > 0" ng-if="rerunSuccess != true" style="float: left;">
<div ng-show="transactionsSelected.length > 0 || transactionsCount > 0" ng-if="rerunSuccess != true" style="float: left;">
<input style="float: left; margin: 10px 10px 0px 20px" id="taskSetupPaused" type="checkbox" ng-model="taskSetup.paused"/>
<label style="float: left; margin: 10px 10px 0px 0px;" for="taskSetupPaused">
Paused
Expand All @@ -47,6 +47,6 @@ <h4 ng-show="transactionsSelected.length > 1">Your selected transactions have be
</div>

<button type="button" class="btn btn-default" ng-click="cancel()">Close</button>
<button type="button" class="btn btn-primary" ng-click="confirmRerun()" ng-show="transactionsSelected.length > 0" ng-if="rerunSuccess != true">Confirm Batch Rerun</button>
<button type="button" class="btn btn-primary" ng-click="confirmRerun()" ng-show="transactionsSelected.length > 0 || transactionsCount > 0" ng-if="rerunSuccess != true">Confirm Batch Rerun</button>
</div>
</form>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "openhim-console",
"description": "This application provides a web application to configure and manage the OpenHIM-core component.",
"version": "1.14.4",
"version": "1.15.0",
"dependencies": {
"@types/http-server": "^0.10.1",
"http-server": "^0.12.3",
Expand Down

0 comments on commit 092e563

Please sign in to comment.