Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jkmarx/fix analysis auto call bug #3292

Merged
merged 3 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 4 additions & 11 deletions refinery/ui/source/js/analysis-monitor/ctrls/ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ function AnalysisMonitorCtrl (
vm.initializedFlag = {};
vm.openAnalysisDeleteModal = openAnalysisDeleteModal;

vm.$onDestroy = function () {
$timeout.cancel(vm.timerList);
};

// On data set browser analysis tab, method set timer and refreshes the
// analysis list and refreshes details for running analyses.
vm.updateAnalysesList = function () {
Expand All @@ -34,10 +38,6 @@ function AnalysisMonitorCtrl (
};

vm.timerList = $timeout(vm.updateAnalysesList, 15000);
// Cancels timer when away from analyses tab
$scope.$on('refinery/analyze-tab-inactive', function () {
$timeout.cancel(vm.timerList);
});

return analysisMonitorFactory.getAnalysesList(param)
.then(function (response) {
Expand All @@ -57,7 +57,6 @@ function AnalysisMonitorCtrl (
$timeout.cancel(vm.timerList);

vm.updateAnalysesList().then(function () {
$rootScope.$broadcast('rf/cancelAnalysis');
// Removes flag because list is updated
vm.setCancelAnalysisFlag(false, uuid);
});
Expand All @@ -75,12 +74,6 @@ function AnalysisMonitorCtrl (
}
};

vm.cancelTimerRunningList = function () {
if (typeof vm.timerRunList !== 'undefined') {
$timeout.cancel(vm.timerRunList);
}
};

/**
* @name getRunningAnalyses
* @desc Helper function to update running analyses with details
Expand Down
18 changes: 2 additions & 16 deletions refinery/ui/source/js/analysis-monitor/ctrls/ctrl.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ describe('Controller: AnalysisMonitorCtrl', function () {
var factory;
var fakeUuid = 'x508x83x-x9xx-4740-x9x7-x7x0x631280x';
var fakeInvalidUuid = 'xxxxx';
var timeout;

beforeEach(module('refineryApp'));
beforeEach(module('refineryAnalysisMonitor'));
beforeEach(inject(function (
$controller, $rootScope, $timeout, $window, analysisMonitorFactory
$controller, $rootScope, $window, analysisMonitorFactory
) {
ctrl = $controller('AnalysisMonitorCtrl', {
$scope: $rootScope.$new()
Expand Down Expand Up @@ -111,9 +110,7 @@ describe('Controller: AnalysisMonitorCtrl', function () {
});

describe('Helper functions', function () {
beforeEach(inject(function ($timeout) {
timeout = $timeout;

beforeEach(inject(function () {
ctrl.analysesDetail[fakeUuid] = {
refineryImport: [{
status: 'PROGRESS',
Expand Down Expand Up @@ -161,17 +158,6 @@ describe('Controller: AnalysisMonitorCtrl', function () {
.toEqual(ctrl.analysesList.length);
});

it('cancelTimerRunningList method is function', function () {
expect(angular.isFunction(ctrl.cancelTimerRunningList)).toBe(true);
});

it('cancelTimerRunningList method cancel timerRunList', function () {
ctrl.timerRunList = timeout(10);
expect(typeof ctrl.timerRunList.$$state.value).toEqual('undefined');
ctrl.cancelTimerRunningList();
expect(ctrl.timerRunList.$$state.value).toEqual('canceled');
});

it('setAnalysesLoadingFlag method is function', function () {
expect(angular.isFunction(ctrl.setAnalysesLoadingFlag)).toBe(true);
});
Expand Down
4 changes: 1 addition & 3 deletions refinery/ui/source/js/data-set-nav/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ function refineryDataSetNavConfig (
templateUrl: function () {
// unit tests redefine $window and thus make it unusable here
return window.getStaticUrl('partials/analysis-monitor/views/analyses-tab.html');
},
controller: 'AnalysisMonitorCtrl',
controllerAs: 'AMCtrl'
}
},
'^\/data_sets\/.*\/$',
true
Expand Down