From 2febc40e01352b920cef122a07f5dffcb23a6ad8 Mon Sep 17 00:00:00 2001 From: danieldeng2 <danieldeng223@gmail.com> Date: Thu, 13 Aug 2020 21:24:25 +0100 Subject: [PATCH] Refactor dashboard --- frontend/src/components/App.scss | 7 + .../src/components/atoms/NoticeItem/index.tsx | 31 ++++ .../atoms/NoticeItem/style.module.scss | 41 +++++ .../src/components/atoms/PersonCard/index.tsx | 2 - .../src/components/atoms/TutorCard/index.tsx | 2 +- .../molecules/DashboardButtonGroup/index.tsx | 36 ++-- .../molecules/ResourcesFolderView/index.tsx | 1 - .../molecules/TutorCardGroup/index.tsx | 60 ++++--- .../organisms/LeftBarDashboard/index.tsx | 1 - .../organisms/LeftBarExams/index.tsx | 2 +- .../organisms/NoticeBoard/index.tsx | 39 +++++ .../src/components/pages/Dashboard/index.tsx | 84 +-------- .../pages/Dashboard/style.module.scss | 164 ------------------ frontend/src/components/pages/Exams/index.tsx | 2 +- .../pages/ModuleResources/index.tsx | 40 ++--- 15 files changed, 210 insertions(+), 302 deletions(-) create mode 100644 frontend/src/components/atoms/NoticeItem/index.tsx create mode 100644 frontend/src/components/atoms/NoticeItem/style.module.scss create mode 100644 frontend/src/components/organisms/NoticeBoard/index.tsx delete mode 100644 frontend/src/components/pages/Dashboard/style.module.scss diff --git a/frontend/src/components/App.scss b/frontend/src/components/App.scss index 1b6f68e4b..89d65ef2e 100644 --- a/frontend/src/components/App.scss +++ b/frontend/src/components/App.scss @@ -13,4 +13,11 @@ body { code { font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace; +} + +.btn-primary.focus, .btn-primary:focus { + color: #000; + background-color: #f8f9fa; + border-color: #0062cc; + box-shadow: none; } \ No newline at end of file diff --git a/frontend/src/components/atoms/NoticeItem/index.tsx b/frontend/src/components/atoms/NoticeItem/index.tsx new file mode 100644 index 000000000..67f861f0c --- /dev/null +++ b/frontend/src/components/atoms/NoticeItem/index.tsx @@ -0,0 +1,31 @@ +import React from "react"; +import styles from "./style.module.scss"; + +export interface NoticeItemProps { + heading: string; + user: string; + time: string; + body: string; +} + +const NoticeItem: React.FC<NoticeItemProps> = ({ + heading, + user, + time, + body, +}: NoticeItemProps) => { + return ( + <> + <div style={{ marginTop: "20px" }} className={styles.noticeContainer}> + <p className={styles.noticeHeading}>{heading}</p> + <span style={{ display: "flex", justifyContent: "space-between" }}> + <p className={styles.noticeUser}>{user}</p> + <p className={styles.noticeTime}>{time}</p> + </span> + <p className={styles.noticeBody}>{body}</p> + </div> + </> + ); +}; + +export default NoticeItem; diff --git a/frontend/src/components/atoms/NoticeItem/style.module.scss b/frontend/src/components/atoms/NoticeItem/style.module.scss new file mode 100644 index 000000000..1f1b10785 --- /dev/null +++ b/frontend/src/components/atoms/NoticeItem/style.module.scss @@ -0,0 +1,41 @@ +@import "assets/scss/custom"; + +.noticeContainer { + background-color: $gray-100; + border-radius: 8px; + padding: 10px; + transition: transform 0.2s, box-shadow 0.2s; +} + +.noticeContainer:hover { + transform: scale(1.03); + box-shadow: 0 0.125rem 0.625rem 0 rgba(0, 0, 0, 0.1); +} + +.noticeHeading { + font-size: 18px; + color: $black; + font-weight: 500; + margin-bottom: 2px; + line-height: 22px; +} + +.noticeUser { + font-size: 16px; + color: $gray-700; + line-height: 18px; + margin-bottom: 10px; +} + +.noticeTime { + font-size: 16px; + color: $gray-600; + line-height: 18px; + margin-bottom: 10px; +} + +.noticeBody { + font-size: 16px; + color: $gray-800; + margin-bottom: 0px; +} diff --git a/frontend/src/components/atoms/PersonCard/index.tsx b/frontend/src/components/atoms/PersonCard/index.tsx index 0b38f8b9e..0d0b832f1 100644 --- a/frontend/src/components/atoms/PersonCard/index.tsx +++ b/frontend/src/components/atoms/PersonCard/index.tsx @@ -1,9 +1,7 @@ import React, { useEffect } from "react"; -import MyBreadcrumbs from "components/atoms/MyBreadcrumbs"; import Image from "react-bootstrap/Image"; import Container from "react-bootstrap/Container"; import styles from "./style.module.scss"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import userImage from "assets/images/user.png"; const PersonCard: React.FC = () => { diff --git a/frontend/src/components/atoms/TutorCard/index.tsx b/frontend/src/components/atoms/TutorCard/index.tsx index 0ba4110ca..c047f861f 100644 --- a/frontend/src/components/atoms/TutorCard/index.tsx +++ b/frontend/src/components/atoms/TutorCard/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React from "react"; import Image from "react-bootstrap/Image"; import Container from "react-bootstrap/Container"; import styles from "./style.module.scss"; diff --git a/frontend/src/components/molecules/DashboardButtonGroup/index.tsx b/frontend/src/components/molecules/DashboardButtonGroup/index.tsx index 3188fad7a..23e22c7d5 100644 --- a/frontend/src/components/molecules/DashboardButtonGroup/index.tsx +++ b/frontend/src/components/molecules/DashboardButtonGroup/index.tsx @@ -1,22 +1,31 @@ -import React, { useEffect } from "react"; +import React from "react"; import Row from "react-bootstrap/Row"; import Col from "react-bootstrap/Col"; import styles from "./style.module.scss"; -import { faGlobe, faFileAlt, faPrint, faFileInvoice, faDatabase, faBullhorn, faUserFriends, faBug } from "@fortawesome/free-solid-svg-icons"; +import { + faGlobe, + faFileAlt, + faPrint, + faFileInvoice, + faDatabase, + faBullhorn, + faUserFriends, + faBug, +} from "@fortawesome/free-solid-svg-icons"; import Button from "react-bootstrap/Button"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; const DashboardButtonGroup: React.FC = () => { - - // @ts-ignore - useEffect(() => {window.Holder.run()}); - return ( <> <Row style={{ marginTop: "45px" }}> - {buttons.map(({title, icon}, i) => ( + {buttons.map(({ title, icon, url }, i) => ( <Col xs={6} sm={6} md={3} key={i}> - <Button className={styles.dashboardButton}> + <Button + className={styles.dashboardButton} + href={url} + target="_blank" + > {title} <FontAwesomeIcon style={{ fontSize: "1.125rem" }} @@ -37,14 +46,17 @@ const buttons = [ { title: "Record", icon: faFileInvoice, + url: "https://cate.doc.ic.ac.uk/student.cgi?key=2019", }, { title: "Website", icon: faGlobe, + url: "https://www.doc.ic.ac.uk/~js4416/", }, { title: "TeachDB", icon: faDatabase, + url: "https://teachdb.doc.ic.ac.uk/db/", }, { title: "Notice Board", @@ -53,17 +65,21 @@ const buttons = [ { title: "Documents", icon: faFileAlt, + url: "https://my.imperial.ac.uk/HomeScreen.aspx", }, { title: "Printing", icon: faPrint, + url: "https://ictprintservice.imperial.ac.uk/safecom/webuser.dll/login", }, { title: "DoCSoc", icon: faUserFriends, + url: "https://docsoc.co.uk/", }, { title: "Report Bugs", icon: faBug, - } -] + url: "https://gitlab.doc.ic.ac.uk/edtech/scientia/-/issues/new", + }, +]; diff --git a/frontend/src/components/molecules/ResourcesFolderView/index.tsx b/frontend/src/components/molecules/ResourcesFolderView/index.tsx index 8e45ecf7a..693926374 100644 --- a/frontend/src/components/molecules/ResourcesFolderView/index.tsx +++ b/frontend/src/components/molecules/ResourcesFolderView/index.tsx @@ -90,7 +90,6 @@ class ResourcesFolderView extends React.Component<PropsType, MyState> { let items = this.props.folderItems; for (let item in items) { if (items[item].id === id) { - console.log(`/${items[item].title}`); this.props.history.push( `${this.props.location.pathname}/${items[item].title}` ); diff --git a/frontend/src/components/molecules/TutorCardGroup/index.tsx b/frontend/src/components/molecules/TutorCardGroup/index.tsx index 9c5083034..311a26ea8 100644 --- a/frontend/src/components/molecules/TutorCardGroup/index.tsx +++ b/frontend/src/components/molecules/TutorCardGroup/index.tsx @@ -1,35 +1,49 @@ -import React, { useEffect } from "react"; -import Image from "react-bootstrap/Image"; -import Container from "react-bootstrap/Container"; -import styles from "./style.module.scss"; +import React from "react"; import TutorCard from "components/atoms/TutorCard"; -import Col from "react-bootstrap/Col"; -export interface TutorCardGroupProp { - tutors: { - name: string; - email: string; - address: string; - image: string; - }[]; -} +import tutorImage1 from "assets/images/tutor-1.png"; +import tutorImage2 from "assets/images/tutor-2.png"; +import tutorImage3 from "assets/images/tutor-3.png"; -const TutorCardGroup: React.FC<TutorCardGroupProp> = ({ - tutors, -}: TutorCardGroupProp) => { - let tutorCards = tutors.map( - ({name, email, address, image}) => { - return <TutorCard name={name} email={email} address={address} image={image} /> - }) +const TutorCardGroup: React.FC = () => { + let tutorCards = tutors.map(({ name, email, address, image }) => { + return ( + <TutorCard key={email} name={name} email={email} address={address} image={image} /> + ); + }); return ( <> - <Col> <h4>Tutors</h4> - {tutorCards} - </Col> + {tutorCards} </> ); }; export default TutorCardGroup; + +const tutors: { + name: string; + email: string; + address: string; + image: string; +}[] = [ + { + name: "Dr. Zahid Barr", + email: "zahid.barr@imperial.ac.uk", + address: "373, Huxley Building", + image: tutorImage1, + }, + { + name: "Dr. Rosalind Baker", + email: "rosalind.baker@imperial.ac.uk", + address: "590, Huxley Building", + image: tutorImage2, + }, + { + name: "Mr. Subhaan Wicks", + email: "subhaan.wicks16@imperial.ac.uk", + address: "Huxley Building", + image: tutorImage3, + }, +]; diff --git a/frontend/src/components/organisms/LeftBarDashboard/index.tsx b/frontend/src/components/organisms/LeftBarDashboard/index.tsx index 7d5f2ac0d..8681df938 100644 --- a/frontend/src/components/organisms/LeftBarDashboard/index.tsx +++ b/frontend/src/components/organisms/LeftBarDashboard/index.tsx @@ -5,7 +5,6 @@ import { faGitlab } from "@fortawesome/free-brands-svg-icons"; import { faFlask, faEnvelopeOpen, faUserFriends, faPlay, faStarHalfAlt} from "@fortawesome/free-solid-svg-icons"; import WorkDueGroup from "components/molecules/WorkDueGroup"; -import Col from "react-bootstrap/Col"; const LeftBarDashboard: React.FC = () => { let linkButtons = [ { diff --git a/frontend/src/components/organisms/LeftBarExams/index.tsx b/frontend/src/components/organisms/LeftBarExams/index.tsx index d28db2a10..b25086bab 100644 --- a/frontend/src/components/organisms/LeftBarExams/index.tsx +++ b/frontend/src/components/organisms/LeftBarExams/index.tsx @@ -45,7 +45,7 @@ const LeftBarExams: React.FC = () => { return ( <LeftBar> - <SideBarTabGroup title="Links" buttons={examButtons} /> + <SideBarTabGroup title="Pages" buttons={examButtons} /> </LeftBar> ); }; diff --git a/frontend/src/components/organisms/NoticeBoard/index.tsx b/frontend/src/components/organisms/NoticeBoard/index.tsx new file mode 100644 index 000000000..778e15921 --- /dev/null +++ b/frontend/src/components/organisms/NoticeBoard/index.tsx @@ -0,0 +1,39 @@ +import React from "react"; +import NoticeItem from "components/atoms/NoticeItem"; + +const NoticeBoard: React.FC = () => { + return ( + <> + <h4>Notice Board</h4> + {noticeItems.map(({ heading, user, time, body }) => ( + <NoticeItem key={heading} heading={heading} user={user} time={time} body={body} /> + ))} + </> + ); +}; + +export default NoticeBoard; + +const noticeItems = [ + { + heading: "Lab Closure Information", + user: "Konstantinos Gkotuzis", + time: "1 Minute Ago", + body: + "Computing lab rooms 209, 208, and 210 would be closed for the year one haskell exams on Friday 20th of April.", + }, + { + heading: "Dead body found in foyer area", + user: "Orenthal James Simpson", + time: "1 hour Ago", + body: + "Whoever left the dead body of Rosalind Baker in the foyer area could you please clean after youself, thank you. Nobody needs to see that. ", + }, + { + heading: "Autumn Fee Information", + user: "Rosalind Baker", + time: "5 hours Ago", + body: + "We understand that a lot of you would not be on campus for the autmumn term, however that does not mean that you should stop paying us. Good day. ", + }, +]; diff --git a/frontend/src/components/pages/Dashboard/index.tsx b/frontend/src/components/pages/Dashboard/index.tsx index e3a599838..efa19e97e 100644 --- a/frontend/src/components/pages/Dashboard/index.tsx +++ b/frontend/src/components/pages/Dashboard/index.tsx @@ -1,23 +1,11 @@ -import React, { useEffect } from "react"; +import React from "react"; import MyBreadcrumbs from "components/atoms/MyBreadcrumbs"; -import Image from "react-bootstrap/Image"; -import Container from "react-bootstrap/Container"; import Row from "react-bootstrap/Row"; import Col from "react-bootstrap/Col"; -import styles from "./style.module.scss"; -import { faFile } from "@fortawesome/free-solid-svg-icons"; -import Button from "react-bootstrap/Button"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; - import PersonCard from "components/atoms/PersonCard"; import DashboardButtonGroup from "components/molecules/DashboardButtonGroup"; -import TutorCard from "components/atoms/TutorCard"; import TutorCardGroup from "components/molecules/TutorCardGroup"; - -import tutorImage1 from "assets/images/tutor-1.png"; -import tutorImage2 from "assets/images/tutor-2.png"; -import tutorImage3 from "assets/images/tutor-3.png"; - +import NoticeBoard from "components/organisms/NoticeBoard"; const Dashboard: React.FC = () => { return ( @@ -26,50 +14,11 @@ const Dashboard: React.FC = () => { <PersonCard /> <DashboardButtonGroup /> <Row style={{ marginTop: "30px" }}> - <TutorCardGroup tutors={tutors} /> <Col> - <h4>Notice Board</h4> - - {/* Notice 1 */} - <div style={{ marginTop: "20px" }} className={styles.noticeContainer}> - <p className={styles.noticeHeading}>Lab Closure Information</p> - <span style={{ display: "flex", justifyContent: "space-between" }}> - <p className={styles.noticeUser}>Konstantinos Gkotuzis</p> - <p className={styles.noticeTime}>1 Minute Ago</p> - </span> - <p className={styles.noticeBody}> - Computing lab rooms 209, 208, and 210 would be closed for the year - one haskell exams on Friday 20th of April. - </p> - </div> - - {/* Notice 2 */} - - <div style={{ marginTop: "15px" }} className={styles.noticeContainer}> - <p className={styles.noticeHeading}>Lab Closure Information</p> - <span style={{ display: "flex", justifyContent: "space-between" }}> - <p className={styles.noticeUser}>Konstantinos Gkotuzis</p> - <p className={styles.noticeTime}>1 Minute Ago</p> - </span> - <p className={styles.noticeBody}> - Computing lab rooms 209, 208, and 210 would be closed for the year - one haskell exams on Friday 20th of April. - </p> - </div> - - {/* Notice 3 */} - - <div style={{ marginTop: "15px" }} className={styles.noticeContainer}> - <p className={styles.noticeHeading}>Lab Closure Information</p> - <span style={{ display: "flex", justifyContent: "space-between" }}> - <p className={styles.noticeUser}>Konstantinos Gkotuzis</p> - <p className={styles.noticeTime}>1 Minute Ago</p> - </span> - <p className={styles.noticeBody}> - Computing lab rooms 209, 208, and 210 would be closed for the year - one haskell exams on Friday 20th of April. - </p> - </div> + <TutorCardGroup /> + </Col> + <Col> + <NoticeBoard /> </Col> </Row> </> @@ -77,24 +26,3 @@ const Dashboard: React.FC = () => { }; export default Dashboard; - -const tutors = [ - { - name: "Dr. Zahid Barr", - email: "zahid.barr@imperial.ac.uk", - address: "373, Huxley Building", - image: tutorImage1, - }, - { - name: "Dr. Rosalind Baker", - email: "rosalind.baker@imperial.ac.uk", - address: "590, Huxley Building", - image: tutorImage2, - }, - { - name: "Mr. Subhaan Wicks", - email: "subhaan.wicks16@imperial.ac.uk", - address: "Huxley Building", - image: tutorImage3, - } -]; diff --git a/frontend/src/components/pages/Dashboard/style.module.scss b/frontend/src/components/pages/Dashboard/style.module.scss deleted file mode 100644 index 0e81b0a21..000000000 --- a/frontend/src/components/pages/Dashboard/style.module.scss +++ /dev/null @@ -1,164 +0,0 @@ -@import "assets/scss/custom"; - -.dashboardImage { - border-radius: 8px; - margin-right: 20px; -} - -.userName { - font-weight: 600; - font-size: 24px; - color: $black; - margin-bottom: 0rem; - line-height: 32px; -} - -.userEmail { - font-size: 16px; - color: $blue-500; - margin-bottom: 0rem; - line-height: 20px; -} - -.userIdentifier { - font-weight: 500; - font-size: 18px; - margin-bottom: 14px; - margin-top: 14px; - line-height: 24px; - display: flex; - align-items: center; -} - -.userYear { - font-size: 17px; - color: $gray-700; - margin-bottom: 0rem; - line-height: 22px; -} - -.userDepartment { - font-size: 17px; - color: $gray-600; - margin-bottom: 0rem; - line-height: 22px; -} - -.userCourse { - font-size: 17px; - color: $gray-800; - margin-top: 10px; - margin-bottom: 0rem; - line-height: 22px; -} - -.dot { - height: 6px; - width: 6px; - border-radius: 50%; - display: inline-block; - margin-right: 8px; - margin-left: 8px; - background-color: $gray-500; -} - -.dashboardButton, -.dashboardButton:global(.a) { - margin-bottom: 0.625rem; - color: #000; - background: #f6f8fa; - font-size: 1.05rem; - letter-spacing: 0; - border-width: 0rem; - line-height: 1.375rem; - height: 2.25rem; - border-radius: 0.5rem !important; - text-align: left; - transition: 0.2s background; - -webkit-transition: 0.2s background; - -moz-transition: 0.2s background; - display: flex; - width: 100%; - justify-content: space-between; - align-items: center; -} - -.dashboardButton:global(.active), -.dashboardButton:active { - color: #fff; - background: #000 !important; - font-weight: 500; - text-align: left; - border-width: 0rem; - height: 2.25rem; - line-height: 1.375rem; -} - -.dashboardButton:hover { - background: #e5e5e5; - border-color: #fff; - color: #000; -} - -.tutorImage { - border-radius: 50%; - margin-right: 20px; -} - -.tutorName, .tutorEmail, .tutorAddress { - font-size: 18px; - margin-bottom: 0px; - line-height: 24px !important; -} - -.tutorName { - color: $blue-500; -} - -.tutorEmail { - color: $gray-700; -} - -.tutorAddress { - color: $gray-600; -} - -.noticeContainer { - background-color: $gray-100; - border-radius: 8px; - padding: 10px; - transition: transform 0.2s, box-shadow 0.2s; -} - -.noticeContainer:hover { - transform: scale(1.03); - box-shadow: 0 0.125rem 0.625rem 0 rgba(0, 0, 0, 0.1); -} - -.noticeHeading { - font-size: 18px; - color: $black; - font-weight: 500; - margin-bottom: 2px; - line-height: 22px; -} - -.noticeUser { - font-size: 16px; - color: $gray-700; - line-height: 18px; - margin-bottom: 10px; -} - -.noticeTime { - font-size: 16px; - color: $gray-600; - line-height: 18px; - margin-bottom: 10px; -} - -.noticeBody { - font-size: 16px; - color: $gray-800; - margin-bottom: 0px; -} diff --git a/frontend/src/components/pages/Exams/index.tsx b/frontend/src/components/pages/Exams/index.tsx index 8dc4cdad4..424154201 100644 --- a/frontend/src/components/pages/Exams/index.tsx +++ b/frontend/src/components/pages/Exams/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React from "react"; import Dandruff from "components/molecules/Dandruff"; const Exams: React.FC = () => { diff --git a/frontend/src/components/pages/ModuleResources/index.tsx b/frontend/src/components/pages/ModuleResources/index.tsx index 9adda7d46..19526dcb6 100644 --- a/frontend/src/components/pages/ModuleResources/index.tsx +++ b/frontend/src/components/pages/ModuleResources/index.tsx @@ -1,8 +1,8 @@ import React, { useEffect, useState } from "react"; import styles from "./style.module.scss"; -import { request } from "../../../utils/api" -import { api } from "../../../constants/routes" +// import { request } from "../../../utils/api" +// import { api } from "../../../constants/routes" import MyBreadcrumbs from "components/atoms/MyBreadcrumbs"; import InputGroup from "react-bootstrap/InputGroup"; @@ -31,26 +31,26 @@ const ModuleResources: React.FC<{ year: string}> = ({year}) => { const module_code = id.startsWith("CO") ? id : id.slice(2); //maybe refactor into class? - const [error, setError] = useState(null); - const [isLoaded, setIsLoaded] = useState(false); - const [resources, setResources] = useState([]); + // const [error, setError] = useState(null); + // const [isLoaded, setIsLoaded] = useState(false); + // const [resources, setResources] = useState([]); - useEffect(() => { - setIsLoaded(false); - const onSuccess = (data: any) => { - setIsLoaded(true); - setResources(data.json()); - } - const onFailure = (error: any) => { - setIsLoaded(true); - setError(error); - } + // useEffect(() => { + // setIsLoaded(false); + // const onSuccess = (data: any) => { + // setIsLoaded(true); + // setResources(data.json()); + // } + // const onFailure = (error: any) => { + // setIsLoaded(true); + // setError(error); + // } - request(api.MATERIALS_RESOURCES, "GET", onSuccess, onFailure, { - "year": year, - "course": module_code - }) - }, [year, module_code]); + // request(api.MATERIALS_RESOURCES, "GET", onSuccess, onFailure, { + // "year": year, + // "course": module_code + // }) + // }, [year, module_code]); return ( <> -- GitLab