Methodology
The very first step of working on this project was learning Node.js.
It was for the dashboard server side which will pull the node status, recent data
and last seven data from the PostgreSQL.
My first attempt of the server was able to retrieve from the AoT links successfully.
All the code were written in server.js file. However, it was not compactable to
fetch multiple requests over time. I learned the lesson and I rewrote my server
from the scratch for the second time. The second server not only using Node.js
standalone but also along with Express library.
The new NodeJS server contains multiple files with various purpose. There are
main index file to call api file to start the server, routes/index.js file to receive
requests from the client and routes/query.js file to retrieve data. There is also
db/index.js to connect to the postgres database.
On the client side, there are project.html, Chicago.json, barGraph.js, heatMap.js,
LineGraph.js, map.js, nodeid.js and project.css. Poject.html contains the html
code for the webpage structure and required documents. Project.css is the
styling sheet for HTML file. Js/map.js is the JavaScript file to draw the Chicago
map using Chicago.json file that contains spatial data. This JS file also draw the
nodes on the map based on the node’s latitude and longitude. Js/barGraph.js
contains the function to create the bar chart that present how many nodes are on
online and how many nodes are not on online.
Js/ nodeid.js contains the function to print the selected node id on the right side
of the dashboard. Js/lineGraph.js has the function to draw the line graph and its
features. Js/heatMap.js contains the function to create the heat map. The project
starts by starting the server using this command:
“PGUSER=postgreUserName\PGHOST=IPaddress_of_serverMachine\
PGPASSWORD= \ PGDATABASE=database_Name \ PGPORT=port_Number \
node index.js”.
Then, open the html file. When the html file is opened, it will connect to the
server, and server will call required files and pull all the node id and its status
from the Chicago area to server the client side. Node status will be retrieved from
this link:
https://www.mcs.anl.gov/research/projects/waggle/downloads/beehive1/live-
nodes.txt.
Map.js will draw the Chicago map and node ids, and then it will call barGraph.js
to present total node id based on its status.