Skip to content

DM-7167: Create lightcurve manager #167

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 1 commit into from
Sep 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
40 changes: 39 additions & 1 deletion src/firefly/js/core/LayoutCntlr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/

import {get, isEmpty} from 'lodash';
import {get, isEmpty, filter, pick} from 'lodash';
import Enum from 'enum';
import {flux} from '../Firefly.js';
import {clone} from '../util/WebUtil.js';
import {smartMerge} from '../tables/TableUtil.js';
import {getDropDownNames} from '../ui/Menu.jsx';
import ImagePlotCntlr from '../visualize/ImagePlotCntlr.js';
import {TBL_RESULTS_ADDED, TABLE_REMOVE} from '../tables/TablesCntlr.js';
import {REPLACE_IMAGES} from '../visualize/MultiViewCntlr.js';
import {updateSet} from '../util/WebUtil.js';

export const LAYOUT_PATH = 'layout';

Expand Down Expand Up @@ -95,6 +99,9 @@ export function getDropDownInfo() {
return get(flux.getState(), 'layout.dropDown', {visible: false});
}

/**
* @returns {LayoutInfo} returns the layout information of the application
*/
export function getLayouInfo() {
const layout = get(flux.getState(), 'layout', {});
const hasImages = get(flux.getState(), 'allPlots.plotViewAry.length') > 0;
Expand All @@ -112,3 +119,34 @@ function getSelView(state, dropDown) {
}


/**
* This handles the general use case of the drop-down panel.
* It will collapse the drop-down panel when new tables or images are added.
* It will expand the drop-down panel when there is no results to be shown.
* @param {LayoutInfo} layoutInfo
* @param {Action} action
* @returns {LayoutInfo} return new LayoutInfo if layout was affected. Otherwise, return the given layoutInfo.
*/
export function dropDownHandler(layoutInfo, action) {
// calculate dropDown when new UI elements are added or removed from results
const count = filter(pick(layoutInfo, ['showTables', 'showXyPlots', 'showImages'])).length;
switch (action.type) {
case TBL_RESULTS_ADDED:
case REPLACE_IMAGES :
case ImagePlotCntlr.PLOT_IMAGE :
case ImagePlotCntlr.PLOT_IMAGE_START :
return updateSet(layoutInfo, 'dropDown.visible', false);
break;

case SHOW_DROPDOWN:
case TABLE_REMOVE:
case ImagePlotCntlr.DELETE_PLOT_VIEW:
if (!get(layoutInfo, 'dropDown.visible', false)) {
if (count===0) {
return updateSet(layoutInfo, 'dropDown.visible', true);
}
}
break;
}
return layoutInfo;
}
25 changes: 25 additions & 0 deletions src/firefly/js/core/core-typedefs.jsdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @global
*/


/**
* @typedef {Object} Action
* @prop {string} type a unique string identifying this action
* @prop {Object} payload the data
*/


/**
* Common Layout information used to control generic behavior, ie drop-down panel, expanded/collapsed state, etc
* The intention here is to allow additional layout attributes to be added to handle specific layout needs of a
* particular component or application. Use dispatchUpdateLayoutInfo to update this object.
* @typedef {Object} LayoutInfo
* @prop {Object} dropDown information used by the drop-down menu component
* @prop {boolean} dropDown.visible true to show the drop-down panel; collapse the panel otherwise
* @prop {string} dropDown.view the selected menuItem to be shown.
* @prop {Object} mode information used to control expanded or standard mode.
* In this context, view a string to denote what to show, ie. 'tables', 'images', or 'tables | images' ( tables and images).
* @prop {string} mode.expanded if not nil/empty, show this view in expanded mode
* @prop {string} mode.standard the current standard view.
*/
92 changes: 0 additions & 92 deletions src/firefly/js/tables/TablesCntlr.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,98 +102,6 @@ export const TABLE_UPDATE = `${DATA_PREFIX}.update`;
export const TABLE_REPLACE = `${DATA_PREFIX}.replace`;


/**
* Top level store for table related data. It's mounted as 'table_space' under the application state
* @typedef {object} TableSpace
* @prop {Object.<string, TableModel>} data repository for table model; keyed by tbl_id
* @prop {Object.<string, TableGroup>} results repository for table group information; keyed by tbl_group name
* @prop {Object.<string, Object>} ui repository for table UI state; keyed by tbl_ui_id
*/


/**
* Table model. The top level table data object with meta info.
* @typedef {object} TableModel
* @prop {string} tbl_id unique ID of this table.
* @prop {string} title title, used on label.
* @prop {TableRequest} request the request used to create this table
* @prop {TableMeta} tableMeta table's meta information stored as key/value pair.
* @prop {TableData} tableData table's meta information stored as key/value pair.
* @prop {number} totalRows total number of rows.
* @prop {number} highlightedRow the current highlighted row index. index is natural order starting from 0.
* @prop {object} selectInfo selection information. use SelectInfo.newInstance take advantage of helper's functions.
* @prop {boolean} isFetching true if data is being fetched and not ready for display.
* @prop {string} error error message if the request fail to create a table.
*/

/**
* Table data. Table data object.
* @typedef {object} TableData
* @prop {TableColumn[]} columns table column definition.
* @prop {string[][]} data 2D array containing the table data
*/

/**
* Table column information.
* @typedef {object} TableColumn
* @prop {string} name name of the column
* @prop {string} label display name of the column
* @prop {string} type data type
* @prop {string} units data units
* @prop {string} desc description of the column
* @prop {number} width column display width
* @prop {number} prefWidth preferred width. if width is not defined
* @prop {boolean} sortable true if undefined
* @prop {string} visibility show, hide, or hidden. hidden columns are not viewable by users.
* @prop {string} sortByCols for multi-columns sorting. column names separated by comma(',').
* @prop {string} related highlight related rows based on this column's value.
*/

/**
* Table meta information. Below is only a small set of predefined meta used by table.
* The meta information in this object are used by many components for many reasons. ie catalog overlay.
* @typedef {object} TableMeta
* @prop {string} Loading-Status COMPLETED or INPROGRESS
* @prop {string} tblFilePath path of the source of this table on the server-side.
* @prop {string} isFullyLoaded 'true' when table is completely loaded on the server-side.
* @prop {string} source path of the original table source before any operations were performed. ie sort, filter, etc. this may not be fully supported.
*/

/**
* Table request. Below is a list of predefined parameters available for table request. All of the options are optional.
* These parameters let you control what data and how it will be returned.
* @typedef {object} TableRequest
* @prop {number} startIdx the starting index to fetch. defaults to zero.
* @prop {number} pageSize the number of rows per page. defaults to 100.
* @prop {string} filters list of conditions separted by comma(,). Format: (col_name|index) operator value.
* operator is one of '> < = ! >= <= IN'. See DataGroupQueryStatement.java doc for more details.
* @prop {string} sortInfo sort information. Format: (ASC|DESC),col_name[,col_name]*
* @prop {string} inclCols list of columns to select. Column names separted by comma(,)
* @prop {string} decimate decimation information.
* @prop {object} META_INFO meta information passed as key/value pair to server then returned as tableMeta.
* @prop {string} use one of 'catalog_overlay', 'catalog_primary', 'data_primary'.
* @prop {string} tbl_id a unique id of a table. auto-create if not given.
*/

/**
* Table group. Define a group of tables used by the UI.
* @typedef {Object} TableGroup
* @prop {string} name unique name of this group
* @prop {string} active tbl_id of the active table in this group
* @prop {Object.<string, TableGroupItem>} tables a map of TableGroupItem(s) keyed by tbl_id
*/

/**
* Table group item. Contains enough key information to identify the table data as well as the UI data associate with this item.
* @typedef {Object} TableGroupItem
* @prop {string} tbl_group table group name
* @prop {string} tbl_id unique id of the table data
* @prop {string} tbl_ui_id unique id of the table's UI data
* @prop {string} title title or label of the table
* @prop {boolean} removable true if this item can be removed from group.
* @prop {Object.<string, *>} options table options, ie. selectable, expandable
*/


/*---------------------------- CREATORS ----------------------------*/

Expand Down
96 changes: 96 additions & 0 deletions src/firefly/js/tables/tables-typedefs.jsdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* @global
*/

/**
* Top level store for table related data. It's mounted as 'table_space' under the application state
* @typedef {object} TableSpace
* @prop {Object.<string, TableModel>} data repository for table model; keyed by tbl_id
* @prop {Object.<string, TableGroup>} results repository for table group information; keyed by tbl_group name
* @prop {Object.<string, Object>} ui repository for table UI state; keyed by tbl_ui_id
*/


/**
* Table model. The top level table data object with meta info.
* @typedef {object} TableModel
* @prop {string} tbl_id unique ID of this table.
* @prop {string} title title, used on label.
* @prop {TableRequest} request the request used to create this table
* @prop {TableMeta} tableMeta table's meta information stored as key/value pair.
* @prop {TableData} tableData table's meta information stored as key/value pair.
* @prop {number} totalRows total number of rows.
* @prop {number} highlightedRow the current highlighted row index. index is natural order starting from 0.
* @prop {object} selectInfo selection information. use SelectInfo.newInstance take advantage of helper's functions.
* @prop {boolean} isFetching true if data is being fetched and not ready for display.
* @prop {string} error error message if the request fail to create a table.
*/

/**
* Table data. Table data object.
* @typedef {object} TableData
* @prop {TableColumn[]} columns table column definition.
* @prop {string[][]} data 2D array containing the table data
*/

/**
* Table column information.
* @typedef {object} TableColumn
* @prop {string} name name of the column
* @prop {string} label display name of the column
* @prop {string} type data type
* @prop {string} units data units
* @prop {string} desc description of the column
* @prop {number} width column display width
* @prop {number} prefWidth preferred width. if width is not defined
* @prop {boolean} sortable true if undefined
* @prop {string} visibility show, hide, or hidden. hidden columns are not viewable by users.
* @prop {string} sortByCols for multi-columns sorting. column names separated by comma(',').
* @prop {string} related highlight related rows based on this column's value.
*/

/**
* Table meta information. Below is only a small set of predefined meta used by table.
* The meta information in this object are used by many components for many reasons. ie catalog overlay.
* @typedef {object} TableMeta
* @prop {string} Loading-Status COMPLETED or INPROGRESS
* @prop {string} tblFilePath path of the source of this table on the server-side.
* @prop {string} isFullyLoaded 'true' when table is completely loaded on the server-side.
* @prop {string} source path of the original table source before any operations were performed. ie sort, filter, etc. this may not be fully supported.
*/

/**
* Table request. Below is a list of predefined parameters available for table request. All of the options are optional.
* These parameters let you control what data and how it will be returned.
* @typedef {object} TableRequest
* @prop {number} startIdx the starting index to fetch. defaults to zero.
* @prop {number} pageSize the number of rows per page. defaults to 100.
* @prop {string} filters list of conditions separted by comma(,). Format: (col_name|index) operator value.
* operator is one of '> < = ! >= <= IN'. See DataGroupQueryStatement.java doc for more details.
* @prop {string} sortInfo sort information. Format: (ASC|DESC),col_name[,col_name]*
* @prop {string} inclCols list of columns to select. Column names separted by comma(,)
* @prop {string} decimate decimation information.
* @prop {object} META_INFO meta information passed as key/value pair to server then returned as tableMeta.
* @prop {string} use one of 'catalog_overlay', 'catalog_primary', 'data_primary'.
* @prop {string} tbl_id a unique id of a table. auto-create if not given.
*/

/**
* Table group. Define a group of tables used by the UI.
* @typedef {Object} TableGroup
* @prop {string} name unique name of this group
* @prop {string} active tbl_id of the active table in this group
* @prop {Object.<string, TableGroupItem>} tables a map of TableGroupItem(s) keyed by tbl_id
*/

/**
* Table group item. Contains enough key information to identify the table data as well as the UI data associate with this item.
* @typedef {Object} TableGroupItem
* @prop {string} tbl_group table group name
* @prop {string} tbl_id unique id of the table data
* @prop {string} tbl_ui_id unique id of the table's UI data
* @prop {string} title title or label of the table
* @prop {boolean} removable true if this item can be removed from group.
* @prop {Object.<string, *>} options table options, ie. selectable, expandable
*/

2 changes: 1 addition & 1 deletion src/firefly/js/templates/fireflyviewer/FireflyViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {pickBy} from 'lodash';
import {flux, firefly} from '../../Firefly.js';
import {getMenu, isAppReady, dispatchSetMenu, dispatchOnAppReady} from '../../core/AppDataCntlr.js';
import {LO_VIEW, getLayouInfo, SHOW_DROPDOWN} from '../../core/LayoutCntlr.js';
import {layoutManager} from './FireflyLayoutManager.js';
import {layoutManager} from './FireflyViewerManager.js';
import {Menu} from '../../ui/Menu.jsx';
import {Banner} from '../../ui/Banner.jsx';
import {DropDownContainer} from '../../ui/DropDownContainer.jsx';
Expand Down
Loading