Skip to content

Commit

Permalink
Merge pull request #958 from spadgett/overview-start-pipeline
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Nov 30, 2016
2 parents 5a88c56 + 464315d commit eea002e
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 71 deletions.
14 changes: 14 additions & 0 deletions app/scripts/controllers/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ angular.module('openshiftConsole')
};

var buildConfigForBuild = $filter('buildConfigForBuild');
var isIncompleteBuild = $filter('isIncompleteBuild');
var groupPipelineByDC = function(build) {
if (!buildConfigs) {
return;
Expand All @@ -417,6 +418,10 @@ angular.module('openshiftConsole')
_.each(dcNames, function(dcName) {
$scope.recentPipelinesByDC[dcName] = $scope.recentPipelinesByDC[dcName] || [];
$scope.recentPipelinesByDC[dcName].push(build);
if (isIncompleteBuild(build)) {
$scope.incompletePipelinesByDC[dcName] = $scope.incompletePipelinesByDC[dcName] || [];
$scope.incompletePipelinesByDC[dcName].push(build);
}
});
};

Expand All @@ -426,6 +431,7 @@ angular.module('openshiftConsole')
}
// reset these maps
$scope.recentPipelinesByDC = {};
$scope.incompletePipelinesByDC = {};
$scope.recentBuildsByOutputImage = {};
_.each(
BuildsService.interestingBuilds(builds),
Expand All @@ -436,6 +442,14 @@ angular.module('openshiftConsole')
}
groupPipelineByDC(build);
});

$scope.pipelinesForDC = {};
_.each(buildConfigs, function(buildConfig) {
_.each(BuildsService.usesDeploymentConfigs(buildConfig), function(dcName) {
$scope.pipelinesForDC[dcName] = $scope.pipelinesForDC[dcName] || [];
$scope.pipelinesForDC[dcName].push(buildConfig);
});
});
};


Expand Down
19 changes: 18 additions & 1 deletion app/scripts/directives/overview/dc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
'use strict';

angular.module('openshiftConsole')
.directive('overviewDeploymentConfig', function($filter, $uibModal, DeploymentsService, Navigate) {
.directive('overviewDeploymentConfig',
function($filter,
$uibModal,
BuildsService,
DeploymentsService,
Navigate) {
return {
restrict: 'E',
// Inherit scope from OverviewController. This directive is only used for the overview.
Expand Down Expand Up @@ -37,6 +42,18 @@ angular.module('openshiftConsole')
return Navigate.resourceURL(name, 'ImageStream', namespace);
};

$scope.startPipeline = function(pipeline) {
BuildsService
.startBuild(pipeline.metadata.name, { namespace: pipeline.metadata.namespace })
.then(_.noop, function(result) {
$scope.alerts["start-pipeline"] = {
type: "error",
message: "An error occurred while starting the pipeline.",
details: $filter('getErrorDetails')(result)
};
});
};

$scope.startDeployment = function() {
DeploymentsService.startLatestDeployment($scope.deploymentConfig, {
namespace: $scope.deploymentConfig.metadata.namespace
Expand Down
28 changes: 22 additions & 6 deletions app/views/overview/_dc.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,28 @@ <h2>No deployments.</h2>
</span>
</div>
<div ng-if="!imageChangeTriggers.length">
<p>
No deployments have started for
<a ng-href="{{deploymentConfig | navigateResourceURL}}">{{deploymentConfig.metadata.name}}</a>.
</p>
<div ng-if="'deploymentconfigs' | canI : 'update'" class="mar-top-md">
<button class="btn btn-primary" ng-click="startDeployment(deploymentConfig)">
<div ng-if="pipeline = pipelinesForDC[deploymentConfig.metadata.name][0]">
<p>
This deployment config is part of pipeline
<a ng-href="{{pipeline | navigateResourceURL}}">{{pipeline.metadata.name}}</a>.
</p>
<div ng-if="('buildconfigs/instantiate' | canI : 'create')">
<!-- Disable the button if a pipeline is running. -->
<button
class="btn btn-primary"
ng-click="startPipeline(pipeline)"
ng-disabled="incompletePipelinesByDC[deploymentConfig.metadata.name].length">
Start Pipeline
</button>
</div>
</div>
<div ng-if="!pipelinesForDC[deploymentConfig.metadata.name].length">
<p>
No deployments have started for
<a ng-href="{{deploymentConfig | navigateResourceURL}}">{{deploymentConfig.metadata.name}}</a>.
</p>

<button ng-if="'deploymentconfigs' | canI : 'update'" class="btn btn-primary" ng-click="startDeployment(deploymentConfig)">
Start Deployment
</button>
</div>
Expand Down
138 changes: 76 additions & 62 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4376,24 +4376,28 @@ _.set(c, [ "routeWarningsByService", a.metadata.name, b.metadata.name ], d);
}, ia = function(a) {
var b = H(_.get(a, "spec.output.to"), a.metadata.namespace);
c.recentBuildsByOutputImage[b] = c.recentBuildsByOutputImage[b] || [], c.recentBuildsByOutputImage[b].push(a);
}, ja = a("buildConfigForBuild"), ka = function(a) {
}, ja = a("buildConfigForBuild"), ka = a("isIncompleteBuild"), la = function(a) {
if (z) {
var b = ja(a), d = z[b];
if (d) {
var f = e.usesDeploymentConfigs(d);
_.each(f, function(b) {
c.recentPipelinesByDC[b] = c.recentPipelinesByDC[b] || [], c.recentPipelinesByDC[b].push(a);
c.recentPipelinesByDC[b] = c.recentPipelinesByDC[b] || [], c.recentPipelinesByDC[b].push(a), ka(a) && (c.incompletePipelinesByDC[b] = c.incompletePipelinesByDC[b] || [], c.incompletePipelinesByDC[b].push(a));
});
}
}
}, la = function() {
A && (c.recentPipelinesByDC = {}, c.recentBuildsByOutputImage = {}, _.each(e.interestingBuilds(A), function(a) {
return E(a) ? void ka(a) :void ia(a);
}));
}, ma = function() {
A && (c.recentPipelinesByDC = {}, c.incompletePipelinesByDC = {}, c.recentBuildsByOutputImage = {}, _.each(e.interestingBuilds(A), function(a) {
return E(a) ? void la(a) :void ia(a);
}), c.pipelinesForDC = {}, _.each(z, function(a) {
_.each(e.usesDeploymentConfigs(a), function(b) {
c.pipelinesForDC[b] = c.pipelinesForDC[b] || [], c.pipelinesForDC[b].push(a);
});
}));
}, na = function() {
var a = _.isEmpty(r) && _.isEmpty(t) && _.isEmpty(c.monopodsByService) && _.isEmpty(u) && _.isEmpty(w) && _.isEmpty(x), b = r && y && u && w && x;
c.renderOptions.showGetStarted = b && a, c.renderOptions.showLoading = !b && a;
}, na = function() {
}, oa = function() {
var a = d.isAlertPermanentlyHidden("overview-quota-limit-reached", c.projectName);
if (!a && p.isAnyQuotaExceeded(c.quotas, c.clusterQuotas)) {
if (c.alerts.quotaExceeded) return;
Expand Down Expand Up @@ -4432,11 +4436,11 @@ var b = _.get(c, [ a, "" ], {});
return !_.isEmpty(b);
});
};
var oa = [];
var pa = [];
c.getHPA = function(a) {
if (!B) return null;
var b = _.get(a, "kind"), c = _.get(a, "metadata.name");
return _.get(C, [ b, c ], oa);
return _.get(C, [ b, c ], pa);
}, window.OPENSHIFT_CONSTANTS.DISABLE_OVERVIEW_METRICS || (o.isAvailable(!0).then(function(a) {
c.showMetrics = a;
}), c.$on("metrics-connection-failed", function(a, b) {
Expand All @@ -4457,64 +4461,64 @@ return d.permanentlyHideAlert("metrics-connection-failed"), !0;
} ]
});
}));
var pa = a("isIE")() || a("isEdge")();
var qa = a("isIE")() || a("isEdge")();
k.get(b.project).then(_.spread(function(a, b) {
c.project = a, c.projectContext = b, D.push(f.watch("pods", b, function(a) {
y = a.by("metadata.name"), aa(), ma(), i.log("pods", y);
y = a.by("metadata.name"), aa(), na(), i.log("pods", y);
})), D.push(f.watch("services", b, function(a) {
c.services = r = a.by("metadata.name"), ga(), aa(), P(), U(), T(), V(), Y(), ha(), ma(), i.log("services (subscribe)", r);
c.services = r = a.by("metadata.name"), ga(), aa(), P(), U(), T(), V(), Y(), ha(), na(), i.log("services (subscribe)", r);
}, {
poll:pa,
poll:qa,
pollInterval:6e4
})), D.push(f.watch("builds", b, function(a) {
A = a.by("metadata.name"), la(), ma(), i.log("builds (subscribe)", A);
A = a.by("metadata.name"), ma(), na(), i.log("builds (subscribe)", A);
})), D.push(f.watch("buildConfigs", b, function(a) {
z = a.by("metadata.name"), la(), i.log("builds (subscribe)", A);
z = a.by("metadata.name"), ma(), i.log("builds (subscribe)", A);
}, {
poll:pa,
poll:qa,
pollInterval:6e4
})), D.push(f.watch("routes", b, function(a) {
q = a.by("metadata.name"), O(), ga(), ha(), i.log("routes (subscribe)", c.routesByService);
}, {
poll:pa,
poll:qa,
pollInterval:6e4
})), D.push(f.watch("replicationcontrollers", b, function(a) {
c.replicationControllersByName = u = a.by("metadata.name"), U(), T(), aa(), la(), ma(), i.log("replicationcontrollers (subscribe)", u);
c.replicationControllersByName = u = a.by("metadata.name"), U(), T(), aa(), ma(), na(), i.log("replicationcontrollers (subscribe)", u);
})), D.push(f.watch("deploymentconfigs", b, function(a) {
t = a.by("metadata.name"), P(), T(), ma(), i.log("deploymentconfigs (subscribe)", t);
t = a.by("metadata.name"), P(), T(), na(), i.log("deploymentconfigs (subscribe)", t);
})), D.push(f.watch({
group:"extensions",
resource:"replicasets"
}, b, function(a) {
w = a.by("metadata.name"), aa(), V(), X(), ma(), i.log("replicasets (subscribe)", w);
w = a.by("metadata.name"), aa(), V(), X(), na(), i.log("replicasets (subscribe)", w);
})), D.push(f.watch({
group:"apps",
resource:"petsets"
}, b, function(a) {
x = a.by("metadata.name"), aa(), Y(), ma(), i.log("petsets (subscribe)", x);
x = a.by("metadata.name"), aa(), Y(), na(), i.log("petsets (subscribe)", x);
}, {
poll:pa,
poll:qa,
pollInterval:6e4
})), D.push(f.watch({
group:"extensions",
resource:"deployments"
}, b, function(a) {
s = a.by("metadata.name"), Q(), X(), ma(), i.log("deployments (subscribe)", s);
s = a.by("metadata.name"), Q(), X(), na(), i.log("deployments (subscribe)", s);
})), D.push(f.watch({
group:"extensions",
resource:"horizontalpodautoscalers"
}, b, function(a) {
B = a.by("metadata.name"), Z();
}, {
poll:pa,
poll:qa,
pollInterval:6e4
})), D.push(f.watch("resourcequotas", b, function(a) {
c.quotas = a.by("metadata.name"), na();
c.quotas = a.by("metadata.name"), oa();
}, {
poll:!0,
pollInterval:6e4
})), D.push(f.watch("appliedclusterresourcequotas", b, function(a) {
c.clusterQuotas = a.by("metadata.name"), na();
c.clusterQuotas = a.by("metadata.name"), oa();
}, {
poll:!0,
pollInterval:6e4
Expand Down Expand Up @@ -12536,72 +12540,82 @@ restrict:"E",
scope:!0,
templateUrl:"views/overview/_set.html"
};
}), angular.module("openshiftConsole").directive("overviewDeploymentConfig", [ "$filter", "$uibModal", "DeploymentsService", "Navigate", function(a, b, c, d) {
}), angular.module("openshiftConsole").directive("overviewDeploymentConfig", [ "$filter", "$uibModal", "BuildsService", "DeploymentsService", "Navigate", function(a, b, c, d, e) {
return {
restrict:"E",
scope:!0,
templateUrl:"views/overview/_dc.html",
link:function(e) {
var f = a("orderObjectsByDate"), g = a("deploymentIsInProgress");
e.$watch("scalableReplicationControllerByDC", function() {
var a = _.get(e, "deploymentConfig.metadata.name");
e.activeReplicationController = _.get(e, [ "scalableReplicationControllerByDC", a ]);
}), e.$watch("visibleRCByDC", function(a) {
var b = _.get(e, "deploymentConfig.metadata.name"), c = _.get(a, [ b ], []);
e.orderedReplicationControllers = f(c, !0), e.inProgressDeployment = _.find(e.orderedReplicationControllers, g);
}), e.$watch("deploymentConfig", function(a) {
link:function(f) {
var g = a("orderObjectsByDate"), h = a("deploymentIsInProgress");
f.$watch("scalableReplicationControllerByDC", function() {
var a = _.get(f, "deploymentConfig.metadata.name");
f.activeReplicationController = _.get(f, [ "scalableReplicationControllerByDC", a ]);
}), f.$watch("visibleRCByDC", function(a) {
var b = _.get(f, "deploymentConfig.metadata.name"), c = _.get(a, [ b ], []);
f.orderedReplicationControllers = g(c, !0), f.inProgressDeployment = _.find(f.orderedReplicationControllers, h);
}), f.$watch("deploymentConfig", function(a) {
var b = _.get(a, "spec.triggers", []);
e.imageChangeTriggers = _.filter(b, function(a) {
f.imageChangeTriggers = _.filter(b, function(a) {
return "ImageChange" === a.type && _.get(a, "imageChangeParams.automatic");
});
}), e.urlForImageChangeTrigger = function(b) {
var c = a("stripTag")(_.get(b, "imageChangeParams.from.name")), f = _.get(b, "imageChangeParams.from.namespace", e.deploymentConfig.metadata.namespace);
return d.resourceURL(c, "ImageStream", f);
}, e.startDeployment = function() {
c.startLatestDeployment(e.deploymentConfig, {
namespace:e.deploymentConfig.metadata.namespace
}, e);
}), f.urlForImageChangeTrigger = function(b) {
var c = a("stripTag")(_.get(b, "imageChangeParams.from.name")), d = _.get(b, "imageChangeParams.from.namespace", f.deploymentConfig.metadata.namespace);
return e.resourceURL(c, "ImageStream", d);
}, f.startPipeline = function(b) {
c.startBuild(b.metadata.name, {
namespace:b.metadata.namespace
}).then(_.noop, function(b) {
f.alerts["start-pipeline"] = {
type:"error",
message:"An error occurred while starting the pipeline.",
details:a("getErrorDetails")(b)
};
var h;
e.$watch("deploymentConfig.spec.paused", function() {
h = !1;
}), e.resumeDeployment = function() {
h || (h = !0, c.setPaused(e.deploymentConfig, !1, {
namespace:e.deploymentConfig.metadata.namespace
});
}, f.startDeployment = function() {
d.startLatestDeployment(f.deploymentConfig, {
namespace:f.deploymentConfig.metadata.namespace
}, f);
};
var i;
f.$watch("deploymentConfig.spec.paused", function() {
i = !1;
}), f.resumeDeployment = function() {
i || (i = !0, d.setPaused(f.deploymentConfig, !1, {
namespace:f.deploymentConfig.metadata.namespace
}).then(_.noop, function(b) {
h = !1, e.alerts["resume-deployment"] = {
i = !1, f.alerts["resume-deployment"] = {
type:"error",
message:"An error occurred resuming the deployment.",
details:a("getErrorDetails")(b)
};
}));
}, e.cancelDeployment = function() {
var a = e.inProgressDeployment;
}, f.cancelDeployment = function() {
var a = f.inProgressDeployment;
if (a) {
var d = a.metadata.name, f = _.get(e, "deploymentConfig.status.latestVersion"), h = b.open({
var c = a.metadata.name, e = _.get(f, "deploymentConfig.status.latestVersion"), g = b.open({
animation:!0,
templateUrl:"views/modals/confirm.html",
controller:"ConfirmModalController",
resolve:{
modalConfig:function() {
return {
message:"Cancel deployment " + d + "?",
details:f ? "This will attempt to stop the in-progress deployment and rollback to the previous deployment, #" + f + ". It may take some time to complete." :"This will attempt to stop the in-progress deployment and may take some time to complete.",
message:"Cancel deployment " + c + "?",
details:e ? "This will attempt to stop the in-progress deployment and rollback to the previous deployment, #" + e + ". It may take some time to complete." :"This will attempt to stop the in-progress deployment and may take some time to complete.",
okButtonText:"Yes, cancel",
okButtonClass:"btn-danger",
cancelButtonText:"No, don't cancel"
};
}
}
});
h.result.then(function() {
var a = _.get(e, [ "replicationControllersByName", d ]);
return a ? g(a) ? void c.cancelRunningDeployment(a, e.projectContext, e) :void (e.alerts["cancel-deployment"] = {
g.result.then(function() {
var a = _.get(f, [ "replicationControllersByName", c ]);
return a ? h(a) ? void d.cancelRunningDeployment(a, f.projectContext, f) :void (f.alerts["cancel-deployment"] = {
type:"error",
message:"Deployment " + d + " is no longer in progress."
}) :void (e.alerts["cancel-deployment"] = {
message:"Deployment " + c + " is no longer in progress."
}) :void (f.alerts["cancel-deployment"] = {
type:"error",
message:"Deployment " + d + " no longer exists."
message:"Deployment " + c + " no longer exists."
});
});
}
Expand Down
16 changes: 14 additions & 2 deletions dist/scripts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -10216,12 +10216,24 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"</span>\n" +
"</div>\n" +
"<div ng-if=\"!imageChangeTriggers.length\">\n" +
"<div ng-if=\"pipeline = pipelinesForDC[deploymentConfig.metadata.name][0]\">\n" +
"<p>\n" +
"This deployment config is part of pipeline\n" +
"<a ng-href=\"{{pipeline | navigateResourceURL}}\">{{pipeline.metadata.name}}</a>.\n" +
"</p>\n" +
"<div ng-if=\"('buildconfigs/instantiate' | canI : 'create')\">\n" +
"\n" +
"<button class=\"btn btn-primary\" ng-click=\"startPipeline(pipeline)\" ng-disabled=\"incompletePipelinesByDC[deploymentConfig.metadata.name].length\">\n" +
"Start Pipeline\n" +
"</button>\n" +
"</div>\n" +
"</div>\n" +
"<div ng-if=\"!pipelinesForDC[deploymentConfig.metadata.name].length\">\n" +
"<p>\n" +
"No deployments have started for\n" +
"<a ng-href=\"{{deploymentConfig | navigateResourceURL}}\">{{deploymentConfig.metadata.name}}</a>.\n" +
"</p>\n" +
"<div ng-if=\"'deploymentconfigs' | canI : 'update'\" class=\"mar-top-md\">\n" +
"<button class=\"btn btn-primary\" ng-click=\"startDeployment(deploymentConfig)\">\n" +
"<button ng-if=\"'deploymentconfigs' | canI : 'update'\" class=\"btn btn-primary\" ng-click=\"startDeployment(deploymentConfig)\">\n" +
"Start Deployment\n" +
"</button>\n" +
"</div>\n" +
Expand Down

0 comments on commit eea002e

Please sign in to comment.