Skip to content

Commit c248e60

Browse files
authored
Firefly-1144: Merge PR #1313 from firefly-1144-tap-searchParams
Firefly-1144: add better support tap search params for click-to-action
2 parents 6f066a6 + 12354f9 commit c248e60

File tree

8 files changed

+38
-33
lines changed

8 files changed

+38
-33
lines changed

src/firefly/java/edu/caltech/ipac/firefly/server/ServerContext.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,12 @@ private static File setupWorkDir(String desc, String fromProp, File altDir) {
207207
log.info(desc + "; Using path from property: " + fromProp);
208208
File workDir = new File(fromProp);
209209
initDir(workDir);
210-
if (!workDir.canWrite()) {
210+
if (workDir.canWrite()) {
211+
return workDir;
212+
}
213+
else {
211214
log.info(desc + " failed. " + " Unable to write to directory: " + workDir.getPath());
212215
}
213-
return workDir;
214216
}
215217

216218
if (altDir == null) {

src/firefly/js/core/AppDataCntlr.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33
*/
44

5-
import {get, map, isUndefined} from 'lodash';
5+
import {get, map, isUndefined, isEmpty} from 'lodash';
66
import {flux} from './ReduxFlux';
77
import {dispatchAddActionWatcher} from './MasterSaga';
88
import {appDataReducer, menuReducer, alertsReducer} from './AppDataReducers.js';
@@ -224,6 +224,14 @@ export function getUserInfo() {
224224
return flux.getState()[APP_DATA_PATH].userInfo;
225225
}
226226

227+
export function getSearchActions() {
228+
const {searchActions, searchActionsCmdMask}= getAppOptions() ?? {};
229+
if (isEmpty(searchActions)) return undefined;
230+
if (isEmpty(searchActionsCmdMask)) return searchActions;
231+
const retSearchActions= searchActions.filter( ({cmd}) => searchActionsCmdMask.includes(cmd));
232+
return retSearchActions;
233+
}
234+
227235
/**
228236
* @param channel
229237
* @returns {number} the number of connections/clients connected to the given channel

src/firefly/js/tables/ui/TablePanel.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import React, {useEffect} from 'react';
66
import PropTypes from 'prop-types';
77
import {isEmpty, truncate, get, set} from 'lodash';
8-
import {getAppOptions} from '../../api/ApiUtil.js';
8+
import {getSearchActions} from '../../core/AppDataCntlr.js';
99
import {ActionsDropDownButton, isTableActionsDropVisible} from '../../ui/ActionsDropDownButton.jsx';
1010

1111
import {useStoreConnector} from '../../ui/SimpleComponent.jsx';
@@ -48,7 +48,7 @@ export function TablePanel(props) {
4848
tbl_ui_id = tbl_ui_id || `${tbl_id}-ui`;
4949

5050
const uiState = useStoreConnector(() => getTableUiById(tbl_ui_id) || {columns:[]}, [tbl_ui_id]);
51-
const searchActions= getAppOptions()?.searchActions;
51+
const searchActions= getSearchActions();
5252

5353
useEffect( () => {
5454
if (!getTableUiByTblId(tbl_id)) {

src/firefly/js/templates/fireflyslate/FireflySlate.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function getNextState(prevS, renderTreeId) {
6262
*
6363
*/
6464
export const FireflySlate= memo(( {initLoadingMessage, appTitle= 'Firefly', appIcon=FFTOOLS_ICO, altAppIcon,
65+
bannerLeftStyle, bannerMiddleStyle,
6566
footer, style, renderTreeId, menu:menuItems, showBgMonitor=false}) => {
6667
const state= useStoreConnector( (prevState) => getNextState(prevState,renderTreeId));
6768
const {isReady, mode={}, gridView= [], gridColumns=1, menu={}, dropDown={}, layoutInfo, initLoadCompleted, dropdownPanels} = state;
@@ -81,7 +82,7 @@ export const FireflySlate= memo(( {initLoadingMessage, appTitle= 'Firefly', appI
8182
<RenderTreeIdCtx.Provider value={{renderTreeId}}>
8283
<div id='App' className='rootStyle' style={style}>
8384
<header>
84-
<BannerSection {...{menu, appTitle, appIcon, altAppIcon}}/>
85+
<BannerSection {...{menu, appTitle, appIcon, altAppIcon, bannerLeftStyle, bannerMiddleStyle}}/>
8586
<div id={warningDivId} data-decor='full' className='warning-div center'/>
8687
<DropDownContainer key='dropdown' footer={footer} visible={!!visible}
8788
selected={view} initArgs={initArgs} {...{dropdownPanels} } />

src/firefly/js/ui/DefaultSearchActions.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,28 @@ const dispatchShowDropDown= ({view, initArgs}) =>
1515
flux.process({type: 'layout.showDropDown', payload: {visible: true, view, initArgs}});
1616
//------------
1717

18-
const showTap= (initArgs) => {
18+
export const showTapSearchPanel= (searchParams={}) => {
1919
const view= getAppOptions()?.multiTableSearchCmdOptions?.find(({id}) => id === 'tap') ? 'MultiTableSearchCmd' : 'TAPSearch';
20-
dispatchShowDropDown({ view, initArgs});
20+
dispatchShowDropDown({ view, initArgs:{defaultSelectedId: 'tap', searchParams}});
2121
};
2222

2323
const showImage= (initArgs) => dispatchShowDropDown( { view: 'ImageSelectDropDownCmd', initArgs});
2424

2525
export const makeDefTapSearchActions = () => {
2626
return [
2727
makeSearchAction('tapRadius', 'tap', 'TAP ', 'Cone Search', SearchTypes.pointRadius, .001, 2.25,
28-
(sa, cenWpt, radius) => {
29-
showTap( {defaultSelectedId: 'tap', searchParams: {radiusInArcSec: radius, wp: cenWpt}});
30-
}),
28+
(sa, cenWpt, radius) => showTapSearchPanel( {radiusInArcSec: radius, wp: cenWpt}), ),
3129
makeSearchAction('tapArea', 'tap', 'TAP', 'Area Search', SearchTypes.area, undefined, undefined,
32-
(sa, cenWpt, radius, corners) => {
33-
showTap({defaultSelectedId: 'tap', searchParams: {corners}});
34-
}),
35-
makeSearchAction('tapRadius', 'tap', 'TAP ', 'Cone Search', SearchTypes.point_table_only, .001, 2.25,
36-
(sa, cenWpt) => {
37-
showTap({defaultSelectedId: 'tap', searchParams: {wp: cenWpt}});
38-
}),
30+
(sa, cenWpt, radius, corners) => showTapSearchPanel({corners}), ),
31+
makeSearchAction('tableTapRadius', 'tap', 'TAP ', 'Cone Search', SearchTypes.point_table_only, .001, 2.25,
32+
(sa, cenWpt) => showTapSearchPanel({wp: cenWpt}), ),
3933
];
4034
};
4135

4236

4337
export const makeDefImageSearchActions = () => {
4438
return [
45-
makeSearchAction('imageFits', 'image', 'FITS', 'Fits tip', SearchTypes.point, undefined, undefined,
39+
makeSearchAction('imageFits', 'image', 'FITS', 'Load a FITS Image at this point', SearchTypes.point, undefined, undefined,
4640
(sa, wp) => showImage( {searchParams: {wp, type: 'singleChannel'}}) ),
4741
makeSearchAction('HiPS', 'image', 'HiPS', 'HiPS tip', SearchTypes.pointRadius, .0025, 180,
4842
(sa, wp, radius) => showImage( {searchParams: {wp, type: 'hipsImage', radius}}), 'Display HiPS at region center'),

src/firefly/js/ui/tap/TableSelectViewPanel.jsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {SpatialPanelWidth} from './TableSearchHelpers.jsx';
1414
import {TableSearchMethods} from './TableSearchMethods.jsx';
1515
import { defTapBrowserState, loadTapColumns, loadTapSchemas, loadTapTables, tapHelpId, } from './TapUtil.js';
1616

17-
1817
import './TableSelectViewPanel.css';
1918

2019

@@ -26,23 +25,18 @@ export const SectionTitle= ({title,helpId,tip}) => (
2625
<div className='TapSearch__section--title' title={tip}>{title}<HelpIcon helpId={tapHelpId(helpId)}/></div>);
2726

2827
export function AdqlUI({serviceUrl}) {
29-
3028
return (
31-
3229
<div className='TapSearch__section' style={{flexDirection: 'column', flexGrow: 1}}>
3330
<div style={{ display: 'inline-flex', alignItems: 'center'}}>
3431
<div className='TapSearch__section--title'>3. Advanced ADQL <HelpIcon helpId={tapHelpId('adql')}/> </div>
3532
<div style={{color: 'brown', fontSize: 'larger'}}>ADQL edits below will not be reflected in <b>Single Table</b> view</div>
3633
</div>
37-
38-
3934
<div className='expandable'>
4035
<div style={{flexGrow: 1}}>
4136
<AdvancedADQL adqlKey='adqlQuery' defAdqlKey='defAdqlKey' tblNameKey='tableName' serviceUrl={serviceUrl}/>
4237
</div>
4338
</div>
4439
</div>
45-
4640
);
4741
}
4842

@@ -57,22 +51,23 @@ function useStateRef(initialState){
5751
}
5852

5953
export function BasicUI(props) {
60-
const {initArgs}= props;
54+
const {initArgs={}}= props;
55+
const {urlApi={},searchParams={}}= initArgs;
6156
const [getTapBrowserState,setTapBrowserState]= useFieldGroupMetaState(defTapBrowserState);
57+
const {selectBy, obsCoreTableModel}= props;
6258
const initState = getTapBrowserState();
6359
const [error, setError] = useState(undefined);
6460
const mountedRef = useRef(false);
6561
const {setVal}= useContext(FieldGroupCtx);
6662
const serviceLabel= props.serviceLabel ?? initState.serviceLabel;
6763
const [serviceUrl, serviceUrlRef, setServiceUrl] = useStateRef(initState.serviceUrl || props.serviceUrl);
68-
const [schemaName, schemaRef, setSchemaName] = useStateRef(initState.schemaName || props.initArgs?.urlApi?.schema);
69-
const [tableName, tableRef, setTableName] = useStateRef(initState.tableName || props.initArgs?.urlApi?.table);
70-
const [obsCoreEnabled, setObsCoreEnabled] = useState(initState.obsCoreEnabled || props.initArgs?.urlApi?.selectBy === 'obscore');
64+
const [schemaName, schemaRef, setSchemaName] = useStateRef(searchParams.schema || initState.schemaName || urlApi.schema);
65+
const [tableName, tableRef, setTableName] = useStateRef(searchParams.table || initState.tableName || urlApi.table);
66+
const [obsCoreEnabled, setObsCoreEnabled] = useState(initState.obsCoreEnabled || initArgs.urlApi?.selectBy === 'obscore');
7167
const [schemaOptions, setSchemaOptions] = useState();
7268
const [tableOptions, setTableOptions] = useState();
7369
const [columnsModel, setColumnsModel] = useState();
74-
const selectBy = props.selectBy;
75-
const obsCoreTableModel = props.obsCoreTableModel;
70+
7671

7772
const obsCoreSelected = selectBy === 'obscore';
7873
const tableSectionNumber = !obsCoreSelected ? '4' : '3';

src/firefly/js/ui/tap/TapSearchRootPanel.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ export function TapSearchPanel({initArgs= {}, titleOn=true}) {
113113
setObsCoreTableModel(undefined);
114114
};
115115

116+
useEffect(() => {
117+
const {serviceUrl:u}= initArgs?.searchParams ?? {};
118+
u && u!==serviceUrl && setServiceUrl(u);
119+
}, [initArgs?.searchParams?.serviceUrl]);
120+
116121
useEffect(() => {
117122
return FieldGroupUtils.bindToStore( TAP_PANEL_GROUP_KEY, (fields) => {
118123
setSelectBy(getFieldVal(TAP_PANEL_GROUP_KEY,'selectBy',selectBy));

src/firefly/js/visualize/iv/ImageViewerDecorate.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React, {memo, useEffect, useState} from 'react';
77
import PropTypes from 'prop-types';
88
import shallowequal from 'shallowequal';
99
import {isEmpty,omit,isFunction} from 'lodash';
10-
import {getAppOptions} from '../../api/ApiUtil.js';
10+
import {getSearchActions} from '../../core/AppDataCntlr.js';
1111
import {getPlotGroupById} from '../PlotGroup.js';
1212
import {ExpandType, dispatchChangeActivePlotView} from '../ImagePlotCntlr.js';
1313
import {VisCtxToolbarView, canConvertHipsAndFits} from '../ui/VisCtxToolbarView';
@@ -138,7 +138,7 @@ function contextToolbar(plotView,dlAry,extensionList, width) {
138138
const clearFilter= showClearFilter(plotView,dlAry);
139139
const selAry= extensionList.filter( (ext) => ext.extType===AREA_SELECT);
140140
const extensionAry= isEmpty(selAry) ? EMPTY_ARRAY : selAry;
141-
const searchActions= getAppOptions()?.searchActions;
141+
const searchActions= getSearchActions();
142142
return (
143143
<VisCtxToolbarView {...{plotView, extensionAry, width,
144144
showSelectionTools:true, showCatSelect:select, showCatUnSelect:unselect, searchActions,

0 commit comments

Comments
 (0)