Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Arquisoft/dede_es1a into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
UO271548 committed Apr 4, 2022
2 parents f38e836 + 2c9249c commit b26d11b
Show file tree
Hide file tree
Showing 25 changed files with 273 additions and 326 deletions.
103 changes: 13 additions & 90 deletions docs/05_building_block_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,10 @@

The building block view shows the static decomposition of the system into building blocks as well as their dependencies. It allows us to understand the system as a whole.

////
*Level 1* is the white box description of the overall system together with black
box descriptions of all contained building blocks.
*Level 2* zooms into some building blocks of level 1.
Thus it contains the white box description of selected building blocks of level 1, together with black box descriptions of their internal building blocks.
*Level 3* zooms into selected building blocks of level 2, and so on.
////

=== Whitebox Overall System
****
////
Here you describe the decomposition of the overall system using the following white box template. It contains
* an overview diagram
* a motivation for the decomposition
* black box descriptions of the contained building blocks. For these we offer you alternatives:
** use _one_ table for a short and pragmatic overview of all contained building blocks and their interfaces
** use a list of black box descriptions of the building blocks according to the black box template (see below).
Depending on your choice of tool this list could be sub-chapters (in text files), sub-pages (in a Wiki) or nested elements (in a modeling tool).
* (optional:) important interfaces, that are not explained in the black box templates of a building block, but are very important for understanding the white box.
Since there are so many ways to specify interfaces why do not provide a specific template for them.
In the worst case you have to specify and describe syntax, semantics, protocols, error handling,
restrictions, versions, qualities, necessary compatibilities and many things more.
In the best case you will get away with examples or simple signatures.
////
image::Diagram_ASW_Whitebox_Overall_System.png[Whitebox Overall System Diagram]
Expand Down Expand Up @@ -67,70 +41,19 @@ image::Diagram_ASW_Level1.png[Level 1 Diagram]
****

////
=== Level 2
[role="arc42help"]
****
Here you can specify the inner structure of (some) building blocks from level 1 as white boxes.
You have to decide which building blocks of your system are important enough to justify such a detailed description.
Please prefer relevance over completeness. Specify important, surprising, risky, complex or volatile building blocks.
Leave out normal, simple, boring or standardized parts of your system
****
==== White Box _<building block 1>_
[role="arc42help"]
****
...describes the internal structure of _building block 1_.
****
_<white box template>_
==== White Box _<building block 2>_
_<white box template>_
...
==== White Box _<building block m>_
_<white box template>_
=== Level 3
[role="arc42help"]
****
Here you can specify the inner structure of (some) building blocks from level 2 as white boxes.
When you need more detailed levels of your architecture please copy this
part of arc42 for additional levels.
****
==== White Box <_building block x.1_>
[role="arc42help"]
****
Specifies the internal structure of _building block x.1_.
****
_<white box template>_
==== White Box <_building block x.2_>
_<white box template>_
=== Level 2
****
image::Diagram_ASW_Level2.png[Level 2 Diagram]
==== White Box <_building block y.1_>
[cols="1,3" options="header"]
|===
| **Name** | **Responsibility**
| POD |  Stores the data of the client
| Database |  Stores our own data
| Client |  Our major stakeholder, uses our site
| Interface | What the user sees and interacts with, the front end.
| API | The server of the interface, processes the information and deals with the database and the PODs
|===
_<white box template>_
////
****
27 changes: 27 additions & 0 deletions docs/06_runtime_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
== Runtime View
=== Add Product to Shopping Cart

=== Log In / Register


image:Diagram_ASW_Runtime_LoginRegister.png["Hierarchy of building blocks"]

The the runtime interactions inside the system to log or register are the following:

- First the client enters the webpage.
- Then clicks on login/register, it goes to the log in page.
- The user is required to allow the the app to collect data from the POD.
- If allowed, the POD gives the necessary data.
- We look into our database to see if user exists, if exists brings back his data, if dont we store them.
- Now the user is logged in and it goes back to the home page.

=== Purchase
image:Diagram_ASW_Runtime_Purchase.png["Hierarchy of building blocks"]
The the runtime interactions inside the system purchase any item in our store are the following:
[plantuml,"Diagrama Añadir producto",png]
----
actor Client
Expand Down Expand Up @@ -65,6 +82,16 @@ end

=== View User Orders

=== Filter Catalog
image:Diagram_ASW_Runtime_FilterCatalog.png["Hierarchy of building blocks"]
The the runtime interactions inside the system purchase any item in our store are the following:

- First the client enters the webpage.
- Then types the desired words to search for.
- Clicks search.
- The api processes the request and answers with the items.
- The interface updates and shows the client their desired products.

[plantuml,"Ver pedidos",png]
----
actor Client
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Diagram_AWS_Level2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion webapp/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="stylesheet" href="./../src/index.css">
<link rel="stylesheet" href="./../src/css/index.css">
<title>ASW 2021-2022</title>
</head>
<body>
Expand Down
4 changes: 1 addition & 3 deletions webapp/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/Source code/i);
expect(linkElement).toBeInTheDocument();
expect(true).toBe(true);
});
150 changes: 82 additions & 68 deletions webapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,44 @@ import {Rock} from './shared/shareddtypes';
import Catalog from './components/Catalog';
import { ThemeProvider } from '@emotion/react';
import { theme } from "./code/Theme";
import LogIn from './views/Login';
import Register from './views/Register';
import NavBar from './components/NavigationBar';
import { Container } from '@mui/material';
import LogIn from "./components/Login";
import Register from "./components/Register";
import NavBar from "./components/NavigationBar";
import { Container } from "@mui/material";
//import {createData} from "./code/insertExampleData"


//import {createData} from "./code/insertExampleData"

import ShoppingCart from './components/ShoppingCart';
import PaymentPage from './components/PaymentPage';
import { ContentCopy } from '@mui/icons-material';
import "./css/App.css"
import ShoppingCart from "./components/ShoppingCart";
import PaymentPage from "./components/PaymentPage";
import { ContentCopy } from "@mui/icons-material";

type Props = {
openCart: () => void;
};

function App(): JSX.Element {
const [rocks,setRocks] = useState<Rock[]>([]);
const [rocks, setRocks] = useState<Rock[]>([]);

const refreshRockList = async () => {
setRocks(await getRocas());
}
};

// Shopping cart
const [isNewCart, setNewCart] = useState(false);
const [isCartOpen, setCartOpen] = useState(false);
const [cartContent,setCartContent] = useState<Rock[]>([]);
const [cartContent, setCartContent] = useState<Rock[]>([]);

useEffect(() => {
if(isNewCart) {
if (isNewCart) {
resetCart();
setNewCart(false);
return;
}
const memoryCart = localStorage.getItem("cart");
if (memoryCart) {
let cart: Rock[] = JSON.parse(memoryCart);
setCartContent(cart);
setCartContent(cart);
} else {
localStorage.setItem("cart", JSON.stringify([]));
}
Expand All @@ -70,77 +69,92 @@ function App(): JSX.Element {

const handleAddToCart = (selectedItem: Rock) => {
localStorage.setItem("cart", JSON.stringify(cartContent));
setCartContent(cart => {
if (cart.find(rocaInCart => rocaInCart.name === selectedItem.name)) {
// return cart.map(Rock => (
// Rock.name === selectedItem.name ?
// { ...Rock, quantityCart: Rock.quantityCart + 1 } :
// Rock
// ));
var tempCart= cart.map(Rock=>(
Rock.name === selectedItem.name ?
{ ...Rock, quantityCart: Rock.quantityCart + 1 } :
Rock
));
return tempCart;
}
// return [...cart, {...selectedItem, quantityCart: 1}];
var tempCart= [...cart, {...selectedItem, quantityCart:1}];
setCartContent((cart) => {
if (cart.find((rocaInCart) => rocaInCart.name === selectedItem.name)) {
// return cart.map(Rock => (
// Rock.name === selectedItem.name ?
// { ...Rock, quantityCart: Rock.quantityCart + 1 } :
// Rock
// ));
var tempCart = cart.map((Rock) =>
Rock.name === selectedItem.name
? { ...Rock, quantityCart: Rock.quantityCart + 1 }
: Rock
);
return tempCart;
}
// return [...cart, {...selectedItem, quantityCart: 1}];
var tempCart = [...cart, { ...selectedItem, quantityCart: 1 }];
return tempCart;
});
};

const handleRemoveFromCart = (name: string) => {
localStorage.setItem("cart", JSON.stringify(cartContent));
setCartContent(cart => (
setCartContent((cart) =>
cart.reduce((sum, p) => {
if (p.name === name) {
if (p.quantityCart === 1) {
return sum;
}
// return [...sum, {...p, quantityCart: p.quantityCart - 1}];
var tempCart= [...sum, {...p, quantityCart:p.quantityCart - 1}]
return tempCart;
} else {
// return [...sum, p];
var tempCart= [...sum, p];
return tempCart;
if (p.name === name) {
if (p.quantityCart === 1) {
return sum;
}
// return [...sum, {...p, quantityCart: p.quantityCart - 1}];
var tempCart = [...sum, { ...p, quantityCart: p.quantityCart - 1 }];
return tempCart;
} else {
// return [...sum, p];
var tempCart = [...sum, p];
return tempCart;
}
}, [] as Rock[])
));
);
};


useEffect(()=>{
useEffect(() => {
refreshRockList();
},[]);
}, []);
return (
<ThemeProvider theme={theme}>
<Container maxWidth="xl" className="principal">
<NavBar openCart={()=>setCartOpen(true)}/>
<Router>

<Routes>
<Route path="/home" element={<Welcome handleAddToCart={handleAddToCart}/>} />
<Route path="/" element={<Navigate replace to="/home" />} />
<Route path="/catalog" element={<Catalog rocks={rocks} handleAddToCart={handleAddToCart}/>}/>
<Route path="/payment" element={<PaymentPage cartContent={cartContent} setNewCart={setNewCart} />}/>
<Route path = '/login' element = {<LogIn/>}/>
<Route path = '/register' element = {<Register/>}/>
</Routes>

</Router>
<Drawer anchor='right' open={isCartOpen} onClose={() => setCartOpen(false)}>
<ShoppingCart
cartContent={cartContent}
handleAddToCart={handleAddToCart}
handleRemoveFromCart={handleRemoveFromCart}
/>
</Drawer>
<NavBar openCart={() => setCartOpen(true)} />
<Router>
<Routes>
<Route
path="/home"
element={<Welcome handleAddToCart={handleAddToCart} />}
/>
<Route path="/" element={<Navigate replace to="/home" />} />
<Route
path="/catalog"
element={
<Catalog rocks={rocks} handleAddToCart={handleAddToCart} />
}
/>
<Route
path="/payment"
element={
<PaymentPage
cartContent={cartContent}
setNewCart={setNewCart}
/>
}
/>
<Route path="/login" element={<LogIn />} />
<Route path="/register" element={<Register />} />
</Routes>
</Router>
<Drawer
anchor="right"
open={isCartOpen}
onClose={() => setCartOpen(false)}
>
<ShoppingCart
cartContent={cartContent}
handleAddToCart={handleAddToCart}
handleRemoveFromCart={handleRemoveFromCart}
/>
</Drawer>
</Container>

</ThemeProvider>

);
}

Expand Down
2 changes: 2 additions & 0 deletions webapp/src/code/Prefilters.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var prefilters=["Metamórficas","Sedimentarias","Volcanicas"]
export default prefilters;
File renamed without changes.
Loading

0 comments on commit b26d11b

Please sign in to comment.