diff --git a/NodeAPI/index.js b/NodeAPI/index.js index 1e2f3daceee0a15819624dd27a1d614305996ca6..76eac2620bd57dd630dd32ae678a09583724230f 100644 --- a/NodeAPI/index.js +++ b/NodeAPI/index.js @@ -41,11 +41,11 @@ app.post('/predict', (req,res) => { if(err) { return console.dir(err); } // 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 var plot = req.body.plot; - var prediction = JSON.parse(body).predictionText; + var prediction = JSON.parse(JSON.parse(body).predictionText); // Get rcord to be inserted var rec = {'Plot':plot, 'Prediction': prediction}; @@ -67,17 +67,16 @@ app.post('/predict', (req,res) => { app.get('/submissions', function (req, res) { var resultArray = []; - /**MongoClient.connect(url, function(err, database) { + MongoClient.connect(url, function(err, db) { 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){ resultArray.push(doc) }, function(){ db.close(); res.render('submissions', {items: resultArray}); }); - });**/ - res.render('submissions', {}); + }); }); \ No newline at end of file diff --git a/NodeAPI/public/css/style.css b/NodeAPI/public/css/style.css index e71915c962dbb1fc6e51c8ee28f739ddc23d8c59..c2b5458585d6204db2b11aa798932c36bbdabdfa 100644 --- a/NodeAPI/public/css/style.css +++ b/NodeAPI/public/css/style.css @@ -146,8 +146,8 @@ p { color: #f2f2f2; text-align: center; padding: 14px 16px; - text-decoration: none; font-size: 1.3em; + text-decoration: none; font-family: Calibri, 'Trebuchet MS', sans-serif; font-weight: bold; } @@ -156,6 +156,7 @@ p { .topnav a:hover { background-color: #ddd; color: #e95e01; + text-decoration: none; } /* Add a color to the active/current link */ @@ -173,4 +174,13 @@ p { .subtitle{ color: #e95e01; font-size: 1.2em; +} + +table, th, td { + border: 1px solid black; + color: black; +} + +td{ + min-width: 10em; } \ No newline at end of file diff --git a/NodeAPI/views/submissions.ejs b/NodeAPI/views/submissions.ejs index d85468f456f5dcb38d298098ae5dbc64010127c6..d085446a111b195d33b549edd6c59708fd84d906 100644 --- a/NodeAPI/views/submissions.ejs +++ b/NodeAPI/views/submissions.ejs @@ -17,7 +17,10 @@ <a href="/">NLP11</a> <a class="active" href="/submissions">Submissions</a> </div> - <body class="text-center" > + <body> + + <h1>Posts</h1> + <%- include("table", {items}); %> </body> </div> diff --git a/NodeAPI/views/table.ejs b/NodeAPI/views/table.ejs new file mode 100644 index 0000000000000000000000000000000000000000..5f802e5eda4a0027ee8de6c05a86c502903b8c85 --- /dev/null +++ b/NodeAPI/views/table.ejs @@ -0,0 +1,17 @@ +<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