Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements in Partner Stats MapSwipe page #6601

Merged
merged 8 commits into from
Nov 13, 2024
9 changes: 6 additions & 3 deletions frontend/src/components/homepage/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import shortNumber from 'short-number';

import messages from './messages';
import { useOsmStatsQuery, useSystemStatisticsQuery } from '../../api/stats';
import StatsInfoFooter from '../statsInfoFooter';

export const StatsNumber = (props) => {
const value = shortNumber(props.value);
Expand Down Expand Up @@ -38,8 +39,10 @@ export const StatsSection = () => {
const hasStatsLoaded = hasTmStatsLoaded && hasOsmStatsLoaded;

return (
<>
<div className="pt5 pb2 ph6-l ph4 flex justify-around flex-wrap flex-nowrap-ns stats-container">
<div className="pt5 pb2 ph6-l ph4 ">
<StatsInfoFooter className="mb4" />

<div className="flex justify-around flex-wrap flex-nowrap-ns stats-container">
<StatsColumn
label={messages.buildingsStats}
value={hasStatsLoaded ? osmStatsData?.buildings : undefined}
Expand All @@ -61,6 +64,6 @@ export const StatsSection = () => {
value={hasStatsLoaded ? tmStatsData.data.mappersOnline : undefined}
/>
</div>
</>
</div>
);
};
7 changes: 5 additions & 2 deletions frontend/src/components/partnerMapswipeStats/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const formatSecondsToTwoUnits = (seconds, shortFormat = false) => {
years: 'yrs',
months: 'mos',
weeks: 'wks',
days: 'ds',
days: 'days',
hours: 'hrs',
minutes: 'mins',
seconds: 'secs',
Expand Down Expand Up @@ -82,8 +82,11 @@ export const Overview = () => {
customPlaceholder={<OverviewPlaceholder />}
ready={!isLoading && !isRefetching}
>
<h3 class="f2 blue-dark fw7 ma0 barlow-condensed v-mid dib mb3">
{data?.nameInsideProvider}
</h3>
<div
className="flex justify-between items-stretch flex-wrap flex-nowrap-ns"
className="flex justify-between items-stretch flex-wrap flex-nowrap-l"
style={{ gap: '1.6rem' }}
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const ProjectTypeAreaStats = ({

return (
<div
className="flex justify-between items-center flex-wrap flex-nowrap-ns"
className="flex justify-between items-center flex-wrap flex-nowrap-l"
style={{ gap: '1.6rem' }}
>
<div className="pa4 flex items-center bg-white shadow-6 w-100" style={{ gap: '1.75rem' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ export const SwipesByOrganization = ({ contributionsByOrganization = [] }) => {
}, []);

return (
<div style={{ width: '48.5%' }}>
<div className="mapswipe-stats-piechart">
<h3 className="f2 fw6 ttu barlow-condensed blue-dark mt0 pt2 mb4">
<FormattedMessage {...messages.swipesByOrganization} />
</h3>

<div className="bg-white pa4 shadow-6 relative" style={{ height: '450px' }}>
<canvas ref={chartRef}></canvas>
{contributionsByOrganization.length === 0 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const SwipesByProjectType = ({ contributionsByProjectType = [] }) => {
}, []);

return (
<div style={{ width: '48.5%' }}>
<div className="mapswipe-stats-piechart">
<h3 className="f2 fw6 ttu barlow-condensed blue-dark mt0 pt2 mb4">
<FormattedMessage {...messages.swipesByProjectType} />
</h3>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/partners/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import messages from '../../views/messages';
import { StatsSection } from './partnersStats';
import { Activity } from './partnersActivity';
import { CurrentProjects } from './currentProjects';
import StatsInfoFooter from '../statsInfoFooter';

export const Leaderboard = ({ partner, partnerStats }) => {
return (
<div className="pa4 bg-tan flex flex-column gap-1.25">
<StatsInfoFooter className="mv3" />

<div className="flex justify-between items-center">
<h3 className="f2 blue-dark fw7 ma0 barlow-condensed v-mid dib">
{partner.primary_hashtag
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/partners/partners.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function PartnersCard({ details }) {
<FormattedMessage {...messages.edit} />
</CustomButton>
</Link>
<Link to={`/partners/${details.permalink}/stats/leaderboard`}>
<Link to={`/partners/${details.permalink}/stats`}>
<CustomButton
style={{ backgroundColor: '#e2e2e2' }}
className="blue-dark ba b--grey-light pa2 br1 f5 pointer"
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/partners/partnersStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import shortNumber from 'short-number';
import messages from './messages';
import { StatsCard } from '../statsCard';
import { MappingIcon, EditIcon, RoadIcon, HomeIcon } from '../svgIcons';
import StatsInfoFooter from '../statsInfoFooter';

const iconClass = 'h-50 w-50';
const iconStyle = { height: '45px' };
Expand Down Expand Up @@ -71,7 +70,6 @@ export const StatsSection = ({ partner }) => {
className={'w-25-l w-50-m w-100 mv1'}
/>
</div>
<StatsInfoFooter />
</div>
);
};
50 changes: 26 additions & 24 deletions frontend/src/components/projectStats/edits.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import projectMessages from './messages';
import userDetailMessages from '../userDetail/messages';
import { MappingIcon, HomeIcon, RoadIcon, EditIcon } from '../svgIcons';
import { StatsCard } from '../statsCard';
import StatsTimestamp from '../statsTimestamp';
import StatsInfoFooter from '../statsInfoFooter';

export const EditsStats = ({ data }) => {
const { changesets, buildings, roads, edits } = data;
Expand All @@ -18,30 +18,32 @@ export const EditsStats = ({ data }) => {
<h3 className="barlow-condensed ttu f3">
<FormattedMessage {...projectMessages.edits} />
</h3>
<StatsTimestamp messageType="project" />
</div>
<div className="db pb2 project-edit-stats">
<StatsCard
field={'changesets'}
icon={<MappingIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...projectMessages.changesets} />}
value={changesets || 0}
/>
<StatsCard
icon={<EditIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...projectMessages.totalEdits} />}
value={edits || 0}
/>
<StatsCard
icon={<HomeIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.buildingsMapped} />}
value={buildings || 0}
/>
<StatsCard
icon={<RoadIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.roadMapped} />}
value={roads || 0}
/>
<div>
<StatsInfoFooter className="mb4" />
<div className="db pb2 project-edit-stats">
<StatsCard
field={'changesets'}
icon={<MappingIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...projectMessages.changesets} />}
value={changesets || 0}
/>
<StatsCard
icon={<EditIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...projectMessages.totalEdits} />}
value={edits || 0}
/>
<StatsCard
icon={<HomeIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.buildingsMapped} />}
value={buildings || 0}
/>
<StatsCard
icon={<RoadIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.roadMapped} />}
value={roads || 0}
/>
</div>
</div>
</div>
);
Expand Down
40 changes: 25 additions & 15 deletions frontend/src/components/statsInfoFooter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,37 @@ import { useIntl } from 'react-intl';

import { useOsmStatsMetadataQuery } from '../../api/stats';
import { dateOptions } from '../statsTimestamp';
import { InfoIcon } from '../svgIcons';
import '../../views/partnersMapswipeStats.scss';

export default function StatsInfoFooter() {
export default function StatsInfoFooter({ className }) {
const intl = useIntl();

const { data: osmStatsMetadata } = useOsmStatsMetadataQuery();

return (
<div className="cf w-100 relative tr pt3">
<span className="ma0 f7 fw4 blue-grey mb1 i">
These statistics come from{' '}
<a
className="blue-grey fw7"
href="https://stats.now.ohsome.org/about"
target="_blank"
rel="noreferrer"
>
ohsomeNow Stats
</a>{' '}
and were last updated at{' '}
<strong>{intl.formatDate(osmStatsMetadata?.max_timestamp, dateOptions)}</strong> (
{intl.timeZone}).
<div
className={`pr3 pv2 pl0 relative inline-flex mapswipe-stats-info-banner
blue-dark ${className}`}
>
<span className="inline-flex items-center ">
<InfoIcon className="mr2" style={{ height: '20px' }} />
<span>
These statistics come from{' '}
<a
className="blue-grey"
href="https://stats.now.ohsome.org/about"
target="_blank"
rel="noreferrer"
>
ohsomeNow Stats
</a>{' '}
and were last updated at{' '}
<span className="fw5 stats-info-datetime">
{intl.formatDate(osmStatsMetadata?.max_timestamp, dateOptions)}
</span>{' '}
({intl.timeZone})
</span>
</span>
</div>
);
Expand Down
55 changes: 29 additions & 26 deletions frontend/src/components/teamsAndOrgs/featureStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import userDetailMessages from '../userDetail/messages';
import { OHSOME_STATS_BASE_URL, defaultChangesetComment } from '../../config';
import { RoadIcon, HomeIcon, WavesIcon, MarkerIcon } from '../svgIcons';
import { StatsCard } from '../statsCard';
import StatsTimestamp from '../statsTimestamp';
import StatsInfoFooter from '../statsInfoFooter';

export const FeatureStats = () => {
const [stats, setStats] = useState({ edits: 0, buildings: 0, roads: 0, pois: 0, waterways: 0 });
Expand Down Expand Up @@ -42,33 +42,36 @@ export const FeatureStats = () => {
<h4 className="f3 fw6 ttu barlow-condensed blue-dark">
<FormattedMessage {...messages.totalFeatures} />
</h4>
<StatsTimestamp messageType="generic" />
</div>
<div className="w-100 cf">
<StatsCard
icon={<HomeIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.buildingsMapped} />}
value={stats.buildings || 0}
className={'w-25-l w-50-m w-100 mv1'}
/>
<StatsCard
icon={<RoadIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.roadMapped} />}
value={stats.roads || 0}
className={'w-25-l w-50-m w-100 mv1'}
/>
<StatsCard
icon={<MarkerIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.poiMapped} />}
value={stats.pois || 0}
className={'w-25-l w-50-m w-100 mv1'}
/>
<StatsCard
icon={<WavesIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.waterwaysMapped} />}
value={stats.waterways || 0}
className={'w-25-l w-50-m w-100 mv1'}
/>
<StatsInfoFooter className="mb4" />

<div className="flex gap-1 flex-nowrap-l flex-wrap">
<StatsCard
icon={<HomeIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.buildingsMapped} />}
value={stats.buildings || 0}
className={'w-25-l w-50-m w-100 mv1'}
/>
<StatsCard
icon={<RoadIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.roadMapped} />}
value={stats.roads || 0}
className={'w-25-l w-50-m w-100 mv1'}
/>
<StatsCard
icon={<MarkerIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.poiMapped} />}
value={stats.pois || 0}
className={'w-25-l w-50-m w-100 mv1'}
/>
<StatsCard
icon={<WavesIcon className={iconClass} style={iconStyle} />}
description={<FormattedMessage {...userDetailMessages.waterwaysMapped} />}
value={stats.waterways || 0}
className={'w-25-l w-50-m w-100 mv1'}
/>
</div>
</div>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/userDetail/elementsMapped.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ export const ElementsMapped = ({ userStats, osmStats }) => {

return (
<div>
<StatsInfoFooter className="mb4" />

<div className="w-100 relative stats-cards-container">
<StatsCard
invertColors={true}
Expand Down Expand Up @@ -173,8 +175,6 @@ export const ElementsMapped = ({ userStats, osmStats }) => {
unitLess={osmStats?.waterway?.modified?.unit_less}
/>
</div>

<StatsInfoFooter />
</div>
);
};
4 changes: 0 additions & 4 deletions frontend/src/views/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { WhoIsMapping } from '../components/homepage/whoIsMapping';
import { Testimonials } from '../components/homepage/testimonials';
import { Alert } from '../components/alert';
import homeMessages from '../components/homepage/messages';
import StatsTimestamp from '../components/statsTimestamp/';

export function Home() {
return (
Expand All @@ -24,9 +23,6 @@ export function Home() {
}
>
<StatsSection />
<div class="cf w-100 relative tr pt3 pr3">
<StatsTimestamp messageType="generic" />
</div>
</ErrorBoundary>
<MappingFlow />
<WhoIsMapping />
Expand Down
17 changes: 0 additions & 17 deletions frontend/src/views/partnersMapswipeStats.css

This file was deleted.

Loading
Loading