diff --git a/store-front/src/app/app.module.ts b/store-front/src/app/app.module.ts index c3dde1c..0b39f72 100644 --- a/store-front/src/app/app.module.ts +++ b/store-front/src/app/app.module.ts @@ -12,12 +12,14 @@ import { HomeComponent } from './components/home/home.component'; import { NavBarComponent } from './components/nav-bar/nav-bar.component'; import { LoginService } from './services/login.service'; +import { MyAccountComponent } from './components/my-account/my-account.component'; @NgModule({ declarations: [ AppComponent, HomeComponent, - NavBarComponent + NavBarComponent, + MyAccountComponent ], imports: [ BrowserModule, diff --git a/store-front/src/app/app.routing.ts b/store-front/src/app/app.routing.ts index 5c059df..0455a3d 100644 --- a/store-front/src/app/app.routing.ts +++ b/store-front/src/app/app.routing.ts @@ -5,6 +5,7 @@ import {ModuleWithProviders} from '@angular/core'; import {Routes, RouterModule} from '@angular/router'; import {HomeComponent} from './components/home/home.component'; +import {MyAccountComponent} from './components/my-account/my-account.component'; const appRoutes: Routes = [ @@ -16,6 +17,10 @@ const appRoutes: Routes = [ { path: 'home', component: HomeComponent + }, + { + path: 'myAccount', + component: MyAccountComponent } ]; diff --git a/store-front/src/app/components/home/home.component.html b/store-front/src/app/components/home/home.component.html index 39049d6..c016306 100644 --- a/store-front/src/app/components/home/home.component.html +++ b/store-front/src/app/components/home/home.component.html @@ -15,21 +15,21 @@
- +
- +
- +
diff --git a/store-front/src/app/components/my-account/my-account.component.css b/store-front/src/app/components/my-account/my-account.component.css new file mode 100644 index 0000000..e69de29 diff --git a/store-front/src/app/components/my-account/my-account.component.html b/store-front/src/app/components/my-account/my-account.component.html new file mode 100644 index 0000000..d06f278 --- /dev/null +++ b/store-front/src/app/components/my-account/my-account.component.html @@ -0,0 +1,64 @@ +
+
+
+

My Account

+
+
+ +
+ +
+
+
+
+
+
+
+
+ + +
+
An email has been sent to email address you just registered. Please validate your email address and update your password info.
+
+
+  Username already exists. Choose a different one. + +

Enter your username, special charaters are not allowed. +

+
+
+  Email already exists. Choose a different one. + +

A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.

+
+ +
+
+
+ +
+
Incorrect username or password.
+
+
+ + +

Enter your username

+
+
+ + +

Enter the password that accompanies your username +

+
+ +
+
+
+ Content 2 +
+
+
+
+
+
+
diff --git a/store-front/src/app/components/my-account/my-account.component.spec.ts b/store-front/src/app/components/my-account/my-account.component.spec.ts new file mode 100644 index 0000000..c312287 --- /dev/null +++ b/store-front/src/app/components/my-account/my-account.component.spec.ts @@ -0,0 +1,28 @@ +/* tslint:disable:no-unused-variable */ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { DebugElement } from '@angular/core'; + +import { MyAccountComponent } from './my-account.component'; + +describe('MyAccountComponent', () => { + let component: MyAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MyAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MyAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/store-front/src/app/components/my-account/my-account.component.ts b/store-front/src/app/components/my-account/my-account.component.ts new file mode 100644 index 0000000..7a75aac --- /dev/null +++ b/store-front/src/app/components/my-account/my-account.component.ts @@ -0,0 +1,47 @@ +import { Component, OnInit } from '@angular/core'; +import {AppConst} from '../../constants/app-const'; +import {Router} from "@angular/router"; +import {LoginService} from "../../services/login.service"; + +@Component({ + selector: 'app-my-account', + templateUrl: './my-account.component.html', + styleUrls: ['./my-account.component.css'] +}) +export class MyAccountComponent implements OnInit { + + private serverPath = AppConst.serverPath; + private loginError:boolean = false; + private loggedIn = false; + private credential = {'username':'', 'password':''}; + + constructor (private loginService: LoginService, private router: Router){ + } + + onSubmit() { + this.loginService.sendCredential(this.credential.username, this.credential.password).subscribe( + res=>{ + console.log(res); + localStorage.setItem("xAuthToken", res.json().token); + this.loggedIn=true; + location.reload(); + this.router.navigate(['/home']); + }, + error=>{ + this.loggedIn=false; + } + ); + } + + ngOnInit() { + this.loginService.checkSession().subscribe( + res => { + this.loggedIn=true; + }, + error => { + this.loggedIn=false; + } + ); + } + +} diff --git a/store-front/src/app/components/nav-bar/nav-bar.component.html b/store-front/src/app/components/nav-bar/nav-bar.component.html index 3419a0e..55d86eb 100644 --- a/store-front/src/app/components/nav-bar/nav-bar.component.html +++ b/store-front/src/app/components/nav-bar/nav-bar.component.html @@ -3,7 +3,7 @@