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

Resource page with Data Explorer or preview #12

Closed
2 of 13 tasks
lauragift21 opened this issue Jun 3, 2020 · 6 comments
Closed
2 of 13 tasks

Resource page with Data Explorer or preview #12

lauragift21 opened this issue Jun 3, 2020 · 6 comments
Labels
Catalog wontfix This will not be worked on
Projects

Comments

@lauragift21
Copy link
Contributor

lauragift21 commented Jun 3, 2020

A page for viewing an individual resource exists and it previews the data (if a preview for that data type exists).

In particular, for CSV etc and data in CKAN DataStore it displays the Data Explorer.

NOTE: ⚠️ there is quite a bit of thinking here about how we refactor the data previewing and data explorer. Read the notes in analysis section below. Note, in particular, that the acceptance and tasks are not yet updated to reflect this (we will probably need to refactor this issue into multiple issues).

Acceptance

Tasks

  • Implement /[org]/[dataset]/r/[resource] page that renders necessary components for the resource page:
    • Navbar
    • About resource component, e.g., metadata table with info such as resource name, title, description, format, created/modified date and link to downloading
  • Data Explorer or Data Preview component based on given resource type:
    • If in datastore, we can show the data explorer that has preview + query builder + map/chart builder + pagination
    • If not in datastore, we only render a preview based on format:
      • tabular data => table
      • image/website/pdf => web view
      • geo data => map
      • anything else => nothing

Analysis

Re-using existing Data Explorer library might not be the best way to go here because:

  • Data Explorer we've built using React + Redux wasn't the easiest library to maintain, for example, if you need to fix something in one of the components (eg, Map Builder), you have to go there and do:
    • fix it
    • if unit tests there, run them
    • test with fixtures (cosmos)
    • test with yarn start to load complete app
    • build the dist version by yarn build:package
    • push to github
    • publish to NPM
    • install it in Data Explorer and build the bundle
    • import the bundles (normally huge ~>2-3MB due to dependencies such as Plotly) into the HTML page

As we can see, it is quite a long process and over time we've seen little feature development but only bug fixes. I believe the process was discouraging for developers in general.

Other points:

  • Currently, using Data Explorer as a React component is not clear as it was always been used as bundles that doesn't get called explicitly with arguments, but inits on load and traverses the DOM to find the HTML tag with data-pacakge attribute. It parses it and uses it as props for child components.
  • If we want to use Data Explorer and its components in NextJS, we have to refactor it as it isn't compatible right away, for example, importing CSS, see https://github.com/vercel/next.js/blob/master/errors/css-npm.md

How would I build Data Explorer today with NextJS?

  • Make the Data Explorer a component rather than a library
  • Control components such as Query/Map/Chart builder from NextJS so basically our frontend app becomes the Data Explorer
  • Use something like SWR for client-side data fetching - https://swr.now.sh/

http://tech.datopian.com/data-explorer

graph TD

DataExplorer
DataPackageViews
DataStoreQueryBuilder
ChartBuilder
MapBuilder
Redux

subgraph old
  Redux -.- DataExplorer
  DataExplorer --> DataPackageViews
  DataExplorer --> DataStoreQueryBuilder
  DataExplorer --> ChartBuilder
  DataExplorer --> MapBuilder
end
graph TD

NextJSPage
DataPackageViews
DataStoreQueryBuilder
ChartBuilder
MapBuilder
GraphQL

subgraph new
  NextJSPage --init--> DataPackageViews
  NextJSPage --init--> DataStoreQueryBuilder
  NextJSPage --init--> ChartBuilder
  NextJSPage --init--> MapBuilder
  GraphQL -.- NextJSPage
  GraphQL -.- DataPackageViews
  GraphQL -.- DataStoreQueryBuilder
  GraphQL -.- ChartBuilder
  GraphQL -.- MapBuilder
end
  • User: GET a resource page - /@org/{dataset-name}/r/{resource-name}
  • NextJS (server side) fetches DMS API to get resource metadata which is then cached by GraphQL
  • NextJS responses with HTML + JSON for hydrating the tempalte
  • Browser renders the page with components
  • DataPackageViews component fetches data from the source url (data can be in filestore [or datastore])
    • OR: could load the data server side and pass down ...
  • Renders the data in a table (for tabular data)
    • TODO: other renderings ...``

First steps:

Notes

  • Resource pages do simple (pre)view by default
  • Explorer page for rich exploration (requires)
# url structure
/dataset/myname/ => [implicitly] /dataset/myname/show/default/ # default-branch-latest-revision/
/dataset/myname/resource/xxx => [implicitly] renders  /dataset/myname/show/default/{resource-id}

# explicit revisions
/dataset/myname/show/{revref}/              # dataset showcase
/dataset/myname/show/{revref}/{resource-id} # resource showcase
@lauragift21 lauragift21 added this to the Sprint - 12 June 2020 milestone Jun 3, 2020
@anuveyatsu anuveyatsu self-assigned this Jun 15, 2020
@anuveyatsu anuveyatsu added this to Prioritized in v1 Overview via automation Jun 15, 2020
@anuveyatsu anuveyatsu moved this from Prioritized to In progress in v1 Overview Jun 15, 2020
@anuveyatsu anuveyatsu changed the title Implement Resource Preview with Local Data Resource page with Data Explorer or preview Jun 15, 2020
@anuveyatsu
Copy link
Member

Re-using existing Data Explorer library might not be the best way to go here because:

  • Data Explorer we've built using React + Redux wasn't the easiest library to maintain, for example, if you need to fix something in one of the components (eg, Map Builder), you have to go there and do:
    • fix it
    • if unit tests there, run them
    • test with fixtures (cosmos)
    • test with yarn start to load complete app
    • build the dist version by yarn build:package
    • push to github
    • publish to NPM
    • install it in Data Explorer and build the bundle
    • import the bundles (normally huge ~>2-3MB due to dependencies such as Plotly) into the HTML page

As we can see, it is quite a long process and over time we've seen little feature development but only bug fixes. I believe the process was discouraging for developers in general.

Other points:

  • Currently, using Data Explorer as a React component is not clear as it was always been used as bundles that doesn't get called explicitly with arguments, but inits on load and traverses the DOM to find the HTML tag with data-pacakge attribute. It parses it and uses it as props for child components.
  • If we want to use Data Explorer and its components in NextJS, we have to refactor it as it isn't compatible right away, for example, importing CSS, see https://github.com/vercel/next.js/blob/master/errors/css-npm.md

@anuveyatsu
Copy link
Member

How would I build Data Explorer today with NextJS?

  • Make the Data Explorer a component rather than a library
  • Control components such as Query/Map/Chart builder from NextJS so basically our frontend app becomes the Data Explorer
  • Use something like SWR for client-side data fetching - https://swr.now.sh/

@anuveyatsu
Copy link
Member

@rufuspollock I've added couple of comments above, please, take a look.

@rufuspollock
Copy link
Member

rufuspollock commented Jun 16, 2020

@anuveyatsu ok - for now we build the page without preview and move one whilst we decide what we want to do here 😄

I've moved this to blocked / waiting for for now.

@rufuspollock rufuspollock moved this from In progress to Blocked (Waiting for) in v1 Overview Jun 16, 2020
anuveyatsu added a commit that referenced this issue Jun 17, 2020
@anuveyatsu
Copy link
Member

This is how resource page looks like at the moment:

https://portal.datopian1.now.sh/@dataset/asdsad/r/gettyimages-954867550.jpg

@rufuspollock
Copy link
Member

WONTFIX. Closing for now as Catalog related and we aren't going to do much morer right now. Note we have implemented views support in the basic portal app in #72.

v1 Overview automation moved this from In progress to Done Mar 11, 2021
@rufuspollock rufuspollock added the wontfix This will not be worked on label Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Catalog wontfix This will not be worked on
Projects
No open projects
v1 Overview
  
Done
Development

No branches or pull requests

4 participants