Skip to content

Commit 9ad799c

Browse files
authored
DM-7167: Create lightcurve manager. Merge pr #167 from Caltech-IPAC/DM-7167_LC_manager
DM-7167: Create lightcurve manager
2 parents d7432e3 + 8093acf commit 9ad799c

File tree

10 files changed

+360
-309
lines changed

10 files changed

+360
-309
lines changed

src/firefly/js/core/LayoutCntlr.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33
*/
44

5-
import {get, isEmpty} from 'lodash';
5+
import {get, isEmpty, filter, pick} from 'lodash';
66
import Enum from 'enum';
77
import {flux} from '../Firefly.js';
88
import {clone} from '../util/WebUtil.js';
99
import {smartMerge} from '../tables/TableUtil.js';
1010
import {getDropDownNames} from '../ui/Menu.jsx';
11+
import ImagePlotCntlr from '../visualize/ImagePlotCntlr.js';
12+
import {TBL_RESULTS_ADDED, TABLE_REMOVE} from '../tables/TablesCntlr.js';
13+
import {REPLACE_IMAGES} from '../visualize/MultiViewCntlr.js';
14+
import {updateSet} from '../util/WebUtil.js';
1115

1216
export const LAYOUT_PATH = 'layout';
1317

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

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

114121

122+
/**
123+
* This handles the general use case of the drop-down panel.
124+
* It will collapse the drop-down panel when new tables or images are added.
125+
* It will expand the drop-down panel when there is no results to be shown.
126+
* @param {LayoutInfo} layoutInfo
127+
* @param {Action} action
128+
* @returns {LayoutInfo} return new LayoutInfo if layout was affected. Otherwise, return the given layoutInfo.
129+
*/
130+
export function dropDownHandler(layoutInfo, action) {
131+
// calculate dropDown when new UI elements are added or removed from results
132+
const count = filter(pick(layoutInfo, ['showTables', 'showXyPlots', 'showImages'])).length;
133+
switch (action.type) {
134+
case TBL_RESULTS_ADDED:
135+
case REPLACE_IMAGES :
136+
case ImagePlotCntlr.PLOT_IMAGE :
137+
case ImagePlotCntlr.PLOT_IMAGE_START :
138+
return updateSet(layoutInfo, 'dropDown.visible', false);
139+
break;
140+
141+
case SHOW_DROPDOWN:
142+
case TABLE_REMOVE:
143+
case ImagePlotCntlr.DELETE_PLOT_VIEW:
144+
if (!get(layoutInfo, 'dropDown.visible', false)) {
145+
if (count===0) {
146+
return updateSet(layoutInfo, 'dropDown.visible', true);
147+
}
148+
}
149+
break;
150+
}
151+
return layoutInfo;
152+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @global
3+
*/
4+
5+
6+
/**
7+
* @typedef {Object} Action
8+
* @prop {string} type a unique string identifying this action
9+
* @prop {Object} payload the data
10+
*/
11+
12+
13+
/**
14+
* Common Layout information used to control generic behavior, ie drop-down panel, expanded/collapsed state, etc
15+
* The intention here is to allow additional layout attributes to be added to handle specific layout needs of a
16+
* particular component or application. Use dispatchUpdateLayoutInfo to update this object.
17+
* @typedef {Object} LayoutInfo
18+
* @prop {Object} dropDown information used by the drop-down menu component
19+
* @prop {boolean} dropDown.visible true to show the drop-down panel; collapse the panel otherwise
20+
* @prop {string} dropDown.view the selected menuItem to be shown.
21+
* @prop {Object} mode information used to control expanded or standard mode.
22+
* In this context, view a string to denote what to show, ie. 'tables', 'images', or 'tables | images' ( tables and images).
23+
* @prop {string} mode.expanded if not nil/empty, show this view in expanded mode
24+
* @prop {string} mode.standard the current standard view.
25+
*/

src/firefly/js/tables/TablesCntlr.js

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -102,98 +102,6 @@ export const TABLE_UPDATE = `${DATA_PREFIX}.update`;
102102
export const TABLE_REPLACE = `${DATA_PREFIX}.replace`;
103103

104104

105-
/**
106-
* Top level store for table related data. It's mounted as 'table_space' under the application state
107-
* @typedef {object} TableSpace
108-
* @prop {Object.<string, TableModel>} data repository for table model; keyed by tbl_id
109-
* @prop {Object.<string, TableGroup>} results repository for table group information; keyed by tbl_group name
110-
* @prop {Object.<string, Object>} ui repository for table UI state; keyed by tbl_ui_id
111-
*/
112-
113-
114-
/**
115-
* Table model. The top level table data object with meta info.
116-
* @typedef {object} TableModel
117-
* @prop {string} tbl_id unique ID of this table.
118-
* @prop {string} title title, used on label.
119-
* @prop {TableRequest} request the request used to create this table
120-
* @prop {TableMeta} tableMeta table's meta information stored as key/value pair.
121-
* @prop {TableData} tableData table's meta information stored as key/value pair.
122-
* @prop {number} totalRows total number of rows.
123-
* @prop {number} highlightedRow the current highlighted row index. index is natural order starting from 0.
124-
* @prop {object} selectInfo selection information. use SelectInfo.newInstance take advantage of helper's functions.
125-
* @prop {boolean} isFetching true if data is being fetched and not ready for display.
126-
* @prop {string} error error message if the request fail to create a table.
127-
*/
128-
129-
/**
130-
* Table data. Table data object.
131-
* @typedef {object} TableData
132-
* @prop {TableColumn[]} columns table column definition.
133-
* @prop {string[][]} data 2D array containing the table data
134-
*/
135-
136-
/**
137-
* Table column information.
138-
* @typedef {object} TableColumn
139-
* @prop {string} name name of the column
140-
* @prop {string} label display name of the column
141-
* @prop {string} type data type
142-
* @prop {string} units data units
143-
* @prop {string} desc description of the column
144-
* @prop {number} width column display width
145-
* @prop {number} prefWidth preferred width. if width is not defined
146-
* @prop {boolean} sortable true if undefined
147-
* @prop {string} visibility show, hide, or hidden. hidden columns are not viewable by users.
148-
* @prop {string} sortByCols for multi-columns sorting. column names separated by comma(',').
149-
* @prop {string} related highlight related rows based on this column's value.
150-
*/
151-
152-
/**
153-
* Table meta information. Below is only a small set of predefined meta used by table.
154-
* The meta information in this object are used by many components for many reasons. ie catalog overlay.
155-
* @typedef {object} TableMeta
156-
* @prop {string} Loading-Status COMPLETED or INPROGRESS
157-
* @prop {string} tblFilePath path of the source of this table on the server-side.
158-
* @prop {string} isFullyLoaded 'true' when table is completely loaded on the server-side.
159-
* @prop {string} source path of the original table source before any operations were performed. ie sort, filter, etc. this may not be fully supported.
160-
*/
161-
162-
/**
163-
* Table request. Below is a list of predefined parameters available for table request. All of the options are optional.
164-
* These parameters let you control what data and how it will be returned.
165-
* @typedef {object} TableRequest
166-
* @prop {number} startIdx the starting index to fetch. defaults to zero.
167-
* @prop {number} pageSize the number of rows per page. defaults to 100.
168-
* @prop {string} filters list of conditions separted by comma(,). Format: (col_name|index) operator value.
169-
* operator is one of '> < = ! >= <= IN'. See DataGroupQueryStatement.java doc for more details.
170-
* @prop {string} sortInfo sort information. Format: (ASC|DESC),col_name[,col_name]*
171-
* @prop {string} inclCols list of columns to select. Column names separted by comma(,)
172-
* @prop {string} decimate decimation information.
173-
* @prop {object} META_INFO meta information passed as key/value pair to server then returned as tableMeta.
174-
* @prop {string} use one of 'catalog_overlay', 'catalog_primary', 'data_primary'.
175-
* @prop {string} tbl_id a unique id of a table. auto-create if not given.
176-
*/
177-
178-
/**
179-
* Table group. Define a group of tables used by the UI.
180-
* @typedef {Object} TableGroup
181-
* @prop {string} name unique name of this group
182-
* @prop {string} active tbl_id of the active table in this group
183-
* @prop {Object.<string, TableGroupItem>} tables a map of TableGroupItem(s) keyed by tbl_id
184-
*/
185-
186-
/**
187-
* Table group item. Contains enough key information to identify the table data as well as the UI data associate with this item.
188-
* @typedef {Object} TableGroupItem
189-
* @prop {string} tbl_group table group name
190-
* @prop {string} tbl_id unique id of the table data
191-
* @prop {string} tbl_ui_id unique id of the table's UI data
192-
* @prop {string} title title or label of the table
193-
* @prop {boolean} removable true if this item can be removed from group.
194-
* @prop {Object.<string, *>} options table options, ie. selectable, expandable
195-
*/
196-
197105

198106
/*---------------------------- CREATORS ----------------------------*/
199107

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* @global
3+
*/
4+
5+
/**
6+
* Top level store for table related data. It's mounted as 'table_space' under the application state
7+
* @typedef {object} TableSpace
8+
* @prop {Object.<string, TableModel>} data repository for table model; keyed by tbl_id
9+
* @prop {Object.<string, TableGroup>} results repository for table group information; keyed by tbl_group name
10+
* @prop {Object.<string, Object>} ui repository for table UI state; keyed by tbl_ui_id
11+
*/
12+
13+
14+
/**
15+
* Table model. The top level table data object with meta info.
16+
* @typedef {object} TableModel
17+
* @prop {string} tbl_id unique ID of this table.
18+
* @prop {string} title title, used on label.
19+
* @prop {TableRequest} request the request used to create this table
20+
* @prop {TableMeta} tableMeta table's meta information stored as key/value pair.
21+
* @prop {TableData} tableData table's meta information stored as key/value pair.
22+
* @prop {number} totalRows total number of rows.
23+
* @prop {number} highlightedRow the current highlighted row index. index is natural order starting from 0.
24+
* @prop {object} selectInfo selection information. use SelectInfo.newInstance take advantage of helper's functions.
25+
* @prop {boolean} isFetching true if data is being fetched and not ready for display.
26+
* @prop {string} error error message if the request fail to create a table.
27+
*/
28+
29+
/**
30+
* Table data. Table data object.
31+
* @typedef {object} TableData
32+
* @prop {TableColumn[]} columns table column definition.
33+
* @prop {string[][]} data 2D array containing the table data
34+
*/
35+
36+
/**
37+
* Table column information.
38+
* @typedef {object} TableColumn
39+
* @prop {string} name name of the column
40+
* @prop {string} label display name of the column
41+
* @prop {string} type data type
42+
* @prop {string} units data units
43+
* @prop {string} desc description of the column
44+
* @prop {number} width column display width
45+
* @prop {number} prefWidth preferred width. if width is not defined
46+
* @prop {boolean} sortable true if undefined
47+
* @prop {string} visibility show, hide, or hidden. hidden columns are not viewable by users.
48+
* @prop {string} sortByCols for multi-columns sorting. column names separated by comma(',').
49+
* @prop {string} related highlight related rows based on this column's value.
50+
*/
51+
52+
/**
53+
* Table meta information. Below is only a small set of predefined meta used by table.
54+
* The meta information in this object are used by many components for many reasons. ie catalog overlay.
55+
* @typedef {object} TableMeta
56+
* @prop {string} Loading-Status COMPLETED or INPROGRESS
57+
* @prop {string} tblFilePath path of the source of this table on the server-side.
58+
* @prop {string} isFullyLoaded 'true' when table is completely loaded on the server-side.
59+
* @prop {string} source path of the original table source before any operations were performed. ie sort, filter, etc. this may not be fully supported.
60+
*/
61+
62+
/**
63+
* Table request. Below is a list of predefined parameters available for table request. All of the options are optional.
64+
* These parameters let you control what data and how it will be returned.
65+
* @typedef {object} TableRequest
66+
* @prop {number} startIdx the starting index to fetch. defaults to zero.
67+
* @prop {number} pageSize the number of rows per page. defaults to 100.
68+
* @prop {string} filters list of conditions separted by comma(,). Format: (col_name|index) operator value.
69+
* operator is one of '> < = ! >= <= IN'. See DataGroupQueryStatement.java doc for more details.
70+
* @prop {string} sortInfo sort information. Format: (ASC|DESC),col_name[,col_name]*
71+
* @prop {string} inclCols list of columns to select. Column names separted by comma(,)
72+
* @prop {string} decimate decimation information.
73+
* @prop {object} META_INFO meta information passed as key/value pair to server then returned as tableMeta.
74+
* @prop {string} use one of 'catalog_overlay', 'catalog_primary', 'data_primary'.
75+
* @prop {string} tbl_id a unique id of a table. auto-create if not given.
76+
*/
77+
78+
/**
79+
* Table group. Define a group of tables used by the UI.
80+
* @typedef {Object} TableGroup
81+
* @prop {string} name unique name of this group
82+
* @prop {string} active tbl_id of the active table in this group
83+
* @prop {Object.<string, TableGroupItem>} tables a map of TableGroupItem(s) keyed by tbl_id
84+
*/
85+
86+
/**
87+
* Table group item. Contains enough key information to identify the table data as well as the UI data associate with this item.
88+
* @typedef {Object} TableGroupItem
89+
* @prop {string} tbl_group table group name
90+
* @prop {string} tbl_id unique id of the table data
91+
* @prop {string} tbl_ui_id unique id of the table's UI data
92+
* @prop {string} title title or label of the table
93+
* @prop {boolean} removable true if this item can be removed from group.
94+
* @prop {Object.<string, *>} options table options, ie. selectable, expandable
95+
*/
96+

src/firefly/js/templates/fireflyviewer/FireflyViewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {pickBy} from 'lodash';
1010
import {flux, firefly} from '../../Firefly.js';
1111
import {getMenu, isAppReady, dispatchSetMenu, dispatchOnAppReady} from '../../core/AppDataCntlr.js';
1212
import {LO_VIEW, getLayouInfo, SHOW_DROPDOWN} from '../../core/LayoutCntlr.js';
13-
import {layoutManager} from './FireflyLayoutManager.js';
13+
import {layoutManager} from './FireflyViewerManager.js';
1414
import {Menu} from '../../ui/Menu.jsx';
1515
import {Banner} from '../../ui/Banner.jsx';
1616
import {DropDownContainer} from '../../ui/DropDownContainer.jsx';

0 commit comments

Comments
 (0)