Skip to content

Commit

Permalink
Merge pull request #489 from digitalgreenorg/fs_eth_test
Browse files Browse the repository at this point in the history
Fs eth test
  • Loading branch information
kanhaiyasuthar95 authored Feb 27, 2023
2 parents 3ef5292 + eee9a4e commit 962ecb3
Show file tree
Hide file tree
Showing 29 changed files with 1,612 additions and 1,008 deletions.
Original file line number Diff line number Diff line change
@@ -1,51 +1,82 @@
import { Avatar, Accordion, AccordionDetails, AccordionSummary, Divider, IconButton, ListItem, ListItemAvatar, ListItemText, Typography, Badge, LinearProgress } from '@mui/material'
import React from 'react'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined';
import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
import {
Avatar,
Accordion,
AccordionDetails,
AccordionSummary,
Divider,
IconButton,
ListItem,
ListItemAvatar,
ListItemText,
Typography,
} from "@mui/material";
import React from "react";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import DescriptionOutlinedIcon from "@mui/icons-material/DescriptionOutlined";
import DeleteOutlinedIcon from "@mui/icons-material/DeleteOutlined";

const AccordionForUploadedFileDetails = ({ data, title, deleteFunc, source, datasetname, loader }) => {
console.log(data)
return (
<Accordion defaultExpanded={true}>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
id="panel1a-header"
>
<Typography sx={{ width: '33%', flexShrink: 0 }}>
{title}
const AccordionForUploadedFileDetails = ({
data,
title,
deleteFunc,
source,
datasetname,
}) => {
console.log(data);
return (
<Accordion defaultExpanded={true}>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
id="panel1a-header"
>
<Typography sx={{ width: "33%", flexShrink: 0 }}>
{title}

<sup style={{ height: "20px", width: "20px", backgroundColor: "green", color: "white", borderRadius: "10px", padding: "0px 5px", fontSize: "small", margin: "0px 5px" }}>{data?.length} </sup>
</Typography>
<Typography sx={{ color: 'text.secondary' }}>
</Typography>
</AccordionSummary>
<AccordionDetails>
<Typography style={{ maxHeight: "300px", overflowY: "scroll" }}>
{/* <ul> */}
{data?.map((item) => {
console.log(data, item)
return <ListItem>
<ListItemAvatar>
<Avatar>
<DescriptionOutlinedIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary={item} secondary="Jan 9, 2014" />
<IconButton edge="end" aria-label="delete">
<DeleteOutlinedIcon
onClick={() => deleteFunc(datasetname, source, item)}
color='warning' />
</IconButton>
<Divider />
</ListItem>
})}
{/* </ul> */}
</Typography>
</AccordionDetails>
</Accordion>
)
}
<sup
style={{
height: "20px",
width: "20px",
backgroundColor: "green",
color: "white",
borderRadius: "10px",
padding: "0px 5px",
fontSize: "small",
margin: "0px 5px",
}}
>
{data?.length}{" "}
</sup>
</Typography>
<Typography sx={{ color: "text.secondary" }}></Typography>
</AccordionSummary>
<AccordionDetails>
<Typography style={{ maxHeight: "300px", overflowY: "scroll" }}>
{/* <ul> */}
{data?.map((item) => {
return (
<ListItem>
<ListItemAvatar>
<Avatar>
<DescriptionOutlinedIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary={item} secondary="Jan 9, 2014" />
<IconButton edge="end" aria-label="delete">
<DeleteOutlinedIcon
onClick={() => deleteFunc(datasetname, source, item)}
color="warning"
/>
</IconButton>
<Divider />
</ListItem>
);
})}
{/* </ul> */}
</Typography>
</AccordionDetails>
</Accordion>
);
};

export default AccordionForUploadedFileDetails
export default AccordionForUploadedFileDetails;
85 changes: 55 additions & 30 deletions src/Components/AdminDatasetConnection/AddDataset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,14 @@ const AddDataset = (props) => {
payload.append("file_name", filename)
payload.append("dataset_name", datasetname)
console.log("PAYLOAD CREATED", payload)

let checkforAccess = isaccesstoken ? isaccesstoken : false;
HTTPService(
"DELETE",
UrlConstant.base_url + UrlConstant.dataseteth,
payload,
true,
true
true,
checkforAccess
).then((response) => {
console.log("RESPONSE", response)
if (source == "file") {
Expand All @@ -164,27 +165,44 @@ const AddDataset = (props) => {
// setKey(Math.random())

}).catch((e) => {
console.log(e);
// var returnValues = GetErrorKey(e, payload.keys());
// var errorKeys = returnValues[0];
// var errorMessages = returnValues[1];
// if (errorKeys.length > 0) {
// for (var i = 0; i < errorKeys.length; i++) {
// switch (errorKeys[i]) {
// case "dataset_name":
// setDatasetNameError(errorMessages[i]);
// break;
// case "datasets":
// setDataSetFileError(errorMessages[i]);
// break;
// default:
// history.push(GetErrorHandlingRoute(e));
// break;
// }
// }
// } else {
// history.push(GetErrorHandlingRoute(e));
// }
var returnValues = GetErrorKey(e, payload.keys());
var errorKeys = returnValues[0];
var errorMessages = returnValues[1];
if (errorKeys.length > 0) {
for (var i = 0; i < errorKeys.length; i++) {
switch (errorKeys[i]) {
case "dataset_name":
// setDatasetNameError(errorMessages[i]);
setMessageForSnackBar("Dataset deletion failed")
setErrorOrSuccess("error")
handleClick()
break;
case "file_name":
// setDataSetFileError(errorMessages[i]);
setMessageForSnackBar("Dataset deletion failed")
setErrorOrSuccess("error")
handleClick()
break;
default:
if (e?.response?.status == 401) {
history.push(GetErrorHandlingRoute(e));
} else {
setMessageForSnackBar("Dataset deletion failed")
setErrorOrSuccess("error")
handleClick()
}
break;
}
}
} else {
if (e?.response?.status == 401) {
history.push(GetErrorHandlingRoute(e));
} else {
setMessageForSnackBar("Dataset deletion failed")
setErrorOrSuccess("error")
handleClick()
}
}
});
}

Expand Down Expand Up @@ -281,16 +299,23 @@ const AddDataset = (props) => {
// setfileValid(errorMessages[i]);
break;
default:
setMessageForSnackBar("Dataset uploaded failed")
setErrorOrSuccess("error")
handleClick()
break;
if (e?.response?.status == 401) {
history.push(GetErrorHandlingRoute(e));
} else {
setMessageForSnackBar("Dataset with this name already exist")
setErrorOrSuccess("error")
handleClick()
}
}
}
} else {
setMessageForSnackBar("Dataset uploaded failed")
setErrorOrSuccess("error")
handleClick()
if (e?.response?.status == 401) {
history.push(GetErrorHandlingRoute(e));
} else {
setMessageForSnackBar("Dataset with this name already exist")
setErrorOrSuccess("error")
handleClick()
}
}
//setfileValid(e.response.data.sample_dataset[0]);
// history.push(GetErrorHandlingRoute(e));
Expand Down
Loading

0 comments on commit 962ecb3

Please sign in to comment.