diff --git a/pkg/plugin/helpers.go b/pkg/plugin/helpers.go index c6ca166..c5b08df 100644 --- a/pkg/plugin/helpers.go +++ b/pkg/plugin/helpers.go @@ -356,7 +356,6 @@ func convertItemsToDataFrame(processedQuery *PiProcessedQuery, d *Datasource, Su webID := processedQuery.WebID includeMetaData := processedQuery.UseUnit digitalStates := processedQuery.DigitalStates - lenElements := len(processedQuery.Elements) noDataReplace := processedQuery.getSummaryNoDataReplace() digitalStateValues := make([]string, 0) @@ -371,24 +370,15 @@ func convertItemsToDataFrame(processedQuery *PiProcessedQuery, d *Datasource, Su } // get frame name - frameName := getDataLabel(d.isUsingNewFormat(), processedQuery, d.getPointTypeForWebID(webID), SummaryType) - dataFrameName := frameName["name"] + frameLabel := getDataLabels(d.isUsingNewFormat(), processedQuery, d.getPointTypeForWebID(webID), SummaryType) + dataFrameName := frameLabel["name"] var labels map[string]string var digitalState = d.getDigitalStateForWebID(webID) - var frame *data.Frame - - if lenElements > 1 { - frame = data.NewFrame(processedQuery.Elements[lenElements-2] + "." + processedQuery.Elements[lenElements-1]) - } else if lenElements > 0 { - frame = data.NewFrame(processedQuery.Elements[lenElements-1]) - } else { - frame = data.NewFrame(dataFrameName) - } - + frame := data.NewFrame(processedQuery.TargetPath) if d.isUsingNewFormat() { - labels = frameName + labels = frameLabel } backend.Logger.Debug("Convert", "frame", dataFrameName, "labels", labels, "type", sliceType.Elem().String()) diff --git a/pkg/plugin/timeseries_query.go b/pkg/plugin/timeseries_query.go index b6c8bee..2b1dcac 100644 --- a/pkg/plugin/timeseries_query.go +++ b/pkg/plugin/timeseries_query.go @@ -95,7 +95,7 @@ func (d *Datasource) processQuery(query backend.DataQuery, datasourceUID string) IsPIPoint: PiQuery.Pi.IsPiPoint, Streamable: PiQuery.isStreamable() && *d.dataSourceOptions.UseExperimental && *d.dataSourceOptions.UseStreaming, FullTargetPath: fullTargetPath, - Elements: strings.Split(targetBasePath, `\`), + TargetPath: targetBasePath, UseUnit: UseUnits, DigitalStates: DigitalStates, Display: PiQuery.Pi.Display, @@ -320,7 +320,7 @@ func (q *PIWebAPIQuery) isSummary() bool { return *q.Summary.Basis != "" && len(*q.Summary.Types) > 0 } -func getDataLabel(useNewFormat bool, q *PiProcessedQuery, pointType string, summaryLabel string) map[string]string { +func getDataLabels(useNewFormat bool, q *PiProcessedQuery, pointType string, summaryLabel string) map[string]string { var frameLabel map[string]string summaryNewFormat := "" @@ -336,7 +336,7 @@ func getDataLabel(useNewFormat bool, q *PiProcessedQuery, pointType string, summ targetParts := strings.Split(q.FullTargetPath, `\`) frameLabel = map[string]string{ "element": targetParts[0], - "name": targetParts[len(targetParts)-1], + "name": q.Label, "type": pointType + summaryNewFormat, } } else { @@ -346,14 +346,15 @@ func getDataLabel(useNewFormat bool, q *PiProcessedQuery, pointType string, summ labelParts := strings.SplitN(targetParts[len(targetParts)-1], "|", 2) frameLabel = map[string]string{ "element": labelParts[0], - "name": labelParts[1], + "name": q.Label, "type": pointType + summaryNewFormat, } } } else { // Old format returns just the tag/attribute name frameLabel = map[string]string{ - "name": q.Label + summaryLabel, + "element": q.TargetPath, + "name": q.Label + summaryLabel, } } diff --git a/pkg/plugin/timeseries_query_models.go b/pkg/plugin/timeseries_query_models.go index edf6378..54e69a8 100644 --- a/pkg/plugin/timeseries_query_models.go +++ b/pkg/plugin/timeseries_query_models.go @@ -197,7 +197,7 @@ type PiProcessedQuery struct { Error error Index int Resource string - Elements []string + TargetPath string Regex *Regex `json:"Regex"` Summary *QuerySummary `json:"Summary"` }