diff --git a/src/groupby.tsx b/src/groupby.tsx index aa879ee..b53da3d 100644 --- a/src/groupby.tsx +++ b/src/groupby.tsx @@ -143,6 +143,7 @@ export class GroupbyComponents extends PureComponent { onChange={this.onGroupBySelect.bind(this)} closeMenuOnSelect={false} width={34} + value={query.queryMeta?.selectedColGroupby ?? undefined} />
diff --git a/src/query_editor.tsx b/src/query_editor.tsx index c3b03b0..1fd798a 100644 --- a/src/query_editor.tsx +++ b/src/query_editor.tsx @@ -59,6 +59,7 @@ export class QueryEditor extends PureComponent { onChange({ ...query, queryType: QueryType.RunScript, + queryScript: option, queryBody: { pxlScript: option?.value.script ?? '' }, queryMeta: { isColDisplay: option.value.isColDisplay || false, @@ -99,7 +100,7 @@ export class QueryEditor extends PureComponent { options={scriptOptions} width={32} onChange={this.onScriptSelect.bind(this)} - defaultValue={scriptOptions[0]} + defaultValue={query.queryScript ?? scriptOptions[0]} />
@@ -116,6 +117,7 @@ export class QueryEditor extends PureComponent { closeMenuOnSelect={false} width={32} inputId="column-selection" + value={query.queryMeta.selectedColDisplay} /> )} diff --git a/src/types.ts b/src/types.ts index ed16be8..c49ed29 100644 --- a/src/types.ts +++ b/src/types.ts @@ -17,7 +17,7 @@ */ import { DataQuery, DataSourceJsonData, SelectableValue } from '@grafana/data'; -import { scriptOptions } from './pxl_scripts'; +import { scriptOptions, Script } from './pxl_scripts'; // Types of available queries to the backend export const enum QueryType { @@ -45,6 +45,7 @@ export interface PixieVariableQuery { export interface PixieDataQuery extends DataQuery { queryType: QueryType; clusterID?: string; + queryScript?: SelectableValue