Skip to content

Commit

Permalink
feat(apps): create login page (#502)
Browse files Browse the repository at this point in the history
Create the login page for the prs application.

PR Close #502
  • Loading branch information
josephperrott committed Apr 7, 2022
1 parent 3e10e5f commit 50857c6
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/prs/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';

const routes: Routes = [];
const routes: Routes = [
{path: 'login', loadChildren: () => import('./login/login.module').then((m) => m.LoginModule)},
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
Expand Down
2 changes: 1 addition & 1 deletion apps/prs/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<mat-toolbar color="primary" class="app-header-bar">
<span class="spacer"></span>
<account></account>
<account-menu-button></account-menu-button>
</mat-toolbar>
<mat-sidenav-container class="sidenav-container">
<mat-sidenav #drawer class="sidenav" mode="side">
Expand Down
1 change: 0 additions & 1 deletion apps/prs/src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
position: sticky;
top: 0;
z-index: 1;
flex-direction: row;

.spacer {
flex: 1;
Expand Down
11 changes: 11 additions & 0 deletions apps/prs/src/app/login/login-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {LoginComponent} from './login.component';

const routes: Routes = [{path: '', component: LoginComponent}];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class LoginRoutingModule {}
11 changes: 11 additions & 0 deletions apps/prs/src/app/login/login.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<mat-card>
<mat-card-title>
Angular PR Management
</mat-card-title>

<!-- TODO: expand on welcome/login screen content. -->

<mat-card-actions align="end">
<button mat-raised-button color="primary" (click)="signIn()">Sign In</button>
</mat-card-actions>
</mat-card>
4 changes: 4 additions & 0 deletions apps/prs/src/app/login/login.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.mat-card {
width: 500px;
margin: 150px auto 0;
}
24 changes: 24 additions & 0 deletions apps/prs/src/app/login/login.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';

import {LoginComponent} from './login.component';

describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [LoginComponent],
}).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
20 changes: 20 additions & 0 deletions apps/prs/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Component} from '@angular/core';
import {Router} from '@angular/router';
import {AccountService} from '../../../../shared/account/account.service';

@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'],
})
export class LoginComponent {
constructor(private account: AccountService, private router: Router) {}

signIn() {
this.account.signInWithGoogle().then((signedIn) => {
if (signedIn) {
this.router.navigateByUrl('');
}
});
}
}
15 changes: 15 additions & 0 deletions apps/prs/src/app/login/login.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';

import {LoginRoutingModule} from './login-routing.module';
import {LoginComponent} from './login.component';

import {MatCardModule} from '@angular/material/card';
import {MatButtonModule} from '@angular/material/button';
import {AccountModule} from '../../../../shared/account/account.module';

@NgModule({
declarations: [LoginComponent],
imports: [CommonModule, LoginRoutingModule, MatCardModule, MatButtonModule, AccountModule],
})
export class LoginModule {}

0 comments on commit 50857c6

Please sign in to comment.