Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
Innoveria Bachelor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Daniel Høyland
Innoveria Bachelor
Commits
1947dacb
Commit
1947dacb
authored
1 year ago
by
Daniel Høyland
Browse files
Options
Downloads
Patches
Plain Diff
fixed some bugs so that adding and edit sensor is possible
parent
c34603c7
Branches
sensorManagement
Branches containing commit
No related tags found
2 merge requests
!71
Dev branch
,
!69
fixed some bugs so that adding and edit sensor is possible
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Backend/API/handlers/newHotdrop.go
+2
-1
2 additions, 1 deletion
Backend/API/handlers/newHotdrop.go
Frontend/power-tracker/src/pages/ManageSensors.tsx
+25
-17
25 additions, 17 deletions
Frontend/power-tracker/src/pages/ManageSensors.tsx
with
27 additions
and
18 deletions
Backend/API/handlers/newHotdrop.go
+
2
−
1
View file @
1947dacb
...
...
@@ -58,8 +58,9 @@ func NewHotDrop(w http.ResponseWriter, r *http.Request) {
w
.
WriteHeader
(
http
.
StatusBadRequest
)
return
}
department
:=
0
//check if it is intended to have a department, if not, skip
if
data
.
DepartmentName
!=
""
{
if
data
.
DepartmentName
!=
""
&&
data
.
DepartmentName
!=
" "
{
department
,
err
=
other
.
GetDepartmentIdByName
(
data
.
DepartmentName
,
building
)
if
err
!=
nil
{
log
.
Println
(
err
.
Error
())
...
...
This diff is collapsed.
Click to expand it.
Frontend/power-tracker/src/pages/ManageSensors.tsx
+
25
−
17
View file @
1947dacb
...
...
@@ -349,7 +349,8 @@ function ManageSensors() {
<
FormItem
>
<
FormLabel
>
EUI
</
FormLabel
>
<
FormControl
>
<
Input
placeholder
=
"EUI"
{
...
field
}
/>
{
/* REMOVED {...field} from the under*/
}
<
Input
placeholder
=
"EUI"
/>
</
FormControl
>
<
FormDescription
>
The id code found under "MAC" on sensor
...
...
@@ -364,7 +365,8 @@ function ManageSensors() {
<
FormItem
>
<
FormLabel
>
Name
</
FormLabel
>
<
FormControl
>
<
Input
placeholder
=
"Name"
{
...
field
}
/>
{
/* REMOVED {...field} from the under*/
}
<
Input
placeholder
=
"Name"
/>
</
FormControl
>
</
FormItem
>
)
}
...
...
@@ -376,7 +378,8 @@ function ManageSensors() {
<
FormItem
>
<
FormLabel
>
Nr
</
FormLabel
>
<
FormControl
>
<
Input
placeholder
=
"Nr"
{
...
field
}
/>
{
/* REMOVED {...field} from the under*/
}
<
Input
placeholder
=
"Nr"
/>
</
FormControl
>
<
FormDescription
>
Custom machine nr
...
...
@@ -390,7 +393,8 @@ function ManageSensors() {
render
=
{
({
field
})
=>
(
<
FormItem
>
<
FormLabel
>
Building
</
FormLabel
>
<
Select
onValueChange
=
{
field
.
onChange
}
defaultValue
=
{
field
.
value
}
>
{
/* REMOVED defaultValue={field.value} from the under*/
}
<
Select
onValueChange
=
{
field
.
onChange
}
>
<
FormControl
>
<
SelectTrigger
>
<
SelectValue
placeholder
=
"Building"
/>
...
...
@@ -409,26 +413,28 @@ function ManageSensors() {
)
}
/>
{
/* If a building is selected, render department picker */
}
{
(
watchBuilding
!=
"
null
"
)
?
(
{
(
watchBuilding
!=
""
)
?
(
<
FormField
control
=
{
form
.
control
}
name
=
'dept'
render
=
{
({
field
})
=>
(
<
FormItem
>
<
FormLabel
>
Department
</
FormLabel
>
<
Select
onValueChange
=
{
field
.
onChange
}
defaultValue
=
{
field
.
value
}
>
{
/* REMOVED defaultValue={field.value} from the under*/
}
<
Select
onValueChange
=
{
field
.
onChange
}
>
<
FormControl
>
<
SelectTrigger
>
<
SelectValue
placeholder
=
"Department"
/>
</
SelectTrigger
>
</
FormControl
>
<
SelectContent
>
<
SelectItem
key
=
{
1
}
value
=
{
"
"
}
>
</
SelectItem
>
{
buildDepData
.
buildingDepartmentData
.
map
((
building
,
index
)
=>
{
if
(
index
==
0
)
return
(<></>)
if
(
building
.
building
.
name
===
watchBuilding
)
return
(
<
div
key
=
{
index
}
>
{
building
.
departments
.
map
((
dept
,
index
)
=>
{
if
(
index
==
0
)
return
(<></>)
if
(
index
==
-
1
)
return
(<></>)
else
return
(
<
SelectItem
key
=
{
index
}
value
=
{
dept
.
name
}
>
{
dept
.
name
}
</
SelectItem
>
)
...
...
@@ -451,7 +457,8 @@ function ManageSensors() {
<
FormItem
>
<
FormLabel
>
Expected power usage
</
FormLabel
>
<
FormControl
>
<
Input
type
=
"number"
placeholder
=
"0"
{
...
field
}
/>
{
/* REMOVED {...field} from the under*/
}
<
Input
type
=
"number"
placeholder
=
"0"
/>
</
FormControl
>
</
FormItem
>
)
}
...
...
@@ -517,7 +524,7 @@ function ManageSensors() {
<
FormItem
>
<
FormLabel
>
EUI
</
FormLabel
>
<
FormControl
>
<
Input
placeholder
=
{
machine
.
eui
}
{
...
field
}
/>
<
Input
defaultValue
=
{
machine
.
eui
}
{
...
field
}
/>
</
FormControl
>
</
FormItem
>
)
}
...
...
@@ -529,7 +536,7 @@ function ManageSensors() {
<
FormItem
>
<
FormLabel
>
Name
</
FormLabel
>
<
FormControl
>
<
Input
placeholder
=
{
machine
.
machine_name
}
{
...
field
}
/>
<
Input
defaultValue
=
{
machine
.
machine_name
}
{
...
field
}
/>
</
FormControl
>
</
FormItem
>
)
}
...
...
@@ -541,7 +548,7 @@ function ManageSensors() {
<
FormItem
>
<
FormLabel
>
Nr
</
FormLabel
>
<
FormControl
>
<
Input
placeholder
=
{
machine
.
machineNr
}
{
...
field
}
/>
<
Input
defaultValue
=
{
machine
.
machineNr
}
{
...
field
}
/>
</
FormControl
>
</
FormItem
>
)
}
...
...
@@ -552,10 +559,10 @@ function ManageSensors() {
render
=
{
({
field
})
=>
(
<
FormItem
>
<
FormLabel
>
Building
</
FormLabel
>
<
Select
onValueChange
=
{
field
.
onChange
}
defaultValue
=
{
field
.
valu
e
}
>
<
Select
onValueChange
=
{
field
.
onChange
}
defaultValue
=
{
machine
.
building_nam
e
}
>
<
FormControl
>
<
SelectTrigger
>
<
SelectValue
placeholder
=
{
machine
.
building_name
}
/>
<
SelectValue
/>
</
SelectTrigger
>
</
FormControl
>
<
SelectContent
>
...
...
@@ -576,22 +583,23 @@ function ManageSensors() {
render
=
{
({
field
})
=>
(
<
FormItem
>
<
FormLabel
>
Department
</
FormLabel
>
<
Select
onValueChange
=
{
field
.
onChange
}
defaultValue
=
{
field
.
valu
e
}
>
<
Select
onValueChange
=
{
field
.
onChange
}
defaultValue
=
{
machine
.
department_nam
e
}
>
<
FormControl
>
<
SelectTrigger
>
<
SelectValue
placeholder
=
{
machine
.
department_name
}
/>
<
SelectValue
/>
</
SelectTrigger
>
</
FormControl
>
<
FormDescription
>
{
"
Please select building first to change department : )
"
}
</
FormDescription
>
<
SelectContent
>
<
SelectItem
key
=
{
1
}
value
=
{
"
"
}
></
SelectItem
>
{
buildDepData
.
buildingDepartmentData
.
map
((
building
,
index
)
=>
{
if
(
index
==
0
)
return
(<></>)
if
(
building
.
building
.
name
===
watchBuilding
)
return
(
<
div
key
=
{
index
}
>
{
building
.
departments
.
map
((
dept
,
index
)
=>
{
if
(
index
==
0
)
return
(<></>)
if
(
index
==
-
1
)
return
(<></>)
else
return
(
<
SelectItem
key
=
{
index
}
value
=
{
dept
.
name
}
>
{
dept
.
name
}
</
SelectItem
>
)
...
...
@@ -612,7 +620,7 @@ function ManageSensors() {
<
FormItem
>
<
FormLabel
>
Expected power usage
</
FormLabel
>
<
FormControl
>
<
Input
type
=
"number"
placeholder
=
"0"
{
...
field
}
/>
<
Input
type
=
"number"
defaultValue
=
{
machine
.
expected_use
}
{
...
field
}
/>
</
FormControl
>
</
FormItem
>
)
}
...
...
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