Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SensorDataCollectorAppServer_IOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Miklósi Máté
SensorDataCollectorAppServer_IOS
Commits
9a8beb40
Commit
9a8beb40
authored
1 year ago
by
Miklosimate
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup
parent
cf1d5da7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
index.html
+5
-5
5 additions, 5 deletions
index.html
index.js
+2
-15
2 additions, 15 deletions
index.js
with
7 additions
and
20 deletions
index.html
+
5
−
5
View file @
9a8beb40
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
index.js
+
2
−
15
View file @
9a8beb40
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment