Skip to content

Commit 22b73a3

Browse files
committed
refactor: handleServerBoardAction
1 parent 1c46b9a commit 22b73a3

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

frontend/src/app/pages/DashBoardPage/pages/Board/slice/asyncActions.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export const handleServerBoardAction =
4242
}) =>
4343
async (dispatch, getState) => {
4444
const { data, renderMode, filterSearchMap } = params;
45-
4645
const dashboard = getDashBoardByResBoard(data);
4746
const { datacharts, views: serverViews, widgets: serverWidgets } = data;
4847

@@ -53,30 +52,34 @@ export const handleServerBoardAction =
5352
dataCharts,
5453
filterSearchMap,
5554
);
56-
5755
const widgetIds = Object.values(widgetMap).map(w => w.id);
58-
//
5956
let boardInfo = getInitBoardInfo({
6057
id: dashboard.id,
6158
widgetIds,
6259
controllerWidgets,
6360
});
64-
6561
if (renderMode === 'schedule') {
6662
boardInfo = getScheduleBoardInfo(boardInfo, widgetMap);
6763
}
64+
const widgetInfoMap = getWidgetInfoMapByServer(widgetMap);
6865

6966
const allDataCharts: DataChart[] = dataCharts.concat(wrappedDataCharts);
67+
7068
const viewViews = getChartDataView(serverViews, allDataCharts);
71-
const widgetInfoMap = getWidgetInfoMapByServer(widgetMap);
72-
dispatch(
73-
boardActions.setBoardDetailToState({
69+
70+
await dispatch(
71+
boardActions.setBoardState({
7472
board: dashboard,
7573
boardInfo: boardInfo,
76-
views: viewViews,
74+
}),
75+
);
76+
dispatch(boardActions.setViewMap(viewViews));
77+
dispatch(boardActions.setDataChartToMap(allDataCharts));
78+
dispatch(
79+
boardActions.setWidgetMapState({
80+
boardId: dashboard.id,
7781
widgetMap: widgetMap,
7882
widgetInfoMap: widgetInfoMap,
79-
dataCharts: allDataCharts,
8083
}),
8184
);
8285
};

frontend/src/app/pages/DashBoardPage/pages/Board/slice/thunk.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ export const fetchBoardDetail = createAsyncThunk<
8383
`/viz/dashboards/${params?.dashboardRelId}`,
8484
);
8585

86-
await dispatch(
86+
dispatch(
8787
handleServerBoardAction({
8888
data,
8989
renderMode: 'read',
9090
filterSearchMap: { params: params?.filterSearchParams },
9191
}),
9292
);
93+
9394
return null;
9495
});
9596

0 commit comments

Comments
 (0)