Skip to content

Commit 71204b0

Browse files
authored
Merge pull request #3 from flatlogic/updated_authorization_added_delete_popup
updated authorization and added delete confirmation popup
2 parents 270d20a + b6cb873 commit 71204b0

29 files changed

+551
-42
lines changed

angular.json

+13-1
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

+7
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

+3-1
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

+32
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+
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

+26
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

+8-1
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

+6-1
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

+2
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
],
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 = '[email protected]';
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

+6
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">

src/app/modules/auth/components/sign-form/sign-form.component.scss

+153
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,156 @@
2121
box-shadow: 0 0 11px 0 $shadow-white, 0 0 0 -2px $shadow-grey, 0 1px 8px 0 $shadow-dark-grey;
2222
}
2323
}
24+
25+
.notification {
26+
width: 100%;
27+
display: flex;
28+
align-items: center;
29+
margin-top: 16px;
30+
margin-bottom: 16px;
31+
height: 45px;
32+
border-radius: 45px;
33+
34+
&_solid {
35+
&-pink {
36+
background-color: $pink;
37+
}
38+
39+
&-blue {
40+
background-color: $blue;
41+
}
42+
43+
&-green {
44+
background-color: $green;
45+
}
46+
47+
&-yellow {
48+
background-color: $yellow;
49+
}
50+
51+
&-violet {
52+
background-color: $violet;
53+
}
54+
}
55+
56+
&_transparent {
57+
&-pink {
58+
background-color: $pink-15;
59+
}
60+
61+
&-blue {
62+
background-color: $blue-15;
63+
}
64+
65+
&-green {
66+
background-color: $green-15;
67+
}
68+
69+
&-yellow {
70+
background-color: $yellow-15;
71+
}
72+
73+
&-violet {
74+
background-color: $violet-15;
75+
}
76+
}
77+
78+
&__title {
79+
margin: 0;
80+
81+
&_white {
82+
color: $white;
83+
}
84+
}
85+
86+
&__icon-wrapper {
87+
height: 45px;
88+
width: 45px;
89+
display: flex;
90+
align-items: center;
91+
justify-content: center;
92+
93+
&_transparent {
94+
color: $white-80;
95+
96+
&-pink {
97+
color: $pink;
98+
}
99+
100+
&-blue {
101+
color: $blue;
102+
}
103+
104+
&-green {
105+
color: $green;
106+
}
107+
108+
&-yellow {
109+
color: $yellow;
110+
}
111+
112+
&-violet {
113+
color: $violet;
114+
}
115+
}
116+
117+
&_solid {
118+
&-pink {
119+
color: $pink;
120+
}
121+
122+
&-blue {
123+
color: $blue;
124+
}
125+
126+
&-green {
127+
color: $green;
128+
}
129+
130+
&-yellow {
131+
color: $yellow;
132+
}
133+
134+
&-violet {
135+
color: $violet;
136+
}
137+
}
138+
}
139+
140+
&__icon-wrapper-circle {
141+
height: 45px;
142+
width: 45px;
143+
display: flex;
144+
align-items: center;
145+
justify-content: center;
146+
border-radius: 45px;
147+
margin-right: 16px;
148+
149+
&_transparent {
150+
&-pink {
151+
color: $pink;
152+
background-color: $pink-15;
153+
}
154+
155+
&-blue {
156+
color: $blue;
157+
background-color: $blue-15;
158+
}
159+
160+
&-green {
161+
color: $green;
162+
background-color:$green-15;
163+
}
164+
165+
&-yellow {
166+
color: $yellow;
167+
background-color: $yellow-15;
168+
}
169+
170+
&-violet {
171+
color: $violet;
172+
background-color: $violet-15;
173+
}
174+
}
175+
}
176+
}

0 commit comments

Comments
 (0)