Compare commits

..

2 Commits

Author SHA1 Message Date
c82ef2e7af getcable 2024-05-08 17:04:24 -04:00
6656e3ba43 getcable 2024-05-08 17:01:33 -04:00
11 changed files with 362 additions and 117 deletions

View File

@ -70,6 +70,7 @@ $white: #fff;
transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out;
cursor: pointer; cursor: pointer;
text-decoration: none; text-decoration: none;
background-color: transparent;
filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25)); filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25));
} }

View File

@ -6,7 +6,8 @@ $black: #000;
$gray: #bdbdbd; $gray: #bdbdbd;
$white: #fff; $white: #fff;
.cable { .cable,
.loading {
background: linear-gradient( background: linear-gradient(
180deg, 180deg,
rgb(0 37 84 / 100%) 0%, rgb(0 37 84 / 100%) 0%,
@ -48,3 +49,140 @@ $white: #fff;
overflow: hidden; overflow: hidden;
background-color: transparent; background-color: transparent;
} }
.cable-main {
width: 80%;
height: 200px;
background: linear-gradient(
-30deg,
rgb(187, 208, 236) 0%,
rgba(255, 255, 255, 1) 100%
);
display: flex;
align-items: center;
justify-content: flex-start;
flex-direction: row;
border-radius: 20px;
border: 1px solid $gray;
padding: 25px;
margin-bottom: 5px;
margin-top: 5px;
transition: all 0.3s ease-in-out;
text-decoration: none;
filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25));
}
.cable-actions {
width: calc(80% + 50px);
height: 60px;
background-color: transparent;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
margin-bottom: 5px;
margin-top: 5px;
transition: all 0.3s ease-in-out;
text-decoration: none;
overflow: visible;
}
.cable-actions-button, .cable-actions-back {
width: 32%;
height: 100%;
background: linear-gradient(
-30deg,
rgb(187, 208, 236) 0%,
rgba(255, 255, 255, 1) 100%
);
display: flex;
align-items: center;
justify-content: space-between;
flex-direction: row;
border-radius: 20px;
border: 1px solid $gray;
transition: all 0.3s ease-in-out;
text-decoration: none;
filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25));
cursor: pointer;
overflow: visible;
}
.cable-actions-button:hover, .cable-main:hover, .cable-actions-back:hover {
transform: translate3d(-5px, -5px, 0);
}
.cable-actions-back {
width: auto;
background: linear-gradient(
-30deg,
rgb(187, 194, 236) 0%,
rgba(255, 255, 255, 1) 100%
);
}
.cable-actions-button span, .cable-actions-back span {
text-align: center;
font-family: "Gotham Medium";
font-size: 20px;
text-decoration: none;
color: $medium-blue;
width: auto;
height: auto;
margin: 20px;
background-color: transparent;
}
.cable-main-image {
aspect-ratio: 1/1;
width: auto;
height: 100%;
object-fit: cover;
background-color: white;
margin-right: 25px;
border: $gray solid 1px;
border-radius: 10px;
filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25));
}
.cable-main-label {
width: 60%;
height: 100%;
background-color: transparent;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
}
.cable-main-name {
background-color: transparent;
font-size: 32px;
color: $medium-blue;
width: auto;
height: auto;
font-family: "Gotham Bold";
margin-bottom: 5px;
}
.cable-main-description {
background-color: transparent;
font-size: 18px;
color: $medium-blue;
width: auto;
height: auto;
font-family: "Gotham Medium";
margin-bottom: 30px;
}
.cable-main-brand,
.cable-main-short,
.cable-main-position {
background-color: transparent;
font-size: 16px;
color: $light-blue;
color: $light-blue;
width: auto;
height: auto;
font-family: "Gotham Medium";
}

View File

@ -10,34 +10,42 @@ $white: #fff;
background: linear-gradient( background: linear-gradient(
180deg, 180deg,
rgb(0 37 84 / 100%) 0%, rgb(0 37 84 / 100%) 0%,
rgb(0 124 190 / 100%) 26%, rgb(0 124 190 / 100%) 50%,
rgb(255 255 255) 39%, rgb(255, 255, 255) 100%
rgb(255 255 255 / 100%) 100%
); );
background-color: transparent; background-color: transparent;
overflow-y: visible;
width: calc(100% - 300px); width: calc(100% - 300px);
height: auto; height: auto;
overflow-y: visible; display: block;
display: flex;
align-items: center;
justify-content: center; justify-content: center;
flex-direction: column; align-items: center;
overflow: visible;
} }
.map-image { .map-image {
width: auto; width: 100%;
height: 250px; height: 200px;
background: transparent; background: transparent;
display: flex;
align-items: center;
justify-content: center;
}
.map-image img {
width: auto;
height: 200px;
background-color: transparent;
} }
.map-fieldContainer { .map-fieldContainer {
width: 100%; width: 100%;
min-height: calc(100% - 250px); min-height: calc(100% - 200px);
height: auto; height: auto;
background-color: transparent;
display: flex; display: flex;
align-items: flex-start; align-items: center;
justify-content: center; justify-content: flex-start;
flex-wrap: wrap; flex-direction: column;
overflow: hidden;
background-color: transparent;
margin-bottom: 50px;
} }

View File

@ -10,34 +10,42 @@ $white: #fff;
background: linear-gradient( background: linear-gradient(
180deg, 180deg,
rgb(0 37 84 / 100%) 0%, rgb(0 37 84 / 100%) 0%,
rgb(0 124 190 / 100%) 26%, rgb(0 124 190 / 100%) 50%,
rgb(255 255 255) 39%, rgb(255, 255, 255) 100%
rgb(255 255 255 / 100%) 100%
); );
background-color: transparent; background-color: transparent;
overflow-y: visible;
width: calc(100% - 300px); width: calc(100% - 300px);
height: auto; height: auto;
overflow-y: visible; display: block;
display: flex;
align-items: center;
justify-content: center; justify-content: center;
flex-direction: column; align-items: center;
overflow: visible;
} }
.settings-image { .settings-image {
width: auto; width: 100%;
height: 250px; height: 200px;
background: transparent; background: transparent;
display: flex;
align-items: center;
justify-content: center;
}
.settings-image img {
width: auto;
height: 200px;
background-color: transparent;
} }
.settings-fieldContainer { .settings-fieldContainer {
width: 100%; width: 100%;
min-height: calc(100% - 250px); min-height: calc(100% - 200px);
height: auto; height: auto;
background-color: transparent;
display: flex; display: flex;
align-items: flex-start; align-items: center;
justify-content: center; justify-content: flex-start;
flex-wrap: wrap; flex-direction: column;
overflow: hidden;
background-color: transparent;
margin-bottom: 50px;
} }

View File

@ -2,33 +2,35 @@ $dark-blue: #002554;
$medium-blue: #004990; $medium-blue: #004990;
$light-blue: #007cbe; $light-blue: #007cbe;
$hover-blue: #25b3ff; $hover-blue: #25b3ff;
$black: #000;
$gray: #bdbdbd;
$white: #fff;
.summary { .summary {
background: linear-gradient( background: linear-gradient(
180deg, 180deg,
rgb(0 37 84 / 100%) 0%, rgb(0 37 84 / 100%) 0%,
rgb(0 124 190 / 100%) 26%, rgb(0 124 190 / 100%) 50%,
rgb(255 255 255) 39%, rgb(255, 255, 255) 100%
rgb(255 255 255 / 100%) 100%
); );
background-color: transparent; background-color: transparent;
overflow-y: visible;
width: calc(100% - 300px); width: calc(100% - 300px);
height: auto; height: auto;
overflow-y: visible; display: block;
display: flex;
align-items: center;
justify-content: center; justify-content: center;
flex-direction: column; align-items: center;
overflow: visible;
} }
.summary-image { .summary-image {
width: auto; width: 100%;
height: 250px; height: 200px;
background: transparent; background: transparent;
display: flex;
align-items: center;
justify-content: center;
}
.summary-image img {
width: auto;
height: 200px;
background-color: transparent;
} }
.summary-fieldContainer { .summary-fieldContainer {
@ -62,3 +64,23 @@ $white: #fff;
margin: 10px; margin: 10px;
display: block; display: block;
} }
.summary-fieldContainer-pp {
width: 25%;
height: 300px;
border-radius: 20px;
text-align: center;
padding: 10px;
}
.summary-fieldContainer-graph {
width: 25%;
}
.summary-fieldContainer-dashboard {
width: 100%;
height: 300px;
border-radius: 20px;
text-align: center;
padding: 10px;
}

View File

@ -19,23 +19,23 @@ class cable {
this.name = name; this.name = name;
this.brand = brand; this.brand = brand;
this.description = description; this.description = description;
this.short_description = short_description; this.short_description = short_description
if (image === undefined) { ? short_description
this.image = DefaultPartImg; : description;
} else { this.image = image
this.image = image; ? `http://localhost${image}`
} : DefaultPartImg;
} }
returnDiv() { returnDiv() {
return ( return (
<NavLink className="browse-cable" to={"/cable/" + this.part_number}> <NavLink className="browse-cable" to={"/browse/cable/" + this.position}>
<img className="browse-cable-image" src={this.image} alt="Cable" /> <img className="browse-cable-image" src={this.image} alt="Cable" />
<div className="browse-cable-label"> <div className="browse-cable-label">
<div className="browse-cable-name">{this.name}</div> <div className="browse-cable-name">{this.name}</div>
<div className="browse-cable-description"> <div className="browse-cable-description">
<span style={{ color: "#007cbe" }}></span> <span style={{ color: "#007cbe" }}></span>
{this.description} {this.short_description}
</div> </div>
<div className="browse-cable-brand"> <div className="browse-cable-brand">
<span style={{ color: "black", backgroundColor: "transparent" }}> <span style={{ color: "black", backgroundColor: "transparent" }}>
@ -85,6 +85,7 @@ export default class BrowseComponent extends Component {
let map = message.data.map; let map = message.data.map;
for (let i = 0; i < map.length; i++) { for (let i = 0; i < map.length; i++) {
let part_number = map[i].part_number; let part_number = map[i].part_number;
let image = map[i].image;
let position = map[i].position; let position = map[i].position;
let name = map[i].name; let name = map[i].name;
let brand = map[i].brand; let brand = map[i].brand;
@ -97,7 +98,8 @@ export default class BrowseComponent extends Component {
name, name,
brand, brand,
description, description,
short_description short_description,
image
) )
); );
} }

View File

@ -4,82 +4,143 @@ import DefaultPartImg from "../assets/images/part.png";
import { NavLink } from "react-router-dom"; import { NavLink } from "react-router-dom";
import "../assets/stylesheets/cabledetail.scss"; import "../assets/stylesheets/cabledetail.scss";
class cable { class Cable {
constructor( constructor(cableData) {
part_number, this.partnum = cableData.partnum;
position, this.id = cableData.id;
name, this.brand = cableData.brand;
brand, this.position = cableData.position;
description, this.description = cableData.description
short_description, ? cableData.image
image : "No description available.";
) { this.image = cableData.image
this.part_number = part_number; ? `http://localhost${cableData.image}`
this.position = position; : DefaultPartImg;
this.name = name; this.dynamicProps = {};
this.brand = brand;
this.description = description;
this.short_description = short_description;
if (image === undefined) {
this.image = DefaultPartImg;
} else {
this.image = image;
}
}
returnDiv() { Object.keys(cableData).forEach((key) => {
return ( if (!["partnum", "id", "brand", "position", "image"].includes(key)) {
<NavLink className="browse-cable" to={"/cable/" + this.part_number}> this.dynamicProps[key] = cableData[key];
<img className="browse-cable-image" src={this.image} alt="Cable" /> }
<div className="browse-cable-label"> });
<div className="browse-cable-name">{this.name}</div>
<div className="browse-cable-brand">
<span style={{ color: "#007cbe" }}>Brand: </span>
{this.brand}
</div>
<div className="browse-cable-description">
<span style={{ color: "#007cbe" }}>About: </span>
{this.description}
</div>
</div>
<span className="browse-cable-arrow">{">"}</span>
</NavLink>
);
} }
} }
export default class CableDetailComponent extends Component { export default class CableDetailComponent extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {
cableDetails: null,
};
} }
componentDidMount() { componentDidMount() {
// this.props.socket.send('{"type":"cable_map","call":"request","data":{}}'); const cablePos = window.location.href.split("/").pop();
// this.props.socket.addEventListener("message", this.handleMessage); this.props.socket.send(
const id = this.props.cableId; `{"type":"cable_details","call":"request","data":{"position":["${cablePos}"]}}`
console.log("ID: ", id); );
this.props.socket.addEventListener("message", this.handleMessage);
} }
// handleMessage = (event) => { handleMessage = (event) => {
// try { try {
// console.log("Message from server", event.data); console.log("Message from server", event.data);
// const message = JSON.parse(event.data); const message = JSON.parse(event.data);
// } catch (error) { const cableDetails = new Cable(message.data.cables[0]);
// console.error("Error parsing message from server:", error); this.setState({ cableDetails });
// } } catch (error) {
// }; console.error("Error parsing message from server:", error);
}
};
// componentWillUnmount() { componentWillUnmount() {
// this.props.socket.removeEventListener("message", this.handleMessage); this.props.socket.removeEventListener("message", this.handleMessage);
// } }
renderTables() {
const { cableDetails } = this.state;
if (!cableDetails) return null;
return Object.keys(cableDetails.dynamicProps).map((key) => (
<div key={key}>
<h2>{key.replace(/([A-Z])/g, " $1").trim()}</h2>
<table>
<tbody>
{Object.entries(cableDetails.dynamicProps[key]).map(
([propKey, value]) => (
<tr key={propKey}>
<td>{propKey}</td>
<td>{Array.isArray(value) ? value.join(", ") : value}</td>
</tr>
)
)}
</tbody>
</table>
</div>
));
}
render() { render() {
const { cableDetails } = this.state;
return ( return (
<div className="cable"> <div className="cable">
<div className="cable-image"> <div className="cable-image">
<img src={BeldenLogo} alt="Belden" /> <img src={BeldenLogo} alt="Belden" />
</div> </div>
<div className="cable-fieldContainer"> <div className="cable-fieldContainer">
<div className="cable-actions">
<NavLink to="/browse" className="cable-actions-back">
<span> Back</span>
</NavLink>
</div>
{cableDetails ? (
<div className="cable-main">
<img
className="cable-main-image"
src={cableDetails.image}
alt="Cable"
/>
<div className="cable-main-label">
<div className="cable-main-name">{cableDetails.partnum}</div>
<div className="cable-main-description">
{cableDetails.description}
</div>
<div className="cable-main-brand">
<span
style={{ color: "black", backgroundColor: "transparent" }}
>
Brand:{" "}
</span>
{cableDetails.brand}
</div>
<div className="cable-main-position">
<span
style={{ color: "black", backgroundColor: "transparent" }}
>
Position:{" "}
</span>
{cableDetails.position}
</div>
</div>
</div>
) : (
<div className="cable-main"></div>
)}
<div className="cable-actions">
<div className="cable-actions-button">
<span> Datasheet</span>
<span></span>
</div>
<div className="cable-actions-button">
<span> Show</span>
<span>💡</span>
</div>
<div className="cable-actions-button">
<span> Dispense</span>
<span>🤲</span>
</div>
</div>
</div> </div>
</div> </div>
); );

View File

@ -6,8 +6,11 @@ export default class MapComponent extends Component {
render() { render() {
return ( return (
<div className="map"> <div className="map">
<img className="map-image" src={BeldenLogo} alt="Belden" /> <div className="map-image">
<div className="map-fieldContainer"></div> <img src={BeldenLogo} alt="Belden" />
</div>
<div className="map-fieldContainer">
</div>
</div> </div>
); );
} }

View File

@ -6,7 +6,9 @@ export default class SettingsComponent extends Component {
render() { render() {
return ( return (
<div className="settings"> <div className="settings">
<img className="settings-image" src={BeldenLogo} alt="Belden" /> <div className="settings-image">
<img src={BeldenLogo} alt="Belden" />
</div>
<div className="settings-fieldContainer"></div> <div className="settings-fieldContainer"></div>
</div> </div>
); );

View File

@ -44,7 +44,7 @@ const init = () => {
// errorElement: <ErrorRoute></ErrorRoute>, // errorElement: <ErrorRoute></ErrorRoute>,
}, },
{ {
path: "/cable/:cableId", path: "/browse/cable/:cablePos",
element: <CableDetailRoute socket={socket} />, element: <CableDetailRoute socket={socket} />,
// errorElement: <ErrorRoute></ErrorRoute>, // errorElement: <ErrorRoute></ErrorRoute>,
}, },

View File

@ -13,7 +13,7 @@ export default class CableDetailRoute extends Component {
return ( return (
<div className="container"> <div className="container">
<NavBar /> <NavBar />
<CableDetailComponent /> <CableDetailComponent socket={this.props.socket} />
</div> </div>
); );
} }