Skip to content

Commit d1ac65e

Browse files
committed
Merge pull request #223 from floreks/label-format
Added common label formatting (as chips) and unified across the project.
2 parents 5da1bc8 + 3c47f67 commit d1ac65e

File tree

16 files changed

+202
-27
lines changed

16 files changed

+202
-27
lines changed

build/karma.conf.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function getFileList() {
4949
*/
5050
module.exports = function(config) {
5151
let configuration = {
52-
basePath: conf.paths.base,
52+
basePath: '.',
5353

5454
files: getFileList(),
5555

@@ -109,7 +109,8 @@ module.exports = function(config) {
109109
// karma-ng-html2js-preprocessor plugin config.
110110
ngHtml2JsPreprocessor: {
111111
stripPrefix: `${conf.paths.frontendSrc}/`,
112-
moduleName: conf.frontend.moduleName,
112+
// Load all template related stuff under ng module as it's loaded with every module.
113+
moduleName: 'ng',
113114
},
114115
};
115116

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 labelsDirective from './labels/labels_directive';
16+
17+
/**
18+
* Module containing common components for the application.
19+
*/
20+
export default angular.module(
21+
'kubernetesDashboard.common.components',
22+
[
23+
'ngMaterial',
24+
])
25+
.directive('kdLabels', labelsDirective);
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+
17+
<md-content>
18+
<div class="kd-labels" ng-repeat="(key, value) in ::labelsCtrl.labels">
19+
{{key}}={{value}}
20+
</div>
21+
</md-content>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 '../../../variables';
16+
17+
$label-height: $caption-font-size-base + 6;
18+
$label-margin: 0 $baseline-grid $baseline-grid 0;
19+
20+
// Style taken(mostly) from angular material md-chip style.
21+
.kd-labels {
22+
background-color: $body;
23+
border-radius: $label-height / 2;
24+
display: inline-block;
25+
font-size: $caption-font-size-base;
26+
line-height: $label-height;
27+
margin: $label-margin;
28+
padding: 0 $baseline-grid;
29+
vertical-align: middle;
30+
}
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+
/**
16+
* @final
17+
*/
18+
export default class LabelsController {
19+
/**
20+
* Constructs labels controller.
21+
* @ngInject
22+
*/
23+
constructor() {
24+
/** @export {Object<string, string>} Initialized from the scope. */
25+
this.labels;
26+
}
27+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 LabelsController from './labels_controller';
16+
17+
/**
18+
* Returns directive definition for label.
19+
*
20+
* @return {!angular.Directive}
21+
*/
22+
export default function labelsDirective() {
23+
return {
24+
controller: LabelsController,
25+
controllerAs: 'labelsCtrl',
26+
templateUrl: 'common/components/labels/labels.html',
27+
scope: {},
28+
bindToController: {
29+
'labels': '=',
30+
},
31+
};
32+
}

src/app/frontend/common/filters/filters_module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import relativeTimeFilter from './relativetime_filter';
1919
* Module containing common filters for the application.
2020
*/
2121
export default angular.module(
22-
'kubernetesDashboard.common.flters',
22+
'kubernetesDashboard.common.filters',
2323
[
2424
'ngMaterial',
2525
])

src/app/frontend/deploy/deploy_module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ export default angular.module(
4242
.directive('kdUniqueName', uniqueNameDirective)
4343
.directive('kdFileReader', fileReaderDirective)
4444
.directive('kdUpload', uploadDirective)
45-
.directive('kdLabel', deployLabelDirective);
45+
.directive('kdDeployLabel', deployLabelDirective);

src/app/frontend/deploy/deployfromsettings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
<p flex>Value</p>
111111
</div>
112112
<div ng-repeat="label in ctrl.labels">
113-
<kd-label layout="row" flex label="label" labels="ctrl.labels"></kd-label>
113+
<kd-deploy-label layout="row" flex label="label" labels="ctrl.labels"></kd-deploy-label>
114114
</div>
115115
</div>
116116
</div>

src/app/frontend/replicasetdetail/replicasetdetail.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@
4848
</span>
4949
<span class="kd-replicasetdetail-sidebar-line">Label selector</span>
5050
<span class="kd-replicasetdetail-sidebar-subline">
51-
{{ctrl.formatLabelString(ctrl.replicaSetDetail.labelSelector)}}
51+
<kd-labels labels="::ctrl.replicaSetDetail.labelSelector"></kd-labels>
5252
</span>
5353
<span class="kd-replicasetdetail-sidebar-title">Replica Sets</span>
5454
<span class="kd-replicasetdetail-sidebar-line">Labels</span>
5555
<span class="kd-replicasetdetail-sidebar-subline">
56-
{{ctrl.formatLabelString(ctrl.replicaSetDetail.labels)}}
56+
<kd-labels labels="::ctrl.replicaSetDetail.labels"></kd-labels>
5757
</span>
5858
<span class="kd-replicasetdetail-sidebar-line">Images</span>
5959
<span class="kd-replicasetdetail-sidebar-subline"
@@ -65,7 +65,7 @@
6565
<span class="kd-replicasetdetail-sidebar-line">Label selector</span>
6666
<span class="kd-replicasetdetail-sidebar-subline"
6767
ng-repeat="service in ::ctrl.replicaSetDetail.services">
68-
{{::ctrl.formatLabelString(service.selector)}}
68+
<kd-labels labels="::service.selector"></kd-labels>
6969
</span>
7070
<span class="kd-replicasetdetail-sidebar-line">Internal endpoint</span>
7171
<div class="kd-replicasetdetail-sidebar-subline"

0 commit comments

Comments
 (0)