diff --git a/Sean/modules/mysql.js b/Sean/modules/mysql.js
index 4ae5252..c0572d8 100644
--- a/Sean/modules/mysql.js
+++ b/Sean/modules/mysql.js
@@ -40,14 +40,8 @@ const connection = mysql.createConnection({
timezone: "Z", // Set the timezone to UTC
});
- const connection2 = mysql.createConnection({
- host: process.env.host,
- user: process.env.DB_USER,
- password: process.env.DB_PASS,
- database: "eco_saver",
- timezone: "Z", // Set the timezone to UTC
- });
-module.exports = { connection,connection2 };
+
+module.exports = { connection, };
diff --git a/Sean/server.js b/Sean/server.js
index 5d281ec..91604e3 100644
--- a/Sean/server.js
+++ b/Sean/server.js
@@ -11,7 +11,7 @@ const validator = require('validator');
const { transporter } = require("./modules/nodeMailer");
const { connection } = require("./modules/mysql");
-const { connection2 } = require("./modules/mysql");
+
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
@@ -302,39 +302,14 @@ app.use(setCSRFToken);
});
-
-
-
-
app.get("/home", isAuthenticated, (req, res) => {
-
- // Retrieve the last 10 sensor data records from the sensordata table
- const sensorDataQuery =
- "SELECT locationid, measurement, createdAt FROM sensordata ORDER BY createdAt DESC LIMIT 10";
-
- connection2.query(sensorDataQuery, (error, sensorDataResults) => {
- if (error) {
- console.error("Error executing sensor data query:", error);
- res.status(500).send("Internal Server Error");
- return;
- }
// Render the home page with sensor data
res.render("home", {
username: req.session.username,
- sensorData: sensorDataResults,
});
});
- });
- app.get('/api/locations', (req, res) => {
- connection2.query('SELECT `id`, `name` FROM `locations`', (error, results) => {
- if (error) {
- console.error('Error fetching locations:', error);
- res.status(500).json({ error: 'Internal Server Error' });
- return;
- }
- res.json(results);
- });
-});
+
+
app.get("/inusers", isAuthenticated, (req, res) => {
// Fetch all user data from the database
diff --git a/Sean/views/home.ejs b/Sean/views/home.ejs
index 41251db..929ea47 100644
--- a/Sean/views/home.ejs
+++ b/Sean/views/home.ejs
@@ -53,35 +53,11 @@
text-align: center;
}
- table {
- border-collapse: collapse;
- width: 80%;
- margin: 20px auto;
- font-size: 16px;
- }
-
- th, td {
- border: 1px solid #dddddd;
- text-align: left;
- padding: 12px;
- }
-
- th {
- background-color: #f2f2f2;
- }
-
- tr:hover {
- background-color: #f5f5f5;
- }
-
- td {
- white-space: nowrap;
- }
-
+
Eco Saver
@@ -93,154 +69,7 @@
Welcome to the Home Page, <%= username %>!
-
Last 10 Sensor Data Records:
-
-
-
-
-
-
- Location |
- CO |
- O3 |
- NO2 |
- PSI |
- SO2 |
- Humidity |
- Wind Speed |
- Temperature |
- Created At |
-
-
-
- <% sensorData.forEach(data => { %>
-
- <%= data.locationid %> |
- <%= data.measurement.co %> |
- <%= data.measurement.o3 %> |
- <%= data.measurement.no2 %> |
- <%= data.measurement.psi %> |
- <%= data.measurement.so2 %> |
- <%= data.measurement.humidity %> |
- <%= data.measurement.windspeed %> |
- <%= data.measurement.temperature %> |
- <%= new Date(data.createdAt).toLocaleString('en-US', { timeZone: 'Asia/Singapore' }) %> |
-
- <% }); %>
-
-
-
-
-
-
-
-
-
+