Skip to content

Commit ab95cf2

Browse files
committed
Bug fixed
1 parent 24a282a commit ab95cf2

11 files changed

+120
-62
lines changed

src/app/component/admin/createnew/createnew.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export class CreatenewComponent implements OnInit {
6565
.subscribe(
6666
data => {
6767
console.log('success');
68-
alert(JSON.parse(data)["message"]);
68+
console.log(data);
69+
alert(JSON.parse(data).message);
6970
this.router.navigate(['/admin-allcourses']);
7071

7172
},

src/app/component/admin/view/view.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class ViewComponent implements OnInit {
4242
this.nodeService.deleteCourse(coursename).subscribe(
4343
(result) =>{
4444
alert(JSON.parse(result["_body"]).message);
45+
this.courses = [];
4546
this.load();
4647
},
4748
(err) => {

src/app/component/home/home.component.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@
3131
<span class="sr-only">Next</span>
3232
</a>
3333
</div>
34-
34+
<div class="container" style="margin-top:10px">
35+
<h1 class="text-center"><b>Discover Latest Courses</b></h1>
36+
</div>
3537
<app-cards></app-cards>
38+
39+
3640
<div class="footer">
3741
<app-footer></app-footer>
3842
</div>

src/app/component/login/login.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
</span>
1111

1212
<div class="wrap-input100 validate-input" data-validate="Valid email is required: ex@abc.xyz">
13-
<input class="input100" type="text" name="email" placeholder="Email" [(ngModel)]="email">
13+
<input class="input100" type="text" name="email" id="email" placeholder="Email" [(ngModel)]="email">
1414
<span class="focus-input100"></span>
1515
<span class="symbol-input100">
1616
<i class="fa fa-envelope" aria-hidden="true"></i>
1717
</span>
1818
</div>
1919

2020
<div class="wrap-input100 validate-input" data-validate="Password is required">
21-
<input class="input100" type="password" name="pass" placeholder="Password" [(ngModel)]="password">
21+
<input class="input100" type="password" name="password" id="password" placeholder="Password" [(ngModel)]="password">
2222
<span class="focus-input100"></span>
2323
<span class="symbol-input100">
2424
<i class="fa fa-lock" aria-hidden="true"></i>
@@ -49,4 +49,4 @@
4949
</form>
5050
</div>
5151
</div>
52-
</div>
52+
</div>

src/app/component/login/login.component.ts

+23-9
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,42 @@ import { Router } from '@angular/router';
99
export class LoginComponent implements OnInit {
1010
email: String;
1111
password: String;
12-
constructor(private nodeService: NodeService, private router: Router) { }
13-
14-
ngOnInit() {
15-
this.nodeService.home().subscribe((result) => {
16-
console.log("res", result);
17-
if (JSON.parse(result["_body"]).message == "loggedinwithsession")
12+
constructor(private nodeService: NodeService, private router: Router) {
13+
this.nodeService.session().subscribe((result) => {
14+
if (JSON.parse(result["_body"]).message == "loggedin")
15+
if (JSON.parse(result["_body"]).username != "admin") {
16+
localStorage.setItem("user", JSON.parse(result["_body"]).username)
1817
this.router.navigate(['/home']);
18+
}
19+
else {
20+
localStorage.setItem("user", JSON.parse(result["_body"]).username)
21+
this.router.navigate(['/admin-allcourses']);
22+
}
1923
},
2024
err => {
2125
console.log("err", err)
2226
})
2327
}
28+
29+
ngOnInit() {
30+
31+
}
2432
onLogin() {
25-
if (this.email != undefined && this.password != undefined) {
33+
console.log(typeof this.email);
34+
35+
if (this.email.length != 0 && this.password.length != 0) {
2636
this.nodeService.login(this.email, this.password).subscribe(
2737
(result) => {
2838
console.log(result);
2939
if (JSON.parse(result["_body"]).message == "loggedin") {
30-
if (JSON.parse(result["_body"]).username != "admin")
40+
if (JSON.parse(result["_body"]).username != "admin") {
41+
localStorage.setItem("user", JSON.parse(result["_body"]).username)
3142
this.router.navigate(['/home']);
32-
else
43+
}
44+
else {
45+
localStorage.setItem("user", JSON.parse(result["_body"]).username)
3346
this.router.navigate(['/admin-allcourses']);
47+
}
3448
}
3549

3650
},

src/app/component/navbar/navbar.component.css

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
}
1616
.navbar-nav>li>a
1717
{
18-
padding-top:10px;
19-
padding-bottom:0px;
20-
line-height:20px
18+
19+
line-height:20px;
20+
font-size: 16px;
21+
2122
}
2223
.size{
2324
font-size: 20px;
@@ -53,6 +54,7 @@
5354
padding: 12px 16px;
5455
text-decoration: none;
5556
display: block;
57+
font-size: 14px;
5658
}
5759

5860
/* Change color of dropdown links on hover */
+56-30
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,64 @@
1-
<nav class="navbar navbar-inverse container-fluid">
2-
<div class="container" >
3-
<div class="navbar-header">
4-
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
5-
<span class="icon-bar"></span>
6-
<span class="icon-bar"></span>
7-
<span class="icon-bar"></span>
8-
</button>
9-
<a class="navbar-brand" href="#" style="color:white;font-size:25px;">Mazelon</a>
10-
</div>
11-
<div class="collapse navbar-collapse" id="myNavbar">
12-
<ul class="nav navbar-nav">
13-
<li class="active size"><a href="#" style="color:white">Home</a></li>
14-
<li class="dropdown">
15-
<a class="dropdown-toggle size" data-toggle="dropdown" href="#"style="color:white">Courses <span class="caret"></span></a>
16-
<ul class="dropdown-menu">
17-
<li class="size"><a href="#" style="color:black">All Courses</a></li>
18-
<li class="size"><a href="#" style="color:black">Chat</a></li>
19-
<li class="size"><a href="#" style="color:black">Questions</a></li>
20-
</ul>
21-
</li>
22-
<li class="dropdown">
1+
<nav class="navbar navbar-inverse container-fluid" style="position:fixed">
2+
<div class="container">
3+
<div class="navbar-header">
4+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
5+
<span class="icon-bar"></span>
6+
<span class="icon-bar"></span>
7+
<span class="icon-bar"></span>
8+
</button>
9+
<a class="navbar-brand" routerLink="/home" routerLinkActive="active" style="color:white;font-size:25px;">Tutorial</a>
10+
</div>
11+
<div class="collapse navbar-collapse" id="myNavbar">
12+
<ul class="nav navbar-nav">
13+
<li class="active size">
14+
<a routerLink="/home" routerLinkActive="active" style="color:white">Home</a>
15+
</li>
16+
<li class="dropdown">
17+
<a class="dropdown-toggle size" data-toggle="dropdown" href="#" style="color:white">Courses
18+
<span class="caret"></span>
19+
</a>
20+
<ul class="dropdown-menu">
21+
<li class="size">
22+
<a href="#" style="color:black">All Courses</a>
23+
</li>
24+
<li class="size">
25+
<a href="#" style="color:black">Chat</a>
26+
</li>
27+
<li class="size">
28+
<a href="#" style="color:black">Questions</a>
29+
</li>
30+
</ul>
31+
</li>
32+
<!-- <li class="dropdown">
2333
<a class="dropdown-toggle size" data-toggle="dropdown" href="#"style="color:white">Installation <span class="caret"></span></a>
2434
<ul class="dropdown-menu">
2535
<li class="size"><a href="#" style="color:black">Install PHP</a></li>
2636
<li class="size"><a href="#" style="color:black">Install Angular </a></li>
2737
<li class="size"><a href="#" style="color:black">Install Node js</a></li>
2838
</ul>
29-
</li>
39+
</li> -->
40+
41+
</ul>
42+
<ul class="nav navbar-nav navbar-right">
43+
3044

31-
</ul>
32-
<ul class="nav navbar-nav navbar-right">
33-
<!-- <li><a href="#"style="color:white"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li> -->
34-
<li><a (click)="logout()" style="color:white"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
35-
</ul>
36-
</div>
45+
<li class="dropdown">
46+
<a class="dropdown-toggle size" data-toggle="dropdown" href="#" style="color:white">{{username}}
47+
<span class="caret"></span>
48+
</a>
49+
<ul class="dropdown-menu">
50+
<li class="size">
51+
<a href="#" style="color:black">My Profile</a>
52+
</li>
53+
<li>
54+
<a (click)="logout()" style="color:white">
55+
<span class="glyphicon glyphicon-log-out"></span> Logout</a>
56+
</li>
57+
58+
</ul>
59+
</li>
60+
61+
</ul>
62+
</div>
3763
</div>
38-
</nav>
64+
</nav>

src/app/component/navbar/navbar.component.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ import { Router } from '@angular/router';
88
styleUrls: ['./navbar.component.css']
99
})
1010
export class NavbarComponent implements OnInit {
11-
12-
constructor(private nodeService: NodeService,private router: Router) { }
11+
username:String;
12+
constructor(private nodeService: NodeService,private router: Router) {
13+
this.username = localStorage.getItem("user")
14+
console.log(this.username);
15+
16+
}
1317

1418
ngOnInit() {
1519
}

src/app/component/readcourse/readcourse.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { NodeService } from "./../../services/node.service";
1010
export class ReadcourseComponent implements OnInit {
1111
coursename : String;
1212
content : String;
13+
1314
constructor(private nodeService: NodeService) {
1415
this.coursename = localStorage.getItem("course");
1516
console.log(this.coursename);
@@ -21,9 +22,9 @@ export class ReadcourseComponent implements OnInit {
2122
var feed = jsondata[i];
2223
this.section.push(feed);
2324
}
25+
this.getCourseData(this.section[0]);
2426
}
2527
)
26-
console.log(1,this.section);
2728

2829
}
2930

src/app/component/signup/signup.component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export class SignupComponent implements OnInit {
2020
}
2121

2222
onSignup(){
23-
if(this.name != undefined && this.email != undefined && this.password != undefined && this.c_password != undefined && this.mobile != undefined){
23+
24+
if(this.name.length !=0 && this.email.length != 0 && this.password.length != 0 && this.c_password.length != 0 && this.mobile.toString().length <= 9){
2425
if(this.password === this.c_password){
2526
this.nodeService.signup(this.name,this.email,this.password,this.mobile).subscribe(
2627
(result)=>{
@@ -29,7 +30,7 @@ export class SignupComponent implements OnInit {
2930
this.router.navigate(['/login']);
3031
},
3132
(err) => {
32-
console.log(err);
33+
alert(err);
3334
}
3435
)
3536
}else{

src/app/services/node.service.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'rxjs/add/operator/map';
66

77
@Injectable()
88
export class NodeService {
9-
9+
baseUrl : string = "http://localhost:3000/";
1010
constructor(public http : Http) { }
1111

1212
login(email,password){
@@ -15,62 +15,66 @@ export class NodeService {
1515
let options = new RequestOptions({headers: headers,withCredentials: true});
1616
let body = JSON.stringify(data);
1717
console.log(body);
18-
return this.http.post('http://localhost:3000/login',body,options);
18+
return this.http.post(this.baseUrl+'login',body,options);
1919
}
2020
signup(name,email,password,mobile){
2121
var data = {"name" : name, "email" : email, "password" : password, "mobile" : mobile};
2222
let headers = new Headers({ 'Content-Type': 'application/json'});
2323
let options = new RequestOptions({headers: headers});
2424
let body = JSON.stringify(data);
2525
console.log(body);
26-
return this.http.post('http://localhost:3000/signup',body,options);
26+
return this.http.post(this.baseUrl+'signup',body,options);
2727
}
2828
home(){
2929
let options = new RequestOptions({withCredentials: true});
30-
return this.http.get("http://localhost:3000/home", options)
30+
return this.http.get(this.baseUrl+"home", options)
3131
}
3232
updateCourse(course_id,course_name,section,content){
3333
var data = {"courseId" : course_id, "courseName" : course_name, "topicName" : section, "courseData" : content};
3434
let headers = new Headers({ 'Content-Type': 'application/json'});
3535
let options = new RequestOptions({headers: headers,withCredentials: true});
3636
let body = JSON.stringify(data);
3737
console.log(body);
38-
return this.http.post('http://localhost:3000/addCourseData',body,options);
38+
return this.http.post(this.baseUrl+'addCourseData',body,options);
3939
}
4040
logout(){
4141
let options = new RequestOptions({withCredentials: true});
42-
return this.http.get("http://localhost:3000/logout", options)
42+
return this.http.get(this.baseUrl+"logout", options)
4343
}
4444
deleteCourse(course_name){
4545
var data = {"coursename" : course_name};
4646
let headers = new Headers({ 'Content-Type': 'application/json'});
4747
let options = new RequestOptions({headers: headers,withCredentials: true});
4848
let body = JSON.stringify(data);
4949
console.log(body);
50-
return this.http.post('http://localhost:3000/deleteCourse',body,options);
50+
return this.http.post(this.baseUrl+'deleteCourse',body,options);
5151
}
5252
getSections(course_name){
5353
var data = {"coursename" : course_name};
5454
let headers = new Headers({ 'Content-Type': 'application/json'});
5555
let options = new RequestOptions({headers: headers,withCredentials: true});
5656
let body = JSON.stringify(data);
5757
console.log(body);
58-
return this.http.post('http://localhost:3000/course/'+course_name,body,options);
58+
return this.http.post(this.baseUrl+'course/'+course_name,body,options);
5959
}
6060
getSectionData(course_name,section){
6161
var data = {"courseName" : course_name,"section":section};
6262
let headers = new Headers({ 'Content-Type': 'application/json'});
6363
let options = new RequestOptions({headers: headers,withCredentials: true});
6464
let body = JSON.stringify(data);
6565
console.log(body);
66-
return this.http.post('http://localhost:3000/course/'+course_name+'/'+section,body,options);
66+
return this.http.post(this.baseUrl+'course/'+course_name+'/'+section,body,options);
6767
}
6868
updateSection(course_name,topicName,content){
6969
var data = {"courseName" : course_name, "topicName" : topicName, "courseData" : content};
7070
let headers = new Headers({ 'Content-Type': 'application/json'});
7171
let options = new RequestOptions({headers: headers,withCredentials: true});
7272
let body = JSON.stringify(data);
7373
console.log(body);
74-
return this.http.post('http://localhost:3000/update-section',body,options);
74+
return this.http.post(this.baseUrl+'update-section',body,options);
75+
}
76+
session(){
77+
let options = new RequestOptions({withCredentials: true});
78+
return this.http.get(this.baseUrl, options)
7579
}
7680
}

0 commit comments

Comments
 (0)