Skip to content

Commit 6b9a845

Browse files
committed
timer works
1 parent 5d10583 commit 6b9a845

24 files changed

Lines changed: 40 additions & 2885 deletions

codecamp-front/src/app/components/navbar/navbar.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<a class="btn btn-light dropdown-toggle"
2222
role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true"
2323
aria-expanded="false">
24-
Welcome {{user?.username}}
24+
Welcome {{user}}
2525
</a>
2626

2727
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink">

codecamp-front/src/app/components/navbar/navbar.component.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,22 @@ import { ContestService } from '../../services/contest.service';
2424
export class NavbarComponent implements OnInit{
2525

2626
user: any;
27+
users;
2728
toggle = true;
2829
constructor(
2930
public authService: AuthService,
3031
private router: Router,
3132
private contestService: ContestService
3233
) {
33-
this.authService.name.subscribe(value => {
34-
this.user = value;
35-
});
36-
}
34+
/*this.authService.name.subscribe(value => {
35+
this.user = value ;
36+
});*/
37+
this.users = authService.getProfile().subscribe(profile => {
38+
this.user = profile.msg.username;
39+
//console.log(this.user);
40+
});
41+
//console.log(this.user);
42+
}
3743

3844
ngOnInit() {
3945
this.contestService.toggle.subscribe(toggle => this.toggle = toggle);
@@ -43,7 +49,7 @@ export class NavbarComponent implements OnInit{
4349
this.authService.logout(); // Logout user
4450
this.router.navigate(['/']); // Navigate back to home page
4551
}
46-
onUndefined() {
52+
undefined() {
4753

4854
}
4955
onToggle(){

codecamp-front/src/app/components/problems/problems.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
<span id="day"></span>days
6262
<span id="hour"></span>hours
6363
<span id="minute"></span>minutes
64-
<span id="second"></span>seconds
65-
{{times}}-->
64+
<span id="second"></span>seconds-->
65+
{{times}}
6666
</div>
6767
</div>
6868
<div class="ranking">

codecamp-front/src/app/components/problems/problems.component.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ export class ProblemsComponent implements OnInit {
5858
//compareDate.setDate(this.end.getDate()); //just for this demo today + 7 days
5959

6060
//console.log(compareDate);
61-
timer = setInterval(function() {
61+
/* timer = setInterval(function() {
6262
timeBetweenDates(compareDate);
63-
}, 1000);
64-
function timeBetweenDates(compareDate){
65-
var dateEntered = compareDate;
63+
}, 1000);*/
64+
setInterval((()=>{
65+
var dateEntered = compareDate;
6666
var now = new Date();
6767
var difference = dateEntered.getTime() - now.getTime();
6868

@@ -82,20 +82,22 @@ export class ProblemsComponent implements OnInit {
8282
minute %= 60;
8383
second %= 60;
8484
//console.log(day,hour,minute,second);
85-
/*this.days = day;
86-
this.hours = hour;
87-
this.minutes = minute;
88-
this.seconds = second;
89-
$("#day").text(day);
85+
// this.days = day;
86+
// this.hours = hour;
87+
// this.minutes = minute;
88+
// this.seconds = second;
89+
/*$("#day").text(day);
9090
$("#hour").text(hour);
9191
$("#minute").text(minute);
9292
$("#second").text(second);
9393
var temp = String(day) + ' days ' + String(hour) + ' hr ' +String(minute) + ' min ' +String(second) + ' sec';
9494
////this.contestService.time.next(temp);
9595
//this.contestService.time.subscribe(value => this.times = value);*/
96+
this.times = String(day) + ' days ' + String(hour) + ' hr ' +String(minute) + ' min ' +String(second) + ' sec';
9697

9798
}
98-
}
99+
}),1000);
100+
99101

100102
});
101103
this.contestService.currentContest.subscribe(contest => this.contestname = contest);

codecamp-front/src/app/components/profile/profile.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class ProfileComponent implements OnInit {
2222
}
2323

2424
ngOnInit() {
25-
25+
console.log(this.user);
2626
}
2727
onSubmitSel() {
2828
this.router.navigate([this.user.username, 'edit-profile']);

codecamp-front/src/app/services/auth.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Subject } from 'rxjs/Subject';
1212
export class AuthService {
1313
public authToken: any;
1414
public user: any;
15-
// public domain = 'http://localhost:80/';
15+
public domain = 'http://localhost:80/';
1616
public options;
1717

1818
constructor(
@@ -34,12 +34,12 @@ export class AuthService {
3434
this.authToken = localStorage.getItem('token'); // Get tokens and asssign to variable to be used elsewhere
3535
}
3636
public registerUser(user) {
37-
return this.http.post(/*this.domain + */'users/signup', user)
37+
return this.http.post(this.domain + 'users/signup', user)
3838
.map(res => res.json());
3939
}
4040

4141
public loginUser(user) {
42-
return this.http.post(/*this.domain + */'users/signin', user)
42+
return this.http.post(this.domain + 'users/signin', user)
4343
.map(res => res.json());
4444
}
4545

@@ -78,6 +78,6 @@ export class AuthService {
7878
}
7979
getProfile() {
8080
this.createAuthenticationHeaders();
81-
return this.http.get(/*this.domain + */'users/profile', this.options).map(res => res.json());
81+
return this.http.get(this.domain + 'users/profile', this.options).map(res => res.json());
8282
}
8383
}

codecamp-front/src/app/services/contest.service.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class ContestService {
1515
public authToken: any;
1616
public user: any;
1717
public contest: any;
18-
// public domain = 'http://localhost:80/';
18+
public domain = 'http://localhost:80/';
1919
public options;
2020
public sol;
2121
public toggler: boolean;
@@ -50,36 +50,36 @@ export class ContestService {
5050

5151
public addContest(contest) {
5252
return this.http
53-
.post( /*this.domain + */ 'contest', contest)
53+
.post( this.domain + 'contest', contest)
5454
.map(res => res.json());
5555
}
5656

5757
public getContest(): Observable<any> {
58-
return this.http.get( /*this.domain + */ 'contest')
58+
return this.http.get( this.domain + 'contest')
5959
.map(res => res.json());
6060
}
6161

6262
public addProblem(problem, contest): Observable<any> {
63-
return this.http.post(/*this.domain + */ 'contest/' + contest, problem)
63+
return this.http.post(this.domain + 'contest/' + contest, problem)
6464
.map(res => res.json());
6565
}
6666

6767
public getProblems(contest): Observable<any> {
68-
return this.http.get( /*this.domain + */'contest/' + contest)
68+
return this.http.get( this.domain + 'contest/' + contest)
6969
.map(res => res.json());
7070
}
7171

7272
public getProblem(code, contest): Observable<any> {
73-
return this.http.get(/*this.domain + */ 'contest/' + contest + '/problems/' + code)
73+
return this.http.get(this.domain + 'contest/' + contest + '/problems/' + code)
7474
.map(res => res.json());
7575
}
7676

7777
public addSolution(solution): Observable<any> {
78-
return this.http.post(/*this.domain + */'solution', solution)
78+
return this.http.post(this.domain + 'solution', solution)
7979
.map(res => res.json());
8080
}
8181
public deleteContest(contest) {
82-
return this.http.delete(/*this.domain + */ 'contest/' + contest)
82+
return this.http.delete(this.domain + 'contest/' + contest)
8383
.map(res => res.json());
8484
}
8585
public setSolution(sol) {
@@ -94,7 +94,7 @@ export class ContestService {
9494
}
9595

9696
getRankings(contest) {
97-
return this.http.get(/*this.domain + */'rankings/' + contest)
97+
return this.http.get(this.domain + 'rankings/' + contest)
9898
.map(res => res.json());
9999
}
100100
ontoggle(value: boolean) {

server/public/3rdpartylicenses.txt

Lines changed: 0 additions & 167 deletions
This file was deleted.

server/public/assets/bg0.jpg

-550 KB
Binary file not shown.

server/public/assets/bg1.jpg

-107 KB
Binary file not shown.

0 commit comments

Comments
 (0)