Skip to content

Commit

Permalink
feat(cubejs-playground): add support for ungrouped and offset options (
Browse files Browse the repository at this point in the history
  • Loading branch information
tenphi committed Sep 18, 2024
1 parent 4875b8e commit 7d77b4a
Show file tree
Hide file tree
Showing 22 changed files with 375 additions and 476 deletions.
14 changes: 5 additions & 9 deletions packages/cubejs-playground/src/QueryBuilderV2/QueryBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ export function QueryBuilder(props: Omit<QueryBuilderProps, 'apiUrl'> & { apiUrl
function queryValidator(query: Query) {
const queryCopy = JSON.parse(JSON.stringify(query));

if (typeof queryCopy.limit !== 'number' || queryCopy.limit < 1 || queryCopy.limit > 50_000) {
queryCopy.limit = 5_000;
// add the last stored timezone if the query is empty
if (JSON.stringify(queryCopy) === '{}' && storedTimezones[0]) {
queryCopy.timezone = storedTimezones[0];
}

/**
* @TODO: Add support for offset
*/
delete queryCopy.offset;

if (!queryCopy.timezone && storedTimezones[0]) {
queryCopy.timezone = storedTimezones[0];
if (typeof queryCopy.limit !== 'number' || queryCopy.limit < 1 || queryCopy.limit > 50_000) {
queryCopy.limit = 5_000;
}

return queryCopy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import {
Badge,
Button,
Dialog,
DialogTrigger,
Expand All @@ -26,6 +25,7 @@ import { useQueryBuilderContext } from './context';
import { PivotAxes, PivotOptions } from './Pivot';
import { ArrowIcon } from './icons/ArrowIcon';
import { AccordionCard } from './components/AccordionCard';
import { OutdatedLabel } from './components/OutdatedLabel';
import { QueryBuilderChartResults } from './QueryBuilderChartResults';

const CHART_HEIGHT = 400;
Expand All @@ -40,26 +40,21 @@ const ALLOWED_CHART_TYPES = ['table', 'line', 'bar', 'area'];

export function QueryBuilderChart(props: QueryBuilderChartProps) {
const [isVizardLoaded, setIsVizardLoaded] = useState(false);
const [isExpanded, setIsExpanded] = useLocalStorage(
'QueryBuilder:Chart:expanded',
false
);
const [isExpanded, setIsExpanded] = useLocalStorage('QueryBuilder:Chart:expanded', false);
const { maxHeight = CHART_HEIGHT, onToggle } = props;
let {
query,
isLoading,
isQueryTouched,
executedQuery,
chartType,
setChartType,
pivotConfig,
updatePivotConfig,
resultSet,
apiToken,
apiUrl,
isResultOutdated,
VizardComponent,
} = useQueryBuilderContext();
const isOutdated = executedQuery && isQueryTouched;
const containerRef = useRef<HTMLDivElement>(null);

if (!ALLOWED_CHART_TYPES.includes(chartType || '')) {
Expand Down Expand Up @@ -146,8 +141,8 @@ export function QueryBuilderChart(props: QueryBuilderChartProps) {
isExpanded ? (
<LoadingOutlined />
) : undefined
) : isOutdated ? (
<Badge type="disabled">OUTDATED</Badge>
) : isResultOutdated ? (
<OutdatedLabel />
) : undefined
}
extra={
Expand Down Expand Up @@ -226,9 +221,7 @@ export function QueryBuilderChart(props: QueryBuilderChartProps) {
}}
>
<>
{isLoading ? (
<Skeleton height={400} layout="chart" padding="0 1x 1x 1x" />
) : undefined}
{isLoading ? <Skeleton height={400} layout="chart" padding="0 1x 1x 1x" /> : undefined}
{chart}
</>
</AccordionCard>
Expand Down
Loading

0 comments on commit 7d77b4a

Please sign in to comment.