-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
205 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,62 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var async = require('async'); | ||
var mongodb = require('mongodb'); | ||
var http = require('http'); | ||
|
||
|
||
/* GET home page. */ | ||
router.get('/', function(req, res) | ||
{ | ||
|
||
var db = req.db; | ||
var collection = db.collection('testing'); | ||
collection.find().toArray(function(err,result){ | ||
if (err) {console.log(err)} | ||
else {console.log("We've got results!")} | ||
console.log(result) | ||
var mystring = result[0]["servicename"] + " , " + result[0]["data"] | ||
res.render('newdashboard',{data:mystring}) | ||
}); | ||
|
||
var async = require('async'); | ||
var router = express.Router(); | ||
|
||
router.get('/', function(req, res) { | ||
|
||
async.parallel([ | ||
function(callback){ | ||
var db = req.db; | ||
var collection = db.collection('testing'); | ||
collection.find().toArray(function(err,result){ | ||
if (err){ | ||
console.log(err); | ||
callback(err); | ||
} | ||
else if (result.length){console.log("We've got results!");} | ||
callback(null,result); | ||
}); | ||
}, | ||
function(callback){ | ||
var db = req.db; | ||
var collection = db.collection('tablespacessco'); | ||
collection.find().sort({timestamp:-1}).limit(1).toArray(function(err,result){ | ||
|
||
if (err){ | ||
console.log(err); | ||
callback(err); | ||
} | ||
else if (result.length){console.log("We've got a table!");} | ||
else {console.log("no se encontro nada");} | ||
callback(null,result); | ||
}); | ||
} | ||
|
||
|
||
], | ||
|
||
|
||
function(err,results){ | ||
if (err){ | ||
console.log(err); | ||
return res.send(400); | ||
} | ||
data1 = results[0][0] | ||
scotable = results[1][0]["data"] | ||
|
||
console.log(data1) | ||
console.log(scotable) | ||
res.render('newdashboard', | ||
{ | ||
data1:data1, | ||
data2:scotable | ||
} | ||
) | ||
//end function results | ||
} | ||
//end async | ||
); | ||
}); | ||
|
||
|
||
|
||
module.exports = router; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters