Skip to content

Commit 0e16dbd

Browse files
committed
redesigning of the resource component with dialog popup
1 parent 3c64330 commit 0e16dbd

23 files changed

+1340
-68
lines changed

gui/README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
**IN DEVELOPMENT**
55

66
## Description
7-
Added Charts to the History Page and Added table for downloading reports.
7+
Added initial Authentication for the dashboard.
88

99

1010
# Todos
1111
- Report Table Dynamic Fetching
1212
- Upload Code
13-
- Improvements in Settings
13+
- Improvements in Authentication
1414
- Improvements in Profile
15+
- Improvements in Settings
1516
- Other issue fixing related to theme
17+
- Auth Guard
1618

1719

1820

@@ -22,8 +24,11 @@ Added Charts to the History Page and Added table for downloading reports.
2224
## Impacted Areas in Application
2325
General components of the application that this PR will affect:
2426

25-
* Tool Component
26-
* Material Module
27+
* Login Component
28+
* app routing Module
29+
* User Model
30+
* app Module
31+
* History Module
2732
* Readme
2833

2934

gui/package-lock.json

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gui/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@angular/platform-browser": "~7.0.0",
2424
"@angular/platform-browser-dynamic": "~7.0.0",
2525
"@angular/router": "~7.0.0",
26+
"angular-bootstrap-md": "^7.5.4",
2627
"angular-chart.js": "^1.1.1",
2728
"bootstrap": "^4.3.1",
2829
"chart.js": "^2.8.0",

gui/src/app/app-routing.module.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ResourcesComponent } from './view/resources/resources.component';
88
import { SettingsComponent } from './view/settings/settings.component';
99
import { SupportComponent } from './view/support/support.component';
1010
import { ToolsComponent } from './view/tools/tools.component';
11+
1112
import { Top10Component } from './view/tools/top10/top10.component';
1213

1314
const routes: Routes = [

gui/src/app/app.component.html

+7-34
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
3+
14
<mat-toolbar >
25
<div><button mat-icon-button>
36
<img src="/assets/img/OWASP-Logo-White.png" width=60 alt="OWASP LOGO">
@@ -6,38 +9,8 @@
69
<div>RISK ASSESSMENT FRAMEWORK</div>
710

811
</mat-toolbar>
9-
<mat-drawer-container hasBackdrop="false">
10-
<mat-drawer opened="true" mode="push" true >
11-
<mat-nav-list>
12-
13-
<div mat-list-item class="avatarDiv">
14-
<mat-icon>security</mat-icon>
15-
</div>
16-
<a mat-list-item routerLink="home" routerLinkActive="activeLink">
17-
<mat-icon>dashboard</mat-icon>
18-
<span class="nav-caption">Home</span></a>
19-
<a mat-list-item routerLink="tools" routerLinkActive="activeLink">
20-
<mat-icon>build</mat-icon>
21-
<span class="nav-caption">Tools</span></a>
22-
<a mat-list-item routerLink="history" routerLinkActive="activeLink">
23-
<mat-icon>access_time</mat-icon>
24-
<span class="nav-caption">History</span></a>
25-
<a mat-list-item routerLink="profile" routerLinkActive="activeLink">
26-
<mat-icon>person</mat-icon>
27-
<span class="nav-caption">Profile</span></a>
28-
<a mat-list-item routerLink="resources" routerLinkActive="activeLink">
29-
<mat-icon>all_inbox</mat-icon>
30-
<span class="nav-caption">Resources</span></a>
31-
<a mat-list-item routerLink="settings" routerLinkActive="activeLink">
32-
<mat-icon>settings</mat-icon>
33-
<span class="nav-caption">Settings</span></a>
34-
<a mat-list-item routerLink="support" routerLinkActive="activeLink">
35-
<mat-icon>help</mat-icon>
36-
<span class="nav-caption">Support</span></a>
37-
</mat-nav-list>
12+
13+
<!-- <app-login *ngIf="!isAuth"></app-login> -->
14+
<app-navigation *ngIf="!isAuth"></app-navigation>
15+
<router-outlet *ngIf="!isAuth"></router-outlet>
3816

39-
</mat-drawer>
40-
<mat-drawer-content>
41-
<router-outlet></router-outlet>
42-
</mat-drawer-content>
43-
</mat-drawer-container>

gui/src/app/app.component.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1-
import { Component, ViewChild } from '@angular/core';
1+
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
2+
import { AuthService } from './auth/auth.service';
3+
import { Subscription } from 'rxjs';
4+
5+
6+
27

38
@Component({
49
selector: 'app-root',
510
templateUrl: './app.component.html',
611
styleUrls: ['./app.component.css']
712
})
8-
export class AppComponent {
13+
export class AppComponent implements OnInit, OnDestroy {
914
title = 'dashboard';
1015
openSidenav = false;
1116

17+
isAuth = false;
18+
authSubscription: Subscription;
19+
constructor(private authService: AuthService) {
1220

21+
}
22+
ngOnDestroy() {
23+
this.authSubscription.unsubscribe();
24+
}
25+
26+
ngOnInit() {
27+
this.authService.authChange.subscribe(authStatus => {
28+
this.isAuth = authStatus;
29+
});
30+
}
1331
}

gui/src/app/app.module.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import { EmbedVideo } from 'ngx-embed-video';
1717
import { FlexLayoutModule } from '@angular/flex-layout';
1818
import { Top10Component } from './view/tools/top10/top10.component';
1919
import { AuthService } from './auth/auth.service';
20+
import { NavigationComponent } from './view/navigation/navigation.component';
21+
import { DialogComponentComponent } from './view/resources/dialog-component/dialog-component.component';
22+
import { FormsModule } from '@angular/forms';
23+
2024

2125

2226
@NgModule({
@@ -30,7 +34,10 @@ import { AuthService } from './auth/auth.service';
3034
SettingsComponent,
3135
ProfileComponent,
3236
SupportComponent,
33-
Top10Component
37+
Top10Component,
38+
NavigationComponent,
39+
DialogComponentComponent
40+
3441
],
3542
imports: [
3643
BrowserModule,
@@ -40,12 +47,13 @@ import { AuthService } from './auth/auth.service';
4047
HttpClientModule,
4148
EmbedVideo.forRoot(),
4249
FlexLayoutModule,
43-
50+
FormsModule
4451

4552

4653

4754
],
4855
providers: [AuthService],
49-
bootstrap: [AppComponent]
56+
bootstrap: [AppComponent],
57+
entryComponents: [DialogComponentComponent]
5058
})
5159
export class AppModule { }

gui/src/app/auth/auth.service.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
11
import { Injectable } from '@angular/core';
22
import { AuthData } from './auth-data.model';
33
import { User } from './user.model';
4+
import { Subject } from 'rxjs';
5+
46
@Injectable({
57
providedIn: 'root'
68
})
79
export class AuthService {
8-
10+
authChange = new Subject<boolean>();
911
private user: User;
1012
login(authData: AuthData) {
1113
this.user = {
1214
email: authData.email,
1315
userId: '3'
1416
};
17+
this.authChange.next(true);
18+
19+
}
20+
21+
logout() {
22+
this.user = null;
23+
this.authChange.next(false);
24+
25+
}
26+
27+
// tslint:disable-next-line: one-line
28+
registerUser(authData: AuthData){
29+
this.user = {
30+
email: authData.email,
31+
userId: Math.round(Math.random() * 10000).toString()
32+
};
33+
this.authChange.next(true);
1534
}
1635

1736
getUser() {

gui/src/app/auth/login/login.component.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
<mat-card class = "login-card">
55

66
<h2>Login</h2>
7-
<form (ngSubmit)="onSubmit()">
7+
<form (onsubmit)="onSubmit($event)" >
88
<div class="form-group">
99
<label for="username">Username</label>
1010
<mat-form-field appearance="outline">
1111
<mat-label>Username</mat-label>
1212
<input matInput placeholder="Placeholder">
1313
<mat-icon matSuffix>sentiment_very_satisfied</mat-icon>
1414
<mat-hint>Hint</mat-hint>
15-
</mat-form-field> <div *ngIf="submitted && f.username.errors" class="invalid-feedback">
16-
<div *ngIf="f.username.errors.required">Username is required</div>
15+
</mat-form-field> <div class="invalid-feedback">
16+
<div>Username is required</div>
1717
</div>
1818
</div>
1919
<div class="form-group">
@@ -23,13 +23,13 @@ <h2>Login</h2>
2323
<input type = "password" matInput placeholder="">
2424
<mat-icon matSuffix>sentiment_very_satisfied</mat-icon>
2525
<mat-hint>Hint</mat-hint>
26-
</mat-form-field> <div *ngIf="submitted && f.password.errors" class="invalid-feedback">
27-
<div *ngIf="f.password.errors.required">Password is required</div>
26+
</mat-form-field> <div class="invalid-feedback">
27+
<div>Password is required</div>
2828
</div>
2929
</div>
3030
<div class="form-group">
31-
<button mat-raised-button [disabled]="loading" color="accent">Login</button>
32-
<a routerLink="/register" class="btn btn-link">Register</a>
31+
<button mat-raised-button onClick="onSubmit($event)"color="accent">Login</button>
32+
<!-- <a routerLink="/register" class="btn btn-link">Register</a> -->
3333
</div>
3434
</form>
3535

gui/src/app/auth/login/login.component.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22
import { MatDialog } from '@angular/material';
33
import { Router } from '@angular/router';
4-
import { FormGroup } from '@angular/forms';
4+
import { FormGroup, FormControl, Validators } from '@angular/forms';
55
import { AuthService } from '../auth.service';
66

77
@Component({
@@ -13,17 +13,27 @@ export class LoginComponent implements OnInit {
1313
public email = '';
1414
public password = '';
1515

16-
16+
loginForm: FormGroup;
1717
constructor(private authService: AuthService) { }
1818

19-
onSubmit() {
19+
onSubmit(event) {
20+
event.preventDefault();
21+
console.log('submit done');
2022
// this.authService.login({
2123
// email: this.loginForm.value.email,
2224
// password: this.loginForm.value.password
2325
// });
26+
2427
}
2528

2629
ngOnInit() {
30+
this.loginForm = new FormGroup({
31+
email: new FormControl('', {
32+
validators: [Validators.required, Validators.email]
33+
}),
34+
password: new FormControl('', {validators : [Validators.required]})
35+
});
36+
2737
}
2838

2939
}

gui/src/app/material.module.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {MatCardModule,
1010
MatExpansionModule} from '@angular/material';
1111
import { AlertModule } from 'ngx-bootstrap';
1212
import {MatGridListModule} from '@angular/material/grid-list';
13+
import { ModalModule, WavesModule, InputsModule, ButtonsModule } from 'angular-bootstrap-md'
1314
import {MatTableModule} from '@angular/material/table';
1415

1516

@@ -25,12 +26,13 @@ import {MatTableModule} from '@angular/material/table';
2526
MatIconModule, MatFormFieldModule,
2627
MatCardModule, MatInputModule,
2728
AlertModule, MatTableModule, MatGridListModule, MatExpansionModule,
28-
MatDialogModule, MatProgressBarModule ],
29+
MatDialogModule, MatProgressBarModule, ModalModule, WavesModule, InputsModule, ButtonsModule,
30+
ModalModule.forRoot()],
2931
exports: [MatButtonModule, MatListModule, MatExpansionModule,
3032
MatToolbarModule, MatSidenavModule,
3133
MatIconModule, MatFormFieldModule,
3234
MatCardModule, MatTableModule, MatInputModule, AlertModule, MatGridListModule,
33-
MatDialogModule, MatProgressBarModule ]
35+
MatDialogModule, MatProgressBarModule, ModalModule, WavesModule, InputsModule, ButtonsModule, ]
3436

3537
})
3638

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
mat-drawer-container{
2+
height: 100%;
3+
4+
}
5+
6+
mat-drawer{
7+
width: 25%;
8+
background-color: #070a19;
9+
10+
11+
}
12+
13+
mat-drawer-content{
14+
position: relative;
15+
left: 3%;
16+
17+
}
18+
19+
mat-toolbar{
20+
height: 8%;
21+
background-color: #070a19;
22+
position: sticky;
23+
position: -webkit-sticky; /* For macOS/iOS Safari */
24+
top: 0; /* Sets the sticky toolbar to be on top */
25+
z-index: 1000}
26+
27+
.nav-caption{
28+
display: inline-block;
29+
padding-left: 12px;
30+
}
31+
32+
33+
34+
mat-nav-list{
35+
background-color: #141831;
36+
37+
height: 100%;
38+
39+
}
40+
41+
mat-nav-list a:hover{
42+
color:white ;
43+
background-color:#040611;
44+
}
45+
46+
mat-nav-list a.activeLink{
47+
color:white ;
48+
background-color: teal;
49+
border: 1px solid #509A9D;
50+
51+
}
52+
53+
/* Avatar */
54+
.avatarDiv {
55+
text-align: left;
56+
background-color:#040611;
57+
position: relative;
58+
top: -10px;
59+
60+
61+
62+
}
63+
.avatarDiv mat-icon{
64+
font-size: 20vw;
65+
margin-left:8%;
66+
67+
}
68+
69+
70+
.content{
71+
margin-top: 3%;
72+
}

0 commit comments

Comments
 (0)