Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e33a663
added
Yashgupta9330 Mar 4, 2025
20423b2
undo
Yashgupta9330 Mar 4, 2025
a9f6f15
fixed
Yashgupta9330 Mar 4, 2025
078359f
Merge branch 'main' into chapters3
Yashgupta9330 Mar 4, 2025
5bec21e
Merge branch 'main' into chapters3
Yashgupta9330 Mar 4, 2025
554ea25
Merge branch 'main' into chapters3
Yashgupta9330 Mar 5, 2025
44f1e68
Merge branch 'main' into chapters3
Yashgupta9330 Mar 5, 2025
c117eed
fixed
Yashgupta9330 Mar 5, 2025
18d706d
fixed
Yashgupta9330 Mar 5, 2025
cfd2ba0
fixed
Yashgupta9330 Mar 5, 2025
588b6d3
fixed
Yashgupta9330 Mar 5, 2025
57ba179
fixed
Yashgupta9330 Mar 5, 2025
5506cd2
fixed
Yashgupta9330 Mar 5, 2025
7512537
Merge branch 'OWASP:main' into chapters3
Yashgupta9330 Mar 5, 2025
94cbe84
fixed
Yashgupta9330 Mar 5, 2025
e4b6235
Merge branch 'main' into chapters3
Yashgupta9330 Mar 5, 2025
b624ad5
pulled
Yashgupta9330 Mar 5, 2025
19bafd6
fixed
Yashgupta9330 Mar 5, 2025
10c13bf
fixed
Yashgupta9330 Mar 5, 2025
7e05dce
fixed
Yashgupta9330 Mar 5, 2025
b12b9e8
fixed
Yashgupta9330 Mar 5, 2025
3ad5ebd
Merge branch 'main' into chapters3
Yashgupta9330 Mar 6, 2025
1153df0
Merge branch 'main' into chapters3
Yashgupta9330 Mar 6, 2025
44d0dc4
Merge branch 'main' into chapters3
Yashgupta9330 Mar 7, 2025
5ddf29b
fixed
Yashgupta9330 Mar 7, 2025
259f9a6
fixed
Yashgupta9330 Mar 7, 2025
79c6947
Merge branch 'main' into chapters3
Yashgupta9330 Mar 7, 2025
2906b11
fixed spacing
Yashgupta9330 Mar 7, 2025
be6a43a
Merge branch 'main' into chapters3
Yashgupta9330 Mar 7, 2025
cf99a17
Merge branch 'main' into chapters3
Yashgupta9330 Mar 8, 2025
0d21b0e
Merge branch 'main' into chapters3
kasya Mar 9, 2025
7e771d3
Merge branch 'main' into chapters3
Yashgupta9330 Mar 9, 2025
5132dba
Update dependencies
arkid15r Mar 10, 2025
426d54d
Issue resolved : #1068 Correction to overflow of name in usercard (#…
KaranNegi20Feb Mar 10, 2025
ac33cf3
Update dependencies
arkid15r Mar 10, 2025
079044d
Fixed issue #1035 Correct redirection and Links have valid URLs. (#1071)
KaranNegi20Feb Mar 11, 2025
817dfa6
🔍 Integrate Event Search from GraphQL (#1064)
rishyym0927 Mar 11, 2025
fc55505
Update CI/CD
arkid15r Mar 11, 2025
946fd76
Update dependencies
arkid15r Mar 11, 2025
9ecb739
Update dependencies
arkid15r Mar 11, 2025
4fe3e89
Update code
arkid15r Mar 11, 2025
ff8d3c4
Merge branch 'main' into chapters3
arkid15r Mar 11, 2025
3e5e00b
Update code
arkid15r Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/__tests__/unit/pages/Home.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('Home', () => {
render(<Home />)

await waitFor(() => {
expect(screen.getByText('OWASP Chapters Nearby')).toBeInTheDocument()
expect(screen.getByText('OWASP Chapters Worldwide')).toBeInTheDocument()
})
})

Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/CardDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const DetailsCard = ({
<div className="mb-8 h-[250px] md:col-span-4 md:h-auto">
<ChapterMap
geoLocData={geolocationData ? [geolocationData] : []}
showLocal={true}
style={{
height: '100%',
width: '100%',
Expand Down
44 changes: 26 additions & 18 deletions frontend/src/components/ChapterMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import { GeoLocDataAlgolia, GeoLocDataGraphQL } from 'types/chapter'

const ChapterMap = ({
geoLocData,
showLocal,
style,
}: {
geoLocData: GeoLocDataGraphQL[] | GeoLocDataAlgolia[]
showLocal: boolean
style: React.CSSProperties
}) => {
const mapRef = useRef<L.Map | null>(null)
const markerClusterRef = useRef<L.MarkerClusterGroup | null>(null)

const normalizedData = useMemo(() => {
const chapters = useMemo(() => {
return geoLocData.map((chapter) => ({
lat: '_geoloc' in chapter ? chapter._geoloc.lat : chapter.geoLocation.lat,
lng: '_geoloc' in chapter ? chapter._geoloc.lng : chapter.geoLocation.lng,
Expand All @@ -24,14 +27,13 @@ const ChapterMap = ({
}))
}, [geoLocData])

//for reference: https://leafletjs.com/reference.html#map-example
useEffect(() => {
if (!mapRef.current) {
mapRef.current = L.map('chapter-map', {
worldCopyJump: false, // Prevents the map from wrapping around the world
worldCopyJump: false,
maxBounds: [
[-90, -180], // Southwest corner of the map bounds (latitude, longitude)
[90, 180], // Northeast corner of the map bounds (latitude, longitude)
[-90, -180],
[90, 180],
],
maxBoundsViscosity: 1.0,
}).setView([20, 0], 2)
Expand All @@ -43,29 +45,28 @@ const ChapterMap = ({
}

const map = mapRef.current

// Remove previous markers
map.eachLayer((layer) => {
if (layer instanceof L.Marker || layer instanceof L.LayerGroup) {
map.removeLayer(layer)
}
})

// Create a new marker cluster group
const markerClusterGroup = L.markerClusterGroup()
const bounds: [number, number][] = []
normalizedData.forEach((chapter) => {
markerClusterRef.current = markerClusterGroup
chapters.forEach((chapter) => {
const markerIcon = new L.Icon({
iconAnchor: [12, 41], // Anchor point
iconAnchor: [12, 41],
iconRetinaUrl: '/img/marker-icon-2x.png',
iconSize: [25, 41], // Default size for Leaflet markers
iconSize: [25, 41],
iconUrl: '/img/marker-icon.png',
popupAnchor: [1, -34], // Popup position relative to marker
shadowSize: [41, 41], // Shadow size
popupAnchor: [1, -34],
shadowSize: [41, 41],
shadowUrl: '/img/marker-shadow.png',
})
const marker = L.marker([chapter.lat, chapter.lng], {
icon: markerIcon,
})
const marker = L.marker([chapter.lat, chapter.lng], { icon: markerIcon })
const popup = L.popup()
const popupContent = document.createElement('div')
popupContent.className = 'popup-content'
Expand All @@ -81,12 +82,19 @@ const ChapterMap = ({

map.addLayer(markerClusterGroup)

if (bounds.length > 0) {
map.fitBounds(bounds as L.LatLngBoundsExpression, { maxZoom: 10 })
if (showLocal) {
const maxNearestChapters = 5
const localChapters = chapters.slice(0, maxNearestChapters - 1)
const localBounds = L.latLngBounds(localChapters.map((ch) => [ch.lat, ch.lng]))
const firstChapter = chapters[0]

const maxZoom = 7
map.setView([firstChapter.lat, firstChapter.lng], maxZoom)
map.fitBounds(localBounds, { maxZoom: maxZoom })
}
}, [normalizedData])
}, [chapters, showLocal])

return <div id="chapter-map" className="rounded-lg dark:bg-[#212529]" style={style} />
return <div id="chapter-map" style={style} />
}

export default ChapterMap
1 change: 1 addition & 0 deletions frontend/src/pages/Chapters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const ChaptersPage = () => {
{chapters.length > 0 && (
<ChapterMap
geoLocData={searchQuery ? chapters : geoLocData}
showLocal={true}
style={{ height: '400px', width: '100%', zIndex: '0' }}
/>
)}
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function Home() {
indexName: 'chapters',
query: '',
currentPage: 1,
hitsPerPage: 25,
hitsPerPage: 1000,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we increase this so much? 🤔

Copy link
Contributor Author

@Yashgupta9330 Yashgupta9330 Mar 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I want to show all chapter also previously only 5 chapters was fetching

}
const data: AlgoliaResponseType<ChapterTypeAlgolia> = await fetchAlgoliaData(
searchParams.indexName,
Expand Down Expand Up @@ -205,14 +205,15 @@ export default function Home() {
</div>
</SecondaryCard>
</div>
<TopContributors contributors={data.topContributors} maxInitialDisplay={9} />
<div className="mb-20">
<h2 className="mb-6 text-3xl font-semibold">OWASP Chapters Nearby</h2>
<h2 className="mb-6 text-3xl font-semibold">OWASP Chapters Worldwide</h2>
<ChapterMap
geoLocData={geoLocData}
showLocal={false}
style={{ height: '400px', width: '100%', zIndex: '0' }}
/>
</div>
<TopContributors contributors={data.topContributors} maxInitialDisplay={9} />
<div className="grid gap-4 md:grid-cols-2">
<ItemCardList
title="Recent Issues"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/SnapshotDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const SnapshotDetailsPage: React.FC = () => {
<div className="mb-4">
<ChapterMap
geoLocData={snapshot.newChapters}
showLocal={false}
style={{ height: '400px', width: '100%', zIndex: '0' }}
/>
</div>
Expand Down