Skip to content

Commit

Permalink
Merge 618547e into f51d1f1
Browse files Browse the repository at this point in the history
  • Loading branch information
eputtone committed Nov 20, 2018
2 parents f51d1f1 + 618547e commit c262afa
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Upgraded Spring to version 5.1.2.RELEASE
- Explorer displays a link in the header based on `returnUrl` and `returnUrlLabel` parameters in the Explorer opening URL
- nflow-netty's StartNflow interface changed to match nflow-jetty's
- Automatic refresh for workflow instance page in Explorer

## 5.1.0 (2018-10-18)

Expand Down
8 changes: 8 additions & 0 deletions nflow-explorer/src/app/services/WorkflowStatsPoller.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
return false;
};

this.stop = function(type) {
if (tasks[type]) {
console.info('Stop stats poller for ' + type);
$interval.cancel(tasks[type].poller);
tasks[type] = undefined;
}
};

this.getLatest = function(type) {
if(!tasks[type]) {
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
updateStateExecutionGraph(type);
}
});
$scope.$on('$destroy', function() {
WorkflowStatsPoller.stop(self.definition.type);
});
}

function isStateSelected(state) {
Expand Down
18 changes: 16 additions & 2 deletions nflow-explorer/src/app/workflow/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,29 @@
var m = angular.module('nflowExplorer.workflow', [
'nflowExplorer.workflow.graph',
'nflowExplorer.workflow.info',
'nflowExplorer.workflow.tabs'
'nflowExplorer.workflow.tabs',
'nflowExplorer.services.WorkflowService'
]);

m.controller('WorkflowCtrl', function (workflow, definition,
parentWorkflow, childWorkflows) {
parentWorkflow, childWorkflows, $scope, config, $interval, WorkflowService) {
var self = this;
self.workflow = workflow;
self.parentWorkflow = parentWorkflow;
self.definition = definition;
self.childWorkflows = childWorkflows;

function reloadWorkflow(workflowId) {
console.log('Fetching workflow id ' + workflowId);
WorkflowService.get(workflowId).then(function(workflow) {
self.workflow = workflow;
});
}
self.poller = $interval(function() { reloadWorkflow(self.workflow.id); },
config.radiator.pollPeriod * 1000);
$scope.$on('$destroy', function() {
console.log('Stop polling workflow id ' + self.workflow.id);
$interval.cancel(self.poller);
});
});
})();
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ describe('Controller: WorkflowDefinitionTabsCtrl', function () {
});
});

describe('Workflow stats poller lifecycle checks', function () {
var ctrl;
it('Poller stopped on $destroy', function() {
stubStatePoller(WorkflowStatsPoller, undefined);
var stopSpy = sinon.stub(WorkflowStatsPoller, 'stop').callsFake(function() {});
ctrl = getCtrl(WorkflowStatsPoller, $scope);
$scope.$broadcast('$destroy');
expect(stopSpy.called).toBe(true);
});
});

function stubStatePoller(WorkflowStatsPoller, stats) {
sinon.stub(WorkflowStatsPoller, 'getLatest').callsFake(function() {
return {
Expand Down

0 comments on commit c262afa

Please sign in to comment.