Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
TanyaStere42 committed Oct 26, 2023
2 parents dafa91f + de69801 commit a8ed741
Show file tree
Hide file tree
Showing 20 changed files with 594 additions and 404 deletions.
19 changes: 13 additions & 6 deletions locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"ASSIGN_ANNOTATIONS": "Assign annotations",
"ASSIGN_ANNOTATIONS_TO_INDIVIDUAL": "Assign annotations to individual",
"ASSIGN_ANNOTATIONS_TO_INDIVIDUAL_INSTRUCTIONS": "Verify that the annotations below should be assigned to this individual before proceeding.",
"ADD_ANNOTATIONS_TO_CLUSTER_TITLE": "Add annotations to animal",
"ADD_ANNOTATIONS_TO_CLUSTER_BUTTON": "Add annotations",
"ADD_ANNOTATIONS_TO_CLUSTER_TITLE": "Assign annotations to animal",
"ADD_ANNOTATIONS_TO_CLUSTER_BUTTON": "Assign annotations",
"SIGHTING_COMMIT_TITLE": "Ready to commit",
"REMOVE_FROM_CLUSTER": "Remove from animal",
"MOVE_ANNOTATION": "Move annotation",
Expand Down Expand Up @@ -765,8 +765,6 @@
"SERVER_STATUS_PAGE_TITLE": "Server Status",
"MATCH_ANNOTATIONS": "Match annotations",
"MATCH_REVIEW": "Match review",
"MARK_SIGHTING_REVIEWED": "Mark sighting reviewed",
"MARK_SIGHTING_REVIEWED_CONFIRMATION": "Are you sure you want to mark this sighting reviewed? This action cannot be undone.",
"MATCH_COUNT": "{matchCount} {matchCount, plural, =0 {matches} one {match} other {matches}}",
"PHOTO_COUNT": "{photoCount} {photoCount, plural, =0 {photographs} one {photograph} other {photographs}}",
"ENCOUNTERS_IMPORTED_COUNT": "{encounterCount} {encounterCount, plural, =0 {encounters} one {encounter} other {encounters}} imported.",
Expand Down Expand Up @@ -797,7 +795,7 @@
"ENCOUNTER_ID": "Encounter ID",
"RESTORE_DELETED_ENCOUNTER_INSTRUCTIONS": "The restored encounter will include all metadata, including the original date of submission.",
"RESTORE_ENCOUNTER": "Restore encounter",
"COPYRIGHT_LINE": "Copyright 2020 Wild Me for Whale Sharks",
"COPYRIGHT_LINE": "Copyright {year} Wild Me",
"LAST_SEEN_DATE": "Last seen on {date}",
"SHOW_FILTERS": "Show filters",
"SUCCESS": "Success",
Expand Down Expand Up @@ -1264,5 +1262,14 @@
"ENCOUNTER_SEX" : "Encounter sex",
"ENCOUNTER_SPECIES" : "Encounter species",
"LAST_REGION" : "Last region",
"LAST_FREEFORM" : "Last freeform"
"LAST_FREEFORM" : "Last freeform",
"UNREVIEWED" : "Unreviewed",
"REVIEWED" : "Reviewed",
"IN_PROGRESS" : "In progress",
"UNPROCESSED" : "Unprocessed",
"NO_MATCH_DESCRIPTION" : "Can't find any match for the sighting?",
"CONFIRM_NO_MATCH" : "Confirm no match",
"NUMBER_OF_INDIVIDUALS" : "Number of individuals",
"NUMBER_OF_ENCOUNTERS" : "Number of animals",
"ASSIGN" : "Assign"
}
32 changes: 18 additions & 14 deletions src/components/AuthenticatedAppHeader/ActionsPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const actions = [
{
id: 'bulk-import',
href: '/bulk-import',
permissionsTest: userData =>
userData?.is_admin ||
userData?.is_staff ||
userData?.is_researcher,
messageId: 'BULK_IMPORT',
icon: BulkImportIcon,
},
Expand Down Expand Up @@ -49,26 +53,26 @@ export default function NotificationsPane({
const name = get(userData, 'full_name') || 'Unnamed user';
const profileSrc = get(userData, ['profile_fileupload', 'src']);

const logout = async (event) => {
const logout = async event => {
event.preventDefault();
let is_authenticated = true;
await fetch('/api/v1/users/me')
.then(response => {
if(response.status == 401) {
is_authenticated = false;
}
})
.catch(error => {
console.log(error);
});
.then(response => {
if (response.status === 401) {
is_authenticated = false;
}
})
.catch(error => {
console.log(error);
});

if(is_authenticated) {
document.getElementById("logoutForm").submit();
}else {
window.location.href = '/';
if (is_authenticated) {
document.getElementById('logoutForm').submit();
} else {
window.location.href = '/';
}
setAnchorEl(null);
};
};

return (
<Popover
Expand Down
6 changes: 5 additions & 1 deletion src/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ export default function Footer({ authenticated = false }) {
justifyContent: 'center',
}}
>
<Text variant="caption" id="COPYRIGHT_LINE" />
<Text
variant="caption"
id="COPYRIGHT_LINE"
values={{ year: new Date().getFullYear() }}
/>
</div>
</div>
);
Expand Down
33 changes: 27 additions & 6 deletions src/components/dataDisplays/ElasticsearchSightingsDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default function ElasticsearchSightingsDisplay({
...rest
}) {
const title = `${dataCount || sightings.length} matching sightings`;
const tableData = sightings.map(sighting => {

const tableData = sightings.map(sighting =>
// const encounters = sighting?.encounters || [];
// const photoCount = encounters.reduce((memo, e) => {
// memo += e.images.length;
Expand All @@ -27,12 +27,12 @@ export default function ElasticsearchSightingsDisplay({
// return individual ? [...memo, individual] : null;
// }, []);

return {
({
...sighting,
// photoCount,
// individuals,
};
});
}),
);

const columns = [
{
Expand All @@ -50,6 +50,24 @@ export default function ElasticsearchSightingsDisplay({
sortable: true,
align: 'left',
},
{
name: 'numberIndividuals',
labelId: 'NUMBER_OF_INDIVIDUALS',
sortable: false,
align: 'left',
},
{
name: 'numberEncounters',
labelId: 'NUMBER_OF_ENCOUNTERS',
sortable: false,
align: 'left',
},
{
name: 'verbatimLocality',
labelId: 'FREEFORM_LOCATION',
sortable: false,
align: 'left',
},
{
name: 'owners',
sortName: 'owners.full_name',
Expand All @@ -58,6 +76,7 @@ export default function ElasticsearchSightingsDisplay({
align: 'left',
options: {
customBodyRender: owners => {
// eslint-disable-line
const ownerName = get(
owners,
[0, 'full_name'],
Expand All @@ -81,7 +100,9 @@ export default function ElasticsearchSightingsDisplay({
labelId: 'ACTIONS',
sortable: false,
options: {
customBodyRender: guid => (
customBodyRender: (
guid, // eslint-disable-line
) => (
<ActionIcon
labelId="VIEW"
variant="view"
Expand Down
83 changes: 83 additions & 0 deletions src/components/dialogs/ReviewSighting.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react';
import useReviewSighting from '../../models/sighting/useReviewSighting';
import Text from '../Text';
import Alert from '../Alert';
import ButtonMenu from '../ButtonMenu';

export default function ReviewSighting({
sightingGuid,
matchStatus,
}) {
const {
mutate: reviewSighting,
error,
clearError,
} = useReviewSighting();

const sendRequest = async status => {
const operations = [
{
op: 'replace',
path: '/match_state',
value: status,
},
];
await reviewSighting({ sightingGuid, operations });
};

const buttonActions = [
{
id: 'mark-sighting-unreviewed',
labelId: 'UNREVIEWED',
onClick: async () => {
sendRequest('unreviewed');
},
},
{
id: 'mark-sighting-in-progress',
labelId: 'IN_PROGRESS',
onClick: async () => {
sendRequest('in_progress');
},
},
{
id: 'mark-sighting-reviewed',
labelId: 'REVIEWED',
onClick: async () => {
sendRequest('reviewed');
},
},
{
id: 'mark-sighting-unidentifiable',
labelId: 'UNIDENTIFIABLE',
onClick: async () => {
sendRequest('unidentifiable');
},
},
];

return (
<div
style={{ display: 'flex', alignItems: 'center', marginTop: 20 }}
>
<Text id="STATUS" />
<ButtonMenu
display="secondary"
buttonId="match-actions"
style={{ marginLeft: 24 }}
actions={buttonActions}
id={matchStatus?.toUpperCase() || 'UNPROCESSED'}
disabled={!matchStatus}
/>
{error && (
<Alert
severity="error"
onClose={clearError}
style={{ margin: '16px 16px', maxWidth: 400 }}
>
{error}
</Alert>
)}
</div>
);
}
65 changes: 0 additions & 65 deletions src/components/dialogs/ReviewSightingDialog.jsx

This file was deleted.

8 changes: 4 additions & 4 deletions src/models/sighting/useReviewSighting.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { usePost } from '../../hooks/useMutate';
import { getSightingQueryKey } from '../../constants/queryKeys';
import { usePatch } from '../../hooks/useMutate';

export default function useReviewSighting() {
return usePost({
deriveUrl: ({ sightingGuid }) =>
`/sightings/${sightingGuid}/reviewed`,
return usePatch({
deriveUrl: ({ sightingGuid }) => `/sightings/${sightingGuid}`,
deriveData: ({ operations }) => operations,
deriveFetchKeys: ({ sightingGuid }) => [
getSightingQueryKey(sightingGuid),
],
Expand Down
9 changes: 9 additions & 0 deletions src/models/sighting/useSightingSearchSchemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ export default function useSightingSearchSchemas() {
queryTerm: 'numberAnnotations',
},
},
{
id: 'numberIndividuals',
labelId: 'NUMBER_OF_INDIVIDUALS',
FilterComponent: IntegerFilter,
filterComponentProps: {
filterId: 'numberIndividuals',
queryTerm: 'numberIndividuals',
},
},
{
id: 'stage',
labelId: 'SIGHTING_STATE',
Expand Down
Loading

0 comments on commit a8ed741

Please sign in to comment.