Skip to content
This repository was archived by the owner on Apr 17, 2020. It is now read-only.

Commit 174331b

Browse files
committed
Upgrade to Angular 7
1 parent 8312ed0 commit 174331b

File tree

5 files changed

+1552
-1004
lines changed

5 files changed

+1552
-1004
lines changed

package.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@
1313
},
1414
"private": true,
1515
"dependencies": {
16-
"@angular/animations": "6.0.0",
17-
"@angular/common": "6.0.0",
18-
"@angular/compiler": "6.0.0",
19-
"@angular/core": "6.0.0",
20-
"@angular/forms": "6.0.0",
21-
"@angular/http": "6.0.0",
22-
"@angular/platform-browser": "6.0.0",
23-
"@angular/platform-browser-dynamic": "6.0.0",
24-
"@angular/router": "6.0.0",
16+
"@angular/animations": "7.0.0",
17+
"@angular/common": "7.0.0",
18+
"@angular/compiler": "7.0.0",
19+
"@angular/core": "7.0.0",
20+
"@angular/forms": "7.0.0",
21+
"@angular/http": "7.0.0",
22+
"@angular/platform-browser": "7.0.0",
23+
"@angular/platform-browser-dynamic": "7.0.0",
24+
"@angular/router": "7.0.0",
2525
"@types/express": "^4.0.35",
2626
"@types/lodash": "^4.14.52",
27-
"angularfire2": "^4.0.0-rc.0",
27+
"@angular/fire": "^5.1.0",
2828
"body-parser": "^1.17.1",
2929
"cookies-js": "^1.2.3",
3030
"core-js": "^2.4.1",
3131
"express": "^4.15.2",
32-
"firebase": "^3.7.4",
32+
"firebase": "^5.5.5",
3333
"lodash": "^4.17.4",
3434
"promise-polyfill": "^6.0.2",
35-
"rxjs": "6.1.0",
35+
"rxjs": "6.3.3",
3636
"rxjs-compat": "^6.0.0-rc.0",
3737
"ts-helpers": "^1.1.1",
3838
"zone.js": "0.8.26"
3939
},
4040
"devDependencies": {
41-
"@angular-devkit/build-angular": "~0.6.0",
42-
"@angular/cli": "^6.0.0",
43-
"@angular/compiler-cli": "6.0.0",
44-
"@angular/language-service": "6.0.0",
41+
"@angular-devkit/build-angular": "~0.10.0",
42+
"@angular/cli": "^7.0.0",
43+
"@angular/compiler-cli": "7.0.0",
44+
"@angular/language-service": "7.0.0",
4545
"@types/jasmine": "~2.5.53",
4646
"@types/jasminewd2": "~2.0.2",
4747
"@types/node": "~6.0.60",
48-
"codelyzer": "~3.2.0",
48+
"codelyzer": "~4.2.0",
4949
"jasmine-core": "~2.6.2",
5050
"jasmine-spec-reporter": "~4.1.0",
5151
"karma": "~1.7.0",
@@ -57,6 +57,6 @@
5757
"protractor": "~5.1.2",
5858
"ts-node": "~3.2.0",
5959
"tslint": "~5.7.0",
60-
"typescript": "~2.7.2"
60+
"typescript": "~3.1.3"
6161
}
62-
}
62+
}

src/app/app.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {EventBusExperimentsComponent} from './event-bus-experiments/event-bus-ex
88
import {LessonsListComponent} from './lessons-list/lessons-list.component';
99
import {LessonsCounterComponent} from './lessons-counter/lessons-counter.component';
1010
import {HomeComponent} from './home/home.component';
11-
import {AngularFireModule} from 'angularfire2';
11+
import {AngularFireModule} from '@angular/fire';
1212
import {RouterModule} from '@angular/router';
1313
import {routerConfig} from "./router.config";
1414
import {CourseDetailComponent} from './course-detail/course-detail.component';
@@ -31,7 +31,7 @@ import { CreateLessonComponent } from './create-lesson/create-lesson.component';
3131
import {CourseDetailResolver} from "./course-detail/course-detail.resolver";
3232
import { LoadingComponent } from './loading/loading.component';
3333
import {firebaseConfig} from "../environments/firebase.config";
34-
import {AngularFireDatabaseModule} from "angularfire2/database";
34+
import {AngularFireDatabaseModule} from "@angular/fire/database";
3535

3636

3737
@NgModule({

src/app/services/courses.service.ts

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Injectable } from '@angular/core';
2-
import {AngularFireDatabase} from "angularfire2/database";
2+
import {AngularFireDatabase} from "@angular/fire/database";
33
import {Observable} from "rxjs/Observable";
44
import {Course} from "../shared/model/course";
55
import {Lesson} from "../shared/model/lesson";
6+
import {first, map} from 'rxjs/operators';
67

78
@Injectable()
89
export class CoursesService {
@@ -13,40 +14,40 @@ export class CoursesService {
1314

1415
findAllCourses(): Observable<Course[]> {
1516
return this.db.list('courses')
17+
.valueChanges()
1618
.first()
1719
.do(console.log);
1820
}
1921

22+
2023
findLatestLessons(): Observable<Lesson[]> {
21-
return this.db.list('lessons', {
22-
query: {
23-
orderByKey: true,
24-
limitToLast: 10
25-
}
26-
})
24+
return this.db.list('lessons', ref => ref.orderByKey().limitToLast(10))
25+
.valueChanges()
2726
.first()
2827
.do(console.log);
2928
}
3029

3130
findCourseByUrl(courseUrl:string): Observable<Course> {
32-
return this.db.list('courses', {
33-
query: {
34-
orderByChild: 'url',
35-
equalTo: courseUrl
36-
}
37-
})
38-
.map( data => data[0])
39-
.first();
31+
return this.db.list('courses', ref => ref.orderByChild('url').equalTo(courseUrl))
32+
.snapshotChanges()
33+
.pipe(
34+
map( changes => {
35+
36+
const snap = changes[0];
37+
38+
return <Course> {
39+
id:snap.payload.key,
40+
...snap.payload.val()
41+
};
4042

43+
}),
44+
first()
45+
)
4146
}
4247

4348
findLessonsForCourse(courseId:string): Observable<Lesson[]> {
44-
return <any>this.db.list('lessons', {
45-
query: {
46-
orderByChild: 'courseId',
47-
equalTo: courseId
48-
}
49-
})
49+
return <any>this.db.list('lessons', ref => ref.orderByChild('courseId').equalTo(courseId))
50+
.valueChanges()
5051
.first();
5152
}
5253

src/polyfills.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
/** Evergreen browsers require these. **/
4444
import 'core-js/es6/reflect';
45-
import 'core-js/es7/reflect';
45+
4646

4747

4848
/** ALL Firefox browsers require the following to support `@angular/animation`. **/

0 commit comments

Comments
 (0)