diff --git a/.gitignore b/.gitignore index 97aca2e..dd4782d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,17 @@ +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results + +npm-debug.log +node_modules .env -node_modules \ No newline at end of file +profileEJSBU.txt diff --git a/app/routes.js b/app/routes.js index a512f12..eda060c 100644 --- a/app/routes.js +++ b/app/routes.js @@ -49,8 +49,14 @@ const moodActions = { const user = req.user || null; const moodCollection = await Mood.find({ userId: req.user._id }); + + const latestMood = await Mood.findOne().sort({ timestamp: 1 }).exec(); + console.log(`This is the latest log: ${latestMood}`) + console.log(`This is the latest mood: ${latestMood.mood}`) + const backgroundColor = latestMood.length > 0 ? latestMood.mood : 'neutral' + console.log(`This is the background color: ${backgroundColor}`) - res.render('profile', { user, moodCollection }); + res.render('profile', { user, moodCollection, backgroundColor }); } catch (err) { console.log('Error fetching moods:', err); res.status(500).send('Internal Server Error'); @@ -106,7 +112,7 @@ app.post('/submitMood', (req, res) => { }); -// Edit mood +// Edit mood app.put('/mood/:id', async (req, res) => { const moodId = req.params.id; diff --git a/config/database.js b/config/database.js index 70df271..cbd3cde 100644 --- a/config/database.js +++ b/config/database.js @@ -1,6 +1,5 @@ // config/database.js module.exports = { - 'MONGO_URL' : 'mongodb://mongo:hFEAPBxjHSBPGoLgPeajINPqOYOBuycW@mongodb-niml.railway.internal:27017', 'dbName': 'mood-tracker' }; diff --git a/public/main.js b/public/main.js index f6b9db2..ad4e32d 100644 --- a/public/main.js +++ b/public/main.js @@ -47,3 +47,49 @@ Array.from(document.querySelectorAll('.deleteClick')).forEach(button => { } }); }); + + + +// fetch('/profile', { +// method: 'GET', +// headers: { +// 'Content-Type': 'application/json', +// }, +// // body: JSON, +// //body: JSON.stringify(payload), +// }) +// .then(response => { +// if (!response.ok) { +// throw new Error('Network response was not ok'); +// } +// return response.text(); +// }) +// .then(data => { +// // Handle the data +// console.log("This is the data from profile route", data.moodCollection) +// // changeBackgroundColor(data); +// }) +// .catch(error => console.error('Error:', error)); + +// function changeBackgroundColor(data) { +// console.log("This is the data from profile route", data) + +// let backgroundColor = '#EEDAD1'; // Default color + +// if (data.mood === 'happy') { +// backgroundColor = '#FFE680'; +// } else if (data.mood === 'sad') { +// backgroundColor = '#7DA3DA'; +// } else if (data.mood === 'angry') { +// backgroundColor = 'blue'; +// } else if (data.mood === 'stressed') { +// backgroundColor = '#935252'; +// } else if (data.mood === 'excited') { +// backgroundColor = 'blue'; +// } else { +// backgroundColor = '#EEDAD1'; +// } + +// setBodyBackgroundColor(backgroundColor); +// } + diff --git a/public/style.css b/public/style.css index 3e914f9..0d467a7 100644 --- a/public/style.css +++ b/public/style.css @@ -6,7 +6,7 @@ body { font-family: 'Helvetica Neue', sans-serif; - background: linear-gradient(180deg, #FBE3D2, #FAF4D9); + /* background: linear-gradient(180deg, #FBE3D2, #FAF4D9); */ color: #333; margin: 0; padding: 0; @@ -14,7 +14,7 @@ body { } .container { - max-width: 900px; + /* max-width: 900px; */ margin: 0 auto; padding: 30px; } @@ -101,6 +101,7 @@ h1 { display: flex; justify-content: space-between; align-items: center; + /* justify-content: center; */ margin-bottom: 20px; } @@ -138,6 +139,14 @@ h1 { background-color: #A03C52; } +.large-mood-text { + font-size: 8rem; +} + +.large-actions-text { + font-size: 3rem; +} + /* Mood Log List */ .moodCollection { list-style: none; @@ -226,9 +235,35 @@ h1 { margin: 5px 0; } +.first-box { + float: left; + width: 20%; + height: 20%; +} +.box { + float: left; + width: 40%; + height: 20%; +} +.logout-box { + float: left; + width: 10%; + /* height: 20%; */ +} +body.happy { + background-color: #FFE680; +} + +body.sad { + background-color: #7DA3DA; +} + +body.neutral { + background-color: #FBE3D2; +} diff --git a/server.js b/server.js index 5dd3217..f0b55c3 100644 --- a/server.js +++ b/server.js @@ -11,6 +11,7 @@ var flash = require('connect-flash'); var morgan = require('morgan'); // Logging var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); // See whats coming with req + var session = require('cookie-session'); // This is to deploy it var configDB = require('./config/database.js'); diff --git a/views/profile.ejs b/views/profile.ejs index 04f5251..ef3cd73 100644 --- a/views/profile.ejs +++ b/views/profile.ejs @@ -8,25 +8,28 @@ - + + <%= backgroundColor %> +
- +
-
+
+

Mood Tracker Profile

+

What should you do today?

+

Enter your mood to find out!

+
+
-

Add a mood

<% if (user) { %>
- +
@@ -44,6 +47,25 @@
<% } %> +
+ + +
+ Logout +
+ +
+ +
+ <% if (moodCollection.length > 0) { %> + <% const mainMoodData = moodCollection[moodCollection.length - 1]; %> +

<%= mainMoodData.mood %>

+

Last logged date: <%= mainMoodData.date %>

+

<%= mainMoodData.actions %>

+ <% } else { %> +

Enter your mood above

+ <% } %> +
<% }); %> -
+