diff --git a/src/Components/Datasets/DataSetForm.css b/src/Components/Datasets/DataSetForm.css
index 025b6f8ca..7ecd8b3db 100644
--- a/src/Components/Datasets/DataSetForm.css
+++ b/src/Components/Datasets/DataSetForm.css
@@ -11,6 +11,7 @@
float: left;
/*margin-left: 20%;*/
margin-top: 3%;
+ margin-bottom: 3%;
}
.datasetform .name {
width: 100%;
@@ -144,6 +145,9 @@
.datasetform .notavaiable {
margin-left: 13%;
}
+.datasetform .private {
+ margin-left: 15%
+}
.datasetupload {
background: #ffffff;
border: 1px dashed #d8af28;
diff --git a/src/Components/Datasets/DataSetForm.js b/src/Components/Datasets/DataSetForm.js
index 5c1bb01c6..25a6fc8a9 100644
--- a/src/Components/Datasets/DataSetForm.js
+++ b/src/Components/Datasets/DataSetForm.js
@@ -22,7 +22,13 @@ import { width } from "@mui/system";
export default function DataSetForm(props) {
const [screenlabels, setscreenlabels] = useState(labels["en"]);
- const fileTypes = ["csv", "xls", "xlsx"];
+ const privateFileTypes = ["csv", "xls", "xlsx"];
+ const publicFileTypes = privateFileTypes.concat([
+ "jpg",
+ "jpeg",
+ "pdf",
+ "png",
+ ]);
return (
@@ -31,6 +37,29 @@ export default function DataSetForm(props) {
{props.title}
+
+
+
+ }
+ label={screenlabels.dataset.public}
+ />
+ }
+ label={screenlabels.dataset.private}
+ className="private"
+ />
+
+
+
-
- {/* */}
@@ -341,7 +353,8 @@ export default function DataSetForm(props) {
aria-labelledby="demo-row-radio-buttons-group-label"
name="row-radio-buttons-group"
value={props.value}
- onChange={props.handleChange}>
+ onChange={props.handleChange}
+ >
}
@@ -424,7 +437,8 @@ export default function DataSetForm(props) {
sm={12}
md={6}
lg={6}
- className="FromDate addDatasetFromdate">
+ className="FromDate addDatasetFromdate"
+ >
+ className="toDate addDatasetTodate"
+ >
+ onChange={props.handleChangeRecords}
+ >
} label="<100k" />
+ onChange={props.handleChangeAvailable}
+ >
}
@@ -550,10 +567,14 @@ export default function DataSetForm(props) {
}
@@ -571,8 +592,9 @@ export default function DataSetForm(props) {
: ""}
- {props.file != null && props.file.size > 2097152
- ? "File uploaded is more than 2MB!"
+ {props.file != null &&
+ props.file.size > (props.isPublic ? 52428800 : 2097152)
+ ? `File uploaded is more than ${props.isPublic ? 50 : 2} MB!`
: ""}
{props.fileValid}
diff --git a/src/Components/Datasets/viewDataSet.js b/src/Components/Datasets/viewDataSet.js
index 53df25186..cd24f2d26 100644
--- a/src/Components/Datasets/viewDataSet.js
+++ b/src/Components/Datasets/viewDataSet.js
@@ -15,6 +15,7 @@ import { Tooltip, Zoom } from "@mui/material";
import Alert from "@mui/material/Alert";
import AlertTitle from "@mui/material/AlertTitle";
import Stack from "@mui/material/Stack";
+import Button from "@mui/material/Button";
const useStyles = {
datasetdescription: {
@@ -89,7 +90,8 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "30px",
"text-align": "left",
- }}>
+ }}
+ >
{"Dataset name"}
@@ -106,18 +108,21 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "5px",
"text-align": "left",
- }}>
+ }}
+ >
+ }}
+ >
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{props.rowdata.name}
@@ -137,14 +142,17 @@ export default function ViewDataSet(props) {
height: "37px",
"line-height": "19px",
"word-break": "break-word",
- }}>
+ }}
+ >
+ title={props.rowdata.description}
+ >
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{" "}
{props.rowdata.description}
@@ -155,7 +163,8 @@ export default function ViewDataSet(props) {
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{categoryStr}
@@ -166,7 +175,8 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "40px",
"text-align": "left",
- }}>
+ }}
+ >
{"Geography"}
@@ -182,10 +192,12 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "5px",
"text-align": "left",
- }}>
+ }}
+ >
+ style={{ width: "30px", height: "37px", "line-height": "19px" }}
+ >
+ }}
+ >
{props.rowdata.geography}
@@ -210,15 +223,18 @@ export default function ViewDataSet(props) {
"line-height": "19px",
"word-break": "break-word",
// border:"1px solid red"
- }}>
+ }}
+ >
+ }
+ >
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{props.rowdata.crop_detail ? props.rowdata.crop_detail : "N/A"}
@@ -235,7 +251,8 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "40px",
"text-align": "left",
- }}>
+ }}
+ >
{"Age of actual data"}
@@ -251,7 +268,8 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "5px",
"text-align": "left",
- }}>
+ }}
+ >
{props.rowdata.age_of_date ? props.rowdata.age_of_date : "N/A"}
@@ -290,17 +308,25 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "40px",
"text-align": "left",
- }}>
+ }}
+ >
{"Connector availablity"}
+
+ {"Data visibility"}
+
+
+
+
+ }}
+ >
{props.rowdata.connector_availability
@@ -308,6 +334,14 @@ export default function ViewDataSet(props) {
: "N/A"}
+
+
+ {props.rowdata["is_public"] ? "Public" : "Private"}
+
+
+
+
+
{!props.isAdminView ? (
@@ -320,7 +354,8 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "30px",
"text-align": "left",
- }}>
+ }}
+ >
{"Contact person's name"}
@@ -338,7 +373,8 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "5px",
"text-align": "left",
- }}>
+ }}
+ >
+ }
+ >
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{props.rowdata.user.first_name} {props.rowdata.user.last_name}
@@ -370,7 +408,8 @@ export default function ViewDataSet(props) {
) : (
+ aria-label="recipe"
+ >
{props.rowdata.organization.name.charAt(0)}
)}
@@ -379,10 +418,12 @@ export default function ViewDataSet(props) {
+ title={props.rowdata.organization.name}
+ >
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{props.rowdata.organization.name}
@@ -397,10 +438,12 @@ export default function ViewDataSet(props) {
props.rowdata.organization.org_email
? props.rowdata.organization.org_email
: "N/A"
- }>
+ }
+ >
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{props.rowdata.organization.org_email
? props.rowdata.organization.org_email
: "N/A"}
@@ -413,7 +456,8 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "30px",
"text-align": "left",
- }}>
+ }}
+ >
{"Contact number"}
@@ -429,7 +473,8 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "5px",
"text-align": "left",
- }}>
+ }}
+ >
+ }
+ >
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{props.rowdata.organization["name"]
? props.rowdata.organization["name"]
: "N/A"}
@@ -455,10 +502,12 @@ export default function ViewDataSet(props) {
props.rowdata.organization["address"]["address"]
? props.rowdata.organization["address"]["address"]
: "N/A"
- }>
+ }
+ >
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{props.rowdata.organization["address"]["address"]
? props.rowdata.organization["address"]["address"]
: "N/A"}
@@ -475,7 +524,8 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "30px",
"text-align": "left",
- }}>
+ }}
+ >
{"Country"}
@@ -491,7 +541,8 @@ export default function ViewDataSet(props) {
"margin-left": "79px",
"margin-top": "5px",
"text-align": "left",
- }}>
+ }}
+ >
+ }
+ >
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{props.rowdata.organization["address"]["country"]
? props.rowdata.organization["address"]["country"]
: "N/A"}
@@ -517,10 +570,12 @@ export default function ViewDataSet(props) {
props.rowdata.organization["address"]["pincode"]
? props.rowdata.organization["address"]["pincode"]
: "N/A"
- }>
+ }
+ >
+ className="thirdmainheading memberDataSetCardTooltipAndWidthAndOverflow d-inline-block text-truncate"
+ >
{props.rowdata.organization["address"]["pincode"]
? props.rowdata.organization["address"]["pincode"]
: "N/A"}
@@ -537,76 +592,100 @@ export default function ViewDataSet(props) {
) : (
<>>
)}
-
- {"Sample data table"}
+ {props.rowdata.is_public ? (
+
+
+
+ {
+ props.downloadAttachment(props.rowdata.sample_dataset);
+ }}
+ variant="contained"
+ className="submitbtn"
+ >
+ Download Dataset
+
+
+
+ ) : (
+ <>
+
+ {"Sample data table"}
-
- props.downloadAttachment(props.rowdata.sample_dataset)
- }>
-
-
-
- props.downloadAttachment(props.rowdata.sample_dataset)
- }>
- {"Download sample data"}
-
-
-
-
-
- {/* Warning */}
- {/* This is a warning alert —{" "} */}
-
- This table's sample dataset is solely meant to be used as a source
- of information. Despite the fact that accuracy is a goal, the
- steward is not accountable for the information. Please let the
- admin know if you come across any information that you think is
- inaccurate.
-
-
-
-
-
-
-
-
-
- {props.tabelkeys.map((key) => (
- {key}
- ))}
-
-
-
- {props.rowdata.content.map((row) => (
-
- {props.tabelkeys.map((key) => (
- {row[key]}
+
+ props.downloadAttachment(props.rowdata.sample_dataset)
+ }
+ >
+
+
+
+ props.downloadAttachment(props.rowdata.sample_dataset)
+ }
+ >
+ {"Download sample data"}
+
+
+
+
+
+ {/* Warning */}
+ {/* This is a warning alert —{" "} */}
+
+ This table's sample dataset is solely meant to be used as a
+ source of information. Despite the fact that accuracy is a
+ goal, the steward is not accountable for the information.
+ Please let the admin know if you come across any information
+ that you think is inaccurate.
+
+
+
+
+
+
+
+
+
+ {props.tabelkeys.map((key) => (
+ {key}
+ ))}
+
+
+
+ {props.rowdata.content.map((row) => (
+
+ {props.tabelkeys.map((key) => (
+ {row[key]}
+ ))}
+
))}
-
- ))}
-
-
-
-
+
+
+
+
+ >
+ )}
>
);
}
diff --git a/src/Constants/labels.js b/src/Constants/labels.js
index 0c4266dd0..11ba7db26 100755
--- a/src/Constants/labels.js
+++ b/src/Constants/labels.js
@@ -154,7 +154,9 @@ const labels = {
Diary: "Diary",
Poultry: "Poultry",
Other: "Other",
-
+ data_access:"Data access type",
+ private:"Private",
+ public:"Public",
Soil_data: "Soil data",
Weather_data: "Weather data",
Research_data: "Research data",
@@ -174,7 +176,7 @@ const labels = {
Available: "Available",
Not_Available: "Not available",
Upload_dataset: " Upload sample datasets *",
-
+ visiblity: "Data Visibility",
filter: "Filter",
geography: "Geography",
age: "Age",
@@ -196,6 +198,12 @@ const labels = {
"Add details about your dataset and make it discoverable to other users of our network.",
no_dataset_text1: "Currently, there are no datasets available.",
no_dataset_text2: "Add your dataset.",
+ private_data_warning: "This table's sample dataset is solely meant to be used as a source of information."+
+ "Despite the fact that accuracy is a goal,the steward is not accountable for the information. Please let" +
+ "the admin know if you come across any information that you think is inaccurate." ,
+ public_data_warning: "This table's dataset is solely meant to be used as a source of information."+
+ "Despite the fact that accuracy is a goal,the steward is not accountable for the information. Please let" +
+ "the admin know if you come across any information that you think is inaccurate."
},
dashboard: {
organisation_details: "Organisation details",
diff --git a/src/Views/Dataset/DatasetAdmin/AddDataset.js b/src/Views/Dataset/DatasetAdmin/AddDataset.js
index 228d89656..ec5da4f08 100644
--- a/src/Views/Dataset/DatasetAdmin/AddDataset.js
+++ b/src/Views/Dataset/DatasetAdmin/AddDataset.js
@@ -10,6 +10,7 @@ import {
validateInputField,
handleUnwantedSpace,
HandleSessionTimeout,
+ fileUpload,
getUserMapId,
GetErrorKey,
} from "../../../Utils/Common";
@@ -59,6 +60,7 @@ export default function AddDataset(props) {
const [value, setValue] = React.useState("");
const [recordsvalue, setrecordsvalue] = React.useState("");
const [availablevalue, setavailablevalue] = React.useState("");
+ const [isPublic, setIsPublic] = useState("");
// const [value, setValue] = React.useState("3 months");
// const [recordsvalue, setrecordsvalue] = React.useState("100k");
@@ -143,15 +145,12 @@ export default function AddDataset(props) {
if (todate != null && Switchchecked == false) {
bodyFormData.append("data_capture_end", todate.toISOString());
}
- if (file != null) {
- bodyFormData.append("sample_dataset", file);
- }
+ fileUpload(bodyFormData, file, "sample_dataset");
bodyFormData.append("connector_availability", availablevalue);
+ bodyFormData.append("is_public", isPublic);
bodyFormData.append("dataset_size", recordsvalue);
bodyFormData.append("user_map", id);
bodyFormData.append("approval_status", "approved");
-
- console.log("add dataset", bodyFormData);
setIsLoader(true);
HTTPService(
"POST",
@@ -224,6 +223,13 @@ export default function AddDataset(props) {
console.log(event.target.value);
setrecordsvalue(event.target.value);
};
+ const handleChangeIsPublic = (event) => {
+ console.log(event.target.value);
+ setIsPublic(event.target.value === "true" ? true : false);
+ // Set file to null whenever a public status is changed because the user could set
+ // a different filetype than allowed for that specific visibility setting
+ setFile(null);
+ };
const handleChangeAvailable = (event) => {
console.log(event.target.value);
setavailablevalue(event.target.value);
@@ -373,7 +379,8 @@ export default function AddDataset(props) {
btntext={"ok"}
heading={"You added a new dataset"}
imageText={"Added Successfully!"}
- msg={"Your dataset added in database."}>
+ msg={"Your dataset added in database."}
+ >
) : (
+ type="submit"
+ >
{screenlabels.common.submit}
) : (
+ className="disbalesubmitbtn"
+ >
{screenlabels.common.submit}
)}
@@ -483,7 +494,8 @@ export default function AddDataset(props) {
history.push("/datahub/datasets")}
variant="outlined"
- className="cancelbtn">
+ className="cancelbtn"
+ >
{screenlabels.common.cancel}
diff --git a/src/Views/Dataset/DatasetAdmin/DatasetAdmin.js b/src/Views/Dataset/DatasetAdmin/DatasetAdmin.js
index 62f872bc0..ab8185699 100644
--- a/src/Views/Dataset/DatasetAdmin/DatasetAdmin.js
+++ b/src/Views/Dataset/DatasetAdmin/DatasetAdmin.js
@@ -1245,12 +1245,15 @@ export default function DatasetAdmin() {
console.log("filter response:", response);
let tempObject = { ...response.data };
setviewdata(tempObject);
- var tabelHeading = Object.keys(response.data.content[0]);
- var temptabelKeys = [...tabelHeading];
- settablekeys(temptabelKeys);
+ if (response.data.content) {
+ var tabelHeading = Object.keys(response.data.content[0]);
+ var temptabelKeys = [...tabelHeading];
+ settablekeys(temptabelKeys);
+ }
changeView("isDataSetView");
})
.catch((e) => {
+ console.error(e);
setIsLoader(false);
history.push(GetErrorHandlingRoute(e));
});
diff --git a/src/Views/Dataset/DatasetAdmin/EditDataset.js b/src/Views/Dataset/DatasetAdmin/EditDataset.js
index 6a7dedbc6..b19e7f7fa 100644
--- a/src/Views/Dataset/DatasetAdmin/EditDataset.js
+++ b/src/Views/Dataset/DatasetAdmin/EditDataset.js
@@ -48,6 +48,7 @@ export default function EditDataset() {
const [value, setValue] = React.useState("");
const [recordsvalue, setrecordsvalue] = React.useState("");
const [availablevalue, setavailablevalue] = React.useState("");
+ const [isPublic, setIsPublic] = React.useState("");
// date picker
const [fromdate, setfromdate] = React.useState(null);
@@ -63,14 +64,16 @@ export default function EditDataset() {
// success screen
const [isSuccess, setisSuccess] = useState(false);
- const [nameErrorMessage, setnameErrorMessage] = useState(null)
- const [descriptionErrorMessage, setDescriptionErrorMessage] = useState(null)
- const [categoryErrorMessage, setCategoryErrorMessage] = useState(null)
- const [geographyErrorMessage, setGeographyErrorMessage] = useState(null)
- const [cropDetailErrorMessage, setCropDetailErrorMessage] = useState(null)
- const [ageErrorMessage, setAgeErrorMessage] = useState(null)
- const [dataCaptureStartErrorMessage, setDataCaptureStartErrorMessage]= useState(null)
- const [dataCaptureEndErrorMessage,setDataCaptureEndErrorMessage]= useState(null)
+ const [nameErrorMessage, setnameErrorMessage] = useState(null);
+ const [descriptionErrorMessage, setDescriptionErrorMessage] = useState(null);
+ const [categoryErrorMessage, setCategoryErrorMessage] = useState(null);
+ const [geographyErrorMessage, setGeographyErrorMessage] = useState(null);
+ const [cropDetailErrorMessage, setCropDetailErrorMessage] = useState(null);
+ const [ageErrorMessage, setAgeErrorMessage] = useState(null);
+ const [dataCaptureStartErrorMessage, setDataCaptureStartErrorMessage] =
+ useState(null);
+ const [dataCaptureEndErrorMessage, setDataCaptureEndErrorMessage] =
+ useState(null);
// retrive id for dataset
const { id } = useParams();
@@ -82,15 +85,15 @@ export default function EditDataset() {
var userid = getUserMapId();
console.log("user id", userid);
- setnameErrorMessage(null);
+ setnameErrorMessage(null);
setDescriptionErrorMessage(null);
setCategoryErrorMessage(null);
- setGeographyErrorMessage(null);
+ setGeographyErrorMessage(null);
setCropDetailErrorMessage(null);
setAgeErrorMessage(null);
- setDataCaptureStartErrorMessage(null);
- setDataCaptureEndErrorMessage(null);
- setfileValid(null);
+ setDataCaptureStartErrorMessage(null);
+ setDataCaptureEndErrorMessage(null);
+ setfileValid(null);
const datefrom = new Date(fromdate);
console.log(datefrom);
@@ -152,6 +155,7 @@ export default function EditDataset() {
} else {
bodyFormData.append("connector_availability", "");
}
+ bodyFormData.append("is_public", isPublic);
if (recordsvalue != null) {
bodyFormData.append("dataset_size", recordsvalue);
} else {
@@ -178,27 +182,46 @@ export default function EditDataset() {
.catch((e) => {
setIsLoader(false);
//console.log(e.response.data.sample_dataset[0]);
- var returnValues = GetErrorKey(e, bodyFormData.keys())
- var errorKeys = returnValues[0]
- var errorMessages = returnValues[1]
- if (errorKeys.length > 0){
- for (var i=0; i 0) {
+ for (var i = 0; i < errorKeys.length; i++) {
+ switch (errorKeys[i]) {
+ case "name":
+ setnameErrorMessage(errorMessages[i]);
+ break;
+ case "description":
+ setDescriptionErrorMessage(errorMessages[i]);
+ break;
+ case "category":
+ setCategoryErrorMessage(errorMessages[i]);
+ break;
+ case "geography":
+ setGeographyErrorMessage(errorMessages[i]);
+ break;
+ case "crop_detail":
+ setCropDetailErrorMessage(errorMessages[i]);
+ break;
+ case "age_of_date":
+ setAgeErrorMessage(errorMessages[i]);
+ break;
+ case "data_capture_start":
+ setDataCaptureStartErrorMessage(errorMessages[i]);
+ break;
+ case "data_capture_end":
+ setDataCaptureEndErrorMessage(errorMessages[i]);
+ break;
+ case "sample_dataset":
+ setfileValid(errorMessages[i]);
+ break;
+ default:
+ history.push(GetErrorHandlingRoute(e));
+ break;
}
}
- }
- else{
- history.push(GetErrorHandlingRoute(e))
+ } else {
+ history.push(GetErrorHandlingRoute(e));
}
//setfileValid(e.response.data.sample_dataset[0]);
@@ -241,6 +264,7 @@ export default function EditDataset() {
setValue(response.data.age_of_date);
settodate(response.data.data_capture_end);
setfromdate(response.data.data_capture_start);
+ setIsPublic(response.data.is_public);
// console.log("picture", response.data.profile_picture);
// setphonenumber(response.data.phone_number);
@@ -284,17 +308,23 @@ export default function EditDataset() {
console.log(event.target.value);
setavailablevalue(event.target.value);
};
+ const handleChangeIsPublic = (event) => {
+ console.log(event.target.value);
+ setIsPublic(event.target.value === "true" ? true : false);
+ // Reset sample file to upload
+ setFile(null);
+ };
const handleFileChange = (file) => {
setFile(file);
setfileValid("");
// setprofile_pic(file);
console.log(file);
console.log(typeof file);
- if (file != null && file.size > 2097152) {
- setfilesize(true);
- } else {
- setfilesize(false);
- }
+ // if (file != null && file.size > 2097152) {
+ // setfilesize(true);
+ // } else {
+ // setfilesize(false);
+ // }
};
const handleChangedatasetname = (e) => {
validateInputField(e.target.value, RegexConstants.connector_name)
@@ -303,7 +333,7 @@ export default function EditDataset() {
};
const handledatasetnameKeydown = (e) => {
handleUnwantedSpace(datasetname, e);
- }
+ };
const handleChangedescription = (e) => {
console.log(e.target.value);
validateInputField(e.target.value, RegexConstants.connector_name)
@@ -322,7 +352,7 @@ export default function EditDataset() {
const handleGeographyKeydown = (e) => {
handleUnwantedSpace(Geography, e);
- }
+ };
const handleChangecropdetail = (e) => {
console.log(e.target.value);
@@ -332,7 +362,7 @@ export default function EditDataset() {
};
const handleCropKeydown = (e) => {
handleUnwantedSpace(cropdetail, e);
- }
+ };
const handleChangeFromDate = (newValue) => {
console.log(newValue);
settodate(null);
@@ -413,7 +443,8 @@ export default function EditDataset() {
btntext={"ok"}
heading={"Dataset updated Successfully"}
imageText={"Success!"}
- msg={"Your dataset are updated."}>
+ msg={"Your dataset are updated."}
+ >
) : (