From 00dd1a5460b07f158d69877886d20d12b4a22662 Mon Sep 17 00:00:00 2001 From: Myriam Gantner <48029745+MGJamJam@users.noreply.github.com> Date: Wed, 8 May 2024 11:11:49 +0200 Subject: [PATCH] Feat/AN-4112 implement order by selection (#69) * implements license fetching and interval selection * add tests for intervalUtils * fix ceiling of timestamp for DAY interval * add tests * fix linting * delete unnecessary export of enum * implement metric selection * implement dimension selection * fix linting errors * add metric support * add metric to query and check for null instead of undefined * implements groupBy selection * fix linting * implements reordering of GroupBys and fixes position of Add Button * make props readonly * implements order By selection * splits orderBy state into two seperate states to fix rendering and renames variables * lint --- .../src/components/GroupByRow.tsx | 6 +- .../src/components/OrderByInput.tsx | 63 +++++++++ .../src/components/OrderByRow.tsx | 121 ++++++++++++++++++ .../src/components/QueryEditor.tsx | 10 ++ .../src/datasource.ts | 13 +- bitmovin-analytics-datasource/src/types.ts | 2 + .../src/types/queryOrderBy.ts | 9 ++ 7 files changed, 211 insertions(+), 13 deletions(-) create mode 100644 bitmovin-analytics-datasource/src/components/OrderByInput.tsx create mode 100644 bitmovin-analytics-datasource/src/components/OrderByRow.tsx create mode 100644 bitmovin-analytics-datasource/src/types/queryOrderBy.ts diff --git a/bitmovin-analytics-datasource/src/components/GroupByRow.tsx b/bitmovin-analytics-datasource/src/components/GroupByRow.tsx index b6e7772..2ff83a8 100644 --- a/bitmovin-analytics-datasource/src/components/GroupByRow.tsx +++ b/bitmovin-analytics-datasource/src/components/GroupByRow.tsx @@ -61,12 +61,12 @@ export function GroupByRow(props: Props) { }; const addGroupByInput = () => { - setSelectedGroupBys((prevState) => [...prevState, { name: '', label: '' }]); + setSelectedGroupBys((prevState) => [...prevState, {}]); }; return ( - {selectedGroupBys?.map((item, index, groupBys) => ( + {selectedGroupBys.map((item, index, groupBys) => ( ))} - addGroupByInput()} size="xxl" /> + addGroupByInput()} size="xl" /> ); diff --git a/bitmovin-analytics-datasource/src/components/OrderByInput.tsx b/bitmovin-analytics-datasource/src/components/OrderByInput.tsx new file mode 100644 index 0000000..033a3fc --- /dev/null +++ b/bitmovin-analytics-datasource/src/components/OrderByInput.tsx @@ -0,0 +1,63 @@ +import React from 'react'; +import { SelectableValue } from '@grafana/data'; +import { HorizontalGroup, IconButton, RadioButtonGroup, Select } from '@grafana/ui'; + +import { QueryAttribute } from '../types/queryAttributes'; +import { QueryAdAttribute } from '../types/queryAdAttributes'; +import { QuerySortOrder } from '../types/queryOrderBy'; +import { REORDER_DIRECTION } from './GroupByInput'; + +type Props = { + readonly isAdAnalytics: boolean; + readonly attribute: SelectableValue; + readonly selectableOrderByAttributes: Array>; + readonly onAttributeChange: (newValue: SelectableValue) => void; + readonly sortOrder: QuerySortOrder; + readonly onSortOrderChange: (newValue: QuerySortOrder) => void; + readonly onDelete: () => void; + readonly isFirst: boolean; + readonly isLast: boolean; + readonly onReorderOrderBy: (direction: REORDER_DIRECTION) => void; +}; + +const sortOrderOption: Array> = [ + { value: 'ASC', description: 'Sort by ascending', icon: 'sort-amount-up' }, + { value: 'DESC', description: 'Sort by descending', icon: 'sort-amount-down' }, +]; + +export function OrderByInput(props: Props) { + return ( + +