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

Continuation of Encounter Search (using OpenSearch) #642

Merged
merged 114 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
4f1c163
todo/note for future cleanup
naknomum Jul 17, 2024
95b444b
fitBounds, remove old bounding box when start drawing
erinz2020 Jul 18, 2024
365989d
measurements and biomeasurements query update to nested
erinz2020 Jul 18, 2024
d324434
set center of map and initial bounds
erinz2020 Jul 18, 2024
cdb9c15
remove confirm buttons, real time update query
erinz2020 Jul 19, 2024
03737b3
update select options background
erinz2020 Jul 19, 2024
826ecfc
interComponent states update
erinz2020 Jul 19, 2024
806d171
first draft, but its a start
naknomum Jul 19, 2024
ad57966
store search queries
naknomum Jul 19, 2024
457d009
use stored search query (alpha)
naknomum Jul 19, 2024
0545a59
fix encounter data table links issue
erinz2020 Jul 19, 2024
c5572a0
get key from property file, cancel checkbox filters
erinz2020 Jul 22, 2024
0f84a5d
nested for metalTags
naknomum Jul 22, 2024
5f77c9a
Merge branch '511_continuation_of_encounter_search' of github.com:Wil…
naknomum Jul 22, 2024
598e441
fix map display issue, add cancel function to select filters
erinz2020 Jul 23, 2024
d1e47d2
bugfix
naknomum Jul 23, 2024
342616b
update queries
erinz2020 Jul 23, 2024
8b71c49
fix banner overlap with header issue
erinz2020 Jul 23, 2024
ef9718b
bioMeasurement queries
erinz2020 Jul 23, 2024
164d690
remove mediaQuery
erinz2020 Jul 24, 2024
b811e90
read/write banner status from Cookie
erinz2020 Jul 24, 2024
99cda30
customize scroll bar
erinz2020 Jul 24, 2024
b36cb71
customize scroll bar
erinz2020 Jul 24, 2024
811896a
customize dropdown menu
erinz2020 Jul 24, 2024
ea3fce4
adjust inputs grid
erinz2020 Jul 24, 2024
388af85
remove 1440px limit
erinz2020 Jul 25, 2024
74f5994
label index for allele, rather than store as array
naknomum Jul 25, 2024
3cd47b8
deal with case range.gte or range.lte is 0
erinz2020 Jul 26, 2024
89da8ba
if update multiple filters in a short time, don't use setState
erinz2020 Jul 26, 2024
a60511b
now this components is a mess, onChange function everywhere
erinz2020 Jul 26, 2024
1aa7d7e
remove logs
erinz2020 Jul 26, 2024
ba346b1
i18n
erinz2020 Jul 26, 2024
7080662
i18n
erinz2020 Jul 27, 2024
de81aab
more i18n and l10n
erinz2020 Jul 29, 2024
fe56a83
adjust some UI styles
erinz2020 Jul 29, 2024
2bac767
copy/past searchQueryId
erinz2020 Jul 29, 2024
aacbf98
adjust header styles
erinz2020 Jul 30, 2024
ae3cc4d
handle the case where username might be empty
erinz2020 Jul 30, 2024
4bd116e
update project field name
erinz2020 Jul 30, 2024
fdc941e
update encounter search result page links
erinz2020 Aug 1, 2024
4d56e2f
parse url params, add to sidebar and filters
erinz2020 Aug 1, 2024
976d739
only cancel service worker locally
erinz2020 Aug 1, 2024
27165bc
customize sort function of search result table
erinz2020 Aug 1, 2024
90b1fdc
quieter on the logging
naknomum Aug 2, 2024
e8255b5
index name fix; deep indiv fix on MarkedIndividual
naknomum Aug 6, 2024
ad70ba3
fix some design discrepancies
erinz2020 Aug 6, 2024
1a35d2b
update some references to search result page
erinz2020 Aug 6, 2024
773b842
update references to search result
erinz2020 Aug 6, 2024
8a67237
table: update null to '-'
erinz2020 Aug 7, 2024
c1b3bea
add settings info
naknomum Aug 7, 2024
186fc01
introduce custom normalizer
naknomum Aug 7, 2024
8a48e38
support 100x50 logo and responsive header
erinz2020 Aug 7, 2024
97ea4db
Merge branch '511_continuation_of_encounter_search' of github.com:Wil…
naknomum Aug 7, 2024
6a7fe89
click back button will go back to filters
erinz2020 Aug 7, 2024
2bf78fc
hover state
erinz2020 Aug 7, 2024
c8010f8
being normal is good
naknomum Aug 7, 2024
4e2fd71
whew, prettier filter label names
erinz2020 Aug 8, 2024
d8d937b
translate _ to space for site-settings api
naknomum Aug 8, 2024
ea157a5
changes to accommodate different queries per slack discussion
naknomum Aug 8, 2024
15d491c
new filters for social unit and relationship role
erinz2020 Aug 9, 2024
6f365a9
Merge branch '511_continuation_of_encounter_search' of https://github…
erinz2020 Aug 9, 2024
953e020
AND operator
erinz2020 Aug 9, 2024
fe57b6e
new UI, new translation
erinz2020 Aug 10, 2024
4928455
AND operator and OR operator
erinz2020 Aug 10, 2024
c498302
social unit name, social relationship role
erinz2020 Aug 10, 2024
223482f
proved both plan A and plan B are working
erinz2020 Aug 10, 2024
48f6d23
adjust button width for responsiveness
erinz2020 Aug 12, 2024
38e5dd5
different field names are killing me
erinz2020 Aug 12, 2024
3353e1d
remove unused lines
erinz2020 Aug 12, 2024
967af78
normalizer for projects and assignedUsername
naknomum Aug 12, 2024
f4a05c1
Merge branch '511_continuation_of_encounter_search' of github.com:Wil…
naknomum Aug 12, 2024
899a2e5
search on username, not uuid
erinz2020 Aug 12, 2024
ede7db0
Merge branch '511_continuation_of_encounter_search' of https://github…
erinz2020 Aug 12, 2024
9ec9e92
map input type should be number
erinz2020 Aug 13, 2024
5bc5681
table header translation
erinz2020 Aug 13, 2024
958c766
preset search query
erinz2020 Aug 13, 2024
bf39e33
more stored query dev
naknomum Aug 13, 2024
6886d4d
Merge branch '511_continuation_of_encounter_search' of github.com:Wil…
naknomum Aug 13, 2024
ffcbe62
bugfix and store creator of query
naknomum Aug 13, 2024
66034e0
alpha of tabs query hackery
naknomum Aug 13, 2024
0f00e23
much kinder messaging
naknomum Aug 14, 2024
24414e6
remove image cuz it has background image
erinz2020 Aug 14, 2024
53180c7
os.getSettings()
naknomum Aug 14, 2024
da52357
usage of os.getSettings()
naknomum Aug 14, 2024
03fa407
attempt to get all matching encounters, but not setting size to high
naknomum Aug 14, 2024
8b8a06d
bugfix and bigger background slice
naknomum Aug 14, 2024
869cc8a
individualDisplayName in enc search doc
naknomum Aug 14, 2024
5e2a342
some fancy timing reports in logs
naknomum Aug 14, 2024
694e55c
apply search ID
erinz2020 Aug 14, 2024
003ce37
Merge branch '511_continuation_of_encounter_search' of https://github…
erinz2020 Aug 14, 2024
a4e1cfb
make stuff keyword-type in index for sake of sorting
naknomum Aug 14, 2024
bef054d
sort/sortOrder "work" on other search tabs - tho i am not sure what t…
naknomum Aug 14, 2024
286e6ed
search ID related stuff, and sorting
erinz2020 Aug 15, 2024
eb0f0e8
Merge branch '511_continuation_of_encounter_search' of https://github…
erinz2020 Aug 15, 2024
310569d
index fields: individualDisplayName, locationName; keyword both for s…
naknomum Aug 15, 2024
9689d63
update links
erinz2020 Aug 15, 2024
0330a05
search ID part2
erinz2020 Aug 15, 2024
d78ce95
Merge branch '511_continuation_of_encounter_search' of https://github…
erinz2020 Aug 15, 2024
e07b935
fix alternative ID sorting
erinz2020 Aug 15, 2024
74f7fd3
update search page on demand
erinz2020 Aug 15, 2024
57b2f07
remove dup desc, add number ph text
TanyaStere42 Aug 15, 2024
63bddcd
i18n new placeholder
erinz2020 Aug 15, 2024
ea34a11
remove some descriptions
erinz2020 Aug 15, 2024
2cc8388
underline, new tab, individual link, etc
erinz2020 Aug 15, 2024
a2ee659
a small fix then I'm away
erinz2020 Aug 15, 2024
418539d
deep-index occurrence; handle index *after* encounter removal from oc…
naknomum Aug 15, 2024
758f3ad
index encounter upon removal from individual
naknomum Aug 15, 2024
5a935c9
force new PIT each search until we give frontend control of it
naknomum Aug 15, 2024
265b68a
for indexing, only count non-trivial annotations
naknomum Aug 16, 2024
2e199fe
conflict resolve
naknomum Aug 16, 2024
32122f0
crustify madness
naknomum Aug 16, 2024
4abca6f
Merge branch 'master' into 511_continuation_of_encounter_search
naknomum Aug 16, 2024
5874e30
Merge branch 'master' into 511_continuation_of_encounter_search
naknomum Aug 16, 2024
abedc76
close query upon exception; move close query sooner; remove debugging…
naknomum Aug 17, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ catalina.base_IS_UNDEFINED
/frontend/.env
/frontend/build
/frontend/.env
/frontend/src/serviceWorkerRegistration.js
/frontend/src/serviceWorker.js
1 change: 0 additions & 1 deletion frontend/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const webpack = require('webpack');
module.exports = function override(config, env) {
if(env === 'production'){
config.devtool = 'source-map';
console.log('source-map');
// config.devtool = 'cheap-module-source-map';
}
config.plugins.push(
Expand Down
22 changes: 22 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"react-burger-menu": "^3.0.9",
"react-data-table-component": "^7.6.2",
"react-dom": "^18.2.0",
"react-hook-form": "^7.52.1",
"react-intl": "^6.6.2",
"react-paginate": "^8.2.0",
"react-router-bootstrap": "^0.26.2",
Expand Down
18 changes: 17 additions & 1 deletion frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { BrowserRouter, useLocation, useRoutes } from "react-router-dom";
import LocaleContext from "./IntlProvider";
import FooterVisibilityContext from "./FooterVisibilityContext";
import Cookies from "js-cookie";
import FilterContext from "./FilterContextProvider";

function App() {
const messageMap = {
Expand All @@ -24,7 +25,7 @@ function App() {
const [locale, setLocale] = useState(initialLocale);
const [visible, setVisible] = useState(true);
const containerStyle = {
maxWidth: "1440px",
// maxWidth: "1440px",
display: "flex",
flexDirection: "column",
minHeight: "100vh",
Expand All @@ -37,6 +38,19 @@ function App() {
Cookies.set("wildbookLangCode", newLocale);
};

const [filters, setFilters] = useState({});
const updateFilter = (filterName, value) => {
setFilters((prevFilters) => ({
...prevFilters,
[filterName]: value,
}));

}

const resetFilters = () => {
setFilters({});
};

return (
<QueryClientProvider client={queryClient}>
<LocaleContext.Provider
Expand All @@ -53,7 +67,9 @@ function App() {
messages={messageMap[locale]}
>
<FooterVisibilityContext.Provider value={{ visible, setVisible }}>
<FilterContext.Provider value={{ filters, updateFilter, resetFilters }}>
<FrontDesk adminUserInitialized={true} setLocale={setLocale} />
</FilterContext.Provider>
</FooterVisibilityContext.Provider>
</IntlProvider>
</BrowserRouter>
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/AuthenticatedSwitch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function AuthenticatedSwitch({ showAlert, setShowAlert }) {
const { isFetched, data, error } = useGetMe();
const username = data?.username;
const avatar = data?.imageURL || "/react/images/Avatar.png";
const [header, setHeader] = React.useState(true);

return (
<div className="d-flex flex-column min-vh-100">
Expand All @@ -23,8 +24,8 @@ export default function AuthenticatedSwitch({ showAlert, setShowAlert }) {
className="position-fixed top-0 mx-auto w-100"
style={{
zIndex: "100",
height: "60px",
maxWidth: "1440px",
height: "50px",
backgroundColor: "#303336",
}}
>
{showAlert && <AlertBanner setShowAlert={setShowAlert} />}
Expand All @@ -38,11 +39,12 @@ export default function AuthenticatedSwitch({ showAlert, setShowAlert }) {

<div
id="main-content"
className="flex-grow-1 d-flex justify-content-center mt-4 pt-5"
className="flex-grow-1 d-flex justify-content-center"
style={{
boxSizing: "border-box",
maxWidth: "1440px",
// maxWidth: "1440px",
overflow: "hidden",
paddingTop: header? "48px" : "0",
}}
>
<Routes>
Expand All @@ -51,7 +53,7 @@ export default function AuthenticatedSwitch({ showAlert, setShowAlert }) {
<Route path="/encounter-search" element={<EncounterSearch />} />
<Route path="/login" element={<Login />} />
<Route path="/" element={<Home />} />
<Route path="*" element={<NotFound />} />
<Route path="*" element={<NotFound setHeader={setHeader}/>} />
</Routes>
</div>

Expand Down
6 changes: 6 additions & 0 deletions frontend/src/FilterContextProvider.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

import { createContext } from "react";

const FilterContext = createContext(true);
export default FilterContext;

7 changes: 3 additions & 4 deletions frontend/src/FrontDesk.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import axios from "axios";
import AuthContext from "./AuthProvider";
import getMergeNotifications from "./models/notifications/getMergeNotifications";
import getCollaborationNotifications from "./models/notifications/getCollaborationNotifications";
import NotFound from "./pages/errorPages/NotFound";
import ServerError from "./pages/errorPages/ServerError";
import LoadingScreen from "./components/LoadingScreen";
import GoogleTagManager from "./GoogleTagManager";
import Cookies from "js-cookie";
import "./css/scrollBar.css";

export default function FrontDesk() {
const [isLoggedIn, setIsLoggedIn] = useState(false);
Expand All @@ -17,11 +17,10 @@ export default function FrontDesk() {
const [collaborationData, setCollaborationData] = useState([]);
const [mergeData, setMergeData] = useState([]);
const [count, setCount] = useState(0);
const [showAlert, setShowAlert] = useState(true);
const [showAlert, setShowAlert] = useState(() => Cookies.get("showAlert") === "false" ? false : true);
const [loading, setLoading] = useState(true);

const checkLoginStatus = () => {
console.log("Polling API...");
axios
.head("/api/v3/user")
.then((response) => {
Expand Down
40 changes: 19 additions & 21 deletions frontend/src/UnAuthenticatedSwitch.jsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
import React from "react";
import React, { useEffect } from "react";
import { Routes, Route } from "react-router-dom";
import ErrorPage from "./pages/errorPages/ErrorPage";
import Login from "./pages/Login";
import Footer from "./components/Footer";
import Home from "./pages/Home";
import AlertBanner from "./components/AlertBanner";
import UnAuthenticatedAppHeader from "./components/UnAuthenticatedAppHeader";
import NotFound from "./pages/errorPages/NotFound";
import Forbidden from "./pages/errorPages/Forbidden";
import Unauthorized from "./pages/errorPages/Unauthorized";
import ServerError from "./pages/errorPages/ServerError";
import BadRequest from "./pages/errorPages/BadRequest";
import About from "./About";
import EncounterSearch from "./pages/EncounterSearch";
import Home from "./pages/Home";

export default function UnAuthenticatedSwitch({ showAlert, setShowAlert }) {
console.log("UnAuthenticatedSwitch", showAlert);
const [header, setHeader] = React.useState(true);
const [headerTop, setHeaderTop] = React.useState("60px");
const alertBannerRef = React.useRef(null);

return (
<div className="d-flex flex-column min-vh-100">
<div
id="header"
className="position-fixed top-0 mx-auto w-100"
className="position-fixed top-0 w-100"
style={{
zIndex: "100",
height: "60px",
maxWidth: "1440px",
height: "50px",
backgroundColor: "#303336",
}}

>
{showAlert && <AlertBanner setShowAlert={setShowAlert} />}
<UnAuthenticatedAppHeader
showAlert={showAlert}
setShowAlert={setShowAlert}
/>
{showAlert && <AlertBanner
setShowAlert={setShowAlert} />}
<UnAuthenticatedAppHeader/>
</div>

<div
id="main-content"
className="flex-grow-1 d-flex justify-content-center mt-4 pt-5"
className="flex-grow-1 d-flex justify-content-center"
style={{
boxSizing: "border-box",
maxWidth: "1440px",
overflow: "hidden",
paddingTop: header ? "48px" : "0",
}}
>
<Routes>
<Route path="/about" element={<About />} />
<Route path="/home" element={<Unauthorized />} />
<Route path="/encounter-search" element={<EncounterSearch />} />
{/* <Route path="/about" element={<About />} /> */}
<Route path="/home" element={<Unauthorized setHeader={setHeader} />} />
{/* <Route path="/encounter-search" element={<EncounterSearch />} /> */}
<Route path="/encounter-search" element={<Login />} />
<Route path="/login" element={<Login />} />
<Route path="/" element={<Login />} />
<Route path="*" element={<NotFound />} />
<Route path="*" element={<NotFound setHeader={setHeader} />} />
</Routes>
</div>
<Footer />
Expand Down
12 changes: 9 additions & 3 deletions frontend/src/components/AlertBanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import React from "react";
import ThemeColorContext from "../ThemeColorProvider";
import { FormattedMessage } from "react-intl";
import BrutalismButton from "./BrutalismButton";
import Cookies from "js-cookie";

export default function AlertBanner({ setShowAlert }) {
export default function AlertBanner({ showAlert, setShowAlert }) {
const theme = React.useContext(ThemeColorContext);
return (
<div
className="alert alert-warning alert-dismissible fade show d-flex justify-content-between align-items-center"
className="fade show d-flex justify-content-between align-items-center"
role="alert"
style={{
margin: "0 !important",
padding: 10,
boxSizing: "border-box",
minHeight: 60,
Expand All @@ -24,7 +26,11 @@ export default function AlertBanner({ setShowAlert }) {
color={theme.primaryColors.primary500}
borderColor={theme.primaryColors.primary500}
style={{ padding: 10, margin: 0 }}
onClick={() => setShowAlert(false)}
onClick={() => {
setShowAlert(false);
Cookies.set("showAlert", false, { expires: 7 });
}
}
>
<FormattedMessage id="OK" />
</BrutalismButton>
Expand Down
93 changes: 93 additions & 0 deletions frontend/src/components/AndSelector.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import Select from 'react-select';
import { useEffect, useState } from 'react';
import { useRef } from 'react';
import { FormattedMessage } from 'react-intl';
import { FormGroup, FormLabel } from 'react-bootstrap';
import Description from './Form/Description'

const colourStyles = {
option: (styles) => ({
...styles,
color: 'black',
}),
control: (styles) => ({ ...styles, backgroundColor: 'white' }),
singleValue: (styles) => ({ ...styles, color: 'black' }),
menuPortal: base => ({ ...base, zIndex: 9999 }),
control: base => ({ ...base, zIndex: 1 }),
};

export default function AndSelector({
noLabel,
noDesc,
label,
isMulti,
options,
onChange,
field,
filterKey,
term, }) {

const [selectedOptions, setSelectedOptions] = useState([]);
const selectedOptionsRef = useRef(selectedOptions);

useEffect(() => {

onChange(null, field);
return () => {
options.forEach(option => {
onChange(null, `${field}.${option.value}`);
});
};
}, []);

const handleChange = (selected) => {

const addedOptions = selected.filter(option => !selectedOptions.includes(option));
const removedOptions = selectedOptions.filter(option => !selected.includes(option));

setSelectedOptions(selected || []);
selectedOptionsRef.current = selected || [];

if (addedOptions.length > 0) {
addedOptions.forEach(option => {
onChange({
filterId: `${field}.${option.value}`,
clause: "filter",
filterKey: filterKey,
query: {
"term": {
[field]: option.value
}
}
});
})
}

if (removedOptions.length > 0) {
removedOptions.forEach(option => {
onChange(null, `${field}.${option.value}`);
});
}
}

return (
<FormGroup className="mt-2">
{noLabel ? null : <FormLabel><FormattedMessage id={label} defaultMessage={label} /></FormLabel>}
{noDesc ? null : <Description>
<FormattedMessage id={`${label}_DESC`} />
</Description>}

<Select
isMulti={isMulti}
options={options}
className="basic-multi-select"
classNamePrefix="select"
styles={colourStyles}
menuPlacement="auto"
menuPortalTarget={document.body}
value={selectedOptions}
onChange={handleChange}
/>
</FormGroup>
);
}
Loading
Loading