Skip to content

DM-7803: add time series launch capability to suit app. #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/firefly/js/tables/TablesCntlr.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ function tableSearch(action) {
return (dispatch) => {
//dispatch(validate(FETCH_TABLE, action));
if (!action.err) {
dispatch(action);
var {request={}, options={}} = action.payload;
const {tbl_ui_id} = options;
const {tbl_id} = request;
Expand Down
78 changes: 78 additions & 0 deletions src/firefly/js/tables/ui/ActiveTableButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/

import React, {Component,PropTypes} from 'react';
import sCompare from 'react-addons-shallow-compare';

import {flux} from '../../Firefly.js';
import {getTblInfoById, getActiveTableId} from '../TableUtil.js';

/**
* This button will track the highlighted row of the given tbl_id or of the active table of the given tbl_grp.
* There are 2 callbacks available as props.
* onClick: This function is called when a user click on this button.
* onChange({tbl_id, highlightedRow}): This function is called when highlightedRow changes.
* The returned object of this function will be set into state.
* Props like show or title can be changed via this function.
*/
export class ActiveTableButton extends Component {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a little trouble figuring out how this all worked. The key is the onChanges function that takes a table_id and a highlighted row and return a boolean and a title. I think this should be documented.

constructor(props) {
super(props);
this.state = {...props};
this.onClick = this.onClick.bind(this);
}

componentDidMount() {
this.removeListener= flux.addListener(() => this.storeUpdate());
}

componentWillUnmount() {
this.removeListener && this.removeListener();
this.isUnmounted = true;
}

storeUpdate() {
if (!this.isUnmounted) {
var {tbl_id, tbl_grp, onChange} = this.props;
tbl_id = tbl_id || getActiveTableId(tbl_grp);
const {highlightedRow} = getTblInfoById(tbl_id);

if (sCompare(this, this.props, Object.assign({}, this.state, {tbl_id, highlightedRow}))) {
this.setState({tbl_id, highlightedRow});
onChange && this.setState(onChange({tbl_id, highlightedRow}));
}
}
}

onClick() {
const {onClick} = this.props;
const {tbl_id, highlightedRow} = this.state;
onClick && onClick({tbl_id, highlightedRow});
}

render() {
const {show=true, title, style, type='standard'} = this.state;
const astyle = Object.assign({textOverflow: 'ellipsis', maxWidth: 200, overflow: 'hidden'}, style);
const className = type === 'standard' ? 'button std' : 'button std hl';
return show && (
<button type = 'button' className={className} onClick = {this.onClick}>
<div title={title} style={astyle}>{title}</div>
</button>
);
}
}


ActiveTableButton.propTypes = {
tbl_id : PropTypes.string,
tbl_grp : PropTypes.string,
show : PropTypes.bool,
title : PropTypes.string,
type : PropTypes.oneOf(['standard', 'highlight']),
style : PropTypes.object,
onChange : PropTypes.func,
onClick : PropTypes.func
};

18 changes: 12 additions & 6 deletions src/firefly/js/templates/fireflyviewer/FireflyViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class FireflyViewer extends Component {

render() {
var {isReady, menu={}, appTitle, appIcon, altAppIcon, dropDown,
dropdownPanels, views, footer, style, showViewsSwitch} = this.state;
dropdownPanels, views, footer, style, showViewsSwitch, leftButtons, centerButtons, rightButtons} = this.state;
const {visible, view} = dropDown || {};

if (!isReady) {
Expand All @@ -106,7 +106,7 @@ export class FireflyViewer extends Component {
{...{dropdownPanels} } />
</header>
<main>
<DynamicResults {...{views, showViewsSwitch}}/>
<DynamicResults {...{views, showViewsSwitch, leftButtons, centerButtons, rightButtons}}/>
</main>
</div>
);
Expand All @@ -129,7 +129,10 @@ FireflyViewer.propTypes = {
dropdownPanels: PropTypes.arrayOf(PropTypes.element),
views: PropTypes.string, // combination of LO_VIEW separated by ' | '. ie. 'images | tables'.
style: PropTypes.object,
showViewsSwitch: PropTypes.bool
showViewsSwitch: PropTypes.bool,
leftButtons: PropTypes.arrayOf( PropTypes.func ),
centerButtons: PropTypes.arrayOf( PropTypes.func ),
rightButtons: PropTypes.arrayOf( PropTypes.func )
};

FireflyViewer.defaultProps = {
Expand Down Expand Up @@ -167,16 +170,19 @@ function BannerSection(props) {


function DynamicResults(props) {
var {views, showViewsSwitch} = props;
var {views, ...rest} = props;
if (LO_VIEW.get(views)) {
return <TriViewPanel {...{showViewsSwitch}}/>;
return <TriViewPanel {...rest}/>;
}
}
DynamicResults.propTypes = {
views: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object]),
showViewsSwitch: PropTypes.bool
showViewsSwitch: PropTypes.bool,
leftButtons: PropTypes.arrayOf( PropTypes.func ),
centerButtons: PropTypes.arrayOf( PropTypes.func ),
rightButtons: PropTypes.arrayOf( PropTypes.func )
};
DynamicResults.defaultProps = {
showViewsSwitch: true
Expand Down
73 changes: 55 additions & 18 deletions src/firefly/js/templates/fireflyviewer/TriViewPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/

import React, {Component} from 'react';
import React, {Component, PropTypes} from 'react';
import sCompare from 'react-addons-shallow-compare';

import {pick} from 'lodash';
Expand Down Expand Up @@ -40,7 +40,7 @@ export class TriViewPanel extends Component {

render() {
// eslint-disable-next-line
const {showViewsSwitch} = this.props;
const {showViewsSwitch, leftButtons, centerButtons, rightButtons} = this.props;
const {title, mode, showTables, showImages, showXyPlots, images={}} = this.state;
const {expanded, standard, closeable} = mode || {};
const content = {};
Expand All @@ -63,27 +63,13 @@ export class TriViewPanel extends Component {
closeable={closeable}
expandedMode={expanded===LO_VIEW.tables}/>);
}
const searchDesc = (showViewsSwitch && showImages && showXyPlots && showTables) ?
(<div>
<div style={ {display: 'inline-block', float: 'right'} }>
<button type='button' className='button std'
onClick={() => dispatchSetLayoutMode(LO_MODE.standard, LO_VIEW.get('tables | images | xyPlots'))}>tri-view</button>
<button type='button' className='button std'
onClick={() => dispatchSetLayoutMode(LO_MODE.standard, LO_VIEW.get('tables | images'))}>img-tbl</button>
<button type='button' className='button std'
onClick={() => dispatchSetLayoutMode(LO_MODE.standard, LO_VIEW.get('images | xyPlots'))}>img-xy</button>
<button type='button' className='button std'
onClick={() => dispatchSetLayoutMode(LO_MODE.standard, LO_VIEW.get('tables | xyPlots'))}>xy-tbl</button>
</div>
</div>)
: <div/>;

const viewSwitch = showViewsSwitch && showImages && showXyPlots && showTables;

if (showImages || showXyPlots || showTables) {
return (
<ResultsPanel key='results'
title={title}
searchDesc ={searchDesc}
searchDesc ={searchDesc({viewSwitch, leftButtons, centerButtons, rightButtons})}
expanded={expanded}
standard={standard}
visToolbar={visToolbar}
Expand All @@ -95,3 +81,54 @@ export class TriViewPanel extends Component {
}
}
}


TriViewPanel.propTypes = {
showViewsSwitch: PropTypes.bool,
leftButtons: PropTypes.arrayOf( PropTypes.func ),
centerButtons: PropTypes.arrayOf( PropTypes.func ),
rightButtons: PropTypes.arrayOf( PropTypes.func )
};
TriViewPanel.defaultProps = {
showViewsSwitch: true
};


// eslint-disable-next-line
function searchDesc({viewSwitch, leftButtons, centerButtons, rightButtons}) {

const hasContent = viewSwitch || leftButtons || centerButtons || rightButtons;
return !hasContent ? <div/> :
(
<div style={{display: 'inline-flex', justifyContent: 'space-between'}}>
<div>
{leftButtons &&
leftButtons.map( (el) => el())
}
</div>
<div>
{centerButtons &&
centerButtons.map( (el) => el())
}
</div>
<div style={{display: 'inline-flex'}}>
{rightButtons &&
rightButtons.map( (el) => el())
}
<div style={{width: 20}}/>
{viewSwitch &&
<div style={ {display: 'inline-block', float: 'right'} }>
<button type='button' className='button std'
onClick={() => dispatchSetLayoutMode(LO_MODE.standard, LO_VIEW.get('tables | images | xyPlots'))}>tri-view</button>
<button type='button' className='button std'
onClick={() => dispatchSetLayoutMode(LO_MODE.standard, LO_VIEW.get('tables | images'))}>img-tbl</button>
<button type='button' className='button std'
onClick={() => dispatchSetLayoutMode(LO_MODE.standard, LO_VIEW.get('images | xyPlots'))}>img-xy</button>
<button type='button' className='button std'
onClick={() => dispatchSetLayoutMode(LO_MODE.standard, LO_VIEW.get('tables | xyPlots'))}>xy-tbl</button>
</div>
}
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion src/firefly/js/templates/lightcurve/LcImageToolbarView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ for(var i= 1; (i<=LC.MAX_IMAGE_CNT); i+=2) {

export function LcImageToolbarView({activePlotId, viewerId, viewerPlotIds, layoutType, dlAry, tableId, closeFunc=null}) {
const converter = getConverterData();
if (!converter) { return; }
if (!converter) { return null; }

const viewer= getViewer(getMultiViewRoot(), viewerId);
const count= get(viewer, 'layoutDetail.count', converter.defaultImageCount);
Expand Down
Loading