Skip to content

DM-8005 Create phase folding parameter setting panel and move the phase folding algorithm to the client side #220

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 4 commits into from
Nov 7, 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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"validator": "4.5.0",
"whatwg-fetch": "0.10.1",
"react-color": "2.2.6",
"shallowequal": "0.2.2"
"shallowequal": "0.2.2",
"rc-slider": "5.1.3"
},
"devDependencies": {
"postcss-loader": "^0.11.1",
Expand Down
8 changes: 5 additions & 3 deletions src/firefly/js/charts/ChartsCntlr.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const FIRST_CDEL_ID = '0'; // first data element id (if missing)
* @function dispatchChartAdd
* @memberof firefly.action
*/
export function dispatchChartAdd({chartId, chartType, chartDataElements, groupId='main', deletable, help_id, mounted=0, dispatcher= flux.process}) {
export function dispatchChartAdd({chartId, chartType, chartDataElements, groupId='main', deletable, help_id, mounted=undefined, dispatcher= flux.process}) {
dispatcher({type: CHART_ADD, payload: {chartId, chartType, chartDataElements, groupId, deletable, help_id, mounted}});
}

Expand Down Expand Up @@ -370,11 +370,13 @@ function reduceData(state={}, action={}) {
switch (action.type) {
case (CHART_ADD) :
{
const {chartId, chartType, chartDataElements, ...rest} = action.payload;

const {chartId, chartType, chartDataElements, mounted, ...rest} = action.payload;
// if a chart is replaced (added with the same id) mounted should not change
const nMounted = isUndefined(mounted) ? get(state, [chartId, 'mounted']) : mounted;
state = updateSet(state, chartId,
omitBy({
chartType,
mounted: nMounted,
chartDataElements: chartDataElementsToObj(chartDataElements),
...rest
}, isUndefined));
Expand Down
9 changes: 2 additions & 7 deletions src/firefly/js/core/ReduxFlux.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ImagePlotCntlr from '../visualize/ImagePlotCntlr.js';
import ExternalAccessCntlr from './ExternalAccessCntlr.js';
import * as TableStatsCntlr from '../charts/TableStatsCntlr.js';
import * as ChartsCntlr from '../charts/ChartsCntlr.js';
import * as TablesCntlr from '../tables/TablesCntlr';
import TablesCntlr from '../tables/TablesCntlr';

import {chartTypeFactory} from '../charts/ChartType.js';
import {SCATTER_TBLVIEW} from '../charts/chartTypes/ScatterTblView.jsx';
Expand Down Expand Up @@ -137,6 +137,7 @@ registerCntlr(BackgroundCntlr);
registerCntlr(ImagePlotCntlr);
registerCntlr(FieldGroupCntlr);
registerCntlr(MouseReadoutCntlr);
registerCntlr(TablesCntlr);
registerCntlr(DrawLayerCntlr.getDrawLayerCntlrDef(drawLayerFactory));


Expand All @@ -148,12 +149,6 @@ actionCreators.set(AppDataCntlr.GRAB_WINDOW_FOCUS, AppDataCntlr.grabWindowFocus)
actionCreators.set(AppDataCntlr.HELP_LOAD, AppDataCntlr.onlineHelpLoad);
actionCreators.set(ExternalAccessCntlr.EXTENSION_ACTIVATE, ExternalAccessCntlr.extensionActivateActionCreator);

actionCreators.set(TablesCntlr.TABLE_SEARCH, TablesCntlr.tableSearch);
actionCreators.set(TablesCntlr.TABLE_FETCH, TablesCntlr.tableFetch);
actionCreators.set(TablesCntlr.TABLE_SORT, TablesCntlr.tableFetch);
actionCreators.set(TablesCntlr.TABLE_FILTER, TablesCntlr.tableFetch);
actionCreators.set(TablesCntlr.TABLE_HIGHLIGHT, TablesCntlr.highlightRow);

actionCreators.set(TableStatsCntlr.LOAD_TBL_STATS, TableStatsCntlr.loadTblStats);
actionCreators.set(ChartsCntlr.CHART_DATA_FETCH, ChartsCntlr.makeChartDataFetch(cdtFactory.getChartDataType));
actionCreators.set(ChartsCntlr.CHART_OPTIONS_REPLACE, ChartsCntlr.makeChartOptionsReplace(cdtFactory.getChartDataType));
Expand Down
11 changes: 7 additions & 4 deletions src/firefly/js/rpc/SearchServicesJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ export function fetchTable(tableRequest, hlRowIdx) {
}

/**
*
* @param {Object} params
* returns the values of the data from the given parameters
* @param {Object} p parameters object
* @param {string} p.columnName name of the column
* @param {string} p.filePath location of the file on the server
* @param {string} p.selectedRows a comma-separated string of indices of the rows to get the data from
* @return {Promise}
*/
export const selectedValues = function(params) {
return doService(doJsonP(), ServerParams.SELECTED_VALUES, params)
export const selectedValues = function({columnName, filePath, selectedRows}) {
return doService(doJsonP(), ServerParams.SELECTED_VALUES, {columnName, filePath, selectedRows})
.then((data) => {
// JsonUtil may not interpret array values correctly due to error-checking.
// returning array as a prop 'values' inside an object instead.
Expand Down
14 changes: 8 additions & 6 deletions src/firefly/js/tables/FilterInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,20 @@ export class FilterInfo {
compareTo = Number(compareTo);
}
switch (op) {
case 'like' :
return compareTo.includes(val);
case '>' :
return compareTo > val;
case '<' :
return compareTo < val;
case '=' :
return compareTo === val;
case '!=' :
return compareTo !== val;
case '>=' :
return compareTo >= val;
case '<=' :
return compareTo <= val;
case '>' :
return compareTo > val;
case '=' :
return compareTo === val;
case 'like' :
return compareTo.includes(val);
case 'in' :
return val.includes(compareTo);
default :
Expand Down
79 changes: 26 additions & 53 deletions src/firefly/js/tables/TableConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,47 @@
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/

import {isEmpty, omitBy, isUndefined, cloneDeep, get} from 'lodash';
import {flux} from '../Firefly.js';
import {isEmpty, omitBy, isUndefined, cloneDeep, get, set} from 'lodash';
import * as TblCntlr from './TablesCntlr.js';
import * as TblUtil from './TableUtil.js';
import {SelectInfo} from './SelectInfo.js';
import {FilterInfo} from './FilterInfo.js';
import {selectedValues} from '../rpc/SearchServicesJson.js';

export class TableConnector {

constructor(tbl_id, tbl_ui_id, tableModel, showUnits=true, showFilters=false, pageSize) {
this.tbl_id = tbl_id;
this.tbl_id = tbl_id || tableModel.tbl_id;
this.tbl_ui_id = tbl_ui_id;
this.localTableModel = tableModel;
this.tableModel = tableModel;

this.origPageSize = pageSize;
this.origShowUnits = showUnits;
this.origShowFilters = showFilters;
}

onSort(sortInfoString) {
var {tableModel, request} = TblUtil.getTblInfoById(this.tbl_id);
if (this.localTableModel) {
tableModel = TblUtil.sortTable(this.localTableModel, sortInfoString);
TblCntlr.dispatchTableReplace(tableModel);
} else {
request = Object.assign({}, request, {sortInfo: sortInfoString});
TblCntlr.dispatchTableSort(request);
onMount() {
const {tbl_ui_id, tbl_id, tableModel} = this;
if (!TblUtil.getTableUiByTblId(tbl_id)) {
TblCntlr.dispatchTableUiUpdate({tbl_ui_id, tbl_id});
if (tableModel && !tableModel.origTableModel) {
set(tableModel, 'request.tbl_id', tbl_id);
const workingTableModel = cloneDeep(tableModel);
workingTableModel.origTableModel = tableModel;
TblCntlr.dispatchTableInsert(workingTableModel, undefined, false);
}
}
}

onSort(sortInfoString) {
var {request} = TblUtil.getTblInfoById(this.tbl_id);
request = Object.assign({}, request, {sortInfo: sortInfoString});
TblCntlr.dispatchTableSort(request);
}

onFilter(filterIntoString) {
var {tableModel, request} = TblUtil.getTblInfoById(this.tbl_id);
if (this.localTableModel) {
tableModel = filterIntoString ? TblUtil.filterTable(this.localTableModel, filterIntoString) : this.localTableModel;
TblCntlr.dispatchTableReplace(tableModel);
} else {
request = Object.assign({}, request, {filters: filterIntoString});
TblCntlr.dispatchTableFilter(request);
}
var {request} = TblUtil.getTblInfoById(this.tbl_id);
request = Object.assign({}, request, {filters: filterIntoString});
TblCntlr.dispatchTableFilter(request);
}

/**
Expand All @@ -50,24 +51,8 @@ export class TableConnector {
*/
onFilterSelected(selected) {
if (isEmpty(selected)) return;

var {tableModel, request} = TblUtil.getTblInfoById(this.tbl_id);
if (this.localTableModel) {
// not implemented yet
} else {
const filterInfoCls = FilterInfo.parse(request.filters);
const filePath = get(tableModel, 'tableMeta.tblFilePath');
if (filePath) {
getRowIdFor(filePath, selected).then( (selectedRowIdAry) => {
const value = selectedRowIdAry.reduce((rv, val, idx) => {
return rv + (idx ? ',':'') + val;
}, 'IN (') + ')';
filterInfoCls.addFilter('ROWID', value);
request = Object.assign({}, request, {filters: filterInfoCls.serialize()});
TblCntlr.dispatchTableFilter(request);
});
}
}
const {request} = TblUtil.getTblInfoById(this.tbl_id);
TblCntlr.dispatchTableFilterSelrow(request, selected);
}

onPageSizeChange(nPageSize) {
Expand All @@ -92,12 +77,7 @@ export class TableConnector {
const {hlRowIdx, startIdx} = TblUtil.getTblInfoById(this.tbl_id);
if (rowIdx !== hlRowIdx) {
const highlightedRow = startIdx + rowIdx;
if (this.localTableModel) {
const tableModel = {tbl_id: this.tbl_id, highlightedRow};
flux.process({type: TblCntlr.TABLE_UPDATE, payload: tableModel});
} else {
TblCntlr.dispatchTableHighlight(this.tbl_id, highlightedRow);
}
TblCntlr.dispatchTableHighlight(this.tbl_id, highlightedRow);
}
}

Expand Down Expand Up @@ -142,7 +122,7 @@ export class TableConnector {
}

onOptionReset() {
const ctable = this.localTableModel || TblUtil.getTblById(this.tbl_id);
const ctable = TblUtil.getTblById(this.tbl_id);
var filterInfo = get(ctable, 'request.filters', '').trim();
filterInfo = filterInfo !== '' ? '' : undefined;
const pageSize = get(ctable, 'request.pageSize') !== this.origPageSize ? this.origPageSize : undefined;
Expand All @@ -157,10 +137,3 @@ export class TableConnector {
}
}


function getRowIdFor(filePath, selected) {
if (isEmpty(selected)) return [];

const params = {id: 'Table__SelectedValues', columnName: 'ROWID', filePath, selectedRows: String(selected)};
return selectedValues(params);
}
Loading