Skip to content

DM-7761 Build LSST Catalog search form using the components from IRSA catalog search form #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/firefly/html/firefly.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
menu: [
{label:'Images', action:'ImageSelectDropDownCmd'},
{label:'Catalogs', action:'IrsaCatalogDropDown'},
{label:'LSST Catalogs', action:'LsstCatalogDropDown'},
{label:'Charts', action:'ChartSelectDropDownCmd'},
{label:'Demo Searches', action:'TestSearches'},
//{label:'Help', action:'app_data.helpLoad', type:'COMMAND'},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@
import org.json.simple.parser.ParseException;
import java.io.*;
import java.util.List;
import edu.caltech.ipac.visualize.plot.CoordinateSys;
import edu.caltech.ipac.firefly.data.table.MetaConst;


/**
* Created by zhang on 10/10/16.
*/
@SearchProcessorImpl(id = "LSSTCataLogSearch")
public class LSSTCataLogSearch extends IpacTablePartProcessor {
private static final String RA = "coord_ra";
private static final String DEC = "coord_decl";

private static final Logger.LoggerImpl _log = Logger.getLogger();

private static String DATA_ACCESS_URI = AppProperties.getProperty("lsst.dataAccess.uri", "lsst.dataAccess.uri");
Expand Down Expand Up @@ -259,6 +264,11 @@ protected String getFilePrefix(TableServerRequest request) {
}
@Override
public void prepareTableMeta(TableMeta meta, List<DataType> columns, ServerRequest request) {
TableMeta.LonLatColumns llc = null;

llc = new TableMeta.LonLatColumns(RA, DEC, CoordinateSys.EQ_J2000);
meta.setCenterCoordColumns(llc);
meta.setAttribute(MetaConst.CATALOG_OVERLAY_TYPE, "LSST");
super.prepareTableMeta(meta, columns, request);
}

Expand Down
2 changes: 1 addition & 1 deletion src/firefly/js/tables/FilterInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class FilterInfo {
*/
static isConditionValid(conditions) {
return !conditions || conditions.split(';').reduce( (rval, v) => {
return rval && cond_only_regex.test(v.trim());
return rval && (!v || cond_only_regex.test(v.trim()));
}, true);
}

Expand Down
38 changes: 36 additions & 2 deletions src/firefly/js/tables/TableUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const SEARCH_SRV_PATH = getRootURL() + 'search/json';
export const MAX_ROW = Math.pow(2,31) - 1;
const SAVE_TABLE_URL = getRootURL() + 'servlet/SaveAsIpacTable';

const LSSTQueryPID = 'LSSTCataLogSearch';
/**
* @public
*/
Expand Down Expand Up @@ -123,6 +124,39 @@ export function makeIrsaCatalogRequest(title, project, catalog, params={}, optio

return omitBy(Object.assign(req, options, params, {id, tbl_id, META_INFO, UserTargetWorldPt, catalogProject, catalog}), isNil);
}

/**
* creates the request to query LSST catalogs. // TODO: more detail to be updated based on the LSST catalog DD content
* @param {string} title title to be displayed with this table result
* @param {string} project
* @param {string} catalog the catalog name to search
* @param {ConeParams|BoxParams|ElipParams} params one of 'Cone','Eliptical','Box','Polygon','Table','AllSky'.
* @param {TableRequest} [options]
* @returns {TableRequest}
* @access public
* @func makeLsstCatalogRequest
* @memberof firefly.util.table
*/
export function makeLsstCatalogRequest(title, project, catalog, params={}, options={}) {
var req = {startIdx: 0, pageSize: 100};

title = title || catalog;
options.use = options.use || 'lsst_catalog_overlay';
const tbl_id = options.tbl_id || uniqueTblId();
const id = LSSTQueryPID;
const UserTargetWorldPt = params.UserTargetWorldPt || params.position; // may need to convert to worldpt.
const table_name = 'RunDeepForcedSource_limit100'; //catalog+'_queryresult';
const meta_table = catalog;
var META_INFO = Object.assign(options.META_INFO || {}, {title, tbl_id});


options = omit(options, 'tbl_id');
params = omit(params, 'position');

return omitBy(Object.assign(req, options, params,
{id, tbl_id, META_INFO, UserTargetWorldPt, table_name, meta_table, project}), isNil);
}

/**
* creates the request to query VO catalog
* @param {string} title title to be displayed with this table result
Expand Down Expand Up @@ -229,8 +263,8 @@ export function doValidate(type, action) {
/**
* updates the given action with a new error given by cause.
* action.err is stored as an array of errors. Errors may be a String or an Error type.
* @param action the actoin to update
* @param cause the error to be added.
* @param {Object} action the action to update
* @param {string} cause the error to be added.
* @public
* @func error
* @memberof firefly.util.table
Expand Down
3 changes: 2 additions & 1 deletion src/firefly/js/tables/ui/BasicTableView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ export class BasicTableView extends React.Component {
this.isUnmounted = true;
}

/*
componentDidUpdate(){
const {onTableChanged} = this.props;
onTableChanged && onTableChanged();
}
*/

shouldComponentUpdate(nProps, nState) {
return sCompare(this, nProps, nState);
Expand Down Expand Up @@ -195,7 +197,6 @@ BasicTableView.propTypes = {
rowHeight: PropTypes.number,
showMask: PropTypes.bool,
currentPage: PropTypes.number,
onTableChanged: PropTypes.func,
bgColor: PropTypes.string,
renderers: PropTypes.objectOf(
PropTypes.shape({
Expand Down
4 changes: 1 addition & 3 deletions src/firefly/js/tables/ui/TablePanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export class TablePanel extends Component {
filterInfo, filterCount, sortInfo, data} = this.state;
const {tableConnector} = this;

const {onTableChanged} = this.props;

if (error) return <div className='TablePanel__error'>{error}</div>;
if (isEmpty(columns)) return <Loading {...{showTitle, tbl_id, title, removable}}/>;
Expand Down Expand Up @@ -172,7 +171,7 @@ export class TablePanel extends Component {
callbacks={tableConnector}
{ ...{columns, data, hlRowIdx, rowHeight, selectable, showUnits, showFilters,
selectInfoCls, filterInfo, sortInfo, textView, showMask, currentPage,
tableConnector, renderers, onTableChanged} }
tableConnector, renderers} }
/>
{showOptionButton && !showToolbar &&
<img className='TablePanel__options--small'
Expand Down Expand Up @@ -217,7 +216,6 @@ TablePanel.propTypes = {
showSave: PropTypes.bool,
showOptionButton: PropTypes.bool,
showFilterButton: PropTypes.bool,
onTableChanged: PropTypes.func,
renderers: PropTypes.objectOf(
PropTypes.shape({
cellRenderer: PropTypes.func,
Expand Down
22 changes: 13 additions & 9 deletions src/firefly/js/ui/CatalogSearchMethodType.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class CatalogSearchMethodType extends Component {
labelWidth: 80,
value: polyIsDef ? SpatialMethod.Polygon.value : SpatialMethod.Cone.value
}}
options={ spatialOptions() }
options={ spatialOptions(this.props.searchOption) }
wrapperStyle={{marginRight:'15px', padding:'10px 0 5px 0'}}
multiple={false}
/>
Expand All @@ -104,6 +104,7 @@ export class CatalogSearchMethodType extends Component {

}
/*
Display the speicified options in case a list of options is given, otherwise display all options.
[
{value: 'Cone', label: 'Cone' },
{value: 'Elliptical', label: 'Elliptical' },
Expand All @@ -112,13 +113,15 @@ export class CatalogSearchMethodType extends Component {
{value: 'Multi-Object', label: 'Multi-Object' },
{value: 'All-Sky', label: 'All Sky' }
]*/
const spatialOptions = () => {
const spatialOptions = (searchTypes) => {
var l = [];
SpatialMethod.enums.forEach(function (enumItem) {
var o = {};
o.label = enumItem.key;
o.value = enumItem.value;
l.push(o);
if (!searchTypes || searchTypes.includes(enumItem.value)) {
var o = {};
o.label = enumItem.key;
o.value = enumItem.value;
l.push(o);
}
}
);
return l;
Expand Down Expand Up @@ -325,8 +328,8 @@ function sizeArea(searchType, imageCornerCalc) {
function renderTargetPanel(groupKey, searchType) {
const visible = searchType === SpatialMethod.Cone.value || searchType === SpatialMethod.Box.value || searchType === SpatialMethod.Elliptical.value;
return (
visible && <div className='intarget'>
<TargetPanel labelWidth={100} groupKey={groupKey}/>
<div className='intarget'>
{visible && <TargetPanel labelWidth={100} groupKey={groupKey}/>}
</div>
);

Expand All @@ -336,6 +339,7 @@ function renderTargetPanel(groupKey, searchType) {
CatalogSearchMethodType.propTypes = {
groupKey: PropTypes.string.isRequired,
polygonDefWhenPlot: PropTypes.bool,
searchOption: PropTypes.arrayOf(PropTypes.string)
};

/*CatalogSearchMethodType.contextTypes = {
Expand Down Expand Up @@ -402,7 +406,7 @@ function fieldInit() {
value: initRadiusArcSec(3600),
unit: 'arcsec',
min: 1 / 3600,
max: 100,
max: 100
},
imageCornerCalc: {
fieldKey: 'imageCornerCalc',
Expand Down
4 changes: 3 additions & 1 deletion src/firefly/js/ui/DropDownContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {TestQueriesPanel} from '../ui/TestQueriesPanel.jsx';
import {ImageSelectDropdown} from '../ui/ImageSelectDropdown.jsx';
import {ChartSelectDropdown} from '../ui/ChartSelectDropdown.jsx';
import {CatalogSelectViewPanel} from '../visualize/ui/CatalogSelectViewPanel.jsx';
import {LSSTCatalogSelectViewPanel} from '../visualize/ui/LSSTCatalogSelectViewPanel.jsx';
import {getAlerts} from '../core/AppDataCntlr.js';

import './DropDownContainer.css';
Expand All @@ -25,7 +26,8 @@ const dropDownMap = {
TestSearches: <TestQueriesPanel />,
ImageSelectDropDownCmd: <ImageSelectDropdown />,
ChartSelectDropDownCmd: <ChartSelectDropdown />,
IrsaCatalogDropDown: <CatalogSelectViewPanel/>
IrsaCatalogDropDown: <CatalogSelectViewPanel/>,
LsstCatalogDropDown: <LSSTCatalogSelectViewPanel/>
};


Expand Down
8 changes: 6 additions & 2 deletions src/firefly/js/ui/FileUpload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const UL_URL = getRootURL() + 'sticky/Firefly_FileUpload';


function FileUploadView({fileType, isLoading, label, valid, wrapperStyle, message, onChange, value}) {
var style = {color: 'transparent', border: 'none', background: 'none'};
var fileName = value ? value.split(/(\\|\/)/g).pop() : 'No file chosen';

return (
<div>
<InputFieldView
Expand All @@ -25,10 +28,11 @@ function FileUploadView({fileType, isLoading, label, valid, wrapperStyle, messag
tooltip = {value}
labelWidth = {0}
inline={true}
style = {{border: 'none', background: 'none'}}
style = {style}
wrapperStyle = {wrapperStyle}
/>
{isLoading && <img style={{position: 'inline-block', width:14,height:14}} src={LOADING}/> }
{fileName && <div style={{display:'inline-block', marginLeft: -170}}>{fileName}</div>}
{isLoading && <img style={{position: 'inline-block', marginLeft: 10, width:14,height:14}} src={LOADING}/> }
</div>
);
}
Expand Down
19 changes: 9 additions & 10 deletions src/firefly/js/ui/InputField.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {PropTypes} from 'react';
import {has, get} from 'lodash';
import {has, get, isNil} from 'lodash';

import {InputFieldView} from './InputFieldView.jsx';
import {NOT_CELL_DATA} from '../tables/ui/TableRenderer.js';
Expand Down Expand Up @@ -30,35 +30,34 @@ export class InputField extends React.Component {
handleChanges(e) {
var {fieldKey, validator, onChange, label='', actOn} = this.props;
const value = e.target.value;
const nState = {fieldKey, value};
const nState = {fieldKey, value, notValidate: true};
if (shouldAct(e, actOn)) {
var {valid, message, ...others} = validator ? validator(value) : {valid: true, message: ''};
var vadVal = get(others, 'value'); // vadVal has value as undefined in case no validator exists.
if (vadVal && vadVal !== NOT_CELL_DATA) {
nState.value = others.value;
}
//has(others, 'value') && (nState.value = others.value); // allow the validator to modify the value.. useful in auto-correct.

nState.valid = valid;
nState.message = valid ? '' : (label + message).replace('::', ':');
nState.isAct = true;
nState.notValidate = false;
onChange && onChange(nState);
} else {
nState.isAct = false;
}

this.setState(nState);
}

componentWillReceiveProps(nProps) {
this.setState(newState({value: nProps.value}));
//this.setState(newState({value: nProps.value}));
this.setState({value: nProps.value})
}

render() {

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

return (
<InputFieldView
Expand Down Expand Up @@ -102,7 +101,7 @@ InputField.propTypes = {
valid: PropTypes.bool,
onChange: PropTypes.func,
actOn: PropTypes.arrayOf(PropTypes.oneOf(['blur', 'enter', 'changes'])),
showWarning : PropTypes.bool,
showWarning : PropTypes.bool
};

InputField.defaultProps = {
Expand Down
8 changes: 5 additions & 3 deletions src/firefly/js/ui/PagingBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class PagingBar extends Component {
render() {
const {currentPage, totalRows, pageSize, showLoading, callbacks} = this.props;

const showAll = pageSize === MAX_ROW;
const showAll = (totalRows === 0) || (pageSize === MAX_ROW);
const startIdx = (currentPage-1) * pageSize;
const endIdx = Math.min(startIdx+pageSize, totalRows);
var totalPages = Math.ceil((totalRows || 0)/pageSize);
Expand All @@ -29,8 +29,10 @@ export class PagingBar extends Component {
callbacks.onGotoPage(pageNum.value);
}
};
const showingLabel = ( <div style={{fontSize: 'smaller', marginLeft: 3}} >
({(startIdx+1).toLocaleString()} - {endIdx.toLocaleString()} of {totalRows.toLocaleString()})
const pagestr = (totalRows === 0) ? '(No Data Found)' :
`(${(startIdx+1).toLocaleString()} - ${endIdx.toLocaleString()} of ${totalRows.toLocaleString()})`;
const showingLabel = ( <div style={{fontSize: 'smaller', marginLeft: 3, display: 'inline-flex', alignItems: 'center' }} >
{pagestr}
</div>
);
if (showAll) {
Expand Down
5 changes: 4 additions & 1 deletion src/firefly/js/ui/RadioGroupInputFieldView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ export function RadioGroupInputFieldView({options,alignment,fieldKey,value,
onChange,label,inline,tooltip,
labelWidth, wrapperStyle={}}) {
const style= Object.assign({whiteSpace:'nowrap',display: inline?'inline-block':'block'},wrapperStyle);
const radioStyle = (alignment && alignment==='vertical') ? {display: 'block', marginTop: (label ? 10 : 0)}
: {display: 'inline-block'};

return (
<div style={style}>
{label && <InputFieldLabel label={label} tooltip={tooltip} labelWidth={labelWidth} /> }
<div style={{display:'inline-block'}} >
<div style={radioStyle} >
{makeOptions(options,alignment,fieldKey,value,onChange,tooltip)}
</div>
</div>
Expand Down
10 changes: 7 additions & 3 deletions src/firefly/js/visualize/saga/CatalogWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function handleCatalogUpdate(tbl_id) {

if (!totalRows ||
!tableMeta[MetaConst.CATALOG_OVERLAY_TYPE] ||
!tableMeta[MetaConst.CATALOG_COORD_COLS]) {
(!tableMeta[MetaConst.CATALOG_COORD_COLS] && !tableMeta[MetaConst.CENTER_COLUMN])) {
return;
}

Expand All @@ -92,8 +92,12 @@ function handleCatalogUpdate(tbl_id) {
return;
}

const s = tableMeta[MetaConst.CATALOG_COORD_COLS].split(';');
if (s.length!== 3) return;
const cenData= tableMeta[MetaConst.CATALOG_COORD_COLS] || tableMeta[MetaConst.CENTER_COLUMN];

var s;
if (cenData) s= cenData.split(';');
if (!s || s.length!== 3) return;

const columns= {
lonCol: s[0],
latCol: s[1],
Expand Down
Loading