Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sirmmo committed Nov 14, 2024
1 parent ac2faf6 commit d011637
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/app/Services/API/Requests/debug.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[0925/151533.979:ERROR:registration_protocol_win.cc(108)] CreateFile: Impossibile trovare il file specificato. (0x2)
[1014/203803.592:ERROR:registration_protocol_win.cc(108)] CreateFile: Impossibile trovare il file specificato. (0x2)
[1112/140114.553:ERROR:registration_protocol_win.cc(108)] CreateFile: Impossibile trovare il file specificato. (0x2)
[1114/145631.897:ERROR:registration_protocol_win.cc(108)] CreateFile: Impossibile trovare il file specificato. (0x2)
37 changes: 22 additions & 15 deletions src/app/Services/API/Requests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@ export class RequestApi extends Http {
* @param {any} dataSet Additional data to be used in the request.
* @returns {Promise<AxiosResponse<any>>} The response of the request.
*/
getForecastData(configuration: any, dataSet?: any) {
getForecastData(configuration: any, dataSet?: any, language: string = 'it') {
let configs = [];
const cstr = localStorage.getItem('configs');
if (cstr) {
configs = JSON.parse(cstr);
}
const labelsf = configs.map((config: any) =>
config.allowed_values.map(x => [
x.name,
language === 'it' ? x.display_name_italian : x.display_name_english,
]),
);
const labels = Object.fromEntries(labelsf.flat());
return this.instance
.get<any>('https://arpav.geobeyond.dev/api/v2/coverages/forecast-data?', {
params: { offset: 0, limit: 100, ...configuration },
Expand All @@ -54,20 +66,14 @@ export class RequestApi extends Http {
: '');
const label = x.split('/')[x.split('/').length - 1];
const tlabel = label.split('-');
const sequence = [
'name',
'aggregation_period',
'archive',
'climatological_model',
'climatological_variable',
'measure',
'time_window',
'year_period',
];

const partial = zip(sequence, tlabel);

return { url, label, partial };
const flabel = tlabel.map(x => {
try {
return labels[x];
} catch (ex) {
return x;
}
});
return { url, rawLabel: label, label: flabel.join(' - ') };
};
return found.coverage_download_links.map(mapCoverageLinks);
});
Expand Down Expand Up @@ -526,6 +532,7 @@ export class RequestApi extends Http {
}

const p = Promise.all(reqs).then(x => {
localStorage.setItem('configs', JSON.stringify(x[0]));
return {
items: x[0],
combinations: x[1].combinations,
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/DownloadDataDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
MapUserContainerStyle,
ModalStyle,
TitleDownloadStyle,
ExtractionStyle
} from './styles';
import MapDlData from './mapDlData';
import UserDlData from '../UserDlData/userDlData';
Expand Down Expand Up @@ -94,6 +95,7 @@ const DownloadDataDialog = (props: DownloadDataDialogProps) => {
).toString()}`;
setDownloadUrl(url);
};


return (
<>
Expand Down Expand Up @@ -178,6 +180,7 @@ const DownloadDataDialog = (props: DownloadDataDialogProps) => {
open={showLinks}
onClose={() => setShowLinks(false)}
BackdropProps={{ open: false }}
sx={ExtractionStyle}
>
<Box>
<Grid
Expand Down
11 changes: 11 additions & 0 deletions src/app/components/DownloadDataDialog/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,14 @@ export const ModalStyle = theme => ({
borderRadius: theme.shape.borderRadius,
boxShadow: 12,
});

export const ExtractionStyle = theme => ({
bottom: '40px',
position: 'absolute',
left: '25%',
right: '25%',
width: '50%',
maxWidth: '800px',
})


0 comments on commit d011637

Please sign in to comment.