Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b6cb873

Browse files
updated authorization and added delete confirmation popup
1 parent 270d20a commit b6cb873

29 files changed

+551
-42
lines changed

‎angular.json‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,22 @@
6868
"with": "src/environments/environment.hmr.ts"
6969
}
7070
]
71+
},
72+
"backend": {
73+
"fileReplacements": [
74+
{
75+
"replace": "src/environments/environment.ts",
76+
"with": "src/environments/environment.backend.ts"
77+
}
78+
]
7179
}
7280
}
7381
},
7482
"serve": {
7583
"builder": "@angular-devkit/build-angular:dev-server",
7684
"options": {
77-
"browserTarget": "angular-material-admin:build"
85+
"browserTarget": "angular-material-admin:build",
86+
"port": 3000
7887
},
7988
"configurations": {
8089
"production": {
@@ -83,6 +92,9 @@
8392
"hmr": {
8493
"hmr": true,
8594
"browserTarget": "angular-material-admin:build:hmr"
95+
},
96+
"backend": {
97+
"browserTarget": "angular-material-admin:build:backend"
8698
}
8799
}
88100
},

‎changelog.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [1.0.8] - 09/14/2021
4+
### Updated
5+
6+
- Updated login page;
7+
- Updated register page;
8+
- Added delete confirmation popup;
9+
310
## [1.0.7] - 05/05/2021
411
### Updated
512

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "angular-material-admin",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",
7+
"start:backend": "ng serve --configuration backend",
78
"build": "ng build --prod",
89
"lint": "ng lint",
910
"hmr": "ng serve --configuration hmr"
@@ -21,6 +22,7 @@
2122
"@angular/platform-browser": "~11.2.12",
2223
"@angular/platform-browser-dynamic": "~11.2.12",
2324
"@angular/router": "~11.2.12",
25+
"@auth0/angular-jwt": "^3.0.1",
2426
"@fullcalendar/angular": "4.4.5-beta",
2527
"@fullcalendar/core": "4.4.2",
2628
"@fullcalendar/daygrid": "4.4.2",

‎src/app/app.config.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Injectable } from '@angular/core';
2+
import { environment } from '../environments/environment';
3+
4+
const hostApi = process.env.NODE_ENV === 'development' ? 'http://localhost' : 'https://flatlogic-node-backend.herokuapp.com';
5+
const portApi = process.env.NODE_ENV === 'development' ? '8080' : '';
6+
const baseURLApi = `${hostApi}${portApi ? `:${portApi}` : ``}`;
7+
8+
@Injectable({
9+
providedIn: 'root'
10+
})
11+
export class AppConfig {
12+
config = {
13+
version: '4.0.0',
14+
remote: 'https://flatlogic-node-backend.herokuapp.com',
15+
isBackend: environment.backend,
16+
hostApi,
17+
portApi,
18+
baseURLApi,
19+
auth: {
20+
email: 'admin@flatlogic.com',
21+
password: 'password'
22+
},
23+
};
24+
25+
constructor() {
26+
}
27+
28+
getConfig(): Object {
29+
return this.config;
30+
}
31+
}
32+

‎src/app/app.interceptor.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Injectable } from '@angular/core';
2+
import { Observable } from 'rxjs';
3+
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
4+
import { AppConfig } from './app.config';
5+
6+
@Injectable()
7+
export class AppInterceptor implements HttpInterceptor {
8+
config;
9+
10+
constructor(appConfig: AppConfig) {
11+
this.config = appConfig.getConfig();
12+
}
13+
14+
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
15+
req = req.clone({url: this.config.baseURLApi + req.url});
16+
17+
const token: string = localStorage.getItem('token');
18+
if (token) {
19+
req = req.clone({
20+
headers: req.headers.set('Authorization', 'Bearer ' + token)
21+
});
22+
}
23+
24+
return next.handle(req);
25+
}
26+
}

‎src/app/app.module.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { MatMenuModule } from '@angular/material/menu';
2020
import { MatRadioModule } from '@angular/material/radio';
2121
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
2222
import { FormsModule } from '@angular/forms';
23+
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
24+
import { AppInterceptor } from './app.interceptor';
2325

2426
@NgModule({
2527
declarations: [
@@ -47,8 +49,13 @@ import { FormsModule } from '@angular/forms';
4749
MatRadioModule,
4850
MatSlideToggleModule,
4951
FormsModule,
52+
HttpClientModule
53+
],
54+
providers: [
55+
{
56+
provide: HTTP_INTERCEPTORS, useClass: AppInterceptor, multi: true
57+
}
5058
],
51-
providers: [],
5259
bootstrap: [AppComponent]
5360
})
5461
export class AppModule { }

‎src/app/modules/auth/auth-routing.module.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ const routes: Routes = [
77
{
88
path: '',
99
component: AuthPageComponent
10-
}
10+
},
11+
{
12+
path: 'register',
13+
component: AuthPageComponent
14+
},
15+
1116
];
1217

1318
@NgModule({

‎src/app/modules/auth/auth.module.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { YearPipe } from './pipes';
1111
import { AuthService, EmailService } from './services';
1212
import { LoginFormComponent, SignFormComponent } from './components';
1313
import { AuthGuard } from './guards';
14+
import { MatIconModule } from '@angular/material/icon';
1415

1516
@NgModule({
1617
declarations: [
@@ -25,6 +26,7 @@ import { AuthGuard } from './guards';
2526
MatTabsModule,
2627
MatButtonModule,
2728
MatInputModule,
29+
MatIconModule,
2830
ReactiveFormsModule,
2931
FormsModule
3032
],
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
22
import { FormControl, FormGroup, Validators } from '@angular/forms';
3+
import { AppConfig } from '../../../../app.config';
34

45
@Component({
56
selector: 'app-login-form',
@@ -9,19 +10,22 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
910
export class LoginFormComponent implements OnInit {
1011
@Output() sendLoginForm = new EventEmitter<void>();
1112
public form: FormGroup;
12-
public flatlogicEmail = 'admin@flatlogic.com';
13-
public flatlogicPassword = 'admin';
13+
config: any;
14+
15+
constructor(appConfig: AppConfig) {
16+
this.config = appConfig.getConfig();
17+
}
1418

1519
public ngOnInit(): void {
1620
this.form = new FormGroup({
17-
email: new FormControl(this.flatlogicEmail, [Validators.required, Validators.email]),
18-
password: new FormControl(this.flatlogicPassword, [Validators.required])
21+
email: new FormControl(this.config.auth.email, [Validators.required, Validators.email]),
22+
password: new FormControl(this.config.auth.password, [Validators.required])
1923
});
2024
}
2125

2226
public login(): void {
2327
if (this.form.valid) {
24-
this.sendLoginForm.emit();
28+
this.sendLoginForm.emit(this.form.value);
2529
}
2630
}
2731
}

‎src/app/modules/auth/components/sign-form/sign-form.component.html‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<div *ngIf="authService.errorMessage" class="notification notification_transparent-pink">
2+
<div class="notification__icon-wrapper notification__icon-wrapper_solid-pink">
3+
<mat-icon>report</mat-icon>
4+
</div>
5+
<p class="notification__title">{{authService.errorMessage}}</p>
6+
</div>
17
<form class="form" [formGroup]="form" (ngSubmit)="sign()">
28
<mat-form-field class="form__input">
39
<input matInput placeholder="Full name" formControlName="name">

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /