Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sirmmo committed Nov 18, 2024
1 parent 3e49815 commit e41b4f7
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 66 deletions.
25 changes: 19 additions & 6 deletions src/app/Services/API/Requests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export class RequestApi extends Http {
const labelsf = configs.map((config: any) =>
config.allowed_values.map(x => [
x.name,
language === 'it' ? x.display_name_italian : x.display_name_english,
[
config.name,
language === 'it' ? x.display_name_italian : x.display_name_english,
],
]),
);
const labels = Object.fromEntries(labelsf.flat());
Expand Down Expand Up @@ -72,11 +75,21 @@ export class RequestApi extends Http {
: '');
const label = x.split('/')[x.split('/').length - 1];
const tlabel = label.split('-');
const flabel = tlabel.map(x => {
if (Object.keys(labels).indexOf(x) >= 0) return labels[x];
else return '';
});
return { url, rawLabel: label, label: flabel.join(' - ') };
const flabel = tlabel
.map(x => {
if (Object.keys(labels).indexOf(x) >= 0) return labels[x];
else return null;
})
.filter(x => x);
const dconf: any = {
...{ time_period: null },
...Object.fromEntries(flabel),
};
const labelout =
`${dconf.climatological_variable} - ${dconf.archive} - ${dconf.climatological_model} - ${dconf.scenario} - ${dconf.aggregation_period} - ${dconf.measure} - ` +
(dconf.time_period ? `${dconf.time_period} - ` : '') +
`${dconf.year_period}`;
return { url, rawLabel: label, label: labelout };
};
return found.coverage_download_links.map(mapCoverageLinks);
});
Expand Down
10 changes: 6 additions & 4 deletions src/app/components/DownloadDataDialog/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ export const ModalStyle = theme => ({
});

export const ExtractionStyle = theme => ({
bottom: '40px',
bottom: '110px',
position: 'absolute',
left: '25%',
right: '25%',
left: '20%',
right: '20%',
width: '50%',
maxWidth: '800px',
top: 'calc(100% - 260px)',
minWidth: '600px',
maxWidth: '1700px',
});
2 changes: 1 addition & 1 deletion src/app/components/MapMenuBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ export function MapMenuBar(props: MapMenuBar) {
</Grid>
<Grid xs={1} sx={FirstRowStyle}>
<Box>
<Typography sx={MenuLabelStyle}>{foundLayers}</Typography>
<Typography sx={MenuLabelStyle}></Typography>
</Box>
</Grid>
</>
Expand Down
94 changes: 39 additions & 55 deletions src/app/pages/MapPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,61 +342,45 @@ export function MapPage(props: MapPageProps) {
};

const handleDownloadMapImg = () => {
// const format = 'image';
// let year = '';
// try {
// year =
// currentMap.data_series === 'yes'
// ? new Date((mapRef.current as any).timeDimension?.getCurrentTime())
// .getFullYear()
// .toString()
// : '';
// } catch (e) {
// // console.log('no year');
// }
//
// setInProgress(true);
// const caption = `${isMobile
// ? currentMap.climatological_variable
// : findValueName('variable', 'variables')
// }
//- ${joinNames([
// findValueName('forecast_model', 'forecast_models'),
// findValueName('scenario', 'scenarios'),
// ])}
//- ${joinNames([
// findValueName('data_series', 'data_series'),
// findValueName('value_type', 'value_types'),
// findValueName('time_window', 'time_windows'),
// ])}
//- ${findValueName('year_period', 'year_periods')}
//${year ? ` - Anno ${year}` : ''} © ARPAV - Arpa FVG`; // string or function, added caption to bottom of screen
// const filename = `Screenshot ${findValueName(
// 'variable',
// 'variables',
// )} - ${joinNames([
// findValueName('forecast_model', 'forecast_models'),
// findValueName('scenario', 'scenarios'),
// ])} - ${joinNames([
// findValueName('data_series', 'data_series'),
// findValueName('value_type', 'value_types'),
// findValueName('time_window', 'time_windows'),
// ])} - ${findValueName('year_period', 'year_periods')} ${year ? ` Anno ${year}` : ''
// }.png`;
// mapScreen
// .takeScreen(format, {
// captionFontSize: isMobile ? 10 : 12,
// screenName: `${findValueName('variable', 'variables')}`,
// caption: caption,
// })
// .then(blob => {
// setInProgress(false);
// saveAs(blob as Blob, filename);
// })
// .catch(e => {
// setInProgress(false);
// console.error(e);
// });
const format = 'image';
let year = '';
try {
year =
currentMap.data_series === 'yes'
? new Date((mapRef.current as any).timeDimension?.getCurrentTime())
.getFullYear()
.toString()
: '';
} catch (e) {
// console.log('no year');
}

setInProgress(true);
const caption = `${currentMap.climatological_variable}
- ${joinNames([currentMap.climatological_model, currentMap.scenario])}
- ${joinNames([currentMap.data_series, currentMap.time_window])}
- ${currentMap.year_period}
${year ? ` - Anno ${year}` : ''} © ARPAV - Arpa FVG`; // string or function, added caption to bottom of screen
const filename = `Screenshot ${currentMap.climatological_variable
} - ${joinNames([
currentMap.climatological_model,
currentMap.scenario,
])} - ${joinNames([currentMap.data_series, currentMap.time_window])} - ${currentMap.year_period
}} ${year ? ` Anno ${year}` : ''}.png`;
mapScreen
.takeScreen(format, {
captionFontSize: isMobile ? 10 : 12,
screenName: `${currentMap.climatological_variable}`,
caption: caption,
})
.then(blob => {
setInProgress(false);
saveAs(blob as Blob, filename);
})
.catch(e => {
setInProgress(false);
console.error(e);
});
};

const openCharts = (latLng: LatLng) => {
Expand Down

0 comments on commit e41b4f7

Please sign in to comment.