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

Ad data explorer #232

Open
wants to merge 463 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
463 commits
Select commit Hold shift + click to select a range
68332a1
CVM change request.
May 14, 2020
aa306ca
Removal of reserve & modification of marketing category source.
May 21, 2020
ef3b711
Added recombinant DNA construct
Jun 2, 2020
b82713b
More CDRH requested updates.
Jun 4, 2020
6312dec
Added Reserve option to Marketing Status
Jun 5, 2020
52f0445
Added ADNDC.
Jun 11, 2020
f29f915
Removed duplicate Application Number.
Jun 11, 2020
8045acf
Updated some columns and filters for ADL.
Aug 27, 2020
2b3255c
Minor change
Sep 2, 2020
c23eed4
Removed references to pet food & phish pharm.
Sep 11, 2020
44d35b0
Manual update from master to reduce conflicts.
Sep 11, 2020
62c3c28
Merge branch 'master' into AD_data_explorer
Sep 11, 2020
1736175
Merge correction.
Sep 11, 2020
217d019
Corrected naming for the `exact` fields.
dkrylovsb Sep 11, 2020
afa8b6b
Corrected naming for the exact fields.
dkrylovsb Sep 11, 2020
4eb0591
Merge remote-tracking branch 'origin/AD_data_explorer' into AD_data_e…
dkrylovsb Sep 11, 2020
9398330
run time fixes.
Sep 15, 2020
82f68e1
marketing_category change, comment out broken tooltip.
Sep 15, 2020
4274426
route_of_admin & product_type fixes.
Sep 15, 2020
16dc23e
Select box CSS fixes.
Sep 15, 2020
5596492
Infographic fixes.
Sep 15, 2020
d4ccf99
Filter fixes.
Sep 15, 2020
c95ab61
Fixed Inactive Ingredient filter.
dkrylovsb Sep 18, 2020
ecc6fbd
Fixed auto-complete on the Application Number filter.
dkrylovsb Sep 18, 2020
cc00a4b
Fixes for Nested Data Window.
Sep 21, 2020
015fb7a
Minor fixes
Sep 21, 2020
1e5fef0
Marketing Status should be obtained from the top-level field.
dkrylovsb Sep 22, 2020
81f066e
Minor fixes
Sep 22, 2020
f9167c0
Merge remote-tracking branch 'origin/AD_data_explorer' into AD_data_e…
Sep 22, 2020
976dbb5
add Dataset Explorer
Feb 16, 2018
c312c7b
fix dataexplorer page
Feb 19, 2018
5065303
switch to basic nivo
Feb 19, 2018
3512f3b
progress on filters
Feb 20, 2018
e0410c0
add API specific Particularly select box, add example autosuggest
gundalar Feb 21, 2018
ae8b430
merge autocomplete components
Feb 21, 2018
a106134
added content component
Feb 22, 2018
8ca1f8b
filters component improvements
Feb 26, 2018
b288c91
share parent dataexplorer with filtersComponent
Feb 26, 2018
64f91cd
add dataset retrieval service
Feb 27, 2018
1b1f8e6
add multiple selections for field, show x box to remove for select bo…
Feb 28, 2018
0489b97
working querying
Mar 2, 2018
502f7c5
add datepicker for time fields
Mar 5, 2018
566f43f
FDA-268 change ingredients fields to free text
gundalar Mar 6, 2018
2fb1a34
FDA-268 fix case for checkbox, field name
gundalar Mar 7, 2018
2545d6a
selected filters and day picker css fix
Mar 9, 2018
04b27ae
fix merge issues
Mar 12, 2018
892565f
Date fixes & initial cosmetic tweaks.
Mar 13, 2018
0625c1a
table styling and use comma fields for ingredients search
Mar 13, 2018
60f0d56
add back daypicker css till we figure out better solution
Mar 13, 2018
12e8c8b
Data Explorer css tweaks.
Mar 13, 2018
aada219
Filter hide function added.
Mar 14, 2018
0e9b0ef
change active ingredients filter to substance name and make it autoco…
gundalar Mar 14, 2018
43c3dcb
Added hero back in.
Mar 14, 2018
bb05f0c
Added more product_type options.
Mar 15, 2018
2b92823
Added more filters.
Mar 15, 2018
26b333d
full text search on inactive ingredients
gundalar Mar 15, 2018
4ff3f39
Added boolean component.
Mar 16, 2018
4af15fe
increase results size to 5000
gundalar Mar 16, 2018
847f543
display array valued columns in bullet format
gundalar Mar 16, 2018
6845342
Added total records.
Mar 16, 2018
c69809a
Added total records.
Mar 20, 2018
e55d688
fix route, NDC display issues
gundalar Mar 16, 2018
58c453b
add infographics
Mar 19, 2018
5ce9228
Added total records.
Mar 20, 2018
0dcefe9
handle changing api
Mar 20, 2018
acb47ec
Changes to react-select implementation.
Mar 20, 2018
baa7779
change search filters
Mar 20, 2018
1ff5877
fix state issues
Mar 20, 2018
6b68cab
visualization changes
Mar 20, 2018
036e548
columns based on view instead of dataset
Mar 21, 2018
98fe7d8
fix ESLint error
gundalar Mar 21, 2018
d2afb3e
update configuration for petfood_reports views
gundalar Mar 21, 2018
a57122e
fix autocompleter URL, fix select component
gundalar Mar 21, 2018
1d82bb9
Fixed id error.
Mar 21, 2018
44af9d6
autocomplete reloading correctly
Mar 21, 2018
d7ae40b
datepicker update correctly
Mar 21, 2018
123d79f
Implemented year picker.
Mar 21, 2018
b1498d4
Fixed selected filter.
Mar 21, 2018
1279f89
fix LLT results display issue and page size
gundalar Mar 22, 2018
b79f0e5
petfood recall infographics
Mar 22, 2018
937646e
Fixed autocomplete dropdowns and styling changes throughout.
Mar 22, 2018
482395b
infographic title changes
Mar 22, 2018
6710b2e
FDA-287, FDA-286, FDA-283 implement comments from petfoods UI demo to…
gundalar Mar 26, 2018
75f3b81
add grouping and move LLT massageData to only compute once
Mar 26, 2018
433cbf4
fda-284 - fixed csv
Mar 26, 2018
ace713e
FDA-288 configuration update
gundalar Mar 26, 2018
1e36ebd
FDA-252 -autocomplete default text and column header changes
gundalar Mar 29, 2018
4be160b
FDA-252 - remove case conversion in display of array valued fields
gundalar Mar 29, 2018
431ba12
FDA-252 fixed stale data retrieval error.
Mar 29, 2018
fd7081c
FDA-293 add custom filtering, pagination to table results
gundalar Mar 30, 2018
3ca53a4
FDA-280 added help modal to pet food reactions.
Mar 30, 2018
1e706f9
remove page from state
gundalar Mar 30, 2018
ec3f633
FDA-280 minor css change.
Mar 30, 2018
11c166e
FDA-280 minor css change.
Mar 30, 2018
88420fe
Fix minor bugs with autocomplete size, product name column filter and…
gundalar Mar 30, 2018
ba32bd8
FDA-290 Added dataset/view help window.
Apr 2, 2018
de40816
FDA-290 Modified years filter.
Apr 3, 2018
683949f
FDA-295 Added table and chart views.
Apr 4, 2018
d7ae777
FDA-295 Minor css change.
Apr 5, 2018
a6d747f
FDA-297 - sort choices in select autocompleters
gundalar Apr 5, 2018
4204785
FDA-252 - fix sort on frequency column, add support for start case
gundalar Apr 5, 2018
80132f2
FDA-296 update data changes.
Apr 5, 2018
03c51da
FDA-296 update data changes pt 2
Apr 6, 2018
7d96f1a
FDA-296 partial update data changes. Not working great.
Apr 9, 2018
f190dc3
FDA-296 Working data update changes. Some bad practices remain.
Apr 10, 2018
73b83f3
FDA-252 Some css fixes.
Apr 10, 2018
02d9a0a
FDA-252 Some css fixes.
Apr 11, 2018
93774df
FDA-252 Final demo prep.
Apr 11, 2018
dea524f
FDA-252 Css changes.
Apr 11, 2018
24e06fa
FDA-252 Removed console output.
Apr 11, 2018
e88ffe3
FDA-252 Fixed autocomplete select state issue - other filters broken.
Apr 11, 2018
5acc52d
FDA-301 All filter state is functional. Content state is delayed.
Apr 12, 2018
a199a95
FDA-301 State management fixed.
Apr 13, 2018
b8ed282
FDA-301 One more minor state fix.
Apr 13, 2018
506fb85
FDA-252 Made pet food the default.
Apr 13, 2018
1bf3348
FDA-299 Improved table view.
Apr 17, 2018
64703ce
FDA-299 CSS tweaks
Apr 17, 2018
c7b3942
FDA-257 - add Phish-Pharm Dataset Explorer
gundalar Apr 20, 2018
f1d5f35
FDA-257 - conditionally render Data View Toggle
gundalar Apr 20, 2018
0c66d5a
FDA-302 Chart overhaul mark 1. Piebar chart (ADL) broken.
Apr 24, 2018
ff47c9f
FDA-315 - Fix Sorting and SubFiltering on Frequency of Reported Signs…
gundalar Apr 24, 2018
fda32ea
FDA-314 - make showing Collapse Rows button on results page configurable
gundalar Apr 24, 2018
e8c262d
FDA-302 Chart overhaul mark 2. Enhanced standalone bar chart.
Apr 25, 2018
b93efb4
FDA-302 Improved the styling for the line and bar charts.
Apr 25, 2018
4551754
FDA-302 - address 508 compliance issues
gundalar Apr 26, 2018
0e667e8
moving to single search box for sub-filtering columns
gundalar Apr 26, 2018
643c368
FDA-302 Line chart enhancements.
Apr 26, 2018
d99a6a0
FDA-302 Line chart styling.
Apr 26, 2018
f1df5e3
FDA-302 Simple text changes.
Apr 26, 2018
ef13c68
FDA-302 - setting alt text to empty string until a better fix is avai…
gundalar Apr 26, 2018
27b2fdf
fix react table search for nested accessors and make it case-insensitive
gundalar Apr 26, 2018
0971b44
FDA-302 Minor tweaks to line chart.
Apr 26, 2018
026e5a4
FDA-302 Fixed line chart errors and tooltip.
Apr 30, 2018
578f5dd
FDA-302 Fixed modal z-index.
Apr 30, 2018
92d32bb
FDA-302 Fixed y-axis issue on line chart.
Apr 30, 2018
d6c3be2
FDA-302 Fixed tooltip prop warning.
Apr 30, 2018
efabe9e
FDA-302 Added pan/zoom to the line graph.
May 2, 2018
ca3ebec
FDA-302 Added detail to the tooltip.
May 2, 2018
fddf668
FDA-302 Pan/zoom only when needed.
May 2, 2018
7d752cb
FDA-302 Bar chart y-axis label.
May 2, 2018
484b9df
FDA-302 Added double bar chart option.
May 2, 2018
ceada24
FDA-302 Fixed bar chart legend.
May 2, 2018
6494253
FDA-302 Converted phishPharm to use days instead of hours
May 2, 2018
473aec8
FDA-302 Fixed chart state issue.
May 3, 2018
f015b6a
FDA-302 Removed particularly for PhishPharm. Styled menu.
May 3, 2018
2ffe09b
FDA-319 rename Report ID column
gundalar May 2, 2018
25c14c9
FDA-302 Added ADL bar chart.
May 4, 2018
9c12fb4
FDA-308 - hide manage columns for petfood LLT view
gundalar May 4, 2018
1aa0b01
FDA-302 fix css for react-table column headers
gundalar May 8, 2018
cdb5314
FDA-316, FDA-318 - make it easier to pick Weight and Age, export to…
gundalar May 8, 2018
33a3618
FDA-306 - add "Select All Columns" and "Reset Column Selection" optio…
gundalar May 10, 2018
096ef4b
FDA-303 Added top five/ten option to line chart.
May 22, 2018
8495d14
FDA-317 - make table scrollbars sticky, FDA-318 - explain export opti…
gundalar May 22, 2018
df16695
FDA-318 - add icons for exports
gundalar May 23, 2018
7dcaabc
Change text for Data Explorer help window link
gundalar May 23, 2018
fa84303
FDA-303 Updated charts for demo.
May 25, 2018
6857fea
FDA-303 Converted line chart to use Victory. Fine-tuning needed.
May 25, 2018
e325719
FDA-327, FDA-312 Changes to Filters Panel and Default Columns
gundalar May 29, 2018
a01843e
FDA-303 Fixed PhishPharm chart and improved legend code.
May 29, 2018
2d4e9e8
Filter style changes
gundalar May 29, 2018
20f9ee3
FDA-303 Reworkedlegend entirely.
May 31, 2018
3d08b6d
FDA-303 Mostly fixed tooltip. Restored ADL pie/bar chart.
Jun 1, 2018
c69ff59
FDA-244 - style changes for checkbox components
gundalar May 31, 2018
bd46eb6
FDA-312 add marketing category as column
gundalar May 31, 2018
78e2798
FDA-303 More chart improvements.
Jun 4, 2018
0dfb68c
FDA-303 Added more colors to the line chart.
Jun 7, 2018
00f5312
FDA-303 Fixed tooltip issue.
Jun 8, 2018
d89e8db
FDA-305 Added help info for pet food formulation.
Jun 13, 2018
1ba1186
FDA-252 fix year range display for phish-pharm dataset
gundalar Jun 22, 2018
215e624
FDA-313 fix Manage Column should keep selections after filters clear…
gundalar Jun 22, 2018
80c376a
Fixed JSON typo.
Jun 25, 2018
7c47ba7
Removed duplication in package.json.
Jun 25, 2018
be13cd3
Final merge fixes.
Jun 25, 2018
e347fd0
FDA-252 - fix checkbox display issue for prefix and boolean searches
gundalar Jun 26, 2018
5c97a00
FDA-249 Added ADL endpoint pages.
Jun 27, 2018
548760f
FDA-249 ADL tweaks
Jun 28, 2018
5302999
FDA-346 Added pet food api pages.
Jun 28, 2018
b6075c7
FDA-258 Added Phish-Pharm endpoint pages.
Jun 29, 2018
91fb3c7
FDA-347 Added ADAE endpoint pages.
Jun 29, 2018
e94af61
FDA-323 Fixed some ADL specific bugs.
Jul 5, 2018
e16f98d
FDA-348 Improved bar chart labels.
Jul 13, 2018
96902c3
Temp bug fixes
Jul 18, 2018
a96e707
FDA-352 ie Style fixes
Jul 19, 2018
c0736d2
fix export to XLS column headers, export only visible columns
gundalar Jul 19, 2018
1136173
FDA-352 ie Style fixes
Jul 20, 2018
3aebdf1
Changed default columns.
Jul 20, 2018
144c6a8
FDA-350 Fixed Pie/Bar Chart.
Jul 22, 2018
709aca5
FDA-307, FDA-354 Added help text to Phish-Pharm & Pet Foods.
Jul 25, 2018
0362082
FDA-351 Enabled scrollbars again.
Jul 25, 2018
569f74a
Deployment changes.
Jul 31, 2018
aa3c09d
Fixed a few bugs.
Aug 15, 2018
625d063
FDA-322 Added form view.
Aug 16, 2018
e5a5359
FDA-322 Form view tweaks.
Aug 16, 2018
b490583
FDA-353 fixed line chart and favicon
Aug 24, 2018
99010a8
Various doc page fixes.
Aug 29, 2018
c457479
Various doc page fixes.
Aug 29, 2018
a94b555
Various doc page fixes.
Aug 29, 2018
e4c40d1
FDA-371 Minor text changes.
Aug 29, 2018
23d009a
FDA-371 Added Explorer Link.
Sep 10, 2018
0bb72ff
FDA-371 Updated api links.
Sep 10, 2018
19e3721
FDA-371 Updated api links.
Sep 10, 2018
943173e
FDA-371 Updated api links.
Sep 11, 2018
8fc04d0
ADAE demo prep
Sep 11, 2018
1c2e2c1
Pet Food demo prep
Sep 11, 2018
4222ebe
Pet Food demo prep
Sep 11, 2018
3bfaa43
Pet food demo prep
Sep 11, 2018
bbe5c6b
ADAE text tweaks
Sep 18, 2018
7fec04e
ADAE text tweaks
Sep 18, 2018
945cb89
Added marketing status.
Sep 20, 2018
ad1f778
Marketing Status tweaks.
Sep 24, 2018
bea65b5
FDA-386 Initial ADL tweaks.
Sep 26, 2018
ae5a14a
ADL demo prep.
Feb 13, 2019
e2203b3
Fixed IE field download buttons.
Mar 8, 2019
20a5994
Skip the empty rows in the exported excel.
nagkuchipudi Jul 9, 2019
57fc317
Frontend changes to support new animal drug label data.
nagkuchipudi Dec 13, 2019
31cdb66
Fix ordering columns and remove duplicate columns from animal drug la…
nagkuchipudi Dec 16, 2019
e070970
Fix ordering columns and remove duplicate columns from animal drug la…
nagkuchipudi Dec 16, 2019
d6ef46a
Fixed build error with react-promise version.
Dec 16, 2019
c198815
CVM change request.
May 14, 2020
abcbe84
Removal of reserve & modification of marketing category source.
May 21, 2020
f4a15ae
Added recombinant DNA construct
Jun 2, 2020
a046955
More CDRH requested updates.
Jun 4, 2020
15802c5
Added Reserve option to Marketing Status
Jun 5, 2020
fbce258
Added ADNDC.
Jun 11, 2020
40a44dc
Removed duplicate Application Number.
Jun 11, 2020
6b9d341
Updated some columns and filters for ADL.
Aug 27, 2020
c0d776c
Minor change
Sep 2, 2020
cd39084
Corrected naming for the `exact` fields.
dkrylovsb Sep 11, 2020
b543909
Corrected naming for the exact fields.
dkrylovsb Sep 11, 2020
40719a6
Removed references to pet food & phish pharm.
Sep 11, 2020
aad55e8
run time fixes.
Sep 15, 2020
7963625
marketing_category change, comment out broken tooltip.
Sep 15, 2020
a6ba905
route_of_admin & product_type fixes.
Sep 15, 2020
1ce8a52
Select box CSS fixes.
Sep 15, 2020
a66f852
Infographic fixes.
Sep 15, 2020
d182468
Filter fixes.
Sep 15, 2020
5979c23
Fixed Inactive Ingredient filter.
dkrylovsb Sep 18, 2020
a8fc262
Fixed auto-complete on the Application Number filter.
dkrylovsb Sep 18, 2020
3c7ce1b
Fixes for Nested Data Window.
Sep 21, 2020
8a24c35
Minor fixes
Sep 22, 2020
aaed2a3
Rebase
violetcrestedwren Sep 6, 2022
6ad347c
Initial post-Rebase changes
violetcrestedwren Sep 6, 2022
0237c0a
SCSS fixes
violetcrestedwren Sep 6, 2022
4f37da1
Enabled data for dev & fixed broken select.
violetcrestedwren Sep 7, 2022
d12d1ac
Some CSS fixes and added basic animation
violetcrestedwren Sep 22, 2022
201d4ff
Various fixes and code style refactors.
violetcrestedwren Sep 26, 2022
52220f8
yearpicker fix.
violetcrestedwren Sep 29, 2022
3a46d97
Made filter scrollable
violetcrestedwren Sep 29, 2022
0eb4199
Minor bug fixes
violetcrestedwren Sep 30, 2022
3b720bc
Fixed marketing_category
violetcrestedwren Oct 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16,261 changes: 9,493 additions & 6,768 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 21 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"copy-webpack-plugin": "4.2.0",
"core-js": "^3.8.0",
"create-react-class": "^15.7.0",
"d3-fetch": "^2.0.0",
"d3-scale": "^3.2.3",
"date-fns": "^2.23.0",
"dateformat": "3.0.2",
"eslint": "^7.14.0",
Expand All @@ -52,38 +54,52 @@
"html-react-parser": "^0.14.2",
"immutability-helper": "^2.6.6",
"jquery": "^3.5.1",
"jsonexport": "^2.0.11",
"loader-utils": "1.0.2",
"localforage": "^1.5.2",
"marked": "^1.1.1",
"matchmedia": "^0.1.2",
"moment": "2.20.1",
"nib": "^1.1.2",
"node-sass": "^4.14.1",
"pandas-js": "0.2.4",
"pondjs": "0.8.7",
"prismjs": "^1.22.0",
"raw-loader": "^4.0.2",
"rc-checkbox": "2.1.4",
"rc-slider": "8.3.1",
"react": "^16.4.2",
"react": "16.14.0",
"react-autosuggest": "^9.3.2",
"react-basic-table": "^1.0.14",
"react-chartjs-2": "^2.11.1",
"react-collapsible": "^2.0.4",
"react-custom-scrollbars": "^4.2.1",
"react-datetime": "^2.14.0",
"react-day-picker": "^7.1.1",
"react-document-title": "^2.0.3",
"react-dom": "^16.4.2",
"react-dom": "16.14.0",
"react-helmet": "^5.1.3",
"react-highlight": "^0.14.0",
"react-highlight.js": "^1.0.7",
"react-joyride": "^2.0.5",
"react-modal": "^3.1.0",
"react-promise": "2.0.0",
"react-radio-group": "^3.0.2",
"react-select": "2.4.4",
"react-select": "^4.3.0",
"react-sticky-state": "^2.1.9",
"react-table": "6.9.0",
"react-timeseries-charts": "^0.14.0",
"react-table": "6.10.0",
"react-timeseries-charts": "^0.16.1",
"react-tippy": "^1.2.3",
"react-tooltip": "^3.9.2",
"react-transition-group": "^2.2.1",
"reactstrap": "^7.1.0",
"recharts": "1.8.5",
"scroll-into-view": "^1.9.1",
"stylus": "^0.54.5",
"typescript": "^4.1.2",
"victory": "^35.4.6",
"whatwg-fetch": "^3.5.0",
"with-query": "^1.1.2",
"xlsx": "0.16.1"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion push-site.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

TODAY=$(date +"%Y-%m-%d")
BUCKET="open.fda.gov-$TODAY"
BUCKET="open.fda.gov-demo-data-explorer"

echo "Pushing to: ${BUCKET}"

Expand Down
2 changes: 2 additions & 0 deletions src/components/ApiStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type tPROPS = {

const catMap: Object = Object.freeze({
'animalandveterinarydrugevent': 'Animal & Veterinary › Adverse Events',
'animalandveterinarylabel': 'Animal & Veterinary › Labeling',
'foodenforcement': 'Foods › Enforcement Reports',
'foodevent': 'Foods › Adverse Events',
'drugevent': 'Drugs › Adverse Events',
Expand All @@ -36,6 +37,7 @@ const catMap: Object = Object.freeze({

const endpointLinkMap: Object = Object.freeze({
'animalandveterinarydrugevent': 'animalandveterinary/event',
'animalandveterinarylabel': 'animalandveterinary/label',
'foodevent': 'food/event',
'foodenforcement': 'food/enforcement',
'drugevent': 'drug/event',
Expand Down
2 changes: 2 additions & 0 deletions src/components/ApiUsage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ const ApiUsage = (props:tPROPS) => {
<td colSpan="2"><strong>Animal & Veterinary</strong></td>
</tr>
<tr><td>Adverse Event Reports</td><td>{this.docCount('animalandveterinarydrugevent')}</td></tr>
<tr><td>Labeling</td><td>{this.docCount('animalandveterinarylabel')}</td></tr>
<tr className="bg-primary-darkest clr-white">
<td colSpan="2"><strong>Drugs</strong></td>
</tr>
Expand Down Expand Up @@ -354,6 +355,7 @@ const ApiUsage = (props:tPROPS) => {
<td colSpan="2"><strong>Animal & Veterinary</strong></td>
</tr>
<tr><td>Adverse Event Reports</td><td>{this.downloadCount('animalandveterinarydrugevent')}</td></tr>
<tr><td>Labeling</td><td>{this.downloadCount('animalandveterinarylabel')}</td></tr>
<tr className="bg-primary-darkest clr-white">
<td colSpan="2"><strong>Drugs</strong></td>
</tr>
Expand Down
113 changes: 113 additions & 0 deletions src/components/AutoComplete.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import Autosuggest from 'react-autosuggest'
import withQuery from 'with-query'
import 'whatwg-fetch'
import React from 'react'

class AutoCompleteComponent extends React.Component {

constructor (props: Object) {
super(props)

this.state = {
value: '',
suggestions: [],
url: this.props.parent.state.dataset.url,
endpoint: this.props.parent.state.dataset.endpoint
}
this.getSuggestions = this.getSuggestions.bind(this)
this.onChange = this.onChange.bind(this)
this.onSuggestionsClearRequested = this.onSuggestionsClearRequested.bind(this)
this.onSuggestionsFetchRequested = this.onSuggestionsFetchRequested.bind(this)
this.onSuggestionSelected = this.onSuggestionSelected.bind(this)
}

// https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#Using_Special_Characters
escapeRegexCharacters(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}

renderSuggestion(suggestion) {
return (
<span>{suggestion}</span>
);
}

getSuggestions(value) {
return fetch(
withQuery(`${this.state.url}/${this.state.endpoint}`,{
searchField: this.props.option.field,
searchText: value,
searchType: 'autocomplete',
limit: this.props.option.limit
})
)
.then(res => res.json())
.then((json) => json.results)
.catch((err) => [])
}

onSuggestionsFetchRequested(value){
var that = this;
const escapedValue = this.escapeRegexCharacters(value.value.trim())
this.getSuggestions(escapedValue).then(result => {
if(!result){
return
}
that.setState({
suggestions: result,
value: escapedValue
})
console.log("suggestions are:", result);
})
}
onSuggestionSelected(event, { suggestion, suggestionValue, suggestionIndex, sectionIndex, method }){
if(this.props.onChange){
this.props.onChange(suggestion, {
field: this.props.option.field,
idx: this.props.option.idx
})
}
console.log(event, suggestion)
}

getSuggestionValue(suggestion) {
return suggestion
}

onChange (event, { newValue, method }) {
if(!newValue.length){
this.setState({
suggestions: [],
value: newValue
})
}
}

onSuggestionsClearRequested (){
this.setState({
suggestions: []
})
}

render() {
return (
<Autosuggest
suggestions={this.state.suggestions}
onSuggestionSelected={this.onSuggestionSelected}
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
getSuggestionValue={this.getSuggestionValue}
renderSuggestion={this.renderSuggestion}
inputProps={{
placeholder: this.props.option.placeholder,
value: this.state.value,
onChange: this.onChange
}}
/>
);
}
}


AutoCompleteComponent.displayName = 'component/AutoCompleteComponent'
export default AutoCompleteComponent
174 changes: 174 additions & 0 deletions src/components/DataRetrieval.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/* @flow */


import withQuery from 'with-query'
import {default as $} from 'jquery'
import Moment from 'moment'
import {API_LINK} from "../constants/api";
import update from "immutability-helper/index";

class DataRetrievalService {

constructor (url, endpoint) {
this.url = url
this.endpoint = endpoint

this.convertFiltersToJson = this.convertFiltersToJson.bind(this)
this.getTopValues = this.getTopValues.bind(this)
this.getTopValuesByIterating = this.getTopValuesByIterating.bind(this)
this.getData = this.getData.bind(this)
this.getTotal = this.getTotal.bind(this)
}

handleErrors(response) {
if (!response.ok) throw Error(response.statusText);
return response;
}

addValue (filters, field, value) {
return filters.map(filter => {
if (filter.field === field) {
return update(filter, {value: {$set: value}})
} else {
return filter
}
})
}

convertFiltersToJson(filters, options){
const formattedFilters = filters.filter(filter => filter.value.length).map((filter,idx) => {
var value = {
"query-type": filter.query_type,
"key": filter.field,
"value": filter.value,
"type": filter.type
}
if (value["query-type"] == "range" && value["type"] == "numeric_range") {
value.value = {
"gte": value.value[0],
"lte": value.value[1]
}
} else if (value["query-type"] == "range") {
value.value = {
"gte": Moment(value.value[0]).format('YYYYMMDD'),
"lte": Moment(value.value[1]).format('YYYYMMDD')
}
} else if (value["query-type"] == "exists"){
value.value = filter.value[0].toString()
}
return value
})

if(options.drugtype){
formattedFilters.push({
"query-type": "term",
"key": "@drugtype",
"value": [
options.drugtype
]
})
}

if(options.groupingField) {
return {
"data": {
"queryJSON": {
"size": 5000,
"searchType": "aggregation",
"groupingField": options.groupingField,
"filters": formattedFilters
}
}
}
}

return {
"data": {
"queryJSON": {
"size": 5000,
"searchType": options.searchType,
"filters": formattedFilters
}
}
}
}

getTopValues(field){
return fetch(
withQuery(`${this.url}/${this.endpoint}`,{
count: field
},{
mode: 'cors'
})
).then(this.handleErrors)
.then(res => res.json())
.then((json) => {
const res = json.results.map(obj => {
return {
label: obj.term,
value: obj.term
}
});
return res.sort( (a,b) => (a.value > b.value) - (a.value < b.value))
}).catch((err) => console.log("err: ", err))
}


getTopValuesByIterating(fields, removeChars){

const limit = 200
let urls = []

for (var i = 0; i < (limit/100); i++) {
urls.push(
withQuery(`${this.url}/${this.endpoint}`, {
limit: 100,
skip: i*100
})
)
}

const itemPromises = urls.map($.getJSON)
return Promise.all(itemPromises)
.then((results) => {
const response = []
results.forEach(r => {
response.push(...r.results)
})
return response
})
}


getData(params, options){
const data = this.convertFiltersToJson(params, options)
console.log(JSON.stringify(data, null, 4));
return fetch(`${this.url}/${this.endpoint}`, {
body: JSON.stringify(data),
headers: {
"Content-Type": "application/json"
},
method: 'POST',
mode: 'cors'
}).then(this.handleErrors)
.then(res => res.json())
.then(res => {
return res
})
.catch((err) => {})
}


getTotal() {
return fetch(`${this.url}/${this.endpoint}`)
.then(this.handleErrors)
.then(res => res.json())
.then(res => {
console.log(res)
return res
})
.catch((err) => {})
}
}

export default DataRetrievalService
Loading