Skip to content

Commit 601b30d

Browse files
author
vinod
committed
adding metowrk grpah
1 parent c0cebc1 commit 601b30d

File tree

11 files changed

+113
-15
lines changed

11 files changed

+113
-15
lines changed

controllers/notes.controller.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function myFirstFunction(data, callback) {
103103
});
104104
}
105105
function mySecondFunction(data, callback) {
106-
User.find({}, { name: 1 }).limit(2).lean()
106+
User.find({}, { name: 1 }).limit(10).lean()
107107
.then(users => {
108108
let obj = {
109109
note: data,
@@ -126,7 +126,6 @@ notesCtrl.renderNotesgrids = (req, res) => {
126126
let obj={}
127127
var date = moment(item.createdAt, "YYYYMMDD").fromNow();
128128
item.date = date
129-
130129
obj={
131130
title:item.title,
132131
description:item.description,
@@ -142,4 +141,27 @@ notesCtrl.renderNotesgrids = (req, res) => {
142141
});
143142
});
144143
};
144+
notesCtrl.renderNotesNetwork = (req, res) => {
145+
Note.find({user:req.user.id})
146+
.then(notes => {
147+
var temp=[]
148+
notes.forEach(function (item) {
149+
let obj={}
150+
var date = moment(item.createdAt, "YYYYMMDD").fromNow();
151+
item.date = date
152+
obj={
153+
title:item.title,
154+
description:item.description,
155+
Created:item.date
156+
}
157+
temp.push(obj)
158+
});
159+
temp=JSON.stringify(temp)
160+
res.render("notes/notesnetwork", { temp });
161+
}).catch(err => {
162+
res.status(500).send({
163+
message: err.message
164+
});
165+
});
166+
};
145167
module.exports = notesCtrl;

database.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const mongoose = require("mongoose");
22
const MONGODB_URI = "mongodb://localhost/pucsd"
33

4-
mongoose.connect(MONGODB_URI, { useNewUrlParser: true })
4+
mongoose.connect(MONGODB_URI, {useNewUrlParser: true, useUnifiedTopology: true})
55
.then(() => {
66
console.log("Successfully connected to MongoDB.");
77
}).catch(err => {

public/css/main.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ body {
3939
.signBtn{
4040
color:whitesmoke;
4141
}
42+
.signupFrm{
43+
border: 1px solid grey;
44+
padding: 10px;
45+
border-radius: 25px;
46+
/*border-radius: 20px 50px;*/
47+
box-shadow: 5px 10px;
48+
}
49+
4250
.navbar{
4351
background-color: #003749;
4452
/*background-color: #bfbfbf;*/
@@ -52,6 +60,10 @@ section{
5260
margin-top: 30px;
5361
}
5462

63+
.edtCrd{
64+
border-radius: 12px;
65+
box-shadow: 5px 5px 5px 5px #4d4d4d;
66+
}
5567
/* Style the buttons */
5668
.btn {
5769
border: none;
@@ -60,6 +72,18 @@ section{
6072
cursor: pointer;
6173
}
6274

75+
.mainselection {
76+
overflow:hidden;
77+
width:200px;
78+
height: 30px;
79+
-moz-border-radius: 9px 9px 9px 9px;
80+
-webkit-border-radius: 9px 9px 9px 9px;
81+
border-radius: 12px;
82+
box-shadow: 1px 1px 5px #330033;
83+
background: no-repeat scroll 319px center;
84+
}
85+
86+
6387
footer{
6488
height: 35vh;
6589
margin-top: 70px;
@@ -72,3 +96,6 @@ footer{
7296
margin-left: 200px;
7397
}
7498

99+
div.vis-network {
100+
background-color: white;
101+
}

routes/notes.routes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const {
1010
updateNote,
1111
deleteNote,
1212
updateStatus,
13-
renderNotesgrids
13+
renderNotesgrids,
14+
renderNotesNetwork
1415
} = require("../controllers/notes.controller");
1516

1617
// Helpers
@@ -37,5 +38,6 @@ router.delete("/notes/delete/:id", isAuthenticated, deleteNote);
3738
router.post("/notes/statusUpdate/:id", isAuthenticated, updateStatus);
3839

3940
router.get("/notesgrid", isAuthenticated, renderNotesgrids);
41+
router.get("/NotesNetwork", isAuthenticated, renderNotesNetwork);
4042

4143
module.exports = router;

views/index.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<span class="bold-text">VS InfoTech</span> helps you take control of your tasks and saves you time <span class="bold-text">by bringing them all</span> into your preferred task manager.
1212
</p>
1313

14-
<a href="/users/signup"><button class="btn btn--red " data-toggle="modal" data-target="#sign-in-modal">Get started - it’s free </button></a>
14+
<a href="/users/signup"><button class="btn btn-success " data-toggle="modal" data-target="#sign-in-modal">Get started - it’s free </button></a>
1515
</div>
1616
</div>
1717
<div class="col-md-4 col-sm-4 col-xs-12 section__content--right">
@@ -56,7 +56,7 @@
5656
You <span class="bold-text">always know what’s on top</span> of the list based on due dates and priorities, no matter where the task came from. <br>
5757
</p>
5858

59-
<a href="/users/signup"><button data-toggle="modal" data-target="#sign-in-modal" class="btn btn-red ">Get started - it’s free </button></a>
59+
<a href="/users/signup"><button data-toggle="modal" data-target="#sign-in-modal" class="btn btn-success ">Get started - it’s free </button></a>
6060
</div>
6161
</div>
6262
<div class="col-md-6 col-sm-6 col-xs-12 section__content--right">

views/layouts/main.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
1111
<!-- CUSTOM CSS -->
1212
<link rel="stylesheet" href="/css/main.css">
13+
<script type="text/javascript" src="https://visjs.github.io/vis-network/standalone/umd/vis-network.min.js"></script>
1314
<script src="https://cdn.zingchart.com/zingchart.min.js"></script>
1415
<script src="https://cdn.zinggrid.com/zinggrid.min.js" defer></script>
1516
</head>
@@ -90,6 +91,7 @@
9091
});
9192
</script>
9293
<!-- Scritps -->
94+
9395
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
9496
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
9597
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

views/notes/edit-note.hbs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{/each}}
99

1010
<div class="col-md-4 mx-auto">
11-
<div class="card">
11+
<div class="card edtCrd">
1212

1313
{{!-- <p>{{notes.note}}</p> --}}
1414

@@ -20,19 +20,25 @@
2020
<form action="/notes/edit-note/{{notes.note._id}}?_method=PUT" method="POST">
2121
<input type="hidden" name="_method" value="PUT">
2222
<div class="form-group">
23+
<b>Title:</b>
2324
<input type="text" name="title" class="form-control" value="{{notes.note.title}}" />
2425
</div>
2526
<div class="form-group">
27+
<b>Description:</b>
2628
<textarea name="description" class="form-control">{{notes.note.description}}</textarea>
2729
</div>
28-
<div class="form-group">
29-
<label for="cars">User List:</label>
30-
<select id="cars" name="userid">
30+
31+
32+
<div class="form-group ">
33+
<h4>User List</h4>
34+
<select class="mainselection" id="cars" name="userid">
3135
{{#each notes.user}}
3236
<option value={{_id}}>{{name}}</option>
3337
{{/each}}
3438
</select>
35-
</div>
39+
</div>
40+
41+
3642
<div class="form-group">
3743
<button class="btn btn-primary btn-block" type="submit">
3844
Save

views/notes/notesnetwork.hbs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
3+
<div id="mynetwork" style="height: 500px;"></div>
4+
5+
<script type="text/javascript">
6+
// create an array with nodes
7+
var nodes = new vis.DataSet([
8+
{id: 1, label: 'Node 1'},
9+
{id: 2, label: 'Node 2'},
10+
{id: 3, label: 'Node 3'},
11+
{id: 4, label: 'Node 4'},
12+
{id: 5, label: 'Node 5'}
13+
]);
14+
15+
// create an array with edges
16+
var edges = new vis.DataSet([
17+
{from: 1, to: 3},
18+
{from: 1, to: 2},
19+
{from: 2, to: 4},
20+
{from: 2, to: 5},
21+
{from: 3, to: 3}
22+
]);
23+
24+
// create a network
25+
var container = document.getElementById('mynetwork');
26+
var data = {
27+
nodes: nodes,
28+
edges: edges
29+
};
30+
var options = {
31+
autoResize: true,
32+
locale: 'en',
33+
clickToUse: false,
34+
};
35+
var network = new vis.Network(container, data, options);
36+
</script>

views/partials/navigation.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
2020
<a class="dropdown-item" href="/notes">All Notes</a>
2121
<a class="dropdown-item" href="/notesgrid">All Notes List</a>
22+
<a class="dropdown-item" href="/NotesNetwork">All Notes network</a>
2223
<a class="dropdown-item" href="/notes/add">Add A Note</a>
2324
<div class="dropdown-divider"></div>
2425
<a class="dropdown-item" href="/users/logout">Logout</a>

views/users/signin.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="row">
22
<div class="col-md-4 mx-auto">
3-
<div class="card mt-4 text-center">
3+
<div class="card mt-4 text-center signupFrm">
44
<div class="card-header">
55
<h1 class="h4">
66
Account Login

0 commit comments

Comments
 (0)