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

Fix: Condition to visibility of all the footer based on a boolean value #6230

Closed
wants to merge 100 commits into from
Closed
Changes from 3 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
e7da777
Remove references to rapid context methods that no longer exist.
Bonkles Apr 11, 2023
8c0e283
Rapid v2: Show the GPX data
tsmock Apr 12, 2023
d2212be
Fix NPE in rapidEditor
tsmock Apr 12, 2023
e000b70
Rapid updates
tsmock Apr 17, 2023
5fc041d
Bump rapid version to 2.0.3, also make use of imagery and init promis…
Bonkles May 3, 2023
e8e5031
Fix bug that would cause the 'custom editor' useEffect code to fire e…
Bonkles May 3, 2023
8b014b1
Update yarn.lock
tsmock Jun 8, 2023
f392ca1
Rapid: Update for next Rapid version
tsmock Jul 27, 2023
3748ace
Update Rapid to v2.1.1
tsmock Aug 30, 2023
99e2fe7
Rapid: Use system interface for setting up Rapid
tsmock Aug 30, 2023
4076030
Rapid: Load css and data resources from CDN
tsmock Aug 31, 2023
369cbea
Rapid: Fix issue where toggling sidebar would lose data, ensure mapvi…
tsmock Aug 31, 2023
8bc4c34
Don't try to upload to sentry if we aren't logged in
tsmock Aug 31, 2023
2853556
Rapid: Fix preauth
tsmock Aug 31, 2023
8ccc027
Rapid: Use URL hash parameters instead of function calls
tsmock Sep 5, 2023
46a7d83
Rapid: Get it working between task switches
tsmock Sep 8, 2023
afbada4
Rapid: Store dom node in state for reuse
tsmock Sep 8, 2023
3b54de2
Rapid: Export functions that may be useful for iD and add basic tests…
tsmock Sep 8, 2023
0a88b11
Listen for reset events to update task state disable state
tsmock Sep 11, 2023
95417b3
Merge branch 'chore/update-rapid' of github.com:facebook/OSM-HOT-Task…
royallsilwallz Oct 16, 2023
5475b68
fix test case fail error
royallsilwallz Oct 16, 2023
3420409
Merge branch 'develop' of github.com:hotosm/tasking-manager into develop
royallsilwallz Nov 29, 2023
94524a2
Merge branch 'chore/update-rapid' of github.com:facebook/OSM-HOT-Task…
royallsilwallz Nov 29, 2023
8c1de4b
+ Add a new view for live quality monitoring
emi420 Dec 6, 2023
a69ab25
Add a TODO message for enable/disable live monitoring button
emi420 Dec 6, 2023
4f574bb
Remove log message
emi420 Dec 6, 2023
9cb3dff
Fix for project's area
emi420 Dec 14, 2023
5ca8a63
Fix for project's area / center
emi420 Dec 14, 2023
8ce1499
Remove log msg
emi420 Dec 14, 2023
35a4490
'building' as default tag
emi420 Dec 14, 2023
6e5809c
Merge branch 'develop' of github.com:hotosm/tasking-manager into develop
royallsilwallz Dec 15, 2023
e0aa9ad
Merge branch 'feature/liveMonitoring' of github.com:hotosm/tasking-ma…
royallsilwallz Dec 15, 2023
77b2316
fix: removed unwanted type of Object
varun2948 Dec 15, 2023
efa4727
fix: mapbox token used from config
varun2948 Dec 15, 2023
07453a3
Merge pull request #28 from varun2948/feat-osm-download
royallsilwallz Dec 15, 2023
8e3b30d
tmpfix: yarn deps lodash fails during prep script
mahesh-naxa Dec 15, 2023
c948cee
Ignore eslint errors in live monitoring
royallsilwallz Dec 18, 2023
8272c9b
Merge branch 'feature/liveMonitoring' of github.com:hotosm/tasking-ma…
royallsilwallz Dec 18, 2023
24186da
Ignore eslint errors in project live monitoring
royallsilwallz Dec 18, 2023
387081a
Merge pull request #27 from naxa-developers/tm/feature/liveMonitoring
royallsilwallz Dec 18, 2023
1520c80
CI: restore CI
nischalstha9 Dec 18, 2023
5eb66cb
Merge pull request #29 from varun2948/feat-osm-download
varun2948 Dec 19, 2023
cde4e94
Merge pull request #30 from varun2948/feat-osm-download
varun2948 Dec 19, 2023
7972898
Merge pull request #31 from varun2948/feat-osm-download
royallsilwallz Dec 22, 2023
c914477
Use `UNDERPASS_URL` in `UnderpassMap` config from env in `ProjectLive…
royallsilwallz Jan 3, 2024
9a50e26
Add `usePriorityGeojsonQuery` hook for fetching priority area of live…
royallsilwallz Jan 3, 2024
184f340
Make `ProjectLiveMonitoring` button conditional based on supported areas
royallsilwallz Jan 3, 2024
9437bc2
Add `UNDERPASS_URL` to example.env
royallsilwallz Jan 3, 2024
ca5c4c5
deploy: frontend specific build
mahesh-naxa Jan 3, 2024
720145b
Merge pull request #33 from varun2948/feat-osm-download
varun2948 Jan 4, 2024
3144762
Merge pull request #34 from varun2948/feat-osm-download
varun2948 Jan 4, 2024
3da57b4
Merge pull request #35 from varun2948/feat-osm-download
varun2948 Jan 4, 2024
9ea4631
Merge pull request #36 from varun2948/feat-osm-download
varun2948 Jan 5, 2024
096d5b0
Merge pull request #37 from varun2948/feat-osm-download
varun2948 Jan 5, 2024
732153b
Merge pull request #38 from varun2948/feat-osm-download
varun2948 Jan 8, 2024
8218c0f
Use `available.json` instead of `priority.geojson` in `Live Monitoring`
royallsilwallz Jan 8, 2024
3913a11
resolve merge conflicts
royallsilwallz Jan 8, 2024
112fc5a
Merge branch 'develop' of github.com:hotosm/tasking-manager into feat…
royallsilwallz Jan 9, 2024
5bcf8cd
resolve merge conflicts
royallsilwallz Jan 9, 2024
2f85db7
Merge pull request #39 from naxa-developers/naxa/deploy/feature/liveM…
mahesh-naxa Jan 9, 2024
70e56fc
Updates following Underpass API changes. Remove hashtag filter. Add f…
emi420 Jan 9, 2024
baabdac
Merge branch 'feature/liveMonitoring' of github.com:hotosm/tasking-ma…
royallsilwallz Jan 10, 2024
49180f6
Upgrade `Underpass UI`
royallsilwallz Jan 10, 2024
a424c7a
Add same background imagery as project in Live Monitoring Map View
royallsilwallz Jan 13, 2024
bfa4171
Fix console error for `unsupported style property` in `Live Monitoring`
royallsilwallz Jan 13, 2024
0307d11
Merge pull request #40 from naxa-developers/feature/liveMonitoring
royallsilwallz Jan 16, 2024
8a30b89
Merge pull request #41 from varun2948/feat-osm-download
mahesh-naxa Jan 17, 2024
b8932b8
fix: header removed, search bar adjusted
manjitapandey Jan 17, 2024
dc893a0
padding changes
manjitapandey Jan 17, 2024
caa68ca
Fixes for styling, more compact design
emi420 Jan 17, 2024
da9d7f5
Add `OSM` as default layer in `Live Monitoring`
royallsilwallz Jan 18, 2024
559efa6
Fix crash issue when `imagery` not selected in `Live Monitoring`
royallsilwallz Jan 18, 2024
5e84581
Fix console error for `unsupported style property` in `Live Monitoring`
royallsilwallz Jan 18, 2024
da61ed7
Fix merge conflicts
royallsilwallz Jan 18, 2024
494fe3b
Fix merge conflicts
royallsilwallz Jan 18, 2024
870fac8
Merge pull request #43 from naxa-developers/tm/feature/liveMonitoring
royallsilwallz Jan 18, 2024
d64f883
Show `Live Monitoring` button only for `PUBLISHED` projects
royallsilwallz Jan 18, 2024
e7ca921
Change `Bing Imagery URL` to `https` in `Live Monitoring`
royallsilwallz Jan 18, 2024
c1af4cb
Merge branch 'feature/liveMonitoring' into tm/feature/liveMonitoring
royallsilwallz Jan 18, 2024
ad3579b
Merge pull request #44 from naxa-developers/tm/feature/liveMonitoring
royallsilwallz Jan 18, 2024
f3d8c90
Style fixes in `Live Monitoring` feature
royallsilwallz Jan 22, 2024
a2784fe
Update for Underpass API URLs
emi420 Jan 23, 2024
4833cb4
Merge pull request #45 from varun2948/feat-osm-download
varun2948 Jan 23, 2024
6e42c5c
Do not fetch user data on suggestions popup click in `Comments Section`
royallsilwallz Jan 23, 2024
03a4a0f
Fix popup close issue on mouse drag outside popup in `TaskActivityDet…
royallsilwallz Jan 19, 2024
bf957ae
Fix `Project Stats` page crash issue for archived projects
royallsilwallz Jan 22, 2024
aebc222
Fix for Underpass API URL env variable on config file
emi420 Jan 24, 2024
beb3578
Data Quality: + Option for list all features or only invalid ones
emi420 Jan 24, 2024
de3d60a
Merge pull request #46 from hotosm/fix/6209-comment-reset-on-mouse-dr…
royallsilwallz Jan 25, 2024
cc3172b
Merge pull request #47 from naxa-developers/fix/6131-stats-page-crash…
royallsilwallz Jan 25, 2024
9e82167
Merge pull request #48 from hotosm/fix/6166-network-error-on-comment-tag
royallsilwallz Jan 25, 2024
11b9b4c
Merge pull request #49 from hotosm/feature/liveMonitoring
royallsilwallz Jan 25, 2024
a6aa6e0
Merge pull request #50 from varun2948/feat-osm-download
varun2948 Jan 26, 2024
26f3c76
Merge pull request #51 from varun2948/feat-osm-download
varun2948 Jan 26, 2024
e9b5a33
Merge pull request #52 from varun2948/feat-osm-download
varun2948 Jan 29, 2024
20ed67e
Merge pull request #53 from varun2948/feat-osm-download
varun2948 Jan 29, 2024
2944c11
Merge pull request #54 from varun2948/feat-osm-download
varun2948 Jan 29, 2024
503c3b8
feat(footer): add condition to make footer detail visible
varun2948 Jan 30, 2024
6e20371
Merge branch 'deployment/naxa' into feat-osm-download
varun2948 Jan 30, 2024
8b28d59
Merge branch 'develop' of github.com:hotosm/tasking-manager into feat…
varun2948 Jan 30, 2024
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
253 changes: 140 additions & 113 deletions frontend/src/components/projectDetail/downloadOsmData.js
Original file line number Diff line number Diff line change
@@ -7,35 +7,34 @@ import { EXPORT_TOOL_S3_URL } from '../../config';
import messages from './messages';
import { FormattedMessage } from 'react-intl';
import formatBytes from '../../utils/formatBytes';
import { format } from 'date-fns';

export const TITLED_ICONS = [
{
Icon: RoadIcon,
title: 'Roads',
title: 'roads',
value: 'ROADS',
featuretype: ['lines'],
featuretype: [{ type: 'lines' }],
formats: ['geojson', 'shp', 'kml'],
},
{
Icon: HomeIcon,
title: 'Buildings',
title: 'buildings',
value: 'BUILDINGS',
featuretype: ['polygons'],
featuretype: [{ type: 'polygons' }],
formats: ['geojson', 'shp', 'kml'],
},
{
Icon: WavesIcon,
title: 'Waterways',
title: 'waterways',
value: 'WATERWAYS',
featuretype: ['lines', 'polygons'],
featuretype: [{ type: 'polygons' }, { type: 'lines' }],
formats: ['geojson', 'shp', 'kml'],
},
{
Icon: TaskIcon,
title: 'Landuse',
title: 'landuse',
value: 'LAND_USE',
featuretype: ['points', 'polygons'],
featuretype: [{ type: 'points' }, { type: 'polygons' }],
formats: ['geojson', 'shp', 'kml'],
},
];
@@ -48,10 +47,10 @@ export const TITLED_ICONS = [
*/

export const DownloadOsmData = ({ projectMappingTypes, project }) => {
const [downloadDataList, setDownloadDataList] = useState(TITLED_ICONS);
const [showPopup, setShowPopup] = useState(false);
const [isDownloadingState, setIsDownloadingState] = useState(null);
const [selectedCategoryFormat, setSelectedCategoryFormat] = useState(null);
const [mergedJSONData, setMergedJSONData] = useState(null);

const datasetConfig = {
dataset_prefix: `hotosm_project_${project.projectId}`,
@@ -66,55 +65,13 @@ export const DownloadOsmData = ({ projectMappingTypes, project }) => {
* @param {string} feature_type - The feature type of the ffile.
* @return {Promise<void>} Promise that resolves when the download is complete.
*/
const fetchMetaJSON = async () => {
const metaJSONResponse = await fetch(
`https://api-prod.raw-data.hotosm.org/v1/s3/get/${datasetConfig.dataset_folder}/${datasetConfig.dataset_prefix}/meta.json`,
);
// const metaJSON = null;
// const metaJSON = null;
const metaJSON = await metaJSONResponse.json();
// console.log(metaJSON, 'metaJSON');
const filteredMappingTypes = TITLED_ICONS?.filter((icon) =>
projectMappingTypes?.includes(icon.value),
);
const mergedData = filteredMappingTypes.map((category) => {
const dataset = metaJSON?.datasets?.find((dataset) => category.title in dataset) || {};
const addedMetaJSON = dataset[category.title] || { resources: [] };

const resources = addedMetaJSON.resources.reduce((mergedResources, resource) => {
const formatIndex = category.formats.indexOf(resource.format);
if (formatIndex !== -1) {
const featureType = resource.name.includes('_polygons') ? 'polygons' : 'lines';
if (category.featuretype.includes(featureType)) {
if (!mergedResources[featureType]) {
mergedResources[featureType] = {};
}

mergedResources[featureType][category.formats[formatIndex]] = {
name: resource.name,
url: resource.url,
description: resource.description,
size: resource.size,
last_modifed: resource.last_modifed,
};
}
}
return mergedResources;
}, {});

return { ...category, resources };
});
setMergedJSONData(mergedData);
console.log(mergedData);
};

const downloadS3File = async (title, fileFormat, feature_type) => {
// Create the base URL for the S3 file
const downloadUrl = `${EXPORT_TOOL_S3_URL}/${datasetConfig.dataset_folder}/${
datasetConfig.dataset_prefix
}/${title.toLowerCase()}/${feature_type}/${
}/${title}/${feature_type}/${
datasetConfig.dataset_prefix
}_${title.toLowerCase()}_${feature_type}_${fileFormat.toLowerCase()}.zip`;
}_${title}_${feature_type}_${fileFormat.toLowerCase()}.zip`;

// Set the state to indicate that the file download is in progress
setIsDownloadingState({ title: title, fileFormat: fileFormat, isDownloading: true });
@@ -147,10 +104,95 @@ export const DownloadOsmData = ({ projectMappingTypes, project }) => {
console.error('Error:', error.message);
}
};
useEffect(() => {
const filteredMappingTypes = downloadDataList?.filter((icon) =>
projectMappingTypes?.includes(icon.value),
);
setDownloadDataList(filteredMappingTypes);
}, [projectMappingTypes]);

useEffect(() => {
fetchMetaJSON();
}, []);
if (!selectedCategoryFormat) return null;
async function fetchData(url) {
const response = await fetch(url, { method: 'HEAD' });
const data = await response;
return {
size: data.headers.get('Content-Length'),
lastmod: data.headers.get('Last-Modified'),
};
}

const multipleHeadCallForFormat = async () => {
setIsDownloadingState({
title: selectedCategoryFormat.title,
fileFormat: selectedCategoryFormat.format,
isDownloading: true,
});

const filterMappingCategory = downloadDataList.find(
(type) => type.title === selectedCategoryFormat.title,
);
async function fetchAndMap(urls) {
const results = await Promise.all(
urls.map(async (url) => {
const data = await fetchData(url);
return data;
}),
);

return results;
}
const multipleUrl = filterMappingCategory.featuretype.map((type) => {
return `${EXPORT_TOOL_S3_URL}/${datasetConfig.dataset_folder}/${
datasetConfig.dataset_prefix
}/${selectedCategoryFormat.title}/${type.type}/${datasetConfig.dataset_prefix}_${
selectedCategoryFormat.title
}_${type.type}_${selectedCategoryFormat.format.toLowerCase()}.zip`;
});
fetchAndMap(multipleUrl)
.then((results) => {
var mergedArray = filterMappingCategory.featuretype.map((feature, index) => ({
...feature,
...results[index],
}));
const mergedListData = downloadDataList.map((type) => {
if (type.title === selectedCategoryFormat.title) {
return {
...type,
featuretype: mergedArray,
};
}
return type;
});
setDownloadDataList(mergedListData);
setIsDownloadingState({
title: selectedCategoryFormat.title,
fileFormat: selectedCategoryFormat.fileFormat,
isDownloading: false,
});
})

.catch((error) => {
console.error(error);
setIsDownloadingState({
title: selectedCategoryFormat.title,
fileFormat: selectedCategoryFormat.fileFormat,
isDownloading: false,
});
})
.finally(() => {
setIsDownloadingState({
title: selectedCategoryFormat.title,
fileFormat: selectedCategoryFormat.fileFormat,
isDownloading: false,
});
});
};
multipleHeadCallForFormat();

console.log('test');
}, [selectedCategoryFormat]);

return (
<div className="mb5 w-100 pb5 ph4 flex flex-wrap">
<Popup modal open={showPopup} closeOnDocumentClick nested onClose={() => setShowPopup(false)}>
@@ -179,13 +221,13 @@ export const DownloadOsmData = ({ projectMappingTypes, project }) => {
</div>
)}
</Popup>
{mergedJSONData?.map((type) => {
{downloadDataList.map((type) => {
const loadingState = isDownloadingState?.isDownloading;
return (
<div
className="osm-card bg-white pa3 mr4 mt4 w-auto-m flex flex-wrap items-center "
style={{
width: '870px',
width: '800px',
gap: '16px',
}}
key={type.title}
@@ -206,8 +248,8 @@ export const DownloadOsmData = ({ projectMappingTypes, project }) => {
</div>
<div className="flex-column">
<div
className="file-list flex barlow-condensed f3 "
style={{ display: 'flex', gap: '12px', width: 'fit-content' }}
className="file-list flex barlow-condensed f3"
style={{ display: 'flex', gap: '12px' }}
>
<p className="fw5 ttc">{type.title}</p>
<FileFormatCard
@@ -230,59 +272,44 @@ export const DownloadOsmData = ({ projectMappingTypes, project }) => {
{selectedCategoryFormat &&
selectedCategoryFormat.title === type.title &&
type?.featuretype?.map((typ) => (
<>
<span
key={`${typ}_${selectedCategoryFormat.title}`}
onClick={() =>
downloadS3File(
selectedCategoryFormat.title,
selectedCategoryFormat.format,
typ,
)
}
onKeyUp={() =>
downloadS3File(
selectedCategoryFormat.title,
selectedCategoryFormat.format,
typ,
)
}
style={
loadingState
? { cursor: 'not-allowed', pointerEvents: 'none', gap: '10px' }
: { cursor: 'pointer', gap: '10px' }
}
className="flex flex-row items-center pointer link hover-red color-inherit categorycard"
>
<div className="flex flex-column">
<div className="flex flex-row items-center ">
<DownloadIcon style={{ height: '28px' }} color="#D73F3F" />
<p className="ttc ml2">
{typ} {selectedCategoryFormat.format}
<span className="ml1 gray f7">
(
{formatBytes(
type.resources[typ][selectedCategoryFormat.format].size,
)}
)
</span>
</p>
</div>
<p className="gray f7" style={{ margin: 0 }}>
Last Generated:{' '}
{type.resources[typ][selectedCategoryFormat.format].last_modifed
? format(
new Date(
type.resources[typ][selectedCategoryFormat.format].last_modifed,
),
'MM/dd/yyyy HH:mm:ss z ',
{ timeZone: 'UTC' },
)
: '-'}
</p>
</div>
</span>
</>
<span
key={`${typ}_${selectedCategoryFormat.title}`}
onClick={() =>
downloadS3File(
selectedCategoryFormat.title,
selectedCategoryFormat.format,
typ.type,
)
}
onKeyUp={() =>
downloadS3File(
selectedCategoryFormat.title,
selectedCategoryFormat.format,
typ.type,
)
}
style={
loadingState
? { cursor: 'not-allowed', pointerEvents: 'none', gap: '10px' }
: { cursor: 'pointer', gap: '10px' }
}
className="flex flex-row items-center pointer link hover-red color-inherit categorycard"
>
<div>
<p className="ttc">
<DownloadIcon cla color="#D73F3F" />
<span className="ml2">
{typ.type} {selectedCategoryFormat.format}
</span>
<span className="ml1 f7 mid-gray">{`(${
typ.size ? formatBytes(typ.size) : '-'
})`}</span>
</p>
<span className="f7 mid-gray">{`Last Generated: ${
typ.lastmod ? typ.lastmod : '-'
})`}</span>
</div>
</span>
))}
</div>
</div>