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

Implement v2 GUI #19

Merged
merged 17 commits into from
Jul 20, 2023
Merged

Implement v2 GUI #19

merged 17 commits into from
Jul 20, 2023

Conversation

brianlove
Copy link
Contributor

@brianlove brianlove commented Jul 13, 2023

Initial draft of v2 GUI, focusing on the list view and filters.

Closes #10, closes #14

TODO

2023-07-18

Initial drafts of both the list view and detail view are available - there are still some pending bits (see above), but higher-level feedback would be good to get. Page URLs for the detail view are explained here.

Current information needs:

  • Any fields beyond those previously specified? (@jmelot, @za158)
    • Company, Country, Continent/Region, Stage, AI pubs, AI pubs growth*, AI patents, AI patents growth*, AI top conference pubs, AI jobs*, AI research intensity, CV pubs*, CV patents*, Robotics pubs*, Robotics patents*, tt1 jobs*
  • Get updated (and expanded) data - those marked with * above do not currently have any data (@jmelot)
  • Get plan for which data will be graphed on which charts (@jmelot, @za158)
    • The mockups show "All publications vs AI publications", "AI publications vs AI subfield publications", "AI publications in top conferences", and "AI patents over time"
      • Should those charts also include the other topics (NLP, CV, robotics)?
      • How should the fields be handled for the subfield chart?

2023-07-13

There are currently two versions of the state management system present (plus some earlier tests using the extra interface elements with colored backgrounds), described in https://docs.google.com/document/d/1It-f0out1G0DX9T1OoQonnAErUNgtC3ec2VHJai-gJs/edit. Option 2 is (IMO) the cleanest to use, although it doesn't use useState() in the traditional manner.

Create a new Gatsby site for PARAT v2 and begin installing needed
dependencies.
Begin adding the company list view, including connecting filter sliders
to URL params (although not yet to the data).  Set up Jest, although
actual tests are still pending.
Identify and implement two options for filter state management that
both tie the currently-applied filters to the URL query parameters (via
`useQueryParamString()`), as well as allow column definitions to access
the state information by indexing into an object.

Selecting the specific option to use will come later, after discussion
with the others.
Apply the currently-selected filters to the list view table.  Add a
debounce to the sliders so that the sliders themsleves update seemlessly
while the table waits before updating, improving slider responsiveness.
@brianlove brianlove requested a review from jmelot July 13, 2023 19:20
@brianlove brianlove self-assigned this Jul 13, 2023
@brianlove brianlove changed the base branch from master to version2 July 13, 2023 19:20
Add functionality to the column add/remove dialog box, including
storing the selected columns (if they differ from the default config)
as URL query params.
@jmelot
Copy link
Contributor

jmelot commented Jul 14, 2023

Excited to take a look! This is what I see when I try to do gatsby develop after npm install:

 ERROR  UNKNOWN

Module not found: Error: Can't resolve '../accessibility' in '/Users/JM3312/code/eto/parat/web/gui-v2/src/components'



  ModuleNotFoundError: Module not found: Error: Can't resolve '../accessibility' in '/Users/JM3312/code/eto/parat/web/gui-v2/src/components'
  
  - Compilation.js:2017 
    [gui-v2]/[webpack]/lib/Compilation.js:2017:28
  
  - NormalModuleFactory.js:817 
    [gui-v2]/[webpack]/lib/NormalModuleFactory.js:817:13
  
  
  - NormalModuleFactory.js:275 
    [gui-v2]/[webpack]/lib/NormalModuleFactory.js:275:22
  
  
  - NormalModuleFactory.js:448 
    [gui-v2]/[webpack]/lib/NormalModuleFactory.js:448:22
  
  - NormalModuleFactory.js:118 
    [gui-v2]/[webpack]/lib/NormalModuleFactory.js:118:11
  
  - NormalModuleFactory.js:689 
    [gui-v2]/[webpack]/lib/NormalModuleFactory.js:689:25
  
  - NormalModuleFactory.js:893 
    [gui-v2]/[webpack]/lib/NormalModuleFactory.js:893:8
  
  - NormalModuleFactory.js:1013 
    [gui-v2]/[webpack]/lib/NormalModuleFactory.js:1013:5
  
  - async.js:6883 
    [gui-v2]/[neo-async]/async.js:6883:13
  
  - NormalModuleFactory.js:988 Array.<anonymous>
    [gui-v2]/[webpack]/lib/NormalModuleFactory.js:988:14
  
  - async.js:2517 arrayEachFunc
    [gui-v2]/[neo-async]/async.js:2517:19
  
  - async.js:6858 Object.parallel
    [gui-v2]/[neo-async]/async.js:6858:9
  
  - NormalModuleFactory.js:911 NormalModuleFactory._resolveResourceErrorHints
    [gui-v2]/[webpack]/lib/NormalModuleFactory.js:911:12
  
  - NormalModuleFactory.js:853 
    [gui-v2]/[webpack]/lib/NormalModuleFactory.js:853:18
  

not finished Building development bundle - 11.141s

Could you have forgotten to add something (although I do see an accessbility.css under src)? Or have I forgotten a setup step?

@brianlove
Copy link
Contributor Author

@jmelot Should be resolved now - that was an old import that's been replaced by src/accessibility.css.

Split option 2 for filter state management out into its own (generalized)
file (`useMultiState`) and convert the list view states accordingly.
Resolve a few bugs with filter, and cleaned up the code.
Create and start implementing the company-specific detail pages.
Add table of contents and the three overall sections (Publications,
Patents, and Workforce) to the company detail page.  Add the initial
set of charts, including helper functions to standardize things as
much as possible.

The current version of the URL slug -> company ID/name extraction
won't work when used with Gatsby's `<Link>` component, since it only
runs once on the initial page load (so navigating to a second company
would still present the first company on the page).
If the company slug doesn't match the canonical version, as determined
by the `companyId`, rewrite the URL.

URLs are of the form `/company/ID-COMPANY_SLUG/`, where `ID` is the
company's numerical `CSET_id` and `COMPANY_SLUG` is a slugified version
of the company's `name`.
@jmelot
Copy link
Contributor

jmelot commented Jul 19, 2023

Some quick initial comments just browsing

This is what I see when I initially load the app. We need to allow the user to paginate and should sort by # AI pubs by default

Screenshot 2023-07-18 at 11 21 08 PM

Let's use autocompletes here, not dropdowns - the company lists especially are kind of unweildly

Screenshot 2023-07-18 at 11 22 06 PM

The user should not be able to unselect the company name

Screenshot 2023-07-18 at 11 23 54 PM

I'm sure you're already aware, but there's a bunch of warnings that will need to get cleaned up at some point:

warn 
/Users/JM3312/code/misc/ai-companies-visualization/web/gui-v2/src/components/DetailView.jsx
  2:18  warning  'GatsbyLink' is defined but never used  no-unused-vars

/Users/JM3312/code/misc/ai-companies-visualization/web/gui-v2/src/components/DetailViewPatents.jsx
  2:10  warning  'css' is defined but never used  no-unused-vars
  7:28  warning  Unexpected empty object pattern  no-empty-pattern

/Users/JM3312/code/misc/ai-companies-visualization/web/gui-v2/src/components/DetailViewPublications.jsx
   2:10  warning  'css' is defined but never used              no-unused-vars
  10:7   warning  'styles' is assigned a value but never used  no-unused-vars

/Users/JM3312/code/misc/ai-companies-visualization/web/gui-v2/src/components/DetailViewWorkforce.jsx
  2:10  warning  'css' is defined but never used  no-unused-vars
  7:30  warning  Unexpected empty object pattern  no-empty-pattern

/Users/JM3312/code/misc/ai-companies-visualization/web/gui-v2/src/components/HeaderSlider.jsx
  40:6  warning  React Hook useMemo has a missing dependency: 'externalHandler'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

/Users/JM3312/code/misc/ai-companies-visualization/web/gui-v2/src/components/ListView.jsx
   2:10  warning  'css' is defined but never used              no-unused-vars
  11:7   warning  'styles' is assigned a value but never used  no-unused-vars

/Users/JM3312/code/misc/ai-companies-visualization/web/gui-v2/src/components/ListViewTable.jsx
   14:3  warning  'Dropdown' is defined but never used                                                                                          no-unused-vars
  175:5  warning  React Hook useMemo has a missing dependency: 'filteredFilters'. Either include it or remove the dependency array              react-hooks/exhaustive-deps
  180:5  warning  React Hook useMemo has a missing dependency: 'filteredFilters'. Either include it or remove the dependency array              react-hooks/exhaustive-deps
  185:5  warning  React Hook useMemo has a missing dependency: 'filteredFilters'. Either include it or remove the dependency array              react-hooks/exhaustive-deps
  190:5  warning  React Hook useMemo has a missing dependency: 'filteredFilters'. Either include it or remove the dependency array              react-hooks/exhaustive-deps
  200:5  warning  React Hook useMemo has missing dependencies: 'companies' and 'countries'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

/Users/JM3312/code/misc/ai-companies-visualization/web/gui-v2/src/pages/company-detail.js
   2:10  warning  'css' is defined but never used              no-unused-vars
  12:7   warning  'styles' is assigned a value but never used  no-unused-vars
  19:65  warning  Unnecessary escape character: \/             no-useless-escape

/Users/JM3312/code/misc/ai-companies-visualization/web/gui-v2/src/static_data/table_columns.js
  5:1  warning  Assign array to a variable before exporting as module default  import/no-anonymous-default-export

/Users/JM3312/code/misc/ai-companies-visualization/web/gui-v2/src/util/useWindowSize.js
  1:8  warning  'React' is defined but never used  no-unused-vars

✖ 21 problems (0 errors, 21 warnings)

Copy link
Contributor

@jmelot jmelot left a comment

Choose a reason for hiding this comment

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

Just a few comments. Because no one else is actively working on this project, I suggest you go ahead and merge this into master when ready, and open issues for the other tasks you've identified

web/gui-v2/src/components/ListViewTable.jsx Show resolved Hide resolved
return false;
}
} else if ( colDef.type === "stock" ) {
// TODO: Figure out how we're filtering the `market_list` column
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll have a look for it, I don't immediately remember this one


const companyData = company_data.find(e => e.CSET_id === companyId);

// If the `pathname` of the page doesn't match the authoritative pathname for
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!!

@jmelot
Copy link
Contributor

jmelot commented Jul 19, 2023

On your current info needs -
(1) is ok for now
(2) I will get this to you when I'm back but in the meantime I think there's plenty to do. If this starts blocking you just mock it out
(3)

The mockups show "All publications vs AI publications", "AI publications vs AI subfield publications", "AI publications in top conferences", and "AI patents over time"

Should those charts also include the other topics (NLP, CV, robotics)?
How should the fields be handled for the subfield chart?

AI publications vs AI subfield publications should include NLP, CV, RO (which we non-obviously are referring to as the "subfields"). I'd just graph them as additional lines. I think (subject to other thoughts from @za158) these graphs are ok for now.

Add tests covering the add/remove columns dialog.  Add a partial test
of filtering by region (currently do not have a working test for
resetting filters).
Add pagination and switch to using an `<Autocomplete>` (which fixed
issue with tests), and do some work on fixing the header width/style
issues.
Sort the list view by AI publications by default (although saving sort
state is deferred to #24).  Add more charts/contents in Patents and
Workforce sections.

Add `util/testing.js`, which slipped through the cracks before, and
clean up various files.
Commented out Python aspects because things were failing
@github-actions
Copy link

github-actions bot commented Jul 20, 2023

JavaScript Coverage

Summary

Lines Statements Branches Functions
Coverage: 60%
59.64% (170/285) 54.8% (57/104) 68.75% (66/96)
Modified Files • (60%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files59.6454.868.7560.29 
components72.2459.7880.5971.85 
   AddRemoveColumnDialog.jsx88.881008088.2365, 81
   CellStat.jsx100100100100 
   DetailView.jsx000027–138
   DetailViewChart.jsx00006–34
   DetailViewIntro.jsx0100006–41
   DetailViewPatents.jsx0100008–31
   DetailViewPublications.jsx0100007–39
   DetailViewWorkforce.jsx0100007–17
   HeaderDropdown.jsx10066.6610010024
   HeaderSlider.jsx92.8510085.7192.354
   HeaderWithLink.jsx00009–44
   ListView.jsx100100100100 
   ListViewTable.jsx87.56897.3687.6101, 151, 166, 247–252, 288, 290, 292, 319, 334–335, 340–347
   StatBox.jsx0100004–27
pages0000 
   404.js00004–49
   company-detail.js00009–36
   index.js01000010–66
static_data83.3310010083.33 
   data.js100100100100 
   table_columns.js100100100100 
   tooltips.js010010001
styles01001000 
   common-styles.js010010006
util36.8433.3342.139.39 
   index.js83.330758025
   plotly-helpers.js0100005–37
   testing.js100100100100 
   useMultiState.js63.635066.6677.7735, 38
   useWindowSize.js10100011.1110–22

@brianlove brianlove merged commit bbd5491 into version2 Jul 20, 2023
This was referenced Jul 20, 2023
@brianlove brianlove deleted the develop-v2-gui branch July 25, 2023 17:03
@za158
Copy link
Member

za158 commented Jul 31, 2023

Any fields beyond those previously specified? (@jmelot, @za158)

* Company, Country, Continent/Region, Stage, AI pubs, _AI pubs growth*_, AI patents, _AI patents growth*_, AI top conference pubs, _AI jobs*_, AI research intensity, _CV pubs*_, _CV patents*_, _Robotics pubs*_, _Robotics patents*_, _tt1 jobs*_

@brianlove Sorry to be so long in responding. Please add an additional field for "Sectors." How exactly we populate this is TBD but we will want it. I am about to create a separate issue about the underlying data.

No further comments from me for now.

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.

Create list view
3 participants