Skip to content

Commit 5a108bb

Browse files
committed
Merge pull request #30 from kubernetes/simple-chrome
Implement simple chrome operating on ui.router
2 parents dbea8e1 + 4c37e87 commit 5a108bb

14 files changed

+128
-32
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"angular-aria": "~1.4.2",
1111
"angular-material": "~0.10.1",
1212
"angular-messages": "~1.4.2",
13+
"angular-ui-router": "~0.2.15",
1314
"angular-resource": "~1.4.2",
14-
"angular-route": "~1.4.2",
1515
"angular-sanitize": "~1.4.2"
1616
},
1717
"devDependencies": {

build/script.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ gulp.task('scripts', ['create-serve-folders'], function() {
9393
'google-closure-compiler/contrib/externs/angular-1.4-http-promise_templated.js'),
9494
path.join(conf.paths.nodeModules,
9595
'google-closure-compiler/contrib/externs/angular-1.4-q_templated.js'),
96+
path.join(conf.paths.nodeModules,
97+
'google-closure-compiler/contrib/externs/angular_ui_router.js'),
9698
path.join(conf.paths.externs, '**/*.js'),
9799
],
98100
// Enable all compiler checks by default and make them errors.
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+
/**
17+
* Controller for the chrome directive.
18+
*
19+
* @final
20+
*/
21+
export default class ChromeController {
22+
constructor() {
23+
// TODO(bryk): This is for tests only, change to something meaningful later.
24+
/** @export {string} */
25+
this.clusterName = 'ClusterName';
26+
}
27+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 ChromeController from './chrome.controller';
16+
17+
18+
/**
19+
* Returns directive definition object for the chrome directive.
20+
*
21+
* @return {!angular.Directive}
22+
*/
23+
export default function chromeDirective() {
24+
return {
25+
bindToController: true,
26+
controller: ChromeController,
27+
controllerAs: 'ctrl',
28+
templateUrl: 'chrome/chrome.html',
29+
transclude: true,
30+
};
31+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div>
2+
<md-content>
3+
<md-toolbar>
4+
<div class="md-toolbar-tools">
5+
<md-button class="md-icon-button" aria-label="Settings">
6+
<md-icon md-font-library="material-icons">menu</md-icon>
7+
</md-button>
8+
<h2>
9+
<span>Kubernetes cluster: {{ctrl.clusterName}}</span>
10+
</h2>
11+
<span flex></span>
12+
<md-button class="md-icon-button" aria-label="Favorite">
13+
<md-icon md-font-library="material-icons">more_vert</md-icon>
14+
</md-button>
15+
</div>
16+
</md-toolbar>
17+
18+
<div ng-transclude></div>
19+
</md-content>
20+
</div>

src/app/frontend/main/main.scss renamed to src/app/frontend/chrome/chrome.module.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015 Google Inc.
1+
// Copyright 2015 Google Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -12,8 +12,15 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import chromeDirective from './chrome.directive';
1516

16-
body {
17-
background-color: gray;
18-
}
1917

18+
/**
19+
* Angular module containing navigation chrome for the application.
20+
*/
21+
export default angular.module(
22+
'kubernetesConsole.chrome',
23+
[
24+
'ngMaterial',
25+
])
26+
.directive('chrome', chromeDirective);

src/app/frontend/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
experience.</p>
2727
<![endif]-->
2828

29-
<div ng-view> <!-- Application content is inserted here. --> </div>
30-
29+
<chrome>
30+
<div ui-view> <!-- Application content is inserted here. --> </div>
31+
</chrome>
3132
<!-- build:js console/vendor.js -->
3233
<!-- bower:js -->
3334
<!-- Bower JS dependencies are populated here (dev build) and compiled

src/app/frontend/index.module.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
* @fileoverview Entry point module to the application. Loads and configures other modules needed
1717
* to bootstrap the application.
1818
*/
19-
import routeConfig from './index.route';
19+
import chromeModule from './chrome/chrome.module';
2020
import mainModule from './main/main.module';
21+
import routeConfig from './index.route';
2122

2223
export default angular.module(
2324
'kubernetesConsole',
@@ -27,8 +28,9 @@ export default angular.module(
2728
'ngMaterial',
2829
'ngMessages',
2930
'ngResource',
30-
'ngRoute',
3131
'ngSanitize',
32+
'ui.router',
33+
chromeModule.name,
3234
mainModule.name,
3335
])
3436
.config(routeConfig);

src/app/frontend/index.route.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414

1515

1616
/**
17-
* @param {!angular.$routeProvider} $routeProvider
17+
* Global route configuration for the application.
18+
*
19+
* @param {!ui.router.$urlRouterProvider} $urlRouterProvider
1820
* @ngInject
1921
*/
20-
export default function routeConfig($routeProvider) {
21-
// TODO(bryk): Configure 'otherwise' route here.
22+
export default function routeConfig($urlRouterProvider) {
23+
// When no state is matched by an URL, redirect to default one.
24+
$urlRouterProvider.otherwise('');
2225
}

src/app/frontend/index.scss

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// Robo Slab font.
16+
@import url(//fonts.googleapis.com/css?family=Roboto+Slab:400,700|Roboto:400,700,700italic,400italic);
1517

16-
body {
17-
border: 1px solid red;
18-
}
18+
// Angular Material icon font. It allows to use the icons as fonts.
19+
@import url(//fonts.googleapis.com/icon?family=Material+Icons);
1920

21+
html {
22+
font-family: 'Roboto Slab', serif;
23+
}

0 commit comments

Comments
 (0)