Skip to content

Commit 3281408

Browse files
committed
Deployment configs on the web console, with deployments grouped
1 parent 0189d1e commit 3281408

File tree

4 files changed

+419
-17
lines changed

4 files changed

+419
-17
lines changed

assets/app/scripts/controllers/deployments.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
angular.module('openshiftConsole')
1111
.controller('DeploymentsController', function ($scope, DataService, $filter, LabelFilter, Logger, ImageStreamResolver) {
1212
$scope.deployments = {};
13-
$scope.podTemplates = {};
1413
$scope.unfilteredDeployments = {};
14+
$scope.deploymentConfigs = {};
15+
$scope.deploymentsByDeploymentConfig = {};
16+
$scope.podTemplates = {};
1517
$scope.imageStreams = {};
1618
$scope.imagesByDockerReference = {};
1719
$scope.imageStreamImageRefByDockerReference = {}; // lets us determine if a particular container's docker image reference belongs to an imageStream
@@ -36,9 +38,24 @@ angular.module('openshiftConsole')
3638
ImageStreamResolver.fetchReferencedImageStreamImages($scope.podTemplates, $scope.imagesByDockerReference, $scope.imageStreamImageRefByDockerReference, $scope);
3739
$scope.emptyMessage = "No deployments to show";
3840
updateFilterWarning();
41+
42+
$scope.deploymentsByDeploymentConfig = {};
43+
angular.forEach($scope.deployments, function(deployment, deploymentName) {
44+
if (deployment.metadata.annotations && deployment.metadata.annotations.deploymentConfig) {
45+
var deploymentConfigName = deployment.metadata.annotations.deploymentConfig;
46+
$scope.deploymentsByDeploymentConfig[deploymentConfigName] = $scope.deploymentsByDeploymentConfig[deploymentConfigName] || {};
47+
$scope.deploymentsByDeploymentConfig[deploymentConfigName][deploymentName] = deployment;
48+
}
49+
});
50+
3951
Logger.log("deployments (subscribe)", $scope.deployments);
4052
}));
4153

54+
watches.push(DataService.watch("deploymentConfigs", $scope, function(deploymentConfigs) {
55+
$scope.deploymentConfigs = deploymentConfigs.by("metadata.name");
56+
Logger.log("deploymentConfigs (subscribe)", $scope.deploymentConfigs);
57+
}));
58+
4259
// Sets up subscription for imageStreams
4360
watches.push(DataService.watch("imageStreams", $scope, function(imageStreams) {
4461
$scope.imageStreams = imageStreams.by("metadata.name");

assets/app/scripts/filters/util.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ angular.module('openshiftConsole')
126126
return "http://docs.openshift.org/latest/dev_guide/builds.html#webhook-triggers";
127127
case "start-build":
128128
return "http://docs.openshift.org/latest/dev_guide/builds.html#starting-a-build";
129+
case "deployment-operations":
130+
return "http://docs.openshift.org/latest/cli_reference/basic_cli_operations.html#deployment-operations";
129131
default:
130132
return "http://docs.openshift.org/latest/welcome/index.html";
131133
}

assets/app/views/deployments.html

Lines changed: 203 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,209 @@ <h1>Deployments</h1>
99
<div>
1010
<em>{{emptyMessage}}</em>
1111
</div>
12-
</div>
13-
<div style="margin-bottom: 10px;" ng-repeat="deployment in deployments">
14-
<h3>{{deployment.metadata.annotations.deploymentConfig}} <span class="small">({{deployment.metadata.name}})</span></h3>
15-
<div>Created: <relative-timestamp timestamp="deployment.metadata.creationTimestamp"></relative-timestamp></div>
16-
<div>Status: {{deployment.metadata.annotations.deploymentStatus}}</div>
17-
<div>Version: {{deployment.metadata.annotations.deploymentVersion}}</div>
18-
<div>Replicas: {{deployment.spec.replicas}}</div>
19-
<pod-template ng-init="podTemplate = deployment.spec.template"></pod-template>
12+
</div>
13+
14+
<div class="tile" ng-repeat="(deploymentConfigName, deploymentConfig) in deploymentConfigs track by (deploymentConfig | uid)">
15+
<div>
16+
<h2>{{deploymentConfigName}}</h2>
17+
<dl class="dl-horizontal left indent">
18+
<div>
19+
<dt>Created:</dt>
20+
<dd><relative-timestamp timestamp="deploymentConfig.metadata.creationTimestamp"></relative-timestamp></dd>
21+
</div>
22+
<div>
23+
<dt>Labels:</dt><dd ng-if="!deploymentConfig.metadata.labels">none</dd>
24+
<dd ng-repeat="(labelKey, labelValue) in deploymentConfig.metadata.labels">{{labelKey}}={{labelValue}}<span ng-show="!$last">, </span></dd>
25+
</div>
26+
<div>
27+
<dt>Latest Version:</dt>
28+
<dd>{{deploymentConfig.latestVersion}}</dd>
29+
</div>
30+
<div ng-if="deploymentConfig.template.strategy.type">
31+
<dt>Strategy:</dt>
32+
<dd>{{deploymentConfig.template.strategy.type}}</dd>
33+
</div>
34+
35+
<div>
36+
<h3>Template:</h3>
37+
<dl class="dl-horizontal left indent">
38+
<dt>Selectors:</dt><dd ng-if="!deploymentConfig.template.controllerTemplate.replicaSelector">none</dd>
39+
<dd ng-repeat="(selectorLabel, selectorValue) in deploymentConfig.template.controllerTemplate.replicaSelector">{{selectorLabel}}={{selectorValue}}<span ng-show="!$last">, </span></dd>
40+
<dt>Replicas:</dt>
41+
<dd>
42+
{{deploymentConfig.template.controllerTemplate.replicas}}
43+
</dd>
44+
</dl>
45+
</div>
46+
47+
<div>
48+
<h3>Triggers:</h3>
49+
<!---<dl class="dl-horizontal left indent">
50+
<dt>Manual:</dt>
51+
<dd>
52+
<span>
53+
<button class="btn btn-primary" ng-click="startLatestDeployment(deploymentConfigName)" ng-disabled="">Start Deployment</button>
54+
<span>
55+
</dd>
56+
</dl>-->
57+
58+
<dl class="dl-horizontal left indent">
59+
<dt>Manual (CLI):
60+
<a href="{{'deployment-operations' | helpLink}}" target="_blank">
61+
<span class="learn-more-block">Learn more <i class="fa fa-external-link"> </i></span>
62+
</a>
63+
</dt>
64+
<dd>
65+
<code>osc deploy {{deploymentConfigName}} --latest -n {{project.metadata.name}}</code>
66+
<copy-to-clipboard-button clipboard-text="'osc deploy ' + deploymentConfigName + ' --latest -n ' + project.metadata.name"></copy-to-clipboard-button>
67+
</dd>
68+
</dl>
69+
70+
<dl class="dl-horizontal left indent">
71+
<div ng-repeat="trigger in deploymentConfig.triggers">
72+
<span ng-switch="trigger.type">
73+
<span ng-switch-default>{{trigger.type}}</span>
74+
<span ng-switch-when="ImageChange">
75+
<div ng-switch="deploymentConfig.template.strategy.type">
76+
<div ng-switch-when="Recreate">
77+
<dl class="dl-horizontal" ng-if="trigger.imageChangeParams.from">
78+
<dt>
79+
New image for:
80+
</dt>
81+
<dd>
82+
Image stream {{trigger.imageChangeParams.from | imageRepoReference : trigger.imageChangeParams.from.kind : trigger.imageChangeParams.tag}}
83+
</dd>
84+
</dl>
85+
</div>
86+
</div>
87+
</span>
88+
<span ng-switch-when="ConfigChange">
89+
<dt>Change of:</dt>
90+
<dd>Config</dd>
91+
</span>
92+
</span>
93+
</div>
94+
</dl>
95+
</div>
96+
97+
<div class="well" style="margin-bottom: 10px;" ng-repeat="deployment in deploymentsByDeploymentConfig[deploymentConfigName] | orderObjectsByDate : true">
98+
<h3>
99+
{{deployment.metadata.name}}
100+
<span ng-if="deployment.metadata.annotations.deploymentVersion == deploymentConfig.latestVersion">(latest)</span>
101+
</h3>
102+
<div>
103+
<dt>Created:</dt>
104+
<dd><relative-timestamp timestamp="deployment.metadata.creationTimestamp"></relative-timestamp></div></dd>
105+
<div>
106+
<span>
107+
<dt>Status:</dt>
108+
<dd>
109+
<span>{{deployment.metadata.annotations.deploymentStatus}}</span>
110+
<span ng-switch="deployment.metadata.annotations.deploymentStatus" class="hide-ng-leave">
111+
<span ng-switch-when="Running"> for <duration-until-now timestamp="deployment.metadata.creationTimestamp"></duration-until-now></span>
112+
<span ng-switch-when="New"> for <duration-until-now timestamp="deployment.metadata.creationTimestamp"></duration-until-now></span>
113+
<span ng-switch-when="Pending"> for <duration-until-now timestamp="deployment.metadata.creationTimestamp"></duration-until-now></span>
114+
</span>
115+
<span ng-switch="deployment.metadata.annotations.deploymentStatus" class="hide-ng-leave">
116+
<span style="margin-left: 5px;" ng-switch-default class="fa fa-refresh fa-spin" aria-hidden="true"></span>
117+
<span ng-switch-when="Complete" class="fa fa-check text-success" aria-hidden="true"></span>
118+
<span ng-switch-when="Failed" class="fa fa-times text-danger" aria-hidden="true"></span>
119+
</span>
120+
</dd>
121+
</span>
122+
</div>
123+
<div>
124+
<dt>Labels:</dt>
125+
<dd>
126+
<span ng-if="!deployment.metadata.labels">none</span>
127+
<span ng-repeat="(labelKey, labelValue) in deployment.metadata.labels">{{labelKey}}={{labelValue}}<span ng-show="!$last">, </span></span>
128+
</dd>
129+
</div>
130+
<div>
131+
<dt>Selectors:</dt>
132+
<dd>
133+
<span ng-if="!deployment.spec.selector">none</span>
134+
<span ng-repeat="(labelKey, labelValue) in deployment.spec.selector">{{labelKey}}={{labelValue}}<span ng-show="!$last">, </span></span>
135+
</dd>
136+
</div>
137+
<div>
138+
<dt>Replicas:</dt>
139+
<dd>{{deployment.spec.replicas}}</dd>
140+
</div>
141+
<div style="padding-top:10px;" ng-if="deployment.spec.template">
142+
<dt>Pod Template:</dt>
143+
<pod-template ng-init="podTemplate = deployment.spec.template"></pod-template>
144+
</div>
145+
</div>
146+
147+
<!--<div ng-if="(deploymentsByDeploymentConfig[deploymentConfigName] | hashSize) > 1">
148+
<button class="btn btn-default" ng-click="" data-toggle="button">Show older deployments</button>
149+
</div>-->
150+
</dl>
151+
</div>
152+
</div>
153+
154+
<!-- render any deployments whose deployment configs no longer exist -->
155+
<div class="tile" ng-repeat="(deploymentConfigName, deployments) in deploymentsByDeploymentConfig" ng-if="!deploymentConfigs[deploymentConfigName]">
156+
<div>
157+
<h2 ng-if="deploymentConfigName != ''">
158+
{{deploymentConfigName}}
159+
<span class="pficon-layered" data-toggle="tooltip" data-placement="right" title="This deployment config no longer exists" style="cursor: help;">
160+
<span class="pficon pficon-warning-triangle"></span>
161+
<span class="pficon pficon-warning-exclamation"></span>
162+
</span>
163+
</h2>
164+
<dl class="dl-horizontal left indent">
165+
<div class="well" style="margin-bottom: 10px;" ng-repeat="deployment in deployments | orderObjectsByDate : true">
166+
<h3>
167+
{{deployment.metadata.name}}
168+
</h3>
169+
<div>
170+
<dt>Created:</dt>
171+
<dd><relative-timestamp timestamp="deployment.metadata.creationTimestamp"></relative-timestamp></div></dd>
172+
<div>
173+
<span>
174+
<dt>Status:</dt>
175+
<dd>
176+
<span>{{deployment.metadata.annotations.deploymentStatus}}</span>
177+
<span ng-switch="deployment.metadata.annotations.deploymentStatus" class="hide-ng-leave">
178+
<span ng-switch-when="Running"> for <duration-until-now timestamp="deployment.metadata.creationTimestamp"></duration-until-now></span>
179+
<span ng-switch-when="New"> for <duration-until-now timestamp="deployment.metadata.creationTimestamp"></duration-until-now></span>
180+
<span ng-switch-when="Pending"> for <duration-until-now timestamp="deployment.metadata.creationTimestamp"></duration-until-now></span>
181+
</span>
182+
<span ng-switch="deployment.metadata.annotations.deploymentStatus" class="hide-ng-leave">
183+
<span style="margin-left: 5px;" ng-switch-default class="fa fa-refresh fa-spin" aria-hidden="true"></span>
184+
<span ng-switch-when="Complete" class="fa fa-check text-success" aria-hidden="true"></span>
185+
<span ng-switch-when="Failed" class="fa fa-times text-danger" aria-hidden="true"></span>
186+
</span>
187+
</dd>
188+
</span>
189+
</div>
190+
<div>
191+
<dt>Labels:</dt>
192+
<dd>
193+
<span ng-if="!deployment.metadata.labels">none</span>
194+
<span ng-repeat="(labelKey, labelValue) in deployment.metadata.labels">{{labelKey}}={{labelValue}}<span ng-show="!$last">, </span></span>
195+
</dd>
196+
</div>
197+
<div>
198+
<dt>Selectors:</dt>
199+
<dd>
200+
<span ng-if="!deployment.spec.selector">none</span>
201+
<span ng-repeat="(labelKey, labelValue) in deployment.spec.selector">{{labelKey}}={{labelValue}}<span ng-show="!$last">, </span></span>
202+
</dd>
203+
</div>
204+
<div>
205+
<dt>Replicas:</dt>
206+
<dd>{{deployment.spec.replicas}}</dd>
207+
</div>
208+
<div style="padding-top:10px;" ng-if="deployment.spec.template">
209+
<dt>Pod Template:</dt>
210+
<pod-template ng-init="podTemplate = deployment.spec.template"></pod-template>
211+
</div>
212+
</div>
213+
</dl>
214+
</div>
20215
</div>
21216
</div>
22217
</project-page>

0 commit comments

Comments
 (0)