Skip to content

Commit

Permalink
Merge pull request #6 from carapai/master
Browse files Browse the repository at this point in the history
Some bug fixes and performance improvements
  • Loading branch information
carapai authored Sep 26, 2019
2 parents 5d79787 + 0846839 commit b561d54
Show file tree
Hide file tree
Showing 30 changed files with 1,206 additions and 633 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
"react-scripts": "3.0.1",
"react-select": "^3.0.4",
"shortid": "^2.2.14",
"source-map-explorer": "^2.1.0",
"xlsx": "^0.14.0"
},
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
"start": "react-app-rewired start",
"build": "react-app-rewired build && cd build && zip -r -D data-import-wizard.zip .",
"test": "react-app-rewired test",
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.webapp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"appType": "APP",
"name": "Data Import Wizard",
"version": "1.0.3",
"version": "1.0.4",
"description": "Data Importer Wizard",
"icons": {
"48": "favicon.ico"
Expand Down
1 change: 1 addition & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class App extends Component {
d2.i18n.translations['last'] = 'Last Run';
d2.i18n.translations['next'] = 'Next Run';
d2.i18n.translations['created'] = 'Created';
d2.i18n.translations['import'] = 'Import Data';

this.state = {
d2,
Expand Down
15 changes: 15 additions & 0 deletions src/components/Loading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import React from 'react';
import { Spin } from 'antd';
const Loading = () => <div style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
width: '100vw',
height: '100vh'
}}>
<Spin size="large" />
</div>;

export default Loading;
126 changes: 126 additions & 0 deletions src/components/aggregate/ImportSummary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import { inject, observer } from "mobx-react";
import React from "react";
import { withStyles } from "@material-ui/core/styles";
import TableHead from "@material-ui/core/TableHead/TableHead";
import TableRow from "@material-ui/core/TableRow/TableRow";
import TableCell from "@material-ui/core/TableCell/TableCell";
import TableBody from "@material-ui/core/TableBody/TableBody";
import * as PropTypes from "prop-types";
import Typography from "@material-ui/core/Typography";
import MUITable from "@material-ui/core/Table";
import { Table } from 'antd';


const columns = [
{ title: 'Affected', dataIndex: 'object', key: 'object' },
{ title: 'Message', dataIndex: 'value', key: 'value' }
];


const styles = theme => ({
margin: {
margin: theme.spacing.unit * 2,
},
padding: {
padding: `0 ${theme.spacing.unit * 2}px`,
},
root: {
flexGrow: 1,
width: '100%',
backgroundColor: theme.palette.background.paper,
}
});

function TabContainer(props) {
return (
<Typography component="div" style={{ padding: 8 * 3 }}>
{props.children}
</Typography>
);
}

TabContainer.propTypes = {
children: PropTypes.node.isRequired,
};


@inject('IntegrationStore')
@observer
class ImportSummary extends React.Component {
integrationStore = null;

constructor(props) {
super(props);
const { IntegrationStore } = props;
this.integrationStore = IntegrationStore;
this.state = {
value: this.integrationStore.dataSet.isDhis2 ? 1 : 0,
};
}


handleChange = (event, value) => {
this.setState({ value });
};

render() {
const { classes } = this.props;
const { importCount, conflicts } = this.integrationStore.dataSet.processedResponses;
return <div className={classes.root}>
<MUITable>
<TableHead>
<TableRow>
<TableCell>Message</TableCell>
<TableCell>Value</TableCell>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell>
Imported
</TableCell>
<TableCell>
{importCount.imported}
</TableCell>
</TableRow>
<TableRow>
<TableCell>
Updated
</TableCell>
<TableCell>
{importCount.updated}
</TableCell>
</TableRow>
<TableRow>
<TableCell>
Ignored
</TableCell>
<TableCell>
{importCount.ignored}
</TableCell>
</TableRow>
<TableRow>
<TableCell>
Deleted
</TableCell>
<TableCell>
{importCount.deleted}
</TableCell>
</TableRow>
</TableBody>
</MUITable>
<h4>Conflicts</h4>

<Table
columns={columns}
size="small"
rowKey="id"
pagination={{ defaultPageSize: 5 }}
dataSource={conflicts}
/>
</div>
}

}

export default withStyles(styles)(ImportSummary);
34 changes: 15 additions & 19 deletions src/components/aggregate/Summary.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {inject, observer} from "mobx-react";
import { inject, observer } from "mobx-react";
import React from "react";
import {withStyles} from "@material-ui/core/styles";
import { withStyles } from "@material-ui/core/styles";
import TableHead from "@material-ui/core/TableHead/TableHead";
import TableRow from "@material-ui/core/TableRow/TableRow";
import TableCell from "@material-ui/core/TableCell/TableCell";
Expand All @@ -12,12 +12,12 @@ import Tabs from "@material-ui/core/Tabs";
import Tab from "@material-ui/core/Tab";
import D4 from "./d4";
import MUITable from "@material-ui/core/Table";
import {Table} from 'antd';
import { Table } from 'antd';


const columns = [
{title: 'Affected', dataIndex: 'object', key: 'object'},
{title: 'Message', dataIndex: 'value', key: 'value'}
{ title: 'Affected', dataIndex: 'object', key: 'object' },
{ title: 'Message', dataIndex: 'value', key: 'value' }
];


Expand All @@ -37,7 +37,7 @@ const styles = theme => ({

function TabContainer(props) {
return (
<Typography component="div" style={{padding: 8 * 3}}>
<Typography component="div" style={{ padding: 8 * 3 }}>
{props.children}
</Typography>
);
Expand All @@ -55,24 +55,22 @@ class Summary extends React.Component {

constructor(props) {
super(props);
const {IntegrationStore} = props;
const { IntegrationStore } = props;
this.integrationStore = IntegrationStore;

this.state = {
value: this.integrationStore.dataSet.isDhis2 ? 1 : 0,
};

}


handleChange = (event, value) => {
this.setState({value});
this.setState({ value });
};

render() {
const {classes} = this.props;
const {value} = this.state;
const {importCount, conflicts} = this.integrationStore.dataSet.processedResponses;
const { classes } = this.props;
const { value } = this.state;
const { importCount, conflicts } = this.integrationStore.dataSet.processedResponses;

return <div className={classes.root}>
<AppBar position="static" color="primary">
Expand All @@ -84,15 +82,13 @@ class Summary extends React.Component {
indicatorColor="secondary"
textColor="inherit"
>
<Tab label="Data"/>
<Tab label="Summary"/>
<Tab label="Data" />
<Tab label="Summary" />
</Tabs>
</AppBar>

{value === 0 && <TabContainer>

{this.integrationStore.dataSet.isDhis2 ? <div>{''}</div> : <D4/>}

{this.integrationStore.dataSet.isDhis2 ? <div></div> : this.integrationStore.dataSet.processed ? <D4 /> : <div></div>}
</TabContainer>}
{value === 1 && <TabContainer>

Expand Down Expand Up @@ -145,7 +141,7 @@ class Summary extends React.Component {
columns={columns}
size="small"
rowKey="id"
pagination={{defaultPageSize: 5}}
pagination={{ defaultPageSize: 5 }}
dataSource={conflicts}
/>
</TabContainer>}
Expand Down
59 changes: 59 additions & 0 deletions src/components/aggregate/SummaryPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { inject, observer } from "mobx-react";
import React from "react";
import { withStyles } from "@material-ui/core/styles";
import * as PropTypes from "prop-types";
import Typography from "@material-ui/core/Typography";
import D4 from "./d4";
import ImportSummary from './ImportSummary';

const styles = theme => ({
margin: {
margin: theme.spacing.unit * 2,
},
padding: {
padding: `0 ${theme.spacing.unit * 2}px`,
},
root: {
flexGrow: 1,
width: '100%',
backgroundColor: theme.palette.background.paper,
}
});

function TabContainer(props) {
return (
<Typography component="div" style={{ padding: 8 * 3 }}>
{props.children}
</Typography>
);
}

TabContainer.propTypes = {
children: PropTypes.node.isRequired,
};


@inject('IntegrationStore')
@observer
class SummaryPage extends React.Component {
integrationStore = null;

constructor(props) {
super(props);
const { IntegrationStore } = props;
this.integrationStore = IntegrationStore;
this.state = {
value: this.integrationStore.dataSet.isDhis2 ? 1 : 0,
};
}

render() {
const { classes } = this.props;
return <div className={classes.root}>
{this.integrationStore.dataSet.isDhis2 ? <ImportSummary /> : this.integrationStore.dataSet.processed ? <D4 /> : <div></div>}
</div>
}

}

export default withStyles(styles)(SummaryPage);
Loading

0 comments on commit b561d54

Please sign in to comment.