Skip to content

Commit 5cac727

Browse files
committed
Merge branch 'master' of github.com:TheCodeCamp/CodeCamp
2 parents 3fbe47c + 3a8d46c commit 5cac727

10 files changed

Lines changed: 155 additions & 54 deletions

File tree

codecamp-front/.angular-cli.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626

2727
"../node_modules/popper.js/dist/umd/popper.min.js",
2828
"../node_modules/jquery/dist/jquery.min.js",
29-
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
29+
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
30+
"../node_modules/ace-builds/src-min/ace.js",
31+
"../node_modules/ace-builds/src-min/mode-c_cpp.js",
32+
"../node_modules/ace-builds/src-min/mode-python.js",
33+
"../node_modules/ace-builds/src-min/mode-java.js"
3034
],
3135
"environmentSource": "environments/environment.ts",
3236
"environments": {

codecamp-front/package-lock.json

Lines changed: 27 additions & 0 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
@@ -27,6 +27,7 @@
2727
"bootstrap": "^4.0.0-beta.2",
2828
"core-js": "^2.4.1",
2929
"jquery": "^3.3.1",
30+
"ng2-ace-editor": "^0.3.4",
3031
"popper.js": "^1.12.9",
3132
"rxjs": "^5.5.6",
3233
"zone.js": "^0.8.19"

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { RouterModule, Routes} from '@angular/router';
44
import { ReactiveFormsModule} from '@angular/forms';
55
import { AppRoutingModule } from './app-routing.module';
66
import {FormControl, FormGroup} from '@angular/forms';
7-
7+
import {AceEditorModule} from 'ng2-ace-editor';
88
import { AppComponent } from './app.component';
99
import { NavbarComponent } from './components/navbar/navbar.component';
1010
import { LoginComponent } from './components/login/login.component';
@@ -57,7 +57,8 @@ import { AddProblemComponent } from './components/add-problem/add-problem.compon
5757
BrowserModule,
5858
HttpModule,
5959
ReactiveFormsModule,
60-
AppRoutingModule
60+
AppRoutingModule,
61+
AceEditorModule
6162
],
6263
providers: [ AuthService, ContestService],
6364
bootstrap: [AppComponent]

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22
<div class="row">
33
<div class="col-md-12">
44
<h1 class="display-4">Online IDE</h1>
5-
<textarea name="" id="" cols="105" rows="28" ></textarea>
5+
<article>
6+
<h5>Select language</h5>
7+
<select (change)="selectLanguage($event)">
8+
<option value="c_cpp">C</option>
9+
<option value="c_cpp">C++</option>
10+
<option value="java">Java</option>
11+
<option value="python">Python</option>
12+
</select>
13+
</article>
14+
15+
<div ace-editor id="" cols="105" rows="28"
16+
[text]="content"
17+
class="aceEditorDirective"
18+
mode="{{selectedLanguage}}"
19+
style="height:500px;"></div>
20+
21+
622
<div class="row">
723
<div class="col-md-8">
824
<label class="file-upload">Upload File
@@ -12,7 +28,14 @@ <h1 class="display-4">Online IDE</h1>
1228
<div class="col-md-4">
1329
<div class="form-check mr-auto">
1430
<button class="btn btn-dark">Compile</button>
15-
31+
<div class="form-check">
32+
<input class="form-check-input" type="checkbox" id="gridCheck">
33+
<label class="form-check-label" for="gridCheck">
34+
Check me out
35+
</label>
36+
</div>
37+
38+
1639
</div>
1740
</div>
1841
</div>

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

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, ViewChild } from '@angular/core';
22

33
@Component({
44
selector: 'app-ide',
@@ -7,7 +7,51 @@ import { Component, OnInit } from '@angular/core';
77
})
88
export class IdeComponent implements OnInit {
99

10-
constructor() { }
10+
11+
selectedLanguage: String = 'c_cpp';
12+
content: string;
13+
selectLanguage(event: any) {
14+
this.selectedLanguage = event.target.value;
15+
if(this.selectedLanguage === 'c_cpp') { this.content =
16+
`#include<stdio.h>
17+
18+
int main()
19+
{
20+
21+
printf("Welcome To CodeCamp");
22+
23+
}
24+
`} else if(this.selectedLanguage === 'java'){this.content =
25+
`import java.util.*;
26+
27+
public class CodeCamp {
28+
29+
public static void main(String[] args) {
30+
31+
System.out.println("Welcome To Code Camp");
32+
33+
}
34+
35+
}
36+
`
37+
} else {
38+
this.content = `print("Welcome To CodeCamp")`
39+
}
40+
41+
}
42+
43+
constructor() {
44+
this.content =
45+
`#include<stdio.h>
46+
47+
int main()
48+
{
49+
50+
printf("Welcome To CodeCamp");
51+
52+
}
53+
`
54+
}
1155

1256
ngOnInit() {
1357
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export class ProfileComponent implements OnInit {
1616
) {
1717
this.user = authService.getProfile().subscribe(profile => {
1818
this.user = profile.msg;
19-
console.log(JSON.stringify(this.user));
19+
//console.log(JSON.stringify(this.user));
2020
});
21-
console.log(this.user);
21+
//console.log(this.user);
2222
}
2323

2424
ngOnInit() {
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
<div class="container">
22
<form [formGroup]="form" (submit)="onSignupSubmit()">
3-
<div class="form-group">
3+
<div class="form-group">
44
<label for="name">Name</label>
5-
<input type="text"
6-
name="name"
7-
formControlName="name"
8-
class="form-control"
9-
placeholder="Enter Name"
5+
<input type="text"
6+
name="name"
7+
formControlName="name"
8+
class="form-control"
9+
placeholder="Enter Name"
1010
autocomplete="off"
1111
[ngClass]="{'is-invalid': (form.controls.name.errors && form.controls.name.dirty) , 'is-valid': !form.controls.name.errors}">
1212
</div>
1313

1414
<div class="form-group">
1515
<label for="username">Username</label>
1616
<input type="text"
17-
name="username"
18-
formControlName="username"
19-
class="form-control"
20-
placeholder="Enter username(XYZ)"
17+
name="username"
18+
formControlName="username"
19+
class="form-control"
20+
placeholder="Enter username(XYZ)"
2121
autocomplete="off"
2222
[ngClass]="{'is-invalid': (form.controls.username.errors && form.controls.username.dirty) , 'is-valid': !form.controls.username.errors}">
2323
</div>
2424

2525
<!-- Email Input -->
2626
<div class="form-group">
2727
<label for="email">Email</label>
28-
<input type="text"
29-
name="email_id"
30-
class="form-control"
28+
<input type="text"
29+
name="email_id"
30+
class="form-control"
3131
[ngClass]="{'is-invalid': (form.controls.email_id.errors && form.controls.email_id.dirty) , 'is-valid': !form.controls.email_id.errors}"
32-
autocomplete="off"
33-
placeholder="*email"
32+
autocomplete="off"
33+
placeholder="*email"
3434
formControlName="email_id">
3535
<!-- Validation -->
3636
<div *ngIf="form.controls.email_id.errors?.required && form.controls.email_id.dirty" class="invalid-feedback">This Field is required</div>
3737
<div class="invalid-feedback" *ngIf="(form.controls.email_id.errors?.minlength && form.controls.email_id.dirty || form.controls.email_id.errors?.maxlength && form.controls.email_id.dirty ) && form.controls.email_id.dirty">Minimum characters: 5, Maximum characters: 30</div>
3838
<div class="invalid-feedback" *ngIf="form.controls.email_id.errors?.validateemail && form.controls.email_id.dirty">This must be a valid e-mail</div>
3939
</div>
40-
40+
4141
<div class="form-group">
4242
<label for="college">College</label>
43-
<input type="text"
44-
name="college"
45-
formControlName="college"
46-
class="form-control"
47-
placeholder="Enter college name"
43+
<input type="text"
44+
name="college"
45+
formControlName="college"
46+
class="form-control"
47+
placeholder="Enter college name"
4848
autocomplete="off"
4949
[ngClass]="{'is-invalid': (form.controls.college.errors && form.controls.college.dirty) , 'is-valid': !form.controls.college.errors}">
5050
</div>
5151

5252
<div class="form-group">
5353
<label for="city">City</label>
54-
<input type="text"
55-
name="city"
56-
formControlName="city"
57-
class="form-control" placeholder="Enter city" autocomplete="off">
54+
<input type="text"
55+
name="city"
56+
formControlName="city"
57+
class="form-control" placeholder="Enter city" autocomplete="off">
5858
</div>
59-
59+
6060
<div class="form-group">
6161
<label for="dob">Date Of Birth</label>
6262
<input type="date"
63-
name="dob"
64-
formControlName="dob"
65-
class="form-control"
63+
name="dob"
64+
formControlName="dob"
65+
class="form-control"
6666
autocomplete="off"
6767
[ngClass]="{'is-invalid': (form.controls.dob.errors && form.controls.dob.dirty) , 'is-valid': !form.controls.dob.errors}">
6868
</div>
@@ -80,31 +80,31 @@
8080

8181
<div class="form-group">
8282
<label for="password">Password</label>
83-
<input type="password"
84-
name="password"
85-
formControlName="password"
86-
class="form-control"
87-
placeholder="Enter password"
83+
<input type="password"
84+
name="password"
85+
formControlName="password"
86+
class="form-control"
87+
placeholder="Enter password"
8888
autocomplete="off"
8989
[ngClass]="{'is-invalid': (form.controls.password.errors && form.controls.password.dirty) , 'is-valid': !form.controls.password.errors}">
9090
</div>
9191

9292
<div class="form-group">
9393
<label for="confirmpassword">Confirm Password</label>
94-
<input type="password"
95-
name="confirm"
96-
formControlName="confirm"
97-
class="form-control"
98-
placeholder="Confrim password"
94+
<input type="password"
95+
name="confirm"
96+
formControlName="confirm"
97+
class="form-control"
98+
placeholder="Confrim password"
9999
autocomplete="off"
100100
[ngClass]="{'is-invalid': (form.controls.confirm.errors && form.controls.confirm.dirty) || (form.errors?.matchingPasswords && form.controls.confirm.dirty) , 'is-valid': !form.controls.confirm.errors && !form.errors?.matchingPasswords}">
101101
<div *ngIf="form.errors?.matchingPasswords && form.controls.confirm.dirty"
102102
class="invalid-feedback">Password do not match</div>
103-
103+
104104
</div>
105105

106-
<input
106+
<input
107107
[disabled]="!form.valid "
108108
type="submit" class="btn btn-primary" value="Sign up">
109109
</form>
110-
</div>
110+
</div>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class RegisterComponent implements OnInit {
4141
username: ['', Validators.required],
4242
confirm: ['', Validators.required],
4343
college: ['', Validators.required],
44-
gender: '',
44+
gender: ['', Validators.required],
4545
dob: ['', Validators.required],
4646
city: ['', Validators.required]
4747
}, { validator: this.matchingPasswords('password', 'confirm')});
@@ -80,7 +80,8 @@ export class RegisterComponent implements OnInit {
8080
password: this.form.get('password').value,
8181
dob: this.form.get('dob').value,
8282
city: this.form.get('city').value,
83-
gender: this.form.get('gender').value
83+
gender: this.form.get('gender').value,
84+
joinedOn: Date.now()
8485
};
8586
this.authService.registerUser(user).subscribe(data => {
8687
if (!data.success) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class AuthService {
2828
}
2929

3030
public loadToken() {
31-
this.authToken = localStorage.getItem('token'); // Get token and asssign to variable to be used elsewhere
31+
this.authToken = localStorage.getItem('token'); // Get tokens and asssign to variable to be used elsewhere
3232
}
3333
public registerUser(user) {
3434
return this.http.post(this.domain + '/users/signup', user)

0 commit comments

Comments
 (0)