Skip to content

Commit 0e9a378

Browse files
committed
up
1 parent b59c3a4 commit 0e9a378

File tree

16 files changed

+99
-44
lines changed

16 files changed

+99
-44
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Injectable, Injector } from '@angular/core';
2+
3+
@Injectable()
4+
export class StorageService {
5+
private baseUrl = '/';
6+
constructor(
7+
) {
8+
}
9+
10+
getPropertyFromLS(key) {
11+
JSON.stringify(window.localStorage.getItem(key));
12+
}
13+
14+
setPropertyFromLS(key, value) {
15+
window.localStorage.setItem(key, JSON.parse(value));
16+
}
17+
18+
removePropertyFromLS(key){
19+
window.localStorage.removeItem(key);
20+
}
21+
22+
23+
}

src/app/app-routing.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { PublicHomeComponent } from './public/home/home.component';
1111
import { AboutComponent } from './private/about/about.component';
1212
import { GalleryComponent } from './private/gallery/gallery.component';
1313
const routes: Routes = [
14-
{ path: '', redirectTo: 'user/home', pathMatch: 'full' },
14+
{ path: '', redirectTo: 'sign-in', pathMatch: 'full' },
1515
{
1616
path: '',
1717
component: PublicComponent,

src/app/app.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { HttpClientModule, HttpClient } from '@angular/common/http';
44
import { BrowserModule } from '@angular/platform-browser';
55
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
66
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
7-
import { FormsModule } from '@angular/forms';
7+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
88
import { AppComponent } from './app.component';
99
import { AppRoutingModule } from './app-routing.module';
1010
import { PublicModule } from './public/public.module';
@@ -20,6 +20,7 @@ import { AlwaysAuthGuard, OnlyLoggedInUsersGuard } from './AlwaysAuthGuard ';
2020
BrowserAnimationsModule,
2121
HttpClientModule,
2222
FormsModule,
23+
ReactiveFormsModule,
2324
AppRoutingModule,
2425
PublicModule,
2526
PrivateModule,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#publicModule{
2+
background-color: #f52c2c;
3+
height: 100vh;
4+
}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<app-public-header></app-public-header>
2-
<div class="container">
3-
<router-outlet></router-outlet>
2+
<div id="publicModule">
3+
<div class="container">
4+
<router-outlet></router-outlet>
5+
</div>
46
</div>
5-
<app-public-footer></app-public-footer>
7+
8+
<app-public-footer></app-public-footer>

src/app/public/public.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ReactiveFormsModule } from '@angular/forms';
12
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
23
import { CommonModule } from '@angular/common';
34
import { PublicHeaderComponent } from './header/header.component';
@@ -11,6 +12,7 @@ import { AppRoutingModule } from '../app-routing.module';
1112
imports: [
1213
CommonModule,
1314
AppRoutingModule,
15+
ReactiveFormsModule
1416

1517
],
1618
declarations: [
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#signIn {
2+
color: #fff;
3+
}
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
<p>
2-
signin
3-
</p>
4-
<input type="text" placeholder="username">
5-
<input type="password" placeholder="password">
6-
<button>login</button>
1+
<div id="signIn">
2+
<div class="row">
3+
<div class="col-sm-6 col-md-6 col-lg-6 col-sm-offset-3 col-md-offset-3 col-lg-offset-3">
4+
<h1 class="text-center">SignIn</h1>
5+
<form [formGroup]="signInForm" (ngSubmit)="onSubmit()" >
6+
<div class="form-group">
7+
<label for="email">Email address *</label>
8+
<input type="email" class="form-control" id="email" [formControl]="signInForm.controls['username']">
9+
</div>
10+
<div class="form-group">
11+
<label for="pwd">Password *</label>
12+
<input type="password" class="form-control" id="pwd" formControlName="password" [formControl]="signInForm.controls['password']">
13+
</div>
14+
<button type="submit" class="btn btn-default ">Submit</button>
15+
</form>
16+
</div>
17+
</div>
18+
</div>
Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
import { Router } from '@angular/router';
2+
import { ToastrService } from 'ngx-toastr';
13
import { Component, OnInit } from '@angular/core';
4+
import { User } from '../../shared/models';
5+
import { FormGroup, FormBuilder, Validators } from '../../../../node_modules/@angular/forms';
26

37
@Component({
48
selector: 'app-signin',
@@ -7,9 +11,30 @@ import { Component, OnInit } from '@angular/core';
711
})
812
export class PublicSigninComponent implements OnInit {
913

10-
constructor() { }
14+
public signInForm: FormGroup;
15+
16+
constructor(
17+
private formBuilder: FormBuilder,
18+
private toastrService:ToastrService,
19+
private router: Router
20+
) {
21+
this.signInForm = formBuilder.group({
22+
username: ['', Validators.required],
23+
password: ['', Validators.required],
24+
});
25+
}
1126

1227
ngOnInit() {
1328
}
1429

30+
onSubmit(){
31+
let signInData:User = this.signInForm.value;
32+
if(signInData.username.toLowerCase() === 'admin' && signInData.password.toLowerCase() === 'admin' ){
33+
this.router.navigate(['user/home']);
34+
}else{
35+
this.toastrService.error('Username or password is wrong', 'Error!', { closeButton: true });
36+
}
37+
38+
}
39+
1540
}

src/app/services/api.service.spec.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)