Skip to content

Commit 1b1d8df

Browse files
author
Cindy Wang
committed
DM-7761 Build LSST Catalog search form using the components from IRSA catalog search form
1 parent 6a15922 commit 1b1d8df

15 files changed

+945
-195
lines changed

src/firefly/html/firefly.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
menu: [
1616
{label:'Images', action:'ImageSelectDropDownCmd'},
1717
{label:'Catalogs', action:'IrsaCatalogDropDown'},
18+
{label:'LSST Catalogs', action:'LsstCatalogDropDown'},
1819
{label:'Charts', action:'ChartSelectDropDownCmd'},
1920
{label:'Demo Searches', action:'TestSearches'},
2021
//{label:'Help', action:'app_data.helpLoad', type:'COMMAND'},

src/firefly/java/edu/caltech/ipac/firefly/server/query/lsst/LSSTCataLogSearch.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@
1919
import org.json.simple.parser.ParseException;
2020
import java.io.*;
2121
import java.util.List;
22+
import edu.caltech.ipac.visualize.plot.CoordinateSys;
23+
import edu.caltech.ipac.firefly.data.table.MetaConst;
2224

2325

2426
/**
2527
* Created by zhang on 10/10/16.
2628
*/
2729
@SearchProcessorImpl(id = "LSSTCataLogSearch")
2830
public class LSSTCataLogSearch extends IpacTablePartProcessor {
31+
private static final String RA = "coord_ra";
32+
private static final String DEC = "coord_decl";
33+
2934
private static final Logger.LoggerImpl _log = Logger.getLogger();
3035

3136
private static String DATA_ACCESS_URI = AppProperties.getProperty("lsst.dataAccess.uri", "lsst.dataAccess.uri");
@@ -259,6 +264,11 @@ protected String getFilePrefix(TableServerRequest request) {
259264
}
260265
@Override
261266
public void prepareTableMeta(TableMeta meta, List<DataType> columns, ServerRequest request) {
267+
TableMeta.LonLatColumns llc = null;
268+
269+
llc = new TableMeta.LonLatColumns(RA, DEC, CoordinateSys.EQ_J2000);
270+
meta.setCenterCoordColumns(llc);
271+
meta.setAttribute(MetaConst.CATALOG_OVERLAY_TYPE, "LSST");
262272
super.prepareTableMeta(meta, columns, request);
263273
}
264274

src/firefly/js/tables/FilterInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class FilterInfo {
9797
*/
9898
static isConditionValid(conditions) {
9999
return !conditions || conditions.split(';').reduce( (rval, v) => {
100-
return rval && cond_only_regex.test(v.trim());
100+
return rval && (!v || cond_only_regex.test(v.trim()));
101101
}, true);
102102
}
103103

src/firefly/js/tables/TableUtil.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const SEARCH_SRV_PATH = getRootURL() + 'search/json';
1414
export const MAX_ROW = Math.pow(2,31) - 1;
1515
const SAVE_TABLE_URL = getRootURL() + 'servlet/SaveAsIpacTable';
1616

17+
const LSSTQueryPID = 'LSSTCataLogSearch';
1718
/**
1819
* @public
1920
*/
@@ -123,6 +124,39 @@ export function makeIrsaCatalogRequest(title, project, catalog, params={}, optio
123124

124125
return omitBy(Object.assign(req, options, params, {id, tbl_id, META_INFO, UserTargetWorldPt, catalogProject, catalog}), isNil);
125126
}
127+
128+
/**
129+
* creates the request to query LSST catalogs. // TODO: more detail to be updated based on the LSST catalog DD content
130+
* @param {string} title title to be displayed with this table result
131+
* @param {string} project
132+
* @param {string} catalog the catalog name to search
133+
* @param {ConeParams|BoxParams|ElipParams} params one of 'Cone','Eliptical','Box','Polygon','Table','AllSky'.
134+
* @param {TableRequest} [options]
135+
* @returns {TableRequest}
136+
* @access public
137+
* @func makeLsstCatalogRequest
138+
* @memberof firefly.util.table
139+
*/
140+
export function makeLsstCatalogRequest(title, project, catalog, params={}, options={}) {
141+
var req = {startIdx: 0, pageSize: 100};
142+
143+
title = title || catalog;
144+
options.use = options.use || 'lsst_catalog_overlay';
145+
const tbl_id = options.tbl_id || uniqueTblId();
146+
const id = LSSTQueryPID;
147+
const UserTargetWorldPt = params.UserTargetWorldPt || params.position; // may need to convert to worldpt.
148+
const table_name = 'RunDeepForcedSource_limit100'; //catalog+'_queryresult';
149+
const meta_table = catalog;
150+
var META_INFO = Object.assign(options.META_INFO || {}, {title, tbl_id});
151+
152+
153+
options = omit(options, 'tbl_id');
154+
params = omit(params, 'position');
155+
156+
return omitBy(Object.assign(req, options, params,
157+
{id, tbl_id, META_INFO, UserTargetWorldPt, table_name, meta_table, project}), isNil);
158+
}
159+
126160
/**
127161
* creates the request to query VO catalog
128162
* @param {string} title title to be displayed with this table result
@@ -229,8 +263,8 @@ export function doValidate(type, action) {
229263
/**
230264
* updates the given action with a new error given by cause.
231265
* action.err is stored as an array of errors. Errors may be a String or an Error type.
232-
* @param action the actoin to update
233-
* @param cause the error to be added.
266+
* @param {Object} action the action to update
267+
* @param {string} cause the error to be added.
234268
* @public
235269
* @func error
236270
* @memberof firefly.util.table

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ export class BasicTableView extends React.Component {
7575
this.isUnmounted = true;
7676
}
7777

78+
/*
7879
componentDidUpdate(){
7980
const {onTableChanged} = this.props;
8081
onTableChanged && onTableChanged();
8182
}
83+
*/
8284

8385
shouldComponentUpdate(nProps, nState) {
8486
return sCompare(this, nProps, nState);
@@ -195,7 +197,6 @@ BasicTableView.propTypes = {
195197
rowHeight: PropTypes.number,
196198
showMask: PropTypes.bool,
197199
currentPage: PropTypes.number,
198-
onTableChanged: PropTypes.func,
199200
bgColor: PropTypes.string,
200201
renderers: PropTypes.objectOf(
201202
PropTypes.shape({

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export class TablePanel extends Component {
117117
filterInfo, filterCount, sortInfo, data} = this.state;
118118
const {tableConnector} = this;
119119

120-
const {onTableChanged} = this.props;
121120

122121
if (error) return <div className='TablePanel__error'>{error}</div>;
123122
if (isEmpty(columns)) return <Loading {...{showTitle, tbl_id, title, removable}}/>;
@@ -172,7 +171,7 @@ export class TablePanel extends Component {
172171
callbacks={tableConnector}
173172
{ ...{columns, data, hlRowIdx, rowHeight, selectable, showUnits, showFilters,
174173
selectInfoCls, filterInfo, sortInfo, textView, showMask, currentPage,
175-
tableConnector, renderers, onTableChanged} }
174+
tableConnector, renderers} }
176175
/>
177176
{showOptionButton && !showToolbar &&
178177
<img className='TablePanel__options--small'
@@ -217,7 +216,6 @@ TablePanel.propTypes = {
217216
showSave: PropTypes.bool,
218217
showOptionButton: PropTypes.bool,
219218
showFilterButton: PropTypes.bool,
220-
onTableChanged: PropTypes.func,
221219
renderers: PropTypes.objectOf(
222220
PropTypes.shape({
223221
cellRenderer: PropTypes.func,

src/firefly/js/ui/CatalogSearchMethodType.jsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class CatalogSearchMethodType extends Component {
9090
labelWidth: 80,
9191
value: polyIsDef ? SpatialMethod.Polygon.value : SpatialMethod.Cone.value
9292
}}
93-
options={ spatialOptions() }
93+
options={ spatialOptions(this.props.searchOption) }
9494
wrapperStyle={{marginRight:'15px', padding:'10px 0 5px 0'}}
9595
multiple={false}
9696
/>
@@ -104,6 +104,7 @@ export class CatalogSearchMethodType extends Component {
104104

105105
}
106106
/*
107+
Display the speicified options in case a list of options is given, otherwise display all options.
107108
[
108109
{value: 'Cone', label: 'Cone' },
109110
{value: 'Elliptical', label: 'Elliptical' },
@@ -112,13 +113,15 @@ export class CatalogSearchMethodType extends Component {
112113
{value: 'Multi-Object', label: 'Multi-Object' },
113114
{value: 'All-Sky', label: 'All Sky' }
114115
]*/
115-
const spatialOptions = () => {
116+
const spatialOptions = (searchTypes) => {
116117
var l = [];
117118
SpatialMethod.enums.forEach(function (enumItem) {
118-
var o = {};
119-
o.label = enumItem.key;
120-
o.value = enumItem.value;
121-
l.push(o);
119+
if (!searchTypes || searchTypes.includes(enumItem.value)) {
120+
var o = {};
121+
o.label = enumItem.key;
122+
o.value = enumItem.value;
123+
l.push(o);
124+
}
122125
}
123126
);
124127
return l;
@@ -325,8 +328,8 @@ function sizeArea(searchType, imageCornerCalc) {
325328
function renderTargetPanel(groupKey, searchType) {
326329
const visible = searchType === SpatialMethod.Cone.value || searchType === SpatialMethod.Box.value || searchType === SpatialMethod.Elliptical.value;
327330
return (
328-
visible && <div className='intarget'>
329-
<TargetPanel labelWidth={100} groupKey={groupKey}/>
331+
<div className='intarget'>
332+
{visible && <TargetPanel labelWidth={100} groupKey={groupKey}/>}
330333
</div>
331334
);
332335

@@ -336,6 +339,7 @@ function renderTargetPanel(groupKey, searchType) {
336339
CatalogSearchMethodType.propTypes = {
337340
groupKey: PropTypes.string.isRequired,
338341
polygonDefWhenPlot: PropTypes.bool,
342+
searchOption: PropTypes.arrayOf(PropTypes.string)
339343
};
340344

341345
/*CatalogSearchMethodType.contextTypes = {
@@ -402,7 +406,7 @@ function fieldInit() {
402406
value: initRadiusArcSec(3600),
403407
unit: 'arcsec',
404408
min: 1 / 3600,
405-
max: 100,
409+
max: 100
406410
},
407411
imageCornerCalc: {
408412
fieldKey: 'imageCornerCalc',

src/firefly/js/ui/DropDownContainer.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {TestQueriesPanel} from '../ui/TestQueriesPanel.jsx';
1414
import {ImageSelectDropdown} from '../ui/ImageSelectDropdown.jsx';
1515
import {ChartSelectDropdown} from '../ui/ChartSelectDropdown.jsx';
1616
import {CatalogSelectViewPanel} from '../visualize/ui/CatalogSelectViewPanel.jsx';
17+
import {LSSTCatalogSelectViewPanel} from '../visualize/ui/LSSTCatalogSelectViewPanel.jsx';
1718
import {getAlerts} from '../core/AppDataCntlr.js';
1819

1920
import './DropDownContainer.css';
@@ -25,7 +26,8 @@ const dropDownMap = {
2526
TestSearches: <TestQueriesPanel />,
2627
ImageSelectDropDownCmd: <ImageSelectDropdown />,
2728
ChartSelectDropDownCmd: <ChartSelectDropdown />,
28-
IrsaCatalogDropDown: <CatalogSelectViewPanel/>
29+
IrsaCatalogDropDown: <CatalogSelectViewPanel/>,
30+
LsstCatalogDropDown: <LSSTCatalogSelectViewPanel/>
2931
};
3032

3133

src/firefly/js/ui/FileUpload.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const UL_URL = getRootURL() + 'sticky/Firefly_FileUpload';
1212

1313

1414
function FileUploadView({fileType, isLoading, label, valid, wrapperStyle, message, onChange, value}) {
15+
var style = {color: 'transparent', border: 'none', background: 'none'};
16+
var fileName = value ? value.split(/(\\|\/)/g).pop() : 'No file chosen';
17+
1518
return (
1619
<div>
1720
<InputFieldView
@@ -25,10 +28,11 @@ function FileUploadView({fileType, isLoading, label, valid, wrapperStyle, messag
2528
tooltip = {value}
2629
labelWidth = {0}
2730
inline={true}
28-
style = {{border: 'none', background: 'none'}}
31+
style = {style}
2932
wrapperStyle = {wrapperStyle}
3033
/>
31-
{isLoading && <img style={{position: 'inline-block', width:14,height:14}} src={LOADING}/> }
34+
{fileName && <div style={{display:'inline-block', marginLeft: -170}}>{fileName}</div>}
35+
{isLoading && <img style={{position: 'inline-block', marginLeft: 10, width:14,height:14}} src={LOADING}/> }
3236
</div>
3337
);
3438
}

src/firefly/js/ui/InputField.jsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {PropTypes} from 'react';
2-
import {has, get} from 'lodash';
2+
import {has, get, isNil} from 'lodash';
33

44
import {InputFieldView} from './InputFieldView.jsx';
55
import {NOT_CELL_DATA} from '../tables/ui/TableRenderer.js';
@@ -30,35 +30,34 @@ export class InputField extends React.Component {
3030
handleChanges(e) {
3131
var {fieldKey, validator, onChange, label='', actOn} = this.props;
3232
const value = e.target.value;
33-
const nState = {fieldKey, value};
33+
const nState = {fieldKey, value, notValidate: true};
3434
if (shouldAct(e, actOn)) {
3535
var {valid, message, ...others} = validator ? validator(value) : {valid: true, message: ''};
3636
var vadVal = get(others, 'value'); // vadVal has value as undefined in case no validator exists.
3737
if (vadVal && vadVal !== NOT_CELL_DATA) {
3838
nState.value = others.value;
3939
}
40-
//has(others, 'value') && (nState.value = others.value); // allow the validator to modify the value.. useful in auto-correct.
40+
4141
nState.valid = valid;
4242
nState.message = valid ? '' : (label + message).replace('::', ':');
43-
nState.isAct = true;
43+
nState.notValidate = false;
4444
onChange && onChange(nState);
45-
} else {
46-
nState.isAct = false;
4745
}
4846

4947
this.setState(nState);
5048
}
5149

5250
componentWillReceiveProps(nProps) {
53-
this.setState(newState({value: nProps.value}));
51+
//this.setState(newState({value: nProps.value}));
52+
this.setState({value: nProps.value})
5453
}
5554

5655
render() {
5756

5857
var {label, labelWidth, tooltip, visible, inline, size,
5958
showWarning, style, wrapperStyle, labelStyle, validator} = this.props;
60-
var {value} = this.state;
61-
var {valid, message} = get(this.state, 'isAct', false)&&validator ? validator(value) : {valid:true, message: ''};
59+
var {value, notValidate} = this.state;
60+
var {valid=true, message=''} = (!isNil(notValidate) && notValidate)? {} : (validator ? validator(value) : {});
6261

6362
return (
6463
<InputFieldView
@@ -102,7 +101,7 @@ InputField.propTypes = {
102101
valid: PropTypes.bool,
103102
onChange: PropTypes.func,
104103
actOn: PropTypes.arrayOf(PropTypes.oneOf(['blur', 'enter', 'changes'])),
105-
showWarning : PropTypes.bool,
104+
showWarning : PropTypes.bool
106105
};
107106

108107
InputField.defaultProps = {

src/firefly/js/ui/PagingBar.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class PagingBar extends Component {
1919
render() {
2020
const {currentPage, totalRows, pageSize, showLoading, callbacks} = this.props;
2121

22-
const showAll = pageSize === MAX_ROW;
22+
const showAll = (totalRows === 0) || (pageSize === MAX_ROW);
2323
const startIdx = (currentPage-1) * pageSize;
2424
const endIdx = Math.min(startIdx+pageSize, totalRows);
2525
var totalPages = Math.ceil((totalRows || 0)/pageSize);
@@ -29,8 +29,10 @@ export class PagingBar extends Component {
2929
callbacks.onGotoPage(pageNum.value);
3030
}
3131
};
32-
const showingLabel = ( <div style={{fontSize: 'smaller', marginLeft: 3}} >
33-
({(startIdx+1).toLocaleString()} - {endIdx.toLocaleString()} of {totalRows.toLocaleString()})
32+
const pagestr = (totalRows === 0) ? '(No Data Found)' :
33+
`(${(startIdx+1).toLocaleString()} - ${endIdx.toLocaleString()} of ${totalRows.toLocaleString()})`;
34+
const showingLabel = ( <div style={{fontSize: 'smaller', marginLeft: 3, display: 'inline-flex', alignItems: 'center' }} >
35+
{pagestr}
3436
</div>
3537
);
3638
if (showAll) {

src/firefly/js/ui/RadioGroupInputFieldView.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ export function RadioGroupInputFieldView({options,alignment,fieldKey,value,
2828
onChange,label,inline,tooltip,
2929
labelWidth, wrapperStyle={}}) {
3030
const style= Object.assign({whiteSpace:'nowrap',display: inline?'inline-block':'block'},wrapperStyle);
31+
const radioStyle = (alignment && alignment==='vertical') ? {display: 'block', marginTop: (label ? 10 : 0)}
32+
: {display: 'inline-block'};
33+
3134
return (
3235
<div style={style}>
3336
{label && <InputFieldLabel label={label} tooltip={tooltip} labelWidth={labelWidth} /> }
34-
<div style={{display:'inline-block'}} >
37+
<div style={radioStyle} >
3538
{makeOptions(options,alignment,fieldKey,value,onChange,tooltip)}
3639
</div>
3740
</div>

0 commit comments

Comments
 (0)