Skip to content

Commit 9666e27

Browse files
committed
DM-7830: Hook image display into raw table as well.
- show xyPlot on all tables
1 parent 5b590ec commit 9666e27

File tree

2 files changed

+43
-31
lines changed

2 files changed

+43
-31
lines changed

src/firefly/js/templates/lightcurve/LcManager.js

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ export function* lcManager() {
4040
]);
4141

4242
/**
43-
* This is the current state of the application. Depending on what action is yielded, modify
44-
* this object accordingly then update it via dispatch.
43+
* This is the current state of the application. Action handlers should return newLayoutInfo if state changes
44+
* If state has changed, it will be dispacthed into the flux.
4545
* @type {LayoutInfo}
4646
* @prop {boolean} layoutInfo.showForm show form panel
4747
* @prop {boolean} layoutInfo.showTables show tables panel
4848
* @prop {boolean} layoutInfo.showCharts show charts panel
4949
* @prop {boolean} layoutInfo.showImages show images panel
5050
* @prop {string} layoutInfo.searchDesc optional string describing search criteria used to generate this result.
51+
* @prop {Object} layoutInfo.images images specific states
52+
* @prop {string} layoutInfo.images.activeTableId last active table id that images responded to
5153
*/
5254
var layoutInfo = getLayouInfo();
5355
var newLayoutInfo = layoutInfo;
@@ -59,10 +61,10 @@ export function* lcManager() {
5961
newLayoutInfo = handleTableLoad(newLayoutInfo, action);
6062
break;
6163
case TABLE_HIGHLIGHT:
62-
handleTableHighlight(PHASE_FOLDED, action);
64+
newLayoutInfo = handleTableHighlight(newLayoutInfo, action);
6365
break;
6466
case CHANGE_VIEWER_LAYOUT:
65-
handleChangeMultiViewLayout(PHASE_FOLDED);
67+
newLayoutInfo = handleChangeMultiViewLayout(newLayoutInfo, action);
6668
break;
6769
case TBL_RESULTS_ACTIVE :
6870
newLayoutInfo = handleTableActive(newLayoutInfo, action);
@@ -79,47 +81,42 @@ export function* lcManager() {
7981

8082
function handleTableLoad(layoutInfo, action) {
8183
const {tbl_id} = action.payload;
82-
layoutInfo = updateSet(layoutInfo, 'showTables', true);
83-
if ( [RAW_TABLE, PEAK_TABLE, PHASE_FOLDED, PERIODOGRAM].includes(tbl_id) ) {
84-
layoutInfo = updateSet(layoutInfo, 'showXyPlots', true);
85-
}
86-
if ( [PHASE_FOLDED].includes(tbl_id) ){
84+
layoutInfo = Object.assign({}, layoutInfo, {showTables: true, showXyPlots: true});
85+
if (isImageEnabledTable(tbl_id)) {
8786
layoutInfo = updateSet(layoutInfo, 'showImages', true);
88-
handleTableHighlight(PHASE_FOLDED, action);
87+
layoutInfo = updateSet(layoutInfo, 'images.activeTableId', tbl_id);
88+
exec(setupImages, tbl_id);
8989
}
9090
return layoutInfo;
9191
}
9292

9393

9494

9595
function handleTableActive(layoutInfo, action) {
96+
const {tbl_id} = action.payload;
97+
if (isImageEnabledTable(tbl_id)) {
98+
layoutInfo = updateSet(layoutInfo, 'images.activeTableId', tbl_id);
99+
exec(setupImages, tbl_id);
100+
}
96101
return layoutInfo;
97102
}
98103

99-
/**
100-
*
101-
* @param {string} activePhaseFoldedTableId last active phase folded table id
102-
* @param {Action} action
103-
*/
104-
function handleTableHighlight(activePhaseFoldedTableId, action) {
104+
function handleTableHighlight(layoutInfo, action) {
105105
const {tbl_id} = action.payload;
106-
if (tbl_id === activePhaseFoldedTableId) {
107-
try {
108-
setupImages(tbl_id);
109-
} catch (E){
110-
console.log(E.toString());
111-
}
112-
106+
if (isImageEnabledTable(tbl_id)) {
107+
exec(setupImages, tbl_id);
113108
}
114109
}
115110

116-
/**
117-
*
118-
* @param {string} activePhaseFoldedTableId last active phase folded table id
119-
*/
120-
function handleChangeMultiViewLayout(activePhaseFoldedTableId) {
121-
const tbl= getTblById(activePhaseFoldedTableId);
122-
if (get(tbl, 'totalRows',0)>0) setupImages(activePhaseFoldedTableId);
111+
function isImageEnabledTable(tbl_id) {
112+
return [PHASE_FOLDED, RAW_TABLE].includes(tbl_id);
113+
}
114+
115+
function handleChangeMultiViewLayout(layoutInfo, action) {
116+
const activeTableId = get(layoutInfo, 'images.activeTableId');
117+
const tbl= getTblById(activeTableId);
118+
if (get(tbl, 'totalRows',0)>0) exec(setupImages, activeTableId);
119+
return layoutInfo;
123120
}
124121

125122
function getWebPlotRequest(tableModel, hlrow) {
@@ -208,3 +205,17 @@ function makePlotIds(highlightedRow, totalRows, totalPlots) {
208205
return plotIds;
209206
}
210207

208+
209+
/**
210+
* A simple wrapper to catch the exception then log it to console
211+
* @param {function} f function to execute
212+
* @param {*} args function's arguments.
213+
*/
214+
function exec(f, args) {
215+
try {
216+
f(args);
217+
} catch (E){
218+
console.log(E.toString());
219+
}
220+
221+
}

src/firefly/js/templates/lightcurve/LcViewer.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ function onSearchSubmit(request) {
226226
} else if ( get(request, PEAK_TABLE) ) {
227227
treq = TblUtil.makeFileRequest('Peak Table', request[PEAK_TABLE], null, {tbl_id:PEAK_TABLE});
228228
treq.tblType='notACatalog';
229+
xyPlotParams = {x: {columnOrExpr: 'Period', options: 'log'}, y: {columnOrExpr: 'Power'}};
229230
}
230-
if (treq != null) {
231+
if (treq !== null) {
231232
dispatchTableSearch(treq, {removable: false});
232233
dispatchHideDropDown();
233234
dispatchInitFieldGroup('LC_FORM');

0 commit comments

Comments
 (0)