Skip to content

Commit

Permalink
refresh panel option now working
Browse files Browse the repository at this point in the history
  • Loading branch information
benkeen committed Feb 8, 2020
1 parent 7a1625c commit ca9b055
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Coverage Status](https://coveralls.io/repos/github/benkeen/generatedata/badge.svg?branch=master)](https://coveralls.io/github/benkeen/generatedata?branch=master)

This is the repo for the downloadable version of [generatedata.com](http://www.generatedata.com). The
script is basically an *engine* to generate any sort of random data in any format. It currently comes with 30 or
script is essentially an *engine* to generate any sort of random data in any format. It currently comes with 30 or
so *Data Types* (types of data it generates), 8 *Export Types* (formats for the data), plus around 30 data sets for specific countries (city names, regions etc). But more importantly it can be extended in any way you want. Check out the [developer documentation](http://benkeen.github.io/generatedata/developer.html)
for more information on that. If you need to generate random data programmatically rather than manually via the UI, you can use the [REST API](http://benkeen.github.io/generatedata/api.html).

Expand Down
26 changes: 13 additions & 13 deletions src/core/generator/generator.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const onSelectDataType = (id: string, dataType: string): any => {
});
});

// now regenerate the whole data set again (this could be smarter once we figure out dependencies)
// now regenerate the whole data set again (this has to be smarter once we figure out dependencies)
const data = generateExportData({
numResults: selectors.getNumPreviewRows(state),
columnTitles: selectors.getColumnTitles(state),
Expand Down Expand Up @@ -101,31 +101,31 @@ export const toggleGrid = (): GDAction => ({ type: TOGGLE_GRID });
export const TOGGLE_PREVIEW = 'TOGGLE_PREVIEW';
export const togglePreview = (): GDAction => ({ type: TOGGLE_PREVIEW });

export const REFRESH_PREVIEW = 'REFRESH_PREVIEW';
export const REFRESH_PREVIEW_DATA = 'REFRESH_PREVIEW_DATA';
export const refreshPreview = (): any => {

return (dispatch: any, getState: any): any => {
const state = getState();
const template = selectors.getGenerationTemplate(state);
const sortedRows = selectors.getSortedRows(state);

const data = generateExportData({
numResults: selectors.getNumPreviewRows(state),
columnTitles: selectors.getColumnTitles(state),
template
});

console.log('!!!', data);
const previewData: any = {};
sortedRows.forEach((id: string, index: number) => {
previewData[id] = data.rows.map((row: any): any => row[index]);
});

// now update the store in one go
// dispatch({
// type: SELECT_DATA_TYPE,
// payload: {
// id,
// value: dataType,
// data: dataTypeDefaultState,
// generatedPreviewData
// }
// });
dispatch({
type: REFRESH_PREVIEW_DATA,
payload: {
previewData
}
});
};
};

Expand Down
7 changes: 7 additions & 0 deletions src/core/generator/generator.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ export const reducer = (state: ReducerState = {
};
}

case actions.REFRESH_PREVIEW_DATA: {
return {
...state,
generatedPreviewData: action.payload.previewData
};
};

case actions.CONFIGURE_DATA_TYPE:
return {
...state,
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,7 @@ export default {
"grid": "Grid",
"preview": "Preview",
no_data: "No data!",
add_some_data_desc: 'Add some rows in the Grid panel above'
add_some_data_desc: 'Add some rows in the Grid panel above',
refresh_panel: 'Refresh Panel',
close_panel: 'Close panel'
};

0 comments on commit ca9b055

Please sign in to comment.