Skip to content
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

feat(geo-widget): backend storage implementation for geo widget #19811

Merged
merged 27 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
42085b2
feat(geo-widget): backend storage implementation for chronograf geo w…
dubsky Oct 23, 2020
080fb8f
Merge branch 'master' of github.com:influxdata/influxdb into feat/geo…
dubsky Oct 26, 2020
c42c81f
fix: formatting & swagger go compatibility check
dubsky Oct 26, 2020
b268e33
fix: update http/swagger.yml formatting
dubsky Oct 26, 2020
74d2ee4
Merge branch 'master' of github.com:influxdata/influxdb into feat/geo…
dubsky Oct 30, 2020
ac43ba9
fix: inconsistent required property
dubsky Oct 30, 2020
83c4c1d
Merge remote-tracking branch 'origin/feat/geo-widget-backend' into fe…
dubsky Oct 30, 2020
33efc5c
test: verify geo configuration serialization
dubsky Nov 9, 2020
b8356bd
feat(geo-widget): pkger support added
dubsky Nov 25, 2020
3f1ab02
Merge branch 'master' into feat/geo-widget-backend
ivankudibal Dec 18, 2020
05b9701
feat(geo-widget): backend storage implementation for chronograf geo w…
dubsky Oct 23, 2020
2304ce3
fix: formatting & swagger go compatibility check
dubsky Oct 26, 2020
5fe1825
fix: update http/swagger.yml formatting
dubsky Oct 26, 2020
780af91
fix: inconsistent required property
dubsky Oct 30, 2020
affbc48
test: verify geo configuration serialization
dubsky Nov 9, 2020
c31b45c
feat(geo-widget): pkger support added
dubsky Nov 25, 2020
e211d8f
Merge branch 'feat/geo-widget-backend' of github.com:dubsky/influxdb …
ivankudibal Dec 18, 2020
a9dc6c6
build: save cache and artifacts after gotest in CI (#20370)
danxmoran Dec 18, 2020
a9e0e5a
fix(cmd/influx): improve CLI error returned on org-not-found (#20387)
danxmoran Dec 21, 2020
c67ecc4
fix: don't duplicate text in task errors (#20380)
danxmoran Dec 21, 2020
ade3008
refactor: simplify how we set the top-level influxd logger (#20374)
danxmoran Dec 21, 2020
fb8def2
Merge branch 'master' into feat/geo-widget-backend
dubsky Dec 22, 2020
a22b4e1
Merge branch 'master' into feat/geo-widget-backend
dubsky Jan 8, 2021
4e60fdf
Merge branch 'master' into feat/geo-widget-backend
ivankudibal Jan 11, 2021
ba33d29
Merge branch 'master' into feat/geo-widget-backend
dubsky Jan 12, 2021
f8452d5
Merge branch 'master' into feat/geo-widget-backend
ivankudibal Jan 13, 2021
7827a11
Merge branch 'master' into feat/geo-widget-backend
danxmoran Jan 13, 2021
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
60 changes: 60 additions & 0 deletions dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ const (
ViewPropertyTypeXY = "xy"
ViewPropertyTypeMosaic = "mosaic"
ViewPropertyTypeBand = "band"
ViewPropertyTypeGeo = "geo"
)

// ViewProperties is used to mark other structures as conforming to a View.
Expand Down Expand Up @@ -450,6 +451,12 @@ func UnmarshalViewPropertiesJSON(b []byte) (ViewProperties, error) {
return nil, err
}
vis = gv
case ViewPropertyTypeGeo:
kristinarobinson marked this conversation as resolved.
Show resolved Hide resolved
var gvw GeoViewProperties
if err := json.Unmarshal(v.B, &gvw); err != nil {
return nil, err
}
vis = gvw
case ViewPropertyTypeTable:
var tv TableViewProperties
if err := json.Unmarshal(v.B, &tv); err != nil {
Expand Down Expand Up @@ -549,6 +556,14 @@ func MarshalViewPropertiesJSON(v ViewProperties) ([]byte, error) {

GaugeViewProperties: vis,
}
case GeoViewProperties:
s = struct {
Shape string `json:"shape"`
GeoViewProperties
}{
Shape: "chronograf-v2",
GeoViewProperties: vis,
}
case XYViewProperties:
s = struct {
Shape string `json:"shape"`
Expand Down Expand Up @@ -950,6 +965,49 @@ type GaugeViewProperties struct {
ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"`
}

// Geographical coordinates
type Datum struct {
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
}

// Single visualization layer properties of a chronograf map widget
type GeoLayer struct {
Type string `json:"type"`
RadiusField string `json:"radiusField"`
ColorField string `json:"colorField"`
IntensityField string `json:"intensityField"`
// circle layer properties
ViewColors []ViewColor `json:"colors"`
Radius int32 `json:"radius"`
Blur int32 `json:"blur"`
RadiusDimension Axis `json:"radiusDimension,omitempty"`
ColorDimension Axis `json:"colorDimension,omitempty"`
IntensityDimension Axis `json:"intensityDimension,omitempty"`
InterpolateColors bool `json:"interpolateColors"`
// track layer properties
TrackWidth int32 `json:"trackWidth"`
Speed int32 `json:"speed"`
RandomColors bool `json:"randomColors"`
// point layer properties
IsClustered bool `json:"isClustered"`
}

// GeoViewProperties represents options for map view in Chronograf
type GeoViewProperties struct {
Type string `json:"type"`
Queries []DashboardQuery `json:"queries"`
Center Datum `json:"center"`
Zoom float64 `json:"zoom"`
MapStyle string `json:"mapStyle"`
AllowPanAndZoom bool `json:"allowPanAndZoom"`
DetectCoordinateFields bool `json:"detectCoordinateFields"`
ViewColor []ViewColor `json:"colors"`
GeoLayers []GeoLayer `json:"layers"`
Note string `json:"note"`
ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"`
}

// TableViewProperties represents options for table view in Chronograf
type TableViewProperties struct {
Type string `json:"type"`
Expand Down Expand Up @@ -997,6 +1055,7 @@ func (HeatmapViewProperties) viewProperties() {}
func (ScatterViewProperties) viewProperties() {}
func (MosaicViewProperties) viewProperties() {}
func (GaugeViewProperties) viewProperties() {}
func (GeoViewProperties) viewProperties() {}
func (TableViewProperties) viewProperties() {}
func (MarkdownViewProperties) viewProperties() {}
func (LogViewProperties) viewProperties() {}
Expand All @@ -1011,6 +1070,7 @@ func (v HeatmapViewProperties) GetType() string { return v.Type }
func (v ScatterViewProperties) GetType() string { return v.Type }
func (v MosaicViewProperties) GetType() string { return v.Type }
func (v GaugeViewProperties) GetType() string { return v.Type }
func (v GeoViewProperties) GetType() string { return v.Type }
func (v TableViewProperties) GetType() string { return v.Type }
func (v MarkdownViewProperties) GetType() string { return v.Type }
func (v LogViewProperties) GetType() string { return v.Type }
Expand Down
189 changes: 167 additions & 22 deletions dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ func TestView_MarshalJSON(t *testing.T) {
wants wants
}{
{
name: "xy",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Is there a reason we are updating tests for xy in this pr? This seems a bit out of scope for geo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I did it because I have been adding extra test case specific to geo as requested. I wanted to make the source file to be more readable and make it obvious what are the individual cases testing. This individual addition means that you will get 'xy' or 'geo' serialization failed message if something goes wrong.

args: args{
view: platform.View{
ViewContents: platform.ViewContents{
ID: platformtesting.MustIDBase16("f01dab1ef005ba11"),
Name: "hello",
Name: "XY widget",
},
Properties: platform.XYViewProperties{
Type: "xy",
Expand All @@ -37,37 +38,182 @@ func TestView_MarshalJSON(t *testing.T) {
json: `
{
"id": "f01dab1ef005ba11",
"name": "hello",
"name": "XY widget",
"properties": {
"shape": "chronograf-v2",
"queries": null,
"axes": null,
"type": "xy",
"colors": null,
"legend": {},
"geom": "",
"colors": null,
"note": "",
"showNoteWhenEmpty": false,
"xColumn": "",
"generateXAxisTicks": null,
"xTotalTicks": 0,
"xTickStart": 0,
"xTickStep": 0,
"yColumn": "",
"generateYAxisTicks": null,
"yTotalTicks": 0,
"yTickStart": 0,
"yTickStep": 0,
"xColumn": "",
"generateXAxisTicks": null,
"xTotalTicks": 0,
"xTickStart": 0,
"xTickStep": 0,
"yColumn": "",
"generateYAxisTicks": null,
"yTotalTicks": 0,
"yTickStart": 0,
"yTickStep": 0,
"shadeBelow": false,
"position": "",
"timeFormat": "",
"hoverDimension": "",
"legendColorizeRows": false,
"legendOpacity": 0,
"legendOrientationThreshold": 0
"position": "",
"timeFormat": "",
"hoverDimension": "",
"legendColorizeRows": false,
"legendOpacity": 0,
"legendOrientationThreshold": 0
}
}
`,
}`,
},
},
{
name: "geo",
args: args{
view: platform.View{
ViewContents: platform.ViewContents{
ID: platformtesting.MustIDBase16("e21da111ef005b11"),
Name: "Circle Map",
},
Properties: platform.GeoViewProperties{
Type: platform.ViewPropertyTypeGeo,
Zoom: 2,
Center: platform.Datum{Lat: 50.4, Lon: 10.1},
AllowPanAndZoom: true,
GeoLayers: []platform.GeoLayer{
{
Type: "circleMap",
RadiusField: "radius",
ColorField: "color",
Radius: 12,
Blur: 20,
RadiusDimension: platform.Axis{
Label: "Frequency",
Bounds: []string{"10", "20"},
Suffix: "m",
},
ColorDimension: platform.Axis{
Label: "Severity",
Bounds: []string{"10.0", "40"},
Suffix: "%",
},
ViewColors: []platform.ViewColor{{
Type: "min",
Hex: "#FF0000",
}, {
Hex: "#000000",
Value: 10,
}, {
Hex: "#FFFFFF",
Value: 40,
}},
IntensityDimension: platform.Axis{
Label: "Impact",
Prefix: "$",
},
InterpolateColors: true,
TrackWidth: 2,
Speed: 1.0,
IsClustered: true,
},
},
Note: "Some more information",
},
},
},
wants: wants{
json: `
{
"id": "e21da111ef005b11",
"name": "Circle Map",
"properties": {
"shape": "chronograf-v2",
"type": "geo",
"queries": null,
"center": {
"lat": 50.4,
"lon": 10.1
},
"zoom": 2,
"mapStyle": "",
"allowPanAndZoom": true,
"detectCoordinateFields": false,
"colors": null,
"layers": [
{
"type": "circleMap",
"radiusField": "radius",
"colorField": "color",
"intensityField": "",
"colors": [
{
"id": "",
"type": "min",
"hex": "#FF0000",
"name": "",
"value": 0
},
{
"id": "",
"type": "",
"hex": "#000000",
"name": "",
"value": 10
},
{
"id": "",
"type": "",
"hex": "#FFFFFF",
"name": "",
"value": 40
}
],
"radius": 12,
"blur": 20,
"radiusDimension": {
"bounds": [
"10",
"20"
],
"label": "Frequency",
"prefix": "",
"suffix": "m",
"base": "",
"scale": ""
},
"colorDimension": {
"bounds": [
"10.0",
"40"
],
"label": "Severity",
"prefix": "",
"suffix": "%",
"base": "",
"scale": ""
},
"intensityDimension": {
"bounds": null,
"label": "Impact",
"prefix": "$",
"suffix": "",
"base": "",
"scale": ""
},
"interpolateColors": true,
"trackWidth": 2,
"speed": 1,
"randomColors": false,
"isClustered": true
}
],
"note": "Some more information",
"showNoteWhenEmpty": false
}
}`,
},
},
}
Expand Down Expand Up @@ -99,6 +245,5 @@ func jsonEqual(s1, s2 string) (eq bool, err error) {
if err = json.Unmarshal([]byte(s2), &o2); err != nil {
return
}

return cmp.Equal(o1, o2), nil
}
Loading