From 63fd2e9b6f46aa1ca81ce358a4aed5cde5844648 Mon Sep 17 00:00:00 2001 From: Johanna Date: Tue, 19 Mar 2024 21:47:16 +0100 Subject: [PATCH 001/110] //fix parse in NewWeeklyReport --- frontend/src/Components/NewWeeklyReport.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/Components/NewWeeklyReport.tsx b/frontend/src/Components/NewWeeklyReport.tsx index ab9084d..1d029c3 100644 --- a/frontend/src/Components/NewWeeklyReport.tsx +++ b/frontend/src/Components/NewWeeklyReport.tsx @@ -54,8 +54,7 @@ export default function NewWeeklyReport(): JSX.Element { type="week" placeholder="Week" onChange={(e) => { - const weekNumber = parseInt(e.target.value.split("-W")[1]); - setWeek(weekNumber); + setWeek(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; From 1974607fc705fc17165732ff6282bea955cd55b4 Mon Sep 17 00:00:00 2001 From: Johanna Date: Tue, 19 Mar 2024 22:04:20 +0100 Subject: [PATCH 002/110] Formating --- frontend/src/Components/NewWeeklyReport.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/Components/NewWeeklyReport.tsx b/frontend/src/Components/NewWeeklyReport.tsx index 1d029c3..4542855 100644 --- a/frontend/src/Components/NewWeeklyReport.tsx +++ b/frontend/src/Components/NewWeeklyReport.tsx @@ -54,7 +54,7 @@ export default function NewWeeklyReport(): JSX.Element { type="week" placeholder="Week" onChange={(e) => { - setWeek(parseInt(e.target.value)); + setWeek(parseInt(e.target.value)); }} onKeyDown={(event) => { const keyValue = event.key; From a5adec82e24b959af3d9c0982e66f94987fe4d20 Mon Sep 17 00:00:00 2001 From: Peter KW Date: Wed, 20 Mar 2024 11:51:04 +0100 Subject: [PATCH 003/110] Modul for showing projectinfo *not finished* --- frontend/src/Components/ProjectInfoModal.tsx | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 frontend/src/Components/ProjectInfoModal.tsx diff --git a/frontend/src/Components/ProjectInfoModal.tsx b/frontend/src/Components/ProjectInfoModal.tsx new file mode 100644 index 0000000..11d29c1 --- /dev/null +++ b/frontend/src/Components/ProjectInfoModal.tsx @@ -0,0 +1,44 @@ +import Button from "./Button"; + +function UserInfoModal(props: { + isVisible: boolean; + projectname: string; + onClose: () => void; +}): JSX.Element { + if (!props.isVisible) return <>; + + return ( +
+
+

{props.projectname}

+
+

+ Members of this project: +

+
{/*Show all members in project*/}
+
+
+
+
+
+ ); +} + +export default UserInfoModal; From e271794b57faf12b1635ddc6fde73adcb5784196 Mon Sep 17 00:00:00 2001 From: Peter KW Date: Wed, 20 Mar 2024 11:51:50 +0100 Subject: [PATCH 004/110] List for showing all projects as admin --- frontend/src/Components/ProjectListAdmin.tsx | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 frontend/src/Components/ProjectListAdmin.tsx diff --git a/frontend/src/Components/ProjectListAdmin.tsx b/frontend/src/Components/ProjectListAdmin.tsx new file mode 100644 index 0000000..dbc7403 --- /dev/null +++ b/frontend/src/Components/ProjectListAdmin.tsx @@ -0,0 +1,56 @@ +import { useState } from "react"; +import { NewProject } from "../Types/goTypes"; +import ProjectInfoModal from "./ProjectInfoModal"; + +/** + * A list of projects for admin manage projects page, that sets an onClick + * function for eact project
  • element, which displays a modul with + * user info. + * @param props - An array of projects to display + * @returns {JSX.Element} The project list + * @example + * const projects: NewProject[] = [{ name: "Project", description: "New" }]; + * return + */ + +export function ProjectListAdmin(props: { + projects: NewProject[]; +}): JSX.Element { + const [modalVisible, setModalVisible] = useState(false); + const [projectname, setProjectname] = useState(""); + + const handleClick = (username: string): void => { + setProjectname(username); + setModalVisible(true); + }; + + const handleClose = (): void => { + setProjectname(""); + setModalVisible(false); + }; + + return ( + <> + +
    +
      + {props.projects.map((project) => ( +
    • { + handleClick(project.name); + }} + > + {project.name} +
    • + ))} +
    +
    + + ); +} From 6317c7674c0957a9b3eed01d7ade1143a57b38c7 Mon Sep 17 00:00:00 2001 From: Peter KW Date: Wed, 20 Mar 2024 11:53:27 +0100 Subject: [PATCH 005/110] Now uses projectListAdmin to show projects --- .../src/Pages/AdminPages/AdminManageProjects.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/Pages/AdminPages/AdminManageProjects.tsx b/frontend/src/Pages/AdminPages/AdminManageProjects.tsx index 177f55b..14e44be 100644 --- a/frontend/src/Pages/AdminPages/AdminManageProjects.tsx +++ b/frontend/src/Pages/AdminPages/AdminManageProjects.tsx @@ -2,9 +2,20 @@ import { Link } from "react-router-dom"; import BackButton from "../../Components/BackButton"; import BasicWindow from "../../Components/BasicWindow"; import Button from "../../Components/Button"; +import { ProjectListAdmin } from "../../Components/ProjectListAdmin"; +import { NewProject } from "../../Types/goTypes"; function AdminManageProjects(): JSX.Element { - const content = <>; + //TODO: Use fetch to get all projects + const projects: NewProject[] = [{ name: "Project", description: "New" }]; + const content = ( + <> +

    Manage Projects

    +
    + +
    + + ); const buttons = ( <> From cea2b6c03cba35a49a421a93420009fb59ebc9cf Mon Sep 17 00:00:00 2001 From: Peter KW Date: Wed, 20 Mar 2024 12:25:07 +0100 Subject: [PATCH 006/110] GetProjects compo --- frontend/src/Components/GetProjects.tsx | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 frontend/src/Components/GetProjects.tsx diff --git a/frontend/src/Components/GetProjects.tsx b/frontend/src/Components/GetProjects.tsx new file mode 100644 index 0000000..d6ab1f7 --- /dev/null +++ b/frontend/src/Components/GetProjects.tsx @@ -0,0 +1,37 @@ +import { Dispatch, useEffect } from "react"; +import { Project } from "../Types/goTypes"; +import { api } from "../API/API"; + +/** + * Gets all projects that user is a member of + * @param props - A setStateAction for the array you want to put projects in + * @returns {void} Nothing + * @example + * const [projects, setProjects] = useState([]); + * GetAllUsers({ setProjectsProp: setProjects }); + */ +function GetProjects(props: { + setProjectsProp: Dispatch>; +}): void { + const setProjects: Dispatch> = + props.setProjectsProp; + useEffect(() => { + const fetchUsers = async (): Promise => { + try { + const token = localStorage.getItem("accessToken") ?? ""; + const response = await api.getUserProjects(token); + if (response.success) { + setProjects(response.data ?? []); + } else { + console.error("Failed to fetch projects:", response.message); + } + } catch (error) { + console.error("Error fetching projects:", error); + } + }; + + void fetchUsers(); + }, [setProjects]); +} + +export default GetProjects; From 33b269e0c987faacfe8e487c516ae772cb880736 Mon Sep 17 00:00:00 2001 From: Peter KW Date: Wed, 20 Mar 2024 12:25:59 +0100 Subject: [PATCH 007/110] Now uses GetProjects --- frontend/src/Pages/AdminPages/AdminManageProjects.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/Pages/AdminPages/AdminManageProjects.tsx b/frontend/src/Pages/AdminPages/AdminManageProjects.tsx index 14e44be..7ea45df 100644 --- a/frontend/src/Pages/AdminPages/AdminManageProjects.tsx +++ b/frontend/src/Pages/AdminPages/AdminManageProjects.tsx @@ -3,11 +3,13 @@ import BackButton from "../../Components/BackButton"; import BasicWindow from "../../Components/BasicWindow"; import Button from "../../Components/Button"; import { ProjectListAdmin } from "../../Components/ProjectListAdmin"; -import { NewProject } from "../../Types/goTypes"; +import { Project } from "../../Types/goTypes"; +import GetProjects from "../../Components/GetProjects"; +import { useState } from "react"; function AdminManageProjects(): JSX.Element { - //TODO: Use fetch to get all projects - const projects: NewProject[] = [{ name: "Project", description: "New" }]; + const [projects, setProjects] = useState([]); + GetProjects({ setProjectsProp: setProjects }); const content = ( <>

    Manage Projects

    From 54e42cd2a8939647cc1f9837c76ccc0433f0bb9f Mon Sep 17 00:00:00 2001 From: Davenludd Date: Wed, 20 Mar 2024 15:19:09 +0100 Subject: [PATCH 008/110] Add support for week input in Chrome and Edge browsers --- frontend/src/Components/NewWeeklyReport.tsx | 58 +++++++++++++++------ 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/frontend/src/Components/NewWeeklyReport.tsx b/frontend/src/Components/NewWeeklyReport.tsx index 292ddf5..2593782 100644 --- a/frontend/src/Components/NewWeeklyReport.tsx +++ b/frontend/src/Components/NewWeeklyReport.tsx @@ -38,6 +38,7 @@ export default function NewWeeklyReport(): JSX.Element { }; const navigate = useNavigate(); + const isChromeOrEdge = /Chrome|Edg/.test(navigator.userAgent); return ( <> @@ -55,23 +56,48 @@ export default function NewWeeklyReport(): JSX.Element { }} >
    - { - const weekNumber = parseInt(e.target.value.split("-W")[1]); - setWeek(weekNumber); - }} - onKeyDown={(event) => { - const keyValue = event.key; - if (!/\d/.test(keyValue) && keyValue !== "Backspace") + {isChromeOrEdge ? ( + { + const weekNumber = parseInt(e.target.value.split("-W")[1]); + setWeek(weekNumber); + }} + onKeyDown={(event) => { + const keyValue = event.key; + if (!/\d/.test(keyValue) && keyValue !== "Backspace") + event.preventDefault(); + }} + onPaste={(event) => { event.preventDefault(); - }} - onPaste={(event) => { - event.preventDefault(); - }} - /> + }} + /> + ) : ( + { + const weekNumber = parseInt(e.target.value); + if (isNaN(weekNumber) || weekNumber < 1 || weekNumber > 53) { + setWeek(0); + return; + } else { + setWeek(weekNumber); + } + }} + onKeyDown={(event) => { + const keyValue = event.key; + if (!/\d/.test(keyValue) && keyValue !== "Backspace") + event.preventDefault(); + }} + onPaste={(event) => { + event.preventDefault(); + }} + /> + )} From 0076a9f4bb7f16808d6e9752f0e57300f3a64cc4 Mon Sep 17 00:00:00 2001 From: pavel Hamawand Date: Wed, 20 Mar 2024 15:30:16 +0100 Subject: [PATCH 009/110] backButton --- frontend/src/Pages/AdminPages/AdminProjectAddMember.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/frontend/src/Pages/AdminPages/AdminProjectAddMember.tsx b/frontend/src/Pages/AdminPages/AdminProjectAddMember.tsx index 96167cb..712df86 100644 --- a/frontend/src/Pages/AdminPages/AdminProjectAddMember.tsx +++ b/frontend/src/Pages/AdminPages/AdminProjectAddMember.tsx @@ -1,3 +1,4 @@ +import BackButton from "../../Components/BackButton"; import BasicWindow from "../../Components/BasicWindow"; import Button from "../../Components/Button"; @@ -13,13 +14,7 @@ function AdminProjectAddMember(): JSX.Element { }} type="button" /> -
    + + + + + + + + + + + + + + + + + + + + + + + + +
    Role + Total Time (min) +
    Project Manager + { + event.preventDefault(); + }} + /> +
    System Manager + { + event.preventDefault(); + }} + /> +
    Administration + { + event.preventDefault(); + }} + /> +
    Own Work + { + event.preventDefault(); + }} + /> +
    +
    + + + ); +} diff --git a/frontend/src/Pages/ProjectManagerPages/PMTotalTimeRole.tsx b/frontend/src/Pages/ProjectManagerPages/PMTotalTimeRole.tsx index c0161f8..7caea04 100644 --- a/frontend/src/Pages/ProjectManagerPages/PMTotalTimeRole.tsx +++ b/frontend/src/Pages/ProjectManagerPages/PMTotalTimeRole.tsx @@ -1,8 +1,13 @@ import BasicWindow from "../../Components/BasicWindow"; import BackButton from "../../Components/BackButton"; +import TimePerRole from "../../Components/TimePerRole"; function PMTotalTimeRole(): JSX.Element { - const content = <>; + const content = ( + <> + + + ); const buttons = ( <> From 4030031ce9c1c936e31ac5b8a13f0764e3a33a22 Mon Sep 17 00:00:00 2001 From: Mattias Date: Wed, 20 Mar 2024 16:36:24 +0100 Subject: [PATCH 020/110] New comp TimePerActivity --- frontend/src/Components/TimePerActivity.tsx | 175 ++++++++++++++++++ .../PMTotalTimeActivity.tsx | 7 +- 2 files changed, 177 insertions(+), 5 deletions(-) create mode 100644 frontend/src/Components/TimePerActivity.tsx diff --git a/frontend/src/Components/TimePerActivity.tsx b/frontend/src/Components/TimePerActivity.tsx new file mode 100644 index 0000000..3dc1a6b --- /dev/null +++ b/frontend/src/Components/TimePerActivity.tsx @@ -0,0 +1,175 @@ +import { useState, useEffect } from "react"; +import { useParams } from "react-router-dom"; + +/** + * Renders the component for showing total time per role in a project. + * @returns JSX.Element + */ +export default function TimePerRole(): JSX.Element { + const [developmentTime, setDevelopmentTime] = useState(); + const [meetingTime, setMeetingTime] = useState(); + const [adminTime, setAdminTime] = useState(); + const [ownWorkTime, setOwnWorkTime] = useState(); + const [studyTime, setStudyTime] = useState(); + const [testingTime, setTestingTime] = useState(); + + // const token = localStorage.getItem("accessToken") ?? ""; + // const username = localStorage.getItem("username") ?? ""; + const { projectName } = useParams(); + + // const fetchTimePerRole = async (): Promise => { + // const response = await api.getTimePerRole( + // username, + // projectName ?? "", + // token, + // ); + // { + // if (response.success) { + // const report: TimePerRole = response.data ?? { + // PManagerTime: 0, + // SManagerTime: 0, + // DeveloperTime: 0, + // TesterTime: 0, + // }; + // } else { + // console.error("Failed to fetch weekly report:", response.message); + // } + // } + + interface TimePerActivity { + developmentTime: number; + meetingTime: number; + adminTime: number; + ownWorkTime: number; + studyTime: number; + testingTime: number; + } + + const fetchTimePerActivity = async (): Promise => { + // Use mock data + const report: TimePerActivity = { + developmentTime: 100, + meetingTime: 200, + adminTime: 300, + ownWorkTime: 50, + studyTime: 75, + testingTime: 110, + }; + + // Set the state with the mock data + setDevelopmentTime(report.developmentTime); + setMeetingTime(report.meetingTime); + setAdminTime(report.adminTime); + setOwnWorkTime(report.ownWorkTime); + setStudyTime(report.studyTime); + setTestingTime(report.testingTime); + + await Promise.resolve(); + }; + + useEffect(() => { + void fetchTimePerActivity(); + }); + + return ( + <> +

    + Total Time Per Activity In: {projectName}{" "} +

    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Activity + Total Time (min) +
    Development + { + event.preventDefault(); + }} + /> +
    Meeting + { + event.preventDefault(); + }} + /> +
    Administration + { + event.preventDefault(); + }} + /> +
    Own Work + { + event.preventDefault(); + }} + /> +
    Studies + { + event.preventDefault(); + }} + /> +
    Testing + { + event.preventDefault(); + }} + /> +
    +
    +
    + + ); +} diff --git a/frontend/src/Pages/ProjectManagerPages/PMTotalTimeActivity.tsx b/frontend/src/Pages/ProjectManagerPages/PMTotalTimeActivity.tsx index 676ea28..257a89c 100644 --- a/frontend/src/Pages/ProjectManagerPages/PMTotalTimeActivity.tsx +++ b/frontend/src/Pages/ProjectManagerPages/PMTotalTimeActivity.tsx @@ -1,14 +1,11 @@ import BackButton from "../../Components/BackButton"; import BasicWindow from "../../Components/BasicWindow"; -import TimeReport from "../../Components/NewWeeklyReport"; +import TimePerActivity from "../../Components/TimePerActivity"; function PMTotalTimeActivity(): JSX.Element { const content = ( <> -

    - Total Time Per Activity -

    - + ); From a3fc71f4bfc0b6131deef705312a45fb2355f912 Mon Sep 17 00:00:00 2001 From: Mattias Date: Wed, 20 Mar 2024 16:36:32 +0100 Subject: [PATCH 021/110] Changed path in main --- frontend/src/main.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index 643eb62..c023660 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -80,7 +80,7 @@ const router = createBrowserRouter([ element: , }, { - path: "/PMTimeActivity", + path: "/PMTimeActivity/:projectName", element: , }, { From 0befc4c7d18ae4ff11fb080d8a60b1868da5cf10 Mon Sep 17 00:00:00 2001 From: Mattias Date: Wed, 20 Mar 2024 16:36:39 +0100 Subject: [PATCH 022/110] Minor fix --- frontend/src/Components/TimePerRole.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/Components/TimePerRole.tsx b/frontend/src/Components/TimePerRole.tsx index a43e732..f62d83a 100644 --- a/frontend/src/Components/TimePerRole.tsx +++ b/frontend/src/Components/TimePerRole.tsx @@ -41,7 +41,7 @@ export default function TimePerRole(): JSX.Element { Tester: number; } - const fetchWeeklyReport = async (): Promise => { + const fetchTimePerRole = async (): Promise => { // Use mock data const report: TimePerRole = { PManager: 120, @@ -60,7 +60,7 @@ export default function TimePerRole(): JSX.Element { }; useEffect(() => { - void fetchWeeklyReport(); + void fetchTimePerRole(); }); return ( From b99de71c38fa7f030bc43b6678f18f4d24c4c98b Mon Sep 17 00:00:00 2001 From: Mattias Date: Wed, 20 Mar 2024 16:41:32 +0100 Subject: [PATCH 023/110] Update links in PMProjectMembers component --- frontend/src/Pages/ProjectManagerPages/PMProjectMembers.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/Pages/ProjectManagerPages/PMProjectMembers.tsx b/frontend/src/Pages/ProjectManagerPages/PMProjectMembers.tsx index 11b8636..f7c902e 100644 --- a/frontend/src/Pages/ProjectManagerPages/PMProjectMembers.tsx +++ b/frontend/src/Pages/ProjectManagerPages/PMProjectMembers.tsx @@ -17,7 +17,7 @@ function PMProjectMembers(): JSX.Element { const buttons = ( <> - +