CEC-3751, CEC-3478 misc window status and invalid location value (#287)

* CEC-3751 misc window status
CEC-3478 invalid location value

* Fix snapshot
Update browser list
This commit is contained in:
John Wu
2023-03-02 12:26:41 -08:00
committed by GitHub
parent 54f4386a58
commit 7b6a2bfa11
4 changed files with 21 additions and 24 deletions

12
package-lock.json generated
View File

@@ -6941,9 +6941,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001387", "version": "1.0.30001458",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001387.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz",
"integrity": "sha512-fKDH0F1KOJvR+mWSOvhj8lVRr/Q/mc5u5nabU2vi1/sgvlSqEsE8dOq0Hy/BqVbDkCYQPRRHB1WRjW6PGB/7PA==", "integrity": "sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@@ -22881,9 +22881,9 @@
} }
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001387", "version": "1.0.30001458",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001387.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz",
"integrity": "sha512-fKDH0F1KOJvR+mWSOvhj8lVRr/Q/mc5u5nabU2vi1/sgvlSqEsE8dOq0Hy/BqVbDkCYQPRRHB1WRjW6PGB/7PA==" "integrity": "sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w=="
}, },
"case-sensitive-paths-webpack-plugin": { "case-sensitive-paths-webpack-plugin": {
"version": "2.4.0", "version": "2.4.0",

View File

@@ -123,7 +123,7 @@ exports[`DigitalTwinTab Render 1`] = `
sunroof sunroof
</b> </b>
: :
closed closed (0)
</p> </p>
</div> </div>
<div <div

View File

@@ -13,6 +13,14 @@ const openCloseState = (value) => (value ? "open" : "closed");
const mapOpenCloseState = (value) => const mapOpenCloseState = (value) =>
keyValueTemplate(value[0], openCloseState(value[1])); keyValueTemplate(value[0], openCloseState(value[1]));
const windowState = (value) => {
if (value[1] === 0 || value[1] > 100) {
return keyValueTemplate(value[0], `closed (${value[1]})`);
} else {
return keyValueTemplate(value[0], `${value[1]}% open`);
}
}
const DigitalTwin = (props) => { const DigitalTwin = (props) => {
const classes = useStyles(); const classes = useStyles();
const { battery, doors, location, trex_version, ip, updated, windows, misc_windows, sunroof, dbc_version, door_locks } = props; const { battery, doors, location, trex_version, ip, updated, windows, misc_windows, sunroof, dbc_version, door_locks } = props;
@@ -45,12 +53,7 @@ const DigitalTwin = (props) => {
<div className={classes.popupSection}> <div className={classes.popupSection}>
<h3>Windows</h3> <h3>Windows</h3>
{Object.entries(windows).map((value) => { {Object.entries(windows).map((value) => {
if (value[1] === 0) { return windowState(value);
return keyValueTemplate(value[0], "closed");
} else {
const percentOpen = Math.min(value[1], 100);
return keyValueTemplate(value[0], `${percentOpen}% open`);
}
})} })}
</div> </div>
)} )}
@@ -58,11 +61,7 @@ const DigitalTwin = (props) => {
<div className={classes.popupSection}> <div className={classes.popupSection}>
<h3>Misc Windows</h3> <h3>Misc Windows</h3>
{Object.entries(misc_windows).map((value) => { {Object.entries(misc_windows).map((value) => {
if (value[1] === 0 || value[1] > 100) { return windowState(value);
return keyValueTemplate(value[0], `closed ${value[1]}%`);
} else {
return keyValueTemplate(value[0], `${value[1]}% open`);
}
})} })}
</div> </div>
)} )}
@@ -70,12 +69,7 @@ const DigitalTwin = (props) => {
<div className={classes.popupSection}> <div className={classes.popupSection}>
<h3>Sunroof</h3> <h3>Sunroof</h3>
{Object.entries(sunroof).map((value) => { {Object.entries(sunroof).map((value) => {
if (value[1] === 0) { return windowState(value);
return keyValueTemplate(value[0], "closed");
} else {
const percentOpen = Math.min(value[1], 100);
return keyValueTemplate(value[0], `${percentOpen}% open`);
}
})} })}
</div> </div>
)} )}

View File

@@ -1,3 +1,5 @@
const invalidLocation = 99999;
export const ValidateLocationData = (location) => { export const ValidateLocationData = (location) => {
if (Math.abs(location.latitude) > 90 || Math.abs(location.longitude) > 180) { if (Math.abs(location.latitude) > 90 || Math.abs(location.longitude) > 180) {
return false; return false;
@@ -9,6 +11,7 @@ export const ValidateLocationData = (location) => {
} }
export const ValidateLocationByParam = (parameter, value) => { export const ValidateLocationByParam = (parameter, value) => {
if (invalidLocation === value) return false;
switch (parameter) { switch (parameter) {
case "latitude": case "latitude":
return Math.abs(value) <= 90; return Math.abs(value) <= 90;