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

SIMSBIOHUB 217 - Edit Animal #1101

Merged
merged 280 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
280 commits
Select commit Hold shift + click to select a range
f1fefb6
created addSectionBtn for animal form sections
MacQSL Jul 26, 2023
89eb82f
removed unused context (formik refactor) -> created animal.ts types f…
MacQSL Jul 26, 2023
3e45574
updated formSectionWrapper and styling in input sections
MacQSL Jul 27, 2023
1e38847
added constants for animal form to i18n.ts and updated refs
MacQSL Jul 27, 2023
62612a4
updated customTextField to handle onBlur changes, used for formik val…
MacQSL Jul 27, 2023
89c2520
updated animal.ts to use yup validation schemas, updated styling / wo…
MacQSL Jul 27, 2023
d1f081b
Implements working floating point field with proper validation. Also …
GrahamS-Quartech Jul 27, 2023
70e4705
Consolidated marker and resizable circle into one component. Renamed …
GrahamS-Quartech Jul 28, 2023
c3c0ad9
Merge branch 'critterbase-map-component' into BCTW-935-Add-Critter-Form
GrahamS-Quartech Jul 28, 2023
2a0b90f
added release section to capture and helper function for generating f…
MacQSL Jul 28, 2023
6ccd2f1
created TextInputToggle.tsx for animal comment inputs
MacQSL Jul 28, 2023
971a8c2
moved inputs to separate component for CaptureAnimalForm
MacQSL Jul 28, 2023
85831f3
added marking boiler plate code
MacQSL Jul 28, 2023
dd0d15d
Added taxon select and capture tab component to the critter form. Als…
GrahamS-Quartech Jul 28, 2023
a625415
Merge branch 'BCTW-935-Add-Critter-Form' of github.com:bcgov/biohubbc…
GrahamS-Quartech Jul 28, 2023
5c8bfab
added controlProps for CbSelect comp, improved validation errs
MacQSL Jul 28, 2023
444a2fd
added marking section
MacQSL Jul 31, 2023
56cbc3e
created UI section for measurements
MacQSL Jul 31, 2023
1f7f28b
Capture form now has toggle between WGS latlon or UTM Zone 10 input. …
GrahamS-Quartech Jul 31, 2023
e178d72
Merge branch 'BCTW-935-Add-Critter-Form' of github.com:bcgov/biohubbc…
GrahamS-Quartech Jul 31, 2023
0fd126d
Implemented separate placement of release coordinate on map page as w…
GrahamS-Quartech Aug 1, 2023
8c56a9f
Updated CbSelect to handle taxon changes
MacQSL Aug 1, 2023
fe86e5a
Merge branch 'BCTW-935-Add-Critter-Form' of https://github.com/bcgov/…
MacQSL Aug 1, 2023
495027e
Added Family form section, added critterApi, added some custom valida…
GrahamS-Quartech Aug 2, 2023
2bc1115
Merge branch 'BCTW-935-Add-Critter-Form' of github.com:bcgov/biohubbc…
GrahamS-Quartech Aug 2, 2023
8a803f8
Adds mortality event form, relevant string constants. Modified CbSele…
GrahamS-Quartech Aug 2, 2023
7a64c73
Added comments to new components, broke some helpers out into separat…
GrahamS-Quartech Aug 3, 2023
b5218de
created measurement section and handling qual/quant measurements as o…
MacQSL Aug 3, 2023
5f71a4a
Refactored all the custom map stuff inside the Capture and Mortality …
GrahamS-Quartech Aug 3, 2023
c793dd4
fixed merge conflict with CbSelect + modified measruement to handle o…
MacQSL Aug 3, 2023
891c0b3
fixed type issue in LocationEntryForm
MacQSL Aug 3, 2023
28c3e98
commit before CbSelect refactor
MacQSL Aug 4, 2023
cd03376
created FormikSelectWrapper component to handle custom select renderings
MacQSL Aug 4, 2023
8b2a020
updated measurements to now support unit type
MacQSL Aug 4, 2023
f1b0e97
Merge branch 'dev' into BCTW-935-Add-Critter-Form
MacQSL Aug 4, 2023
1658063
created critter class for handling critterbase payload
MacQSL Aug 9, 2023
32fe6fc
fixed measurements from not being fetched
MacQSL Aug 9, 2023
74f7e2e
Updated Critter class payload formatting
MacQSL Aug 10, 2023
7a52f12
updated capture form styling
MacQSL Aug 10, 2023
3c5c57f
Modified some of the critter form transformations to make each of the…
GrahamS-Quartech Aug 11, 2023
9174b10
Fixed markings so that they won't have empty string default for non r…
GrahamS-Quartech Aug 11, 2023
24e36fd
modified temp date fields to real date/timestamp inputs
MacQSL Aug 11, 2023
974ebe1
corrected merge conflict
MacQSL Aug 11, 2023
0829656
commit before grouping refactor
MacQSL Aug 11, 2023
a67d924
updated form styling to be inline with current sims forms
MacQSL Aug 11, 2023
7a1986f
finalized UI changes for Indivdual Animal form
MacQSL Aug 14, 2023
95b920b
created helper function for required fields for yup validation
MacQSL Aug 14, 2023
bd5ada9
Fixed sending empty values on mortality form section and corrected a …
GrahamS-Quartech Aug 14, 2023
3e0f018
updated required fields to use helper function
MacQSL Aug 14, 2023
b41b59c
added temp dev logs for form_values and payload
MacQSL Aug 15, 2023
7b5c683
corrected merge conflict in markings
MacQSL Aug 15, 2023
18dbbf4
Updated critter payload class and UI components to be centered around…
GrahamS-Quartech Aug 15, 2023
7d5ac93
Merge branch 'BCTW-935-Add-Critter-Form' of github.com:bcgov/biohubbc…
GrahamS-Quartech Aug 15, 2023
f418c9e
fixed animal mutation bug + removed excess logging
MacQSL Aug 15, 2023
1883056
Merge branch 'BCTW-935-Add-Critter-Form' of github.com:bcgov/biohubbc…
GrahamS-Quartech Aug 15, 2023
5287165
removed deep copy from Critter constructor
MacQSL Aug 15, 2023
5c451a9
removed deep copy from Critter constructor
MacQSL Aug 15, 2023
60b1d65
updated component / function comments
MacQSL Aug 15, 2023
aa18256
corrected merge conflict in animal constructor
MacQSL Aug 15, 2023
28ebba2
updated animal captured sub header
MacQSL Aug 16, 2023
65f4942
Family section now has a button to view the basic hierarchy of the fa…
GrahamS-Quartech Aug 16, 2023
b58ce0f
Merge branch 'BCTW-935-Add-Critter-Form' of github.com:bcgov/biohubbc…
GrahamS-Quartech Aug 16, 2023
6c0ab62
wrapped children of family modal in outlined papers
MacQSL Aug 16, 2023
548a425
added temp dev button to display form values
MacQSL Aug 16, 2023
ab6e0da
Added snackbar toast to animal form
MacQSL Aug 16, 2023
c010f14
added helper function to pluarlize dialog/toast text
MacQSL Aug 16, 2023
41a0607
auto formatted code for PR
MacQSL Aug 16, 2023
3c999d7
fixed CB_API_URL formatting error
MacQSL Aug 16, 2023
00924bc
fixed merge conflicts with dev
MacQSL Aug 16, 2023
7305b3c
added tests for animal.ts helper functions
MacQSL Aug 16, 2023
e6eabff
Fixed a bug where switching to UTM coordinates would not populate the…
GrahamS-Quartech Aug 17, 2023
c8d8ed5
Merge branch 'BCTW-935-Add-Critter-Form' of github.com:bcgov/biohubbc…
GrahamS-Quartech Aug 17, 2023
f08bda7
added tests for critter captures/markings
MacQSL Aug 17, 2023
650798c
Merge branch 'BCTW-935-Add-Critter-Form' of https://github.com/bcgov/…
MacQSL Aug 17, 2023
7ec9c76
Added some basic tests for critterbase api hooks
GrahamS-Quartech Aug 17, 2023
58f6c5b
changed function isReq -> isRequiredInSchema
MacQSL Aug 17, 2023
0f55e50
created stable id values for the array form sections
MacQSL Aug 17, 2023
98ebb2f
removed commented code
MacQSL Aug 17, 2023
be96c9a
updated tests
MacQSL Aug 17, 2023
175a223
fixed formatting issue in measurement
MacQSL Aug 17, 2023
9cf9775
Created basic service to send requests to BCTW API
JeremyQuartech Aug 17, 2023
a5c3656
fixed multiple codeSmells ignore-skip
MacQSL Aug 17, 2023
4b20cee
removed nested template literal ignore-skip
MacQSL Aug 17, 2023
aad8763
fixed key issue in formSectionWrapper
MacQSL Aug 17, 2023
bd0aa93
fixed issue with url formatting in useAxios
MacQSL Aug 18, 2023
738832b
Added bctw health endpoint to test connection and auth.
JeremyQuartech Aug 18, 2023
6f3aafc
corrected all issues in PR comments
MacQSL Aug 18, 2023
aa65957
fixed formatting
MacQSL Aug 18, 2023
5200b24
Added new keycloak method to get service token.
JeremyQuartech Aug 21, 2023
57d6cb8
CbSelectField updated for exhaustive dependecies / ignoring one instance
MacQSL Aug 21, 2023
5ea64d6
wrapped isValueInRange in useMemo
MacQSL Aug 21, 2023
f73e4a3
updated animal constructor to removed dead values
MacQSL Aug 21, 2023
fcae94e
updated family to use CbSelectWrapper
MacQSL Aug 21, 2023
036e78c
fixed issue with capture section add btn being incorrectly disabled
MacQSL Aug 21, 2023
ae69d68
removed console.log in capture
MacQSL Aug 21, 2023
4d98ab6
added additional props for TextInputToggle to control the toggle stat…
MacQSL Aug 22, 2023
b1446f2
fixed measurement selection bug
MacQSL Aug 22, 2023
5d48e92
updated general section key + added custom canAddSection handler for …
MacQSL Aug 22, 2023
bb193ec
WIP: Adds basic endpoints to BCTW service.
JeremyQuartech Aug 22, 2023
853aa34
Fixed typescript error in makeRequest function
JeremyQuartech Aug 23, 2023
678230a
Merge branch 'BCTW-935-Add-Critter-Form' of github.com:bcgov/biohubbc…
GrahamS-Quartech Aug 23, 2023
3e3ea5e
Added support for query to makeGetRequest bctw method.
JeremyQuartech Aug 23, 2023
e7666fe
Added a critterbase service in the same style as the bctw-service
GrahamS-Quartech Aug 23, 2023
354d96a
Merge branch 'BCTW-935-Add-Critter-Form' into critterbase-service
GrahamS-Quartech Aug 23, 2023
76c842d
Added unit tests for bctw-service.
JeremyQuartech Aug 23, 2023
3940f06
Added test coverage for missing line.
JeremyQuartech Aug 23, 2023
86a3d4b
Added telemetry vendor lookup route and removed deprecated deployment…
JeremyQuartech Aug 24, 2023
d92ec3e
Added unit tests for vendor request handler.
JeremyQuartech Aug 24, 2023
bce16d6
Fleshed out the critterbase service with more of the required routes …
GrahamS-Quartech Aug 24, 2023
d03b7d9
Fixed signup hook so that it also goes through the critterbase servic…
GrahamS-Quartech Aug 28, 2023
f9ee232
Fixed names of some of the ICbRoute keys to be more consistent with o…
GrahamS-Quartech Aug 28, 2023
61e5217
Some more renames, removed console logs, fixed lint issues
GrahamS-Quartech Aug 28, 2023
bc50882
Merge branch 'critterbase-service' into SIMSBIOHUB-239
GrahamS-Quartech Aug 28, 2023
37235b8
Moved some duplicate code from critter measurement paths into a reusa…
GrahamS-Quartech Aug 28, 2023
926979c
Merge branch 'dev' into SIMSBIOHUB-239
GrahamS-Quartech Aug 28, 2023
aff674d
Added a missing function to the lookup hook, fixed a broken test
GrahamS-Quartech Aug 28, 2023
5502848
Fixed a duplicately named function
GrahamS-Quartech Aug 28, 2023
888bf4e
Fixed some tests and linting issues
GrahamS-Quartech Aug 28, 2023
237bc04
Added tests for critterbase service
GrahamS-Quartech Aug 29, 2023
5e4df5e
Added family index request handler try/catch and unit tests.
JeremyQuartech Aug 29, 2023
118d022
Merge branch 'SIMSBIOHUB-239' of https://github.com/bcgov/biohubbc in…
JeremyQuartech Aug 29, 2023
5161c2c
Added unit tests for 'getFamilyById'
JeremyQuartech Aug 29, 2023
d63bea0
Added unit test for 'getTaxonBodyLocations'
JeremyQuartech Aug 29, 2023
e2f1480
Added unit tests for 'getTaxonMeasurements'
JeremyQuartech Aug 29, 2023
1659306
Added unit tests for 'getQualMeasurementOptions'
JeremyQuartech Aug 29, 2023
93d7ff0
Added unit tests for 'signUp'
JeremyQuartech Aug 29, 2023
6660d97
Added tests for critters and lookups paths
GrahamS-Quartech Aug 29, 2023
4a7fd49
Merge branch 'SIMSBIOHUB-239' of github.com:bcgov/biohubbc into SIMSB…
GrahamS-Quartech Aug 29, 2023
ea815d1
Merge branch 'dev' into SIMSBIOHUB-239
JeremyQuartech Aug 29, 2023
b444fab
Merge branch 'SIMSBIOHUB-239' of github.com:bcgov/biohubbc into SIMSB…
GrahamS-Quartech Aug 29, 2023
39f5d57
Missed the tiniest of tiny lints
GrahamS-Quartech Aug 29, 2023
4553ef1
Added environment variables for BCTW and Critterbase API URLs, ignore…
JeremyQuartech Aug 29, 2023
97b5f5c
Small fixes to deployment config
GrahamS-Quartech Aug 29, 2023
2490104
Added new env to the top of the template as well
GrahamS-Quartech Aug 29, 2023
0252c79
Changed BctwService interfaces to zod objects
JeremyQuartech Aug 29, 2023
57bf290
Adressed review comments. Renamed critter post path, fixed some strin…
GrahamS-Quartech Aug 29, 2023
adc1c79
Merge branch 'SIMSBIOHUB-239' of github.com:bcgov/biohubbc into SIMSB…
GrahamS-Quartech Aug 29, 2023
f339cdb
Merge branch 'dev' into SIMSBIOHUB-239
GrahamS-Quartech Aug 29, 2023
b8f111e
ignore-skip
al-rosenthal Aug 29, 2023
55a9c07
SIMSBIOHUB-239: updated error handling
curtisupshall Aug 30, 2023
f8b06b7
Added error handling to interceptor and removed makePostPatch method …
JeremyQuartech Aug 30, 2023
339a58f
Added request interceptor to axios instance to allow async keycloak t…
JeremyQuartech Aug 30, 2023
5acc4bd
Removed test code
JeremyQuartech Aug 30, 2023
efe242d
Fixed axios instance for critterbase service, fixed bulk insert behav…
GrahamS-Quartech Aug 30, 2023
0ef26ba
Merge branch 'SIMSBIOHUB-239' of github.com:bcgov/biohubbc into SIMSB…
GrahamS-Quartech Aug 30, 2023
63e49f4
WIP: Updated bctw tests
JeremyQuartech Aug 30, 2023
27c7286
Merge branch 'SIMSBIOHUB-239' of https://github.com/bcgov/biohubbc in…
JeremyQuartech Aug 30, 2023
9453798
Fixed failing BctwService tests
JeremyQuartech Aug 30, 2023
8086044
Fixed failing critterbase service tests
JeremyQuartech Aug 30, 2023
c8e3abe
Addressed more review comments. Added uuid format to paths, fixed tes…
GrahamS-Quartech Aug 30, 2023
558e085
Removed some outdated checks against frontend critterbase env vars
GrahamS-Quartech Aug 30, 2023
989b991
Added hooks and endpoint for filtering critterbase critters
GrahamS-Quartech Aug 30, 2023
817b47a
Added empty telemetry form
JeremyQuartech Aug 31, 2023
d8063a0
Merge branch 'dev' into SIMSBIOHUB-207
JeremyQuartech Aug 31, 2023
dd8b9f7
Added typing for the critter response, basic table with actions menu …
GrahamS-Quartech Aug 31, 2023
0b9bf49
Merge branch 'dev' into SIMSBIOHUB-216
GrahamS-Quartech Aug 31, 2023
cbee3d5
WIP: telemetry form
JeremyQuartech Aug 31, 2023
8250f41
WIP: Telemetry Device form, Telemetry select fields, and telemetry Ap…
JeremyQuartech Sep 1, 2023
32a35c2
Adds relevant routes, types, and services functions to add critters a…
GrahamS-Quartech Sep 1, 2023
a632c2b
Added routes and functions for removing a critter from a survey. Ther…
GrahamS-Quartech Sep 1, 2023
67a6a66
Merge branch 'SIMSBIOHUB-207' into SIMSBIOHUB-216
GrahamS-Quartech Sep 1, 2023
c687b25
This adds the ability to deploy devices from SIMS. Also adds code fet…
GrahamS-Quartech Sep 6, 2023
61e21c8
WIP: Joined device data to critters in SurveyAnimalsTable
JeremyQuartech Sep 6, 2023
72666a2
Added support for multiple devices per critter at survey level.
JeremyQuartech Sep 6, 2023
ff09d0d
Added basic tests for useDeviceApi
JeremyQuartech Sep 7, 2023
0996787
Fixed infered type error
JeremyQuartech Sep 7, 2023
f6fb6fa
WIP: Writing tests for new critter and device endpoints
JeremyQuartech Sep 7, 2023
c634e02
WIP: Added tests to critter / deployment related survey endpoints
JeremyQuartech Sep 7, 2023
9d19d06
Updated BctwService and CritterbaseService tests
JeremyQuartech Sep 8, 2023
a824e66
Various PR recommendations
JeremyQuartech Sep 8, 2023
52dff78
Removed old comments, ignore-skip
JeremyQuartech Sep 8, 2023
a3d6dcb
Added new survey-repository tests for new critter and device funciton…
JeremyQuartech Sep 8, 2023
b9269b3
Added survey-service tests for new critter and device methods
JeremyQuartech Sep 8, 2023
9aca229
Fixed code smells and lint errors
JeremyQuartech Sep 11, 2023
032c164
Code smell fixes
JeremyQuartech Sep 11, 2023
1d82ea8
Create critter duplicated code fix.
JeremyQuartech Sep 11, 2023
ddb61a9
Addressed review comments, made critter service its own thing separat…
GrahamS-Quartech Sep 11, 2023
3e74745
Merge branch 'SIMSBIOHUB-216' of github.com:bcgov/biohubbc into SIMSB…
GrahamS-Quartech Sep 11, 2023
1eac3ad
Merge branch 'dev' into SIMSBIOHUB-216
JeremyQuartech Sep 11, 2023
0dfffed
Added string / number type to Telemetry select field data loader types
JeremyQuartech Sep 11, 2023
6fa39d2
Merge branch 'SIMSBIOHUB-216' of https://github.com/bcgov/biohubbc in…
JeremyQuartech Sep 11, 2023
32ac44c
Made generic CustomDataGrid so custom styling can be reused
GrahamS-Quartech Sep 11, 2023
b913e4f
Merge branch 'SIMSBIOHUB-216' of github.com:bcgov/biohubbc into SIMSB…
GrahamS-Quartech Sep 11, 2023
951962d
Fixed some broken api tests
GrahamS-Quartech Sep 11, 2023
5a4229f
Refactored critter-survey matching for faster lookup
JeremyQuartech Sep 11, 2023
de7a9b3
Merge branch 'SIMSBIOHUB-216' of https://github.com/bcgov/biohubbc in…
JeremyQuartech Sep 11, 2023
1b30598
Added some additional tests for the survey hook
GrahamS-Quartech Sep 11, 2023
2736029
Merge branch 'SIMSBIOHUB-216' of github.com:bcgov/biohubbc into SIMSB…
GrahamS-Quartech Sep 11, 2023
e77001b
Adds some api routes and added error handling in the frontend for the…
GrahamS-Quartech Sep 11, 2023
a99b623
Merge branch 'dev' into SIMSBIOHUB-216
JeremyQuartech Sep 11, 2023
7f24991
Adds missing test for deviceId route
GrahamS-Quartech Sep 11, 2023
8e2d454
Merge branch 'SIMSBIOHUB-216' of github.com:bcgov/biohubbc into SIMSB…
GrahamS-Quartech Sep 11, 2023
4046d46
Fixes a small type complaint
GrahamS-Quartech Sep 12, 2023
51c20e2
Conditional rendering for certain table actions depending on device s…
GrahamS-Quartech Sep 13, 2023
f01968c
Functional edit deployment screen but broken add deployment. Comittin…
GrahamS-Quartech Sep 13, 2023
4aa70c4
Several changes to improve some strange defocusing behavior on the te…
GrahamS-Quartech Sep 14, 2023
44c9e80
Fully functional edit deployment screen that will send requests to up…
GrahamS-Quartech Sep 15, 2023
15c51f2
CHanged location of dynamic bctw errors in the form
GrahamS-Quartech Sep 15, 2023
70d61ef
Merge branch 'dev' into SIMSBIOHUB-211
GrahamS-Quartech Sep 15, 2023
ee414d9
Fixed a broken test
GrahamS-Quartech Sep 15, 2023
1fc3f8c
Removed some unwanted buttons in the action menu that I added back ac…
GrahamS-Quartech Sep 15, 2023
6008ae9
adds additional testing for new services and endpoints
GrahamS-Quartech Sep 18, 2023
cd6b08a
Adds additional missing test, fixes lint error
GrahamS-Quartech Sep 18, 2023
96e6845
Forgot a test file
GrahamS-Quartech Sep 18, 2023
bb82bcd
Fixed some borked Survey UI tests
GrahamS-Quartech Sep 18, 2023
5a1e18c
SurveyAnimals test will now press buttons
GrahamS-Quartech Sep 18, 2023
5a562f9
Adresses PR comments, adds enums, return types, adds specific try cat…
GrahamS-Quartech Sep 18, 2023
eafcbc1
Catches some bugs surrounding submitting new deployments and editing …
GrahamS-Quartech Sep 18, 2023
90bacec
Adds some more test and addresses PR comments
GrahamS-Quartech Sep 19, 2023
e06bcca
Adds more tests
GrahamS-Quartech Sep 19, 2023
a196f9e
lint fix
GrahamS-Quartech Sep 19, 2023
cbad57a
Removing the code smell surrounding array indexes as react keys
GrahamS-Quartech Sep 19, 2023
ae21c2d
added more survey tests to make review pass
GrahamS-Quartech Sep 19, 2023
9085810
Separated current and previous devices into own columns, made wlh id …
GrahamS-Quartech Sep 19, 2023
770a894
Fully implemented critter collection unit form section, submits corre…
GrahamS-Quartech Sep 19, 2023
a7026e7
Added tests for new hooks and routes
GrahamS-Quartech Sep 20, 2023
d8cbfcb
Merge branch 'dev' into SIMSBIOHUB-281
GrahamS-Quartech Sep 20, 2023
53aec06
Removed some routes that proved unecessary after all. Fixed some brok…
GrahamS-Quartech Sep 20, 2023
d3f87e0
Added proper string constants, fixed wlh id being excluded from paylo…
GrahamS-Quartech Sep 20, 2023
ddd58d9
Forgot to commit lint fix
GrahamS-Quartech Sep 20, 2023
0ba32b9
Added an app test for new form section
GrahamS-Quartech Sep 20, 2023
58b6943
tiny lint
GrahamS-Quartech Sep 20, 2023
3c35778
Added edit critter button back in, got fields filled for captures, ma…
GrahamS-Quartech Sep 20, 2023
9b47028
Markings, measurements, mortality all being displayed on edit form
GrahamS-Quartech Sep 21, 2023
43be467
Updating/creating/deleting in edit animal form appears to be working …
GrahamS-Quartech Sep 22, 2023
9b85c22
Locks in release checbox if editing a capture event that already has …
GrahamS-Quartech Sep 25, 2023
ac17d9e
Prevented a bug where New Family option in the family form section wo…
GrahamS-Quartech Sep 25, 2023
26474c1
Fixed react errors present in capture form and cb select field
GrahamS-Quartech Sep 25, 2023
9c1eeed
Added some tests, fixed some broken ones, added force_create_release …
GrahamS-Quartech Sep 25, 2023
5fac0c6
Merge branch 'dev' into SIMSBIOHUB-217, ignore-skip
GrahamS-Quartech Sep 26, 2023
b960ea6
Missed some merge markers woops
GrahamS-Quartech Sep 26, 2023
447e16b
Adds tests for updatecritter service, fixes some tests, addresses som…
GrahamS-Quartech Sep 26, 2023
b24e087
Updated tests with hardcoded UUIDs, fixed Critter constructor mutatin…
GrahamS-Quartech Sep 26, 2023
bee8208
Made the update critter endpoint routed to the internal critter id
GrahamS-Quartech Sep 26, 2023
0428ab4
Fixed bug behavior in useDataLoader's isMounted check which fixed som…
GrahamS-Quartech Sep 27, 2023
9d77ce1
Improved critter related openapi schema, fixed some issues with the v…
GrahamS-Quartech Sep 27, 2023
a208bea
Refactored renderAnimalFormSafe to exclude try catch
GrahamS-Quartech Sep 27, 2023
1a70e25
Fixes broken tests and adds critter repository tests
GrahamS-Quartech Sep 28, 2023
0c96c9f
lint fix
GrahamS-Quartech Sep 28, 2023
2c7ea52
added nested location schema to openapi request object
GrahamS-Quartech Sep 28, 2023
e58b619
Added some more tests
GrahamS-Quartech Sep 28, 2023
7e6b778
Improved try catch snackbar handling, return async functions properly…
GrahamS-Quartech Sep 28, 2023
80c85f3
Built out the animal-form-helpers tests
GrahamS-Quartech Sep 28, 2023
afc0341
Added test for FamilyAnimalForm
GrahamS-Quartech Sep 28, 2023
4cb9583
Added a default sort to the critter table so it won't display strange…
GrahamS-Quartech Sep 28, 2023
741a2ac
Merge branch 'dev' into SIMSBIOHUB-217
JeremyQuartech Sep 28, 2023
43716e0
Changed release date to not be required
GrahamS-Quartech Sep 29, 2023
abdab7a
Merge branch 'SIMSBIOHUB-217' of github.com:bcgov/biohubbc into SIMSB…
GrahamS-Quartech Sep 29, 2023
c312ede
Merge branch 'dev' into SIMSBIOHUB-217
GrahamS-Quartech Sep 29, 2023
89a4159
Also made COD confidence nullable
GrahamS-Quartech Sep 29, 2023
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
349 changes: 340 additions & 9 deletions api/src/openapi/schemas/critter.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api/src/paths/critter-data/critters/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RequestHandler } from 'express';
import { Operation } from 'express-openapi';
import { PROJECT_PERMISSION, SYSTEM_ROLE } from '../../../constants/roles';
import { critterCreateRequestObject } from '../../../openapi/schemas/critter';
import { critterBulkRequestObject } from '../../../openapi/schemas/critter';
import { authorizeRequestHandler } from '../../../request-handlers/security/authorization';
import { CritterbaseService, ICritterbaseUser } from '../../../services/critterbase-service';
import { getLogger } from '../../../utils/logger';
Expand Down Expand Up @@ -39,7 +39,7 @@ POST.apiDoc = {
description: 'Critterbase bulk creation request object',
content: {
'application/json': {
schema: critterCreateRequestObject
schema: critterBulkRequestObject
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,11 @@ describe('addCritterToSurvey', () => {
});

const mockDBConnection = getMockDBConnection({ release: sinon.stub() });
const mockSurveyCritter = 123;
const mockCBCritter = { critter_id: 'critterbase1' };

it('returns critters from survey', async () => {
const mockGetDBConnection = sinon.stub(db, 'getDBConnection').returns(mockDBConnection);
const mockAddCritterToSurvey = sinon
.stub(SurveyCritterService.prototype, 'addCritterToSurvey')
.resolves(mockSurveyCritter);
const mockAddCritterToSurvey = sinon.stub(SurveyCritterService.prototype, 'addCritterToSurvey').resolves();
const mockCreateCritter = sinon.stub(CritterbaseService.prototype, 'createCritter').resolves(mockCBCritter);
const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { RequestHandler } from 'express';
import { Operation } from 'express-openapi';
import { PROJECT_PERMISSION, SYSTEM_ROLE } from '../../../../../../constants/roles';
import { getDBConnection } from '../../../../../../database/db';
import { critterCreateRequestObject } from '../../../../../../openapi/schemas/critter';
import { bulkCreateResponse, critterBulkRequestObject } from '../../../../../../openapi/schemas/critter';
import { authorizeRequestHandler } from '../../../../../../request-handlers/security/authorization';
import { CritterbaseService, ICritterbaseUser } from '../../../../../../services/critterbase-service';
import { SurveyCritterService } from '../../../../../../services/survey-critter-service';
Expand Down Expand Up @@ -129,7 +129,7 @@ POST.apiDoc = {
description: 'Critterbase bulk creation request object',
content: {
'application/json': {
schema: critterCreateRequestObject
schema: critterBulkRequestObject
}
}
},
Expand All @@ -138,10 +138,7 @@ POST.apiDoc = {
description: 'Responds with counts of objects created in critterbase.',
content: {
'application/json': {
schema: {
title: 'Bulk creation response object',
type: 'object'
}
schema: bulkCreateResponse
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
import Ajv from 'ajv';
import { expect } from 'chai';
import sinon from 'sinon';
import * as db from '../../../../../../database/db';
import { HTTPError } from '../../../../../../errors/http-error';
import { CritterbaseService } from '../../../../../../services/critterbase-service';
import { SurveyCritterService } from '../../../../../../services/survey-critter-service';
import { getMockDBConnection, getRequestHandlerMocks } from '../../../../../../__mocks__/db';
import { removeCritterFromSurvey } from './{critterId}';
import { DELETE, PATCH, removeCritterFromSurvey, updateSurveyCritter } from './{critterId}';

describe('critterId openapi schema', () => {
const ajv = new Ajv();

it('PATCH is valid openapi v3 schema', () => {
expect(ajv.validateSchema((PATCH.apiDoc as unknown) as object)).to.be.true;
});

it('DELETE is valid openapi v3 schema', () => {
expect(ajv.validateSchema((DELETE.apiDoc as unknown) as object)).to.be.true;
});
});

describe('removeCritterFromSurvey', () => {
afterEach(() => {
sinon.restore();
});

const mockDBConnection = getMockDBConnection({ release: sinon.stub() });
const mockSurveyCritter = 123;

it('removes critter from survey', async () => {
sinon.stub(db, 'getDBConnection').returns(mockDBConnection);
sinon.stub(SurveyCritterService.prototype, 'removeCritterFromSurvey').resolves(mockSurveyCritter);
sinon.stub(SurveyCritterService.prototype, 'removeCritterFromSurvey').resolves();

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();
const requestHandler = removeCritterFromSurvey();

await requestHandler(mockReq, mockRes, mockNext);

expect(mockRes.statusValue).to.equal(200);
expect(mockRes.jsonValue).to.equal(mockSurveyCritter);
});

it('catches and re-throws errors', async () => {
Expand All @@ -43,3 +56,81 @@ describe('removeCritterFromSurvey', () => {
}
});
});

describe('updateSurveyCritter', () => {
afterEach(() => {
sinon.restore();
});

const mockDBConnection = getMockDBConnection({ release: sinon.stub() });
const mockCBCritter = { critter_id: 'critterbase1' };

it('returns critters from survey', async () => {
const mockGetDBConnection = sinon.stub(db, 'getDBConnection').returns(mockDBConnection);
const mockSurveyUpdateCritter = sinon.stub(SurveyCritterService.prototype, 'updateCritter').resolves();
const mockCritterbaseUpdateCritter = sinon
.stub(CritterbaseService.prototype, 'updateCritter')
.resolves(mockCBCritter);
const mockCritterbaseCreateCritter = sinon
.stub(CritterbaseService.prototype, 'createCritter')
.resolves(mockCBCritter);
const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();
mockReq.body = {
create: {},
update: { critter_id: 'critterbase1' }
};
const requestHandler = updateSurveyCritter();
await requestHandler(mockReq, mockRes, mockNext);

expect(mockGetDBConnection.calledOnce).to.be.true;
expect(mockSurveyUpdateCritter.calledOnce).to.be.true;
expect(mockCritterbaseUpdateCritter.calledOnce).to.be.true;
expect(mockCritterbaseCreateCritter.calledOnce).to.be.true;
expect(mockRes.status).to.have.been.calledWith(200);
expect(mockRes.json).to.have.been.calledWith(mockCBCritter);
});

it('catches and re-throws errors', async () => {
const mockError = new Error('a test error');
const mockGetDBConnection = sinon.stub(db, 'getDBConnection').returns(mockDBConnection);
const mockSurveyUpdateCritter = sinon.stub(SurveyCritterService.prototype, 'updateCritter').rejects(mockError);
const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();
mockReq.body = {
create: {},
update: { critter_id: 'critterbase1' }
};
const requestHandler = updateSurveyCritter();

try {
await requestHandler(mockReq, mockRes, mockNext);
expect.fail();
} catch (actualError) {
expect(actualError).to.equal(mockError);
expect(mockSurveyUpdateCritter.calledOnce).to.be.true;
expect(mockGetDBConnection.calledOnce).to.be.true;
expect(mockDBConnection.release).to.have.been.called;
}
});

it('catches and re-throws errors', async () => {
const errMsg = 'No external critter ID was found.';
const mockGetDBConnection = sinon.stub(db, 'getDBConnection').returns(mockDBConnection);
const mockSurveyUpdateCritter = sinon.stub(SurveyCritterService.prototype, 'updateCritter').resolves();
const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();
mockReq.body = {
update: {}
};
const requestHandler = updateSurveyCritter();

try {
await requestHandler(mockReq, mockRes, mockNext);
expect.fail();
} catch (actualError) {
expect((actualError as HTTPError).message).to.equal(errMsg);
expect((actualError as HTTPError).status).to.equal(400);
expect(mockSurveyUpdateCritter.calledOnce).to.be.false;
expect(mockGetDBConnection.calledOnce).to.be.true;
expect(mockDBConnection.release).to.have.been.called;
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { RequestHandler } from 'express';
import { Operation } from 'express-openapi';
import { PROJECT_PERMISSION, SYSTEM_ROLE } from '../../../../../../constants/roles';
import { getDBConnection } from '../../../../../../database/db';
import { HTTPError, HTTPErrorType } from '../../../../../../errors/http-error';
import { bulkUpdateResponse, critterBulkRequestObject } from '../../../../../../openapi/schemas/critter';
import { authorizeRequestHandler } from '../../../../../../request-handlers/security/authorization';
import { CritterbaseService, ICritterbaseUser } from '../../../../../../services/critterbase-service';
import { SurveyCritterService } from '../../../../../../services/survey-critter-service';
import { getLogger } from '../../../../../../utils/logger';

Expand All @@ -26,6 +29,25 @@ export const DELETE: Operation = [
removeCritterFromSurvey()
];

export const PATCH: Operation = [
authorizeRequestHandler((req) => {
return {
or: [
{
validProjectPermissions: [PROJECT_PERMISSION.COORDINATOR, PROJECT_PERMISSION.COLLABORATOR],
projectId: Number(req.params.projectId),
discriminator: 'ProjectPermission'
},
{
validSystemRoles: [SYSTEM_ROLE.DATA_ADMINISTRATOR],
discriminator: 'SystemRole'
}
]
};
}),
updateSurveyCritter()
];

DELETE.apiDoc = {
description: 'Removes association of this critter to this survey.',
tags: ['critterbase'],
Expand Down Expand Up @@ -54,13 +76,58 @@ DELETE.apiDoc = {
],
responses: {
200: {
description: 'Responds with affected number of rows.',
description: 'Critter was removed from survey'
},
400: {
$ref: '#/components/responses/400'
},
401: {
$ref: '#/components/responses/401'
},
403: {
$ref: '#/components/responses/401'
},
500: {
$ref: '#/components/responses/500'
},
default: {
$ref: '#/components/responses/default'
}
}
};

PATCH.apiDoc = {
description: 'Patches a critter in critterbase, also capable of deleting relevant rows if marked with _delete.',
tags: ['critterbase'],
security: [
{
Bearer: []
}
],
parameters: [
{
in: 'path',
name: 'surveyId',
schema: {
type: 'number'
},
required: true
}
],
requestBody: {
description: 'Critterbase bulk patch request object',
content: {
'application/json': {
schema: critterBulkRequestObject
}
}
},
responses: {
200: {
description: 'Responds with counts of objects created in critterbase.',
content: {
'application/json': {
schema: {
title: 'Affected rows',
type: 'number'
}
schema: bulkUpdateResponse
}
}
},
Expand Down Expand Up @@ -101,3 +168,40 @@ export function removeCritterFromSurvey(): RequestHandler {
}
};
}

export function updateSurveyCritter(): RequestHandler {
return async (req, res) => {
const user: ICritterbaseUser = {
keycloak_guid: req['system_user']?.user_guid,
username: req['system_user']?.user_identifier
};

const critterId = Number(req.params.critterId);
const connection = getDBConnection(req['keycloak_token']);
const surveyService = new SurveyCritterService(connection);
const cb = new CritterbaseService(user);
try {
await connection.open();
const critterbaseCritterId = req.body.update.critter_id;
if (!critterbaseCritterId) {
throw new HTTPError(HTTPErrorType.BAD_REQUEST, 400, 'No external critter ID was found.');
}
await surveyService.updateCritter(critterId, critterbaseCritterId);
let createResult, updateResult;
if (req.body.update) {
updateResult = await cb.updateCritter(req.body.update);
}
if (req.body.create) {
createResult = await cb.createCritter(req.body.create);
}
await connection.commit();
return res.status(200).json({ ...createResult, ...updateResult });
} catch (error) {
defaultLog.error({ label: 'updateCritter', message: 'error', error });
await connection.rollback();
throw error;
} finally {
connection.release();
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('critter deployments', () => {
});

const mockDBConnection = getMockDBConnection({ release: sinon.stub() });
const mockSurveyEntry = 123;

describe('openapi schema', () => {
const ajv = new Ajv();
Expand All @@ -27,7 +26,7 @@ describe('critter deployments', () => {
describe('upsertDeployment', () => {
it('updates an existing deployment', async () => {
const mockGetDBConnection = sinon.stub(db, 'getDBConnection').returns(mockDBConnection);
const mockAddDeployment = sinon.stub(SurveyCritterService.prototype, 'upsertDeployment').resolves(1);
const mockAddDeployment = sinon.stub(SurveyCritterService.prototype, 'upsertDeployment').resolves();
const mockBctwService = sinon.stub(BctwService.prototype, 'updateDeployment');

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();
Expand All @@ -39,7 +38,6 @@ describe('critter deployments', () => {
expect(mockAddDeployment.calledOnce).to.be.true;
expect(mockBctwService.calledOnce).to.be.true;
expect(mockRes.status).to.have.been.calledWith(200);
expect(mockRes.json).to.have.been.calledWith(1);
});

it('catches and re-throws errors', async () => {
Expand All @@ -63,9 +61,7 @@ describe('critter deployments', () => {
describe('deployDevice', () => {
it('deploys a new telemetry device', async () => {
const mockGetDBConnection = sinon.stub(db, 'getDBConnection').returns(mockDBConnection);
const mockAddDeployment = sinon
.stub(SurveyCritterService.prototype, 'upsertDeployment')
.resolves(mockSurveyEntry);
const mockAddDeployment = sinon.stub(SurveyCritterService.prototype, 'upsertDeployment').resolves();
const mockBctwService = sinon.stub(BctwService.prototype, 'deployDevice');

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();
Expand All @@ -77,7 +73,6 @@ describe('critter deployments', () => {
expect(mockAddDeployment.calledOnce).to.be.true;
expect(mockBctwService.calledOnce).to.be.true;
expect(mockRes.status).to.have.been.calledWith(201);
expect(mockRes.json).to.have.been.calledWith(mockSurveyEntry);
});

it('catches and re-throws errors', async () => {
Expand Down
Loading