diff --git a/docker/grafana/dashboards/table_examples_dashboard.json b/docker/grafana/dashboards/table_examples_dashboard.json index 98f9d8f8f..7a844ff89 100644 --- a/docker/grafana/dashboards/table_examples_dashboard.json +++ b/docker/grafana/dashboards/table_examples_dashboard.json @@ -273,7 +273,7 @@ "type": "table" } ], - "schemaVersion": 22, + "schemaVersion": 40, "style": "dark", "tags": [], "templating": { diff --git a/package.json b/package.json index dbc3ee199..091e43255 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "create_instrumented": "npx nyc instrument --source-map --nycrc-path .nycrc ./src ./instrumented", "build:test:frontend": "webpack -c ./webpack.config.instrumented.ts --env test", "build:frontend": "webpack -c ./.config/webpack/webpack.config.ts --env production", + "build:backend": "docker compose run --rm backend_builder && chmod +rx ./dist", "build:wasm": "GOARCH=wasm GOOS=js tinygo build --target wasm ./pkg/backend_wasm.go && gzip -f ./backend_wasm.wasm && mkdir -pv ./src/static/ && mv -fv ./backend_wasm.wasm.gz ./src/static/backend.wasm.gz" }, "author": "Altinity", diff --git a/pkg/backend_wasm.go b/pkg/backend_wasm.go index 7d44606fc..f6298779f 100644 --- a/pkg/backend_wasm.go +++ b/pkg/backend_wasm.go @@ -176,7 +176,7 @@ func applyAdhocFiltersWasm(this js.Value, args []js.Value) interface{} { // Replace $adhoc macro renderedCondition := "1" if len(adhocConditions) > 0 { - renderedCondition = fmt.Sprintf("(%s)", strings.Join(adhocConditions, " AND ")) + renderedCondition = fmt.Sprintf("AND (%s)", strings.Join(adhocConditions, " AND ")) } query = strings.ReplaceAll(query, "$adhoc", renderedCondition) diff --git a/pkg/response.go b/pkg/response.go index 7a694999e..505e676d2 100644 --- a/pkg/response.go +++ b/pkg/response.go @@ -178,7 +178,7 @@ func (r *Response) createFrameIfNotExistsAndAddPoint(query *Query, framesMap map timeStampDataFieldMap[frameName] = data.NewField(timestampFieldName, nil, []time.Time{}) valueDataFieldMap[frameName] = NewDataFieldByType(frameName, fieldType) framesMap[frameName] = data.NewFrame( - frameName, + "", timeStampDataFieldMap[frameName], valueDataFieldMap[frameName], ) diff --git a/src/views/QueryEditor/QueryEditor.tsx b/src/views/QueryEditor/QueryEditor.tsx index 608a2a2e7..3d9c2a152 100644 --- a/src/views/QueryEditor/QueryEditor.tsx +++ b/src/views/QueryEditor/QueryEditor.tsx @@ -17,6 +17,15 @@ export function QueryEditor(props: QueryEditorProps { + if (formattedData !== initializedQuery.query) { + onChange({ ...initializedQuery, rawQuery: formattedData }) + } + + // eslint-disable-next-line + }, [formattedData, initializedQuery.query]); + const [editorMode, setEditorMode] = useState(initializedQuery.editorMode || EditorMode.Builder); useQueryState(query, onChange, datasource); @@ -89,6 +98,15 @@ export function QueryEditorVariable(props: QueryEditorProps { + if (formattedData !== initializedQuery.query) { + onChange({ ...initializedQuery, rawQuery: formattedData }) + } + + // eslint-disable-next-line + }, [formattedData, initializedQuery.query]); + useQueryState(query, onChange, datasource); const onSqlChange = (sql: string) => onChange({ ...initializedQuery, query: sql }); const onFieldChange = (field: any) => onChange({ ...initializedQuery, [field.fieldName]: field.value });