Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataset types url #1478

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/src/components/collections/collections.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ export function CollectionForm (props){
entity.id = entity.uuid;
//When coming from the Entity, the Datasets use dataset_type, from the Search UI they pass display_subtype instead
if (entity.dataset_type && entity.dataset_type.length > 0) {
var subtype = generateDisplaySubtypeSimple_UBKG(entity.dataset_type[0],props.dtl_all);
var subtype = "";
if (typeof entity.dataset_type === 'string'){
subtype = generateDisplaySubtypeSimple_UBKG(entity.dataset_type,props.dtl_all);
}else{
subtype = generateDisplaySubtypeSimple_UBKG(entity.dataset_type[0],props.dtl_all);
}
entity.display_subtype = subtype;
}else {

Expand Down
7 changes: 6 additions & 1 deletion src/src/components/collections/epicollections.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ export function EPICollectionForm (props){
entity.id = entity.uuid;
//When coming from the Entity, the Datasets use dataset_type, from the Search UI they pass display_subtype instead
if (entity.dataset_type && entity.dataset_type.length > 0) {
var subtype = generateDisplaySubtypeSimple_UBKG(entity.dataset_type[0],props.dtl_all);
var subtype = "";
if (typeof entity.dataset_type === 'string'){
subtype = generateDisplaySubtypeSimple_UBKG(entity.dataset_type,props.dtl_all);
}else{
subtype = generateDisplaySubtypeSimple_UBKG(entity.dataset_type[0],props.dtl_all);
}
entity.display_subtype = subtype;
}else {

Expand Down
2 changes: 1 addition & 1 deletion src/src/components/datasets.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState, useRef, useContext } from "react";
import { useParams }from 'react-router-dom';
import { entity_api_get_entity} from '../service/entity_api';
import { ubkg_api_get_assay_type_set } from "../service/ubkg_api";
// import { ubkg_api_get_assay_type_set } from "../service/ubkg_api";
import DatasetFormLegacy from "./ingest/dataset_edit";
import {useNavigate} from "react-router-dom";
import {useLocation } from 'react-router'
Expand Down
4 changes: 2 additions & 2 deletions src/src/components/ingest/dataset_edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1712,8 +1712,8 @@ name, display_doi, doi
<option value=""></option>
{this.props.dtl_all.map((type, index) => {
return (
<option key={index + 1} value={type.term}>
{type.term}
<option key={index + 1} value={type.dataset_type}>
{type.dataset_type}
</option>
);
})}
Expand Down
89 changes: 45 additions & 44 deletions src/src/components/ingest/publications_edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {
entity_api_get_entity,
} from "../../service/entity_api";
//import { withRouter } from 'react-router-dom';
import {ubkg_api_get_assay_type_set} from "../../service/ubkg_api";
// import {ubkg_api_get_assay_type_set} from "../../service/ubkg_api";
import {getPublishStatusColor} from "../../utils/badgeClasses";
import {generateDisplaySubtype} from "../../utils/display_subtypes";
import {removeEmptyValues} from "../../utils/constants_helper";
Expand Down Expand Up @@ -81,7 +81,7 @@ class PublicationEdit extends Component {
newForm: this.props.newForm,
dataset_type:"publication",
dtl_primary: [],
dtl_all: [],
// dtl_all: [],
selected_dt: "",
dataset_info: "",
description: "",
Expand Down Expand Up @@ -215,7 +215,7 @@ class PublicationEdit extends Component {
//consoledebug("this.state.validationStatus.publication_doi.length >0", this.state.validationStatus.publication_doi.length >0);
// Modal state as flag for add/remove?
document.addEventListener("click", this.handleClickOutside);
this.setAssayLists();
// this.setAssayLists();
var savedGeneticsStatus = undefined;
try {
var auth = JSON.parse(localStorage.getItem("info")).groups_token;
Expand Down Expand Up @@ -477,26 +477,26 @@ class PublicationEdit extends Component {
}
}

setAssayLists() {
ubkg_api_get_assay_type_set()
.then((res) => {
this.setState({
dtl_all: res.data.result.map((value, index) => {
return value.name;
}),
});
})
.catch((err) => {});
ubkg_api_get_assay_type_set("primary")
.then((res) => {
this.setState({
dtl_primary: res.data.result.map((value, index) => {
return value.name;
}),
});
})
.catch((err) => {});
}
// setAssayLists() {
// ubkg_api_get_assay_type_set()
// .then((res) => {
// this.setState({
// dtl_all: res.data.result.map((value, index) => {
// return value.name;
// }),
// });
// })
// .catch((err) => {});
// ubkg_api_get_assay_type_set("primary")
// .then((res) => {
// this.setState({
// dtl_primary: res.data.result.map((value, index) => {
// return value.name;
// }),
// });
// })
// .catch((err) => {});
// }

componentWillUnmount() {
document.removeEventListener("click", this.handleClickOutside, true);
Expand Down Expand Up @@ -1888,28 +1888,28 @@ class PublicationEdit extends Component {
// }
// }

renderAssayColumn(min, max) {
// Hijacking Select options based on Primary DT status
if (this.props.dtl_status || this.props.newForm) {
// true = primary dt, set options to primary
return this.props.dtl_primary.slice(min, max).map((val, idx) => {
return this.renderAssay(val, idx);
});
} else {
// false = Not primary DT, set options to full
return this.props.dtl_all.slice(min, max).map((val, idx) => {
return this.renderAssay(val, idx);
});
}
}
// renderAssayColumn(min, max) {
// // Hijacking Select options based on Primary DT status
// if (this.props.dtl_status || this.props.newForm) {
// // true = primary dt, set options to primary
// return this.props.dtl_primary.slice(min, max).map((val, idx) => {
// return this.renderAssay(val, idx);
// });
// } else {
// // false = Not primary DT, set options to full
// return this.props.dtl_all.slice(min, max).map((val, idx) => {
// return this.renderAssay(val, idx);
// });
// }
// }

renderAssay(val) {
return (
<option key={val.name} value={val.name} id={val.name}>
{val.description}
</option>
);
}
// renderAssay(val) {
// return (
// <option key={val.name} value={val.name} id={val.name}>
// {val.description}
// </option>
// );
// }

renderListAssay(val) {
return <li key={val}>{val}</li>;
Expand Down Expand Up @@ -2319,6 +2319,7 @@ class PublicationEdit extends Component {
<div className="form-group">
<FormControl fullWidth>
<TextField
required
error={this.state.validationStatus.description.length >0}
label="Abstract"
disabled={!this.state.writeable}
Expand Down
15 changes: 9 additions & 6 deletions src/src/components/publications.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState, useRef } from "react";
import { useParams }from 'react-router-dom';
import { entity_api_get_entity} from '../service/entity_api';
import { ubkg_api_get_assay_type_set } from "../service/ubkg_api";
import { ubkg_api_get_dataset_type_set } from "../service/ubkg_api";
import PublicationFormLegacy from "./ingest/publications_edit";
import {useNavigate} from "react-router-dom";
import { useLocation } from 'react-router'
Expand Down Expand Up @@ -77,13 +77,16 @@ export const RenderPublication = (props) => {

function checkAssayType(dtype){
// These'll likely be changing and it's causing off behavior for publications
// Nuking for now
ubkg_api_get_assay_type_set("primary")// the list call only gets primaries for now.
// // Nuking for now
// Just swap for the new dataset types call

// ubkg_api_get_assay_type_set("primary")// the list call only gets primaries for now.
ubkg_api_get_dataset_type_set()
.then((response) => {
console.debug("checkAssayType Primary", response);
setDataTypeList(response.data.result);
setDtl_primary(response.data.result);
setDtl_all(response.data.result);
setDataTypeList(response);
setDtl_primary(response);
setDtl_all(response);
setDtl_status(true);
setIsLoadingDTList(0);
})
Expand Down
23 changes: 0 additions & 23 deletions src/src/service/search_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,29 +263,6 @@ export function search_api_get_assay_type(assay) {
});
}

export function search_api_get_assay_list(params) {
// So the api defaults to primary even if False is passed as ?primary=false
var primaryParam = {};
if (params) {
primaryParam = { params: params };
}
return (
axios
// Only regards flag via url for some reason?
.get(`${process.env.REACT_APP_SEARCH_API_URL}/assaytype?primary=true`)
.then((res) => {
let data = res.data;
let dtListMapped = data.result.map((value, index) => {
return value;
});
return { status: res.status, data: dtListMapped };
})
.catch((error) => {
return { error };
})
);
}

export function search_api_get_assay_set(scope) {
// Scope informs either Primary, Alt, or All
var target = "";
Expand Down
53 changes: 27 additions & 26 deletions src/src/service/ubkg_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@ import { stripHTML,toTitleCase } from '../utils/string_helper'
*
* return: { status, results}
*/
export function ubkg_api_get_assay_type_set(scope) {
// application_context
// console.debug("ubkg_api_get_assay_type_set", scope);
let url = `${process.env.REACT_APP_UBKG_API_URL}/assaytype?application_context=HUBMAP`;
// let url = `${process.env.REACT_APP_SEARCH_API_URL}/v3/assaytype`;
// Note: scope == 'all' will not include the query parameter
if (scope === 'primary') {
url += '&primary=true'
} else if (scope === 'alt') {
url += '&primary=false'
}
// console.debug("ubkg_api_get_assay_type_set url", url);
return axios
.get(url)
.then(res => {
// let mapCheck = data.result.map((value, index) => { return value });
let data = res.data;
return {data}
})
.catch(error => {
console.debug('%c⭗', 'color:#ff005d', "ubkg_api_get_assaytype", error, error.response);
var errorResp = captureError(error);
return errorResp
});
};
// export function ubkg_api_get_assay_type_set(scope) {
// // application_context
// // console.debug("ubkg_api_get_assay_type_set", scope);
// let url = `${process.env.REACT_APP_UBKG_API_URL}/assaytype?application_context=HUBMAP`;
// // let url = `${process.env.REACT_APP_SEARCH_API_URL}/v3/assaytype`;
// // Note: scope == 'all' will not include the query parameter
// if (scope === 'primary') {
// url += '&primary=true'
// } else if (scope === 'alt') {
// url += '&primary=false'
// }
// // console.debug("ubkg_api_get_assay_type_set url", url);
// return axios
// .get(url)
// .then(res => {
// // let mapCheck = data.result.map((value, index) => { return value });
// let data = res.data;
// return {data}
// })
// .catch(error => {
// console.debug('%c⭗', 'color:#ff005d', "ubkg_api_get_assaytype", error, error.response);
// var errorResp = captureError(error);
// return errorResp
// });
// };

/*
* UBKG GET organtype/all method
Expand Down Expand Up @@ -71,7 +71,8 @@ export function ubkg_api_get_organ_type_set() {
*
*/
export function ubkg_api_get_dataset_type_set() {
let url = `${process.env.REACT_APP_UBKG_API_URL}/valueset?parent_sab=HUBMAP&parent_code=C003041&child_sabs=HUBMAP`;
// let url = `${process.env.REACT_APP_UBKG_API_URL}/valueset?parent_sab=HUBMAP&parent_code=C003041&child_sabs=HUBMAP`;
let url = `${process.env.REACT_APP_UBKG_API_URL}/dataset-types?application_context=HUBMAP`;
return axios
.get(url)
.then(res => {
Expand Down
41 changes: 20 additions & 21 deletions src/src/utils/display_subtypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// otherwise the display name linked to the value of the corresponding description of specimen_type code
// Dataset: the display names linked to the values in dataset_type as a comma separated list

import { ubkg_api_get_organ_type_set,ubkg_api_get_assay_type_set } from "../service/ubkg_api";
import { ubkg_api_get_organ_type_set,ubkg_api_get_dataset_type_set } from "../service/ubkg_api";
import { SAMPLE_TYPES } from "../constants";


Expand Down Expand Up @@ -134,23 +134,23 @@ function get_organ_description_UBKG(organ_code) {
}

// Get Sample Types
function get_sample_types_UBKG(tissue_code){
ubkg_api_get_assay_type_set()
.then((res) => {
console.debug('%c⊙', 'color:#00ff7b', res);
return res;
})
.catch((error) => {
console.error('%c⭗', 'color:#ff005d', "ERROR: ubkg_api_get_organ_type_set",error);
});
// function get_sample_types_UBKG(tissue_code){
// ubkg_api_get_assay_type_set()
// .then((res) => {
// console.debug('%c⊙', 'color:#00ff7b', res);
// return res;
// })
// .catch((error) => {
// console.error('%c⭗', 'color:#ff005d', "ERROR: ubkg_api_get_organ_type_set",error);
// });

}
function get_sample_description_UBKG(tissue_code) {
var typeList = get_sample_types_UBKG();
console.debug('%c⊙', 'color:#00ff7b', "typeList",typeList );
console.debug("get_organ_description",typeList[tissue_code]);
return "TEST";
}
// }
// function get_sample_description_UBKG(tissue_code) {
// var typeList = get_sample_types_UBKG();
// console.debug('%c⊙', 'color:#00ff7b', "typeList",typeList );
// console.debug("get_organ_description",typeList[tissue_code]);
// return "TEST";
// }


export function generateDisplaySubtype( entity) {
Expand Down Expand Up @@ -194,10 +194,9 @@ export function generateDisplaySubtype( entity) {


export function generateDisplaySubtypeSimple_UBKG(datatype, datatypeList) {
// console.debug('%c⊙', 'color:#00ff7b', "generateDisplaySubtypeSimple_UBKG", datatype, datatypeList);
const assayDetail = datatypeList.find(({ term }) => term === datatype);
if (assayDetail !==undefined && assayDetail && assayDetail.term) {
return assayDetail.term
const assayDetail = datatypeList.find(({ dataset_type }) => dataset_type === datatype);
if (assayDetail !==undefined && assayDetail && assayDetail.dataset_type) {
return assayDetail.dataset_type
} else {
return "N/A"
}
Expand Down
Loading