Skip to content

Commit

Permalink
Merge branch 'dev' into DVT-240
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfbolat authored Apr 9, 2024
2 parents 2ac0296 + 4528547 commit 98f039a
Show file tree
Hide file tree
Showing 9 changed files with 883 additions and 370 deletions.
480 changes: 201 additions & 279 deletions superset-frontend/src/pages/DvtChart/dvtChartDataCustomize.ts

Large diffs are not rendered by default.

98 changes: 97 additions & 1 deletion superset-frontend/src/pages/DvtChart/dvtChartDataOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const chartFormsOption = {
rolling_type: [
{
label: t('None'),
value: 'null',
value: 'None',
},
{
label: t('mean'),
Expand Down Expand Up @@ -634,6 +634,102 @@ const chartFormsOption = {
value: 'Count as Fraction of Columns',
},
],
label_type: [
{
label: t('Value'),
value: 'value',
},
{
label: t('Category Name'),
value: 'key',
},
{
label: t('Percentage'),
value: 'percent',
},
{
label: t('Category and Value'),
value: 'key_value',
},
{
label: t('Category and Percentage'),
value: 'key_percent',
},
{
label: t('Category, Value and Percentage'),
value: 'key_value_percent',
},
],
header_font_size: [
{
label: 'Tiny',
value: 0.2,
},
{
label: 'Small',
value: 0.3,
},
{
label: 'Normal',
value: 0.4,
},
{
label: 'Large',
value: 0.5,
},
{
label: 'Huge',
value: 0.6,
},
],
subheader_font_size: [
{
label: 'Tiny',
value: 0.125,
},
{
label: 'Small',
value: 0.15,
},
{
label: 'Normal',
value: 0.2,
},
{
label: 'Large',
value: 0.3,
},
{
label: 'Huge',
value: 0.4,
},
],
page_length: [
{
label: t('All'),
value: 0,
},
{
label: '10',
value: 10,
},
{
label: '20',
value: 20,
},
{
label: '50',
value: 50,
},
{
label: '100',
value: 100,
},
{
label: '200',
value: 200,
},
],
};

export { forecastSeasonality, chartFormsOption };
50 changes: 33 additions & 17 deletions superset-frontend/src/pages/DvtChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ import DvtRange from 'src/components/DvtRange';
import DvtSpinner from 'src/components/DvtSpinner';
import ChartContainer from 'src/components/Chart/ChartContainer';
import moment from 'moment';
import { dvtNavbarChartAddSetVizType } from 'src/dvt-redux/dvt-navbarReducer';
import {
dvtNavbarChartAddSetVizType,
dvtNavbarChartsSetTabs,
} from 'src/dvt-redux/dvt-navbarReducer';
import { objectIsEmptyForArray } from 'src/dvt-utils/object-is-empty-for-array';
import openSelectMenuData from 'src/components/DvtOpenSelectMenu/dvtOpenSelectMenuData';
import DvtChartData from './dvtChartData';
Expand Down Expand Up @@ -99,7 +102,7 @@ const DvtChart = () => {
show_empty_columns: true,
rolling_type: {
label: t('None'),
value: 'null',
value: 'None',
},
time_compare: [],
comparison_type: {
Expand Down Expand Up @@ -519,21 +522,22 @@ const DvtChart = () => {
);
setActive(getFormData.viz_type);
setValues({
...values,
x_axis: emptyArrayOrOneFindItem(getFormData.x_axis),
time_grain_sqla: chartFormsFindOptions('time_grain_sqla', {
label: t('Day'),
value: 'P1D',
}),
metrics: getFormData.metrics
metrics: getFormData?.metrics
? getFormData.metrics.map((v: any) => metricsOrColumnsFormation(v))
: [],
groupby: getFormData.groupby
groupby: getFormData?.groupby
? getFormData.groupby.map((v: any) => metricsOrColumnsFormation(v))
: [],
contributionMode: chartFormsFindOptions('contributionMode', ''),
adhoc_filters: [
...filtersOnItem,
...(getFormData.adhoc_filters
...(getFormData?.adhoc_filters
? getFormData.adhoc_filters.map((v: any) =>
adhocFiltersFormation(v),
)
Expand Down Expand Up @@ -562,7 +566,7 @@ const DvtChart = () => {
show_empty_columns: true,
rolling_type: chartFormsFindOptions('rolling_type', {
label: t('None'),
value: 'null',
value: 'None',
}),
time_compare: getFormData?.time_compare
? getFormData.time_compare
Expand Down Expand Up @@ -620,7 +624,7 @@ const DvtChart = () => {
sort_by_metric: getFormData?.sort_by_metric
? getFormData.sort_by_metric
: false,
subheader: getFormData.subheader ? getFormData.subheader : '',
subheader: getFormData?.subheader ? getFormData.subheader : '',
dimension: emptyArrayOrOneFindItem(getFormData.series),
entity: emptyArrayOrOneFindItem(getFormData.entity),
x: emptyArrayOrOneFindItem(getFormData.x),
Expand Down Expand Up @@ -1284,7 +1288,7 @@ const DvtChart = () => {
? [postProcessingRename]
: []),
...(postProcessingRollingChartActives.includes(active) &&
values.rolling_type.value !== 'null'
values.rolling_type.value !== 'None'
? [postProcessingRollingType]
: []),
{
Expand Down Expand Up @@ -1630,6 +1634,12 @@ const DvtChart = () => {
useEffect(
() => () => {
dispatch(dvtNavbarChartAddSetVizType(''));
dispatch(
dvtNavbarChartsSetTabs({
label: t('Data'),
value: 'data',
}),
);
},
[],
);
Expand Down Expand Up @@ -1692,7 +1702,9 @@ const DvtChart = () => {
{fItem.status === 'tabs' && (
<DvtButtonTabs
data={fItem.options?.length ? fItem.options : []}
active={values[fItem.name]}
active={
values[fItem.name] || { label: '', value: '' }
}
setActive={v =>
setValues({ ...values, [fItem.name]: v })
}
Expand All @@ -1704,7 +1716,7 @@ const DvtChart = () => {
placeholder={fItem.placeholder}
popoverLabel={fItem.popper}
number={fItem.number}
value={values[fItem.name]}
value={values[fItem.name] || ''}
onChange={v =>
setValues({ ...values, [fItem.name]: v })
}
Expand All @@ -1715,7 +1727,7 @@ const DvtChart = () => {
label={fItem.label}
placeholder={fItem.placeholder}
popoverLabel={fItem.popper}
selectedValue={values[fItem.name]}
selectedValue={values[fItem.name] || ''}
setSelectedValue={v =>
setValues({ ...values, [fItem.name]: v })
}
Expand All @@ -1729,7 +1741,7 @@ const DvtChart = () => {
label={fItem.label}
placeholder={fItem.placeholder}
// popoverLabel={fItem.popper}
selectedValues={values[fItem.name]}
selectedValues={values[fItem.name] || []}
setSelectedValues={v =>
setValues({ ...values, [fItem.name]: v })
}
Expand Down Expand Up @@ -1774,7 +1786,7 @@ const DvtChart = () => {
{fItem.status === 'checkbox' && (
<DvtCheckbox
label={fItem.label}
checked={values[fItem.name]}
checked={values[fItem.name] || false}
onChange={v =>
setValues({ ...values, [fItem.name]: v })
}
Expand All @@ -1789,7 +1801,7 @@ const DvtChart = () => {
popoverLabel={vfIndex === 0 ? fItem.popper : ''}
placeholder={vfItem.placeholder}
number={vfItem.number}
value={values?.[fItem.name]?.[vfItem.name]}
value={values?.[fItem.name]?.[vfItem.name] || ''}
onChange={v =>
setValues({
...values,
Expand All @@ -1811,7 +1823,9 @@ const DvtChart = () => {
label={vfIndex === 0 ? fItem.label : ''}
popoverLabel={vfIndex === 0 ? fItem.popper : ''}
placeholder={vfItem.placeholder}
selectedValue={values[fItem.name][vfItem.name]}
selectedValue={
values?.[fItem.name]?.[vfItem.name] || ''
}
setSelectedValue={v =>
setValues({
...values,
Expand All @@ -1833,7 +1847,9 @@ const DvtChart = () => {
<DvtColorSelect
label={fItem.label}
popoverLabel={fItem.popper}
value={values[fItem.name]}
value={
values[fItem.name] || { r: 0, g: 0, b: 0, a: 0 }
}
setValue={v =>
setValues({ ...values, [fItem.name]: v })
}
Expand All @@ -1843,7 +1859,7 @@ const DvtChart = () => {
<DvtRange
label={fItem.label}
popoverLabel={fItem.popper}
value={values[fItem.name]}
value={values[fItem.name] || 0}
setValue={v =>
setValues({ ...values, [fItem.name]: v })
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* eslint-disable react-hooks/exhaustive-deps */
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React, { useState } from 'react';
import Icon from 'src/components/Icons/Icon';
import { supersetTheme } from '@superset-ui/core';
import {
StyledDashboardDroppedRow,
StyledDashboardDroppedRowOptions,
StyledDashboardDroppedRowDivider,
} from '../dvtDashboardEdit.module';

interface DvtDashboardEditDividerProps {
deleteClick: () => void;
id: string;
isEdit: boolean;
}

const DvtDashboardEditDivider = ({
deleteClick,
id,
isEdit,
}: DvtDashboardEditDividerProps) => {
const [onHover, setOnHover] = useState<boolean>(false);
const [onDraggable, setOnDraggable] = useState<boolean>(false);

const handleDragStart = (e: React.DragEvent<HTMLDivElement>) => {
e.dataTransfer.setData('drag-drop-move-id', JSON.stringify(id));
};

return (
<StyledDashboardDroppedRow
onMouseLeave={() => setOnHover(false)}
onMouseOver={() => setOnHover(true)}
draggable={onDraggable}
onDragStart={handleDragStart}
>
{isEdit && onHover && (
<StyledDashboardDroppedRowOptions>
<Icon
fileName="dvt-delete"
iconColor={supersetTheme.colors.dvt.grayscale.base}
onClick={deleteClick}
/>
</StyledDashboardDroppedRowOptions>
)}
<StyledDashboardDroppedRowDivider
onDragOver={e => e.preventDefault()}
isEdit={isEdit}
onMouseDown={() => setOnDraggable(true)}
onMouseUp={() => setOnDraggable(false)}
/>
</StyledDashboardDroppedRow>
);
};

export default DvtDashboardEditDivider;
Loading

0 comments on commit 98f039a

Please sign in to comment.