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

Release dev-staging changes to dev #1131

Merged
merged 36 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
72a0bf4
SIMSBIOHUB-226: Survey Prototyping + Observation Map View (#1116)
curtisupshall Oct 18, 2023
0302baf
Merge branch 'dev' into dev-staging
curtisupshall Oct 18, 2023
6362e8e
UI Fixes
jeznorth Oct 19, 2023
9cba403
Merge branch 'dev' into dev-staging
curtisupshall Oct 19, 2023
4a4d742
Fix issues
NickPhura Oct 19, 2023
27cd7c3
Merge branch 'dev' into dev-staging
curtisupshall Oct 19, 2023
1c31751
Merge branch 'dev-staging' of github.com:bcgov/biohubbc into dev-staging
curtisupshall Oct 19, 2023
336a266
Fix pipeline route issues
NickPhura Oct 20, 2023
58616cd
Fix non-unique key issue
NickPhura Oct 20, 2023
04d2912
Merge branch 'dev' into dev-staging
NickPhura Oct 23, 2023
0b116a7
SIMSBIOHUB-258 (#1134)
jeznorth Oct 23, 2023
e627df7
SIMSBIOHUB-296/313: Import Observations (#1128)
curtisupshall Oct 24, 2023
3199784
SIMSBIOHUB-177: Survey Study Area enhancements (#1136)
al-rosenthal Oct 25, 2023
3b1400a
Merge branch 'dev' into dev-staging
NickPhura Oct 25, 2023
f6389df
SIMSBIOHUB-336/337 (#1142)
JeremyQuartech Oct 26, 2023
6b965b9
SIMSBIOHUB 343 - Incorrect date overlap error in sampling methods (#1…
GrahamS-Quartech Oct 26, 2023
9143004
SIMSBIOHUB-334/350/352 (#1143)
curtisupshall Oct 27, 2023
e5158d6
SIMSBIOHUB-323: Remove Ecological Season (#1153)
JeremyQuartech Oct 31, 2023
ac199ba
SIMSBIOHUB 347/341 - Names from shapefiles (#1146)
GrahamS-Quartech Oct 31, 2023
0b52d4c
TechDebt: Map container refactor (#1148)
al-rosenthal Oct 31, 2023
7cb5142
SIMSBIOHUB-353/325: Survey form updates (#1149)
al-rosenthal Oct 31, 2023
a284963
SIMSBIOHUB-342: Delete Sampling Site (#1147)
KjartanE Oct 31, 2023
6c568a2
SIMSBIOHUB 324 - Multiple Ecological Variables (Intended Outcomes) (#…
GrahamS-Quartech Nov 1, 2023
d71b919
SIMSBIOHUB 335: Tab Through Observation Edit (#1156)
GrahamS-Quartech Nov 1, 2023
18a5f28
SIMSBIOHUB-356: Update survey list endpoint to return a subset of sur…
NickPhura Nov 1, 2023
2876f50
SIMSBIOHUB-331: Keycloak Library Updates (#1151)
NickPhura Nov 2, 2023
4051da8
SIMSBIOHUB-354-355: Study area and Sampling sites on observations map…
al-rosenthal Nov 3, 2023
a359ed2
SIMSBIOHUB-348: Delete single or many observation records (#1154)
curtisupshall Nov 3, 2023
ec677ac
SIMSBIOHUB-363: Import Survey Area Name and Description from Shapefil…
GrahamS-Quartech Nov 6, 2023
5468433
SIMSBIOHUB-334 UI Fixes (#1164)
jeznorth Nov 7, 2023
14608a6
SIMSBIOHUB-297: Keycloak Value Case Sensitivity (#1166)
JeremyQuartech Nov 7, 2023
a02df6f
SIMSBIOHUB-345: Display Time in Sampling Periods (#1167)
KjartanE Nov 8, 2023
004f66a
SIMSBIOHUB-371: Update Seed to Create Sampling Site and Observation R…
GrahamS-Quartech Nov 8, 2023
0c558c1
SIMSBIOHUB-344: Tech debt: Observation Table Species display (#1160)
curtisupshall Nov 9, 2023
1d929e7
SIMSBIOHUB-361: Remove all study areas button (#1163)
al-rosenthal Nov 9, 2023
cd8e3e0
ignore-skip
NickPhura Nov 9, 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
16 changes: 2 additions & 14 deletions api/src/paths/funding-sources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FundingSource, FundingSourceSupplementaryData } from '../../repositorie
import { SystemUser } from '../../repositories/user-repository';
import { authorizeRequestHandler } from '../../request-handlers/security/authorization';
import { FundingSourceService, IFundingSourceSearchParams } from '../../services/funding-source-service';
import { UserService } from '../../services/user-service';
import { getLogger } from '../../utils/logger';

const defaultLog = getLogger('paths/funding-sources/index');
Expand Down Expand Up @@ -121,7 +122,7 @@ export function getFundingSources(): RequestHandler {
await connection.commit();

const systemUserObject: SystemUser = req['system_user'];
if (!isAdmin(systemUserObject)) {
if (!UserService.isAdmin(systemUserObject)) {
// User is not an admin, strip sensitive fields from response
response = removeNonAdminFieldsFromFundingSourcesResponse(response);
}
Expand All @@ -137,19 +138,6 @@ export function getFundingSources(): RequestHandler {
};
}

/**
* Checks if the system user is an admin (has an admin level system role).
*
* @param {SystemUser} systemUserObject
* @return {*} {boolean} `true` if the user is an admin, `false` otherwise.
*/
function isAdmin(systemUserObject: SystemUser): boolean {
return (
systemUserObject.role_names.includes(SYSTEM_ROLE.SYSTEM_ADMIN) ||
systemUserObject.role_names.includes(SYSTEM_ROLE.DATA_ADMINISTRATOR)
);
}

/**
* Removes sensitive (admin-only) fields from the funding sources response, returning a new sanitized array.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getDBConnection } from '../../../../../database/db';
import { SystemUser } from '../../../../../repositories/user-repository';
import { authorizeRequestHandler } from '../../../../../request-handlers/security/authorization';
import { AttachmentService } from '../../../../../services/attachment-service';
import { UserService } from '../../../../../services/user-service';
import { getLogger } from '../../../../../utils/logger';
import { attachmentApiDocObject } from '../../../../../utils/shared-api-docs';

Expand Down Expand Up @@ -104,15 +105,12 @@ export function deleteAttachment(): RequestHandler {
const attachmentService = new AttachmentService(connection);

const systemUserObject: SystemUser = req['system_user'];
const isAdmin =
systemUserObject.role_names.includes(SYSTEM_ROLE.SYSTEM_ADMIN) ||
systemUserObject.role_names.includes(SYSTEM_ROLE.DATA_ADMINISTRATOR);

await attachmentService.handleDeleteProjectAttachment(
Number(req.params.projectId),
Number(req.params.attachmentId),
req.body.attachmentType,
isAdmin
UserService.isAdmin(systemUserObject)
);

await connection.commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getDBConnection } from '../../../../../../../database/db';
import { SystemUser } from '../../../../../../../repositories/user-repository';
import { authorizeRequestHandler } from '../../../../../../../request-handlers/security/authorization';
import { AttachmentService } from '../../../../../../../services/attachment-service';
import { UserService } from '../../../../../../../services/user-service';
import { getLogger } from '../../../../../../../utils/logger';
import { attachmentApiDocObject } from '../../../../../../../utils/shared-api-docs';

Expand Down Expand Up @@ -110,15 +111,12 @@ export function deleteAttachment(): RequestHandler {
const attachmentService = new AttachmentService(connection);

const systemUserObject: SystemUser = req['system_user'];
const isAdmin =
systemUserObject.role_names.includes(SYSTEM_ROLE.SYSTEM_ADMIN) ||
systemUserObject.role_names.includes(SYSTEM_ROLE.DATA_ADMINISTRATOR);

await attachmentService.handleDeleteSurveyAttachment(
Number(req.params.surveyId),
Number(req.params.attachmentId),
req.body.attachmentType,
isAdmin
UserService.isAdmin(systemUserObject)
);

await connection.commit();
Expand Down
14 changes: 14 additions & 0 deletions api/src/services/user-service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SYSTEM_ROLE } from '../constants/roles';
import { IDBConnection } from '../database/db';
import { ApiExecuteSQLError } from '../errors/api-error';
import { SystemUser, UserRepository, UserSearchCriteria } from '../repositories/user-repository';
Expand All @@ -15,6 +16,19 @@ export class UserService extends DBService {
this.userRepository = new UserRepository(connection);
}

/**
* Checks if the given system user is an admin (has an admin level system role).
*
* @param {SystemUser} systemUser
* @return {*} {boolean} `true` if the user is an admin, `false` otherwise.
*/
static isAdmin(systemUser: SystemUser): boolean {
return (
systemUser.role_names.includes(SYSTEM_ROLE.SYSTEM_ADMIN) ||
systemUser.role_names.includes(SYSTEM_ROLE.DATA_ADMINISTRATOR)
);
}

/**
* Fetch a single system user by their system user ID.
*
Expand Down
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@turf/boolean-equal": "~6.3.0",
"@turf/center-of-mass": "~6.5.0",
"@turf/centroid": "~6.4.0",
"@turf/turf": "^6.5.0",
"axios": "~0.21.4",
"clsx": "~1.2.1",
"express": "~4.17.1",
Expand Down
76 changes: 21 additions & 55 deletions app/src/components/boundary/InferredLocationDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
import { Theme } from '@mui/material';
import Box from '@mui/material/Box';
import { grey } from '@mui/material/colors';
import Divider from '@mui/material/Divider';
import Typography from '@mui/material/Typography';
import { makeStyles } from '@mui/styles';
import React from 'react';

const useStyles = makeStyles((theme: Theme) => ({
boundaryGroup: {
clear: 'both',
overflow: 'hidden',
'&:first-child': {
marginTop: 0
}
},
boundaryList: {
margin: 0,
padding: 0,
listStyleType: 'none',
'& li': {
display: 'inline-block',
float: 'left'
},
'& li + li': {
marginLeft: theme.spacing(1)
}
},
metaSectionHeader: {
color: grey[600],
fontWeight: 700,
textTransform: 'uppercase',
'& + hr': {
marginTop: theme.spacing(0.75),
marginBottom: theme.spacing(0.75)
}
}
}));

export interface IInferredLayers {
parks: string[];
Expand All @@ -48,30 +12,32 @@
layers: IInferredLayers;
}

const InferredLocationDetails: React.FC<IInferredLocationDetailsProps> = (props) => {
const classes = useStyles();
const displayInferredLayersInfo = (data: any[], type: string) => {
if (!data.length) {
const InferredLocationDetails = (props: IInferredLocationDetailsProps) => {
const displayInferredLayersInfo = (layerNames: string[], type: string) => {
if (!layerNames.length) {
return;
}

return (
<>
<Box className={classes.boundaryGroup} mt={3}>
<Typography variant="body2" component="h3" className={classes.metaSectionHeader}>
{type} ({data.length})
</Typography>
<Divider></Divider>
<Box component="ul" className={classes.boundaryList}>
{data.map((item: string, index: number) => (
<Typography key={index} variant="body1" component="li">
{item}
{index < data.length - 1 && ', '}
</Typography>
))}
</Box>
<Box className="row">
<Typography component="dt">
{type} ({layerNames.length})
</Typography>
<Box>
{layerNames.map((name: string, index: number) => (
<Typography

Check warning on line 28 in app/src/components/boundary/InferredLocationDetails.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/boundary/InferredLocationDetails.tsx#L28

Added line #L28 was not covered by tests
key={name}
component="dd"
sx={{
display: 'inline-block',
mr: '5px'
}}>
{name}
{index < layerNames.length - 1 && ', '}
</Typography>
))}
</Box>
</>
</Box>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { mdiMagnify } from '@mdi/js';
import Icon from '@mdi/react';
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
import Box from '@mui/material/Box';
import CircularProgress from '@mui/material/CircularProgress';
Expand Down Expand Up @@ -170,16 +168,11 @@ const AsyncAutocompleteDataGridEditCell = <DataGridType extends GridValidRowMode
renderInput={(params) => (
<TextField
{...params}
size="small"
variant="outlined"
placeholder={'Type to search...'}
fullWidth
InputProps={{
...params.InputProps,
startAdornment: (
<Box mt="6px">
<Icon path={mdiMagnify} size={1}></Icon>
</Box>
),
endAdornment: (
<>
{isLoading ? <CircularProgress color="inherit" size={20} /> : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ const AutocompleteDataGridEditCell = <DataGridType extends GridValidRowModel, Va
renderInput={(params) => (
<TextField
{...params}
size="small"
variant="outlined"
placeholder={'Type to filter...'}
fullWidth
InputProps={{
...params.InputProps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Typography from '@mui/material/Typography';
import { GridRenderCellParams, GridValidRowModel } from '@mui/x-data-grid';
import { IAutocompleteDataGridOption } from 'components/data-grid/autocomplete/AutocompleteDataGrid.interface';

Expand Down Expand Up @@ -33,7 +34,14 @@
props: IAutocompleteDataGridViewCellProps<DataGridType, ValueType>
) => {
const { dataGridProps, options } = props;
return <>{options.find((item) => item.value === dataGridProps.value)?.label ?? ''}</>;
return (

Check warning on line 37 in app/src/components/data-grid/autocomplete/AutocompleteDataGridViewCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/autocomplete/AutocompleteDataGridViewCell.tsx#L37

Added line #L37 was not covered by tests
<Typography
variant="body2"
component="div"
sx={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
{options.find((item) => item.value === dataGridProps.value)?.label ?? ''}
</Typography>
);
};

export default AutocompleteDataGridViewCell;
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,17 @@
const getCurrentOption = async (
speciesId: string | number
): Promise<IAutocompleteDataGridOption<ValueType> | null> => {
const response = await biohubApi.taxonomy.getSpeciesFromIds([Number(speciesId)]);
if (!speciesId) {
return null;

Check warning on line 31 in app/src/components/data-grid/taxonomy/TaxonomyDataGridEditCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridEditCell.tsx#L31

Added line #L31 was not covered by tests
}

const id = Number(speciesId);

Check warning on line 34 in app/src/components/data-grid/taxonomy/TaxonomyDataGridEditCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridEditCell.tsx#L34

Added line #L34 was not covered by tests

if (isNaN(id)) {
return null;

Check warning on line 37 in app/src/components/data-grid/taxonomy/TaxonomyDataGridEditCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridEditCell.tsx#L37

Added line #L37 was not covered by tests
}

const response = await biohubApi.taxonomy.getSpeciesFromIds([id]);

Check warning on line 40 in app/src/components/data-grid/taxonomy/TaxonomyDataGridEditCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridEditCell.tsx#L40

Added line #L40 was not covered by tests

if (response.searchResponse.length !== 1) {
return null;
Expand All @@ -43,6 +53,11 @@
searchTerm: string,
onSearchResults: (searchedValues: IAutocompleteDataGridOption<ValueType>[]) => void
) => {
if (!searchTerm) {
onSearchResults([]);
return;

Check warning on line 58 in app/src/components/data-grid/taxonomy/TaxonomyDataGridEditCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridEditCell.tsx#L57-L58

Added lines #L57 - L58 were not covered by tests
}

const response = await biohubApi.taxonomy.searchSpecies(searchTerm);
const options = response.searchResponse.map((item) => ({
value: parseInt(item.id) as ValueType,
Expand Down
24 changes: 22 additions & 2 deletions app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Typography from '@mui/material/Typography';
import { GridRenderCellParams, GridValidRowModel } from '@mui/x-data-grid';
import { useBiohubApi } from 'hooks/useBioHubApi';
import useDataLoader from 'hooks/useDataLoader';
Expand All @@ -20,7 +21,19 @@

const biohubApi = useBiohubApi();

const taxonomyDataLoader = useDataLoader(() => biohubApi.taxonomy.getSpeciesFromIds([Number(dataGridProps.value)]));
const taxonomyDataLoader = useDataLoader(async () => {

Check warning on line 24 in app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx#L24

Added line #L24 was not covered by tests
if (!dataGridProps.value) {
return { searchResponse: [] };

Check warning on line 26 in app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx#L26

Added line #L26 was not covered by tests
}

const id = Number(dataGridProps.value);

Check warning on line 29 in app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx#L29

Added line #L29 was not covered by tests

if (isNaN(id)) {
return { searchResponse: [] };

Check warning on line 32 in app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx#L32

Added line #L32 was not covered by tests
}

return biohubApi.taxonomy.getSpeciesFromIds([Number(dataGridProps.value)]);

Check warning on line 35 in app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx#L35

Added line #L35 was not covered by tests
});

taxonomyDataLoader.load();

Expand All @@ -32,7 +45,14 @@
return null;
}

return <>{taxonomyDataLoader.data?.searchResponse[0].label}</>;
return (

Check warning on line 48 in app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/data-grid/taxonomy/TaxonomyDataGridViewCell.tsx#L48

Added line #L48 was not covered by tests
<Typography
variant="body2"
component="div"
sx={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
{taxonomyDataLoader.data?.searchResponse[0].label}
</Typography>
);
};

export default TaxonomyDataGridViewCell;
21 changes: 14 additions & 7 deletions app/src/components/map/MapContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { layerContentHandlers } from 'components/map/wfs-utils';
import { Feature } from 'geojson';
import { useBiohubApi } from 'hooks/useBioHubApi';
import L, { LatLngBoundsExpression, LeafletEventHandlerFnMap } from 'leaflet';
import L, { LatLng, LatLngBoundsExpression, LeafletEventHandlerFnMap } from 'leaflet';
import 'leaflet-fullscreen/dist/leaflet.fullscreen.css';
import 'leaflet-fullscreen/dist/Leaflet.fullscreen.js';
import iconRetina from 'leaflet/dist/images/marker-icon-2x.png';
Expand All @@ -24,6 +24,10 @@
import StaticLayers, { IStaticLayer } from './components/StaticLayers';
import WFSFeatureGroup from './WFSFeatureGroup';

const point = (feature: Feature, latlng: LatLng) => {
return new L.CircleMarker(latlng, { radius: 6, fillOpacity: 1, fillColor: '#006edc', color: '#ffffff', weight: 1 });

Check warning on line 28 in app/src/components/map/MapContainer.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/components/map/MapContainer.tsx#L28

Added line #L28 was not covered by tests
};

/*
Get leaflet icons working
*/
Expand Down Expand Up @@ -60,6 +64,7 @@
additionalLayers?: IAdditionalLayers;
clusteredPointGeometries?: IClusteredPointGeometries[];
confirmDeletion?: boolean;
hideLayerControls?: boolean;
setInferredLayersInfo?: (inferredLayersInfo: any) => void;
onBoundsChange?: IMapBoundsOnChange;
onDrawChange?: IDrawControlsOnChange;
Expand Down Expand Up @@ -197,7 +202,7 @@
)}

{nonEditableGeometries?.map((nonEditableGeo: INonEditableGeometries) => (
<GeoJSON key={uuidv4()} data={nonEditableGeo.feature}>
<GeoJSON key={uuidv4()} data={nonEditableGeo.feature} pointToLayer={point}>
{nonEditableGeo.popupComponent}
</GeoJSON>
))}
Expand All @@ -215,13 +220,15 @@

{additionalLayers && <AdditionalLayers layers={additionalLayers} />}

<LayersControl position="bottomright">
<StaticLayers layers={staticLayers} />
{props.hideLayerControls !== true && (
<LayersControl position="bottomright">
<StaticLayers layers={staticLayers} />

<MarkerCluster layers={markerLayers} />
<MarkerCluster layers={markerLayers} />

<BaseLayerControls />
</LayersControl>
<BaseLayerControls />
</LayersControl>
)}
</LeafletMapContainer>
);
};
Expand Down
Loading