Skip to content

Commit 973ca50

Browse files
authored
Merge pull request #2621 from angular-fullstack/fix-ts-errors-v2
Fix TS errors, upgrade Angular
2 parents 5556877 + 18c86d6 commit 973ca50

20 files changed

+133
-157
lines changed

Diff for: templates/app/_package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@
5454
"@angularclass/match-control": "^2.0.0",
5555
"reflect-metadata": "^0.1.3",
5656
"rxjs": "^5.3.0",
57-
"zone.js": "^0.7.2",
58-
"@angular/common": "~2.4.9",
59-
"@angular/compiler": "~2.4.9",
60-
"@angular/core": "~2.4.9",
61-
"@angular/forms": "~2.4.9",
62-
"@angular/http": "~2.4.9",
57+
"zone.js": "^0.8.4",
58+
"@angular/common": "^4.3.3",
59+
"@angular/compiler": "^4.3.3",
60+
"@angular/core": "^4.3.3",
61+
"@angular/forms": "^4.3.3",
62+
"@angular/http": "^4.3.3",
63+
"@angular/platform-browser": "^4.3.3",
64+
"@angular/platform-browser-dynamic": "^4.3.3",
65+
"@angular/router": "^4.3.3",
6366
<%#"@angular/material": "^2.0.0-alpha.10",%>
64-
"@angular/platform-browser": "~2.4.9",
65-
"@angular/platform-browser-dynamic": "~2.4.9",
66-
"@angular/router": "^3.4.7",
6767
"@angularclass/hmr": "^1.2.1",
6868
<%_ if(filters.ts) { -%>
6969
"@types/core-js": "^0.9.41",
@@ -82,7 +82,7 @@
8282
"@types/webpack": "^2.2.15",
8383
<%_ } -%>
8484
"angular2-universal": "2.1.0-rc.1",
85-
"angular2-jwt": "^0.1.24",
85+
"angular2-jwt": "^0.1.28",
8686
<% if(filters.auth) { %>
8787
"angular-validation-match": "^1.9.0",<% } %>
8888
<% if(filters.uirouter) { %>

Diff for: templates/app/client/__index.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
ga('send', 'pageview');
2626
</script>
2727

28-
<app>LOADING</app>
29-
<navbar></navbar>
30-
<% if (filters.ngroute) { %><router-outlet></router-outlet><% } %><% if (filters.uirouter) { %><div ui-view=""></div><% } %>
31-
<footer></footer>
28+
<app>Loading...</app>
3229
</body>
3330
</html>

Diff for: templates/app/client/app/account(auth)/account.module.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import { NgModule } from '@angular/core';
22
import { FormsModule } from '@angular/forms';
33
import { BrowserModule } from '@angular/platform-browser';
4-
<%_ if (filters.uirouter) { -%>
4+
<%_ if(filters.uirouter) { -%>
55
import { UIRouterModule } from 'ui-router-ng2';<% } %>
6-
<%_ if (filters.ngroute) { -%>
6+
<%_ if(filters.ngroute) { -%>
77
import { RouterModule, Routes } from '@angular/router';<% } %>
88
<%_ if(filters.oauth) { -%>
99
import { DirectivesModule } from '../../components/directives.module';<% } %>
1010

11-
import { STATES } from './account.routes';
11+
<%_ if(filters.uirouter) { -%>
12+
import { STATES } from './account.routes';<% } %>
1213

1314
import { LoginComponent } from './login/login.component';
1415
import { SettingsComponent } from './settings/settings.component';
1516
import { SignupComponent } from './signup/signup.component';
1617

17-
<%_ if (filters.ngroute) { -%>
18+
<%_ if(filters.ngroute) { -%>
1819
const accountRoutes: Routes = [{
1920
path: 'login',
2021
component: LoginComponent,
@@ -31,11 +32,11 @@ const accountRoutes: Routes = [{
3132
imports: [
3233
FormsModule,
3334
BrowserModule,
34-
<%_ if (filters.uirouter) { -%>
35+
<%_ if(filters.uirouter) { -%>
3536
UIRouterModule.forChild({
3637
states: STATES,
3738
}),<% } %>
38-
<%_ if (filters.ngroute) { -%>
39+
<%_ if(filters.ngroute) { -%>
3940
RouterModule.forChild(accountRoutes),<% } %>
4041
<%_ if(filters.oauth) { -%>
4142
DirectivesModule,<% } %>

Diff for: templates/app/client/app/account(auth)/login/login.component.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export class LoginComponent {
3434
errors = {login: undefined};
3535
submitted = false;
3636
AuthService;
37-
<%_ if(filters.ngroute) { -%><% } %>
37+
<%_ if(filters.ngroute) { -%>
38+
Router;<% } %>
3839
<%_ if(filters.uirouter) { -%>
3940
StateService;<% } %>
4041

Diff for: templates/app/client/app/account(auth)/settings/settings.component.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,14 @@ export class SettingsComponent {
4040
changePassword(form) {
4141
this.submitted = true;
4242

43-
if(form.$valid) {
44-
this.AuthService.changePassword(this.user.oldPassword, this.user.newPassword)
45-
.then(() => {
46-
this.message = 'Password successfully changed.';
47-
})
48-
.catch(() => {
49-
form.password.$setValidity('mongoose', false);
50-
this.errors.other = 'Incorrect password';
51-
this.message = '';
52-
});
53-
}
43+
return this.AuthService.changePassword(this.user.oldPassword, this.user.newPassword)
44+
.then(() => {
45+
this.message = 'Password successfully changed.';
46+
})
47+
.catch(() => {
48+
// form.password.$setValidity('mongoose', false);
49+
this.errors.other = 'Incorrect password';
50+
this.message = '';
51+
});
5452
}
5553
}

Diff for: templates/app/client/app/account(auth)/settings/settings.html

+9-11
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,31 @@ <h1>Change Password</h1>
99
<div class="form-group">
1010
<label>Current Password</label>
1111

12-
<input type="password" name="password" class="form-control" [(ngModel)]="user.oldPassword" mongoose-error/>
13-
<p class="help-block" [hidden]="!form.password.$error.mongoose">
14-
{{ errors.other }}
12+
<input type="password" name="password" class="form-control" [(ngModel)]="user.oldPassword" required #oldPassword="ngModel"/>
13+
<p class="help-block" [hidden]="oldPassword.valid || !submitted">
14+
Required
1515
</p>
1616
</div>
1717

1818
<div class="form-group">
1919
<label>New Password</label>
2020

21-
<input type="password" name="newPassword" class="form-control" [(ngModel)]="user.newPassword"
22-
ng-minlength="3"
23-
required/>
21+
<input type="password" name="newPassword" class="form-control" [(ngModel)]="user.newPassword" required #newPassword="ngModel"
22+
minlength="3"/>
2423
<p class="help-block"
25-
[hidden]="!(form.newPassword.$error.minlength || form.newPassword.$error.required) || !(form.newPassword.$dirty || submitted)">
24+
[hidden]="newPassword.valid || !submitted">
2625
Password must be at least 3 characters.
2726
</p>
2827
</div>
2928

3029
<div class="form-group">
3130
<label>Confirm New Password</label>
3231

33-
<input type="password" name="confirmPassword" class="form-control" [(ngModel)]="user.confirmPassword"
32+
<input type="password" name="confirmPassword" class="form-control" [(ngModel)]="user.confirmPassword" required #confirmPassword="ngModel"
3433
match="user.newPassword"
35-
ng-minlength="3"
36-
required=""/>
34+
minlength="3"/>
3735
<p class="help-block"
38-
[hidden]="!form.confirmPassword.$error.match || !submitted">
36+
[hidden]="confirmPassword.valid || !submitted">
3937
Passwords must match.
4038
</p>
4139

Diff for: templates/app/client/app/account(auth)/signup/signup.component.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import { Component } from '@angular/core';
33
<%_ if(filters.uirouter) { -%>
44
import { StateService } from 'ui-router-ng2';<% } %>
5-
<%_ if(filters.ngroute) { -%><% } %>
5+
<%_ if(filters.ngroute) { -%>
6+
import { Router } from '@angular/router';<% } %>
67
import { AuthService } from '../../../components/auth/auth.service';
7-
import {ANGULARCLASS_MATCH_CONTROL_DIRECTIVES} from '@angularclass/match-control';
88

99
<%_ if(filters.flow) { -%>
1010
type User = {
@@ -21,8 +21,7 @@ interface User {
2121

2222
@Component({
2323
selector: 'signup',
24-
template: require('./signup.<%=templateExt%>'),
25-
directives: [...ANGULARCLASS_MATCH_CONTROL_DIRECTIVES]
24+
template: require('./signup.<%=templateExt%>')
2625
})
2726
export class SignupComponent {
2827
user: User = {
@@ -33,14 +32,16 @@ export class SignupComponent {
3332
errors = {};
3433
submitted = false;
3534
AuthService;
36-
<%_ if(filters.ngroute) { -%><% } %>
35+
<%_ if(filters.ngroute) { -%>
36+
Router;<% } %>
3737
<%_ if(filters.uirouter) { -%>
3838
StateService;<% } %>
3939

40-
static parameters = [AuthService, <% if(filters.ngroute) { %><% } else { %>StateService<% } %>];
41-
constructor(_AuthService_: AuthService, <% if(filters.ngroute) { %><% } else { %>_StateService_: StateService<% } %>) {
40+
static parameters = [AuthService, <% if(filters.ngroute) { %>Router<% } else { %>StateService<% } %>];
41+
constructor(_AuthService_: AuthService, <% if(filters.ngroute) { %>router: Router<% } else { %>_StateService_: StateService<% } %>) {
4242
this.AuthService = _AuthService_;
43-
<%_ if(filters.ngroute) { -%><% } -%>
43+
<%_ if(filters.ngroute) { -%>
44+
this.Router = router;<% } -%>
4445
<%_ if(filters.uirouter) { -%>
4546
this.StateService = _StateService_;<% } -%>
4647
}
@@ -55,7 +56,7 @@ export class SignupComponent {
5556
})
5657
.then(() => {
5758
// Account created, redirect to home
58-
<% if(filters.ngroute) { %>this.$location.path('/');<% } -%>
59+
<% if(filters.ngroute) { %>this.Router.navigateByUrl('/home');<% } -%>
5960
<% if(filters.uirouter) { %>this.StateService.go('main');<% } -%>
6061
})
6162
.catch(err => {

Diff for: templates/app/client/app/admin(auth)/admin.component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class AdminComponent {
1212

1313
<%_ } _%>
1414
static parameters = [UserService];
15-
constructor(userService: UserService) {
15+
constructor(<%= private() %>userService: UserService) {
1616
this.userService = userService;
1717
// Use the user service to fetch all users
1818
this.userService.query().subscribe(users => {

Diff for: templates/app/client/app/admin(auth)/admin.module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { AdminComponent } from './admin.component';
99

1010
<%_ if(filters.uirouter) { -%>
1111
import { STATES } from './admin.routes';<% } %>
12-
<%_ if (filters.ngroute) { -%>
12+
<%_ if(filters.ngroute) { -%>
1313
const adminRoutes: Routes = [{
1414
path: 'admin',
1515
component: AdminComponent,

Diff for: templates/app/client/app/app.constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<%_ if(filters.babel) { -%>
22
export default from '../../server/config/environment/shared';<% } %>
33
<%_ if(filters.ts) { -%>
4-
import shared from '../../server/config/environment/shared';
4+
import shared from '../../server/config/environment/shared.js';
55

66
export default shared;<% } %>

Diff for: templates/app/client/app/app.module.js

+16-55
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,13 @@
1-
// import angular from 'angular';
2-
// // import ngAnimate from 'angular-animate';
3-
// import ngCookies from 'angular-cookies';
4-
// import ngResource from 'angular-resource';
5-
// import ngSanitize from 'angular-sanitize';
6-
// <%_ if(filters.socketio) { _%>
7-
// import 'angular-socket-io';<% } %>
8-
// <%_ if(filters.ngroute) { _%>
9-
// const ngRoute = require('angular-route');<% } %>
10-
// <%_ if(filters.uirouter) { _%>
11-
// import uiRouter from 'angular-ui-router';<% } %>
12-
// <%_ if(filters.uibootstrap) { _%>
13-
// import uiBootstrap from 'angular-ui-bootstrap';<% } %>
14-
// // import ngMessages from 'angular-messages';
15-
// <%_ if(filters.auth) { _%>
16-
// // import ngValidationMatch from 'angular-validation-match';<% } %>
17-
18-
// import {routeConfig} from './app.config';
19-
20-
// <%_ if(filters.auth) { _%>
21-
// import _Auth from '../components/auth/auth.module';
22-
// import account from './account';
23-
// import admin from './admin';<% } %>
24-
// import navbar from '../components/navbar/navbar.component';
25-
// import footer from '../components/footer/footer.component';
26-
// import main from './main/main.component';
27-
// import constants from './app.constants';
28-
// import util from '../components/util/util.module';
29-
// <%_ if(filters.socketio) { _%>
30-
// import socket from '../components/socket/socket.service';<% } %>
31-
32-
// .config(routeConfig)
33-
// <%_ if(filters.auth) { _%>
34-
// .run(function($rootScope, $location, Auth) {
35-
// 'ngInject';
36-
// // Redirect to login if route requires auth and you're not logged in
37-
// $rootScope.$on('$stateChangeStart', function(event, next) {
38-
// Auth.isLoggedIn(function(loggedIn) {
39-
// if(next.authenticate && !loggedIn) {
40-
// $location.path('/login');
41-
// }
42-
// });
43-
// });
44-
// })<% } %>;
45-
46-
471
import {
482
NgModule,
493
ErrorHandler,
504
Injectable,
515
ApplicationRef,
6+
Provider,
527
} from '@angular/core';
538
import { BrowserModule } from '@angular/platform-browser';
549
import {
10+
Http,
5511
HttpModule,
5612
BaseRequestOptions,
5713
RequestOptions,
@@ -60,15 +16,13 @@ import {
6016
import {
6117
removeNgStyles,
6218
createNewHosts,
63-
disposeOldHosts,
6419
createInputTransfer,
65-
restoreInputValues,
6620
} from '@angularclass/hmr';
6721
<%_ if (filters.uirouter) { -%>
6822
import { UIRouterModule } from 'ui-router-ng2';<% } %>
6923
<%_ if (filters.ngroute) { -%>
7024
import { RouterModule, Routes } from '@angular/router';<% } %>
71-
import { provideAuth } from 'angular2-jwt';
25+
import { provideAuth, AuthHttp, AuthConfig } from 'angular2-jwt';
7226

7327
import { AppComponent } from './app.component';
7428
import { MainModule } from './main/main.module';
@@ -79,12 +33,19 @@ import { AdminModule } from './admin/admin.module';
7933

8034
import constants from './app.constants';
8135

82-
let providers = [
83-
provideAuth({
84-
// Allow using AuthHttp while not logged in
36+
export function getAuthHttp(http) {
37+
return new AuthHttp(new AuthConfig({
8538
noJwtError: true,
86-
})
87-
];
39+
globalHeaders: [{'Accept': 'application/json'}],
40+
tokenGetter: (() => localStorage.getItem('id_token')),
41+
}), http);
42+
}
43+
44+
let providers: Provider[] = [{
45+
provide: AuthHttp,
46+
useFactory: getAuthHttp,
47+
deps: [Http]
48+
}];
8849

8950
if(constants.env === 'development') {
9051
@Injectable()
@@ -134,7 +95,7 @@ const appRoutes: Routes = [
13495
})
13596
export class AppModule {
13697
static parameters = [ApplicationRef];
137-
constructor(appRef/*: ApplicationRef*/) {
98+
constructor(<%= private() %>appRef: ApplicationRef) {
13899
this.appRef = appRef;
139100
}
140101

Diff for: templates/app/client/app/main/main.component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import { SocketService } from '../../components/socket/socket.service';
99
styles: [require('./main.<%=styleExt%>')],
1010
})
1111
export class MainComponent implements OnInit<% if(filters.ws) { %>, OnDestroy<% } %> {
12+
Http;
1213
<%_ if(filters.ws) { -%>
1314
SocketService;<% } %>
1415
awesomeThings = [];
1516
<%_ if(filters.models) { -%>
1617
newThing = '';<% } %>
1718

18-
<%_ if(filters.babel) { -%>
19-
static parameters = [Http, SocketService];<% } %>
19+
static parameters = [Http, SocketService];
2020
constructor(<%= private() %>http: Http<% if(filters.ws) { %>, <%= private() %>socketService: SocketService<% } %>) {
2121
this.Http = http;
2222
<%_ if(filters.ws) { -%>

0 commit comments

Comments
 (0)