Skip to content

Commit aed0589

Browse files
committed
add some firebase
1 parent 30cde50 commit aed0589

15 files changed

+175
-6
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
firebase.config.ts
2+
13
# See http://help.github.com/ignore-files/ for more about ignoring files.
24

35
# compiled output

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ script:
3333
export TARGET="$ROOT/$path";
3434
cd $TARGET;
3535
36+
if [ "$path" == "03-angular4-firebase-auth" ]; then
37+
cp -Rf ./src/firebase.config-default.ts ./firebase.config.ts
38+
fi;
39+
3640
yarn install;
3741
yarn predeploy;
3842
if [ -f npm-debug.log ]; then cat npm-debug.log; fi;

03-angular4-firebase-auth/.angular-cli.json

+16-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@
4242
],
4343
"defaults": {
4444
"styleExt": "css",
45-
"component": {}
45+
"component": {
46+
"spec": false,
47+
"inlineStyle": true
48+
},
49+
"directive": {
50+
"spec": false
51+
},
52+
"module": {
53+
"spec": false
54+
},
55+
"pipe": {
56+
"spec": false
57+
},
58+
"service": {
59+
"spec": false
60+
}
4661
}
4762
}

03-angular4-firebase-auth/README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
# TODO App using Angular 4 Redux store [![Build Status](https://travis-ci.org/daggerok/angular-examples.svg)](https://travis-ci.org/daggerok/angular-examples)
1+
# Auth App using Angular 4 Firebase [![Build Status](https://travis-ci.org/daggerok/angular-examples.svg)](https://travis-ci.org/daggerok/angular-examples)
22

3-
[read more about bootswatch 4](https://bootswatch.com/4-alpha/materia/)
3+
- [TODO](https://www.youtube.com/watch?v=O_jxEC0hWcA)
4+
5+
- [angularfire2 auth](https://github.com/angular/angularfire2/blob/master/docs/1-install-and-setup.md)
6+
7+
- [read more about angularfire2](https://github.com/angular/angularfire2/blob/master/docs/)
8+
9+
- [read more about bootswatch 4](https://bootswatch.com/4-alpha/materia/)
410

511
**default REAMDE.md:**
612

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"users": {
3+
"daggerok": {
4+
"name": "Maksim",
5+
"email": "[email protected]"
6+
}
7+
}
8+
}

03-angular4-firebase-auth/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
"@angular/platform-browser": "4.4.1",
2727
"@angular/platform-browser-dynamic": "4.4.1",
2828
"@angular/router": "4.4.1",
29+
"angularfire2": "4.0.0-rc.2",
2930
"bootstrap": "4.0.0-beta",
3031
"bootswatch": "4.0.0-alpha.6",
3132
"core-js": "2.5.1",
33+
"firebase": "4.3.1",
3234
"jquery": "3.2.1",
3335
"popper.js": "1.12.5",
3436
"rxjs": "5.4.3",

03-angular4-firebase-auth/src/app/app.component.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@ <h1 class="display-3">Auth App</h1>
3333
</div>
3434

3535
<div class="container-fluid">
36-
36+
<ul *ngFor="let user of users" class="list-group">
37+
<li class="list-group-item">{{ user.name}} &lt;{{user.email}}&gt;</li>
38+
</ul>
3739
</div>
40+
41+
<app-login></app-login>

03-angular4-firebase-auth/src/app/app.component.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component } from '@angular/core';
2+
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
23

34
@Component({
45
selector: 'app-root',
@@ -7,4 +8,12 @@ import { Component } from '@angular/core';
78
})
89
export class AppComponent {
910
title = 'Auth App using Angular 4 and Firebase';
11+
$users: FirebaseObjectObservable<any[]>;
12+
users: any[];
13+
constructor(db: AngularFireDatabase) {
14+
this.$users = db.object('users');
15+
this.$users.subscribe(users => {
16+
this.users = Object.keys(users).map(k => users[k]);
17+
});
18+
}
1019
}

03-angular4-firebase-auth/src/app/app.module.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,36 @@ import { FormsModule } from '@angular/forms';
44
import { HttpModule } from '@angular/http';
55

66
import { AppComponent } from './app.component';
7+
import { AngularFireModule } from 'angularfire2';
8+
9+
import { config } from '../firebase.config';
10+
import { LoginComponent } from './components/login/login.component';
11+
import { EmailComponent } from './components/email/email.component';
12+
import { SignupComponent } from './components/signup/signup.component';
13+
import { MembersComponent } from './components/members/members.component';
14+
import { AngularFireDatabaseModule, AngularFireDatabaseProvider } from 'angularfire2/database';
15+
import { AngularFireAuthModule, AngularFireAuthProvider } from 'angularfire2/auth';
716

817
@NgModule({
918
declarations: [
1019
AppComponent,
20+
LoginComponent,
21+
EmailComponent,
22+
SignupComponent,
23+
MembersComponent,
1124
],
1225
imports: [
26+
AngularFireModule.initializeApp(config),
27+
AngularFireDatabaseModule,
28+
AngularFireAuthModule,
1329
BrowserModule,
1430
FormsModule,
1531
HttpModule,
1632
],
17-
providers: [],
33+
providers: [
34+
AngularFireDatabaseProvider,
35+
AngularFireAuthProvider,
36+
],
1837
bootstrap: [AppComponent]
1938
})
2039
export class AppModule {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-email',
5+
template: `
6+
<p>
7+
email Works!
8+
</p>
9+
`,
10+
styles: []
11+
})
12+
export class EmailComponent implements OnInit {
13+
14+
constructor() { }
15+
16+
ngOnInit() {
17+
}
18+
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { AngularFireAuth } from 'angularfire2/auth';
3+
import { Observable } from 'rxjs/Observable';
4+
import { auth, User } from 'firebase/app';
5+
6+
const GoogleAuthProvider = auth.GoogleAuthProvider;
7+
8+
@Component({
9+
selector: 'app-login',
10+
template: `
11+
<div class="container-fluid">
12+
<div> {{ (user | async)?.uid }} </div>
13+
<button class="btn btn-primary" (click)="logIn()">Login</button>
14+
<button class="btn btn-info" (click)="logOut()">Logout</button>
15+
</div>
16+
`,
17+
styles: [],
18+
})
19+
export class LoginComponent implements OnInit {
20+
user: Observable<User>;
21+
constructor(public afAuth: AngularFireAuth) {
22+
this.user = afAuth.authState;
23+
}
24+
ngOnInit() {}
25+
logIn() {
26+
this.afAuth.auth.signInWithPopup(
27+
new GoogleAuthProvider()
28+
);
29+
}
30+
logOut() {
31+
this.afAuth.auth.signOut();
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-members',
5+
template: `
6+
<p>
7+
members Works!
8+
</p>
9+
`,
10+
styles: []
11+
})
12+
export class MembersComponent implements OnInit {
13+
14+
constructor() { }
15+
16+
ngOnInit() {
17+
}
18+
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-signup',
5+
template: `
6+
<p>
7+
signup Works!
8+
</p>
9+
`,
10+
styles: []
11+
})
12+
export class SignupComponent implements OnInit {
13+
14+
constructor() { }
15+
16+
ngOnInit() {
17+
}
18+
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { FirebaseAppConfig } from 'angularfire2';
2+
3+
export const config: FirebaseAppConfig = {
4+
apiKey: "...",
5+
authDomain: "...",
6+
databaseURL: "...",
7+
projectId: "...",
8+
storageBucket: "...",
9+
messagingSenderId: "..."
10+
};

03-angular4-firebase-auth/src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<!--<script src="service-worker-register.js" async></script>-->
55
<meta charset="utf-8">
6-
<title>Angular 4 Redux TODO</title>
6+
<title>Angular 4 Firebase Auth</title>
77
<base href="/">
88
<meta name="viewport" content="width=device-width, initial-scale=1">
99
<link rel="icon" type="image/x-icon" href="favicon.ico">

0 commit comments

Comments
 (0)