Merge branch 'feature/react.js'
# Conflicts: # readme.md
Showing
36 changed files
with
775 additions
and
0 deletions
client/.gitignore
0 → 100644
1 | +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
2 | + | ||
3 | +# dependencies | ||
4 | +/node_modules | ||
5 | +/.pnp | ||
6 | +.pnp.js | ||
7 | + | ||
8 | +# testing | ||
9 | +/coverage | ||
10 | + | ||
11 | +# production | ||
12 | +/build | ||
13 | + | ||
14 | +# misc | ||
15 | +.DS_Store | ||
16 | +.env.local | ||
17 | +.env.development.local | ||
18 | +.env.test.local | ||
19 | +.env.production.local | ||
20 | + | ||
21 | +npm-debug.log* | ||
22 | +yarn-debug.log* | ||
23 | +yarn-error.log* |
client/README.md
0 → 100644
1 | +# Getting Started with Create React App | ||
2 | + | ||
3 | +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
4 | + | ||
5 | +## Available Scripts | ||
6 | + | ||
7 | +In the project directory, you can run: | ||
8 | + | ||
9 | +### `yarn start` | ||
10 | + | ||
11 | +Runs the app in the development mode.\ | ||
12 | +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
13 | + | ||
14 | +The page will reload if you make edits.\ | ||
15 | +You will also see any lint errors in the console. | ||
16 | + | ||
17 | +### `yarn test` | ||
18 | + | ||
19 | +Launches the test runner in the interactive watch mode.\ | ||
20 | +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
21 | + | ||
22 | +### `yarn build` | ||
23 | + | ||
24 | +Builds the app for production to the `build` folder.\ | ||
25 | +It correctly bundles React in production mode and optimizes the build for the best performance. | ||
26 | + | ||
27 | +The build is minified and the filenames include the hashes.\ | ||
28 | +Your app is ready to be deployed! | ||
29 | + | ||
30 | +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
31 | + | ||
32 | +### `yarn eject` | ||
33 | + | ||
34 | +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
35 | + | ||
36 | +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
37 | + | ||
38 | +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
39 | + | ||
40 | +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
41 | + | ||
42 | +## Learn More | ||
43 | + | ||
44 | +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
45 | + | ||
46 | +To learn React, check out the [React documentation](https://reactjs.org/). | ||
47 | + | ||
48 | +### Code Splitting | ||
49 | + | ||
50 | +This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) | ||
51 | + | ||
52 | +### Analyzing the Bundle Size | ||
53 | + | ||
54 | +This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) | ||
55 | + | ||
56 | +### Making a Progressive Web App | ||
57 | + | ||
58 | +This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) | ||
59 | + | ||
60 | +### Advanced Configuration | ||
61 | + | ||
62 | +This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) | ||
63 | + | ||
64 | +### Deployment | ||
65 | + | ||
66 | +This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) | ||
67 | + | ||
68 | +### `yarn build` fails to minify | ||
69 | + | ||
70 | +This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) |
client/package-lock.json
0 → 100644
This diff could not be displayed because it is too large.
client/package.json
0 → 100644
1 | +{ | ||
2 | + "name": "client", | ||
3 | + "version": "0.1.0", | ||
4 | + "private": true, | ||
5 | + "dependencies": { | ||
6 | + "@testing-library/jest-dom": "^5.11.4", | ||
7 | + "@testing-library/react": "^11.1.0", | ||
8 | + "@testing-library/user-event": "^12.1.10", | ||
9 | + "axios": "^0.24.0", | ||
10 | + "google-map-react": "^2.1.10", | ||
11 | + "google-maps-react": "^2.0.6", | ||
12 | + "http-proxy-middleware": "^2.0.1", | ||
13 | + "postcss-safe-parser": "^6.0.0", | ||
14 | + "react": "^17.0.2", | ||
15 | + "react-dom": "^17.0.2", | ||
16 | + "react-scripts": "4.0.3", | ||
17 | + "web-vitals": "^1.0.1" | ||
18 | + }, | ||
19 | + "scripts": { | ||
20 | + "start": "react-scripts start", | ||
21 | + "build": "react-scripts build", | ||
22 | + "test": "react-scripts test", | ||
23 | + "eject": "react-scripts eject" | ||
24 | + }, | ||
25 | + "eslintConfig": { | ||
26 | + "extends": [ | ||
27 | + "react-app", | ||
28 | + "react-app/jest" | ||
29 | + ] | ||
30 | + }, | ||
31 | + "browserslist": { | ||
32 | + "production": [ | ||
33 | + ">0.2%", | ||
34 | + "not dead", | ||
35 | + "not op_mini all" | ||
36 | + ], | ||
37 | + "development": [ | ||
38 | + "last 1 chrome version", | ||
39 | + "last 1 firefox version", | ||
40 | + "last 1 safari version" | ||
41 | + ] | ||
42 | + } | ||
43 | +} |
client/public/favicon.ico
0 → 100644
No preview for this file type
client/public/index.html
0 → 100644
1 | +<!DOCTYPE html> | ||
2 | +<html lang="en"> | ||
3 | + <head> | ||
4 | + <meta charset="utf-8" /> | ||
5 | + <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
6 | + <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
7 | + <meta name="theme-color" content="#000000" /> | ||
8 | + <meta | ||
9 | + name="description" | ||
10 | + content="Web site created using create-react-app" | ||
11 | + /> | ||
12 | + <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> | ||
13 | + <!-- | ||
14 | + manifest.json provides metadata used when your web app is installed on a | ||
15 | + user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
16 | + --> | ||
17 | + <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
18 | + <!-- | ||
19 | + Notice the use of %PUBLIC_URL% in the tags above. | ||
20 | + It will be replaced with the URL of the `public` folder during the build. | ||
21 | + Only files inside the `public` folder can be referenced from the HTML. | ||
22 | + | ||
23 | + Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
24 | + work correctly both with client-side routing and a non-root public URL. | ||
25 | + Learn how to configure a non-root public URL by running `npm run build`. | ||
26 | + --> | ||
27 | + <title>React App</title> | ||
28 | + </head> | ||
29 | + <body> | ||
30 | + <noscript>You need to enable JavaScript to run this app.</noscript> | ||
31 | + <div id="root"></div> | ||
32 | + <!-- | ||
33 | + This HTML file is a template. | ||
34 | + If you open it directly in the browser, you will see an empty page. | ||
35 | + | ||
36 | + You can add webfonts, meta tags, or analytics to this file. | ||
37 | + The build step will place the bundled scripts into the <body> tag. | ||
38 | + | ||
39 | + To begin the development, run `npm start` or `yarn start`. | ||
40 | + To create a production bundle, use `npm run build` or `yarn build`. | ||
41 | + --> | ||
42 | + </body> | ||
43 | +</html> |
client/public/logo192.png
0 → 100644
5.22 KB
client/public/logo512.png
0 → 100644
9.44 KB
client/public/manifest.json
0 → 100644
1 | +{ | ||
2 | + "short_name": "React App", | ||
3 | + "name": "Create React App Sample", | ||
4 | + "icons": [ | ||
5 | + { | ||
6 | + "src": "favicon.ico", | ||
7 | + "sizes": "64x64 32x32 24x24 16x16", | ||
8 | + "type": "image/x-icon" | ||
9 | + }, | ||
10 | + { | ||
11 | + "src": "logo192.png", | ||
12 | + "type": "image/png", | ||
13 | + "sizes": "192x192" | ||
14 | + }, | ||
15 | + { | ||
16 | + "src": "logo512.png", | ||
17 | + "type": "image/png", | ||
18 | + "sizes": "512x512" | ||
19 | + } | ||
20 | + ], | ||
21 | + "start_url": ".", | ||
22 | + "display": "standalone", | ||
23 | + "theme_color": "#000000", | ||
24 | + "background_color": "#ffffff" | ||
25 | +} |
client/public/robots.txt
0 → 100644
client/src/App.css
0 → 100644
1 | +.App { | ||
2 | + text-align: center; | ||
3 | +} | ||
4 | + | ||
5 | +.App-header { | ||
6 | + background-color: #282c34; | ||
7 | + min-height: 100vh; | ||
8 | + display: flex; | ||
9 | + flex-direction: column; | ||
10 | + align-items: center; | ||
11 | + justify-content: center; | ||
12 | + font-size: calc(10px + 2vmin); | ||
13 | + color: white; | ||
14 | +} | ||
15 | + | ||
16 | +.App-link { | ||
17 | + color: #61dafb; | ||
18 | +} | ||
19 | + | ||
20 | +@keyframes App-logo-spin { | ||
21 | + from { | ||
22 | + transform: rotate(0deg); | ||
23 | + } | ||
24 | + to { | ||
25 | + transform: rotate(360deg); | ||
26 | + } | ||
27 | +} |
client/src/App.js
0 → 100644
1 | +import './App.css'; | ||
2 | +import { useEffect} from "react"; | ||
3 | +import axios from 'axios'; | ||
4 | + | ||
5 | +function App(){ | ||
6 | + | ||
7 | +return <div> | ||
8 | +<title>Take an Umbrella</title> | ||
9 | +<h1> Take an Umbrella </h1> | ||
10 | +<h3> 철학과 2017101598 맹주환 </h3> | ||
11 | +<pre align="center"> | ||
12 | + 반가워요! | ||
13 | + Take an umbrella는 스마트 조명 제품 Philips hue API와 기상청 공공데이터 날씨 API로 구성되어 있어요. | ||
14 | + Hue가 연결된 WI-FI로 접속하셔서 아래의 지도로 현재 위치를 조회하시면, 해당 지역 기상 예보를 받아와 조명을 통해 우산을 챙겨야 하는지 알려줘요! | ||
15 | + </pre> | ||
16 | + </div>; | ||
17 | +} | ||
18 | + | ||
19 | +export default App; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
client/src/App.test.js
0 → 100644
client/src/index.css
0 → 100644
1 | +body { | ||
2 | + margin: 0; | ||
3 | + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | ||
4 | + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
5 | + sans-serif; | ||
6 | + -webkit-font-smoothing: antialiased; | ||
7 | + -moz-osx-font-smoothing: grayscale; | ||
8 | +} | ||
9 | + | ||
10 | +code { | ||
11 | + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
12 | + monospace; | ||
13 | +} |
client/src/index.js
0 → 100644
1 | +import React from 'react'; | ||
2 | +import ReactDOM from 'react-dom'; | ||
3 | +import './index.css'; | ||
4 | +import App from './App'; | ||
5 | +import reportWebVitals from './reportWebVitals'; | ||
6 | +import MapContainer from './map/index'; | ||
7 | +import Location from './map/location'; | ||
8 | + | ||
9 | +ReactDOM.render( | ||
10 | + <React.StrictMode> | ||
11 | + <App /> | ||
12 | + <Location /> | ||
13 | + </React.StrictMode>, | ||
14 | + document.getElementById('root') | ||
15 | +); | ||
16 | + | ||
17 | +// If you want to start measuring performance in your app, pass a function | ||
18 | +// to log results (for example: reportWebVitals(console.log)) | ||
19 | +// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals | ||
20 | +reportWebVitals(); |
client/src/logo.svg
0 → 100644
1 | +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
client/src/map/index.js
0 → 100644
1 | +import React, { Component } from "react"; | ||
2 | +import { Map, GoogleApiWrapper, Marker } from 'google-maps-react'; | ||
3 | +import './style.css'; | ||
4 | + | ||
5 | +const mapStyles = { | ||
6 | + width: '600px', | ||
7 | + height: '600px', | ||
8 | +}; | ||
9 | + | ||
10 | +class Demo1 extends Component { | ||
11 | + constructor() { | ||
12 | + super(); | ||
13 | + this.state = { | ||
14 | + name: "React" | ||
15 | + }; | ||
16 | + } | ||
17 | + | ||
18 | + render() { | ||
19 | + return ( | ||
20 | + <div class="map"> | ||
21 | + <Map | ||
22 | + google={this.props.google} | ||
23 | + zoom={14} | ||
24 | + style={mapStyles} | ||
25 | + initialCenter={{ | ||
26 | + lat: '37.5905144', | ||
27 | + lng: '127.0576477' | ||
28 | + }} | ||
29 | + > | ||
30 | + <Marker | ||
31 | + onClick={this.onMarkerClick} | ||
32 | + /> | ||
33 | + </Map> | ||
34 | + </div> | ||
35 | + ); | ||
36 | + } | ||
37 | +} | ||
38 | + | ||
39 | +export default GoogleApiWrapper({ | ||
40 | + apiKey: 'AIzaSyAguo3zH8vWZJbzXEqyp8D8UvnBh3zX8rQ' | ||
41 | +})(Demo1); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
client/src/map/location.js
0 → 100644
1 | +import React, { Component } from "react"; | ||
2 | +import axios from 'axios'; | ||
3 | + | ||
4 | +class App extends Component { | ||
5 | + constructor(props) { | ||
6 | + super(props); | ||
7 | + this.state = { | ||
8 | + }; | ||
9 | + } | ||
10 | + | ||
11 | + render() { | ||
12 | + let data = { | ||
13 | + lat : null, | ||
14 | + lag : null | ||
15 | + }; | ||
16 | + navigator.geolocation.getCurrentPosition(function(position) { | ||
17 | + data = { | ||
18 | + lat : position.coords.latitude, | ||
19 | + lag : position.coords.longitude | ||
20 | + }; | ||
21 | + axios.post('/locate', JSON.stringify(data), { | ||
22 | + headers: { | ||
23 | + "Content-Type": `application/json`, | ||
24 | + }, | ||
25 | + }).then((res) => { | ||
26 | + console.log("complete"); | ||
27 | + }); | ||
28 | + }); | ||
29 | + return ( | ||
30 | + <div> | ||
31 | + </div> | ||
32 | + ); | ||
33 | + } | ||
34 | +} | ||
35 | +export default App; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
client/src/map/map.js
0 → 100644
1 | +// Note: This example requires that you consent to location sharing when | ||
2 | +// prompted by your browser. If you see the error "The Geolocation service | ||
3 | +// failed.", it means you probably did not give permission for the browser to | ||
4 | +// locate you. | ||
5 | + | ||
6 | +let map, infoWindow; | ||
7 | + | ||
8 | +function initMap() { | ||
9 | + map = new google.maps.Map(document.getElementById("map"), { | ||
10 | + center: { lat: 37.5642135, lng: 127.0016985 }, | ||
11 | + zoom: 10, | ||
12 | + }); | ||
13 | + infoWindow = new google.maps.InfoWindow(); | ||
14 | + | ||
15 | + const locationButton = document.createElement("button"); | ||
16 | + | ||
17 | + locationButton.textContent = "위치 조회 하기"; | ||
18 | + locationButton.classList.add("custom-map-control-button"); | ||
19 | + map.controls[google.maps.ControlPosition.TOP_CENTER].push(locationButton); | ||
20 | + locationButton.addEventListener("click", () => { | ||
21 | + // Try HTML5 geolocation. | ||
22 | + if (navigator.geolocation) { | ||
23 | + navigator.geolocation.getCurrentPosition( | ||
24 | + (position) => { | ||
25 | + const pos = { | ||
26 | + lat: position.coords.latitude, | ||
27 | + lng: position.coords.longitude, | ||
28 | + }; | ||
29 | + infoWindow.setPosition(pos); | ||
30 | + infoWindow.setContent("위치를 찾았습니다."); | ||
31 | + infoWindow.open(map); | ||
32 | + map.setCenter(pos); | ||
33 | + document.getElementById("lat").innerHTML = pos.lat; | ||
34 | + document.getElementById("lng").innerHTML = pos.lng; | ||
35 | + // console.log(dfs_xy_conv("toXY",pos.lat,pos.lng)); | ||
36 | + | ||
37 | + }, | ||
38 | + () => { | ||
39 | + handleLocationError(true, infoWindow, map.getCenter()); | ||
40 | + } | ||
41 | + ); | ||
42 | + } else { | ||
43 | + // Browser doesn't support Geolocation | ||
44 | + handleLocationError(false, infoWindow, map.getCenter()); | ||
45 | + } | ||
46 | + }); | ||
47 | +} | ||
48 | + | ||
49 | +function handleLocationError(browserHasGeolocation, infoWindow, pos) { | ||
50 | + infoWindow.setPosition(pos); | ||
51 | + infoWindow.setContent( | ||
52 | + browserHasGeolocation | ||
53 | + ? "Error: 위치 조회 서비스가 실패하였습니다." | ||
54 | + : "Error: 브라우저가 위치 조회 기능을 지원하지 않습니다." | ||
55 | + ); | ||
56 | + infoWindow.open(map); | ||
57 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
client/src/map/style.css
0 → 100644
1 | +/* Always set the map height explicitly to define the size of the div | ||
2 | + * element that contains the map. */ | ||
3 | + | ||
4 | + h1 { text-align: center; } | ||
5 | + h2 { text-align: center; } | ||
6 | + h3 { text-align: center; } | ||
7 | + | ||
8 | + #map { | ||
9 | + width:600px; | ||
10 | + height:400px; | ||
11 | + margin: 0 auto; | ||
12 | + | ||
13 | + | ||
14 | + } | ||
15 | + .custom-map-control-button { | ||
16 | + background-color: #fff; | ||
17 | + border: 0; | ||
18 | + border-radius: 2px; | ||
19 | + box-shadow: 0 1px 4px -1px rgba(0, 0, 0, 0.3); | ||
20 | + margin: 10px; | ||
21 | + padding: 0 0.5em; | ||
22 | + font: 400 18px Roboto, Arial, sans-serif; | ||
23 | + overflow: hidden; | ||
24 | + height: 40px; | ||
25 | + cursor: pointer; | ||
26 | + } | ||
27 | + .custom-map-control-button:hover { | ||
28 | + background: #ebebeb; | ||
29 | + } | ||
30 | + | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
client/src/reportWebVitals.js
0 → 100644
1 | +const reportWebVitals = onPerfEntry => { | ||
2 | + if (onPerfEntry && onPerfEntry instanceof Function) { | ||
3 | + import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { | ||
4 | + getCLS(onPerfEntry); | ||
5 | + getFID(onPerfEntry); | ||
6 | + getFCP(onPerfEntry); | ||
7 | + getLCP(onPerfEntry); | ||
8 | + getTTFB(onPerfEntry); | ||
9 | + }); | ||
10 | + } | ||
11 | +}; | ||
12 | + | ||
13 | +export default reportWebVitals; |
client/src/setupProxy.js
0 → 100644
1 | +const proxy = require('http-proxy-middleware'); | ||
2 | + | ||
3 | +module.exports = function (app) { | ||
4 | + app.use( | ||
5 | + proxy.createProxyMiddleware('/api', { | ||
6 | + target: 'http://localhost:5000', | ||
7 | + changeOrigin : true | ||
8 | + }) | ||
9 | + ); | ||
10 | + app.use( | ||
11 | + proxy.createProxyMiddleware('/locate', { | ||
12 | + target: 'http://localhost:5000', | ||
13 | + changeOrigin : true | ||
14 | + }) | ||
15 | + ); | ||
16 | +}; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
client/src/setupTests.js
0 → 100644
client/src/user/user.js
0 → 100644
1 | +class App extends React.Component { | ||
2 | + state = { | ||
3 | + players: [ | ||
4 | + {name: 'LDK', score: 0, id: 1}, | ||
5 | + {name: 'HONG', score: 0, id: 2}, | ||
6 | + {name: 'KIM', score: 0, id: 3}, | ||
7 | + {name: 'PARK', score: 0, id: 4}, | ||
8 | + ] | ||
9 | + }; | ||
10 | + | ||
11 | + handleRemovePlayer = (id) => { | ||
12 | + this.setState(prevState => { | ||
13 | + return { | ||
14 | + players: prevState.players.filter(item => item.id !== id) | ||
15 | + } | ||
16 | + }) | ||
17 | + } | ||
18 | + | ||
19 | + render() { | ||
20 | + return ( | ||
21 | + <div className="container p-3"> | ||
22 | + <Header title="My scoreboard" totalPlayers={this.state.players.length} /> | ||
23 | + | ||
24 | + {/*Players List*/} | ||
25 | + { this.state.players.map(item => | ||
26 | + <Player key={item.id} | ||
27 | + name={item.name} score={item.score} | ||
28 | + removePlayer={this.handleRemovePlayer} id={item.id} />) } | ||
29 | + </div> | ||
30 | + ); | ||
31 | + } | ||
32 | + } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
client/yarn.lock
0 → 100644
This diff could not be displayed because it is too large.
package-lock.json
0 → 100644
This diff could not be displayed because it is too large.
package.json
0 → 100644
1 | +{ | ||
2 | + "scripts": { | ||
3 | + "server": "cd server && nodemon server.js", | ||
4 | + "client": "cd client && npm start", | ||
5 | + "start": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"" | ||
6 | + }, | ||
7 | + "dependencies": { | ||
8 | + "body-parser": "^1.19.0", | ||
9 | + "concurrently": "^6.4.0", | ||
10 | + "cors": "^2.8.5", | ||
11 | + "express": "^4.17.1", | ||
12 | + "moment": "^2.29.1", | ||
13 | + "moment-timezone": "^0.5.34", | ||
14 | + "node-hue-api": "^5.0.0-beta.8", | ||
15 | + "nodemon": "^2.0.15", | ||
16 | + "request": "^2.88.2", | ||
17 | + "require": "^2.4.20" | ||
18 | + } | ||
19 | +} |
... | @@ -22,3 +22,8 @@ NPM node-hue API | ... | @@ -22,3 +22,8 @@ NPM node-hue API |
22 | 5. AWS를 통한 서비스 제공 계획 | 22 | 5. AWS를 통한 서비스 제공 계획 |
23 | 23 | ||
24 | 24 | ||
25 | +<<<<<<< HEAD | ||
26 | +경위도 : https://developers.google.com/maps/documentation/javascript/examples/map-geolocation?hl=ko#maps_map_geolocation-javascript | ||
27 | +======= | ||
28 | +https://www.data.go.kr/tcs/dss/selectApiDataDetailView.do?publicDataPk=15084084 기상청 | ||
29 | +>>>>>>> feature/add_Weather_API | ... | ... |
server/router/Weather.js
0 → 100644
1 | +const express = require('express'); | ||
2 | +const router = express.Router(); | ||
3 | +const request = require('request'); | ||
4 | +const moment = require('moment'); | ||
5 | +require('moment-timezone'); | ||
6 | +moment.tz.setDefault("Asia/seoul"); | ||
7 | +let date = new String(get_base_date()); | ||
8 | +let time = new String(get_base_time()); | ||
9 | +var url = 'http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst'; | ||
10 | +var queryParams = '?' + encodeURIComponent('serviceKey') + '=5e8RQfsCMcXO61FvD7j5tgt5fHf0NYadkSaW6%2FhYQHdoxSgQFXbN7VSb4CI%2BW9scLv2usb3riB7UAGNF7Wb6nA%3D%3D'; /* Service Key*/ | ||
11 | +queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */ | ||
12 | +queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('10'); /* */ | ||
13 | +queryParams += '&' + encodeURIComponent('dataType') + '=' + encodeURIComponent('JSON'); /* */ | ||
14 | +queryParams += '&' + encodeURIComponent('base_date') + '=' + encodeURIComponent(date); /* */ | ||
15 | +queryParams += '&' + encodeURIComponent('base_time') + '=' + encodeURIComponent(time); /* */ | ||
16 | +queryParams += '&' + encodeURIComponent('nx') + '=' + encodeURIComponent('55'); /* */ | ||
17 | +queryParams += '&' + encodeURIComponent('ny') + '=' + encodeURIComponent('127'); /* */ | ||
18 | + | ||
19 | + | ||
20 | +function get_base_date() // 날짜 추출 함수 | ||
21 | +{ | ||
22 | + // 0000~0210 사이 시간대에 조회시 전일(date -1)로 변경 | ||
23 | + let date =moment().format('YYYYMMDD'); | ||
24 | + let time = new String(moment().format('HHmm')); | ||
25 | + if ('0000'<=time && time<'0210'){date -= 1} | ||
26 | + return date | ||
27 | +} | ||
28 | + | ||
29 | +function get_base_time() // 시간 추출 함수 | ||
30 | +{ | ||
31 | + //단기예보 | ||
32 | + //- Base_time : 0200, 0500, 0800, 1100, 1400, 1700, 2000, 2300 (1일 8회) | ||
33 | + //- API 제공 시간(~이후) : 02:10, 05:10, 08:10, 11:10, 14:10, 17:10, 20:10, 23:10 | ||
34 | + //- 시간대 맞추기 | ||
35 | + let time = new String(moment().format('HHmm')); | ||
36 | + if ('0000'<=time && time<'0210'){time = '2300'} | ||
37 | + else if ('0210'<=time && time<'0510'){time = '0200'} | ||
38 | + else if ('0510'<=time && time<'0810'){time = '0500'} | ||
39 | + else if ('0810'<=time && time<'1110'){time = '0800'} | ||
40 | + else if ('1110'<=time && time<'1410'){time = '1100'} | ||
41 | + else if ('1410'<=time && time<'1710'){time = '1400'} | ||
42 | + else if ('1710'<=time && time<'2010'){time = '1700'} | ||
43 | + else if ('2010'<=time && time<'2310'){time = '2010'} | ||
44 | + else if ('2310'<=time && time<'2359'){time = '2300'} | ||
45 | + return time | ||
46 | + } | ||
47 | + | ||
48 | +router.get("/", (req, res) =>{ | ||
49 | + request( | ||
50 | + {url: url + queryParams, | ||
51 | + method: 'GET', | ||
52 | + }, | ||
53 | + (error, response, body) => { | ||
54 | + console.log('Status', response.statusCode); | ||
55 | + console.log('Headers', JSON.stringify(response.headers)); | ||
56 | + console.log('Reponse received', body); | ||
57 | + } | ||
58 | + ); | ||
59 | +}); | ||
60 | + | ||
61 | +module.exports = router; | ||
62 | + | ||
63 | +// | ||
64 | +// (사용 예) | ||
65 | +// var rs = dfs_xy_conv("toLL","60","127"); | ||
66 | +// console.log(rs.lat, rs.lng); | ||
67 | + | ||
68 | +dfs_xy_conv = function (code, v1, v2) { | ||
69 | +// 소스출처 : http://www.kma.go.kr/weather/forecast/digital_forecast.jsp | ||
70 | +// LCC DFS 좌표변환 ( code : "toXY"(위경도->좌표, v1:위도, v2:경도), "toLL"(좌표->위경도,v1:x, v2:y) ) | ||
71 | + | ||
72 | + var RE = 6371.00877; // 지구 반경(km) | ||
73 | + var GRID = 5.0; // 격자 간격(km) | ||
74 | + var SLAT1 = 30.0; // 투영 위도1(degree) | ||
75 | + var SLAT2 = 60.0; // 투영 위도2(degree) | ||
76 | + var OLON = 126.0; // 기준점 경도(degree) | ||
77 | + var OLAT = 38.0; // 기준점 위도(degree) | ||
78 | + var XO = 43; // 기준점 X좌표(GRID) | ||
79 | + var YO = 136; // 기1준점 Y좌표(GRID) | ||
80 | + | ||
81 | + var DEGRAD = Math.PI / 180.0; | ||
82 | + var RADDEG = 180.0 / Math.PI; | ||
83 | + | ||
84 | + var re = RE / GRID; | ||
85 | + var slat1 = SLAT1 * DEGRAD; | ||
86 | + var slat2 = SLAT2 * DEGRAD; | ||
87 | + var olon = OLON * DEGRAD; | ||
88 | + var olat = OLAT * DEGRAD; | ||
89 | + | ||
90 | + var sn = Math.tan(Math.PI * 0.25 + slat2 * 0.5) / Math.tan(Math.PI * 0.25 + slat1 * 0.5); | ||
91 | + sn = Math.log(Math.cos(slat1) / Math.cos(slat2)) / Math.log(sn); | ||
92 | + var sf = Math.tan(Math.PI * 0.25 + slat1 * 0.5); | ||
93 | + sf = Math.pow(sf, sn) * Math.cos(slat1) / sn; | ||
94 | + var ro = Math.tan(Math.PI * 0.25 + olat * 0.5); | ||
95 | + ro = re * sf / Math.pow(ro, sn); | ||
96 | + var rs = {}; | ||
97 | + if (code == "toXY") { | ||
98 | + rs['lat'] = v1; | ||
99 | + rs['lng'] = v2; | ||
100 | + var ra = Math.tan(Math.PI * 0.25 + (v1) * DEGRAD * 0.5); | ||
101 | + ra = re * sf / Math.pow(ra, sn); | ||
102 | + var theta = v2 * DEGRAD - olon; | ||
103 | + if (theta > Math.PI) theta -= 2.0 * Math.PI; | ||
104 | + if (theta < -Math.PI) theta += 2.0 * Math.PI; | ||
105 | + theta *= sn; | ||
106 | + rs['x'] = Math.floor(ra * Math.sin(theta) + XO + 0.5); | ||
107 | + rs['y'] = Math.floor(ro - ra * Math.cos(theta) + YO + 0.5); | ||
108 | + } | ||
109 | + else { | ||
110 | + rs['x'] = v1; | ||
111 | + rs['y'] = v2; | ||
112 | + var xn = v1 - XO; | ||
113 | + var yn = ro - v2 + YO; | ||
114 | + ra = Math.sqrt(xn * xn + yn * yn); | ||
115 | + if (sn < 0.0) - ra; | ||
116 | + var alat = Math.pow((re * sf / ra), (1.0 / sn)); | ||
117 | + alat = 2.0 * Math.atan(alat) - Math.PI * 0.5; | ||
118 | + | ||
119 | + if (Math.abs(xn) <= 0.0) { | ||
120 | + theta = 0.0; | ||
121 | + } | ||
122 | + else { | ||
123 | + if (Math.abs(yn) <= 0.0) { | ||
124 | + theta = Math.PI * 0.5; | ||
125 | + if (xn < 0.0) - theta; | ||
126 | + } | ||
127 | + else theta = Math.atan2(xn, yn); | ||
128 | + } | ||
129 | + var alon = theta / sn + olon; | ||
130 | + rs['lat'] = alat * RADDEG; | ||
131 | + rs['lng'] = alon * RADDEG; | ||
132 | + } | ||
133 | + return rs; | ||
134 | + } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
server/router/item.json
0 → 100644
1 | +[ | ||
2 | + { | ||
3 | + "GoodsCode": "1625717680", | ||
4 | + "OriginalPrice": "29,800", | ||
5 | + "SalePrice": "26,230", | ||
6 | + "GoodsName": "달콤나시(OBWC5266)(갤러리아)", | ||
7 | + "DiscountRate": "11", | ||
8 | + "Delivery": { | ||
9 | + "DeliveryInfo": "조건부무료", | ||
10 | + "DeliveryText": "배송비 3,000원", | ||
11 | + "DeliveryType": "GRAY", | ||
12 | + "ShowDeliveryInfo": true | ||
13 | + } | ||
14 | + }, | ||
15 | + { | ||
16 | + "GoodsCode": "1421117680", | ||
17 | + "OriginalPrice": "9,800", | ||
18 | + "SalePrice": "7,700", | ||
19 | + "GoodsName": "나시(현대)" | ||
20 | + } | ||
21 | +] | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
server/router/location.js
0 → 100644
1 | +const express = require('express'); | ||
2 | +const router = express.Router(); | ||
3 | + | ||
4 | +let location = new Array(); | ||
5 | + | ||
6 | +location = { | ||
7 | + lat : null, | ||
8 | + lng : null | ||
9 | +} | ||
10 | + | ||
11 | +router.post("/", (req,res) => { | ||
12 | + location.lat = req.body.lat; | ||
13 | + location.lng = req.body.lag; | ||
14 | + res.send({test : "hi"}); | ||
15 | +}); | ||
16 | + | ||
17 | +module.exports =router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
server/router/test.js
0 → 100644
1 | +const express = require('express'); | ||
2 | +const router = express.Router(); | ||
3 | + | ||
4 | +router.get("/", (req,res) => { | ||
5 | + res.send([ | ||
6 | + { | ||
7 | + "GoodsCode": "1625717680", | ||
8 | + "OriginalPrice": "29,800", | ||
9 | + "SalePrice": "26,230", | ||
10 | + "GoodsName": "달콤나시(OBWC5266)(갤러리아)", | ||
11 | + "DiscountRate": "11", | ||
12 | + "Delivery": { | ||
13 | + "DeliveryInfo": "조건부무료", | ||
14 | + "DeliveryText": "배송비 3,000원", | ||
15 | + "DeliveryType": "GRAY", | ||
16 | + "ShowDeliveryInfo": true | ||
17 | + } | ||
18 | + }, | ||
19 | + { | ||
20 | + "GoodsCode": "1421117680", | ||
21 | + "OriginalPrice": "9,800", | ||
22 | + "SalePrice": "7,700", | ||
23 | + "GoodsName": "나시(현대)" | ||
24 | + } | ||
25 | + ]); | ||
26 | +}); | ||
27 | + | ||
28 | +module.exports =router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
server/router/user.js
0 → 100644
server/server.js
0 → 100644
1 | +const express = require('express'); | ||
2 | +const app = express(); | ||
3 | +const port = 5000; | ||
4 | +const test = require('./router/test'); | ||
5 | +const weather = require('./router/Weather'); | ||
6 | +const location = require('./router/location'); | ||
7 | +const bodyParser = require('body-parser'); | ||
8 | +const cors = require('cors'); | ||
9 | + | ||
10 | +app.use(bodyParser.urlencoded({ extended: false })); | ||
11 | +app.use(bodyParser.json()); | ||
12 | +app.use(cors()); | ||
13 | +app.use("/api", test); | ||
14 | +app.use("/weather", weather); | ||
15 | +app.use("/locate", location); | ||
16 | + | ||
17 | + | ||
18 | + | ||
19 | +app.listen(port, ()=> console.log('Server is running on :', port)); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
No preview for this file type
-
Please register or login to post a comment