Skip to content

Commit

Permalink
Add Image src
Browse files Browse the repository at this point in the history
  • Loading branch information
sehee0207 committed Feb 21, 2024
1 parent 5329b7b commit 4c7d399
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 19 deletions.
Binary file modified data/docity.xlsx
Binary file not shown.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap" rel="stylesheet">
<title>SHIELD</title>
</head>
<body>
Expand Down
51 changes: 33 additions & 18 deletions src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ interface ModalProps{
onClick? : () => void;
}

interface ImageStyleProps {
url: string;
}

const ModalWrap = styled.div`
position: fixed;
display: flex;
Expand Down Expand Up @@ -43,7 +47,7 @@ const ModalContainer = styled.div`
position: relative;
z-index: 25;
width: 360px;
height: 70vh;
height: 80vh;
`;

const CloseButtonStyle = styled.div`
Expand All @@ -68,45 +72,54 @@ const InfoContainerStyle = styled.div`
`

const WeatherContainerStyle = styled.div`
margin: 10px
`

const WeatherDivStyle = styled.div`
padding: 10px 0px 0px 0px;
`

const ImageStyle = styled.div<ImageStyleProps>`
width: 300px;
height: 150px;
background-image: url(${props => props.url});
background-position: center;
background-repeat: no-repeat;
background-size: cover;
`


const Modal = ({ title, latlng, onClick }: ModalProps) =>{
const [weatherData, setWeatherData] = useState<any>(null);
const [camnum, setCamnum] = useState<number>(2);
const [imgurl, setImgurl] = useState<string>("");

useEffect(() => {
if(latlng){
if(latlng.lat() === 37.5455){ setCamnum(1) }
if(latlng.lat() === 37.5455){
setCamnum(1);
}
}
}, [latlng]);

useEffect(() => {
if(latlng){
fetch(`https://api.openweathermap.org/data/2.5/weather?lat=${latlng.lat()}&lon=${latlng.lng()}&appid=${import.meta.env.VITE_WEATHER_API_KEY}`)
.then(response => response.json())
.then(data => setWeatherData(data))
.catch(error => console.error('Error:', error));
.then(response => response.json())
.then(data => setWeatherData(data))
.catch(error => console.error('Error:', error));
}

// axios.get('http://localhost:8080/api/fire-Info')
// .then(response => {
// console.log(response.data)
// })
// .catch(error => {
// console.error('Error:', error);
// });

axios.get("http://localhost:8080/api/fire-Info")
.then(response => {
axios.post(`http://localhost:8080/api/fire-Info/${camnum}`)
.then(response => {
console.log("카메라다" + camnum);
console.log(response.data)
setImgurl(response.data);
})
.catch(error => {
console.error('Error:', error);
});

}, [latlng]);
}, [camnum])

const getWindDirection = (deg: number) => {
const directions = ['North', 'Northeast', 'East', 'Southeast', 'South', 'Southwest', 'West', 'Northwest'];
Expand Down Expand Up @@ -147,6 +160,8 @@ const Modal = ({ title, latlng, onClick }: ModalProps) =>{
<WeatherDivStyle>Cloud : {weatherData.clouds.all} %</WeatherDivStyle>
</WeatherContainerStyle>
)}

<ImageStyle url={imgurl}>.</ImageStyle>

</InfoContainerStyle>
</ModalContainer>
Expand Down
1 change: 0 additions & 1 deletion src/styles/GlobalStyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const GlobalStyle = createGlobalStyle`
*{
box-sizing: border-box;
font-family: 'Nanum Gothic', sans-serif;
}
body{
Expand Down
7 changes: 7 additions & 0 deletions src/styles/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
*{
font-family: "Nunito", sans-serif;
font-optical-sizing: auto;
font-weight: weight;
font-style: normal;
}

select{
width: 200px;
height: 4vh;
Expand Down

0 comments on commit 4c7d399

Please sign in to comment.