diff --git a/src/api/analyzer.js b/src/api/analyzer.js new file mode 100644 index 0000000..3ec70c5 --- /dev/null +++ b/src/api/analyzer.js @@ -0,0 +1,27 @@ +async function AnalyzerList(payload) { + let final_response + try { + const response = await fetch('http://34.105.100.197/api/v1/analyzer/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(payload), + }) + .then((response) => { + if (response.status==200) { + return response.json(); + } + }) + .then(data => { + console.log('API response:', data); + final_response = data + return data + }) + return final_response; + } catch (error) { + console.error("Error fetching scraper text:", error); + return []; + } + } + export default AnalyzerList; \ No newline at end of file diff --git a/src/components/homePage/algoComparision.js b/src/components/homePage/algoComparision.js index 7635469..773b026 100644 --- a/src/components/homePage/algoComparision.js +++ b/src/components/homePage/algoComparision.js @@ -103,7 +103,7 @@ const AlgoComparision = ({ multialgo }) => { // const name = algoData[context.dataIndex].algoName; // return `${label}: ${name}`; return `${label}` - + }, }, }, @@ -111,7 +111,7 @@ const AlgoComparision = ({ multialgo }) => { }; - return ; + return ; }; export default AlgoComparision; diff --git a/src/components/homePage/inSight.js b/src/components/homePage/inSight.js new file mode 100644 index 0000000..f0d2a2c --- /dev/null +++ b/src/components/homePage/inSight.js @@ -0,0 +1,64 @@ +import * as React from 'react'; +import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Paper, styled } from '@mui/material'; + +const StyledTableCell = styled(TableCell)(({ theme }) => ({ + backgroundColor: '#FABB2E', + color: theme.palette.common.black, + padding: '8px', + fontWeight: 'bold', + marginRight: '3px', +})); + +const StyledTableRow = styled(TableRow)(({ theme }) => ({ + '&:nth-of-type(odd)': { + backgroundColor: theme.palette.action.hover, + padding: '8px', + }, + // hide last border + '&:last-child td, &:last-child th': { + border: 0, + }, +})); + +const StickyTableHead = styled(TableHead)({ + position: 'sticky', + top: 0, + zIndex: 1, + backgroundColor: '#FABB2E', +}); + +const TableWrapper = styled('div')({ + overflowY: 'auto', + maxHeight: '43%', + marginRight:'10%', + marginTop:'5%', + marginLeft: '10%' +}) + +export default function InsightTable({ analyzerData }) { + console.log('analyzerData', analyzerData); + + return ( + + + + + + Insights + + + + {analyzerData && analyzerData.pages.map((page, pageIndex) => ( + // Create a new row for each warning + page.warnings.map((warning, warningIndex) => ( + + {warning}  + + )) + ))} + +
+
+
+ ); +} diff --git a/src/components/homePage/index.js b/src/components/homePage/index.js index 1d60ade..7b576ef 100644 --- a/src/components/homePage/index.js +++ b/src/components/homePage/index.js @@ -8,8 +8,10 @@ import MultiAlgoComparision from "../../api/multiAlgo"; import keywordList from "../../api/keyword"; import KeywordListFrame from './keywordListFrame'; import AlgoComparision from './algoComparision'; -import TableComponent from './tableComponent'; +import TableComponent from './recommendationTableComponent'; import RecommendationList from "../../api/recommendation"; +import AnalyzerList from "../../api/analyzer" +import InsightTable from './inSight' function HomePage() { const [urlInput, setUrlInput] = useState(""); @@ -19,6 +21,7 @@ function HomePage() { const [keywordListData, setKeywordListData] = useState(""); const [multialgo, setMultialgo] = useState(""); const [recommendationListData, setRecommendationListData]=useState('') + const [analyzerData, setAnalyzerData]= useState(""); const [scrollPosition, setScrollPosition] = useState(0); const [scrollUp, setScrollUp] = useState(false); const [resetScroll, setResetScroll] = useState(false); @@ -44,6 +47,7 @@ function HomePage() { const handleUrlChange = (event) => { const inputValue = event.target.value; + // if(!inputValue)return false // const urlRegex = /^(ftp|http|https):\/\/[^ "]+$/; @@ -58,11 +62,11 @@ function HomePage() { setSelectedAlgorithm(event.target.value); }; - const handleDownload = () => { - // const element = document.getElementById('pdf-container'); - // html2pdf(element); - window.print(); - }; + // const handleDownload = () => { + // // const element = document.getElementById('pdf-container'); + // // html2pdf(element); + // window.print(); + // }; const handleScrollUp = () => { setScrollUp(true); @@ -124,6 +128,15 @@ function HomePage() { setLoading(false); }); + const urlAnalyzerData=AnalyzerList(payload) + urlAnalyzerData.then((response) => + setAnalyzerData(response)) + .catch(error => { + console.error('API error:', error); + }) + .finally(() => { + setLoading(false); + }); }; @@ -172,16 +185,22 @@ function HomePage() { )} - {scraperData && } - {scraperData&&keywordListData&& } + {scraperData && } + {scraperData && keywordListData&& }
-
- {keywordListData&&recommendationListData && } -
-
- {multialgo && } +
+ {scraperData && keywordListData&&recommendationListData && }
+
+
+ {scraperData && keywordListData && multialgo && } +
+
+ {scraperData && analyzerData && } +
+
+ {/*