-
Notifications
You must be signed in to change notification settings - Fork 0
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
add the csv distribution when dataset is a proxied csv #20
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { DatasetResource, datasetToItem, getProxyUrl, IHubRequestOptions } from '@esri/hub-common'; | ||
import * as _ from 'lodash'; | ||
|
||
const WFS_SERVER = 'WFSServer'; | ||
|
@@ -19,6 +20,10 @@ export function _generateDistributions (dataset: any, landingPage: string) { | |
getEsriGeoServiceDistribution | ||
]; | ||
|
||
if (isProxiedCSV(dataset)) { | ||
distributionFns.push(getCSVDistribution); | ||
} | ||
|
||
if (isLayer(dataset)) { | ||
distributionFns.push(getGeoJSONDistribution); | ||
distributionFns.push(getCSVDistribution); | ||
|
@@ -53,6 +58,16 @@ function isLayer (dataset: any) { | |
return /_/.test(dataset.id); | ||
} | ||
|
||
function isProxiedCSV(dataset: any) { | ||
const item = datasetToItem({ | ||
id: dataset.id, | ||
attributes: dataset | ||
} as DatasetResource); | ||
const requestOptions: IHubRequestOptions = { isPortal: false }; | ||
|
||
return !!getProxyUrl(item, requestOptions); | ||
Comment on lines
+62
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking out loud... This set of conversions is clever, but squishy. We're basically taking a V3 API response, making it look sorta like a dataset, then making that sorta look like an item, then throwing it into the We can do this because we happen to know about the internals of That said, if it works—great. A regression here would be low-impact and you have a test to validate it anyways. One question though—why not just use isProxiedCSV instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay—I see now that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andrewctate thanks for the review!
That was my original plan, but Tom is really trying to minimize hub.js' public footprint. I discussed it with him, but ultimately he asked for us to do it this way 🤷♂️
I know it's not ideal. Tom is doing a massive refactor for getting IHubContents that we'll probably use in the near future. The result of that refactor will already have the proxied csv stuff baked in 🙌 |
||
} | ||
|
||
// HUBJS CANDIDATE | ||
function getDownloadLinkFn (landingPage: string, dataset: any) { | ||
const spatialReference = _.get(dataset, 'server.spatialReference'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drspacemanphd this is what I was talking about. This package is declared as a dependency in the example app, but when I run
npm run dev
the script chokes on a typescript error, saying that an interface from this package is not defined. Adding it as a dev and a peer dependency solves the issue and shouldn't affect consumers.