Skip to content

Commit f11db57

Browse files
committed
changed in ranking.js
2 parents d2cfa5f + e7e94b1 commit f11db57

17 files changed

Lines changed: 577 additions & 268 deletions

File tree

codecamp-front/package-lock.json

Lines changed: 329 additions & 136 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codecamp-front/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"jquery": "3.3.1",
3232
"jquery-slimscroll": "1.3.8",
3333
"ng2-ace-editor": "0.3.4",
34+
"ng2-date-countdown": "0.0.5",
3435
"ng2-file-upload": "1.3.0",
3536
"ngx-progressbar": "2.1.1",
3637
"popper.js": "1.12.9",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { NgProgressModule, NgProgressBrowserXhr } from 'ngx-progressbar';
4141
import { BrowserXhr } from '@angular/http';
4242
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
4343
import { FlashMessagesModule } from 'angular2-flash-messages';
44+
import { CountDown } from 'ng2-date-countdown';
4445

4546
@NgModule({
4647
declarations: [
@@ -66,7 +67,8 @@ import { FlashMessagesModule } from 'angular2-flash-messages';
6667
SolultionSubmitComponent,
6768
PreloaderComponent,
6869
SidebarComponent,
69-
EditProfileComponent
70+
EditProfileComponent,
71+
CountDown
7072
],
7173
imports: [
7274
BrowserModule,

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

Lines changed: 71 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@
33
<div class="col-md-12">
44
<div class="display-4">Add Problem</div>
55
<form [formGroup]="form" (submit)="onAddProblemSubmit()">
6-
<div class="form-group">
6+
<div class="form-group">
77
<label for="name">Problem Name</label>
8-
<input type="text"
9-
name="name"
10-
formControlName="name"
11-
class="form-control"
12-
placeholder="Enter Name"
8+
<input type="text"
9+
name="name"
10+
formControlName="name"
11+
class="form-control"
12+
placeholder="Enter Name"
1313
autocomplete="off"
1414
[ngClass]="{'is-invalid': (form.controls.name.errors && form.controls.name.dirty) , 'is-valid': !form.controls.name.errors}">
1515
</div>
16-
16+
1717
<div class="form-group">
1818
<label for="id">Problem Code</label>
1919
<input type="text"
20-
name="code"
21-
formControlName="code"
22-
class="form-control"
23-
placeholder="Enter contest ID"
20+
name="code"
21+
formControlName="code"
22+
class="form-control"
23+
placeholder="Enter contest ID"
2424
autocomplete="off"
2525
[ngClass]="{'is-invalid': (form.controls.code.errors && form.controls.code.dirty) , 'is-valid': !form.controls.code.errors}">
2626
</div>
2727
<div class="row">
2828
<div class="col-md-6">
2929
<div class="form-group">
3030
<label for="level">Problem Level</label>
31-
<input type="text"
32-
name="level"
33-
formControlName="level"
34-
class="form-control"
35-
placeholder="Problem Level"
31+
<input type="text"
32+
name="level"
33+
formControlName="level"
34+
class="form-control"
35+
placeholder="Problem Level"
3636
autocomplete="off"
3737
[ngClass]="{'is-invalid': (form.controls.level.errors && form.controls.level.dirty) , 'is-valid': !form.controls.level.errors}">
3838
</div>
@@ -41,10 +41,10 @@
4141
<div class="form-group">
4242
<label for="Author">Author</label>
4343
<input type="text"
44-
name="author"
45-
formControlName="author"
46-
class="form-control"
47-
placeholder="Author Name"
44+
name="author"
45+
formControlName="author"
46+
class="form-control"
47+
placeholder="Author Name"
4848
autocomplete="off"
4949
[ngClass]="{'is-invalid': (form.controls.author.errors && form.controls.author.dirty) , 'is-valid': !form.controls.author.errors}">
5050
</div>
@@ -54,11 +54,11 @@
5454
<div class="col-md-6">
5555
<div class="form-group">
5656
<label for="Input Format">Input Format</label>
57-
<textarea
58-
name="input_format"
59-
formControlName="input_format"
60-
class="form-control"
61-
placeholder="Input Format"
57+
<textarea
58+
name="input_format"
59+
formControlName="input_format"
60+
class="form-control"
61+
placeholder="Input Format"
6262
autocomplete="off"
6363
[ngClass]="{'is-invalid': (form.controls.input_format.errors && form.controls.input_format.dirty) , 'is-valid': !form.controls.input_format.errors}">
6464
</textarea>
@@ -68,10 +68,10 @@
6868
<div class="form-group">
6969
<label for="output_format">Output format</label>
7070
<textarea
71-
name="output_format"
72-
formControlName="output_format"
73-
class="form-control"
74-
placeholder="output_format"
71+
name="output_format"
72+
formControlName="output_format"
73+
class="form-control"
74+
placeholder="output_format"
7575
autocomplete="off"
7676
[ngClass]="{'is-invalid': (form.controls.output_format.errors && form.controls.output_format.dirty) , 'is-valid': !form.controls.output_format.errors}">
7777
</textarea>
@@ -80,41 +80,41 @@
8080
</div>
8181
<div class="form-group">
8282
<label for="Description">Description</label>
83-
<textarea
84-
name="description"
85-
formControlName="description"
86-
class="form-control" placeholder="Enter Description" autocomplete="off" rows="10">
83+
<textarea
84+
name="description"
85+
formControlName="description"
86+
class="form-control" placeholder="Enter Description" autocomplete="off" rows="10">
8787
</textarea>
8888
</div>
8989
<div class="form-group">
9090
<label for="Constraint">Constraint</label>
91-
<textarea
92-
name="constraints"
93-
formControlName="constraints"
94-
class="form-control" placeholder="Enter Constraints" autocomplete="off" rows="10">
91+
<textarea
92+
name="constraints"
93+
formControlName="constraints"
94+
class="form-control" placeholder="Enter Constraints" autocomplete="off" rows="10">
9595
</textarea>
9696
</div>
9797
<div class="row">
9898
<div class="col-md-6">
99-
<div class="form-group">
99+
<div class="form-group">
100100
<label for="timelimit">Time Limit</label>
101-
<input type="text"
102-
name="timelimit"
103-
formControlName="timelimit"
104-
class="form-control"
105-
placeholder="Enter Time Limit"
101+
<input type="text"
102+
name="timelimit"
103+
formControlName="timelimit"
104+
class="form-control"
105+
placeholder="Enter Time Limit"
106106
autocomplete="off"
107107
[ngClass]="{'is-invalid': (form.controls.timelimit.errors && form.controls.timelimit.dirty) , 'is-valid': !form.controls.timelimit.errors}">
108108
</div>
109109
</div>
110110
<div class="col-md-6">
111-
<div class="form-group">
111+
<div class="form-group">
112112
<label for="sourcelimit">Source Limit</label>
113-
<input type="text"
114-
name="sourcelimit"
115-
formControlName="sourcelimit"
116-
class="form-control"
117-
placeholder="Enter Source Limit"
113+
<input type="text"
114+
name="sourcelimit"
115+
formControlName="sourcelimit"
116+
class="form-control"
117+
placeholder="Enter Source Limit"
118118
autocomplete="off"
119119
[ngClass]="{'is-invalid': (form.controls.sourcelimit.errors && form.controls.sourcelimit.dirty) , 'is-valid': !form.controls.sourcelimit.errors}">
120120
</div>
@@ -124,11 +124,11 @@
124124
<div class="col-md-6">
125125
<div class="form-group">
126126
<label for="Input TestCase">Input Testcase</label>
127-
<textarea
128-
name="input_example"
129-
formControlName="input_example"
130-
class="form-control"
131-
placeholder="Input TestCase"
127+
<textarea
128+
name="input_example"
129+
formControlName="input_example"
130+
class="form-control"
131+
placeholder="Input TestCase"
132132
autocomplete="off"
133133
[ngClass]="{'is-invalid': (form.controls.input_example.errors && form.controls.input_example.dirty) , 'is-valid': !form.controls.input_example.errors}">
134134
</textarea>
@@ -138,10 +138,10 @@
138138
<div class="form-group">
139139
<label for="output_example">Output Testcase</label>
140140
<textarea
141-
name="output_example"
142-
formControlName="output_example"
143-
class="form-control"
144-
placeholder="Output Test case"
141+
name="output_example"
142+
formControlName="output_example"
143+
class="form-control"
144+
placeholder="Output Test case"
145145
autocomplete="off"
146146
[ngClass]="{'is-invalid': (form.controls.output_example.errors && form.controls.output_example.dirty) , 'is-valid': !form.controls.output_example.errors}">
147147
</textarea>
@@ -151,43 +151,33 @@
151151
<div class="col-md-6">
152152
<div class="form-group">
153153
<label for="Input File">Input File</label>
154-
<textarea
155-
name="Input"
156-
formControlName="Input"
157-
class="form-control"
158-
placeholder="Input TestCase"
159-
autocomplete="off"
160-
[ngClass]="{'is-invalid': (form.controls.Input.errors && form.controls.Input.dirty) , 'is-valid': !form.controls.Input.errors}">
161-
</textarea>
154+
<input type="file" class="form-control-file" placeholder="Upload file" (change)="onFileChange1($event)">
162155
</div>
163156
</div>
164157
<div class="col-md-6">
165158
<div class="form-group">
166159
<label for="output File">Output File</label>
167-
<textarea
168-
name="Output"
169-
formControlName="Output"
170-
class="form-control"
171-
placeholder="Output Test case"
172-
autocomplete="off"
173-
[ngClass]="{'is-invalid': (form.controls.Output.errors && form.controls.Output.dirty) , 'is-valid': !form.controls.Output.errors}">
174-
</textarea>
160+
<input type="file" class="form-control-file" placeholder="Upload file" (change)="onFileChange2($event)">
175161
</div>
176162
</div>
177163
</div>
164+
<div class="form-group">
165+
<label for="Explanation Example">Image Upload</label>
166+
<input type="file" class="form-control-file" placeholder="Upload file" (change)="onFileChange3($event)">
167+
</div>
178168
<div class="form-group">
179169
<label for="Explanation Example">Explanation Example</label>
180-
<textarea
181-
name="explanation_example"
182-
formControlName="explanation_example"
183-
class="form-control" placehzolder="Explanation Example" autocomplete="off" rows="10">
170+
<textarea
171+
name="explanation_example"
172+
formControlName="explanation_example"
173+
class="form-control" placehzolder="Explanation Example" autocomplete="off" rows="10">
184174
</textarea>
185175
</div>
186176

187-
<input
188-
177+
<input
178+
189179
type="submit" class="btn btn-primary" value="Add Problem">
190180
</form>
191181
</div>
192182
</div>
193-
</div>
183+
</div>

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

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import { FlashMessagesService } from 'angular2-flash-messages';
1111
export class AddProblemComponent implements OnInit {
1212
form: FormGroup;
1313
contest;
14+
Input;
15+
Output;
16+
image;
1417
constructor(
1518
private contestService: ContestService,
1619
private router: Router,
@@ -43,6 +46,37 @@ export class AddProblemComponent implements OnInit {
4346
Output: ['', Validators.required]
4447
});
4548
}
49+
onFileChange1(event) {
50+
let reader = new FileReader();
51+
if(event.target.files && event.target.files.length > 0) {
52+
let file = event.target.files[0];
53+
reader.readAsDataURL(file);
54+
reader.onload = () => {
55+
this.Input = reader.result.split(',')[1];
56+
};
57+
}
58+
}
59+
onFileChange2(event) {
60+
let reader = new FileReader();
61+
if(event.target.files && event.target.files.length > 0) {
62+
let file = event.target.files[0];
63+
reader.readAsDataURL(file);
64+
reader.onload = () => {
65+
this.Output = reader.result.split(',')[1];
66+
};
67+
}
68+
}
69+
70+
onFileChange3(event) {
71+
let reader = new FileReader();
72+
if(event.target.files && event.target.files.length > 0) {
73+
let file = event.target.files[0];
74+
reader.readAsDataURL(file);
75+
reader.onload = () => {
76+
this.image = reader.result.split(',')[1];
77+
};
78+
}
79+
}
4680

4781
onAddProblemSubmit() {
4882
const problem = {
@@ -59,10 +93,12 @@ export class AddProblemComponent implements OnInit {
5993
timelimit: this.form.get('timelimit').value,
6094
sourcelimit: this.form.get('sourcelimit').value,
6195
author: this.form.get('author').value,
62-
testCaseInput: this.form.get('Input').value,
63-
testCaseOutput: this.form.get('Output').value
96+
testCaseInput: this.Input,
97+
testCaseOutput: this.Output,
98+
image: this.image
6499
};
65100

101+
66102
this.contestService.addProblem(problem, this.contest).subscribe(data => {
67103
if (!data.success) {
68104
this._flashMessagesService.show(data.msg, { cssClass: 'alert-danger' } );

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ export class LoginComponent implements OnInit {
4242
password: this.form.get('password').value // Password input field
4343
};
4444
this.authService.loginUser(user).subscribe(data => {
45-
if(!data.success){
45+
if (!data.success) {
4646
this._flashMessagesService.show(data.msg, { cssClass: 'alert-danger', timeout: 2000});
47-
}
48-
else{
47+
} else {
4948
this.authService.storeUserData(data.token, data.user);
49+
this.authService.name.next(data.user);
5050
this.router.navigate(['/']);
51-
this.message = false;
5251
} // Navigate to dashboard view
5352
});
5453
}

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

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

2626
user: any;
27-
toggle: boolean = true;
27+
toggle = true;
2828
constructor(
2929
public authService: AuthService,
3030
private router: Router,
3131
private contestService: ContestService
3232
) {
33+
this.authService.name.subscribe(value => {
34+
this.user = value;
35+
});
3336
}
3437

3538
ngOnInit() {
3639
this.contestService.toggle.subscribe(toggle => this.toggle = toggle);
37-
this.user = this.authService.getProfile().subscribe(profile => {
38-
this.user = profile.msg;
39-
});
4040
}
4141

4242
onLogoutClick() {
4343
this.authService.logout(); // Logout user
4444
this.router.navigate(['/']); // Navigate back to home page
4545
}
46+
onUndefined() {
4647

48+
}
4749
onToggle(){
4850
this.toggle = this.toggle? false:true;
4951
this.contestService.ontoggle(this.toggle);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ <h6>Explanations</h6>
4545
<p [innerText]="problem?.explanation_example"></p>
4646
</div>
4747
</div>
48+
<img *ngIf="base64Image" [src]="base64Image" >
4849
</div>
4950

5051
<div class="col-md-4">

0 commit comments

Comments
 (0)