2016-09-22 23:22:41 +00:00
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
2016-11-04 00:44:28 +00:00
|
|
|
"encoding/json"
|
2017-12-13 18:38:01 +00:00
|
|
|
"fmt"
|
2016-09-22 23:22:41 +00:00
|
|
|
|
|
|
|
"github.com/gogo/protobuf/proto"
|
2016-10-20 14:38:23 +00:00
|
|
|
"github.com/influxdata/chronograf"
|
2016-09-22 23:22:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
//go:generate protoc --gogo_out=. internal.proto
|
|
|
|
|
2017-12-16 22:09:37 +00:00
|
|
|
// MarshalBuild encodes a build to binary protobuf format.
|
2017-12-16 09:01:14 +00:00
|
|
|
func MarshalBuild(b chronograf.BuildInfo) ([]byte, error) {
|
2017-12-16 20:27:24 +00:00
|
|
|
return proto.Marshal(&BuildInfo{
|
|
|
|
Version: b.Version,
|
|
|
|
Commit: b.Commit,
|
|
|
|
})
|
2017-12-16 09:01:14 +00:00
|
|
|
}
|
2017-12-16 22:09:37 +00:00
|
|
|
|
|
|
|
// UnmarshalBuild decodes a build from binary protobuf data.
|
2017-12-16 09:01:14 +00:00
|
|
|
func UnmarshalBuild(data []byte, b *chronograf.BuildInfo) error {
|
2017-12-16 20:27:24 +00:00
|
|
|
var pb BuildInfo
|
|
|
|
if err := proto.Unmarshal(data, &pb); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
b.Version = pb.Version
|
|
|
|
b.Commit = pb.Commit
|
2017-12-16 09:01:14 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-10-06 04:26:39 +00:00
|
|
|
// MarshalSource encodes a source to binary protobuf format.
|
2016-10-20 14:38:23 +00:00
|
|
|
func MarshalSource(s chronograf.Source) ([]byte, error) {
|
2016-09-30 20:39:27 +00:00
|
|
|
return proto.Marshal(&Source{
|
2017-01-05 01:35:07 +00:00
|
|
|
ID: int64(s.ID),
|
|
|
|
Name: s.Name,
|
|
|
|
Type: s.Type,
|
|
|
|
Username: s.Username,
|
|
|
|
Password: s.Password,
|
2017-07-15 01:02:13 +00:00
|
|
|
SharedSecret: s.SharedSecret,
|
2017-01-05 01:35:07 +00:00
|
|
|
URL: s.URL,
|
2017-02-07 23:57:51 +00:00
|
|
|
MetaURL: s.MetaURL,
|
2017-01-05 01:35:07 +00:00
|
|
|
InsecureSkipVerify: s.InsecureSkipVerify,
|
|
|
|
Default: s.Default,
|
|
|
|
Telegraf: s.Telegraf,
|
2017-10-25 15:51:15 +00:00
|
|
|
Organization: s.Organization,
|
2017-11-03 18:21:21 +00:00
|
|
|
Role: s.Role,
|
2018-04-11 21:57:50 +00:00
|
|
|
DefaultRP: s.DefaultRP,
|
2016-09-30 20:39:27 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-10-06 04:26:39 +00:00
|
|
|
// UnmarshalSource decodes a source from binary protobuf data.
|
2016-10-20 14:38:23 +00:00
|
|
|
func UnmarshalSource(data []byte, s *chronograf.Source) error {
|
2016-09-30 20:39:27 +00:00
|
|
|
var pb Source
|
|
|
|
if err := proto.Unmarshal(data, &pb); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
s.ID = int(pb.ID)
|
|
|
|
s.Name = pb.Name
|
|
|
|
s.Type = pb.Type
|
|
|
|
s.Username = pb.Username
|
|
|
|
s.Password = pb.Password
|
2017-07-15 01:02:13 +00:00
|
|
|
s.SharedSecret = pb.SharedSecret
|
2016-10-25 15:20:06 +00:00
|
|
|
s.URL = pb.URL
|
2017-02-07 23:57:51 +00:00
|
|
|
s.MetaURL = pb.MetaURL
|
2017-01-05 01:35:07 +00:00
|
|
|
s.InsecureSkipVerify = pb.InsecureSkipVerify
|
2016-09-30 20:39:27 +00:00
|
|
|
s.Default = pb.Default
|
2016-11-18 19:13:32 +00:00
|
|
|
s.Telegraf = pb.Telegraf
|
2017-10-25 15:51:15 +00:00
|
|
|
s.Organization = pb.Organization
|
2017-11-03 18:21:21 +00:00
|
|
|
s.Role = pb.Role
|
2018-04-11 21:57:50 +00:00
|
|
|
s.DefaultRP = pb.DefaultRP
|
2016-09-30 20:39:27 +00:00
|
|
|
return nil
|
|
|
|
}
|
2016-09-30 23:46:28 +00:00
|
|
|
|
2016-10-06 04:26:39 +00:00
|
|
|
// MarshalServer encodes a server to binary protobuf format.
|
2016-10-20 14:38:23 +00:00
|
|
|
func MarshalServer(s chronograf.Server) ([]byte, error) {
|
2018-05-18 00:35:27 +00:00
|
|
|
var (
|
|
|
|
metadata []byte
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
metadata, err = json.Marshal(s.Metadata)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2016-09-30 23:46:28 +00:00
|
|
|
return proto.Marshal(&Server{
|
2018-03-13 23:50:32 +00:00
|
|
|
ID: int64(s.ID),
|
|
|
|
SrcID: int64(s.SrcID),
|
|
|
|
Name: s.Name,
|
|
|
|
Username: s.Username,
|
|
|
|
Password: s.Password,
|
|
|
|
URL: s.URL,
|
|
|
|
Active: s.Active,
|
|
|
|
Organization: s.Organization,
|
|
|
|
InsecureSkipVerify: s.InsecureSkipVerify,
|
2018-05-16 23:04:52 +00:00
|
|
|
Type: s.Type,
|
2018-05-18 00:35:27 +00:00
|
|
|
MetadataJSON: string(metadata),
|
2016-09-30 23:46:28 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-10-06 04:26:39 +00:00
|
|
|
// UnmarshalServer decodes a server from binary protobuf data.
|
2016-10-20 14:38:23 +00:00
|
|
|
func UnmarshalServer(data []byte, s *chronograf.Server) error {
|
2016-09-30 23:46:28 +00:00
|
|
|
var pb Server
|
|
|
|
if err := proto.Unmarshal(data, &pb); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-05-18 00:35:27 +00:00
|
|
|
s.Metadata = make(map[string]interface{})
|
|
|
|
if len(pb.MetadataJSON) > 0 {
|
2018-05-18 23:55:12 +00:00
|
|
|
if err := json.Unmarshal([]byte(pb.MetadataJSON), &s.Metadata); err != nil {
|
2018-05-18 00:35:27 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-30 23:46:28 +00:00
|
|
|
s.ID = int(pb.ID)
|
2016-10-03 17:41:50 +00:00
|
|
|
s.SrcID = int(pb.SrcID)
|
2016-09-30 23:46:28 +00:00
|
|
|
s.Name = pb.Name
|
|
|
|
s.Username = pb.Username
|
|
|
|
s.Password = pb.Password
|
|
|
|
s.URL = pb.URL
|
2017-04-20 23:15:37 +00:00
|
|
|
s.Active = pb.Active
|
2017-10-25 16:42:50 +00:00
|
|
|
s.Organization = pb.Organization
|
2018-03-13 23:50:32 +00:00
|
|
|
s.InsecureSkipVerify = pb.InsecureSkipVerify
|
2018-05-16 23:04:52 +00:00
|
|
|
s.Type = pb.Type
|
2016-09-30 23:46:28 +00:00
|
|
|
return nil
|
|
|
|
}
|
2016-10-06 04:26:39 +00:00
|
|
|
|
|
|
|
// MarshalLayout encodes a layout to binary protobuf format.
|
2016-10-20 14:38:23 +00:00
|
|
|
func MarshalLayout(l chronograf.Layout) ([]byte, error) {
|
2016-10-06 04:26:39 +00:00
|
|
|
cells := make([]*Cell, len(l.Cells))
|
|
|
|
for i, c := range l.Cells {
|
|
|
|
queries := make([]*Query, len(c.Queries))
|
|
|
|
for j, q := range c.Queries {
|
2016-11-29 21:04:54 +00:00
|
|
|
r := new(Range)
|
|
|
|
if q.Range != nil {
|
|
|
|
r.Upper, r.Lower = q.Range.Upper, q.Range.Lower
|
|
|
|
}
|
2016-10-06 04:26:39 +00:00
|
|
|
queries[j] = &Query{
|
2016-11-07 22:29:39 +00:00
|
|
|
Command: q.Command,
|
|
|
|
DB: q.DB,
|
|
|
|
RP: q.RP,
|
|
|
|
GroupBys: q.GroupBys,
|
2016-11-08 02:35:46 +00:00
|
|
|
Wheres: q.Wheres,
|
2016-11-29 21:04:54 +00:00
|
|
|
Label: q.Label,
|
|
|
|
Range: r,
|
2016-10-06 04:26:39 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-22 17:27:27 +00:00
|
|
|
|
2017-07-24 22:30:53 +00:00
|
|
|
axes := make(map[string]*Axis, len(c.Axes))
|
|
|
|
for a, r := range c.Axes {
|
|
|
|
axes[a] = &Axis{
|
2017-08-10 19:51:08 +00:00
|
|
|
Bounds: r.Bounds,
|
2017-08-10 19:56:01 +00:00
|
|
|
Label: r.Label,
|
2017-07-24 22:30:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-06 04:26:39 +00:00
|
|
|
cells[i] = &Cell{
|
|
|
|
X: c.X,
|
|
|
|
Y: c.Y,
|
|
|
|
W: c.W,
|
|
|
|
H: c.H,
|
2016-10-28 20:43:06 +00:00
|
|
|
I: c.I,
|
|
|
|
Name: c.Name,
|
2016-10-06 04:26:39 +00:00
|
|
|
Queries: queries,
|
2016-12-06 05:46:30 +00:00
|
|
|
Type: c.Type,
|
2017-07-24 22:30:53 +00:00
|
|
|
Axes: axes,
|
2016-10-06 04:26:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return proto.Marshal(&Layout{
|
2017-12-05 22:28:33 +00:00
|
|
|
ID: l.ID,
|
|
|
|
Measurement: l.Measurement,
|
|
|
|
Application: l.Application,
|
|
|
|
Autoflow: l.Autoflow,
|
|
|
|
Cells: cells,
|
2016-10-06 04:26:39 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalLayout decodes a layout from binary protobuf data.
|
2016-10-20 14:38:23 +00:00
|
|
|
func UnmarshalLayout(data []byte, l *chronograf.Layout) error {
|
2016-10-06 04:26:39 +00:00
|
|
|
var pb Layout
|
|
|
|
if err := proto.Unmarshal(data, &pb); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-10-10 22:00:27 +00:00
|
|
|
l.ID = pb.ID
|
2016-10-06 23:31:56 +00:00
|
|
|
l.Measurement = pb.Measurement
|
|
|
|
l.Application = pb.Application
|
2016-11-15 18:11:32 +00:00
|
|
|
l.Autoflow = pb.Autoflow
|
2016-10-20 14:38:23 +00:00
|
|
|
cells := make([]chronograf.Cell, len(pb.Cells))
|
2016-10-06 04:26:39 +00:00
|
|
|
for i, c := range pb.Cells {
|
2016-10-20 14:38:23 +00:00
|
|
|
queries := make([]chronograf.Query, len(c.Queries))
|
2016-10-06 04:26:39 +00:00
|
|
|
for j, q := range c.Queries {
|
2016-10-20 14:38:23 +00:00
|
|
|
queries[j] = chronograf.Query{
|
2016-11-07 22:29:39 +00:00
|
|
|
Command: q.Command,
|
|
|
|
DB: q.DB,
|
|
|
|
RP: q.RP,
|
|
|
|
GroupBys: q.GroupBys,
|
2016-11-08 02:35:46 +00:00
|
|
|
Wheres: q.Wheres,
|
2016-11-29 21:04:54 +00:00
|
|
|
Label: q.Label,
|
|
|
|
}
|
|
|
|
if q.Range.Upper != q.Range.Lower {
|
|
|
|
queries[j].Range = &chronograf.Range{
|
|
|
|
Upper: q.Range.Upper,
|
|
|
|
Lower: q.Range.Lower,
|
|
|
|
}
|
2016-10-06 04:26:39 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-24 22:30:53 +00:00
|
|
|
axes := make(map[string]chronograf.Axis, len(c.Axes))
|
|
|
|
for a, r := range c.Axes {
|
2017-08-10 19:51:08 +00:00
|
|
|
axes[a] = chronograf.Axis{
|
|
|
|
Bounds: r.Bounds,
|
2017-08-10 19:56:01 +00:00
|
|
|
Label: r.Label,
|
2017-08-10 19:51:08 +00:00
|
|
|
}
|
2017-07-24 22:30:53 +00:00
|
|
|
}
|
2016-11-22 17:27:27 +00:00
|
|
|
|
2016-10-20 14:38:23 +00:00
|
|
|
cells[i] = chronograf.Cell{
|
2016-10-06 04:26:39 +00:00
|
|
|
X: c.X,
|
|
|
|
Y: c.Y,
|
|
|
|
W: c.W,
|
|
|
|
H: c.H,
|
2016-10-28 20:43:06 +00:00
|
|
|
I: c.I,
|
|
|
|
Name: c.Name,
|
2016-10-06 04:26:39 +00:00
|
|
|
Queries: queries,
|
2016-12-06 05:46:30 +00:00
|
|
|
Type: c.Type,
|
2017-07-24 22:30:53 +00:00
|
|
|
Axes: axes,
|
2016-10-06 04:26:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
l.Cells = cells
|
|
|
|
return nil
|
|
|
|
}
|
2016-11-04 00:44:28 +00:00
|
|
|
|
2016-12-13 10:25:26 +00:00
|
|
|
// MarshalDashboard encodes a dashboard to binary protobuf format.
|
2016-12-09 03:28:40 +00:00
|
|
|
func MarshalDashboard(d chronograf.Dashboard) ([]byte, error) {
|
2016-12-14 00:19:42 +00:00
|
|
|
cells := make([]*DashboardCell, len(d.Cells))
|
2016-12-13 11:07:24 +00:00
|
|
|
for i, c := range d.Cells {
|
2017-01-27 12:29:38 +00:00
|
|
|
queries := make([]*Query, len(c.Queries))
|
|
|
|
for j, q := range c.Queries {
|
|
|
|
r := new(Range)
|
|
|
|
if q.Range != nil {
|
|
|
|
r.Upper, r.Lower = q.Range.Upper, q.Range.Lower
|
|
|
|
}
|
2017-11-10 19:06:48 +00:00
|
|
|
q.Shifts = q.QueryConfig.Shifts
|
2017-01-27 12:29:38 +00:00
|
|
|
queries[j] = &Query{
|
Introduce ability to edit a dashboard cell
* Correct documentation for dashboards
* Exclude .git and use 'make run-dev' in 'make continuous'
* Fix dashboard deletion bug where id serialization was wrong
* Commence creation of overlay technology, add autoRefresh props to DashboardPage
* Enhance overlay magnitude of overlay technology
* Add confirm buttons to overlay technology
* Refactor ResizeContainer to accommodate arbitrary containers
* Refactor ResizeContainer to require explicit ResizeTop and ResizeBottom for clarity
* Add markup and styles for OverlayControls
* CellEditorOverlay needs a larger minimum bottom height to accommodate more things
* Revert Visualization to not use ResizeTop or flex-box
* Remove TODO and move to issue
* Refactor CellEditorOverlay to allow selection of graph type
* Style Overlay controls, move confirm buttons to own stylesheet
* Fix toggle buttons in overlay so active is actually active
* Block user-select on a few UI items
* Update cell query shape to support Visualization and LayoutRenderer
* Code cleanup
* Repair fixture schema; update props for affected components
* Wired up selectedGraphType and activeQueryID in CellEditorOverlay
* Wire up chooseMeasurements in QueryBuilder
Pass queryActions into QueryBuilder so that DataExplorer can provide
actionCreators and CellEditorOverlay can provide functions that
modify its component state
* semicolon cleanup
* Bind all queryModifier actions to component state with a stateReducer
* Overlay Technologies™ can add and delete a query from a cell
* Semicolon cleanup
* Add conversion of InfluxQL to QueryConfig for dashboards
* Update go deps to add influxdb at af72d9b0e4ebe95be30e89b160f43eabaf0529ed
* Updated docs for dashboard query config
* Update CHANGELOG to mention InfluxQL to QueryConfig
* Make reducer’s name more specific for clarity
* Remove 'table' as graphType
* Make graph renaming prettier
* Remove duplicate DashboardQuery in swagger.json
* Fix swagger to include name and links for Cell
* Refactor CellEditorOverlay to enable graph type selection
* Add link.self to all Dashboard cells; add bolt migrations
* Make dash graph names only hover on contents
* Consolidate timeRange format patterns, clean up
* Add cell endpoints to dashboards
* Include Line + Stat in Visualization Type list
* Add cell link to dashboards
* Enable step plot and stacked graph in Visualization
* Overlay Technologies are summonable and dismissable
* OverlayTechnologies saves changes to a cell
* Convert NameableGraph to createClass for state
This was converted from a pure function to encapsulate the state of the
buttons. An attempt was made previously to store this state in Redux,
but it proved too convoluted with the current state of the reducers for
cells and dashboards. Another effort must take place to separate a cell
reducer to manage the state of an individual cell in Redux in order for
this state to be sanely kept in Redux as well.
For the time being, this state is being kept in the component for the
sake of expeditiousness, since this is needed for Dashboards to be
released. A refactor of this will occur later.
* Cells should contain a links key in server response
* Clean up console logs
* Use live data instead of a cellQuery fixture
* Update docs for dashboard creation
* DB and RP are already present in the Command field
* Fix LayoutRenderer’s understanding of query schema
* Return a new object, rather that mutate in place
* Visualization doesn’t use activeQueryID
* Selected is an object, not a string
* QueryBuilder refactored to use query index instead of query id
* CellEditorOverlay refactored to use query index instead of query id
* ConfirmButtons doesn’t need to act on an item
* Rename functions to follow convention
* Queries are no longer guaranteed to have ids
* Omit WHERE and GROUP BY clauses when saving query
* Select new query on add in OverlayTechnologies
* Add click outside to dash graph menu, style menu also
* Change context menu from ... to a caret
More consistent with the rest of the UI, better affordance
* Hide graph context menu in presentation mode
Don’t want people editing a dashboard from presentation mode
* Move graph refreshing spinner so it does not overlap with context menu
* Wire up Cell Menu to Overlay Technologies
* Correct empty dashboard type
* Refactor dashboard spec fixtures
* Test syncDashboardCell reducer
* Remove Delete button from graph dropdown menu (for now)
* Update changelog
2017-03-24 00:12:33 +00:00
|
|
|
Command: q.Command,
|
|
|
|
Label: q.Label,
|
|
|
|
Range: r,
|
2017-09-14 18:13:47 +00:00
|
|
|
Source: q.Source,
|
2017-01-27 12:29:38 +00:00
|
|
|
}
|
2017-11-10 19:06:48 +00:00
|
|
|
|
|
|
|
shifts := make([]*TimeShift, len(q.Shifts))
|
|
|
|
for k := range q.Shifts {
|
|
|
|
shift := &TimeShift{
|
|
|
|
Label: q.Shifts[k].Label,
|
|
|
|
Unit: q.Shifts[k].Unit,
|
|
|
|
Quantity: q.Shifts[k].Quantity,
|
|
|
|
}
|
|
|
|
|
|
|
|
shifts[k] = shift
|
|
|
|
}
|
|
|
|
|
|
|
|
queries[j].Shifts = shifts
|
2017-01-27 12:29:38 +00:00
|
|
|
}
|
2016-12-13 10:25:26 +00:00
|
|
|
|
2017-11-22 01:26:25 +00:00
|
|
|
colors := make([]*Color, len(c.CellColors))
|
|
|
|
for j, color := range c.CellColors {
|
|
|
|
colors[j] = &Color{
|
|
|
|
ID: color.ID,
|
|
|
|
Type: color.Type,
|
|
|
|
Hex: color.Hex,
|
|
|
|
Name: color.Name,
|
|
|
|
Value: color.Value,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-21 15:08:52 +00:00
|
|
|
axes := make(map[string]*Axis, len(c.Axes))
|
2017-07-19 14:27:21 +00:00
|
|
|
for a, r := range c.Axes {
|
2017-07-21 15:08:52 +00:00
|
|
|
axes[a] = &Axis{
|
2017-08-02 15:29:29 +00:00
|
|
|
Bounds: r.Bounds,
|
|
|
|
Label: r.Label,
|
2017-08-09 20:06:34 +00:00
|
|
|
Prefix: r.Prefix,
|
|
|
|
Suffix: r.Suffix,
|
|
|
|
Base: r.Base,
|
2017-08-18 17:48:41 +00:00
|
|
|
Scale: r.Scale,
|
2017-07-19 14:27:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-17 00:03:20 +00:00
|
|
|
sortBy := &RenamableField{
|
2018-03-12 22:04:17 +00:00
|
|
|
InternalName: c.TableOptions.SortBy.InternalName,
|
|
|
|
DisplayName: c.TableOptions.SortBy.DisplayName,
|
2018-03-16 00:35:59 +00:00
|
|
|
Visible: c.TableOptions.SortBy.Visible,
|
2018-03-09 19:47:56 +00:00
|
|
|
}
|
|
|
|
|
2018-03-12 22:04:17 +00:00
|
|
|
tableOptions := &TableOptions{
|
|
|
|
VerticalTimeAxis: c.TableOptions.VerticalTimeAxis,
|
2018-03-09 19:47:56 +00:00
|
|
|
SortBy: sortBy,
|
2018-03-12 22:04:17 +00:00
|
|
|
Wrapping: c.TableOptions.Wrapping,
|
2018-03-19 21:49:05 +00:00
|
|
|
FixFirstColumn: c.TableOptions.FixFirstColumn,
|
2018-03-09 19:47:56 +00:00
|
|
|
}
|
|
|
|
|
2018-04-27 23:36:02 +00:00
|
|
|
decimalPlaces := &DecimalPlaces{
|
|
|
|
IsEnforced: c.DecimalPlaces.IsEnforced,
|
|
|
|
Digits: c.DecimalPlaces.Digits,
|
|
|
|
}
|
|
|
|
|
2018-04-18 23:48:44 +00:00
|
|
|
fieldOptions := make([]*RenamableField, len(c.FieldOptions))
|
|
|
|
for i, field := range c.FieldOptions {
|
|
|
|
fieldOptions[i] = &RenamableField{
|
|
|
|
InternalName: field.InternalName,
|
|
|
|
DisplayName: field.DisplayName,
|
|
|
|
Visible: field.Visible,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-14 00:19:42 +00:00
|
|
|
cells[i] = &DashboardCell{
|
Introduce ability to edit a dashboard cell
* Correct documentation for dashboards
* Exclude .git and use 'make run-dev' in 'make continuous'
* Fix dashboard deletion bug where id serialization was wrong
* Commence creation of overlay technology, add autoRefresh props to DashboardPage
* Enhance overlay magnitude of overlay technology
* Add confirm buttons to overlay technology
* Refactor ResizeContainer to accommodate arbitrary containers
* Refactor ResizeContainer to require explicit ResizeTop and ResizeBottom for clarity
* Add markup and styles for OverlayControls
* CellEditorOverlay needs a larger minimum bottom height to accommodate more things
* Revert Visualization to not use ResizeTop or flex-box
* Remove TODO and move to issue
* Refactor CellEditorOverlay to allow selection of graph type
* Style Overlay controls, move confirm buttons to own stylesheet
* Fix toggle buttons in overlay so active is actually active
* Block user-select on a few UI items
* Update cell query shape to support Visualization and LayoutRenderer
* Code cleanup
* Repair fixture schema; update props for affected components
* Wired up selectedGraphType and activeQueryID in CellEditorOverlay
* Wire up chooseMeasurements in QueryBuilder
Pass queryActions into QueryBuilder so that DataExplorer can provide
actionCreators and CellEditorOverlay can provide functions that
modify its component state
* semicolon cleanup
* Bind all queryModifier actions to component state with a stateReducer
* Overlay Technologies™ can add and delete a query from a cell
* Semicolon cleanup
* Add conversion of InfluxQL to QueryConfig for dashboards
* Update go deps to add influxdb at af72d9b0e4ebe95be30e89b160f43eabaf0529ed
* Updated docs for dashboard query config
* Update CHANGELOG to mention InfluxQL to QueryConfig
* Make reducer’s name more specific for clarity
* Remove 'table' as graphType
* Make graph renaming prettier
* Remove duplicate DashboardQuery in swagger.json
* Fix swagger to include name and links for Cell
* Refactor CellEditorOverlay to enable graph type selection
* Add link.self to all Dashboard cells; add bolt migrations
* Make dash graph names only hover on contents
* Consolidate timeRange format patterns, clean up
* Add cell endpoints to dashboards
* Include Line + Stat in Visualization Type list
* Add cell link to dashboards
* Enable step plot and stacked graph in Visualization
* Overlay Technologies are summonable and dismissable
* OverlayTechnologies saves changes to a cell
* Convert NameableGraph to createClass for state
This was converted from a pure function to encapsulate the state of the
buttons. An attempt was made previously to store this state in Redux,
but it proved too convoluted with the current state of the reducers for
cells and dashboards. Another effort must take place to separate a cell
reducer to manage the state of an individual cell in Redux in order for
this state to be sanely kept in Redux as well.
For the time being, this state is being kept in the component for the
sake of expeditiousness, since this is needed for Dashboards to be
released. A refactor of this will occur later.
* Cells should contain a links key in server response
* Clean up console logs
* Use live data instead of a cellQuery fixture
* Update docs for dashboard creation
* DB and RP are already present in the Command field
* Fix LayoutRenderer’s understanding of query schema
* Return a new object, rather that mutate in place
* Visualization doesn’t use activeQueryID
* Selected is an object, not a string
* QueryBuilder refactored to use query index instead of query id
* CellEditorOverlay refactored to use query index instead of query id
* ConfirmButtons doesn’t need to act on an item
* Rename functions to follow convention
* Queries are no longer guaranteed to have ids
* Omit WHERE and GROUP BY clauses when saving query
* Select new query on add in OverlayTechnologies
* Add click outside to dash graph menu, style menu also
* Change context menu from ... to a caret
More consistent with the rest of the UI, better affordance
* Hide graph context menu in presentation mode
Don’t want people editing a dashboard from presentation mode
* Move graph refreshing spinner so it does not overlap with context menu
* Wire up Cell Menu to Overlay Technologies
* Correct empty dashboard type
* Refactor dashboard spec fixtures
* Test syncDashboardCell reducer
* Remove Delete button from graph dropdown menu (for now)
* Update changelog
2017-03-24 00:12:33 +00:00
|
|
|
ID: c.ID,
|
2016-12-13 10:25:26 +00:00
|
|
|
X: c.X,
|
|
|
|
Y: c.Y,
|
|
|
|
W: c.W,
|
|
|
|
H: c.H,
|
|
|
|
Name: c.Name,
|
2017-01-27 12:29:38 +00:00
|
|
|
Queries: queries,
|
2016-12-13 10:25:26 +00:00
|
|
|
Type: c.Type,
|
2017-07-19 14:27:21 +00:00
|
|
|
Axes: axes,
|
2017-11-22 01:26:25 +00:00
|
|
|
Colors: colors,
|
2018-02-05 20:25:29 +00:00
|
|
|
Legend: &Legend{
|
|
|
|
Type: c.Legend.Type,
|
|
|
|
Orientation: c.Legend.Orientation,
|
|
|
|
},
|
2018-04-27 23:36:02 +00:00
|
|
|
TableOptions: tableOptions,
|
|
|
|
FieldOptions: fieldOptions,
|
|
|
|
TimeFormat: c.TimeFormat,
|
|
|
|
DecimalPlaces: decimalPlaces,
|
2016-12-13 10:25:26 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-20 19:31:29 +00:00
|
|
|
templates := make([]*Template, len(d.Templates))
|
|
|
|
for i, t := range d.Templates {
|
|
|
|
vals := make([]*TemplateValue, len(t.Values))
|
|
|
|
for j, v := range t.Values {
|
|
|
|
vals[j] = &TemplateValue{
|
|
|
|
Selected: v.Selected,
|
|
|
|
Type: v.Type,
|
|
|
|
Value: v.Value,
|
2018-06-19 21:50:16 +00:00
|
|
|
Key: v.Key,
|
2017-04-20 19:31:29 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-09 03:28:40 +00:00
|
|
|
|
2017-04-20 19:31:29 +00:00
|
|
|
template := &Template{
|
|
|
|
ID: string(t.ID),
|
|
|
|
TempVar: t.Var,
|
|
|
|
Values: vals,
|
|
|
|
Type: t.Type,
|
|
|
|
Label: t.Label,
|
|
|
|
}
|
|
|
|
if t.Query != nil {
|
|
|
|
template.Query = &TemplateQuery{
|
|
|
|
Command: t.Query.Command,
|
|
|
|
Db: t.Query.DB,
|
|
|
|
Rp: t.Query.RP,
|
|
|
|
Measurement: t.Query.Measurement,
|
|
|
|
TagKey: t.Query.TagKey,
|
|
|
|
FieldKey: t.Query.FieldKey,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
templates[i] = template
|
|
|
|
}
|
2016-12-13 10:25:26 +00:00
|
|
|
return proto.Marshal(&Dashboard{
|
2017-10-25 18:00:06 +00:00
|
|
|
ID: int64(d.ID),
|
|
|
|
Cells: cells,
|
|
|
|
Templates: templates,
|
|
|
|
Name: d.Name,
|
|
|
|
Organization: d.Organization,
|
2016-12-09 03:28:40 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-12-13 10:25:26 +00:00
|
|
|
// UnmarshalDashboard decodes a layout from binary protobuf data.
|
2016-12-13 11:07:24 +00:00
|
|
|
func UnmarshalDashboard(data []byte, d *chronograf.Dashboard) error {
|
2016-12-13 10:25:26 +00:00
|
|
|
var pb Dashboard
|
|
|
|
if err := proto.Unmarshal(data, &pb); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-01-27 09:23:19 +00:00
|
|
|
cells := make([]chronograf.DashboardCell, len(pb.Cells))
|
|
|
|
for i, c := range pb.Cells {
|
Introduce ability to edit a dashboard cell
* Correct documentation for dashboards
* Exclude .git and use 'make run-dev' in 'make continuous'
* Fix dashboard deletion bug where id serialization was wrong
* Commence creation of overlay technology, add autoRefresh props to DashboardPage
* Enhance overlay magnitude of overlay technology
* Add confirm buttons to overlay technology
* Refactor ResizeContainer to accommodate arbitrary containers
* Refactor ResizeContainer to require explicit ResizeTop and ResizeBottom for clarity
* Add markup and styles for OverlayControls
* CellEditorOverlay needs a larger minimum bottom height to accommodate more things
* Revert Visualization to not use ResizeTop or flex-box
* Remove TODO and move to issue
* Refactor CellEditorOverlay to allow selection of graph type
* Style Overlay controls, move confirm buttons to own stylesheet
* Fix toggle buttons in overlay so active is actually active
* Block user-select on a few UI items
* Update cell query shape to support Visualization and LayoutRenderer
* Code cleanup
* Repair fixture schema; update props for affected components
* Wired up selectedGraphType and activeQueryID in CellEditorOverlay
* Wire up chooseMeasurements in QueryBuilder
Pass queryActions into QueryBuilder so that DataExplorer can provide
actionCreators and CellEditorOverlay can provide functions that
modify its component state
* semicolon cleanup
* Bind all queryModifier actions to component state with a stateReducer
* Overlay Technologies™ can add and delete a query from a cell
* Semicolon cleanup
* Add conversion of InfluxQL to QueryConfig for dashboards
* Update go deps to add influxdb at af72d9b0e4ebe95be30e89b160f43eabaf0529ed
* Updated docs for dashboard query config
* Update CHANGELOG to mention InfluxQL to QueryConfig
* Make reducer’s name more specific for clarity
* Remove 'table' as graphType
* Make graph renaming prettier
* Remove duplicate DashboardQuery in swagger.json
* Fix swagger to include name and links for Cell
* Refactor CellEditorOverlay to enable graph type selection
* Add link.self to all Dashboard cells; add bolt migrations
* Make dash graph names only hover on contents
* Consolidate timeRange format patterns, clean up
* Add cell endpoints to dashboards
* Include Line + Stat in Visualization Type list
* Add cell link to dashboards
* Enable step plot and stacked graph in Visualization
* Overlay Technologies are summonable and dismissable
* OverlayTechnologies saves changes to a cell
* Convert NameableGraph to createClass for state
This was converted from a pure function to encapsulate the state of the
buttons. An attempt was made previously to store this state in Redux,
but it proved too convoluted with the current state of the reducers for
cells and dashboards. Another effort must take place to separate a cell
reducer to manage the state of an individual cell in Redux in order for
this state to be sanely kept in Redux as well.
For the time being, this state is being kept in the component for the
sake of expeditiousness, since this is needed for Dashboards to be
released. A refactor of this will occur later.
* Cells should contain a links key in server response
* Clean up console logs
* Use live data instead of a cellQuery fixture
* Update docs for dashboard creation
* DB and RP are already present in the Command field
* Fix LayoutRenderer’s understanding of query schema
* Return a new object, rather that mutate in place
* Visualization doesn’t use activeQueryID
* Selected is an object, not a string
* QueryBuilder refactored to use query index instead of query id
* CellEditorOverlay refactored to use query index instead of query id
* ConfirmButtons doesn’t need to act on an item
* Rename functions to follow convention
* Queries are no longer guaranteed to have ids
* Omit WHERE and GROUP BY clauses when saving query
* Select new query on add in OverlayTechnologies
* Add click outside to dash graph menu, style menu also
* Change context menu from ... to a caret
More consistent with the rest of the UI, better affordance
* Hide graph context menu in presentation mode
Don’t want people editing a dashboard from presentation mode
* Move graph refreshing spinner so it does not overlap with context menu
* Wire up Cell Menu to Overlay Technologies
* Correct empty dashboard type
* Refactor dashboard spec fixtures
* Test syncDashboardCell reducer
* Remove Delete button from graph dropdown menu (for now)
* Update changelog
2017-03-24 00:12:33 +00:00
|
|
|
queries := make([]chronograf.DashboardQuery, len(c.Queries))
|
2017-01-27 12:29:38 +00:00
|
|
|
for j, q := range c.Queries {
|
Introduce ability to edit a dashboard cell
* Correct documentation for dashboards
* Exclude .git and use 'make run-dev' in 'make continuous'
* Fix dashboard deletion bug where id serialization was wrong
* Commence creation of overlay technology, add autoRefresh props to DashboardPage
* Enhance overlay magnitude of overlay technology
* Add confirm buttons to overlay technology
* Refactor ResizeContainer to accommodate arbitrary containers
* Refactor ResizeContainer to require explicit ResizeTop and ResizeBottom for clarity
* Add markup and styles for OverlayControls
* CellEditorOverlay needs a larger minimum bottom height to accommodate more things
* Revert Visualization to not use ResizeTop or flex-box
* Remove TODO and move to issue
* Refactor CellEditorOverlay to allow selection of graph type
* Style Overlay controls, move confirm buttons to own stylesheet
* Fix toggle buttons in overlay so active is actually active
* Block user-select on a few UI items
* Update cell query shape to support Visualization and LayoutRenderer
* Code cleanup
* Repair fixture schema; update props for affected components
* Wired up selectedGraphType and activeQueryID in CellEditorOverlay
* Wire up chooseMeasurements in QueryBuilder
Pass queryActions into QueryBuilder so that DataExplorer can provide
actionCreators and CellEditorOverlay can provide functions that
modify its component state
* semicolon cleanup
* Bind all queryModifier actions to component state with a stateReducer
* Overlay Technologies™ can add and delete a query from a cell
* Semicolon cleanup
* Add conversion of InfluxQL to QueryConfig for dashboards
* Update go deps to add influxdb at af72d9b0e4ebe95be30e89b160f43eabaf0529ed
* Updated docs for dashboard query config
* Update CHANGELOG to mention InfluxQL to QueryConfig
* Make reducer’s name more specific for clarity
* Remove 'table' as graphType
* Make graph renaming prettier
* Remove duplicate DashboardQuery in swagger.json
* Fix swagger to include name and links for Cell
* Refactor CellEditorOverlay to enable graph type selection
* Add link.self to all Dashboard cells; add bolt migrations
* Make dash graph names only hover on contents
* Consolidate timeRange format patterns, clean up
* Add cell endpoints to dashboards
* Include Line + Stat in Visualization Type list
* Add cell link to dashboards
* Enable step plot and stacked graph in Visualization
* Overlay Technologies are summonable and dismissable
* OverlayTechnologies saves changes to a cell
* Convert NameableGraph to createClass for state
This was converted from a pure function to encapsulate the state of the
buttons. An attempt was made previously to store this state in Redux,
but it proved too convoluted with the current state of the reducers for
cells and dashboards. Another effort must take place to separate a cell
reducer to manage the state of an individual cell in Redux in order for
this state to be sanely kept in Redux as well.
For the time being, this state is being kept in the component for the
sake of expeditiousness, since this is needed for Dashboards to be
released. A refactor of this will occur later.
* Cells should contain a links key in server response
* Clean up console logs
* Use live data instead of a cellQuery fixture
* Update docs for dashboard creation
* DB and RP are already present in the Command field
* Fix LayoutRenderer’s understanding of query schema
* Return a new object, rather that mutate in place
* Visualization doesn’t use activeQueryID
* Selected is an object, not a string
* QueryBuilder refactored to use query index instead of query id
* CellEditorOverlay refactored to use query index instead of query id
* ConfirmButtons doesn’t need to act on an item
* Rename functions to follow convention
* Queries are no longer guaranteed to have ids
* Omit WHERE and GROUP BY clauses when saving query
* Select new query on add in OverlayTechnologies
* Add click outside to dash graph menu, style menu also
* Change context menu from ... to a caret
More consistent with the rest of the UI, better affordance
* Hide graph context menu in presentation mode
Don’t want people editing a dashboard from presentation mode
* Move graph refreshing spinner so it does not overlap with context menu
* Wire up Cell Menu to Overlay Technologies
* Correct empty dashboard type
* Refactor dashboard spec fixtures
* Test syncDashboardCell reducer
* Remove Delete button from graph dropdown menu (for now)
* Update changelog
2017-03-24 00:12:33 +00:00
|
|
|
queries[j] = chronograf.DashboardQuery{
|
|
|
|
Command: q.Command,
|
|
|
|
Label: q.Label,
|
2017-09-14 18:13:47 +00:00
|
|
|
Source: q.Source,
|
2017-01-27 12:51:31 +00:00
|
|
|
}
|
2017-11-10 19:06:48 +00:00
|
|
|
|
2017-01-27 12:51:31 +00:00
|
|
|
if q.Range.Upper != q.Range.Lower {
|
|
|
|
queries[j].Range = &chronograf.Range{
|
|
|
|
Upper: q.Range.Upper,
|
|
|
|
Lower: q.Range.Lower,
|
|
|
|
}
|
2017-01-27 12:29:38 +00:00
|
|
|
}
|
2017-11-10 19:06:48 +00:00
|
|
|
|
|
|
|
shifts := make([]chronograf.TimeShift, len(q.Shifts))
|
|
|
|
for k := range q.Shifts {
|
|
|
|
shift := chronograf.TimeShift{
|
|
|
|
Label: q.Shifts[k].Label,
|
|
|
|
Unit: q.Shifts[k].Unit,
|
|
|
|
Quantity: q.Shifts[k].Quantity,
|
|
|
|
}
|
|
|
|
|
|
|
|
shifts[k] = shift
|
|
|
|
}
|
|
|
|
|
|
|
|
queries[j].Shifts = shifts
|
2017-01-27 12:29:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-22 01:26:25 +00:00
|
|
|
colors := make([]chronograf.CellColor, len(c.Colors))
|
|
|
|
for j, color := range c.Colors {
|
|
|
|
colors[j] = chronograf.CellColor{
|
|
|
|
ID: color.ID,
|
|
|
|
Type: color.Type,
|
|
|
|
Hex: color.Hex,
|
|
|
|
Name: color.Name,
|
|
|
|
Value: color.Value,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-20 18:39:19 +00:00
|
|
|
axes := make(map[string]chronograf.Axis, len(c.Axes))
|
2017-07-19 14:27:21 +00:00
|
|
|
for a, r := range c.Axes {
|
2017-08-09 20:06:34 +00:00
|
|
|
// axis base defaults to 10
|
|
|
|
if r.Base == "" {
|
|
|
|
r.Base = "10"
|
|
|
|
}
|
|
|
|
|
2017-08-22 22:11:29 +00:00
|
|
|
if r.Scale == "" {
|
|
|
|
r.Scale = "linear"
|
|
|
|
}
|
|
|
|
|
2017-08-02 14:58:01 +00:00
|
|
|
if r.Bounds != nil {
|
|
|
|
axes[a] = chronograf.Axis{
|
|
|
|
Bounds: r.Bounds,
|
2017-08-02 15:12:47 +00:00
|
|
|
Label: r.Label,
|
2017-08-09 20:06:34 +00:00
|
|
|
Prefix: r.Prefix,
|
|
|
|
Suffix: r.Suffix,
|
|
|
|
Base: r.Base,
|
2017-08-18 17:48:41 +00:00
|
|
|
Scale: r.Scale,
|
2017-08-02 14:58:01 +00:00
|
|
|
}
|
2017-08-09 20:06:34 +00:00
|
|
|
|
2017-08-02 14:58:01 +00:00
|
|
|
} else {
|
|
|
|
axes[a] = chronograf.Axis{
|
|
|
|
Bounds: []string{},
|
2017-08-09 20:06:34 +00:00
|
|
|
Base: r.Base,
|
2017-08-22 22:11:29 +00:00
|
|
|
Scale: r.Scale,
|
2017-08-02 14:58:01 +00:00
|
|
|
}
|
2017-07-26 19:45:17 +00:00
|
|
|
}
|
2017-07-19 14:27:21 +00:00
|
|
|
}
|
|
|
|
|
2018-02-05 20:25:29 +00:00
|
|
|
legend := chronograf.Legend{}
|
|
|
|
if c.Legend != nil {
|
|
|
|
legend.Type = c.Legend.Type
|
|
|
|
legend.Orientation = c.Legend.Orientation
|
|
|
|
}
|
|
|
|
|
2018-03-12 22:04:17 +00:00
|
|
|
tableOptions := chronograf.TableOptions{}
|
|
|
|
if c.TableOptions != nil {
|
2018-03-17 00:03:20 +00:00
|
|
|
sortBy := chronograf.RenamableField{}
|
2018-03-12 22:04:17 +00:00
|
|
|
if c.TableOptions.SortBy != nil {
|
|
|
|
sortBy.InternalName = c.TableOptions.SortBy.InternalName
|
|
|
|
sortBy.DisplayName = c.TableOptions.SortBy.DisplayName
|
2018-03-16 00:35:59 +00:00
|
|
|
sortBy.Visible = c.TableOptions.SortBy.Visible
|
2018-03-09 19:47:56 +00:00
|
|
|
}
|
2018-03-12 22:04:17 +00:00
|
|
|
tableOptions.SortBy = sortBy
|
|
|
|
tableOptions.VerticalTimeAxis = c.TableOptions.VerticalTimeAxis
|
|
|
|
tableOptions.Wrapping = c.TableOptions.Wrapping
|
2018-03-19 21:49:05 +00:00
|
|
|
tableOptions.FixFirstColumn = c.TableOptions.FixFirstColumn
|
2018-04-18 23:48:44 +00:00
|
|
|
}
|
2018-03-09 19:47:56 +00:00
|
|
|
|
2018-04-18 23:48:44 +00:00
|
|
|
fieldOptions := make([]chronograf.RenamableField, len(c.FieldOptions))
|
|
|
|
for i, field := range c.FieldOptions {
|
|
|
|
fieldOptions[i] = chronograf.RenamableField{}
|
|
|
|
fieldOptions[i].InternalName = field.InternalName
|
|
|
|
fieldOptions[i].DisplayName = field.DisplayName
|
|
|
|
fieldOptions[i].Visible = field.Visible
|
2018-04-27 23:36:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
decimalPlaces := chronograf.DecimalPlaces{}
|
|
|
|
if c.DecimalPlaces != nil {
|
|
|
|
decimalPlaces.IsEnforced = c.DecimalPlaces.IsEnforced
|
|
|
|
decimalPlaces.Digits = c.DecimalPlaces.Digits
|
2018-05-01 18:19:11 +00:00
|
|
|
} else {
|
|
|
|
decimalPlaces.IsEnforced = false
|
|
|
|
decimalPlaces.Digits = 3
|
2018-03-09 19:47:56 +00:00
|
|
|
}
|
|
|
|
|
2018-03-12 21:32:09 +00:00
|
|
|
// FIXME: this is merely for legacy cells and
|
|
|
|
// should be removed as soon as possible
|
|
|
|
cellType := c.Type
|
|
|
|
if cellType == "" {
|
|
|
|
cellType = "line"
|
|
|
|
}
|
|
|
|
|
2016-12-14 00:19:42 +00:00
|
|
|
cells[i] = chronograf.DashboardCell{
|
2018-04-27 23:36:02 +00:00
|
|
|
ID: c.ID,
|
|
|
|
X: c.X,
|
|
|
|
Y: c.Y,
|
|
|
|
W: c.W,
|
|
|
|
H: c.H,
|
|
|
|
Name: c.Name,
|
|
|
|
Queries: queries,
|
|
|
|
Type: cellType,
|
|
|
|
Axes: axes,
|
|
|
|
CellColors: colors,
|
|
|
|
Legend: legend,
|
|
|
|
TableOptions: tableOptions,
|
|
|
|
FieldOptions: fieldOptions,
|
|
|
|
TimeFormat: c.TimeFormat,
|
|
|
|
DecimalPlaces: decimalPlaces,
|
2016-12-14 00:19:42 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-20 19:31:29 +00:00
|
|
|
|
|
|
|
templates := make([]chronograf.Template, len(pb.Templates))
|
|
|
|
for i, t := range pb.Templates {
|
2017-11-08 17:27:35 +00:00
|
|
|
vals := make([]chronograf.TemplateValue, len(t.Values))
|
2017-04-20 19:31:29 +00:00
|
|
|
for j, v := range t.Values {
|
2017-11-08 17:27:35 +00:00
|
|
|
vals[j] = chronograf.TemplateValue{
|
2017-04-20 19:31:29 +00:00
|
|
|
Selected: v.Selected,
|
|
|
|
Type: v.Type,
|
|
|
|
Value: v.Value,
|
2018-06-19 21:50:16 +00:00
|
|
|
Key: v.Key,
|
2017-04-20 19:31:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template := chronograf.Template{
|
|
|
|
ID: chronograf.TemplateID(t.ID),
|
2017-11-08 17:27:35 +00:00
|
|
|
TemplateVar: chronograf.TemplateVar{
|
2017-04-20 19:31:29 +00:00
|
|
|
Var: t.TempVar,
|
|
|
|
Values: vals,
|
|
|
|
},
|
|
|
|
Type: t.Type,
|
|
|
|
Label: t.Label,
|
|
|
|
}
|
|
|
|
|
|
|
|
if t.Query != nil {
|
|
|
|
template.Query = &chronograf.TemplateQuery{
|
|
|
|
Command: t.Query.Command,
|
|
|
|
DB: t.Query.Db,
|
|
|
|
RP: t.Query.Rp,
|
|
|
|
Measurement: t.Query.Measurement,
|
|
|
|
TagKey: t.Query.TagKey,
|
|
|
|
FieldKey: t.Query.FieldKey,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
templates[i] = template
|
|
|
|
}
|
|
|
|
|
2016-12-14 20:12:20 +00:00
|
|
|
d.ID = chronograf.DashboardID(pb.ID)
|
2016-12-14 00:19:42 +00:00
|
|
|
d.Cells = cells
|
2017-04-20 19:31:29 +00:00
|
|
|
d.Templates = templates
|
2016-12-14 20:12:20 +00:00
|
|
|
d.Name = pb.Name
|
2017-10-25 18:00:06 +00:00
|
|
|
d.Organization = pb.Organization
|
2016-12-13 10:25:26 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-11-04 01:56:42 +00:00
|
|
|
// ScopedAlert contains the source and the kapacitor id
|
|
|
|
type ScopedAlert struct {
|
|
|
|
chronograf.AlertRule
|
|
|
|
SrcID int
|
|
|
|
KapaID int
|
|
|
|
}
|
|
|
|
|
2016-11-04 00:44:28 +00:00
|
|
|
// MarshalAlertRule encodes an alert rule to binary protobuf format.
|
2016-11-04 01:56:42 +00:00
|
|
|
func MarshalAlertRule(r *ScopedAlert) ([]byte, error) {
|
|
|
|
j, err := json.Marshal(r.AlertRule)
|
2016-11-04 00:44:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return proto.Marshal(&AlertRule{
|
2016-11-04 01:56:42 +00:00
|
|
|
ID: r.ID,
|
|
|
|
SrcID: int64(r.SrcID),
|
|
|
|
KapaID: int64(r.KapaID),
|
|
|
|
JSON: string(j),
|
2016-11-04 00:44:28 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalAlertRule decodes an alert rule from binary protobuf data.
|
2016-11-04 01:56:42 +00:00
|
|
|
func UnmarshalAlertRule(data []byte, r *ScopedAlert) error {
|
2016-11-04 00:44:28 +00:00
|
|
|
var pb AlertRule
|
|
|
|
if err := proto.Unmarshal(data, &pb); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-11-04 01:56:42 +00:00
|
|
|
err := json.Unmarshal([]byte(pb.JSON), &r.AlertRule)
|
2016-11-04 00:44:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2016-11-04 01:56:42 +00:00
|
|
|
r.SrcID = int(pb.SrcID)
|
|
|
|
r.KapaID = int(pb.KapaID)
|
2016-11-04 00:44:28 +00:00
|
|
|
return nil
|
|
|
|
}
|
2016-11-17 23:57:46 +00:00
|
|
|
|
|
|
|
// MarshalUser encodes a user to binary protobuf format.
|
2017-02-17 19:37:00 +00:00
|
|
|
// We are ignoring the password for now.
|
2016-11-17 23:57:46 +00:00
|
|
|
func MarshalUser(u *chronograf.User) ([]byte, error) {
|
2017-10-24 17:29:46 +00:00
|
|
|
roles := make([]*Role, len(u.Roles))
|
2017-10-12 20:31:53 +00:00
|
|
|
for i, role := range u.Roles {
|
2017-10-24 17:29:46 +00:00
|
|
|
roles[i] = &Role{
|
2017-10-30 16:28:57 +00:00
|
|
|
Organization: role.Organization,
|
|
|
|
Name: role.Name,
|
2017-10-24 17:29:46 +00:00
|
|
|
}
|
2017-10-12 20:31:53 +00:00
|
|
|
}
|
2017-02-17 19:37:00 +00:00
|
|
|
return MarshalUserPB(&User{
|
2017-10-31 22:27:24 +00:00
|
|
|
ID: u.ID,
|
|
|
|
Name: u.Name,
|
|
|
|
Provider: u.Provider,
|
|
|
|
Scheme: u.Scheme,
|
|
|
|
Roles: roles,
|
|
|
|
SuperAdmin: u.SuperAdmin,
|
2016-11-17 23:57:46 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-02-17 19:37:00 +00:00
|
|
|
// MarshalUserPB encodes a user to binary protobuf format.
|
|
|
|
// We are ignoring the password for now.
|
|
|
|
func MarshalUserPB(u *User) ([]byte, error) {
|
|
|
|
return proto.Marshal(u)
|
|
|
|
}
|
|
|
|
|
2016-11-17 23:57:46 +00:00
|
|
|
// UnmarshalUser decodes a user from binary protobuf data.
|
2017-02-17 19:37:00 +00:00
|
|
|
// We are ignoring the password for now.
|
2016-11-17 23:57:46 +00:00
|
|
|
func UnmarshalUser(data []byte, u *chronograf.User) error {
|
|
|
|
var pb User
|
2017-02-17 19:37:00 +00:00
|
|
|
if err := UnmarshalUserPB(data, &pb); err != nil {
|
2016-11-17 23:57:46 +00:00
|
|
|
return err
|
|
|
|
}
|
2017-10-12 20:31:53 +00:00
|
|
|
roles := make([]chronograf.Role, len(pb.Roles))
|
|
|
|
for i, role := range pb.Roles {
|
|
|
|
roles[i] = chronograf.Role{
|
2017-10-30 16:28:57 +00:00
|
|
|
Organization: role.Organization,
|
|
|
|
Name: role.Name,
|
2017-10-12 20:31:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
u.ID = pb.ID
|
2017-02-17 19:37:00 +00:00
|
|
|
u.Name = pb.Name
|
2017-10-12 20:31:53 +00:00
|
|
|
u.Provider = pb.Provider
|
|
|
|
u.Scheme = pb.Scheme
|
2017-10-31 22:27:24 +00:00
|
|
|
u.SuperAdmin = pb.SuperAdmin
|
2017-10-12 20:31:53 +00:00
|
|
|
u.Roles = roles
|
|
|
|
|
2017-02-17 19:37:00 +00:00
|
|
|
return nil
|
|
|
|
}
|
2016-11-17 23:57:46 +00:00
|
|
|
|
2017-04-20 19:31:29 +00:00
|
|
|
// UnmarshalUserPB decodes a user from binary protobuf data.
|
2017-02-17 19:37:00 +00:00
|
|
|
// We are ignoring the password for now.
|
|
|
|
func UnmarshalUserPB(data []byte, u *User) error {
|
2017-11-08 17:27:35 +00:00
|
|
|
return proto.Unmarshal(data, u)
|
2016-11-17 23:57:46 +00:00
|
|
|
}
|
2017-10-20 14:14:09 +00:00
|
|
|
|
2017-11-01 16:30:42 +00:00
|
|
|
// MarshalRole encodes a role to binary protobuf format.
|
2017-10-24 17:29:46 +00:00
|
|
|
func MarshalRole(r *chronograf.Role) ([]byte, error) {
|
|
|
|
return MarshalRolePB(&Role{
|
2017-10-30 16:28:57 +00:00
|
|
|
Organization: r.Organization,
|
|
|
|
Name: r.Name,
|
2017-10-24 17:29:46 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-11-01 16:30:42 +00:00
|
|
|
// MarshalRolePB encodes a role to binary protobuf format.
|
2017-10-24 17:29:46 +00:00
|
|
|
func MarshalRolePB(r *Role) ([]byte, error) {
|
|
|
|
return proto.Marshal(r)
|
|
|
|
}
|
|
|
|
|
2017-11-01 16:30:42 +00:00
|
|
|
// UnmarshalRole decodes a role from binary protobuf data.
|
2017-10-24 17:29:46 +00:00
|
|
|
func UnmarshalRole(data []byte, r *chronograf.Role) error {
|
|
|
|
var pb Role
|
|
|
|
if err := UnmarshalRolePB(data, &pb); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-10-30 16:28:57 +00:00
|
|
|
r.Organization = pb.Organization
|
2017-10-24 17:29:46 +00:00
|
|
|
r.Name = pb.Name
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-11-01 16:30:42 +00:00
|
|
|
// UnmarshalRolePB decodes a role from binary protobuf data.
|
2017-10-24 17:29:46 +00:00
|
|
|
func UnmarshalRolePB(data []byte, r *Role) error {
|
2018-02-05 20:25:29 +00:00
|
|
|
return proto.Unmarshal(data, r)
|
2017-10-24 17:29:46 +00:00
|
|
|
}
|
|
|
|
|
2017-10-20 14:14:09 +00:00
|
|
|
// MarshalOrganization encodes a organization to binary protobuf format.
|
|
|
|
func MarshalOrganization(o *chronograf.Organization) ([]byte, error) {
|
2018-01-02 23:48:10 +00:00
|
|
|
|
2017-10-20 14:14:09 +00:00
|
|
|
return MarshalOrganizationPB(&Organization{
|
2017-11-11 02:23:41 +00:00
|
|
|
ID: o.ID,
|
|
|
|
Name: o.Name,
|
|
|
|
DefaultRole: o.DefaultRole,
|
2017-10-20 14:14:09 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalOrganizationPB encodes a organization to binary protobuf format.
|
|
|
|
func MarshalOrganizationPB(o *Organization) ([]byte, error) {
|
|
|
|
return proto.Marshal(o)
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalOrganization decodes a organization from binary protobuf data.
|
|
|
|
func UnmarshalOrganization(data []byte, o *chronograf.Organization) error {
|
|
|
|
var pb Organization
|
|
|
|
if err := UnmarshalOrganizationPB(data, &pb); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-10-20 15:13:13 +00:00
|
|
|
o.ID = pb.ID
|
2017-10-20 14:14:09 +00:00
|
|
|
o.Name = pb.Name
|
2017-11-02 22:32:13 +00:00
|
|
|
o.DefaultRole = pb.DefaultRole
|
2017-10-20 14:14:09 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalOrganizationPB decodes a organization from binary protobuf data.
|
|
|
|
func UnmarshalOrganizationPB(data []byte, o *Organization) error {
|
2018-02-05 20:25:29 +00:00
|
|
|
return proto.Unmarshal(data, o)
|
2017-10-20 14:14:09 +00:00
|
|
|
}
|
2017-12-13 18:38:01 +00:00
|
|
|
|
|
|
|
// MarshalConfig encodes a config to binary protobuf format.
|
|
|
|
func MarshalConfig(c *chronograf.Config) ([]byte, error) {
|
2018-07-03 18:44:39 +00:00
|
|
|
columns := make([]*LogViewerColumn, len(c.LogViewer.Columns))
|
2018-07-03 00:54:14 +00:00
|
|
|
for i, column := range c.LogViewer.Columns {
|
2018-07-02 23:35:06 +00:00
|
|
|
encodings := make([]*ColumnEncoding, len(column.Encodings))
|
2018-06-30 01:44:57 +00:00
|
|
|
|
2018-07-02 23:35:06 +00:00
|
|
|
for j, e := range column.Encodings {
|
2018-06-30 01:44:57 +00:00
|
|
|
encodings[j] = &ColumnEncoding{
|
|
|
|
Type: e.Type,
|
|
|
|
Value: e.Value,
|
|
|
|
Name: e.Name,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-03 18:44:39 +00:00
|
|
|
columns[i] = &LogViewerColumn{
|
2018-07-02 23:35:06 +00:00
|
|
|
Name: column.Name,
|
|
|
|
Position: column.Position,
|
|
|
|
Encodings: encodings,
|
2018-06-30 01:44:57 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-13 18:38:01 +00:00
|
|
|
return MarshalConfigPB(&Config{
|
|
|
|
Auth: &AuthConfig{
|
2017-12-13 22:49:49 +00:00
|
|
|
SuperAdminNewUsers: c.Auth.SuperAdminNewUsers,
|
2017-12-13 18:38:01 +00:00
|
|
|
},
|
2018-07-03 18:44:39 +00:00
|
|
|
LogViewer: &LogViewerConfig{
|
2018-06-30 01:44:57 +00:00
|
|
|
Columns: columns,
|
|
|
|
},
|
2017-12-13 18:38:01 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalConfigPB encodes a config to binary protobuf format.
|
|
|
|
func MarshalConfigPB(c *Config) ([]byte, error) {
|
|
|
|
return proto.Marshal(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalConfig decodes a config from binary protobuf data.
|
|
|
|
func UnmarshalConfig(data []byte, c *chronograf.Config) error {
|
|
|
|
var pb Config
|
|
|
|
if err := UnmarshalConfigPB(data, &pb); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if pb.Auth == nil {
|
|
|
|
return fmt.Errorf("Auth config is nil")
|
|
|
|
}
|
2017-12-13 22:49:49 +00:00
|
|
|
c.Auth.SuperAdminNewUsers = pb.Auth.SuperAdminNewUsers
|
2017-12-13 18:38:01 +00:00
|
|
|
|
2018-07-03 00:54:14 +00:00
|
|
|
if pb.LogViewer == nil {
|
2018-07-03 18:44:39 +00:00
|
|
|
return fmt.Errorf("Log Viewer config is nil")
|
2018-06-30 01:44:57 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 18:44:39 +00:00
|
|
|
columns := make([]chronograf.LogViewerColumn, len(pb.LogViewer.Columns))
|
2018-06-30 01:44:57 +00:00
|
|
|
|
2018-07-03 00:54:14 +00:00
|
|
|
for i, c := range pb.LogViewer.Columns {
|
2018-06-30 01:44:57 +00:00
|
|
|
columns[i].Name = c.Name
|
|
|
|
columns[i].Position = c.Position
|
|
|
|
|
2018-07-02 23:35:06 +00:00
|
|
|
encodings := make([]chronograf.ColumnEncoding, len(c.Encodings))
|
|
|
|
for j, e := range c.Encodings {
|
2018-06-30 01:44:57 +00:00
|
|
|
encodings[j].Type = e.Type
|
|
|
|
encodings[j].Value = e.Value
|
|
|
|
encodings[j].Name = e.Name
|
|
|
|
}
|
|
|
|
|
2018-07-02 23:35:06 +00:00
|
|
|
columns[i].Encodings = encodings
|
2018-06-30 01:44:57 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 00:54:14 +00:00
|
|
|
c.LogViewer.Columns = columns
|
2018-06-30 01:44:57 +00:00
|
|
|
|
2017-12-13 18:38:01 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalConfigPB decodes a config from binary protobuf data.
|
|
|
|
func UnmarshalConfigPB(data []byte, c *Config) error {
|
2018-02-05 20:25:29 +00:00
|
|
|
return proto.Unmarshal(data, c)
|
2017-12-13 18:38:01 +00:00
|
|
|
}
|
2018-02-05 19:54:39 +00:00
|
|
|
|
|
|
|
// MarshalMapping encodes a mapping to binary protobuf format.
|
|
|
|
func MarshalMapping(m *chronograf.Mapping) ([]byte, error) {
|
|
|
|
|
|
|
|
return MarshalMappingPB(&Mapping{
|
2018-02-07 02:33:27 +00:00
|
|
|
Provider: m.Provider,
|
|
|
|
Scheme: m.Scheme,
|
|
|
|
ProviderOrganization: m.ProviderOrganization,
|
|
|
|
ID: m.ID,
|
|
|
|
Organization: m.Organization,
|
2018-02-05 19:54:39 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalMappingPB encodes a mapping to binary protobuf format.
|
|
|
|
func MarshalMappingPB(m *Mapping) ([]byte, error) {
|
|
|
|
return proto.Marshal(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalMapping decodes a mapping from binary protobuf data.
|
|
|
|
func UnmarshalMapping(data []byte, m *chronograf.Mapping) error {
|
|
|
|
var pb Mapping
|
|
|
|
if err := UnmarshalMappingPB(data, &pb); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
m.Provider = pb.Provider
|
|
|
|
m.Scheme = pb.Scheme
|
2018-02-07 02:33:27 +00:00
|
|
|
m.ProviderOrganization = pb.ProviderOrganization
|
2018-02-05 19:54:39 +00:00
|
|
|
m.Organization = pb.Organization
|
|
|
|
m.ID = pb.ID
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalMappingPB decodes a mapping from binary protobuf data.
|
|
|
|
func UnmarshalMappingPB(data []byte, m *Mapping) error {
|
2018-02-05 23:20:03 +00:00
|
|
|
return proto.Unmarshal(data, m)
|
2018-02-05 19:54:39 +00:00
|
|
|
}
|