Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
fix(Time Series): corrects bug where dataset uploads were not correctly
Browse files Browse the repository at this point in the history
setting the start/end uuids.
-corrects bug with File import not respecting control settings
closes #277
  • Loading branch information
rashley-iqt committed Apr 4, 2019
1 parent 7fc3848 commit 5713d2b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
7 changes: 4 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class App extends Component {
const uniqueUuids = datasetAdded || nextProps.uuids.length === 0
? Array.from(new Set(nextProps.uuids.concat(this.state.uuids)))
: nextProps.uuids;
const startUuid = nextProps.startUuid || this.state.startUuid || uniqueUuids[0];
const startUuid = nextProps.startUuid || this.state.startUuid;
const endUuid = nextProps.endUuid || this.state.endUuid;
this.setState({
uuids: uniqueUuids,
Expand Down Expand Up @@ -166,7 +166,7 @@ class App extends Component {
const ignoredFields = this.state.options.data && this.props.ignoredFields;
const exportData = getDataToExport(datasets, keyFields, ignoredFields, controls)
const urlObject = window.URL || window.webkitURL || window;
const json = JSON.stringify(exportData);
const json = JSON.stringify(exportData, null, 2);
const blob = new Blob([json], {'type': "application/json"});
const url = urlObject.createObjectURL(blob);;
return url;
Expand Down Expand Up @@ -262,7 +262,7 @@ class App extends Component {
<div key={ uuid } >
<div className={style.dataControlHeader}>
Series {index}
{index > 0 && <FontAwesomeIcon icon={faMinusCircle} onClick={ () => {this.removeDatasetEntry(uuid)}} />}
{uuids.length > 1 && <FontAwesomeIcon icon={faMinusCircle} onClick={ () => {this.removeDatasetEntry(uuid)}} />}
</div>
<DatasetControls uuid={ uuid } datasets={ datasets }/>
</div>
Expand Down Expand Up @@ -447,6 +447,7 @@ const mapStateToProps = state => {
const uuids = Object.keys(datasets) || [uuidv4()];
const dataset = datasets[uuids[0]] && datasets[uuids[0]].dataset ? datasets[uuids[0]].dataset : [];
const controls = selectControls(state);

return {
dataset: dataset,
darkTheme: controls.darkTheme,
Expand Down
6 changes: 3 additions & 3 deletions src/domain/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const reducer = handleActions(
const hierarchyConfig = payload.hierarchyConfig || defaultState.hierarchyConfig;
const shouldShowNodes = ('shouldShowNodes' in payload) ? !!payload.shouldShowNodes : true;
const darkTheme = ('darkTheme' in payload) ? !!payload.darkTheme : false;
const colorBy = payload.colorBy || defaultState.colorBy
const start = payload.start || defaultState.start
const end = payload.end || defaultState.end
const colorBy = payload.colorBy || defaultState.colorBy;
const start = payload.start || state.start;
const end = payload.end || state.end;
return {
...state,
hierarchyConfig: hierarchyConfig,
Expand Down
9 changes: 6 additions & 3 deletions src/epics/upload-dataset-epic.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const uploadDatasetEpic = (action$, store) => {
mergeMap((action) => {
const owner = action.payload.owner;
const file = action.payload.file;
return fromReader(owner, file).pipe(
const includeData = ('includeData' in action.payload) ? action.payload.includeData : true;
const includeControls = ('includeControls' in action.payload) ? action.payload.includeControls: false;
return fromReader(owner, includeData, includeControls, file).pipe(
debounceTime(500)
,map(CSVconvert)
,map(fromJson)
Expand All @@ -39,13 +41,14 @@ const uploadDatasetEpic = (action$, store) => {
* Little function to create an observable to read local files.
* RxJS DOM v5 doesn't have it!?
*/
const fromReader = (owner, file) => {
const fromReader = (owner, includeData, includeControls, file) => {
return Observable.create((observer) => {
const source = file.name;
const reader = new window.FileReader();

reader.addEventListener('load', () => {
observer.next({ 'owner': owner, 'source': source, 'file': reader.result });
observer.next({ 'owner': owner, 'source': source, 'includeData':includeData,
'includeControls': includeControls, 'file': reader.result });
observer.complete();
});

Expand Down
26 changes: 22 additions & 4 deletions src/features/dataset-controls/DatasetControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { fetchDataset, buildAuthHeader } from "epics/fetch-dataset-epic";
import { startRefresh, stopRefresh } from "epics/refresh-dataset-epic";
import { uploadDataset } from "epics/upload-dataset-epic";
import { removeSearchIndex } from "epics/index-dataset-epic";
import { showNodes, setHierarchyConfig, colorBy, selectControls } from "domain/controls"
import {
showNodes, setHierarchyConfig, colorBy, selectControls, setStartDataset, setEndDataset
} from "domain/controls"

import { setError } from "domain/error"
import {
Expand Down Expand Up @@ -109,7 +111,7 @@ class DatasetControls extends React.Component {
if (isNil(dataset)) {
return this.resetDataset();
}
console.log(dataset);

this.props.removeDataset({owner: this.props.uuid});
this.props.removeSearchIndex({owner: this.props.uuid});
this.props.stopRefresh();
Expand All @@ -133,9 +135,9 @@ class DatasetControls extends React.Component {
{
const url = dataset.url;
this.fetchAndSetDataset(url, dataset, null, null, null);
this.setStartOrEnd(this.props.uuid);
}

console.log(this.state.selected);
}

onUpload = (file) => {
Expand Down Expand Up @@ -170,6 +172,7 @@ class DatasetControls extends React.Component {
const url = this.state.url;
dataset.url = url;
this.fetchAndSetDataset(url, dataset, this.state.username, this.state.password, this.state.token);
this.setStartOrEnd(this.props.uuid);
}
}

Expand All @@ -196,9 +199,20 @@ class DatasetControls extends React.Component {
this.setState({
showUpload: false,
});

this.setStartOrEnd(this.props.uuid);
}
}

setStartOrEnd = (uuid) =>{
if(!this.props.controls.start){
this.props.setStartDataset(uuid);
}
else if(!this.props.controls.end){
this.props.setEndDataset(uuid);
}
}

onUploadCancel = () => {
this.setState({
selectedFile: null,
Expand All @@ -212,7 +226,7 @@ class DatasetControls extends React.Component {
const keyFields = this.props.keyFields;
const ignoredFields = this.props.ignoredFields;
const urlObject = window.URL || window.webkitURL || window;
const json = JSON.stringify(getDataToExport(datasets, keyFields, ignoredFields, controls));
const json = JSON.stringify(getDataToExport(datasets, keyFields, ignoredFields, controls), null, 2);
const blob = new Blob([json], {'type': "application/json"});
const url = urlObject.createObjectURL(blob);;
return url;
Expand Down Expand Up @@ -454,6 +468,8 @@ DatasetControls.propTypes = {
fetchDataset: PropTypes.func.isRequired,
uploadDataset: PropTypes.func.isRequired,
setDataset: PropTypes.func.isRequired,
setStartDataset: PropTypes.func.isRequired,
setEndDataset: PropTypes.func.isRequired,
removeDataset: PropTypes.func.isRequired,
removeSearchIndex: PropTypes.func.isRequired,
getIsFetching: PropTypes.func.isRequired,
Expand Down Expand Up @@ -493,6 +509,8 @@ const mapDispatchToProps = {
fetchDataset,
uploadDataset,
setDataset,
setStartDataset,
setEndDataset,
selectDataset,
removeDataset,
removeSearchIndex,
Expand Down
6 changes: 0 additions & 6 deletions src/features/visualization/d3-viz/append-circles.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ const scaleAndTrimToLabelWidth = (node, datum, initialFontScale) => {
if ((boxHeight > maxTextHeight)){
const heightScale = 1-Math.abs((boxHeight - maxTextHeight)/boxHeight);
fontScale = Math.max(minFontScale, heightScale * initialFontScale);
if (datum.data.fieldValue === "File server"){
console.log("boxHeight: %o", boxHeight);
console.log("maxTextHeight: %o", maxTextHeight);
console.log("initialFontScale: %o", initialFontScale);
console.log("fontScale: %o", fontScale);
}
select(node)
.style('font-size', (d, i, nodes) => fontScale + "%")
.text(labelText);
Expand Down
2 changes: 1 addition & 1 deletion src/features/visualization/d3-viz/setup-legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const colorAnnotations = ({ annotations, colorMap, getValue, coloredField, isCol
.select(`g.${className("total-container")}`)
.attr('class', (d) => {
const { disabled, className } = colorMap[getValue(d.data)] || {};
console.log(className)

return isColoringGroup
&& equals(d.data.field, coloredField)
&& !disabled
Expand Down

0 comments on commit 5713d2b

Please sign in to comment.