11import { isArray , isNumber , isString } from 'lodash' ;
22import { ReservedParams } from '../../api/WebApi.js' ;
33import { sprintf } from '../../externalSource/sprintf.js' ;
4+ import { sortInfoString } from '../../tables/SortInfo.js' ;
45import { makeFileRequest , makeTblRequest , setNoCache } from '../../tables/TableRequestUtil.js' ;
56import { cisxAdhocServiceUtype , standardIDs } from '../../voAnalyzer/VoConst.js' ;
67import { splitByWhiteSpace , tokenSub } from '../../util/WebUtil.js' ;
@@ -308,20 +309,34 @@ export function makeSearchAreaInfo(cisxUI) {
308309let tblCnt = 1 ;
309310
310311export function makeServiceDescriptorSearchRequest ( request , serviceDescriptor , extraMeta = { } ) {
311- const { standardID = '' , accessURL, utype, serDefParams, title} = serviceDescriptor ;
312+ const { standardID = '' , accessURL, utype, serDefParams, title, cisxUI= [ ] } = serviceDescriptor ;
313+ const hiddenColumns = cisxUI . find ( ( e ) => e . name === 'hidden_columns' ) ?. value ;
314+ const tblSortOrder = cisxUI . find ( ( e ) => e . name === 'table_sort_order' ) ?. value ;
312315 const MAXREC = 50000 ;
313316 const tblTitle = `${ title } - ${ tblCnt ++ } ` ;
314317
318+ const hideObj = hiddenColumns ?
319+ Object . fromEntries ( hiddenColumns . split ( ',' ) . map ( ( c ) => [ `col.${ c } .visibility` , 'hide' ] ) ) : { } ;
320+
321+ const sAry = tblSortOrder ?. split ( ',' ) ;
322+ let sortObj = { } ;
323+ if ( sAry ?. length > 1 ) {
324+ const dir = sAry . shift ( ) ;
325+ sortObj = { sortInfo : sortInfoString ( sAry , dir ?. toUpperCase ( ) === 'ASC' ) } ;
326+ }
327+
328+ const options = { ...sortObj , META_INFO : { ...hideObj , ...extraMeta } } ;
329+
315330 if ( isSIAStandardID ( standardID ) ) {
316331 // we know this is a table so make a table request
317332 const url = accessURL + '?' + new URLSearchParams ( request ) . toString ( ) ;
318- return makeFileRequest ( tblTitle , url , undefined , { META_INFO : extraMeta } ) ; //todo- figure out title
333+ return makeFileRequest ( tblTitle , url , undefined , options ) ; //todo- figure out title
319334 }
320335 else if ( isSSAStandardID ( standardID ) ) {
321336 const url = accessURL + '?' + new URLSearchParams ( request ) . toString ( ) ;
322- return makeFileRequest ( tblTitle , url , undefined , { META_INFO : extraMeta } ) ; //todo- figure out title
337+ return makeFileRequest ( tblTitle , url , undefined , options ) ; //todo- figure out title
323338 }
324- else if ( isCisxTapStandardID ( standardID , utype , undefined , { META_INFO : extraMeta } ) ) {
339+ else if ( isCisxTapStandardID ( standardID , utype ) ) {
325340 // we know this is a table so make a table request either sync or async
326341 const doAsync = standardID . toLowerCase ( ) . includes ( 'async' ) ;
327342 const query = serDefParams . find ( ( { name} ) => name === 'QUERY' ) ?. value ;
@@ -332,20 +347,20 @@ export function makeServiceDescriptorSearchRequest(request, serviceDescriptor, e
332347
333348 if ( ! query ) return ;
334349 if ( doAsync ) {
335- const asyncReq = makeTblRequest ( 'AsyncTapQuery' , tblTitle , { serviceUrl, QUERY : finalQuery , MAXREC , META_INFO : extraMeta } ) ;
350+ const asyncReq = makeTblRequest ( 'AsyncTapQuery' , tblTitle , { serviceUrl, QUERY : finalQuery , MAXREC } , options ) ;
336351 setNoCache ( asyncReq ) ;
337352 return asyncReq ;
338353 } else {
339354 const serParam = new URLSearchParams ( { QUERY : finalQuery , REQUEST : 'doQuery' , LANG : 'ADQL' , MAXREC } ) ;
340355 const completeUrl = serviceUrl + '/sync?' + serParam . toString ( ) ;
341- return makeFileRequest ( title , completeUrl , undefined , { META_INFO : extraMeta } ) ; //todo- figure out title
356+ return makeFileRequest ( title , completeUrl , undefined , options ) ; //todo- figure out title
342357 }
343358
344359 }
345360 else {
346361 //todo: we should to call file analysis first
347362 const url = accessURL + '?' + new URLSearchParams ( request ) . toString ( ) ;
348- return makeFileRequest ( tblTitle , url ) ; //todo- figure out title
363+ return makeFileRequest ( tblTitle , url , undefined , options ) ; //todo- figure out title
349364 }
350365}
351366
0 commit comments