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

feat(map): download collection metrics [EP-3002] #328

Merged
merged 2 commits into from
Nov 27, 2020
Merged

feat(map): download collection metrics [EP-3002] #328

merged 2 commits into from
Nov 27, 2020

Conversation

dan-qc
Copy link
Contributor

@dan-qc dan-qc commented Nov 26, 2020

No description provided.

* wip

* feat(map): download collection metrics [EP-3002]
Copy link
Contributor

@ancashoria ancashoria left a comment

Choose a reason for hiding this comment

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

great work! 👍
just some nitpicking

<h2 className="ng-text-display-s ng-body-color ng-margin-medium-bottom ng-margin-top-remove">
{t('Download metrics')}
&nbsp;
<i className="ng-icon-download-outline" style={{ verticalAlign: 'middle' }} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<i className="ng-icon-download-outline" style={{ verticalAlign: 'middle' }} />
<i className="ng-icon-download-outline ng-vertical-align-middle" />

onCancel={() => setIsOnDownloadMetrics(false)}
onDownloadStart={() => [setIsDownloadingMetrics(true), setIsOnDownloadMetrics(false)]}
onDownloadEnd={() => setIsDownloadingMetrics(false)}
onDownloadError={(err) => setDownloadError(err)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
onDownloadError={(err) => setDownloadError(err)}
onDownloadError={setDownloadError}


import { TitleHero, Card } from '@marapp/earth-shared';
import MetricService from 'services/MetricService';
import { ReactSelect, serializeFilters } from '@marapp/earth-shared';
Copy link
Contributor

Choose a reason for hiding this comment

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

combine earth-shared imports

Comment on lines 176 to 179
normalizedData.map((item) => ({
'#': item['#'],
...flatten(omit(item, '#')),
}))
Copy link
Contributor

Choose a reason for hiding this comment

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

If you can find a valid constant name to replace '#' eg: nr the code would become:

Suggested change
normalizedData.map((item) => ({
'#': item['#'],
...flatten(omit(item, '#')),
}))
normalizedData.map(({nr, ...item}) => ({
nr,
...flatten(item),
}))

const zipName = `${collectionSlug}-metrics.zip`;
const zipContent = await zip.generateAsync({ type: 'blob' });

FileSaver.saveAs(zipContent, zipName);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should clear the previous error message somehow.
One suggestion could be to add onDownloadSuccess() prop and call it here

const { data, meta } = await fetchMetricById(collectionId, { ...query, 'page[number]': page });

return meta.pagination.page < meta.pagination.total
? data.concat(await downloadMetrics(collectionId, query, page + 1))
Copy link
Contributor

Choose a reason for hiding this comment

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

cool ⚡

@dan-qc dan-qc merged commit 7815e82 into develop Nov 27, 2020
dan-qc added a commit that referenced this pull request Nov 27, 2020
dan-qc added a commit that referenced this pull request Nov 27, 2020
genodeploy pushed a commit that referenced this pull request Dec 17, 2020
# [1.16.0](v1.15.0...v1.16.0) (2020-12-17)

### Bug Fixes

* **admin:** Fix scrolling while in edit mode [EP-3146] ([1f3be9d](1f3be9d))
* **admin:** fix sidenav search box styling ([#346](#346)) ([1afcb1a](1afcb1a))
* **admin:** handle SSR request for window usage ([1d67f43](1d67f43))
* **admin:** hide collections from places ([#351](#351)) ([613994b](613994b))
* **admin:** loading indicator on user role [EP-3424] ([c9d5dec](c9d5dec))
* **admin:** place edit reset geojson on cancel [EP-3025] ([047af4b](047af4b))
* **auth:** Error message is not displayed when a invalid link from the email is clicked [EP-3443] ([#338](#338)) ([1ed7fe5](1ed7fe5))
* **map:** collection long name overlap [EP-3595] ([a4c906b](a4c906b))
* **map:** preserve language on refresh or app change ([#345](#345)) ([32294bb](32294bb))
* **map:** support for decodeFunction on layers ([b6b98ed](b6b98ed))
* **profile:** split profile fetching and display a visual loading ind… ([#340](#340)) ([9b1d1fa](9b1d1fa))

### Features

* **map:** Clip and export layers [EP-3594] ([7a118c8](7a118c8))
* **map:** download collection metrics [EP-3002] ([#328](#328)) ([7815e82](7815e82))
* **map:** download collection metrics [EP-3002] ([#333](#333)) ([cbc780c](cbc780c))
* **map:** keep map coordinates in url ([#331](#331)) ([2c8cec8](2c8cec8))
* **map:** weglot support [EP-3441] ([#341](#341)) ([5905af3](5905af3))

### Reverts

* Revert "feat(map): download collection metrics [EP-3002] (#328)" (#332) ([a6da184](a6da184)), closes [#328](#328) [#332](#332)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants