-
-
-
-
-
- {renderStat('Resolved', '449')}
- {renderStat('Received', '426')}
- {renderStat('Average first response time', '33m')}
- {renderStat('Average response time', '3h 8m')}
- {renderStat('Resolution within SLA', '94%')}
-
-
- );
-}
-
-export default TodayTrendsComponent;
diff --git a/frontend/src/components/dashboard/UnresolvedTicketsComponent.js b/frontend/src/components/dashboard/UnresolvedTicketsComponent.js
deleted file mode 100644
index 952cbda6..00000000
--- a/frontend/src/components/dashboard/UnresolvedTicketsComponent.js
+++ /dev/null
@@ -1,51 +0,0 @@
-import React from 'react';
-import { Row } from 'simple-flexbox';
-import { createUseStyles, useTheme } from 'react-jss';
-import CardComponent from 'components/cards/CardComponent';
-
-const useStyles = createUseStyles((theme) => ({
- itemTitle: {
- ...theme.typography.itemTitle,
- color: theme.color.veryDarkGrayishBlue
- },
- itemValue: {
- color: theme.color.grayishBlue2
- }
-}));
-
-function UnresolvedTicketsComponent({ containerStyles }) {
- const theme = useTheme();
- const classes = useStyles({ theme });
-
- function renderStat(title, value) {
- return (
-
- {title}
- {value}
-
- );
- }
-
- return (
-
- );
-}
-
-export default UnresolvedTicketsComponent;
diff --git a/frontend/src/components/dashboard/index.js b/frontend/src/components/dashboard/index.js
deleted file mode 100644
index bc1836f6..00000000
--- a/frontend/src/components/dashboard/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import DashboardComponent from './DashboardComponent';
-
-export default DashboardComponent;
diff --git a/frontend/src/components/details/ColumnChartComponent.jsx b/frontend/src/components/details/ColumnChartComponent.jsx
index ae9a93df..468ed7cd 100644
--- a/frontend/src/components/details/ColumnChartComponent.jsx
+++ b/frontend/src/components/details/ColumnChartComponent.jsx
@@ -24,7 +24,7 @@ const ColumnChartComponent = () => {
plotOptions: {
bar: {
- columnWidth: '70%',
+ columnWidth: '75%',
BorderRadius: 10,
dataLabels: {
position: 'top' // top, center, bottom
@@ -42,7 +42,7 @@ const ColumnChartComponent = () => {
},
offsetY: -20,
style: {
- fontSize: '12px',
+ fontSize: '10px',
colors: ['#21cc82']
}
},
@@ -63,7 +63,7 @@ const ColumnChartComponent = () => {
labels: {
rotate: -90,
style: {
- fontSize: 10
+ fontSize: 6.8,
}
},
responsive: [
@@ -71,7 +71,7 @@ const ColumnChartComponent = () => {
breakpoint: 6400,
options: {
chart: {
- width: 500
+ width: 600
},
legend: {
position: 'bottom'
diff --git a/frontend/src/components/details/DetailsComponent.js b/frontend/src/components/details/DetailsComponent.js
index b2f06451..3b4c4724 100644
--- a/frontend/src/components/details/DetailsComponent.js
+++ b/frontend/src/components/details/DetailsComponent.js
@@ -1,12 +1,12 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import ScenarioComponent from './ScenarioComponent';
-import { jsPDF } from 'jspdf';
-import html2canvas from 'html2canvas';
import { Col, Container, Row } from 'react-grid-system';
import './navbar.css';
import { postCalculationRequest } from 'interface/BackendConnect';
import LoadingComponent from 'components/loading';
+import { exportPdf } from '../../interface/PdfExporter.js';
+
/**
* the main component for detail page which includes
* canvas page and variable drop down list
@@ -15,18 +15,34 @@ import LoadingComponent from 'components/loading';
*/
class DetailsComponent extends Component {
- /* State consists of three variable one for each of the possible state
+ /*
+ * selectedScenarioId: for storing the id of the selected scenario
+ * to send the calculation request to server
+ * slectedScenarioType: for sending it to SelectScenarioComponent
* baselineScenario: only display the baseline scenario
* modifiedScenario: only display the modified scenario
* state at the beginng: only baseline scenario
*/
state = {
+ selectedScenarioId: '',
+ selectedScenarioType: '',
baselineScenario: true,
modifiedScenario: false,
loadComparePage: false,
- stillLoading: true
+ stillLoading: true,
+ onExportClicked: false
};
+ /**
+ * initializing selectedScenarioType and selectedScenarioId
+ * to request the baseline scenario for the first calculation request
+ */
+ constructor(props) {
+ super(props);
+ this.state.selectedScenarioType = props.selectedProduct.scenarioType;
+ this.state.selectedScenarioId = props.selectedProduct.productID;
+ }
+
render() {
/*
* compare buttons exist only when a single scenario is displayed
@@ -62,27 +78,34 @@ class DetailsComponent extends Component {
this.setState({ baselineScenario, modifiedScenario, loadComparePage });
};
+ /**
+ * this function will be envoced from SelectScenarioComponent,
+ * once the user changes the scenario in drop down menue
+ *
+ * then selectedScenarioId and selectedScenarioType will be updated
+ *
+ * @param item: selected scenario
+ */
+ let handleNewScenarioSelection = (item) => {
+ this.setState({ selectedScenarioId: item.id }, () => {
+ this.setState({ stillLoading: true });
+ this.setState({ selectedScenarioType: item.name });
+ });
+ };
+
let handleExportPdfButton = () => {
- // getting the element that should be exported
- var div = document.getElementById('capture');
+ this.setState({ onExportClicked: true });
- // converting html to an image and then exporting it by pdf
- html2canvas(div).then((canvas) => {
- var imgData = canvas.toDataURL('image/jpeg', 1);
- // pdf configuration
- var pdf = new jsPDF('p', 'mm', 'a4');
- var pageWidth = pdf.internal.pageSize.getWidth();
- var pageHeight = pdf.internal.pageSize.getHeight();
- var imageWidth = canvas.width;
- var imageHeight = canvas.height;
+ // geting the element that should be exported
+ var div1 = document.getElementById('capturePieChart');
+ var div2 = document.getElementById('captureColumnDiagram');
+ var div3 = document.getElementById('captureTable');
- var ratio =
- imageWidth / imageHeight >= pageWidth / pageHeight
- ? pageWidth / imageWidth
- : pageHeight / imageHeight;
- pdf.addImage(imgData, 'JPEG', 0, 0, imageWidth * ratio, imageHeight * ratio);
- pdf.save('invoice.pdf');
- });
+ exportPdf(div1, div2, div3, pdfExportDoneCallback);
+ };
+
+ let pdfExportDoneCallback = () => {
+ this.setState({ onExportClicked: false });
};
/*
* Important function that is given as the callback parameter to the postCalculationRequest in order to be called
@@ -100,7 +123,7 @@ class DetailsComponent extends Component {
const { selectedProduct } = this.props;
if (this.state.stillLoading) {
- postCalculationRequest(selectedProduct.productID, handleFinishedDataRequest);
+ postCalculationRequest(this.state.selectedScenarioId, handleFinishedDataRequest);
return ;
}
@@ -114,9 +137,12 @@ class DetailsComponent extends Component {
@@ -131,9 +157,12 @@ class DetailsComponent extends Component {
@@ -151,7 +180,9 @@ class DetailsComponent extends Component {
onExportClick={handleExportPdfButton}
onCloseClick={handleCloseBaselineButton}
scenarioName={scenarioNames.baseline}
+ selectedScenarioType={this.state.selectedScenarioType}
selectedProduct={selectedProduct}
+ newScenarioHandler={handleNewScenarioSelection}
/>
@@ -163,7 +194,9 @@ class DetailsComponent extends Component {
onExportClick={handleExportPdfButton}
onCloseClick={handleCloseModifiedButton}
scenarioName={scenarioNames.modified}
+ selectedScenarioType={this.state.selectedScenarioType}
selectedProduct={selectedProduct}
+ newScenarioHandler={handleNewScenarioSelection}
/>
@@ -178,9 +211,10 @@ DetailsComponent.propTypes = {
categories: PropTypes.array, // [(categories.generation, categories.transmission)],
modelID: PropTypes.string, // 'none',
modelName: PropTypes.string, // 'please select a Product',
- productID: PropTypes.string, // 'dummydum-13b0-4e09-9fb4-50398483ecfd'
+ productID: PropTypes.string.isRequired, // 'dummydum-13b0-4e09-9fb4-50398483ecfd'
productImage: PropTypes.string, //ImagePath?
- productName: PropTypes.string //'please select a Product'
+ productName: PropTypes.string, //'please select a Product'
+ scenarioType: PropTypes.string
})
};
diff --git a/frontend/src/components/details/MobileTableComponent.jsx b/frontend/src/components/details/MobileTableComponent.jsx
index 984f24e9..c33e478b 100644
--- a/frontend/src/components/details/MobileTableComponent.jsx
+++ b/frontend/src/components/details/MobileTableComponent.jsx
@@ -19,16 +19,6 @@ class MobileTableComponent extends Component {
const idKey = this.props.tableKey;
return (
- {/* dynamic display of product and model */}
-
{this.props.productName}
-
- {/* Don't display model name if model name == product name or undefined */}
- {this.props.modelName === this.props.productName ||
- this.props.modelName === undefined
- ? ''
- : this.props.modelName}
-
-
{/* style needs to be defined in js */}
diff --git a/frontend/src/components/details/NavbarComponent.js b/frontend/src/components/details/NavbarComponent.js
index b576c52e..4fca2c4d 100644
--- a/frontend/src/components/details/NavbarComponent.js
+++ b/frontend/src/components/details/NavbarComponent.js
@@ -3,6 +3,7 @@ import React from 'react';
import slugs from 'resources/slugs';
import { Link } from 'react-router-dom';
import { useHistory } from 'react-router-dom';
+import { CircularProgress } from '@material-ui/core';
/**
* a divider Pannel for seperating search compoents and result components
@@ -17,17 +18,24 @@ const NavbarComponent = (props) => {
{/* used the history.goback() function to go one step backward where it stores the previous steps including the prevs stage of clicking items on the sidebar */}
+ {/* Swaps out the table with a mobile version for screens <= sm
And when on the compare version already swap out for screens <= lg */}
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -90,8 +119,9 @@ class ScenarioComponent extends Component {
ScenarioComponent.propTypes = {
loadComparePage: PropTypes.bool,
onCloseClick: PropTypes.func,
+ newScenarioHandler: PropTypes.func.isRequired,
onCompareClick: PropTypes.func.isRequired,
- onExportClick: PropTypes.func.isRequired,
+ onExportClicked: PropTypes.bool,
scenarioName: PropTypes.string,
selectedProduct: PropTypes.shape({
modelID: PropTypes.string,
diff --git a/frontend/src/components/details/SelectScenarioComponent.jsx b/frontend/src/components/details/SelectScenarioComponent.jsx
new file mode 100644
index 00000000..8896e805
--- /dev/null
+++ b/frontend/src/components/details/SelectScenarioComponent.jsx
@@ -0,0 +1,115 @@
+import React, { Component } from 'react';
+import PropTypes from 'prop-types';
+
+/**
+ * a drop down component for selecting a scenario
+ */
+class SelectScenarioComponent extends Component {
+ state = {
+ secondScenario: '', // TODO: for comparing scenarios this should be removed and use props from detail component
+ scenarios: [{ id: '', name: '' }]
+ };
+
+ /**
+ * in this function a callback function
+ * in DetailsComponent should be called
+ * in order to send a new calculation request
+ * based on new selected scenario
+ *
+ * @param item: selected scenario
+ */
+ onDropDownItemSelectedHandler = (item) => {
+ this.props.newScenarioHandler(item);
+ };
+
+ onSecondDropDownSelectedHandler = (name) => {
+ const secondScenario = name;
+ this.setState({ secondScenario: secondScenario });
+ };
+
+ /**
+ * once this component is created this function is called
+ * before render method
+ */
+ componentDidMount = () => {
+ this.setState(this.updateStateScenario());
+ };
+
+ /**
+ * by this function the scenario list will be
+ * updated based on the available scenarios in
+ * scenario list
+ *
+ * @returns the updated state
+ */
+ updateStateScenario = () => {
+ let scenarioList = [];
+ // Handle the first element (baseline)
+ scenarioList.push({
+ id: this.props.selectedProduct.productID,
+ name: this.props.selectedProduct.scenarioType
+ });
+ let secondaryScenarioList = this.props.selectedProduct.scenarioList;
+
+ // Handle the scenarioList of the baseline (if any)
+ for (let index = 0; index < secondaryScenarioList.length; index++) {
+ const product = secondaryScenarioList[index];
+ scenarioList.push({ id: product.productID, name: product.scenarioType });
+ }
+
+ // Set State to the calculated List
+ let newState = {
+ selectedSecondScenario: '',
+ scenarios: scenarioList
+ };
+ return newState;
+ };
+
+ render() {
+ /*
+ if the loadComparePage state from its parrent (the detail Component)
+ is set to true, here an extra drop down for the second variable
+ should be rendered
+ */
+
+ return (
+
+
+
+
+
+ {this.state.scenarios.map((item) => (
+
+ ))}
+
+
+
+
+ );
+ }
+}
+
+SelectScenarioComponent.propTypes = {
+ newScenarioHandler: PropTypes.func,
+ selectedScenarioType: PropTypes.string,
+ selectedProduct: PropTypes.shape({
+ categories: PropTypes.array, // [(categories.generation, categories.transmission)],
+ modelID: PropTypes.string, // 'none',
+ modelName: PropTypes.string, // 'please select a Product',
+ productID: PropTypes.string.isRequired, // 'dummydum-13b0-4e09-9fb4-50398483ecfd'
+ productImage: PropTypes.string, //ImagePath?
+ productName: PropTypes.string, //'please select a Product'
+ scenarioList: PropTypes.array.isRequired,
+ scenarioType: PropTypes.string.isRequired
+ })
+};
+
+export default SelectScenarioComponent;
diff --git a/frontend/src/components/details/SelectVariableComponent.jsx b/frontend/src/components/details/SelectVariableComponent.jsx
deleted file mode 100644
index 4451af3e..00000000
--- a/frontend/src/components/details/SelectVariableComponent.jsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import React, { Component } from 'react';
-
-/**
- * a drop down component for selecting variable
- *
- */
-
-class SelectVariableComponent extends Component {
- /*
- hard coded state for storing variabes array
- and selected variable
-
- note: later on this state should be removed
- and instead props should be used
- because of the single source of truth rule
- */
- state = {
- selectedVariable: 'variable 1',
- secondVariable: 'variable 2',
- variables: [{ id: '1', name: 'variable 1' }]
- };
-
- handleSubmit = () => {
- alert('The choosen variable is: ' + this.state.selectedVariable);
- };
-
- onDropDownItemSelectedHandler = (name) => {
- const selectedVariable = name;
- this.setState({ selectedVariable });
- };
-
- onSecondDropDownSelectedHandler = (name) => {
- const secondVariable = name;
- this.setState({ secondVariable });
- };
-
- render() {
- /*
- if the loadComparePage state from its parrent (the detail Component)
- is set to true, here an extra drop down for the second variable
- should be rendered
- */
-
- return (
-
-
-
Select your desire variable:
-
-
-
-
-
- {this.state.variables.map((item) => (
-
- ))}
-
-
-
-
- );
- }
-}
-
-export default SelectVariableComponent;
diff --git a/frontend/src/components/details/TableComponent.jsx b/frontend/src/components/details/TableComponent.jsx
index 34f12b9f..86bc4325 100644
--- a/frontend/src/components/details/TableComponent.jsx
+++ b/frontend/src/components/details/TableComponent.jsx
@@ -17,15 +17,6 @@ class TableComponent extends Component {
const idKey = this.props.tableKey;
return (
- {/* dynamic display of product and model */}
-