diff --git a/src/App.js b/src/App.js index 32c20bd..b41d4a8 100644 --- a/src/App.js +++ b/src/App.js @@ -1,19 +1,23 @@ import logo from "./logo.svg"; import "./App.css"; - +import { useState, useEffect } from "react"; import Search from "./Components/Layout/Search/Search"; import Filter from "./Components/Layout/Filter/Filter"; import ComplainceFilter from "./Components/Layout/Filter/ComplainceFilter"; import Results from "./Components/Layout/Results/Results"; -import { Fragment, useState, useEffect } from "react"; +import AppliedFilters from "./Components/Layout/AppliedFilters/AppliedFilters"; +import IddrsImg from "./Static/Imgs/IDDRS.png" import axios from "axios"; import FeaturedQuestions from "./Components/Layout/FeaturedQuestions/FeaturedQuestions"; import WordCloud_ from "./Components/Layout/WordCloud_/WordCloud_"; import Stack from "react-bootstrap/esm/Stack"; import Container from "react-bootstrap/esm/Container"; +import Image from 'react-bootstrap/Image'; function App() { const [data, setData] = useState(""); + const [phrase, setPhrase] = useState(""); + const [showResults, setShowResults] = useState(false); const [results, setResults] = useState([]); const [filteredResults, setFilteredResults] = useState([]); const [filtersComplaince, setFiltersComplaince] = useState([]); @@ -32,9 +36,11 @@ function App() { event.preventDefault(); // Send the input value to Django axios - .post("http://localhost:8000/get_input/", { data }) + .post("http://localhost:8000/client_api/get_input/", { data }) .then((response) => { + setPhrase(data['phrase']) setResults(response.data.results); + setShowResults(true) setFilteredResults(response.data.results); }) .catch((error) => { @@ -45,8 +51,9 @@ function App() { const handleSubmit_ = (value) => { // Send the input value to Django axios - .post("http://localhost:8000/get_input/", { data: { phrase: value } }) + .post("http://localhost:8000/client_api/get_input/", { data: { phrase: value } }) .then((response) => { + setShowResults(true); setResults(response.data.results); setFilteredResults(response.data.results); }) @@ -106,21 +113,31 @@ function App() { }; return ( - -
- - - +
+ + IDDRS + + {showResults && } + {showResults && ( - + )} - - - - - -
- + {filtersStandards.length > 0 && } + + {showResults && ( + + )} + + + + + +
+
); } diff --git a/src/AppContext.js b/src/AppContext.js new file mode 100644 index 0000000..6bff804 --- /dev/null +++ b/src/AppContext.js @@ -0,0 +1,5 @@ +import React from "react"; + +const AppContext = React.createContext(); + +export default AppContext; \ No newline at end of file diff --git a/src/Components/Layout/AppliedFilters/AppliedFilters.js b/src/Components/Layout/AppliedFilters/AppliedFilters.js new file mode 100644 index 0000000..a216e98 --- /dev/null +++ b/src/Components/Layout/AppliedFilters/AppliedFilters.js @@ -0,0 +1,25 @@ +import React from "react"; +import Stack from "react-bootstrap/esm/Stack"; +import Accordion from "react-bootstrap/Accordion"; +const AppliedFilters = (props) => { + return ( +
+ + +
The following filter/s are applied:
+ + + {props.standards.map((standard, index) => ( +
+ {standard} +
+ ))} +
+
+
+
+
+ ); +}; + +export default AppliedFilters; diff --git a/src/Components/Layout/FeaturedQuestions/FeaturedQuestions.js b/src/Components/Layout/FeaturedQuestions/FeaturedQuestions.js index 4b170ec..187f831 100644 --- a/src/Components/Layout/FeaturedQuestions/FeaturedQuestions.js +++ b/src/Components/Layout/FeaturedQuestions/FeaturedQuestions.js @@ -1,5 +1,4 @@ import React, { useState } from "react"; -import Container from "react-bootstrap/esm/Container"; import Stack from "react-bootstrap/esm/Stack"; import Card from "react-bootstrap/Card"; @@ -18,7 +17,6 @@ const FeaturedQuestions = ({ handleButtonClick }) => { ]; return ( -

Featured Questions About IDDRS Framework @@ -33,7 +31,6 @@ const FeaturedQuestions = ({ handleButtonClick }) => { ))} -

); }; diff --git a/src/Components/Layout/Filter/ComplainceFilter.js b/src/Components/Layout/Filter/ComplainceFilter.js index 4cb932e..c9aba4f 100644 --- a/src/Components/Layout/Filter/ComplainceFilter.js +++ b/src/Components/Layout/Filter/ComplainceFilter.js @@ -1,7 +1,6 @@ import { useState } from "react"; import ToggleButton from "react-bootstrap/ToggleButton"; import ToggleButtonGroup from "react-bootstrap/ToggleButtonGroup"; -import Container from "react-bootstrap/esm/Container"; import classes from "./ComplainceFilter.module.css"; function ComplainceFilter({ onFilterChange }) { @@ -14,23 +13,22 @@ function ComplainceFilter({ onFilterChange }) { * not using it in this example so we will omit it. */ const handleChange = (val) => { - //console.log(val); setValue(val); onFilterChange(val); }; const complaince = ["Shall", "Should", "May", "Must", "Can"]; return ( -
-
Compliance Check:
- +
+
Compliance Check:
+ {complaince.map((comp, index) => ( {comp} diff --git a/src/Components/Layout/Filter/ComplainceFilter.module.css b/src/Components/Layout/Filter/ComplainceFilter.module.css index e69de29..6e41b3d 100644 --- a/src/Components/Layout/Filter/ComplainceFilter.module.css +++ b/src/Components/Layout/Filter/ComplainceFilter.module.css @@ -0,0 +1,5 @@ +.hover-effect:hover{ + background-color: #6c757d !important; /* Set the background color on hover */ + color: #fff !important; /* Set the text color on hover */ + /* Add any other styles you want for the hover effect */ + } \ No newline at end of file diff --git a/src/Components/Layout/Filter/Filter.js b/src/Components/Layout/Filter/Filter.js index d2e245b..eff5553 100644 --- a/src/Components/Layout/Filter/Filter.js +++ b/src/Components/Layout/Filter/Filter.js @@ -1,9 +1,9 @@ -import React, { useEffect, useState, Fragment } from "react"; -import Container from "react-bootstrap/Container"; +import React, { useEffect, useState } from "react"; import Dropdown from "react-bootstrap/Dropdown"; import classes from "../../../Static/styles.module.css"; import ToggleButton from "react-bootstrap/esm/ToggleButton"; import ToggleButtonGroup from "react-bootstrap/esm/ToggleButtonGroup"; +import filterClasses from "./Filter.module.css"; import axios from "axios"; @@ -21,21 +21,21 @@ const Filter = ({ onFilterChange }) => { useEffect(() => { axios - .get("http://127.0.0.1:8000/levels/") + .get("http://127.0.0.1:8000/client_api/levels/") .then((response) => setLevels(response.data)) .catch((error) => console.log(error)); }, []); useEffect(() => { axios - .get("http://127.0.0.1:8000/standards/") + .get("http://127.0.0.1:8000/client_api/standards/") .then((response) => setStandards(response.data)) .catch((error) => console.log(error)); }, []); return (
-
Filter by standards:
+
Filter by Standards:
{levels.map((level) => ( @@ -66,7 +66,7 @@ const Filter = ({ onFilterChange }) => { variant="outline-secondary" key={standard.id} id={`std-btn-${standard.id}`} - //className={classes["comp-btn"]} + className={classes[`list-items-${standard.standardLevel}`]} value={standard.standardTitle} > {standard.standardTitle} diff --git a/src/Components/Layout/Filter/Filter.module.css b/src/Components/Layout/Filter/Filter.module.css new file mode 100644 index 0000000..e69de29 diff --git a/src/Components/Layout/Results/Results.js b/src/Components/Layout/Results/Results.js index b4cdca9..92e0c7e 100644 --- a/src/Components/Layout/Results/Results.js +++ b/src/Components/Layout/Results/Results.js @@ -1,6 +1,5 @@ import React, { useState } from "react"; import Card from "../../UI/Card/Card"; -import Container from "react-bootstrap/esm/Container"; import Stack from "react-bootstrap/Stack"; import ResultsItem from "./ResultsItem"; import ResultModal from "../../UI/ResultModal/ResultModal"; @@ -39,7 +38,7 @@ const Results = (props) => { {/* */} -

Searched Phrase

+

{props.searchedPhrase}

{currentPost.map((result) => ( @@ -50,6 +49,8 @@ const Results = (props) => { title={result.Title} heading1={result.Heading1} paragraph={result.Paragraph} + complainceFilter = {props.complainceFilter} + pageNumber = {result.PageNum} > ))} @@ -74,6 +75,7 @@ const Results = (props) => { heading4={selectedResult ? selectedResult.Heading4 : ""} pageNumber={selectedResult ? selectedResult.PageNum : ""} paragraph={selectedResult ? selectedResult.Paragraph : ""} + sentence={selectedResult ? selectedResult.Sentence : ""} > diff --git a/src/Components/Layout/Results/ResultsItem.js b/src/Components/Layout/Results/ResultsItem.js index d3d7d49..ac91e97 100644 --- a/src/Components/Layout/Results/ResultsItem.js +++ b/src/Components/Layout/Results/ResultsItem.js @@ -1,27 +1,34 @@ import React from "react"; import Card from "react-bootstrap/Card"; -import classes from "../../../Static/styles.module.css" - +import classes from "../../../Static/styles.module.css"; +import Stack from "react-bootstrap/esm/Stack"; +import Badge from "react-bootstrap/Badge"; const ResultsItem = (props) => { - - const truncateText = (text, maxLength) =>{ + const truncateText = (text, maxLength) => { if (text.length > maxLength) { return text.substring(0, maxLength) + "..."; } else { return text; } - } + }; return ( - - - Level {props.level}, {props.title} - - - {props.heading1} - {truncateText(props.paragraph, 300)} - - + + + + Level {props.level}, {props.title} Page: {props.pageNumber} + + + {props.heading1} + {truncateText(props.paragraph, 300)} + + + + {props.complainceFilter.map((comp) => ( + {comp} + ))} + + ); }; diff --git a/src/Components/Layout/Search/Search.js b/src/Components/Layout/Search/Search.js index c1e9595..9f74386 100644 --- a/src/Components/Layout/Search/Search.js +++ b/src/Components/Layout/Search/Search.js @@ -1,12 +1,9 @@ import React, { useState } from "react"; import Input from "../../UI/Input/Input"; -import Button_ from "../../UI/Button/Button_"; import Form from "react-bootstrap/Form"; -import Container from "react-bootstrap/Container"; - +import Button from "react-bootstrap/esm/Button"; const Search = (props) => { - return (
{ aria-describedby="basic-addon1" onChange={props.onChange} > + - - Search -
); diff --git a/src/Components/Layout/WordCloud_/WordCloud_.js b/src/Components/Layout/WordCloud_/WordCloud_.js index 21740ef..f6360cf 100644 --- a/src/Components/Layout/WordCloud_/WordCloud_.js +++ b/src/Components/Layout/WordCloud_/WordCloud_.js @@ -1,7 +1,5 @@ import React, { Fragment } from "react"; -import { render } from "react-dom"; import WordCloud from "react-d3-cloud"; -import Container from "react-bootstrap/esm/Container"; import Card from "react-bootstrap/Card"; const data = [ @@ -90,18 +88,18 @@ const data = [ const WordCloud_ = () => { return ( -
- -

+ +

Most Frequent Key-Phrases

Math.log2(word.value) * 3} + fontSize={(word) => Math.log2(word.value) * 5 } + //fontSize={33} spiral="rectangular" rotate={0} fill = "gray" @@ -111,7 +109,6 @@ const WordCloud_ = () => { }} />
-

); }; diff --git a/src/Components/UI/Input/Input.js b/src/Components/UI/Input/Input.js index 7eb715c..8aeffc3 100644 --- a/src/Components/UI/Input/Input.js +++ b/src/Components/UI/Input/Input.js @@ -5,17 +5,17 @@ import InputGroup from "react-bootstrap/InputGroup"; const Input = (props) => { return ( - + - + ); }; diff --git a/src/Components/UI/ResultModal/ResultModal.js b/src/Components/UI/ResultModal/ResultModal.js index e5e6d66..1ed65b1 100644 --- a/src/Components/UI/ResultModal/ResultModal.js +++ b/src/Components/UI/ResultModal/ResultModal.js @@ -1,22 +1,47 @@ import React, { useState } from "react"; import Modal from "react-bootstrap/Modal"; import Button from "react-bootstrap/esm/Button"; -import classes from "../../../Static/styles.module.css" - +import classes from "../../../Static/styles.module.css"; const ResultModal = (props) => { + + const HighlightSubstring = ({ text, substring }) => { + const highlightStyle = { + backgroundColor: "yellow", + fontWeight: "bold", + }; + + // Split the text into parts based on the substring + const parts = text.split(new RegExp(`(${substring})`, "gi")); + console.log(parts) + + // Wrap the matching parts with a span and apply the highlight style + const highlightedText = parts.map((part, index) => { + if (part == substring) { + return ( + + {part} + + ); + } + return part; + }); + return highlightedText; + }; + return ( -
Level {props.level}
+
+ Level {props.level} +
IDDRS - {props.module}

{props.heading1}

{props.heading2}

@@ -25,8 +50,10 @@ const ResultModal = (props) => {
-

{props.paragraph}

-

Page: {props.pageNumber}

+

+
+

Page: {props.pageNumber}

+
diff --git a/src/Components/UI/ResultsPagination/ResultsPagination.js b/src/Components/UI/ResultsPagination/ResultsPagination.js index 1a7baba..d9aec0e 100644 --- a/src/Components/UI/ResultsPagination/ResultsPagination.js +++ b/src/Components/UI/ResultsPagination/ResultsPagination.js @@ -1,7 +1,6 @@ import React, { useState } from "react"; import classes from "./ResultsPagination.module.css"; import Button from "react-bootstrap/esm/Button"; -import Pagination from "react-bootstrap/Pagination"; const ResultsPagination = ({ totalPosts, diff --git a/src/Static/Imgs/IDDRS.png b/src/Static/Imgs/IDDRS.png new file mode 100644 index 0000000..298d918 Binary files /dev/null and b/src/Static/Imgs/IDDRS.png differ diff --git a/src/Static/styles.module.css b/src/Static/styles.module.css index d3aff88..62fd7c1 100644 --- a/src/Static/styles.module.css +++ b/src/Static/styles.module.css @@ -50,4 +50,34 @@ .level-text-6 { color: #CF7AB2 !important; +} + +.list-items-1:hover { + color: #fff !important; + background-color: #f07f4e54 !important; +} + +.list-items-2:hover { + color: #fff !important; + background-color: #008DCA54 !important; +} + +.list-items-3:hover { + color: #fff !important; + background-color: #00A55454 !important; +} + +.list-items-4:hover { + color: #fff !important; + background-color: #7366A354 !important; +} + +.list-items-5:hover { + color: #fff !important; + background-color: #D1000754 !important; +} + +.list-items-6:hover { + color: #fff !important; + background-color: #CF7AB254 !important; } \ No newline at end of file