Skip to content

Commit

Permalink
Merge commit '3f1e0b6010e0c798d78f9e71bfd330b93747b196' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonestla committed Nov 29, 2024
2 parents 97ea43d + 3f1e0b6 commit cdfc29e
Show file tree
Hide file tree
Showing 21 changed files with 75 additions and 26 deletions.
3 changes: 1 addition & 2 deletions client/src/api/networks/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default async function networkCreate(
model: string,
filters: NetworkFilters,
aggregation: ElasticBuckets,
computeClusters: boolean,
parameters: NetworkParameters,
lang: string
): Promise<NetworkData> {
Expand Down Expand Up @@ -89,7 +88,7 @@ export default async function networkCreate(
forceAtlas2.assign(graph, { iterations: 100, settings: sensibleSettings })

// Add communities
const communities = await communitiesCreate(graph, computeClusters)
const communities = await communitiesCreate(graph, parameters.clusters)

// Create network
const network: NetworkData = {
Expand Down
6 changes: 2 additions & 4 deletions client/src/api/networks/search/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const networkSearchBody = (model: string, query?: string | unknown): NetworkSear
},
})

export async function networkSearch({ model, query, options, parameters, filters }: NetworkSearchArgs): Promise<Network> {
export async function networkSearch({ model, query, lang, parameters, filters }: NetworkSearchArgs): Promise<Network> {
const body = networkSearchBody(model, query)

if (filters && filters.length > 0) body.query.bool.filter = filters
Expand All @@ -64,9 +64,7 @@ export async function networkSearch({ model, query, options, parameters, filters
return null
}

const computeClusters = options?.computeClusters ?? false
const lang = options?.lang ?? "fr"
const network = await networkCreate(query, model, filters, aggregation, computeClusters, parameters, lang)
const network = await networkCreate(query, model, filters, aggregation, parameters, lang)
const config = configCreate(model)
const info = infoCreate(query, model)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function NetworkAnalytics() {
const { screen } = useScreenSize()
const { currentTab } = useTab()
const { parameters } = useParameters()
const { search, currentQuery } = useSearchData(currentTab, parameters.clusters)
const { search, currentQuery } = useSearchData(currentTab)
const clusters = search.data?.network?.clusters

if (Boolean(search.error) || !currentQuery || !parameters.clusters) return null
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/networks/components/clusters/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function ClustersButton() {
const { currentTab } = useTab()
const { integrationOptions } = useIntegration()
const { parameters, handleParametersChange } = useParameters()
const { search, currentQuery } = useSearchData(currentTab, parameters.clusters)
const { search, currentQuery } = useSearchData(currentTab)

if (integrationOptions.showClustersButton === false) return null

Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/networks/components/clusters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default function NetworkClusters() {
const intl = useIntl()
const { currentTab } = useTab()
const { parameters } = useParameters()
const { search, currentQuery } = useSearchData(currentTab, parameters.clusters)
const { search, currentQuery } = useSearchData(currentTab)
const [seeMore, setSeeMore] = useState(false)

const network = search?.data?.network as NetworkData
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/networks/components/exports/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function NetworkExports() {
const intl = useIntl()
const { currentTab } = useTab()
const { integrationOptions } = useIntegration()
const { search, currentQuery } = useSearchData(currentTab, false)
const { search, currentQuery } = useSearchData(currentTab)
const { isExporting, exportFile } = useExportData()

if (integrationOptions?.showExports === false) return null
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/networks/components/graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function NetworkGraph() {
const { parameters } = useParameters()
const { focusItem } = useNetworkContext()
const { search, currentQuery, filters } = useSearchData(currentTab, false)
const { search: searchClusters } = useSearchData(currentTab, parameters.clusters)
const { search: searchClusters } = useSearchData(currentTab)
const { locale: lang } = useDSFRConfig()
const theme = document.documentElement.getAttribute("data-fr-theme")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import useSearchData from "../../../hooks/useSearchData"

export default function AutocompleteFilterNode() {
const { currentTab } = useTab()
const { parameters, handleParametersChange } = useParameters()
const { search } = useSearchData(currentTab, parameters.clusters)
const { handleParametersChange } = useParameters()
const { search } = useSearchData(currentTab)

const nodes = search?.data?.network?.items?.map((item) => ({ label: item.label, id: item.id }))
const autocomplete =
Expand Down
4 changes: 1 addition & 3 deletions client/src/pages/networks/hooks/useExportData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import useTab from "./useTab"
import useSearchData from "./useSearchData"
import { NetworkData } from "../../../types/network"
import * as XLSX from "xlsx"
import useParameters from "./useParameters"

function stringToArrayBuffer(string: string) {
const buffer = new ArrayBuffer(string.length)
Expand Down Expand Up @@ -87,8 +86,7 @@ const exportNetwork = (network: NetworkData) => ({

export default function useExportData() {
const { currentTab } = useTab()
const { parameters } = useParameters()
const { search } = useSearchData(currentTab, parameters.clusters)
const { search } = useSearchData(currentTab)
const [isLoading, setIsLoading] = useState(false)

const exportFile = useCallback(
Expand Down
8 changes: 5 additions & 3 deletions client/src/pages/networks/hooks/useSearchData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@ import { networkSearch } from "../../../api/networks/search/search"
import useIntegration from "./useIntegration"
import useParameters from "./useParameters"

export default function useSearchData(networkTab: string, computeClusters: boolean) {
export default function useSearchData(networkTab: string, forceClusters?: boolean) {
const { currentQuery, filters } = useUrl()
const { integrationId, integrationLang } = useIntegration()
const { parameters } = useParameters()
const { currentTab } = useTab()
const { locale } = useDSFRConfig()
const lang = integrationId ? integrationLang : locale

if (forceClusters !== undefined) parameters.clusters = forceClusters

const { data, error, isFetching } = useQuery({
queryKey: ["network", networkTab, currentQuery, filters, computeClusters, lang, parameters],
queryKey: ["network", networkTab, currentQuery, filters, lang, parameters],
queryFn: () =>
networkSearch({
model: networkTab,
query: currentQuery,
options: { computeClusters: computeClusters, lang: lang },
lang: lang,
parameters: parameters,
filters,
}),
Expand Down
5 changes: 4 additions & 1 deletion client/src/pages/networks/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"networks.filters.current.publications.type": "Publikationstyp",
"networks.filters.current.publications.year": "Veröffentlichungsjahre",
"networks.filters.current.publications.projects.type": "Finanzierungstyp",
"networks.filters.current.publications.tags.id": "Tags",
"networks.filters.display": "Ergebnisse anzeigen",
"networks.filters.title": "Filter",
"networks.filters.active-filter-title": "Aktive Filter",
Expand All @@ -56,7 +57,9 @@
"search.filters.publications.by-organization": "Nach Zugehörigkeit filtern",
"search.filters.publications.by-organization-description": "Wählen Sie eine oder mehrere Zugehörigkeiten aus",
"search.filters.publications.by-country": "Nach Land filtern",
"search.filters.publications.by-country-description": "Wählen Sie ein oder mehrere Länder aus",
"search.filters.publications.by-country-description": "Wählen Sie eine oder mehrere Länder aus",
"search.filters.publications.by-tag": "Nach Tag filtern",
"search.filters.publications.by-tag-description": "Wählen Sie einen oder mehrere Tags aus",
"search.top.publications.filters.result-count": "{count, plural, =0 {# Veröffentlichung} one {# Veröffentlichung} other {# Veröffentlichungen}}",
"search.top.filters.display": "Ergebnisse anzeigen",
"search.top.result-more-than": "Mehr als ",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/networks/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"networks.filters.current.publications.type": "Publication Type",
"networks.filters.current.publications.year": "Publication Years",
"networks.filters.current.publications.projects.type": "Funding Type",
"networks.filters.current.publications.tags.id": "Tags",
"networks.filters.display": "Display Results",
"networks.filters.title": "Filters",
"networks.filters.active-filter-title": "Active Filters",
Expand All @@ -79,6 +80,8 @@
"search.filters.publications.by-organization-description": "Select one or more affiliations",
"search.filters.publications.by-country": "Filter by Country",
"search.filters.publications.by-country-description": "Select one or more countries",
"search.filters.publications.by-tag": "Filter by Tag",
"search.filters.publications.by-tag-description": "Select one or more tag",
"search.top.publications.filters.result-count": "{count, plural, =0 {# publication} one {# publication} other {# publications}}",
"search.top.filters.display": "Display Results",
"search.top.result-more-than": "More than ",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/networks/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"networks.filters.current.publications.type": "Tipo de Publicación",
"networks.filters.current.publications.year": "Años de Publicación",
"networks.filters.current.publications.projects.type": "Tipo de Financiamiento",
"networks.filters.current.publications.tags.id": "Etiquetas",
"networks.filters.display": "Mostrar Resultados",
"networks.filters.title": "Filtros",
"networks.filters.active-filter-title": "Filtros Activos",
Expand All @@ -57,6 +58,8 @@
"search.filters.publications.by-organization-description": "Seleccione una o más afiliaciones",
"search.filters.publications.by-country": "Filtrar por país",
"search.filters.publications.by-country-description": "Seleccione una o más países",
"search.filters.publications.by-tag": "Filtrar por etiqueta",
"search.filters.publications.by-tag-description": "Seleccione una o más etiquetas",
"search.top.publications.filters.result-count": "{count, plural, =0 {# publicación} one {# publicación} other {# publicaciones}}",
"search.top.filters.display": "Mostrar Resultados",
"search.top.result-more-than": "Más de ",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/networks/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"networks.filters.current.publications.type": "Type de publication",
"networks.filters.current.publications.year": "Années de publication",
"networks.filters.current.publications.projects.type": "Type de financement",
"networks.filters.current.publications.tags.id": "Tags",
"networks.filters.display": "Afficher les résultats",
"networks.filters.title": "Filtres",
"networks.filters.active-filter-title": "Filtres actifs",
Expand All @@ -79,6 +80,8 @@
"search.filters.publications.by-organization-description": "Sélectionnez une ou plusieurs affiliations",
"search.filters.publications.by-country": "Filtrer par pays",
"search.filters.publications.by-country-description": "Sélectionnez un ou plusieurs pays",
"search.filters.publications.by-tag": "Filter par tag",
"search.filters.publications.by-tag-description": "Sélectionnez un ou plusieurs tag",
"search.top.publications.filters.result-count": "{count, plural, =0 {# publication} one {# publication} other {# publications}}",
"search.top.filters.display": "Afficher les résultats",
"search.top.result-more-than": "Plus de ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import PublicationFunderFilter from "./funders";
import PublicationTypeFilter from "./types";
import PublicationYearFilter from "./years";
import PublicationCountriesFilter from "./countries"

import PublicationTagsFilter from "./tags"

export default function PublicationFilters() {
const intl = useIntl()
const { total, search: { isFetching } } = useSearchData();
const {
total,
search: { isFetching },
} = useSearchData()
const { api } = useUrl()
const id = `${api}-filters`

Expand All @@ -37,6 +40,8 @@ export default function PublicationFilters() {
<hr className="fr-mt-3w" />
<PublicationFunderFilter />
<hr className="fr-mt-3w" />
<PublicationTagsFilter />
<hr className="fr-mt-3w" />
</Container>
<div className="fr-modal__footer fr-px-0" style={{ display: "flex", width: "100%", alignItems: "center" }}>
<div style={{ flexGrow: 1 }}>
Expand Down
26 changes: 26 additions & 0 deletions client/src/pages/search/components/publications/filters/tags.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { TagInput, Text } from "@dataesr/dsfr-plus"
import { FormattedMessage } from "react-intl"
import useUrl from "../../../hooks/useUrl"

export default function PublicationTagsFilter() {
const { currentFilters, handleFilterChange } = useUrl()

const key = JSON.stringify(currentFilters?.["tags.id"]?.values?.map((tag) => String(tag.value)) || {})

return (
<>
<Text className="fr-mb-1v" bold size="md">
<FormattedMessage id="search.filters.publications.by-tag" />
</Text>
<Text className="fr-card__detail fr-mb-2w" size="sm">
<FormattedMessage id="search.filters.publications.by-tag-description" />
</Text>
<TagInput
key={key}
label=""
tags={currentFilters?.["tags.id"]?.values?.map((tag) => String(tag.value))}
onTagsChange={(tags) => tags.forEach((tag) => handleFilterChange({ field: "tags.id", value: tag }))}
/>
</>
)
}
3 changes: 3 additions & 0 deletions client/src/pages/search/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"search.filters.publications.by-organization-description": "Eine oder mehrere Zugehörigkeiten auswählen",
"search.filters.publications.by-country": "Nach Land filtern",
"search.filters.publications.by-country-description": "Wählen Sie ein oder mehrere Länder aus",
"search.filters.publications.by-tag": "Nach Tag filtern",
"search.filters.publications.by-tag-description": "Wählen Sie einen oder mehrere Tags aus",
"search.filters.organizations.by-project": "Nach Finanzierungstyp filtern",
"search.filters.organizations.by-project-description": "Einen oder mehrere Finanzierungstypen auswählen",
"search.filters.organizations.by-kind": "Nach Sektor filtern",
Expand Down Expand Up @@ -133,6 +135,7 @@
"search.filters.current.projects.participants.structure.mainAddress.localisationSuggestions": "Standort eines Teilnehmers",
"search.filters.current.projects.participants.structure.id": "Teilnehmer",
"search.filters.current.publications.isOa": "Zugriffstyp",
"search.filters.current.publications.tags.id": "Tags",
"search.filters.current.patents.isInternational": "Ausgewählte Region",
"search.filters.current.patents.isOeb": "Ausgewählte Region",
"search.filters.current.patents.isGranted": "Ausgestellte Patente",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/search/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"search.filters.publications.by-organization-description": "Select one or more affiliations",
"search.filters.publications.by-country": "Filter by Country",
"search.filters.publications.by-country-description": "Select one or more countries",
"search.filters.publications.by-tag": "Filter by Tag",
"search.filters.publications.by-tag-description": "Select one or more tag",
"search.filters.organizations.by-project": "Filter by funding Type",
"search.filters.organizations.by-project-description": "Select one or more funding types",
"search.filters.organizations.by-kind": "Filter by sector",
Expand Down Expand Up @@ -130,6 +132,7 @@
"search.filters.current.projects.participants.structure.mainAddress.localisationSuggestions": "Location of a participant",
"search.filters.current.projects.participants.structure.id": "Participants",
"search.filters.current.publications.isOa": "Access type",
"search.filters.current.publications.tags.id": "Tags",
"search.filters.current.patents.isInternational": "Selected region",
"search.filters.current.patents.isOeb": "Selected region",
"search.filters.current.patents.isGranted": "Granted patents",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/search/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"search.filters.publications.by-organization-description": "Selecciona una o más afiliaciones",
"search.filters.publications.by-country": "Filtrar por país",
"search.filters.publications.by-country-description": "Seleccione uno o más países",
"search.filters.publications.by-tag": "Filtrar por etiqueta",
"search.filters.publications.by-tag-description": "Seleccione una o más etiquetas",
"search.filters.organizations.by-project": "Filtrar por Tipo de Financiamiento",
"search.filters.organizations.by-project-description": "Selecciona uno o más tipos de financiamiento",
"search.filters.organizations.by-kind": "Filtrar por Sector",
Expand Down Expand Up @@ -133,6 +135,7 @@
"search.filters.current.projects.participants.structure.mainAddress.localisationSuggestions": "Ubicación de un Participante",
"search.filters.current.projects.participants.structure.id": "Participantes",
"search.filters.current.publications.isOa": "Tipo de Acceso",
"search.filters.current.publications.tags.id": "Etiquetas",
"search.filters.current.patents.isInternational": "Región Seleccionada",
"search.filters.current.patents.isOeb": "Región Seleccionada",
"search.filters.current.patents.isGranted": "Patentes Concedidas",
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/search/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"search.filters.publications.by-organization-description": "Sélectionnez une ou plusieurs affiliations",
"search.filters.publications.by-country": "Filtrer par pays",
"search.filters.publications.by-country-description": "Sélectionnez un ou plusieurs pays",
"search.filters.publications.by-tag": "Filter par tag",
"search.filters.publications.by-tag-description": "Sélectionnez un ou plusieurs tag",
"search.filters.organizations.by-project": "Filtrer par type de financement",
"search.filters.organizations.by-project-description": "Sélectionnez un ou plusieurs types de financement",
"search.filters.organizations.by-kind": "Filtrer par secteur",
Expand Down Expand Up @@ -134,6 +136,7 @@
"search.filters.current.projects.participants.structure.mainAddress.localisationSuggestions": "Localisation d'un participant",
"search.filters.current.projects.participants.structure.id": "Participants",
"search.filters.current.publications.isOa": "Type d'accès",
"search.filters.current.publications.tags.id": "Tags",
"search.filters.current.patents.isInternational": "Région selectionnée",
"search.filters.current.patents.isOeb": "Région selectionnée",
"search.filters.current.patents.isGranted": "Les brevets délivrés",
Expand Down
5 changes: 1 addition & 4 deletions client/src/types/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ export type NetworkSearchArgs = {
model: string
query?: string
filters?: NetworkFilters
options?: {
computeClusters?: boolean
lang?: string
}
lang?: string
parameters?: NetworkParameters
}
export type NetworkSearchHitsArgs = {
Expand Down

0 comments on commit cdfc29e

Please sign in to comment.