Add map as a template variable value type to the backend

pull/10616/head
ebb-tide 2018-07-02 17:45:44 -07:00
parent 475ab5ed5f
commit b900fead75
5 changed files with 7 additions and 7 deletions

View File

@ -97,7 +97,7 @@ message Template {
}
message TemplateValue {
string type = 1; // Type can be tagKey, tagValue, fieldKey, csv, measurement, database, constant
string type = 1; // Type can be tagKey, tagValue, fieldKey, csv, map, measurement, database, constant
string value = 2; // Value is the specific value used to replace a template in an InfluxQL query
bool selected = 3; // Selected states that this variable has been picked to use for replacement
string key = 4; // Key is the key for a specific Value if the Template Type is map (optional)

View File

@ -159,7 +159,7 @@ type Range struct {
// TemplateValue is a value use to replace a template in an InfluxQL query
type TemplateValue struct {
Value string `json:"value"` // Value is the specific value used to replace a template in an InfluxQL query
Type string `json:"type"` // Type can be tagKey, tagValue, fieldKey, csv, measurement, database, constant, influxql
Type string `json:"type"` // Type can be tagKey, tagValue, fieldKey, csv, map, measurement, database, constant, influxql
Selected bool `json:"selected"` // Selected states that this variable has been picked to use for replacement
Key string `json:"key,omitempty"` // Key is the key for the Value if the Template Type is 'map'
}
@ -177,7 +177,7 @@ type TemplateID string
type Template struct {
TemplateVar
ID TemplateID `json:"id"` // ID is the unique ID associated with this template
Type string `json:"type"` // Type can be fieldKeys, tagKeys, tagValues, CSV, constant, measurements, databases, map, influxql
Type string `json:"type"` // Type can be fieldKeys, tagKeys, tagValues, csv, constant, measurements, databases, map, influxql
Label string `json:"label"` // Label is a user-facing description of the Template
Query *TemplateQuery `json:"query,omitempty"` // Query is used to generate the choices for a template
}

View File

@ -4178,7 +4178,7 @@
},
"type": {
"type": "string",
"enum": ["csv", "tagKey", "tagValue", "fieldKey", "timeStamp"],
"enum": ["csv", "tagKey", "tagValue", "fieldKey", "timeStamp", "map"],
"description":
"The type will change the format of the output value. tagKey/fieldKey are double quoted; tagValue are single quoted; csv and timeStamp are not quoted."
},

View File

@ -22,7 +22,7 @@ func ValidTemplateRequest(template *chronograf.Template) error {
switch v.Type {
default:
return fmt.Errorf("Unknown template variable type %s", v.Type)
case "csv", "fieldKey", "tagKey", "tagValue", "measurement", "database", "constant", "influxql":
case "csv", "map", "fieldKey", "tagKey", "tagValue", "measurement", "database", "constant", "influxql":
}
if template.Type == "map" && v.Key == "" {

View File

@ -69,7 +69,7 @@ func TestValidTemplateRequest(t *testing.T) {
{
Key: "key",
Value: "value",
Type: "constant",
Type: "map",
},
},
},
@ -84,7 +84,7 @@ func TestValidTemplateRequest(t *testing.T) {
Values: []chronograf.TemplateValue{
{
Value: "value",
Type: "constant",
Type: "map",
},
},
},