Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
integrated more cahnges
Browse files Browse the repository at this point in the history
  • Loading branch information
evansuong committed Apr 15, 2021
1 parent 9b9a0cc commit c734ee4
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 221 deletions.
2 changes: 1 addition & 1 deletion .eslintcache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/index.js":"1","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/App.jsx":"2","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/ChartPanel.jsx":"3","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/Map.jsx":"4","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/InfoPanel.jsx":"5","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SessionList.jsx":"6","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/DateFilter.jsx":"7","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SmartfinMap.jsx":"8","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SearchInput.jsx":"9","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/index.js":"10","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/App.jsx":"11","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/Map.jsx":"12","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/ChartPanel.jsx":"13","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/InfoPanel.jsx":"14","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SmartfinMap.jsx":"15","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/DateFilter.jsx":"16","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SearchInput.jsx":"17","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SessionList.jsx":"18","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.react.js":"19","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.min.js":"20"},{"size":231,"mtime":1614119328701,"results":"21","hashOfConfig":"22"},{"size":549,"mtime":1618209148173,"results":"23","hashOfConfig":"22"},{"size":10754,"mtime":1618294587196,"results":"24","hashOfConfig":"22"},{"size":5991,"mtime":1618294417335,"results":"25","hashOfConfig":"22"},{"size":3504,"mtime":1618292888085,"results":"26","hashOfConfig":"22"},{"size":1327,"mtime":1618288058886,"results":"27","hashOfConfig":"22"},{"size":1646,"mtime":1618215380619,"results":"28","hashOfConfig":"22"},{"size":2400,"mtime":1618293741666,"results":"29","hashOfConfig":"22"},{"size":857,"mtime":1614919248018,"results":"30","hashOfConfig":"22"},{"size":231,"mtime":1614119328701,"results":"31","hashOfConfig":"32"},{"size":464,"mtime":1617745880967,"results":"33","hashOfConfig":"32"},{"size":7168,"mtime":1617749923987,"results":"34","hashOfConfig":"32"},{"size":2358,"mtime":1614929190546,"results":"35","hashOfConfig":"32"},{"size":2728,"mtime":1617748315357,"results":"36","hashOfConfig":"32"},{"size":1649,"mtime":1617748131180,"results":"37","hashOfConfig":"32"},{"size":1646,"mtime":1617750011753,"results":"38","hashOfConfig":"32"},{"size":857,"mtime":1614919248018,"results":"39","hashOfConfig":"32"},{"size":1311,"mtime":1614923275663,"results":"40","hashOfConfig":"32"},{"size":1720,"mtime":1618207459158,"results":"41","hashOfConfig":"22"},{"size":459239,"mtime":1618207457353,"results":"42","hashOfConfig":"22"},{"filePath":"43","messages":"44","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"45"},"1voh3dn",{"filePath":"46","messages":"47","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"45"},{"filePath":"48","messages":"49","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"52","messages":"53","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"54","messages":"55","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"45"},{"filePath":"56","messages":"57","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"45"},{"filePath":"58","messages":"59","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"60","messages":"61","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"45"},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1xlz4ck",{"filePath":"64","messages":"65","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"66","messages":"67","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"68","messages":"69","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"72","messages":"73","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"74","messages":"75","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"78","messages":"79","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"80","messages":"81","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"45"},{"filePath":"82","messages":"83","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"45"},"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/index.js",[],[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/App.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/ChartPanel.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/Map.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/InfoPanel.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SessionList.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/DateFilter.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SmartfinMap.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SearchInput.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/index.js",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/App.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/Map.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/ChartPanel.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/InfoPanel.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SmartfinMap.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/DateFilter.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SearchInput.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SessionList.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.react.js",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.min.js",[]]
[{"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/index.js":"1","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/App.jsx":"2","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/ChartPanel.jsx":"3","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/Map.jsx":"4","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/InfoPanel.jsx":"5","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SessionList.jsx":"6","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/DateFilter.jsx":"7","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SmartfinMap.jsx":"8","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SearchInput.jsx":"9","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/index.js":"10","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/App.jsx":"11","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/Map.jsx":"12","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/ChartPanel.jsx":"13","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/InfoPanel.jsx":"14","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SmartfinMap.jsx":"15","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/DateFilter.jsx":"16","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SearchInput.jsx":"17","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SessionList.jsx":"18","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.react.js":"19","/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.min.js":"20","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.react.js":"21","/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.min.js":"22"},{"size":231,"mtime":1614119328701,"results":"23","hashOfConfig":"24"},{"size":549,"mtime":1618209148173,"results":"25","hashOfConfig":"24"},{"size":10754,"mtime":1618294587196,"results":"26","hashOfConfig":"24"},{"size":5991,"mtime":1618294417335,"results":"27","hashOfConfig":"24"},{"size":3504,"mtime":1618292888085,"results":"28","hashOfConfig":"24"},{"size":1327,"mtime":1618288058886,"results":"29","hashOfConfig":"24"},{"size":1646,"mtime":1618215380619,"results":"30","hashOfConfig":"24"},{"size":2400,"mtime":1618293741666,"results":"31","hashOfConfig":"24"},{"size":857,"mtime":1614919248018,"results":"32","hashOfConfig":"24"},{"size":231,"mtime":1614119328701,"results":"33","hashOfConfig":"34"},{"size":549,"mtime":1618209148173,"results":"35","hashOfConfig":"34"},{"size":5889,"mtime":1618460073739,"results":"36","hashOfConfig":"34"},{"size":10786,"mtime":1618438416202,"results":"37","hashOfConfig":"34"},{"size":3605,"mtime":1618450860694,"results":"38","hashOfConfig":"34"},{"size":2551,"mtime":1618450867486,"results":"39","hashOfConfig":"34"},{"size":1638,"mtime":1618460459029,"results":"40","hashOfConfig":"34"},{"size":1145,"mtime":1618460062558,"results":"41","hashOfConfig":"34"},{"size":2514,"mtime":1618458954681,"results":"42","hashOfConfig":"34"},{"size":1720,"mtime":1618207459158,"results":"43","hashOfConfig":"24"},{"size":459239,"mtime":1618207457353,"results":"44","hashOfConfig":"24"},{"size":1720,"mtime":1618207459158,"results":"45","hashOfConfig":"34"},{"size":459239,"mtime":1618207457353,"results":"46","hashOfConfig":"34"},{"filePath":"47","messages":"48","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},"1voh3dn",{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"52","messages":"53","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"54","messages":"55","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"56","messages":"57","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"60","messages":"61","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"66","messages":"67","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"68"},"1xlz4ck",{"filePath":"69","messages":"70","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"68"},{"filePath":"71","messages":"72","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"75","messages":"76","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"77","messages":"78","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"79","messages":"80","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"81","messages":"82","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"83","messages":"84","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"85","messages":"86","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"87","messages":"88","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"49"},{"filePath":"89","messages":"90","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"68"},{"filePath":"91","messages":"92","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"68"},"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/index.js",[],[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/App.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/ChartPanel.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/Map.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/InfoPanel.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SessionList.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/DateFilter.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SmartfinMap.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/components/SearchInput.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/index.js",[],[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/App.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/Map.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/ChartPanel.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/InfoPanel.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SmartfinMap.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/DateFilter.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SearchInput.jsx",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/components/SessionList.jsx",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.react.js",[],"/mnt/c/Users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.min.js",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.react.js",[],"/mnt/c/users/evans/Desktop/smartfin-maps-repo/src/assets/canvasjs.min.js",[]]
85 changes: 40 additions & 45 deletions src/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ import ChartPanel from './components/ChartPanel';

const API = {
fetchSessions: async function() {
console.log('sessions: ');

let sessions = await fetch("http://ec2-54-203-7-235.us-west-2.compute.amazonaws.com/ride/rides/fields=longitude,latitude,loc1,startTime")
.then(response => response.json())
.then(data => (data.data));
sessions = sessions.map(session => (
{
type: 'session',
id: session.rideId,
city: session.loc1,
date: session.startDate,
position: [session.latitude, session.longitude]
}
));
.then(data => {
return data.data.map(session => {
return {
type: 'session',
position: [session.latitude, session.longitude],
id: session.rideId,
city: session.loc1,
date: session.startTime * 1000,
}
});
})
.catch(error => console.log(error));
localStorage.setItem('sessions', JSON.stringify(sessions));
return sessions;
},
Expand Down Expand Up @@ -54,12 +54,8 @@ export default function Map() {
// top level data, this should not change and only update when we get a new session from api
const [sessions, setSessions] = useState([]);
const [buoys, setBuoys] = useState([]);

const [mapView, setMapView] = useState({ center: [32.8, -117.2], zoom: 10 });

const [startDate, setStartDate] = useState(0);
const [endDate, setEndDate] = useState(0);

// display chart panel
const [chartPanelDisplayed, setChartPanelDisplayed] = useState(false);

Expand All @@ -69,7 +65,7 @@ export default function Map() {

useEffect(() => {
async function fetchData() {
let sessions = localStorage.getItem('sessions');
let sessions = null//localStorage.getItem('sessions');

if (sessions) {
sessions = JSON.parse(sessions);
Expand All @@ -78,7 +74,7 @@ export default function Map() {
}
setSessions(sessions);

let buoys = localStorage.getItem('buoys');
let buoys = null//localStorage.getItem('buoys');

if (buoys) {
buoys = JSON.parse(buoys);
Expand All @@ -90,31 +86,10 @@ export default function Map() {
fetchData()
}, []);

useEffect(() => {
async function filterSessions() {
if (!sessions) return;
// filter list data based on start and end date
// this should actually change map data
if(startDate === 0 && endDate === 0) {
filterList(0);
return;
}

let newSessions = JSON.parse(localStorage.getItem('sessions'));
if (!newSessions) return;

if (!startDate && !endDate) {
newSessions = newSessions.filter(
session => (session.date >= startDate && session.date <= endDate)
);
}
setSessions(newSessions);
}
filterSessions();
}, [startDate, endDate]);



function filterList(id) {
console.log("SESSION clicked", id)
if (!sessions) {
return;
}
Expand All @@ -137,13 +112,31 @@ export default function Map() {
}

function setDates(startDate, endDate) {
setStartDate(startDate);
setEndDate(endDate);
console.log(startDate, endDate, 'ZSDFKJ')

if (!sessions) return;
// filter list data based on start and end date
// this should actually change map data
if(startDate === 0 && endDate === 0) {
filterList(0);
return;
}

let newSessions = JSON.parse(localStorage.getItem('sessions'));
if (!newSessions) return;

if (startDate && endDate) {
newSessions = newSessions.filter(
session => (session.date >= startDate && session.date <= endDate)
);
}
setSessions(newSessions);
}

function onMapMove(topLeftCoordinates, bottomRightCoordinates) {
let updatedList = JSON.parse(localStorage.getItem('sessions'));
if (!updatedList) return;
console.log(updatedList)
// get all sessions between bottom and top latitude
let topLat = topLeftCoordinates.lat;
let bottomLat = bottomRightCoordinates.lat;
Expand All @@ -153,8 +146,9 @@ export default function Map() {
let leftLng = topLeftCoordinates.lng;
let rightLng = bottomRightCoordinates.lng;
updatedList = updatedList.filter(session => ( session.position[1] < leftLng && session.position[1] > rightLng ));
console.log(updatedList)

setSessions(updatedList);
// setSessions(updatedList);
}

// TODO: ADD IN HOVER FUNCTIONALITY TO PULL UP SESSION INFO PANELS
Expand All @@ -178,7 +172,8 @@ export default function Map() {
<div id="sidebar">
<SearchInput
sessions={sessions}
filterList={filterList}/>
filterList={filterList}
/>
<SessionList
sessions={sessions}
buoys={buoys}
Expand Down
Loading

0 comments on commit c734ee4

Please sign in to comment.