Skip to content

Commit 284547c

Browse files
committed
Signin/signup
1 parent 2b41bdf commit 284547c

21 files changed

Lines changed: 188 additions & 36 deletions

codecamp-front/.angular-cli.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"testTsconfig": "tsconfig.spec.json",
2020
"prefix": "app",
2121
"styles": [
22-
"styles.css",
23-
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
22+
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
23+
"styles.css"
2424
],
2525
"scripts": [
2626

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { DiscussComponent } from './components/discuss/discuss.component';
1313
import { ContestComponent } from './components/contest/contest.component';
1414
import { AboutComponent } from './components/about/about.component';
1515
import { IdeComponent } from './components/ide/ide.component';
16+
import { ProblemsComponent } from './components/problems/problems.component';
1617

1718

1819

@@ -21,16 +22,17 @@ const appRoutes: Routes = [
2122
{path: 'about', component: AboutComponent},
2223
{path: 'register' , component: RegisterComponent},
2324
{path: 'login' , component: LoginComponent},
24-
{path: 'practice' , component: PracticeComponent},
25+
{path: 'problems' , component: PracticeComponent},
2526
{path: 'contest' , component: ContestComponent},
2627
{path: 'discuss' , component: DiscussComponent},
2728
{path: 'profile' , component: ProfileComponent},
2829
{path: 'ide', component: IdeComponent},
30+
{path: 'problems/:problem', component: ProblemsComponent}
2931
];
3032

3133
@NgModule({
3234
imports: [RouterModule.forRoot(appRoutes)],
3335
exports: [RouterModule]
3436
})
35-
export class AppRoutingModule {
36-
}
37+
export class AppRoutingModule {
38+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { AboutComponent } from './components/about/about.component';
1919
import { AuthService } from './services/auth.service';
2020
import { HttpModule } from '@angular/http';
2121
import { IdeComponent } from './components/ide/ide.component';
22+
import { ProblemsComponent } from './components/problems/problems.component';
2223

2324

2425
@NgModule({
@@ -33,7 +34,8 @@ import { IdeComponent } from './components/ide/ide.component';
3334
DiscussComponent,
3435
ContestComponent,
3536
AboutComponent,
36-
IdeComponent
37+
IdeComponent,
38+
ProblemsComponent
3739
],
3840
imports: [
3941
BrowserModule,
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
<p>
2-
contest works!
3-
</p>
1+
<div class="container">
2+
<div class="row">
3+
<div class="col-md-12">
4+
<button class="btn btn-warning" *ngIf="authService.checkisAdmin() === true">Add Contest</button>
5+
</div>
6+
</div>
7+
</div>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { AuthService } from '../../services/auth.service';
23

34
@Component({
45
selector: 'app-contest',
@@ -7,7 +8,9 @@ import { Component, OnInit } from '@angular/core';
78
})
89
export class ContestComponent implements OnInit {
910

10-
constructor() { }
11+
constructor(
12+
private authService: AuthService
13+
) { }
1114

1215
ngOnInit() {
1316
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class LoginComponent implements OnInit {
1616
private authService: AuthService,
1717
private router: Router,
1818
private formBuilder: FormBuilder
19-
) {
19+
) {
2020
this.createForm();
2121
}
2222

@@ -38,12 +38,11 @@ export class LoginComponent implements OnInit {
3838
username: this.form.get('username').value, // Username input field
3939
password: this.form.get('password').value // Password input field
4040
};
41+
console.log(user);
4142
this.authService.loginUser(user).subscribe(data => {
42-
this.authService.storeUserData(data.token, data.user);
43+
this.authService.storeUserData(data.token, data.user, data.isAdmin);
4344
// After 2 seconds, redirect to dashboard page
44-
setTimeout(() => {
45-
this.router.navigate(['/']); // Navigate to dashboard view
46-
}, 2000);
45+
this.router.navigate(['/']); // Navigate to dashboard view
4746
});
4847
}
4948
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</li>
2727
<li class="nav-item">
2828
<a class="nav-link"
29-
routerLink="/practice"
29+
routerLink="/problems"
3030
routerLinkActive="active"
3131
>Practice</a>
3232
</li>
@@ -42,6 +42,12 @@
4242
routerLinkActive="active"
4343
>Contest</a>
4444
</li>
45+
<li class="nav-item" >
46+
<a class="nav-link"
47+
routerLink="/ide"
48+
routerLinkActive="active"
49+
>Online IDE</a>
50+
</li>
4551
</ul>
4652
<ul class="navbar-nav ml-auto">
4753
<li class="nav-item">

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ export class NavbarComponent implements OnInit {
1717
ngOnInit() {
1818
}
1919

20+
onLogoutClick() {
21+
this.authService.logout(); // Logout user
22+
this.router.navigate(['/']); // Navigate back to home page
23+
}
24+
2025
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
p{
2+
margin: 8px 0;
3+
}
4+
5+
.title{
6+
padding-top: 10px;
7+
background: #343a40;
8+
color: white;
9+
}
10+
a{
11+
color: black;
12+
padding: 0;
13+
}
14+
15+
hr{
16+
margin: 0;
17+
border: 0.5px solid grey;
18+
}
19+
20+
.problem{
21+
background: white;
22+
}
Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1-
<p>
2-
practice works!
3-
</p>
1+
<div class="container box">
2+
<div class="row title">
3+
<div class="col-md-6">
4+
<p>Name</p>
5+
</div>
6+
<div class="col-md-3">
7+
<p>Code</p>
8+
</div>
9+
<div class="col-md-3">
10+
<p>Submission</p>
11+
</div>
12+
</div>
13+
<a href="#" class="nav-link">
14+
<div class="row problem ">
15+
<div class="col-md-6">
16+
<p>A puzzle Game</p>
17+
</div>
18+
<div class="col-md-3">
19+
<p>H1</p>
20+
</div>
21+
<div class="col-md-3">
22+
<p>43.43</p>
23+
</div>
24+
</div>
25+
</a>
26+
</div>
27+
28+
<hr>

0 commit comments

Comments
 (0)