From 773b1c2a361a2ce598db60149b31a828591614cb Mon Sep 17 00:00:00 2001 From: jrmartin Date: Mon, 26 May 2025 19:51:15 -0700 Subject: [PATCH 1/7] #116 - new ontology method --- src/api/endpoints/apiService.ts | 20 ++++++++++++++++++-- src/config.js | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/api/endpoints/apiService.ts b/src/api/endpoints/apiService.ts index d11682c0..9ecb8a66 100644 --- a/src/api/endpoints/apiService.ts +++ b/src/api/endpoints/apiService.ts @@ -79,7 +79,7 @@ export const getSelectedTermLabel = async (searchTerm: string): Promise { +export const createNewEntity = async ({ group, data, session }: { group: string; data: any; session: string }) => { try { const endpoint = `/${group}${API_CONFIG.REAL_API.CREATE_NEW_ENTITY}`; const response = await createPostRequest( @@ -123,5 +123,21 @@ export const createNewEntity = async ({group,data,session}: { group: string; dat status: error?.response?.status, }; } + +}; + +export const createNewOntology = async ({ user,token,ontologyName,title,subjects }: { + user: string; token: string; ontologyName: string; title: string; subjects: string[] }) => { + const endpoint = `/${user}/ontologies/uris/${ontologyName}/spec`; + + const data = { + title, + subjects, + }; -}; \ No newline at end of file + const response = await createPostRequest( + endpoint, + "application/json")(data); + + return response +}; diff --git a/src/config.js b/src/config.js index ca956942..bb265d87 100644 --- a/src/config.js +++ b/src/config.js @@ -30,6 +30,7 @@ export const API_CONFIG = { USER_SETTINGS: "/priv/settings", CREATE_NEW_ORGANIZATION: "/priv/org-new", CREATE_NEW_ENTITY: "/priv/entity-new", + CREATE_NEW_ONTOLOGY: "/{groupname}/ontologies/uris/{filename}/spec", GET_ORGANIZATIONS: "/priv/role-other", LOGOUT: "/priv/logout", }, From a54a66901fbfda19ecab7399609af53bfc9ce40b Mon Sep 17 00:00:00 2001 From: jrmartin Date: Mon, 26 May 2025 20:59:04 -0700 Subject: [PATCH 2/7] #116 - Create new ontology --- src/api/endpoints/apiService.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/api/endpoints/apiService.ts b/src/api/endpoints/apiService.ts index 49f470f1..cd52e057 100644 --- a/src/api/endpoints/apiService.ts +++ b/src/api/endpoints/apiService.ts @@ -125,7 +125,7 @@ export const createNewEntity = async ({ group, data, session }: { group: string; }; -export const createNewOntology = async ({ user,token,ontologyName,title,subjects }: { +export const createNewOntology = async ({ user, token , ontologyName , title , subjects }: { user: string; token: string; ontologyName: string; title: string; subjects: string[] }) => { const endpoint = `/${user}/ontologies/uris/${ontologyName}/spec`; @@ -133,10 +133,15 @@ export const createNewOntology = async ({ user,token,ontologyName,title,subjects title, subjects, }; + + const headers = { + 'Authorization': `Bearer ${token}`, + 'Content-Type': 'application/json', + }; const response = await createPostRequest( endpoint, - "application/json")(data); + headers )(data); return response }; From 5cde8fc9aaba65c801f41dffc93eff572b3dd744 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Mon, 2 Jun 2025 16:15:51 -0700 Subject: [PATCH 3/7] #116 - Create New Ontology methods --- src/api/endpoints/apiService.ts | 69 ++++++++++++++++--- .../SingleOrganization/CreateForkDialog.jsx | 67 ++++++++++++++---- src/components/SingleOrganization/index.jsx | 2 +- src/config.js | 1 + vite.config.js | 40 +++++++++++ 5 files changed, 154 insertions(+), 25 deletions(-) diff --git a/src/api/endpoints/apiService.ts b/src/api/endpoints/apiService.ts index cd52e057..63259dab 100644 --- a/src/api/endpoints/apiService.ts +++ b/src/api/endpoints/apiService.ts @@ -125,23 +125,70 @@ export const createNewEntity = async ({ group, data, session }: { group: string; }; -export const createNewOntology = async ({ user, token , ontologyName , title , subjects }: { - user: string; token: string; ontologyName: string; title: string; subjects: string[] }) => { - const endpoint = `/${user}/ontologies/uris/${ontologyName}/spec`; +export const createNewOntology = async ({ + groupname, + token, + ontologyName, + title, + subjects, +}: { + groupname: string; + token: string; + ontologyName: string; + title: string; + subjects: string[]; +}) => { + const endpoint = `/${groupname}/ontologies/uris/${ontologyName}/spec`; const data = { - title, - subjects, + title : title, + subjects : subjects, }; const headers = { - 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` }; - - const response = await createPostRequest( - endpoint, - headers )(data); - return response + try { + const postResponse = await createPostRequest(endpoint, headers)(data); + + // If the POST creates a new location, try fetching it (simulate follow-up GETs from the test) + if (postResponse?.location) { + const getResponse = await fetch(postResponse.location, { + headers: { + Accept: 'application/json', + }, + }); + + // Optionally fetch HTML if needed (like the .html equivalent in the Python test) + const htmlResponse = await fetch(endpoint, { + headers: { + Accept: 'text/html', + }, + }); + + return { + created: true, + data: postResponse, + jsonResponse: await getResponse.json(), + htmlAvailable: htmlResponse.ok, + }; + } + + return { + created: true, + data: postResponse, + }; + } catch (error: any) { + return { + created: false, + error: error?.response?.data || error.message, + }; + } }; + +export const getNewTokenApi = ({ groupname, data }: { groupname: string, data: any }) => { + const endpoint = `/${groupname}${API_CONFIG.REAL_API.API_NEW_TOKEN}`; + return createPostRequest(endpoint, { "Content-Type" : "application/json" })(data); +}; \ No newline at end of file diff --git a/src/components/SingleOrganization/CreateForkDialog.jsx b/src/components/SingleOrganization/CreateForkDialog.jsx index 0e879396..1573a55c 100644 --- a/src/components/SingleOrganization/CreateForkDialog.jsx +++ b/src/components/SingleOrganization/CreateForkDialog.jsx @@ -1,16 +1,20 @@ import * as React from "react"; +import { useContext } from "react"; import { debounce } from 'lodash'; import PropTypes from "prop-types"; import termParser from "../../parsers/termParser"; import CustomInputBox from "../common/CustomInputBox"; -import { getOrganizations } from "../../api/endpoints"; import CustomSelectBox from "../common/CustomSelectBox"; import { useState, useEffect, useCallback } from "react"; import CustomizedDialog from "../common/CustomizedDialog"; import ForkRightIcon from '@mui/icons-material/ForkRight'; import CustomAutocompleteBox from "../common/CustomAutocompleteBox"; import { Stack, Button, Grid, Box, Typography } from "@mui/material"; +import { GlobalDataContext } from "../../contexts/DataContext"; import * as mockApi from "../../api/endpoints/swaggerMockMissingEndpoints"; +import { useOrganizations } from "../../helpers/useOrganizations"; +import { createNewOntology , getNewTokenApi} from "../../api/endpoints/apiService"; +import { API_CONFIG } from '../../config'; import { vars } from "../../theme/variables"; const { gray800, gray500, gray600 } = vars; @@ -40,31 +44,69 @@ const CreateForkDialog = ({ open, handleClose, onSubmit }) => { // eslint-disable-next-line no-unused-vars const [loading, setLoading] = useState(true); const [termResults, setTermResults] = useState([]); - const [organizations, setOrganizations] = useState([]); const [newFork, setNewFork] = React.useState({ term: null, owner: "", name: "" }); + const { user } = useContext(GlobalDataContext); + const groupname = user?.groupname || "base"; + const { + organizations, + } = useOrganizations(groupname); + + + const testCreateOntology = async () => { + const data = { + "token-type": "personal", + "scope": "user-all" + }; + + const token = "localStorage.getItem("token")" + const ontologyName = `test-${Math.random().toString(36).substring(2, 10)}`; + const title = 'Test New Ontology Title'; + const subjects = [ + 'http://purl.obolibrary.org/obo/BFO_0000001', + 'http://purl.obolibrary.org/obo/IAO_0000002', + ]; + + const result = await createNewOntology({ + groupname, + token, + ontologyName, + title, + subjects, + }); + + if (result.created) { + console.log('✅ Ontology created successfully!'); + console.log('Ontology details:', result.data); + + if (result.jsonResponse) { + console.log('Retrieved JSON:', result.jsonResponse); + } + + if (result.htmlAvailable !== undefined) { + console.log('HTML version available:', result.htmlAvailable); + } + } else { + console.error('❌ Failed to create ontology:', result.error); + } + }; // eslint-disable-next-line react-hooks/exhaustive-deps const fetchTerms = useCallback( debounce((term) => { setLoading(true); - getMatchTerms("base", "i", { filter: "", value: "" }).then(data => { - const parsedData = termParser(data, term); - setTermResults(parsedData.results); - }); + // getMatchTerms("base", "i", { filter: "", value: "" }).then(data => { + // const parsedData = termParser(data, term); + // setTermResults(parsedData.results); + // }); + testCreateOntology(); }, 300), [getMatchTerms] ); - const fetchOrganizations = async () => { - const organizations = await getOrganizations("base") - setOrganizations(organizations); - setLoading(false) - } - const handleCreateFork = () => { onSubmit(newFork); }; @@ -90,7 +132,6 @@ const CreateForkDialog = ({ open, handleClose, onSubmit }) => { useEffect(() => { setLoading(true) - fetchOrganizations(); }, []); diff --git a/src/components/SingleOrganization/index.jsx b/src/components/SingleOrganization/index.jsx index fa38eb55..1caf40dc 100644 --- a/src/components/SingleOrganization/index.jsx +++ b/src/components/SingleOrganization/index.jsx @@ -72,7 +72,7 @@ const useOrganizationData = (id) => { } }; - fetchData(); + //fetchData(); }, [id]); return { organization, organizationCuries, organizationTerms, organizationOntologies, loading }; diff --git a/src/config.js b/src/config.js index bb265d87..cbb420b1 100644 --- a/src/config.js +++ b/src/config.js @@ -31,6 +31,7 @@ export const API_CONFIG = { CREATE_NEW_ORGANIZATION: "/priv/org-new", CREATE_NEW_ENTITY: "/priv/entity-new", CREATE_NEW_ONTOLOGY: "/{groupname}/ontologies/uris/{filename}/spec", + API_NEW_TOKEN: "/priv/api-token-new", GET_ORGANIZATIONS: "/priv/role-other", LOGOUT: "/priv/logout", }, diff --git a/vite.config.js b/vite.config.js index 6dca0b47..e2bd7e32 100644 --- a/vite.config.js +++ b/vite.config.js @@ -59,6 +59,8 @@ export default defineConfig({ console.log('Request:', proxyReq); }); proxy.on('proxyRes', (proxyRes, req, res) => { + console.log('Received response', res); + console.log('Received Response from the Target:', proxyRes.statusCode, req.url); const location = proxyRes.headers['location']; console.log('Received location', location); @@ -95,6 +97,44 @@ export default defineConfig({ res.setHeader('Access-Control-Allow-Credentials', 'true'); }); }, + }, + '^/[^/]+/ontologies/uris/.*/spec': { + target: 'https://uri.olympiangods.org', + changeOrigin: true, + secure: false, + rewrite: path => path, // Keep full path + configure: (proxy) => { + proxy.on('proxyReq', (proxyReq, req, _res) => { + console.log('Proxying ontology spec request:', req.method, req.url); + console.log('Headers:', proxyReq.getHeaders()); + if (req.headers.authorization) { + proxyReq.setHeader('Authorization', req.headers.authorization); + } + }); + + proxy.on('proxyRes', (proxyRes, req, res) => { + console.log('Received response', res); + console.log('Received Response from the Target:', proxyRes.statusCode, req.url); + const location = proxyRes.headers['location']; + console.log('Received location', location); + + if (proxyRes.statusCode === 303 && location) { + // Prevent browser from seeing the actual Location + delete proxyRes.headers['location']; + + // Inject the location into a custom header we can use in Axios + res.setHeader('X-Redirect-Location', location); + } + + // Required for credentialed CORS + const origin = req.headers.origin; + if (origin) { + res.setHeader('Access-Control-Allow-Origin', origin); + } + res.setHeader('Access-Control-Allow-Credentials', 'true'); + res.setHeader('Access-Control-Expose-Headers', 'X-Redirect-Location'); + }); + }, } }, }, From 6d4fa2e0f82c7b604544f03f937c44c167fb6b76 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Mon, 9 Jun 2025 18:02:21 -0700 Subject: [PATCH 4/7] #116 - Retrieve api token from endpoint prior to send Ontology POST request. Adds UI to import ontologies from json by upload, following changes to figma design --- src/api/endpoints/apiService.ts | 5 + .../AddNewOntologyDialog.jsx | 125 ++++++++++++++++-- .../SingleOrganization/CreateForkDialog.jsx | 47 +------ src/components/TermEditor/ImportFile.jsx | 2 +- src/components/common/StatusDialog.jsx | 21 ++- src/config.js | 1 + vite.config.js | 2 +- 7 files changed, 142 insertions(+), 61 deletions(-) diff --git a/src/api/endpoints/apiService.ts b/src/api/endpoints/apiService.ts index 63259dab..3e2f0387 100644 --- a/src/api/endpoints/apiService.ts +++ b/src/api/endpoints/apiService.ts @@ -191,4 +191,9 @@ export const createNewOntology = async ({ export const getNewTokenApi = ({ groupname, data }: { groupname: string, data: any }) => { const endpoint = `/${groupname}${API_CONFIG.REAL_API.API_NEW_TOKEN}`; return createPostRequest(endpoint, { "Content-Type" : "application/json" })(data); +}; + +export const retrieveTokenApi = ({ groupname }: { groupname: string }) => { + const endpoint = `/${groupname}${API_CONFIG.REAL_API.API_RETRIEVE_TOKEN}`; + return createGetRequest(endpoint, "application/json")(); }; \ No newline at end of file diff --git a/src/components/SingleOrganization/AddNewOntologyDialog.jsx b/src/components/SingleOrganization/AddNewOntologyDialog.jsx index 19ed7f7f..7c0e89ff 100644 --- a/src/components/SingleOrganization/AddNewOntologyDialog.jsx +++ b/src/components/SingleOrganization/AddNewOntologyDialog.jsx @@ -1,4 +1,3 @@ -import * as React from "react"; import PropTypes from "prop-types"; import AddIcon from '@mui/icons-material/Add'; import Checkbox from "../common/CustomCheckbox"; @@ -6,6 +5,12 @@ import StatusDialog from "../common/StatusDialog"; import CustomInputBox from "../common/CustomInputBox"; import { Stack, Button, Grid, Box } from "@mui/material"; import CustomizedDialog from "../common/CustomizedDialog"; +import ImportFileTab from "./../TermEditor/ImportFileTab"; +import BasicTabs from "../common/CustomTabs"; +import { useState } from "react"; +import { createNewOntology, retrieveTokenApi } from "../../api/endpoints/apiService"; +import { GlobalDataContext } from "../../contexts/DataContext"; +import { useContext } from "react"; const HeaderRightSideContent = ({ handleClose, onAddNewOntology }) => { return ( @@ -25,14 +30,58 @@ HeaderRightSideContent.propTypes = { } const AddNewOntologyDialog = ({ open, handleClose }) => { - const [openStatusDialog, setOpenStatusDialog] = React.useState(false); - const [newOntology, setNewOntology] = React.useState({ + const [openStatusDialog, setOpenStatusDialog] = useState(false); + const [newOntology, setNewOntology] = useState({ title: "", description: "" }); + const [newOntologyResponse, setNewOntologyResponse] = useState({ + title: "", + description: "", + created : false, + message : "Your ontology “Nervous system” has been added. Click 'Go to Ontology' to go see the result, or add a new ontology." + }); + const [files, setFiles] = useState([]); + const [url, setUrl] = useState(''); + const [tabValue, setTabValue] = useState(0); + const { user } = useContext(GlobalDataContext); + + const handleSubmit = async() => { + const groupname = user?.groupname - const handleSubmit = () => { - console.log("Submit new ontology data!"); + const retrieved_tokens = await retrieveTokenApi({groupname}) + const token = retrieved_tokens?.[1]?.key + const ontologyName = newOntology?.title + "_" + Math.random().toString(36).substring(2, 10); + const title = newOntology?.title; + const subjects = files?.[0]?.data?.subjects; + + const result = await createNewOntology({ + groupname, + token, + ontologyName, + title, + subjects, + }); + + let ontologyResponseMessage = "Ontology created successfully!" + + if (result.created) { + console.log('Ontology details:', result.data); + + if (result.jsonResponse) { + console.log('Retrieved JSON:', result.jsonResponse); + } + + if (result.htmlAvailable !== undefined) { + console.log('HTML version available:', result.htmlAvailable); + } + } else { + ontologyResponseMessage = "Failed to create ontology" + console.error('❌ Failed to create ontology:', result.error); + } + + setOpenStatusDialog(true); + setNewOntologyResponse({title : newOntology?.title, description : ontologyResponseMessage, message : ontologyResponseMessage, created : result.created}) } const handleNewOntologyChange = (e) => { @@ -45,8 +94,6 @@ const AddNewOntologyDialog = ({ open, handleClose }) => { const handleAddNewOntology = () => { handleSubmit(); - setOpenStatusDialog(true); - setNewOntology({ title: "", description: "" }) }; const handleCloseStatusDialog = () => { @@ -56,9 +103,56 @@ const AddNewOntologyDialog = ({ open, handleClose }) => { const handleFinishButtonClick = () => { handleClose(); setOpenStatusDialog(false); - setNewOntology({ title: "", description: "" }) } + const handleChangeUrl = (event) => { + setUrl(event.target.value); + } + + const handleFilesSelected = async (newFiles) => { + const fileArray = Array.from(newFiles); + + const readFileContents = (file) => { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + + reader.onload = () => { + let content = reader.result; + + // Try parsing JSON if it's a JSON file + if (file.name.endsWith('.json')) { + try { + content = JSON.parse(content); + } catch (e) { + console.error(`Invalid JSON in file ${file.name}`, e); + content = null; + } + } + + resolve({ + name: file.name, + size: (file.size / 1024).toFixed(2), + progress: 100, + data: content + }); + }; + + reader.onerror = () => reject(reader.error); + reader.readAsText(file); + }); + }; + + const updatedFiles = await Promise.all(fileArray.map(readFileContents)); + + setFiles(prevFiles => { + const prevString = JSON.stringify(prevFiles); + const newString = JSON.stringify(updatedFiles); + return prevString !== newString ? updatedFiles : prevFiles; + }); + }; + + const handleChangeTabs = (_, newValue) => setTabValue(newValue); + return ( <> { /> } > + + + + {tabValue === 0 && ( @@ -101,16 +199,21 @@ const AddNewOntologyDialog = ({ open, handleClose }) => { /> + )} + {tabValue === 1 && } + + ) diff --git a/src/components/SingleOrganization/CreateForkDialog.jsx b/src/components/SingleOrganization/CreateForkDialog.jsx index 1573a55c..4e044552 100644 --- a/src/components/SingleOrganization/CreateForkDialog.jsx +++ b/src/components/SingleOrganization/CreateForkDialog.jsx @@ -2,7 +2,6 @@ import * as React from "react"; import { useContext } from "react"; import { debounce } from 'lodash'; import PropTypes from "prop-types"; -import termParser from "../../parsers/termParser"; import CustomInputBox from "../common/CustomInputBox"; import CustomSelectBox from "../common/CustomSelectBox"; import { useState, useEffect, useCallback } from "react"; @@ -13,8 +12,6 @@ import { Stack, Button, Grid, Box, Typography } from "@mui/material"; import { GlobalDataContext } from "../../contexts/DataContext"; import * as mockApi from "../../api/endpoints/swaggerMockMissingEndpoints"; import { useOrganizations } from "../../helpers/useOrganizations"; -import { createNewOntology , getNewTokenApi} from "../../api/endpoints/apiService"; -import { API_CONFIG } from '../../config'; import { vars } from "../../theme/variables"; const { gray800, gray500, gray600 } = vars; @@ -43,7 +40,7 @@ const CreateForkDialog = ({ open, handleClose, onSubmit }) => { const { getMatchTerms } = useMockApi(); // eslint-disable-next-line no-unused-vars const [loading, setLoading] = useState(true); - const [termResults, setTermResults] = useState([]); + const [termResults] = useState([]); const [newFork, setNewFork] = React.useState({ term: null, owner: "", @@ -55,54 +52,14 @@ const CreateForkDialog = ({ open, handleClose, onSubmit }) => { organizations, } = useOrganizations(groupname); - - const testCreateOntology = async () => { - const data = { - "token-type": "personal", - "scope": "user-all" - }; - - const token = "localStorage.getItem("token")" - const ontologyName = `test-${Math.random().toString(36).substring(2, 10)}`; - const title = 'Test New Ontology Title'; - const subjects = [ - 'http://purl.obolibrary.org/obo/BFO_0000001', - 'http://purl.obolibrary.org/obo/IAO_0000002', - ]; - - const result = await createNewOntology({ - groupname, - token, - ontologyName, - title, - subjects, - }); - - if (result.created) { - console.log('✅ Ontology created successfully!'); - console.log('Ontology details:', result.data); - - if (result.jsonResponse) { - console.log('Retrieved JSON:', result.jsonResponse); - } - - if (result.htmlAvailable !== undefined) { - console.log('HTML version available:', result.htmlAvailable); - } - } else { - console.error('❌ Failed to create ontology:', result.error); - } - }; - // eslint-disable-next-line react-hooks/exhaustive-deps const fetchTerms = useCallback( - debounce((term) => { + debounce(() => { setLoading(true); // getMatchTerms("base", "i", { filter: "", value: "" }).then(data => { // const parsedData = termParser(data, term); // setTermResults(parsedData.results); // }); - testCreateOntology(); }, 300), [getMatchTerms] ); diff --git a/src/components/TermEditor/ImportFile.jsx b/src/components/TermEditor/ImportFile.jsx index 8638f781..42e79db1 100644 --- a/src/components/TermEditor/ImportFile.jsx +++ b/src/components/TermEditor/ImportFile.jsx @@ -114,7 +114,7 @@ const ImportFile = ({ onFilesSelected }) => { hidden id="browse" onChange={handleFileChange} - accept=".csv" + accept=".csv,.json" multiple /> diff --git a/src/components/common/StatusDialog.jsx b/src/components/common/StatusDialog.jsx index 9ca26c45..15138c47 100644 --- a/src/components/common/StatusDialog.jsx +++ b/src/components/common/StatusDialog.jsx @@ -1,7 +1,7 @@ import PropTypes from "prop-types"; import { Box } from "@mui/material"; import Button from "@mui/material/Button"; -import { BackgroundPattern } from "../../Icons"; +import { BackgroundPattern, StatusErrorBackgroundPattern } from "../../Icons"; import CustomizedDialog from "./CustomizedDialog"; import Typography from "@mui/material/Typography"; @@ -24,7 +24,7 @@ HeaderRightSideContent.propTypes = { finishButtonEndIcon: PropTypes.node, }; -const StatusDialog = ({ open, handleClose, title, message, subMessage, finishButtonTitle, actionButtonTitle, handleActionButtonClick, finishButtonEndIcon, actionButtonStartIcon }) => { +const StatusDialog = ({ open, handleClose, title, message, subMessage, finishButtonTitle, actionButtonTitle, handleActionButtonClick, finishButtonEndIcon, actionButtonStartIcon, errored }) => { return ( } > - + : + + + } path, // Keep full path configure: (proxy) => { - proxy.on('proxyReq', (proxyReq, req, _res) => { + proxy.on('proxyReq', (proxyReq, req) => { console.log('Proxying ontology spec request:', req.method, req.url); console.log('Headers:', proxyReq.getHeaders()); if (req.headers.authorization) { From 87dc99d256b53ab3c92a6782969258cf34762911 Mon Sep 17 00:00:00 2001 From: Jesus M Date: Wed, 11 Jun 2025 10:35:04 -0700 Subject: [PATCH 5/7] Update src/components/SingleOrganization/index.jsx #116 - removing unused fetchdata call Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/components/SingleOrganization/index.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/SingleOrganization/index.jsx b/src/components/SingleOrganization/index.jsx index 1caf40dc..2fb3bc27 100644 --- a/src/components/SingleOrganization/index.jsx +++ b/src/components/SingleOrganization/index.jsx @@ -72,7 +72,6 @@ const useOrganizationData = (id) => { } }; - //fetchData(); }, [id]); return { organization, organizationCuries, organizationTerms, organizationOntologies, loading }; From c7b008c9bc47c5692082b2d497d6577ea1a94a9b Mon Sep 17 00:00:00 2001 From: Jesus M Date: Thu, 12 Jun 2025 07:03:38 -0700 Subject: [PATCH 6/7] Update src/components/SingleOrganization/CreateForkDialog.jsx Remove Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/components/SingleOrganization/CreateForkDialog.jsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/SingleOrganization/CreateForkDialog.jsx b/src/components/SingleOrganization/CreateForkDialog.jsx index 4e044552..d2227bc5 100644 --- a/src/components/SingleOrganization/CreateForkDialog.jsx +++ b/src/components/SingleOrganization/CreateForkDialog.jsx @@ -56,10 +56,7 @@ const CreateForkDialog = ({ open, handleClose, onSubmit }) => { const fetchTerms = useCallback( debounce(() => { setLoading(true); - // getMatchTerms("base", "i", { filter: "", value: "" }).then(data => { - // const parsedData = termParser(data, term); - // setTermResults(parsedData.results); - // }); + }, 300), [getMatchTerms] ); From 89e17ddb69d84dbd40d0f04eba2c95a8c765e3d7 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Fri, 13 Jun 2025 08:55:30 -0700 Subject: [PATCH 7/7] #116 - Fix lint and check if new token is needed when retrieved tokens are null --- .../SingleOrganization/AddNewOntologyDialog.jsx | 12 ++++++++++-- src/components/SingleOrganization/index.jsx | 7 ++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/SingleOrganization/AddNewOntologyDialog.jsx b/src/components/SingleOrganization/AddNewOntologyDialog.jsx index 7c0e89ff..dbc76619 100644 --- a/src/components/SingleOrganization/AddNewOntologyDialog.jsx +++ b/src/components/SingleOrganization/AddNewOntologyDialog.jsx @@ -8,7 +8,7 @@ import CustomizedDialog from "../common/CustomizedDialog"; import ImportFileTab from "./../TermEditor/ImportFileTab"; import BasicTabs from "../common/CustomTabs"; import { useState } from "react"; -import { createNewOntology, retrieveTokenApi } from "../../api/endpoints/apiService"; +import { createNewOntology, getNewTokenApi, retrieveTokenApi } from "../../api/endpoints/apiService"; import { GlobalDataContext } from "../../contexts/DataContext"; import { useContext } from "react"; @@ -50,7 +50,15 @@ const AddNewOntologyDialog = ({ open, handleClose }) => { const groupname = user?.groupname const retrieved_tokens = await retrieveTokenApi({groupname}) - const token = retrieved_tokens?.[1]?.key + let token = null; + if ( retrieved_tokens?.length > 0 ){ + token = retrieved_tokens?.[retrieved_tokens?.length - 1]?.key; + } + + if ( token === undefined || token === null) { + const newToken = await getNewTokenApi({groupname}); + token = newToken?.key; + } const ontologyName = newOntology?.title + "_" + Math.random().toString(36).substring(2, 10); const title = newOntology?.title; const subjects = files?.[0]?.data?.subjects; diff --git a/src/components/SingleOrganization/index.jsx b/src/components/SingleOrganization/index.jsx index 2fb3bc27..271aacdd 100644 --- a/src/components/SingleOrganization/index.jsx +++ b/src/components/SingleOrganization/index.jsx @@ -71,7 +71,9 @@ const useOrganizationData = (id) => { setLoading(false); } }; - + if ( id ) { + fetchData(); + } }, [id]); return { organization, organizationCuries, organizationTerms, organizationOntologies, loading }; @@ -92,9 +94,8 @@ const SingleOrganization = () => { const [ontologiesPageOptions, setOntologiesPageOptions] = useState([]); const navigate = useNavigate(); - const id = "1"; // Hardcoded for now - const { organization, organizationTerms, organizationOntologies, loading } = useOrganizationData(id); + const { organization, organizationTerms, organizationOntologies, loading } = useOrganizationData(); useEffect(() => { if (organizationTerms.length > 0) {