Skip to content

Commit

Permalink
Add missing fields to JSON endpoints for read and set
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-ceccato committed Feb 8, 2024
1 parent 6a07b8c commit 396e09f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion config.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ <h1>Configuration Page</h1>
<label for="pomoCount">Current pomo:</label>
<input type="number" id="pomoCount" name="pomoCount" required>

<label for="pomoTime">Pomo Time (seconds):</label>
<input type="number" id="focusTime" name="focusTime" required>

<label for="shortRestTime">Short Rest Time (seconds):</label>
<input type="number" id="shortRestTime" name="shortRestTime" required>

Expand Down Expand Up @@ -72,6 +75,7 @@ <h1>Configuration Page</h1>
document.getElementById('pomosBeforeLongRest').value = data.pomosBeforeLongRest;
document.getElementById('shortRestTime').value = data.shortRestTime;
document.getElementById('longRestTime').value = data.longRestTime;
document.getElementById('focusTime').value = data.focusTime;
document.getElementById('currTime').value = data.currTime;
document.getElementById('isResting').checked = data.isResting;
document.getElementById('isLongResting').checked = data.isLongResting;
Expand All @@ -86,11 +90,12 @@ <h1>Configuration Page</h1>
const shortRestTime = document.getElementById('shortRestTime').value;
const longRestTime = document.getElementById('longRestTime').value;
const currTime = document.getElementById('currTime').value;
const focusTime = document.getElementById('focusTime').value;
const isResting = document.getElementById('isResting').checked;
const isLongResting = document.getElementById('isLongResting').checked;
const pomoCount = document.getElementById('pomoCount').value;

// Example: Send the values to the server (you might want to use AJAX for this)
// Send the values to the server (you might want to use AJAX for this)
fetch('/save-config', {
method: 'POST',
headers: {
Expand All @@ -101,6 +106,7 @@ <h1>Configuration Page</h1>
shortRestTime,
longRestTime,
currTime,
focusTime,
pomoCount,
isResting,
isLongResting
Expand Down
3 changes: 3 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ getPomoStateJSON = () => {
pomoCount: pomoCount,
isResting: isResting,
isLongResting: isLongResting,
focusTime: focusTime,
shortRestTime: shortRestTime,
longRestTime: longRestTime,
timestamp: new Date().toISOString(),
};
};
Expand Down

0 comments on commit 396e09f

Please sign in to comment.