Commit 5a38bcb2 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '102-admin-kpi-inteface' into 'master'

Resolve "Admin KPI Inteface"

Closes #102

See merge request genesys-pgr/genesys-ui!106
parents 260ebb08 507fb86f
...@@ -66,7 +66,9 @@ export default function admin(state = INITIAL_STATE, action: IReducerAction) { ...@@ -66,7 +66,9 @@ export default function admin(state = INITIAL_STATE, action: IReducerAction) {
[receivedIndex]: {$set: execution}, [receivedIndex]: {$set: execution},
}, },
}, },
details: {$set: execution}, details: {
execution: {$set: execution},
},
}, },
}); });
} else { } else {
...@@ -75,7 +77,9 @@ export default function admin(state = INITIAL_STATE, action: IReducerAction) { ...@@ -75,7 +77,9 @@ export default function admin(state = INITIAL_STATE, action: IReducerAction) {
page: { page: {
content: {$push: [execution]}, content: {$push: [execution]},
}, },
details: {$set: execution}, details: {
execution: {$set: execution},
},
}, },
}); });
} }
......
...@@ -41,6 +41,9 @@ interface IDashboardProps extends React.ClassAttributes<any> { ...@@ -41,6 +41,9 @@ interface IDashboardProps extends React.ClassAttributes<any> {
class Dashboard extends React.Component<IDashboardProps, any> { class Dashboard extends React.Component<IDashboardProps, any> {
protected static needs = [ protected static needs = [
({}) => listExecutions({}),
({}) => listParameters({}),
({}) => listDimensions({}),
]; ];
public componentWillMount() { public componentWillMount() {
...@@ -76,15 +79,15 @@ class Dashboard extends React.Component<IDashboardProps, any> { ...@@ -76,15 +79,15 @@ class Dashboard extends React.Component<IDashboardProps, any> {
{ stillLoading && <Loading /> } { stillLoading && <Loading /> }
<h5>{ t(`kpi.admin.p.dashboard.KPIExecutions`) }</h5> <h5>{ t(`kpi.admin.p.dashboard.KPIExecutions`) }</h5>
{ execs && execs.content.map((exec, i) => ( { execs && execs.content && execs.content.map((exec, i) => (
<ExecutionCard key={ exec.id } index={ i } execution={ exec } compact style={ {marginBottom: '8px'} }/> <ExecutionCard key={ exec.id } index={ i } execution={ exec } compact style={ {marginBottom: '8px'} }/>
)) } )) }
<h5>{ t(`kpi.admin.p.dashboard.KPIParameters`) }</h5> <h5>{ t(`kpi.admin.p.dashboard.KPIParameters`) }</h5>
{ params && params.content.map((param, i) => ( { params && params.content && params.content.map((param, i) => (
<ParameterCard key={ param.id } parameter={ param } index={ i } style={ {marginBottom: '8px'} }/> <ParameterCard key={ param.id } parameter={ param } index={ i } style={ {marginBottom: '8px'} }/>
)) } )) }
<h5>{ t(`kpi.admin.p.dashboard.KPIDimensions`) }</h5> <h5>{ t(`kpi.admin.p.dashboard.KPIDimensions`) }</h5>
{ dims && dims.content.map((dim, i) => ( { dims && dims.content && dims.content.map((dim, i) => (
<DimensionCard key={ dim.id } dimension={ dim } index={ i } style={ {marginBottom: '8px'} }/> <DimensionCard key={ dim.id } dimension={ dim } index={ i } style={ {marginBottom: '8px'} }/>
)) } )) }
</Grid> </Grid>
......
...@@ -54,6 +54,7 @@ class ExecutionDialog extends React.Component<IExecutionDialogProps, any> { ...@@ -54,6 +54,7 @@ class ExecutionDialog extends React.Component<IExecutionDialogProps, any> {
private handleSubmit = (execution: any) => { private handleSubmit = (execution: any) => {
const {saveExecution} = this.props; const {saveExecution} = this.props;
execution.parameter = typeof execution.parameter === 'string' ? JSON.parse(execution.parameter) : execution.parameter;
saveExecution(execution); saveExecution(execution);
this.setState({open: false}); this.setState({open: false});
} }
...@@ -64,10 +65,10 @@ class ExecutionDialog extends React.Component<IExecutionDialogProps, any> { ...@@ -64,10 +65,10 @@ class ExecutionDialog extends React.Component<IExecutionDialogProps, any> {
<span> <span>
<Button className={ classes.createButton } onClick={ this.show } variant={ variant }>{ buttonLabel || t(`kpi.admin.p.executionDialog.button`) }</Button> <Button className={ classes.createButton } onClick={ this.show } variant={ variant }>{ buttonLabel || t(`kpi.admin.p.executionDialog.button`) }</Button>
{ this.state.open && { this.state.open &&
<Dialog open={ this.state.open } onClose={ this.hide } maxWidth="md" fullWidth disableEnforceFocus> <Dialog open={ this.state.open } onClose={ this.hide } maxWidth="md" fullWidth>
<DialogTitle>{ t(`kpi.admin.p.executionDialog.title`) }</DialogTitle> <DialogTitle>{ t(`kpi.admin.p.executionDialog.title`) }</DialogTitle>
<DialogContent> <DialogContent>
<ExecutionForm nameDisabled={ execution && execution.name } onCancel={ this.hide } onSubmit={ this.handleSubmit } initialValues={ execution }/> <ExecutionForm t={ t } nameDisabled={ execution && execution.name } onCancel={ this.hide } onSubmit={ this.handleSubmit } initialValues={ execution }/>
</DialogContent> </DialogContent>
</Dialog> </Dialog>
} }
...@@ -84,4 +85,4 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({ ...@@ -84,4 +85,4 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
saveExecution, saveExecution,
}, dispatch); }, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)<any>(translate()(ExecutionDialog))); export default translate()(connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(ExecutionDialog)));
...@@ -3,7 +3,7 @@ import { connect } from 'react-redux'; ...@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { translate } from 'react-i18next'; import { translate } from 'react-i18next';
// Actions // Actions
import { deleteExecution, executeExecution, getExecution } from 'kpi/actions/admin'; import { deleteExecution, executeExecution, getExecution, listDimensions, listParameters } from 'kpi/actions/admin';
// Models // Models
import ExecutionDetails from 'model/kpi/ExecutionDetails'; import ExecutionDetails from 'model/kpi/ExecutionDetails';
import ExecutionRun from 'model/kpi/ExecutionRun'; import ExecutionRun from 'model/kpi/ExecutionRun';
...@@ -37,6 +37,8 @@ class ExecutionDisplay extends React.Component<IExecutionProps, any> { ...@@ -37,6 +37,8 @@ class ExecutionDisplay extends React.Component<IExecutionProps, any> {
protected static needs = [ protected static needs = [
({ params: { shortName } }) => getExecution(shortName), ({ params: { shortName } }) => getExecution(shortName),
({}) => listParameters({}),
({}) => listDimensions({}),
]; ];
public state = { public state = {
......
...@@ -5,7 +5,7 @@ import BooleanDimension from 'model/kpi/BooleanDimension'; ...@@ -5,7 +5,7 @@ import BooleanDimension from 'model/kpi/BooleanDimension';
import JpaDimension from 'model/kpi/JpaDimension'; import JpaDimension from 'model/kpi/JpaDimension';
import NumericListDimension from 'model/kpi/NumericListDimension'; import NumericListDimension from 'model/kpi/NumericListDimension';
import StringListDimension from 'model/kpi/StringListDimension'; import StringListDimension from 'model/kpi/StringListDimension';
import Select from '@material-ui/core/es/Select'; import Select from '@material-ui/core/Select';
import MenuItem from '@material-ui/core/MenuItem'; import MenuItem from '@material-ui/core/MenuItem';
import FormControl from 'ui/common/forms/FormControl'; import FormControl from 'ui/common/forms/FormControl';
import {NumericListDimensionFormExtra} from './NumericListDimensionFormExtra'; import {NumericListDimensionFormExtra} from './NumericListDimensionFormExtra';
......
...@@ -6,7 +6,7 @@ import {Field} from 'redux-form'; ...@@ -6,7 +6,7 @@ import {Field} from 'redux-form';
import { listDimensions } from 'kpi/actions/admin'; import { listDimensions } from 'kpi/actions/admin';
import Dimension from 'model/kpi/Dimension'; import Dimension from 'model/kpi/Dimension';
import Select from '@material-ui/core/es/Select'; import Select from '@material-ui/core/Select';
import MenuItem from '@material-ui/core/MenuItem'; import MenuItem from '@material-ui/core/MenuItem';
import FormControl from 'ui/common/forms/FormControl'; import FormControl from 'ui/common/forms/FormControl';
import Grid from '@material-ui/core/Grid'; import Grid from '@material-ui/core/Grid';
......
...@@ -4,7 +4,7 @@ import { connect } from 'react-redux'; ...@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import {withStyles} from '@material-ui/core/styles'; import {withStyles} from '@material-ui/core/styles';
import Select from '@material-ui/core/es/Select'; import Select from '@material-ui/core/Select';
import MenuItem from '@material-ui/core/MenuItem'; import MenuItem from '@material-ui/core/MenuItem';
import FormControl from 'ui/common/forms/FormControl'; import FormControl from 'ui/common/forms/FormControl';
import {listParameters} from 'kpi/actions/admin'; import {listParameters} from 'kpi/actions/admin';
...@@ -73,4 +73,4 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({ ...@@ -73,4 +73,4 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
}, dispatch); }, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(translate()(withStyles(styles)(ParameterSelector))); export default translate()(connect(mapStateToProps, mapDispatchToProps)((withStyles(styles)(ParameterSelector))));
import * as React from 'react'; import * as React from 'react';
import {translate} from 'react-i18next';
import {Field, reduxForm} from 'redux-form'; import {Field, reduxForm} from 'redux-form';
import {TextField} from 'ui/common/text-field'; import {TextField} from 'ui/common/text-field';
// constants // constants
...@@ -60,7 +59,7 @@ class ExecutionForm extends React.Component<any, void> { ...@@ -60,7 +59,7 @@ class ExecutionForm extends React.Component<any, void> {
} }
} }
export default translate()(reduxForm({ export default reduxForm({
form: EXEC_FORM, form: EXEC_FORM,
enableReinitialize: true, enableReinitialize: true,
})(ExecutionForm)); })(ExecutionForm);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment