@@ -21,7 +21,7 @@ import {makeFileRequest} from '../../tables/TableRequestUtil.js';
2121import { SelectInfo } from '../../tables/SelectInfo.js' ;
2222import { getAViewFromMultiView , getMultiViewRoot , IMAGE } from '../MultiViewCntlr.js' ;
2323import WebPlotRequest from '../WebPlotRequest.js' ;
24- import { dispatchPlotHiPS , dispatchPlotImage , visRoot } from '../ImagePlotCntlr.js' ;
24+ import { dispatchPlotImage , visRoot } from '../ImagePlotCntlr.js' ;
2525import { RadioGroupInputField } from '../../ui/RadioGroupInputField.jsx' ;
2626import { showInfoPopup } from '../../ui/PopupUtil.jsx' ;
2727import { WorkspaceUpload } from '../../ui/WorkspaceViewer.jsx' ;
@@ -44,7 +44,7 @@ import {FileAnalysisType, Format} from '../../data/FileAnalysis';
4444import { dispatchValueChange } from 'firefly/fieldGroup/FieldGroupCntlr.js' ;
4545import { CompleteButton , NONE } from 'firefly/ui/CompleteButton.jsx' ;
4646import { createNewRegionLayerId } from 'firefly/drawingLayers/RegionPlot.js' ;
47- import { PLOT_ID } from 'firefly/visualize/saga/CoverageWatcher .js' ;
47+ import { getAppOptions } from 'firefly/core/AppDataCntlr .js' ;
4848
4949
5050export const panelKey = 'FileUploadAnalysis' ;
@@ -66,6 +66,14 @@ const SUPPORTED_TYPES=[
6666 FileAnalysisType . REGION ,
6767] ;
6868
69+ const TABLES_ONLY_SUPPORTED_TYPES = [
70+ FileAnalysisType . Table ,
71+ ] ;
72+
73+
74+ const isTablesOnly = ( ) => getAppOptions ( ) ?. uploadPanelLimit === 'tablesOnly' ;
75+
76+
6977const uploadOptions = 'uploadOptions' ;
7078
7179let currentAnalysisResult , currentReport , currentSummaryModel , currentDetailsModel ;
@@ -88,6 +96,8 @@ export function FileUploadViewPanel() {
8896 }
8997 } ) ;
9098
99+ const tablesOnly = isTablesOnly ( ) ;
100+
91101 const workspace = getWorkspaceConfig ( ) ;
92102 const uploadMethod = [ { value : FILE_ID , label : 'Upload file' } ,
93103 { value : URL_ID , label : 'Upload from URL' }
@@ -117,7 +127,7 @@ export function FileUploadViewPanel() {
117127 { report && < CompleteButton text = 'Clear File' groupKey = { NONE } onSuccess = { ( ) => clearReport ( ) } /> }
118128 </ div >
119129 </ div >
120- < FileAnalysis { ...{ report, summaryModel, detailsModel} } />
130+ < FileAnalysis { ...{ report, summaryModel, detailsModel, tablesOnly } } />
121131 < ImageDisplayOption />
122132 </ div >
123133 </ FieldGroup >
@@ -134,18 +144,49 @@ const getPartCnt= () => currentReport?.parts?.length ?? 1;
134144const getFirstPartType = ( ) => currentSummaryModel ?. tableData . data [ 0 ] ?. [ 1 ] ;
135145const getFileFormat = ( ) => currentReport ?. fileFormat ;
136146const isRegion = ( ) => getFirstPartType ( ) === FileAnalysisType . REGION ;
137- const isSupported = ( ) => getFirstPartType ( ) && ( SUPPORTED_TYPES . includes ( getFirstPartType ( ) ) || getFileFormat ( ) === Format . FITS ) ;
147+
148+ function isSinglePartFileSupported ( ) {
149+ const supportedTypes = isTablesOnly ( ) ? TABLES_ONLY_SUPPORTED_TYPES : SUPPORTED_TYPES ;
150+ return getFirstPartType ( ) && ( supportedTypes . includes ( getFirstPartType ( ) ) ) ;
151+ }
152+
153+ function isFileSupported ( ) {
154+ return getFirstPartType ( ) && ( SUPPORTED_TYPES . includes ( getFirstPartType ( ) ) || getFileFormat ( ) === Format . FITS ) ;
155+ }
156+
157+
158+ function getFirstExtWithData ( parts ) {
159+ return isTablesOnly ( ) ?
160+ parts . findIndex ( ( p ) => p . type . includes ( FileAnalysisType . Table ) ) :
161+ parts . findIndex ( ( p ) => ! p . type . includes ( FileAnalysisType . HeaderOnly ) ) ;
162+ }
138163
139164
140165
166+ function tablesOnlyResultSuccess ( ) {
167+ const tableIndices = getSelectedRows ( FileAnalysisType . Table ) ;
168+ const imageIndices = getSelectedRows ( FileAnalysisType . Image ) ;
169+
170+ if ( tableIndices . length > 0 ) {
171+ imageIndices . length > 0 && showInfoPopup ( 'Only loading the tables, ignoring the images.' ) ;
172+ sendTableRequest ( tableIndices , getFileCacheKey ( ) ) ;
173+ return true ;
174+ }
175+ else {
176+ showInfoPopup ( 'You may only upload tables.' ) ;
177+ return false ;
178+ }
179+ }
180+
141181
142182export function resultSuccess ( request ) {
183+ if ( isTablesOnly ( ) ) return tablesOnlyResultSuccess ( ) ;
143184 const fileCacheKey = getFileCacheKey ( ) ;
144185
145- const tableIndices = getSelectedRows ( ' Table' ) ;
146- const imageIndices = getSelectedRows ( ' Image' ) ;
186+ const tableIndices = getSelectedRows ( FileAnalysisType . Table ) ;
187+ const imageIndices = getSelectedRows ( FileAnalysisType . Image ) ;
147188
148- if ( ! isSupported ( ) ) {
189+ if ( ! isFileSupported ( ) ) {
149190 showInfoPopup ( `File type of ${ getFirstPartType ( ) } is not supported.` ) ;
150191 return false ;
151192 }
@@ -210,11 +251,12 @@ function getNextState() {
210251 } ;
211252 modelToUseForDetails = currentSummaryModel ;
212253
213- const firstExtWithData = parts . findIndex ( ( p ) => ! p . type . includes ( 'HeaderOnly' ) ) ;
254+ const firstExtWithData = getFirstExtWithData ( parts ) ;
214255 if ( firstExtWithData >= 0 ) {
215256 const selectInfo = SelectInfo . newInstance ( { rowCount : data . length } ) ;
216257 selectInfo . setRowSelect ( firstExtWithData , true ) ; // default select first extension/part with data
217258 currentSummaryModel . selectInfo = selectInfo . data ;
259+ modelToUseForDetails . highlightedRow = firstExtWithData ;
218260 }
219261
220262 }
@@ -337,7 +379,7 @@ function AnalysisTable({summaryModel, detailsModel, report}) {
337379 ) ;
338380}
339381
340- function SingleDataSet ( { type, desc, detailsModel, report, supported= isSupported ( ) } ) {
382+ function SingleDataSet ( { type, desc, detailsModel, report, supported= isSinglePartFileSupported ( ) } ) {
341383 const showDetails = supported && detailsModel ;
342384 return (
343385 < div style = { { display :'flex' , flex :'1 1 auto' , justifyContent : showDetails ?'start' :'center' } } >
@@ -375,18 +417,24 @@ function Details({detailsModel}) {
375417}
376418
377419
378- const FileAnalysis = React . memo ( ( { report, summaryModel, detailsModel} ) => {
379- const isUnknownFormat = get ( report , 'fileFormat' ) === UNKNOWN_FORMAT ;
380- const tableArea = isUnknownFormat ?
381- < div style = { { flexGrow : 1 , marginTop : 40 , textAlign :'center' , fontSize : 'larger' , color : 'red' } } >
382- Error: Unrecognized Format
383- </ div > :
384- < AnalysisTable { ...{ summaryModel, detailsModel, report} } /> ;
420+ function getTableArea ( report , summaryModel , detailsModel ) {
421+ if ( report ?. fileFormat === UNKNOWN_FORMAT ) {
422+ return (
423+ < div style = { { flexGrow : 1 , marginTop : 40 , textAlign :'center' , fontSize : 'larger' , color : 'red' } } >
424+ Error: Unrecognized Format
425+ </ div >
426+ ) ;
427+ }
428+ return < AnalysisTable { ...{ summaryModel, detailsModel, report} } /> ;
429+ }
430+
431+
432+ const FileAnalysis = React . memo ( ( { report, summaryModel, detailsModel, tablesOnly} ) => {
385433 if ( report ) {
386434 return (
387435 < div className = 'FileUpload__report' >
388436 { summaryModel . tableData . data . length > 1 && < AnalysisInfo report = { report } /> }
389- { tableArea }
437+ { getTableArea ( report , summaryModel , detailsModel ) }
390438 </ div >
391439 ) ;
392440 }
@@ -396,9 +444,9 @@ const FileAnalysis = React.memo( ({report, summaryModel, detailsModel}) => {
396444 You can load any of the following types of files:
397445 < ul >
398446 < li style = { liStyle } > Custom catalog in IPAC, CSV, TSV, VOTABLE, or FITS table format</ li >
399- < li style = { liStyle } > Any FITS file with tables or images (including multiple HDUs)</ li >
400- < li style = { liStyle } > A Region file</ li >
401- < li style = { liStyle } > A MOC FITS file</ li >
447+ { ! tablesOnly && < li style = { liStyle } > Any FITS file with tables or images (including multiple HDUs)</ li > }
448+ { ! tablesOnly && < li style = { liStyle } > A Region file</ li > }
449+ { ! tablesOnly && < li style = { liStyle } > A MOC FITS file</ li > }
402450 </ ul >
403451 </ div > ) ;
404452
@@ -428,17 +476,7 @@ function getSelectedRows(type) {
428476function sendRegionRequest ( fileCacheKey ) {
429477 const drawLayerId = createNewRegionLayerId ( ) ;
430478 const title = currentReport . fileName ?? 'Region File' ;
431- // if (!getPlotViewAry(visRoot())?.length) {
432- // const wpRequest= WebPlotRequest.makeHiPSRequest('ivo://CDS/P/2MASS/color');
433- // const {viewerId=''} = getAViewFromMultiView(getMultiViewRoot(), IMAGE) || {};
434- // dispatchPlotHiPS({plotId: PLOT_ID, viewerId, wpRequest, pvOptions: {displayFixedTarget:false} });
435- // setTimeout(() => {
436- // dispatchCreateRegionLayer(drawLayerId, title, fileCacheKey, null);
437- // }, 2000);
438- // }
439- // else {
440- dispatchCreateRegionLayer ( drawLayerId , title , fileCacheKey , null ) ;
441- // }
479+ dispatchCreateRegionLayer ( drawLayerId , title , fileCacheKey , null ) ;
442480 if ( ! getPlotViewAry ( visRoot ( ) ) ?. length ) {
443481 showInfoPopup ( 'The region file is loaded but you will not be able to see it until you load an image (FITS or HiPS)' , 'Warning' ) ;
444482 }
0 commit comments