File tree 11 files changed +28
-63
lines changed
11 files changed +28
-63
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"todos" : [
3
- {
4
- "userId" : 1 ,
5
- "title" : " Maria" ,
6
- "completed" : false ,
7
- "id" : 1
8
- },
9
- {
10
- "userId" : 1 ,
11
- "title" : " Marios" ,
12
- "completed" : false ,
13
- "id" : 2
14
- },
15
- {
16
- "userId" : 1 ,
17
- "title" : " Marios Patsis 3" ,
18
- "completed" : false ,
19
- "id" : 3
20
- },
21
- {
22
- "userId" : 1 ,
23
- "title" : " T" ,
24
- "completed" : false ,
25
- "id" : 7
26
- },
27
- {
28
- "userId" : 1 ,
29
- "title" : " faaf" ,
30
- "completed" : false ,
31
- "id" : 8
32
- },
33
- {
34
- "userId" : " KkiEUwCAj7PrGnNBOlhoAMNBlEd2" ,
35
- "title" : " Test 1" ,
36
- "completed" : false ,
37
- "id" : 9
38
- }
39
3
]
40
- }
4
+ }
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const Routes: Routes = [
19
19
{
20
20
path : 'sign-in' ,
21
21
loadChildren : ( ) => import ( './pages/sign-in/sign-in.module' ) . then ( m => m . SignInModule ) ,
22
- // canActivate: [AuthGuard]
22
+ canActivate : [ AuthGuard ]
23
23
} ,
24
24
{ path : '' ,
25
25
redirectTo : '/' ,
Original file line number Diff line number Diff line change 1
- import { Component , OnInit } from '@angular/core' ;
2
- import { Task } from '../../models/task' ;
3
- import { ApiService } from '../../services/api.service' ;
1
+ import { Component , OnInit } from '@angular/core' ;
2
+ import { Task } from '../../models/task' ;
3
+ import { ApiService } from '../../services/api.service' ;
4
4
import { MatSnackBar } from '@angular/material/snack-bar' ;
5
- import { AuthService } from '../../services/auth.service' ;
5
+ import { AuthService } from '../../services/auth.service' ;
6
6
7
7
@Component ( {
8
8
selector : 'app-new-task' ,
@@ -45,5 +45,4 @@ export class NewTaskComponent implements OnInit {
45
45
openSnackBar ( msg : string ) : void {
46
46
this . snackBar . open ( msg , 'Dismiss' , { duration : 5000 } ) ;
47
47
}
48
-
49
48
}
Original file line number Diff line number Diff line change @@ -22,14 +22,12 @@ export class TaskItemComponent implements OnInit {
22
22
) { }
23
23
24
24
ngOnInit ( ) : void {
25
- console . log ( this . task ) ;
26
25
this . inputValue = this . task . title ;
27
26
this . inputLineThroughClassName = this . task . completed ? 'line' : '' ;
28
27
}
29
28
30
29
handleDelete ( ) : void {
31
30
this . apiService . deleteTask ( this . task . id ) . subscribe ( res => {
32
- console . log ( res ) ;
33
31
this . apiService . removeTask ( this . task . id ) ;
34
32
} , error => {
35
33
this . openSnackBar ( 'Error saving your data' ) ;
@@ -41,7 +39,6 @@ export class TaskItemComponent implements OnInit {
41
39
this . inputLineThroughClassName = this . task . completed ? 'line' : '' ;
42
40
43
41
this . apiService . updateTask ( this . task . id , { completed : this . task . completed } ) . subscribe ( res => {
44
- console . log ( res ) ;
45
42
this . apiService . editTask ( res ) ;
46
43
} , error => {
47
44
this . task . completed = ! this . task . completed ;
@@ -61,7 +58,6 @@ export class TaskItemComponent implements OnInit {
61
58
this . inputValue = title ;
62
59
} else if ( inputValue !== title ) {
63
60
this . apiService . updateTask ( this . task . id , { title : inputValue } ) . subscribe ( res => {
64
- console . log ( res ) ;
65
61
this . apiService . editTask ( res ) ;
66
62
} , error => {
67
63
this . openSnackBar ( 'Error saving your data' ) ;
Original file line number Diff line number Diff line change @@ -21,11 +21,9 @@ export class TaskListComponent implements OnInit {
21
21
this . getUserTasks ( ) ;
22
22
}
23
23
24
- getUserTasks ( ) {
24
+ getUserTasks ( ) : void {
25
25
this . apiService . getUserTasks ( ) . subscribe ( res => {
26
- console . log ( res )
27
26
this . loading = false ;
28
- // this.tasks = res;
29
27
this . apiService . setTasks ( res ) ;
30
28
} , error => {
31
29
this . loading = false ;
@@ -34,7 +32,6 @@ export class TaskListComponent implements OnInit {
34
32
35
33
this . apiService . userTasks$ . subscribe ( ( tasks : Task [ ] ) => {
36
34
this . tasks = tasks ;
37
- console . log ( this . tasks )
38
35
} ) ;
39
36
}
40
37
Original file line number Diff line number Diff line change @@ -13,10 +13,9 @@ export class SignInComponent implements OnInit {
13
13
) { }
14
14
15
15
ngOnInit ( ) : void {
16
- console . log ( 'SIGN IN COMPONENT' ) ;
17
16
}
18
17
19
- handleGoogleButton ( ) {
18
+ handleGoogleButton ( ) : void {
20
19
this . authService . loginWithGoogle ( ) ;
21
20
}
22
21
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ export class ApiService {
15
15
16
16
constructor (
17
17
private http : HttpClient ,
18
- private authService : AuthService ) { }
18
+ private authService : AuthService
19
+ ) { }
19
20
20
21
getUserTasks ( ) : Observable < any > {
21
22
return this . http . get ( `${ environment . serverUrl } /todos` , { params : { userId : this . authService . user . uid } } ) ;
Original file line number Diff line number Diff line change @@ -12,15 +12,16 @@ export class AuthGuard implements CanActivate {
12
12
constructor (
13
13
private authService : AuthService ,
14
14
private router : Router
15
- ) { }
15
+ ) {
16
+ }
17
+
16
18
canActivate (
17
19
next : ActivatedRouteSnapshot ,
18
20
state : RouterStateSnapshot ) : Observable < boolean | UrlTree > | Promise < boolean | UrlTree > | boolean | UrlTree {
19
-
20
- if ( this . authService . isLoggedIn ) {
21
- return true ;
21
+ if ( state . url === '/sign-in' ) {
22
+ return this . authService . isLoggedIn ? this . router . navigate ( [ '' ] ) : true ;
23
+ } else {
24
+ return this . authService . isLoggedIn ;
22
25
}
23
- return false ;
24
26
}
25
-
26
27
}
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ export class AuthService {
15
15
) {
16
16
this . user = JSON . parse ( localStorage . getItem ( 'user' ) ) || null ;
17
17
this . fireAuth . authState . subscribe ( user => {
18
- console . log ( user ) ;
19
18
this . user = user ;
20
19
if ( this . user ) {
21
20
localStorage . setItem ( 'user' , JSON . stringify ( this . user ) ) ;
@@ -29,7 +28,6 @@ export class AuthService {
29
28
loginWithGoogle ( ) : Promise < any > {
30
29
return this . fireAuth . signInWithPopup ( new auth . GoogleAuthProvider ( ) )
31
30
. then ( success => {
32
- console . log ( success )
33
31
this . user = success . user ;
34
32
this . router . navigate ( [ '' ] ) ;
35
33
} )
Original file line number Diff line number Diff line change 1
1
export const environment = {
2
- production : true
2
+ production : true ,
3
+ serverUrl : 'https://arr-todo.herokuapp.com' ,
4
+ firebase : {
5
+ apiKey : 'AIzaSyBx-clRxjAtjniw1bxBG_p7-4DtnhKQX6g' ,
6
+ authDomain : 'todos-angular-app.firebaseapp.com' ,
7
+ databaseURL : 'https://todos-angular-app.firebaseio.com' ,
8
+ projectId : 'todos-angular-app' ,
9
+ storageBucket : 'todos-angular-app.appspot.com' ,
10
+ messagingSenderId : '676540201517' ,
11
+ appId : '1:676540201517:web:5792196cf1eb157b98d6a4'
12
+ }
3
13
} ;
You can’t perform that action at this time.
0 commit comments