diff --git a/package.json b/package.json index 4fbb31cbd..1aeb70a4c 100755 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ }, "scripts": { "start": "env-cmd -f .env.production react-scripts start", - "build": "env-cmd -f .env.production react-scripts --max_old_space_size=3072 build", + "build": "env-cmd -f .env.production react-scripts --max_old_space_size=6168 build", "test": "react-scripts test", "eject": "react-scripts eject" }, @@ -89,4 +89,4 @@ "last 1 safari version" ] } -} +} \ No newline at end of file diff --git a/src/Assets/CSS/common.css b/src/Assets/CSS/common.css index 04d1a64bc..396072bae 100644 --- a/src/Assets/CSS/common.css +++ b/src/Assets/CSS/common.css @@ -995,6 +995,10 @@ button.disbalesubmitbtndept { color: #000000 !important; } +.dataset_selector_in_integration .row { + margin-top: 0px !important; +} + .dataset_selector_in_integration .MuiCollapse-entered { background: #FFFFFF !important; box-shadow: 0px 20px 40px -4px rgb(145 158 171 / 16%) !important; @@ -1002,8 +1006,9 @@ button.disbalesubmitbtndept { } .accordion_for_columns_under_integration .accordion_detail .MuiSvgIcon-root, -.accordion_for_columns_under_integration .select_all_btn .MuiSvgIcon-root { - color: #637381 !important; +.accordion_for_columns_under_integration .select_all_btn .MuiSvgIcon-root, +.dataset_selector_in_integration .MuiSvgIcon-root { + color: #c09507 !important; } .dataset_selector_in_integration .MuiDataGrid-columnHeaders { @@ -1034,4 +1039,89 @@ button.disbalesubmitbtndept { .back_btn_guest .MuiSvgIcon-root { color: #3491EE !important; +} + +.dataset_selector_in_integration .MuiFormControlLabel-label { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.dataset_selector_in_integration .deleteicon { + cursor: pointer; +} + +.dataset_selector_in_integration .deleteicon:hover { + color: red !important; +} + +.deleteicon:hover .mainBoxInIntegration { + border: 1px solid red !important; +} + +.dataset_integration_selectors .row { + background-color: #ab8405 !important; +} + +html { + scroll-behavior: smooth; +} + +.MuiInputLabel-asterisk { + color: red !important; +} + +.all_selectors_as_sticky { + transition: all 0.2s; +} + +.ant-affix .all_selectors_as_sticky { + box-shadow: 0px 2px 5px rgb(0 0 0 / 50%) !important; + /* width: 100vw !important; */ + margin: 0px !important; + padding: 5px 0px !important; + border-bottom-left-radius: 10px !important; + border-bottom-right-radius: 10px !important; + + +} + +.dataset_selector_in_integration .MuiDataGrid-row:nth-child(even) { + background-color: #F9EABC !important; + /* color: white; */ + margin: 5px 0px; +} + +.dataset_selector_in_integration .MuiDataGrid-row:nth-child(odd) { + background-color: #f7f4ebd3 !important; + /* color: white; */ + padding: 5px 0px; +} + +.connectorCard { + padding: 20px 40px 20px 5px; + font-family: "Open Sans"; + font-style: normal; + font-weight: 400; + font-size: 14px; + color: #3d4a52; + line-height: 19px; + border-radius: 10px; + width: 368px; + height: 178px; + margin: 30px 15px 15px 15px; + border: 1px solid #C0C7D1; +} + +.connectorCard:hover { + border: 1px solid #c09507; + cursor: pointer; +} + +.dataset_selector_in_integration .backButtonMainDiv .MuiSvgIcon-root { + color: #3491ee !important; +} + +.dataset_selector_in_integration .Mui-focused { + /* border: 1px solid #ab8405 !important; */ } \ No newline at end of file diff --git a/src/Assets/Img/Join type/Check circle.svg b/src/Assets/Img/Join type/Check circle.svg new file mode 100644 index 000000000..0c2125b0a --- /dev/null +++ b/src/Assets/Img/Join type/Check circle.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/Assets/Img/Join type/Color/Left.svg b/src/Assets/Img/Join type/Color/Left.svg new file mode 100644 index 000000000..e87f8a47c --- /dev/null +++ b/src/Assets/Img/Join type/Color/Left.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Assets/Img/Join type/Color/Tick icon.svg b/src/Assets/Img/Join type/Color/Tick icon.svg new file mode 100644 index 000000000..456964971 --- /dev/null +++ b/src/Assets/Img/Join type/Color/Tick icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/Assets/Img/Join type/Color/inner.svg b/src/Assets/Img/Join type/Color/inner.svg new file mode 100644 index 000000000..c474fd0c0 --- /dev/null +++ b/src/Assets/Img/Join type/Color/inner.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Assets/Img/Join type/Color/outer.svg b/src/Assets/Img/Join type/Color/outer.svg new file mode 100644 index 000000000..f847f1309 --- /dev/null +++ b/src/Assets/Img/Join type/Color/outer.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Assets/Img/Join type/Color/right.svg b/src/Assets/Img/Join type/Color/right.svg new file mode 100644 index 000000000..9cfc9979b --- /dev/null +++ b/src/Assets/Img/Join type/Color/right.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Assets/Img/Join type/Normal state/inner.svg b/src/Assets/Img/Join type/Normal state/inner.svg new file mode 100644 index 000000000..91df43be5 --- /dev/null +++ b/src/Assets/Img/Join type/Normal state/inner.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Assets/Img/Join type/Normal state/left.svg b/src/Assets/Img/Join type/Normal state/left.svg new file mode 100644 index 000000000..9c83afad7 --- /dev/null +++ b/src/Assets/Img/Join type/Normal state/left.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Assets/Img/Join type/Normal state/outer.svg b/src/Assets/Img/Join type/Normal state/outer.svg new file mode 100644 index 000000000..333bb215e --- /dev/null +++ b/src/Assets/Img/Join type/Normal state/outer.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Assets/Img/Join type/Normal state/right.svg b/src/Assets/Img/Join type/Normal state/right.svg new file mode 100644 index 000000000..494f23b1c --- /dev/null +++ b/src/Assets/Img/Join type/Normal state/right.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Assets/Img/download_data.svg b/src/Assets/Img/download_data.svg new file mode 100644 index 000000000..9c907761a --- /dev/null +++ b/src/Assets/Img/download_data.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/Assets/Img/globe.svg b/src/Assets/Img/globe.svg new file mode 100644 index 000000000..45214fe5d --- /dev/null +++ b/src/Assets/Img/globe.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/Assets/Img/integration_bg.svg b/src/Assets/Img/integration_bg.svg new file mode 100644 index 000000000..c6c70b6e2 --- /dev/null +++ b/src/Assets/Img/integration_bg.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/Assets/Img/join_inner_black_.jpg b/src/Assets/Img/join_inner_black_.jpg new file mode 100644 index 000000000..05ce8f858 Binary files /dev/null and b/src/Assets/Img/join_inner_black_.jpg differ diff --git a/src/Assets/Img/join_left_selected.svg b/src/Assets/Img/join_left_selected.svg new file mode 100644 index 000000000..7966a5e10 --- /dev/null +++ b/src/Assets/Img/join_left_selected.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Assets/Img/join_right_black_.svg b/src/Assets/Img/join_right_black_.svg new file mode 100644 index 000000000..a8c2920c0 --- /dev/null +++ b/src/Assets/Img/join_right_black_.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Assets/Img/line.svg b/src/Assets/Img/line.svg new file mode 100644 index 000000000..fbd589fd5 --- /dev/null +++ b/src/Assets/Img/line.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/Assets/Img/setting.gif b/src/Assets/Img/setting.gif new file mode 100644 index 000000000..4934ee38e Binary files /dev/null and b/src/Assets/Img/setting.gif differ diff --git a/src/Components/AdminDatasetConnection/AddDataset.jsx b/src/Components/AdminDatasetConnection/AddDataset.jsx index 44c81c7bb..c39e7f3b7 100644 --- a/src/Components/AdminDatasetConnection/AddDataset.jsx +++ b/src/Components/AdminDatasetConnection/AddDataset.jsx @@ -32,9 +32,10 @@ import axios from "axios" import { Avatar, Checkbox, CircularProgress, FormControl, FormControlLabel, FormGroup, InputAdornment, InputLabel, ListItem, ListItemAvatar, ListItemText, MenuItem, Select, List, IconButton, Snackbar, Alert, Chip, Paper, Divider, Skeleton } from '@mui/material' import Success from '../Success/Success'; import CategorySelectorList from './CategorySelectorList'; +import DataStandardizationInAddDataset from './DataStandardizationInAddDataset.js'; //stepper steps label -const steps = ['Dataset name', 'Create or upload dataset', 'Create a metadata']; +const steps = ['Dataset name', 'Create or upload dataset', 'Data standardization', 'Create a metadata']; const AddDataset = (props) => { const { isDatasetEditModeOn, datasetId, isaccesstoken, setOnBoardedTrue, cancelAction, setTokenLocal, onBoardingPage } = props @@ -61,6 +62,8 @@ const AddDataset = (props) => { const [newSelectedCategory, setNewSelectedCategory] = useState([]) const [newSelectedSubCategory, setNewSelectedSubCategory] = useState([]) + const [allStandardisedFile, setAllStandardisedFile] = useState({}) + const [standardisedFileLink, setStandardisedFileLink] = useState({}) @@ -680,6 +683,9 @@ const AddDataset = (props) => { return main_list } + console.log("allStandardisedFile", allStandardisedFile, standardisedFileLink) + + const handleAddDatasetSubmit = (e) => { console.log(finalJson, "Main") e.preventDefault(); @@ -728,6 +734,10 @@ const AddDataset = (props) => { bodyFormData.append("constantly_update", Switchchecked); bodyFormData.append("data_capture_start", fromdate ? fromdate.toISOString() : ""); bodyFormData.append("data_capture_end", todate ? todate.toISOString() : ""); + console.log("allStandardisedFile", allStandardisedFile, standardisedFileLink) + bodyFormData.append("standardisation_template", JSON.stringify(standardisedFileLink)); + bodyFormData.append("standardisation_config", JSON.stringify(allStandardisedFile)); + let obj = { "name": datasetname, description: govLawDesc, category: JSON.stringify(finalJson), user_map: id, geography: geography, deleted: JSON.stringify(idsForFilesDeleted), constantly_update: Switchchecked, data_capture_start: fromdate ? fromdate.toISOString() : "", data_capture_end: todate ? todate.toISOString() : "" } let accesstoken = getTokenLocal(); @@ -1019,7 +1029,7 @@ const AddDataset = (props) => { ) : ( {/* {activeStep == 0 ? "Please provide the dataset name to enable the further steps" : ""} */} - {activeStep == 0 ? + {activeStep == 0 ? { : ""} - {activeStep == 2 ? + { + activeStep == 2 ? + + : + "" + } + + {activeStep == 3 ? { categoryNameList={categoryNameList} handleChangeCategory={handleChangeCategory} category={category} subCategoryNameList={subCategoryNameList} handleSubCategory={handleSubCategory} subCategory={subCategory} /> : ""} */} - + : " "} - {activeStep != 0 && !isSubmitted ? : ""} + {activeStep != 0 && !isSubmitted ? : ""} {/* {(isStepOptional(activeStep) && (localUploaded.length > 0 || mysqlFileList.length > 0 || postgresFileList.length > 0)) && ( )} */} - {activeStep == 2 ? : : } diff --git a/src/Components/AdminDatasetConnection/AddMetadata.jsx b/src/Components/AdminDatasetConnection/AddMetadata.jsx index 17ea44ecc..372af3736 100644 --- a/src/Components/AdminDatasetConnection/AddMetadata.jsx +++ b/src/Components/AdminDatasetConnection/AddMetadata.jsx @@ -16,7 +16,7 @@ import { Select } from 'antd'; import { DatePicker, Space } from 'antd'; import { DatePickerProps } from 'antd'; import dayjs from 'dayjs'; - +import "./admin-add-dataset.css" const { RangePicker } = DatePicker; const ITEM_HEIGHT = 48; @@ -72,7 +72,7 @@ const AddMetadata = (props) => { } } - + const onChange = (date, dateString) => { props.handleChangeFromDate(new Date(dateString[0])) @@ -231,7 +231,7 @@ const AddMetadata = (props) => { /> - @@ -365,7 +365,7 @@ const AddMetadata = (props) => { + + + ) : null} + + ); +}; + +export default DataStandardizationInAddDataset; diff --git a/src/Components/AdminDatasetConnection/LiveApiConnection.jsx b/src/Components/AdminDatasetConnection/LiveApiConnection.jsx index b79a5100b..06c4fa127 100644 --- a/src/Components/AdminDatasetConnection/LiveApiConnection.jsx +++ b/src/Components/AdminDatasetConnection/LiveApiConnection.jsx @@ -121,6 +121,8 @@ export default function LiveApiConnection(props) { <> {loader ? : ""} div :nth-child(2){ + max-width: 1300px !important; + overflow: scroll !important; + height: 35px !important; } \ No newline at end of file diff --git a/src/Components/AdminDatasetConnection/MysqlFormForConnection.jsx b/src/Components/AdminDatasetConnection/MysqlFormForConnection.jsx index bf0b4cc7a..649314b29 100644 --- a/src/Components/AdminDatasetConnection/MysqlFormForConnection.jsx +++ b/src/Components/AdminDatasetConnection/MysqlFormForConnection.jsx @@ -135,13 +135,6 @@ const MysqlFormForConnection = ({ isDatasetEditModeOn, seteErrorDatasetName, han port: "" } - // //clear input fields - // setConnectionData({ - // ...connectionData, ...dataForReset - // }) - - - var returnValues = GetErrorKey(err, ["database", "username", "password", "host", "port"]) var errorKeys = returnValues[0] var errorMessages = returnValues[1] diff --git a/src/Components/AdminDatasetConnection/ViewMetaDatasetDetails.jsx b/src/Components/AdminDatasetConnection/ViewMetaDatasetDetails.jsx index 63e7bf59b..b4365ce9d 100644 --- a/src/Components/AdminDatasetConnection/ViewMetaDatasetDetails.jsx +++ b/src/Components/AdminDatasetConnection/ViewMetaDatasetDetails.jsx @@ -388,7 +388,10 @@ export default function ViewMetaDatasetDetails(props) { {userType != "guest" ? <> - {fileData.map((downloadfile) => ( + {fileData.map((downloadfile) => { + console.log('downloadfile',downloadfile) + let filePathToDownload = downloadfile?.standardised_file ? downloadfile?.standardised_file : "" + return( - downloadAttachment(UrlConstant.base_url + downloadfile?.file ? downloadfile?.file : "", downloadfile?.file?.split("/").pop()) + downloadAttachment(`${UrlConstant.base_url}${filePathToDownload}`, "") } > - {downloadfile?.file?.split("/").pop()} + {downloadfile?.standardised_file?.split("/").pop()} {/*
*/} {/* m */}
-
))} +
+ )})} : " "} {/*
*/}
diff --git a/src/Components/AdminDatasetConnection/admin-add-dataset.css b/src/Components/AdminDatasetConnection/admin-add-dataset.css index 4ede5edb6..86ca67aab 100644 --- a/src/Components/AdminDatasetConnection/admin-add-dataset.css +++ b/src/Components/AdminDatasetConnection/admin-add-dataset.css @@ -114,4 +114,68 @@ /* .Mui-completed { font-weight: 600 !important; font-size: 20px !important; -} */ \ No newline at end of file +} */ +.button_main_box button { + width: 20%; + text-transform: capitalize !important; +} + +.button_main_box .next_btn { + color: #c09507 !important; + border: 1px solid #c09507 !important; + +} + +.button_main_box .next_btn:hover { + color: white !important; + background-color: #c09507 !important; + +} + +.button_main_box .next_btn:disabled { + color: rgba(128, 128, 128, 0.78) !important; + background-color: rgba(128, 128, 128, 0.58) !important; + border-color: grey !important; +} + +.button_main_box .cancel_btn { + color: red !important; + border: 1px solid red !important; +} + +.button_main_box .cancel_btn:hover { + color: white !important; + background-color: red !important; +} + +.button_main_box .back_btn { + color: #c09507 !important; +} + +.button_main_box .back_btn:hover { + color: #c09507 !important; + background-color: unset !important; +} + +#admin_add_dataset_main_container .submit_btn { + width: 400px !important; + color: #c09507 !important; + border: 1px solid #c09507 !important; + text-transform: capitalize !important; + margin-top: 20px; + +} + +#admin_add_dataset_main_container .submit_btn:hover { + color: white !important; + background-color: #c09507 !important; + +} + +#admin_add_dataset_main_container .submit_btn:disabled { + color: rgba(255, 255, 255, 0.45) !important; + background-color: grey !important; + border-color: grey !important; + width: 400px !important; + text-transform: capitalize !important; +} \ No newline at end of file diff --git a/src/Components/Datasets/IntegrationDatasets/CardDetail/CardDetail.jsx b/src/Components/Datasets/IntegrationDatasets/CardDetail/CardDetail.jsx new file mode 100644 index 000000000..826d427bd --- /dev/null +++ b/src/Components/Datasets/IntegrationDatasets/CardDetail/CardDetail.jsx @@ -0,0 +1,111 @@ +import React from 'react' +import { Checkbox, FormControlLabel } from '@mui/material' +import { Col, Container, Row } from 'react-bootstrap' +import styles from "./card_detail.module.css" +import DeleteIcon from '@mui/icons-material/Delete'; +import CloseIcon from '@mui/icons-material/Close'; +import { useEffect } from 'react'; +const CardDetail = (props) => { + const { setIsAllConditionForSaveMet, temporaryDeletedCards, setTemporaryDeletedCards, generateData, setCompleteJoinData, completedJoinData, setTotalCounter, orgList, data, setCompleteData, index, completeData } = props + + const handleCheckColumns = (e, value) => { + let arr = [...completeData] + let present_card = { ...data } + if (e.target.checked && !present_card.columnsSelected.includes(value) && present_card.availabeColumns.includes(value)) { + present_card["columnsSelected"] = [...present_card.columnsSelected, value] + arr[index] = { ...present_card } + setCompleteData([...arr]) + } + else if (!e.target.checked && present_card?.columnsSelected?.includes(value) && present_card.availabeColumns?.includes(value)) { + let i = present_card.columnsSelected.indexOf(value) + if (i > -1) { + present_card.columnsSelected.splice(i, 1) + } + arr[index] = present_card + setCompleteData([...arr]) + } + } + const handleSelectAll = (e) => { + let arr = [...completeData] + let present_card = { ...data } + if (e.target.checked) { + present_card["columnsSelected"] = [...present_card.availabeColumns] + } else { + present_card["columnsSelected"] = [] + } + arr[index] = { ...present_card } + setCompleteData([...arr]) + } + + const handleDeleteCard = () => { + let arr = [...completeData] + // generateData(index, "delete_map_card") + + if ((index == arr.length - 1) && arr.length > 2) { + setIsAllConditionForSaveMet(true) + } else { + setIsAllConditionForSaveMet(false) + } + console.log(temporaryDeletedCards) + // .then(()=>{ + let obj + if (index != 0) { + obj = arr[index - 1] + obj["right_on"] = [] + obj["type"] = "" + obj["next_left"] = [] + arr[index - 1] = obj + } + arr.splice(index, 1) + + let deleteArr = [] + let start = index == 0 ? index : index - 1 + for (let i = start; i < completeData.length; i++) { + console.log(index, i, temporaryDeletedCards) + if (!temporaryDeletedCards?.includes(completeData[i]["map_id"]) && completeData[i]["map_id"]) { + deleteArr.push(completeData[i]["map_id"]) + } + } + setTemporaryDeletedCards([...temporaryDeletedCards, ...deleteArr]) + + + setCompleteData([...arr]) + setTotalCounter((prev) => prev - 1) + // }) + } + useEffect(() => { + }) + return ( + <> +
+ + +
Organisation name
+
{data?.org_name ? data.org_name : ""}
+ + +
Dataset name
+
{data?.dataset_name ? decodeURI(data.dataset_name) : ""}
+
File name
+
{data?.file_name ? decodeURI(data.file_name.split("/")[data.file_name.split("/").length - 1]) : ""}
+ +
+ + +
Select columns
+
} checked={data?.availabeColumns?.length == data?.columnsSelected?.length} onChange={(e) => handleSelectAll(e)} />} label={data?.availabeColumns?.length != data?.columnsSelected?.length ? "Select all" : "Clear"} />
+ +
+ + + {data?.availabeColumns?.length > 0 && data.availabeColumns.map((eachCol, in_) => { + return handleCheckColumns(e, eachCol)} />} label={eachCol} /> + })} + + +
+ + ) +} + +export default CardDetail \ No newline at end of file diff --git a/src/Components/Datasets/IntegrationDatasets/CardDetail/card_detail.module.css b/src/Components/Datasets/IntegrationDatasets/CardDetail/card_detail.module.css new file mode 100644 index 000000000..f0a1cb371 --- /dev/null +++ b/src/Components/Datasets/IntegrationDatasets/CardDetail/card_detail.module.css @@ -0,0 +1,70 @@ +@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap'); + +.mainBox { + border-radius: 10px; + border: 1px solid #919EAB; + padding: 0px; + margin: 0px 0px; + overflow: hidden; + font-family: 'Inter', sans-serif; + font-family: 'Montserrat', sans-serif; + font-style: normal; + +} + + +.mainBox:hover { + box-shadow: 0 3px 10px #ab840574; +} + +.topRowOfCard { + height: 90px; + background: #F9EABC; + padding: 20px; + font-weight: 400; + font-size: 16px; + line-height: 24px; + text-align: left; + border-bottom: 1px solid #9AA1A9; +} + +.topRowOfCard div:nth-child(2) { + font-weight: 700; + +} + +.topRowOfCard>div:nth-child(2) { + font-weight: 400; +} + + +.selectAllRow { + text-align: left; + padding: 10px 20px 0px 20px; + border-bottom: 1px solid #9AA1A9; +} + +.columnsRow { + text-align: left; + padding: 20px; + +} + +.selectColumns { + display: grid; + grid-template-columns: auto auto auto auto; + gap: 10px; +} + +.eachCol { + width: 250px; +} + +.deleteicon:hover .topRowOfCard { + background: red !important; + color: white !important; +} + +.deleteicon { + /* align-self: flex-end; */ +} \ No newline at end of file diff --git a/src/Components/Datasets/IntegrationDatasets/DatasetIntegration.jsx b/src/Components/Datasets/IntegrationDatasets/DatasetIntegration.jsx index 198f8bf65..76af517ce 100644 --- a/src/Components/Datasets/IntegrationDatasets/DatasetIntegration.jsx +++ b/src/Components/Datasets/IntegrationDatasets/DatasetIntegration.jsx @@ -1,112 +1,151 @@ -import React, { useEffect } from 'react' +import React, { useEffect, useState } from 'react' import { Col, Container, Row } from 'react-bootstrap' import DatasetSelect from './DatasetSelect/DatasetSelect' import Join from './Join/Join' import Preview from './Preview/Preview' import styles from "./dataset_integration.module.css" -import { useState } from 'react' import HTTPService from '../../../Services/HTTPService' import UrlConstant from '../../../Constants/UrlConstants' import Loader from '../../Loader/Loader' -import { Alert, Button, Collapse, IconButton } from '@mui/material' +import { Alert, Button, Collapse, Fab, IconButton, Snackbar } from '@mui/material' import CloseIcon from '@mui/icons-material/Close'; +import { CheckLg } from 'react-bootstrap-icons' +import { GetErrorHandlingRoute, GetErrorKey, getUserLocal, goToTop } from '../../../Utils/Common' +import { useHistory } from 'react-router-dom' +import { Affix } from 'antd' +import { AddIcCallOutlined } from '@material-ui/icons' +import ConnectorsList from '../../IntegrationConnectors/ConnectorsList' +import FileSaver from 'file-saver' const converter = require('json-2-csv') const fs = require('fs') -const DatasetIntegration = () => { +const DatasetIntegration = (props) => { + const [isEditModeOn, setIsEditModeOn] = useState(false) + const [counterForIntegrator, setCounterForIntegration] = useState(2) + const [isEdited, setIsEdited] = useState(false) + + const [isConditionForConnectorDataForSaveMet, setIsConditionForConnectorDataForSaveMet] = useState(false) + const [isAllConditionForSaveMet, setIsAllConditionForSaveMet] = useState(false) + const [temporaryDeletedCards, setTemporaryDeletedCards] = useState([]) + const [isDatasetIntegrationListModeOn, setIsDatasetIntegrationListModeOn] = useState(true) + const [top, setTop] = useState(10); + const [orgList, setOrgList] = useState([]) const [message, setMessage] = useState("") const [alertType, setAlertType] = useState("") const [open, setOpen] = React.useState(false); - // - const [noOfDatasetSelector, setNoOfDatasetSelector] = useState([]) - const [listOfDatasetSelected, setListOfDatasetSelected] = useState([]) - const [allDatasetNameList, setAllDatasetNameList] = useState([]) + const [connectorId, setConnectorId] = useState("") + const [connectorTimeData, setConnectorTimeData] = useState({ + create_at: "", last_updated: "" + }) + const [connectorIdForView, setConnectorIdForView] = useState("") + + const [template, setTemplate] = useState( + { org_id: "", dataset_list: [], file_list: [], org_name: "", dataset_id: "", dataset_name: "", file_name: "", availabeColumns: [], columnsSelected: [], left: [], right: [], left_on: [], right_on: [], type: "" }, + + ) + const [empty, setEmptyTemplate] = useState( + { org_id: "", dataset_list: [], file_list: [], org_name: "", dataset_id: "", dataset_name: "", file_name: "", availabeColumns: [], columnsSelected: [], left: [], right: [], left_on: [], right_on: [], type: "" }, + ) + + + + const [joinType, setJoinType] = useState("") - const [noOfFileSelector, setNoOfFileSelector] = useState([]) - const [listOfFilesSelected, setListOfFilesSelected] = useState([]) - const [listOfFilesAvailableForSelect, setListOfFilesAvailableForSelect] = useState([ + //This is main array which will have all the data with the format of template or empty + const [completeData, setCompleteData] = useState([ + + //In dev mode this is the dummy data + // { org_id: "A", dataset_list: ["d1", "d2", "d3"], file_list: ["f1", "f2", "f3"], org_name: "org_nameA", dataset_id: "id", dataset_name: "dataset_name1", file_name: "file_name1", availabeColumns: ["c1", "c2", "c3"], columnsSelected: [], left: [], right: [], left_on: [], right_on: [], type: "" }, + // { org_id: "B", dataset_list: ["d1", "d2", "d3"], file_list: ["f1", "f2", "f3"], org_name: "org_nameA", dataset_id: "id", dataset_name: "dataset_name1", file_name: "file_name1", availabeColumns: ["c4", "c5", "c6"], columnsSelected: [], left: [], right: [], left_on: [], right_on: [], type: "" }, + // { org_id: "C", dataset_list: ["d1", "d2", "d3"], file_list: ["f1", "f2", "f3"], org_name: "org_nameA", dataset_id: "id", dataset_name: "dataset_name1", file_name: "file_name1", availabeColumns: ["c7", "c8", "c9"], columnsSelected: [], left: [], right: [], left_on: [], right_on: [], type: "" }, ]) - const [listOfDatsetFileAvailableForColumn, setListOfDatsetFileAvailableForColumn] = useState([]) + + // const [listOfDatsetFileAvailableForColumn, setListOfDatsetFileAvailableForColumn] = useState([]) const [finalDataNeedToBeGenerated, setFinalDataNeedToBeGenerated] = useState({}) + const [integratedFilePath, setIntegratedFilePath] = useState("") + const [noOfRecords, setNoOfRecords] = useState(0) const [finalDatasetAfterIntegration, setFinalDatasetAfterIntegration] = useState([]) + const [finalDatasetAfterSaving, setFinalDatasetAfterSaving] = useState([]) //loader for every network request const [loader, setLoader] = useState(false) - const [circleLoad, setCircleLoad] = useState(false) + //connector data + const [connectorData, setConnectorData] = useState({ + name: "", desc: "", + }) - const handleChangeDatasetNameSelector = (event, i, source) => { - console.log(event.target.value, i, source) - if (source == "dataset") { - let list_selected = [...listOfDatasetSelected] - list_selected[i] = event.target.value - console.log(list_selected, "list_selected") - setListOfDatasetSelected([...list_selected]); - getFilesAssociatedForTheSelectedDatasets(source, list_selected) - } else { - let list_selected = [...listOfFilesSelected] - list_selected[i] = event.target.value - console.log(list_selected, "file_selected") - setListOfFilesSelected([...list_selected]); - let newListForColumns = listOfFilesAvailableForSelect.filter((eachFile, index) => { - return list_selected.includes(eachFile.name) - }) - // setListOfDatsetFileAvailableForColumn([...newListForColumns]) - getFilesAssociatedForTheSelectedDatasets(source, list_selected) + + const history = useHistory(); + + const handleChangeDatasetNameSelector = (event, i, source, name) => { + if (source == "org") { + let res = getFilesAssociatedForTheSelectedDatasets(source, [], event.target.value, i, name) + return } - }; - const handleChangeFileNameSelector = (event, i) => { + else if (source == "dataset") { + if (event.target.value) { + let res = getFilesAssociatedForTheSelectedDatasets(source, [event.target.value], event.target.value, i) + } + } else if (source == "file") { + if (event.target.value) { + + let res = getFilesAssociatedForTheSelectedDatasets(source, [event.target.value], "", i) + res.then((res) => { + }) + + } else { + } + } }; const handleClickSelectDataset = (source) => { if (source == "dataset") { - let selector = noOfDatasetSelector.length; - let selectedDataset = listOfDatasetSelected.length - let availableDataset = allDatasetNameList.length - if (selectedDataset != availableDataset) { - let max = +selector - +selectedDataset - console.log(max, selector, selectedDataset) - if (max <= 0 && !listOfDatasetSelected.includes("")) { - setNoOfDatasetSelector([...noOfDatasetSelector, ""]) - } - } } else { - let selector = noOfFileSelector.length; - let selectedDataset = listOfFilesSelected.length - let availableDataset = listOfFilesAvailableForSelect.length - if (selectedDataset != availableDataset) { - let max = +selector - +selectedDataset - console.log(max, selector, selectedDataset) - if (max <= 0 && !listOfFilesSelected.includes("")) { - setNoOfFileSelector([...noOfFileSelector, ""]) - } - } } } - const getListOfDatasetNames = () => { - setLoader(true) - let url = UrlConstant.base_url + UrlConstant.get_dataset_name_list - let method = "GET" + const getDataList = (source, index) => { + // setLoader(true) + let url = "" + let method + if (source == "org_names") { + url = UrlConstant.base_url + UrlConstant.get_org_name_list + method = "GET" + } else if (source == "dataset_names") { + url = UrlConstant.base_url + UrlConstant.get_dataset_name_list + method = "GET" + } HTTPService(method, url, "", false, true, false).then((res) => { - setLoader(false) - setAllDatasetNameList([...res.data]) - }).catch((e) => { + // if (!isEditModeOn && !connectorIdForView) { + // setLoader(false) + // } + if (source == "org_names") { + setOrgList([...res.data]) + } else if (source == "dataset_names") { + setTemplate({ ...template, dataset_list: [...res.data] }) + } + }).catch((err) => { setAlertType("error") - setMessage("Error occurred! Dataset could not fetched.") - setLoader(false) + if (err?.response.status == 401 || err?.response.status == 502) { + history.push(GetErrorHandlingRoute(err)); + } else { + setMessage(err?.response?.data?.error ? err?.response?.data?.error : "Error occurred! Dataset could not fetched.") + } + // setLoader(false) }) } - const getFilesAssociatedForTheSelectedDatasets = (source, list) => { + const getFilesAssociatedForTheSelectedDatasets = async (source, list, org, i) => { list = list.filter((item) => item != "") setLoader(true) let url = "" let payload = {} + let method = "POST" if (source == "dataset") { url = UrlConstant.base_url + UrlConstant.get_files_for_selected_datasets payload = { @@ -117,180 +156,458 @@ const DatasetIntegration = () => { payload = { files: [...list] } - } - let method = "POST" + } else if (source == "org") { + method = "GET" + url = UrlConstant.base_url + UrlConstant.get_dataset_name_list + "?org_id=" + org + payload = { - HTTPService(method, url, payload, false, true, false).then((res) => { + } + } + return await HTTPService(method, url, payload, false, true, false).then((res) => { setLoader(false) if (source == "dataset") { - setListOfFilesAvailableForSelect([...res.data]) + setTemplate({ ...template, availabeColumns: [], dataset_name: res.data[0]?.dataset_name ? res.data[0].dataset_name : "N/A", dataset_id: org ? org : "", file_name: "", availabeColumns: [], file_list: [...res.data] }) } else if (source == "file") { - // let allColumnsOfResponse = Object.keys(res?.data) - // let listForColumnsAvailable = [] - // for (let i = 0; i < allColumnsOfResponse.length; i++) { - // listForColumnsAvailable.push(...res.data[allColumnsOfResponse[i]]) - // } - // setListOfFilesAvailableForSelect([ - // { name: res.data?.files1[0], columns: [] }, - // { name: res.data?.files2[0], columns: [] } - // ]) - console.log(res.data) - setListOfDatsetFileAvailableForColumn( - { ...res.data } - ) + let name = list[0] + let resArr = [] + let fileId = res.data?.id ? res.data.id : "" + for (var key in res.data) { + resArr.push(res.data[key]) + } + setTemplate({ ...template, file_id: fileId, file_name: name, availabeColumns: [...res.data[name]] }) + } else if (source == "org") { + console.log(template) + setTemplate({ ...template, availabeColumns: [], dataset_name: "", dataset_id: "", file_name: "", file_list: [], dataset_list: [...res.data], org_id: org, org_name: res?.data?.length > 0 ? res.data[0]?.org_name : "" }) } - }).catch((e) => { - setOpen(true); - setAlertType("error") - setMessage(e?.message ? e.message : "Some error occurred while generating!") - let id = setTimeout(() => { - setOpen(false); - return clearTimeout(id) - }, 2500) - // if (source == "dataset") { - // setListOfFilesAvailableForSelect([ - // { file_name: "name_of_the file1", file: "path_of_the_file1" }, - // { file_name: "name_of_the file2", file: "path_of_the_file2" }, - // { file_name: "name_of_the file3", file: "path_of_the_file3" }, - // { file_name: "name_of_the file4", file: "path_of_the_file4" }, - // { file_name: "name_of_the file5", file: "path_of_the_file5" }, - // { file_name: "name_of_the file6", file: "path_of_the_file6" }, - // { file_name: "name_of_the file7", file: "path_of_the_file7" }, - // { file_name: "name_of_the file8", file: "path_of_the_file8" }, - // ]) - // } else if (source == "file") { - // setListOfDatsetFileAvailableForColumn( - // { - // path_of_the_file1: ["id", "mobile_number"], - // path_of_the_file6: ["id", "phone_number"] - // } - // ) - // } + return true + }).catch((err) => { + goToTop(0) + // setOpen(true); + // setAlertType("error") + console.log(err?.response?.data) + setMessage(err?.response?.data?.error ? err?.response?.data?.error : "Some error occurred while generating!") + // let id = setTimeout(() => { + // setOpen(false); + // return clearTimeout(id) + // }, 2500) setLoader(false) + + var returnValues = GetErrorKey(err, ["datasets", "files"]) + var errorKeys = returnValues[0] + var errorMessages = returnValues[1] + if (errorKeys.length > 0) { + for (var i = 0; i < errorKeys.length; i++) { + let id; + switch (errorKeys[i]) { + case "datasets": + setOpen(true); + setLoader(false) + setAlertType("error") + setMessage(errorMessages[i] ? errorMessages[i] : "Some error occurred while fetching files for selected dataset!") + id = setTimeout(() => { + setOpen(false); + return clearTimeout(id) + }, 2500) + return false + case "files": setOpen(true); + setLoader(false) + setAlertType("error") + setMessage(errorMessages[i] ? errorMessages[i] : "Some error occurred while fetching files for selected dataset!") + id = setTimeout(() => { + setOpen(false); + return clearTimeout(id) + }, 2500) + return false + default: + if (err?.response?.status == 401 || err?.response?.status == 502) { + history.push(GetErrorHandlingRoute(err)); + } else { + setOpen(true); + setLoader(false) + setAlertType("error") + console.log(err?.response?.data) + setMessage(err?.response?.data?.error ? err?.response?.data?.error : "Some error occurred while generating!") + let id = setTimeout(() => { + setOpen(false); + return clearTimeout(id) + }, 2500) + } + return false + } + } + } + else { + + if (err?.response?.status == 401 || err?.response?.status == 502) { + history.push(GetErrorHandlingRoute(err)); + } else { + setOpen(true); + setLoader(false) + setAlertType("error") + console.log(err?.response?.data) + setMessage(err?.response?.data?.error ? err.response.data.error : "Some error occurred while generating!") + let id = setTimeout(() => { + setOpen(false); + return clearTimeout(id) + }, 2500) + } + } + return false }) } - const deleteTable = (tableName, index) => { - let newArr = listOfDatsetFileAvailableForColumn.filter((each) => each.name != tableName.name) - setListOfDatsetFileAvailableForColumn([...newArr]) - - let list_selected = [...listOfFilesSelected] - console.log(list_selected, tableName.name, index) - list_selected.splice(index, 1) - // list_selected.filter((each) => { - // return each != tableName.name - // }) - console.log(list_selected, tableName.name, index) - setListOfFilesSelected([...list_selected]); + const resetAll = (main, connector, join, goback, func1, func2) => { + + // goToTop() + if (isEditModeOn) { + setIsConditionForConnectorDataForSaveMet(false) + setIsAllConditionForSaveMet(false) + } + setTemporaryDeletedCards([]) + setIntegratedFilePath("") + setNoOfRecords(0) + setTemplate({ ...empty }) + setConnectorId("") + setCounterForIntegration(2) + setCompleteData([]) + setFinalDatasetAfterIntegration([]) + setConnectorData({ name: "", desc: "" }) + setIsEditModeOn(false) + setIsDatasetIntegrationListModeOn(true) + + } + const completeDataGenerator = (maps) => { + // { org_id: "", dataset_list: [], file_list: [], org_name: "", dataset_id: "", dataset_name: "", file_name: "", availabeColumns: [], columnsSelected: [], left: [], right: [], left_on: [], right_on: [], type: "" }, + + let arr = [] + for (let i = 0; i < maps.length; i++) { + let currentObj = {} + let nextObj = {} + + //Current obj + currentObj["file_name"] = maps[i]?.left_dataset_file?.file ? maps[i]?.left_dataset_file?.file : "N/A" + currentObj["file_id"] = maps[i]?.left_dataset_file?.id ? maps[i]?.left_dataset_file?.id : "" + // currentObj["dataset_id"] = maps[i]?.left_dataset_file?.dataset?. ? maps[i]?.left_dataset_file?.file.split("/").at(-1) : "N/A" + currentObj["dataset_name"] = maps[i]?.left_dataset_file?.dataset?.name ? maps[i]?.left_dataset_file?.dataset?.name : "" + currentObj["org_name"] = maps[i]?.left_dataset_file?.dataset?.user_map?.organization?.name ? maps[i]?.left_dataset_file?.dataset?.user_map?.organization?.name : "" + currentObj["org_id"] = maps[i]?.left_dataset_file?.dataset?.user_map?.id ? maps[i]?.left_dataset_file?.dataset?.user_map?.id : "" + currentObj["type"] = maps[i]?.condition?.how ? maps[i]?.condition?.how : "left" + currentObj["left_on"] = maps[i]?.condition?.left_on + currentObj["right_on"] = maps[i]?.condition?.right_on + currentObj["columnsSelected"] = maps[i]?.condition?.left_selected + currentObj["left"] = maps[i]?.condition?.left?.length > 0 ? maps[i]?.condition?.left : [] + currentObj["next_left"] = maps[i]?.condition?.left?.length > 0 ? maps[i]?.condition?.left : [] + currentObj["map_id"] = maps[i]?.id ? maps[i]?.id : null + + currentObj["availabeColumns"] = maps[i]?.condition?.left_available_columns?.length > 0 ? maps[i]?.condition?.left_available_columns : maps[i]?.condition?.left_selected + arr[i] = currentObj + + //Next obj + nextObj["left"] = maps[i]?.condition?.left?.length > 0 ? maps[i]?.condition?.left : [] + nextObj["file_name"] = maps[i]?.right_dataset_file?.file ? maps[i]?.right_dataset_file?.file : "N/A" + nextObj["file_id"] = maps[i]?.right_dataset_file?.id ? maps[i]?.right_dataset_file?.id : "" + nextObj["dataset_name"] = maps[i]?.right_dataset_file?.dataset?.name ? maps[i]?.right_dataset_file?.dataset?.name : "" + nextObj["columnsSelected"] = maps[i]?.condition?.right_selected.length > 0 ? maps[i]?.condition?.right_selected : [] + nextObj["availabeColumns"] = maps[i]?.condition?.right_available_columns?.length > 0 ? maps[i]?.condition?.right_available_columns : maps[i]?.condition?.left_selected + nextObj["org_name"] = maps[i]?.right_dataset_file?.dataset?.user_map?.organization?.name ? maps[i]?.right_dataset_file?.dataset?.user_map?.organization?.name : "" + nextObj["org_id"] = maps[i]?.right_dataset_file?.dataset?.user_map?.id ? maps[i]?.right_dataset_file?.dataset?.user_map?.id : "" + arr[i + 1] = nextObj + } + // let obj = {} + // obj["left"] = maps[maps.length - 1]?.next_left + // arr[arr.length] = { ...obj } + console.log(arr) + setCompleteData([...arr]) + setCounterForIntegration(arr.length >= 2 ? arr.length : 2) } - const generateData = (left_on, right_on) => { + + const setterForPreRender = (dataForRender) => { + //set name and desc + setConnectorData({ + ...completeData, name: dataForRender?.name ? dataForRender?.name : "", desc: dataForRender?.description ? dataForRender?.description : "" + }) + if (dataForRender?.name && dataForRender?.description) { + setIsConditionForConnectorDataForSaveMet(true) + } + //set connector id for deleting the connector if user wants + setConnectorId(dataForRender?.id) + //file path setting + setIntegratedFilePath(dataForRender?.integrated_file?.replace("/media", "")) + setNoOfRecords(dataForRender?.data?.no_of_records ? dataForRender?.data?.no_of_records : 0) + + //set already generated data + setFinalDatasetAfterIntegration([...dataForRender?.data?.data ? (dataForRender?.data?.data) : []]) + + //A function to generate complete Data from maps of dataForRender + completeDataGenerator(dataForRender?.maps?.length > 0 ? dataForRender?.maps : []) + } + + //this function is being used to generate the data at first place, Save the generated data and delete the saved connectors + const generateData = (index, condition, map_id) => { + let connector_id = connectorId + // let map_id + if (condition == "view_details") { + connector_id = connectorIdForView + } + // else if (condition == "delete_map_card" && isEditModeOn) { + // map_id = completeData[index]["map_id"] ? completeData[index]["map_id"] : "" + // setTemporaryDeletedCards([...temporaryDeletedCards, map_id]) + // return + // } + //condition can be ===> [integrate, delete, save] any one of the listed elements setLoader(true) - let url = UrlConstant.base_url + UrlConstant.joining_the_table - console.log(finalDataNeedToBeGenerated, "finalDataNeedToBeGenerated") - let arr = Object.keys(finalDataNeedToBeGenerated) - let firstFile = arr[0] - let secondFile = arr[1] - let payload = { - file_path1: firstFile, - "columns1": [ - ...finalDataNeedToBeGenerated[firstFile] - ], - "file_path2": secondFile, - "columns2": [ - ...finalDataNeedToBeGenerated[secondFile] - ], - "how": "left", - "left_on": [left_on], - "right_on": [right_on], + let url = "" + + let payload = [] + + // console.log(index, completeData, condition, "MAIN DATA") + if (condition !== "view_details" && condition != "delete" && condition != "delete_map_card") { + for (let i = 0; i < index + 1; i++) { + //Generating the payload as array of objects each object having data friom completeData and completeJoinData + let obj = { + left_dataset_file: completeData[i]?.file_id, + right_dataset_file: completeData[i + 1]?.file_id, + left_dataset_file_path: completeData[i]?.file_name, + right_dataset_file_path: completeData[i + 1]?.file_name, + condition: { + left: completeData[i]?.next_left?.length > 0 ? completeData[i].next_left : [], right: completeData[i]?.right?.length > 0 ? completeData[i].right : [], + left_available_columns: completeData[i]?.availabeColumns?.length > 0 ? [...completeData[i]?.availabeColumns] : [], + right_available_columns: completeData[i + 1]?.availabeColumns?.length > 0 ? [...completeData[i + 1]?.availabeColumns] : [], + right_selected: [...completeData[i + 1]?.columnsSelected], left_selected: [...completeData[i]?.columnsSelected], + how: completeData[i]?.type ? completeData[i]?.type : "left", + left_on: completeData[i]?.left_on, + right_on: completeData[i]?.right_on + } + } + if (isEditModeOn) { + obj["id"] = completeData[i]?.map_id ? completeData[i]?.map_id : null + } + payload.push(obj) + } } - let method = "POST" - HTTPService(method, url, payload, false, true, false).then((res) => { + let finalPayload + let method + if (condition == "save") { + finalPayload = { name: connectorData.name, description: connectorData.desc, user: getUserLocal(), maps: payload, integrated_file: integratedFilePath } + if (isEditModeOn) { + url = UrlConstant.base_url + UrlConstant.integration_connectors + connector_id + "/" // for saving + method = "PUT" + } else { + url = UrlConstant.base_url + UrlConstant.integration_connectors // for saving + method = "POST" + } + } else if (condition == "integrate") { + finalPayload = { name: connectorData.name, description: connectorData.desc, user: getUserLocal(), maps: payload } + if (isEditModeOn) { + url = UrlConstant.base_url + UrlConstant.joining_the_table + "?edit=True" //for generating + } else { + url = UrlConstant.base_url + UrlConstant.joining_the_table //for generating + } + method = "POST" + } else if (condition == "delete" && connector_id) { + finalPayload = {} + url = UrlConstant.base_url + UrlConstant.integration_connectors + connector_id + "/" + method = "DELETE" + } else if (condition == "view_details") { + url = UrlConstant.base_url + UrlConstant.integration_connectors + connector_id + "/" + finalPayload = {} + method = "GET" + } else if (condition == "delete_map_card" && isEditModeOn && map_id) { + method = "DELETE" + url = UrlConstant.base_url + UrlConstant.integration_connectors + map_id + "/?maps=True" + + } else { setLoader(false) - console.log(JSON.parse(res.data)) - setFinalDatasetAfterIntegration([...JSON.parse(res.data)]) - setOpen(true); - setAlertType("success") - setMessage("Data generated successfully!") - let id = setTimeout(() => { - setOpen(false); - return clearTimeout(id) - }, 2500) - }).catch((err) => { - setOpen(true); + return + } + console.table(finalPayload, "PAYLOAD") + HTTPService(method, url, finalPayload, false, true, false).then((res) => { + setLoader(false) - setAlertType("error") - setMessage(err?.message ? err.message : "Some error occurred while generating!") - let id = setTimeout(() => { - setOpen(false); - return clearTimeout(id) - }, 2500) + if (condition == "integrate") { + console.log("inside integrate", res.data) + setIntegratedFilePath(res?.data?.integrated_file ? res?.data?.integrated_file : "") + setNoOfRecords(res?.data?.no_of_records ? res?.data?.no_of_records : 0) + + setFinalDatasetAfterIntegration([...res.data?.data?.data]) + let allKeys = (res.data?.data?.data)?.length > 0 ? Object.keys((res.data.data.data)[0]) : [] + if (allKeys.length > 1) { + let arr = [...completeData] + let obj = arr[index + 1] + let first_obj = arr[index] + first_obj["next_left"] = [...allKeys] + obj["left"] = [...allKeys] + obj["left_on"] = [] + console.log("HERE IS THE CALL", arr.length, index,) + if (arr.length > 2 && index != arr.length - 2) { + for (let i = index + 1; i < arr.length; i++) { + arr[i]["left_on"] = [] + } + setIsAllConditionForSaveMet(false) + } else { + // setIsConditionForConnectorDataForSaveMet(true) + setIsAllConditionForSaveMet(true) + } + arr[index] = { ...first_obj } + arr[index + 1] = { ...obj } + setCompleteData([...arr]) + setOpen(true); + setAlertType("success") + setMessage("Data generated successfully!") + let id = setTimeout(() => { + setOpen(false); + return clearTimeout(id) + }, 2500) + document.querySelector('#previewTable').scrollIntoView({ behavior: 'smooth' }); + } + + } else if (condition == "save") { + console.log("inside save", res.data) + // setConnectorId(res?.data?.id ? res.data.id : "") + setOpen(true); + setAlertType("success") + setMessage("Data saved successfully!") + resetAll() + let id = setTimeout(() => { + setOpen(false); + return clearTimeout(id) + }, 2500) + // document.querySelector('#previewTable').scrollIntoView({ behavior: 'smooth' }); + + } else if (condition == "delete") { + console.log("inside delete", res) + // setOpen(true); + // setAlertType("success") + // setMessage("Data deleted successfully!") + // let id = setTimeout(() => { + // setOpen(false); + // return clearTimeout(id) + // }, 2500) + } else if (condition == "view_details") { + console.log(res.data, "inside view_details") + //setter function for pre prendering of the data + setterForPreRender(res.data) + } + + // goToTop(2000) + }).catch((err) => { + if (err?.response?.status == 401 || err?.response?.status == 502) { + history.push(GetErrorHandlingRoute(err)); + } else { + if (condition == "integrate") { + setIsAllConditionForSaveMet(false) + } + console.log(err.response.data) + console.log(Object.values(err?.response?.data)[0]) + setOpen(true); + setLoader(false) + setAlertType("error") + setMessage(err?.response?.data ? Object.values(err?.response?.data)[0] : "Some error occurred while generating!") + let id = setTimeout(() => { + setOpen(false); + return clearTimeout(id) + }, 2500) + // if (condition == "view_details") { + // setIsEditModeOn(false) + // setIsDatasetIntegrationListModeOn(true) + // } + goToTop(0) + } }) } + + + + //Download functionality const downloadDocument = () => { - converter.json2csv(finalDatasetAfterIntegration, async (err, csv) => { - if (err) { - throw err - } - // print CSV string - console.log(csv) - download(csv) - }) + // converter.json2csv(finalDatasetAfterIntegration, async (err, csv) => { + // if (err) { + // throw err + // } + // // print CSV string + // download(csv) + // }) + let uri + if (integratedFilePath[0] === "/") { + uri = UrlConstant.base_url_without_slash + integratedFilePath + } else { + uri = UrlConstant.base_url + integratedFilePath + + } + download(uri, connectorData.name ? connectorData.name : "Integrated_dataset"); + } + + //number of integration handler + const integrateMore = (value) => { + if (counterForIntegrator == completeData.length) { + setCounterForIntegration((pre) => pre + value) + } } - const download = (data) => { - const blob = new Blob([data], { type: 'text/csv' }) - const url = window.URL.createObjectURL(blob); + const download = (url, connector_name) => { const a = document.createElement('a'); a.setAttribute('hidden', '') a.setAttribute('href', url) - a.setAttribute('download', "Dataset.csv"); + a.setAttribute('download', connector_name); document.body.appendChild(a); a.click(); document.body.removeChild(a); - + } + const deleteConnector = () => { + generateData(1, "delete") + resetAll() } useEffect(() => { - setNoOfDatasetSelector(["", ""]) - setNoOfFileSelector(["", ""]) - getListOfDatasetNames() - }, []) + getDataList("org_names") + if (isEditModeOn && connectorIdForView) { + generateData(0, "view_details") + } + }, [isEditModeOn, connectorIdForView, isDatasetIntegrationListModeOn]) return ( <> {loader ? : ""} - - - {open ? { - setOpen(false); - }} - > - - - } - sx={{ mb: 2 }} - > - {message ? message : ""} - : ""} - - - - - + + + + {open ? + + { + setOpen(false); + }} + > + + + } + // sx={{ mb: 1 }} + > + {message ? message : ""} + + + + : ""} + + + + {!isDatasetIntegrationListModeOn && } + {!isDatasetIntegrationListModeOn && completeData.length > 0 && finalDatasetAfterIntegration?.length > 0 && < Preview temporaryDeletedCards={temporaryDeletedCards} integratedFilePath={integratedFilePath} noOfRecords={noOfRecords} isConditionForConnectorDataForSaveMet={isConditionForConnectorDataForSaveMet} isAllConditionForSaveMet={isAllConditionForSaveMet} isEdited={isEdited} setIsEdited={setIsEdited} generateData={generateData} setIsDatasetIntegrationListModeOn={setIsDatasetIntegrationListModeOn} deleteConnector={deleteConnector} counterForIntegrator={counterForIntegrator} completeData={completeData} isEditModeOn={isEditModeOn} integrateMore={integrateMore} resetAll={resetAll} connectorData={connectorData} downloadDocument={downloadDocument} finalDatasetAfterIntegration={finalDatasetAfterIntegration} />} + {isDatasetIntegrationListModeOn && } ) } -export default DatasetIntegration \ No newline at end of file +export default DatasetIntegration + diff --git a/src/Components/Datasets/IntegrationDatasets/DatasetSelect/DatasetSelect.jsx b/src/Components/Datasets/IntegrationDatasets/DatasetSelect/DatasetSelect.jsx index 919dfbcdb..0d2ea78ed 100644 --- a/src/Components/Datasets/IntegrationDatasets/DatasetSelect/DatasetSelect.jsx +++ b/src/Components/Datasets/IntegrationDatasets/DatasetSelect/DatasetSelect.jsx @@ -11,13 +11,63 @@ import AccordionDetails from '@mui/material/AccordionDetails'; import Typography from '@mui/material/Typography'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import DeleteIcon from '@mui/icons-material/Delete'; -import { Checkbox, FormControlLabel } from '@mui/material'; +import { Checkbox, Fab, FormControlLabel, TextField } from '@mui/material'; +import { CheckLg } from 'react-bootstrap-icons'; +import CardDetail from '../CardDetail/CardDetail'; +import { Button, Affix, Alert } from 'antd'; +import { dateTimeFormat, handleUnwantedSpace, validateInputField } from '../../../../Utils/Common'; +import RegexConstants from '../../../../Constants/RegexConstants'; +import Join from '../Join/Join'; +import leftG from "../../../../Assets/Img/Join type/Color/Left.svg" +import leftB from "../../../../Assets/Img/Join type/Normal state/left.svg" +import rightB from "../../../../Assets/Img/Join type/Normal state/right.svg" +import rightG from "../../../../Assets/Img/Join type/Color/right.svg" +import fullB from "../../../../Assets/Img/Join type/Normal state/outer.svg" +import fullG from "../../../../Assets/Img/Join type/Color/outer.svg" +import innerB from "../../../../Assets/Img/Join type/Normal state/inner.svg" +import innerG from "../../../../Assets/Img/Join type/Color/inner.svg" +import settinggif from "../../../../Assets/Img/setting.gif" +import ArrowBackIcon from "@mui/icons-material/ArrowBack"; + const DatasetSelect = (props) => { - const { setFinalDataNeedToBeGenerated, finalDataNeedToBeGenerated, deleteTable, listOfFilesSelected, handleChangeFileNameSelector, noOfFileSelector, listOfFilesAvailableForSelect, allDatasetNameList, listOfDatasetSelected, handleChangeDatasetNameSelector, noOfDatasetSelector, handleClickSelectDataset, listOfDatsetFileAvailableForColumn } = props + const { setIsAllConditionForSaveMet, temporaryDeletedCards, setTemporaryDeletedCards, connectorTimeData, isEditModeOn, setIsConditionForConnectorDataForSaveMet, isEdited, setIsEdited, setIsEditModeOn, setIsDatasetIntegrationListModeOn, integrateMore, empty, template, setTemplate, counterForIntegrator, completedJoinData, setCompleteJoinData, resetAll, generateData, orgList, joinType, setJoinType, setCompleteData, setConnectorData, connectorData, completeData, setFinalDataNeedToBeGenerated, finalDataNeedToBeGenerated, listOfFilesSelected, allDatasetNameList, listOfDatasetSelected, handleChangeDatasetNameSelector, listOfDatsetFileAvailableForColumn, } = props + const [errorConnectorName, setErrorConnectorName] = useState("") + const [errorConnectorDesc, setErrorConnectorDesc] = useState("") + const [show, setShow] = useState(false) + const [indexShow, setIndex] = useState(-1) + const handleChange = (e) => { + let value = e.target.name + if (value == "name") { + if (e.target.value && connectorData.desc) { + setIsConditionForConnectorDataForSaveMet(true) + } else { + setIsConditionForConnectorDataForSaveMet(false) + + } + setErrorConnectorName("") + validateInputField(e.target.value, RegexConstants.connector_name) + ? setConnectorData({ ...connectorData, [e.target.name]: e.target.value }) + : e.preventDefault(); + } else { + if (e.target.value && connectorData.name) { + setIsConditionForConnectorDataForSaveMet(true) + } else { + setIsConditionForConnectorDataForSaveMet(false) + } + setErrorConnectorDesc("") + validateInputField(e.target.value, RegexConstants.connector_name) + ? setConnectorData({ ...connectorData, [e.target.name]: e.target.value }) + : e.preventDefault(); + } + + } + const [selectAll, setSelectAll] = useState(false) + const [totalCounter, setTotalCounter] = useState(-1) const [selectedColumns, setSelectedColumns] = useState({}) + const [top, setTop] = useState(0); const changeAllSelect = (file) => { - console.log(selectedColumns) + //console.log(selectedColumns) if (selectedColumns[file.name]) { let obj = { ...selectedColumns } delete obj[file.name]; @@ -28,8 +78,17 @@ const DatasetSelect = (props) => { setSelectedColumns({ ...obj }) } } + const [joinTypeArr, setJoinTypeArr] = useState([ + { name: "left", black: leftB, green: leftG }, + { name: "right", black: rightB, green: rightG }, + { name: "inner", black: innerB, green: innerG }, + { name: "outer", black: fullB, green: fullG }, + ]) + const selectThisType = (name) => { + setJoinType(name) + } const handleChangeColumns = (e, file, col) => { - console.log(e.target.checked, file, col) + //console.log(e.target.checked, file, col) let obj = { ...finalDataNeedToBeGenerated } if (obj[file]) { if (e.target.checked && !obj[file].includes(col)) { @@ -51,119 +110,202 @@ const DatasetSelect = (props) => { setFinalDataNeedToBeGenerated({ ...obj }) } + + //after all selection field is filled this func will be triggered when clicked on add + const addNewForm = () => { + let arr = [...completeData] + console.log("template", template, arr) + arr.push(template) + setCompleteData([...arr]) + setTotalCounter((prev) => prev + 1) + setTemplate({ ...empty }) + console.log(arr, "ARR NEW") + + } + + //datasetname no space handler + const handleConnectorNameKeydown = (e) => { + if (e.target.name == "name") { + handleUnwantedSpace(connectorData.name, e); + } else { + handleUnwantedSpace(connectorData.desc, e); + } + }; + const handleMoreDataShow = (index, condition, e) => { + e.stopPropagation() + if (condition) { + setIndex(index) + setShow(true) + } + else { + setIndex(-1) + setShow(false) + } + + } + return ( - - - - Select datasets + + + { + resetAll() + } + } + className={styles.backButtonMainDiv + " backButtonMainDiv"} + > + {" "} +
+ Back +
- - {/* handleClickSelectDataset("dataset")}>+ Add datasets */} - = allDatasetNameList.length ? styles.add_dataset_btn_dis : styles.add_dataset_btn} onClick={() => handleClickSelectDataset("dataset")}>+ Add datasets +
+ + + Dataset integration details + {isEditModeOn && {"Last updated on: " + dateTimeFormat(connectorTimeData.last_updated, true)}} - {noOfDatasetSelector.map((eachDatasetName, i) => { - return - - Dataset name - - - - })} + + + - - Select Files - - - handleClickSelectDataset("file")}>+ Add files - {/* = listOfFilesAvailableForSelect.length ? styles.add_dataset_btn_dis : styles.add_dataset_btn} onClick={() => handleClickSelectDataset("file")}>+ Add files */} + + - - {noOfFileSelector.map((eachFileName, i) => { - return - - File name - - - - })} - - {/* {listOfDatsetFileAvailableForColumn.length > 0 && */} - - - Select Columns + + + + Select datasets for connector + + {counterForIntegrator === completeData.length &&
To choose other files for integration, click on integrate more datasets.
} + - {Object.keys(listOfDatsetFileAvailableForColumn).map((eachDatasetFile, index) => { - return - } - aria-controls="panel1a-content" - id="panel1a-header" - > - {eachDatasetFile.split("/")[eachDatasetFile.split("/").length - 1]} - {/* - deleteTable(eachDatasetFile, index)} /> - */} - - {/* - changeAllSelect(eachDatasetFile)} control={} label={"Select all"} /> - */} - - {listOfDatsetFileAvailableForColumn[eachDatasetFile]?.length > 0 && listOfDatsetFileAvailableForColumn[eachDatasetFile]?.map((eachColumn, index) => { - return handleChangeColumns(e, eachDatasetFile, eachColumn)} />} label={eachColumn} /> - })} - - + + + + + + Organization name * + + + + + + Dataset name * + + + + + + File name * + + + + + + + + +
+ {/* {completeData?.length > 0 && completeData.map((each, index) => { + //console.log(show, indexShow) + if (totalCounter >= index && index < counterForIntegrator) { + return + {index != 0 && handleMoreDataShow(index, false)} onMouseOver={() => handleMoreDataShow(index, true)} style={{ height: `${show && index == indexShow ? "300px" : "50px"}`, overflow: "hidden", width: `${show && index == indexShow ? "700px" : "50px"}`, margin: "auto", backgroundImage: index != indexShow ? `url(${settinggif})` : "none", backgroundRepeat: "no-repeat", backgroundSize: "50px 50px", backgroundPosition: "center", boxShadow: "0 3px 10px #ab840574", }} className={index == indexShow ? styles.hoveredOne : styles.alwaysHave}> + {index == indexShow ? : } + } + {index != 0 && } + {each?.availabeColumns?.length > 0 && } + {index != totalCounter && handleMoreDataShow(index, true)} style={{ border: index == indexShow - 1 && "1.5px solid #C09507" }} class={styles.vl} >} + + } + })} */} + {completeData?.length > 0 && completeData.map((each, index) => { + return + {} + {index < completeData.length - 1 && } + {index < completeData.length - 1 && + handleMoreDataShow(index, true, e)} style={{ display: "flex", justifyContent: "center", alignItems: "center", cursor: !show ? "pointer" : "", height: `${show && index == indexShow ? "350px" : "50px"}`, overflow: "hidden", width: `${show && index == indexShow ? "700px" : "50px"}`, margin: "auto", backgroundRepeat: "no-repeat", backgroundSize: "50px 50px", backgroundPosition: "center", }} className={index == indexShow ? styles.hoveredOne : styles.alwaysHave}> + { + {indexShow != index && } + } + } + {index !== indexShow && index < completeData.length - 1 && +
Joined by
+
+ +
Left column
+
{each?.left_on?.length > 0 ? each?.left_on[0] : "Not selected"}
+
+ +
Right column
+
{each?.right_on?.length > 0 ? each?.right_on[0] : "Not selected"}
+
+ +
Join type
+
{each?.type ? each?.type : "Not selected"}
+
+
+
} + {index !== indexShow && index < completeData.length - 1 && each.left_on?.length <= 0 && + + } + {index < completeData.length - 1 && handleMoreDataShow(index, true, e)} style={{ border: index == indexShow && "1.5px solid #C09507" }} class={styles.vl} >} +
})} + +
- {/* } */} - -
+
) } diff --git a/src/Components/Datasets/IntegrationDatasets/Join/Join.jsx b/src/Components/Datasets/IntegrationDatasets/Join/Join.jsx index 584a3de50..74ecc7e7a 100644 --- a/src/Components/Datasets/IntegrationDatasets/Join/Join.jsx +++ b/src/Components/Datasets/IntegrationDatasets/Join/Join.jsx @@ -6,164 +6,152 @@ import FormControl from '@mui/material/FormControl'; import Select from '@mui/material/Select'; import styles from "../dataset_integration.module.css" import DragHandleIcon from '@mui/icons-material/DragHandle'; -import { Button, CircularProgress } from '@mui/material'; -const Join = (props) => { - const { circleLoad, listOfDatasetSelected, listOfDatsetFileAvailableForColumn, generateData, finalDataNeedToBeGenerated } = props - const [join, setJoin] = useState({}) - const [joinVal1, setJoinVal1] = useState("") - const [joinVal2, setJoinVal2] = useState("") - const [age, setAge] = React.useState(''); +import { CircularProgress } from '@mui/material'; +import { Cpu } from 'react-bootstrap-icons'; +import leftG from "../../../../Assets/Img/Join type/Color/Left.svg" +import leftB from "../../../../Assets/Img/Join type/Normal state/left.svg" +import rightB from "../../../../Assets/Img/Join type/Normal state/right.svg" +import rightG from "../../../../Assets/Img/Join type/Color/right.svg" +import fullB from "../../../../Assets/Img/Join type/Normal state/outer.svg" +import fullG from "../../../../Assets/Img/Join type/Color/outer.svg" +import innerB from "../../../../Assets/Img/Join type/Normal state/inner.svg" +import innerG from "../../../../Assets/Img/Join type/Color/inner.svg" - const [finalJoin, setFinalJoin] = useState({}) - const handleChange = (event, source) => { - console.log(event.target.value) - if (source == "val1") { - setJoinVal1(event.target.value); - } else { - setJoinVal2(event.target.value) - } - if (finalJoin[event.target.value]) { - let obj = { ...finalJoin } - delete obj[event.target.value] - setFinalJoin(obj) - } - let list = [...Object.keys(listOfDatsetFileAvailableForColumn)]; - let join1Obj = list.filter((each, index) => { - return each == event.target.value - }) - let obj = { [event.target.value]: listOfDatsetFileAvailableForColumn[join1Obj[0]] } - setJoin({ ...obj, ...join }) - }; +import smallG from "../../../../Assets/Img/Join type/Color/Tick icon.svg" +import CloseIcon from '@mui/icons-material/Close'; +import { Button } from 'antd'; +const Join = (props) => { + const { handleMoreDataShow, indexShow, file_right, file_left, setCompleteJoinData, right_on, left_on, completedJoinData, type, left, right, index, each, resetAll, joinType, setJoinType, connectorData, setCompleteData, completeData, listOfDatsetFileAvailableForColumn, generateData } = props + const [joinTypeArr, setJoinTypeArr] = useState([ + { name: "left", black: leftB, green: leftG }, + { name: "right", black: rightB, green: rightG }, + { name: "inner", black: innerB, green: innerG }, + { name: "outer", black: fullB, green: fullG }, + ]) const handleChangeJoin = (e, source) => { + let arr = [...completeData] + let obj1 = { ...each } + const { + target: { value }, + } = e; + // On autofill we get a stringified value. + // if (typeof value === 'string') { + // value.split(',') + // } if (source == "join1") { - setFinalJoin({ ...finalJoin, [joinVal1]: e.target.value }) + console.log(value) + obj1["left_on"] = [value] + arr[index] = { ...obj1 } } else { - setFinalJoin({ ...finalJoin, [joinVal2]: e.target.value }) + obj1["right_on"] = [value] + arr[index] = { ...obj1 } } + + setCompleteData([...arr]) + } + + const selectThisType = (name) => { + let arr = [...completeData] + let obj = { ...each } + // let arr1 = [...completedJoinData] + // let obj1 = { ...arr1[index - 1] } + obj["type"] = name + // arr1[index - 1] = { ...obj1 } + // setCompleteJoinData([...arr1]) + // obj["joinTypeWithNextOrBack"] = name + // arr[index - 1] = { ...obj } + arr[index] = obj + setCompleteData([...arr]) + setJoinType(name) } - console.log(listOfDatsetFileAvailableForColumn, "listOfDatsetFileAvailableForColumn") - let arr = Object.keys(finalDataNeedToBeGenerated) - let firstColms = finalDataNeedToBeGenerated[arr[0]] - let secondColms = finalDataNeedToBeGenerated[arr[1]] useEffect(() => { + // console.log(index, "[index]", each) }, []) return ( - + index == indexShow && - + Join + handleMoreDataShow(indexShow, false, e)} className='deleteicon' color='secondary' /> - - - - - - Primary dataset - - - - - - Primary dataset colounm name - - - - + + + + Primary dataset column name + {/* {console.log(each)} */} + + + {/* + */} - + - - - - Primary dataset - handleChangeJoin(e, "join2")} + label="Primary dataset colounm name" + // multiple + > + {completeData[index + 1]?.columnsSelected?.map((eachFile, ind_) => { + if (completeData[index + 1]?.availabeColumns.includes(eachFile)) { + return {eachFile} + } + })} + + - } - })} - - - - - - Primary dataset colounm name - - - - - - - - - {console.log(joinVal1, joinVal2, finalJoin)} - - + {/* + Join type + */} + + { + completeData.length >= 2 && + + + {joinTypeArr.map((eachT, ind) => { + return selectThisType(eachT.name)} className={each.type == eachT.name ? styles.stypeMainBox : styles.typeMainBox}> +
{each.type == eachT.name && ticked}
+ {eachT.name} + {eachT.name} +
+ })} + + + + + + + + +
+ } + ) } diff --git a/src/Components/Datasets/IntegrationDatasets/Preview/Preview.jsx b/src/Components/Datasets/IntegrationDatasets/Preview/Preview.jsx index 5c0cee26e..03a94f802 100644 --- a/src/Components/Datasets/IntegrationDatasets/Preview/Preview.jsx +++ b/src/Components/Datasets/IntegrationDatasets/Preview/Preview.jsx @@ -1,10 +1,12 @@ -import { Button, Stack } from '@mui/material' +import { Stack } from '@mui/material' import React, { useEffect, useState } from 'react' import { Col, Container, Row } from 'react-bootstrap' import styles from "../dataset_integration.module.css" -import downloadIcon from "../../../../Assets/Img/download_btn_white.svg"; +import download_data from "../../../../Assets/Img/download_data.svg"; import { DataGrid } from '@mui/x-data-grid'; import NoDataAvailable from '../../../Dashboard/NoDataAvailable/NoDataAvailable'; +import { Affix, Button } from 'antd'; +import { message, Popconfirm } from 'antd'; function NoResultsOverlay() { @@ -27,16 +29,22 @@ function NoRowsOverlay() { } const Preview = (props) => { - const { finalDatasetAfterIntegration, downloadDocument } = props + const { temporaryDeletedCards, noOfRecords, isConditionForConnectorDataForSaveMet, isAllConditionForSaveMet, connectorData, generateData, setIsDatasetIntegrationListModeOn, deleteConnector, counterForIntegrator, completeData, isEditModeOn, integrateMore, resetAll, generatedConnectorData, finalDatasetAfterIntegration, downloadDocument } = props const [col, setCol] = useState([]) const [row, setRow] = useState([]) - useEffect(() => { - // console.log(finalDatasetAfterIntegration) - + const confirm = (e) => { + // console.log(e); + deleteConnector() + message.success('Connector deleted successfully!'); + }; + const cancel = (e) => { + // console.log(e); + message.error('Connector deletion cancelled!'); + }; + useEffect(() => { if (finalDatasetAfterIntegration.length > 0) { - // console.log(arr) let val = [] for (let key in finalDatasetAfterIntegration[0]) { @@ -45,32 +53,38 @@ const Preview = (props) => { } let rowArr = [] for (let i = 0; i < finalDatasetAfterIntegration.length; i++) { - let obj1 = { "id": i, ...finalDatasetAfterIntegration[i] } - console.log(obj1) + let obj1 + if (finalDatasetAfterIntegration[i]["id"]) { + obj1 = { ...finalDatasetAfterIntegration[i] } + //console.log(obj1) + } else { + //console.log(obj1) + obj1 = { "id": i, ...finalDatasetAfterIntegration[i] } + } rowArr.push(obj1) } - console.log(val, rowArr) + //console.log(val, rowArr) setCol([...val]) setRow([...rowArr]) } - }, [finalDatasetAfterIntegration]) + }, [finalDatasetAfterIntegration,]) return ( - - - - Preview + + + + Preview - { } - + -
+
+ { } {
- - - + {/*
*/} + {/* */} + +
+
+ + + + + {/* */} + {/* */} + + {/* */} + {/* */} + {console.log(isConditionForConnectorDataForSaveMet, isAllConditionForSaveMet, "isAllConditionForSaveMet ")} + {finalDatasetAfterIntegration.length > 0 && isAllConditionForSaveMet && isConditionForConnectorDataForSaveMet && completeData.length != 1 && + } + {/* */} + {/* */} + {true && + + + + + } -
+
) } diff --git a/src/Components/Datasets/IntegrationDatasets/dataset_integration.module.css b/src/Components/Datasets/IntegrationDatasets/dataset_integration.module.css index e2b381205..2bfd73ce0 100644 --- a/src/Components/Datasets/IntegrationDatasets/dataset_integration.module.css +++ b/src/Components/Datasets/IntegrationDatasets/dataset_integration.module.css @@ -1,16 +1,22 @@ .select_dataset_logo { text-align: left; - font-family: 'Open Sans'; - font-style: normal; - font-weight: 700; - font-size: 20px; - line-height: 138.69%; - /* identical to box height, or 28px */ /* headings */ color: #3D4A52; width: 100%; + /* margin: 10px 0px; */ + /* padding: 50px 0px 0px 0px; */ + + font-weight: 600; + font-size: 32px; + line-height: 40px; + + + color: #000000; + font-family: 'Inter', sans-serif; + font-family: 'Montserrat', sans-serif; + font-style: normal; margin-bottom: 20px; } @@ -59,24 +65,75 @@ } .generate_btn_parent_col { - text-align: right; - margin-top: 30px; + text-align: left; + /* margin-top: 30px; */ } .generate_data_btn { - width: 200px !important; - height: 42px !important; + /* width: 20px !important; */ + transition: all 0.3s; + border-radius: 8px; + border: 1px solid #C09507 !important; + text-transform: none !important; background: #C09507 !important; color: white !important; + /* outline-width: 8px; + outline-offset: -8px; */ + height: 48px; + /* width: 100% !important; */ + text-align: center; +} + +.generate_data_btn:hover { + background: #b7931bd5 !important; +} + +.generate_data_btn:hover .download_btn { + height: 68px !important; + width: 68px !important; +} + +.delete_btn { + /* width: 20px !important; */ + border-radius: 8px; + border: 1px solid #FF5630 !important; + color: #FF5630 !important; + text-transform: none !important; + height: 48px; + /* width: 100%; */ +} + +.delete_btn:hover { + background-color: #FF5630 !important; + color: white !important; +} + +.save_btn { + /* width: 20px !important; */ + border-radius: 8px; + background-color: #C09507 !important; + border: 1px solid #C09507 !important; + color: white !important; text-transform: none !important; - padding: 11.5px 23px; + height: 48px; + /* width: 171px; */ +} +.save_btn:hover { + background: #b7931bd5 !important; + color: white !important; +} + +.heightwidth { + width: 250px !important; + height: 182px !important; } .download_btn { - height: 16px !important; - width: 16px !important; - margin-right: 14px !important; + transition: all 0.3s ease-in-out; + height: 64px !important; + width: 64px !important; + /* margin-right: 14px !important; */ } .table_head { @@ -123,8 +180,7 @@ } .generate_data_btn_dis { - font-family: 'Open Sans'; - font-style: normal; + font-weight: 600; font-size: 14px; line-height: 19px; @@ -133,11 +189,293 @@ background-color: #9aa7b5 !important; cursor: auto !important; + border-radius: 8px; + height: 48px; + color: white !important; + text-transform: none !important; +} - width: 200px !important; - height: 42px !important; +.select_file_main_col { + display: flex; + justify-content: space-between; + align-items: center; +} + +.already_been_selected {} + +.disabled_option { + display: flex; + justify-content: space-between; +} + +.button { + /* background-color: #C09507 !important; */ + height: 48px !important; + width: 171px !important; + color: #C09507 !important; + border: 1px solid #C09507 !important; +} +.button:hover { + background-color: #C09507 !important; color: white !important; - text-transform: none !important; - padding: 11.5px 23px; + outline-width: 8px; + outline-offset: -8px; +} + +.selectors { + margin: 20px 0px; + display: flex; + align-items: center; + justify-content: space-evenly; + background-color: white; +} + +.typeMainBox { + border: 1px solid; + width: 108px; + height: 108px; + background: #FFFFFF; + border-radius: 6px; + display: inline-block; + cursor: pointer; + text-transform: capitalize; + margin: 12px; +} + +.stypeMainBox { + border: 1px solid #C09507; + text-transform: capitalize; + width: 108px; + height: 108px; + background: #FFFFFF; + border-radius: 6px; + display: inline-block; + cursor: pointer; + box-shadow: 5px 10px 1px 0.5 #C09507; + /* background-color: #f0cd59b9; */ + margin: 12px; +} + +.typeMainBox:hover { + /* border: 2px solid #C09507; */ + background-color: #f0cd59b9; +} + +.selectedTypeMainBox { + text-align: right; + height: 20px; +} + +.selectedTypeImage { + text-align: center; + height: 55px; + width: 75px; +} + +.labelTypeJoin {} + +.flexForBtn { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + +.cancelBtn { + font-weight: 700; + font-size: 15px; + line-height: 26px; + /* identical to box height, or 173% */ + + + /* Primary/Main */ + box-shadow: none !important; + color: #C09507; + border: none !important; + background-color: transparent !important; +} + +.cancelBtn:hover { + color: #C09507 !important; +} + +.data_before_download div:nth-child(1) { + font-weight: 400; + font-size: 16px; + line-height: 24px; + /* identical to box height, or 150% */ + + + color: #000000; +} + +.data_before_download div:nth-child(2) { + font-weight: 600; +} + +.vl { + border-left: 1px dashed #C09507; + height: 54px; + display: inline-block; +} + +.alwaysHave { + transition: all 0.3s; + display: block; + height: 50px; + border: 0.5px solid black !important; + border-radius: 50%; +} + +.hoveredOne { + transition: all 0.3s; + display: block; + height: 50px; + border: 0.5px solid black !important; + border-radius: 8px; +} + +.settingGif { + height: 0px; + width: 0px; + /* transition: all 0.6s; */ + -webkit-animation: slide 3s linear infinite; + -moz-animation: slide 3s linear infinite; + animation: slide 3s linear infinite; +} + + +@-webkit-keyframes slide { + 0% { + height: 30px; + width: 30px; + } + + 50% { + height: 70px; + width: 70px; + } + + 100% { + height: 30px; + width: 30px; + } +} + + + +@-moz-keyframes slide { + 0% { + height: 30px; + width: 30px; + } + + 50% { + height: 70px; + width: 70px; + } + + 100% { + height: 30px; + width: 30px; + } +} + +@keyframes slide { + 0% { + height: 30px; + width: 30px; + } + + 50% { + height: 70px; + width: 70px; + } + + 100% { + height: 30px; + width: 30px; + } +} + +.alwaysHave:hover { + transition: all 0.3s; + /* height: 300px; */ + border: 1px solid black !important; +} + +.backButtonMainDiv { + display: flex; + /* margin-left: 290px; */ + /* justify-content: space-between; */ + color: #3491ee !important; + align-items: center; + cursor: pointer; +} + +.backButtonMainDiv .MuiSvgIcon-root { + color: #3491ee !important +} + +.backArrowIcon { + width: 16px; + height: 16px; + margin-right: 14px; + cursor: pointer; +} + +.backButtonText { + font-size: 14px; + font-weight: 400; + cursor: pointer; +} + +/* .hideData { + transition: all 2s; + height: 0px; + visibility: visible; + display: none; + width: 0px; +} */ + +/* .showMoreData { + margin: auto; + transition: all 2s; + display: block; + border: 1px solid black; + border-radius: 16px; + height: 300px; + width: 400px; + visibility: visible; +} */ + +/* .vl:hover .showMoreData { + height: 300px; + width: 400px; + display: block; +} */ +.detail_joins div:nth-child(1) { + /* font-family: Montserrat; */ + font-style: normal; + font-weight: 400; + font-size: 16px; + line-height: 24px; + text-transform: capitalize !important; +} + +.detail_joins div:nth-child(2) { + /* font-family: 'Montserrat'; */ + font-style: normal; + font-weight: 700; + font-size: 16px; + line-height: 24px; + text-transform: capitalize !important; +} + +.subTime { + all: unset !important; + font-weight: 400 !important; + margin-left: 20px !important; + font-size: 14px !important; } \ No newline at end of file diff --git a/src/Components/IntegrationConnectors/ConnectorCard.jsx b/src/Components/IntegrationConnectors/ConnectorCard.jsx new file mode 100644 index 000000000..b7da1cb79 --- /dev/null +++ b/src/Components/IntegrationConnectors/ConnectorCard.jsx @@ -0,0 +1,117 @@ +import React from "react"; +import Card from "@mui/material/Card"; +import CardHeader from "@mui/material/CardHeader"; +import CardContent from "@mui/material/CardContent"; +import Avatar from "@mui/material/Avatar"; +import Row from "react-bootstrap/Row"; +import Col from "react-bootstrap/Col"; +import { useHistory } from "react-router-dom"; +import { dateTimeFormat } from "../../Utils/Common"; + +const useStyles = { + marginrowtop: { "margin-top": "30px" }, + cardDataHeading: { + "font-family": "Open Sans", + "font-weight": "400", + "font-size": "16px", + color: "#3D4A52", + }, + cardData: { + "font-family": "Open Sans", + "font-weight": "600", + "font-size": "16px", + color: "#3D4A52", + "margin-top": "10px" + }, + cardDataHead: { + "color": "#c09507", + "text-transform": "capitalize", + 'font-family': 'Open Sans', + "font-weight": "600", + "font-size": "24px", + "font-style": "normal", + "width": "272px", + "height": "25px", + "line-height": "19px", + "text-align": "left", + "margin-bottom": "20px", + "overflow": "hidden", + "textOverflow": "ellipsis", + "white-space": "nowrap", + }, + cardDataUser: { + "font-family": "Open Sans", + "font-weight": "400", + "font-size": "14px", + "font-style": "normal", + color: "#3D4A52", + "width": "314px", + "height": "19px", + "line-height": "19px", + "text-align": "left", + }, + header: { + height: "4px", + "text-align": "left", + "font-family": "Open Sans", + "font-style": "normal", + "font-weight": 400, + "font-size": "14px", + "line-height": "19px", + "color": "#9BA0A7", + + }, +} + +export default function ConnectorCard(props) { + const { click } = props + const history = useHistory(); + return ( + + + } + title={"Last Updated on: " + dateTimeFormat(props.firsttext, true)} + style={useStyles.header} + /> + + + + {props.secondtext} + + + + + Used Datasets +
+
+ {props.useddataset > 9 ? props.useddataset : "0" + props.useddataset} +
+ + + Providers +
+
+ {props.providers > 9 ? props.providers : "0" + props.providers} +
+ +
+
+
+ ); +} diff --git a/src/Components/IntegrationConnectors/ConnectorsList.jsx b/src/Components/IntegrationConnectors/ConnectorsList.jsx new file mode 100644 index 000000000..569cd79d2 --- /dev/null +++ b/src/Components/IntegrationConnectors/ConnectorsList.jsx @@ -0,0 +1,201 @@ +import React from "react"; +import { useState, useEffect } from "react"; +import { Row, Col } from "react-bootstrap"; +import ConnectorCard from "../IntegrationConnectors/ConnectorCard" +import { Button } from "@mui/material"; +import THEME_COLORS from "../../Constants/ColorConstants"; +import Loader from "../Loader/Loader"; +import HTTPService from "../../Services/HTTPService"; +import { GetErrorHandlingRoute, getUserLocal } from "../../Utils/Common"; +import { useHistory } from "react-router-dom"; +import UrlConstant from "../../Constants/UrlConstants"; +import ViewModuleIcon from '@mui/icons-material/ViewModule'; +import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted'; +import NoDataAvailable from "../Dashboard/NoDataAvailable/NoDataAvailable"; + +export default function ConnectorsList(props) { + const { setConnectorTimeData, setIsEditModeOn, setConnectorIdForView, setIsDatasetIntegrationListModeOn } = props + const [isLoader, setIsLoader] = useState(false); + const [isShowLoadMoreButton, setisShowLoadMoreButton] = useState(false) + const [connectorList, setConnectorList] = useState([]); + const [connectorUrl, setConnectorUrl] = useState(""); + const [gridView, setGridView] = useState(true); //change of list and grid view state + + const history = useHistory() + const useStyles = { + marginrowtoptab50px: { "margin-top": "50px" }, + marginrowtop: { "margin-top": "20px" }, + background: { + "margin-left": "120px", + "margin-right": "120px", + background: "#FCFCFC", + + }, + marginrowtop10px: { "margin-top": "30px" }, + marginrowtop50: { "margin-top": "50px" }, + addButton: { + "border-radius": "8px", + "background": "#c09507", + "width": "176px", + "height": "48px", + "color": "#FFFFFF", + "font-family": "Open Sans", + "font-style": "normal", + "font-weight": "700", + "font-size": "14px", + "align-item": "right", + "border-color": THEME_COLORS.THEME_COLOR, + "text-transform": "inherit" + }, + cardtext: { + color: "#A3B0B8", + "margin-top": "30px", + "font-size": "14px", + 'font-family': 'Open Sans', + 'font-style': 'normal', + 'font-weight': 400, + 'font-size': '14px', + 'line-height': '19px', + 'text-align': 'center', + }, + } + + const getListOfConnectors = () => { + setIsLoader(true); + HTTPService( + "GET", + UrlConstant.base_url + UrlConstant.list_of_connectors + "?user=" + getUserLocal(), + "", + false, + true + ) + .then((response) => { + setIsLoader(false); + console.log("connectors list", response.data); + if (response.data.next == null) { + setisShowLoadMoreButton(false); + } else { + setConnectorUrl(response.data.next); + setisShowLoadMoreButton(true); + } + setConnectorList(response.data.results); + }) + .catch((e) => { + setIsLoader(false); + history.push(GetErrorHandlingRoute(e)); + }); + } + + //list of connectors will display when loadmore button clicks + const connectorsListOnLoadMore = () => { + setIsLoader(true); + HTTPService( + "GET", + connectorUrl, + "", + false, + true + ).then((response) => { + setIsLoader(false); + if (response.data.next == null) { + setisShowLoadMoreButton(false) + } else { + setisShowLoadMoreButton(true); + setConnectorUrl(response.data.next); + } + let initialList = connectorList; + let totalListOfConnectors = [...initialList, ...response.data.results]; + setConnectorList(totalListOfConnectors); + }).catch((e) => { + setIsLoader(false); + history.push(GetErrorHandlingRoute(e)); + }) + } + + + useEffect(() => { + getListOfConnectors() + }, []) + + + return ( +
+ {isLoader ? : ""} + + + + {"List of Connectors"} + + + + + + + + + new + + + {connectorList.length > 0 ? <> + + {connectorList.map((list, index) => ( + + { + setConnectorTimeData({ last_updated: list.updated_at }) + setConnectorIdForView(list?.id ? list?.id : "") + setIsDatasetIntegrationListModeOn(false) + setIsEditModeOn(true) + }} + firsttext={list.updated_at} + secondtext={list?.name} + useddataset={list?.dataset_count} + providers={list?.providers_count} + index={index} + > + + ))} + + + + {isShowLoadMoreButton ? ( + + + + ) : ( + <> + )} + + : <> + {/* If there is no connectors available this component will render */} + + + + + + } +
+ ) +} + diff --git a/src/Components/Navbar/GuestUserNavbar.js b/src/Components/Navbar/GuestUserNavbar.js index ad6b9604b..1ae4753ff 100644 --- a/src/Components/Navbar/GuestUserNavbar.js +++ b/src/Components/Navbar/GuestUserNavbar.js @@ -12,9 +12,11 @@ import Farmstack from "../../Assets/Img/farmstack.jpg"; import Toolbar from "@mui/material/Toolbar"; const GuestUserNavBar = (props) => { + console.log("navguest") const [screenlabels, setscreenlabels] = useState(labels["en"]); const [isLoader, setIsLoader] = useState(false); const [phoneNumber, setPhoneNumber] = useState(null); + const [isadminOnboarded, setIsadminOnboarded] = useState(false); useEffect(() => { HTTPService( @@ -25,6 +27,7 @@ const GuestUserNavBar = (props) => { false ) .then((response) => { + console.log(response) setIsLoader(false); if ( response.data.organization && @@ -32,6 +35,11 @@ const GuestUserNavBar = (props) => { ) { setPhoneNumber(response.data.organization.phone_number); } + if(response?.data?.organization) { + console.log(response?.data?.organization) + setIsadminOnboarded(true) + } + }) .catch((e) => { setIsLoader(false); @@ -154,6 +162,8 @@ const GuestUserNavBar = (props) => { */} + {isadminOnboarded ? + <> {   {"Register"} - + : "" } + { />   {screenlabels.navbar.datasets} - + new new -   {screenlabels.navbar.integration} +   {screenlabels.navbar.connectors} {/* {   {screenlabels.navbar.connectors} */} {!isLoggedInUserCoSteward() ? - - new - new -   {screenlabels.navbar.Support} - : <> } + + new + new +   {screenlabels.navbar.Support} + : <>} { />   {screenlabels.navbar.datasets} - + new new -   {screenlabels.navbar.integration} +   {screenlabels.navbar.connectors} - {/* + {/* - ); } diff --git a/src/Views/Participants/AddParticipants.js b/src/Views/Participants/AddParticipants.js index d84774428..3d616380b 100644 --- a/src/Views/Participants/AddParticipants.js +++ b/src/Views/Participants/AddParticipants.js @@ -264,7 +264,7 @@ function AddParticipants(props) { orginsationemail && !isorganisationemailerror && countryvalue && - mobileNumberMinimunLengthCheck(contactnumber) && + mobileNumberMinimunLengthCheck(contactnumber) && websitelink && !iswebsitelinkrerror && organisationaddress && diff --git a/src/Views/Participants/EditParticipants.js b/src/Views/Participants/EditParticipants.js index cc5fbb3bb..b1b410aa0 100644 --- a/src/Views/Participants/EditParticipants.js +++ b/src/Views/Participants/EditParticipants.js @@ -16,6 +16,7 @@ import Loader from "../../Components/Loader/Loader"; import { GetErrorHandlingRoute, GetErrorKey, + mobileNumberMinimunLengthCheck, stringMinimumLengthCheck, } from "../../Utils/Common"; const useStyles = { @@ -314,7 +315,7 @@ function EditParticipants(props) { orginsationemail && !isorganisationemailerror && countryvalue && - contactnumber.length == 15 && + mobileNumberMinimunLengthCheck(contactnumber) && websitelink && !iswebsitelinkrerror && organisationaddress && diff --git a/src/Views/Settings/ParticipantSettings/ParticipantOrganisationSettings/ParticipantOrganisationSetting.js b/src/Views/Settings/ParticipantSettings/ParticipantOrganisationSettings/ParticipantOrganisationSetting.js index 85e50e54f..e77beaa7d 100644 --- a/src/Views/Settings/ParticipantSettings/ParticipantOrganisationSettings/ParticipantOrganisationSetting.js +++ b/src/Views/Settings/ParticipantSettings/ParticipantOrganisationSettings/ParticipantOrganisationSetting.js @@ -475,7 +475,7 @@ export default function ParticipantOrganisationSetting(props) { console.log(e.target.value); if (e.target.value > 10) e.target.value = e.target.value.substring(0, 10); var pincode = e.target.value; - if (pincode.length > 0) { + if (pincode.length >= 5) { setispincodeerror(false); setOrgpincodebtn(true); // setOrgnextbutton(true); diff --git a/src/Views/Settings/Settings/Settings.js b/src/Views/Settings/Settings/Settings.js index b0f20ae28..144589755 100644 --- a/src/Views/Settings/Settings/Settings.js +++ b/src/Views/Settings/Settings/Settings.js @@ -23,7 +23,7 @@ import OrganisationSetting from "../organisation/OrganisationSetting"; import { useParams } from "react-router-dom"; import PolicySettings from "../PolicySettings/PolicySettings"; import BrandingSetting from "../branding/BrandingSetting"; -import HandleSessionTimeout, { isLoggedInUserCoSteward } from "../../../Utils/Common"; +import HandleSessionTimeout, { isLoggedInUserAdmin, isLoggedInUserCoSteward } from "../../../Utils/Common"; import Loader from "../../../Components/Loader/Loader"; import { GetErrorHandlingRoute } from "../../../Utils/Common"; import DepartmentSettingsCard from "../ParticipantSettings/DepartmentSettingsCard"; @@ -31,6 +31,7 @@ import ProjectListing from "../ParticipantSettings/Project/ProjectListing"; import DepartmentListing from "../Department/DepartmentListing"; import AdminCategorySetupAndEdit from "../../../Components/Catergories/AdminCategorySetupAndEdit"; import AddingCategory from "../../../Components/Catergories/AddingCategory"; +import StandardizationInOnbord from "../../../Components/Standardization/StandardizationInOnbording"; const useStyles = { btncolor: { @@ -288,10 +289,15 @@ function Settings(props) { : "" } {!isLoggedInUserCoSteward() ? : "" } - - {!isLoggedInUserCoSteward() ? - : " "} + : " "} + { + isLoggedInUserAdmin() ? + + : "" + } + {/* + // */}
@@ -390,8 +396,8 @@ function Settings(props) { {/* */} - - + {/* + */} {/* My departments @@ -428,12 +434,13 @@ function Settings(props) { ))} */} + {/* */} + + - - - - + {/* */} +
diff --git a/src/Views/Settings/organisation/OrganisationSetting.js b/src/Views/Settings/organisation/OrganisationSetting.js index 22f8f8def..3d3c94465 100644 --- a/src/Views/Settings/organisation/OrganisationSetting.js +++ b/src/Views/Settings/organisation/OrganisationSetting.js @@ -459,7 +459,7 @@ export default function OrganisationSetting(props) { console.log(e.target.value); if (e.target.value > 10) e.target.value = e.target.value.substring(0, 10); var pincode = e.target.value; - if (pincode.length > 0) { + if (pincode.length >= 5) { setispincodeerror(false); setOrgpincodebtn(true); // setOrgnextbutton(true);