Skip to content

Commit

Permalink
Merge pull request #24 from khajatakreemulla/feat-backend-integration
Browse files Browse the repository at this point in the history
Backend Integration
  • Loading branch information
gitcommitshow authored Jul 31, 2022
2 parents b68c995 + 38ae8e9 commit 5e1be1a
Show file tree
Hide file tree
Showing 29 changed files with 368 additions and 53 deletions.
4 changes: 4 additions & 0 deletions frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ const routes: Routes = [
path: 'reference',
loadChildren: () => import('./reference/reference.module').then(mod => mod.ReferenceModule),
},
{
path: 'authorize',
loadChildren: () => import('./login/login.module').then(mod => mod.LoginModule),
},
{
path: '**',
redirectTo: 'home',
Expand Down
47 changes: 24 additions & 23 deletions frontend/src/app/generate-token/generate-token.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,32 @@ <h1 class="mb-5 heading">{{ "generate-token.create" | transloco }}</h1>
<a target="_blank" href="https://tools.ietf.org/html/rfc7518#section-3">Recommend algorithms</a>
</p>

<p class="rectangle">
HS256
<span></span>
</p>
<form #postForm="ngForm" (ngSubmit)="onCreateToken(postForm.value)">
<select ngModel name="algo" class="rectangle">
<option selected>HS256</option>
<option>RS256</option>
<option>ES256</option>
</select>

<p class="font-grey algo">{{"generate-token.data" | transloco}}</p>
<p class="font-grey algo">{{"generate-token.data" | transloco}}</p>

<p class="rectangle-1 data1">
{{ "generate-token.data1" | transloco }}
</p>
<textarea [(ngModel)]="payloadValue" name="payload" class="rectangle-1 data1"></textarea>

<p class="font-grey flex-column note">
<span>
{{ "generate-token.note" | transloco }}
</span>
<span>
{{ "generate-token.note1" | transloco }}
</span>
<span>
{{ "generate-token.note2" | transloco }}
</span>
</p>
<p class="font-grey flex-column note">
<span>
{{ "generate-token.note" | transloco }}
</span>
<span>
{{ "generate-token.note1" | transloco }}
</span>
<span>
{{ "generate-token.note2" | transloco }}
</span>
</p>

<div class="row">
<div class="col-auto text-end">
<button type="button" (click)="nextStep()" class="btn btn-warning mt-5" innerHTML="{{ 'generate-token.generateToken' | transloco }}"></button>
<div class="row">
<div class="col-auto text-end">
<button type="submit" (click)="nextStep()" class="btn btn-warning mt-5" innerHTML="{{ 'generate-token.generateToken' | transloco }}"></button>
</div>
</div>
</div>
</form>
7 changes: 5 additions & 2 deletions frontend/src/app/generate-token/generate-token.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
color: #7292ff;
display: flex;
align-items: center;

-webkit-appearance : none

span {
width: 0;
height: 0;
Expand All @@ -47,10 +48,12 @@
.rectangle-1{
width: 668px;
height: 110px;
padding: 17px 397px 72px 24px;
padding: 17px 17px;
font-weight: bold;
border-radius: 6px;
border: solid 1px #3a3f51;
background-color: #272f48;
color: #fff
}
.data1 {
font-family: Helvetica;
Expand Down
20 changes: 19 additions & 1 deletion frontend/src/app/generate-token/generate-token.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { JwtService } from '../shared/services/jwt.service';
import { StepService } from '../shared/services/step.service';

@Component({
Expand All @@ -9,15 +10,32 @@ import { StepService } from '../shared/services/step.service';
})
export class GenerateTokenComponent implements OnInit {

payloadValue = '{ "data" : "We raised series A" }'

@Input() token = ""

constructor(private router: Router,
private jwtService: JwtService,
private stepService: StepService) {
this.stepService.setStep(5)
}

ngOnInit(): void {
}

onCreateToken(postData: {algo: string, payload: string}){
this.jwtService.post(postData).subscribe({
next: (success: any)=>{
this.token = success.token
localStorage.setItem('token', this.token)
}, error: (error: any) => {
console.error('error:', error);
},
})
}

nextStep(){
this.onCreateToken
this.stepService.setStep(5)
this.router.navigate(['generate-token1'])
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/generate-token/generate-token.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CommonModule } from '@angular/common';
import { GenerateTokenRoutingModule } from './generate-token-routing.module';
import { TranslocoModule } from '@ngneat/transloco';
import { GenerateTokenComponent } from './generate-token.component';
import { FormsModule } from '@angular/forms';


@NgModule({
Expand All @@ -13,6 +14,7 @@ import { GenerateTokenComponent } from './generate-token.component';
imports: [
CommonModule,
TranslocoModule,
FormsModule,
GenerateTokenRoutingModule
]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 class="mb-5">{{ "generate-token1.create" | transloco }}</h1>
</div>
</div>
<div class="card-body">
<span class="jwt-decoded">{{ "From backend" }}</span>
<span class="jwt-decoded">{{ generatedToken }}</span>
</div>
</div>

Expand Down
5 changes: 5 additions & 0 deletions frontend/src/app/generate-token1/generate-token1.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { DemoService } from '../shared/services/demo.service';
import { StepService } from '../shared/services/step.service';

@Component({
Expand All @@ -9,13 +10,17 @@ import { StepService } from '../shared/services/step.service';
})
export class GenerateToken1Component implements OnInit {

generatedToken: string | null = ""
constructor(private router: Router,
private demoService: DemoService,
private stepService: StepService,
) {
this.stepService.setStep(5)
}

ngOnInit(): void {
var myToken = localStorage.getItem('token')
this.generatedToken = myToken
}


Expand Down
16 changes: 16 additions & 0 deletions frontend/src/app/login/login-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 { }
9 changes: 9 additions & 0 deletions frontend/src/app/login/login.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>SignUp</h1>

<form #loginForm="ngForm" (ngSubmit)="login(loginForm.value)">
<div class="form_group">
<input ngModel="user" name="username" class="login_input" type="text">
<input ngModel="pass" name="password" class="login_input" type="password">
</div>
<button class="login_button" type="submit">Login</button>
</form>
20 changes: 20 additions & 0 deletions frontend/src/app/login/login.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.login_input{
background-color: #161f27;
color: #fff;
border: none;
padding: 8px;
border-radius: 4px;
margin-bottom: 10px ;
width: 250px;
}
.form_group{
display: flex;
flex-direction: column;
}
.login_button{
background-color: #161f27;
padding: 10px 20px;
border: none;
color: #fff;
border-radius: 4px;
}
25 changes: 25 additions & 0 deletions frontend/src/app/login/login.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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();
});
});
29 changes: 29 additions & 0 deletions frontend/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { DemoService } from '../shared/services/demo.service';

@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {

success : any

constructor(
private router: Router,
private demoService: DemoService
) { }

ngOnInit(): void {
}

login(value: any){
this.demoService.remote().login(value).subscribe((success: any)=>{
this.success = success
this.router.navigate(['send-jwt4'])
})
}

}
19 changes: 19 additions & 0 deletions frontend/src/app/login/login.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { LoginRoutingModule } from './login-routing.module';
import { FormsModule } from '@angular/forms';
import { LoginComponent } from './login.component';


@NgModule({
declarations: [
LoginComponent
],
imports: [
CommonModule,
LoginRoutingModule,
FormsModule
]
})
export class LoginModule { }
9 changes: 5 additions & 4 deletions frontend/src/app/send-jwt1/send-jwt1.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ <h1 class="mb-3 heading">{{ "send-jwt1.introduction" | transloco }}</h1>

<hr>

<div class="rectangle">
<div *ngIf="successToken" class="rectangle">
<img src="assets/images/icon-check-square.png"/>
<span>{{ "send-jwt1.authenticated" | transloco | uppercase }}</span>
</div>

<div class="rectangle1">
<h1>{{ "send-jwt1.request" | transloco }}</h1>
<div class="box">
<a href="#" class="font-grey">{{ "send-jwt1.request1" | transloco | uppercase }}</a>
<button (click)="sendJwtThroughRequestParameter()" class="font-grey">{{ "send-jwt1.request1" | transloco | uppercase }}</button>
<img src="assets/images/icon-arrow-right.svg"/>
</div>

<p class="font-grey">{{ "send-jwt1.request2" | transloco}}</p>

<div class="box1">

<div class="box1" style="margin-bottom: 20px;">
<code>
{{ "send-jwt1.code" | transloco }}</code>
</div>

<a class="query" target="_blank" href="#">{{ "send-jwt1.queryParameter" | transloco}}</a>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/app/send-jwt1/send-jwt1.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@
display: flex;
align-items: center;

a {
button {
font-size: 13px;
font-weight: bold;
font-stretch: normal;
font-style: normal;
letter-spacing: 0.13px;
border: none;
background: transparent;
color: #2a2f44;
text-decoration: none;
}
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/app/send-jwt1/send-jwt1.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { DemoService } from '../shared/services/demo.service';
import { StepService } from '../shared/services/step.service';

@Component({
Expand All @@ -11,13 +12,24 @@ export class SendJwt1Component implements OnInit {

constructor(
private router: Router,
private demoService: DemoService,
private stepService: StepService
) {
this.stepService.setStep(7)
}

ngOnInit(): void {
}
successToken = false
sendJwtThroughRequestParameter(){
var myToken = localStorage.getItem('token')
this.demoService.remote().getFromRequestParameter(myToken).subscribe({
next: (success: any)=>{
this.successToken = true
}, error: (error: any) => {
console.error('error:', error);
},
})
}

backStep() {
this.stepService.setStep(6)
Expand Down
Loading

0 comments on commit 5e1be1a

Please sign in to comment.