Skip to content
Snippets Groups Projects
Commit e37ea25f authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

Merge branch 'backoffice-moteur-de-recherche-a-simplifier' into 'dev'

Backoffice moteur de recherche a simplifier

See merge request !85
parents 63e06105 88ac10f2
No related branches found
No related tags found
4 merge requests!96Deploy OpenShift v2,!95MEP fix liens undefined,!91MEP: removed Meilisearch,!85Backoffice moteur de recherche a simplifier
Pipeline #52504 passed
......@@ -25,5 +25,4 @@ DATABASE_USER=
DATABASE_PASSWORD=
DATABASE_NAME=
SGE_API_TOKEN=
MEILI_MASTER_KEY=
\ No newline at end of file
SGE_API_TOKEN=
\ No newline at end of file
......@@ -18,7 +18,6 @@
.env.development.local
.env.test.local
.env.production.local
meili_data
db_data
npm-debug.log*
......
......@@ -16,7 +16,8 @@
"activityBar.activeBackground": "#37cc4e",
"sash.hoverBorder": "#37cc4e",
"statusBarItem.remoteBackground": "#2aa63d",
"statusBarItem.remoteForeground": "#e7e7e7"
"statusBarItem.remoteForeground": "#e7e7e7",
"commandCenter.border": "#e7e7e799"
},
"editor.formatOnSave": true,
"eslint.format.enable": true,
......
......@@ -30,20 +30,6 @@ services:
timeout: 10s
retries: 60
meilisearch:
image: getmeili/meilisearch:v0.28.1
healthcheck:
test: ['CMD', 'curl', '-f', 'http://0.0.0.0:7700']
interval: 10s
timeout: 10s
retries: 3
volumes:
- ./meili_data:/meili_data
ports:
- 7700:7700
environment:
- MEILI_MASTER_KEY=${MEILI_MASTER_KEY}
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
depends_on:
......@@ -59,8 +45,6 @@ services:
depends_on:
database-agent:
condition: service_healthy
meilisearch:
condition: service_healthy
restart: unless-stopped
volumes:
- ./mnt:/app/mnt
......@@ -85,5 +69,3 @@ services:
- MOCK_OAUTH2=${MOCK_OAUTH2}
- IMAGE_FOLDER=${IMAGE_FOLDER}
- SGE_API_TOKEN=${SGE_API_TOKEN}
- MEILI_HOST=http://meilisearch:7700
- MEILI_MASTER_KEY=${MEILI_MASTER_KEY}
......@@ -157,23 +157,16 @@ const Consents: React.FC = () => {
async (newSearch: string) => {
setSearch(newSearch)
if (user) {
let consentsData: IConsent[] | null = []
if (newSearch) {
consentsData = await consentService.searchConsent(
newSearch,
getAxiosXSRFHeader(user.xsrftoken)
)
} else {
const consentPagination = await consentService.getConsents(
rowsPerPage,
page,
getAxiosXSRFHeader(user.xsrftoken)
)
consentsData = consentPagination && consentPagination.rows
}
if (consentsData) {
setConsents(consentsData)
const consentPagination = await consentService.searchConsents(
newSearch,
rowsPerPage,
page,
getAxiosXSRFHeader(user.xsrftoken)
)
if (consentPagination) {
setConsents(consentPagination.rows)
checkSelectedNodes()
setTotalRows(consentPagination.totalRows)
}
}
},
......@@ -259,25 +252,12 @@ const Consents: React.FC = () => {
}
}, [gridApi])
/** Trigger search when page loads or when admin changes pagination */
useEffect(() => {
async function getConsentsData() {
if (user) {
const consentsPaginationData = await consentService.getConsents(
rowsPerPage,
page,
getAxiosXSRFHeader(user.xsrftoken)
)
if (consentsPaginationData) {
setConsents(consentsPaginationData.rows)
checkSelectedNodes()
setTotalRows(consentsPaginationData.totalRows)
}
}
}
getConsentsData()
// /!\ Do not add checkSelected in dependencies or effect will trigger on each selection
handleSearchChange(search)
// /!\ Do not change dependencies or effect will not trigger when pagination changes
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user, consentService, rowsPerPage, page])
}, [rowsPerPage, page])
return (
<>
......@@ -291,8 +271,8 @@ const Consents: React.FC = () => {
<input
value={search}
name="search"
type="text"
placeholder="N°PDL, Nom, Prénom..."
type="number"
placeholder="N°PDL (14 chiffres)"
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleSearchChange(e.target.value)
}
......@@ -320,7 +300,7 @@ const Consents: React.FC = () => {
pagination={false}
suppressCellFocus={true}
></AgGridReact>
{search === '' && !isShowingSelection && (
{!isShowingSelection && (
<TablePagination
labelRowsPerPage="Consentements par page"
component="div"
......
......@@ -11,46 +11,19 @@ export class ConsentService {
/**
* Search for consents
* @param search
* @param axiosHeaders
*/
public searchConsent = async (
search: string,
axiosHeaders: AxiosRequestConfig
): Promise<IConsent[] | null> => {
try {
const { data } = await axios.get(
`/api/admin/consent?search=${search}`,
axiosHeaders
)
const consentEntities = data as ConsentEntity[]
return consentEntities.map((entity) => this.parseConsent(entity))
} catch (e: any) {
if (e.response.status === 403) {
toast.error(
"Unauthorized : You don't have the rights to do this operation"
)
} else {
toast.error('Failed to search consents')
}
console.error(e)
return null
}
}
/**
* Gets consents
* @param limit
* @param page
* @param axiosHeaders
*/
public getConsents = async (
public searchConsents = async (
search: string,
limit: number,
page: number,
axiosHeaders: AxiosRequestConfig
): Promise<IConsentPagination | null> => {
try {
const { data } = await axios.get(
`/api/admin/consent?limit=${limit}&page=${page}`,
`/api/admin/consent?search=${search}&limit=${limit}&page=${page}`,
axiosHeaders
)
const consentPagination = data as ConsentPaginationEntity
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment