Skip to content
This repository was archived by the owner on Jan 23, 2022. It is now read-only.

Commit 356a0a5

Browse files
committed
Added login and display user components.
1 parent 1ceb0f6 commit 356a0a5

15 files changed

+222
-129
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ npm install -g generator-angular2-firebase-bootstrap
1313
Then generate your new project:
1414

1515
```bash
16-
yo angular-2-firebase-bootstrap
16+
yo angular2-firebase-bootstrap
1717
```
1818

1919
## Features

generators/app/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ module.exports = yeoman.Base.extend({
7272
"./e2e/tsconfig.json",
7373
"./karma.conf.js",
7474
"./protractor.conf.js",
75+
"./src/app/display-user/display-user.component.css",
76+
"./src/app/display-user/display-user.component.html",
77+
"./src/app/display-user/display-user.component.spec.ts",
78+
"./src/app/display-user/display-user.component.ts",
79+
"./src/app/login-user/login-user.component.css",
80+
"./src/app/login-user/login-user.component.html",
81+
"./src/app/login-user/login-user.component.spec.ts",
82+
"./src/app/login-user/login-user.component.ts",
7583
"./src/app/app.component.css",
7684
"./src/app/app.component.html",
7785
"./src/app/app.module.ts",

generators/app/templates/package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@
2424
"firebase": "^3.6.5",
2525
"bootstrap": "^3.3.7",
2626
"core-js": "^2.4.1",
27-
<<<<<<< HEAD
2827
"ng2-bootstrap": "^1.2.2",
2928
"rxjs": "^5.0.3",
3029
"ts-helpers": "^1.1.2",
31-
"zone.js": "^0.7.5"
32-
=======
33-
"ng2-bootstrap": "^1.1.16-9",
34-
"rxjs": "^5.0.2",
35-
"ts-helpers": "^1.1.1",
36-
"zone.js": "0.7.2"
37-
>>>>>>> v1.0.6
30+
"zone.js": "^0.7.6"
3831
},
3932
"devDependencies": {
4033
"@angular/compiler-cli": "^2.4.3",
Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +0,0 @@
1-
.main {
2-
max-width: 320px;
3-
margin: 0 auto;
4-
}
5-
6-
.login-or {
7-
position: relative;
8-
font-size: 18px;
9-
color: #aaa;
10-
margin-top: 10px;
11-
margin-bottom: 10px;
12-
padding-top: 10px;
13-
padding-bottom: 10px;
14-
}
15-
16-
.span-or {
17-
display: block;
18-
position: absolute;
19-
left: 50%;
20-
top: -2px;
21-
margin-left: -25px;
22-
background-color: #fff;
23-
width: 50px;
24-
text-align: center;
25-
}
26-
27-
.hr-or {
28-
background-color: #cdcdcd;
29-
height: 1px;
30-
margin-top: 0px !important;
31-
margin-bottom: 0px !important;
32-
}
33-
34-
h3 {
35-
text-align: center;
36-
line-height: 300%;
37-
}

generators/app/templates/src/app/app.component.html

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,6 @@
22
<h1>
33
{{title}}
44
</h1>
5-
<div class="row" *ngIf="isLoggedIn()|async">
6-
<div class="row">
7-
<div class="col-md-6 col-md-offset-3">
8-
<div class="panel panel-default">
9-
<div class="panel-heading">User Information</div>
10-
<ul class="list-group">
11-
<li class="list-group-item">Email: {{(currentUser()|async).email}}</li>
12-
<li class="list-group-item">Display Name: {{(currentUser()|async).displayName}}</li>
13-
<li class="list-group-item">Uid: {{(currentUser()|async).uid}}</li>
14-
<li class="list-group-item">Provider Id: {{(currentUser()|async).providerId}}</li>
15-
<li class="list-group-item" *ngIf="(currentUser()|async).photoURL"><img [src]="(currentUser()|async).photoURL"/></li>
16-
</ul>
17-
</div>
18-
</div>
19-
<div class="row">
20-
<div class="col-md-3 col-md-offset-5">
21-
<a href="#" class="btn btn-lg btn-primary btn-block" (click)="logout()">Log out</a>
22-
</div>
23-
</div>
24-
</div>
25-
</div>
26-
<div class="row">
27-
<div class="main" *ngIf="!(isLoggedIn()|async)">
28-
29-
<h3>Please Log In
30-
<!--, or <a href="#">Sign Up</a>-->
31-
</h3>
32-
<div class="row">
33-
<div class="col-xs-6 col-sm-6 col-md-6">
34-
<a href="#" class="btn btn-lg btn-primary btn-block" (click)="loginVia('twitter')">Twitter</a>
35-
</div>
36-
<div class="col-xs-6 col-sm-6 col-md-6">
37-
<a href="#" class="btn btn-lg btn-info btn-block" (click)="loginVia('google')">Google</a>
38-
</div>
39-
</div>
40-
<div class="login-or">
41-
<hr class="hr-or">
42-
<span class="span-or">or</span>
43-
</div>
44-
45-
<form role="form">
46-
<div class="form-group">
47-
<label for="email">Email</label>
48-
<input required type="text" class="form-control" id="email" name="email" [(ngModel)]="email">
49-
</div>
50-
<div class="form-group">
51-
<label for="password">Password</label>
52-
<input type="password" class="form-control" id="password" name="password" [(ngModel)]="password">
53-
</div>
54-
<button class="btn btn btn-primary" (click)="login()">
55-
Log In
56-
</button>
57-
</form>
58-
59-
</div>
60-
</div>
5+
<app-display-user></app-display-user>
6+
<app-login-user></app-login-user>
617
</div>
Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import {Component} from "@angular/core";
2-
import {AuthService} from "app/shared/auth.service";
3-
import {Observable} from "rxjs";
4-
import {UserInfo} from "app/shared/user-info";
52

63
@Component({
74
selector: 'app-root',
@@ -11,28 +8,6 @@ import {UserInfo} from "app/shared/user-info";
118
export class AppComponent {
129
title = 'app works! - <%= name %>';
1310

14-
email: string;
15-
password: string;
16-
17-
constructor(private authService: AuthService) {}
18-
19-
login() {
20-
this.authService.login(this.email, this.password);
21-
}
22-
23-
loginVia(provider: string) {
24-
this.authService.loginViaProvider(provider);
25-
}
26-
27-
logout() {
28-
this.authService.logout();
29-
}
30-
31-
isLoggedIn(): Observable<boolean> {
32-
return this.authService.isLoggedIn();
33-
}
34-
35-
currentUser(): Observable<UserInfo> {
36-
return this.authService.currentUser();
11+
constructor() {
3712
}
3813
}

generators/app/templates/src/app/app.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ import { AppComponent } from './app.component';
77
import {authConfig, firebaseConfig} from "environments/firebaseConfig";
88
import {AngularFireModule} from "angularfire2";
99
import {AuthService} from "app/shared/auth.service";
10+
import {LoginUserComponent} from "app/login-user/login-user.component";
11+
import {DisplayUserComponent} from "app/display-user/display-user.component";
1012

1113
@NgModule({
1214
declarations: [
13-
AppComponent
15+
AppComponent,
16+
DisplayUserComponent,
17+
LoginUserComponent
1418
],
1519
imports: [
1620
BrowserModule,

generators/app/templates/src/app/display-user/display-user.component.css

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div class="row" *ngIf="isLoggedIn()|async">
2+
<div class="row">
3+
<div class="col-md-6 col-md-offset-3">
4+
<div class="panel panel-default">
5+
<div class="panel-heading">User Information</div>
6+
<ul class="list-group">
7+
<li class="list-group-item">Email: {{(currentUser()|async).email}}</li>
8+
<li class="list-group-item">Display Name: {{(currentUser()|async).displayName}}</li>
9+
<li class="list-group-item">Uid: {{(currentUser()|async).uid}}</li>
10+
<li class="list-group-item">Provider Id: {{(currentUser()|async).providerId}}</li>
11+
<li class="list-group-item" *ngIf="(currentUser()|async).photoURL"><img [src]="(currentUser()|async).photoURL"/></li>
12+
</ul>
13+
</div>
14+
</div>
15+
<div class="row">
16+
<div class="col-md-3 col-md-offset-5">
17+
<a href="#" class="btn btn-lg btn-primary btn-block" (click)="logout()">Log out</a>
18+
</div>
19+
</div>
20+
</div>
21+
</div>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* tslint:disable:no-unused-variable */
2+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3+
import { By } from '@angular/platform-browser';
4+
import { DebugElement } from '@angular/core';
5+
6+
import { DisplayUserComponent } from './display-user.component';
7+
8+
describe('DisplayUserComponent', () => {
9+
let component: DisplayUserComponent;
10+
let fixture: ComponentFixture<DisplayUserComponent>;
11+
12+
beforeEach(async(() => {
13+
TestBed.configureTestingModule({
14+
declarations: [ DisplayUserComponent ]
15+
})
16+
.compileComponents();
17+
}));
18+
19+
beforeEach(() => {
20+
fixture = TestBed.createComponent(DisplayUserComponent);
21+
component = fixture.componentInstance;
22+
fixture.detectChanges();
23+
});
24+
25+
it('should create', () => {
26+
expect(component).toBeTruthy();
27+
});
28+
});

0 commit comments

Comments
 (0)