diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 3652459c..9fc9c9b6 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -6,7 +6,7 @@ on: - "v[0-9]+.[0-9]+.[0-9]+" env: - DEPLOYMENT: scanr-next-gen + DEPLOYMENT: scanr-ui DEPLOYMENT_NAMESPACE: scanr DEPLOYMENT_URL: https://scanr.dataesr.ovh MM_NOTIFICATION_CHANNEL: bots diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 7b60905d..85b71f92 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -6,7 +6,7 @@ on: - staging env: - DEPLOYMENT: scanr-next-gen + DEPLOYMENT: scanr-ui DEPLOYMENT_NAMESPACE: scanr DEPLOYMENT_URL: https://scanr.staging.dataesr.ovh MM_NOTIFICATION_CHANNEL: bots diff --git a/client/src/api/networks/network/config.ts b/client/src/api/networks/network/config.ts index c892024d..4b405175 100644 --- a/client/src/api/networks/network/config.ts +++ b/client/src/api/networks/network/config.ts @@ -92,6 +92,5 @@ export default function configCreate(model: string): NetworkConfig { ...(terminology && { terminology: terminology }), } - console.log("config", config) return config } diff --git a/client/src/api/networks/network/network.ts b/client/src/api/networks/network/network.ts index 347dca02..19bce30b 100644 --- a/client/src/api/networks/network/network.ts +++ b/client/src/api/networks/network/network.ts @@ -55,8 +55,6 @@ export default async function networkCreate( })) }) - console.log(`Graph items=${graph.order}, links=${graph.size}, components=${connectedComponents(graph).length}`) - // Keep only largests components const sortedComponents = connectedComponents(graph).sort((a, b) => b.length - a.length) let numberOfComponents = GRAPH_MAX_COMPONENTS @@ -65,38 +63,15 @@ export default async function networkCreate( numberOfComponents -= 1 graph = subgraph(graph, sortedComponents.slice(0, numberOfComponents).flat()) } - console.log(`Components graph items=${graph.order}, links=${graph.size}, components=${connectedComponents(graph).length}`) - - // Filter with minimal number of nodes - // let nodeWeightThresh = 1 - // while (graph.order > GRAPH_MAX_ORDER) { - // nodeWeightThresh += 1 - // graph = subgraph(graph, (_, attr) => attr?.weight >= nodeWeightThresh) // eslint-disable-line no-loop-func - // } - - // console.log(`Filtered graph items=${graph.order}, links=${graph.size}, components=${connectedComponents(graph).length}`) - - // Filter with minimal number of edges - // let edgeWeightThresh = 1 - // while (graph.size / graph.order > GRAPH_MAX_RATIO) { - // edgeWeightThresh += 1 - // graph.filterEdges((edge, attr) => attr?.weight < edgeWeightThresh).forEach((edge) => graph.dropEdge(edge)) // eslint-disable-line no-loop-func - // graph = subgraph(graph, (node) => graph.degree(node) > 0) // eslint-disable-line no-loop-func - // } - // console.log("Edge weight threshold :", edgeWeightThresh) // Add forceAtlas layout random.assign(graph) // Needs a starting layout for forceAtlas to work const sensibleSettings = forceAtlas2.inferSettings(graph) forceAtlas2.assign(graph, { iterations: 100, settings: sensibleSettings }) - console.log("Atlas2 settings", sensibleSettings) // Add communities const communities = await communitiesCreate(graph, computeClusters) - console.log("Communities", communities) - console.log("Graph nodes", Array.from(graph.nodeEntries())) - // Create network const network: NetworkData = { items: graph.mapNodes((key, attr) => ({ @@ -117,6 +92,5 @@ export default async function networkCreate( clusters: communities, } - console.log("network", network) return network } diff --git a/client/src/api/networks/network/openai.ts b/client/src/api/networks/network/openai.ts index 144bcadb..38219fed 100644 --- a/client/src/api/networks/network/openai.ts +++ b/client/src/api/networks/network/openai.ts @@ -31,7 +31,6 @@ async function mistralLabelsFromDomains(domains: string): Promise { randomSeed: 42, }) - console.log("mistral_completion", completion) const answer: string = completion.choices[0].message.content return answer } @@ -52,7 +51,6 @@ export async function openAiLabeledClusters(clusters: NetworkCommunities): Promi } return acc }, "") as string - console.log("domains", domains) if (!domains) return clusters @@ -60,7 +58,6 @@ export async function openAiLabeledClusters(clusters: NetworkCommunities): Promi (response) => JSON.parse(response), (err) => console.log(err) ) - console.log("mistral_labels", mistral_labels) if (!mistral_labels || mistral_labels.constructor != Object) { return clusters } diff --git a/client/src/api/networks/search/search.ts b/client/src/api/networks/search/search.ts index 4b6d41ab..609aed37 100644 --- a/client/src/api/networks/search/search.ts +++ b/client/src/api/networks/search/search.ts @@ -35,7 +35,6 @@ export async function networkSearch({ model, query, options, filters }: NetworkS if (filters && filters.length > 0) body.query.bool.filter = filters if (!query) body.query = { function_score: { query: body.query, random_score: {} } } - console.log("networkSearch", body) const res = await fetch(`${publicationsIndex}/_search`, { method: "POST", @@ -46,7 +45,6 @@ export async function networkSearch({ model, query, options, filters }: NetworkS throw new Error(`Elasticsearch error: ${res.status}`) } const json = await res.json() - console.log("endOfSearch", json) const aggregation = json.aggregations?.[model].buckets if (!aggregation?.length) { @@ -69,7 +67,6 @@ export async function networkSearch({ model, query, options, filters }: NetworkS info: info, } - console.log("data", data) return data } diff --git a/client/src/hooks/useConsent.ts b/client/src/hooks/useConsent.ts index b1c7436c..cfb55f5e 100644 --- a/client/src/hooks/useConsent.ts +++ b/client/src/hooks/useConsent.ts @@ -2,66 +2,75 @@ import { useEffect, useState } from "react"; type Consent = { [key: string]: 0 | 1; -} +}; type UseConsent = { consent: Consent; setConsent: (newConcent: Consent) => void; set: boolean; dialogId: string; -} +}; if (typeof Proxy === "undefined") { throw new Error("This browser doesn't support Proxy"); } -const dialogId = 'fr-consent-dialog'; -const consentKey = 'consent'; +const dialogId = "fr-consent-dialog"; +const consentKey = "consent"; export default function useConsent(defaultConsent: Consent = {}): UseConsent { const [set, setSet] = useState(false); const readValue = (): Consent => { - const storedConsentString = localStorage.getItem(consentKey); - const storedConsent = storedConsentString ? JSON.parse(storedConsentString) : null; + let storedConsentString = localStorage.getItem(consentKey); + let storedConsent = null; + try { + storedConsent = JSON.parse(storedConsentString); + } catch (e) { + storedConsentString = ""; + } setSet(!!storedConsent); return storedConsent || defaultConsent; - } + }; const [innerConsent, setInnerConsent] = useState(() => readValue()); const consent = new Proxy(innerConsent, { get: function (target, key) { - if (typeof key === 'string') { + if (typeof key === "string") { return target[key]; } return undefined; }, set: function (target, key, val) { - if (typeof key === 'string') { + if (typeof key === "string") { setInnerConsent({ ...innerConsent, [key]: val }); target[key] = val; return true; } return false; - } + }, }); const setConsent = (newConcent) => { - localStorage.setItem(consentKey, JSON.stringify(newConcent || innerConsent)); - window.dispatchEvent(new StorageEvent('local-storage', { key: consentKey })) - } + localStorage.setItem( + consentKey, + JSON.stringify(newConcent || innerConsent) + ); + window.dispatchEvent( + new StorageEvent("local-storage", { key: consentKey }) + ); + }; useEffect(() => { const handleStorage = (e: StorageEvent) => { if (e.key === consentKey) { setInnerConsent(readValue()); } - } - window.addEventListener('local-storage', handleStorage); + }; + window.addEventListener("local-storage", handleStorage); return () => { - window.removeEventListener('local-storage', handleStorage); - } + window.removeEventListener("local-storage", handleStorage); + }; }); - return { consent, setConsent, set, dialogId }; -} \ No newline at end of file +} diff --git a/client/src/layout/components/footer/index.tsx b/client/src/layout/components/footer/index.tsx index 4a49c875..5b17dc33 100644 --- a/client/src/layout/components/footer/index.tsx +++ b/client/src/layout/components/footer/index.tsx @@ -329,7 +329,7 @@ export default function MainFooter() { target="_blank" rel="noreferer noopenner" className="fr-footer__bottom-link" - href={`https://github.com/dataesr/scanr-next-gen/releases/tag/v${version}`} + href={`https://github.com/dataesr/scanr-ui/releases/tag/v${version}`} > {intl.formatMessage({ id: "layout.footer.version" }, { version })} diff --git a/client/src/pages/networks/components/analytics.tsx b/client/src/pages/networks/components/analytics.tsx index f8ecb662..7b831bc1 100644 --- a/client/src/pages/networks/components/analytics.tsx +++ b/client/src/pages/networks/components/analytics.tsx @@ -22,7 +22,6 @@ export default function ClustersAnalytics({ clustersTabs, show }: { clustersTabs const sizeChartOptions = getSizeChartOptions({ data: clusters.slice(0, 10) }) const oaChartOptions = getOaChartOptions({ data: clusters.slice(0, 10) }) const yearsChartOptions = getYearsChartOptions({ data: clusters.slice(0, 10) }) - console.log(yearsChartOptions) return ( diff --git a/client/src/pages/networks/components/graph.tsx b/client/src/pages/networks/components/graph.tsx index 9e09b14f..a1523abc 100644 --- a/client/src/pages/networks/components/graph.tsx +++ b/client/src/pages/networks/components/graph.tsx @@ -1,15 +1,16 @@ import { useMemo } from "react" import { Container, Spinner } from "@dataesr/dsfr-plus" import { VOSviewerOnline } from "vosviewer-online" +import { useDSFRConfig } from "@dataesr/dsfr-plus" import useSearchData from "../hooks/useSearchData" import Error204 from "./error204" export default function Graph({ currentTab, computeClusters }: { currentTab: string; computeClusters: boolean }) { const { search, currentQuery, filters } = useSearchData(currentTab, false) const { search: searchClusters } = useSearchData(currentTab, computeClusters) + const { locale: lang } = useDSFRConfig() const keyClusters = searchClusters.isFetching ? false : computeClusters const vosviewer = keyClusters ? searchClusters?.data : search?.data - const lang = document.documentElement.getAttribute("lang") const key = useMemo( () => JSON.stringify({ currentTab, currentQuery, filters, keyClusters, lang }), [currentTab, currentQuery, filters, keyClusters, lang] diff --git a/client/src/pages/networks/hooks/useExportData.ts b/client/src/pages/networks/hooks/useExportData.ts index a8ad1a24..1ab69562 100644 --- a/client/src/pages/networks/hooks/useExportData.ts +++ b/client/src/pages/networks/hooks/useExportData.ts @@ -60,7 +60,6 @@ export default function useExportData() { setIsLoading(true) const network = exportNetwork(search?.data?.network) const blob = exporter(format)(network) - console.log("blob", blob) const url = window.URL.createObjectURL(blob) const link = document.createElement("a") link.href = url diff --git a/client/src/pages/networks/hooks/useSearchData.ts b/client/src/pages/networks/hooks/useSearchData.ts index 3a6d8238..94151887 100644 --- a/client/src/pages/networks/hooks/useSearchData.ts +++ b/client/src/pages/networks/hooks/useSearchData.ts @@ -1,5 +1,6 @@ import { useQuery } from "@tanstack/react-query" import { useMemo } from "react" +import { useDSFRConfig } from "@dataesr/dsfr-plus" import useUrl from "../../search/hooks/useUrl" import useTab from "./useTab" import { networkSearch } from "../../../api/networks/search/search" @@ -7,7 +8,7 @@ import { networkSearch } from "../../../api/networks/search/search" export default function useSearchData(networkTab: string, computeClusters: boolean) { const { currentQuery, filters } = useUrl() const { currentTab } = useTab() - const lang = document.documentElement.getAttribute("lang") + const { locale: lang } = useDSFRConfig() const { data, error, isFetching } = useQuery({ queryKey: ["network", networkTab, currentQuery, filters, computeClusters, lang],