Skip to content

Commit

Permalink
Refactor dashboards.go
Browse files Browse the repository at this point in the history
Signed-off-by: felix.gateru <[email protected]>
  • Loading branch information
felixgateru committed Feb 5, 2024
1 parent 4bb8f0e commit 2a7b52b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/ui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

type config struct {
LogLevel string `env:"MG_UI_LOG_LEVEL" envDefault:"debug"`
Port string `env:"MG_UI_PORT" envDefault:"9095"`
Port string `env:"MG_UI_PORT" envDefault:"9095ma"`
InstanceID string `env:"MG_UI_INSTANCE_ID" envDefault:""`
HTTPAdapterURL string `env:"MG_HTTP_ADAPTER_URL" envDefault:"http://localhost:8008"`
ReaderURL string `env:"MG_READER_URL" envDefault:"http://localhost:9007"`
Expand Down
2 changes: 1 addition & 1 deletion docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MG_USERS_URL=http://localhost:9002
MG_INVITATIONS_URL=http://localhost:9020
MG_DOMAINS_URL = http://localhost:8189
MG_BOOTSTRAP_URL=http://localhost:9013
MG_UI_HOST_URL=http://localhost:9096
MG_UI_HOST_URL=http://localhost:9095
MG_UI_VERIFICATION_TLS=false
MG_UI_CONTENT_TYPE = application/senml+json
MG_UI_INSTANCE_ID=
Expand Down
10 changes: 5 additions & 5 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
version: "3.7"

networks:
magistrala-ui-net:
magistrala-base-net:
driver: bridge

volumes:
Expand All @@ -13,12 +13,12 @@ volumes:
services:
ui:
image: magistrala/ui:${MG_RELEASE_TAG}
container_name: magistrala-ui-standalone
container_name: magistrala-ui
restart: on-failure
ports:
- ${MG_UI_PORT}:${MG_UI_PORT}
networks:
- magistrala-ui-net
- magistrala-base-net
environment:
MG_UI_LOG_LEVEL: ${MG_UI_LOG_LEVEL}
MG_UI_PORT: ${MG_UI_PORT}
Expand All @@ -38,13 +38,13 @@ services:

ui-db:
image: postgres:16.1-alpine
container_name: magistrala-ui-standalone-db
container_name: magistrala-ui-db
restart: on-failure
command: postgres -c "max_connections=${MG_POSTGRES_MAX_CONNECTIONS}"
ports:
- 6044:5432
networks:
- magistrala-ui-net
- magistrala-base-net
volumes:
- magistrala-ui-db-volume:/var/lib/postgresql/data
environment:
Expand Down
14 changes: 7 additions & 7 deletions ui/dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
)

type Dashboard struct {
DashboardID string `json:"dashboard_id,omitempty" db:"dashboard_id"`
CreatedBy string `json:"created_by,omitempty" db:"created_by"`
DashboardName string `json:"dashboard_name,omitempty" db:"dashboard_name"`
DashboardID string `json:"dashboard_id" db:"dashboard_id"`
CreatedBy string `json:"created_by" db:"created_by"`
DashboardName string `json:"dashboard_name" db:"dashboard_name"`
Description string `json:"description,omitempty" db:"description"`
Metadata string `json:"metadata,omitempty" db:"metadata"`
Layout string `json:"layout,omitempty" db:"layout"`
CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"`
Layout string `json:"layout" db:"layout"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at"`
}

Expand All @@ -34,10 +34,10 @@ type DashboardPageMeta struct {
}

type DashboardReq struct {
DashboardName string `json:"dashboard_name,omitempty"`
DashboardName string `json:"dashboard_name"`
Description string `json:"description,omitempty"`
Metadata string `json:"metadata,omitempty"`
Layout string `json:"layout,omitempty"`
Layout string `json:"layout"`
}

type DashboardRepository interface {
Expand Down
1 change: 0 additions & 1 deletion ui/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2393,7 +2393,6 @@ func (us *uiService) CreateDashboard(token string, dashboardReq DashboardReq) ([
Metadata: dashboardReq.Metadata,
Layout: dashboardReq.Layout,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}

if err = us.drepo.Create(context.Background(), dashboard); err != nil {
Expand Down

0 comments on commit 2a7b52b

Please sign in to comment.