Skip to content

Commit

Permalink
DM-14867, IRSA-2466: fixed bugs in tickets
Browse files Browse the repository at this point in the history
    - IRSA-2466: Only HiPS or AllSky FITS will recenter when table tabs switch
    - DM-14867: Toolbar button and then "Select new Image" buttons is active when image plot fails in API
    - API UI Test framework modified to allows for resizing the IFrames
  • Loading branch information
robyww committed Jan 17, 2019
1 parent 361c9a7 commit 8a6722b
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 29 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/firefly/html/test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ <h4>To add a test to an existing page</h4>
+ indent-3 :source need to adjust for 3 indentation
+ indent-4 :source need to adjust for 4 indentation
+ indent-5 :source need to adjust for 5 indentation
expected-list :turn on normal list styling, use with ul element (firefly turns it off)
</xmp>
</div>

Expand Down
9 changes: 9 additions & 0 deletions src/firefly/html/test/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
padding: 0 5px;
}

ul.expected-list li{
list-style-type: circle;
}

.source-code.indent-2 {margin-left: -4ch;}
.source-code.indent-2 {margin-left: -8ch;}
.source-code.indent-3 {margin-left: -12ch;}
Expand Down Expand Up @@ -84,6 +88,10 @@
.tst-iframe-container iframe {
border: 0;
width: 100%;
resize : both;
display: flex;
background-color: rgba(0,0,0, .04);
margin-bottom: 5px;
}

#tpl-container {
Expand All @@ -98,6 +106,7 @@
display: inline-flex;
overflow-x: auto;
overflow-y: hidden;
flex-grow: 1;
}

.tpl-item-box {
Expand Down
5 changes: 2 additions & 3 deletions src/firefly/html/test/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
~ License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
-->

<html>
<html style='height: 100%;'>

<head>
<title>Firefly API Test</title>
Expand Down Expand Up @@ -37,7 +37,6 @@

document.getElementById('tpl-container').appendChild(document.importNode(t, true));
document.getElementById("tpl-source-code-container").style.display = 'none';
resizeIframe();
};

function showSource(flg) {
Expand Down Expand Up @@ -70,7 +69,7 @@

</head>

<body>
<body style='height: 100%;'>


<template id="test_template">
Expand Down
9 changes: 3 additions & 6 deletions src/firefly/html/test/template_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@
});
};

function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 20 + 'px';
}

function renderTest(expected, actual, script, title, className) {
const iframe = document.createElement('iframe');
iframe.src = './template.html';
iframe.style.minHeight= '200px';
const idiv = document.createElement('div');
idiv.className = 'tst-iframe-container';
idiv.appendChild(iframe);
document.getElementById('tst-container').appendChild(idiv);

iframe.contentWindow.template = {expected, actual, script, title, className};
iframe.contentWindow.resizeIframe = function () {
resizeIframe(iframe);
iframe.contentWindow.resizeIframeToHeight= function (size) {
iframe.style.minHeight= size;
};
}

40 changes: 36 additions & 4 deletions src/firefly/html/test/tests-main.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<!-- define all of your tests below -->

<template title="IRSA Gator Table" class="tpl">
<template title="IRSA Gator Table" class="tpl" >
<div id="expected" class="flow-h">
<div class="source-code indent-3">
- widgets loaded
Expand All @@ -31,6 +31,7 @@
<div id="gatorXy" class="box"></div>
</div>
<script>
resizeIframeToHeight('300px');
irsaviewer_init();

onFireflyLoaded = function (firefly) {
Expand Down Expand Up @@ -82,6 +83,7 @@
</div>
<div id="actual" class="box x3"></div>
<script>
resizeIframeToHeight('240px');
onFireflyLoaded = function (firefly) {
tblReq = firefly.util.table.makeTblRequest('NedSearch', 'm8 (NED SCS 10)',
{ use: "catalog_overlay",
Expand All @@ -102,10 +104,12 @@
</template>

<template title="GAIA tap search" class="tpl sm">
<div id="expected" class="source-code indent-2">
<div id="expected">
Table successfully loaded
- VOTable
- first 3 rows of gaia_source
<ul class='expected-list'>
<li>VOTable</li>
<li>first 3 rows of gaia_source</li>
</ul>
</div>
<div id="actual" class="box x3"></div>
<script>
Expand All @@ -120,6 +124,34 @@
</script>
</template>

<template title="Failed API Image Load" class="tpl sm">
<div id="expected" style="width: 400px; white-space: normal; padding-top: 2px">
<div>Image load fails. The following should happen:
<ul class='expected-list'>
<li>No Image</li>
<li><i>Centered Message</i>: Failed- SDSS: Area not covered</li>
<li>Toolbar button active, when toolbar popup shown, toolbar should have "select image" button active</li>
</ul>
</div>
<div><img src="./images/fail-plot-expected.jpg"></div>
</div>
<div id="actual" class="box x3"></div>
<script>
resizeIframeToHeight('260px');
function onFireflyLoaded(firefly) {
const req= {
plotGroupId : 'myGroup',
Service : 'SDSS',
SurveyKey : 'u',
WorldPt : '10.68479;41.26906;EQ_J2000',
SizeInDeg : '.12'
};
firefly.showImage('actual', req);
}
</script>
</template>



<!-- this is where test cases will be attached-->
<div id="tst-container"/>
Expand Down
2 changes: 2 additions & 0 deletions src/firefly/js/drawingLayers/WebGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ function getDrawData(dataType, plotId, drawLayer, action, lastDataRet){
drawData= Object.assign({},drawLayer.drawData, {data});
return {drawData};
}
break;
case DrawLayerCntlr.MODIFY_CUSTOM_FIELD:
const {coordinate}= action.payload.changes;
if (coordinate !== drawLayer.coordinate ) {
const drawData= Object.assign({},drawLayer.drawData, {data:null});
return { coordinate, drawData};
}
break;
}
return null;

Expand Down
5 changes: 2 additions & 3 deletions src/firefly/js/templates/fireflyviewer/FireflyViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import {getWorkspaceConfig, initWorkspace} from '../../visualize/WorkspaceCntlr.
import {warningDivId} from '../../ui/LostConnection.jsx'

import FFTOOLS_ICO from 'html/images/fftools-logo-offset-small-75x75.png';

// import {deepDiff} from '../util/WebUtil.js';

import {startMasterTableWatcher} from '../../visualize/saga/MasterTableWatch';

/**
* This FireflyViewer is a generic application with some configurable behaviors.
Expand All @@ -51,6 +49,7 @@ export class FireflyViewer extends PureComponent {
getImageMasterData();
const views = LO_VIEW.get(props.views) || LO_VIEW.none;
this.state = this.getNextState();
startMasterTableWatcher([{}]);
dispatchAddSaga(watchCatalogs);
if (views.has(LO_VIEW.images) ) launchImageMetaDataSega();
dispatchAddSaga(layoutManager,{views: props.views});
Expand Down
10 changes: 5 additions & 5 deletions src/firefly/js/visualize/PlotViewUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,12 @@ export function clonePvAryWithPv(ref, plotView) {
/**
* Find a plot by id in a PlotView
* @param {PlotView} plotView
* @param {string} imagePlotId
* @param {string} plotImageId
* @return {WebPlot}
*/
export function findPlot(plotView, imagePlotId) {
if (!plotView) return null;
return plotView.plots.find( (p) => imagePlotId===p.imagePlotId);
export function findPlot(plotView, plotImageId) {
if (!plotView) return undefined;
return plotView.plots.find( (p) => plotImageId===p.plotImageId);
}


Expand Down Expand Up @@ -739,7 +739,7 @@ export function getFoV(pv, alternateZoomFactor) {
* @return {boolean} true if there are cubes or images
*/
export function isMultiImageFits(pv) {
return Boolean(isMultiHDUFits(pv) || getNumberOfCubesInPV(pv)>0)
return Boolean(isMultiHDUFits(pv) || getNumberOfCubesInPV(pv)>0);
}

/**
Expand Down
17 changes: 17 additions & 0 deletions src/firefly/js/visualize/__tests__/PlotViewUtil-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {primePlot, getPlotViewById, isActivePlotView, getActivePlotView} from '../PlotViewUtil.js';
import {makePlotView} from '../reducer/PlotView.js';
import {WebPlotRequest} from '../WebPlotRequest.js'
import {findPlot, primePlotType} from '../PlotViewUtil';



Expand Down Expand Up @@ -106,3 +107,19 @@ describe('Test PlotViewUtil active PlotView functions', () => {
expect(pv.plotId).toEqual(ACTIVE_ID);
});
});

describe('Less used PlotViewUtil functions', () => {
test('primePlotType)', () => {
const pv= getPlotViewById(pvAry, 'testId-xxxx');
expect(primePlotType(pv)).toEqual('image');
});

test('findPlot)', () => {
debugger;
const pv= getPlotViewById(pvAry, 'testId1');
const plot= findPlot(pv, 'testId1-image1');
expect(plot).toBeDefined();
expect(plot.plotImageId).toEqual('testId1-image1');
});

});
16 changes: 13 additions & 3 deletions src/firefly/js/visualize/iv/ImageViewerDecorate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,20 @@ const bgSlightGray= {background: 'rgba(255,255,255,.2)'};
const bgFFGray= {background: '#e3e3e3'};

function makeInlineRightToolbar(visRoot,pv,dlAry,mousePlotId, handleInlineTools, showDelete) {
const tb= !isExpanded && visRoot.useFloatToolbar;
const lVis= BrowserInfo.isTouchInput() || (visRoot.useFloatToolbar && pv && mousePlotId===pv.plotId);
const style= (lVis || tb) && handleInlineTools ? bgFFGray : bgSlightGray;
if (!pv && tb && handleInlineTools) {
return (
<div style={style} className='iv-decorate-inline-toolbar-container'>
<VisInlineToolbarView pv={pv} dlAry={undefined} showLayer={false}
showExpand={false} showToolbarButton={true} showDelete ={false} />
</div>
);

}
if (!pv) return false;

const useInlineToolbar = toolsAnno.includes(pv.plotViewCtx.annotationOps);
const isExpanded= visRoot.expandedMode!==ExpandType.COLLAPSE;

Expand All @@ -199,10 +212,7 @@ function makeInlineRightToolbar(visRoot,pv,dlAry,mousePlotId, handleInlineTools,
return false;
}
}
const lVis= BrowserInfo.isTouchInput() || (visRoot.useFloatToolbar && mousePlotId===pv.plotId);
const exVis= BrowserInfo.isTouchInput() || mousePlotId===pv.plotId;
const tb= !isExpanded && visRoot.useFloatToolbar;
const style= (lVis || tb) && handleInlineTools ? bgFFGray : bgSlightGray;
return (
<div style={style} className='iv-decorate-inline-toolbar-container'>
<VisInlineToolbarView
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/js/visualize/reducer/HandlePlotChange.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ function recenter(state,action) {
} );
}
else {
plotViewAry= applyToOnePvOrGroup(plotViewAry,plotId,plotGroup,true, recenterPv(centerPt, centerOnImage));
plotViewAry= applyToOnePvOrGroup(plotViewAry,plotId,plotGroup,false, recenterPv(centerPt, centerOnImage));
}


Expand Down
6 changes: 4 additions & 2 deletions src/firefly/js/visualize/saga/CatalogWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {parseWorldPt, pointEquals, makeWorldPt} from '../Point.js';
import {computeCentralPointAndRadius} from '../VisUtil.js';
import CsysConverter from '../CsysConverter.js';
import {COVERAGE_CREATED} from './CoverageWatcher.js';
import {isImage,isHiPS} from '../WebPlot';

/**
* this saga does the following:
Expand Down Expand Up @@ -124,8 +125,9 @@ function recenterImage(tbl) {
newCenter = centralPoint;
}

// recenter image for 'hips' and 'image' type
if (newCenter && (plot.plotType === 'hips' || cc.pointInPlot(newCenter)) && !pointEquals(centerPt, newCenter)) {
const allSky= Boolean( (isImage(plot) && plot.projection.isWrappingProjection()) || isHiPS(plot));
// recenter image for 'hips' and allsky 'image' type
if (newCenter && allSky && !pointEquals(centerPt, newCenter)) {
dispatchRecenter({plotId: plot.plotId, centerPt: newCenter});
}
}
Expand Down
58 changes: 58 additions & 0 deletions src/firefly/js/visualize/saga/MasterTableWatch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {get} from 'lodash';
import { TABLE_SEARCH } from '../../tables/TablesCntlr';
import {dispatchAddActionWatcher} from '../../core/MasterSaga';
import {onTableLoaded} from '../../tables/TableUtil';

/**
* @global
* @public
* @typedef {Object} TableWatcherDef
*
* @summary Define a table watch definition
*
* @param {Function} startWatcher(table)
* @param {Object} watcherData
* @param {Function} testTable - testTable(table) return 'watch' 'exclusiveWatch' or false
*
*
*
*/

/**
* Start the master table Watcher
* @param {Array.<TableWatcherDef>} tableWatcherDefList
*/
export function startMasterTableWatcher(tableWatcherDefList) {


const actions = [TABLE_SEARCH];

dispatchAddActionWatcher({
actions,
id: 'masterTableWatcher',
callback: masterTableWatcher,
params: {tableWatcherDefList}});

}

function masterTableWatcher(action, cancelSelf, params) {

const {tableWatcherDefList}= params;
const tbl_id = get(action.payload, 'request.tbl_id');
if (!tbl_id) return;

switch (action.type) {
case TABLE_SEARCH:
onTableLoaded(tbl_id).then( (table) =>
!table.error && evaluateTableAndStartWatchers(table, tableWatcherDefList));
break;

}

}


function evaluateTableAndStartWatchers(table, tableWatcherDefList) {

console.log(`new loaded table: ${table.tbl_id}`);
}
3 changes: 2 additions & 1 deletion src/firefly/js/visualize/ui/VisInlineToolbarView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class VisInlineToolbarView extends PureComponent {

render() {
const {pv, dlAry, showLayer, expandGrid, showExpand, showDelete, showToolbarButton, help_id}= this.props;
const shouldShowTools= Boolean((showToolbarButton && showExpand) || (showToolbarButton && !pv.plots.length));

return (
<div style={rS}>
Expand All @@ -80,7 +81,7 @@ export class VisInlineToolbarView extends PureComponent {
tip='Show tools'
additionalStyle={{alignSelf:'flex-start'}}
horizontal={true}
visible={Boolean(showToolbarButton && showExpand)}
visible={shouldShowTools}
onClick={showTools}/>
{help_id && <div style={{marginRight: 20}}><HelpIcon helpId={help_id}/></div>}
<ToolbarButton icon={expandGrid? GRID_EXPAND : OUTLINE_EXPAND}
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/js/visualize/ui/VisToolbarView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class VisToolbarView extends PureComponent {

{apiToolsView && <ToolbarButton icon={NEW_IMAGE}
tip='Select a new image'
enabled={enabled}
enabled={true}
horizontal={true}
visible={mi.imageSelect}
onClick={showImagePopup}/>}
Expand Down

0 comments on commit 8a6722b

Please sign in to comment.