Skip to content

Commit

Permalink
Merge branch 'main' into combine_bump_express_and_dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
erinz2020 authored Jan 2, 2025
2 parents 3ef7ee2 + 1f2ca68 commit 94ff934
Show file tree
Hide file tree
Showing 49 changed files with 734 additions and 132 deletions.
5 changes: 5 additions & 0 deletions config/indices.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
-- UGH, i guess _IDX (in caps!) should be what we standardize on. that is what datanucleus does.
-- to make matters worse, we have some places we named them explicitely in package.jdo (but those should fix themselves?)

BEGIN;

CREATE INDEX IF NOT EXISTS "MEDIAASSET_PARENTID_idx" ON "MEDIAASSET" ("PARENTID");
CREATE INDEX IF NOT EXISTS "MEDIAASSET_HASHCODE_idx" ON "MEDIAASSET" ("HASHCODE");

CREATE INDEX IF NOT EXISTS "ENCOUNTER_LOCATIONID_idx" ON "ENCOUNTER" ("LOCATIONID");
CREATE INDEX IF NOT EXISTS "ENCOUNTER_STATE_idx" ON "ENCOUNTER" ("STATE");
CREATE INDEX IF NOT EXISTS "ENCOUNTER_MODIFIED_idx" ON "ENCOUNTER" ("MODIFIED");
CREATE INDEX IF NOT EXISTS "ENCOUNTER_INDIVIDUALID_idx" ON "ENCOUNTER" ("INDIVIDUALID");
CREATE INDEX IF NOT EXISTS "ENCOUNTER_DATEINMILLISECONDS_idx" ON "ENCOUNTER" ("DATEINMILLISECONDS");
CREATE INDEX IF NOT EXISTS "ENCOUNTER_DECIMALLATITUDE_idx" ON "ENCOUNTER" ("DECIMALLATITUDE");
Expand Down Expand Up @@ -45,3 +48,5 @@ CREATE INDEX IF NOT EXISTS "TASK_CREATED_IDX" ON "TASK" ("CREATED");

INSERT INTO "RELATIONSHIP" ("RELATIONSHIP_ID", "MARKEDINDIVIDUALNAME1", "MARKEDINDIVIDUALNAME2", "MARKEDINDIVIDUALROLE1", "MARKEDINDIVIDUALROLE2", "TYPE", "STARTTIME", "ENDTIME") VALUES (0, (SELECT "INDIVIDUALID" FROM "MARKEDINDIVIDUAL" ORDER BY random() LIMIT 1), (SELECT "INDIVIDUALID" FROM "MARKEDINDIVIDUAL" ORDER BY random() LIMIT 1), 'placeholder', 'placeholder', 'placeholder-to-prevent-empty-table', 0, 0);

END;

2 changes: 2 additions & 0 deletions frontend/src/AuthenticatedSwitch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function AuthenticatedSwitch({
showAlert,
setShowAlert,
showclassicsubmit,
showClassicEncounterSearch,
}) {
const { data } = useGetMe();
const username = data?.username;
Expand All @@ -44,6 +45,7 @@ export default function AuthenticatedSwitch({
showAlert={showAlert}
setShowAlert={setShowAlert}
showclassicsubmit={showclassicsubmit}
showClassicEncounterSearch={showClassicEncounterSearch}
/>
</div>

Expand Down
5 changes: 4 additions & 1 deletion frontend/src/FrontDesk.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import {
sessionCountdownTime,
} from "./constants/sessionWarning";
import useGetSiteSettings from "./models/useGetSiteSettings";
import useDocumentTitle from "./hooks/useDocumentTitle";

export default function FrontDesk() {
useDocumentTitle();
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [collaborationTitle, setCollaborationTitle] = useState();
const [collaborationData, setCollaborationData] = useState([]);
Expand All @@ -28,7 +30,7 @@ export default function FrontDesk() {
const [loading, setLoading] = useState(true);
const { data } = useGetSiteSettings();
const showclassicsubmit = data?.showClassicSubmit;

const showClassicEncounterSearch = data?.showClassicEncounters;
const checkLoginStatus = () => {
axios
.head("/api/v3/user")
Expand Down Expand Up @@ -93,6 +95,7 @@ export default function FrontDesk() {
showAlert={showAlert}
setShowAlert={setShowAlert}
showclassicsubmit={showclassicsubmit}
showClassicEncounterSearch={showClassicEncounterSearch}
/>
</AuthContext.Provider>
);
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/AuthenticatedAppHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function AuthenticatedAppHeader({
username,
avatar,
showclassicsubmit,
showClassicEncounterSearch,
}) {
const { visible } = useContext(FooterVisibilityContext);

Expand Down Expand Up @@ -74,6 +75,7 @@ export default function AuthenticatedAppHeader({
<Menu
username={username}
showclassicsubmit={showclassicsubmit}
showClassicEncounterSearch={showClassicEncounterSearch}
/>
</Nav>
<NotificationButton
Expand Down
44 changes: 23 additions & 21 deletions frontend/src/components/DataTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,6 @@ const customStyles = {
},
};

const conditionalRowStyles = (theme) => [
{
when: (row) => row.tableID % 2 === 0,
style: {
backgroundColor: "#ffffff", // Light gray color
"&:hover": {
backgroundColor: theme?.primaryColors?.primary300 || "#e0f7fa",
},
},
},
{
when: (row) => row.tableID % 2 !== 0,
style: {
backgroundColor: "#f2f2f2", // White color
"&:hover": {
backgroundColor: theme?.primaryColors?.primary300 || "#e0f7fa",
},
},
},
];

const MyDataTable = ({
title = "",
columnNames = [],
Expand All @@ -52,6 +31,7 @@ const MyDataTable = ({
style = {},
tabs = [],
isLoading = false,
extraStyles = [],
onSelectedRowsChange = () => {},
onRowClicked = () => {},
}) => {
Expand All @@ -61,6 +41,28 @@ const MyDataTable = ({
const perPageOptions = [10, 20, 30, 40, 50];
const intl = useIntl();

const conditionalRowStyles = (theme) =>
[
{
when: (row) => row.tableID % 2 === 0,
style: {
backgroundColor: "#ffffff", // Light gray color
"&:hover": {
backgroundColor: theme?.primaryColors?.primary300 || "#e0f7fa",
},
},
},
{
when: (row) => row.tableID % 2 !== 0,
style: {
backgroundColor: "#f2f2f2", // White color
"&:hover": {
backgroundColor: theme?.primaryColors?.primary300 || "#e0f7fa",
},
},
},
].concat(extraStyles);

const wrappedColumns = useMemo(
() =>
columnNames.map((col) => {
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/components/header/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import DownIcon from "../svg/DownIcon";
import RightIcon from "../svg/RightIcon";
import { authenticatedMenu } from "../../constants/navMenu";

export default function Menu({ username, showclassicsubmit }) {
export default function Menu({
username,
showclassicsubmit,
showClassicEncounterSearch,
}) {
const [dropdownColor, setDropdownColor] = useState("transparent");

const [dropdownShows, setDropdownShows] = useState({});
Expand All @@ -21,7 +25,11 @@ export default function Menu({ username, showclassicsubmit }) {

return (
<>
{authenticatedMenu(username, showclassicsubmit).map((item, idx) => (
{authenticatedMenu(
username,
showclassicsubmit,
showClassicEncounterSearch,
).map((item, idx) => (
<Nav className="me-auto" key={idx}>
<NavDropdown
className="header-dropdown"
Expand Down
19 changes: 18 additions & 1 deletion frontend/src/constants/navMenu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from "react";
import { FormattedMessage } from "react-intl";

const authenticatedMenu = (username, showclassicsubmit) => [
const authenticatedMenu = (
username,
showclassicsubmit,
showClassicEncounterSearch,
) => [
{
Submit: [
{
Expand Down Expand Up @@ -169,6 +173,19 @@ const authenticatedMenu = (username, showclassicsubmit) => [
),
href: `${process.env.PUBLIC_URL}/encounter-search`,
},
...(showClassicEncounterSearch
? [
{
name: (
<FormattedMessage
id="MENU_SEARCH_ENCOUNTERS_CLASSIC"
defaultMessage="Encounters (Classic)"
/>
),
href: "/encounters/encounterSearch.jsp",
},
]
: []),
{
name: (
<FormattedMessage
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"MENU_LEARN_MYBULKIMPORTS": "Meine Bulk-Importe",
"MENU_LEARN_MYPROJECTS": "Meine Projekte",
"MENU_SEARCH_ENCOUNTERS": "Begegnungen",
"MENU_SEARCH_ENCOUNTERS_CLASSIC": "Begegnungssuche (Klassisch)",
"MENU_SEARCH_INDIVIDUALS": "Individuen",
"MENU_SEARCH_SIGHTINGS": "Sichtungen",
"MENU_ANIMALS_INDIVIDUALGALLERY": "Individuelle Galerie",
Expand Down Expand Up @@ -315,6 +316,7 @@
"INVALID_LAT": "Der Breitengrad muss zwischen -90 und 90 liegen",
"INVALID_LONG": "Der Längengrad muss zwischen -180 und 180 liegen",
"BEERROR_REQUIRED" : "Konnte nicht übermittelt werden; erforderliches Feld fehlt: ",
"SUBMISSION_FAILED": "Einreichung fehlgeschlagen",
"BEERROR_INVALID" : "Konnte nicht übermittelt werden; Feldformat war ungültig: ",
"BEERROR_UNKNOWN" : "Konnte aufgrund eines unbekannten Fehlers nicht abgeschickt werden.",
"ANON_UPLOAD_IMAGE_WARNING": "Bilder können erst hochgeladen werden, wenn das Captcha abgeschlossen ist.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"MENU_LEARN_MYBULKIMPORTS": "My Bulk Imports",
"MENU_LEARN_MYPROJECTS": "My Projects",
"MENU_SEARCH_ENCOUNTERS": "Encounters",
"MENU_SEARCH_ENCOUNTERS_CLASSIC": "Encounter Search (Classic)",
"MENU_SEARCH_INDIVIDUALS": "Individuals",
"MENU_SEARCH_SIGHTINGS": "Sightings",
"MENU_ANIMALS_INDIVIDUALGALLERY": "Individual Gallery",
Expand Down Expand Up @@ -315,6 +316,7 @@
"INVALID_LAT": "Latitude must be between -90 and 90",
"INVALID_LONG": "Longitude must be between -180 and 180",
"BEERROR_REQUIRED" : "Could not submit; missing required field: ",
"SUBMISSION_FAILED" : "Submission Failed",
"BEERROR_INVALID" : "Could not submit; field format was invalid: ",
"BEERROR_UNKNOWN" : "Could not submit due to unknown error.",
"ANON_UPLOAD_IMAGE_WARNING": "Images cannot be uploaded until captcha is complete.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/locale/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"MENU_LEARN_MYBULKIMPORTS": "Mis importaciones masivas",
"MENU_LEARN_MYPROJECTS": "Mis proyectos",
"MENU_SEARCH_ENCOUNTERS": "Encuentros",
"MENU_SEARCH_ENCOUNTERS_CLASSIC": "Búsqueda de Encuentros (Clásico)",
"MENU_SEARCH_INDIVIDUALS": "Individuos",
"MENU_SEARCH_SIGHTINGS": "Avistamientos",
"MENU_ANIMALS_INDIVIDUALGALLERY": "Galería de individuos",
Expand Down Expand Up @@ -314,6 +315,7 @@
"INVALID_LAT": "La latitud debe estar entre -90 y 90",
"INVALID_LONG": "La longitud debe estar entre -180 y 180",
"BEERROR_REQUIRED" : "No se ha podido enviar; falta el campo obligatorio: ",
"SUBMISSION_FAILED" : "No se pudo enviar; inténtalo de nuevo.",
"BEERROR_INVALID" : "No se pudo enviar; el formato del campo no era válido: ",
"BEERROR_UNKNOWN" : "No se pudo enviar debido a un error desconocido.",
"ANON_UPLOAD_IMAGE_WARNING": "No se pueden subir imágenes hasta que se complete el captcha.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"MENU_LEARN_MYBULKIMPORTS": "Mes importations en masse",
"MENU_LEARN_MYPROJECTS": "Mes projets",
"MENU_SEARCH_ENCOUNTERS": "Rencontres",
"MENU_SEARCH_ENCOUNTERS_CLASSIC": "Recherche de Rencontres (Classique)",
"MENU_SEARCH_INDIVIDUALS": "Individus",
"MENU_SEARCH_SIGHTINGS": "Observations",
"MENU_ANIMALS_INDIVIDUALGALLERY": "Galerie individuelle",
Expand Down Expand Up @@ -314,6 +315,7 @@
"INVALID_LAT": "La latitude doit être comprise entre -90 et 90",
"INVALID_LONG": "La longitude doit être comprise entre -180 et 180",
"BEERROR_REQUIRED" : "Impossible de soumettre ; champ requis manquant : ",
"SUBMISSION_FAILED": "Échec de la soumission",
"BEERROR_INVALID" : "Impossible de soumettre ; le format du champ n'est pas valide : ",
"BEERROR_UNKNOWN" : "Impossible de soumettre en raison d'une erreur inconnue.",
"ANON_UPLOAD_IMAGE_WARNING": "Les images ne peuvent pas être téléchargées tant que le captcha n'est pas complété.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/locale/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"MENU_LEARN_MYBULKIMPORTS": "Le mie importazioni in massa",
"MENU_LEARN_MYPROJECTS": "I miei progetti",
"MENU_SEARCH_ENCOUNTERS": "Incontri",
"MENU_SEARCH_ENCOUNTERS_CLASSIC": "Ricerca di Incontri (Classico)",
"MENU_SEARCH_INDIVIDUALS": "Individui",
"MENU_SEARCH_SIGHTINGS": "Avvistamenti",
"MENU_ANIMALS_INDIVIDUALGALLERY": "Galleria individuale",
Expand Down Expand Up @@ -314,6 +315,7 @@
"INVALID_LAT": "La latitudine deve essere compresa tra -90 e 90",
"INVALID_LONG": "La longitudine deve essere compresa tra -180 e 180",
"BEERROR_REQUIRED" : "Impossibile inviare; manca un campo obbligatorio: ",
"SUBMISSION_FAILED" : "Invio fallito",
"BEERROR_INVALID" : "Impossibile inviare; il formato del campo non era valido: ",
"BEERROR_UNKNOWN" : "Impossibile inviare a causa di un errore sconosciuto.",
"ANON_UPLOAD_IMAGE_WARNING": "Non è possibile caricare immagini finché il captcha non è completato.",
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/pages/EncounterSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useSearchParams } from "react-router-dom";
import { useIntl } from "react-intl";
import axios from "axios";
import { get } from "lodash";
import ThemeColorContext from "../ThemeColorProvider";

const columns = [
{ name: "INDIVIDUAL_ID", selector: "individualDisplayName" },
Expand All @@ -31,6 +32,7 @@ export default function EncounterSearch() {
const [paramsFormFilters, setParamsFormFilters] = useState([]);
const paramsObject = Object.fromEntries(searchParams.entries()) || {};
const [formFilters, setFormFilters] = useState([]);
const theme = React.useContext(ThemeColorContext);

const regularQuery = searchParams.get("regularQuery");

Expand Down Expand Up @@ -272,10 +274,20 @@ export default function EncounterSearch() {
onPerPageChange={queryID ? setSearchIdResultPerPage1 : setPerPage}
setSort={setSort}
loading={false}
extraStyles={[
{
when: (row) => row.access === "none",
style: {
backgroundColor: theme?.statusColors?.yellow100 || "#fff3cd",
"&:hover": {
backgroundColor: theme?.primaryColors?.primary300 || "#e0f7fa",
},
},
},
]}
onRowClicked={(row) => {
const url = `/encounters/encounter.jsp?number=${row.id}`;
window.open(url, "_blank");
// window.location.href = url;
}}
onSelectedRowsChange={(selectedRows) => {
console.log("Selected Rows: ", selectedRows);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.ecocean</groupId>
<artifactId>wildbook</artifactId>
<version>10.5.1</version>
<version>10.5.2</version>
<packaging>war</packaging>

<properties>
Expand Down
27 changes: 25 additions & 2 deletions src/main/java/org/ecocean/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@
*/
public abstract void addComments(final String newComments);

public abstract List<String> userIdsWithViewAccess(Shepherd myShepherd);
public abstract List<String> userIdsWithEditAccess(Shepherd myShepherd);
// issue 785 makes this no longer necessary; the overrides are left on Occurrence and MarkedIndividual
// for now as reference -- but are not called. they will need to be addressed when these classes are searchable
// public abstract List<String> userIdsWithViewAccess(Shepherd myShepherd);
// public abstract List<String> userIdsWithEditAccess(Shepherd myShepherd);

public abstract String opensearchIndexName();

Expand All @@ -97,6 +99,8 @@ public JSONObject opensearchMapping() {
map.put("version", new org.json.JSONObject("{\"type\": \"long\"}"));
// id should be keyword for the sake of sorting
map.put("id", new org.json.JSONObject("{\"type\": \"keyword\"}"));
map.put("viewUsers", new org.json.JSONObject("{\"type\": \"keyword\"}"));
map.put("editUsers", new org.json.JSONObject("{\"type\": \"keyword\"}"));
return map;
}

Expand Down Expand Up @@ -153,11 +157,24 @@ public void opensearchUnindexDeep()
this.opensearchUnindex();
}

public void opensearchUpdate(final JSONObject updateData)
throws IOException {
if (updateData == null) return;
OpenSearch opensearch = new OpenSearch();

opensearch.indexUpdate(this.opensearchIndexName(), this.getId(), updateData);
}

// should be overridden
public void opensearchDocumentSerializer(JsonGenerator jgen, Shepherd myShepherd)
throws IOException, JsonProcessingException {
jgen.writeStringField("id", this.getId());
jgen.writeNumberField("version", this.getVersion());
jgen.writeNumberField("indexTimestamp", System.currentTimeMillis());

/*
these are no longer computed in the general opensearchIndex() call.
they are too expensive. see Encounter.opensearchIndexPermission()
jgen.writeFieldName("viewUsers");
jgen.writeStartArray();
Expand All @@ -172,6 +189,7 @@ public void opensearchDocumentSerializer(JsonGenerator jgen, Shepherd myShepherd
jgen.writeString(id);
}
jgen.writeEndArray();
*/
}

public void opensearchDocumentSerializer(JsonGenerator jgen)
Expand All @@ -196,6 +214,11 @@ public static JSONObject opensearchQuery(final String indexname, final JSONObjec
return res;
}

// this is so we can call it on Base obj, but really is only needed by [overridden by] Encounter (currently)
public boolean getOpensearchProcessPermissions() {
return false;
}

public static Map<String, Long> getAllVersions(Shepherd myShepherd, String sql) {
Query query = myShepherd.getPM().newQuery("javax.jdo.query.SQL", sql);
Map<String, Long> rtn = new HashMap<String, Long>();
Expand Down
Loading

0 comments on commit 94ff934

Please sign in to comment.