Commit 72c3b59c authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Matija Obreza

Admin KPI user inteface

- added execution display, fixed execution form, several small bugfixes and code cleanup
- added simple param/dimension cards with ability to edit, fixed booleanFormExtra
- added KPI forms
parent 6578a367
......@@ -58,15 +58,19 @@
"dateNotProvided": "Date not provided",
"description": "Description",
"either": "Either",
"false": "False",
"itemEditorWarn": "Don't use the ItemsEditor for more than 100 items!",
"lastModified": "Last modified",
"lastUpdated": "Last updated",
"modified": "Modified",
"name": "Name",
"newVersionAvailable": "New version available",
"no": "No",
"prettyNumber": "{{value, number}}",
"sortBy": "Sort By",
"stepsForDataPublication": "Steps for data publication completion",
"title": "Title",
"true": "True",
"UUID": "UUID",
"yes": "Yes"
},
......
......@@ -486,6 +486,93 @@
"accessionsInGenesys": "Accessions in Genesys"
}
}
,"kpi": {
"admin": {
"c": {
"dimensionForm": {
"description": "Description",
"name": "Name",
"title": "Title",
"type": "Type",
"values": "Values"
},
"executionCard": {
"dimensionField": "Field",
"dimensionLink": "Link",
"dimensionsInfo": "Dimension info",
"mainInformation": "General info",
"parameterCondition": "Condition",
"parameterDescription": "Description",
"parameterEntity": "Entity",
"parameterInfo": "Parameter info",
"property": "Property",
"type": "Type"
},
"executionForm": {
"dimensionList": {
"selectDimension": "Select dimension"
},
"dimensions": "Dimensions",
"type": "Type",
"field": "Field",
"link": "Link",
"parameter": "Parameter",
"parameterSelector": {
"selectParameter": "Select parameter"
}
},
"jpaDimensionExtra": {
"condition": "Condition",
"entity": "Entity",
"field": "Field"
},
"parameterForm": {
"condition": "Condition",
"description": "Description",
"entity": "Entity"
}
},
"dimensionForm": {
"selectType": "Select type"
},
"p": {
"dashboard": {
"KPIDimensions": "Dimensions",
"KPIExecutions": "Executions",
"KPIParameters": "Parameters",
"title": "KPI management"
},
"dimensionDialog": {
"button": "Add dimension",
"title": "Dimension info"
},
"executionDialog": {
"button": "Add execution",
"title": "Execution info"
},
"executionDisplay": {
"lastRun": "Last run ",
"runFrom": "Run from ",
"runs": "Runs",
"execute": "Execute",
"title": "Execution details"
},
"parameterDialog": {
"button": "Add parameter",
"title": "Parameter info"
}
}
},
"common": {
"type": {
"BooleanDimension": "BooleanDimension",
"JpaDimension": "JpaDimension",
"NumericListDimension": "NumericListDimension",
"StringListDimension": "StringListDimension"
},
"showRun": "Show run info"
}
}
,"list": {
"public": {
"p": {
......
......@@ -2078,11 +2078,6 @@
"tweetnacl": "^0.14.3"
}
},
"before-build-webpack": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/before-build-webpack/-/before-build-webpack-0.2.5.tgz",
"integrity": "sha512-C0JfCFlKIRchTJ6LX0/bYyCvwjMUm8s3Hf/FZXluZmzx6Ho/GjqBSMyGtzMT+n20rWx4on4GB7eb87eRaJEuow=="
},
"big.js": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz",
......
import KpiService from 'service/genesys/KpiService';
// actions
import navigateTo from 'actions/navigation';
// constants
import {
ADMIN_REMOVE_EXEC, ADMIN_RECEIVE_PARAMS,
ADMIN_RECEIVE_PARAM, ADMIN_RECEIVE_DIMS,
ADMIN_RECEIVE_EXECS, ADMIN_RECEIVE_EXEC,
ADMIN_RECEIVE_EXEC_LASTRUN, ADMIN_RECEIVE_DIM,
ADMIN_RECEIVE_EXEC_DET, ADMIN_REMOVE_DIM,
ADMIN_REMOVE_PARAM,
} from 'kpi/constants';
// model
import { IReducerAction } from 'model/common.model';
import Page, { IPageRequest } from 'model/Page';
import KPIParameter from 'model/kpi/KPIParameter';
import { IReducerAction } from 'model/common.model';
import { ADMIN_RECEIVE_PARAMS, ADMIN_RECEIVE_DIMS, ADMIN_RECEIVE_EXECS, ADMIN_RECEIVE_EXEC, ADMIN_RECEIVE_EXEC_LASTRUN } from 'kpi/constants';
import Dimension from 'model/kpi/Dimension';
import NumericListDimension from 'model/kpi/NumericListDimension';
import StringListDimension from 'model/kpi/StringListDimension';
import BooleanDimension from 'model/kpi/BooleanDimension';
import JpaDimension from 'model/kpi/JpaDimension';
import Execution from 'model/kpi/Execution';
import ExecutionDetails from 'model/kpi/ExecutionDetails';
import ExecutionRun from 'model/kpi/ExecutionRun';
// service
import KpiService from 'service/genesys/KpiService';
const ensureDimensionType = (dimensions) => {
dimensions.content.map((dimension) => {
switch (dimension._class) {
case 'NumericListDimension': dimension._fullClass = NumericListDimension.CLASS; break;
case 'StringListDimension': dimension._fullClass = StringListDimension.CLASS; break;
case 'BooleanDimension': dimension._fullClass = BooleanDimension.CLASS; break;
case 'JpaDimension': dimension._fullClass = JpaDimension.CLASS; break;
}
return dimension;
});
return dimensions;
};
export const listExecutions = (page: IPageRequest) => (dispatch) => {
KpiService.listExecutions(page).then((data) => {
dispatch(receiveExecutions(data));
......@@ -21,12 +54,12 @@ const receiveExecutions = (page: Page<Execution>): IReducerAction => ({
export const getExecution = (name: string) => (dispatch) => {
KpiService.executionDetails(name).then((data) => {
dispatch(receiveExecution(data));
dispatch(receiveExecutionDetails(data));
});
};
const receiveExecution = (execution: ExecutionDetails): IReducerAction => ({
type: ADMIN_RECEIVE_EXEC, payload: execution,
const receiveExecutionDetails = (execution: ExecutionDetails): IReducerAction => ({
type: ADMIN_RECEIVE_EXEC_DET, payload: execution,
});
export const executeExecution = (name: string) => (dispatch) => {
......@@ -41,7 +74,7 @@ const receiveExecutionRun = (executionRun: ExecutionRun): IReducerAction => ({
export const listDimensions = (page: IPageRequest) => (dispatch) => {
KpiService.listDimensions(page).then((data) => {
dispatch(receiveDimensions(data));
dispatch(receiveDimensions(ensureDimensionType(data)));
});
};
......@@ -49,6 +82,53 @@ const receiveDimensions = (page: Page<Dimension<any>>): IReducerAction => ({
type: ADMIN_RECEIVE_DIMS, payload: page,
});
export const saveExecution = (execution: Execution) => (dispatch) => {
KpiService.saveExecution(execution)
.then((execution) => dispatch(receiveExecution(execution)));
};
const receiveExecution = (execution: Execution): IReducerAction => ({
type: ADMIN_RECEIVE_EXEC, payload: execution,
});
export const deleteExecution = (execution: Execution) => (dispatch) => {
KpiService.deleteExecution(execution.name)
.then((execution) => {
dispatch(removeExecution(execution));
dispatch(navigateTo('/admin/kpi'));
});
};
const removeExecution = (execution: Execution): IReducerAction => ({
type: ADMIN_REMOVE_EXEC, payload: execution,
});
export const loadDimension = (name: string) => (dispatch) => {
KpiService.getDimension(name)
.then((dimension) => dispatch(receiveDimension(dimension)));
};
export const clearDimDetails = () => (dispatch) => {
dispatch(receiveDimension(null));
};
export const saveDimension = (dimension: Dimension<any>) => (dispatch) => {
KpiService.saveDimension(dimension)
.then((dimension) => dispatch(receiveDimension(dimension)));
};
export const deleteDimension = (dimension: Dimension<any>) => (dispatch) => {
KpiService.deleteDimension(dimension.name)
.then((dimension) => dispatch(removeDimension(dimension)));
};
const removeDimension = (dimension: Dimension<any>): IReducerAction => ({
type: ADMIN_REMOVE_DIM, payload: dimension,
});
const receiveDimension = (dimension: Dimension<any>): IReducerAction => ({
type: ADMIN_RECEIVE_DIM, payload: dimension,
});
export const listParameters = (page: IPageRequest) => (dispatch) => {
KpiService.listParameters(page).then((data) => {
......@@ -60,3 +140,25 @@ const receiveParameters = (page: Page<KPIParameter>): IReducerAction => ({
type: ADMIN_RECEIVE_PARAMS, payload: page,
});
export const clearParameterDetails = () => (dispatch) => {
dispatch(receiveParameter(null));
};
export const saveParameter = (parameter: KPIParameter) => (dispatch) => {
KpiService.saveParameter(parameter)
.then((parameter) => dispatch(receiveParameter(parameter)));
};
export const deleteParameter = (parameter: KPIParameter) => (dispatch) => {
KpiService.deleteParameter(parameter.name)
.then((parameter) => dispatch(removeParameter(parameter)));
};
const receiveParameter = (parameter: KPIParameter): IReducerAction => ({
type: ADMIN_RECEIVE_PARAM, payload: parameter,
});
const removeParameter = (parameter: KPIParameter): IReducerAction => ({
type: ADMIN_REMOVE_PARAM, payload: parameter,
});
......@@ -8,8 +8,21 @@
// export const INSTITUTE_FILTERFORM = 'Form/institutes/INSTITUTE_FILTERFORM';
export const PARAMETER_FORM = 'Form/kpi/PARAMETER_FORM';
export const DIMENSION_FORM = 'Form/kpi/DIMENSION_FORM';
export const EXEC_FORM = 'Form/kpi/EXEC_FORM';
export const ADMIN_RECEIVE_EXECS = 'kpi/admin/RECEIVE_EXECS';
export const ADMIN_RECEIVE_EXEC = 'kpi/admin/RECEIVE_EXEC';
export const ADMIN_REMOVE_EXEC = 'kpi/admin/REMOVE_EXEC';
export const ADMIN_RECEIVE_EXEC_DET = 'kpi/admin/RECEIVE_EXEC_DET';
export const ADMIN_RECEIVE_EXEC_LASTRUN = 'kpi/admin/RECEIVE_LASTRUN';
export const ADMIN_RECEIVE_PARAMS = 'kpi/admin/RECEIVE_PARAMS';
export const ADMIN_RECEIVE_PARAM = 'kpi/admin/RECEIVE_PARAM';
export const ADMIN_REMOVE_PARAM = 'kpi/admin/REMOVE_PARAM';
export const ADMIN_RECEIVE_DIM = 'kpi/admin/RECEIVE_DIM';
export const ADMIN_REMOVE_DIM = 'kpi/admin/REMOVE_DIM';
export const ADMIN_RECEIVE_DIMS = 'kpi/admin/RECEIVE_DIMS';
export const ADMIN_RECEIVE_EXEC_LASTRUN = 'kpi/admin/RECEIVE_LASTRUN';
import update from 'immutability-helper';
import {IReducerAction} from 'model/common.model';
import { ADMIN_RECEIVE_EXECS, ADMIN_RECEIVE_DIMS, ADMIN_RECEIVE_PARAMS, ADMIN_RECEIVE_EXEC, ADMIN_RECEIVE_EXEC_LASTRUN } from 'kpi/constants';
import {
ADMIN_RECEIVE_DIM,
ADMIN_RECEIVE_DIMS,
ADMIN_RECEIVE_EXEC,
ADMIN_RECEIVE_EXEC_DET,
ADMIN_RECEIVE_EXEC_LASTRUN,
ADMIN_RECEIVE_EXECS,
ADMIN_RECEIVE_PARAM,
ADMIN_RECEIVE_PARAMS,
ADMIN_REMOVE_DIM,
ADMIN_REMOVE_EXEC,
ADMIN_REMOVE_PARAM,
} from 'kpi/constants';
import Execution from 'model/kpi/Execution';
import Page from 'model/Page';
import Dimension from 'model/kpi/Dimension';
import KPIParameter from 'model/kpi/KPIParameter';
const INITIAL_STATE: {
exec: {
page: Page<Execution>,
details: Execution,
},
dim: {
page: Page<Dimension<any>>,
details: Dimension<any>,
},
param: {
page: Page<KPIParameter>,
details: KPIParameter,
},
} = {
exec: {
page: null,
......@@ -10,9 +38,11 @@ const INITIAL_STATE: {
},
dim: {
page: null,
details: null,
},
param: {
page: null,
details: null,
},
};
......@@ -25,6 +55,49 @@ export default function admin(state = INITIAL_STATE, action: IReducerAction) {
});
}
case ADMIN_RECEIVE_EXEC: {
const execution = action.payload;
const receivedIndex = state.exec.page ? state.exec.page.content.findIndex((item) => item.name === execution.name) : -1;
if (receivedIndex !== -1) {
return update(state, {
exec: {
page: {
content: {
[receivedIndex]: {$set: execution},
},
},
details: {$set: execution},
},
});
} else {
return update(state, {
exec: {
page: {
content: {$push: [execution]},
},
details: {$set: execution},
},
});
}
}
case ADMIN_REMOVE_EXEC: {
const toDelete = action.payload;
const toDeleteIndex = state.exec && state.exec.page && state.exec.page.content ? state.exec.page.content.findIndex((item) => toDelete.name === item.name) : -1;
return toDeleteIndex === -1 ? state
:
update(state, {
exec: {
page: {
content: {$splice: [[toDeleteIndex, 1]]},
},
details: {$set: null},
},
});
}
case ADMIN_RECEIVE_EXEC_DET: {
return update(state, {
exec: { details: { $set: action.payload } },
});
......@@ -40,11 +113,109 @@ export default function admin(state = INITIAL_STATE, action: IReducerAction) {
dim: { page: { $set: action.payload } },
});
}
case ADMIN_RECEIVE_DIM: {
const dimension = action.payload;
if (!dimension) {
return update(state, {
dim: {
details: {$set: null},
},
});
}
const receivedIndex = state.dim.page ? state.dim.page.content.findIndex((item) => item.name === dimension.name) : -1;
if (receivedIndex !== -1) {
return update(state, {
dim: {
page: {
content: {
[receivedIndex]: {$set: dimension},
},
},
details: {$set: dimension},
},
});
} else {
return update(state, {
dim: {
page: {
content: {$push: [dimension]},
},
details: {$set: dimension},
},
});
}
}
case ADMIN_REMOVE_DIM: {
const toDelete = action.payload;
const toDeleteIndex = state.dim && state.dim.page && state.dim.page.content ? state.dim.page.content.findIndex((item) => toDelete.name === item.name) : -1;
return toDeleteIndex === -1 ? state
:
update(state, {
dim: {
page: {
content: {$splice: [[toDeleteIndex, 1]]},
},
details: {$set: null},
},
});
}
case ADMIN_RECEIVE_PARAMS: {
return update(state, {
param: { page: { $set: action.payload } },
});
}
case ADMIN_RECEIVE_PARAM: {
const param = action.payload;
if (!param) {
return update(state, {
param: {
details: {$set: null},
},
});
}
const receivedIndex = param && state.param.page ? state.param.page.content.findIndex((item) => item.name === param.name) : -1;
if (receivedIndex !== -1) {
return update(state, {
param: {
page: {
content: {
[receivedIndex]: {$set: param},
},
},
details: {$set: param},
},
});
} else {
return update(state, {
param: {
page: {
content: {$push: [param]},
},
details: {$set: param},
},
});
}
}
case ADMIN_REMOVE_PARAM: {
const toDelete = action.payload;
const toDeleteIndex = state.param && state.param.page && state.param.page.content ? state.param.page.content.findIndex((item) => toDelete.name === item.name) : -1;
return toDeleteIndex === -1 ? state
:
update(state, {
param: {
page: {
content: {$splice: [[toDeleteIndex, 1]]},
},
details: {$set: null},
},
});
}
default:
return state;
}
......
{
"admin": {
"c": {
"dimensionForm": {
"description": "Description",
"name": "Name",
"title": "Title",
"type": "Type",
"values": "Values"
},
"executionCard": {
"dimensionField": "Field",
"dimensionLink": "Link",
"dimensionsInfo": "Dimension info",
"mainInformation": "General info",
"parameterCondition": "Condition",
"parameterDescription": "Description",
"parameterEntity": "Entity",
"parameterInfo": "Parameter info",
"property": "Property",
"type": "Type"
},
"executionForm": {
"dimensionList": {
"selectDimension": "Select dimension"
},
"dimensions": "Dimensions",
"type": "Type",
"field": "Field",
"link": "Link",
"parameter": "Parameter",
"parameterSelector": {
"selectParameter": "Select parameter"
}
},
"jpaDimensionExtra": {
"condition": "Condition",
"entity": "Entity",
"field": "Field"
},
"parameterForm": {
"condition": "Condition",
"description": "Description",
"entity": "Entity"
}
},
"dimensionForm": {
"selectType": "Select type"
},
"p": {
"dashboard": {
"KPIDimensions": "Dimensions",
"KPIExecutions": "Executions",
"KPIParameters": "Parameters",
"title": "KPI management"
},
"dimensionDialog": {
"button": "Add dimension",
"title": "Dimension info"
},
"executionDialog": {
"button": "Add execution",
"title": "Execution info"
},
"executionDisplay": {
"lastRun": "Last run ",
"runFrom": "Run from ",
"runs": "Runs",
"execute": "Execute",
"title": "Execution details"
},
"parameterDialog": {
"button": "Add parameter",
"title": "Parameter info"
}
}
},
"common": {
"type": {
"BooleanDimension": "BooleanDimension",
"JpaDimension": "JpaDimension",
"NumericListDimension": "NumericListDimension",
"StringListDimension": "StringListDimension"
},
"showRun": "Show run info"
}