mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Add height parameter to dashboard data model #36
This commit is contained in:
parent
9649967187
commit
1fa7444c66
7 changed files with 60 additions and 658 deletions
|
@ -145,6 +145,8 @@ type Dashboard struct {
|
||||||
Name string `json:"name" gorm:"not null"`
|
Name string `json:"name" gorm:"not null"`
|
||||||
// Grid of dashboard
|
// Grid of dashboard
|
||||||
Grid int `json:"grid" gorm:"default:15"`
|
Grid int `json:"grid" gorm:"default:15"`
|
||||||
|
// Height of dashboard
|
||||||
|
Height int `json:"height"`
|
||||||
// ID of scenario to which dashboard belongs
|
// ID of scenario to which dashboard belongs
|
||||||
ScenarioID uint `json:"scenarioID"`
|
ScenarioID uint `json:"scenarioID"`
|
||||||
// Widgets that belong to dashboard
|
// Widgets that belong to dashboard
|
||||||
|
|
250
doc/api/docs.go
250
doc/api/docs.go
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -70,8 +70,9 @@ func (d *Dashboard) update(modifiedDab Dashboard) error {
|
||||||
db := database.GetDB()
|
db := database.GetDB()
|
||||||
|
|
||||||
err := db.Model(d).Updates(map[string]interface{}{
|
err := db.Model(d).Updates(map[string]interface{}{
|
||||||
"Name": modifiedDab.Name,
|
"Name": modifiedDab.Name,
|
||||||
"Grid": modifiedDab.Grid,
|
"Grid": modifiedDab.Grid,
|
||||||
|
"Height": modifiedDab.Height,
|
||||||
}).Error
|
}).Error
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -41,6 +41,7 @@ var router *gin.Engine
|
||||||
type DashboardRequest struct {
|
type DashboardRequest struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Grid int `json:"grid,omitempty"`
|
Grid int `json:"grid,omitempty"`
|
||||||
|
Height int `json:"height,omitempty"`
|
||||||
ScenarioID uint `json:"scenarioID,omitempty"`
|
ScenarioID uint `json:"scenarioID,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,14 @@ var validate *validator.Validate
|
||||||
type validNewDashboard struct {
|
type validNewDashboard struct {
|
||||||
Name string `form:"Name" validate:"required"`
|
Name string `form:"Name" validate:"required"`
|
||||||
Grid int `form:"Grid" validate:"required"`
|
Grid int `form:"Grid" validate:"required"`
|
||||||
|
Height int `form:"Height" validate:"omitempty"`
|
||||||
ScenarioID uint `form:"ScenarioID" validate:"required"`
|
ScenarioID uint `form:"ScenarioID" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type validUpdatedDashboard struct {
|
type validUpdatedDashboard struct {
|
||||||
Name string `form:"Name" validate:"omitempty" json:"name"`
|
Name string `form:"Name" validate:"omitempty" json:"name"`
|
||||||
Grid int `form:"Grid" validate:"omitempty" json:"grid"`
|
Height int `form:"Height" validate:"omitempty" json:"height"`
|
||||||
|
Grid int `form:"Grid" validate:"omitempty" json:"grid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type addDashboardRequest struct {
|
type addDashboardRequest struct {
|
||||||
|
@ -63,6 +65,7 @@ func (r *addDashboardRequest) createDashboard() Dashboard {
|
||||||
|
|
||||||
s.Name = r.Dashboard.Name
|
s.Name = r.Dashboard.Name
|
||||||
s.Grid = r.Dashboard.Grid
|
s.Grid = r.Dashboard.Grid
|
||||||
|
s.Height = r.Dashboard.Height
|
||||||
s.ScenarioID = r.Dashboard.ScenarioID
|
s.ScenarioID = r.Dashboard.ScenarioID
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
@ -80,5 +83,9 @@ func (r *updateDashboardRequest) updatedDashboard(oldDashboard Dashboard) Dashbo
|
||||||
s.Grid = r.Dashboard.Grid
|
s.Grid = r.Dashboard.Grid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.Dashboard.Height > 0 {
|
||||||
|
s.Height = r.Dashboard.Height
|
||||||
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue