diff --git a/src/firefly/js/tables/TableUtil.js b/src/firefly/js/tables/TableUtil.js index d3d264c85a..bb18edec54 100644 --- a/src/firefly/js/tables/TableUtil.js +++ b/src/firefly/js/tables/TableUtil.js @@ -4,6 +4,7 @@ import {take, fork, cancel} from 'redux-saga/effects'; import {get, set, unset, has, isEmpty, isUndefined, uniqueId, cloneDeep, omit, omitBy, isNil, isPlainObject, isArray, padEnd} from 'lodash'; +import Enum from 'enum'; import * as TblCntlr from './TablesCntlr.js'; import {SortInfo, SORT_ASC, UNSORTED} from './SortInfo.js'; @@ -17,10 +18,13 @@ import {ServerParams} from '../data/ServerParams.js'; import {doUpload} from '../ui/FileUpload.jsx'; import {dispatchAddSaga} from '../core/MasterSaga.js'; +export const COL_TYPE = new Enum(['ALL', 'NUMBER', 'TEXT']); export const MAX_ROW = Math.pow(2,31) - 1; /* TABLE_REQUEST should match QueryUtil on the server-side */ const LSSTQueryPID = 'LSSTCataLogSearch'; + + /** * @public */ @@ -896,33 +900,6 @@ export function createErrorTbl(tbl_id, error) { } -/** - * @summary get column names from the column of numeric type - * @param {Array} tblColumns - * @returns {Array} - */ -export function getNumericColNames(tblColumns) { - const NumTypes = ['double', 'd', 'long', 'l', 'int', 'i', 'float', 'f']; - - return isEmpty(tblColumns) ? [] : - tblColumns.filter((tblCol) => (get(tblCol, 'visibility', '') !== 'hidden')) - .filter((tblCol) => (NumTypes.includes(tblCol.type))) - .map((tblCol) => (tblCol.name)); -} - -/** - * @summary get column names from the column of string or char type - * @param {Array} tblColumns - * @returns {Array} - */ -export function getStringColNames(tblColumns) { - const CharTypes = ['char', 'c', 's', 'str']; - - return isEmpty(tblColumns) ? [] : - tblColumns.filter((tblCol) => (get(tblCol, 'visibility', '') !== 'hidden')) - .filter((tblCol) => (CharTypes.includes(tblCol.type))) - .map((tblCol) => (tblCol.name)); -} /** * this function invoke the given callback when changes are made to the given tbl_id @@ -955,6 +932,34 @@ export function watchTableChanges(tbl_id, actions, callback) { return () => stopWatching = true; } + +/** + * @summary returns the non-hidden columns of the given table. If type is given, it + * will only return columns that match type. + * @param {TableModel} tableModel + * @param {COL_TYPE} type one of predefined COL_TYPE. defaults to 'ALL'. + * @returns {Array} + */ +export function getColumns(tableModel, type=COL_TYPE.ALL) { + return getColsByType(get(tableModel, 'tableData.columns', []), type); +} + +/** + * @summary returns only the non-hidden columns matching the given type. + * @param {Array} tblColumns + * @param {COL_TYPE} type one of predefined COL_TYPE. defaults to 'ALL'. + * @returns {Array} + */ +export function getColsByType(tblColumns=[], type=COL_TYPE.ALL) { + const charTypes = ['char', 'c', 's', 'str']; + const numTypes = ['double', 'd', 'long', 'l', 'int', 'i', 'float', 'f']; + const matcher = type === COL_TYPE.TEXT ? charTypes : numTypes; + return tblColumns.filter((col) => get(col, 'visibility') !== 'hidden' + && (type === COL_TYPE.ALL || matcher.includes(col.type))); +} + + + /*-------------------------------------private------------------------------------------------*/ /** * this saga watches for table update and invoke the given callback when @@ -982,5 +987,3 @@ function* doOnTblLoaded({tbl_id, callback}) { } callback && callback(getTblInfoById(tbl_id)); } - - diff --git a/src/firefly/js/templates/hydra/HydraManager.js b/src/firefly/js/templates/hydra/HydraManager.js index 123cf22853..65e8232d90 100644 --- a/src/firefly/js/templates/hydra/HydraManager.js +++ b/src/firefly/js/templates/hydra/HydraManager.js @@ -15,7 +15,6 @@ import {deleteAllDrawLayers} from '../../visualize/PlotViewUtil.js'; import {CHART_ADD} from '../../charts/ChartsCntlr.js'; import {REPLACE_VIEWER_ITEMS} from '../../visualize/MultiViewCntlr.js'; - /** * Configurable part of this template * @typedef {object} Config diff --git a/src/firefly/js/templates/lightcurve/LcConverterFactory.js b/src/firefly/js/templates/lightcurve/LcConverterFactory.js index 43a3600636..692f55106b 100644 --- a/src/firefly/js/templates/lightcurve/LcConverterFactory.js +++ b/src/firefly/js/templates/lightcurve/LcConverterFactory.js @@ -5,14 +5,17 @@ import {get, isNil} from 'lodash'; import {TitleOptions} from '../../visualize/WebPlotRequest.js'; import {logError} from '../../util/WebUtil.js'; +import {getWebPlotRequestViaPTFIbe} from './ptf/PTFPlotRequests.js'; import {getWebPlotRequestViaWISEIbe} from './wise/WisePlotRequests.js'; import {makeLsstSdssPlotRequest} from './lsst_sdss/LsstSdssPlotRequests.js'; import {makeURLPlotRequest} from './generic/DefaultPlotRequests.js'; import {basicURLPlotRequest} from './basic/BasicPlotRequests'; import {LsstSdssSettingBox, lsstSdssOnNewRawTable, lsstSdssOnFieldUpdate, lsstSdssRawTableRequest} from './lsst_sdss/LsstSdssMissionOptions.js'; -import {WiseSettingBox, wiseOnNewRawTable, wiseOnFieldUpdate, wiseRawTableRequest, isBasicTableUploadValid} from './wise/WiseMissionOptions.js'; import {DefaultSettingBox, defaultOnNewRawTable, defaultOnFieldUpdate, defaultRawTableRequest} from './generic/DefaultMissionOptions.js'; import {BasicSettingBox, basicOnNewRawTable, basicOnFieldUpdate, basicRawTableRequest, imagesShouldBeDisplayed} from './basic/BasicMissionOptions.js'; +import {WiseSettingBox, wiseOnNewRawTable, wiseOnFieldUpdate, wiseRawTableRequest,isValidWiseTable} from './wise/WiseMissionOptions.js'; +import {PTFSettingBox, ptfOnNewRawTable, ptfOnFieldUpdate, ptfRawTableRequest,isValidPTFTable} from './ptf/PTFMissionOptions.js'; + import {LC} from './LcManager.js'; export const UNKNOWN_MISSION = 'generic'; @@ -21,7 +24,6 @@ export const coordSysOptions = 'coordSysOptions'; /** * A function to create a WebPlotRequest from the given parameters * @callback WebplotRequestCreator - * @param {TableModel} tableModel * @param {number} hlrow * @param {number} cutoutSize * @param {Object} params - mission specific parameters @@ -91,7 +93,7 @@ const converters = { dataSource: 'frame_id', webplotRequestCreator: getWebPlotRequestViaWISEIbe, shouldImagesBeDisplayed: () => {return true;}, - isTableUploadValid: isBasicTableUploadValid, + isTableUploadValid: isValidWiseTable, yNamesChangeImage: [], showPlotTitle:getPlotTitle }, @@ -111,9 +113,28 @@ const converters = { yErrNames: ['magErr', 'tsv_fluxErr'], webplotRequestCreator: makeLsstSdssPlotRequest, shouldImagesBeDisplayed: () => {return true;}, - isTableUploadValid: () => {return true;}, + isTableUploadValid: () => {return {errorMsg:undefined, isValid:true};}, yNamesChangeImage: [] }, + 'ptf': { + converterId: 'ptf', + defaultImageCount: 5, + defaultTimeCName: 'obsmjd', + defaultYCname: 'mag_autocorr', + defaultYErrCname: '', + missionName: 'PTF', + MissionOptions: PTFSettingBox, + onNewRawTable: ptfOnNewRawTable, + onFieldUpdate: ptfOnFieldUpdate, + rawTableRequest: ptfRawTableRequest, //the r + yErrNames: '', + dataSource: 'pid', + webplotRequestCreator: getWebPlotRequestViaPTFIbe, + shouldImagesBeDisplayed: () => {return true;}, + isTableUploadValid:isValidPTFTable, + yNamesChangeImage: [], + showPlotTitle:getPlotTitle + }, [UNKNOWN_MISSION]: { converterId: UNKNOWN_MISSION, defaultImageCount: 3, @@ -132,7 +153,7 @@ const converters = { [coordSysOptions]: COORD_SYSTEM_OPTIONS, webplotRequestCreator: makeURLPlotRequest, shouldImagesBeDisplayed: () => {return true;}, - isTableUploadValid: () => {return true;}, + isTableUploadValid: () => {return {errorMsg:undefined, isValid:true};}, yNamesChangeImage: [], // TODO: y columns which will affect the image display noImageCutout: true // no image cutout is used }, @@ -155,7 +176,7 @@ const converters = { [coordSysOptions]: COORD_SYSTEM_OPTIONS, webplotRequestCreator: basicURLPlotRequest, shouldImagesBeDisplayed: imagesShouldBeDisplayed, - isTableUploadValid: () => {return true;}, + isTableUploadValid: () => {return {errorMsg:undefined, isValid:true}; }, yNamesChangeImage: [], showPlotTitle:getPlotTitle } diff --git a/src/firefly/js/templates/lightcurve/LcManager.js b/src/firefly/js/templates/lightcurve/LcManager.js index 9c02fd4111..8ba210239d 100644 --- a/src/firefly/js/templates/lightcurve/LcManager.js +++ b/src/firefly/js/templates/lightcurve/LcManager.js @@ -1,14 +1,13 @@ /* * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {get, has, isEmpty, isNil, set, cloneDeep, defer} from 'lodash'; +import {get, has, isEmpty, isNil, cloneDeep, defer} from 'lodash'; import {take, fork} from 'redux-saga/effects'; import {SHOW_DROPDOWN, SET_LAYOUT_MODE, getLayouInfo, dispatchUpdateLayoutInfo, dropDownManager} from '../../core/LayoutCntlr.js'; import {TBL_RESULTS_ADDED, TABLE_LOADED, TBL_RESULTS_ACTIVE, TABLE_HIGHLIGHT, TABLE_SEARCH, TABLE_FETCH, dispatchTableRemove, dispatchTableHighlight, dispatchTableFetch, dispatchTableSort} from '../../tables/TablesCntlr.js'; import {getCellValue, getTblById, getTblIdsByGroup, getActiveTableId, smartMerge, getColumnIdx, removeTablesFromGroup} from '../../tables/TableUtil.js'; -import {dispatchTableReplace} from '../../tables/TablesCntlr.js'; import {updateSet, updateMerge, logError} from '../../util/WebUtil.js'; import ImagePlotCntlr, {dispatchPlotImage, visRoot, dispatchDeletePlotView, dispatchChangeActivePlotView, @@ -25,8 +24,6 @@ import {getConverter} from './LcConverterFactory.js'; import {sortInfoString} from '../../tables/SortInfo.js'; import {makeMissionEntries, keepHighlightedRowSynced} from './LcUtil.jsx'; import {dispatchMountFieldGroup} from '../../fieldGroup/FieldGroupCntlr.js'; -import {ServerParams} from '../../data/ServerParams.js'; -import {convertAngle} from '../../visualize/VisUtil.js'; @@ -466,6 +463,7 @@ function handleRawTableLoad(layoutInfo, tblId) { return; } + //TODO LZ How validTable is used, the onNewRawtable has its value to false. But it was never used here??? let {newLayoutInfo, shouldContinue, validTable} = converterData.onNewRawTable(rawTable, missionEntries, generalEntries, converterData, layoutInfo); const newMissionEntries = get(newLayoutInfo, ['missionEntries']); // missionEntries could have changed after calling specific mission onRaw newLayoutInfo = updateSet(newLayoutInfo, 'rawTableColumns', get(rawTable, ['tableData', 'columns'])); diff --git a/src/firefly/js/templates/lightcurve/LcUtil.jsx b/src/firefly/js/templates/lightcurve/LcUtil.jsx index 7edbbd48d8..d155c02924 100644 --- a/src/firefly/js/templates/lightcurve/LcUtil.jsx +++ b/src/firefly/js/templates/lightcurve/LcUtil.jsx @@ -1,10 +1,16 @@ import React from 'react'; import PropTypes from 'prop-types'; -import {get} from 'lodash'; +import {get, has, set, isEmpty} from 'lodash'; import {LC} from './LcManager.js'; import {getConverter} from './LcConverterFactory.js'; -import {getCellValue, getTblById, findIndex} from '../../tables/TableUtil.js'; +import {getCellValue, getTblById, findIndex, getColsByType, getColumnIdx, COL_TYPE} from '../../tables/TableUtil.js'; import {dispatchTableHighlight} from '../../tables/TablesCntlr.js'; +import {ValidationField} from '../../ui/ValidationField.jsx'; +import {SuggestBoxInputField} from '../../ui/SuggestBoxInputField.jsx'; +import {getMissionName} from './LcConverterFactory.js'; +import {getLayouInfo} from '../../core/LayoutCntlr.js'; +import {getViewerGroupKey, onTimeColumnChange} from './LcManager.js'; +import {FieldGroup} from '../../ui/FieldGroup.jsx'; export function getTypeData(key, val='', tip = '', labelV='', labelW) { return { @@ -16,6 +22,7 @@ export function getTypeData(key, val='', tip = '', labelV='', labelW) { }; } + export var ReadOnlyText = ({label, content, labelWidth, wrapperStyle}) => { return (
@@ -32,7 +39,12 @@ ReadOnlyText.propTypes = { wrapperStyle: PropTypes.object }; - +/** + * @desc This method is created a mission entries for all missions + * @param {object} tableMeta - the meta data in the IpacTable Object + * @param {object} layoutInfo - the layout of the UI + * @returns {{converterData: *, missionEntries: (*|{})}} + */ export function makeMissionEntries(tableMeta, layoutInfo={}) { var converterData = getConverter(get(tableMeta, LC.META_MISSION)) || getConverter(); var missionEntries = layoutInfo.missionEntries || {}; @@ -71,3 +83,251 @@ export function keepHighlightedRowSynced(tbl_id, highlightedRow=0) { }); } } +/** + * @desc This method returns a suggested list of the column names based on the val entered and the defaultVal if provided. + * @param {string} val - the input in the text field + * @param {array} columnNames - the array of string + * @param {string} defaultVal - the default value, it can be null. + * @returns {*} + */ +export function getSuggestedList (val, columnNames, defaultVal) { + return columnNames.reduce((prev, name) => { + if ( name.startsWith(val) || (defaultVal && val===defaultVal)) { + prev.push(name); + } + return prev; + }, []); +} + +export function getInitialDefaultValues(labelWidth, missionName) { + var commonDefault = { + [LC.META_TIME_CNAME]: Object.assign(getTypeData(LC.META_TIME_CNAME, '', + 'Time column name', + 'Time Column:', labelWidth), + {validator: null}), + [LC.META_FLUX_CNAME]: Object.assign(getTypeData(LC.META_FLUX_CNAME, '', + 'Value column name', + 'Value Column:', labelWidth), + {validator: null}), + [LC.META_TIME_NAMES]: Object.assign(getTypeData(LC.META_TIME_NAMES, '', + 'Value column suggestion'), + {validator: null}), + [LC.META_FLUX_NAMES]: Object.assign(getTypeData(LC.META_FLUX_NAMES, '', + 'Value column suggestion'), + {validator: null}), + ['cutoutSize']: Object.assign(getTypeData('cutoutSize', '', + 'image cutout size', + 'Cutout Size (arcmin):', 100)), + [LC.META_URL_CNAME]: Object.assign(getTypeData(LC.META_URL_CNAME, '', + 'Image url column name', + 'Source Column:', labelWidth)) + + }; + + switch (missionName){ + case 'generic': + var genericDefault = { + [LC.META_ERR_CNAME]: Object.assign(getTypeData(LC.META_ERR_CNAME, '', + 'flux error column name', + 'Error Column:', labelWidth)), + [LC.META_COORD_XNAME]: Object.assign(getTypeData(LC.META_COORD_XNAME, '', + 'Coordinate X column name', + 'X Column:', labelWidth)), + [LC.META_COORD_YNAME]: Object.assign(getTypeData(LC.META_COORD_YNAME, '', + 'Coordinate Y column name', + 'Y Column:', labelWidth)), + [LC.META_COORD_SYS]: Object.assign(getTypeData(LC.META_COORD_SYS, '', + 'Coordinate system', + 'Coord System:', labelWidth)) + }; + + return Object.assign ({},commonDefault, genericDefault ); + case 'other': + return commonDefault; + case 'wise': + const wiseDefault = { + [LC.META_FLUX_BAND]: Object.assign(getTypeData(LC.META_FLUX_BAND, '', '' + + 'Select WISE band for images to be displayed', 'Image display:', 70)), + [LC.META_ERR_CNAME]: Object.assign(getTypeData(LC.META_ERR_CNAME, '', + 'value error column name', 'Error Column:', labelWidth)) + }; + return Object.assign ({},commonDefault, wiseDefault ); + case 'ptf': + return commonDefault; + } + +} + +/** + * + * @param {array} numColumns - the array of numerical column names + * @param {object} wrapperStyle + * @returns {Array} + */ +export function getMissionInput (numColumns, wrapperStyle){ + const missionKeys = [LC.META_TIME_CNAME, LC.META_FLUX_CNAME]; + + const topZ = 3; + return missionKeys.map((key) => + getSuggestedList(val,numColumns)}/> + ); + +} + +/** + * @desc This method returns the common entries nd the missionInout UI's + * @param {object} generalEntries + * @param {object} missionEntries + * @param {array} tblColumns + * @param wrapperStyle + * @returns {*} + */ +export function getMissionEntries(generalEntries, missionEntries,tblColumns,wrapperStyle){ + + if (isEmpty(generalEntries) || isEmpty(missionEntries)) return false; + + const numColumns = getColsByType(tblColumns, COL_TYPE.NUMBER).map( (c) => c.name); + + var allCommonEntries = Object.keys(generalEntries).map((key) => + + ); + var missionInputs = getMissionInput(numColumns, wrapperStyle); + return {allCommonEntries, missionInputs}; +} +/** + * @desc This method returns the mission's information, such as missName, period, title, and uploaded file name. + * @param {object} missionEntries + * @param {TableModel} tblModel + * @returns {{missionName: (*|string), period: *, title: *, uploadedFileName: string}} + */ +export function getMissionInfo(missionEntries, tblModel){ + const converterId = get(missionEntries, LC.META_MISSION); + var missionName = getMissionName(converterId) || 'Mission'; + + const layoutInfo = getLayouInfo(); + var period = get(layoutInfo, ['periodRange','period'], ''); + const title = get(tblModel, 'request.uploadFileName',''); + //if the name is too long, truncates it and displays it as a tip + const uploadedFileName =( title && title.length>20)?title.substring(0, 20)+'...':title; + + return {missionName, period, title, uploadedFileName}; +} + + +export function renderMissionView(generalEntries,missionEntries,missionBands,tblModel, wrapperStyle,labelWidth,callback ){ + + //const wrapperStyle = {margin: '3px 0'}; + const tblColumns = get(tblModel, ['tableData', 'columns'], []); + const groupKey = getViewerGroupKey(missionEntries); + const {allCommonEntries, missionInputs} = getMissionEntries(generalEntries, missionEntries,tblColumns ,wrapperStyle); + + const {missionName, period, title, uploadedFileName} = getMissionInfo(missionEntries, tblModel); + return ( + + +
+
Column Selection
+ +
Images
+
+ +
+
+ + {missionInputs} +
+
+ {missionBands} + {allCommonEntries} +
+
+
+ + +
+
+ ); +} + +/** + * @desc This method is validating if the fields are valid entries. + * @param fldsWithValidators + * @param missionEntries + * @param typeColumns + * @returns {*} + */ +export function validate(fldsWithValidators, missionEntries, typeColumns ){ + return fldsWithValidators.reduce((all, fld) => { + all[fld.key] = + (val) => { + let valid = true; + const cols = get(missionEntries, fld.vkey, []); + + if (cols.length === 0 && typeColumns) { + const selColumns = fld.type === 'char' ? typeColumns.charColumns : typeColumns.numColumns; + + if (selColumns.findIndex((col) => (col === val)) < 0) { + valid = false; + } + } else if (!cols.includes(val)) { + valid = false; + } + return valid ? {valid, message: ''} : {valid, message: `${val} is not a valid column name`}; + }; + return all; + }, {}); +} + +export function getTimeAndYColInfo(numericalCols, xyColPattern, rawTable, converterData ){ + let defaultCTimeName = (getColumnIdx(rawTable, converterData.defaultTimeCName) > 0) ? converterData.defaultTimeCName : numericalCols[0]; + let defaultYColName = (getColumnIdx(rawTable, converterData.defaultYCname) > 0) ? converterData.defaultYCname : numericalCols[1]; + + defaultYColName = numericalCols.filter((el) => { + if (el.toLocaleLowerCase().match(xyColPattern[1]) !== null) { + return el; + } + })[0] || defaultYColName; + defaultCTimeName = numericalCols.filter((el) => { + if (el.toLocaleLowerCase().match(xyColPattern[0]) !== null) { + return el; + } + })[0] || defaultCTimeName; + + return {defaultCTimeName,defaultYColName}; +} + +export function fileUpdateOnTimeColumn(fieldKey, value){ + const {missionEntries} = getLayouInfo() || {}; + if (!missionEntries) return; + + onTimeColumnChange(missionEntries[fieldKey], value); + return {[fieldKey]: value}; +} + +/** + * + * @desc This method is updating the defV based on the input. The defV is an object, thus, its value can be modified. + * @param missionListKeys + * @param missionEntries + * @param missionKeys + * @param validators + * @param defV + */ +export function setValueAndValidator(missionListKeys, missionEntries,missionKeys, validators, defV){ + missionListKeys.forEach((key) => { + set(defV, [key, 'value'], get(missionEntries, key, [])); + }); + + // set value and validator + missionKeys.forEach((key) => { + set(defV, [key, 'value'], get(missionEntries, key, '')); + if (has(validators, key)) { + set(defV, [key, 'validator'], validators[key]); + } + }); +} \ No newline at end of file diff --git a/src/firefly/js/templates/lightcurve/LcViewer.jsx b/src/firefly/js/templates/lightcurve/LcViewer.jsx index bac0285cd0..8b22303876 100644 --- a/src/firefly/js/templates/lightcurve/LcViewer.jsx +++ b/src/firefly/js/templates/lightcurve/LcViewer.jsx @@ -5,7 +5,7 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; -import {pickBy, get, isEmpty, capitalize} from 'lodash'; +import {pickBy, get, capitalize} from 'lodash'; import {flux, firefly} from '../../Firefly.js'; import {getMenu, isAppReady, dispatchSetMenu, dispatchOnAppReady} from '../../core/AppDataCntlr.js'; import {dispatchHideDropDown, getLayouInfo, SHOW_DROPDOWN} from '../../core/LayoutCntlr.js'; @@ -30,9 +30,7 @@ import {HelpIcon} from './../../ui/HelpIcon.jsx'; import {getAllConverterIds, getConverter, getMissionName} from './LcConverterFactory.js'; import FieldGroupUtils from '../../fieldGroup/FieldGroupUtils.js'; import {getAppOptions} from '../../core/AppDataCntlr.js'; - import {HelpText} from './../../ui/HelpText.jsx'; -import {HELP_LOAD} from '../../core/AppDataCntlr.js'; const vFileKey = LC.FG_FILE_FINDER; /** @@ -78,7 +76,7 @@ export class LcViewer extends PureComponent { render() { var {isReady, menu={}, appTitle, appIcon, altAppIcon, additionalTitleStyle, dropDown, missionOptions, - dropdownPanels=[], footer, style, displayMode, missionEntries, error} = this.state; + dropdownPanels=[], footer, style, displayMode, missionEntries} = this.state; const {visible, view} = dropDown || {}; const periodProps = { displayMode, timeColName: get(missionEntries, [LC.META_TIME_CNAME]), @@ -86,29 +84,18 @@ export class LcViewer extends PureComponent { }; dropdownPanels.push(); - //let title = 'Time Series Tool'; - //if (displayMode && displayMode.startsWith('period')) { - // title = 'Time Series Tool: Period Finder'; - //}else{ - // title= 'Time Series Tool: Viewer'; - //} - const LcPeriodInstance= get(getAppOptions(), 'charts.chartEngine')==='plotly' ? LcPeriodPlotly : LcPeriod; - var mainView = (err,converterId) => { - if (!isEmpty(error) && converterId) { + const LcPeriodInstance= get(getAppOptions(), 'charts.chartEngine')==='plotly' ? LcPeriodPlotly : LcPeriod; - let errorMsg = `Table uploaded is not ${getMissionName(converterId)} valid, missing columns: ${error}. - Please, select option 'Other' for general table upload.`; + var mainView = (converterId) => { + const converter = getConverter(converterId); + if (!converter.isTableUploadValid().isValid){ - if (converterId === 'wise') { - errorMsg = `The uploaded table is not valid. The ${getMissionName(converterId)} option requires frame_id, source_id, or both scan_id and frame_num. - Please select the "Other" upload option for tables that do not meet these requirements.`; - } return (
- {errorMsg} + {converter.isTableUploadValid().errorMsg}
@@ -127,6 +114,7 @@ export class LcViewer extends PureComponent { } }; + let title = appTitle; if (displayMode && displayMode.startsWith('period')) { title = appTitle + ': Period Finder'; @@ -151,7 +139,7 @@ export class LcViewer extends PureComponent { {...{dropdownPanels} } />
- {mainView(error,converterId)} + {mainView(converterId)}
); @@ -217,17 +205,12 @@ export function UploadPanel(props) { const wrapperStyle = {color:'inherit', margin: '5px 0'}; const {missionOptions=getAllConverterIds()} = props || {}; - let instruction = 'Plot time series data, view associated images, find period, and phase fold.'; + const instruction = 'Plot time series data, view associated images, find period, and phase fold.'; const options = missionOptions.map((id) => { return {label: getMissionName(id) || capitalize(id), value: id}; }); - var helpClick = (helpId) => { - flux.process({ - type: HELP_LOAD, - payload: {helpId} - }); - }; + return (
{instruction}
@@ -291,7 +274,6 @@ UploadPanel.defaultProps = { function onSearchSubmit(request) { if (request.rawTblSource) { - const {mission} = request; const converter = getConverter(request.mission); if (!converter) return; diff --git a/src/firefly/js/templates/lightcurve/PTF/PTFMissionOptions.js b/src/firefly/js/templates/lightcurve/PTF/PTFMissionOptions.js new file mode 100644 index 0000000000..47509cc227 --- /dev/null +++ b/src/firefly/js/templates/lightcurve/PTF/PTFMissionOptions.js @@ -0,0 +1,153 @@ +import React, {PureComponent} from 'react'; +import PropTypes from 'prop-types'; +import {get, set, isNil} from 'lodash'; +import {RadioGroupInputField} from '../../../ui/RadioGroupInputField.jsx'; +import {makeFileRequest, getCellValue, getTblById, getColumnIdx, smartMerge, getColumns, COL_TYPE} from '../../../tables/TableUtil.js'; +import {sortInfoString} from '../../../tables/SortInfo.js'; +import {getInitialDefaultValues,renderMissionView,validate,getTimeAndYColInfo,fileUpdateOnTimeColumn,setValueAndValidator} from '../LcUtil.jsx'; +import {LC} from '../LcManager.js'; + + +const labelWidth = 80; +export class PTFSettingBox extends PureComponent { + constructor(props) { + super(props); + + } + + render() { + var {generalEntries, missionEntries} = this.props; + const tblModel = getTblById(LC.RAW_TABLE); + const wrapperStyle = {margin: '3px 0'}; + + var missionFilters = (); + + return renderMissionView(generalEntries,missionEntries, missionFilters,tblModel,wrapperStyle,labelWidth , ptfOptionsReducer); + + + } +} + +PTFSettingBox.propTypes = { + generalEntries: PropTypes.object, + missionEntries: PropTypes.object +}; + +//TODO, this is copied from WISE, need to refactor it after the images and other information are updated. +export const ptfOptionsReducer = (missionEntries, generalEntries) => { + return (inFields, action) => { + if (inFields) { + return inFields; + } + + + const defValues =getInitialDefaultValues(labelWidth,'ptf'); + + var defV = Object.assign({}, defValues); + + const missionKeys = [LC.META_TIME_CNAME, LC.META_FLUX_CNAME, LC.META_URL_CNAME]; + const missionListKeys = [LC.META_TIME_NAMES, LC.META_FLUX_NAMES]; + const validators = getFieldValidators(missionEntries); + + setValueAndValidator(missionListKeys, missionEntries,missionKeys, validators, defV); + Object.keys(generalEntries).forEach((key) => { + set(defV, [key, 'value'], get(generalEntries, key, '')); + }); + return defV; + }; +}; + +//TODO, after the PTF images loaded, this function can be updated. It is the place holder for now. +function getFieldValidators(missionEntries) { + const fldsWithValidators = [ + {key: LC.META_TIME_CNAME, vkey: LC.META_TIME_NAMES}, + {key: LC.META_FLUX_CNAME, vkey: LC.META_FLUX_NAMES}, + {key: LC.META_URL_CNAME} + + ]; + return validate(fldsWithValidators, missionEntries); + +} + + +export function isValidPTFTable() { + + const tableModel = getTblById(LC.RAW_TABLE); + + const pid = getCellValue(tableModel, 0, 'pid'); + if (!isNil(pid)) { + return {errorMsg: undefined, isValid: true}; + } + else { + const errorMsg = `The uploaded table is not valid. The PTF option requires pid. + Please select the "Other" upload option for tables that do not meet these requirements.`; + return {errorMsg, isValid:false}; + } +} + +/** + * Pregex pattern for wise, at least to find mjd and w1mpro if present + * @type {string[]} + */ +const xyColPattern = ['\\w*jd\\w*', 'w[1-4]mpro\\w*']; +export function ptfOnNewRawTable(rawTable, missionEntries, generalEntries, converterData, layoutInfo) { + + // Update default values AND sortInfo and + const metaInfo = rawTable && rawTable.tableMeta; + + const numericalCols = getColumns(rawTable, COL_TYPE.NUMBER).map((c) => c.name); + const defaultDataSource = (getColumnIdx(rawTable, converterData.dataSource) > 0) ? converterData.dataSource : numericalCols[3]; + + const {defaultCTimeName,defaultYColName } = getTimeAndYColInfo(numericalCols,xyColPattern,rawTable,converterData ); + + const defaultValues = { + [LC.META_TIME_CNAME]: get(metaInfo, LC.META_TIME_CNAME, defaultCTimeName), + [LC.META_FLUX_CNAME]: get(metaInfo, LC.META_FLUX_CNAME, defaultYColName), + [LC.META_TIME_NAMES]: get(metaInfo, LC.META_TIME_NAMES, numericalCols), + [LC.META_FLUX_NAMES]: get(metaInfo, LC.META_FLUX_NAMES, numericalCols), + [LC.META_URL_CNAME]: get(metaInfo, LC.META_URL_CNAME, defaultDataSource), + [LC.META_FLUX_BAND]: get(metaInfo, LC.META_FLUX_BAND, 'g') + + }; + + missionEntries = Object.assign({}, missionEntries, defaultValues); + const newLayoutInfo = smartMerge(layoutInfo, {missionEntries, generalEntries}); + + return {newLayoutInfo, shouldContinue: false}; +} + +//TODO if ptfRawTableRequest and ptfOnFieldUpdate are nothing different from the ones in wiseMssionOption, these two can be replaced. +export function ptfRawTableRequest(converter, source, uploadFileName='') { + const timeCName = converter.defaultTimeCName; + const mission = converter.converterId; + const options = { + tbl_id: LC.RAW_TABLE, + sortInfo: sortInfoString(timeCName), // if present, it will skip LcManager.js#ensureValidRawTable + META_INFO: {[LC.META_MISSION]: mission, timeCName}, + pageSize: LC.TABLE_PAGESIZE, + uploadFileName + + }; + return makeFileRequest('Input Data', source, null, options); + +} + + +export function ptfOnFieldUpdate(fieldKey, value) { + // images are controlled by radio button -> band w1,w2,w3,w4. + if (fieldKey === LC.META_TIME_CNAME) { + return fileUpdateOnTimeColumn(fieldKey, value); + } else if ([LC.META_FLUX_CNAME, LC.META_ERR_CNAME, LC.META_FLUX_BAND].includes(fieldKey)) { + return {[fieldKey]: value}; + } + + +} + diff --git a/src/firefly/js/templates/lightcurve/PTF/PTFPlotRequests.js b/src/firefly/js/templates/lightcurve/PTF/PTFPlotRequests.js new file mode 100644 index 0000000000..345d70bfe4 --- /dev/null +++ b/src/firefly/js/templates/lightcurve/PTF/PTFPlotRequests.js @@ -0,0 +1,104 @@ +/* + * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt + */ +import {getCellValue} from '../../../tables/TableUtil.js'; +import {WebPlotRequest} from '../../../visualize/WebPlotRequest.js'; +import {makeWorldPt} from '../../../visualize/Point.js'; +import {CoordinateSys} from '../../../visualize/CoordSys.js'; +import {ServerRequest} from '../../../data/ServerRequest.js'; +import {isNil} from 'lodash'; +import {ERROR_MSG_KEY} from '../generic/errorMsg.js'; + +import {addCommonReqParams} from '../LcConverterFactory.js'; +import {convertAngle} from '../../../visualize/VisUtil.js'; + +export function makePTFPlotRequest(table, rowIdx, cutoutSize) { + const ra = getCellValue(table, rowIdx, 'ra'); + const dec = getCellValue(table, rowIdx, 'dec'); + const pid = getCellValue(table, rowIdx, 'pid'); + + var ptf_sexp_ibe = /(\d+)([0-9][a-z])(\w+)/g; + var res = ptf_sexp_ibe.exec(pid); + const scan_id = res[1] + res[2]; + const scangrp = res[2]; + const frame_num = res[3]; + //const band=`${params.fluxCol}`.match(/\d/g); + const band = 1; + + // convert the default Cutout size in arcmin to deg for WebPlotRequest + const cutoutSizeInDeg = convertAngle('arcmin','deg', cutoutSize); + + const serverinfo = 'http://irsa.ipac.caltech.edu/ibe/data/ptf/merge/merge_p1bm_frm/'; + const centerandsize = cutoutSize ? `?center=${ra},${dec}&size=${cutoutSizeInDeg}&gzip=false` : ''; + const url = `${serverinfo}${scangrp}/${scan_id}/${frame_num}/${scan_id}${frame_num}-w${band}-int-1b.fits${centerandsize}`; + const plot_desc = `PTF-${pid}`; + const reqParams = WebPlotRequest.makeURLPlotRequest(url, plot_desc); + const title = 'PTF-' + pid + (cutoutSize ? ` size: ${cutoutSize}(arcmin)` : ''); + return addCommonReqParams(reqParams, title, makeWorldPt(ra, dec, CoordinateSys.EQ_J2000)); +} + +//TODO to be implemented +/** + * + * @param tableModel + * @param hlrow + * @param cutoutSize + * @param params object attribute match the LcManager#getImagePlotParams() + * @returns {WebPlotRequest} + */ +export function getWebPlotRequestViaPTFIbe(tableModel, hlrow, cutoutSize, params = { + bandName: 'w1', + fluxCol: 'mag_autocorr', + dataSource: 'frame_id' +}) { + const ra = getCellValue(tableModel, hlrow, 'ra'); + const dec = getCellValue(tableModel, hlrow, 'dec'); + + const pid = getCellValue(tableModel, hlrow, 'pid'); + + + // convert the default Cutout size in arcmin to deg for WebPlotRequest + const cutoutSizeInDeg = convertAngle('arcmin','deg', cutoutSize); + + try { + var ptf_sexp_ibe = /(\d+)([0-9][a-z])(\w+)/g; + var tmpId = ''; + var res; + if (!isNil(pid)) { + res = ptf_sexp_ibe.exec(pid); + tmpId = pid; + } + + + // flux/value column control this | unless UI has radio button band enabled, put bandName back here to match band + const band = `${params.bandName}`.match(/[1-4]/i);// `${params.fluxCol}`.match(/w[1-4]/i); //check if name has wW[1-4] in name + + + let title = 'PTFE-W' + band + '-' + tmpId; + + const sr = new ServerRequest('ibe_file_retrieve'); + sr.setParam('mission', 'PTF'); + sr.setParam('PROC_ID', 'ibe_file_retrieve'); + sr.setParam('ProductLevel', '1b'); + + sr.setParam('band', `${band}`); + + var wp = null; + sr.setParam('doCutout', 'false'); + if (!isNil(ra) && !isNil(dec)) { + sr.setParam('center', `${ra},${dec}`); + sr.setParam('in_ra', `${ra}`); + sr.setParam('in_dec', `${dec}`); + wp = makeWorldPt(ra, dec, CoordinateSys.EQ_J2000); + sr.setParam('doCutout', 'true'); + sr.setParam('size', `${cutoutSizeInDeg}`); + sr.setParam('subsize', `${cutoutSizeInDeg}`); + title = 'PTF-W' + band + '-' + tmpId + (cutoutSize ? ` size: ${cutoutSize}(arcmin)` : ''); + } + + const reqParams = WebPlotRequest.makeProcessorRequest(sr, 'ptf'); + return addCommonReqParams(reqParams, title, wp); + } catch (E) { + throw new Error(E.message + ': as a consequence, images will fail', ERROR_MSG_KEY.IMAGE_FETCH); + } +} \ No newline at end of file diff --git a/src/firefly/js/templates/lightcurve/SettingBox.jsx b/src/firefly/js/templates/lightcurve/SettingBox.jsx new file mode 100644 index 0000000000..c91392f92f --- /dev/null +++ b/src/firefly/js/templates/lightcurve/SettingBox.jsx @@ -0,0 +1,47 @@ +import {PureComponent} from 'react'; +import { getColsByType, COL_TYPE} from '../../tables/TableUtil.js'; +import {getLayouInfo} from '../../core/LayoutCntlr.js'; +import {flux} from '../../Firefly.js'; +import {get} from 'lodash'; + +/** + * @desc This is the base class that is used by DefaultMissionOption and BasicMissionOption. + */ + +export class SettingBox extends PureComponent { + constructor(props) { + super(props); + + this.getNextState = () => { + return Object.assign({}, {tblColumns: get(getLayouInfo(), 'rawTableColumns', [])}); + }; + + const {tblColumns} = this.getNextState(); + const numColumns = getColsByType(tblColumns, COL_TYPE.NUMBER).map((c) => c.name); + const charColumns = getColsByType(tblColumns, COL_TYPE.TEXT).map((c) => c.name);//(tblColumns, ['char', 'c', 's', 'str']); + this.state = {tblColumns, charColumns, numColumns}; + } + + componentWillUnmount() { + this.iAmMounted = false; + this.removeListener && this.removeListener(); + } + + componentDidMount() { + this.iAmMounted = true; + this.removeListener = flux.addListener(() => this.storeUpdate()); + } + + storeUpdate() { + if (this.iAmMounted) { + const {tblColumns} = this.getNextState(); + + if (tblColumns !== this.state.tblColumns) { + const numColumns = getColsByType(tblColumns, COL_TYPE.NUMBER).map((c) => c.name); + const charColumns = getColsByType(tblColumns, COL_TYPE.TEXT).map((c) => c.name); + ;//getColNames(tblColumns, ['char', 'c', 's', 'str']); + this.setState({tblColumns, charColumns, numColumns}); + } + } + } +} \ No newline at end of file diff --git a/src/firefly/js/templates/lightcurve/basic/BasicMissionOptions.js b/src/firefly/js/templates/lightcurve/basic/BasicMissionOptions.js index a0045db0ef..2b83e404e9 100644 --- a/src/firefly/js/templates/lightcurve/basic/BasicMissionOptions.js +++ b/src/firefly/js/templates/lightcurve/basic/BasicMissionOptions.js @@ -1,55 +1,19 @@ -import React, {PureComponent} from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; -import {flux} from '../../../Firefly.js'; -import {get, has, isEmpty, set} from 'lodash'; +import {get,isEmpty} from 'lodash'; import {FieldGroup} from '../../../ui/FieldGroup.jsx'; -import {ValidationField} from '../../../ui/ValidationField.jsx'; -import {SuggestBoxInputField} from '../../../ui/SuggestBoxInputField.jsx'; import {makeFileRequest} from '../../../tables/TableUtil.js'; -import {getColumnIdx, smartMerge, getNumericColNames, getStringColNames,getTblById} from '../../../tables/TableUtil.js'; -import {ReadOnlyText, getTypeData} from '../LcUtil.jsx'; -import {LC, getViewerGroupKey, onTimeColumnChange} from '../LcManager.js'; +import {getColumnIdx, smartMerge, getColsByType, COL_TYPE} from '../../../tables/TableUtil.js'; +import {ReadOnlyText, getInitialDefaultValues,getMissionInput,getMissionInfo,validate,fileUpdateOnTimeColumn, setValueAndValidator} from '../LcUtil.jsx'; +import {LC, getViewerGroupKey} from '../LcManager.js'; import {getMissionName} from '../LcConverterFactory.js'; -import {getLayouInfo} from '../../../core/LayoutCntlr.js'; - +import {SettingBox} from '../SettingBox.jsx'; const labelWidth = 90; -export class BasicSettingBox extends PureComponent { +export class BasicSettingBox extends SettingBox { constructor(props) { super(props); - - this.getNextState = () => { - return Object.assign({}, {tblColumns: get(getLayouInfo(), 'rawTableColumns', [])}); - }; - - const {tblColumns} = this.getNextState(); - const numColumns = getNumericColNames(tblColumns); - const charColumns = getStringColNames(tblColumns); - this.state = {tblColumns, charColumns, numColumns}; - } - - componentWillUnmount() { - this.iAmMounted = false; - this.removeListener && this.removeListener(); - } - - componentDidMount() { - this.iAmMounted = true; - this.removeListener = flux.addListener(() => this.storeUpdate()); } - - storeUpdate() { - if (this.iAmMounted) { - const {tblColumns} = this.getNextState(); - - if (tblColumns !== this.state.tblColumns) { - const numColumns = getNumericColNames(tblColumns); - const charColumns = getStringColNames(tblColumns); - this.setState({tblColumns, charColumns, numColumns}); - } - } - } - render() { var {generalEntries, missionEntries} = this.props; var {tblColumns, numColumns, charColumns} = this.state; @@ -58,47 +22,13 @@ export class BasicSettingBox extends PureComponent { if (isEmpty(tblColumns) || isEmpty(generalEntries) || isEmpty(missionEntries)) return false; const wrapperStyle = {margin: '3px 0'}; - const missionKeys = [LC.META_TIME_CNAME, LC.META_FLUX_CNAME]; - const missionUrl = [LC.META_URL_CNAME]; - const missionOtherKeys = [LC.META_ERR_CNAME]; - const topZ = 3; - - var getList = (val, type, valDefault) => { - const selCols = (!type || (type === 'numeric')) ? numColumns : charColumns; - - return selCols.reduce((prev, col) => { - if ((col.startsWith(val) || val === valDefault)) { - prev.push(col); - } - return prev; - }, []); - }; - - var missionInputs = missionKeys.map((key) => - getList(val)}/> - ); - - var missionData = missionUrl.map((key) => - getList(val, 'char', '')}/> - ); - - var missionOthers = missionOtherKeys.map((key) => - - ); + const missionInputs=getMissionInput (numColumns, wrapperStyle); const groupKey = getViewerGroupKey(missionEntries); - const converterId = get(missionEntries, LC.META_MISSION); const typeColumns = {charColumns, numColumns}; - const layoutInfo = getLayouInfo(); - - const tblModel = getTblById(LC.RAW_TABLE); - const title = get(tblModel, 'request.uploadFileName',''); - const uploadedFileName =( title && title.length>20)?title.substring(0, 20)+'...':title; + const {missionName, period, title, uploadedFileName} = getMissionInfo(missionEntries, typeColumns); - var period = get(layoutInfo, ['periodRange','period'], ''); return ( @@ -109,13 +39,13 @@ export class BasicSettingBox extends PureComponent {
- {getMissionName(converterId) !== '' && - }
{missionInputs} - {/*missionData*/} +
@@ -146,28 +76,7 @@ export const basicOptionsReducer = (missionEntries, generalEntries, typeColumns) // fluxcols: flux column candidates // errorcolumm: error column // cutoutsize: image cutout size - const defValues = { - [LC.META_TIME_CNAME]: Object.assign(getTypeData(LC.META_TIME_CNAME, '', - 'Time column name', - 'Time Column:', labelWidth), - {validator: null}), - [LC.META_FLUX_CNAME]: Object.assign(getTypeData(LC.META_FLUX_CNAME, '', - 'Value column name', - 'Value Column:', labelWidth), - {validator: null}), - [LC.META_TIME_NAMES]: Object.assign(getTypeData(LC.META_TIME_NAMES, '', - 'Value column suggestion'), - {validator: null}), - [LC.META_FLUX_NAMES]: Object.assign(getTypeData(LC.META_FLUX_NAMES, '', - 'Value column suggestion'), - {validator: null}), - ['cutoutSize']: Object.assign(getTypeData('cutoutSize', '', - 'image cutout size', - 'Cutout Size (arcmin):', 100)), - [LC.META_URL_CNAME]: Object.assign(getTypeData(LC.META_URL_CNAME, '', - 'Image url column name', - 'Source Column:', labelWidth)) - }; + const defValues =getInitialDefaultValues(labelWidth, 'other'); var defV = Object.assign({}, defValues); const validators = getFieldValidators(missionEntries, typeColumns); @@ -176,23 +85,9 @@ export const basicOptionsReducer = (missionEntries, generalEntries, typeColumns) LC.META_COORD_XNAME, LC.META_COORD_YNAME, LC.META_COORD_SYS]; const missionListKeys = [LC.META_TIME_NAMES, LC.META_FLUX_NAMES]; - missionListKeys.forEach((key) => { - set(defV, [key, 'value'], get(missionEntries, key, [])); - }); - // set value and validator - missionKeys.forEach((key) => { - set(defV, [key, 'value'], get(missionEntries, key, '')); - if (has(validators, key)) { - set(defV, [key, 'validator'], validators[key]); - } - }); - /* - Object.keys(generalEntries).forEach((key) => { - set(defV, [key, 'value'], get(generalEntries, key, '')); - }); - */ + setValueAndValidator(missionListKeys, missionEntries,missionKeys, validators, defV); return defV; }; }; @@ -206,25 +101,8 @@ function getFieldValidators(missionEntries, typeColumns) { {key: LC.META_URL_CNAME, vkey: LC.META_URL_NAMES, type:'char'} ]; - return fldsWithValidators.reduce((all, fld) => { - all[fld.key] = - (val) => { - let valid = true; - const cols = get(missionEntries, fld.vkey, []); - - if (cols.length === 0) { - const selColumns = fld.type === 'char' ? typeColumns.charColumns : typeColumns.numColumns; - - if (selColumns.findIndex((col) => (col === val)) < 0) { - valid = false; - } - } else if (!cols.includes(val)) { - valid = false; - } - return valid ? {valid, message: ''} : {valid, message: `${val} is not a valid column name`}; - }; - return all; - }, {}); + return validate(fldsWithValidators, missionEntries, typeColumns ); + } @@ -254,7 +132,8 @@ export function basicOnNewRawTable(rawTable, missionEntries, generalEntries, con // Update default values AND sortInfo and const metaInfo = rawTable && rawTable.tableMeta; - const numericalCols = getNumericColNames(get(rawTable, ['tableData', 'columns'], [])); + const tblColumns = get(rawTable, ['tableData', 'columns'], []); + const numericalCols = getColsByType(tblColumns, COL_TYPE.NUMBER).map((c) => c.name); //let strCols = getStringCol(rawTable); //strCols.push('');// Empty means no images @@ -269,8 +148,7 @@ export function basicOnNewRawTable(rawTable, missionEntries, generalEntries, con const defaultValues = { [LC.META_TIME_CNAME]: get(metaInfo, LC.META_TIME_CNAME, defaultCTimeName), [LC.META_FLUX_CNAME]: get(metaInfo, LC.META_FLUX_CNAME, defaultYColName) - //[LC.META_URL_CNAME]: get(metaInfo, LC.META_URL_CNAME, converterData.dataSource), - //[LC.META_URL_NAMES]: get(metaInfo, LC.META_URL_NAMES, strCols) + }; missionEntries = Object.assign({}, missionEntries, defaultValues); @@ -286,7 +164,6 @@ export function basicRawTableRequest(converter, source, uploadFileName='') { pageSize: LC.TABLE_PAGESIZE, uploadFileName }; - return makeFileRequest('Input Data', source, null, options); @@ -294,11 +171,7 @@ export function basicRawTableRequest(converter, source, uploadFileName='') { export function basicOnFieldUpdate(fieldKey, value) { if ([LC.META_TIME_CNAME].includes(fieldKey)) { - const {missionEntries}= getLayouInfo() || {}; - if (!missionEntries) return; - - onTimeColumnChange(missionEntries[fieldKey], value); - return {[fieldKey]: value}; + return fileUpdateOnTimeColumn(fieldKey, value); } else if ([LC.META_FLUX_CNAME].includes(fieldKey)) { return {[fieldKey]: value}; } diff --git a/src/firefly/js/templates/lightcurve/generic/DefaultMissionOptions.js b/src/firefly/js/templates/lightcurve/generic/DefaultMissionOptions.js index 00859f635e..b3db9d7377 100644 --- a/src/firefly/js/templates/lightcurve/generic/DefaultMissionOptions.js +++ b/src/firefly/js/templates/lightcurve/generic/DefaultMissionOptions.js @@ -1,52 +1,21 @@ -import React, {PureComponent} from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; -import {get, has, isEmpty, set} from 'lodash'; -import {flux} from '../../../Firefly.js'; +import {get, isEmpty} from 'lodash'; import {FieldGroup} from '../../../ui/FieldGroup.jsx'; import {ValidationField} from '../../../ui/ValidationField.jsx'; import {SuggestBoxInputField} from '../../../ui/SuggestBoxInputField.jsx'; -import {smartMerge, makeFileRequest, getNumericColNames, getStringColNames} from '../../../tables/TableUtil.js'; -import {ReadOnlyText, getTypeData} from '../LcUtil.jsx'; -import {LC, getViewerGroupKey, onTimeColumnChange} from '../LcManager.js'; +import {smartMerge, makeFileRequest} from '../../../tables/TableUtil.js'; +import {ReadOnlyText,getSuggestedList,getInitialDefaultValues,getMissionInput,validate,fileUpdateOnTimeColumn,setValueAndValidator} from '../LcUtil.jsx'; +import {LC, getViewerGroupKey} from '../LcManager.js'; import {getMissionName, coordSysOptions} from '../LcConverterFactory.js'; -import {getLayouInfo} from '../../../core/LayoutCntlr.js'; +import {SettingBox} from '../SettingBox.jsx'; const labelWidth = 90; -export class DefaultSettingBox extends PureComponent { +export class DefaultSettingBox extends SettingBox { constructor(props) { super(props); - this.getNextState = () => { - return Object.assign({}, {tblColumns: get(getLayouInfo(), 'rawTableColumns', [])}); - }; - - const {tblColumns} = this.getNextState(); - const numColumns = getNumericColNames(tblColumns); - const charColumns = getStringColNames(tblColumns); - this.state = {tblColumns, charColumns, numColumns}; - } - - componentWillUnmount() { - this.iAmMounted = false; - this.removeListener && this.removeListener(); - } - - componentDidMount() { - this.iAmMounted = true; - this.removeListener = flux.addListener(() => this.storeUpdate()); - } - - storeUpdate() { - if (this.iAmMounted) { - const {tblColumns} = this.getNextState(); - - if (tblColumns !== this.state.tblColumns) { - const numColumns = getNumericColNames(tblColumns); - const charColumns = getStringColNames(tblColumns); - this.setState({tblColumns, charColumns, numColumns}); - } - } } render() { @@ -56,29 +25,15 @@ export class DefaultSettingBox extends PureComponent { if (isEmpty(tblColumns) || isEmpty(generalEntries) || isEmpty(missionEntries)) return false; const wrapperStyle = {margin: '3px 0'}; - const missionKeys = [LC.META_TIME_CNAME, LC.META_FLUX_CNAME]; + const missionUrl = [LC.META_URL_CNAME]; const missionOtherKeys = [ LC.META_ERR_CNAME]; const topZ = 3; - var getList = (val, type) => { - const selCols = (!type || (type === 'numeric')) ? numColumns : charColumns; - return selCols.reduce((prev, col) => { - if ((col.startsWith(val))) { - prev.push(col); - } - return prev; - }, []); - }; - - var missionInputs = missionKeys.map((key) => - getList(val)} /> - ); - + const missionInputs=getMissionInput (numColumns, wrapperStyle); var missionData = missionUrl.map((key) => getList(val, 'char')} /> + getSuggestions={(val) => getSuggestedList(val, charColumns)} /> ); var missionOthers = missionOtherKeys.map((key) => @@ -94,7 +49,7 @@ export class DefaultSettingBox extends PureComponent { ); var xyCols = [LC.META_COORD_XNAME, LC.META_COORD_YNAME].map((key) => getList(val)} /> + getSuggestions={(val) => getSuggestedList(val, charColumns)} /> ); return [sysCol, xyCols]; @@ -145,41 +100,7 @@ export const defaultOptionsReducer = (missionEntries, generalEntries, typeColumn // fluxcols: flux column candidates // errorcolumm: error column // cutoutsize: image cutout size - const defValues = { - [LC.META_TIME_CNAME]: Object.assign(getTypeData(LC.META_TIME_CNAME, '', - 'Time column name', - 'Time Column:', labelWidth), - {validator: null}), - [LC.META_FLUX_CNAME]: Object.assign(getTypeData(LC.META_FLUX_CNAME, '', - 'Value column name', - 'Value Column:', labelWidth), - {validator: null}), - [LC.META_TIME_NAMES]: Object.assign(getTypeData(LC.META_TIME_NAMES, '', - 'Value column suggestion'), - {validator: null}), - [LC.META_FLUX_NAMES]: Object.assign(getTypeData(LC.META_FLUX_NAMES, '', - 'Value column suggestion'), - {validator: null}), - ['cutoutSize']: Object.assign(getTypeData('cutoutSize', '', - 'image cutout size', - 'Cutout Size (arcmin):', 100)), - [LC.META_ERR_CNAME]: Object.assign(getTypeData(LC.META_ERR_CNAME, '', - 'flux error column name', - 'Error Column:', labelWidth)), - [LC.META_URL_CNAME]: Object.assign(getTypeData(LC.META_URL_CNAME, '', - 'Image url column name', - 'Source Column:', labelWidth)), - [LC.META_COORD_XNAME]: Object.assign(getTypeData(LC.META_COORD_XNAME, '', - 'Coordinate X column name', - 'X Column:', labelWidth)), - [LC.META_COORD_YNAME]: Object.assign(getTypeData(LC.META_COORD_YNAME, '', - 'Coordinate Y column name', - 'Y Column:', labelWidth)), - [LC.META_COORD_SYS]: Object.assign(getTypeData(LC.META_COORD_SYS, '', - 'Coordinate system', - 'Coord System:', labelWidth)) - }; - + const defValues = getInitialDefaultValues(labelWidth, 'generic'); var defV = Object.assign({}, defValues); const validators = getFieldValidators(missionEntries, typeColumns); @@ -187,23 +108,9 @@ export const defaultOptionsReducer = (missionEntries, generalEntries, typeColumn LC.META_COORD_XNAME, LC.META_COORD_YNAME, LC.META_COORD_SYS]; const missionListKeys = [LC.META_TIME_NAMES, LC.META_FLUX_NAMES]; - missionListKeys.forEach((key) => { - set(defV, [key, 'value'], get(missionEntries, key, [])); - }); - - // set value and validator - missionKeys.forEach((key) => { - set(defV, [key, 'value'], get(missionEntries, key, '')); - if (has(validators, key)) { - set(defV, [key, 'validator'], validators[key]); - } - }); - - /* - Object.keys(generalEntries).forEach((key) => { - set(defV, [key, 'value'], get(generalEntries, key, '')); - }); - */ + + setValueAndValidator(missionListKeys, missionEntries,missionKeys, validators, defV); + return defV; }; }; @@ -212,34 +119,16 @@ export const defaultOptionsReducer = (missionEntries, generalEntries, typeColumn function getFieldValidators(missionEntries, typeColumns) { const fldsWithValidators = [ - {key: LC.META_TIME_CNAME}, - {key: LC.META_FLUX_CNAME}, - {key: LC.META_URL_CNAME, type: 'char'}, - {key: LC.META_COORD_XNAME}, - {key: LC.META_COORD_YNAME}, - {key: LC.META_COORD_SYS, vkey: coordSysOptions} - //{key: LC.META_ERR_CNAME, vkey: LC.META_ERR_NAMES} // error can have no value + {key: LC.META_TIME_CNAME}, + {key: LC.META_FLUX_CNAME}, + {key: LC.META_URL_CNAME, type: 'char'}, + {key: LC.META_COORD_XNAME}, + {key: LC.META_COORD_YNAME}, + {key: LC.META_COORD_SYS, vkey: coordSysOptions} ]; - return fldsWithValidators.reduce((all, fld) => { - all[fld.key] = - (val) => { - let valid = true; - const cols = get(missionEntries, fld.vkey, []); - - if (cols.length === 0) { - const selColumns = fld.type === 'char' ? typeColumns.charColumns : typeColumns.numColumns; - if (selColumns.findIndex((col) => (col === val)) < 0) { - valid = false; - } - } else if (!cols.includes(val)) { - valid = false; - } - - return valid ? {valid, message: ''} : {valid, message: `${val} is not a valid column name`}; - }; - return all; - }, {}); + return validate(fldsWithValidators, missionEntries, typeColumns ); + } const posColumnInfo = (posCoords) => { @@ -288,11 +177,7 @@ export function defaultRawTableRequest(converter, source) { export function defaultOnFieldUpdate(fieldKey, value) { if ([LC.META_TIME_CNAME].includes(fieldKey)) { - const {missionEntries} = getLayouInfo() || {}; - if (!missionEntries) return; - - onTimeColumnChange(missionEntries[fieldKey], value); - return {[fieldKey]: value}; + return fileUpdateOnTimeColumn(fieldKey, value); } else if ([LC.META_FLUX_CNAME, LC.META_ERR_CNAME, LC.META_URL_CNAME, LC.META_COORD_XNAME, LC.META_COORD_YNAME, LC.META_COORD_SYS].includes(fieldKey)) { return {[fieldKey] : value}; diff --git a/src/firefly/js/templates/lightcurve/lsst_sdss/LsstSdssMissionOptions.js b/src/firefly/js/templates/lightcurve/lsst_sdss/LsstSdssMissionOptions.js index 2d9b9896c5..45f33ac13e 100644 --- a/src/firefly/js/templates/lightcurve/lsst_sdss/LsstSdssMissionOptions.js +++ b/src/firefly/js/templates/lightcurve/lsst_sdss/LsstSdssMissionOptions.js @@ -134,9 +134,11 @@ const lsstSdssReducer = (missionEntries, generalEntries) => { missionKeys.forEach((key) => { set(defV, [key, 'value'], get(missionEntries, key, '')); }); + Object.keys(generalEntries).forEach((key) => { set(defV, [key, 'value'], get(generalEntries, key, '')); }); + return defV; }; }; diff --git a/src/firefly/js/templates/lightcurve/wise/WiseMissionOptions.js b/src/firefly/js/templates/lightcurve/wise/WiseMissionOptions.js index bd2a6e879d..3ebfc9397f 100644 --- a/src/firefly/js/templates/lightcurve/wise/WiseMissionOptions.js +++ b/src/firefly/js/templates/lightcurve/wise/WiseMissionOptions.js @@ -1,19 +1,13 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; -import {get, has, isEmpty, set, isNil} from 'lodash'; -import {FieldGroup} from '../../../ui/FieldGroup.jsx'; -import {ValidationField} from '../../../ui/ValidationField.jsx'; -import {SuggestBoxInputField} from '../../../ui/SuggestBoxInputField.jsx'; +import {get, set, isNil} from 'lodash'; import {RadioGroupInputField} from '../../../ui/RadioGroupInputField.jsx'; -import {getLayouInfo} from '../../../core/LayoutCntlr.js'; -import {makeFileRequest, getCellValue, getTblById, getColumnIdx, smartMerge} from '../../../tables/TableUtil.js'; +import {makeFileRequest, getCellValue, getTblById, getColumnIdx, smartMerge, getColumns, COL_TYPE} from '../../../tables/TableUtil.js'; import {sortInfoString} from '../../../tables/SortInfo.js'; -import {ReadOnlyText, getTypeData} from '../LcUtil.jsx'; -import {LC, getViewerGroupKey, onTimeColumnChange} from '../LcManager.js'; +import {getInitialDefaultValues,renderMissionView,validate,getTimeAndYColInfo,fileUpdateOnTimeColumn,setValueAndValidator} from '../LcUtil.jsx'; +import {LC} from '../LcManager.js'; -import {getMissionName} from '../LcConverterFactory.js'; - const labelWidth = 80; export class WiseSettingBox extends PureComponent { @@ -25,71 +19,10 @@ export class WiseSettingBox extends PureComponent { render() { var {generalEntries, missionEntries} = this.props; - - if (isEmpty(generalEntries) || isEmpty(missionEntries)) return false; - + const tblModel = getTblById(LC.RAW_TABLE); const wrapperStyle = {margin: '3px 0'}; - - const tblModel = getTblById(LC.RAW_TABLE); - //const validTimes = get(missionEntries, LC.META_FLUX_NAMES, []); - //const validValues = gnTablet(missionEntries, LC.META_FLUX_NAMES, []); - - var getList = (val, type) => { - var colType = (!type || type === 'numeric') ? - ['double', 'd', 'long', 'l', 'int', 'i', 'float', 'f'] : ['char', 'c', 's', 'str', 'double', 'd', 'long', 'l', 'int', 'i', 'float', 'f']; - - return get(tblModel, ['tableData', 'columns']).reduce((prev, col) => { - if ((colType.includes(col.type)) && - (!has(col, 'visibility') || get(col, 'visibility') !== 'hidden') && - (col.name.startsWith(val))) { - prev.push(col.name); - } - return prev; - }, []); - }; - var allCommonEntries = Object.keys(generalEntries).map((key) => - - ); - - const missionKeys = [LC.META_TIME_CNAME, LC.META_FLUX_CNAME]; - const missionOtherKeys = [LC.META_ERR_CNAME]; - const imageDataSource = [LC.META_URL_CNAME]; // use meta_url from generic case, see LcManager.js:320 for why - const missionListKeys = [LC.META_TIME_NAMES, LC.META_FLUX_NAMES]; - const topZ = 3; - var missionInputs = missionKeys.map((key, index) => - getList(val, 'numeric')}/> - ); - - var missionData = imageDataSource.map((key) => - getList(val)}/> - ); - - - //var period = getTblById(LC.PHASE_FOLDED)? get( FieldGroupUtils.getGroupFields(LC.FG_PERIOD_FINDER), ['period', 'value'], ''):''; - - - - //const frameId = getColumnIdx(tblModel, 'frame_id'); - //var missionOthers = (frameId) => { - // if (frameId > -1) { - // return ; - // } else { - // return
frame_id column is missing, no images will be displayed
; - // } - //}; - var missionOthers = (); - const groupKey = getViewerGroupKey(missionEntries); - - - const converterId = get(missionEntries, LC.META_MISSION); - var missionName = getMissionName(converterId) || 'Mission'; - const layoutInfo = getLayouInfo(); - var period = get(layoutInfo, ['periodRange','period'], ''); - const title = get(tblModel, 'request.uploadFileName',''); - //if the name is too long, truncates it and displays it as a tip - const uploadedFileName =( title && title.length>20)?title.substring(0, 20)+'...':title; - - - return ( - - -
-
Column Selection
- -
Images
-
- -
-
- - {missionInputs} - {/*missionData*/} -
-
- {missionOthers} - {allCommonEntries} -
-
-
- - -
-
- ); + + return renderMissionView(generalEntries,missionEntries,missionBands,tblModel,wrapperStyle,labelWidth, wiseOptionsReducer ); + + } } @@ -149,46 +45,16 @@ WiseSettingBox.propTypes = { export const wiseOptionsReducer = (missionEntries, generalEntries) => { + + const labelWidth = 80; + return (inFields, action) => { if (inFields) { return inFields; } // defValues used to keep the initial values for parameters in the field group of result page - // time: time column - // flux: flux column - // timecols: time column candidates - // fluxcols: flux column candidates - // errorcolumm: error column - // cutoutsize: image cutout size - const defValues = { - [LC.META_FLUX_BAND]: Object.assign(getTypeData(LC.META_FLUX_BAND, '', - 'Select WISE band for images to be displayed', - 'Image display:', 70)), - [LC.META_TIME_CNAME]: Object.assign(getTypeData(LC.META_TIME_CNAME, '', - 'time column name', - 'Time Column:', labelWidth), - {validator: null}), - [LC.META_FLUX_CNAME]: Object.assign(getTypeData(LC.META_FLUX_CNAME, '', - 'value column name', - 'Value Column:', labelWidth), - {validator: null}), - [LC.META_TIME_NAMES]: Object.assign(getTypeData(LC.META_TIME_NAMES, '', - 'time column suggestion'), - {validator: null}), - [LC.META_FLUX_NAMES]: Object.assign(getTypeData(LC.META_FLUX_NAMES, '', - 'value column suggestion'), - {validator: null}), - ['cutoutSize']: Object.assign(getTypeData('cutoutSize', '', - 'image cutout size', - 'Cutout Size (arcmin):', 100)), - [LC.META_URL_CNAME]: Object.assign(getTypeData(LC.META_URL_CNAME, '', - 'WISE Image identifier column name (frame_id)', - 'Image Column:', labelWidth)), - [LC.META_ERR_CNAME]: Object.assign(getTypeData(LC.META_ERR_CNAME, '', - 'value error column name', - 'Error Column:', labelWidth)) - }; + const defValues =getInitialDefaultValues(labelWidth,'wise'); var defV = Object.assign({}, defValues); @@ -196,17 +62,8 @@ export const wiseOptionsReducer = (missionEntries, generalEntries) => { const missionListKeys = [LC.META_TIME_NAMES, LC.META_FLUX_NAMES]; const validators = getFieldValidators(missionEntries); - missionListKeys.forEach((key) => { - set(defV, [key, 'value'], get(missionEntries, key, [])); - }); - // set value and validator - missionKeys.forEach((key) => { - set(defV, [key, 'value'], get(missionEntries, key, '')); - if (has(validators, key)) { - set(defV, [key, 'validator'], validators[key]); - } - }); + setValueAndValidator(missionListKeys, missionEntries,missionKeys, validators, defV); Object.keys(generalEntries).forEach((key) => { set(defV, [key, 'value'], get(generalEntries, key, '')); }); @@ -222,72 +79,14 @@ function getFieldValidators(missionEntries) { {key: LC.META_URL_CNAME} //{key: LC.META_ERR_CNAME, vkey: LC.META_ERR_NAMES} // error can have no value ]; - return fldsWithValidators.reduce((all, fld) => { - all[fld.key] = - (val) => { - let retVal = {valid: true, message: ''}; - const cols = get(missionEntries, fld.vkey, []); - if (cols.length !== 0 && !cols.includes(val)) { - retVal = {valid: false, message: `${val} is not a valid column name`}; - } - return retVal; - }; - return all; - }, {}); -} -/* - function setFields(missionEntries, generalEntries) { - const groupKey = getViewerGroupKey(missionEntries); - const fields = FieldGroupUtils.getGroupFields(groupKey); - const validators = getFieldValidators(missionEntries); - if (fields) { - const initState = Object.keys(fields).reduce((prev, fieldKey) => { - if (has(missionEntries, fieldKey)) { - prev.push({fieldKey, value: get(missionEntries, fieldKey), validator: validators[fieldKey]}); - } else if (has(generalEntries,fieldKey)) { - prev.push({fieldKey, value: get(generalEntries, fieldKey)}); - } - return prev; - }, []); - dispatchMultiValueChange(groupKey, initState); - } - } - */ -/** - * Returns only numerical column names form raw lc table - * @param {Object} rawTbl - * @returns {TableColumn[]} - array of table columns objects - */ -function getOnlyNumericalCol(rawTbl) { - //let cols = get(rawTbl, 'tableData.columns'); - //let cnum = cols.filter((c) => c.type != 'char'); - //let c = []; - //cnum.forEach((el) => { - // c.push(el.name); - //}); - //return c; - - var colType = ['double', 'd', 'long', 'l', 'int', 'i', 'float', 'f']; - return get(rawTbl, ['tableData', 'columns']).reduce((prev, col) => { - if ((colType.includes(col.type)) && - (!has(col, 'visibility') || get(col, 'visibility') !== 'hidden')) { - prev.push(col.name); - } - return prev; - }, []); + return validate(fldsWithValidators, missionEntries); + } -/** - * Check if this is WISE MEP table on upload, otherise bailout - * @returns {boolean} error message to be picked up by UI - */ -export function isBasicTableUploadValid() { +export function isValidWiseTable(){ const tableModel = getTblById(LC.RAW_TABLE); - // For wcs target match and overlay - const ra = getCellValue(tableModel, 0, 'ra'); - const dec = getCellValue(tableModel, 0, 'dec'); // For images from AllWise: const frameId = getCellValue(tableModel, 0, 'frame_id'); @@ -297,18 +96,17 @@ export function isBasicTableUploadValid() { const scanId = getCellValue(tableModel, 0, 'scan_id'); const sourceId = getCellValue(tableModel, 0, 'source_id'); - // For now, bailout when images fetched will fail: - if(isNil(frameId)){ - if(isNil(sourceId)){ - return (!isNil(scanId) && !isNil(frameNum)); - }else{ - return true; - } - }else{ - return true; + if (!isNil(frameId) || !isNil(sourceId) || (!isNil(scanId) && !isNil(frameNum)) ){ + return {errorMsg:undefined, isValid:true}; + } + else { + const errorMsg=`The uploaded table is not valid. The WISE option requires frame_id, or source_id, or both scan_id and frame_num. + Please select the "Other" upload option for tables that do not meet these requirements.`; + return {errorMsg, isValid:false}; } } + /** * Pregex pattern for wise, at least to find mjd and w1mpro if present * @type {string[]} @@ -318,66 +116,23 @@ export function wiseOnNewRawTable(rawTable, missionEntries, generalEntries, conv // Update default values AND sortInfo and const metaInfo = rawTable && rawTable.tableMeta; - - let error = ''; - if(!isBasicTableUploadValid()){ - const frameId = getCellValue(rawTable, 0, 'frame_id'); - const sourceId = getCellValue(rawTable, 0, 'source_id'); - const frameNum = getCellValue(rawTable, 0, 'frame_num'); - const scanId = getCellValue(rawTable, 0, 'scan_id'); - var a = []; - isNil(frameId) ? a.push('frame_id') :''; - isNil(sourceId) ? a.push('source_id'):''; - isNil(scanId) ? a.push('scan_id') : ''; - isNil(frameNum) ? a.push('frame_num'):''; - - for (let i=0; i< a.length-1;i++){ - error+= a[i]+', '; - } - error+= a[a.length-1]; - } - - - let numericalCols = getOnlyNumericalCol(rawTable); - - //Find column based on a pattern, if not, just get the constant value from the converter (=mjd, =w1mpro_ep) - - let defaultCTimeName = (getColumnIdx(rawTable, converterData.defaultTimeCName) > 0) ? converterData.defaultTimeCName : numericalCols[0]; - let defaultYColName = (getColumnIdx(rawTable, converterData.defaultYCname) > 0) ? converterData.defaultYCname : numericalCols[1]; + const numericalCols = getColumns(rawTable, COL_TYPE.NUMBER).map((c) => c.name); let defaultDataSource = (getColumnIdx(rawTable, converterData.dataSource) > 0) ? converterData.dataSource : numericalCols[3]; - defaultYColName = numericalCols.filter((el) => { - if (el.toLocaleLowerCase().match(xyColPattern[1]) != null) { - return el; - } - })[0] || defaultYColName; - defaultCTimeName = numericalCols.filter((el) => { - if (el.toLocaleLowerCase().match(xyColPattern[0]) != null) { - return el; - } - })[0] || defaultCTimeName; + const {defaultCTimeName,defaultYColName } = getTimeAndYColInfo(numericalCols,xyColPattern,rawTable,converterData ); const defaultValues = { [LC.META_TIME_CNAME]: get(metaInfo, LC.META_TIME_CNAME, defaultCTimeName), [LC.META_FLUX_CNAME]: get(metaInfo, LC.META_FLUX_CNAME, defaultYColName), [LC.META_TIME_NAMES]: get(metaInfo, LC.META_TIME_NAMES, numericalCols), [LC.META_FLUX_NAMES]: get(metaInfo, LC.META_FLUX_NAMES, numericalCols), [LC.META_URL_CNAME]: get(metaInfo, LC.META_URL_CNAME, defaultDataSource), - [LC.META_FLUX_BAND]: get(metaInfo, LC.META_FLUX_BAND, 'w1'), + [LC.META_FLUX_BAND]: get(metaInfo, LC.META_FLUX_BAND, 'w1') }; missionEntries = Object.assign({}, missionEntries, defaultValues); - // - // - //var {rawTableRequest} = layoutInfo; - //rawTableRequest = cloneDeep(rawTable.request); - //const options = { - // sortInfo: sortInfoString(defaultCTimeName), - // META_INFO: {...pick(missionEntries, [LC.META_MISSION, LC.META_TIME_CNAME, LC.META_FLUX_CNAME])} - //}; + const newLayoutInfo = smartMerge(layoutInfo, {missionEntries, generalEntries}); - - const newLayoutInfo = smartMerge(layoutInfo, {missionEntries, generalEntries, error}); return {newLayoutInfo, shouldContinue: false}; } @@ -393,20 +148,14 @@ export function wiseRawTableRequest(converter, source, uploadFileName='') { }; - var req=makeFileRequest('Input Data', source, null, options); - return req; - + return makeFileRequest('Input Data', source, null, options); } export function wiseOnFieldUpdate(fieldKey, value) { // images are controlled by radio button -> band w1,w2,w3,w4. if (fieldKey === LC.META_TIME_CNAME) { - const {missionEntries} = getLayouInfo() || {}; - if (!missionEntries) return; - - onTimeColumnChange(missionEntries[fieldKey], value); - return {[fieldKey]: value}; + return fileUpdateOnTimeColumn(fieldKey, value); } else if ([LC.META_FLUX_CNAME, LC.META_ERR_CNAME, LC.META_URL_CNAME, LC.META_FLUX_BAND].includes(fieldKey)) { return {[fieldKey]: value}; } diff --git a/src/firefly/test/edu/caltech/ipac/firefly/ws/WsListTest.java b/src/firefly/test/edu/caltech/ipac/firefly/ws/WsListTest.java index 2457d356fd..961f1f1eb2 100644 --- a/src/firefly/test/edu/caltech/ipac/firefly/ws/WsListTest.java +++ b/src/firefly/test/edu/caltech/ipac/firefly/ws/WsListTest.java @@ -134,7 +134,7 @@ private void printChildren(List childNodes) { public void tearDown() throws IOException { // Gets children folder meta under user home ws. - // Equivalent to WsResponse wsResponse = m.getList("/", 1); + // Equivalent to WsResponse wsResponse = m.getSuggestedList("/", 1); // WspaceMeta mMeta = m.getMeta("/", WspaceMeta.Includes.CHILDREN); if (mMeta != null) { diff --git a/src/firefly/test/edu/caltech/ipac/firefly/ws/WsTest.java b/src/firefly/test/edu/caltech/ipac/firefly/ws/WsTest.java index 80654e4d7a..05769f838a 100644 --- a/src/firefly/test/edu/caltech/ipac/firefly/ws/WsTest.java +++ b/src/firefly/test/edu/caltech/ipac/firefly/ws/WsTest.java @@ -177,7 +177,7 @@ public static void cleanUp() throws IOException { // } // - // OR using getList from manager get children of root + // OR using getSuggestedList from manager get children of root WsResponse response = man.getList("/", 1); List meta = response.getWspaceMeta();