Skip to content

Commit eea002e

Browse files
author
OpenShift Bot
authored
Merge pull request #958 from spadgett/overview-start-pipeline
Merged by openshift-bot
2 parents 5a88c56 + 464315d commit eea002e

File tree

5 files changed

+144
-71
lines changed

5 files changed

+144
-71
lines changed

app/scripts/controllers/overview.js

+14
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ angular.module('openshiftConsole')
401401
};
402402

403403
var buildConfigForBuild = $filter('buildConfigForBuild');
404+
var isIncompleteBuild = $filter('isIncompleteBuild');
404405
var groupPipelineByDC = function(build) {
405406
if (!buildConfigs) {
406407
return;
@@ -417,6 +418,10 @@ angular.module('openshiftConsole')
417418
_.each(dcNames, function(dcName) {
418419
$scope.recentPipelinesByDC[dcName] = $scope.recentPipelinesByDC[dcName] || [];
419420
$scope.recentPipelinesByDC[dcName].push(build);
421+
if (isIncompleteBuild(build)) {
422+
$scope.incompletePipelinesByDC[dcName] = $scope.incompletePipelinesByDC[dcName] || [];
423+
$scope.incompletePipelinesByDC[dcName].push(build);
424+
}
420425
});
421426
};
422427

@@ -426,6 +431,7 @@ angular.module('openshiftConsole')
426431
}
427432
// reset these maps
428433
$scope.recentPipelinesByDC = {};
434+
$scope.incompletePipelinesByDC = {};
429435
$scope.recentBuildsByOutputImage = {};
430436
_.each(
431437
BuildsService.interestingBuilds(builds),
@@ -436,6 +442,14 @@ angular.module('openshiftConsole')
436442
}
437443
groupPipelineByDC(build);
438444
});
445+
446+
$scope.pipelinesForDC = {};
447+
_.each(buildConfigs, function(buildConfig) {
448+
_.each(BuildsService.usesDeploymentConfigs(buildConfig), function(dcName) {
449+
$scope.pipelinesForDC[dcName] = $scope.pipelinesForDC[dcName] || [];
450+
$scope.pipelinesForDC[dcName].push(buildConfig);
451+
});
452+
});
439453
};
440454

441455

app/scripts/directives/overview/dc.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
'use strict';
22

33
angular.module('openshiftConsole')
4-
.directive('overviewDeploymentConfig', function($filter, $uibModal, DeploymentsService, Navigate) {
4+
.directive('overviewDeploymentConfig',
5+
function($filter,
6+
$uibModal,
7+
BuildsService,
8+
DeploymentsService,
9+
Navigate) {
510
return {
611
restrict: 'E',
712
// Inherit scope from OverviewController. This directive is only used for the overview.
@@ -37,6 +42,18 @@ angular.module('openshiftConsole')
3742
return Navigate.resourceURL(name, 'ImageStream', namespace);
3843
};
3944

45+
$scope.startPipeline = function(pipeline) {
46+
BuildsService
47+
.startBuild(pipeline.metadata.name, { namespace: pipeline.metadata.namespace })
48+
.then(_.noop, function(result) {
49+
$scope.alerts["start-pipeline"] = {
50+
type: "error",
51+
message: "An error occurred while starting the pipeline.",
52+
details: $filter('getErrorDetails')(result)
53+
};
54+
});
55+
};
56+
4057
$scope.startDeployment = function() {
4158
DeploymentsService.startLatestDeployment($scope.deploymentConfig, {
4259
namespace: $scope.deploymentConfig.metadata.namespace

app/views/overview/_dc.html

+22-6
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,28 @@ <h2>No deployments.</h2>
5151
</span>
5252
</div>
5353
<div ng-if="!imageChangeTriggers.length">
54-
<p>
55-
No deployments have started for
56-
<a ng-href="{{deploymentConfig | navigateResourceURL}}">{{deploymentConfig.metadata.name}}</a>.
57-
</p>
58-
<div ng-if="'deploymentconfigs' | canI : 'update'" class="mar-top-md">
59-
<button class="btn btn-primary" ng-click="startDeployment(deploymentConfig)">
54+
<div ng-if="pipeline = pipelinesForDC[deploymentConfig.metadata.name][0]">
55+
<p>
56+
This deployment config is part of pipeline
57+
<a ng-href="{{pipeline | navigateResourceURL}}">{{pipeline.metadata.name}}</a>.
58+
</p>
59+
<div ng-if="('buildconfigs/instantiate' | canI : 'create')">
60+
<!-- Disable the button if a pipeline is running. -->
61+
<button
62+
class="btn btn-primary"
63+
ng-click="startPipeline(pipeline)"
64+
ng-disabled="incompletePipelinesByDC[deploymentConfig.metadata.name].length">
65+
Start Pipeline
66+
</button>
67+
</div>
68+
</div>
69+
<div ng-if="!pipelinesForDC[deploymentConfig.metadata.name].length">
70+
<p>
71+
No deployments have started for
72+
<a ng-href="{{deploymentConfig | navigateResourceURL}}">{{deploymentConfig.metadata.name}}</a>.
73+
</p>
74+
75+
<button ng-if="'deploymentconfigs' | canI : 'update'" class="btn btn-primary" ng-click="startDeployment(deploymentConfig)">
6076
Start Deployment
6177
</button>
6278
</div>

dist/scripts/scripts.js

+76-62
Original file line numberDiff line numberDiff line change
@@ -4376,24 +4376,28 @@ _.set(c, [ "routeWarningsByService", a.metadata.name, b.metadata.name ], d);
43764376
}, ia = function(a) {
43774377
var b = H(_.get(a, "spec.output.to"), a.metadata.namespace);
43784378
c.recentBuildsByOutputImage[b] = c.recentBuildsByOutputImage[b] || [], c.recentBuildsByOutputImage[b].push(a);
4379-
}, ja = a("buildConfigForBuild"), ka = function(a) {
4379+
}, ja = a("buildConfigForBuild"), ka = a("isIncompleteBuild"), la = function(a) {
43804380
if (z) {
43814381
var b = ja(a), d = z[b];
43824382
if (d) {
43834383
var f = e.usesDeploymentConfigs(d);
43844384
_.each(f, function(b) {
4385-
c.recentPipelinesByDC[b] = c.recentPipelinesByDC[b] || [], c.recentPipelinesByDC[b].push(a);
4385+
c.recentPipelinesByDC[b] = c.recentPipelinesByDC[b] || [], c.recentPipelinesByDC[b].push(a), ka(a) && (c.incompletePipelinesByDC[b] = c.incompletePipelinesByDC[b] || [], c.incompletePipelinesByDC[b].push(a));
43864386
});
43874387
}
43884388
}
4389-
}, la = function() {
4390-
A && (c.recentPipelinesByDC = {}, c.recentBuildsByOutputImage = {}, _.each(e.interestingBuilds(A), function(a) {
4391-
return E(a) ? void ka(a) :void ia(a);
4392-
}));
43934389
}, ma = function() {
4390+
A && (c.recentPipelinesByDC = {}, c.incompletePipelinesByDC = {}, c.recentBuildsByOutputImage = {}, _.each(e.interestingBuilds(A), function(a) {
4391+
return E(a) ? void la(a) :void ia(a);
4392+
}), c.pipelinesForDC = {}, _.each(z, function(a) {
4393+
_.each(e.usesDeploymentConfigs(a), function(b) {
4394+
c.pipelinesForDC[b] = c.pipelinesForDC[b] || [], c.pipelinesForDC[b].push(a);
4395+
});
4396+
}));
4397+
}, na = function() {
43944398
var a = _.isEmpty(r) && _.isEmpty(t) && _.isEmpty(c.monopodsByService) && _.isEmpty(u) && _.isEmpty(w) && _.isEmpty(x), b = r && y && u && w && x;
43954399
c.renderOptions.showGetStarted = b && a, c.renderOptions.showLoading = !b && a;
4396-
}, na = function() {
4400+
}, oa = function() {
43974401
var a = d.isAlertPermanentlyHidden("overview-quota-limit-reached", c.projectName);
43984402
if (!a && p.isAnyQuotaExceeded(c.quotas, c.clusterQuotas)) {
43994403
if (c.alerts.quotaExceeded) return;
@@ -4432,11 +4436,11 @@ var b = _.get(c, [ a, "" ], {});
44324436
return !_.isEmpty(b);
44334437
});
44344438
};
4435-
var oa = [];
4439+
var pa = [];
44364440
c.getHPA = function(a) {
44374441
if (!B) return null;
44384442
var b = _.get(a, "kind"), c = _.get(a, "metadata.name");
4439-
return _.get(C, [ b, c ], oa);
4443+
return _.get(C, [ b, c ], pa);
44404444
}, window.OPENSHIFT_CONSTANTS.DISABLE_OVERVIEW_METRICS || (o.isAvailable(!0).then(function(a) {
44414445
c.showMetrics = a;
44424446
}), c.$on("metrics-connection-failed", function(a, b) {
@@ -4457,64 +4461,64 @@ return d.permanentlyHideAlert("metrics-connection-failed"), !0;
44574461
} ]
44584462
});
44594463
}));
4460-
var pa = a("isIE")() || a("isEdge")();
4464+
var qa = a("isIE")() || a("isEdge")();
44614465
k.get(b.project).then(_.spread(function(a, b) {
44624466
c.project = a, c.projectContext = b, D.push(f.watch("pods", b, function(a) {
4463-
y = a.by("metadata.name"), aa(), ma(), i.log("pods", y);
4467+
y = a.by("metadata.name"), aa(), na(), i.log("pods", y);
44644468
})), D.push(f.watch("services", b, function(a) {
4465-
c.services = r = a.by("metadata.name"), ga(), aa(), P(), U(), T(), V(), Y(), ha(), ma(), i.log("services (subscribe)", r);
4469+
c.services = r = a.by("metadata.name"), ga(), aa(), P(), U(), T(), V(), Y(), ha(), na(), i.log("services (subscribe)", r);
44664470
}, {
4467-
poll:pa,
4471+
poll:qa,
44684472
pollInterval:6e4
44694473
})), D.push(f.watch("builds", b, function(a) {
4470-
A = a.by("metadata.name"), la(), ma(), i.log("builds (subscribe)", A);
4474+
A = a.by("metadata.name"), ma(), na(), i.log("builds (subscribe)", A);
44714475
})), D.push(f.watch("buildConfigs", b, function(a) {
4472-
z = a.by("metadata.name"), la(), i.log("builds (subscribe)", A);
4476+
z = a.by("metadata.name"), ma(), i.log("builds (subscribe)", A);
44734477
}, {
4474-
poll:pa,
4478+
poll:qa,
44754479
pollInterval:6e4
44764480
})), D.push(f.watch("routes", b, function(a) {
44774481
q = a.by("metadata.name"), O(), ga(), ha(), i.log("routes (subscribe)", c.routesByService);
44784482
}, {
4479-
poll:pa,
4483+
poll:qa,
44804484
pollInterval:6e4
44814485
})), D.push(f.watch("replicationcontrollers", b, function(a) {
4482-
c.replicationControllersByName = u = a.by("metadata.name"), U(), T(), aa(), la(), ma(), i.log("replicationcontrollers (subscribe)", u);
4486+
c.replicationControllersByName = u = a.by("metadata.name"), U(), T(), aa(), ma(), na(), i.log("replicationcontrollers (subscribe)", u);
44834487
})), D.push(f.watch("deploymentconfigs", b, function(a) {
4484-
t = a.by("metadata.name"), P(), T(), ma(), i.log("deploymentconfigs (subscribe)", t);
4488+
t = a.by("metadata.name"), P(), T(), na(), i.log("deploymentconfigs (subscribe)", t);
44854489
})), D.push(f.watch({
44864490
group:"extensions",
44874491
resource:"replicasets"
44884492
}, b, function(a) {
4489-
w = a.by("metadata.name"), aa(), V(), X(), ma(), i.log("replicasets (subscribe)", w);
4493+
w = a.by("metadata.name"), aa(), V(), X(), na(), i.log("replicasets (subscribe)", w);
44904494
})), D.push(f.watch({
44914495
group:"apps",
44924496
resource:"petsets"
44934497
}, b, function(a) {
4494-
x = a.by("metadata.name"), aa(), Y(), ma(), i.log("petsets (subscribe)", x);
4498+
x = a.by("metadata.name"), aa(), Y(), na(), i.log("petsets (subscribe)", x);
44954499
}, {
4496-
poll:pa,
4500+
poll:qa,
44974501
pollInterval:6e4
44984502
})), D.push(f.watch({
44994503
group:"extensions",
45004504
resource:"deployments"
45014505
}, b, function(a) {
4502-
s = a.by("metadata.name"), Q(), X(), ma(), i.log("deployments (subscribe)", s);
4506+
s = a.by("metadata.name"), Q(), X(), na(), i.log("deployments (subscribe)", s);
45034507
})), D.push(f.watch({
45044508
group:"extensions",
45054509
resource:"horizontalpodautoscalers"
45064510
}, b, function(a) {
45074511
B = a.by("metadata.name"), Z();
45084512
}, {
4509-
poll:pa,
4513+
poll:qa,
45104514
pollInterval:6e4
45114515
})), D.push(f.watch("resourcequotas", b, function(a) {
4512-
c.quotas = a.by("metadata.name"), na();
4516+
c.quotas = a.by("metadata.name"), oa();
45134517
}, {
45144518
poll:!0,
45154519
pollInterval:6e4
45164520
})), D.push(f.watch("appliedclusterresourcequotas", b, function(a) {
4517-
c.clusterQuotas = a.by("metadata.name"), na();
4521+
c.clusterQuotas = a.by("metadata.name"), oa();
45184522
}, {
45194523
poll:!0,
45204524
pollInterval:6e4
@@ -12536,72 +12540,82 @@ restrict:"E",
1253612540
scope:!0,
1253712541
templateUrl:"views/overview/_set.html"
1253812542
};
12539-
}), angular.module("openshiftConsole").directive("overviewDeploymentConfig", [ "$filter", "$uibModal", "DeploymentsService", "Navigate", function(a, b, c, d) {
12543+
}), angular.module("openshiftConsole").directive("overviewDeploymentConfig", [ "$filter", "$uibModal", "BuildsService", "DeploymentsService", "Navigate", function(a, b, c, d, e) {
1254012544
return {
1254112545
restrict:"E",
1254212546
scope:!0,
1254312547
templateUrl:"views/overview/_dc.html",
12544-
link:function(e) {
12545-
var f = a("orderObjectsByDate"), g = a("deploymentIsInProgress");
12546-
e.$watch("scalableReplicationControllerByDC", function() {
12547-
var a = _.get(e, "deploymentConfig.metadata.name");
12548-
e.activeReplicationController = _.get(e, [ "scalableReplicationControllerByDC", a ]);
12549-
}), e.$watch("visibleRCByDC", function(a) {
12550-
var b = _.get(e, "deploymentConfig.metadata.name"), c = _.get(a, [ b ], []);
12551-
e.orderedReplicationControllers = f(c, !0), e.inProgressDeployment = _.find(e.orderedReplicationControllers, g);
12552-
}), e.$watch("deploymentConfig", function(a) {
12548+
link:function(f) {
12549+
var g = a("orderObjectsByDate"), h = a("deploymentIsInProgress");
12550+
f.$watch("scalableReplicationControllerByDC", function() {
12551+
var a = _.get(f, "deploymentConfig.metadata.name");
12552+
f.activeReplicationController = _.get(f, [ "scalableReplicationControllerByDC", a ]);
12553+
}), f.$watch("visibleRCByDC", function(a) {
12554+
var b = _.get(f, "deploymentConfig.metadata.name"), c = _.get(a, [ b ], []);
12555+
f.orderedReplicationControllers = g(c, !0), f.inProgressDeployment = _.find(f.orderedReplicationControllers, h);
12556+
}), f.$watch("deploymentConfig", function(a) {
1255312557
var b = _.get(a, "spec.triggers", []);
12554-
e.imageChangeTriggers = _.filter(b, function(a) {
12558+
f.imageChangeTriggers = _.filter(b, function(a) {
1255512559
return "ImageChange" === a.type && _.get(a, "imageChangeParams.automatic");
1255612560
});
12557-
}), e.urlForImageChangeTrigger = function(b) {
12558-
var c = a("stripTag")(_.get(b, "imageChangeParams.from.name")), f = _.get(b, "imageChangeParams.from.namespace", e.deploymentConfig.metadata.namespace);
12559-
return d.resourceURL(c, "ImageStream", f);
12560-
}, e.startDeployment = function() {
12561-
c.startLatestDeployment(e.deploymentConfig, {
12562-
namespace:e.deploymentConfig.metadata.namespace
12563-
}, e);
12561+
}), f.urlForImageChangeTrigger = function(b) {
12562+
var c = a("stripTag")(_.get(b, "imageChangeParams.from.name")), d = _.get(b, "imageChangeParams.from.namespace", f.deploymentConfig.metadata.namespace);
12563+
return e.resourceURL(c, "ImageStream", d);
12564+
}, f.startPipeline = function(b) {
12565+
c.startBuild(b.metadata.name, {
12566+
namespace:b.metadata.namespace
12567+
}).then(_.noop, function(b) {
12568+
f.alerts["start-pipeline"] = {
12569+
type:"error",
12570+
message:"An error occurred while starting the pipeline.",
12571+
details:a("getErrorDetails")(b)
1256412572
};
12565-
var h;
12566-
e.$watch("deploymentConfig.spec.paused", function() {
12567-
h = !1;
12568-
}), e.resumeDeployment = function() {
12569-
h || (h = !0, c.setPaused(e.deploymentConfig, !1, {
12570-
namespace:e.deploymentConfig.metadata.namespace
12573+
});
12574+
}, f.startDeployment = function() {
12575+
d.startLatestDeployment(f.deploymentConfig, {
12576+
namespace:f.deploymentConfig.metadata.namespace
12577+
}, f);
12578+
};
12579+
var i;
12580+
f.$watch("deploymentConfig.spec.paused", function() {
12581+
i = !1;
12582+
}), f.resumeDeployment = function() {
12583+
i || (i = !0, d.setPaused(f.deploymentConfig, !1, {
12584+
namespace:f.deploymentConfig.metadata.namespace
1257112585
}).then(_.noop, function(b) {
12572-
h = !1, e.alerts["resume-deployment"] = {
12586+
i = !1, f.alerts["resume-deployment"] = {
1257312587
type:"error",
1257412588
message:"An error occurred resuming the deployment.",
1257512589
details:a("getErrorDetails")(b)
1257612590
};
1257712591
}));
12578-
}, e.cancelDeployment = function() {
12579-
var a = e.inProgressDeployment;
12592+
}, f.cancelDeployment = function() {
12593+
var a = f.inProgressDeployment;
1258012594
if (a) {
12581-
var d = a.metadata.name, f = _.get(e, "deploymentConfig.status.latestVersion"), h = b.open({
12595+
var c = a.metadata.name, e = _.get(f, "deploymentConfig.status.latestVersion"), g = b.open({
1258212596
animation:!0,
1258312597
templateUrl:"views/modals/confirm.html",
1258412598
controller:"ConfirmModalController",
1258512599
resolve:{
1258612600
modalConfig:function() {
1258712601
return {
12588-
message:"Cancel deployment " + d + "?",
12589-
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.",
12602+
message:"Cancel deployment " + c + "?",
12603+
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.",
1259012604
okButtonText:"Yes, cancel",
1259112605
okButtonClass:"btn-danger",
1259212606
cancelButtonText:"No, don't cancel"
1259312607
};
1259412608
}
1259512609
}
1259612610
});
12597-
h.result.then(function() {
12598-
var a = _.get(e, [ "replicationControllersByName", d ]);
12599-
return a ? g(a) ? void c.cancelRunningDeployment(a, e.projectContext, e) :void (e.alerts["cancel-deployment"] = {
12611+
g.result.then(function() {
12612+
var a = _.get(f, [ "replicationControllersByName", c ]);
12613+
return a ? h(a) ? void d.cancelRunningDeployment(a, f.projectContext, f) :void (f.alerts["cancel-deployment"] = {
1260012614
type:"error",
12601-
message:"Deployment " + d + " is no longer in progress."
12602-
}) :void (e.alerts["cancel-deployment"] = {
12615+
message:"Deployment " + c + " is no longer in progress."
12616+
}) :void (f.alerts["cancel-deployment"] = {
1260312617
type:"error",
12604-
message:"Deployment " + d + " no longer exists."
12618+
message:"Deployment " + c + " no longer exists."
1260512619
});
1260612620
});
1260712621
}

dist/scripts/templates.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -10216,12 +10216,24 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1021610216
"</span>\n" +
1021710217
"</div>\n" +
1021810218
"<div ng-if=\"!imageChangeTriggers.length\">\n" +
10219+
"<div ng-if=\"pipeline = pipelinesForDC[deploymentConfig.metadata.name][0]\">\n" +
10220+
"<p>\n" +
10221+
"This deployment config is part of pipeline\n" +
10222+
"<a ng-href=\"{{pipeline | navigateResourceURL}}\">{{pipeline.metadata.name}}</a>.\n" +
10223+
"</p>\n" +
10224+
"<div ng-if=\"('buildconfigs/instantiate' | canI : 'create')\">\n" +
10225+
"\n" +
10226+
"<button class=\"btn btn-primary\" ng-click=\"startPipeline(pipeline)\" ng-disabled=\"incompletePipelinesByDC[deploymentConfig.metadata.name].length\">\n" +
10227+
"Start Pipeline\n" +
10228+
"</button>\n" +
10229+
"</div>\n" +
10230+
"</div>\n" +
10231+
"<div ng-if=\"!pipelinesForDC[deploymentConfig.metadata.name].length\">\n" +
1021910232
"<p>\n" +
1022010233
"No deployments have started for\n" +
1022110234
"<a ng-href=\"{{deploymentConfig | navigateResourceURL}}\">{{deploymentConfig.metadata.name}}</a>.\n" +
1022210235
"</p>\n" +
10223-
"<div ng-if=\"'deploymentconfigs' | canI : 'update'\" class=\"mar-top-md\">\n" +
10224-
"<button class=\"btn btn-primary\" ng-click=\"startDeployment(deploymentConfig)\">\n" +
10236+
"<button ng-if=\"'deploymentconfigs' | canI : 'update'\" class=\"btn btn-primary\" ng-click=\"startDeployment(deploymentConfig)\">\n" +
1022510237
"Start Deployment\n" +
1022610238
"</button>\n" +
1022710239
"</div>\n" +

0 commit comments

Comments
 (0)