diff --git a/bitmovin-analytics-datasource/src/components/FilterRow.tsx b/bitmovin-analytics-datasource/src/components/FilterRow.tsx index ad226b2..2816fee 100644 --- a/bitmovin-analytics-datasource/src/components/FilterRow.tsx +++ b/bitmovin-analytics-datasource/src/components/FilterRow.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import { Box, HorizontalGroup, IconButton, InlineLabel, VerticalGroup } from '@grafana/ui'; -import { InputQueryFilter } from '../types/queryFilter'; +import { QueryFilter } from '../types/queryFilter'; import { ATTRIBUTE_COMPONENT_WIDTH, OPERATOR_COMPONENT_WIDTH, @@ -11,8 +11,8 @@ import { type Props = { readonly isAdAnalytics: boolean; - readonly onQueryFilterChange: (newFilters: InputQueryFilter[]) => void; - readonly filters: InputQueryFilter[]; + readonly onQueryFilterChange: (newFilters: QueryFilter[]) => void; + readonly filters: QueryFilter[]; }; export function FilterRow(props: Props) { @@ -24,13 +24,13 @@ export function FilterRow(props: Props) { props.onQueryFilterChange(newQueryFilters); } - function handleQueryFilterChange(queryFilterIndex: number, changedQueryFilter: InputQueryFilter) { + function handleQueryFilterChange(queryFilterIndex: number, changedQueryFilter: QueryFilter) { const newQueryFilters = [...props.filters]; newQueryFilters.splice(queryFilterIndex, 1, changedQueryFilter); props.onQueryFilterChange(newQueryFilters); } - function handleNewQueryFilterChange(newQueryFilter: InputQueryFilter) { + function handleNewQueryFilterChange(newQueryFilter: QueryFilter) { const newQueryFilters = [...props.filters, newQueryFilter]; props.onQueryFilterChange(newQueryFilters); setHasNewQueryFilter(false); diff --git a/bitmovin-analytics-datasource/src/components/QueryEditor.tsx b/bitmovin-analytics-datasource/src/components/QueryEditor.tsx index 639ebb4..708cec8 100644 --- a/bitmovin-analytics-datasource/src/components/QueryEditor.tsx +++ b/bitmovin-analytics-datasource/src/components/QueryEditor.tsx @@ -19,7 +19,7 @@ import { isMetric, SELECTABLE_METRICS } from '../types/metric'; import { GroupByRow } from './GroupByRow'; import { OrderByRow } from './OrderByRow'; import type { QueryOrderBy } from '../types/queryOrderBy'; -import type { InputQueryFilter } from '../types/queryFilter'; +import type { QueryFilter } from '../types/queryFilter'; import { FilterRow } from './FilterRow'; enum LoadingState { @@ -88,7 +88,7 @@ export function QueryEditor(props: Props) { props.onRunQuery(); }; - const handleQueryFilterChange = (newFilters: InputQueryFilter[]) => { + const handleQueryFilterChange = (newFilters: QueryFilter[]) => { props.onChange({ ...query, filter: newFilters }); props.onRunQuery(); }; diff --git a/bitmovin-analytics-datasource/src/components/QueryFilterInput.tsx b/bitmovin-analytics-datasource/src/components/QueryFilterInput.tsx index 17706c2..a10e787 100644 --- a/bitmovin-analytics-datasource/src/components/QueryFilterInput.tsx +++ b/bitmovin-analytics-datasource/src/components/QueryFilterInput.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import { HorizontalGroup, IconButton, Input, Select, Tooltip } from '@grafana/ui'; -import { InputQueryFilter, QueryFilterOperator, SELECTABLE_QUERY_FILTER_OPERATORS } from '../types/queryFilter'; +import { QueryFilter, QueryFilterOperator, SELECTABLE_QUERY_FILTER_OPERATORS } from '../types/queryFilter'; import type { SelectableValue } from '@grafana/data'; import { QueryAttribute, SELECTABLE_QUERY_ATTRIBUTES } from '../types/queryAttributes'; import { QueryAdAttribute, SELECTABLE_QUERY_AD_ATTRIBUTES } from '../types/queryAdAttributes'; @@ -10,12 +10,12 @@ import { convertFilterValueToProperType } from 'utils/filterUtils'; interface QueryFilterInputProps { /** `undefined` when component is used to create new filter (no values yet) */ - value: undefined | InputQueryFilter; - onChange(queryFilter: InputQueryFilter): void; + value: undefined | QueryFilter; + onChange(queryFilter: QueryFilter): void; onDelete(): void; isAdAnalytics: boolean; /** Selected query filters are used to filter out used values from attribute select options */ - selectedQueryFilters: InputQueryFilter[]; + selectedQueryFilters: QueryFilter[]; } export function QueryFilterInput(props: Readonly) { @@ -185,18 +185,18 @@ export const OPERATOR_COMPONENT_WIDTH = 15; export const VALUE_COMPONENT_WIDTH = 30; type DerivedQueryFilterState = { - attribute: undefined | InputQueryFilter['name']; + attribute: undefined | QueryFilter['name']; attributeError: undefined | string; - operator: undefined | InputQueryFilter['operator']; + operator: undefined | QueryFilter['operator']; operatorError: undefined | string; - value: undefined | InputQueryFilter['value']; + value: undefined | QueryFilter['value']; /** `true` if some values have been changed by inputs */ dirty: boolean; /** `undefined` when input value is valid */ inputValueError: undefined | string; }; -function buildInitialDerivedQueryFilterState(queryFilter: undefined | InputQueryFilter): DerivedQueryFilterState { +function buildInitialDerivedQueryFilterState(queryFilter: undefined | QueryFilter): DerivedQueryFilterState { return { attribute: queryFilter?.name, attributeError: undefined, @@ -209,7 +209,7 @@ function buildInitialDerivedQueryFilterState(queryFilter: undefined | InputQuery } function buildAttributeSelectableValues( - usedQueryFilters: InputQueryFilter[], + usedQueryFilters: QueryFilter[], isAdAnalytics: boolean ): Array> { const ALL_ATTRIBUTES: Array> = isAdAnalytics diff --git a/bitmovin-analytics-datasource/src/datasource.ts b/bitmovin-analytics-datasource/src/datasource.ts index c48b309..c79dc8f 100644 --- a/bitmovin-analytics-datasource/src/datasource.ts +++ b/bitmovin-analytics-datasource/src/datasource.ts @@ -28,7 +28,7 @@ import { import { calculateQueryInterval, QueryInterval } from './utils/intervalUtils'; import { isMetric, Metric } from './types/metric'; import { AggregationMethod } from './types/aggregationMethod'; -import { OutputQueryFilter } from './types/queryFilter'; +import { ProperTypedQueryFilter } from './types/queryFilter'; import { QueryAttribute } from './types/queryAttributes'; import { QueryAdAttribute } from './types/queryAdAttributes'; import { QueryOrderBy } from './types/queryOrderBy'; @@ -38,7 +38,7 @@ type BitmovinAnalyticsRequestQuery = { licenseKey: string; start: Date; end: Date; - filters: OutputQueryFilter[]; + filters: ProperTypedQueryFilter[]; groupBy: Array; orderBy: QueryOrderBy[]; dimension?: QueryAttribute | QueryAdAttribute; @@ -106,7 +106,7 @@ export class DataSource extends DataSourceApi< } } - const filters: OutputQueryFilter[] = target.filter.map((filter) => { + const filters: ProperTypedQueryFilter[] = target.filter.map((filter) => { return { name: filter.name, operator: filter.operator, diff --git a/bitmovin-analytics-datasource/src/types/grafanaTypes.ts b/bitmovin-analytics-datasource/src/types/grafanaTypes.ts index a4cece1..ea5d671 100644 --- a/bitmovin-analytics-datasource/src/types/grafanaTypes.ts +++ b/bitmovin-analytics-datasource/src/types/grafanaTypes.ts @@ -5,7 +5,7 @@ import { QueryAttribute } from './queryAttributes'; import { QueryAdAttribute } from './queryAdAttributes'; import { Metric } from './metric'; import { QueryOrderBy } from './queryOrderBy'; -import { InputQueryFilter } from './queryFilter'; +import { QueryFilter } from './queryFilter'; import { AggregationMethod } from './aggregationMethod'; type ResultFormat = 'table' | 'time_series'; @@ -21,7 +21,7 @@ export interface BitmovinAnalyticsDataQuery extends DataQuery { groupBy: Array; orderBy: QueryOrderBy[]; limit?: number; - filter: InputQueryFilter[]; + filter: QueryFilter[]; alias?: string; percentileValue?: number; resultFormat: ResultFormat; @@ -39,7 +39,7 @@ export interface OldBitmovinAnalyticsDataQuery extends DataQuery { groupBy: Array; orderBy: QueryOrderBy[]; limit?: string; - filter: InputQueryFilter[]; + filter: QueryFilter[]; alias?: string; percentileValue: number; resultFormat: ResultFormat; diff --git a/bitmovin-analytics-datasource/src/types/queryFilter.ts b/bitmovin-analytics-datasource/src/types/queryFilter.ts index 55da901..3bd64c0 100644 --- a/bitmovin-analytics-datasource/src/types/queryFilter.ts +++ b/bitmovin-analytics-datasource/src/types/queryFilter.ts @@ -11,14 +11,14 @@ export const SELECTABLE_QUERY_FILTER_OPERATORS: Array