From 45b0abbaf2aae9dfd9af4134cb5f30f86d858a3f Mon Sep 17 00:00:00 2001 From: GisellePerez Date: Sun, 1 Jan 2023 09:06:26 -0300 Subject: [PATCH 1/5] fetching data from form --- package-lock.json | 1 + src/App.vue | 58 +++++++++++- src/components/Form.vue | 124 ++++++++++++++++++++++++++ src/components/Map.vue | 12 ++- src/components/SideBar.vue | 34 +++++++ src/components/ui/DatepickerField.vue | 35 ++++++++ 6 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 src/components/Form.vue create mode 100644 src/components/ui/DatepickerField.vue diff --git a/package-lock.json b/package-lock.json index a58c9de..d217a8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "frontend-screening", "version": "0.1.0", "dependencies": { "@mapbox/mapbox-gl-geocoder": "^4.7.1", diff --git a/src/App.vue b/src/App.vue index 069f0d1..cef9795 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,9 +1,15 @@ @@ -15,6 +15,8 @@ export default { name: "Map", + props: ["dataUrl"], + data() { return { map: null, @@ -34,5 +36,13 @@ export default { }, }; }, + computed: { + dynamicSourceOptions() { + let localOptions = Object.assign({}, this.sourceOptions); // Updating data.sourceOptions.data with the url received as prop + localOptions.data = this.dataUrl + + return localOptions + } + } }; diff --git a/src/components/SideBar.vue b/src/components/SideBar.vue index 11b1143..87ea23e 100644 --- a/src/components/SideBar.vue +++ b/src/components/SideBar.vue @@ -4,11 +4,45 @@ Earthquakes Map
The form goes here...
+ +
diff --git a/src/components/ui/DatepickerField.vue b/src/components/ui/DatepickerField.vue new file mode 100644 index 0000000..84618ee --- /dev/null +++ b/src/components/ui/DatepickerField.vue @@ -0,0 +1,35 @@ + + + + + From 45a121abfb8691695e56cb96399039ccbcc0464a Mon Sep 17 00:00:00 2001 From: GisellePerez Date: Sun, 1 Jan 2023 11:03:22 -0300 Subject: [PATCH 2/5] feat: dynamic marker first attempt --- src/components/Map.vue | 50 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/components/Map.vue b/src/components/Map.vue index 7f27944..0d24749 100644 --- a/src/components/Map.vue +++ b/src/components/Map.vue @@ -6,6 +6,28 @@ :zoom="2" @mb-created="(mapInstance) => (map = mapInstance)" > + + + + + + mdi-calendar + + + + @@ -19,6 +41,15 @@ export default { data() { return { + dummyData: { + markers: [ + { lng: 1, lat: 1, text: "a", scale: 1 }, + { lng: 20, lat: 20, text: "b", scale: 2 }, + { lng: 30, lat: 30, text: "c", scale: 4 }, + { lng: 60, lat: 60, text: "ddd", scale: 2 }, + ], + }, + map: null, sourceOptions: { type: "geojson", @@ -39,10 +70,21 @@ export default { computed: { dynamicSourceOptions() { let localOptions = Object.assign({}, this.sourceOptions); // Updating data.sourceOptions.data with the url received as prop - localOptions.data = this.dataUrl + localOptions.data = this.dataUrl; - return localOptions - } - } + return localOptions; + }, + }, }; + + From 19eb4009e4180d89e4235f64aa752416ee8b48c8 Mon Sep 17 00:00:00 2001 From: GisellePerez Date: Sun, 1 Jan 2023 19:10:02 -0300 Subject: [PATCH 3/5] feat: working markers and fetched data --- src/App.vue | 70 ++++++++++++-------- src/components/Form.vue | 33 ++-------- src/components/Map.vue | 117 +++++++++++++++++---------------- src/components/SideBar.vue | 23 +------ src/components/ui/InfoItem.vue | 25 +++++++ 5 files changed, 135 insertions(+), 133 deletions(-) create mode 100644 src/components/ui/InfoItem.vue diff --git a/src/App.vue b/src/App.vue index cef9795..58d92a4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,6 @@ diff --git a/src/components/Map.vue b/src/components/Map.vue index 0d24749..7c151d1 100644 --- a/src/components/Map.vue +++ b/src/components/Map.vue @@ -1,90 +1,95 @@ diff --git a/src/components/SideBar.vue b/src/components/SideBar.vue index 87ea23e..794c4a5 100644 --- a/src/components/SideBar.vue +++ b/src/components/SideBar.vue @@ -3,11 +3,9 @@ Earthquakes Map -
The form goes here...
+
What data would you like to check?
diff --git a/src/components/ui/InfoItem.vue b/src/components/ui/InfoItem.vue new file mode 100644 index 0000000..b6e1d1d --- /dev/null +++ b/src/components/ui/InfoItem.vue @@ -0,0 +1,25 @@ + + + + + From 5120d49dcaeb069a7b2b280860a5cc1243726cb4 Mon Sep 17 00:00:00 2001 From: GisellePerez Date: Sun, 1 Jan 2023 20:56:36 -0300 Subject: [PATCH 4/5] feat: set max and min values for datepickers --- src/components/Form.vue | 149 +++++++++++++++++++-------------- src/components/Map.vue | 25 +----- src/components/ui/InfoItem.vue | 10 ++- 3 files changed, 94 insertions(+), 90 deletions(-) diff --git a/src/components/Form.vue b/src/components/Form.vue index 6e0343a..4e76e60 100644 --- a/src/components/Form.vue +++ b/src/components/Form.vue @@ -1,77 +1,80 @@ diff --git a/src/components/Map.vue b/src/components/Map.vue index 7c151d1..c1ee827 100644 --- a/src/components/Map.vue +++ b/src/components/Map.vue @@ -37,7 +37,7 @@ :value="marker.properties.time" :withMarginBottom="true" /> - + @@ -45,8 +45,6 @@ diff --git a/src/components/ui/InfoItem.vue b/src/components/ui/InfoItem.vue index b6e1d1d..06748d4 100644 --- a/src/components/ui/InfoItem.vue +++ b/src/components/ui/InfoItem.vue @@ -1,7 +1,13 @@ From 35c41e8501fac877b581c19acd9c5690038c2210 Mon Sep 17 00:00:00 2001 From: GisellePerez Date: Sun, 1 Jan 2023 22:16:10 -0300 Subject: [PATCH 5/5] feat: final corrections --- src/App.vue | 42 +-------------------------- src/components/Form.vue | 7 +---- src/components/ui/DatepickerField.vue | 35 ---------------------- 3 files changed, 2 insertions(+), 82 deletions(-) delete mode 100644 src/components/ui/DatepickerField.vue diff --git a/src/App.vue b/src/App.vue index 58d92a4..aacaf02 100644 --- a/src/App.vue +++ b/src/App.vue @@ -38,52 +38,12 @@ export default { }, methods: { - formatData(rawData) { - // eslint-disable-next-line no-debugger - debugger; - console.log({ rawData }); - return rawData.map((item) => { - // eslint-disable-next-line no-debugger - debugger; - - console.log({ item }); - const id = item.id; - const { mag, place, time } = item.properties; - - const formattedItem = { - id, - coordinates: { - longitude: item.geometry.coordinates[0], // 0 - latitude: item.geometry.coordinates[1], // 1 - }, - properties: { - mag, - place, - time, - }, - }; - - console.log({ formattedItem }); - return formattedItem; - }); - }, async fetchData(starttime, endtime, minmagnitude) { - console.log( - `https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=${starttime}&endtime=${endtime}&minmagnitude=${minmagnitude}` - ); - // return (this.dataUrl = `https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=${starttime}&endtime=${endtime}&minmagnitude=${minmagnitude}`); - fetch( `https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=${starttime}&endtime=${endtime}&minmagnitude=${minmagnitude}` ) .then((response) => { - response - .json() - .then((res) => { - console.log("App", res); - return res; - }) - .then((res) => (this.requestedData = res.features)); + response.json().then((res) => (this.requestedData = res.features)); }) .catch((err) => { console.error(err); diff --git a/src/components/Form.vue b/src/components/Form.vue index 4e76e60..a1cc968 100644 --- a/src/components/Form.vue +++ b/src/components/Form.vue @@ -15,7 +15,6 @@ @@ -23,14 +22,11 @@ - - - - -