Skip to content

Commit

Permalink
Merge pull request #72 from amosproj/backend-dev-#46
Browse files Browse the repository at this point in the history
Implementation of #46
  • Loading branch information
Waldleufer authored Jun 1, 2021
2 parents d5000e0 + 3034eb9 commit e71ef26
Show file tree
Hide file tree
Showing 14 changed files with 289 additions and 198 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ on:
branches: [ main, backend-dev, release ]

jobs:
buildAndTest:
name: Build and Test Backend
runs-on: ubuntu-latest

build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
- name: Setup .NET
- name: Setup .NET5
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
Expand All @@ -23,5 +25,3 @@ jobs:
run: nuget restore backend/CarbonFootprintVisualization.sln
- name: Build
run: dotnet build backend/CarbonFootprintVisualization.sln --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
7 changes: 2 additions & 5 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"ExpandedNodes": [
"",
"\\Backend",
"\\Backend\\Backend",
"\\Backend\\Backend\\Controllers",
"\\Backend\\CarbonFootprintVisualization"
"\\backend"
],
"SelectedNode": "\\Backend\\CarbonFootprintVisualization.sln",
"SelectedNode": "\\backend\\CarbonFootprintVisualization.sln",
"PreviewInSolutionExplorer": false
}
10 changes: 10 additions & 0 deletions backend/Backend.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Backend.Controllers"/>
<PackageReference Include="Backend.Security"/>
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion backend/Backend/Backend.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
Expand All @@ -18,3 +18,4 @@
</ItemGroup>

</Project>

6 changes: 0 additions & 6 deletions backend/CarbonFootprintVisualization.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Backend", "Backend\Backend.csproj", "{40A6CB29-AC0B-4581-8F8F-EE683CC103C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{99AE127E-0806-47AB-8257-B69CBF34D03B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -17,10 +15,6 @@ Global
{40A6CB29-AC0B-4581-8F8F-EE683CC103C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40A6CB29-AC0B-4581-8F8F-EE683CC103C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40A6CB29-AC0B-4581-8F8F-EE683CC103C9}.Release|Any CPU.Build.0 = Release|Any CPU
{99AE127E-0806-47AB-8257-B69CBF34D03B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99AE127E-0806-47AB-8257-B69CBF34D03B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99AE127E-0806-47AB-8257-B69CBF34D03B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99AE127E-0806-47AB-8257-B69CBF34D03B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
33 changes: 0 additions & 33 deletions backend/Test/Test.csproj

This file was deleted.

90 changes: 0 additions & 90 deletions backend/Test/UnitTest1.cs

This file was deleted.

13 changes: 0 additions & 13 deletions backend/backend.csproj

This file was deleted.

133 changes: 130 additions & 3 deletions frontend/src/components/productGrid/ModelDropdownComponent.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
import React, { useContext, useState } from 'react';
import React, { useContext, useState, useEffect } from 'react';
import { getModels } from 'interface/simaProInterface';
import { PrivateSectionContext } from 'hooks/PrivateSectionContext';
import { Col, Container, Row } from 'react-grid-system';
import theme from 'resources/theme';
import LoadingComponent from 'components/loading';

/**
* This component creates the dropdownboxes for the related products
*
* It calls the Backend to get the Models for a specific productID
*
* @returns the model properties of the related product depending on the model values from getModels func from interface/simaProInterface
* @author Parham Gandomkar, Martin Wagner, Irem Toroslu, Mani Anand
*/

const ModelDropdownComponent = (props) => {
const productID = props.productID;
const productName = props.productName;

// eslint-disable-next-line
const [getSelectedProducts, setSelectedProducts] = useContext(PrivateSectionContext);
const [selectedProducts, setSelectedProducts] = useContext(PrivateSectionContext);
// set the initial values for the dropdown list derived from getModels
const variables = getModels(productID);
console.log('variables');
console.log(variables);
const [selected, setSelected] = useState('Select a model');
//checking if the variable list is empty

/* useEffect(() => {
async function getProductModels() {
const variables = getModels(productID);
setVariableList(variables);
console.log(variables);
}
getProductModels();
}, []); */

if (variables === [] || variables === undefined || variables === null) {
return <LoadingComponent />;
}
// else:

return (
<Container fluid={true}>
<Row
Expand Down Expand Up @@ -80,4 +100,111 @@ const ModelDropdownComponent = (props) => {

export default ModelDropdownComponent;

/*
const ModelDropdownComponent = (props) => {
const productID = props.productID;
const productName = props.productName;
// eslint-disable-next-line
const [getSelectedProducts, setSelectedProducts] = useContext(PrivateSectionContext);
// set the initial values for the dropdown list derived from getModels
const variables = getModels(productID);
//const [variableList,setVariableList] = useState([productID]);
const [selected, setSelected] = useState('Select a model');
/*useEffect(() => {
async function getProductModels() {
const variables = getModels(productID);
setVariableList(variables);
console.log(variables);
}
getProductModels();
}, [productID]);
};
if (variables === null || variables === undefined) {
if (variableList === null || variableList === undefined) {
return (
<Container fluid={true}>
<Row
className='w3-dropdown-hover w3-margin-top w3-margin-bottom:2em'
disabled={true}
style={{ backgroundColor: theme.uniformStyle.color.secondaryBackgroundColor }}
>
<button
className='w3-button'
style={{
color: theme.uniformStyle.color.secondaryFontColor,
backgroundColor: theme.uniformStyle.color.secondaryBackgroundColor,
fontSize: theme.typography.buttontitle.fontSize,
fontWeight: theme.typography.buttontitle.fontWeight,
lineHeight: theme.typography.buttontitle.lineHeight,
letterSpacing: theme.typography.buttontitle.letterSpacing
}}
>
Default Model
</button>
</Row>
</Container>
);
}
// else:
return (
<Container fluid={true}>
<Row
className='w3-dropdown-hover w3-margin-top w3-margin-bottom:2em'
style={{ backgroundColor: theme.uniformStyle.color.secondaryBackgroundColor }}
>
<Col xs={2}>
<button
className='w3-button'
style={{
color: theme.uniformStyle.color.secondaryFontColor,
backgroundColor: theme.uniformStyle.color.secondaryBackgroundColor,
fontSize: theme.typography.buttontitle.fontSize,
fontWeight: theme.typography.buttontitle.fontWeight,
lineHeight: theme.typography.buttontitle.lineHeight,
letterSpacing: theme.typography.buttontitle.letterSpacing
}}
>
{selected}
</button>
<div
className='w3-dropdown-content w3-bar-block w3-border'
style={{
color: theme.uniformStyle.color.secondaryFontColor,
backgroundColor: theme.uniformStyle.color.secondaryBackgroundColor,
fontSize: theme.typography.buttontitle.fontSize,
fontWeight: theme.typography.buttontitle.fontWeight,
lineHeight: theme.typography.buttontitle.lineHeight,
letterSpacing: theme.typography.buttonSendtitle.letterSpacing
}}
>
{variables.map((item) => (
<button
onClick={(props) => {
const newSelectedProducts = [
{
productID: productID,
productName: productName,
modelID: item.modelID,
modelName: item.modelName
}
];
setSelected(item.modelName);
setSelectedProducts(newSelectedProducts);
}}
className=' w3-bar w3-button'
key={item.modelID}
>
{item.modelName}
</button>
))}
</div>
</Col>
</Row>
</Container>
);
};
export default ModelDropdownComponent;
*/
Loading

0 comments on commit e71ef26

Please sign in to comment.