diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 24de53c..519d39f 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,16 +1,23 @@ import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; +import { Routes, RouterModule, PreloadAllModules } from '@angular/router'; import { LoginComponent } from './login/login.component'; import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; +import { AuthGuard } from './auth.guard'; const routes: Routes = [ { path: '', component: LoginComponent }, - { path: '**', component: PageNotFoundComponent}, + { + canActivate: [AuthGuard], + path: 'words', + loadChildren: './words/words.module#WordsModule' + }, + { path: '**', component: PageNotFoundComponent } ]; @NgModule({ - imports: [RouterModule.forRoot(routes)], + imports: [ + RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) + ], exports: [RouterModule] }) export class AppRoutingModule {} - \ No newline at end of file diff --git a/src/app/auth.guard.spec.ts b/src/app/auth.guard.spec.ts new file mode 100644 index 0000000..7ed05ee --- /dev/null +++ b/src/app/auth.guard.spec.ts @@ -0,0 +1,15 @@ +import { TestBed, async, inject } from '@angular/core/testing'; + +import { AuthGuard } from './auth.guard'; + +describe('AuthGuard', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [AuthGuard] + }); + }); + + it('should ...', inject([AuthGuard], (guard: AuthGuard) => { + expect(guard).toBeTruthy(); + })); +}); diff --git a/src/app/auth.guard.ts b/src/app/auth.guard.ts new file mode 100644 index 0000000..101e1b9 --- /dev/null +++ b/src/app/auth.guard.ts @@ -0,0 +1,25 @@ +import { Injectable } from '@angular/core'; +import { + CanActivate, + ActivatedRouteSnapshot, + RouterStateSnapshot +} from '@angular/router'; +import { Observable } from 'rxjs'; +import { AuthService } from './auth.service'; + +@Injectable({ + providedIn: 'root' +}) +export class AuthGuard implements CanActivate { + constructor(private authService: AuthService) {} + + canActivate( + next: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): Observable | Promise | boolean { + if (!this.authService.isLoggedIn) { + return false; + } + return true; + } +} diff --git a/src/app/auth.service.ts b/src/app/auth.service.ts index 21107f0..5ace130 100644 --- a/src/app/auth.service.ts +++ b/src/app/auth.service.ts @@ -1,7 +1,8 @@ -import { Injectable } from "@angular/core"; +import { Injectable } from '@angular/core'; +import { CurrentUser } from './typings'; @Injectable({ - providedIn: "root" + providedIn: 'root' }) export class AuthService { public isLoggedIn: boolean; @@ -9,11 +10,11 @@ export class AuthService { constructor() {} - login(userName: string, password: string) {} + login(userName: string, password: string) { + this.isLoggedIn = true; + } - logOut() {} -} - -interface CurrentUser { - userName: string; + logOut() { + this.isLoggedIn = false; + } } diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html index 9ec2294..cc0da34 100644 --- a/src/app/login/login.component.html +++ b/src/app/login/login.component.html @@ -1,4 +1,83 @@ -
+
+
+
+
+
+
+
+
+ Phoenix Builder +
+
+
+
+
+ +
+
+
+
+ +

+
+
+ +

+
+ +
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+ +
+
+ +
+
+
+
+
+ + - \ No newline at end of file +
--> \ No newline at end of file diff --git a/src/app/login/login.component.scss b/src/app/login/login.component.scss index 4d66230..6e63503 100644 --- a/src/app/login/login.component.scss +++ b/src/app/login/login.component.scss @@ -1,3 +1,20 @@ -body{ +:host { background-color:#039; } + +.grid-y { + background-color: #039; +} + +.footer-brand-text { + color: white; +} + +.inline-list { + list-style: none; + text-align: right; + & > li { + display: inline; + margin-right: 2rem; + } +} \ No newline at end of file diff --git a/src/app/login/login.module.ts b/src/app/login/login.module.ts index 64b0888..10f8b86 100644 --- a/src/app/login/login.module.ts +++ b/src/app/login/login.module.ts @@ -10,7 +10,7 @@ import { RouterModule } from '@angular/router'; imports: [ CommonModule, RouterModule.forChild([ - { path: '/login', component: LoginComponent } + { path: 'login', component: LoginComponent } ]), ], })