-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from KNU-AEYE/46-태그-검색-기능
46-태그-검색-기능
- Loading branch information
Showing
22 changed files
with
616 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,57 @@ | ||
"use client"; | ||
|
||
import { useEffect } from "react"; | ||
import { useEffect, useState } from "react"; | ||
import fetchWithInterception from "@/app/fetchWrapper"; | ||
import { Grid } from "@mui/material"; | ||
|
||
export default function Cams() { | ||
const [videos, setVideos] = useState<VideoResponseDto[]>([]); | ||
const [page, setPage] = useState(0); | ||
|
||
useEffect(() => { | ||
fetchWithInterception("https://api.a-eye.live/video", { | ||
method: "GET", | ||
}) | ||
.then((response) => response.json()) | ||
.then((jsonData) => console.log(jsonData.data)) | ||
.catch((error) => console.error(error)); | ||
}, []); | ||
return <div></div>; | ||
const fetchVideos = async () => { | ||
try { | ||
const response = await fetchWithInterception( | ||
`https://api.a-eye.live/video?page=${page}&size=12`, | ||
{ | ||
method: "GET", | ||
} | ||
); | ||
const jsonData = await response.json(); | ||
setVideos((prevVideos) => [...prevVideos, ...jsonData.data.videos]); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
fetchVideos(); | ||
window.addEventListener("scroll", handleScroll); | ||
return () => { | ||
window.removeEventListener("scroll", handleScroll); | ||
}; | ||
}, [page]); | ||
|
||
const handleScroll = () => { | ||
if ( | ||
window.innerHeight + document.documentElement.scrollTop === | ||
document.documentElement.offsetHeight | ||
) { | ||
setPage((prevPage) => prevPage + 1); | ||
} | ||
}; | ||
|
||
return ( | ||
<Grid container spacing={2}> | ||
{videos.map((video, index) => ( | ||
<Grid item xs={12} sm={6} md={4} lg={3} key={index}> | ||
<video | ||
id={`videoPlayer_${index}`} | ||
autoPlay | ||
muted | ||
src={video.videoUri} | ||
style={{ width: "100%", height: "100%" }} | ||
/> | ||
</Grid> | ||
))} | ||
</Grid> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Chip, Stack } from "@mui/material"; | ||
import { selectedTagsState } from "@/app/recoil-states"; | ||
import { useRecoilState } from "recoil"; | ||
|
||
const tags = ["새 객체", "넘어짐", "화재", "자동차", "도로"]; | ||
|
||
export default function SearchTagList() { | ||
const [selectedTags, setSelectedTags] = useRecoilState(selectedTagsState); | ||
|
||
const handleChipClick = (tag: string) => { | ||
setSelectedTags((prevSelectedTags) => { | ||
if (prevSelectedTags.includes(tag)) { | ||
return prevSelectedTags.filter((t) => t !== tag); | ||
} else { | ||
return [...prevSelectedTags, tag]; | ||
} | ||
}); | ||
}; | ||
return ( | ||
<Stack flexDirection="row" mb="15px"> | ||
{tags.map((tag, index) => ( | ||
<Chip | ||
label={tag} | ||
key={index} | ||
variant={selectedTags.includes(tag) ? "filled" : "outlined"} | ||
sx={{ margin: "0.5vh" }} | ||
color={selectedTags.includes(tag) ? "primary" : "default"} | ||
onClick={() => handleChipClick(tag)} | ||
/> | ||
))} | ||
</Stack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import InputBase from "@mui/material/InputBase"; | ||
import { styled, alpha } from "@mui/material/styles"; | ||
|
||
const Search = styled("div")(({ theme }) => ({ | ||
position: "relative", | ||
borderRadius: theme.shape.borderRadius, | ||
backgroundColor: theme.palette.info.main, // Use theme.palette.info.main | ||
marginLeft: 0, | ||
width: "100%", | ||
marginBottom: theme.spacing(2), | ||
transition: theme.transitions.create([ | ||
"background-color", | ||
"box-shadow", | ||
"border", | ||
]), | ||
border: `1px solid transparent`, // Default border | ||
"&:hover, &:focus-within": { | ||
backgroundColor: theme.palette.info.light, | ||
boxShadow: `0 0 0 1px ${alpha(theme.palette.info.contrastText, 0.5)}`, | ||
border: `1px solid ${theme.palette.info.main}`, | ||
}, | ||
[theme.breakpoints.up("sm")]: { | ||
marginLeft: theme.spacing(1), | ||
width: "auto", | ||
}, | ||
})); | ||
|
||
const SearchIconWrapper = styled("div")(({ theme }) => ({ | ||
padding: theme.spacing(0, 2), | ||
height: "100%", | ||
position: "absolute", | ||
pointerEvents: "none", | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
})); | ||
|
||
const StyledInputBase = styled(InputBase)(({ theme }) => ({ | ||
color: theme.palette.info.contrastText, // Use theme.palette.info.contrastText for text color | ||
width: "100%", | ||
"& .MuiInputBase-input": { | ||
padding: theme.spacing(1, 1, 1, 0), | ||
paddingLeft: `calc(1em + ${theme.spacing(4)})`, | ||
transition: theme.transitions.create("width"), | ||
[theme.breakpoints.up("sm")]: { | ||
width: "12ch", | ||
"&:focus": { | ||
width: "20ch", | ||
}, | ||
}, | ||
}, | ||
})); | ||
|
||
export { Search, SearchIconWrapper, StyledInputBase }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import Navbar from "@/app/components/Navbar"; | ||
import { Container } from "@mui/material"; | ||
import OnlineUserSpeedDial from "@/app/onlineUserSpeedDial"; | ||
|
||
export default function NavLayout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<> | ||
<Navbar /> | ||
<div>{children}</div> | ||
<Container> | ||
<Navbar /> | ||
<div>{children}</div> | ||
</Container> | ||
<OnlineUserSpeedDial /> | ||
</> | ||
); | ||
} |
Oops, something went wrong.