-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MG-94 - Add storage for dashboards #104
Conversation
1a749a9
to
c0a7326
Compare
27993e3
to
230edae
Compare
c0a7326
to
9743af1
Compare
2db28a2
to
9e93b0d
Compare
3e92b86
to
65ab229
Compare
9743af1
to
e687f0d
Compare
65ab229
to
e9c47a9
Compare
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
e9c47a9
to
1850085
Compare
ui/api/logging.go
Outdated
lm.logger.Warn("View dashboards failed to complete successfully", args...) | ||
return | ||
} | ||
lm.logger.Info("View dashboards completed successfully", args...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lm.logger.Info("View dashboards completed successfully", args...) | |
lm.logger.Info("View dashboard completed successfully", args...) |
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
2a7b52b
to
ff2ce8b
Compare
ui/service.go
Outdated
return btpl.Bytes(), errors.Wrap(ErrFailedRetrieveUserID, err) | ||
} | ||
|
||
entropy := rand.New(rand.NewSource(time.Now().UnixNano())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for uniformity of the id's I suggest you use the Magistrala format for uuid: https://github.com/absmach/magistrala/blob/main/pkg/uuid/uuid.go
postgres/dashboards.go
Outdated
|
||
// Retrieve all dashboards for a user using a user id. | ||
func (r *repo) RetrieveAll(ctx context.Context, page ui.DashboardPageMeta) (ui.DashboardPage, error) { | ||
q := `SELECT dashboard_id, created_by, dashboard_name, description, metadata, created_at, updated_at FROM dashboards WHERE created_by = :created_by LIMIT :limit OFFSET :offset` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ORDER BY created_at
to retrieve beginning with the latest dashboard
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
docker/docker-compose.yml
Outdated
restart: on-failure | ||
command: postgres -c "max_connections=${MG_POSTGRES_MAX_CONNECTIONS}" | ||
ports: | ||
- 6044:5432 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 6044:5432 | |
- 6042:5432 |
postgres/dashboards.go
Outdated
q := ` | ||
INSERT INTO dashboards (dashboard_id, created_by, dashboard_name, description, metadata, layout, created_at, updated_at) | ||
VALUES (:dashboard_id, :created_by, :dashboard_name, :description, :metadata, :layout, :created_at, :updated_at) | ||
RETURNING dashboard_id, created_by, dashboard_name, description, metadata, layout, created_at, updated_at` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RETURNING dashboard_id, created_by, dashboard_name, description, metadata, layout, created_at, updated_at` | |
RETURNING dashboard_id, created_by, dashboard_name, description, metadata, layout, created_at |
Signed-off-by: felix.gateru <[email protected]>
Signed-off-by: felix.gateru <[email protected]>
postgres/init.go
Outdated
dashboard_id VARCHAR(36) NOT NULL, | ||
created_by VARCHAR(36) NOT NULL, | ||
dashboard_name VARCHAR(255) NOT NULL, | ||
description TEXT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a dashboard
prefix for ID and name.
ui/api/endpoint.go
Outdated
} | ||
|
||
return uiRes{ | ||
code: http.StatusOK, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we do not return anything else, the correct code would be No Content. Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE.
postgres/init.go
Outdated
created_by VARCHAR(36) NOT NULL, | ||
dashboard_name VARCHAR(255) NOT NULL, | ||
description TEXT, | ||
metadata TEXT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For other entities it is added as the option for extension, but we probably do not need metadata for dashboards. Please remove.
Signed-off-by: felix.gateru <[email protected]>
* Add postgres storage to dashboards Signed-off-by: felix.gateru <[email protected]> * Implement CRUD operations for dashboards Signed-off-by: felix.gateru <[email protected]> * Add Dashboard Name as a database field Signed-off-by: felix.gateru <[email protected]> * Fix db bug Signed-off-by: felix.gateru <[email protected]> * Fix retreive all error Signed-off-by: felix.gateru <[email protected]> * Refactor list dashboars response Signed-off-by: felix.gateru <[email protected]> * Revert port configuration to default Signed-off-by: felix.gateru <[email protected]> * Fix list dashboards bug Signed-off-by: felix.gateru <[email protected]> * Enhance update request Signed-off-by: felix.gateru <[email protected]> * Add standalone config Signed-off-by: felix.gateru <[email protected]> * Add created and updated time stamps Signed-off-by: felix.gateru <[email protected]> * Refactor dashboards.go Signed-off-by: felix.gateru <[email protected]> * Change dashboard id from ulid to uuid Signed-off-by: felix.gateru <[email protected]> * Change config urls Signed-off-by: felix.gateru <[email protected]> * cleaning up Signed-off-by: felix.gateru <[email protected]> * Revert config urls Signed-off-by: felix.gateru <[email protected]> * Rename dashboard id and name Signed-off-by: felix.gateru <[email protected]> --------- Signed-off-by: felix.gateru <[email protected]>
* Add postgres storage to dashboards Signed-off-by: felix.gateru <[email protected]> * Implement CRUD operations for dashboards Signed-off-by: felix.gateru <[email protected]> * Add Dashboard Name as a database field Signed-off-by: felix.gateru <[email protected]> * Fix db bug Signed-off-by: felix.gateru <[email protected]> * Fix retreive all error Signed-off-by: felix.gateru <[email protected]> * Refactor list dashboars response Signed-off-by: felix.gateru <[email protected]> * Revert port configuration to default Signed-off-by: felix.gateru <[email protected]> * Fix list dashboards bug Signed-off-by: felix.gateru <[email protected]> * Enhance update request Signed-off-by: felix.gateru <[email protected]> * Add standalone config Signed-off-by: felix.gateru <[email protected]> * Add created and updated time stamps Signed-off-by: felix.gateru <[email protected]> * Refactor dashboards.go Signed-off-by: felix.gateru <[email protected]> * Change dashboard id from ulid to uuid Signed-off-by: felix.gateru <[email protected]> * Change config urls Signed-off-by: felix.gateru <[email protected]> * cleaning up Signed-off-by: felix.gateru <[email protected]> * Revert config urls Signed-off-by: felix.gateru <[email protected]> * Rename dashboard id and name Signed-off-by: felix.gateru <[email protected]> --------- Signed-off-by: felix.gateru <[email protected]>
* Add postgres storage to dashboards Signed-off-by: felix.gateru <[email protected]> * Implement CRUD operations for dashboards Signed-off-by: felix.gateru <[email protected]> * Add Dashboard Name as a database field Signed-off-by: felix.gateru <[email protected]> * Fix db bug Signed-off-by: felix.gateru <[email protected]> * Fix retreive all error Signed-off-by: felix.gateru <[email protected]> * Refactor list dashboars response Signed-off-by: felix.gateru <[email protected]> * Revert port configuration to default Signed-off-by: felix.gateru <[email protected]> * Fix list dashboards bug Signed-off-by: felix.gateru <[email protected]> * Enhance update request Signed-off-by: felix.gateru <[email protected]> * Add standalone config Signed-off-by: felix.gateru <[email protected]> * Add created and updated time stamps Signed-off-by: felix.gateru <[email protected]> * Refactor dashboards.go Signed-off-by: felix.gateru <[email protected]> * Change dashboard id from ulid to uuid Signed-off-by: felix.gateru <[email protected]> * Change config urls Signed-off-by: felix.gateru <[email protected]> * cleaning up Signed-off-by: felix.gateru <[email protected]> * Revert config urls Signed-off-by: felix.gateru <[email protected]> * Rename dashboard id and name Signed-off-by: felix.gateru <[email protected]> --------- Signed-off-by: felix.gateru <[email protected]>
* Add postgres storage to dashboards Signed-off-by: felix.gateru <[email protected]> * Implement CRUD operations for dashboards Signed-off-by: felix.gateru <[email protected]> * Add Dashboard Name as a database field Signed-off-by: felix.gateru <[email protected]> * Fix db bug Signed-off-by: felix.gateru <[email protected]> * Fix retreive all error Signed-off-by: felix.gateru <[email protected]> * Refactor list dashboars response Signed-off-by: felix.gateru <[email protected]> * Revert port configuration to default Signed-off-by: felix.gateru <[email protected]> * Fix list dashboards bug Signed-off-by: felix.gateru <[email protected]> * Enhance update request Signed-off-by: felix.gateru <[email protected]> * Add standalone config Signed-off-by: felix.gateru <[email protected]> * Add created and updated time stamps Signed-off-by: felix.gateru <[email protected]> * Refactor dashboards.go Signed-off-by: felix.gateru <[email protected]> * Change dashboard id from ulid to uuid Signed-off-by: felix.gateru <[email protected]> * Change config urls Signed-off-by: felix.gateru <[email protected]> * cleaning up Signed-off-by: felix.gateru <[email protected]> * Revert config urls Signed-off-by: felix.gateru <[email protected]> * Rename dashboard id and name Signed-off-by: felix.gateru <[email protected]> --------- Signed-off-by: felix.gateru <[email protected]>
* Add postgres storage to dashboards Signed-off-by: felix.gateru <[email protected]> * Implement CRUD operations for dashboards Signed-off-by: felix.gateru <[email protected]> * Add Dashboard Name as a database field Signed-off-by: felix.gateru <[email protected]> * Fix db bug Signed-off-by: felix.gateru <[email protected]> * Fix retreive all error Signed-off-by: felix.gateru <[email protected]> * Refactor list dashboars response Signed-off-by: felix.gateru <[email protected]> * Revert port configuration to default Signed-off-by: felix.gateru <[email protected]> * Fix list dashboards bug Signed-off-by: felix.gateru <[email protected]> * Enhance update request Signed-off-by: felix.gateru <[email protected]> * Add standalone config Signed-off-by: felix.gateru <[email protected]> * Add created and updated time stamps Signed-off-by: felix.gateru <[email protected]> * Refactor dashboards.go Signed-off-by: felix.gateru <[email protected]> * Change dashboard id from ulid to uuid Signed-off-by: felix.gateru <[email protected]> * Change config urls Signed-off-by: felix.gateru <[email protected]> * cleaning up Signed-off-by: felix.gateru <[email protected]> * Revert config urls Signed-off-by: felix.gateru <[email protected]> * Rename dashboard id and name Signed-off-by: felix.gateru <[email protected]> --------- Signed-off-by: felix.gateru <[email protected]>
What type of PR is this?
What does this do?
Adds postgress implementation for storage of dashboards
Which issue(s) does this PR fix/relate to?
Have you included tests for your changes?
Did you document any new/modified functionality?
Notes