Commit 1fa7444c authored by Sonja Happ's avatar Sonja Happ
Browse files

Add height parameter to dashboard data model #36

parent 96499671
......@@ -145,6 +145,8 @@ type Dashboard struct {
Name string `json:"name" gorm:"not null"`
// Grid of dashboard
Grid int `json:"grid" gorm:"default:15"`
// Height of dashboard
Height int `json:"height"`
// ID of scenario to which dashboard belongs
ScenarioID uint `json:"scenarioID"`
// Widgets that belong to dashboard
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -70,8 +70,9 @@ func (d *Dashboard) update(modifiedDab Dashboard) error {
db := database.GetDB()
err := db.Model(d).Updates(map[string]interface{}{
"Name": modifiedDab.Name,
"Grid": modifiedDab.Grid,
"Name": modifiedDab.Name,
"Grid": modifiedDab.Grid,
"Height": modifiedDab.Height,
}).Error
return err
......
......@@ -41,6 +41,7 @@ var router *gin.Engine
type DashboardRequest struct {
Name string `json:"name,omitempty"`
Grid int `json:"grid,omitempty"`
Height int `json:"height,omitempty"`
ScenarioID uint `json:"scenarioID,omitempty"`
}
......
......@@ -30,12 +30,14 @@ var validate *validator.Validate
type validNewDashboard struct {
Name string `form:"Name" validate:"required"`
Grid int `form:"Grid" validate:"required"`
Height int `form:"Height" validate:"omitempty"`
ScenarioID uint `form:"ScenarioID" validate:"required"`
}
type validUpdatedDashboard struct {
Name string `form:"Name" validate:"omitempty" json:"name"`
Grid int `form:"Grid" validate:"omitempty" json:"grid"`
Name string `form:"Name" validate:"omitempty" json:"name"`
Height int `form:"Height" validate:"omitempty" json:"height"`
Grid int `form:"Grid" validate:"omitempty" json:"grid"`
}
type addDashboardRequest struct {
......@@ -63,6 +65,7 @@ func (r *addDashboardRequest) createDashboard() Dashboard {
s.Name = r.Dashboard.Name
s.Grid = r.Dashboard.Grid
s.Height = r.Dashboard.Height
s.ScenarioID = r.Dashboard.ScenarioID
return s
......@@ -80,5 +83,9 @@ func (r *updateDashboardRequest) updatedDashboard(oldDashboard Dashboard) Dashbo
s.Grid = r.Dashboard.Grid
}
if r.Dashboard.Height > 0 {
s.Height = r.Dashboard.Height
}
return s
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment