Skip to content

Commit 43d97c3

Browse files
authored
Merge pull request #1504 from hubmapconsortium/bulkUp
capture of network failures
2 parents 909cf8f + 38708d7 commit 43d97c3

File tree

6 files changed

+117
-59
lines changed

6 files changed

+117
-59
lines changed

src/src/App.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,4 +921,7 @@ svg.invalid {
921921
font-weight: 300;
922922
gap: 4px;
923923
line-height: 1.5;
924+
}
925+
.fullDialog .MuiPaper-root{
926+
max-width:1200px!important;
924927
}

src/src/App.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -230,30 +230,6 @@ export function App (props){
230230
}
231231
}, [ ]);
232232

233-
234-
// useEffect(() => {
235-
// console.debug("useEffect ubkg")
236-
// ubkg_api_get_dataset_type_set()
237-
// .then((response) => {
238-
// console.debug('%c⊙', 'color:#00ff7b', "DATSETTYPES", response );
239-
// let dtypes = response;
240-
// setDataTypeList(dtypes);
241-
// setDataTypeListAll(dtypes);
242-
// ubkg_api_get_organ_type_set()
243-
// .then((res) => {
244-
// setOrganList(res);
245-
// setDTLoading(false)
246-
// })
247-
// .catch((err) => {
248-
// reportError(err)
249-
// })
250-
// })
251-
// .catch(error => {
252-
// console.debug('%c⭗', 'color:#ff005d', "APP ubkg_api_get_assay_type_set ERROR", error);
253-
// reportError(error)
254-
// });
255-
// }, [ ]);
256-
257233
useEffect(() => {
258234
if(localStorage.getItem("info")){
259235
try {

src/src/Nav.js

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ import Dialog from '@mui/material/Dialog';
1818
import DialogContent from '@mui/material/DialogContent';
1919
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
2020
import LoadingButton from '@mui/lab/LoadingButton';
21-
21+
import MUIDialog from "./components/ui/dialog";
2222
import UploadsForm from "./components/uploads/createUploads";
2323

2424
export const Navigation = (props) => {
2525
const [userInfo, setUserInfo] = React.useState();
26+
const [metaModalOpen, setMetaModalOpen] = React.useState(false);
27+
const [exampleLink, setExampleLink] = React.useState("block");
2628
// const [userGroups, setUserGroups] = React.useState();
2729
const [userDataGroups, setUserDataGroups] = React.useState([]);
2830
const [uploadsDialog, setUploadsDialog] = React.useState(false);
@@ -32,6 +34,9 @@ export const Navigation = (props) => {
3234
const open_I = Boolean(anchorEl_I);
3335
const open_B = Boolean(anchorEl_B);
3436
const open_S = Boolean(anchorEl_S);
37+
var dialogMetadataTitle = 'Metadata Bulk Uploading Temporarily Unavailable';
38+
var dialogMetadataMessage = "<strong>Please prepare any new data submissions using the new next-generation metadata and directory schemas</strong>, which are linked from <a href=\""+exampleLink+"\" target=\"_blank\">this page</a>. The schemas you should use are marked <strong>\"use this one\"</strong> on the schema pages. You can validate <strong>next-gen metadata schemas</strong> using the <a href=\"https://docs.google.com/document/d/1lfgiDGbyO4K4Hz1FMsJjmJd9RdwjShtJqFYNwKpbcZY/edit#heading=h.d6xf2xeysl78\" target=\"_blank\">process outlined here</a>. <strong>Please also <a href=\"https://docs.google.com/spreadsheets/d/19ZJx_EVyBGKNeW0xxQlOsMdt1DVNZYWmuG014rXsQP4/edit#gid=0\" target=\"_blank\">update this data pulse check spreadsheet</a></strong> so we know what data is coming from your team. We\'re looking forward to your submissions!<br/> \
39+
Please contact <a href=\"mailto:[email protected]\">[email protected]</a> if you have questions.";
3540
const location = useLocation();
3641
let navigate = useNavigate();
3742
useEffect(() => {
@@ -45,6 +50,16 @@ export const Navigation = (props) => {
4550
}
4651
}, [props, props.app_info, location]);
4752

53+
const handleCancel = () => {
54+
setMetaModalOpen(false);
55+
}
56+
const handleOpenModal = (type) => {
57+
let sampleType = type.toString();
58+
console.debug('%c◉ type ', 'color:#00ff7b', type, sampleType, typeof sampleType);
59+
setExampleLink("https://hubmapconsortium.github.io/ingest-validation-tools/sample-"+sampleType.toLowerCase()+"/current/")
60+
console.debug('%c◉ link ', 'color:#00ff7b', exampleLink);
61+
setMetaModalOpen(true);
62+
}
4863

4964
// @TODO: Dry this up
5065
const handleClick_S = (event) => {
@@ -79,6 +94,13 @@ export const Navigation = (props) => {
7994

8095
return (
8196
<AppBar position="static" id="header">
97+
<MUIDialog
98+
open={metaModalOpen}
99+
handleClose={handleCancel}
100+
title={dialogMetadataTitle}
101+
message={dialogMetadataMessage}
102+
// dialogHelpLink={dialogHelpLinkURL}
103+
bgcol = "Red" />
82104
<Dialog open={uploadsDialog}>
83105
<DialogContent>
84106
<UploadsForm
@@ -227,23 +249,23 @@ export const Navigation = (props) => {
227249
<MenuItem
228250
className="nav-link"
229251
sx={{ width: "200px" }}
230-
component={Link}
231-
onClick={handleClose}
232-
to="/metadata/block" >
252+
// component={Link}
253+
to="/metadata/block"
254+
onClick={() => handleOpenModal("Block")}>
233255
Block
234256
</MenuItem>
235257
<MenuItem
236258
className="nav-link"
237259
component={Link}
238-
onClick={handleClose}
239-
to="/metadata/section" >
260+
to="/metadata/section"
261+
onClick={() => handleOpenModal("Section")}>
240262
Section
241263
</MenuItem>
242264
<MenuItem
243265
className="nav-link"
244266
component={Link}
245-
onClick={handleClose}
246-
to="/metadata/suspension" >
267+
to="/metadata/suspension"
268+
onClick={() => handleOpenModal("Suspension")}>
247269
Suspension
248270
</MenuItem>
249271
</Menu>
@@ -396,22 +418,22 @@ export const Navigation = (props) => {
396418
className="nav-link"
397419
sx={{ width: "200px" }}
398420
component={Link}
399-
onClick={handleClose}
400-
to="/metadata/block" >
421+
// to="/metadata/block"
422+
onClick={() => handleOpenModal("Block")}>
401423
Block
402424
</MenuItem>
403425
<MenuItem
404426
className="nav-link"
405427
component={Link}
406-
onClick={handleClose}
407-
to="/metadata/section" >
428+
// to="/metadata/section"
429+
onClick={() => handleOpenModal("Section")}>
408430
Section
409431
</MenuItem>
410432
<MenuItem
411433
className="nav-link"
412434
component={Link}
413-
onClick={handleClose}
414-
to="/metadata/suspension" >
435+
// to="/metadata/suspension"
436+
onClick={() => handleOpenModal("Suspension")} >
415437
Suspension
416438
</MenuItem>
417439
</Menu>

src/src/assets/App.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,4 +855,8 @@ svg.invalid{
855855
font-weight: 300;
856856
gap: 4px;
857857
line-height: 1.5;
858+
}
859+
860+
.fullDialog .MuiPaper-root{
861+
max-width:1200px!important;
858862
}

src/src/components/metadata.jsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const RenderMetadata = (props) => {
5757
whiteSpace: 'nowrap',
5858
width: 1,
5959
});
60-
60+
6161

6262
var [errorHandler, setErrorHandler] = useState({
6363
status: '',
@@ -124,36 +124,28 @@ export const RenderMetadata = (props) => {
124124
message: resp.results.message||resp
125125
})
126126
} else {
127-
console.debug('%c◉ Attach fail ', 'color:#ffe921',resp.error.response.data,resp.error.response.data.error );
127+
// console.debug('%c◉ Attach fail ', 'color:#ffe921',resp.error );
128+
let err = resp.error?.response?.data?.error ?? resp.error?.response ?? resp.error ?? resp;
128129
setAttachmentFails(attachmentFails => [...attachmentFails, {
129130
status:"failed",
130131
row: thisRow.metadata['file_row'],
131-
error: resp.error.response.data.error||resp
132+
error: err
132133
}])
133134
fails.push({
134135
status:"failed",
135136
row: thisRow.metadata['file_row'],
136-
error: resp.error.response.data.error||resp
137+
error: err
137138
})
138139
}
139140
})
140141
.catch((error)=>{
141-
console.debug('%c◉ entity_api_attach_bulk_metadata Call ERrr ', 'color:#ff005d', error);
142-
// console.debug('%c⭗', 'color:#', 'Error', error);
142+
setAttachmentFails(attachmentFails => [...attachmentFails, {
143+
status:"failed",
144+
row: thisRow.metadata['file_row'],
145+
error: error.toString()
146+
}])
143147
})
144148

145-
// var errorTable = getErrorList(resp.error.response.data)
146-
// attachErrorTable.push(errorTable)
147-
148-
149-
// console.debug('%c◉ errorTable ', 'color:#ffe921', fails);
150-
// setTable(fails)
151-
// // setTable(table => [...table, errorTable])
152-
// setIssues(resp.error.response.data);
153-
// setFailed(1);
154-
// setFailedStep(3);
155-
// setAttaching(false);
156-
157149
row++
158150
if(row === validatedMeta[0].length){
159151
setTimeout(() => {
@@ -219,7 +211,11 @@ function getColNames() {
219211
}
220212

221213
var errorTable = getErrorList(cleanErr)
222-
setIssues(resp.error.response.data);
214+
if(resp.error && resp.error.response){
215+
setIssues(resp.error.response.data);
216+
}else{
217+
setIssues(resp);
218+
}
223219
setFailed(1);
224220
setFailedStep(2);
225221
setActiveStep(4);
@@ -229,7 +225,9 @@ function getColNames() {
229225
}
230226
})
231227
.catch((error) => {
232-
console.debug('%c⭗', 'color:#ff005d', 'Error', error,error.description);
228+
console.debug('%c⭗ Error Handle Upload File', 'color:#ff005d', error,error.description);
229+
let errorTable = getErrorList(error)
230+
setIssues(error);
233231
setProcessed(true);
234232
});
235233
};
@@ -503,7 +501,7 @@ const introText = () =>{
503501
if(row.status && row.status === "failed"){
504502
// if(typeof row.error === 'string' && row.error.indexOf("error: ") === 0){
505503
// we're likely a API error not a CEDAR error
506-
return <span>{row.error}</span>
504+
return <span>{row.error.toString()}</span>
507505
}
508506
// let err = handleErrorRow(row)
509507

@@ -560,6 +558,8 @@ const exampleFile ="https://hubmapconsortium.github.io/ingest-validation-tools/s
560558

561559
return (
562560
<div className="row">
561+
562+
563563
<h4>{toTitleCase(props.type)} Metadata Upload</h4>
564564
<div className=' col-sm-2' id='stepContainer'>
565565
<Stepper activeStep={activeStep} orientation="vertical">

src/src/components/ui/dialog.jsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
import * as React from 'react';
3+
import Button from '@mui/material/Button';
4+
import { styled } from '@mui/material/styles';
5+
import Dialog from '@mui/material/Dialog';
6+
import DialogTitle from '@mui/material/DialogTitle';
7+
import DialogContent from '@mui/material/DialogContent';
8+
import DialogActions from '@mui/material/DialogActions';
9+
import IconButton from '@mui/material/IconButton';
10+
import CloseIcon from '@mui/icons-material/Close';
11+
import Typography from '@mui/material/Typography';
12+
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
13+
import {faExclamationTriangle} from "@fortawesome/free-solid-svg-icons";
14+
15+
export default function MUIDialog(props) {
16+
17+
return (
18+
<React.Fragment>
19+
20+
<Dialog
21+
// onClose={props.handleClose}
22+
aria-labelledby="customized-dialog-title"
23+
open={props.open}
24+
className="fullDialog"
25+
>
26+
<DialogTitle sx={{ m: 0, p: 2 }} style={{background:"red", color:"white"}} id="customized-dialog-title">
27+
<FontAwesomeIcon icon={faExclamationTriangle} style={{ fontSize:"2.5rem", marginRight:"20px"}} sx={{padding:1}}/> {props.title} </DialogTitle>
28+
<IconButton
29+
aria-label="close"
30+
onClick={props.handleClose}
31+
style={{
32+
position: 'absolute',
33+
right: 10,
34+
top: 10,
35+
color: "white",
36+
}}
37+
>
38+
<CloseIcon />
39+
</IconButton>
40+
<DialogContent dividers>
41+
<Typography dangerouslySetInnerHTML={{ __html:props.message }}>
42+
43+
</Typography>
44+
</DialogContent>
45+
<DialogActions>
46+
<Button style={{position:"relative",margin:"0 auto 0 auto"}} autoFocus onClick={props.handleClose}>
47+
OK
48+
</Button>
49+
</DialogActions>
50+
</Dialog>
51+
</React.Fragment>
52+
);
53+
}

0 commit comments

Comments
 (0)