From e3d2e4e6304700a7c7201070f60aca921a967711 Mon Sep 17 00:00:00 2001 From: "chunhui.wang1" Date: Tue, 28 Dec 2021 18:59:22 +0800 Subject: [PATCH 001/384] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=EF=BC=88DataProvider=EF=BC=89=E5=A4=84=E7=90=86=E5=99=A8?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datart/core/base/ExtendProcessor.java | 4 ++ .../processor/DataProviderPostProcessor.java | 11 +++++ .../processor/DataProviderPreProcessor.java | 10 ++++ .../datart/data/provider/ProviderManager.java | 47 +++++++++++++++++-- 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 core/src/main/java/datart/core/base/ExtendProcessor.java create mode 100644 core/src/main/java/datart/core/data/provider/processor/DataProviderPostProcessor.java create mode 100644 core/src/main/java/datart/core/data/provider/processor/DataProviderPreProcessor.java diff --git a/core/src/main/java/datart/core/base/ExtendProcessor.java b/core/src/main/java/datart/core/base/ExtendProcessor.java new file mode 100644 index 000000000..3722aeb20 --- /dev/null +++ b/core/src/main/java/datart/core/base/ExtendProcessor.java @@ -0,0 +1,4 @@ +package datart.core.base; + +public interface ExtendProcessor { +} diff --git a/core/src/main/java/datart/core/data/provider/processor/DataProviderPostProcessor.java b/core/src/main/java/datart/core/data/provider/processor/DataProviderPostProcessor.java new file mode 100644 index 000000000..75797d93a --- /dev/null +++ b/core/src/main/java/datart/core/data/provider/processor/DataProviderPostProcessor.java @@ -0,0 +1,11 @@ +package datart.core.data.provider.processor; + +import datart.core.base.ExtendProcessor; +import datart.core.data.provider.DataProviderSource; +import datart.core.data.provider.Dataframe; +import datart.core.data.provider.ExecuteParam; +import datart.core.data.provider.QueryScript; + +public interface DataProviderPostProcessor extends ExtendProcessor { + public void postRun(Dataframe frame, DataProviderSource config, QueryScript script, ExecuteParam executeParam); +} diff --git a/core/src/main/java/datart/core/data/provider/processor/DataProviderPreProcessor.java b/core/src/main/java/datart/core/data/provider/processor/DataProviderPreProcessor.java new file mode 100644 index 000000000..87d8033c0 --- /dev/null +++ b/core/src/main/java/datart/core/data/provider/processor/DataProviderPreProcessor.java @@ -0,0 +1,10 @@ +package datart.core.data.provider.processor; + +import datart.core.base.ExtendProcessor; +import datart.core.data.provider.DataProviderSource; +import datart.core.data.provider.ExecuteParam; +import datart.core.data.provider.QueryScript; + +public interface DataProviderPreProcessor extends ExtendProcessor { + public void preRun(DataProviderSource config, QueryScript script, ExecuteParam executeParam); +} diff --git a/data-providers/src/main/java/datart/data/provider/ProviderManager.java b/data-providers/src/main/java/datart/data/provider/ProviderManager.java index 896bf7043..406a386c5 100644 --- a/data-providers/src/main/java/datart/data/provider/ProviderManager.java +++ b/data-providers/src/main/java/datart/data/provider/ProviderManager.java @@ -18,10 +18,14 @@ package datart.data.provider; +import datart.core.base.ExtendProcessor; import datart.core.base.exception.Exceptions; import datart.core.data.provider.*; +import datart.core.data.provider.processor.DataProviderPostProcessor; +import datart.core.data.provider.processor.DataProviderPreProcessor; import datart.data.provider.optimize.DataProviderExecuteOptimizer; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -35,6 +39,9 @@ @Slf4j public class ProviderManager extends DataProviderExecuteOptimizer implements DataProviderManager { + @Autowired(required=false) + private List extendProcessors = new ArrayList(); + private static final Map cachedDataProviders = new ConcurrentSkipListMap<>(); @Override @@ -90,17 +97,51 @@ public Dataframe execute(DataProviderSource source, QueryScript queryScript, Exe } } + dataframe = queryScript(source, queryScript, param, queryKey); + + if (param.isCacheEnable()) { + setCache(queryKey, dataframe, param.getCacheExpires()); + } + return dataframe; + + } + + private Dataframe queryScript(DataProviderSource source, QueryScript queryScript, ExecuteParam param, String queryKey) throws Exception { + + //sql + param preprocessing + this.preProcessorQuery(source,queryScript,param); + + Dataframe dataframe; if (param.isConcurrencyOptimize()) { dataframe = runOptimize(queryKey, source, queryScript, param); } else { dataframe = run(source, queryScript, param); } - if (param.isCacheEnable()) { - setCache(queryKey, dataframe, param.getCacheExpires()); - } + //data postprocessing + this.postProcessorQuery(dataframe,source,queryScript,param); + return dataframe; + } + + private void preProcessorQuery(DataProviderSource source, QueryScript queryScript, ExecuteParam param){ + if(!CollectionUtils.isEmpty(extendProcessors)){ + for(ExtendProcessor processor: extendProcessors){ + if(processor instanceof DataProviderPreProcessor){ + ((DataProviderPreProcessor) processor).preRun(source,queryScript,param); + } + } + } + } + private void postProcessorQuery(Dataframe dataframe,DataProviderSource source, QueryScript queryScript, ExecuteParam param){ + if(!CollectionUtils.isEmpty(extendProcessors)){ + for(ExtendProcessor processor: extendProcessors){ + if(processor instanceof DataProviderPostProcessor){ + ((DataProviderPostProcessor) processor).postRun(dataframe,source,queryScript,param); + } + } + } } @Override From 9b9df8befdf5968cbf6ab11937170b93c1dd66b8 Mon Sep 17 00:00:00 2001 From: "chunhui.wang1" Date: Tue, 28 Dec 2021 20:17:57 +0800 Subject: [PATCH 002/384] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=EF=BC=88DataProvider=EF=BC=89=E5=A4=84=E7=90=86=E5=99=A8?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E7=82=B9,=E8=B0=83=E6=95=B4=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/datart/data/provider/ProviderManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data-providers/src/main/java/datart/data/provider/ProviderManager.java b/data-providers/src/main/java/datart/data/provider/ProviderManager.java index 406a386c5..8526b58e0 100644 --- a/data-providers/src/main/java/datart/data/provider/ProviderManager.java +++ b/data-providers/src/main/java/datart/data/provider/ProviderManager.java @@ -97,7 +97,7 @@ public Dataframe execute(DataProviderSource source, QueryScript queryScript, Exe } } - dataframe = queryScript(source, queryScript, param, queryKey); + dataframe = runScript(source, queryScript, param, queryKey); if (param.isCacheEnable()) { setCache(queryKey, dataframe, param.getCacheExpires()); @@ -106,7 +106,7 @@ public Dataframe execute(DataProviderSource source, QueryScript queryScript, Exe } - private Dataframe queryScript(DataProviderSource source, QueryScript queryScript, ExecuteParam param, String queryKey) throws Exception { + private Dataframe runScript(DataProviderSource source, QueryScript queryScript, ExecuteParam param, String queryKey) throws Exception { //sql + param preprocessing this.preProcessorQuery(source,queryScript,param); From 0999219df42e6a58f0a677b05cd32f35ef9d4f02 Mon Sep 17 00:00:00 2001 From: xieliuduo Date: Wed, 5 Jan 2022 11:52:42 +0800 Subject: [PATCH 003/384] refactor: Uniform variable name TIME_FORMATTER --- .../DateConditionConfiguration.tsx | 9 +++------ .../ChartTimeSelector/ExactTimeSelector.tsx | 4 ++-- .../MannualRangeTimeSelector.tsx | 4 ++-- .../ManualSingleTimeSelector.tsx | 4 ++-- .../models/ChartHttpRequest.ts | 6 +++--- .../MediaWidget/TimerWidget/index.tsx | 6 +++--- .../components/ControllerWidgetPanel/utils.ts | 17 +++++++---------- .../src/app/pages/DashBoardPage/utils/index.ts | 10 +++++----- .../pages/MainPage/pages/SchedulePage/utils.ts | 10 +++------- .../pages/VariablePage/DefaultValue.tsx | 7 ++++--- .../MainPage/pages/VariablePage/constants.ts | 2 -- .../pages/MainPage/pages/VariablePage/index.tsx | 13 ++++--------- .../ViewPage/Main/Properties/Variables.tsx | 9 +++------ .../components/RangeTimePickerFilter.tsx | 4 ++-- frontend/src/app/utils/time.ts | 8 ++------ frontend/src/globalConstants.ts | 2 +- 16 files changed, 46 insertions(+), 69 deletions(-) diff --git a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartFieldAction/FilterControlPanel/DateConditionConfiguration.tsx b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartFieldAction/FilterControlPanel/DateConditionConfiguration.tsx index 8fcb7b9e7..21fd21bb3 100644 --- a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartFieldAction/FilterControlPanel/DateConditionConfiguration.tsx +++ b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartFieldAction/FilterControlPanel/DateConditionConfiguration.tsx @@ -20,10 +20,7 @@ import { Tabs } from 'antd'; import useI18NPrefix, { I18NComponentProps } from 'app/hooks/useI18NPrefix'; import { FilterConditionType } from 'app/types/ChartConfig'; import { formatTime } from 'app/utils/time'; -import { - FILTER_TIME_FORMATTER_IN_QUERY, - RECOMMEND_TIME, -} from 'globalConstants'; +import { RECOMMEND_TIME, TIME_FORMATTER } from 'globalConstants'; import moment from 'moment'; import { FC, memo, useState } from 'react'; import styled from 'styled-components/macro'; @@ -56,8 +53,8 @@ const DateConditionConfiguration: FC< } else if (conditionType === FilterConditionType.RangeTime) { const filterRow = new ConditionBuilder(condition) .setValue([ - formatTime(moment(), FILTER_TIME_FORMATTER_IN_QUERY), - formatTime(moment(), FILTER_TIME_FORMATTER_IN_QUERY), + formatTime(moment(), TIME_FORMATTER), + formatTime(moment(), TIME_FORMATTER), ]) .asRangeTime(); onConditionChange?.(filterRow); diff --git a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/ExactTimeSelector.tsx b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/ExactTimeSelector.tsx index 49a649d8f..0d3e4b446 100644 --- a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/ExactTimeSelector.tsx +++ b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/ExactTimeSelector.tsx @@ -20,7 +20,7 @@ import { DatePicker } from 'antd'; import useI18NPrefix, { I18NComponentProps } from 'app/hooks/useI18NPrefix'; import { TimeFilterConditionValue } from 'app/types/ChartConfig'; import { formatTime } from 'app/utils/time'; -import { FILTER_TIME_FORMATTER_IN_QUERY } from 'globalConstants'; +import { TIME_FORMATTER } from 'globalConstants'; import moment from 'moment'; import { FC, memo } from 'react'; @@ -33,7 +33,7 @@ const ExactTimeSelector: FC< const t = useI18NPrefix(i18nPrefix); const handleMomentTimeChange = momentTime => { - const timeStr = formatTime(momentTime, FILTER_TIME_FORMATTER_IN_QUERY); + const timeStr = formatTime(momentTime, TIME_FORMATTER); onChange?.(timeStr); }; diff --git a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/MannualRangeTimeSelector.tsx b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/MannualRangeTimeSelector.tsx index 303ced8ad..d9e9b7210 100644 --- a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/MannualRangeTimeSelector.tsx +++ b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/MannualRangeTimeSelector.tsx @@ -20,7 +20,7 @@ import { Row, Space } from 'antd'; import { I18NComponentProps } from 'app/hooks/useI18NPrefix'; import { FilterCondition, FilterConditionType } from 'app/types/ChartConfig'; import { formatTime, getTime } from 'app/utils/time'; -import { FILTER_TIME_FORMATTER_IN_QUERY } from 'globalConstants'; +import { TIME_FORMATTER } from 'globalConstants'; import { FC, memo, useState } from 'react'; import ChartFilterCondition, { ConditionBuilder, @@ -60,7 +60,7 @@ const MannualRangeTimeSelector: FC< t.unit, t.isStart, ); - return formatTime(time, FILTER_TIME_FORMATTER_IN_QUERY); + return formatTime(time, TIME_FORMATTER); } return t; }); diff --git a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/ManualSingleTimeSelector.tsx b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/ManualSingleTimeSelector.tsx index ad67d633b..92b16aba0 100644 --- a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/ManualSingleTimeSelector.tsx +++ b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTimeSelector/ManualSingleTimeSelector.tsx @@ -21,7 +21,7 @@ import useI18NPrefix, { I18NComponentProps } from 'app/hooks/useI18NPrefix'; import { TimeFilterConditionValue } from 'app/types/ChartConfig'; import { TimeFilterValueCategory } from 'app/types/FilterControlPanel'; import { formatTime } from 'app/utils/time'; -import { FILTER_TIME_FORMATTER_IN_QUERY } from 'globalConstants'; +import { TIME_FORMATTER } from 'globalConstants'; import moment from 'moment'; import { FC, memo, useState } from 'react'; import styled from 'styled-components/macro'; @@ -45,7 +45,7 @@ const ManualSingleTimeSelector: FC< const handleTimeCategoryChange = type => { setType(type); if (type === TimeFilterValueCategory.Exact) { - onTimeChange?.(formatTime(moment(), FILTER_TIME_FORMATTER_IN_QUERY)); + onTimeChange?.(formatTime(moment(), TIME_FORMATTER)); } else if (type === TimeFilterValueCategory.Relative) { onTimeChange?.({ unit: 'd', amount: 1, direction: '-' }); } else { diff --git a/frontend/src/app/pages/ChartWorkbenchPage/models/ChartHttpRequest.ts b/frontend/src/app/pages/ChartWorkbenchPage/models/ChartHttpRequest.ts index 08829f946..10db3114f 100644 --- a/frontend/src/app/pages/ChartWorkbenchPage/models/ChartHttpRequest.ts +++ b/frontend/src/app/pages/ChartWorkbenchPage/models/ChartHttpRequest.ts @@ -24,7 +24,7 @@ import { getTime, recommendTimeRangeConverter, } from 'app/utils/time'; -import { FILTER_TIME_FORMATTER_IN_QUERY } from 'globalConstants'; +import { TIME_FORMATTER } from 'globalConstants'; import { isEmptyArray, IsKeyIn } from 'utils/object'; import { AggregateFieldActionType, @@ -189,9 +189,9 @@ export class ChartDataRequestBuilder { value.unit, value.isStart, ); - return formatTime(time, FILTER_TIME_FORMATTER_IN_QUERY); + return formatTime(time, TIME_FORMATTER); } - return formatTime(value, FILTER_TIME_FORMATTER_IN_QUERY); + return formatTime(value, TIME_FORMATTER); }; const _transformFieldValues = (field: ChartDataSectionField) => { diff --git a/frontend/src/app/pages/DashBoardPage/components/WidgetCore/MediaWidget/TimerWidget/index.tsx b/frontend/src/app/pages/DashBoardPage/components/WidgetCore/MediaWidget/TimerWidget/index.tsx index 549bcc905..bc958d9b3 100644 --- a/frontend/src/app/pages/DashBoardPage/components/WidgetCore/MediaWidget/TimerWidget/index.tsx +++ b/frontend/src/app/pages/DashBoardPage/components/WidgetCore/MediaWidget/TimerWidget/index.tsx @@ -26,7 +26,7 @@ import { BoardActionContext } from 'app/pages/DashBoardPage/contexts/BoardAction import { WidgetContext } from 'app/pages/DashBoardPage/contexts/WidgetContext'; import { WidgetInfoContext } from 'app/pages/DashBoardPage/contexts/WidgetInfoContext'; import { MediaWidgetContent } from 'app/pages/DashBoardPage/pages/Board/slice/types'; -import { DEFAULT_VALUE_DATE_FORMAT } from 'app/pages/MainPage/pages/VariablePage/constants'; +import { TIME_FORMATTER } from 'globalConstants'; import produce from 'immer'; import moment from 'moment'; import React, { useContext, useEffect, useMemo, useState } from 'react'; @@ -47,7 +47,7 @@ const FONT_DATA = { }; const FORMAT_DATA = { comType: 'input', - default: DEFAULT_VALUE_DATE_FORMAT, + default: TIME_FORMATTER, disabled: undefined, key: 'timeFormat', label: '格式', @@ -73,7 +73,7 @@ const TimerWidget: React.FC = () => { ); const [currentTime, setCurrentTime] = useState( - moment().format(timerConfig?.time?.timeFormat || DEFAULT_VALUE_DATE_FORMAT), + moment().format(timerConfig?.time?.timeFormat || TIME_FORMATTER), ); useEffect(() => { const timerConfig: TimerConfig = { diff --git a/frontend/src/app/pages/DashBoardPage/pages/BoardEditor/components/ControllerWidgetPanel/utils.ts b/frontend/src/app/pages/DashBoardPage/pages/BoardEditor/components/ControllerWidgetPanel/utils.ts index 0523b2924..5fa615964 100644 --- a/frontend/src/app/pages/DashBoardPage/pages/BoardEditor/components/ControllerWidgetPanel/utils.ts +++ b/frontend/src/app/pages/DashBoardPage/pages/BoardEditor/components/ControllerWidgetPanel/utils.ts @@ -15,15 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import { ValueOptionType, ValueOptionTypes, } from 'app/pages/DashBoardPage/constants'; -import { - DEFAULT_VALUE_DATE_FORMAT, - VariableValueTypes, -} from 'app/pages/MainPage/pages/VariablePage/constants'; +import { VariableValueTypes } from 'app/pages/MainPage/pages/VariablePage/constants'; import { ChartDataViewFieldCategory, ChartDataViewFieldType, @@ -35,6 +31,7 @@ import { } from 'app/types/FilterControlPanel'; import moment, { Moment } from 'moment'; import { FilterSqlOperator } from '../../../../../../../globalConstants'; +import { TIME_FORMATTER } from './../../../../../../../globalConstants'; import { DateControllerTypes, NumericalControllerTypes, @@ -118,14 +115,14 @@ export const formatControlDateToMoment = (config: ControllerConfig) => { if (filterDate.startTime && filterDate.startTime.exactValue) { if (typeof filterDate.startTime.exactValue === 'string') { let exactTime = filterDate.startTime.exactValue; - let newExactTime = moment(exactTime, DEFAULT_VALUE_DATE_FORMAT); + let newExactTime = moment(exactTime, TIME_FORMATTER); config.controllerDate.startTime.exactValue = newExactTime; } } if (filterDate.endTime && filterDate.endTime.exactValue) { if (typeof filterDate.endTime.exactValue === 'string') { let exactTime = filterDate.endTime.exactValue; - let newExactTime = moment(exactTime, DEFAULT_VALUE_DATE_FORMAT); + let newExactTime = moment(exactTime, TIME_FORMATTER); config.controllerDate.endTime!.exactValue = newExactTime; } } @@ -139,14 +136,14 @@ export const formatControlDateToStr = (config: ControllerConfig) => { if (filterDate.startTime && filterDate.startTime.exactValue) { if ((filterDate.startTime.exactValue as Moment).format) { let exactTime = filterDate.startTime.exactValue as Moment; - let newExactTime = exactTime.format(DEFAULT_VALUE_DATE_FORMAT); + let newExactTime = exactTime.format(TIME_FORMATTER); config.controllerDate.startTime.exactValue = newExactTime; } } if (filterDate.endTime && filterDate.endTime.exactValue) { if ((filterDate.endTime.exactValue as Moment).format) { let exactTime = filterDate.endTime.exactValue as Moment; - let newExactTime = exactTime.format(DEFAULT_VALUE_DATE_FORMAT); + let newExactTime = exactTime.format(TIME_FORMATTER); config.controllerDate.endTime!.exactValue = newExactTime; } } @@ -295,7 +292,7 @@ export const formatDateByPickType = ( pickerType: PickerType, momentTime: Moment, ) => { - const formatTemp = DEFAULT_VALUE_DATE_FORMAT; + const formatTemp = TIME_FORMATTER; if (!momentTime) { return null; } diff --git a/frontend/src/app/pages/DashBoardPage/utils/index.ts b/frontend/src/app/pages/DashBoardPage/utils/index.ts index 646583fb8..d872a50cc 100644 --- a/frontend/src/app/pages/DashBoardPage/utils/index.ts +++ b/frontend/src/app/pages/DashBoardPage/utils/index.ts @@ -3,7 +3,6 @@ import { transformToViewConfig, } from 'app/pages/ChartWorkbenchPage/models/ChartHttpRequest'; import { RelatedView } from 'app/pages/DashBoardPage/pages/Board/slice/types'; -import { DEFAULT_VALUE_DATE_FORMAT } from 'app/pages/MainPage/pages/VariablePage/constants'; import { ChartDataSectionField, ChartDataSectionType, @@ -17,7 +16,7 @@ import { TimeFilterValueCategory, } from 'app/types/FilterControlPanel'; import { getTime } from 'app/utils/time'; -import { FilterSqlOperator } from 'globalConstants'; +import { FilterSqlOperator, TIME_FORMATTER } from 'globalConstants'; import i18next from 'i18next'; import moment from 'moment'; import { STORAGE_IMAGE_KEY_PREFIX } from '../constants'; @@ -36,6 +35,7 @@ import { import { ChartRequestFilter } from './../../ChartWorkbenchPage/models/ChartHttpRequest'; import { PickerType } from './../pages/BoardEditor/components/ControllerWidgetPanel/types'; import { getLinkedColumn } from './widget'; + export const convertImageUrl = (urlKey: string = ''): string => { if (urlKey.startsWith(STORAGE_IMAGE_KEY_PREFIX)) { return localStorage.getItem(urlKey) || ''; @@ -284,7 +284,7 @@ export const getControllerDateValues = (obj: { } else { const { amount, unit, direction } = startTime.relativeValue!; const time = getTime(+(direction + amount), unit)(unit, true); - timeValues[0] = time.format(DEFAULT_VALUE_DATE_FORMAT); + timeValues[0] = time.format(TIME_FORMATTER); } if (endTime) { if (endTime.relativeOrExact === TimeFilterValueCategory.Exact) { @@ -300,7 +300,7 @@ export const getControllerDateValues = (obj: { } else { const { amount, unit, direction } = endTime.relativeValue!; const time = getTime(+(direction + amount), unit)(unit, false); - timeValues[1] = time.format(DEFAULT_VALUE_DATE_FORMAT); + timeValues[1] = time.format(TIME_FORMATTER); } } @@ -336,7 +336,7 @@ export const adjustRangeDataEndValue = ( default: break; } - let end = adjustTime.format(DEFAULT_VALUE_DATE_FORMAT); + let end = adjustTime.format(TIME_FORMATTER); return end; }; export const getBoardChartRequests = (params: { diff --git a/frontend/src/app/pages/MainPage/pages/SchedulePage/utils.ts b/frontend/src/app/pages/MainPage/pages/SchedulePage/utils.ts index 46b6db614..428a867dc 100644 --- a/frontend/src/app/pages/MainPage/pages/SchedulePage/utils.ts +++ b/frontend/src/app/pages/MainPage/pages/SchedulePage/utils.ts @@ -1,6 +1,6 @@ +import { TIME_FORMATTER } from 'globalConstants'; import moment from 'moment'; import { PermissionLevels, ResourceTypes } from '../PermissionPage/constants'; -import { DEFAULT_VALUE_DATE_FORMAT } from '../VariablePage/constants'; import { JobTypes, TimeModes, VizTypes } from './constants'; import { AddScheduleParams, Schedule, VizContentsItem } from './slice/types'; import { FormValues } from './types'; @@ -105,12 +105,8 @@ export const toScheduleSubmitParams = ( ? cronExpression : getCronExpressionByPartition(values), type: jobType as JobTypes, - startDate: dateRange[0] - ? dateRange[0].format(DEFAULT_VALUE_DATE_FORMAT) - : undefined, - endDate: dateRange[1] - ? dateRange[1].format(DEFAULT_VALUE_DATE_FORMAT) - : undefined, + startDate: dateRange[0] ? dateRange[0].format(TIME_FORMATTER) : undefined, + endDate: dateRange[1] ? dateRange[1].format(TIME_FORMATTER) : undefined, orgId, config: jobConfigStr, }; diff --git a/frontend/src/app/pages/MainPage/pages/VariablePage/DefaultValue.tsx b/frontend/src/app/pages/MainPage/pages/VariablePage/DefaultValue.tsx index 58ed14c29..46ab0ca1c 100644 --- a/frontend/src/app/pages/MainPage/pages/VariablePage/DefaultValue.tsx +++ b/frontend/src/app/pages/MainPage/pages/VariablePage/DefaultValue.tsx @@ -19,11 +19,12 @@ import { CheckOutlined } from '@ant-design/icons'; import { Button, DatePicker, Input, InputNumber, Space, Tag } from 'antd'; import useI18NPrefix from 'app/hooks/useI18NPrefix'; +import { TIME_FORMATTER } from 'globalConstants'; import moment from 'moment'; import { memo, useCallback, useEffect, useState } from 'react'; import styled from 'styled-components/macro'; import { SPACE, SPACE_TIMES } from 'styles/StyleConstants'; -import { DEFAULT_VALUE_DATE_FORMAT, VariableValueTypes } from './constants'; +import { VariableValueTypes } from './constants'; interface DefaultValueProps { type: VariableValueTypes; @@ -117,7 +118,7 @@ export const DefaultValue = memo( case VariableValueTypes.Date: conditionalInputComponent = ( - (d as Moment).format(DEFAULT_VALUE_DATE_FORMAT), + (d as Moment).format(TIME_FORMATTER), ); } @@ -242,7 +237,7 @@ export function VariablePage() { value: cr.value && (editingVariable?.valueType === VariableValueTypes.Date - ? cr.value.map(m => (m as Moment).format(DEFAULT_VALUE_DATE_FORMAT)) + ? cr.value.map(m => (m as Moment).format(TIME_FORMATTER)) : cr.value), })); diff --git a/frontend/src/app/pages/MainPage/pages/ViewPage/Main/Properties/Variables.tsx b/frontend/src/app/pages/MainPage/pages/ViewPage/Main/Properties/Variables.tsx index 98ec187de..529fa7392 100644 --- a/frontend/src/app/pages/MainPage/pages/ViewPage/Main/Properties/Variables.tsx +++ b/frontend/src/app/pages/MainPage/pages/ViewPage/Main/Properties/Variables.tsx @@ -29,7 +29,6 @@ import { ListItem, ListTitle } from 'app/components'; import useI18NPrefix from 'app/hooks/useI18NPrefix'; import { getRoles } from 'app/pages/MainPage/pages/MemberPage/slice/thunks'; import { - DEFAULT_VALUE_DATE_FORMAT, VariableScopes, VariableTypes, VariableValueTypes, @@ -43,7 +42,7 @@ import { VariableFormModel } from 'app/pages/MainPage/pages/VariablePage/types'; import { VariableForm } from 'app/pages/MainPage/pages/VariablePage/VariableForm'; import { selectOrgId } from 'app/pages/MainPage/slice/selectors'; import classnames from 'classnames'; -import { CommonFormTypes } from 'globalConstants'; +import { CommonFormTypes, TIME_FORMATTER } from 'globalConstants'; import { Moment } from 'moment'; import { memo, @@ -181,7 +180,7 @@ export const Variables = memo(() => { let defaultValue: any = values.defaultValue; if (values.valueType === VariableValueTypes.Date && !values.expression) { defaultValue = values.defaultValue.map(d => - (d as Moment).format(DEFAULT_VALUE_DATE_FORMAT), + (d as Moment).format(TIME_FORMATTER), ); } @@ -240,9 +239,7 @@ export const Variables = memo(() => { value: JSON.stringify( cr.value && (editingVariable?.valueType === VariableValueTypes.Date - ? cr.value.map(d => - (d as Moment).format(DEFAULT_VALUE_DATE_FORMAT), - ) + ? cr.value.map(d => (d as Moment).format(TIME_FORMATTER)) : cr.value), ), })); diff --git a/frontend/src/app/pages/MainPage/pages/VizPage/ChartPreview/components/ControllerPanel/components/RangeTimePickerFilter.tsx b/frontend/src/app/pages/MainPage/pages/VizPage/ChartPreview/components/ControllerPanel/components/RangeTimePickerFilter.tsx index cdd53284a..d59311815 100644 --- a/frontend/src/app/pages/MainPage/pages/VizPage/ChartPreview/components/ControllerPanel/components/RangeTimePickerFilter.tsx +++ b/frontend/src/app/pages/MainPage/pages/VizPage/ChartPreview/components/ControllerPanel/components/RangeTimePickerFilter.tsx @@ -24,7 +24,7 @@ import { getTime, recommendTimeRangeConverter, } from 'app/utils/time'; -import { FILTER_TIME_FORMATTER_IN_QUERY } from 'globalConstants'; +import { TIME_FORMATTER } from 'globalConstants'; import moment from 'moment'; import { FC, memo, useMemo } from 'react'; import { PresentControllerFilterProps } from '.'; @@ -36,7 +36,7 @@ const toMoment = t => { } if (Boolean(t) && typeof t === 'object' && 'unit' in t) { const time = getTime(+(t.direction + t.amount), t.unit)(t.unit, t.isStart); - return moment(formatTime(time, FILTER_TIME_FORMATTER_IN_QUERY)); + return moment(formatTime(time, TIME_FORMATTER)); } return moment(t); }; diff --git a/frontend/src/app/utils/time.ts b/frontend/src/app/utils/time.ts index 93713cc25..92a92493b 100644 --- a/frontend/src/app/utils/time.ts +++ b/frontend/src/app/utils/time.ts @@ -16,8 +16,7 @@ * limitations under the License. */ -import { DEFAULT_VALUE_DATE_FORMAT } from 'app/pages/MainPage/pages/VariablePage/constants'; -import { RECOMMEND_TIME } from 'globalConstants'; +import { RECOMMEND_TIME, TIME_FORMATTER } from 'globalConstants'; import moment, { Moment, unitOfTime } from 'moment'; export function getTimeRange( @@ -27,10 +26,7 @@ export function getTimeRange( return unitOfTime => { const startTime = moment().add(amount?.[0], unit).startOf(unitOfTime); const endTime = moment().add(amount?.[1], unit).endOf(unitOfTime); - return [ - startTime.format(DEFAULT_VALUE_DATE_FORMAT), - endTime.format(DEFAULT_VALUE_DATE_FORMAT), - ]; + return [startTime.format(TIME_FORMATTER), endTime.format(TIME_FORMATTER)]; }; } diff --git a/frontend/src/globalConstants.ts b/frontend/src/globalConstants.ts index 8a64509d3..d789f682f 100644 --- a/frontend/src/globalConstants.ts +++ b/frontend/src/globalConstants.ts @@ -144,7 +144,7 @@ export enum FilterSqlOperator { GreaterThanOrEqual = 'GTE', } -export const FILTER_TIME_FORMATTER_IN_QUERY = 'yyyy-MM-DD HH:mm:ss'; +export const TIME_FORMATTER = 'YYYY-MM-DD HH:mm:ss'; export const CONTROLLER_WIDTH_OPTIONS = [ { label: 'auto', value: 'auto' }, From b1f2dd5d07ef4bbb90d3b7e266efde91d592e04e Mon Sep 17 00:00:00 2001 From: xieliuduo Date: Wed, 5 Jan 2022 11:59:34 +0800 Subject: [PATCH 004/384] refactor: DATE_FORMATTER --- .../components/ChartFieldAction/NumberFormatAction.tsx | 8 ++++++-- .../app/pages/DashBoardPage/pages/Board/slice/types.ts | 2 +- .../pages/SchedulePage/EditorPage/BasicBaseForm/index.tsx | 3 ++- frontend/src/globalConstants.ts | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartFieldAction/NumberFormatAction.tsx b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartFieldAction/NumberFormatAction.tsx index fa413c1df..c8c483b77 100644 --- a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartFieldAction/NumberFormatAction.tsx +++ b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartFieldAction/NumberFormatAction.tsx @@ -35,7 +35,11 @@ import { } from 'app/types/ChartConfig'; import { CURRENCIES } from 'app/utils/currency'; import { updateBy } from 'app/utils/mutation'; -import { NumberUnitKey, NumericUnitDescriptions } from 'globalConstants'; +import { + DATE_FORMATTER, + NumberUnitKey, + NumericUnitDescriptions, +} from 'globalConstants'; import { FC, useState } from 'react'; import styled from 'styled-components/macro'; import { SPACE_TIMES } from 'styles/StyleConstants'; @@ -62,7 +66,7 @@ const DefaultFormatDetailConfig: IFieldFormatConfig = { decimalPlaces: 2, }, [FieldFormatType.DATE]: { - format: 'YYYY-MM-DD', + format: DATE_FORMATTER, }, [FieldFormatType.CUSTOM]: { format: '', diff --git a/frontend/src/app/pages/DashBoardPage/pages/Board/slice/types.ts b/frontend/src/app/pages/DashBoardPage/pages/Board/slice/types.ts index 1a7db5d1d..bde0c1d3b 100644 --- a/frontend/src/app/pages/DashBoardPage/pages/Board/slice/types.ts +++ b/frontend/src/app/pages/DashBoardPage/pages/Board/slice/types.ts @@ -280,7 +280,7 @@ export type MediaWidgetContent = { timerConfig?: { time: { timeDuration: number; // 定时器刷新时间 - timeFormat: string; // 'YYYY-MM-DD HH:mm:ss' + timeFormat: string; // }; font: { color: string; diff --git a/frontend/src/app/pages/MainPage/pages/SchedulePage/EditorPage/BasicBaseForm/index.tsx b/frontend/src/app/pages/MainPage/pages/SchedulePage/EditorPage/BasicBaseForm/index.tsx index b915b67af..ec0d5fb3b 100644 --- a/frontend/src/app/pages/MainPage/pages/SchedulePage/EditorPage/BasicBaseForm/index.tsx +++ b/frontend/src/app/pages/MainPage/pages/SchedulePage/EditorPage/BasicBaseForm/index.tsx @@ -1,5 +1,6 @@ import { DatePicker, Form, Input, Radio } from 'antd'; import useI18NPrefix from 'app/hooks/useI18NPrefix'; +import { TIME_FORMATTER } from 'globalConstants'; import { FC, useCallback } from 'react'; import { JobTypes, JOB_TYPES_OPTIONS } from '../../constants'; import { checkScheduleName } from '../../services'; @@ -59,7 +60,7 @@ export const BasicBaseForm: FC = ({ /> - + diff --git a/frontend/src/globalConstants.ts b/frontend/src/globalConstants.ts index d789f682f..d3f2492b2 100644 --- a/frontend/src/globalConstants.ts +++ b/frontend/src/globalConstants.ts @@ -143,7 +143,7 @@ export enum FilterSqlOperator { LessThanOrEqual = 'LTE', GreaterThanOrEqual = 'GTE', } - +export const DATE_FORMATTER = 'YYYY-MM-DD'; export const TIME_FORMATTER = 'YYYY-MM-DD HH:mm:ss'; export const CONTROLLER_WIDTH_OPTIONS = [ From 1616a50cc474a150e084ea115c9e59aaadfe0869 Mon Sep 17 00:00:00 2001 From: "jin.gao" Date: Wed, 5 Jan 2022 16:24:08 +0800 Subject: [PATCH 005/384] =?UTF-8?q?fix:=20=E6=95=B0=E6=8D=AE=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E5=88=97=E8=A1=A8=E5=9B=BD=E9=99=85=E5=8C=96=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/pages/MainPage/pages/ViewPage/Sidebar/FolderTree.tsx | 2 +- .../src/app/pages/MainPage/pages/ViewPage/Sidebar/Recycle.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/pages/MainPage/pages/ViewPage/Sidebar/FolderTree.tsx b/frontend/src/app/pages/MainPage/pages/ViewPage/Sidebar/FolderTree.tsx index 2a7b75acd..c89819f8b 100644 --- a/frontend/src/app/pages/MainPage/pages/ViewPage/Sidebar/FolderTree.tsx +++ b/frontend/src/app/pages/MainPage/pages/ViewPage/Sidebar/FolderTree.tsx @@ -57,7 +57,7 @@ export const FolderTree = memo(({ treeData }: FolderTreeProps) => { const currentEditingViewKey = useSelector(selectCurrentEditingViewKey); const orgId = useSelector(selectOrgId); const viewsData = useSelector(selectViews); - const t = useI18NPrefix('view.form'); + const t = useI18NPrefix('view.saveForm'); const tg = useI18NPrefix('global'); useEffect(() => { diff --git a/frontend/src/app/pages/MainPage/pages/ViewPage/Sidebar/Recycle.tsx b/frontend/src/app/pages/MainPage/pages/ViewPage/Sidebar/Recycle.tsx index 0c0ab9a3a..a6a427ad4 100644 --- a/frontend/src/app/pages/MainPage/pages/ViewPage/Sidebar/Recycle.tsx +++ b/frontend/src/app/pages/MainPage/pages/ViewPage/Sidebar/Recycle.tsx @@ -66,7 +66,7 @@ export const Recycle = memo(({ list }: RecycleProps) => { const views = useSelector(selectViews); const isOwner = useSelector(selectIsOrgOwner); const permissionMap = useSelector(selectPermissionMap); - const t = useI18NPrefix('view.form'); + const t = useI18NPrefix('view.saveForm'); const tg = useI18NPrefix('global'); useEffect(() => { From 7c411479345064d51067d09aa4e5c46e27259be4 Mon Sep 17 00:00:00 2001 From: Stephen Cui <229063661@qq.com> Date: Wed, 5 Jan 2022 16:45:18 +0800 Subject: [PATCH 006/384] fix(chart): fix pie chart center label issue --- .../components/ChartGraph/BasicPieChart/BasicPieChart.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartGraph/BasicPieChart/BasicPieChart.tsx b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartGraph/BasicPieChart/BasicPieChart.tsx index 1fa4cc66d..012ab0217 100644 --- a/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartGraph/BasicPieChart/BasicPieChart.tsx +++ b/frontend/src/app/pages/ChartWorkbenchPage/components/ChartOperationPanel/components/ChartGraph/BasicPieChart/BasicPieChart.tsx @@ -272,7 +272,13 @@ class BasicPieChart extends Chart { const position = getStyleValueByGroup(styles, 'label', 'position'); const font = getStyleValueByGroup(styles, 'label', 'font'); const formatter = this.getLabelFormatter(styles); - return { show, position, ...font, formatter }; + + return { + show: position === 'center' ? false : show, + position, + ...font, + formatter, + }; } getLabelFormatter(styles) { From bc6ddce0968ab291a472b4b13b4a1013323dd8b5 Mon Sep 17 00:00:00 2001 From: "jin.gao" Date: Wed, 5 Jan 2022 17:09:16 +0800 Subject: [PATCH 007/384] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8F=8A=E5=85=B6=E7=9B=AE=E5=BD=95=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=E5=9B=9E=E6=94=B6=E7=AB=99=E6=97=A0=E6=B3=95=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/utils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/utils.ts b/frontend/src/utils/utils.ts index c8f6ad7d5..a6717c768 100644 --- a/frontend/src/utils/utils.ts +++ b/frontend/src/utils/utils.ts @@ -230,7 +230,10 @@ export function getPath( path: string[] = [], ) { if (!item?.parentId) { - return [rootId].concat(item.id).concat(path); + if (item) { + return [rootId].concat(item.id).concat(path); + } + return [rootId].concat(path); } else { const parent = list.find(({ id }) => id === item.parentId)!; return getPath(list, parent, rootId, [item.id].concat(path)); @@ -348,4 +351,3 @@ export function fastDeleteArrayElement(arr: any[], index: number) { arr[index] = arr[arr.length - 1]; arr.pop(); } - From 795091005e1f50e5fd0114fa94edd7a89d69ab2f Mon Sep 17 00:00:00 2001 From: xieliuduo Date: Wed, 5 Jan 2022 17:40:16 +0800 Subject: [PATCH 008/384] refactor: del VizState.playingStoryId --- .../MainPage/pages/VizPage/Main/index.tsx | 20 ++++++++++++++----- .../MainPage/pages/VizPage/slice/index.ts | 4 +--- .../MainPage/pages/VizPage/slice/selectors.ts | 4 ---- .../MainPage/pages/VizPage/slice/types.ts | 5 ++--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/frontend/src/app/pages/MainPage/pages/VizPage/Main/index.tsx b/frontend/src/app/pages/MainPage/pages/VizPage/Main/index.tsx index feab2ad31..3fa0ca1b0 100644 --- a/frontend/src/app/pages/MainPage/pages/VizPage/Main/index.tsx +++ b/frontend/src/app/pages/MainPage/pages/VizPage/Main/index.tsx @@ -1,19 +1,24 @@ import { CloseOutlined } from '@ant-design/icons'; import { EmptyFiller, TabPane, Tabs } from 'app/components'; +import useI18NPrefix from 'app/hooks/useI18NPrefix'; import { selectOrgId } from 'app/pages/MainPage/slice/selectors'; import { StoryPlayer } from 'app/pages/StoryBoardPage/Player'; import { useCallback, useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { useHistory, useLocation, useRouteMatch } from 'react-router-dom'; +import { + Route, + Switch, + useHistory, + useLocation, + useRouteMatch, +} from 'react-router-dom'; import styled from 'styled-components/macro'; -import useI18NPrefix from 'app/hooks/useI18NPrefix'; import { STICKY_LEVEL } from 'styles/StyleConstants'; import { useVizSlice } from '../slice'; import { selectArchivedDashboards, selectArchivedDatacharts, selectArchivedStoryboards, - selectPlayingStoryId, selectSelectedTab, selectStoryboards, selectTabs, @@ -39,7 +44,7 @@ export function Main() { const tabs = useSelector(selectTabs); const selectedTab = useSelector(selectSelectedTab); const orgId = useSelector(selectOrgId); - const playingStoryId = useSelector(selectPlayingStoryId); + const t = useI18NPrefix('viz.main'); useEffect(() => { @@ -177,7 +182,12 @@ export function Main() { ))} {!tabs.length && } - {playingStoryId && } + + } + /> + ); } diff --git a/frontend/src/app/pages/MainPage/pages/VizPage/slice/index.ts b/frontend/src/app/pages/MainPage/pages/VizPage/slice/index.ts index 81cba38c6..f2cc5ca4f 100644 --- a/frontend/src/app/pages/MainPage/pages/VizPage/slice/index.ts +++ b/frontend/src/app/pages/MainPage/pages/VizPage/slice/index.ts @@ -69,9 +69,7 @@ const slice = createSlice({ } }, - changePlayingStoryId(state, action: PayloadAction) { - state.playingStoryId = action.payload; - }, + updateChartPreviewFilter( state, action: PayloadAction<{ backendChartId: string; payload }>, diff --git a/frontend/src/app/pages/MainPage/pages/VizPage/slice/selectors.ts b/frontend/src/app/pages/MainPage/pages/VizPage/slice/selectors.ts index b5b7ab119..fefee8fc5 100644 --- a/frontend/src/app/pages/MainPage/pages/VizPage/slice/selectors.ts +++ b/frontend/src/app/pages/MainPage/pages/VizPage/slice/selectors.ts @@ -116,10 +116,6 @@ export const selectSelectedTab = createSelector([selectDomain], vizState => vizState.tabs.find(t => t.id === vizState.selectedTab), ); -export const selectPlayingStoryId = createSelector( - [selectDomain], - vizState => vizState.playingStoryId, -); export const selectPreviewCharts = createSelector( [selectDomain], vizState => vizState.chartPreviews, diff --git a/frontend/src/app/pages/MainPage/pages/VizPage/slice/types.ts b/frontend/src/app/pages/MainPage/pages/VizPage/slice/types.ts index 2a903f1e8..726c6bd33 100644 --- a/frontend/src/app/pages/MainPage/pages/VizPage/slice/types.ts +++ b/frontend/src/app/pages/MainPage/pages/VizPage/slice/types.ts @@ -28,7 +28,6 @@ export interface VizState { tabs: VizTab[]; selectedTab: string; dataChartListLoading: boolean; - playingStoryId?: string; chartPreviews: ChartPreview[]; } @@ -95,7 +94,7 @@ export interface VizTab { export interface AddVizParams { viz: { name: string; - index:number | null; + index: number | null; description?: string; parentId?: string | null; orgId: string; @@ -115,7 +114,7 @@ export interface UnarchiveVizParams { name: string; vizType: VizType; parentId: string | null; - index:number | null; + index: number | null; }; resolve: () => void; } From 0eea2451e3110cd3d6c535d6516f2243bb04dc0f Mon Sep 17 00:00:00 2001 From: xieliuduo Date: Wed, 5 Jan 2022 17:42:05 +0800 Subject: [PATCH 009/384] feat: play story on new window.tab --- .../SharePage/StoryPlayerForShare/StoryPlayerForShare.tsx | 3 +-- frontend/src/app/pages/StoryBoardPage/Player/index.tsx | 2 -- frontend/src/app/pages/StoryBoardPage/Preview/Preview.tsx | 6 ++---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/pages/SharePage/StoryPlayerForShare/StoryPlayerForShare.tsx b/frontend/src/app/pages/SharePage/StoryPlayerForShare/StoryPlayerForShare.tsx index 11a72a408..35e17c2c8 100644 --- a/frontend/src/app/pages/SharePage/StoryPlayerForShare/StoryPlayerForShare.tsx +++ b/frontend/src/app/pages/SharePage/StoryPlayerForShare/StoryPlayerForShare.tsx @@ -16,7 +16,6 @@ * limitations under the License. */ import { Layout } from 'antd'; -import { vizActions } from 'app/pages/MainPage/pages/VizPage/slice'; import React, { memo, RefObject, @@ -127,7 +126,7 @@ export const StoryPlayerForShare: React.FC<{ storyBoard: StoryBoard }> = memo( keyboard: { 27: () => { // disabled esc - dispatch(vizActions.changePlayingStoryId('')); + }, // do something custom when ESC is pressed }, }); diff --git a/frontend/src/app/pages/StoryBoardPage/Player/index.tsx b/frontend/src/app/pages/StoryBoardPage/Player/index.tsx index 134776d7d..2db1d6635 100644 --- a/frontend/src/app/pages/StoryBoardPage/Player/index.tsx +++ b/frontend/src/app/pages/StoryBoardPage/Player/index.tsx @@ -16,7 +16,6 @@ * limitations under the License. */ import { Layout } from 'antd'; -import { vizActions } from 'app/pages/MainPage/pages/VizPage/slice'; import React, { memo, RefObject, @@ -129,7 +128,6 @@ export const StoryPlayer: React.FC<{ storyId: string }> = memo( keyboard: { 27: () => { // disabled esc - dispatch(vizActions.changePlayingStoryId('')); }, // do something custom when ESC is pressed }, }); diff --git a/frontend/src/app/pages/StoryBoardPage/Preview/Preview.tsx b/frontend/src/app/pages/StoryBoardPage/Preview/Preview.tsx index ca8f5c493..2b1d96901 100644 --- a/frontend/src/app/pages/StoryBoardPage/Preview/Preview.tsx +++ b/frontend/src/app/pages/StoryBoardPage/Preview/Preview.tsx @@ -19,7 +19,6 @@ import { Layout, message } from 'antd'; import { Split } from 'app/components'; import usePrefixI18N from 'app/hooks/useI18NPrefix'; import { useSplitSizes } from 'app/hooks/useSplitSizes'; -import { vizActions } from 'app/pages/MainPage/pages/VizPage/slice'; import { selectPublishLoading } from 'app/pages/MainPage/pages/VizPage/slice/selectors'; import { publishViz } from 'app/pages/MainPage/pages/VizPage/slice/thunks'; import { StoryContext } from 'app/pages/StoryBoardPage/contexts/StoryContext'; @@ -82,9 +81,8 @@ export const StoryPagePreview: React.FC<{ setEditorVisible(c => !c); }, []); const playStory = useCallback(() => { - message.info(t('playTip')); - dispatch(vizActions.changePlayingStoryId(storyId || '')); - }, [dispatch, storyId, t]); + window.open(`${storyId}/storyPlay`, '_blank'); + }, [storyId]); useEffect(() => { if (sortedPages.length === 0) { From f5b9c5e2d8b0b233e6d3687e20bbc4c8fc535f5a Mon Sep 17 00:00:00 2001 From: xieliuduo Date: Wed, 5 Jan 2022 17:42:38 +0800 Subject: [PATCH 010/384] chore: del playTip key of i18n --- frontend/src/locales/en/translation.json | 1 - frontend/src/locales/zh/translation.json | 1 - 2 files changed, 2 deletions(-) diff --git a/frontend/src/locales/en/translation.json b/frontend/src/locales/en/translation.json index 64970519e..29e33008a 100644 --- a/frontend/src/locales/en/translation.json +++ b/frontend/src/locales/en/translation.json @@ -670,7 +670,6 @@ "unpublished": "Unpublished", "archived": "Archived", "play": "Play", - "playTip": "Press Esc to quit playing", "share": { "link": "Link", "password": "Password", diff --git a/frontend/src/locales/zh/translation.json b/frontend/src/locales/zh/translation.json index 62283878a..574a81660 100644 --- a/frontend/src/locales/zh/translation.json +++ b/frontend/src/locales/zh/translation.json @@ -670,7 +670,6 @@ "unpublished": "未发布", "archived": "已归档", "play": "播放", - "playTip": "按 Esc 退出播放", "share": { "link": "链接", "password": "密码", From b15484c7dd941d1f606f3b70295d9be76f7ed162 Mon Sep 17 00:00:00 2001 From: xieliuduo Date: Wed, 5 Jan 2022 18:09:07 +0800 Subject: [PATCH 011/384] refactor: Initialize the flicker problem in app --- frontend/src/app/hooks/useCacheWidthHeight.ts | 4 ++-- .../MainPage/pages/VizPage/ChartPreview/ChartPreview.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/hooks/useCacheWidthHeight.ts b/frontend/src/app/hooks/useCacheWidthHeight.ts index f4a55bd93..aa453e020 100644 --- a/frontend/src/app/hooks/useCacheWidthHeight.ts +++ b/frontend/src/app/hooks/useCacheWidthHeight.ts @@ -20,8 +20,8 @@ import { useEffect, useState } from 'react'; import useResizeObserver from './useResizeObserver'; export const useCacheWidthHeight = ( - initWidth: number = 400, - initHeight: number = 300, + initWidth: number = 0, + initHeight: number = 0, ) => { const [cacheW, setCacheW] = useState(initWidth); const [cacheH, setCacheH] = useState(initHeight); diff --git a/frontend/src/app/pages/MainPage/pages/VizPage/ChartPreview/ChartPreview.tsx b/frontend/src/app/pages/MainPage/pages/VizPage/ChartPreview/ChartPreview.tsx index c3bc22451..da180efb1 100644 --- a/frontend/src/app/pages/MainPage/pages/VizPage/ChartPreview/ChartPreview.tsx +++ b/frontend/src/app/pages/MainPage/pages/VizPage/ChartPreview/ChartPreview.tsx @@ -60,7 +60,7 @@ const ChartPreviewBoard: FC<{ allowManage, }) => { useVizSlice(); - const { ref, cacheW, cacheH } = useCacheWidthHeight(800, 600); + const { ref, cacheW, cacheH } = useCacheWidthHeight(0, 0); const { actions } = useMainSlice(); const chartManager = ChartManager.instance(); const dispatch = useDispatch(); From 004b170aea1da250c86a65dc74e7f07947c93e41 Mon Sep 17 00:00:00 2001 From: xieliuduo Date: Wed, 5 Jan 2022 18:09:58 +0800 Subject: [PATCH 012/384] refactor: Initialize the flicker problem in share --- .../src/app/pages/SharePage/ChartForShare.tsx | 235 +++++++++--------- 1 file changed, 113 insertions(+), 122 deletions(-) diff --git a/frontend/src/app/pages/SharePage/ChartForShare.tsx b/frontend/src/app/pages/SharePage/ChartForShare.tsx index 404d54ff0..62d84496c 100644 --- a/frontend/src/app/pages/SharePage/ChartForShare.tsx +++ b/frontend/src/app/pages/SharePage/ChartForShare.tsx @@ -21,7 +21,7 @@ import useMount from 'app/hooks/useMount'; import useResizeObserver from 'app/hooks/useResizeObserver'; import Chart from 'app/pages/ChartWorkbenchPage/models/Chart'; import ChartManager from 'app/pages/ChartWorkbenchPage/models/ChartManager'; -import { CSSProperties, FC, memo, useState } from 'react'; +import { FC, memo, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import styled from 'styled-components/macro'; import ChartTools from '../ChartWorkbenchPage/components/ChartOperationPanel/components/ChartTools'; @@ -43,144 +43,135 @@ import { const TitleHeight = 100; const ChartForShare: FC<{ - style?: CSSProperties; chartPreview?: ChartPreview; filterSearchParams?: FilterSearchParams; onCreateDataChartDownloadTask: ( downloadParams: ChartRequest[], fileName: string, ) => void; -}> = memo( - ({ - chartPreview, - style = { width: 800, height: 600 }, - onCreateDataChartDownloadTask, - }) => { - const dispatch = useDispatch(); - const [chart] = useState(() => { - const currentChart = ChartManager.instance().getById( - chartPreview?.backendChart?.config?.chartGraphId, - ); - return currentChart; - }); - const { - ref, - width = style?.width, - height = style?.height, - } = useResizeObserver({ +}> = memo(({ chartPreview, onCreateDataChartDownloadTask }) => { + const dispatch = useDispatch(); + const [chart] = useState(() => { + const currentChart = ChartManager.instance().getById( + chartPreview?.backendChart?.config?.chartGraphId, + ); + return currentChart; + }); + const { + ref, + width = 0, + height = 0, + } = useResizeObserver({ + refreshMode: 'debounce', + refreshRate: 500, + }); + const { ref: controlRef, height: controlH = 0 } = + useResizeObserver({ refreshMode: 'debounce', refreshRate: 500, }); - const { ref: controlRef, height: controlH = 0 } = - useResizeObserver({ - refreshMode: 'debounce', - refreshRate: 500, - }); - const headlessBrowserRenderSign = useSelector( - selectHeadlessBrowserRenderSign, - ); - useMount(() => { - if (!chartPreview) { - return; - } - dispatch( - fetchShareDataSetByPreviewChartAction({ preview: chartPreview }), - ); - registerChartEvents(chart); - }); + const headlessBrowserRenderSign = useSelector( + selectHeadlessBrowserRenderSign, + ); + useMount(() => { + if (!chartPreview) { + return; + } + dispatch(fetchShareDataSetByPreviewChartAction({ preview: chartPreview })); + registerChartEvents(chart); + }); - const registerChartEvents = chart => { - chart?.registerMouseEvents([ - { - name: 'click', - callback: param => { - if ( - param.componentType === 'table' && - param.seriesType === 'paging-sort-filter' - ) { - dispatch( - fetchShareDataSetByPreviewChartAction({ - preview: chartPreview!, - sorter: { - column: param?.seriesName!, - operator: param?.value?.direction, - }, - pageInfo: { - pageNo: param?.value?.pageNo, - }, - }), - ); - return; - } - }, + const registerChartEvents = chart => { + chart?.registerMouseEvents([ + { + name: 'click', + callback: param => { + if ( + param.componentType === 'table' && + param.seriesType === 'paging-sort-filter' + ) { + dispatch( + fetchShareDataSetByPreviewChartAction({ + preview: chartPreview!, + sorter: { + column: param?.seriesName!, + operator: param?.value?.direction, + }, + pageInfo: { + pageNo: param?.value?.pageNo, + }, + }), + ); + return; + } }, - ]); - }; + }, + ]); + }; - const handleFilterChange = (type, payload) => { - dispatch( - updateFilterAndFetchDatasetForShare({ - backendChartId: chartPreview?.backendChart?.id!, - chartPreview, - payload, - }), - ); - }; + const handleFilterChange = (type, payload) => { + dispatch( + updateFilterAndFetchDatasetForShare({ + backendChartId: chartPreview?.backendChart?.id!, + chartPreview, + payload, + }), + ); + }; - const handleCreateDownloadDataTask = async () => { - const builder = new ChartDataRequestBuilder( - { - id: chartPreview?.backendChart?.viewId, - computedFields: - chartPreview?.backendChart?.config?.computedFields || [], - } as any, - chartPreview?.chartConfig?.datas, - chartPreview?.chartConfig?.settings, - {}, - false, - chartPreview?.backendChart?.config?.aggregation, - ); - const downloadParams = [builder.build()]; - const fileName = chartPreview?.backendChart?.name || 'chart'; - onCreateDataChartDownloadTask(downloadParams, fileName); - }; + const handleCreateDownloadDataTask = async () => { + const builder = new ChartDataRequestBuilder( + { + id: chartPreview?.backendChart?.viewId, + computedFields: + chartPreview?.backendChart?.config?.computedFields || [], + } as any, + chartPreview?.chartConfig?.datas, + chartPreview?.chartConfig?.settings, + {}, + false, + chartPreview?.backendChart?.config?.aggregation, + ); + const downloadParams = [builder.build()]; + const fileName = chartPreview?.backendChart?.name || 'chart'; + onCreateDataChartDownloadTask(downloadParams, fileName); + }; - return ( - - + +
+ -
- -
+
-
- -
- + -
- ); - }, -); + + + + ); +}); export default ChartForShare; From ea2b3b56bdfedcf1d538783bfd8b359a515420a2 Mon Sep 17 00:00:00 2001 From: "761302945@qq.com" <761302945@qq.com> Date: Thu, 6 Jan 2022 14:43:53 +0800 Subject: [PATCH 013/384] fix: sql parser function name support --- .../src/main/java/codegen/Parser.jj | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/data-providers/src/main/java/codegen/Parser.jj b/data-providers/src/main/java/codegen/Parser.jj index 99043f31a..ac169a446 100644 --- a/data-providers/src/main/java/codegen/Parser.jj +++ b/data-providers/src/main/java/codegen/Parser.jj @@ -6592,12 +6592,45 @@ SqlIdentifier FunctionName() : qualifiedName = CompoundIdentifier() | qualifiedName = ReservedFunctionName() + + | qualifiedName = FunctionNameSupport() // [datart] function name support + ) { return qualifiedName; } } +// [datart] function name support +SqlIdentifier FunctionNameSupport(): +{ +} +{ + ( + NonReservedKeyWord() + | KeywordFunctionNameSupport() + + ) + { + return new SqlIdentifier(unquotedIdentifier(), getPos()); + } +} +// [datart] function name support +String KeywordFunctionNameSupport() : +{ +} +{ + ( + + |