Skip to content

Add dashboard list command #45

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

Merged
merged 8 commits into from
Oct 12, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove share details
  • Loading branch information
polldo committed Oct 12, 2021
commit 71113a22621d81f36d2cd52aaae7113b44bdc886
28 changes: 11 additions & 17 deletions command/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,29 @@

package dashboard

import iotclient "github.com/arduino/iot-client-go"
import (
iotclient "github.com/arduino/iot-client-go"
)

// DashboardInfo contains the most interesting
// information, in string format, of an Arduino IoT Cloud dashboard.
type DashboardInfo struct {
Name string `json:"name"`
ID string `json:"id"`
SharedBy string `json:"shared_by"`
SharedWith []string `json:"shared_with"`
UpdatedAt string `json:"updated_at"`
Widgets []string `json:"widgets"`
Name string `json:"name"`
ID string `json:"id"`
UpdatedAt string `json:"updated_at"`
Widgets []string `json:"widgets"`
}

func getDashboardInfo(dashboard *iotclient.ArduinoDashboardv2) *DashboardInfo {
var shares []string
for _, s := range dashboard.SharedWith {
shares = append(shares, s.Username)
}
var widgets []string
for _, w := range dashboard.Widgets {
widgets = append(widgets, w.Name)
}
info := &DashboardInfo{
Name: dashboard.Name,
ID: dashboard.Id,
SharedBy: dashboard.SharedBy.Username,
SharedWith: shares,
UpdatedAt: dashboard.UpdatedAt.String(),
Widgets: widgets,
Name: dashboard.Name,
ID: dashboard.Id,
UpdatedAt: dashboard.UpdatedAt.String(),
Widgets: widgets,
}
return info
}