diff --git a/bitmovin-analytics-datasource/src/components/GroupByInput.tsx b/bitmovin-analytics-datasource/src/components/GroupByInput.tsx new file mode 100644 index 0000000..b0d3588 --- /dev/null +++ b/bitmovin-analytics-datasource/src/components/GroupByInput.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { HorizontalGroup, IconButton, Select } from '@grafana/ui'; +import { QueryAttribute } from '../types/queryAttributes'; +import { QueryAdAttribute } from '../types/queryAdAttributes'; +import { SelectableValue } from '@grafana/data'; + +type Props = { + groupBy: SelectableValue; + selectableGroupBys: Array>; + onDelete: () => void; + onChange: (newValue: SelectableValue) => void; +}; +export function GroupByInput(props: Props) { + //TODOMY delete margin between select and icon + //TODOMY border around the icon + return ( + + onIntervalChange(item)} - width={40} + width={30} options={SELECTABLE_QUERY_INTERVALS} /> @@ -103,7 +109,7 @@ export function QueryEditor({ query, onChange, onRunQuery, datasource }: Props) > + + + diff --git a/bitmovin-analytics-datasource/src/datasource.ts b/bitmovin-analytics-datasource/src/datasource.ts index 54f3027..db37e2d 100644 --- a/bitmovin-analytics-datasource/src/datasource.ts +++ b/bitmovin-analytics-datasource/src/datasource.ts @@ -19,7 +19,7 @@ import { Aggregation } from './types/aggregations'; type AnalyticsQuery = { filters: Array<{ name: string; operator: string; value: number }>; - groupBy: string[]; + groupBy: QueryAttribute[] | QueryAdAttribute[]; orderBy: Array<{ name: string; order: string }>; dimension?: QueryAttribute | QueryAdAttribute; metric?: Metric; @@ -71,7 +71,7 @@ export class DataSource extends DataSourceApi { value: 0, }, ], - groupBy: [], + groupBy: target.groupBy, orderBy: interval ? [ { diff --git a/bitmovin-analytics-datasource/src/types.ts b/bitmovin-analytics-datasource/src/types.ts index d53deec..a25440d 100644 --- a/bitmovin-analytics-datasource/src/types.ts +++ b/bitmovin-analytics-datasource/src/types.ts @@ -12,6 +12,7 @@ export interface MyQuery extends DataQuery { aggregation?: Aggregation; metric?: Metric; dimension?: QueryAttribute | QueryAdAttribute; + groupBy: QueryAttribute[] | QueryAdAttribute[]; } export const DEFAULT_QUERY: Partial = {};