diff --git a/index.html b/index.html index c84dd96f99fb9ee8de4656b7da4588ffa6d26c85..9b921b0d976fa662331b5322ad650fc8ca0cd5ff 100644 --- a/index.html +++ b/index.html @@ -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) { diff --git a/index.js b/index.js index dfb3b72791fcaa17082d6ba3f0d9478f85e9ad3e..639f14207f61e062e375c2ba9fafec054588a917 100644 --- a/index.js +++ b/index.js @@ -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);