diff --git a/src/components/models-download/ModelsDownload.tsx b/src/components/models-download/ModelsDownload.tsx index b5f8d7d0..573aa3da 100644 --- a/src/components/models-download/ModelsDownload.tsx +++ b/src/components/models-download/ModelsDownload.tsx @@ -29,7 +29,7 @@ export default function ModelsDownload() { function refetchModels() { getModelProviderInfo((res) => { - dispatch(setModelsDownloaded(res.data['modelProviderInfo'])); + dispatch(setModelsDownloaded(res)); }); } diff --git a/src/components/projects/ProjectsList.tsx b/src/components/projects/ProjectsList.tsx index c4a14d5a..00dc2f67 100644 --- a/src/components/projects/ProjectsList.tsx +++ b/src/components/projects/ProjectsList.tsx @@ -49,24 +49,15 @@ export default function ProjectsList() { function refetchProjectsAndPostProcess() { getAllProjects((res) => { - const projects = res.data["allProjects"].edges.map((edge: any) => edge.node); - dispatch(setAllProjects(projects)); + dispatch(setAllProjects(res)); setDataLoaded(true); }); } function refetchStatsAndPostProcess() { getOverviewStats((res) => { - const stats = res.data["overviewStats"]; - const statsDict = {}; - if (stats == null) return; - stats.forEach((stat: ProjectStatistics) => { - const statCopy = { ...stat }; - stat.manuallyLabeled = percentRoundString(statCopy.numDataScaleManual / statCopy.numDataScaleUploaded, 2); - stat.weaklySupervised = percentRoundString(statCopy.numDataScaleProgrammatical / statCopy.numDataScaleUploaded, 2); - statsDict[stat.projectId] = stat; - }); - setProjectStatisticsById(statsDict); + if (res == null) return; + setProjectStatisticsById(res); }); } diff --git a/src/components/projects/SampleProjectsDropdown.tsx b/src/components/projects/SampleProjectsDropdown.tsx index 152a4924..07f0283c 100644 --- a/src/components/projects/SampleProjectsDropdown.tsx +++ b/src/components/projects/SampleProjectsDropdown.tsx @@ -40,7 +40,7 @@ export default function SampleProjectsDropdown() { dispatch(setSearchGroupsStore({})); createSampleProject({ name: projectNameFinal, projectType: projectTypeFinal }, (res) => { dispatch(closeModal(ModalEnum.SAMPLE_PROJECT_TITLE)); - const projectId = res['data']['createSampleProject']['project'].id; + const projectId = res?.id; dispatch(setProjectIdSampleProject(projectId)); }); }, [projects, projectNameInput, projectTypeInput, router]); diff --git a/src/components/projects/new/NewProject.tsx b/src/components/projects/new/NewProject.tsx index 3863cd44..e54452f8 100644 --- a/src/components/projects/new/NewProject.tsx +++ b/src/components/projects/new/NewProject.tsx @@ -19,8 +19,7 @@ export default function NewProject() { useEffect(() => { dispatch(setUploadFileType(COMPONENT_FILE_TYPE)); getAllProjects((res) => { - const projects = res.data["allProjects"].edges.map((edge: any) => edge.node); - dispatch(setAllProjects(projects)); + dispatch(setAllProjects(res)); }); }, []); diff --git a/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx b/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx index 2153b96e..454140c3 100644 --- a/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx +++ b/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx @@ -27,7 +27,7 @@ import { CommentType } from "@/src/types/shared/comments"; import { AttributeCodeLookup } from "@/src/util/classes/attribute-calculation"; import KernDropdown from "@/submodules/react-components/components/KernDropdown"; import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/useWebsocket"; -import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; +import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; import { getAllComments } from "@/src/services/base/comment"; import { getAttributes } from "@/src/services/base/attribute"; import { getLookupListsByProjectId } from "@/src/services/base/lookup-lists"; @@ -65,7 +65,7 @@ export default function AttributeCalculation() { if (!projectId) return; if (!currentAttribute || attributes.length == 0) { getAttributes(projectId, ['ALL'], (res) => { - dispatch(setAllAttributes(res.data['attributesByProjectId'])); + dispatch(setAllAttributes(res)); const currentAttribute = postProcessCurrentAttribute(attributes.find((attribute) => attribute.id === router.query.attributeId)); setCurrentAttribute(currentAttribute); setEditorValue(currentAttribute?.sourceCodeToDisplay); @@ -73,7 +73,7 @@ export default function AttributeCalculation() { } if (lookupLists.length == 0) { getLookupListsByProjectId(projectId, (res) => { - dispatch(setAllLookupLists(res.data['knowledgeBasesByProjectId'])); + dispatch(setAllLookupLists(res)); }); } refetchLabelingTasksAndProcess(); @@ -136,7 +136,7 @@ export default function AttributeCalculation() { CommentDataManager.registerCommentRequests(CurrentPage.ATTRIBUTE_CALCULATION, requests); const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -221,14 +221,13 @@ export default function AttributeCalculation() { function checkProjectTokenization() { getProjectTokenization(projectId, (res) => { - setTokenizationProgress(res.data['projectTokenization']?.progress); + setTokenizationProgress(res?.progress); }); } function refetchLabelingTasksAndProcess() { getLabelingTasksByProjectId(projectId, (res) => { - const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']); - dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(labelingTasks))); + dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(res))); }); } @@ -243,11 +242,11 @@ export default function AttributeCalculation() { setCurrentAttribute(currentAttributeCopy); } else { getAttributes(projectId, ['ALL'], (res) => { - dispatch(setAllAttributes(res.data['attributesByProjectId'])); + dispatch(setAllAttributes(res)); }); - getAttributeByAttributeId(projectId, currentAttribute?.id, (res) => { - const attribute = res.data['attributeByAttributeId']; - if (attribute == null) setCurrentAttribute(null); + if (msgParts[2] == 'deleted') return + getAttributeByAttributeId(projectId, currentAttribute?.id, (attribute) => { + if (!attribute) setCurrentAttribute(null); else setCurrentAttribute(postProcessCurrentAttribute(attribute)); }); if (msgParts[2] == "finished") { @@ -256,7 +255,7 @@ export default function AttributeCalculation() { } } else if (['knowledge_base_updated', 'knowledge_base_deleted', 'knowledge_base_created'].includes(msgParts[1])) { getLookupListsByProjectId(projectId, (res) => { - dispatch(setAllLookupLists(res.data['knowledgeBasesByProjectId'])); + dispatch(setAllLookupLists(res)); }); } else if (msgParts[1] == 'tokenization' && msgParts[2] == 'docbin') { if (msgParts[3] == 'progress') { @@ -388,8 +387,7 @@ export default function AttributeCalculation() { setEnableButton(value)} refetchCurrentAttribute={() => { - getAttributeByAttributeId(projectId, currentAttribute?.id, (res) => { - const attribute = res.data['attributeByAttributeId']; + getAttributeByAttributeId(projectId, currentAttribute?.id, (attribute) => { if (attribute == null) setCurrentAttribute(null); else setCurrentAttribute(postProcessCurrentAttribute(attribute)); }); diff --git a/src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx b/src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx index ea0e38ab..5caa22bc 100644 --- a/src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx +++ b/src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx @@ -37,7 +37,7 @@ export default function ExecutionContainer(props: ExecutionContainerProps) { if (requestedSomething) return; setRequestedSomething(true); getSampleRecords(projectId, props.currentAttribute.id, (res) => { - const sampleRecordsFinal = { ...res.data['calculateUserAttributeSampleRecords'] }; + const sampleRecordsFinal = { ...res }; setRequestedSomething(false); props.setEnabledButton(false); setRunOn10HasError(sampleRecordsFinal.calculatedAttributes.length > 0 ? false : true); @@ -53,7 +53,7 @@ export default function ExecutionContainer(props: ExecutionContainerProps) { function recordByRecordId(recordId: string) { getRecordByRecordId(projectId, recordId, (res) => { - dispatch(setModalStates(ModalEnum.VIEW_RECORD_DETAILS, { record: postProcessRecordByRecordId(res.data['recordByRecordId']) })); + dispatch(setModalStates(ModalEnum.VIEW_RECORD_DETAILS, { record: postProcessRecordByRecordId(res) })); }); } diff --git a/src/components/projects/projectId/data-browser/DataBrowser.tsx b/src/components/projects/projectId/data-browser/DataBrowser.tsx index 1a3e7e02..48ed77ae 100644 --- a/src/components/projects/projectId/data-browser/DataBrowser.tsx +++ b/src/components/projects/projectId/data-browser/DataBrowser.tsx @@ -5,7 +5,7 @@ import { useCallback, useEffect, useState } from "react"; import { expandRecordList, selectActiveSearchParams, selectActiveSlice, selectConfiguration, selectFullSearchStore, selectRecords, setActiveDataSlice, setDataSlices, setRecordComments, setUniqueValuesDict, updateAdditionalDataState } from "@/src/reduxStore/states/pages/data-browser"; import { postProcessRecordsExtended, postProcessUniqueValues } from "@/src/util/components/projects/projectId/data-browser/data-browser-helper"; import { selectAttributes, selectLabelingTasksAll, setAllAttributes, setAllEmbeddings, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings"; -import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; +import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; import { selectAllUsers, selectOrganizationId, selectUser, setComments } from "@/src/reduxStore/states/general"; import DataBrowserRecords from "./DataBrowserRecords"; import { postProcessingEmbeddings } from "@/src/util/components/projects/projectId/settings/embeddings-helper"; @@ -64,12 +64,12 @@ export default function DataBrowser() { getRecordsByStaticSlice(projectId, activeSlice.id, { offset: searchRequest.offset, limit: searchRequest.limit }, (res) => { - dispatch(expandRecordList(postProcessRecordsExtended(res.data['recordsByStaticSlice'], labelingTasks))); + dispatch(expandRecordList(postProcessRecordsExtended(res, labelingTasks))); }); } else { const filterData = parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, fullSearchStore[SearchGroup.DRILL_DOWN]) searchRecordsExtended(projectId, filterData, searchRequest.offset, searchRequest.limit, (res) => { - const parsedRecordData = postProcessRecordsExtended(res.data['searchRecordsExtended'], labelingTasks); + const parsedRecordData = postProcessRecordsExtended(res, labelingTasks); dispatch(expandRecordList(parsedRecordData)); refetchRecordCommentsAndProcess(parsedRecordData.recordList); }); @@ -93,7 +93,7 @@ export default function DataBrowser() { CommentDataManager.registerCommentRequests(CurrentPage.DATA_BROWSER, requests); const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(users); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -101,9 +101,9 @@ export default function DataBrowser() { function refetchDataSlicesAndProcess(dataSliceId?: string) { getDataSlices(projectId, null, (res) => { - dispatch(setDataSlices(res.data.dataSlices)); + dispatch(setDataSlices(res)); if (dataSliceId) { - const findSlice = res.data.dataSlices.find((slice) => slice.id == dataSliceId); + const findSlice = res.find((slice) => slice.id == dataSliceId); if (findSlice) dispatch(setActiveDataSlice(findSlice)); } }); @@ -111,20 +111,19 @@ export default function DataBrowser() { function refetchAttributesAndProcess() { getAttributes(projectId, ['ALL'], (res) => { - dispatch(setAllAttributes(res.data['attributesByProjectId'])); + dispatch(setAllAttributes(res)); }); } function refetchLabelingTasksAndProcess() { getLabelingTasksByProjectId(projectId, (res) => { - const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']); - dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(labelingTasks))); + dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(res))); }); } function refetchEmbeddingsAndPostProcess() { getEmbeddings(projectId, (res) => { - const embeddings = postProcessingEmbeddings(res.data['projectByProjectId']['embeddings']['edges'].map((e) => e['node']), []); + const embeddings = postProcessingEmbeddings(res, []); dispatch(setAllEmbeddings(embeddings)); }); } @@ -133,7 +132,7 @@ export default function DataBrowser() { const currentRecordIds = parsedRecordData?.map((record) => record.id); if (!currentRecordIds || currentRecordIds.length == 0) return; getRecordComments(projectId, currentRecordIds, (res) => { - dispatch(setRecordComments(res.data['getRecordComments'])); + dispatch(setRecordComments(res)); }); } @@ -143,7 +142,7 @@ export default function DataBrowser() { function refetchUniqueValuesAndProcess() { getUniqueValuesByAttributes(projectId, (res) => { - dispatch(setUniqueValuesDict(postProcessUniqueValues(res.data['uniqueValuesByAttributes'], attributes))); + dispatch(setUniqueValuesDict(postProcessUniqueValues(res, attributes))); }); } diff --git a/src/components/projects/projectId/data-browser/SearchGroups.tsx b/src/components/projects/projectId/data-browser/SearchGroups.tsx index 6fdec082..5cf9fa32 100644 --- a/src/components/projects/projectId/data-browser/SearchGroups.tsx +++ b/src/components/projects/projectId/data-browser/SearchGroups.tsx @@ -112,7 +112,7 @@ export default function SearchGroups() { dispatch(updateAdditionalDataState('loading', true)); const refetchTimer = setTimeout(() => { searchRecordsExtended(projectId, parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, fullSearchStore[SearchGroup.DRILL_DOWN]), 0, 20, (res) => { - dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res.data['searchRecordsExtended'], labelingTasks))); + dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res, labelingTasks))); dispatch(updateAdditionalDataState('loading', false)); }); }, 500); @@ -133,14 +133,14 @@ export default function SearchGroups() { options.limit = 20; } getRecordsByStaticSlice(projectId, activeSlice.id, options, (res) => { - dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res.data['recordsByStaticSlice'], labelingTasks))); + dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res, labelingTasks))); staticDataSlicesCurrentCount(projectId, activeSlice.id, (res) => { - if (!res.data) { + if (!res) { dispatch(updateAdditionalDataState('staticDataSliceCurrentCount', null)); return; } - dispatch(updateAdditionalDataState('staticDataSliceCurrentCount', res['data']['staticDataSlicesCurrentCount'])); + dispatch(updateAdditionalDataState('staticDataSliceCurrentCount', res)); }); }); } @@ -569,7 +569,7 @@ export default function SearchGroups() { if (res == null) { setCurrentWeakSupervisionRun({ state: Status.NOT_YET_RUN }); } else { - setCurrentWeakSupervisionRun(postProcessCurrentWeakSupervisionRun(res['data']['currentWeakSupervisionRun'])); + setCurrentWeakSupervisionRun(postProcessCurrentWeakSupervisionRun(res)); } }); } diff --git a/src/components/projects/projectId/data-browser/modals/SaveDataSliceModal.tsx b/src/components/projects/projectId/data-browser/modals/SaveDataSliceModal.tsx index 7bf040fd..05c9d687 100644 --- a/src/components/projects/projectId/data-browser/modals/SaveDataSliceModal.tsx +++ b/src/components/projects/projectId/data-browser/modals/SaveDataSliceModal.tsx @@ -37,7 +37,7 @@ export default function SaveDataSliceModal(props: { fullSearch: {} }) { filterRaw: getRawFilterForSave(props.fullSearch), filterData: parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, props.fullSearch[SearchGroup.DRILL_DOWN].value) }, (res) => { - const id = res["data"]["createDataSlice"]["id"]; + const id = res?.id; const slice = { id: id, name: modalSaveDataSlice.sliceName, static: isStatic, filterRaw: getRawFilterForSave(props.fullSearch), filterData: parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, props.fullSearch[SearchGroup.DRILL_DOWN].value), color: getColorStruct(isStatic), diff --git a/src/components/projects/projectId/data-browser/modals/SimilaritySeachModal.tsx b/src/components/projects/projectId/data-browser/modals/SimilaritySeachModal.tsx index 7c7df516..bc15e9da 100644 --- a/src/components/projects/projectId/data-browser/modals/SimilaritySeachModal.tsx +++ b/src/components/projects/projectId/data-browser/modals/SimilaritySeachModal.tsx @@ -45,7 +45,7 @@ export default function SimilaritySearchModal() { function getSimilarRecords(hasFilter: boolean = false) { const attFilter = hasFilter ? prepareAttFilter(filterAttributesForm, attributes) : null; getRecordsBySimilarity(projectId, selectedEmbedding.id, modalSS.recordId, attFilter, null, (res) => { - dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res.data['searchRecordsBySimilarity'], labelingTasks))); + dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res, labelingTasks))); dispatch(setRecordsInDisplay(true)); }); } diff --git a/src/components/projects/projectId/edit-records/SyncRecordsModal.tsx b/src/components/projects/projectId/edit-records/SyncRecordsModal.tsx index 2256c07c..a79aa10e 100644 --- a/src/components/projects/projectId/edit-records/SyncRecordsModal.tsx +++ b/src/components/projects/projectId/edit-records/SyncRecordsModal.tsx @@ -29,13 +29,12 @@ export default function SyncRecordsModal(props: SyncRecordsModalProps) { const changes = jsonCopy(erdDataCopy.cachedRecordChanges); for (const key in changes) delete changes[key].display; syncEditedRecords(projectId, changes, (res) => { - const tmp = res?.data?.editRecords; - if (tmp?.ok) { + if (res) { erdDataCopy.data.records = jsonCopy(erdDataCopy.displayRecords); erdDataCopy.cachedRecordChanges = {}; dispatch(setModalStates(ModalEnum.SYNC_RECORDS, { syncModalAmount: Object.keys(erdDataCopy.cachedRecordChanges).length })); } else { - if (tmp) erdDataCopy.errors = tmp.errors; + if (res) erdDataCopy.errors = JSON.parse(res); else erdDataCopy.errors = ["Request didn't go through"]; } setSyncing(false); diff --git a/src/components/projects/projectId/heuristics/HeuristicsHeader.tsx b/src/components/projects/projectId/heuristics/HeuristicsHeader.tsx index 0897cda1..b01f7849 100644 --- a/src/components/projects/projectId/heuristics/HeuristicsHeader.tsx +++ b/src/components/projects/projectId/heuristics/HeuristicsHeader.tsx @@ -60,7 +60,7 @@ export default function HeuristicsHeader(props: HeuristicsHeaderProps) { if (res == null) { setCurrentWeakSupervisionRun({ state: Status.NOT_YET_RUN }); } else { - setCurrentWeakSupervisionRun(postProcessCurrentWeakSupervisionRun(res['data']['currentWeakSupervisionRun'])); + setCurrentWeakSupervisionRun(postProcessCurrentWeakSupervisionRun(res)); } }); } diff --git a/src/components/projects/projectId/heuristics/HeuristicsOverview.tsx b/src/components/projects/projectId/heuristics/HeuristicsOverview.tsx index 0010a2e0..4fd03ee5 100644 --- a/src/components/projects/projectId/heuristics/HeuristicsOverview.tsx +++ b/src/components/projects/projectId/heuristics/HeuristicsOverview.tsx @@ -4,7 +4,7 @@ import style from '@/src/styles/components/projects/projectId/heuristics/heurist import { useCallback, useEffect, useState } from "react"; import { selectEmbeddings, selectUsableNonTextAttributes, setAllAttributes, setAllEmbeddings, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings"; import { LabelingTask } from "@/src/types/components/projects/projectId/settings/labeling-tasks"; -import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; +import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; import { postProcessHeuristics } from "@/src/util/components/projects/projectId/heuristics/heuristics-helper"; import { selectHeuristicsAll, setAllHeuristics } from "@/src/reduxStore/states/pages/heuristics"; import GridCards from "@/src/components/shared/grid-cards/GridCards"; @@ -44,7 +44,7 @@ export function HeuristicsOverview() { checkProjectTokenization(); if (attributes.length == 0) { getAttributes(projectId, ['ALL'], (res) => { - dispatch(setAllAttributes(res.data['attributesByProjectId'])); + dispatch(setAllAttributes(res)); }); } }, [projectId]); @@ -65,7 +65,7 @@ export function HeuristicsOverview() { CommentDataManager.registerCommentRequests(CurrentPage.HEURISTICS, requests); const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -73,14 +73,13 @@ export function HeuristicsOverview() { function refetchLabelingTasksAndProcess() { getLabelingTasksByProjectId(projectId, (res) => { - const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']); - dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(labelingTasks))); + dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(res))); }); } function refetchHeuristicsAndProcess() { getInformationSourcesOverviewData(projectId, (res) => { - const heuristics = postProcessHeuristics(res['data']['informationSourcesOverviewData'], projectId); + const heuristics = postProcessHeuristics(res, projectId); dispatch(setAllHeuristics(heuristics)); setFilteredList(heuristics); }); @@ -88,14 +87,14 @@ export function HeuristicsOverview() { function refetchEmbeddingsAndProcess() { getEmbeddings(projectId, (res) => { - const embeddingsFinal = postProcessingEmbeddings(res.data['projectByProjectId']['embeddings']['edges'].map((e) => e['node']), []); + const embeddingsFinal = postProcessingEmbeddings(res, []); dispatch(setAllEmbeddings(embeddingsFinal)); }); } function checkProjectTokenization() { getProjectTokenization(projectId, (res) => { - setTokenizationProgress(res.data['projectTokenization']?.progress); + setTokenizationProgress(res?.progress); }); } diff --git a/src/components/projects/projectId/heuristics/heuristicId/active-learning/ActiveLearning.tsx b/src/components/projects/projectId/heuristics/heuristicId/active-learning/ActiveLearning.tsx index 8dbb0425..7ddcbae7 100644 --- a/src/components/projects/projectId/heuristics/heuristicId/active-learning/ActiveLearning.tsx +++ b/src/components/projects/projectId/heuristics/heuristicId/active-learning/ActiveLearning.tsx @@ -8,7 +8,7 @@ import { getClassLine, postProcessCurrentHeuristic, postProcessLastTaskLogs } fr import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants"; import { Tooltip } from "@nextui-org/react"; import { selectEmbeddings, selectEmbeddingsFiltered, selectLabelingTasksAll, selectVisibleAttributesHeuristics, setAllEmbeddings, setFilteredEmbeddings, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings"; -import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; +import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; import { postProcessingEmbeddings } from "@/src/util/components/projects/projectId/settings/embeddings-helper"; import { embeddingRelevant } from "@/src/util/components/projects/projectId/heuristics/heuristicId/labeling-functions-helper"; import { Embedding } from "@/src/types/components/projects/projectId/settings/embeddings"; @@ -88,7 +88,7 @@ export default function ActiveLearning() { CommentDataManager.registerCommentRequests(CurrentPage.ACTIVE_LEARNING, requests); const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -101,13 +101,13 @@ export default function ActiveLearning() { return; } getPayloadByPayloadId(projectId, currentHeuristic.lastTask.id, (res) => { - setLastTaskLogs(postProcessLastTaskLogs((res['data']['payloadByPayloadId']))); + setLastTaskLogs(postProcessLastTaskLogs(res)); }); } function refetchCurrentHeuristicAndProcess() { getHeuristicByHeuristicId(projectId, router.query.heuristicId as string, (res) => { - dispatch(setActiveHeuristics(postProcessCurrentHeuristic(res['data']['informationSourceBySourceId'], labelingTasks))); + dispatch(setActiveHeuristics(postProcessCurrentHeuristic(res, labelingTasks))); }); } @@ -121,14 +121,13 @@ export default function ActiveLearning() { function refetchLabelingTasksAndProcess() { getLabelingTasksByProjectId(projectId, (res) => { - const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']); - dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(labelingTasks))); + dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(res))); }); } function refetchEmbeddingsAndPostProcess() { getEmbeddings(projectId, (res) => { - const embeddings = postProcessingEmbeddings(res.data['projectByProjectId']['embeddings']['edges'].map((e) => e['node']), []); + const embeddings = postProcessingEmbeddings(res, []); dispatch(setAllEmbeddings(embeddings)); }); } diff --git a/src/components/projects/projectId/heuristics/heuristicId/labeling-function/LabelingFunction.tsx b/src/components/projects/projectId/heuristics/heuristicId/labeling-function/LabelingFunction.tsx index 7cf349b5..32d07374 100644 --- a/src/components/projects/projectId/heuristics/heuristicId/labeling-function/LabelingFunction.tsx +++ b/src/components/projects/projectId/heuristics/heuristicId/labeling-function/LabelingFunction.tsx @@ -7,7 +7,7 @@ import { selectHeuristic, setActiveHeuristics, updateHeuristicsState } from "@/s import { postProcessCurrentHeuristic, postProcessLastTaskLogs } from "@/src/util/components/projects/projectId/heuristics/heuristicId/heuristics-details-helper"; import { Tooltip } from "@nextui-org/react"; import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants"; -import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; +import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; import { selectVisibleAttributesHeuristics, selectLabelingTasksAll, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings"; import HeuristicsEditor from "../shared/HeuristicsEditor"; import DangerZone from "@/src/components/shared/danger-zone/DangerZone"; @@ -90,7 +90,7 @@ export default function LabelingFunction() { CommentDataManager.registerCommentRequests(CurrentPage.LABELING_FUNCTION, requests); const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -98,14 +98,13 @@ export default function LabelingFunction() { function refetchCurrentHeuristicAndProcess() { getHeuristicByHeuristicId(projectId, router.query.heuristicId as string, (res) => { - dispatch(setActiveHeuristics(postProcessCurrentHeuristic(res['data']['informationSourceBySourceId'], labelingTasks))); + dispatch(setActiveHeuristics(postProcessCurrentHeuristic(res, labelingTasks))); }); } function refetchLabelingTasksAndProcess() { getLabelingTasksByProjectId(projectId, (res) => { - const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']); - dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(labelingTasks))); + dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(res))); }); } @@ -129,7 +128,7 @@ export default function LabelingFunction() { return; } getPayloadByPayloadId(projectId, currentHeuristic.lastPayload.id, (res) => { - setLastTaskLogs(postProcessLastTaskLogs((res['data']['payloadByPayloadId']))); + setLastTaskLogs(postProcessLastTaskLogs(res)); }); } @@ -138,8 +137,8 @@ export default function LabelingFunction() { setRunOn10IsRunning(true); getLabelingFunctionOn10Records(projectId, currentHeuristic.id, (res) => { setRunOn10IsRunning(false); - setSampleRecords(postProcessSampleRecords(res['data']['getLabelingFunctionOn10Records'], labelingTasks, currentHeuristic.labelingTaskId)); - setLastTaskLogs(parseContainerLogsData(res['data']['getLabelingFunctionOn10Records']['containerLogs'])) + setSampleRecords(postProcessSampleRecords(res, labelingTasks, currentHeuristic.labelingTaskId)); + setLastTaskLogs(parseContainerLogsData(res['containerLogs'])) }); } diff --git a/src/components/projects/projectId/heuristics/heuristicId/shared/HeuristicsLayout.tsx b/src/components/projects/projectId/heuristics/heuristicId/shared/HeuristicsLayout.tsx index a77a0de7..4d81a917 100644 --- a/src/components/projects/projectId/heuristics/heuristicId/shared/HeuristicsLayout.tsx +++ b/src/components/projects/projectId/heuristics/heuristicId/shared/HeuristicsLayout.tsx @@ -96,13 +96,13 @@ export default function HeuristicsLayout(props: any) { function refetchAttributesAndProcess() { getAttributes(projectId, ['ALL'], (res) => { - dispatch(setAllAttributes(res.data['attributesByProjectId'])); + dispatch(setAllAttributes(res)); }); } function refetchLookupListsAndProcess() { getLookupListsByProjectId(projectId, (res) => { - dispatch(setAllLookupLists(res.data['knowledgeBasesByProjectId'])); + dispatch(setAllLookupLists(res)); }); } diff --git a/src/components/projects/projectId/heuristics/modals/AddActiveLearnerModal.tsx b/src/components/projects/projectId/heuristics/modals/AddActiveLearnerModal.tsx index 9d8cf811..49b42c28 100644 --- a/src/components/projects/projectId/heuristics/modals/AddActiveLearnerModal.tsx +++ b/src/components/projects/projectId/heuristics/modals/AddActiveLearnerModal.tsx @@ -47,7 +47,7 @@ export default function AddActiveLeanerModal() { const codeData = getInformationSourceTemplate(matching, heuristicType, embedding.name); if (!codeData) return; createHeuristicPost(projectId, labelingTask.id, codeData.code, name, description, heuristicType, (res) => { - let id = res['data']?.['createInformationSource']?.['informationSource']?.['id']; + let id = res?.id; if (id) { router.push(getRouterLinkHeuristic(heuristicType, projectId, id)) } else { diff --git a/src/components/projects/projectId/heuristics/modals/AddLabelingFunctionModal.tsx b/src/components/projects/projectId/heuristics/modals/AddLabelingFunctionModal.tsx index 48d6c8a5..c236793b 100644 --- a/src/components/projects/projectId/heuristics/modals/AddLabelingFunctionModal.tsx +++ b/src/components/projects/projectId/heuristics/modals/AddLabelingFunctionModal.tsx @@ -32,7 +32,7 @@ export default function AddLabelingFunctionModal() { const codeData = getInformationSourceTemplate(matching, heuristicType, ''); if (!codeData) return; createHeuristicPost(projectId, labelingTask.id, codeData.code, name, description, heuristicType, (res) => { - let id = res['data']?.['createInformationSource']?.['informationSource']?.['id']; + let id = res?.id; if (id) { router.push(getRouterLinkHeuristic(heuristicType, projectId, id)) } else { diff --git a/src/components/projects/projectId/labeling/sessionId/main-component/DeleteRecordModal.tsx b/src/components/projects/projectId/labeling/sessionId/main-component/DeleteRecordModal.tsx index 0b31c24b..294898ca 100644 --- a/src/components/projects/projectId/labeling/sessionId/main-component/DeleteRecordModal.tsx +++ b/src/components/projects/projectId/labeling/sessionId/main-component/DeleteRecordModal.tsx @@ -21,7 +21,7 @@ export default function DeleteRecordModal() { const deleteRecord = useCallback(() => { const recordId = record.id; deleteRecordById(projectId, recordId, (r) => { - if (r['data']['deleteRecord']) { + if (r) { SessionManager.setCurrentRecordDeleted(); dispatch(updateRecordRequests('record', null)); LabelingSuiteManager.somethingLoading = false; diff --git a/src/components/projects/projectId/labeling/sessionId/main-component/LabelingMainComponent.tsx b/src/components/projects/projectId/labeling/sessionId/main-component/LabelingMainComponent.tsx index e7eec796..1498c142 100644 --- a/src/components/projects/projectId/labeling/sessionId/main-component/LabelingMainComponent.tsx +++ b/src/components/projects/projectId/labeling/sessionId/main-component/LabelingMainComponent.tsx @@ -18,7 +18,7 @@ import LabelingSuiteTaskHeader from "../sub-components/LabelingSuiteTaskHeader"; import LabelingSuiteOverviewTable from "../sub-components/LabelingSuiteOverviewTable"; import LabelingSuiteLabeling from "../sub-components/LabelingSuiteLabeling"; import { setAllAttributes, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings"; -import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; +import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; import { CommentDataManager } from "@/src/util/classes/comments"; import { CommentType } from "@/src/types/shared/comments"; import { LabelingTask } from "@/src/types/components/projects/projectId/settings/labeling-tasks"; @@ -83,8 +83,7 @@ export default function LabelingMainComponent() { dispatch(setDisplayUserRole(user.role)); return; } - getLinkLocked(projectId, { linkRoute: router.asPath }, (result) => { - const lockedLink = result['data']['linkLocked']; + getLinkLocked(projectId, { linkRoute: router.asPath }, (lockedLink) => { if (lockedLink) { setAbsoluteWarning('This link is locked, contact your supervisor to request access'); if (router.query.type == LabelingLinkType.HEURISTIC) { @@ -152,14 +151,13 @@ export default function LabelingMainComponent() { if (SessionManager.currentRecordId !== null) { setTimeout(() => { getTokenizedRecord({ recordId: SessionManager.currentRecordId }, (res) => { - dispatch(updateRecordRequests('token', res.data.tokenizeRecord)); + dispatch(updateRecordRequests('token', res)); }); getRecordByRecordId(projectId, SessionManager.currentRecordId, (res) => { - dispatch(updateRecordRequests('record', res.data.recordByRecordId)); + dispatch(updateRecordRequests('record', res)); }); getRecordLabelAssociations(projectId, SessionManager.currentRecordId, (rla) => { - const rlas = rla['data']?.['recordByRecordId']?.['recordLabelAssociations']['edges'].map(e => e.node); - dispatch(updateRecordRequests('rla', prepareRLADataForRole(rlas, user, userDisplayId, userDisplayRole))); + dispatch(updateRecordRequests('rla', prepareRLADataForRole(rla?.recordLabelAssociations, user, userDisplayId, userDisplayRole))); }); }, 100); } @@ -186,7 +184,7 @@ export default function LabelingMainComponent() { CommentDataManager.registerCommentRequests(CurrentPage.LABELING, requests); const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -203,7 +201,7 @@ export default function LabelingMainComponent() { return; } getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -221,7 +219,7 @@ export default function LabelingMainComponent() { return; } getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -231,8 +229,7 @@ export default function LabelingMainComponent() { function requestHuddleData(huddleId: string) { if (hasRequestedHuddleData.current === true) return; hasRequestedHuddleData.current = true; - getHuddleData(projectId, { huddleId: huddleId, huddleType: SessionManager.labelingLinkData.linkType }, (result) => { - const huddleData = result['data']['requestHuddleData']; + getHuddleData(projectId, { huddleId: huddleId, huddleType: SessionManager.labelingLinkData.linkType }, (huddleData) => { if (huddleId == DUMMY_HUDDLE_ID) { SessionManager.labelingLinkData.huddleId = huddleData.huddleId; } @@ -269,8 +266,7 @@ export default function LabelingMainComponent() { function collectAvailableLinks() { if (userDisplayRole?.role == UserRole.ENGINEER) return; const heuristicId = SessionManager.labelingLinkData.linkType == LabelingLinkType.HEURISTIC ? SessionManager.labelingLinkData.huddleId : null; - getAvailableLinks(projectId, user?.role, heuristicId, (result) => { - const availableLinks = result['data']['availableLinks']; + getAvailableLinks(projectId, user?.role, heuristicId, (availableLinks) => { dispatch(setAvailableLinks(availableLinks)); const linkRoute = router.asPath.split("?")[0]; dispatch(setSelectedLink(availableLinks.find(link => link.link.split("?")[0] == linkRoute))); @@ -279,14 +275,13 @@ export default function LabelingMainComponent() { function refetchAttributesAndProcess() { getAttributes(projectId, ['ALL'], (res) => { - dispatch(setAllAttributes(res.data['attributesByProjectId'])); + dispatch(setAllAttributes(res)); }); } function refetchLabelingTasksAndProcess() { getLabelingTasksByProjectId(projectId, (res) => { - const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']); - const labelingTasksProcessed = postProcessLabelingTasksSchema(labelingTasks); + const labelingTasksProcessed = postProcessLabelingTasksSchema(res); dispatch(setLabelingTasksAll(prepareTasksForRole(labelingTasksProcessed, userDisplayRole))); }); } @@ -319,7 +314,7 @@ export default function LabelingMainComponent() { const recordId = SessionManager.currentRecordId ?? record.id; if (msgParts[2] == recordId) { getRecordLabelAssociations(projectId, recordId, (rla) => { - const rlas = rla['data']?.['recordByRecordId']?.['recordLabelAssociations']['edges'].map(e => e.node); + const rlas = rla?.recordLabelAssociations; dispatch(updateRecordRequests('rla', prepareRLADataForRole(rlas, user, userDisplayId, userDisplayRole))); }); } diff --git a/src/components/projects/projectId/labeling/sessionId/main-component/NavigationBarTop.tsx b/src/components/projects/projectId/labeling/sessionId/main-component/NavigationBarTop.tsx index 84f667a7..ad2f7d97 100644 --- a/src/components/projects/projectId/labeling/sessionId/main-component/NavigationBarTop.tsx +++ b/src/components/projects/projectId/labeling/sessionId/main-component/NavigationBarTop.tsx @@ -30,8 +30,7 @@ export default function NavigationBarTop(props: NavigationBarTopProps) { useEffect(() => { if (userDisplayRole?.role == UserRole.ENGINEER || !SessionManager.labelingLinkData) return; const heuristicId = SessionManager.labelingLinkData.linkType == LabelingLinkType.HEURISTIC ? SessionManager.labelingLinkData.huddleId : null; - getAvailableLinks(projectId, userDisplayRole?.role, heuristicId, (result) => { - const availableLinks = result['data']['availableLinks']; + getAvailableLinks(projectId, userDisplayRole?.role, heuristicId, (availableLinks) => { dispatch(setAvailableLinks(availableLinks)); const linkRoute = router.asPath.split("?")[0]; dispatch(setSelectedLink(availableLinks.find(link => link.link.split("?")[0] == linkRoute))); diff --git a/src/components/projects/projectId/labeling/sessionId/sub-components/LabelingSuiteLabeling.tsx b/src/components/projects/projectId/labeling/sessionId/sub-components/LabelingSuiteLabeling.tsx index 05af6ab6..74d8aa5a 100644 --- a/src/components/projects/projectId/labeling/sessionId/sub-components/LabelingSuiteLabeling.tsx +++ b/src/components/projects/projectId/labeling/sessionId/sub-components/LabelingSuiteLabeling.tsx @@ -170,7 +170,7 @@ export default function LabelingSuiteLabeling() { attribute: null, }; for (const task of labelingTasks) { - const attributeKey = task.attribute ? task.attribute.id : FULL_RECORD_ID; + const attributeKey = task.targetId || FULL_RECORD_ID; const taskCopy = { ...task }; taskCopy.displayLabels = task.labels.slice(0, settings.labeling.showNLabelButton); lVarsCopy.taskLookup[attributeKey].lookup.push({ @@ -427,7 +427,7 @@ export default function LabelingSuiteLabeling() { if (task.taskType == LabelingTaskTaskType.MULTICLASS_CLASSIFICATION) { addLabelToTask(task.id, labelId); } else { - addLabelToSelection(task.attribute.id, task.id, labelId); + addLabelToSelection(task.targetId, task.id, labelId); } if (settings.labeling.closeLabelBoxAfterLabel) { setActiveTasksFuncRef.current([]); diff --git a/src/components/projects/projectId/lookup-lists/LookupListsOverview.tsx b/src/components/projects/projectId/lookup-lists/LookupListsOverview.tsx index 2f5ef054..3873310b 100644 --- a/src/components/projects/projectId/lookup-lists/LookupListsOverview.tsx +++ b/src/components/projects/projectId/lookup-lists/LookupListsOverview.tsx @@ -51,7 +51,7 @@ export default function LookupListsOverview() { CommentDataManager.registerCommentRequests(CurrentPage.LOOKUP_LISTS_OVERVIEW, requests); const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -60,15 +60,14 @@ export default function LookupListsOverview() { useEffect(() => { if (!projectId) return; getLookupListsByProjectId(projectId, (res) => { - dispatch(setAllLookupLists(res.data["knowledgeBasesByProjectId"])); + dispatch(setAllLookupLists(res)); }); }, [projectId]); function createLookupList() { createKnowledgeBase(projectId, (res) => { - const lookupList = res.data?.createKnowledgeBase["knowledgeBase"]; - dispatch(extendAllLookupLists(lookupList)); - router.push(`/projects/${projectId}/lookup-lists/${lookupList.id}`); + dispatch(extendAllLookupLists(res)); + router.push(`/projects/${projectId}/lookup-lists/${res?.id}`); }); } @@ -109,7 +108,7 @@ export default function LookupListsOverview() { const handleWebsocketNotification = useCallback((msgParts: string[]) => { if (['knowledge_base_updated', 'knowledge_base_deleted', 'knowledge_base_created'].includes(msgParts[1])) { getLookupListsByProjectId(projectId, (res) => { - dispatch(setAllLookupLists(res.data["knowledgeBasesByProjectId"])); + dispatch(setAllLookupLists(res)); }); } }, [projectId]); diff --git a/src/components/projects/projectId/lookup-lists/lookupListId/LookupListOperations.tsx b/src/components/projects/projectId/lookup-lists/lookupListId/LookupListOperations.tsx index 472e7d74..477432f6 100644 --- a/src/components/projects/projectId/lookup-lists/lookupListId/LookupListOperations.tsx +++ b/src/components/projects/projectId/lookup-lists/lookupListId/LookupListOperations.tsx @@ -38,9 +38,9 @@ export default function LookupListOperations(props: LookupListOperationsProps) { setDownloadMessage(DownloadState.PREPARATION); getExportLookupList(projectId, router.query.lookupListId, (res) => { setDownloadMessage(DownloadState.DOWNLOAD); - const downloadContent = JSON.parse(res.data['exportKnowledgeBase']); + const downloadContent = JSON.parse(res); downloadByteData(downloadContent, 'lookup_list.json'); - const timerTime = Math.max(2000, res.data['exportKnowledgeBase'].length * 0.0001); + const timerTime = Math.max(2000, res.length * 0.0001); timer(timerTime).subscribe(() => setDownloadMessage(DownloadState.NONE)); }); } diff --git a/src/components/projects/projectId/lookup-lists/lookupListId/LookupListsDetails.tsx b/src/components/projects/projectId/lookup-lists/lookupListId/LookupListsDetails.tsx index 2c8c7ec4..8924c06f 100644 --- a/src/components/projects/projectId/lookup-lists/lookupListId/LookupListsDetails.tsx +++ b/src/components/projects/projectId/lookup-lists/lookupListId/LookupListsDetails.tsx @@ -42,7 +42,7 @@ export default function LookupListsDetails() { useEffect(() => { if (!projectId || !router.query.lookupListId) return; getLookupListsByLookupListId(projectId, router.query.lookupListId as string, (res) => { - setLookupList(postProcessLookupList(res.data['knowledgeBaseByKnowledgeBaseId'])); + setLookupList(postProcessLookupList(res)); }); refetchTerms(); }, [projectId, router.query.lookupListId]); @@ -68,7 +68,7 @@ export default function LookupListsDetails() { CommentDataManager.registerCommentRequests(CurrentPage.LOOKUP_LISTS_DETAILS, requests); const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -76,8 +76,8 @@ export default function LookupListsDetails() { function refetchTerms() { getTermsByLookupListId(projectId, router.query.lookupListId as string, (res) => { - setFinalSize(res.data['termsByKnowledgeBaseId'].length); - setTerms(postProcessTerms(res.data['termsByKnowledgeBaseId'])); + setFinalSize(res.length); + setTerms(postProcessTerms(res)); }); } @@ -128,7 +128,7 @@ export default function LookupListsDetails() { if (msgParts[2] == router.query.lookupListId) { if (msgParts[1] == 'knowledge_base_updated') { getLookupListsByLookupListId(projectId, router.query.lookupListId as string, (res) => { - setLookupList(postProcessLookupList(res.data['knowledgeBaseByKnowledgeBaseId'])); + setLookupList(postProcessLookupList(res)); }); } else if (msgParts[1] == 'knowledge_base_deleted') { alert('Lookup list was deleted'); diff --git a/src/components/projects/projectId/overview/ProjectOverview.tsx b/src/components/projects/projectId/overview/ProjectOverview.tsx index d5b0d1a7..48f3978e 100644 --- a/src/components/projects/projectId/overview/ProjectOverview.tsx +++ b/src/components/projects/projectId/overview/ProjectOverview.tsx @@ -6,7 +6,7 @@ import { getEmptyProjectStats, postProcessLabelDistribution, postProcessingStats import ProjectOverviewCards from './ProjectOverviewCards'; import { ProjectStats } from '@/src/types/components/projects/projectId/project-overview/project-overview'; import style from '@/src/styles/components/projects/projectId/project-overview.module.css'; -import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from '@/src/util/components/projects/projectId/settings/labeling-tasks-helper'; +import { postProcessLabelingTasksSchema } from '@/src/util/components/projects/projectId/settings/labeling-tasks-helper'; import { selectLabelingTasksAll, setAllAttributes, setLabelingTasksAll } from '@/src/reduxStore/states/pages/settings'; import { setDataSlices } from '@/src/reduxStore/states/pages/data-browser'; import { selectOverviewFilters } from '@/src/reduxStore/states/tmp'; @@ -70,27 +70,26 @@ export default function ProjectOverview() { CommentDataManager.registerCommentRequests(CurrentPage.PROJECT_OVERVIEW, requests); const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); } function refetchAttributesAndProcess() { getAttributes(projectId, ['ALL'], (res) => { - dispatch(setAllAttributes(res.data['attributesByProjectId'])); + dispatch(setAllAttributes(res)); }); } function refetchLabelingTasksAndProcess() { getLabelingTasksByProjectId(projectId, (res) => { - const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']); - dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(labelingTasks))); + dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(res))); }); } function refetchDataSlicesAndProcess() { getDataSlices(projectId, null, (res) => { - dispatch(setDataSlices(res.data.dataSlices)); + dispatch(setDataSlices(res)); }); } @@ -99,8 +98,7 @@ export default function ProjectOverview() { const dataSliceFindId = overviewFilters.dataSlice?.id; const dataSliceId = dataSliceFindId == "@@NO_SLICE@@" ? null : dataSliceFindId; getLabelDistribution(projectId, labelingTaskId, dataSliceId, (res) => { - if (res['data'] == null) return; - setLabelDistribution(postProcessLabelDistribution(res['data']['labelDistribution'], false)); + setLabelDistribution(postProcessLabelDistribution(res, false)); }); } @@ -113,8 +111,8 @@ export default function ProjectOverview() { const dataSliceId = dataSliceFindId == "@@NO_SLICE@@" ? null : dataSliceFindId; getGeneralProjectStats(projectId, labelingTaskId, dataSliceId, (res) => { - if (res['data'] == null) return; - setProjectStats(postProcessingStats(res['data']['generalProjectStats'])); + if (!res) return; + setProjectStats(postProcessingStats(res)); }); } diff --git a/src/components/projects/projectId/overview/ProjectOverviewCards.tsx b/src/components/projects/projectId/overview/ProjectOverviewCards.tsx index 28ac2f8d..325e4f61 100644 --- a/src/components/projects/projectId/overview/ProjectOverviewCards.tsx +++ b/src/components/projects/projectId/overview/ProjectOverviewCards.tsx @@ -16,7 +16,6 @@ const CARDS_DATA = [ export default function ProjectOverviewCards(props: ProjectOverviewCardsProps) { const router = useRouter(); const projectId = useSelector(selectProjectId); - return (
{CARDS_DATA.map((card: CardStats) => ( diff --git a/src/components/projects/projectId/settings/CreateNewAttributeModal.tsx b/src/components/projects/projectId/settings/CreateNewAttributeModal.tsx index 11d2442b..4e34be4c 100644 --- a/src/components/projects/projectId/settings/CreateNewAttributeModal.tsx +++ b/src/components/projects/projectId/settings/CreateNewAttributeModal.tsx @@ -31,7 +31,7 @@ export default function CreateNewAttributeModal() { const createUserAttribute = useCallback(() => { createAttribute(projectId, attributeName, attributeType.value, (res) => { - const id = res?.data?.createUserAttribute.attributeId; + const id = res?.attributeId; if (id) { localStorage.setItem('isNewAttribute', "X"); dispatch(setCurrentPage(CurrentPage.ATTRIBUTE_CALCULATION)); diff --git a/src/components/projects/projectId/settings/ProjectSettings.tsx b/src/components/projects/projectId/settings/ProjectSettings.tsx index 4145a622..5bf061d5 100644 --- a/src/components/projects/projectId/settings/ProjectSettings.tsx +++ b/src/components/projects/projectId/settings/ProjectSettings.tsx @@ -24,7 +24,7 @@ import { CommentType } from "@/src/types/shared/comments"; import { CommentDataManager } from "@/src/util/classes/comments"; import CreateNewAttributeModal from "./CreateNewAttributeModal"; import ProjectSnapshotExportModal from "./ProjectSnapshotExportModal"; -import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; +import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/useWebsocket"; import { getLabelingTasksByProjectId, getProjectByProjectId, getProjectTokenization } from "@/src/services/base/project"; import { getAllComments } from "@/src/services/base/comment"; @@ -66,9 +66,9 @@ export default function ProjectSettings() { if (!project) return; requestPKeyCheck(); getRecommendedEncoders(project.id, (res) => { - const encoderSuggestions = res['data']['recommendedEncoders'].filter(e => e.tokenizers.includes("all") || e.tokenizers.includes(project.tokenizer)); + const encoderSuggestions = res.filter(e => e.tokenizers.includes("all") || e.tokenizers.includes(project.tokenizer)); dispatch(setRecommendedEncodersAll(encoderSuggestions as RecommendedEncoder[])); - dispatch(setAllRecommendedEncodersDict(postProcessingRecommendedEncoders(attributes, project.tokenizer, res['data']['recommendedEncoders']))); + dispatch(setAllRecommendedEncodersDict(postProcessingRecommendedEncoders(attributes, project.tokenizer, res))); }); }, [attributes]); @@ -88,7 +88,7 @@ export default function ProjectSettings() { CommentDataManager.registerCommentRequests(CurrentPage.PROJECT_SETTINGS, requests); const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); @@ -96,18 +96,18 @@ export default function ProjectSettings() { function refetchAttributesAndPostProcess() { getAttributes(project.id, ['ALL'], (res) => { - dispatch(setAllAttributes(res.data['attributesByProjectId'])); + dispatch(setAllAttributes(res)); }); } function refetchEmbeddingsAndPostProcess() { getEmbeddings(project.id, (res) => { getQueuedTasks(project.id, "EMBEDDING", (queuedTasks) => { - const queuedEmbeddings = queuedTasks.data['queuedTasks'].map((task) => { + const queuedEmbeddings = queuedTasks?.map((task) => { const copy = { ...task }; return copy; }) - dispatch(setAllEmbeddings(postProcessingEmbeddings(res.data['projectByProjectId']['embeddings']['edges'].map((e) => e['node']), queuedEmbeddings))); + dispatch(setAllEmbeddings(postProcessingEmbeddings(res, queuedEmbeddings))); }); }); } @@ -119,7 +119,7 @@ export default function ProjectSettings() { const tmpTimer = timer(500).subscribe(() => { getCheckCompositeKey(project.id, (res) => { setPKeyCheckTimer(null); - if (anyPKey()) setPKeyValid(res.data['checkCompositeKey']); + if (anyPKey()) setPKeyValid(res); else setPKeyValid(null); }); }); @@ -136,7 +136,7 @@ export default function ProjectSettings() { function checkProjectTokenization() { getProjectTokenization(project.id, (res) => { - setTokenizationProgress(res.data['projectTokenization']?.progress); + setTokenizationProgress(res?.progress); setIsAcRunning(checkIfAcRunning()); }); } @@ -161,11 +161,11 @@ export default function ProjectSettings() { getEmbeddings(project.id, (res) => { getQueuedTasks(project.id, "EMBEDDING", (queuedTasks) => { - const queuedEmbeddings = queuedTasks.data['queuedTasks'].map((task) => { + const queuedEmbeddings = queuedTasks?.map((task) => { const copy = { ...task }; return copy; }) - const newEMbeddings = postProcessingEmbeddings(res.data['projectByProjectId']['embeddings']['edges'].map((e) => e['node']), queuedEmbeddings); + const newEMbeddings = postProcessingEmbeddings(res, queuedEmbeddings); for (let e of newEMbeddings) { if (e.id == msgParts[2]) { if (msgParts[3] == "state") { @@ -203,7 +203,7 @@ export default function ProjectSettings() { refetchAttributesAndPostProcess(); } else if (msgParts[1] == 'project_update' && msgParts[2] == project.id) { getProjectByProjectId(project.id, (res) => { - dispatch(setActiveProject(res.data["projectByProjectId"])); + dispatch(setActiveProject(res)); }) } else if (msgParts[1] == 'calculate_attribute') { @@ -217,7 +217,7 @@ export default function ProjectSettings() { timer(5000).subscribe(() => checkProjectTokenization()); } else { getAttributes(project.id, ['ALL'], (res) => { - dispatch(setAllAttributes(res.data['attributesByProjectId'])); + dispatch(setAllAttributes(res)); setIsAcRunning(checkIfAcRunning()); }); if (msgParts[2] == 'finished') timer(5000).subscribe(() => checkProjectTokenization()); @@ -231,8 +231,7 @@ export default function ProjectSettings() { function refetchLabelingTasksAndProcess() { getLabelingTasksByProjectId(project.id, (res) => { - const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']); - dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(labelingTasks))); + dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(res))); }); } diff --git a/src/components/projects/projectId/settings/ProjectSnapshotExportModal.tsx b/src/components/projects/projectId/settings/ProjectSnapshotExportModal.tsx index b568b58e..272a384e 100644 --- a/src/components/projects/projectId/settings/ProjectSnapshotExportModal.tsx +++ b/src/components/projects/projectId/settings/ProjectSnapshotExportModal.tsx @@ -55,14 +55,13 @@ export default function ProjectSnapshotExportModal() { function requestProjectSize() { getProjectSize(projectId, (res) => { - setProjectSize(res.data['projectSize']); - setProjectExportArray(postProcessingFormGroups(res.data['projectSize'], embeddings)); + setProjectSize(res); + setProjectExportArray(postProcessingFormGroups(res, embeddings)); }); } function requestProjectExportCredentials() { - getLastProjectExportCredentials(projectId, (res) => { - const projectExportCredentials = res.data['lastProjectExportCredentials']; + getLastProjectExportCredentials(projectId, (projectExportCredentials) => { if (!projectExportCredentials) setProjectExportCredentials(null); else { const credentials = JSON.parse(projectExportCredentials); diff --git a/src/components/projects/projectId/settings/embeddings/AddNewEmbeddingModal.tsx b/src/components/projects/projectId/settings/embeddings/AddNewEmbeddingModal.tsx index 2617c080..4e7e89ba 100644 --- a/src/components/projects/projectId/settings/embeddings/AddNewEmbeddingModal.tsx +++ b/src/components/projects/projectId/settings/embeddings/AddNewEmbeddingModal.tsx @@ -341,7 +341,7 @@ function SuggestionsModel(props: SuggestionsProps) { useEffect(() => { //collect on mount (open modal) getModelProviderInfo((res) => { - setCachedModelInfo(postProcessingModelsDownload(res.data['modelProviderInfo'])); + setCachedModelInfo(postProcessingModelsDownload(res)); }); }, []) diff --git a/src/components/projects/projectId/settings/labeling-tasks/RenameLabelModal.tsx b/src/components/projects/projectId/settings/labeling-tasks/RenameLabelModal.tsx index 6c4225a9..a471213a 100644 --- a/src/components/projects/projectId/settings/labeling-tasks/RenameLabelModal.tsx +++ b/src/components/projects/projectId/settings/labeling-tasks/RenameLabelModal.tsx @@ -58,8 +58,7 @@ export default function RenameLabelModal() { const [acceptButtonRename, setAcceptButtonRename] = useState(ACCEPT_BUTTON); function checkRenameLabel() { - getCheckRenameLabel(projectId, modalRenameLabel.label.id, renameLabelData.newLabelName, res => { - const result = res.data['checkRenameLabel']; + getCheckRenameLabel(projectId, modalRenameLabel.label.id, renameLabelData.newLabelName, result => { const renameLabelDataCopy = { ...renameLabelData }; result.warnings.forEach(e => { e.open = false; diff --git a/src/components/shared/comments/Comments.tsx b/src/components/shared/comments/Comments.tsx index ff79492a..7ff202cc 100644 --- a/src/components/shared/comments/Comments.tsx +++ b/src/components/shared/comments/Comments.tsx @@ -45,11 +45,11 @@ export default function Comments() { if (somethingToRerequest) { const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); if (allUsers.length == 0) { getOrganizationUsers((res) => { - dispatch(setAllUsers(res.data["allUsers"])); - CommentDataManager.parseToCurrentData(res.data["allUsers"]); + dispatch(setAllUsers(res)); + CommentDataManager.parseToCurrentData(res); }); } else { CommentDataManager.parseToCurrentData(allUsers); @@ -83,7 +83,7 @@ export default function Comments() { if (somethingToRerequest) { const requestJsonString = CommentDataManager.buildRequestJSON(); getAllComments(requestJsonString, (res) => { - CommentDataManager.parseCommentData(res.data['getAllComments']); + CommentDataManager.parseCommentData(res); CommentDataManager.parseToCurrentData(allUsers); dispatch(setComments(CommentDataManager.currentDataOrder)); }); diff --git a/src/components/shared/export/ExportRecordsModal.tsx b/src/components/shared/export/ExportRecordsModal.tsx index f596c1ce..405b503b 100644 --- a/src/components/shared/export/ExportRecordsModal.tsx +++ b/src/components/shared/export/ExportRecordsModal.tsx @@ -68,7 +68,7 @@ export default function ExportRecordsModal(props: ExportProps) { function requestRecordsExportCredentials() { getLastRecordExportCredentials(projectId, (res) => { - const recordExportCredentials = res.data['lastRecordExportCredentials']; + const recordExportCredentials = res; if (!recordExportCredentials) setRecordExportCredentials(null); else { const credentials = JSON.parse(recordExportCredentials); @@ -88,7 +88,7 @@ export default function ExportRecordsModal(props: ExportProps) { enumArraysCopy.set(ExportEnums.LabelSource, enumToArray(LabelSource, { nameFunction: labelSourceToString })); if (!force && enumArraysCopy[ExportEnums.Heuristics]) return; getRecordExportFromData(projectId, (res) => { - const postProcessedRes = postProcessExportRecordData(res['data']['projectByProjectId']); + const postProcessedRes = postProcessExportRecordData(res); enumArraysCopy.set(ExportEnums.Heuristics, postProcessedRes.informationSources); enumArraysCopy.set(ExportEnums.Attributes, postProcessedRes.attributes); enumArraysCopy.set(ExportEnums.LabelingTasks, postProcessedRes.labelingTasks); @@ -213,9 +213,9 @@ export default function ExportRecordsModal(props: ExportProps) { let keyToSend = key; if (!keyToSend) keyToSend = null; prepareRecordExport(projectId, { exportOptions: jsonString, key: keyToSend }, (res) => { - if (!res.data) { + if (!res?.prepared) { ExportHelper.error.push("Something went wrong in the backend:"); - ExportHelper.error.push(res.error); + ExportHelper.error.push(res.message); setPrepareErrors(ExportHelper.error); } setDownloadState(DownloadState.DOWNLOAD); diff --git a/src/components/shared/header/Header.tsx b/src/components/shared/header/Header.tsx index 04ec798b..ab8ac7ee 100644 --- a/src/components/shared/header/Header.tsx +++ b/src/components/shared/header/Header.tsx @@ -52,8 +52,7 @@ export default function Header() { function openModalAndRefetchNotifications() { getAllProjects((res) => { - const projects = res.data["allProjects"].edges.map((edge: any) => edge.node); - dispatch(setAllProjects(projects)); + dispatch(setAllProjects(res)); getNotifications({ projectFilter: [], levelFilter: [], @@ -61,7 +60,7 @@ export default function Header() { userFilter: true, limit: 50 }, (res) => { - dispatch(setNotifications(postProcessNotifications(res.data['notifications'], arrayToDict(projects, 'id'), notificationId))); + dispatch(setNotifications(postProcessNotifications(res, arrayToDict(res, 'id'), notificationId))); dispatch(openModal(ModalEnum.NOTIFICATION_CENTER)); }); }); diff --git a/src/components/shared/layout/Layout.tsx b/src/components/shared/layout/Layout.tsx index b2093cc6..ad811b3c 100644 --- a/src/components/shared/layout/Layout.tsx +++ b/src/components/shared/layout/Layout.tsx @@ -78,12 +78,12 @@ export default function Layout({ children }) { function refetchNotificationsAndProcess() { getNotificationsByUser((res) => { - setNotificationsState(postProcessNotificationsUser(res['data']['notificationsByUserId'], notificationsState)); + setNotificationsState(postProcessNotificationsUser(res, notificationsState)); }); } function refetchAdminMessagesAndProcess() { - getAllActiveAdminMessages((res) => setActiveAdminMessages(postProcessAdminMessages(res['data']['allActiveAdminMessages']))); + getAllActiveAdminMessages((res) => setActiveAdminMessages(postProcessAdminMessages(res))); } function unsubscribeDeletionTimer(deletionTimer) { diff --git a/src/components/shared/sidebar/Sidebar.tsx b/src/components/shared/sidebar/Sidebar.tsx index f3b81dd6..c5a59be8 100644 --- a/src/components/shared/sidebar/Sidebar.tsx +++ b/src/components/shared/sidebar/Sidebar.tsx @@ -8,7 +8,7 @@ import { useState } from 'react'; import AppSelectionDropdown from '@/submodules/react-components/components/AppSelectionDropdown'; import { ModalEnum } from '@/src/types/shared/modal'; import { openModal } from '@/src/reduxStore/states/modal'; -import { IconAlertCircle, IconApi, IconBulb, IconChartPie, IconMaximize, IconMinimize, IconTag, IconTriangleSquareCircle } from '@tabler/icons-react'; +import { IconAlertCircle, IconBulb, IconChartPie, IconMaximize, IconMinimize, IconTag, IconTriangleSquareCircle } from '@tabler/icons-react'; import { IconSettings } from '@tabler/icons-react'; import { useRouter } from 'next/router'; import { TOOLTIPS_DICT } from '@/src/util/tooltip-constants'; @@ -65,7 +65,7 @@ export default function Sidebar() { dispatch(openModal(ModalEnum.VERSION_OVERVIEW)); if (versionOverviewData) { getHasUpdates(res => { - setHasUpdates(res.data["hasUpdates"]); + setHasUpdates(res); }); } } @@ -154,14 +154,6 @@ export default function Sidebar() {
} ) : (<>)} -
- - - - - -
{!isFullScreen &&
diff --git a/src/components/shared/upload/Upload.tsx b/src/components/shared/upload/Upload.tsx index 88bc5794..321ca5cc 100644 --- a/src/components/shared/upload/Upload.tsx +++ b/src/components/shared/upload/Upload.tsx @@ -74,8 +74,7 @@ export default function Upload(props: UploadProps) { if (msgParts[2] != uploadTask.id) return; if (msgParts[3] == 'state') { if (msgParts[4] == UploadStates.DONE) { - getUploadTaskById(projectId, uploadTask.id, (res) => { - const task = res.data['uploadTaskById']; + getUploadTaskById(projectId, uploadTask.id, (task) => { handleUploadTaskResult(task); }); } @@ -93,8 +92,7 @@ export default function Upload(props: UploadProps) { } } else if (msgParts[3] == 'progress') { if (msgParts[4] == "100") { - getUploadTaskById(projectId, uploadTask.id, (res) => { - const task = res.data['uploadTaskById']; + getUploadTaskById(projectId, uploadTask.id, (task) => { handleUploadTaskResult(task); }); } @@ -117,14 +115,14 @@ export default function Upload(props: UploadProps) { return; } createProjectPost({ name: projectTitle, description: projectDescription }, (res) => { - const project = res.data.createProject['project']; + const project = res['project']; dispatch(extendAllProjects(project)); UploadHelper.setProjectId(project.id); executeUploadFile(); }) } else if (uploadFileType == UploadFileType.PROJECT) { createProjectPost({ name: props.uploadOptions.projectName, description: "Created during file upload " + selectedFile?.name }, (res) => { - const project = res.data.createProject['project']; + const project = res['project']; dispatch(extendAllProjects(project)); UploadHelper.setProjectId(project.id); executeUploadFile(); @@ -173,17 +171,15 @@ export default function Upload(props: UploadProps) { function finishUpUpload(finalFinalName: string, importOptionsPrep: string) { let keyToSend = key; if (!keyToSend) keyToSend = null; - getUploadCredentialsAndId(UploadHelper.getProjectId(), finalFinalName, uploadFileType, importOptionsPrep, UploadType.DEFAULT, keyToSend, (results) => { - const credentialsAndUploadId = JSON.parse(JSON.parse(results.data['uploadCredentialsAndId'])); - uploadFileToMinio(credentialsAndUploadId, finalFinalName); + getUploadCredentialsAndId(UploadHelper.getProjectId(), finalFinalName, uploadFileType, importOptionsPrep, UploadType.DEFAULT, keyToSend, (res) => { + uploadFileToMinio(res, finalFinalName); }); } function uploadFileToMinio(credentialsAndUploadId: any, fileName: string) { setUploadStarted(true); setDoingSomething(true); - getUploadTaskById(UploadHelper.getProjectId(), credentialsAndUploadId.uploadTaskId, (res) => { - const task = res.data['uploadTaskById']; + getUploadTaskById(UploadHelper.getProjectId(), credentialsAndUploadId.uploadTaskId, (task) => { handleUploadTaskResult(task); uploadFile(credentialsAndUploadId, selectedFile, fileName).subscribe((progress) => { setProgressState(progress); diff --git a/src/reduxStore/StoreManagerComponent.tsx b/src/reduxStore/StoreManagerComponent.tsx index f413f886..427da7b1 100644 --- a/src/reduxStore/StoreManagerComponent.tsx +++ b/src/reduxStore/StoreManagerComponent.tsx @@ -28,24 +28,24 @@ export function GlobalStoreDataComponent(props: React.PropsWithChildren) { const [dataLoaded, setDataLoaded] = useState(false); useEffect(() => { - getIsAdmin((data) => { - dispatch(setIsAdmin(data.data.isAdmin)); + getIsAdmin((isAdmin) => { + dispatch(setIsAdmin(isAdmin)); }); getUserInfo((res) => { - const userInfo = { ...res.data["userInfo"] }; - userInfo.avatarUri = getUserAvatarUri(res.data["userInfo"]); + const userInfo = { ...res }; + userInfo.avatarUri = getUserAvatarUri(res); dispatch(setUser(userInfo)); - dispatch(setDisplayUserRole(res.data["userInfo"].role)); + dispatch(setDisplayUserRole(res.role)); }); getOrganization((res) => { - if (res.data["userOrganization"]) { + if (res?.id) { if (WebSocketsService.getConnectionOpened()) return; WebSocketsService.setConnectionOpened(true); WebSocketsService.initWsNotifications(); setDataLoaded(true); - dispatch(setOrganization(res.data["userOrganization"])); + dispatch(setOrganization(res)); } else { dispatch(setOrganization(null)); timer(60000).subscribe(() => location.reload()) @@ -54,18 +54,16 @@ export function GlobalStoreDataComponent(props: React.PropsWithChildren) { // Set cache getVersionOverview((res) => { - dispatch(setCache(CacheEnum.VERSION_OVERVIEW, postprocessVersionOverview(res.data['versionOverview']))); + dispatch(setCache(CacheEnum.VERSION_OVERVIEW, postprocessVersionOverview(res))); }); getEmbeddingPlatforms((res) => { - dispatch(setCache(CacheEnum.EMBEDDING_PLATFORMS, postProcessingEmbeddingPlatforms(res.data['embeddingPlatforms'], organization))) + dispatch(setCache(CacheEnum.EMBEDDING_PLATFORMS, postProcessingEmbeddingPlatforms(res, organization))) }); }, []); useEffect(() => { if (!organization) return; - getOrganizationUsers((res) => { - dispatch(setAllUsers(res.data["allUsers"])); - }); + getOrganizationUsers((res) => dispatch(setAllUsers(res))); }, [organization]); useEffect(() => { @@ -90,21 +88,21 @@ export function GlobalStoreDataComponent(props: React.PropsWithChildren) { const projectId = router.query.projectId as string; if (projectId) { getProjectByProjectId(projectId, (res) => { - dispatch(setActiveProject(res.data["projectByProjectId"])); + dispatch(setActiveProject(res)); }) } else { dispatch(setActiveProject(null)); } getRecommendedEncoders(null, (resEncoders) => { - dispatch(setCache(CacheEnum.MODELS_LIST, postProcessingEncoders(resEncoders.data['recommendedEncoders']))) + dispatch(setCache(CacheEnum.MODELS_LIST, postProcessingEncoders(resEncoders))) }); }, [router.query.projectId]); useEffect(() => { if (!ConfigManager.isInit()) return; getAllTokenizerOptions((res) => { - dispatch(setCache(CacheEnum.TOKENIZER_VALUES, checkWhitelistTokenizer(res.data['languageModels']))); + dispatch(setCache(CacheEnum.TOKENIZER_VALUES, checkWhitelistTokenizer(res))); }) }, [ConfigManager.isInit()]); diff --git a/src/services/base/heuristic.ts b/src/services/base/heuristic.ts index ba37fe9a..32807553 100644 --- a/src/services/base/heuristic.ts +++ b/src/services/base/heuristic.ts @@ -29,11 +29,6 @@ export function getLabelingFunctionOn10Records(projectId: string, heuristicId: s jsonFetchWrapper(finalUrl, FetchType.GET, onResult); } -export function getAccessLink(projectId: string, linkId: string, onResult: (result: any) => void) { - const finalUrl = `${heuristicEndpoint}/${projectId}/access-link?link_id=${linkId}`; - jsonFetchWrapper(finalUrl, FetchType.GET, onResult); -} - export function toggleHeuristicById(projectId: string, heuristicId: string, onResult: (result: any) => void) { const finalUrl = `${heuristicEndpoint}/${projectId}/${heuristicId}/toggle-heuristic`; jsonFetchWrapper(finalUrl, FetchType.POST, onResult); diff --git a/src/services/base/labeling.ts b/src/services/base/labeling.ts index 4758fae1..4eb5a1d8 100644 --- a/src/services/base/labeling.ts +++ b/src/services/base/labeling.ts @@ -41,25 +41,6 @@ export function getLinkLocked(projectId: string, options: { jsonFetchWrapper(finalUrl, FetchType.POST, onResult, JSON.stringify(convertCamelToSnakeCase(options))); } -export function generateAccessLinkPost(projectId: string, options: { - type: string, id: string, -}, onResult: (result: any) => void) { - const finalUrl = `${labelingEndpoint}/${projectId}/generate-access-link`; - jsonFetchWrapper(finalUrl, FetchType.POST, onResult, JSON.stringify(convertCamelToSnakeCase(options))); -} - -export function removeAccessLinkPost(projectId: string, linkId: string, onResult: (result: any) => void) { - const finalUrl = `${labelingEndpoint}/${projectId}/remove-access-link`; - jsonFetchWrapper(finalUrl, FetchType.DELETE, onResult, JSON.stringify({ "value": linkId })); -} - -export function lockAccessLink(projectId: string, options: { - linkId: string, lockState: boolean -}, onResult: (result: any) => void) { - const finalUrl = `${labelingEndpoint}/${projectId}/lock-access-link`; - jsonFetchWrapper(finalUrl, FetchType.PUT, onResult, JSON.stringify(convertCamelToSnakeCase(options))); -} - export function addClassificationLabels(projectId: string, recordId: string, labelingTaskId: string, labelId: string, asGoldStar: boolean, sourceId: string, onResult: (result: any) => void) { const finalUrl = `${labelingEndpoint}/${projectId}/add-classification-labels`; const body = { diff --git a/src/services/base/project-setting.ts b/src/services/base/project-setting.ts index ef757eaf..835037f3 100644 --- a/src/services/base/project-setting.ts +++ b/src/services/base/project-setting.ts @@ -48,11 +48,6 @@ export function getProjectSize(projectId: string, onResult: (result: any) => voi jsonFetchWrapper(finalUrl, FetchType.GET, onResult); } -export function createLabels(projectId: string, labelingTaskId: string, labels: string[], onResult: (result: any) => void) { - const finalUrl = `${projectSettingEndpoint}/${projectId}/create-labels`; - jsonFetchWrapper(finalUrl, FetchType.POST, onResult, JSON.stringify({ labelingTaskId, labels })); -} - export function createAttribute(projectId: string, name: string, dataType: string, onResult: (result: any) => void) { const finalUrl = `${projectSettingEndpoint}/${projectId}/create-attribute`; jsonFetchWrapper(finalUrl, FetchType.POST, onResult, JSON.stringify(convertCamelToSnakeCase({ name, dataType }))); @@ -68,11 +63,4 @@ export function calculateUserAttributeAllRecordsPost(projectId: string, options: }, onResult: (result: any) => void) { const finalUrl = `${projectSettingEndpoint}/${projectId}/calculate-user-attribute-all-records`; jsonFetchWrapper(finalUrl, FetchType.POST, onResult, JSON.stringify(convertCamelToSnakeCase(options))); -} - -export function createTaskAndLabels(projectId: string, options: { - labelingTaskName: string, labelingTaskType: string, labelingTaskTargetId: string, labels: string[] -}, onResult: (result: any) => void) { - const finalUrl = `${projectSettingEndpoint}/${projectId}/create-task-and-labels`; - jsonFetchWrapper(finalUrl, FetchType.POST, onResult, JSON.stringify(convertCamelToSnakeCase(options))); } \ No newline at end of file diff --git a/src/util/components/projects/projectId/data-browser/search-groups-helper.ts b/src/util/components/projects/projectId/data-browser/search-groups-helper.ts index 28a71ed3..c18a9549 100644 --- a/src/util/components/projects/projectId/data-browser/search-groups-helper.ts +++ b/src/util/components/projects/projectId/data-browser/search-groups-helper.ts @@ -152,7 +152,7 @@ export function labelingTasksCreateSearchGroup(item, task: LabelingTask, globalS group: item.group, groupKey: item.groupKey, type: item.type, - taskTarget: task.taskTarget == LabelingTaskTarget.ON_ATTRIBUTE ? task.attribute.name : 'Full Record', + taskTarget: task.targetName, taskId: task.id, active: false, manualLabels: labelingTaskLabelArray(task), diff --git a/src/util/components/projects/projectId/heuristics/heuristicId/heuristics-details-helper.ts b/src/util/components/projects/projectId/heuristics/heuristicId/heuristics-details-helper.ts index 4eaeaae5..d6ea0080 100644 --- a/src/util/components/projects/projectId/heuristics/heuristicId/heuristics-details-helper.ts +++ b/src/util/components/projects/projectId/heuristics/heuristicId/heuristics-details-helper.ts @@ -12,7 +12,7 @@ export function postProcessCurrentHeuristic(heuristic: Heuristic, labelingTasks: prepareHeuristic.labelSource = LabelSource.INFORMATION_SOURCE; prepareHeuristic.informationSourceType = InformationSourceType[heuristic['type']]; prepareHeuristic.selected = heuristic['isSelected']; - prepareHeuristic.stats = mapInformationSourceStats(heuristic['sourceStatistics']['edges']); + prepareHeuristic.stats = mapInformationSourceStats(heuristic['sourceStatistics']); prepareHeuristic.stats.forEach((stat) => { stat.color = getColorStruct(stat.color); }); diff --git a/src/util/components/projects/projectId/heuristics/shared-helper.ts b/src/util/components/projects/projectId/heuristics/shared-helper.ts index 7f40af44..54b2a212 100644 --- a/src/util/components/projects/projectId/heuristics/shared-helper.ts +++ b/src/util/components/projects/projectId/heuristics/shared-helper.ts @@ -30,9 +30,9 @@ function convertStatDataGlobal(data = null) { } } -export function mapInformationSourceStats(edges) { - if (edges.length) { - return edges.map((wrapper) => { +export function mapInformationSourceStats(sourceStatistics) { + if (sourceStatistics.length) { + return sourceStatistics.map((wrapper) => { return convertStatData(wrapper['node']) }) } else { diff --git a/src/util/components/projects/projectId/settings/labeling-tasks-helper.ts b/src/util/components/projects/projectId/settings/labeling-tasks-helper.ts index 3bed3495..0615ca52 100644 --- a/src/util/components/projects/projectId/settings/labeling-tasks-helper.ts +++ b/src/util/components/projects/projectId/settings/labeling-tasks-helper.ts @@ -1,35 +1,7 @@ import { Attribute } from "@/src/types/components/projects/projectId/settings/data-schema"; -import { LabelingTask, LabelingTaskTarget, LabelingTaskTaskType } from "@/src/types/components/projects/projectId/settings/labeling-tasks"; +import { LabelingTask, LabelingTaskTaskType } from "@/src/types/components/projects/projectId/settings/labeling-tasks"; import { LabelHelper } from "@/src/util/classes/label-helper"; -let rPos = { pos: 9990 }; //as object to increase in private function - -export function postProcessLabelingTasks(labelingTasks: any[]): any[] { - if (!labelingTasks) return []; - const prepareLabelingTasks = labelingTasks.map((labelingTask: any) => { - const data = labelingTask.node; - return { - id: data.id, - name: data.name, - taskTarget: data.taskTarget, - attribute: data.attribute, - taskType: data.taskType, - labels: !data.labels.edges - ? [] - : data.labels.edges.map((edge) => { - return edge.node; - }), - informationSources: !data.informationSources.edges - ? [] - : data.informationSources.edges.map((edge) => { - return edge.node; - }), - relativePosition: data.attribute?.relativePosition ?? rPos.pos++, - }; - }).sort((a, b) => (a.relativePosition - b.relativePosition) || a.name.localeCompare(b.name)); - return prepareLabelingTasks; -} - export function postProcessLabelingTasksSchema(labelingTasks: LabelingTask[]): LabelingTask[] { const prepareLabelingTasks = []; labelingTasks.forEach((task) => { @@ -37,8 +9,6 @@ export function postProcessLabelingTasksSchema(labelingTasks: LabelingTask[]): L LabelHelper.labelingTaskColors.set(task.id, task.labels.map((label) => label.color)); task.labels = task.labels.map((label) => LabelHelper.extendLabelForColor({ ...label })); task.nameOpen = false; - task.targetId = task.taskTarget == LabelingTaskTarget.ON_ATTRIBUTE ? task.attribute.id : ""; - task.targetName = task.taskTarget == LabelingTaskTarget.ON_ATTRIBUTE ? task.attribute.name : "Full Record"; LabelHelper.labelMap.set(task.id, task.labels); prepareLabelingTasks.push(task); }); diff --git a/src/util/components/projects/projectId/settings/project-export-helper.ts b/src/util/components/projects/projectId/settings/project-export-helper.ts index 50fe0c84..86ff72b3 100644 --- a/src/util/components/projects/projectId/settings/project-export-helper.ts +++ b/src/util/components/projects/projectId/settings/project-export-helper.ts @@ -29,7 +29,7 @@ export function postProcessingFormGroups(projectSize: any, embeddings: Embedding moveRight: getMoveRight(element.table), name: element.table, desc: hasGdpr ? null : element.description, - sizeNumber: element.byteSize, + sizeNumber: parseFloat(element.byteSize), sizeReadable: element.byteReadable, }; projectExportArray.push(group); diff --git a/src/util/shared/export-helper.ts b/src/util/shared/export-helper.ts index f1a7de90..022bd66f 100644 --- a/src/util/shared/export-helper.ts +++ b/src/util/shared/export-helper.ts @@ -10,12 +10,12 @@ let rPos = { pos: 9990 }; export default function postProcessExportRecordData(data: any) { let x: any = { - projectId: data.id, + projectId: data.projectId, name: data.name, - labelingTasks: data.labelingTasks.edges.map((edge) => edge.node), - informationSources: data.informationSources.edges.map((edge) => edge.node), - attributes: data.attributes.edges.map((edge) => edge.node).filter((att) => [Status.UPLOADED, Status.USABLE, Status.AUTOMATICALLY_CREATED].includes(att.state)), - dataSlices: data.dataSlices.edges.map((edge) => edge.node), + labelingTasks: data.labelingTasks, + informationSources: data.informationSources, + attributes: data.attributes.filter((att) => [Status.UPLOADED, Status.USABLE, Status.AUTOMATICALLY_CREATED].includes(att.state)), + dataSlices: data.dataSlices, } x.dataSlices.forEach(element => { if (element.sliceType == Slice.STATIC_OUTLIER) { diff --git a/submodules/javascript-functions b/submodules/javascript-functions index 3bd200a3..12bf29c1 160000 --- a/submodules/javascript-functions +++ b/submodules/javascript-functions @@ -1 +1 @@ -Subproject commit 3bd200a34cc3531519d0b3e48fca5910a10b19e3 +Subproject commit 12bf29c1966fe1bfeb716d4e6f4dc9112e7c1ee4