Skip to content

Commit b2bd7f0

Browse files
authored
Merge pull request #94 from running-elephant/dev
Dev
2 parents 206fefe + 74fa460 commit b2bd7f0

File tree

13 files changed

+65
-86
lines changed

13 files changed

+65
-86
lines changed

frontend/src/app/components/ChartDrill/ChartDrillPaths.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export default ChartDrillPaths;
6464

6565
const StyledChartDrillPaths = styled.div`
6666
padding: ${SPACE_XS} ${SPACE_SM};
67-
background-color: ${p => p.theme.componentBackground};
6867
`;
6968

7069
const StyledDrillNode = styled(Breadcrumb.Item)<{ isActive: boolean }>`

frontend/src/app/components/ChartEditor.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ export const ChartEditor: FC<ChartEditorProps> = ({
212212
{
213213
name: 'click',
214214
callback: param => {
215-
if (drillOptionRef.current?.isSelectedDrill) {
215+
if (
216+
drillOptionRef.current?.isSelectedDrill &&
217+
!drillOptionRef.current.isBottomLevel
218+
) {
216219
const option = drillOptionRef.current;
217220
option.drillDown(param.data.rowData);
218221
drillOptionRef.current = option;

frontend/src/app/pages/DashBoardPage/actions/widgetAction.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
import { urlSearchTransfer } from 'app/pages/MainPage/pages/VizPage/utils';
1919
import { ChartMouseEventParams } from 'app/types/Chart';
20-
import { History } from 'history';
2120
import i18next from 'i18next';
2221
import { RootState } from 'types';
2322
import { jumpTypes } from '../constants';
@@ -106,13 +105,14 @@ export const tableChartClickAction =
106105
};
107106

108107
export const widgetClickJumpAction =
109-
(
110-
renderMode: VizRenderMode,
111-
widget: Widget,
112-
params: ChartMouseEventParams,
113-
history: History,
114-
) =>
108+
(obj: {
109+
renderMode: VizRenderMode;
110+
widget: Widget;
111+
params: ChartMouseEventParams;
112+
history: any;
113+
}) =>
115114
(dispatch, getState) => {
115+
const { renderMode, widget, params, history } = obj;
116116
const state = getState() as RootState;
117117
const orgId = state?.main?.orgId || '';
118118
const folderIds = state.viz?.vizs?.map(v => v.relId) || [];
@@ -245,15 +245,16 @@ export const widgetClickLinkageAction =
245245
};
246246
//
247247
export const widgetChartClickAction =
248-
(
249-
boardId: string,
250-
editing: boolean,
251-
renderMode: VizRenderMode,
252-
widget: Widget,
253-
params: ChartMouseEventParams,
254-
history: History,
255-
) =>
248+
(obj: {
249+
boardId: string;
250+
editing: boolean;
251+
renderMode: VizRenderMode;
252+
widget: Widget;
253+
params: ChartMouseEventParams;
254+
history: any;
255+
}) =>
256256
dispatch => {
257+
const { boardId, editing, renderMode, widget, params, history } = obj;
257258
//is tableChart
258259
if (
259260
params.componentType === 'table' &&
@@ -267,7 +268,7 @@ export const widgetChartClickAction =
267268
// jump
268269
const jumpConfig = widget.config?.jumpConfig;
269270
if (jumpConfig && jumpConfig.open) {
270-
dispatch(widgetClickJumpAction(renderMode, widget, params, history));
271+
dispatch(widgetClickJumpAction({ renderMode, widget, params, history }));
271272
return;
272273
}
273274
// linkage

frontend/src/app/pages/DashBoardPage/components/ActionProvider/WidgetActionProvider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const WidgetActionProvider: FC<{
7777
renderMode: VizRenderMode;
7878
}> = memo(({ boardEditing, boardId, orgId, renderMode, children }) => {
7979
const dispatch = useDispatch();
80-
const history = useHistory();
80+
const history = useHistory<any>();
8181
const methods = useMemo(() => {
8282
const contextValue: WidgetActionContextProps = {
8383
onEditLayerToTop: () => {
@@ -178,14 +178,14 @@ export const WidgetActionProvider: FC<{
178178
//
179179
onWidgetChartClick: (widget: Widget, params: ChartMouseEventParams) => {
180180
dispatch(
181-
widgetChartClickAction(
181+
widgetChartClickAction({
182182
boardId,
183-
boardEditing,
183+
editing: boardEditing,
184184
renderMode,
185185
widget,
186186
params,
187187
history,
188-
),
188+
}),
189189
);
190190
},
191191

frontend/src/app/pages/DashBoardPage/components/BoardDrillManager/BoardDrillManager.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { ChartDrillOption } from 'app/models/ChartDrillOption';
2-
31
/**
42
* Datart
53
*
@@ -17,7 +15,9 @@ import { ChartDrillOption } from 'app/models/ChartDrillOption';
1715
* See the License for the specific language governing permissions and
1816
* limitations under the License.
1917
*/
18+
import { ChartDrillOption } from 'app/models/ChartDrillOption';
2019
type WidgetDrillMap = Record<string, ChartDrillOption | undefined>;
20+
export const EDIT_PREFIX = '@EDIT@';
2121
export class BoardDrillManager {
2222
private static _manager: BoardDrillManager;
2323
private boardMap: Record<string, WidgetDrillMap> = {};
@@ -59,4 +59,3 @@ export class BoardDrillManager {
5959
}
6060

6161
export const boardDrillManager = BoardDrillManager.getInstance();
62-
export const EDIT_PREFIX = '@EDIT@';

frontend/src/app/pages/DashBoardPage/components/FreeBoardBackground.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import StyledBackground from '../pages/Board/components/StyledBackground';
2222
import { BoardConfigContext } from './BoardProvider/BoardConfigProvider';
2323
import { BoardContext } from './BoardProvider/BoardProvider';
2424

25-
export const scaleContext = createContext<[number, number]>([1, 1]);
25+
export const BoardScaleContext = createContext<[number, number]>([1, 1]);
2626
export interface IProps {
2727
scale: [number, number];
2828
slideTranslate: [number, number];
@@ -60,9 +60,9 @@ const SlideBackground: React.FC<IProps> = props => {
6060

6161
return (
6262
<Wrapper bg={background} style={slideStyle} editing={editing}>
63-
<scaleContext.Provider value={scale}>
63+
<BoardScaleContext.Provider value={scale}>
6464
{props.children}
65-
</scaleContext.Provider>
65+
</BoardScaleContext.Provider>
6666
</Wrapper>
6767
);
6868
};

frontend/src/app/pages/DashBoardPage/components/Widgets/DataChartWidget/DataChartWidgetCore.tsx

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,20 @@ import React, {
4040
useRef,
4141
} from 'react';
4242
import styled from 'styled-components/macro';
43-
import { BORDER_RADIUS } from 'styles/StyleConstants';
4443
import { WidgetActionContext } from '../../ActionProvider/WidgetActionProvider';
4544
import {
4645
boardDrillManager,
4746
EDIT_PREFIX,
4847
} from '../../BoardDrillManager/BoardDrillManager';
4948
import { BoardContext } from '../../BoardProvider/BoardProvider';
49+
import { BoardScaleContext } from '../../FreeBoardBackground';
5050
import { WidgetChartContext } from '../../WidgetProvider/WidgetChartProvider';
5151
import { WidgetDataContext } from '../../WidgetProvider/WidgetDataProvider';
5252
import { WidgetContext } from '../../WidgetProvider/WidgetProvider';
5353

5454
export const DataChartWidgetCore: React.FC<{}> = memo(() => {
5555
const dataChart = useContext(WidgetChartContext);
56+
const scale = useContext(BoardScaleContext);
5657
const { data } = useContext(WidgetDataContext);
5758
const { renderMode } = useContext(BoardContext);
5859
const widget = useContext(WidgetContext);
@@ -78,11 +79,7 @@ export const DataChartWidgetCore: React.FC<{}> = memo(() => {
7879
let drillOption;
7980
drillOption = option;
8081
drillOptionRef.current = drillOption;
81-
boardDrillManager.setWidgetDrill({
82-
bid,
83-
wid,
84-
drillOption,
85-
});
82+
boardDrillManager.setWidgetDrill({ bid, wid, drillOption });
8683
onWidgetGetData(widgetRef.current);
8784
},
8885

@@ -215,37 +212,36 @@ export const DataChartWidgetCore: React.FC<{}> = memo(() => {
215212
drillOption={drillOption}
216213
containerId={wid}
217214
widgetSpecialConfig={widgetSpecialConfig}
215+
scale={scale}
218216
/>
219217
);
220218
}, [
221219
config,
222220
cacheH,
223221
cacheW,
224222
errText,
225-
drillOptionRef,
226-
wid,
227223
dataset,
228224
chart,
225+
wid,
229226
widgetSpecialConfig,
227+
scale,
230228
]);
231229

232230
return (
233231
<Wrapper id={renderMode + wid} className="widget-chart" ref={ref}>
234232
<ChartFrameBox>
235-
<PreviewBlock>
236-
<ChartDrillContext.Provider
237-
value={{
238-
drillOption: drillOptionRef.current,
239-
onDrillOptionChange: handleDrillOptionChange,
240-
}}
241-
>
242-
<ChartWrapper>
243-
<ChartDrillContextMenu>{chartFrame}</ChartDrillContextMenu>
244-
</ChartWrapper>
233+
<ChartDrillContext.Provider
234+
value={{
235+
drillOption: drillOptionRef.current,
236+
onDrillOptionChange: handleDrillOptionChange,
237+
}}
238+
>
239+
<ChartWrapper>
240+
<ChartDrillContextMenu>{chartFrame}</ChartDrillContextMenu>
241+
</ChartWrapper>
245242

246-
<ChartDrillPaths />
247-
</ChartDrillContext.Provider>
248-
</PreviewBlock>
243+
<ChartDrillPaths />
244+
</ChartDrillContext.Provider>
249245
</ChartFrameBox>
250246
</Wrapper>
251247
);
@@ -257,6 +253,9 @@ const Wrapper = styled.div`
257253
`;
258254
const ChartFrameBox = styled.div`
259255
position: absolute;
256+
display: flex;
257+
flex: 1;
258+
flex-direction: column;
260259
width: 100%;
261260
height: 100%;
262261
overflow: hidden;
@@ -265,18 +264,7 @@ const ChartWrapper = styled.div`
265264
position: relative;
266265
display: flex;
267266
flex: 1;
268-
background-color: ${p => p.theme.componentBackground};
269-
border-radius: ${BORDER_RADIUS};
270267
.chart-drill-menu-container {
271268
height: 100%;
272269
}
273270
`;
274-
const PreviewBlock = styled.div`
275-
display: flex;
276-
flex: 1;
277-
flex-direction: column;
278-
width: 100%;
279-
height: 100%;
280-
overflow: hidden;
281-
box-shadow: ${p => p.theme.shadowBlock};
282-
`;

frontend/src/app/pages/DashBoardPage/pages/Board/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { DndProvider } from 'react-dnd';
2323
import { HTML5Backend } from 'react-dnd-html5-backend';
2424
import { useDispatch, useSelector } from 'react-redux';
2525
import styled from 'styled-components/macro';
26+
import { boardDrillManager } from '../../components/BoardDrillManager/BoardDrillManager';
2627
import { TitleHeader } from '../../components/BoardHeader/TitleHeader';
2728
import { BoardLoading } from '../../components/BoardLoading';
2829
import { BoardInitProvider } from '../../components/BoardProvider/BoardInitProvider';
@@ -151,6 +152,7 @@ export const Board: FC<BoardProps> = memo(
151152
// 销毁组件 清除该对象缓存
152153
return () => {
153154
dispatch(boardActions.clearBoardStateById(boardId));
155+
boardDrillManager.clearMapByBoardId(boardId);
154156
};
155157
}, [boardId, dispatch, fetchData, searchParams]);
156158

frontend/src/app/pages/DashBoardPage/pages/BoardEditor/FreeEditor/WidgetOfFreeEdit.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { useDispatch, useSelector } from 'react-redux';
3434
import { Resizable, ResizeCallbackData } from 'react-resizable';
3535
import styled from 'styled-components/macro';
3636
import { WidgetActionContext } from '../../../components/ActionProvider/WidgetActionProvider';
37-
import { scaleContext } from '../../../components/FreeBoardBackground';
37+
import { BoardScaleContext } from '../../../components/FreeBoardBackground';
3838
import { editBoardStackActions } from '../slice';
3939
import { widgetMove, widgetMoveEnd } from '../slice/events';
4040
import { selectSelectedIds } from '../slice/selectors';
@@ -48,7 +48,7 @@ export const WidgetOfFreeEdit: React.FC<{}> = () => {
4848
const { onUpdateWidgetConfig } = useContext(WidgetActionContext);
4949

5050
const dispatch = useDispatch();
51-
const scale = useContext(scaleContext);
51+
const scale = useContext(BoardScaleContext);
5252
const { x, y, width, height } = widget.config.rect;
5353
const [curXY, setCurXY] = useState<[number, number]>([
5454
widget.config.rect.x,

frontend/src/app/pages/DashBoardPage/pages/BoardEditor/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import { useHistory } from 'react-router-dom';
2424
import styled from 'styled-components/macro';
2525
import { LEVEL_50 } from 'styles/StyleConstants';
2626
import { uuidv4 } from 'utils/utils';
27+
import {
28+
boardDrillManager,
29+
EDIT_PREFIX,
30+
} from '../../components/BoardDrillManager/BoardDrillManager';
2731
import EditorHeader from '../../components/BoardHeader/EditorHeader';
2832
import { BoardLoading } from '../../components/BoardLoading';
2933
import { BoardInitProvider } from '../../components/BoardProvider/BoardInitProvider';
@@ -142,12 +146,13 @@ export const BoardEditor: React.FC<{
142146
useEffect(() => {
143147
initialization();
144148
return () => {
145-
console.log('__ 销毁 ed');
146149
// fix issue: #800
147150
onCloseChartEditor();
148151
dispatch(clearEditBoardState());
149152
//销毁时 更新view界面数据
150153
dispatch(fetchBoardDetail({ dashboardRelId: boardId }));
154+
//
155+
boardDrillManager.clearMapByBoardId(EDIT_PREFIX + boardId);
151156
};
152157
// eslint-disable-next-line react-hooks/exhaustive-deps
153158
}, [onCloseChartEditor]);

0 commit comments

Comments
 (0)