-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66e14fd
commit 418e624
Showing
7 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="bg-info p-2 text-white"> | ||
<h3>Placeholder for Admin Features</h3> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
templateUrl: "admin.component.html" | ||
}) | ||
|
||
export class AdminComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { NgModule } from "@angular/core"; | ||
import { CommonModule } from "@angular/common"; | ||
import { FormsModule } from "@angular/forms"; | ||
import { RouterModule } from "@angular/router"; | ||
import { AuthComponent } from "./auth.component"; | ||
import { AdminComponent } from "./admin.component"; | ||
|
||
let routing = RouterModule.forChild([ | ||
{ path: "auth", component: AuthComponent }, | ||
{ path: "main", component: AdminComponent }, | ||
{ path: "**", redirectTo: "auth" }, | ||
]) | ||
|
||
@NgModule({ | ||
imports: [CommonModule, FormsModule, routing], | ||
declarations: [AuthComponent, AdminComponent] | ||
}) | ||
export class AdminModule{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div class="bg-info p-2 text-center"> | ||
<h3>SportsStore Admin</h3> | ||
</div> | ||
<div class="bg-danger mt-2 p-2 text-center text-white" *ngIf="errorMessage != null"> | ||
{{ errorMessage }} | ||
</div> | ||
<div class="p-2"> | ||
<form novalidate #form="ngForm" (ngSubmit)="authenticate(form)"> | ||
<div class="form-group"> | ||
<label>Name</label> | ||
<input class="form-control" name="username" [(ngModel)]="username" required /> | ||
</div> | ||
<div class="form-group"> | ||
<label>Password</label> | ||
<input class="form-control" type="password" name="password" [(ngModel)]="password" required /> | ||
</div> | ||
<div class="text-center"> | ||
<button class="btn btn-secondary m-1" routerLink="/">Go back></button> | ||
<button class="btn btn-primary m-1" type="submit">Log in</button> | ||
</div> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Component } from "@angular/core"; | ||
import { NgForm } from "@angular/forms"; | ||
import { Router } from "@angular/router"; | ||
|
||
@Component({ | ||
templateUrl: "auth.component.html" | ||
}) | ||
|
||
export class AuthComponent { | ||
|
||
public username: string; | ||
public password: string; | ||
public errorMessage: string; | ||
|
||
constructor(private router: Router){} | ||
|
||
authenticate(form: NgForm) { | ||
if (form.valid) { | ||
//perform authentication | ||
this.router.navigateByUrl("/admin/main"); | ||
} else { | ||
this.errorMessage = "Form data invalid"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters