Skip to content
Snippets Groups Projects
Commit 9a8beb40 authored by Miklosimate's avatar Miklosimate
Browse files

Cleanup

parent cf1d5da7
Branches
No related tags found
No related merge requests found
......@@ -58,7 +58,6 @@
<tr>
<th>ID</th>
<th>State</th>
<th>Count</th>
</tr>
</thead>
<tbody id="deviceTableBody">
......@@ -103,17 +102,19 @@
const row = document.createElement('tr');
const idCell = document.createElement('td');
const stateCell = document.createElement('td');
const dotCell = document.createElement('td'); // New cell for dots
idCell.textContent = device.id;
stateCell.textContent = device.state;
dotCell.textContent = device.current_cnt
// Create dots based on current_cnt and numberOfMeasurements
const numberOfMeasurements = document.getElementById('numberOfMeasurements').value;
const dotContainer = document.createElement('div');
dotContainer.style.display = 'flex';
for (let i = 0; i < numberOfMeasurements; i++) {
const dot = document.createElement('div');
dot.style.width = '10px';
......@@ -134,8 +135,7 @@
// Append cells to the row
row.appendChild(idCell);
row.appendChild(stateCell);
dotCell.appendChild(dotContainer);
row.appendChild(dotCell);
deviceTableBody.appendChild(row);
});
} catch (error) {
......
......@@ -8,13 +8,11 @@ const fs = require('fs')
const bodyParser = require('body-parser');
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.json({limit: '100mb'})); // Use express.json() to parse JSON bodies
app.use(bodyParser.json({ limit: '5mb' })); // Set maximum payload size to 5 MB
app.use(express.json({limit: '100mb'}));
app.use(bodyParser.json({ limit: '5mb' }));
app.use(bodyParser.urlencoded({ extended: true, limit: '5mb' }));
// Use body-parser to parse plain text request bodies
const connectedDevices = {};
let serverReady = false;
let serverConfig = {
......@@ -101,14 +99,7 @@ app.post('/json/:deviceID/:f_n', (req, res) => {
if (!fs.existsSync(measurementsFolderPath)) {
fs.mkdirSync(measurementsFolderPath, { recursive: true });
}
// Get filename from request body
console.log("The body of the request is:")
console.log(req.body)
console.log("The parameters are:")
console.log(req.params)
const { filename, ...jsonData } = req.body;
console.log(`The filename should be: ${filename}`)
// Generate unique filename if not provided
const fileName = f_n + '.json' || deviceID + '.json';
......@@ -116,10 +107,6 @@ app.post('/json/:deviceID/:f_n', (req, res) => {
// Path to save the file
const filePath = path.join(measurementsFolderPath, fileName);
// Write JSON data to the file
fs.writeFile(filePath, JSON.stringify(jsonData, null, 2), (err) => {
if (err) {
console.error('Error saving file:', err);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment