Skip to content

Commit

Permalink
Merge pull request #148 from amosproj/dev-#17
Browse files Browse the repository at this point in the history
Propagating This Sprints Changes
  • Loading branch information
Waldleufer authored Jul 4, 2021
2 parents 26886f1 + 90724d5 commit 6ef3eec
Show file tree
Hide file tree
Showing 28 changed files with 930 additions and 306 deletions.
153 changes: 153 additions & 0 deletions frontend/src/assets/dummyData/dummyData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import logo from 'assets/logo/LogoCarbonteam.png';
import logo_1 from 'assets/dummyImages/Image_1.PNG';
import logo_2 from 'assets/dummyImages/Logo2.png';

export function getDummyProductData() {
// WTH are we looking for here? do we need to iterate over projects (api_demo_project, ...) or over final processes?
const products = [
{
Id: '09f64eeb-13b0-4e09-9fb4-50398483ecfd', //(project_id?) final_process_id? (final_product_id?)
Name: 'Electric Motors#ID:09f64eeb-13b0-4e09-9fb4-50398483ecfd#Scenario:scenario_baseline',
Description:
'Categorie:Generation/Product#Model:09f64eeb-13b0-4e09-9fb4-50398483ecfd#Location:Germany',
productImage: logo
},
{
Id: 'aufwlc93-kldp-4fer-15s7-51245631fega',
Name: 'Electric Motors#ID:aufwlc93-kldp-4fer-15s7-51245631fega#Scenario:scenario_scenario1',
Description:
'Categorie:Generation/Product#Model:09f64eeb-13b0-4e09-9fb4-503984f3ecfd#Location:Germany',
productImage: logo_1
},
{
Id: 'aufwlc93-kldp-4fer-15s7-5124563regen',
Name: 'Electric Motors#ID:aufwlc93-kldp-4fer-15s7-5124563regen#Scenario:scenario_scenario3',
Description:
'Categorie:Generation/Product#Model:09f64eeb-13b0-4e09-9fb4-503984f3ecfd#Location:Germany',
productImage: logo_1
},
{
Id: 'aufwlc93-kldp-4fer-15s7-51245631mega',
Name: 'Electric Motors#ID:aufwlc93-kldp-4fer-15s7-51245631mega#Scenario:scenario_scenario2',
Description:
'Categorie:Generation/Product#Model:09f64eeb-13b0-4e09-9fb4-503984f3ecfd#Location:Germany',
productImage: logo_1
},
{
Id: '7ghnaoeb-kfue-qp04-slfg-12059492gggg',
Name: 'Wireless Power Transmittor#ID:7ghnaoeb-kfue-qp04-slfg-12059492begp#Scenario:scenario_secondOption',
Description:
'Categorie:Transmission/Product#Model:09f64eeb-12f0-4e09-9fb4-50398483ecfd#Location:Germany',
productImage: logo_2
},
{
Id: '7ghnaoeb-kfue-qp04-slfg-12059492begp', //(project_id?) final_process_id? (final_product_id?)
Name: 'Wireless Power Transmittor#ID:7ghnaoeb-kfue-qp04-slfg-12059492begp#Scenario:scenario_baseline',
Description:
'Categorie:Transmission/Product#Model:09f64eeb-12f0-4e09-9fb4-50398483ecfd#Location:Germany',
productImage: logo_2
},
{
Id: 'whatis00-this-id00-just-d01n9352rnow', //(project_id?) final_process_id? (final_product_id?)
Name: 'Gas Turbine#ID:whatis00-this-id00-just-d01n9352rnow#Scenario:scenario_baseline',
Description:
'Categorie:Generation/Product#Model:09f64eeb-12f0-4e09-9fb4-50395583ecfd#Location:Germany',
productImage: logo
},
{
Id: 'aufglc25-kldd-4ger-16s2-51002631fell', //(project_id?) final_process_id? (final_product_id?)
Name: 'Alround Product#ID:aufglc25-kldd-4ger-16s2-51002631fell#Scenario:scenario_baseline',
Description:
'Categorie:Generation/Product#Model:09f64eeb-1234-4e09-9fb4-50398483ecfd#Location:France',
productImage: logo_1
},
{
Id: 'aufglc25-kldd-4ger-16s2-5100Julian00', //(project_id?) final_process_id? (final_product_id?)
Name: 'Super Product#ID:aufglc25-kldd-4ger-16s2-5100Julian00#Scenario:scenario_baseline',
Description:
'Categorie:Generation/Product#Model:09f64eeb-1234-4321-9fb4-50398483ecfd#Location:Germany',
productImage: logo_1
},
{
Id: 'aufglc25-kldd-4ger-16s2-5100100sai00', //(project_id?) final_process_id? (final_product_id?)
Name: 'Super Product#ID:aufglc25-kldd-4ger-16s2-5100100sai00#Scenario:scenario_1',
Description:
'Categorie:Generation/Product#Model:09f64eeb-1234-4321-9fb4-50398483ecfd#Location:India',
productImage: logo_1
},
{
Id: 'aufglc25-kldd-4ger-16s2-5100MartinWl', //(project_id?) final_process_id? (final_product_id?)
Name: 'Super Service#ID:aufglc25-kldd-4ger-16s2-5100MartinWl#Scenario:scenario_baseline',
Description:
'Categorie:Generation/Service#Model:09f64eeb-1234-4e09-9fb4-50398483ecfd#Location:Germany',
productImage: logo
},
{
Id: 'aufglc25-kldd-4ger-16s2-510MartinD1l', //(project_id?) final_process_id? (final_product_id?)
Name: 'Super Service#ID:aufglc25-kldd-4ger-16s2-510MartinD1l#Scenario:scenario_1',
Description:
'Categorie:Generation/Service#Model:09f64eeb-1234-4e09-9fb4-50398483ecfd#Location:Germany',
productImage: logo
},
{
Id: 'aufglc25-kldd-4ger-16s2-510026Irem01', //(project_id?) final_process_id? (final_product_id?)
Name: 'Super Solution#ID:aufglc25-kldd-4ger-16s2-510026Irem01#Scenario:scenario_baseline',
Description:
'Categorie:Generation/Solution#Model:09f64eeb-1234-4e09-9fb4-50398483ecfd#Location:Germany',
productImage: logo_1
},
{
Id: 'hello0th-ere0-4ger-16s2-51002631Mani', //(project_id?) final_process_id? (final_product_id?)
Name: 'Super Solution#ID:hello0th-ere0-4ger-16s2-51002631Mani#Scenario:scenario_1',
Description:
'Categorie:Transmission/Solution#Model:09f64eeb-1234-4e09-9fb4-50398483ecfd#Location:India',
productImage: logo_1
},
{
Id: 'hello0th-ere0-4ger-16s2-51002Parham1',
Name: 'THE Solution#ID:hello0th-ere0-4ger-16s2-51002Parham1#Scenario:scenario_baseline',
Description:
'Categorie:Transmission/Solution#Model:09f64eeb-1234-4e09-9fb4-50355483ecfd#Location:Iran',
productImage: logo_1
}
];
return products;
}

/**
* should get all the Models for one Product
* @param productID the id of the Project to get the models for
* @returns
*/
//export async function getModels(productID) {
export function getModels(productName, productID) {
switch (productID) {
case '09f64eeb-13b0-4e09-9fb4-50398483ecfd':
return [{ modelID: 1, productID: productID, modelName: 'Electric Motor Type 25b' }];
case 'aufwlc93-kldp-4fer-15s7-51245631fega':
return [];
case '7ghnaoeb-kfue-qp04-slfg-12059492begp':
return [
{ modelID: 6, productID: productID, modelName: 'Transmitter DIN42a' },
{ modelID: 7, productID: productID, modelName: 'Transmitter DIN42b' },
{ modelID: 8, productID: productID, modelName: 'Transmitter DIN42c' },
{ modelID: 9, productID: productID, modelName: 'Transmitter DIN42d' }
];
case 'whatis00-this-id00-just-d01n9352rnow':
return [
{ modelID: 10, productID: productID, modelName: 'Gas Turbine Type 1' },
{ modelID: 11, productID: productID, modelName: 'Gas Turbine Type 2' },
{ modelID: 12, productID: productID, modelName: 'Gas Turbine Type 3' },
{ modelID: 13, productID: productID, modelName: 'Gas Turbine Type 4' }
];
case 'aufglc25-kldd-4ger-16s2-51002631fell':
return [
{ modelID: 14, productID: productID, modelName: 'Allround Product 1' },
{ modelID: 15, productID: productID, modelName: 'Allround Product 2' },
{ modelID: 16, productID: productID, modelName: 'Allround Product 3' },
{ modelID: 17, productID: productID, modelName: 'Allround Product 4' }
];
default:
return [{ modelID: 42, productID: productID, modelName: productName }];
}
}
47 changes: 43 additions & 4 deletions frontend/src/components/details/DetailsComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,33 @@ 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
};

/**
* 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
Expand Down Expand Up @@ -62,6 +77,21 @@ 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');
Expand Down Expand Up @@ -100,7 +130,7 @@ class DetailsComponent extends Component {
const { selectedProduct } = this.props;

if (this.state.stillLoading) {
postCalculationRequest(selectedProduct.productID, handleFinishedDataRequest);
postCalculationRequest(this.state.selectedScenarioId, handleFinishedDataRequest);
return <LoadingComponent loading />;
}

Expand All @@ -116,7 +146,9 @@ class DetailsComponent extends Component {
onCompareClick={handleCompareButton}
onExportClick={handleExportPdfButton}
scenarioName={scenarioNames.baseline}
selectedScenarioType={this.state.selectedScenarioType}
selectedProduct={selectedProduct}
newScenarioHandler={handleNewScenarioSelection}
/>
</Col>
</Row>
Expand All @@ -133,7 +165,9 @@ class DetailsComponent extends Component {
onCompareClick={handleCompareButton}
onExportClick={handleExportPdfButton}
scenarioName={scenarioNames.modified}
selectedScenarioType={this.state.selectedScenarioType}
selectedProduct={selectedProduct}
newScenarioHandler={handleNewScenarioSelection}
/>
</Col>
</Row>
Expand All @@ -151,7 +185,9 @@ class DetailsComponent extends Component {
onExportClick={handleExportPdfButton}
onCloseClick={handleCloseBaselineButton}
scenarioName={scenarioNames.baseline}
selectedScenarioType={this.state.selectedScenarioType}
selectedProduct={selectedProduct}
newScenarioHandler={handleNewScenarioSelection}
/>
</Col>

Expand All @@ -163,7 +199,9 @@ class DetailsComponent extends Component {
onExportClick={handleExportPdfButton}
onCloseClick={handleCloseModifiedButton}
scenarioName={scenarioNames.modified}
selectedScenarioType={this.state.selectedScenarioType}
selectedProduct={selectedProduct}
newScenarioHandler={handleNewScenarioSelection}
/>
</Col>
</Row>
Expand All @@ -178,9 +216,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
})
};

Expand Down
35 changes: 0 additions & 35 deletions frontend/src/components/details/PanelComponent.jsx

This file was deleted.

10 changes: 8 additions & 2 deletions frontend/src/components/details/ScenarioComponent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import SelectVariableComponent from './SelectVariableComponent';
import SelectScenarioComponent from './SelectScenarioComponent';
import NavbarComponent from './NavbarComponent';
import PieChartComponent from './PieChartComponent';
import ColumnChartComponent from './ColumnChartComponent';
Expand Down Expand Up @@ -31,7 +31,12 @@ class ScenarioComponent extends Component {
<h2 className='TextContent'>
The chosen Model is <b>{this.props.selectedProduct.modelName}</b>
</h2>
<SelectVariableComponent loadComparePage={this.props.loadComparePage} />
<SelectScenarioComponent
selectedProduct={this.props.selectedProduct}
loadComparePage={this.props.loadComparePage}
selectedScenarioType={this.props.selectedScenarioType}
newScenarioHandler={this.props.newScenarioHandler}
/>
<Row>
<Col xs={12} sm={12} md={12} lg={6} className='CardsContainer'>
<div className='CardTitle'>
Expand Down Expand Up @@ -90,6 +95,7 @@ class ScenarioComponent extends Component {
ScenarioComponent.propTypes = {
loadComparePage: PropTypes.bool,
onCloseClick: PropTypes.func,
newScenarioHandler: PropTypes.func.isRequired,
onCompareClick: PropTypes.func.isRequired,
onExportClick: PropTypes.func.isRequired,
scenarioName: PropTypes.string,
Expand Down
Loading

0 comments on commit 6ef3eec

Please sign in to comment.