Skip to content

Commit 3a5ad15

Browse files
committed
Merge branch 'DM-6137-catalog-dd-constraints-table' into dev
2 parents 54002e4 + ba296de commit 3a5ad15

11 files changed

+718
-214
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ export class BasicTable extends Component {
2323
super(props);
2424
var {tbl_id, tbl_ui_id, tableModel} = props;
2525

26+
var isLocal = false;
2627
if (!tbl_id && tableModel) {
27-
tbl_id = get(tableModel, 'tbl_id', TblUtil.uniqueTblId());
28+
tbl_id = get(tableModel, 'tbl_id');
29+
isLocal = true;
2830
}
29-
tbl_ui_id = tbl_ui_id || TblUtil.uniqueTblUiId();
30-
this.tableConnector = TableConnector.newInstance(tbl_id, tbl_ui_id, tableModel);
31+
tbl_ui_id = tbl_ui_id || tbl_id + '-ui';
32+
this.tableConnector = TableConnector.newInstance(tbl_id, tbl_ui_id, isLocal);
3133
const uiState = TblUtil.getTableUiById(tbl_ui_id);
32-
this.state = Object.assign({}, this.props, uiState);
34+
this.state = uiState || {};
3335
}
3436

3537
componentDidMount() {
@@ -38,9 +40,10 @@ export class BasicTable extends Component {
3840
const {tbl_id, tbl_ui_id} = this.tableConnector;
3941
if (!get(this.state, 'tbl_id')) {
4042
dispatchTableUiUpdate({tbl_ui_id, tbl_id});
41-
if (tableModel) {
42-
dispatchTableReplace(tableModel);
43-
}
43+
}
44+
if (tableModel && isEmpty(this.state)) {
45+
set(tableModel, 'meta.local', true);
46+
dispatchTableReplace(tableModel);
4447
}
4548
}
4649

@@ -59,7 +62,7 @@ export class BasicTable extends Component {
5962
}
6063

6164
render() {
62-
const {selectable, border, renderers} = this.props || {};
65+
const {selectable, border, renderers} = this.props;
6366
const {columns, showUnits, showFilters, textView, startIdx, showMask, currentPage,
6467
hlRowIdx, selectInfo, filterInfo, sortInfo, data, error} = this.state;
6568
const {tableConnector} = this;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ export class BasicTableView extends React.Component {
7474
this.isUnmounted = true;
7575
}
7676

77+
componentDidUpdate(){
78+
const {onTableChanged} = this.props;
79+
onTableChanged && onTableChanged();
80+
}
81+
7782
shouldComponentUpdate(nProps, nState) {
7883
return sCompare(this, nProps, nState);
7984
}
@@ -148,6 +153,7 @@ export class BasicTableView extends React.Component {
148153
onSort, onFilter, onRowSelect, onSelectAll, onFilterSelected};
149154

150155
const headerHeight = 22 + (showUnits && 12) + (showFilters && 20);
156+
151157
return (
152158
<Resizable id='table-resizer' tabIndex='-1' onKeyDown={this.onKeyDown} className='TablePanel__frame' onResize={this.onResize}>
153159
{ widthPx === 0 ? <div /> :
@@ -188,6 +194,7 @@ BasicTableView.propTypes = {
188194
rowHeight: PropTypes.number,
189195
showMask: PropTypes.bool,
190196
currentPage: PropTypes.number,
197+
onTableChanged: PropTypes.func,
191198
renderers: PropTypes.objectOf(
192199
PropTypes.shape({
193200
cellRenderer: PropTypes.func,
@@ -202,6 +209,7 @@ BasicTableView.propTypes = {
202209
onFilter: PropTypes.func,
203210
onGotoPage: PropTypes.func
204211
})
212+
205213
};
206214

207215
BasicTableView.defaultProps = {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ export class TablePanel extends Component {
9999
filterInfo, filterCount, sortInfo, data} = this.state;
100100
const {tableConnector} = this;
101101

102+
const {onTableChanged} = this.props;
103+
102104
if (error) return <div className='TablePanel__error'>{error}</div>;
103105
if (isEmpty(columns)) return <div style={{position: 'relative', width: '100%', height: '100%'}}><div msg='loading...' className='loading-mask'/></div>;
104106

@@ -151,6 +153,7 @@ export class TablePanel extends Component {
151153
currentPage={currentPage}
152154
callbacks={tableConnector}
153155
renderers={renderers}
156+
onTableChanged={onTableChanged}
154157
/>
155158
{showOptions && <TablePanelOptions
156159
columns={columns}
@@ -189,6 +192,7 @@ TablePanel.propTypes = {
189192
showSave: PropTypes.bool,
190193
showOptionButton: PropTypes.bool,
191194
showFilterButton: PropTypes.bool,
195+
onTableChanged: PropTypes.func,
192196
renderers: PropTypes.objectOf(
193197
PropTypes.shape({
194198
cellRenderer: PropTypes.func,

src/firefly/js/tables/ui/TableRenderer.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,25 @@ export const ImageCell = ({rowIndex, data, col}) => (
190190
* @param value display this value for every cell.
191191
* @returns {function()}
192192
*/
193-
export const createLinkCell = ({valFromCol, value}) => {
193+
export const createLinkCell = ({hrefColIdx, value}) => {
194194

195195
return ({rowIndex, data, col, ...CellProps}) => {
196-
const href = get(data, [rowIndex, col],'undef');
197-
const val = value || get(data, [rowIndex, valFromCol], 'undef');
196+
hrefColIdx = hrefColIdx || col;
197+
const href = get(data, [rowIndex, hrefColIdx],'undef');
198+
const val = value || get(data, [rowIndex, col], 'undef');
199+
if(href ==='undef' || href === '#'){
200+
return (
201+
<Cell {...CellProps}>
202+
{val}
203+
</Cell>
204+
);
205+
}else {
198206
return (
199207
<Cell {...CellProps}>
200-
<a href={href}>{val}</a>
208+
<a target='_blank' href={href}>{val}</a>
201209
</Cell>
202210
);
211+
}
203212
};
204213
};
205214

@@ -211,7 +220,7 @@ export const createLinkCell = ({valFromCol, value}) => {
211220
* @param onChange
212221
* @returns {function()}
213222
*/
214-
export const createInputCell = (tooltips, size=10, validator, onChange) => {
223+
export const createInputCell = ({tooltips, size=10, validator, onChange}) => {
215224
const changeHandler = (rowIndex, data, col, v) => {
216225
set(data, [rowIndex, col], v.value);
217226
onChange && onChange(v);

src/firefly/js/ui/CatalogSearchMethodType.jsx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {dispatchAddImages,getAViewFromMultiView} from '../visualize/MultiViewCnt
3131
import WebPlotRequest from '../visualize/WebPlotRequest.js';
3232
import {dispatchPlotImage} from '../visualize/ImagePlotCntlr.js';
3333
import {FileUpload} from '../ui/FileUpload.jsx';
34+
import {getActiveTarget} from '../core/AppDataCntlr.js';
3435

3536
import './CatalogSearchMethodType.css';
3637
/*
@@ -61,13 +62,14 @@ export class CatalogSearchMethodType extends Component {
6162
render() {
6263
const {fields}= this.state;
6364
const searchType = get(fields, 'spatial.value', SpatialMethod.Cone.value);
65+
const max = get(fields, 'conesize.max', 10);
6466
const {groupKey} = this.props;
6567

6668
return (
67-
<div style={{padding: 10, display:'flex', flexDirection:'column', flexWrap:'no-wrap', alignItems:'center'}}>
69+
<div style={{display:'flex', flexDirection:'column', alignItems:'center'}}>
6870
{renderTargetPanel(groupKey, searchType)}
6971
<div
70-
style={{display:'flex', flexDirection:'row', flexWrap:'no-wrap', alignItems:'center' }}>
72+
style={{display:'flex', flexDirection:'column', flexWrap:'no-wrap', alignItems:'center' }}>
7173
<ListBoxInputField
7274
fieldKey='spatial'
7375
initialState={{
@@ -77,10 +79,10 @@ export class CatalogSearchMethodType extends Component {
7779
value:SpatialMethod.Cone.value
7880
}}
7981
options={ spatialOptions() }
80-
wrapperStyle={{marginRight:'15px'}}
82+
wrapperStyle={{marginRight:'15px', padding:'10px 0 5px 0'}}
8183
multiple={false}
8284
/>
83-
{sizeArea(searchType)}
85+
{sizeArea(searchType, max)}
8486
</div>
8587
</div>
8688
);
@@ -119,12 +121,12 @@ const spatialOptions = () => {
119121
* @param {number} max by default is 1 degree (3600 arcsec)
120122
* @returns {XML} SizeInputFields component
121123
*/
122-
function radiusInField(label = 'Radius:', tooltip = 'Enter radius of the search', min = 1 / 3600, max = 1) {
124+
function radiusInField({label = 'Radius:', tooltip = 'Enter radius of the search', min = 1 / 3600, max = 1}) {
123125
return (
124126
<SizeInputFields fieldKey='conesize' showFeedback={true}
125127
wrapperStyle={{padding:5, margin: '5px 0 5px 0'}}
126128
initialState={{
127-
value:initRadiusArcSec,
129+
value:initRadiusArcSec(max),
128130
tooltip: {tooltip},
129131
unit: 'arcsec',
130132
min: {min},
@@ -134,19 +136,19 @@ function radiusInField(label = 'Radius:', tooltip = 'Enter radius of the search'
134136
label={label}/>
135137
);
136138
}
137-
function sizeArea(searchType) {
139+
function sizeArea(searchType, max) {
138140

139141
if (searchType === SpatialMethod.Cone.value) {
140142
return (
141143
<div style={{border: '1px solid #a3aeb9'}}>
142-
{radiusInField()}
144+
{radiusInField({max})}
143145
</div>
144146
);
145147
} else if (searchType === SpatialMethod.Elliptical.value) {
146148
return (
147149
<div
148150
style={{padding:5, display:'flex', flexDirection:'column', flexWrap:'no-wrap', alignItems:'center', border:'solid #a3aeb9 1px' }}>
149-
{radiusInField('Semi-major Axis:', 'Enter the semi-major axis of the search')}
151+
{radiusInField({label:'Semi-major Axis:', tooltip:'Enter the semi-major axis of the search'})}
150152
<ValidationField fieldKey='posangle'
151153
forceReinit={true}
152154
initialState={{
@@ -173,7 +175,7 @@ function sizeArea(searchType) {
173175

174176
return (
175177
<div style={{border: '1px solid #a3aeb9'}}>
176-
{radiusInField('Side:', 'Enter side size of the box search', 1 / 3600, 7200 / 3600)}
178+
{radiusInField({label:'Side:', tooltip:'Enter side size of the box search', min:1 / 3600, max:7200 / 3600})}
177179
</div>
178180

179181
);
@@ -188,17 +190,17 @@ function sizeArea(searchType) {
188190
tooltip: 'Select a file to upload',
189191
label: 'Filename:'}}
190192
/>
191-
{radiusInField()}
193+
{radiusInField({})}
192194
</div>
193195
);
194196
} else if (searchType === SpatialMethod.Polygon.value) {
195197

196198
return (
197199
<div
198-
style={{padding:5, display:'flex', flexDirection:'column', flexWrap:'wrap', alignItems:'center', border:'solid #a3aeb9 1px' }}>
200+
style={{padding:5, border:'solid #a3aeb9 1px' }}>
199201
<InputAreaFieldConnected fieldKey='polygoncoords'
200-
wrapperStyle={{padding:5,display:'flex', flexDirection:'row', flexWrap:'wrap', alignItems:'center'}}
201-
style={{maxWidth:'350px', width:'200px', height:'30px', maxHeight:'150px', overflow:'auto'}}
202+
wrapperStyle={{padding:5}}
203+
style={{overflow:'auto',height:'65px', maxHeight:'200px', width:'220px', maxWidth:'300px'}}
202204
initialState={{
203205
tooltip:'Enter polygon coordinates search',
204206
labelWidth:70
@@ -227,10 +229,9 @@ function sizeArea(searchType) {
227229

228230
function renderTargetPanel(groupKey, searchType) {
229231
const visible = searchType === SpatialMethod.Cone.value || searchType === SpatialMethod.Box.value || searchType === SpatialMethod.Elliptical.value;
230-
231232
return (
232233
visible && <div className="intarget">
233-
<TargetPanel groupKey={groupKey}/>
234+
<TargetPanel wrapperStyle={{width:'200px'}} labelWidth={90} groupKey={groupKey}/>
234235
<ListBoxInputField
235236
fieldKey='targettry'
236237
options={[{label: 'Try NED then Simbad', value: 'NED'},
@@ -261,9 +262,15 @@ export const SpatialMethod = new Enum({
261262
'Box': 'Box',
262263
'Polygon': 'Polygon',
263264
'Multi-Object': 'Table',
264-
'All Sky': 'NONE'
265+
'All Sky': 'AllSky'
265266
},
266267
{ignoreCase: true}
267268
);
268269

269-
const initRadiusArcSec = parseFloat(500 / 3600).toString();
270+
var initRadiusArcSec = (max) => {
271+
if (max >= 10/3600) {
272+
return parseFloat(10 / 3600).toString();
273+
} else {
274+
return parseFloat(1 / 3600).toString();
275+
}
276+
};

src/firefly/js/ui/SizeInputField.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ class SizeInputFieldView extends Component {
196196
<ListBoxInputFieldView
197197
onChange={this.onUnitChange}
198198
options={
199-
[{label: 'Degree', value: 'deg'},
200-
{label: 'Arc Minutes', value: 'arcmin'},
201-
{label: 'Arc Seconds', value: 'arcsec'}
199+
[{label: 'degree', value: 'deg'},
200+
{label: 'arcminute', value: 'arcmin'},
201+
{label: 'arcsecond', value: 'arcsec'}
202202
]}
203203
value={unit}
204204
multiple={false}

0 commit comments

Comments
 (0)