Skip to content

Commit 597f6e4

Browse files
committed
Merge pull request #717 from bryk/deployments-frontend
Frontend for deployment list and workloads
2 parents 8a6eb0d + 886d479 commit 597f6e4

22 files changed

+788
-0
lines changed

src/app/externs/backendapi.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,23 @@ backendApi.ReplicaSetDetail;
194194
*/
195195
backendApi.ReplicaSetList;
196196

197+
/**
198+
* @typedef {{
199+
* objectMeta: !backendApi.ObjectMeta,
200+
* typeMeta: !backendApi.TypeMeta,
201+
* pods: !backendApi.PodInfo,
202+
* containerImages: !Array<string>,
203+
* }}
204+
*/
205+
backendApi.Deployment;
206+
207+
/**
208+
* @typedef {{
209+
* deployments: !Array<!backendApi.Deployment>
210+
* }}
211+
*/
212+
backendApi.DeploymentList;
213+
197214
/**
198215
* @typedef {{
199216
* pods: !Array<!backendApi.Pod>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2015 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import filtersModule from 'common/filters/filters_module';
16+
import componentsModule from 'common/components/components_module';
17+
import stateConfig from './deploymentdetail_stateconfig';
18+
19+
/**
20+
* Angular module for the Deployment details view.
21+
*
22+
* The view shows detailed view of a Deployment.
23+
*/
24+
export default angular
25+
.module(
26+
'kubernetesDashboard.deploymentdetail',
27+
[
28+
'ngMaterial',
29+
'ngResource',
30+
'ui.router',
31+
componentsModule.name,
32+
filtersModule.name,
33+
])
34+
.config(stateConfig);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2015 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/** Name of the state. Can be used in, e.g., $state.go method. */
16+
export const stateName = 'deploymentdetail';
17+
18+
/**
19+
* Parameters for this state.
20+
*
21+
* All properties are @exported and in sync with URL param names.
22+
* @final
23+
*/
24+
export class StateParams {
25+
/**
26+
* @param {string} namespace
27+
* @param {string} deployment
28+
*/
29+
constructor(namespace, deployment) {
30+
/** @export {string} Namespace of this Deployment. */
31+
this.namespace = namespace;
32+
33+
/** @export {string} Name of this Deployment. */
34+
this.deployment = deployment;
35+
}
36+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2015 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import {stateName} from './deploymentdetail_state';
16+
17+
/**
18+
* Configures states for the replica set details view.
19+
*
20+
* @param {!ui.router.$stateProvider} $stateProvider
21+
* @ngInject
22+
*/
23+
export default function stateConfig($stateProvider) {
24+
$stateProvider.state(stateName, {
25+
url: '/deployments/:namespace/:deployment',
26+
});
27+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!--
2+
Copyright 2015 Google Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<kd-resource-card type-meta="$ctrl.deployment.typeMeta" object-meta="$ctrl.deployment.objectMeta">
18+
<kd-resource-card-status layout="row">
19+
<md-icon class="material-icons md-warn"
20+
ng-if="::$ctrl.hasWarnings()">
21+
error
22+
<md-tooltip>One or more pods have errors</md-tooltip>
23+
</md-icon>
24+
<md-icon class="material-icons"
25+
ng-if="::$ctrl.isPending()">
26+
timelapse
27+
<md-tooltip>One or more pods are in pending state</md-tooltip>
28+
</md-icon>
29+
30+
<md-icon class="material-icons kd-success" ng-if="::$ctrl.isSuccess()">
31+
beenhere
32+
</md-icon>
33+
</kd-resource-card-status>
34+
<kd-resource-card-columns>
35+
<kd-resource-card-column>
36+
<div>
37+
<a ng-href="{{::$ctrl.getDeploymentDetailHref()}}" style="display: block;">
38+
<kd-middle-ellipsis display-string="{{$ctrl.deployment.objectMeta.name}}">
39+
</kd-middle-ellipsis>
40+
</a>
41+
</div>
42+
</kd-resource-card-column>
43+
<kd-resource-card-column>
44+
<kd-labels labels="::$ctrl.deployment.objectMeta.labels"></kd-labels>
45+
</kd-resource-card-column>
46+
<kd-resource-card-column>
47+
<span class="kd-replicase-card-pods-stat">
48+
{{::$ctrl.deployment.pods.running}} /
49+
{{::$ctrl.deployment.pods.desired}}
50+
</span>
51+
</kd-resource-card-column>
52+
<kd-resource-card-column>
53+
{{::$ctrl.deployment.objectMeta.creationTime | relativeTime}}
54+
<md-tooltip>
55+
Created at {{::$ctrl.deployment.objectMeta.creationTime | date:'short'}}
56+
</md-tooltip>
57+
</kd-resource-card-column>
58+
<kd-resource-card-column>
59+
<div ng-repeat="image in ::$ctrl.deployment.containerImages track by $index">
60+
<kd-middle-ellipsis display-string="{{::image}}"></kd-middle-ellipsis>
61+
</div>
62+
</kd-resource-card-column>
63+
</kd-resource-card-columns>
64+
<kd-resource-card-footer ng-if="::$ctrl.hasWarnings()">
65+
<div ng-repeat="warning in ::$ctrl.deployment.pods.warnings">
66+
<span class="kd-deployment-card-error">{{::warning.message}}</span>
67+
</div>
68+
</kd-resource-card-footer>
69+
</kd-resource-card>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright 2015 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import {StateParams} from 'deploymentdetail/deploymentdetail_state';
16+
import {stateName} from 'deploymentdetail/deploymentdetail_state';
17+
18+
/**
19+
* Controller for the replica set card.
20+
*
21+
* @final
22+
*/
23+
export default class DeploymentCardController {
24+
/**
25+
* @param {!ui.router.$state} $state
26+
* @ngInject
27+
*/
28+
constructor($state) {
29+
/**
30+
* Initialized from the scope.
31+
* @export {!backendApi.Deployment}
32+
*/
33+
this.deployment;
34+
35+
/** @private {!ui.router.$state} */
36+
this.state_ = $state;
37+
}
38+
39+
/**
40+
* @return {string}
41+
* @export
42+
*/
43+
getDeploymentDetailHref() {
44+
return this.state_.href(
45+
stateName,
46+
new StateParams(this.deployment.objectMeta.namespace, this.deployment.objectMeta.name));
47+
}
48+
49+
/**
50+
* Returns true if any of replica set pods has warning, false otherwise
51+
* @return {boolean}
52+
* @export
53+
*/
54+
hasWarnings() { return this.deployment.pods.warnings.length > 0; }
55+
56+
/**
57+
* Returns true if replica set pods have no warnings and there is at least one pod
58+
* in pending state, false otherwise
59+
* @return {boolean}
60+
* @export
61+
*/
62+
isPending() { return !this.hasWarnings() && this.deployment.pods.pending > 0; }
63+
64+
/**
65+
* @return {boolean}
66+
* @export
67+
*/
68+
isSuccess() { return !this.isPending() && !this.hasWarnings(); }
69+
}
70+
71+
/**
72+
* @return {!angular.Component}
73+
*/
74+
export const deploymentCardComponent = {
75+
bindings: {
76+
'deployment': '=',
77+
},
78+
controller: DeploymentCardController,
79+
templateUrl: 'deploymentlist/deploymentcard.html',
80+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!--
2+
Copyright 2015 Google Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<kd-resource-card-list selectable="false" with-statuses="true">
18+
<kd-resource-card-header-columns>
19+
<kd-resource-card-header-column grow="2">
20+
Name
21+
</kd-resource-card-header-column>
22+
<kd-resource-card-header-column grow="2">
23+
Labels
24+
</kd-resource-card-header-column>
25+
<kd-resource-card-header-column grow="nogrow" size="small">
26+
Pods
27+
</kd-resource-card-header-column>
28+
<kd-resource-card-header-column grow="nogrow" size="small">
29+
Age
30+
</kd-resource-card-header-column>
31+
<kd-resource-card-header-column>
32+
Images
33+
</kd-resource-card-header-column>
34+
</kd-resource-card-header-columns>
35+
<kd-deployment-card ng-repeat="deployment in $ctrl.deployments" deployment="deployment">
36+
</kd-deployment-card>
37+
</kd-resource-card-list>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2015 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* @return {!angular.Component}
17+
*/
18+
export const deploymentCardListComponent = {
19+
transclude: true,
20+
bindings: {
21+
'deployments': '<',
22+
},
23+
templateUrl: 'deploymentlist/deploymentcardlist.html',
24+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!--
2+
Copyright 2015 Google Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<kd-content-card>
17+
<kd-content>
18+
<kd-deployment-card-list deployments="$ctrl.deployments">
19+
</kd-deployment-card-list>
20+
</kd-content>
21+
</kd-content-card>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2015 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* Controller for the replica set list view.
17+
*
18+
* @final
19+
*/
20+
export class DeploymentListController {
21+
/**
22+
* @param {!backendApi.DeploymentList} deployments
23+
* @ngInject
24+
*/
25+
constructor(deployments) {
26+
/** @export {!Array<!backendApi.Deployment>} */
27+
this.deployments = deployments.deployments;
28+
}
29+
}

0 commit comments

Comments
 (0)