Skip to content

Commit

Permalink
Fix not-a-function errors navigating between pages
Browse files Browse the repository at this point in the history
In some cases, watch listeners inside controllers are called immediately
upon registration with DataService. This leads to not-a-function errors
when function expressions below haven't been evaluated. Use function
statements rather than function expressions to avoid the errors.

Fixes openshift#1855
  • Loading branch information
spadgett committed Apr 29, 2015
1 parent 57b3138 commit 786ef25
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions assets/app/scripts/controllers/builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ angular.module('openshiftConsole')
Logger.log("buildConfigs (subscribe)", $scope.buildConfigs);
}));

var associateRunningBuildToBuildConfig = function(buildsByBuildConfig) {
function associateRunningBuildToBuildConfig(buildsByBuildConfig) {
var buildConfigBuildsInProgress = {};
angular.forEach(buildsByBuildConfig, function(buildConfigBuilds, buildConfigName) {
buildConfigBuildsInProgress[buildConfigName] = {};
Expand All @@ -78,7 +78,7 @@ angular.module('openshiftConsole')
return buildConfigBuildsInProgress;
};

var updateFilterWarning = function() {
function updateFilterWarning() {
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.builds) && !$.isEmptyObject($scope.unfilteredBuilds)) {
$scope.alerts["builds"] = {
type: "warning",
Expand Down Expand Up @@ -149,4 +149,4 @@ angular.module('openshiftConsole')
$scope.$on('$destroy', function(){
DataService.unwatchAll(watches);
});
});
});
6 changes: 3 additions & 3 deletions assets/app/scripts/controllers/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ angular.module('openshiftConsole')
$scope.emptyMessage = "Loading...";
var watches = [];

var extractPodTemplates = function() {
function extractPodTemplates() {
angular.forEach($scope.deployments, function(deployment, deploymentId){
$scope.podTemplates[deploymentId] = deployment.spec.template;
});
Expand Down Expand Up @@ -52,7 +52,7 @@ angular.module('openshiftConsole')
Logger.log("builds (subscribe)", $scope.builds);
}));

var updateFilterWarning = function() {
function updateFilterWarning() {
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.deployments) && !$.isEmptyObject($scope.unfilteredDeployments)) {
$scope.alerts["deployments"] = {
type: "warning",
Expand All @@ -75,4 +75,4 @@ angular.module('openshiftConsole')
$scope.$on('$destroy', function(){
DataService.unwatchAll(watches);
});
});
});
4 changes: 2 additions & 2 deletions assets/app/scripts/controllers/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ angular.module('openshiftConsole')
Logger.log("image streams (subscribe)", $scope.imageStreams);
}));

var updateFilterWarning = function() {
function updateFilterWarning() {
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.imageStreams) && !$.isEmptyObject($scope.unfilteredImageStreams)) {
$scope.alerts["imageStreams"] = {
type: "warning",
Expand All @@ -50,4 +50,4 @@ angular.module('openshiftConsole')
$scope.$on('$destroy', function(){
DataService.unwatchAll(watches);
});
});
});
12 changes: 6 additions & 6 deletions assets/app/scripts/controllers/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ angular.module('openshiftConsole')
}));

// Expects deploymentsByServiceByDeploymentConfig to be up to date
var podRelationships = function() {
function podRelationships() {
$scope.monopodsByService = {"": {}};
$scope.podsByService = {};
$scope.podsByDeployment = {};
Expand Down Expand Up @@ -123,7 +123,7 @@ angular.module('openshiftConsole')
};

// Filter out monopods we know we don't want to see
var showMonopod = function(pod) {
function showMonopod(pod) {
// Hide pods in the Succeeded or Terminated phase since these are run once pods
// that are done
if (pod.status.phase == 'Succeeded' || pod.status.phase == 'Terminated') {
Expand All @@ -146,7 +146,7 @@ angular.module('openshiftConsole')
return true;
};

var deploymentConfigsByService = function() {
function deploymentConfigsByService() {
$scope.deploymentConfigsByService = {"": {}};
angular.forEach($scope.deploymentConfigs, function(deploymentConfig, depName){
var foundMatch = false;
Expand All @@ -167,7 +167,7 @@ angular.module('openshiftConsole')
});
};

var deploymentsByService = function() {
function deploymentsByService() {
var bySvc = $scope.deploymentsByService = {"": {}};
var bySvcByDepCfg = $scope.deploymentsByServiceByDeploymentConfig = {"": {}};

Expand Down Expand Up @@ -241,7 +241,7 @@ angular.module('openshiftConsole')
Logger.log("imageStreams (subscribe)", $scope.imageStreams);
}));

var associateDeploymentConfigTriggersToBuild = function(deploymentConfig, build) {
function associateDeploymentConfigTriggersToBuild(deploymentConfig, build) {
// Make sure we have both a deploymentConfig and a build
if (!deploymentConfig || !build) {
return;
Expand Down Expand Up @@ -319,7 +319,7 @@ angular.module('openshiftConsole')
Logger.log("builds (subscribe)", $scope.builds);
}));

var updateFilterWarning = function() {
function updateFilterWarning() {
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.services) && !$.isEmptyObject($scope.unfilteredServices)) {
$scope.alerts["services"] = {
type: "warning",
Expand Down
4 changes: 2 additions & 2 deletions assets/app/scripts/controllers/pods.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ angular.module('openshiftConsole')
Logger.log("builds (subscribe)", $scope.builds);
}));

var updateFilterWarning = function() {
function updateFilterWarning() {
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.pods) && !$.isEmptyObject($scope.unfilteredPods)) {
$scope.alerts["pods"] = {
type: "warning",
Expand All @@ -67,4 +67,4 @@ angular.module('openshiftConsole')
$scope.$on('$destroy', function(){
DataService.unwatchAll(watches);
});
});
});
4 changes: 2 additions & 2 deletions assets/app/scripts/controllers/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ angular.module('openshiftConsole')
Logger.log("routes (subscribe)", $scope.routesByService);
}));

var routesByService = function(routes) {
function routesByService(routes) {
var routeMap = {};
angular.forEach(routes, function(route, routeName){
routeMap[route.serviceName] = routeMap[route.serviceName] || {};
Expand All @@ -41,7 +41,7 @@ angular.module('openshiftConsole')
return routeMap;
};

var updateFilterWarning = function() {
function updateFilterWarning() {
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.services) && !$.isEmptyObject($scope.unfilteredServices)) {
$scope.alerts["services"] = {
type: "warning",
Expand Down

0 comments on commit 786ef25

Please sign in to comment.