Skip to content

Commit 5b4d732

Browse files
committed
DM-6473: Fixes the following, mostly related to show images view the meta data via table
- images cannot be remove, but in expanded mode, it can. - plot group fails are not failing correctly, no message shown - When a non-meta table is selected, images are shown, but not the toolbar. - After table is removed, images are still there. - Firefly viewer uses 'triViewImages’ viewer_id while api has no viewer_id. as a result, images loaded by api will be lost once table or other searched data are returned. (I think this is fixed, but I may not understand it) - Catalog or Grid overlay are drawn outside of the images.
1 parent 750d98a commit 5b4d732

20 files changed

+194
-89
lines changed

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/VisServerOps.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,9 @@ private static WebPlotResult createError(String logMsg, PlotState state, WebPlot
16321632
WebPlotResult retval;
16331633
boolean userAbort = false;
16341634
String progressKey = "";
1635-
if (reqAry != null) {
1635+
String plotId= null;
1636+
if (reqAry != null && reqAry.length>0) {
1637+
plotId= reqAry[0].getPlotId();
16361638
for (int i = 0; (i < reqAry.length); i++) {
16371639
if (reqAry[i] != null) {
16381640
progressKey = reqAry[i].getProgressKey();
@@ -1643,17 +1645,17 @@ private static WebPlotResult createError(String logMsg, PlotState state, WebPlot
16431645

16441646
if (e instanceof FileRetrieveException) {
16451647
FileRetrieveException fe = (FileRetrieveException) e;
1646-
retval = WebPlotResult.makeFail("Retrieve failed", "Could not retrieve fits file", fe.getDetailMessage(), progressKey);
1648+
retval = WebPlotResult.makeFail("Retrieve failed", "Could not retrieve fits file", fe.getDetailMessage(), progressKey, plotId);
16471649
fe.setSimpleToString(true);
16481650
} else if (e instanceof FailedRequestException) {
16491651
FailedRequestException fe = (FailedRequestException) e;
1650-
retval = WebPlotResult.makeFail(fe.getUserMessage(), fe.getUserMessage(), fe.getDetailMessage(), progressKey);
1652+
retval = WebPlotResult.makeFail(fe.getUserMessage(), fe.getUserMessage(), fe.getDetailMessage(), progressKey, plotId);
16511653
fe.setSimpleToString(true);
16521654
userAbort = VisContext.PLOT_ABORTED.equals(fe.getDetailMessage());
16531655
} else if (e instanceof SecurityException) {
1654-
retval = WebPlotResult.makeFail("No Access", "You do not have access to this data,", e.getMessage(), progressKey);
1656+
retval = WebPlotResult.makeFail("No Access", "You do not have access to this data,", e.getMessage(), progressKey, plotId);
16551657
} else {
1656-
retval = WebPlotResult.makeFail("Server Error, Please Report", e.getMessage(), null, progressKey);
1658+
retval = WebPlotResult.makeFail("Server Error, Please Report", e.getMessage(), null, progressKey, plotId);
16571659
}
16581660
List<String> messages = new ArrayList<String>(8);
16591661
messages.add(logMsg);

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/WebPlotResultSerializer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public static JSONObject createJsonDeep(WebPlotResult res) {
163163
map.put( "userFailReason", res.getUserFailReason());
164164
map.put( "detailFailReason", res.getDetailFailReason());
165165
map.put( "progressKey", pKey);
166+
map.put( "plotId", res.getPlotId());
166167
}
167168

168169
JSONObject wraperObj= new JSONObject();

src/firefly/java/edu/caltech/ipac/firefly/visualize/WebPlotResult.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,46 +49,51 @@ public class WebPlotResult implements Serializable, DataEntry, Iterable<Map.Entr
4949
private String _userFailReason;
5050
private String _detailFailReason;
5151
private String _progressKey;
52+
private String _plotId;
5253
private HashMap<String, DataEntry> _map= new HashMap<String, DataEntry>(3);
5354

5455
//======================================================================
5556
//----------------------- Constructors ---------------------------------
5657
//======================================================================
5758

58-
public WebPlotResult() { this(null, true,"", "","",""); }
59-
public WebPlotResult(String ctxStr) { this(ctxStr, true,"", "","",""); }
59+
public WebPlotResult() { this(null, true,"", "","","",null); }
60+
public WebPlotResult(String ctxStr) { this(ctxStr, true,"", "","","",null); }
6061
protected WebPlotResult(String briefFailReason,
6162
String userFailReason,
6263
String detailFailReason,
63-
String progressKey) {
64-
this(null, false, briefFailReason, userFailReason, detailFailReason,progressKey);
64+
String progressKey,
65+
String plotId) {
66+
this(null, false, briefFailReason, userFailReason, detailFailReason,progressKey,plotId);
6567
}
6668

6769
public static WebPlotResult makeFail(String briefFailReason,
6870
String userFailReason,
6971
String detailFailReason) {
70-
return new WebPlotResult(briefFailReason, userFailReason,detailFailReason,"");
72+
return new WebPlotResult(briefFailReason, userFailReason,detailFailReason,"",null);
7173
}
7274

7375
public static WebPlotResult makeFail(String briefFailReason,
7476
String userFailReason,
7577
String detailFailReason,
76-
String progressKey) {
77-
return new WebPlotResult(briefFailReason, userFailReason,detailFailReason,progressKey);
78+
String progressKey,
79+
String plotId) {
80+
return new WebPlotResult(briefFailReason, userFailReason,detailFailReason,progressKey, plotId);
7881
}
7982

8083
private WebPlotResult(String ctxStr,
8184
boolean success,
8285
String briefFailReason,
8386
String userFailReason,
8487
String detailFailReason,
85-
String progressKey) {
88+
String progressKey,
89+
String plotId) {
8690
_ctxStr= ctxStr;
8791
_success= success;
8892
_briefFailReason= briefFailReason;
8993
_userFailReason= userFailReason;
9094
_detailFailReason= detailFailReason;
9195
_progressKey= progressKey;
96+
_plotId= plotId;
9297
}
9398
//======================================================================
9499
//----------------------- Public Methods -------------------------------
@@ -116,6 +121,7 @@ public String getStringResult(String key) {
116121
public String getUserFailReason() { return _userFailReason; }
117122
public String getDetailFailReason() { return _detailFailReason; }
118123
public String getProgressKey() { return _progressKey; }
124+
public String getPlotId() { return _plotId; }
119125
public String getContextStr() { return _ctxStr; }
120126

121127
public Iterator<Map.Entry<String,DataEntry>> iterator() {

src/firefly/java/edu/caltech/ipac/firefly/visualize/WebPlotResultParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static WebPlotResult convertItem(PlotResultOverlay res) {
103103
retval= WebPlotResult.makeFail(res.getBriefFailReason(),
104104
res.getUserFailReason(),
105105
res.getDetailFailReason(),
106-
res.getProgressKey());
106+
res.getProgressKey(),null);
107107

108108
}
109109
return retval;

src/firefly/js/core/ReduxFlux.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ var logger= loggerMiddleware({duration:true, predicate:logFilter, collapsed:coll
214214
function createRedux() {
215215
// create a rootReducer from all of the registered reducers
216216
const rootReducer = combineReducers(reducers);
217-
const middleWare= applyMiddleware(thunkMiddleware, createSagaMiddleware(masterSaga));
217+
const middleWare= applyMiddleware(thunkMiddleware, /*logger,*/ createSagaMiddleware(masterSaga));
218218

219219
return createStore(rootReducer, middleWare);
220220
}

src/firefly/js/core/layout/FireflyLayoutManager.js

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
*/
44

55
import {take} from 'redux-saga/effects';
6-
import {get, filter, omitBy, isNil} from 'lodash';
6+
import {get, filter, omitBy, isNil, isEmpty} from 'lodash';
77

88
import {LO_VIEW, LO_MODE, SHOW_DROPDOWN, SET_LAYOUT_MODE, getLayouInfo, dispatchUpdateLayoutInfo} from '../LayoutCntlr.js';
99
import {clone} from '../../util/WebUtil.js';
10-
import {TBL_RESULTS_ADDED, TABLE_LOADED, TABLE_REMOVE} from '../../tables/TablesCntlr.js';
10+
import {findGroupByTblId, getTblIdsByGroup,getActiveTableId} from '../../tables/TableUtil.js';
11+
import {TBL_RESULTS_ADDED, TABLE_LOADED, TABLE_REMOVE, TBL_RESULTS_ACTIVE} from '../../tables/TablesCntlr.js';
1112
import ImagePlotCntlr from '../../visualize/ImagePlotCntlr.js';
1213
import {isMetaDataTable, isCatalogTable} from '../../metaConvert/converterUtils.js';
1314
import {META_VIEWER_ID} from '../../visualize/ui/TriViewImageSection.jsx';
@@ -30,7 +31,8 @@ export function* layoutManager({title, views='tables | images | xyPlots'}) {
3031
ImagePlotCntlr.PLOT_IMAGE_START, ImagePlotCntlr.PLOT_IMAGE,
3132
ImagePlotCntlr.DELETE_PLOT_VIEW, REPLACE_IMAGES,
3233
TBL_RESULTS_ADDED, TABLE_REMOVE, TABLE_LOADED,
33-
SHOW_DROPDOWN, SET_LAYOUT_MODE
34+
SHOW_DROPDOWN, SET_LAYOUT_MODE,
35+
TBL_RESULTS_ACTIVE
3436
]);
3537

3638
var {hasImages, hasTables, hasXyPlots, mode, dropDown={}, ...others} = getLayouInfo();
@@ -64,6 +66,13 @@ export function* layoutManager({title, views='tables | images | xyPlots'}) {
6466
case ImagePlotCntlr.PLOT_IMAGE_START :
6567
[showImages, images, ignore] = handleNewImage(action, images);
6668
break;
69+
case TBL_RESULTS_ACTIVE:
70+
[showImages, images] = handleActiveTableChange(action.payload.tbl_id, images);
71+
break;
72+
case TABLE_REMOVE:
73+
[showImages, images] = handleActiveTableChange(getActiveTableId(findGroupByTblId(action.payload.tbl_id)), images);
74+
break;
75+
6776
}
6877

6978
if (ignore) continue; // ignores, don't update layout.
@@ -88,8 +97,10 @@ export function* layoutManager({title, views='tables | images | xyPlots'}) {
8897
expanded = LO_VIEW.none;
8998
}
9099
mode = {expanded, standard, closeable};
100+
break;
91101
}
92102

103+
93104
// calculate dropDown when new UI elements are added or removed from results
94105
switch (action.type) {
95106
case TBL_RESULTS_ADDED:
@@ -131,12 +142,62 @@ function handleNewTable(action, images, showImages) {
131142
}
132143
}
133144
if (isMeta) {
134-
images = clone(images, {selectedTab: 'meta', showMeta: true});
145+
images = clone(images, {selectedTab: 'meta', showMeta: true, metaDataTableId: tbl_id});
135146
showImages = true;
136147
}
137148
return [showImages, images];
138149
}
139150

151+
function handleActiveTableChange (tbl_id, images) {
152+
// check for catalog or meta images
153+
154+
const showFits= shouldShowFits();
155+
var showImages= showFits;
156+
157+
if (!tbl_id) {
158+
images = clone(images, {showMeta: false, showCoverage: false, showFits, metaDataTableId: null});
159+
return [showFits, images];
160+
}
161+
162+
const tblGroup= findGroupByTblId(tbl_id);
163+
if (!tblGroup) return [showImages, images];
164+
const tblList= getTblIdsByGroup(tblGroup);
165+
if (isEmpty(tblList)) return [showImages, images];
166+
167+
const anyHasCatalog= hasCatalogTable(tblList);
168+
const anyHasMeta= hasMetaTable(tblList);
169+
170+
171+
if (!anyHasCatalog && !anyHasMeta) {
172+
images = clone(images, {showMeta: false, showCoverage: false, showFits, metaDataTableId: null});
173+
return [showFits, images];
174+
}
175+
176+
177+
178+
if (hasCatalogTable(tblList)) {
179+
images = clone(images, {showCoverage: true, showFits});
180+
showImages = true;
181+
}
182+
183+
if (hasMetaTable(tblList)) {
184+
const metaTableId= isMetaDataTable(tbl_id) ? tbl_id : findFirstMetaTable(tblList);
185+
images = clone(images, {showMeta: true, showFits, metaDataTableId:metaTableId});
186+
showImages = true;
187+
}
188+
else {
189+
images = clone(images, {showMeta: false, showFits, metaTableId:null});
190+
}
191+
return [showImages, images];
192+
}
193+
194+
const hasCatalogTable= (tblList) => tblList.some( (id) => isCatalogTable(id) );
195+
const hasMetaTable= (tblList) => tblList.some( (id) => isMetaDataTable(id) );
196+
const findFirstMetaTable= (tblList) => tblList.find( (id) => isMetaDataTable(id) );
197+
const shouldShowFits= () => !isEmpty(getViewerPlotIds(getMultiViewRoot(), DEFAULT_FITS_VIEWER_ID));
198+
199+
200+
140201
function handleNewImage(action, images) {
141202
var ignore = false;
142203
const {viewerId, plotGroupId} = action.payload || {};

src/firefly/js/visualize/ImagePlotCntlr.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ export function dispatchPlotImage({plotId,wpRequest, threeColor=isArray(wpReques
432432
* @param wpRequestAry
433433
* @param {function} dispatcher only for special dispatching uses such as remote
434434
*/
435-
export function dispatchPlotGroup({wpRequestAry, pvOptions= {}, dispatcher= flux.process}) {
436-
dispatcher( { type: PLOT_IMAGE, payload: { wpRequestAry} });
435+
export function dispatchPlotGroup({wpRequestAry, viewerId, pvOptions= {}, dispatcher= flux.process}) {
436+
dispatcher( { type: PLOT_IMAGE, payload: { wpRequestAry, pvOptions, viewerId} });
437437
}
438438

439439

src/firefly/js/visualize/PlotImageTask.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function makePlotImageAction(rawAction) {
107107
wpRequestAry:ensureWPR(wpRequestAry),
108108
viewerId:rawAction.payload.viewerId,
109109
attributes:rawAction.payload.attributes,
110-
pvOptions: rawAction.pvOptions,
110+
pvOptions: rawAction.payload.pvOptions,
111111
threeColor:false,
112112
addToHistory:false,
113113
useContextModifications:true,
@@ -203,8 +203,8 @@ export function processPlotImageSuccessResponse(dispatcher, payload, result) {
203203
var failAry= [];
204204

205205
if (result.success && Array.isArray(result.data)) {
206-
successAry= result.data.filter( (d) => d.success);
207-
failAry= result.data.filter( (d) => !d.success);
206+
successAry= result.data.filter( (d) => d.data.success);
207+
failAry= result.data.filter( (d) => !d.data.success);
208208
}
209209
else {
210210
if (result.success) successAry= [{data:result}];
@@ -248,6 +248,7 @@ export function processPlotImageSuccessResponse(dispatcher, payload, result) {
248248
resultPayload.briefDescription= data.briefFailReason;
249249
resultPayload.description= 'Plot Failed- ' + data.userFailReason;
250250
resultPayload.detailFailReason= data.detailFailReason;
251+
resultPayload.plotId= data.plotId;
251252
dispatcher( { type: ImagePlotCntlr.PLOT_IMAGE_FAIL, payload:resultPayload} );
252253
});
253254

src/firefly/js/visualize/iv/ExpandedModeDisplay.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export class ExpandedModeDisplay extends Component {
6363
additionalStyle={{flex:'1 1 auto'}}
6464
closeFunc={closeFunc}
6565
defaultDecoration={false}
66-
canDelete={true}
6766
showWhenExpanded={true}
6867
insideFlex={insideFlex}
6968
/>

src/firefly/js/visualize/iv/ImageViewer.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class ImageViewer extends Component {
9292

9393
render() {
9494
var {plotView,allPlots,drawLayersAry,mousePlotId}= this.state;
95-
var {showWhenExpanded, plotId, handleInlineTools, showDelete}= this.props;
95+
var {showWhenExpanded, plotId, handleInlineTools}= this.props;
9696
if (!showWhenExpanded && allPlots.expandedMode!==ExpandType.COLLAPSE) return false;
9797
if (!plotView) return false;
9898

@@ -109,7 +109,6 @@ export class ImageViewer extends Component {
109109
visRoot={allPlots}
110110
mousePlotId={mousePlotId}
111111
handleInlineTools={handleInlineTools}
112-
showDelete={showDelete}
113112
extensionList={getExtensionList(plotId)} />
114113
);
115114
}
@@ -119,13 +118,11 @@ ImageViewer.propTypes= {
119118
plotId : PropTypes.string.isRequired,
120119
showWhenExpanded : PropTypes.bool,
121120
handleInlineTools : PropTypes.bool,
122-
showDelete : PropTypes.bool
123121
};
124122

125123
ImageViewer.defaultProps = {
126124
handleInlineTools : true,
127125
showWhenExpanded : false,
128-
showDelete : false
129126
};
130127

131128

src/firefly/js/visualize/iv/ImageViewerDecorate.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,11 @@ export class ImageViewerDecorate extends Component {
273273

274274
render() {
275275
const {plotView:pv,drawLayersAry,extensionList,visRoot,mousePlotId,
276-
handleInlineTools,showDelete,width,height}= this.props;
276+
handleInlineTools,width,height}= this.props;
277277

278278
if (!width || !height) return false;
279279

280+
const showDelete= pv.plotViewCtx.userCanDeletePlots;
280281
const ctxToolbar= contextToolbar(pv,drawLayersAry,extensionList);
281282
const top= ctxToolbar?32:0;
282283
var title, zoomFactor;
@@ -360,7 +361,6 @@ ImageViewerDecorate.propTypes= {
360361
width : PropTypes.number.isRequired,
361362
height : PropTypes.number.isRequired,
362363
handleInlineTools : PropTypes.bool,
363-
showDelete : PropTypes.bool
364364
};
365365

366366

src/firefly/js/visualize/reducer/HandlePlotCreation.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,29 @@ function plotFail(state,action) {
127127
return clone(state, {plotViewAry:clonePvAry(plotViewAry,plotId,changes)});
128128
}
129129

130+
131+
// function plotFail(state,action) {
132+
// const {description, plotId, wpRequestAry}= action.payload;
133+
// var {plotViewAry}= state;
134+
// if (plotId) {
135+
// const plotView= getPlotViewById(state,plotId);
136+
// if (!plotView) return state;
137+
// const changes= {plottingStatus:description,serverCall:'fail' };
138+
// return clone(state, {plotViewAry:clonePvAry(plotViewAry,plotId,changes)});
139+
// }
140+
// else if (wpRequestAry) {
141+
// const pvChangeAry= wpRequestAry.map( (r) => {
142+
// const pv= getPlotViewById(state,plotId);
143+
// if (!pv) return null;
144+
// return clone(pv,{plottingStatus:description,serverCall:'fail' } );
145+
// });
146+
// const newPlotViewAry= unionBy(pvChangeAry,plotViewAry, 'plotId');
147+
// return clone(state, {plotViewAry:newPlotViewAry});
148+
// }
149+
// }
150+
151+
152+
130153
/**
131154
/**
132155
*

0 commit comments

Comments
 (0)