Skip to content
Snippets Groups Projects
Commit ce7ce2b6 authored by Iskandar, Michelle P (UG - Computer Science)'s avatar Iskandar, Michelle P (UG - Computer Science) :ice_skate:
Browse files

Connected db to submissions front end

parent fac28e8d
No related branches found
No related tags found
1 merge request!5Database
...@@ -41,11 +41,11 @@ app.post('/predict', (req,res) => { ...@@ -41,11 +41,11 @@ app.post('/predict', (req,res) => {
if(err) { return console.dir(err); } if(err) { return console.dir(err); }
// Create collection if does not exist // Create collection if does not exist
var collection = db.createCollection('Pred_Records'); var collection = db.db('ClusterNLP').collection('Pred_Records');
// Get the data to be stored // Get the data to be stored
var plot = req.body.plot; var plot = req.body.plot;
var prediction = JSON.parse(body).predictionText; var prediction = JSON.parse(JSON.parse(body).predictionText);
// Get rcord to be inserted // Get rcord to be inserted
var rec = {'Plot':plot, 'Prediction': prediction}; var rec = {'Plot':plot, 'Prediction': prediction};
...@@ -67,17 +67,16 @@ app.post('/predict', (req,res) => { ...@@ -67,17 +67,16 @@ app.post('/predict', (req,res) => {
app.get('/submissions', function (req, res) { app.get('/submissions', function (req, res) {
var resultArray = []; var resultArray = [];
/**MongoClient.connect(url, function(err, database) { MongoClient.connect(url, function(err, db) {
if(err) { return console.dir(err); } if(err) { return console.dir(err); }
var cursor = database.db().collection('Pred_Records').find() var cursor = db.db('ClusterNLP').collection('Pred_Records').find();
cursor.forEach(function(doc, err){ cursor.forEach(function(doc, err){
resultArray.push(doc) resultArray.push(doc)
}, function(){ }, function(){
db.close(); db.close();
res.render('submissions', {items: resultArray}); res.render('submissions', {items: resultArray});
}); });
});**/ });
res.render('submissions', {});
}); });
\ No newline at end of file
...@@ -146,8 +146,8 @@ p { ...@@ -146,8 +146,8 @@ p {
color: #f2f2f2; color: #f2f2f2;
text-align: center; text-align: center;
padding: 14px 16px; padding: 14px 16px;
text-decoration: none;
font-size: 1.3em; font-size: 1.3em;
text-decoration: none;
font-family: Calibri, 'Trebuchet MS', sans-serif; font-family: Calibri, 'Trebuchet MS', sans-serif;
font-weight: bold; font-weight: bold;
} }
...@@ -156,6 +156,7 @@ p { ...@@ -156,6 +156,7 @@ p {
.topnav a:hover { .topnav a:hover {
background-color: #ddd; background-color: #ddd;
color: #e95e01; color: #e95e01;
text-decoration: none;
} }
/* Add a color to the active/current link */ /* Add a color to the active/current link */
...@@ -173,4 +174,13 @@ p { ...@@ -173,4 +174,13 @@ p {
.subtitle{ .subtitle{
color: #e95e01; color: #e95e01;
font-size: 1.2em; font-size: 1.2em;
}
table, th, td {
border: 1px solid black;
color: black;
}
td{
min-width: 10em;
} }
\ No newline at end of file
...@@ -17,7 +17,10 @@ ...@@ -17,7 +17,10 @@
<a href="/">NLP11</a> <a href="/">NLP11</a>
<a class="active" href="/submissions">Submissions</a> <a class="active" href="/submissions">Submissions</a>
</div> </div>
<body class="text-center" > <body>
<h1>Posts</h1>
<%- include("table", {items}); %>
</body> </body>
</div> </div>
......
<table class="table">
<tr>
<th>Prediction</th>
<th>Plot</th>
</tr>
<%if (items.length >0){ %>
<% items.forEach(function(row) { %>
<tr>
<td><%= row.Prediction %></td>
<td><%= row.Plot %></td>
</tr>
<% })}else{ %>
<tr>
<td colspan="6">No Record Found</td>
</tr>
<% } %>
</table>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment