From a34770070d95bac51376f24488e8418565bddf11 Mon Sep 17 00:00:00 2001 From: henrietteharmse Date: Wed, 8 Nov 2023 11:06:12 +0000 Subject: [PATCH 01/11] Updated Solr and Neo4J K8s memory requests to reflect production use. --- k8chart/ols4/templates/ols4-neo4j-deployment.yaml | 2 +- k8chart/ols4/templates/ols4-solr-deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/k8chart/ols4/templates/ols4-neo4j-deployment.yaml b/k8chart/ols4/templates/ols4-neo4j-deployment.yaml index ac040d8af..7df78f2f5 100644 --- a/k8chart/ols4/templates/ols4-neo4j-deployment.yaml +++ b/k8chart/ols4/templates/ols4-neo4j-deployment.yaml @@ -28,7 +28,7 @@ spec: args: ["rm -rf /data/* && wget -qO- $NEO4J_TARBALL_URL | tar -xz -C /data/ && tini -g -- /startup/docker-entrypoint.sh neo4j"] resources: requests: - memory: 10Gi + memory: 15Gi cpu: 0.5 limits: memory: 20Gi diff --git a/k8chart/ols4/templates/ols4-solr-deployment.yaml b/k8chart/ols4/templates/ols4-solr-deployment.yaml index e0f3d3d4b..2d49477ce 100644 --- a/k8chart/ols4/templates/ols4-solr-deployment.yaml +++ b/k8chart/ols4/templates/ols4-solr-deployment.yaml @@ -30,7 +30,7 @@ spec: args: ["echo Downloading data && rm -rf /data/solr && mkdir /data/solr && wget -qO- $SOLR_TARBALL_URL | tar -xz -C /data/ && echo Starting solr && solr-foreground -a -XX:CompileCommand=exclude,com.github.benmanes.caffeine.cache.BoundedLocalCache::put"] resources: requests: - memory: 10Gi + memory: 15Gi cpu: 2 limits: memory: 20Gi From 1560000640af111f1f30dd1e90a4db2b4f05b8d1 Mon Sep 17 00:00:00 2001 From: henrietteharmse Date: Fri, 24 Nov 2023 09:44:36 +0000 Subject: [PATCH 02/11] Solr hitting CPU limit on prod. --- k8chart/ols4/templates/ols4-solr-deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8chart/ols4/templates/ols4-solr-deployment.yaml b/k8chart/ols4/templates/ols4-solr-deployment.yaml index 2d49477ce..e89a0fa10 100644 --- a/k8chart/ols4/templates/ols4-solr-deployment.yaml +++ b/k8chart/ols4/templates/ols4-solr-deployment.yaml @@ -31,10 +31,10 @@ spec: resources: requests: memory: 15Gi - cpu: 2 + cpu: 3 limits: memory: 20Gi - cpu: 2 + cpu: 3 env: - name: SOLR_TARBALL_URL value: {{.Values.solrTarballUrl}} From 9462a71596f28cff10f006647bda6f8b2a19468f Mon Sep 17 00:00:00 2001 From: henrietteharmse Date: Fri, 24 Nov 2023 11:16:03 +0000 Subject: [PATCH 03/11] Revert "Merge remote-tracking branch 'origin/stable' into stable" This reverts commit a6b617d9bef03c6917015722458dcfeed83f5d33, reversing changes made to 1560000640af111f1f30dd1e90a4db2b4f05b8d1. --- .../controller/api/v1/V1SearchController.java | 2 +- .../ols/repository/solr/OlsSolrQuery.java | 38 ++++++++++--------- .../v2/helpers/V2SearchFieldsParser.java | 1 + .../src/pages/ontologies/ontologiesSlice.ts | 1 - 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java b/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java index 1d641b071..e2cb35e64 100644 --- a/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java +++ b/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java @@ -242,7 +242,7 @@ public void search( Map responseBody = new HashMap<>(); responseBody.put("numFound", qr.getResults().getNumFound()); - responseBody.put("start", start); + responseBody.put("start", 0); responseBody.put("docs", docs); Map responseObj = new HashMap<>(); diff --git a/backend/src/main/java/uk/ac/ebi/spot/ols/repository/solr/OlsSolrQuery.java b/backend/src/main/java/uk/ac/ebi/spot/ols/repository/solr/OlsSolrQuery.java index 58a895d67..b74500a84 100644 --- a/backend/src/main/java/uk/ac/ebi/spot/ols/repository/solr/OlsSolrQuery.java +++ b/backend/src/main/java/uk/ac/ebi/spot/ols/repository/solr/OlsSolrQuery.java @@ -68,7 +68,8 @@ public SolrQuery constructQuery() { if(qf.length() > 0) { qf.append(" "); } - qf.append(ClientUtils.escapeQueryChars( getSolrPropertyName(searchField.propertyName, exactMatch ? SearchType.WHOLE_FIELD : searchField.searchType)) ); + qf.append(ClientUtils.escapeQueryChars( getSolrPropertyName(searchField.propertyName, + exactMatch ? SearchType.WHOLE_FIELD : searchField.searchType)) ); qf.append("^"); qf.append(searchField.weight); } @@ -177,22 +178,25 @@ public BoostField(String propertyName, String propertyValue, int weight, SearchT } private String getSolrPropertyName(String propertyName, SearchType searchType) { - switch(searchType) { - case CASE_INSENSITIVE_TOKENS: - return "lowercase_" + propertyName; - case CASE_SENSITIVE_TOKENS: - return propertyName; - case WHOLE_FIELD: - return "str_" + propertyName; - case EDGES: - return "edge_" + propertyName; - case WHITESPACE: - return "whitespace_" + propertyName; - case WHITESPACE_EDGES: - return "whitespace_edge_" + propertyName; - default: - throw new RuntimeException("unknown filter accuracy"); - } + if (propertyName.compareTo("_json") == 0) + return propertyName; + else + switch(searchType) { + case CASE_INSENSITIVE_TOKENS: + return "lowercase_" + propertyName; + case CASE_SENSITIVE_TOKENS: + return propertyName; + case WHOLE_FIELD: + return "str_" + propertyName; + case EDGES: + return "edge_" + propertyName; + case WHITESPACE: + return "whitespace_" + propertyName; + case WHITESPACE_EDGES: + return "whitespace_edge_" + propertyName; + default: + throw new RuntimeException("unknown filter accuracy"); + } } private String getSolrPropertyValue(String propertyValue, SearchType searchType) { diff --git a/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/helpers/V2SearchFieldsParser.java b/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/helpers/V2SearchFieldsParser.java index 6a2cff813..a39c1b461 100644 --- a/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/helpers/V2SearchFieldsParser.java +++ b/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/helpers/V2SearchFieldsParser.java @@ -25,6 +25,7 @@ public static void addSearchFieldsToQuery(OlsSolrQuery query, String searchField query.addSearchField(field.property, field.weight, SearchType.CASE_INSENSITIVE_TOKENS); } } + query.addSearchField("_json", 1, SearchType.CASE_INSENSITIVE_TOKENS); } public static void addBoostFieldsToQuery(OlsSolrQuery query, String boostFields) { diff --git a/frontend/src/pages/ontologies/ontologiesSlice.ts b/frontend/src/pages/ontologies/ontologiesSlice.ts index 9314b7fe4..9395981f6 100644 --- a/frontend/src/pages/ontologies/ontologiesSlice.ts +++ b/frontend/src/pages/ontologies/ontologiesSlice.ts @@ -132,7 +132,6 @@ export const getEntityWithType = createAsyncThunk( { rejectWithValue } ) => { const apiSearchParams = mapToApiParams(searchParams); - apiSearchParams.set("includeObsoleteEntities", "true"); const doubleEncodedTermUri = encodeURIComponent( encodeURIComponent(entityIri) ); From 9d4072fd273f2a383da15181967601dfdc8d5203 Mon Sep 17 00:00:00 2001 From: henrietteharmse Date: Fri, 24 Nov 2023 11:43:29 +0000 Subject: [PATCH 04/11] Revert "Revert "Merge remote-tracking branch 'origin/stable' into stable"" This reverts commit 9462a71596f28cff10f006647bda6f8b2a19468f. --- .../controller/api/v1/V1SearchController.java | 2 +- .../ols/repository/solr/OlsSolrQuery.java | 38 +++++++++---------- .../v2/helpers/V2SearchFieldsParser.java | 1 - .../src/pages/ontologies/ontologiesSlice.ts | 1 + 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java b/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java index e2cb35e64..1d641b071 100644 --- a/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java +++ b/backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v1/V1SearchController.java @@ -242,7 +242,7 @@ public void search( Map responseBody = new HashMap<>(); responseBody.put("numFound", qr.getResults().getNumFound()); - responseBody.put("start", 0); + responseBody.put("start", start); responseBody.put("docs", docs); Map responseObj = new HashMap<>(); diff --git a/backend/src/main/java/uk/ac/ebi/spot/ols/repository/solr/OlsSolrQuery.java b/backend/src/main/java/uk/ac/ebi/spot/ols/repository/solr/OlsSolrQuery.java index b74500a84..58a895d67 100644 --- a/backend/src/main/java/uk/ac/ebi/spot/ols/repository/solr/OlsSolrQuery.java +++ b/backend/src/main/java/uk/ac/ebi/spot/ols/repository/solr/OlsSolrQuery.java @@ -68,8 +68,7 @@ public SolrQuery constructQuery() { if(qf.length() > 0) { qf.append(" "); } - qf.append(ClientUtils.escapeQueryChars( getSolrPropertyName(searchField.propertyName, - exactMatch ? SearchType.WHOLE_FIELD : searchField.searchType)) ); + qf.append(ClientUtils.escapeQueryChars( getSolrPropertyName(searchField.propertyName, exactMatch ? SearchType.WHOLE_FIELD : searchField.searchType)) ); qf.append("^"); qf.append(searchField.weight); } @@ -178,25 +177,22 @@ public BoostField(String propertyName, String propertyValue, int weight, SearchT } private String getSolrPropertyName(String propertyName, SearchType searchType) { - if (propertyName.compareTo("_json") == 0) - return propertyName; - else - switch(searchType) { - case CASE_INSENSITIVE_TOKENS: - return "lowercase_" + propertyName; - case CASE_SENSITIVE_TOKENS: - return propertyName; - case WHOLE_FIELD: - return "str_" + propertyName; - case EDGES: - return "edge_" + propertyName; - case WHITESPACE: - return "whitespace_" + propertyName; - case WHITESPACE_EDGES: - return "whitespace_edge_" + propertyName; - default: - throw new RuntimeException("unknown filter accuracy"); - } + switch(searchType) { + case CASE_INSENSITIVE_TOKENS: + return "lowercase_" + propertyName; + case CASE_SENSITIVE_TOKENS: + return propertyName; + case WHOLE_FIELD: + return "str_" + propertyName; + case EDGES: + return "edge_" + propertyName; + case WHITESPACE: + return "whitespace_" + propertyName; + case WHITESPACE_EDGES: + return "whitespace_edge_" + propertyName; + default: + throw new RuntimeException("unknown filter accuracy"); + } } private String getSolrPropertyValue(String propertyValue, SearchType searchType) { diff --git a/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/helpers/V2SearchFieldsParser.java b/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/helpers/V2SearchFieldsParser.java index a39c1b461..6a2cff813 100644 --- a/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/helpers/V2SearchFieldsParser.java +++ b/backend/src/main/java/uk/ac/ebi/spot/ols/repository/v2/helpers/V2SearchFieldsParser.java @@ -25,7 +25,6 @@ public static void addSearchFieldsToQuery(OlsSolrQuery query, String searchField query.addSearchField(field.property, field.weight, SearchType.CASE_INSENSITIVE_TOKENS); } } - query.addSearchField("_json", 1, SearchType.CASE_INSENSITIVE_TOKENS); } public static void addBoostFieldsToQuery(OlsSolrQuery query, String boostFields) { diff --git a/frontend/src/pages/ontologies/ontologiesSlice.ts b/frontend/src/pages/ontologies/ontologiesSlice.ts index 9395981f6..9314b7fe4 100644 --- a/frontend/src/pages/ontologies/ontologiesSlice.ts +++ b/frontend/src/pages/ontologies/ontologiesSlice.ts @@ -132,6 +132,7 @@ export const getEntityWithType = createAsyncThunk( { rejectWithValue } ) => { const apiSearchParams = mapToApiParams(searchParams); + apiSearchParams.set("includeObsoleteEntities", "true"); const doubleEncodedTermUri = encodeURIComponent( encodeURIComponent(entityIri) ); From 605ad899f3aec2825f7a266e9fab6104f784e8a2 Mon Sep 17 00:00:00 2001 From: henrietteharmse Date: Fri, 24 Nov 2023 11:44:28 +0000 Subject: [PATCH 05/11] Revert "Merge remote-tracking branch 'origin/stable' into stable" This reverts commit a6b617d9bef03c6917015722458dcfeed83f5d33, reversing changes made to cce671894596cbc5980edbf72e60413c92cfcd9c. --- k8chart/ols4/templates/ols4-solr-deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8chart/ols4/templates/ols4-solr-deployment.yaml b/k8chart/ols4/templates/ols4-solr-deployment.yaml index e89a0fa10..2d49477ce 100644 --- a/k8chart/ols4/templates/ols4-solr-deployment.yaml +++ b/k8chart/ols4/templates/ols4-solr-deployment.yaml @@ -31,10 +31,10 @@ spec: resources: requests: memory: 15Gi - cpu: 3 + cpu: 2 limits: memory: 20Gi - cpu: 3 + cpu: 2 env: - name: SOLR_TARBALL_URL value: {{.Values.solrTarballUrl}} From 068df36b29dbf1924948fb5bf92c65b83fcf586e Mon Sep 17 00:00:00 2001 From: henrietteharmse Date: Fri, 24 Nov 2023 11:55:49 +0000 Subject: [PATCH 06/11] Prod hitting CPU limit. --- k8chart/ols4/templates/ols4-solr-deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8chart/ols4/templates/ols4-solr-deployment.yaml b/k8chart/ols4/templates/ols4-solr-deployment.yaml index 2d49477ce..e89a0fa10 100644 --- a/k8chart/ols4/templates/ols4-solr-deployment.yaml +++ b/k8chart/ols4/templates/ols4-solr-deployment.yaml @@ -31,10 +31,10 @@ spec: resources: requests: memory: 15Gi - cpu: 2 + cpu: 3 limits: memory: 20Gi - cpu: 2 + cpu: 3 env: - name: SOLR_TARBALL_URL value: {{.Values.solrTarballUrl}} From 9a5614c458e6047a59a8171bb41cde2593173a63 Mon Sep 17 00:00:00 2001 From: henrietteharmse Date: Fri, 24 Nov 2023 12:08:23 +0000 Subject: [PATCH 07/11] Revert "Prod hitting CPU limit." This reverts commit 068df36b29dbf1924948fb5bf92c65b83fcf586e. --- k8chart/ols4/templates/ols4-solr-deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8chart/ols4/templates/ols4-solr-deployment.yaml b/k8chart/ols4/templates/ols4-solr-deployment.yaml index e89a0fa10..2d49477ce 100644 --- a/k8chart/ols4/templates/ols4-solr-deployment.yaml +++ b/k8chart/ols4/templates/ols4-solr-deployment.yaml @@ -31,10 +31,10 @@ spec: resources: requests: memory: 15Gi - cpu: 3 + cpu: 2 limits: memory: 20Gi - cpu: 3 + cpu: 2 env: - name: SOLR_TARBALL_URL value: {{.Values.solrTarballUrl}} From 49cf6f57aec1bf5e8b5943938602feb2c0178912 Mon Sep 17 00:00:00 2001 From: henrietteharmse Date: Wed, 29 Nov 2023 11:50:03 +0000 Subject: [PATCH 08/11] Increase Solr cpu request and limit. --- k8chart/ols4/templates/ols4-solr-deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8chart/ols4/templates/ols4-solr-deployment.yaml b/k8chart/ols4/templates/ols4-solr-deployment.yaml index 2d49477ce..e89a0fa10 100644 --- a/k8chart/ols4/templates/ols4-solr-deployment.yaml +++ b/k8chart/ols4/templates/ols4-solr-deployment.yaml @@ -31,10 +31,10 @@ spec: resources: requests: memory: 15Gi - cpu: 2 + cpu: 3 limits: memory: 20Gi - cpu: 2 + cpu: 3 env: - name: SOLR_TARBALL_URL value: {{.Values.solrTarballUrl}} From 73456630e30387018d833bea1684ed5aafb385e5 Mon Sep 17 00:00:00 2001 From: henrietteharmse Date: Wed, 29 Nov 2023 13:26:54 +0000 Subject: [PATCH 09/11] Increase Neo4j cpu request and limit. --- k8chart/ols4/templates/ols4-neo4j-deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8chart/ols4/templates/ols4-neo4j-deployment.yaml b/k8chart/ols4/templates/ols4-neo4j-deployment.yaml index 623033f96..0ac6f8e40 100644 --- a/k8chart/ols4/templates/ols4-neo4j-deployment.yaml +++ b/k8chart/ols4/templates/ols4-neo4j-deployment.yaml @@ -29,10 +29,10 @@ spec: resources: requests: memory: 15Gi - cpu: 0.5 + cpu: 3 limits: memory: 20Gi - cpu: 2 + cpu: 3 env: - name: NEO4J_HEAP_MEMORY value: 15g From 696e27c90ef0ed555a678f41e4c563d7119ea45b Mon Sep 17 00:00:00 2001 From: haider Date: Mon, 18 Mar 2024 15:00:01 +0000 Subject: [PATCH 10/11] - Add routing for ebi-lookup --- frontend/src/pages/home/Home.tsx | 42 +++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/home/Home.tsx b/frontend/src/pages/home/Home.tsx index 49a14a3cc..ff3d3035f 100644 --- a/frontend/src/pages/home/Home.tsx +++ b/frontend/src/pages/home/Home.tsx @@ -1,17 +1,57 @@ import moment from "moment"; -import { useEffect } from "react"; +import {useEffect, useState} from "react"; import { Link } from "react-router-dom"; import { useAppDispatch, useAppSelector } from "../../app/hooks"; import { Banner } from "../../components/Banner"; import Header from "../../components/Header"; import SearchBox from "../../components/SearchBox"; import { getBannerText, getStats } from "./homeSlice"; +import { useNavigate, useSearchParams } from "react-router-dom"; export default function Home() { const dispatch = useAppDispatch(); const stats = useAppSelector((state) => state.home.stats); const banner = useAppSelector((state) => state.home.bannerText); + /* + + The following code handles a special case where the user is redirected to the class page of a term. + The service which initiates this workflow is the ebi lookup service. http://www.ebi.ac.uk/ontology-lookup/?termId=ECO:0000353 + this url redirects to the OLS class page. It used to work in OLS3 but not in OLS 4. The following code is a workaround to make it work in OLS 4. + + Refer to this RT ticket for further details: https://helpdesk.ebi.ac.uk/Ticket/Display.html?id=714111 + + */ + + + const navigate = useNavigate(); + const [searchParams] = useSearchParams(); + const termId = searchParams.get("termId"); + const [iri, setIri] = useState(''); + + useEffect(() => { + const fetchEntity = async () => { + try { + const response = await fetch(`${process.env.REACT_APP_APIURL}api/v2/entities?search=${termId}`); + const data = await response.json(); + const entity = data.elements[0]; + setIri(entity.iri); + } catch (error) { + console.error('Failed to fetch entity:', error); + } + }; + + if (termId) { + fetchEntity(); + } + }, [termId]); + + useEffect(() => { + if (iri && termId) { + navigate(`/ontologies/${termId.split(':')[0].toLowerCase()}/classes?iri=${encodeURIComponent(iri)}`); + } + }, [iri, navigate]); + useEffect(() => { dispatch(getStats()); }, [dispatch]); From 7e1b1d3785a6238da1047c3d08d5cb611c46664d Mon Sep 17 00:00:00 2001 From: henrietteharmse <32327979+henrietteharmse@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:17:22 +0000 Subject: [PATCH 11/11] UI component, routing, issue templates and biolink (#634) * Update issue templates Removed "outdated ontology" tag from Bug report. * Update issue templates Template for documentation related issues. * - Update build widget script * - Add README.md * - Update package version * - Update README.md * Add routing support for ebi-lookup service (#631) * - Add routing for ebi lookup service * - Fix URL routing with env variable * - Add console log - Try diff caddy config * - REVERT - Add console log - REVERT - Try diff caddy config * Add biolink (#632) * Add biolink * fix typo --------- Co-authored-by: haider Co-authored-by: Haider Iqbal Co-authored-by: jamesamcl --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- ...ncorrect-or-insufficient-documentation-.md | 18 +++++ ebi_ontologies.json | 6 +- frontend/build_widgets.mjs | 6 +- frontend/dist_widgets/README.md | 71 +++++++++++++++++++ .../manually_maintained_types.d.ts | 15 ++-- frontend/dist_widgets/package.json | 7 +- frontend/src/widgets/index.ts | 6 +- 8 files changed, 111 insertions(+), 20 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/incorrect-or-insufficient-documentation-.md create mode 100644 frontend/dist_widgets/README.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b28b8c979..ea70569ce 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,7 @@ name: Bug report about: Create a report to help us improve title: '' -labels: bug, outdated ontology +labels: bug assignees: '' --- diff --git a/.github/ISSUE_TEMPLATE/incorrect-or-insufficient-documentation-.md b/.github/ISSUE_TEMPLATE/incorrect-or-insufficient-documentation-.md new file mode 100644 index 000000000..fab57b175 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/incorrect-or-insufficient-documentation-.md @@ -0,0 +1,18 @@ +--- +name: 'Incorrect or insufficient documentation ' +about: 'Used to report documentation related deficiencies ' +title: '' +labels: documentation +assignees: '' + +--- + +**Describe the documentation deficiency** + +**Url to existing documentation if applicable** + +**What are you trying to do?** +1. Name of ontology you are trying to access, if applicable: +2. URL of term you trying to access, if applicable: +3. Search criteria you are trying to search for: +4. Anything else? diff --git a/ebi_ontologies.json b/ebi_ontologies.json index aac0cb708..44cf9a0ad 100644 --- a/ebi_ontologies.json +++ b/ebi_ontologies.json @@ -1,6 +1,10 @@ { "ontologies": [ - + { + "id": "biolink", + "ontology_purl": "https://github.com/biolink/biolink-model/raw/master/project/owl/biolink_model.owl.ttl", + "homepage": "https://biolink.github.io/biolink-model/" + }, { "id": "semapv", "title": "Semantic Mapping Vocabulary", diff --git a/frontend/build_widgets.mjs b/frontend/build_widgets.mjs index 46f3473cc..00eca8adf 100644 --- a/frontend/build_widgets.mjs +++ b/frontend/build_widgets.mjs @@ -15,7 +15,8 @@ build({ plugins: [ ], logLevel: 'info', - sourcemap: 'linked' + sourcemap: 'linked', + format: "esm" }); console.log('### Building ols4_widgets.min.js') @@ -29,7 +30,8 @@ build({ ], logLevel: 'info', minify: true, - sourcemap: 'linked' + sourcemap: 'linked', + format: "esm" }); console.log('### Copying treestyles.css') diff --git a/frontend/dist_widgets/README.md b/frontend/dist_widgets/README.md new file mode 100644 index 000000000..c89f6f756 --- /dev/null +++ b/frontend/dist_widgets/README.md @@ -0,0 +1,71 @@ +# OLS4 Widgets + +OLS4 Widgets is a library for various ols components. At the moment only one component +is exposed called `entityTree` which is ideal for seamless ontology visualisations. + +## Installation + +You can install OLS4 Widgets using npm: + +```bash +npm i @ebi-ols/ols4-widgets +``` + +This command installs the latest version of OLS4 widgets and saves it as a dependency in your project's `package.json` file. + +## Usage + +After installation, you can use OLS4 Widgets in your project by including the necessary files and +initializing the widget with a simple javaScript command. Here's a quick example of +how to display the chebi tree in a **React** application: + +1. Import the dependencies in the js file you want to render the component: + +```javascript +import '@ebi-ols/ols4-widgets/treestyles.css' +import { useEffect, useRef } from 'react'; +import { createEntityTree } from '@ebi-ols/ols4-widgets/ols4_widgets'; +``` + +2. Create the function to render the tree: + +```javascript +function EntityTree() { + + let div = useRef() + + useEffect(() => { + if(div.current) { + createEntityTree({ + ontologyId: "chebi", + apiUrl: "https://www.ebi.ac.uk/ols4/" + }, div.current); + } + }, [div]) + + return
+} + +``` +**NOTE:** The main point to notice here is the ontologyId and the apiUrl. The ontologyId is the id of the ontology you want to display and the apiUrl is the base url of the OLS4 API. + +3. Add the element where you want the tree to appear in your HTML file: + +```javascript +function App() { +return ( +
+ +
+); +} +``` +### Example of the rendered tree + +![chebi-tree-render](https://github.com/EBISPOT/ols4/assets/13108541/b9e14c70-6be0-4007-8311-91605087d5ad) + + +## Features + +- Easy to integrate with any web application. +- Lightweight and fast. \ No newline at end of file diff --git a/frontend/dist_widgets/manually_maintained_types.d.ts b/frontend/dist_widgets/manually_maintained_types.d.ts index eb3b295f6..f36301c26 100644 --- a/frontend/dist_widgets/manually_maintained_types.d.ts +++ b/frontend/dist_widgets/manually_maintained_types.d.ts @@ -1,11 +1,6 @@ - -declare global { - interface OLSWidgets { - createEntityTree:(props:{ - iri?:string, - ontologyId:string, - apiUrl:string - }, target:Element)=>void - } -} +export function createEntityTree(props:{ + iri?:string, + ontologyId:string, + apiUrl:string +}, target:Element); diff --git a/frontend/dist_widgets/package.json b/frontend/dist_widgets/package.json index 941f1d87a..f394e9fda 100644 --- a/frontend/dist_widgets/package.json +++ b/frontend/dist_widgets/package.json @@ -1,6 +1,7 @@ { - "name": "ols4-widgets", - "version": "1.0.0", - "main": "ols4_widgets.min.js", + "name": "@ebi-ols/ols4-widgets", + "version": "1.0.2", + "type": "module", + "main": "ols4_widgets.js", "types": "manually_maintained_types.d.ts" } diff --git a/frontend/src/widgets/index.ts b/frontend/src/widgets/index.ts index f501984ec..63e3f7c2b 100644 --- a/frontend/src/widgets/index.ts +++ b/frontend/src/widgets/index.ts @@ -1,8 +1,8 @@ import { createEntityTree } from "./EntityTreeWidget" -window['OLSWidgets'] = { - createEntityTree -} +// window['OLSWidgets'] = { +// createEntityTree +// } export { createEntityTree }