Skip to content

Commit d516d00

Browse files
committed
Use standard Angular router instead of the new one
This change modifies a lot of JS, but this is only to prove that the code works. Later changes will cleanup the JS more.
1 parent 9850c13 commit d516d00

File tree

8 files changed

+40
-78
lines changed

8 files changed

+40
-78
lines changed

bower.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,12 @@
1010
"angular-aria": "~1.4.2",
1111
"angular-material": "~0.10.1",
1212
"angular-messages": "~1.4.2",
13-
"angular-new-router": "~0.5.3",
1413
"angular-resource": "~1.4.2",
14+
"angular-route": "~1.4.2",
1515
"angular-sanitize": "~1.4.2"
1616
},
1717
"devDependencies": {
1818
"angular-mocks": "~1.4.2",
1919
"google-closure-library": "*"
20-
},
21-
"//": "Some dependencies do not have main files defined. Override this here so that",
22-
"//": "build tools know what files to serve.",
23-
"overrides": {
24-
"angular-new-router": {
25-
"main": [
26-
"dist/router.es5.js"
27-
]
28-
}
2920
}
3021
}

src/app/frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
experience.</p>
2727
<![endif]-->
2828

29-
<div ng-viewport ng-controller="RouterController"></div>
29+
<div ng-view> <!-- Application content is inserted here. --> </div>
3030

3131
<!-- build:js console/vendor.js -->
3232
<!-- bower:js -->

src/app/frontend/index.module.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@
1616
* @fileoverview Entry point module to the application. Loads and configures other modules needed
1717
* to bootstrap the application.
1818
*/
19-
import {config} from './index.config';
20-
import {RouterController, routerConfig} from './index.route';
21-
import {runBlock} from './index.run';
22-
import {MainController} from './main/main.controller';
19+
import routeConfig from './index.route';
20+
import mainModule from './main/main.module';
2321

2422
export default angular.module(
2523
'kubernetesConsole',
26-
['ngAnimate', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource', 'ngNewRouter', 'ngMaterial'])
27-
.config(config)
28-
.config(routerConfig)
29-
.run(runBlock)
30-
.controller('RouterController', RouterController)
31-
.controller('MainController', MainController);
24+
[
25+
'ngAnimate',
26+
'ngAria',
27+
'ngMaterial',
28+
'ngMessages',
29+
'ngResource',
30+
'ngRoute',
31+
'ngSanitize',
32+
mainModule.name,
33+
])
34+
.config(routeConfig);

src/app/frontend/index.route.js

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

1515

1616
/**
17-
* @param {!ngNewRouter.$componentLoaderProvider} $componentLoaderProvider
17+
* @param {!angular.$routeProvider} $routeProvider
1818
* @ngInject
1919
*/
20-
export function routerConfig($componentLoaderProvider) {
21-
$componentLoaderProvider.setTemplateMapping(function(name) {
22-
return `${name}/${name}.html`;
23-
});
24-
}
25-
26-
27-
export class RouterController {
28-
/**
29-
* @param {!ngNewRouter.$router} $router
30-
* @ngInject
31-
*/
32-
constructor($router) {
33-
$router.config([
34-
{path: '/', component: 'main'},
35-
]);
36-
}
20+
export default function routeConfig($routeProvider) {
21+
// TODO(bryk): Configure 'otherwise' route here.
3722
}

src/app/frontend/main/main.controller.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@
1313
// limitations under the License.
1414

1515

16-
export class MainController {
17-
constructor() {
18-
/** @export */
19-
this.testValue = 7;
20-
}
21-
16+
export default class MainController {
2217
/**
2318
* @param {!angular.$timeout} $timeout
2419
* @ngInject
25-
* @export
2620
*/
27-
activate($timeout) {
21+
constructor($timeout) {
22+
/** @export */
23+
this.testValue = 7;
24+
2825
$timeout(() => {
2926
this.testValue = 8;
3027
}, 4000);

src/app/frontend/main/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div layout="vertical" layout-fill>
22
<md-content>
33
<header>
4-
Hello world! {{main.testValue}}
4+
Hello world! {{ctrl.testValue}}
55
</header>
66

77
<section class="jumbotron">
Lines changed: 5 additions & 8 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,11 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import routeConfig from './main.route';
1516

16-
/**
17-
* @param {!angular.$log} $log
18-
* @ngInject
19-
*/
20-
export function runBlock ($log) {
21-
$log.debug('runBlock end');
22-
}
17+
18+
export default angular.module('kubernetesConsole.main', [])
19+
.config(routeConfig);
Lines changed: 11 additions & 22 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,28 +12,17 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
/**
16-
* @fileoverview Externs for Angular router: https://github.com/angular/router
17-
*
18-
* TODO(bryk): Move the externs out of this project.
19-
*/
20-
21-
22-
/** @const */
23-
var ngNewRouter = {};
24-
25-
26-
/**
27-
* @typedef {{
28-
* setTemplateMapping: function(function(string):string)
29-
* }}
30-
*/
31-
ngNewRouter.$componentLoaderProvider = {};
15+
import MainController from './main.controller';
3216

3317

3418
/**
35-
* @typedef {{
36-
* config: function(!Array<{path: string, component: string}>)
37-
* }}
19+
* @param {!angular.$routeProvider} $routeProvider
20+
* @ngInject
3821
*/
39-
ngNewRouter.$router = {};
22+
export default function routeConfig($routeProvider) {
23+
$routeProvider.when('/', {
24+
templateUrl: 'main/main.html',
25+
controller: MainController,
26+
controllerAs: 'ctrl',
27+
});
28+
}

0 commit comments

Comments
 (0)