Skip to content

Commit

Permalink
Merge commit 'ae7cf1f13d1527b5d031c9162a80bc44497b00ba' into bass
Browse files Browse the repository at this point in the history
  • Loading branch information
holmbergius committed Jan 17, 2025
2 parents fae7fe9 + ae7cf1f commit 4195483
Show file tree
Hide file tree
Showing 13 changed files with 1,625 additions and 1,569 deletions.
232 changes: 126 additions & 106 deletions frontend/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions 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 Down
26 changes: 26 additions & 0 deletions frontend/src/hooks/useDocumentTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,36 @@ import useGetSiteSettings from "../models/useGetSiteSettings";

export default function useDocumentTitle() {
const { data: siteSettings } = useGetSiteSettings();

document.title = siteSettings?.siteName || "wildbook";
useEffect(() => {
if (!siteSettings) return;
let iconURL = siteSettings?.siteFavicon;
let link = document.querySelector("link[rel*='icon']");
const metaDescription = document.querySelector("meta[name='description']");
const metaKeywords = document.querySelector("meta[name='keywords']");
const metaAuthor = document.querySelector("meta[name='author']");

if (!metaDescription) {
const meta = document.createElement("meta");
meta.name = "description";
meta.content = siteSettings?.siteDescription;
document.getElementsByTagName("head")[0].appendChild(meta);
}

if (!metaKeywords) {
const meta = document.createElement("meta");
meta.name = "keywords";
meta.content = siteSettings?.siteKeywords;
document.getElementsByTagName("head")[0].appendChild(meta);
}

if (!metaAuthor) {
const meta = document.createElement("meta");
meta.name = "author";
meta.content = siteSettings?.siteAuthor;
document.getElementsByTagName("head")[0].appendChild(meta);
}

if (link) {
link.href = iconURL;
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.2</version>
<version>10.5.3</version>
<packaging>war</packaging>

<properties>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/ecocean/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ public JSONObject opensearchMapping() {

public void opensearchIndex()
throws IOException {
long startT = System.currentTimeMillis();
OpenSearch opensearch = new OpenSearch();

opensearch.index(this.opensearchIndexName(), this);
long endT = System.currentTimeMillis();
System.out.println("opensearchIndex(): " + (endT - startT) + "ms indexing " + this);
}

// this will index "related" objects as needed
Expand Down
31 changes: 0 additions & 31 deletions src/main/java/org/ecocean/Encounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4705,35 +4705,4 @@ public void sendCreationEmails(Shepherd myShepherd, String langCode) {
}
}

public void opensearchIndexDeep()
throws IOException {
final String encId = this.getId();
final Encounter origEnc = this;
ExecutorService executor = Executors.newFixedThreadPool(4);
Runnable rn = new Runnable() {
public void run() {
Shepherd bgShepherd = new Shepherd("context0");
bgShepherd.setAction("Encounter.opensearchIndexDeep_" + encId);
bgShepherd.beginDBTransaction();
try {
Encounter enc = bgShepherd.getEncounter(encId);
if (enc == null) {
// we use origEnc if we can (especially necessary on initial creation of Encounter)
if (origEnc != null) origEnc.opensearchIndex();
bgShepherd.rollbackAndClose();
executor.shutdown();
return;
}
enc.opensearchIndex();
} catch (Exception e) {
e.printStackTrace();
} finally {
bgShepherd.rollbackAndClose();
}
executor.shutdown();
}
};

executor.execute(rn);
}
}
2,642 changes: 1,337 additions & 1,305 deletions src/main/java/org/ecocean/EncounterQueryProcessor.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/org/ecocean/MarkedIndividual.java
Original file line number Diff line number Diff line change
Expand Up @@ -2609,7 +2609,7 @@ public void run() {
try {
MarkedIndividual indiv = bgShepherd.getMarkedIndividual(indivId);
if ((indiv == null) || (indiv.getEncounters() == null)) {
bgShepherd.rollbackAndClose();
//bgShepherd.rollbackAndClose();
executor.shutdown();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/ecocean/Occurrence.java
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ public void run() {
try {
Occurrence occur = bgShepherd.getOccurrence(occurId);
if ((occur == null) || (occur.getEncounters() == null)) {
bgShepherd.rollbackAndClose();
// rollbackAndClose handled by finally
executor.shutdown();
return;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/ecocean/api/SiteSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
// note: there is a CommonConfiguration property: htmlShortcutIcon=images/favicon.ico?v=2
settings.put("siteFavicon", "/images/favicon.ico");
settings.put("siteName", CommonConfiguration.getHTMLTitle(context));
settings.put("siteDescription", CommonConfiguration.getHTMLDescription(context));
settings.put("siteKeywords", CommonConfiguration.getHTMLKeywords(context));
settings.put("siteAuthor", CommonConfiguration.getHTMLAuthor(context));
settings.put("locationData", LocationID.getLocationIDStructure());

settings.put("mapCenterLat", CommonConfiguration.getCenterLat(context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
}
if (!locked) {
myShepherd.commitDBTransaction();
if (enc2remove != null) enc2remove.opensearchIndexDeep();
//if (enc2remove != null) enc2remove.opensearchIndexDeep();
out.println(ServletUtilities.getHeader(request));
response.setStatus(HttpServletResponse.SC_OK);
out.println("<strong>Success:</strong> Encounter #" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
if (!locked) {
myShepherd.commitDBTransaction();
// out.println(ServletUtilities.getHeader(request));
if (enc2remove != null) enc2remove.opensearchIndexDeep();
//if (enc2remove != null) enc2remove.opensearchIndexDeep();
out.println("<strong>Success:</strong> Encounter " +
request.getParameter("number") +
" was successfully removed from occurrence " + old_name + ".");
Expand Down
Loading

0 comments on commit 4195483

Please sign in to comment.