From eb3b9d2c9ab344b679a3219adea1535df0f52709 Mon Sep 17 00:00:00 2001 From: Samuel Padgett Date: Wed, 29 Apr 2015 13:41:50 -0400 Subject: [PATCH] Fix not-a-function errors navigating between pages 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 #1855 --- assets/app/scripts/controllers/builds.js | 6 +- assets/app/scripts/controllers/deployments.js | 6 +- assets/app/scripts/controllers/images.js | 4 +- assets/app/scripts/controllers/overview.js | 12 +- assets/app/scripts/controllers/pods.js | 4 +- assets/app/scripts/controllers/services.js | 4 +- assets/app/scripts/services/data.js | 2 +- pkg/assets/bindata.go | 243 +++++++++--------- 8 files changed, 139 insertions(+), 142 deletions(-) diff --git a/assets/app/scripts/controllers/builds.js b/assets/app/scripts/controllers/builds.js index 8aefb757aa03..039c52f6bfea 100644 --- a/assets/app/scripts/controllers/builds.js +++ b/assets/app/scripts/controllers/builds.js @@ -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] = {}; @@ -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", @@ -149,4 +149,4 @@ angular.module('openshiftConsole') $scope.$on('$destroy', function(){ DataService.unwatchAll(watches); }); - }); \ No newline at end of file + }); diff --git a/assets/app/scripts/controllers/deployments.js b/assets/app/scripts/controllers/deployments.js index 16e9fe1597ce..fbf1afcf7845 100644 --- a/assets/app/scripts/controllers/deployments.js +++ b/assets/app/scripts/controllers/deployments.js @@ -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; }); @@ -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", @@ -75,4 +75,4 @@ angular.module('openshiftConsole') $scope.$on('$destroy', function(){ DataService.unwatchAll(watches); }); - }); \ No newline at end of file + }); diff --git a/assets/app/scripts/controllers/images.js b/assets/app/scripts/controllers/images.js index 622560cd9076..870b424b1de5 100644 --- a/assets/app/scripts/controllers/images.js +++ b/assets/app/scripts/controllers/images.js @@ -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", @@ -50,4 +50,4 @@ angular.module('openshiftConsole') $scope.$on('$destroy', function(){ DataService.unwatchAll(watches); }); - }); \ No newline at end of file + }); diff --git a/assets/app/scripts/controllers/overview.js b/assets/app/scripts/controllers/overview.js index dfb3a80822de..cec6904629d8 100644 --- a/assets/app/scripts/controllers/overview.js +++ b/assets/app/scripts/controllers/overview.js @@ -70,7 +70,7 @@ angular.module('openshiftConsole') })); // Expects deploymentsByServiceByDeploymentConfig to be up to date - var podRelationships = function() { + function podRelationships() { $scope.monopodsByService = {"": {}}; $scope.podsByService = {}; $scope.podsByDeployment = {}; @@ -126,7 +126,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') { @@ -149,7 +149,7 @@ angular.module('openshiftConsole') return true; }; - var deploymentConfigsByService = function() { + function deploymentConfigsByService() { $scope.deploymentConfigsByService = {"": {}}; angular.forEach($scope.deploymentConfigs, function(deploymentConfig, depName){ var foundMatch = false; @@ -170,7 +170,7 @@ angular.module('openshiftConsole') }); }; - var deploymentsByService = function() { + function deploymentsByService() { var bySvc = $scope.deploymentsByService = {"": {}}; var bySvcByDepCfg = $scope.deploymentsByServiceByDeploymentConfig = {"": {}}; @@ -244,7 +244,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; @@ -322,7 +322,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", diff --git a/assets/app/scripts/controllers/pods.js b/assets/app/scripts/controllers/pods.js index 4418d6924642..bdc5cf54e478 100644 --- a/assets/app/scripts/controllers/pods.js +++ b/assets/app/scripts/controllers/pods.js @@ -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", @@ -67,4 +67,4 @@ angular.module('openshiftConsole') $scope.$on('$destroy', function(){ DataService.unwatchAll(watches); }); - }); \ No newline at end of file + }); diff --git a/assets/app/scripts/controllers/services.js b/assets/app/scripts/controllers/services.js index 1d40480d7e53..772307d0a8ba 100644 --- a/assets/app/scripts/controllers/services.js +++ b/assets/app/scripts/controllers/services.js @@ -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] || {}; @@ -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", diff --git a/assets/app/scripts/services/data.js b/assets/app/scripts/services/data.js index abe26d58ea64..4196143269f6 100644 --- a/assets/app/scripts/services/data.js +++ b/assets/app/scripts/services/data.js @@ -241,7 +241,7 @@ angular.module('openshiftConsole') // If this is a cached type (immutable types only), ignore the force parameter if (this._isTypeCached(type) && existingData && existingData.by('metadata.name')[name]) { - return existingData.by('metadata.name')[name]; + deferred.resolve(existingData.by('metadata.name')[name]); } else if (!force && this._watchInFlight(type, context) && this._resourceVersion(type, context)) { var obj = existingData.by('metadata.name')[name]; diff --git a/pkg/assets/bindata.go b/pkg/assets/bindata.go index 35275acc1967..9fd9346d122e 100644 --- a/pkg/assets/bindata.go +++ b/pkg/assets/bindata.go @@ -15083,8 +15083,7 @@ void 0 !== this._objectType(b) && (b = this._objectType(b)), h = h || {}; var i = !!h.force; delete h.force; var j = d.defer(), k = this._data(b, g); -if (this._isTypeCached(b) && k && k.by("metadata.name")[e]) return k.by("metadata.name")[e]; -if (!i && this._watchInFlight(b, g) && this._resourceVersion(b, g)) { +if (this._isTypeCached(b) && k && k.by("metadata.name")[e]) j.resolve(k.by("metadata.name")[e]); else if (!i && this._watchInFlight(b, g) && this._resourceVersion(b, g)) { var l = k.by("metadata.name")[e]; c.$apply(l ? function() { j.resolve(l); @@ -15738,45 +15737,29 @@ a.projects = b.by("metadata.name"), h.log("projects", a.projects); }); }); } ]), angular.module("openshiftConsole").controller("PodsController", [ "$scope", "DataService", "$filter", "LabelFilter", "Logger", "ImageStreamResolver", function(a, b, c, d, e, f) { -a.pods = {}, a.unfilteredPods = {}, a.imageStreams = {}, a.imagesByDockerReference = {}, a.imageStreamImageRefByDockerReference = {}, a.builds = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading..."; -var g = []; -g.push(b.watch("pods", a, function(b) { -a.unfilteredPods = b.by("metadata.name"), f.fetchReferencedImageStreamImages(a.pods, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), d.addLabelSuggestionsFromResources(a.unfilteredPods, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.pods = d.getLabelSelector().select(a.unfilteredPods), a.emptyMessage = "No pods to show", h(), e.log("pods (subscribe)", a.unfilteredPods); -})), g.push(b.watch("imageStreams", a, function(b) { -a.imageStreams = b.by("metadata.name"), f.buildDockerRefMapForImageStreams(a.imageStreams, a.imageStreamImageRefByDockerReference), f.fetchReferencedImageStreamImages(a.pods, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), e.log("imageStreams (subscribe)", a.imageStreams); -})), g.push(b.watch("builds", a, function(b) { -a.builds = b.by("metadata.name"), e.log("builds (subscribe)", a.builds); -})); -var h = function() { +function g() { d.getLabelSelector().isEmpty() || !$.isEmptyObject(a.pods) || $.isEmptyObject(a.unfilteredPods) ? delete a.alerts.pods :a.alerts.pods = { type:"warning", details:"The active filters are hiding all pods." }; -}; -d.onActiveFiltersChanged(function(b) { +} +a.pods = {}, a.unfilteredPods = {}, a.imageStreams = {}, a.imagesByDockerReference = {}, a.imageStreamImageRefByDockerReference = {}, a.builds = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading..."; +var h = []; +h.push(b.watch("pods", a, function(b) { +a.unfilteredPods = b.by("metadata.name"), f.fetchReferencedImageStreamImages(a.pods, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), d.addLabelSuggestionsFromResources(a.unfilteredPods, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.pods = d.getLabelSelector().select(a.unfilteredPods), a.emptyMessage = "No pods to show", g(), e.log("pods (subscribe)", a.unfilteredPods); +})), h.push(b.watch("imageStreams", a, function(b) { +a.imageStreams = b.by("metadata.name"), f.buildDockerRefMapForImageStreams(a.imageStreams, a.imageStreamImageRefByDockerReference), f.fetchReferencedImageStreamImages(a.pods, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), e.log("imageStreams (subscribe)", a.imageStreams); +})), h.push(b.watch("builds", a, function(b) { +a.builds = b.by("metadata.name"), e.log("builds (subscribe)", a.builds); +})), d.onActiveFiltersChanged(function(b) { a.$apply(function() { -a.pods = b.select(a.unfilteredPods), h(); +a.pods = b.select(a.unfilteredPods), g(); }); }), a.$on("$destroy", function() { -b.unwatchAll(g); +b.unwatchAll(h); }); } ]), angular.module("openshiftConsole").controller("OverviewController", [ "$scope", "DataService", "$filter", "LabelFilter", "Logger", "ImageStreamResolver", function(a, b, c, d, e, f) { -function g(a) { -if (a.metadata.annotations && a.metadata.annotations.encodedDeploymentConfig) try { -var b = $.parseJSON(a.metadata.annotations.encodedDeploymentConfig); -a.details = b.details; -} catch (c) { -e.error("Failed to parse encoded deployment config", c); -} -} -a.pods = {}, a.services = {}, a.unfilteredServices = {}, a.deployments = {}, a.deploymentConfigs = {}, a.builds = {}, a.imageStreams = {}, a.imagesByDockerReference = {}, a.imageStreamImageRefByDockerReference = {}, a.podsByService = {}, a.podsByDeployment = {}, a.monopodsByService = {}, a.deploymentsByServiceByDeploymentConfig = {}, a.deploymentsByService = {}, a.deploymentConfigsByService = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading...", a.renderOptions = a.renderOptions || {}, a.renderOptions.showSidebarRight = !0; -var h = []; -h.push(b.watch("pods", a, function(b) { -a.pods = b.by("metadata.name"), i(), f.fetchReferencedImageStreamImages(a.pods, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), e.log("pods", a.pods); -})), h.push(b.watch("services", a, function(b) { -a.unfilteredServices = b.by("metadata.name"), d.addLabelSuggestionsFromResources(a.unfilteredServices, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.services = d.getLabelSelector().select(a.unfilteredServices), l(), k(), i(), a.emptyMessage = "No services to show", n(), e.log("services (list)", a.services); -})); -var i = function() { +function g() { a.monopodsByService = { "":{} }, a.podsByService = {}, a.podsByDeployment = {}; @@ -15801,14 +15784,16 @@ angular.forEach(f, function(b) { j = j || a.deploymentsByService[h] && a.deploymentsByService[h][b]; }), j || (a.monopodsByService[h] = a.monopodsByService[h] || {}, a.monopodsByService[h][e] = d); } -}), 0 == f.length && 0 == g.length && j(d) && (a.monopodsByService[""][e] = d); +}), 0 == f.length && 0 == g.length && h(d) && (a.monopodsByService[""][e] = d); }), e.log("podsByDeployment", a.podsByDeployment), e.log("podsByService", a.podsByService), e.log("monopodsByService", a.monopodsByService); -}, j = function(b) { +} +function h(b) { if ("Succeeded" == b.status.phase || "Terminated" == b.status.phase) return !1; if (b.metadata.annotations && b.metadata.annotations.deployment) return !1; for (var c in a.builds) if (a.builds[c].metadata.name == b.metadata.name) return !1; return !0; -}, k = function() { +} +function i() { a.deploymentConfigsByService = { "":{} }, angular.forEach(a.deploymentConfigs, function(b, c) { @@ -15819,7 +15804,8 @@ var h = new LabelSelector(f.spec.selector); h.covers(e) && (a.deploymentConfigsByService[g][c] = b, d = !0); }), d || (a.deploymentConfigsByService[""][c] = b); }); -}, l = function() { +} +function j() { var b = a.deploymentsByService = { "":{} }, c = a.deploymentsByServiceByDeploymentConfig = { @@ -15833,15 +15819,16 @@ var j = new LabelSelector(a.spec.selector); j.covers(g) && (b[i][e] = d, c[i][h] = c[i][h] || {}, c[i][h][e] = d, f = !0); }), f || (b[""][e] = d, c[""][h] = c[""][h] || {}, c[""][h][e] = d); }); -}; -h.push(b.watch("replicationcontrollers", a, function(b, c, d) { -a.deployments = b.by("metadata.name"), d ? "DELETED" !== c && g(d) :angular.forEach(a.deployments, function(a) { -g(a); -}), l(), i(), e.log("deployments (subscribe)", a.deployments); -})), h.push(b.watch("imageStreams", a, function(b) { -a.imageStreams = b.by("metadata.name"), f.buildDockerRefMapForImageStreams(a.imageStreams, a.imageStreamImageRefByDockerReference), f.fetchReferencedImageStreamImages(a.pods, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), e.log("imageStreams (subscribe)", a.imageStreams); -})); -var m = function(a, b) { +} +function k(a) { +if (a.metadata.annotations && a.metadata.annotations.encodedDeploymentConfig) try { +var b = $.parseJSON(a.metadata.annotations.encodedDeploymentConfig); +a.details = b.details; +} catch (c) { +e.error("Failed to parse encoded deployment config", c); +} +} +function l(a, b) { if (a && b && b.parameters.output.to) for (var c = 0; c < a.triggers.length; c++) { var d = a.triggers[c]; if ("ImageChange" === d.type) { @@ -15854,36 +15841,47 @@ if (i !== j) continue; d.builds = d.builds || {}, d.builds[b.metadata.name] = b; } } +} +function m() { +d.getLabelSelector().isEmpty() || !$.isEmptyObject(a.services) || $.isEmptyObject(a.unfilteredServices) ? delete a.alerts.services :a.alerts.services = { +type:"warning", +details:"The active filters are hiding all services." }; -h.push(b.watch("deploymentConfigs", a, function(b, c, d) { +} +a.pods = {}, a.services = {}, a.unfilteredServices = {}, a.deployments = {}, a.deploymentConfigs = {}, a.builds = {}, a.imageStreams = {}, a.imagesByDockerReference = {}, a.imageStreamImageRefByDockerReference = {}, a.podsByService = {}, a.podsByDeployment = {}, a.monopodsByService = {}, a.deploymentsByServiceByDeploymentConfig = {}, a.deploymentsByService = {}, a.deploymentConfigsByService = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading...", a.renderOptions = a.renderOptions || {}, a.renderOptions.showSidebarRight = !0; +var n = []; +n.push(b.watch("pods", a, function(b) { +a.pods = b.by("metadata.name"), g(), f.fetchReferencedImageStreamImages(a.pods, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), e.log("pods", a.pods); +})), n.push(b.watch("services", a, function(b) { +a.unfilteredServices = b.by("metadata.name"), d.addLabelSuggestionsFromResources(a.unfilteredServices, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.services = d.getLabelSelector().select(a.unfilteredServices), j(), i(), g(), a.emptyMessage = "No services to show", m(), e.log("services (list)", a.services); +})), n.push(b.watch("replicationcontrollers", a, function(b, c, d) { +a.deployments = b.by("metadata.name"), d ? "DELETED" !== c && k(d) :angular.forEach(a.deployments, function(a) { +k(a); +}), j(), g(), e.log("deployments (subscribe)", a.deployments); +})), n.push(b.watch("imageStreams", a, function(b) { +a.imageStreams = b.by("metadata.name"), f.buildDockerRefMapForImageStreams(a.imageStreams, a.imageStreamImageRefByDockerReference), f.fetchReferencedImageStreamImages(a.pods, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), e.log("imageStreams (subscribe)", a.imageStreams); +})), n.push(b.watch("deploymentConfigs", a, function(b, c, d) { a.deploymentConfigs = b.by("metadata.name"), c ? "DELETED" !== c && angular.forEach(a.builds, function(a) { -m(d, a); +l(d, a); }) :angular.forEach(a.deploymentConfigs, function(b) { angular.forEach(a.builds, function(a) { -m(b, a); +l(b, a); }); -}), k(), e.log("deploymentConfigs (subscribe)", a.deploymentConfigs); -})), h.push(b.watch("builds", a, function(b, c, d) { +}), i(), e.log("deploymentConfigs (subscribe)", a.deploymentConfigs); +})), n.push(b.watch("builds", a, function(b, c, d) { a.builds = b.by("metadata.name"), c ? ("ADDED" === c || "MODIFIED" === c) && angular.forEach(a.deploymentConfigs, function(a) { -m(a, d); +l(a, d); }) :angular.forEach(a.builds, function(b) { angular.forEach(a.deploymentConfigs, function(a) { -m(a, b); +l(a, b); }); }), e.log("builds (subscribe)", a.builds); -})); -var n = function() { -d.getLabelSelector().isEmpty() || !$.isEmptyObject(a.services) || $.isEmptyObject(a.unfilteredServices) ? delete a.alerts.services :a.alerts.services = { -type:"warning", -details:"The active filters are hiding all services." -}; -}; -d.onActiveFiltersChanged(function(b) { +})), d.onActiveFiltersChanged(function(b) { a.$apply(function() { -a.services = b.select(a.unfilteredServices), n(); +a.services = b.select(a.unfilteredServices), m(); }); }), a.$on("$destroy", function() { -b.unwatchAll(h); +b.unwatchAll(n); }); } ]), angular.module("openshiftConsole").controller("SettingsController", [ "$scope", "DataService", "$filter", "LabelFilter", "$timeout", "Logger", function(a, b, c, d, e, f) { a.quotas = {}, a.limitRanges = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessageQuotas = "Loading...", a.emptyMessageLimitRanges = "Loading...", a.renderOptions = a.renderOptions || {}, a.renderOptions.hideFilterWidget = !0; @@ -15906,24 +15904,7 @@ a.max[c] = a.max[c] || "", a.min[c] = a.min[c] || ""; b.unwatchAll(g); }); } ]), angular.module("openshiftConsole").controller("BuildsController", [ "$scope", "DataService", "$filter", "LabelFilter", "Logger", function(a, b, c, d, e) { -a.builds = {}, a.unfilteredBuilds = {}, a.buildConfigs = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading...", a.buildsByBuildConfig = {}; -var f = []; -f.push(b.watch("builds", a, function(b, c, f) { -if (a.unfilteredBuilds = b.by("metadata.name"), d.addLabelSuggestionsFromResources(a.unfilteredBuilds, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.builds = d.getLabelSelector().select(a.unfilteredBuilds), a.emptyMessage = "No builds to show", h(), a.buildsByBuildConfig = {}, angular.forEach(a.builds, function(b, c) { -var d = ""; -b.metadata.labels && (d = b.metadata.labels.buildconfig || ""), a.buildsByBuildConfig[d] = a.buildsByBuildConfig[d] || {}, a.buildsByBuildConfig[d][c] = b; -}), f) var i = f.metadata.labels.buildconfig, j = f.metadata.name; -if (c) { -if ("ADDED" === c) a.buildConfigBuildsInProgress[i][j] = f; else if ("MODIFIED" === c) { -var k = f.status; -("Complete" === k || "Failed" === k || "Error" === k || "Cancelled" === k) && delete a.buildConfigBuildsInProgress[i][j]; -} -} else a.buildConfigBuildsInProgress = g(a.buildsByBuildConfig); -e.log("builds (subscribe)", a.unfilteredBuilds); -})), f.push(b.watch("buildConfigs", a, function(b) { -a.buildConfigs = b.by("metadata.name"), e.log("buildConfigs (subscribe)", a.buildConfigs); -})); -var g = function(a) { +function f(a) { var b = {}; return angular.forEach(a, function(a, c) { b[c] = {}, angular.forEach(a, function(a, d) { @@ -15931,13 +15912,30 @@ var e = a.status; ("New" === e || "Pending" === e || "Running" === e) && (b[c][d] = a); }); }), b; -}, h = function() { +} +function g() { d.getLabelSelector().isEmpty() || !$.isEmptyObject(a.builds) || $.isEmptyObject(a.unfilteredBuilds) ? delete a.alerts.builds :a.alerts.builds = { type:"warning", details:"The active filters are hiding all builds." }; -}; -a.startBuild = function(c) { +} +a.builds = {}, a.unfilteredBuilds = {}, a.buildConfigs = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading...", a.buildsByBuildConfig = {}; +var h = []; +h.push(b.watch("builds", a, function(b, c, h) { +if (a.unfilteredBuilds = b.by("metadata.name"), d.addLabelSuggestionsFromResources(a.unfilteredBuilds, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.builds = d.getLabelSelector().select(a.unfilteredBuilds), a.emptyMessage = "No builds to show", g(), a.buildsByBuildConfig = {}, angular.forEach(a.builds, function(b, c) { +var d = ""; +b.metadata.labels && (d = b.metadata.labels.buildconfig || ""), a.buildsByBuildConfig[d] = a.buildsByBuildConfig[d] || {}, a.buildsByBuildConfig[d][c] = b; +}), h) var i = h.metadata.labels.buildconfig, j = h.metadata.name; +if (c) { +if ("ADDED" === c) a.buildConfigBuildsInProgress[i][j] = h; else if ("MODIFIED" === c) { +var k = h.status; +("Complete" === k || "Failed" === k || "Error" === k || "Cancelled" === k) && delete a.buildConfigBuildsInProgress[i][j]; +} +} else a.buildConfigBuildsInProgress = f(a.buildsByBuildConfig); +e.log("builds (subscribe)", a.unfilteredBuilds); +})), h.push(b.watch("buildConfigs", a, function(b) { +a.buildConfigs = b.by("metadata.name"), e.log("buildConfigs (subscribe)", a.buildConfigs); +})), a.startBuild = function(c) { var d = { metadata:{ name:c @@ -15975,82 +15973,81 @@ details:"Status: " + b.status + ". " + b.data }); }, d.onActiveFiltersChanged(function(b) { a.$apply(function() { -a.builds = b.select(a.unfilteredBuilds), h(); +a.builds = b.select(a.unfilteredBuilds), g(); }); }), a.$on("$destroy", function() { -b.unwatchAll(f); +b.unwatchAll(h); }); } ]), angular.module("openshiftConsole").controller("ImagesController", [ "$scope", "DataService", "$filter", "LabelFilter", "Logger", function(a, b, c, d, e) { -a.imageStreams = {}, a.unfilteredImageStreams = {}, a.builds = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading..."; -var f = []; -f.push(b.watch("imageStreams", a, function(b) { -a.unfilteredImageStreams = b.by("metadata.name"), d.addLabelSuggestionsFromResources(a.unfilteredImageStreams, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.imageStreams = d.getLabelSelector().select(a.unfilteredImageStreams), a.emptyMessage = "No image streams to show", g(), e.log("image streams (subscribe)", a.imageStreams); -})); -var g = function() { +function f() { d.getLabelSelector().isEmpty() || !$.isEmptyObject(a.imageStreams) || $.isEmptyObject(a.unfilteredImageStreams) ? delete a.alerts.imageStreams :a.alerts.imageStreams = { type:"warning", details:"The active filters are hiding all image streams." }; -}; -d.onActiveFiltersChanged(function(b) { +} +a.imageStreams = {}, a.unfilteredImageStreams = {}, a.builds = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading..."; +var g = []; +g.push(b.watch("imageStreams", a, function(b) { +a.unfilteredImageStreams = b.by("metadata.name"), d.addLabelSuggestionsFromResources(a.unfilteredImageStreams, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.imageStreams = d.getLabelSelector().select(a.unfilteredImageStreams), a.emptyMessage = "No image streams to show", f(), e.log("image streams (subscribe)", a.imageStreams); +})), d.onActiveFiltersChanged(function(b) { a.$apply(function() { -a.imageStreams = b.select(a.unfilteredImageStreams), g(); +a.imageStreams = b.select(a.unfilteredImageStreams), f(); }); }), a.$on("$destroy", function() { -b.unwatchAll(f); +b.unwatchAll(g); }); } ]), angular.module("openshiftConsole").controller("DeploymentsController", [ "$scope", "DataService", "$filter", "LabelFilter", "Logger", "ImageStreamResolver", function(a, b, c, d, e, f) { -a.deployments = {}, a.podTemplates = {}, a.unfilteredDeployments = {}, a.imageStreams = {}, a.imagesByDockerReference = {}, a.imageStreamImageRefByDockerReference = {}, a.builds = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading..."; -var g = [], h = function() { +function g() { angular.forEach(a.deployments, function(b, c) { a.podTemplates[c] = b.spec.template; }); -}; -g.push(b.watch("replicationcontrollers", a, function(b) { -a.unfilteredDeployments = b.by("metadata.name"), d.addLabelSuggestionsFromResources(a.unfilteredDeployments, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.deployments = d.getLabelSelector().select(a.unfilteredDeployments), h(), f.fetchReferencedImageStreamImages(a.podTemplates, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), a.emptyMessage = "No deployments to show", i(), e.log("deployments (subscribe)", a.deployments); -})), g.push(b.watch("imageStreams", a, function(b) { -a.imageStreams = b.by("metadata.name"), f.buildDockerRefMapForImageStreams(a.imageStreams, a.imageStreamImageRefByDockerReference), f.fetchReferencedImageStreamImages(a.podTemplates, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), e.log("imageStreams (subscribe)", a.imageStreams); -})), g.push(b.watch("builds", a, function(b) { -a.builds = b.by("metadata.name"), e.log("builds (subscribe)", a.builds); -})); -var i = function() { +} +function h() { d.getLabelSelector().isEmpty() || !$.isEmptyObject(a.deployments) || $.isEmptyObject(a.unfilteredDeployments) ? delete a.alerts.deployments :a.alerts.deployments = { type:"warning", details:"The active filters are hiding all deployments." }; -}; -d.onActiveFiltersChanged(function(b) { +} +a.deployments = {}, a.podTemplates = {}, a.unfilteredDeployments = {}, a.imageStreams = {}, a.imagesByDockerReference = {}, a.imageStreamImageRefByDockerReference = {}, a.builds = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading..."; +var i = []; +i.push(b.watch("replicationcontrollers", a, function(b) { +a.unfilteredDeployments = b.by("metadata.name"), d.addLabelSuggestionsFromResources(a.unfilteredDeployments, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.deployments = d.getLabelSelector().select(a.unfilteredDeployments), g(), f.fetchReferencedImageStreamImages(a.podTemplates, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), a.emptyMessage = "No deployments to show", h(), e.log("deployments (subscribe)", a.deployments); +})), i.push(b.watch("imageStreams", a, function(b) { +a.imageStreams = b.by("metadata.name"), f.buildDockerRefMapForImageStreams(a.imageStreams, a.imageStreamImageRefByDockerReference), f.fetchReferencedImageStreamImages(a.podTemplates, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, a), e.log("imageStreams (subscribe)", a.imageStreams); +})), i.push(b.watch("builds", a, function(b) { +a.builds = b.by("metadata.name"), e.log("builds (subscribe)", a.builds); +})), d.onActiveFiltersChanged(function(b) { a.$apply(function() { -a.deployments = b.select(a.unfilteredDeployments), i(); +a.deployments = b.select(a.unfilteredDeployments), h(); }); }), a.$on("$destroy", function() { -b.unwatchAll(g); +b.unwatchAll(i); }); } ]), angular.module("openshiftConsole").controller("ServicesController", [ "$scope", "DataService", "$filter", "LabelFilter", "Logger", function(a, b, c, d, e) { -a.services = {}, a.unfilteredServices = {}, a.routesByService = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading..."; -var f = []; -f.push(b.watch("services", a, function(b) { -a.unfilteredServices = b.by("metadata.name"), d.addLabelSuggestionsFromResources(a.unfilteredServices, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.services = d.getLabelSelector().select(a.unfilteredServices), a.emptyMessage = "No services to show", h(), e.log("services (subscribe)", a.unfilteredServices); -})), f.push(b.watch("routes", a, function(b) { -a.routesByService = g(b.by("metadata.name")), e.log("routes (subscribe)", a.routesByService); -})); -var g = function(a) { +function f(a) { var b = {}; return angular.forEach(a, function(a, c) { b[a.serviceName] = b[a.serviceName] || {}, b[a.serviceName][c] = a; }), b; -}, h = function() { +} +function g() { d.getLabelSelector().isEmpty() || !$.isEmptyObject(a.services) || $.isEmptyObject(a.unfilteredServices) ? delete a.alerts.services :a.alerts.services = { type:"warning", details:"The active filters are hiding all services." }; -}; -d.onActiveFiltersChanged(function(b) { +} +a.services = {}, a.unfilteredServices = {}, a.routesByService = {}, a.labelSuggestions = {}, a.alerts = a.alerts || {}, a.emptyMessage = "Loading..."; +var h = []; +h.push(b.watch("services", a, function(b) { +a.unfilteredServices = b.by("metadata.name"), d.addLabelSuggestionsFromResources(a.unfilteredServices, a.labelSuggestions), d.setLabelSuggestions(a.labelSuggestions), a.services = d.getLabelSelector().select(a.unfilteredServices), a.emptyMessage = "No services to show", g(), e.log("services (subscribe)", a.unfilteredServices); +})), h.push(b.watch("routes", a, function(b) { +a.routesByService = f(b.by("metadata.name")), e.log("routes (subscribe)", a.routesByService); +})), d.onActiveFiltersChanged(function(b) { a.$apply(function() { -a.services = b.select(a.unfilteredServices), h(); +a.services = b.select(a.unfilteredServices), g(); }); }), a.$on("$destroy", function() { -b.unwatchAll(f); +b.unwatchAll(h); }); } ]), angular.module("openshiftConsole").controller("CreateFromImageController", [ "$scope", "Logger", "$q", "$routeParams", "DataService", "Navigate", "NameGenerator", "ApplicationGenerator", "TaskList", function(a, b, c, d, e, f, g, h, i) { function j(a) {