Skip to content

Commit df8633b

Browse files
committed
App Build
1 parent 5f401d2 commit df8633b

44 files changed

Lines changed: 2999 additions & 47 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

codecamp-front/src/app/app-routing.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ const appRoutes: Routes = [
8787
component: AddProblemComponent,
8888
canActivate: [AuthGuard]
8989
},
90+
{
91+
path: 'contest/:contest/ranking',
92+
component: RanklistComponent
93+
},
9094
{
9195
path: 'contest/:contest/:problem',
9296
component: ProblemComponent

codecamp-front/src/app/components/add-problem/add-problem.component.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@
8686
class="form-control" placeholder="Enter Description" autocomplete="off" rows="10">
8787
</textarea>
8888
</div>
89+
<div class="form-group">
90+
<label for="Constraint">Constraint</label>
91+
<textarea
92+
name="constraint"
93+
formControlName="constraint"
94+
class="form-control" placeholder="Enter Constraint" autocomplete="off" rows="10">
95+
</textarea>
96+
</div>
8997
<div class="row">
9098
<div class="col-md-6">
9199
<div class="form-group">

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ <h2 class="card-title">SIGN IN</h2>
4040
</div>
4141
</div>
4242
</div>
43-
<p>{{message}}</p>
4443
<div class="row">
4544
<div class="col-md-9 offset-md-3">
4645
<div class="row">

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ <h1 class="display-4">{{contestname}}</h1>
2929
</div>
3030
<div class="col-md-3 head">
3131
Successful Submission
32-
</div>
33-
32+
</div>
3433
</div>
3534
<a
3635
class="nav-link problem"
@@ -50,7 +49,9 @@ <h1 class="display-4">{{contestname}}</h1>
5049
<div class="timer">
5150
<p>Time to start</p>
5251
</div>
53-
52+
<div class="ranking">
53+
<button class="btn btn-info" (click)="onClickRanking()">Contest Rankings</button>
54+
</div>
5455
</div>
5556
</div>
5657
</div>

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ export class ProblemsComponent implements OnInit {
1717
constructor(
1818
private contestService: ContestService,
1919
private router: Router,
20-
private authService: AuthService,
20+
public authService: AuthService,
2121
private route: ActivatedRoute
2222
) { }
2323

2424
ngOnInit() {
2525
this.contest = this.route.snapshot.params['contest'];
2626
this.contestService.getProblems(this.contest).subscribe(contest => {
27-
this.problems = contest.msg.questions;
27+
this.problems = contest.msg[0].questions;
28+
console.log(contest.msg);
2829
});
2930
this.contestService.currentContest.subscribe(contest => this.contestname=contest);
3031
}
@@ -39,4 +40,8 @@ export class ProblemsComponent implements OnInit {
3940
this.router.navigate(['/contest']);
4041
})
4142
}
43+
44+
onClickRanking() {
45+
this.router.navigate(['/contest',this.contest,'ranking']);
46+
}
4247
}
Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1-
<p>
2-
ranklist works!
3-
</p>
1+
2+
<div class="container">
3+
<div class="row">
4+
<div class="col-md-12">
5+
<p *ngIf="problems?.length===0">No Successful Solutions Submitted Yet.</p>
6+
7+
<!--
8+
<nav aria-label="Page navigation example">
9+
<ul class="pagination justify-content-center">
10+
<li class="page-item disabled">
11+
<a class="page-link" href="#" tabindex="-1">Previous</a>
12+
</li>
13+
<li class="page-item"><a class="page-link">1</a></li>
14+
<li class="page-item"><a class="page-link">2</a></li>
15+
<li class="page-item"><a class="page-link" href="#">3</a></li>
16+
<li class="page-item">
17+
<a class="page-link" href="#">Next</a>
18+
</li>
19+
</ul>
20+
</nav>
21+
-->
22+
<table class="table table-striped">
23+
<thead>
24+
<tr>
25+
<th scope="col">#</th>
26+
<th scope="col">Username</th>
27+
<th scope="col">Score</th>
28+
</tr>
29+
</thead>
30+
<tbody>
31+
<tr *ngFor="let rank of problems; let i=index;">
32+
<th scope="row">{{i}}</th>
33+
<td>{{rank.name}}</td>
34+
<td>{{rank.score}}</td>
35+
</tr>
36+
</tbody>
37+
</table>
38+
</div>
39+
</div>
40+
</div>
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { ContestService } from '../../services/contest.service';
3+
import { Router } from '@angular/router';
4+
import { AuthService } from '../../services/auth.service';
5+
import { ActivatedRoute } from '@angular/router';
26

37
@Component({
48
selector: 'app-ranklist',
@@ -7,9 +11,20 @@ import { Component, OnInit } from '@angular/core';
711
})
812
export class RanklistComponent implements OnInit {
913

10-
constructor() { }
14+
contest;
15+
problems;
16+
constructor(
17+
private contestService: ContestService,
18+
private router: Router,
19+
private authService: AuthService,
20+
private route: ActivatedRoute ) { }
1121

1222
ngOnInit() {
23+
this.contest = this.route.snapshot.params['contest'];
24+
this.contestService.getRankings(this.contest).subscribe(contest => {
25+
this.problems = contest.msg;
26+
console.log(this.problems);
27+
});
1328
}
1429

1530
}

codecamp-front/src/app/components/solultion-submit/solution/solution.component.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,31 @@ export class SolutionComponent implements OnInit {
1616

1717
ngOnInit() {
1818
this.data = this.contestService.getSolution();
19-
if(this.data[0]==='C')
20-
this.condition = 'green';
21-
else if(this.data[0] === 'w')
22-
this.condition = 'red';
23-
else
19+
if(this.data === true)
20+
{
21+
this.data = "Correct Answer";
22+
this.condition = 'green';
23+
}
24+
else if(this.data === false)
25+
{
26+
this.data = "Worng Answer";
27+
this.condition = 'red';
28+
}
29+
else if(this.data === 'RE')
2430
{
25-
this.data = "Compile Time Error";
31+
this.data = "Runtime Error";
32+
this.condition = 'red';
33+
}
34+
else if(this.data === 'TLE')
35+
{
36+
this.data = "Time Limit Exceed";
2637
this.condition = 'blue';
2738
}
39+
else
40+
{
41+
this.data = "Compile Time Error";
42+
this.condition = 'red';
43+
}
2844
}
2945

3046
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { tokenNotExpired } from 'angular2-jwt';
99
export class AuthService {
1010
public authToken: any;
1111
public user: any;
12-
public domain = 'http://localhost:3000';
12+
//public domain = 'http://localhost:80/';
1313
public options;
1414

1515
constructor(
@@ -31,12 +31,12 @@ export class AuthService {
3131
this.authToken = localStorage.getItem('token'); // Get tokens and asssign to variable to be used elsewhere
3232
}
3333
public registerUser(user) {
34-
return this.http.post(this.domain + '/users/signup', user)
34+
return this.http.post('users/signup', user)
3535
.map(res => res.json());
3636
}
3737

3838
public loginUser(user) {
39-
return this.http.post(this.domain + '/users/signin', user)
39+
return this.http.post('users/signin', user)
4040
.map(res => res.json());
4141
}
4242

@@ -75,6 +75,6 @@ export class AuthService {
7575
}
7676
getProfile() {
7777
this.createAuthenticationHeaders();
78-
return this.http.get(this.domain + '/users/profile', this.options).map(res => res.json());
78+
return this.http.get('users/profile', this.options).map(res => res.json());
7979
}
8080
}

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

Lines changed: 12 additions & 8 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:3000';
18+
//public domain = 'http://localhost:3000';
1919
public options;
2020
public sol;
2121
public toggler: boolean;
@@ -48,38 +48,38 @@ export class ContestService {
4848

4949
public addContest(contest) {
5050
return this.http
51-
.post(this.domain + '/contest', contest)
51+
.post('contest', contest)
5252
.map(res => res.json());
5353
}
5454

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

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

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

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

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

96+
getRankings(contest) {
97+
return this.http.get('rankings/' + contest)
98+
.map(res => res.json());
99+
}
96100
ontoggle(value: boolean){
97101
this.Toggler.next(value);
98102
}

0 commit comments

Comments
 (0)