Skip to content

Commit

Permalink
Handling Errors like today
Browse files Browse the repository at this point in the history
  • Loading branch information
KR-Ravindra committed Oct 28, 2023
1 parent 867f04a commit 6ba5d2a
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/api/keyword.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async function keywordList(payload) {
return final_response;
} catch (error) {
console.error("Error fetching scraper text:", error);
window.location.reload();
return [];
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/api/multiAlgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ async function multialgoComparision(payload) {
.then(data => {
console.log('API response:', data);
final_response = data

return data
})
return final_response;
} catch (error) {
console.error("Error fetching scraper text:", error);
window.location.reload();
return [];
}
}
Expand Down
1 change: 1 addition & 0 deletions src/api/recommendation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async function RecommendationList(payload) {
return final_response;
} catch (error) {
console.error("Error fetching scraper text:", error);
window.location.reload();
return [];
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/api/scraperText.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
.then(data => {
console.log('API response:', data);
final_response = data
if (data == null || data.length == 0) {
window.location.reload();
}
return data
})
return final_response;
Expand Down
96 changes: 79 additions & 17 deletions src/components/homePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import WordCloud from "./wordCloud";

function HomePage() {
const [urlInput, setUrlInput] = useState("");
const [selectedAlgorithm, setSelectedAlgorithm] = useState("rabin_karp");
const [selectedAlgorithm, setSelectedAlgorithm] = useState("suffix_array");
const [loading, setLoading] = useState(false);
const [scraperData, setScraperData] = useState("");
const [keywordListData, setKeywordListData] = useState("");
Expand All @@ -26,6 +26,7 @@ function HomePage() {
const [scrollPosition, setScrollPosition] = useState(0);
const [scrollUp, setScrollUp] = useState(false);
const [resetScroll, setResetScroll] = useState(false);
const [started, setStarted] = useState(false);

useEffect(() => {
const container = document.getElementById("pdf-container");
Expand Down Expand Up @@ -65,6 +66,7 @@ function HomePage() {
};

const handleSubmit = () => {
setStarted(true);
setScraperData("");
setKeywordListData("");
setMultialgo("");
Expand Down Expand Up @@ -106,7 +108,19 @@ function HomePage() {
const keywordListData = keywordList(payload);

keywordListData
.then((response) => setKeywordListData(response))
.then((response) => {
setKeywordListData(response)

const multialgoComparision = MultiAlgoComparision(payload);
multialgoComparision
.then((response) => setMultialgo(response))
.catch((error) => {
console.error("API error:", error);
})
.finally(() => {
setLoading(false);
});
})
.catch((error) => {
console.error("API error:", error);
})
Expand All @@ -123,15 +137,7 @@ function HomePage() {
console.log("Finalised");
});

const multialgoComparision = MultiAlgoComparision(payload);
multialgoComparision
.then((response) => setMultialgo(response))
.catch((error) => {
console.error("API error:", error);
})
.finally(() => {
setLoading(false);
});


const urlAnalyzerData = AnalyzerList(payload);
urlAnalyzerData
Expand Down Expand Up @@ -205,10 +211,47 @@ function HomePage() {
analyzerData={analyzerData}
/>
)}


{ started && !keywordListData && (

<div className="center">
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
</div>

)}

{scraperData && keywordListData && (
<KeywordListFrame keywordListData={keywordListData} />
)}


{ started && !recommendationListData && (

<div className="center">
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
</div>

)}

{scraperData && keywordListData && recommendationListData && (
<div
style={{
Expand All @@ -226,17 +269,18 @@ function HomePage() {
</h4>
</div>
)}
{ scraperData && keywordListData && recommendationListData && analyzerData && (
<div style={{ display: "flex", flexDirection: "row", width: "90%" }}>
<div style={{ width: "45%", minHeight: "60vw", maxHeigh: "60vw" }}>
{scraperData && keywordListData && recommendationListData && (

<TableComponent recommendationListData={recommendationListData} />
)}

</div>
<div style={{ width: "55%" }}>
<div style={{ maxHeight: "40vw", width: "100%", overflow: "auto" }}>
{scraperData && analyzerData && recommendationListData && (

<InsightTable analyzerData={analyzerData} />
)}

</div>
<div
style={{
Expand All @@ -247,12 +291,30 @@ function HomePage() {
marginTop: "1%",
}}
>
{scraperData && analyzerData && recommendationListData && (

<WordCloud analyzerData={analyzerData} />
)}

</div>
</div>
</div>
)}
{ started && !keywordListData && !multialgo && (

<div className="center">
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
<div className="wave"></div>
</div>

)}

{scraperData &&
keywordListData &&
multialgo &&
Expand Down

0 comments on commit 6ba5d2a

Please sign in to comment.