|
@@ -22,7 +22,7 @@ import { FilterSearchParamsWithMatch } from 'app/pages/MainPage/pages/VizPage/sl
|
|
|
import { mainActions } from 'app/pages/MainPage/slice';
|
|
|
import { ExecuteToken } from 'app/pages/SharePage/slice/types';
|
|
|
import { ChartDataRequest } from 'app/types/ChartDataRequest';
|
|
|
-import { downloadFile, makeDownloadDataTask } from 'app/utils/fetch';
|
|
|
+import { downloadFile, makeDownloadDataTask, makeShareDownloadDataTask } from 'app/utils/fetch';
|
|
|
import { RootState } from 'types';
|
|
|
import { UniqWith } from 'utils/object';
|
|
|
import { boardActions } from '.';
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
VizRenderMode,
|
|
|
WidgetData,
|
|
|
} from './types';
|
|
|
+import { shareActions } from '../../../../SharePage/slice';
|
|
|
|
|
|
export const handleServerBoardAction =
|
|
|
(params: {
|
|
@@ -60,7 +61,6 @@ export const handleServerBoardAction =
|
|
|
const { data, renderMode, filterSearchMap, executeToken } = params;
|
|
|
const dashboard = getDashBoardByResBoard(data);
|
|
|
const { datacharts, views: serverViews, widgets: serverWidgets } = data;
|
|
|
-
|
|
|
const dataCharts: DataChart[] = getDataChartsByServer(
|
|
|
datacharts,
|
|
|
serverViews,
|
|
@@ -167,10 +167,23 @@ export const getBoardStateAction =
|
|
|
};
|
|
|
};
|
|
|
export const boardDownLoadAction =
|
|
|
- (params: { boardId: string; downloadType: DownloadFileType,direct:any }) =>
|
|
|
+ (params: { boardId: string; downloadType: DownloadFileType, clientId:any,
|
|
|
+ needVerify:any,
|
|
|
+ shareBoard:any,
|
|
|
+ executeTokenMap:any,
|
|
|
+ routerParams:any,
|
|
|
+ sharePassword:any}) =>
|
|
|
async (dispatch, getState) => {
|
|
|
+ const {
|
|
|
+ clientId,
|
|
|
+ needVerify,
|
|
|
+ shareBoard,
|
|
|
+ executeTokenMap,
|
|
|
+ routerParams,
|
|
|
+ sharePassword
|
|
|
+ } = params
|
|
|
const state = getState() as RootState;
|
|
|
- const { boardId, downloadType,direct } = params;
|
|
|
+ const { boardId, downloadType } = params;
|
|
|
const vizs = state.viz?.vizs;
|
|
|
const folderId = vizs?.filter(v => v.relId === boardId)[0].id;
|
|
|
const boardInfoRecord = state.board?.boardInfoRecord;
|
|
@@ -185,25 +198,44 @@ export const boardDownLoadAction =
|
|
|
getBoardDownloadParams({ boardId }),
|
|
|
);
|
|
|
|
|
|
- dispatch(
|
|
|
- makeDownloadDataTask({
|
|
|
- downloadParams:
|
|
|
- downloadType === DownloadFileType.Excel
|
|
|
- ? requestParams
|
|
|
- : [{ analytics: false, vizType: 'dashboard', vizId: folderId }],
|
|
|
- fileName,
|
|
|
- downloadType,
|
|
|
- imageWidth,
|
|
|
- resolve: (res) => {
|
|
|
- if (direct){
|
|
|
- downloadFile(res.id).then(() => {
|
|
|
- dispatch(mainActions.setDownloadPolling(true));
|
|
|
- });
|
|
|
- }
|
|
|
- dispatch(mainActions.setDownloadPolling(true));
|
|
|
- },
|
|
|
- }),
|
|
|
- );
|
|
|
+ if (!Boolean(needVerify) && shareBoard && !folderId){
|
|
|
+ if (clientId && executeTokenMap) {
|
|
|
+ const { requestParams, fileName } = await dispatch(
|
|
|
+ getBoardDownloadParams({ boardId }),
|
|
|
+ );
|
|
|
+ if (requestParams) {
|
|
|
+ dispatch(
|
|
|
+ makeShareDownloadDataTask({
|
|
|
+ clientId: clientId,
|
|
|
+ executeToken: executeTokenMap,
|
|
|
+ downloadParams: requestParams,
|
|
|
+ shareToken:routerParams?.params.token,
|
|
|
+ fileName: fileName,
|
|
|
+ resolve: () => {
|
|
|
+ dispatch(shareActions.setShareDownloadPolling(true));
|
|
|
+ },
|
|
|
+ password: sharePassword,
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ dispatch(
|
|
|
+ makeDownloadDataTask({
|
|
|
+ downloadParams:
|
|
|
+ downloadType === DownloadFileType.Excel
|
|
|
+ ? requestParams
|
|
|
+ : [{ analytics: false, vizType: 'dashboard', vizId: folderId }],
|
|
|
+ fileName,
|
|
|
+ downloadType,
|
|
|
+ imageWidth,
|
|
|
+ resolve: (res) => {
|
|
|
+ dispatch(mainActions.setDownloadPolling(true));
|
|
|
+ },
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ }
|
|
|
};
|
|
|
export const getBoardDownloadParams =
|
|
|
(params: { boardId: string }) => (dispatch, getState) => {
|