Skip to content

Commit 59897ce

Browse files
committed
production enviroment and console logs removed
1 parent e2ee2a1 commit 59897ce

File tree

11 files changed

+28
-63
lines changed

11 files changed

+28
-63
lines changed

json-server/db.json

+1-37
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,4 @@
11
{
22
"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-
}
393
]
40-
}
4+
}

src/app/app.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const Routes: Routes = [
1919
{
2020
path: 'sign-in',
2121
loadChildren: () => import('./pages/sign-in/sign-in.module').then(m => m.SignInModule),
22-
// canActivate: [AuthGuard]
22+
canActivate: [AuthGuard]
2323
},
2424
{ path: '',
2525
redirectTo: '/',

src/app/components/new-task/new-task.component.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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';
44
import { MatSnackBar } from '@angular/material/snack-bar';
5-
import {AuthService} from '../../services/auth.service';
5+
import { AuthService } from '../../services/auth.service';
66

77
@Component({
88
selector: 'app-new-task',
@@ -45,5 +45,4 @@ export class NewTaskComponent implements OnInit {
4545
openSnackBar(msg: string): void {
4646
this.snackBar.open(msg, 'Dismiss', {duration: 5000});
4747
}
48-
4948
}

src/app/components/task-item/task-item.component.ts

-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ export class TaskItemComponent implements OnInit {
2222
) { }
2323

2424
ngOnInit(): void {
25-
console.log(this.task);
2625
this.inputValue = this.task.title;
2726
this.inputLineThroughClassName = this.task.completed ? 'line' : '';
2827
}
2928

3029
handleDelete(): void {
3130
this.apiService.deleteTask(this.task.id).subscribe(res => {
32-
console.log(res);
3331
this.apiService.removeTask(this.task.id);
3432
}, error => {
3533
this.openSnackBar('Error saving your data');
@@ -41,7 +39,6 @@ export class TaskItemComponent implements OnInit {
4139
this.inputLineThroughClassName = this.task.completed ? 'line' : '';
4240

4341
this.apiService.updateTask(this.task.id, {completed: this.task.completed}).subscribe(res => {
44-
console.log(res);
4542
this.apiService.editTask(res);
4643
}, error => {
4744
this.task.completed = !this.task.completed;
@@ -61,7 +58,6 @@ export class TaskItemComponent implements OnInit {
6158
this.inputValue = title;
6259
} else if (inputValue !== title) {
6360
this.apiService.updateTask(this.task.id, { title: inputValue } ).subscribe(res => {
64-
console.log(res);
6561
this.apiService.editTask(res);
6662
}, error => {
6763
this.openSnackBar('Error saving your data');

src/app/components/task-list/task-list.component.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ export class TaskListComponent implements OnInit {
2121
this.getUserTasks();
2222
}
2323

24-
getUserTasks() {
24+
getUserTasks(): void {
2525
this.apiService.getUserTasks().subscribe(res => {
26-
console.log(res)
2726
this.loading = false;
28-
// this.tasks = res;
2927
this.apiService.setTasks(res);
3028
}, error => {
3129
this.loading = false;
@@ -34,7 +32,6 @@ export class TaskListComponent implements OnInit {
3432

3533
this.apiService.userTasks$.subscribe((tasks: Task[]) => {
3634
this.tasks = tasks;
37-
console.log(this.tasks)
3835
});
3936
}
4037

src/app/pages/sign-in/sign-in.component.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ export class SignInComponent implements OnInit {
1313
) { }
1414

1515
ngOnInit(): void {
16-
console.log('SIGN IN COMPONENT');
1716
}
1817

19-
handleGoogleButton() {
18+
handleGoogleButton(): void {
2019
this.authService.loginWithGoogle();
2120
}
2221

src/app/services/api.service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export class ApiService {
1515

1616
constructor(
1717
private http: HttpClient,
18-
private authService: AuthService) { }
18+
private authService: AuthService
19+
) { }
1920

2021
getUserTasks(): Observable<any> {
2122
return this.http.get(`${environment.serverUrl}/todos`, {params: {userId: this.authService.user.uid}});

src/app/services/auth.guard.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ export class AuthGuard implements CanActivate {
1212
constructor(
1313
private authService: AuthService,
1414
private router: Router
15-
) {}
15+
) {
16+
}
17+
1618
canActivate(
1719
next: ActivatedRouteSnapshot,
1820
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;
2225
}
23-
return false;
2426
}
25-
2627
}

src/app/services/auth.service.ts

-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export class AuthService {
1515
) {
1616
this.user = JSON.parse(localStorage.getItem('user')) || null;
1717
this.fireAuth.authState.subscribe(user => {
18-
console.log(user);
1918
this.user = user;
2019
if (this.user){
2120
localStorage.setItem('user', JSON.stringify(this.user));
@@ -29,7 +28,6 @@ export class AuthService {
2928
loginWithGoogle(): Promise<any> {
3029
return this.fireAuth.signInWithPopup(new auth.GoogleAuthProvider())
3130
.then( success => {
32-
console.log(success)
3331
this.user = success.user;
3432
this.router.navigate(['']);
3533
})

src/assets/icons/github-logo.png

1.67 KB
Loading

src/environments/environment.prod.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
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+
}
313
};

0 commit comments

Comments
 (0)