diff --git a/.gitignore b/.gitignore index 31b153a9b..8ad729bbf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode .DS_Store node_modules -.cache \ No newline at end of file +.cache +.env \ No newline at end of file diff --git a/README.md b/README.md index 8e4b04468..54fd2e74e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,26 @@ # Weather Report +## Team Plan + +* Access needs + * No working on the weekend! + * defined end times <3 + * Let's aim for submission deadline of next Wednesday + * don't work on it on your own. let's work on it together. +* Your learning style + * if one person doesn't get it, the other person shouldn't move on without their partner. + * instead, we should work together until everyone understands before moving on. + * J: hands-on learning, speaking out loud the problem, diagrams are useful, knowing the why of why we're doing something + * L: hands-on learning, knowing the why, speaking out loud the problem, sometimes I need to be slow about understanding it and need to get it before moving on. +* How you prefer to receive feedback + * J: always constructive, don't take it personal, let me know if there's something I'm doing that's not working for you + * L: direct, timely, let me know if there's something I'm doing that's not working for you +* One team communication skill you want to improve with this experience + * making a plan up front for what works (which we're doing) + * put your seatbelt on + * time management! + + ## Skills Assessed - Following directions and reading comprehension diff --git a/ada-project-docs/useful links we found b/ada-project-docs/useful links we found new file mode 100644 index 000000000..ce5aed7f8 --- /dev/null +++ b/ada-project-docs/useful links we found @@ -0,0 +1,3 @@ +https://api.openweathermap.org/data/2.5/weather this is where to call the api + +here is the documentation website for open weather: https://openweathermap.org/current \ No newline at end of file diff --git a/index.html b/index.html index 68b320b9a..cd8d78bed 100644 --- a/index.html +++ b/index.html @@ -4,9 +4,43 @@ + + Weather Report +
+
+

Weather App

+

Weather Garden

+

Garden

+ + +
+
+

Weather for the city of Seattle

+ + + + +

tempcount

+ + +
+ +
+ + + + + + + + + + + - \ No newline at end of file + + diff --git a/package.json b/package.json index 9cf5ca65b..7a5796d8a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,7 @@ { "dependencies": { - "axios": "^0.27.2" + "axios": "^1.2.1", + "dotenv": "^16.0.3", + "node": "^19.2.0" } } diff --git a/src/index.js b/src/index.js index e69de29bb..82b597480 100644 --- a/src/index.js +++ b/src/index.js @@ -0,0 +1,110 @@ +//GET THE AXIOS CALL WORKING +//LOOK AT THE 7-WONDERS CODE TO TRY TO GET THE PROMISE AND THE ASYNC AND AWAIT FUNCTION WORKING. + +//CODE FOR BUTTON: + +const state = { + tempCount: 60, //was temp +}; +var tempCountContainer = document.querySelector('#tempCount'); +var gardenContainer = document.querySelector('#garden'); + +//changing the background color temp function +const setTempColor = () => { + if (state.tempCount <= 49) { + tempCountContainer.style.backgroundColor = 'teal'; + gardenContainer.textContent = 'πŸŒ²πŸŒ²β›„οΈπŸŒ²β›„οΈπŸ‚πŸŒ²πŸπŸŒ²πŸŒ²β›„οΈπŸ‚πŸŒ²'; + } else if (state.tempCount >= 50 && state.tempCount <= 59) { + tempCountContainer.style.backgroundColor = 'green'; + gardenContainer.textContent = 'πŸŒ²πŸŒ²β›„οΈπŸŒ²β›„οΈπŸ‚πŸŒ²πŸπŸŒ²πŸŒ²β›„οΈπŸ‚πŸŒ²'; + } else if (state.tempCount >= 60 && state.tempCount <= 69) { + tempCountContainer.style.backgroundColor = 'yellow'; + gardenContainer.textContent = '🌾🌾_πŸƒ_πŸͺ¨__πŸ›€_🌾🌾🌾_πŸƒ'; + } else if (state.tempCount >= 70 && state.tempCount <= 79) { + tempCountContainer.style.backgroundColor = 'orange'; + gardenContainer.textContent = '🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷'; + } else if (state.tempCount >= 80) { + tempCountContainer.style.backgroundColor = 'red'; + gardenContainer.textContent = '🌡__🐍_πŸ¦‚_🌡🌡__🐍_🏜_πŸ¦‚'; + } +}; + +const renderTemp = () => { + tempCountContainer.textContent = state.tempCount + ' Β°F'; + setTempColor(); +}; + +renderTemp(); + +const addTemp = (event) => { + state.tempCount += 1; + renderTemp(); +}; + +const subtractTemp = (event) => { + state.tempCount -= 1; + renderTemp(); +}; + +const registerEventHandlers = (event) => { + // console.log('in registerEventHandelers:', event); + const upButton = document.querySelector('#upButton'); + const downButton = document.querySelector('#downButton'); + console.log(upButton); + upButton.addEventListener('click', addTemp); + downButton.addEventListener('click', subtractTemp); + console.log(downButton); +}; + +registerEventHandlers(undefined); + +//AXIOS CODE + +//call to the flask app to get weather +const lat = 47.6038321; +const lon = -122.330062; +axios + .get('http://127.0.0.1:5000/weather' + '?lat=' + lat + '&lon=' + lon) + .then((response) => { + var temp = response.data.main.temp; + temp = Math.round(((temp - 273.15) * 9) / 5 + 32); //convert to Farenheit + console.log(temp); + + //need to update the state. + state.tempCount = temp; + renderTemp(); + }) + .catch((error) => { + console.log(`there has been an error in the axios call. Cause: ${error}`); + }); + +//what we tried to get async functions working. + +// async function get_temp(query) { +// let response = await axios.get; +// } + +// adding temperature number +// async function f() { +// let promise = new + +// async function addTemp(event) { +// state.tempCount += 1; +// } + +// const getPromise = (time) => { +// const timeoutTime = time * 1000; +// const myPromise = new Promise((resolve, reject) => { +// setTimeout(() => resolve("It's go time!"), timeoutTime); +// }); +// return myPromise; +// }; + +// state.tempCount += 1; +// const bookCountContainer = document.querySelector("#bookCount"); +// bookCountContainer.textContent = `Book Count: ${state.bookCount}`; +// }; + +//registering event handler + +//if loading, diff --git a/styles/index.css b/styles/index.css index e69de29bb..efbfde968 100644 --- a/styles/index.css +++ b/styles/index.css @@ -0,0 +1,34 @@ +.grid-container { + display: grid; + grid-template-columns: auto auto auto; + background-color: #2196F3; + padding: 10px; +} +.grid-item { + background-color: rgba(255, 255, 255, 0.8); + border: 1px solid rgba(0, 0, 0, 0.8); + padding: 20px; + font-size: 30px; + text-align: center; +} + +button { + font-size: x-large; +} + +#tempCount { + background-color: pink; +} + +#pink-section { + background-color: lightpink; +} + +#garden { + background-color: white; + border: 1px solid black; +} + +h2 { + font-size : 20px; +} \ No newline at end of file diff --git a/weather-report-proxy-server b/weather-report-proxy-server new file mode 160000 index 000000000..ea5dd1a76 --- /dev/null +++ b/weather-report-proxy-server @@ -0,0 +1 @@ +Subproject commit ea5dd1a768fd69f8a879aee21b638aeb1cb52fae diff --git a/yarn.lock b/yarn.lock index 37fbaed29..91790c01c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,13 +7,14 @@ asynckit@^0.4.0: resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== -axios@^0.27.2: - version "0.27.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" - integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== +axios@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.2.1.tgz#44cf04a3c9f0c2252ebd85975361c026cb9f864a" + integrity sha512-I88cFiGu9ryt/tfVEi4kX2SITsvDddTajXTOFmt2uK1ZVA8LytjtdeyefdQWEf5PU8w+4SSJDoYnggflB5tW4A== dependencies: - follow-redirects "^1.14.9" + follow-redirects "^1.15.0" form-data "^4.0.0" + proxy-from-env "^1.1.0" combined-stream@^1.0.8: version "1.0.8" @@ -27,10 +28,15 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= -follow-redirects@^1.14.9: - version "1.15.0" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.0.tgz#06441868281c86d0dda4ad8bdaead2d02dca89d4" - integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ== +dotenv@^16.0.3: + version "16.0.3" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.3.tgz#115aec42bac5053db3c456db30cc243a5a836a07" + integrity sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ== + +follow-redirects@^1.15.0: + version "1.15.2" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" + integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== form-data@^4.0.0: version "4.0.0" @@ -52,3 +58,20 @@ mime-types@^2.1.12: integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== dependencies: mime-db "1.52.0" + +node-bin-setup@^1.0.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/node-bin-setup/-/node-bin-setup-1.1.3.tgz#d45d5220e3b2ecc3a94263a56116f727f6c1bb14" + integrity sha512-opgw9iSCAzT2+6wJOETCpeRYAQxSopqQ2z+N6BXwIMsQQ7Zj5M8MaafQY8JMlolRR6R1UXg2WmhKp0p9lSOivg== + +node@^19.2.0: + version "19.2.0" + resolved "https://registry.yarnpkg.com/node/-/node-19.2.0.tgz#f377e046002065fd1a9a23dd7bffc8026be77847" + integrity sha512-ETicZqrcApHCufk8L7HCO6eUe6HmZFN3YmAklYdETyp8Gi10UZGFvVJ/AvihE9i5CueXsebEP/7DgFKjohHXHw== + dependencies: + node-bin-setup "^1.0.0" + +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==