Skip to content

Commit 7c16529

Browse files
authored
Merge pull request #1230 from xieliuduo/dev35-jumpDate
fix :widget click jump with a DateValue
2 parents 14a968b + 8370842 commit 7c16529

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

frontend/src/app/pages/DashBoardPage/utils/widget.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616
* limitations under the License.
1717
*/
1818

19-
import { ControllerFacadeTypes } from 'app/constants';
19+
import { ControllerFacadeTypes, TimeFilterValueCategory } from 'app/constants';
2020
import {
2121
ContainerItem,
2222
WidgetType,
2323
} from 'app/pages/DashBoardPage/pages/Board/slice/types';
2424
import { FilterSearchParamsWithMatch } from 'app/pages/MainPage/pages/VizPage/slice/types';
2525
import { ChartsEventData } from 'app/types/Chart';
2626
import ChartDataView from 'app/types/ChartDataView';
27-
import { FilterSqlOperator } from 'globalConstants';
27+
import { formatTime } from 'app/utils/time';
28+
import { FilterSqlOperator, TIME_FORMATTER } from 'globalConstants';
2829
import produce from 'immer';
2930
import { DeltaStatic } from 'quill';
3031
import { CSSProperties } from 'react';
@@ -816,6 +817,16 @@ export const getWidgetMap = (
816817
content.config.controllerDate.endTime.exactValue = _value?.[0];
817818
}
818819
break;
820+
821+
case ControllerFacadeTypes.Time:
822+
content.config.controllerDate = {
823+
...(content.config.controllerDate as any),
824+
startTime: {
825+
relativeOrExact: TimeFilterValueCategory.Exact,
826+
exactValue: formatTime(_value as any, TIME_FORMATTER),
827+
},
828+
};
829+
break;
819830
default:
820831
content.config.controllerValues = _value || [];
821832
break;

frontend/src/app/utils/time.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export function getTime(
4848
};
4949
}
5050

51-
export function formatTime(time: string | Moment, format): string {
52-
return moment(time).format(format);
51+
export function formatTime(time: string | Moment, format?): string {
52+
return moment(time).format(format || TIME_FORMATTER);
5353
}
5454

5555
export function recommendTimeRangeConverter(relativeTimeRange) {

0 commit comments

Comments
 (0)