Skip to content

Commit

Permalink
fix: change inactive check to assetStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
ImRodry committed Jun 7, 2024
1 parent 8597ee6 commit 21c9fbb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion scripts/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async function loadStationMarkersFromArray(stationsArray, showDocks = false) {

let iconStyle;

if (station.docks === 0) {
if (station.assetStatus === "repair") {
// Deactivated station

iconStyle = new ol.style.Style({
Expand Down
2 changes: 1 addition & 1 deletion scripts/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async function stopNavigation() {
.forEach(layer => map.removeLayer(layer));

// Add back the stations layer (only if user has clicked navigate to stations)
getStations();
loadStationMarkersFromArray(stationsArray);
}

// Show cycleways layer
Expand Down
2 changes: 1 addition & 1 deletion scripts/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ function addStationPointToMap(station, start = true) {
});

let iconStyle;
if (station.docks !== 0) {
if (station.assetStatus === "active") {
const bikeRatio = station.bikes / station.docks;
const filled =
station.bikes === 0
Expand Down
9 changes: 3 additions & 6 deletions scripts/stations.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ async function getStations() {
);

if (typeof response !== "undefined") {
// Load the stations to the map
stationsArray = response.data.getStations;
loadStationMarkersFromArray(stationsArray);

return response.data.getStations;
}
}
Expand Down Expand Up @@ -115,6 +111,7 @@ async function openStationMenu(stationSerialNumber) {
const numDocks = stationObj.dockList.filter(d => d.lockStatus === "unlocked").length - numBikes; // number of free docks
const distanceToStation = distance(pos, [lastStationObj.longitude, lastStationObj.latitude]);

console.log(stationObj);
// set the inner HTML after the animation has started
if (typeof bikeAndDocks.getBikes !== "undefined" && typeof bikeAndDocks.getDocks !== "undefined") {
menu.innerHTML = `
Expand All @@ -129,7 +126,7 @@ async function openStationMenu(stationSerialNumber) {
<div id="docksButton">${numDocks === 1 ? "1 doca" : `${numDocks} docas`}</div>
<img id="bikesImage" src="assets/images/mGira_bike.png" alt="Gira bike" width="25%">
<div id="bikesButton${
stationObj.docks === 0 ? 'Disabled"' : `" onclick="openBikeList('${stationSerialNumber}')"`
stationObj.assetStatus === "repair" ? 'Disabled"' : `" onclick="openBikeList('${stationSerialNumber}')"`
} >
${numBikes === 1 ? "1 bicicleta" : `${numBikes} bicicletas`}
</div>`;
Expand Down Expand Up @@ -192,7 +189,7 @@ function hideStationMenu(exitToRight = false) {
.setVisible(true);

// Add back the stations layer (only if user has clicked navigate to stations)
getStations();
loadStationMarkersFromArray(stationsArray);
}
}

Expand Down
10 changes: 5 additions & 5 deletions scripts/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ async function login(event) {
}

async function runStartupFunctions() {
// Start WebSocket connection
startWSConnection();

// Get all user details
getUserInformation();

Expand All @@ -102,8 +99,11 @@ async function runStartupFunctions() {
// Start rotation of location dot
startLocationDotRotation();

// Get the stations and load them to the map
await getStations();
// Start WebSocket connection and await the stations
startWSConnection();

// Load the stations into the map
loadStationMarkersFromArray(stationsArray);

// Show any messages from EMEL
await validateLogin();
Expand Down

0 comments on commit 21c9fbb

Please sign in to comment.