Skip to content

Commit bd7ce40

Browse files
authored
FIREFLY-1771: Merge PR #1788 from Caltech-IPAC/FIREFLY-1771-row-mismatch
FIREFLY-1771: Fix Existing Table Load missing rows
2 parents 5c48213 + e79f2c2 commit bd7ce40

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/firefly/js/ui/UploadTableChooser.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Stack, Typography, Box} from '@mui/joy';
2-
import React from 'react';
1+
import {Stack, Typography} from '@mui/joy';
2+
import React, {useState} from 'react';
33

44
import {dispatchHideDialog, dispatchShowDialog} from '../core/ComponentCntlr.js';
55
import {FileAnalysisType, Format} from '../data/FileAnalysis.js';
@@ -19,9 +19,10 @@ import {ServerParams} from 'firefly/data/ServerParams';
1919
import {doJsonRequest} from 'firefly/core/JsonUtils';
2020
import {dispatchTableSearch} from 'firefly/tables/TablesCntlr';
2121
import {MetaConst} from 'firefly/data/MetaConst';
22-
import {makeFileRequest} from 'firefly/api/ApiUtilTable';
22+
import {cloneRequest, makeFileRequest} from 'firefly/api/ApiUtilTable';
2323
import {dispatchHideDropDown} from 'firefly/core/LayoutCntlr';
2424
import {determineValidity, fileAnalysisErr} from 'firefly/ui/FileUploadProcessor';
25+
import {LoadingMessage} from 'firefly/visualize/ui/FileUploadViewPanel';
2526

2627
const dialogId = 'Upload-spatial-table';
2728
const UPLOAD_TBL_SOURCE= 'UPLOAD_TBL_SOURCE';
@@ -110,19 +111,22 @@ function uploadSubmit(request,setUploadInfo,defaultColsEnabled) {
110111
* @param request
111112
* @param setUploadInfo
112113
* @param {DefaultColsEnabled} defaultColsEnabled
114+
* @param setLoading
113115
* @returns {boolean}
114116
*/
115-
function existingTableSubmit(request,setUploadInfo,defaultColsEnabled) {
117+
function existingTableSubmit(request,setUploadInfo,defaultColsEnabled,setLoading) {
116118
if (!request) return false;
119+
setLoading(true);
117120
const tbl = getTblById('existing-table-list-ui');
118121
const idx = tbl.highlightedRow;
119122
const activeTblId = tbl.tableData.data[idx][3]; //tbl_id
120123
const activeTbl = getTableUiByTblId(activeTblId);
121-
const tableRequest = activeTbl.request;
122124
const columnData = activeTbl.columns;
123125
const columns = columnData.map((col) => col.visibility === 'hide' || col.visibility === 'hidden'? ({...col, use:false}) : ({...col, use:true})); //filter out hidden cols
124126
const columnsSelected = applyDefColumnSelection(columns,defaultColsEnabled);
125127

128+
const tableRequest = cloneRequest(activeTbl.request, {pageSize : 2147483647});
129+
126130
const params ={
127131
[ServerParams.COMMAND]: ServerParams.TABLE_SAVE,
128132
[ServerParams.REQUEST]: JSON.stringify(tableRequest),
@@ -132,10 +136,13 @@ function existingTableSubmit(request,setUploadInfo,defaultColsEnabled) {
132136
};
133137

134138
doJsonRequest(ServerParams.TABLE_SAVE, params).then((result) => {
139+
setLoading(false);
140+
135141
if (!result.success) {
136142
showInfoPopup('Error loading this table', result.error);
137143
return false;
138144
}
145+
139146
const uploadInfo = {
140147
serverFile: result?.serverFile ?? null,
141148
title: tableRequest?.META_INFO?.title,
@@ -204,7 +211,7 @@ const NoTables = () => {
204211
};
205212

206213
const LoadedTables= (props) => {
207-
const {onSubmit, onCancel=dispatchHideDropDown, keepState=true, groupKey} = props;
214+
const {onSubmit, onCancel=dispatchHideDropDown, keepState=true, groupKey, isLoading} = props;
208215
const tables = getTableGroup()?.tables ?? null;
209216
if (!tables) {
210217
return <NoTables/>;
@@ -238,6 +245,7 @@ const LoadedTables= (props) => {
238245
<FormPanel onSuccess={onSubmit} onCancel={onCancel} completeText='Load Table'>
239246
<TablePanel tbl_id={tbl_id+'-ui'} tbl_ui_id={tbl_id+'-ui'} tableModel={tableModel} border={false} showTypes={false}
240247
showToolbar={false} showFilters={true} selectable={false} showOptionButton={false}/>
248+
{isLoading && <LoadingMessage/>}
241249
</FormPanel>
242250
</FieldGroup>
243251
</Stack>);
@@ -268,6 +276,7 @@ export function showUploadTableChooser(setUploadInfo,groupKey= 'table-chooser',d
268276
}
269277

270278
const TableUploadPanel= ({setUploadInfo,groupKey= 'table-chooser',defaultColsEnabledObj}) => {
279+
const [isLoading, setLoading]= useState(false);
271280
return (
272281
<Stack height='35rem' sx={{resize:'both', overflow:'hidden',minHeight:'35rem', minWidth:'40rem'}}>
273282
<FieldGroup groupKey={groupKey} sx={{ flexGrow: 1}}>
@@ -287,9 +296,9 @@ const TableUploadPanel= ({setUploadInfo,groupKey= 'table-chooser',defaultColsEna
287296
</Tab>
288297
<Tab name='Loaded Tables' id='tableLoad' sx={{fontSize:'larger'}}>
289298
<LoadedTables {...{
290-
keepState: true, groupKey:groupKey+'-tableLoad',
299+
keepState: true, groupKey:groupKey+'-tableLoad',isLoading,
291300
onCancel:() => dispatchHideDialog(dialogId),
292-
onSubmit:(request) => existingTableSubmit(request,setUploadInfo,defaultColsEnabledObj)
301+
onSubmit:(request) => existingTableSubmit(request,setUploadInfo,defaultColsEnabledObj,setLoading)
293302
}}/>
294303
</Tab>
295304
</FieldGroupTabs>

src/firefly/js/visualize/ui/FileUploadViewPanel.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export function FileDropZone({dropEvent, setDropEvent, setLoadingOp, sx, childre
244244
);
245245
}
246246

247-
const LoadingMessage= ({message}) => (
247+
export const LoadingMessage= ({message}) => (
248248
<div style={{
249249
position: 'absolute',
250250
zIndex:20,

0 commit comments

Comments
 (0)