diff --git a/backend/internal/database/sample_data/0010_sample_data.sql b/backend/internal/database/sample_data/0010_sample_data.sql index f519608..70499b0 100644 --- a/backend/internal/database/sample_data/0010_sample_data.sql +++ b/backend/internal/database/sample_data/0010_sample_data.sql @@ -1,220 +1,58 @@ INSERT OR IGNORE INTO users(username, password) -VALUES ("admin", "123"), - ("user", "123"), - ("user2", "123"), - ("John", "123"), - ("Emma", "123"), - ("Michael", "123"), - ("Liam", "123"), - ("Oliver", "123"), - ("Amelia", "123"), - ("Benjamin", "123"), - ("Mia", "123"), - ("Elijah", "123"), - ("Charlotte", "123"), - ("Henry", "123"), - ("Harper", "123"), - ("Lucas", "123"), - ("Emily", "123"), - ("Alexander", "123"), - ("Daniel", "123"), - ("Ella", "123"), - ("Matthew", "123"), - ("Madison", "123"), - ("Samuel", "123"), - ("Avery", "123"), - ("Sofia", "123"), - ("David", "123"), - ("Victoria", "123"), - ("Jackson", "123"), - ("Abigail", "123"), - ("Gabriel", "123"), - ("Luna", "123"), - ("Wyatt", "123"), - ("Chloe", "123"), - ("Nora", "123"), - ("Joshua", "123"), - ("Hazel", "123"), - ("Riley", "123"), - ("Scarlett", "123"), - ("Aria", "123"), - ("Carter", "123"), - ("Grace", "123"), - ("Jayden", "123"), - ("Hannah", "123"), - ("Zoe", "123"), - ("Luke", "123"), - ("Sophia", "123"), - ("Jack", "123"), - ("Isabella", "123"), - ("William", "123"), - ("Mason", "123"), - ("Evelyn", "123"), - ("James", "123"), - ("Cynthia", "123"), - ("Abraham", "123"), - ("Ava", "123"), - ("Aiden", "123"), - ("Natalie", "123"), - ("Lily", "123"), - ("Olivia", "123"), - ("Alexander", "123"), - ("Ethan", "123"), - ("Mila", "123"), - ("Evelyn", "123"), - ("Logan", "123"), - ("Riley", "123"), - ("Grace", "123"), - ("Arnold", "123"), - ("Connor", "123"), - ("Samantha", "123"), - ("Emma", "123"), - ("Sarah", "123"), - ("Nathan", "123"), - ("Layla", "123"), - ("Ryan", "123"), - ("Zoey", "123"), - ("Megan", "123"), - ("Christian", "123"), - ("Eva", "123"), - ("Isaac", "123"), - ("Michaela", "123"), - ("Caroline", "123"), - ("Elijah", "123"), - ("Elena", "123"), - ("Julian", "123"), - ("Sophie", "123"), - ("Gabriella", "123"), - ("Cole", "123"), - ("Hannah", "123"), - ("Lucy", "123"), - ("Katherine", "123"), - ("Benjamin", "123"), - ("Ella", "123"), - ("Evan", "123"); +VALUES ("admin", "123"); -INSERT OR IGNORE INTO projects(name, description, owner_user_id) -VALUES ("projecttest1", "Description for projecttest1", 1), - ("projecttest2", "Description for projecttest2", 1), - ("projecttest3", "Description for projecttest3", 1), - ("projecttest4", "Description for projecttest4", 1), - ("projecttest5", "Description for projecttest5", 1), - ("projecttest6", "Description for projecttest6", 1), - ("projecttest7", "Description for projecttest7", 1), - ("projecttest8", "Description for projecttest8", 1), - ("projecttest9", "Description for projecttest9", 1), - ("projecttest10", "Description for projecttest10", 1), - ("projecttest11", "Description for projecttest11", 1), - ("projecttest12", "Description for projecttest12", 1), - ("projecttest13", "Description for projecttest13", 1), - ("projecttest14", "Description for projecttest14", 1), - ("projecttest15", "Description for projecttest15", 1); +INSERT OR IGNORE INTO users(username, password) +VALUES ("user", "123"); + +INSERT OR IGNORE INTO users(username, password) +VALUES ("user2", "123"); + +INSERT OR IGNORE INTO site_admin VALUES (1); + +INSERT OR IGNORE INTO projects(name,description,owner_user_id) +VALUES ("projecttest","test project", 1); + +INSERT OR IGNORE INTO projects(name,description,owner_user_id) +VALUES ("projecttest2","test project2", 1); + +INSERT OR IGNORE INTO projects(name,description,owner_user_id) +VALUES ("projecttest3","test project3", 1); INSERT OR IGNORE INTO user_roles(user_id,project_id,p_role) -VALUES (1,1,"project_manager"), - (1,2,"project_manager"), - (1,3,"project_manager"), - (1,4,"project_manager"), - (1,5,"project_manager"), - (1,6,"project_manager"), - (1,7,"project_manager"), - (1,8,"project_manager"), - (1,9,"project_manager"), - (1,10,"project_manager"), - (1,11,"project_manager"), - (1,12,"project_manager"), - (1,13,"project_manager"), - (1,14,"project_manager"), - (1,15,"project_manager"), - (2,1,"project_manager"), - (2,2,"member"), - (2,3,"member"), - (2,4,"member"), - (2,5,"member"), - (2,6,"member"), - (2,7,"member"), - (2,8,"member"), - (2,9,"member"), - (2,10,"member"), - (2,11,"member"), - (2,12,"member"), - (2,13,"member"), - (2,14,"member"), - (2,15,"member"), - (3,1,"member"), - (3,2,"member"), - (3,3,"member"), - (3,4,"member"), - (3,5,"member"), - (3,6,"member"), - (3,7,"member"), - (3,8,"member"), - (3,9,"member"), - (3,10,"member"), - (3,11,"member"), - (3,12,"member"), - (3,13,"member"), - (3,14,"member"), - (3,15,"member"), - (4,1,"member"), - (4,2,"member"), - (4,3,"member"), - (4,4,"member"), - (4,5,"member"), - (4,6,"member"), - (4,7,"member"), - (4,8,"member"), - (4,9,"member"), - (4,10,"member"), - (4,11,"member"), - (4,12,"member"), - (4,13,"member"), - (4,14,"member"), - (4,15,"member"), - (5,1,"member"), - (5,2,"member"), - (5,3,"member"), - (5,4,"member"), - (5,5,"member"), - (5,6,"member"), - (5,7,"member"), - (5,8,"member"), - (5,9,"member"), - (5,10,"member"), - (5,11,"member"), - (5,12,"member"), - (5,13,"member"), - (5,14,"member"), - (5,15,"member"); +VALUES (1,1,"project_manager"); + +INSERT OR IGNORE INTO user_roles(user_id,project_id,p_role) +VALUES (1,2,"project_manager"); + +INSERT OR IGNORE INTO user_roles(user_id,project_id,p_role) +VALUES (1,3,"project_manager"); + +INSERT OR IGNORE INTO user_roles(user_id,project_id,p_role) +VALUES (2,1,"member"); + +INSERT OR IGNORE INTO user_roles(user_id,project_id,p_role) +VALUES (3,1,"member"); + +INSERT OR IGNORE INTO user_roles(user_id,project_id,p_role) +VALUES (3,2,"member"); + +INSERT OR IGNORE INTO user_roles(user_id,project_id,p_role) +VALUES (3,3,"member"); + +INSERT OR IGNORE INTO user_roles(user_id,project_id,p_role) +VALUES (2,1,"project_manager"); INSERT OR IGNORE INTO weekly_reports (user_id, project_id, week, development_time, meeting_time, admin_time, own_work_time, study_time, testing_time, signed_by) -VALUES (2, 1, 12, 100, 50, 30, 150, 80, 20, NULL), - (3, 1, 12, 200, 80, 20, 200, 100, 30, NULL), - (3, 1, 14, 150, 70, 40, 180, 90, 25, NULL), - (3, 2, 12, 120, 60, 35, 160, 85, 15, NULL), - (3, 3, 12, 180, 90, 25, 190, 110, 40, NULL), - (2, 1, 13, 130, 70, 40, 170, 95, 35, NULL), - (3, 1, 15, 140, 60, 50, 200, 120, 30, NULL), - (2, 2, 11, 110, 50, 45, 140, 70, 25, NULL), - (3, 3, 14, 170, 80, 30, 180, 100, 35, NULL), - (3, 3, 15, 200, 100, 20, 220, 130, 45, NULL), - (2, 4, 12, 120, 60, 40, 160, 80, 30, NULL), - (3, 5, 14, 150, 70, 30, 180, 90, 25, NULL), - (3, 5, 15, 180, 90, 20, 190, 110, 35, NULL), - (2, 6, 11, 100, 50, 35, 130, 60, 20, NULL), - (3, 7, 14, 170, 80, 25, 180, 100, 30, NULL), - (2, 8, 12, 130, 70, 30, 170, 90, 25, NULL), - (2, 8, 13, 150, 80, 20, 180, 110, 35, NULL), - (3, 9, 12, 140, 60, 40, 180, 100, 30, NULL), - (3, 10, 11, 120, 50, 45, 150, 70, 25, NULL), - (2, 11, 13, 110, 60, 35, 140, 80, 30, NULL), - (3, 12, 12, 160, 70, 30, 180, 100, 35, NULL), - (3, 12, 13, 180, 90, 25, 190, 110, 40, NULL), - (3, 12, 14, 200, 100, 20, 220, 130, 45, NULL), - (2, 13, 11, 100, 50, 45, 130, 60, 20, NULL), - (2, 13, 12, 120, 60, 40, 160, 80, 30, NULL), - (3, 14, 13, 140, 70, 30, 160, 90, 35, NULL), - (3, 15, 12, 150, 80, 25, 180, 100, 30, NULL), - (3, 15, 13, 170, 90, 20, 190, 110, 35, NULL); +VALUES (2, 1, 12, 20, 10, 5, 30, 15, 10, NULL); -INSERT OR IGNORE INTO site_admin VALUES (1); \ No newline at end of file +INSERT OR IGNORE INTO weekly_reports (user_id, project_id, week, development_time, meeting_time, admin_time, own_work_time, study_time, testing_time, signed_by) +VALUES (3, 1, 12, 20, 10, 5, 30, 15, 10, NULL); + +INSERT OR IGNORE INTO weekly_reports (user_id, project_id, week, development_time, meeting_time, admin_time, own_work_time, study_time, testing_time, signed_by) +VALUES (3, 1, 14, 20, 10, 5, 30, 15, 10, NULL); + +INSERT OR IGNORE INTO weekly_reports (user_id, project_id, week, development_time, meeting_time, admin_time, own_work_time, study_time, testing_time, signed_by) +VALUES (3, 2, 12, 20, 10, 5, 30, 15, 10, NULL); + +INSERT OR IGNORE INTO weekly_reports (user_id, project_id, week, development_time, meeting_time, admin_time, own_work_time, study_time, testing_time, signed_by) +VALUES (3, 3, 12, 20, 10, 5, 30, 15, 10, NULL); diff --git a/frontend/src/Components/AddProject.tsx b/frontend/src/Components/AddProject.tsx index cbc3622..c8a1c66 100644 --- a/frontend/src/Components/AddProject.tsx +++ b/frontend/src/Components/AddProject.tsx @@ -67,7 +67,6 @@ function AddProject(): JSX.Element { e.preventDefault(); setName(e.target.value); }} - placeholder={"Name"} />
diff --git a/frontend/src/Components/AddUserToProject.tsx b/frontend/src/Components/AddUserToProject.tsx index 43d9345..f567560 100644 --- a/frontend/src/Components/AddUserToProject.tsx +++ b/frontend/src/Components/AddUserToProject.tsx @@ -1,9 +1,9 @@ import { useEffect, useState } from "react"; import Button from "./Button"; import AddMember, { AddMemberInfo } from "./AddMember"; +import BackButton from "./BackButton"; import GetUsersInProject, { ProjectMember } from "./GetUsersInProject"; import GetAllUsers from "./GetAllUsers"; -import InputField from "./InputField"; /** * Provides UI for adding a member to a project. @@ -13,7 +13,6 @@ function AddUserToProject(props: { projectName: string }): JSX.Element { const [names, setNames] = useState([]); const [users, setUsers] = useState([]); const [usersProj, setUsersProj] = useState([]); - const [search, setSearch] = useState(""); // Gets all users and project members for filtering GetAllUsers({ setUsersProp: setUsers }); @@ -37,10 +36,8 @@ function AddUserToProject(props: { projectName: string }): JSX.Element { // Attempts to add all of the selected users to the project const handleAddClick = async (): Promise => { - if (names.length === 0) { + if (names.length === 0) alert("You have to choose at least one user to add"); - return; - } for (const name of names) { const newMember: AddMemberInfo = { userName: name, @@ -63,47 +60,32 @@ function AddUserToProject(props: { projectName: string }): JSX.Element { }; return ( -
+

{props.projectName}

Choose users to add:

- -
- { - setSearch(e.target.value); - }} - /> -
    +
    +
      - {users - .filter((user) => { - return search.toLowerCase() === "" - ? user - : user.toLowerCase().includes(search.toLowerCase()); - }) - .map((user) => ( -
    • { - handleUserClick(user); - }} - > - {user} -
    • - ))} + {users.map((user) => ( +
    • { + handleUserClick(user); + }} + > + {user} +
    • + ))}

    @@ -117,7 +99,9 @@ function AddUserToProject(props: { projectName: string }): JSX.Element { }} type="button" /> +

+

); } diff --git a/frontend/src/Components/ChangeUsername.tsx b/frontend/src/Components/ChangeUsername.tsx index 608c24c..2f73bb6 100644 --- a/frontend/src/Components/ChangeUsername.tsx +++ b/frontend/src/Components/ChangeUsername.tsx @@ -9,10 +9,6 @@ function ChangeUsername(props: { nameChange: StrNameChange }): void { alert("You have to give a new name\n\nName not changed"); return; } - if (props.nameChange.prevName === localStorage.getItem("username")) { - alert("You cannot change admin name"); - return; - } api .changeUserName(props.nameChange, localStorage.getItem("accessToken") ?? "") .then((response: APIResponse) => { diff --git a/frontend/src/Components/InputField.tsx b/frontend/src/Components/InputField.tsx index 5a5cdaf..699d8fa 100644 --- a/frontend/src/Components/InputField.tsx +++ b/frontend/src/Components/InputField.tsx @@ -4,21 +4,19 @@ * @returns {JSX.Element} The input field * @example * { * setExample(e.target.value); * }} + * value={example} * /> */ function InputField(props: { - label?: string; - placeholder?: string; - type?: string; - value?: string; - onChange?: (e: React.ChangeEvent) => void; + label: string; + type: string; + value: string; + onChange: (e: React.ChangeEvent) => void; }): JSX.Element { return (
@@ -32,7 +30,7 @@ function InputField(props: { className="appearance-none border-2 border-black rounded-2xl w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id={props.label} type={props.type} - placeholder={props.placeholder} + placeholder={props.label} value={props.value} onChange={props.onChange} /> diff --git a/frontend/src/Components/LoginCheck.tsx b/frontend/src/Components/LoginCheck.tsx index 752c2dc..f44d7f3 100644 --- a/frontend/src/Components/LoginCheck.tsx +++ b/frontend/src/Components/LoginCheck.tsx @@ -11,10 +11,6 @@ function LoginCheck(props: { password: string; setAuthority: Dispatch>; }): void { - if (props.username === "" || props.password === "") { - alert("Please enter username and password to login"); - return; - } const user: NewUser = { username: props.username, password: props.password, @@ -47,7 +43,6 @@ function LoginCheck(props: { } } else { console.error("Token could not be fetched/No such user"); - alert("Could not login, wrong username or password"); } }) .catch((error) => { diff --git a/frontend/src/Components/LoginField.tsx b/frontend/src/Components/LoginField.tsx index 8d0aa62..dda1714 100644 --- a/frontend/src/Components/LoginField.tsx +++ b/frontend/src/Components/LoginField.tsx @@ -33,7 +33,6 @@ function Login(props: { props.setUsername(e.target.value); }} value={props.username} - placeholder={"Username"} />
-
- - )} -

Statistics:

-
-

Number of members: {users.length}

-

+

+ {props.projectname} +

+
+

Statistics:

+
+
+

Number of members: {users.length}

+

Total time reported:{" "} {Math.floor(totalTime.current / 60 / 24) + " d "} {Math.floor((totalTime.current / 60) % 24) + " h "} {(totalTime.current % 60) + " m "}

-

Project members:

-
- { - setSearch(e.target.value); - }} - /> -
    - {users - .filter((user) => { - return search.toLowerCase() === "" - ? user.Username - : user.Username.toLowerCase().includes( - search.toLowerCase(), - ); - }) - .map((user) => ( -
  • { - props.onClick(user.Username); - }} - > - - Name: {user.Username} -
    - Role: {user.UserRole} -
    -
  • - ))} +
    +

    Project members:

    +
    +
    +
      +
      + {users.map((user) => ( +
    • { + props.onClick(user.Username); + }} + > + + Name: {user.Username} +
      + Role: {user.UserRole} +
      +
    • + ))}
    diff --git a/frontend/src/Components/ProjectListAdmin.tsx b/frontend/src/Components/ProjectListAdmin.tsx index 9c98855..294a131 100644 --- a/frontend/src/Components/ProjectListAdmin.tsx +++ b/frontend/src/Components/ProjectListAdmin.tsx @@ -2,7 +2,6 @@ import { useState } from "react"; import { NewProject } from "../Types/goTypes"; import ProjectInfoModal from "./ProjectInfoModal"; import MemberInfoModal from "./MemberInfoModal"; -import InputField from "./InputField"; /** * A list of projects for admin manage projects page, that sets an onClick @@ -22,7 +21,6 @@ export function ProjectListAdmin(props: { const [projectName, setProjectName] = useState(""); const [userModalVisible, setUserModalVisible] = useState(false); const [username, setUsername] = useState(""); - const [search, setSearch] = useState(""); const handleClickUser = (username: string): void => { setUsername(username); @@ -46,7 +44,6 @@ export function ProjectListAdmin(props: { return ( <> -

    Manage Projects

    {projectModalVisible && ( )}
    - { - setSearch(e.target.value); - }} - /> -
      - {props.projects - .filter((project) => { - return search.toLowerCase() === "" - ? project.name - : project.name.toLowerCase().includes(search.toLowerCase()); - }) - .map((project) => ( -
    • { - handleClickProject(project.name); - }} - > - {project.name} -
    • - ))} +
        + {props.projects.map((project) => ( +
      • { + handleClickProject(project.name); + }} + > + {project.name} +
      • + ))}
    diff --git a/frontend/src/Components/Register.tsx b/frontend/src/Components/Register.tsx index af5808c..be35a74 100644 --- a/frontend/src/Components/Register.tsx +++ b/frontend/src/Components/Register.tsx @@ -61,7 +61,6 @@ export default function Register(): JSX.Element { onChange={(e) => { setUsername(e.target.value); }} - placeholder={"Username"} /> { setPassword(e.target.value); }} - placeholder={"Password"} />
    diff --git a/frontend/src/Components/UserInfoModal.tsx b/frontend/src/Components/UserInfoModal.tsx index 6caf8d9..eae011c 100644 --- a/frontend/src/Components/UserInfoModal.tsx +++ b/frontend/src/Components/UserInfoModal.tsx @@ -13,7 +13,6 @@ function UserInfoModal(props: { }): JSX.Element { const [showInput, setShowInput] = useState(false); const [newUsername, setNewUsername] = useState(""); - const [newPassword, setNewPassword] = useState(""); if (!props.isVisible) { return <>; } @@ -27,34 +26,11 @@ function UserInfoModal(props: { }; const handleClickChangeName = (): void => { - if (newUsername === "") return; - if ( - confirm( - `Do you really want to change username of ${props.username} to ${newUsername}?`, - ) - ) { - const nameChange: StrNameChange = { - prevName: props.username, - newName: newUsername.replace(/ /g, ""), - }; - ChangeUsername({ nameChange: nameChange }); - } else { - alert("Name was not changed!"); - } - }; - - const handleClickChangePassword = (): void => { - if (newPassword === "") return; - - if ( - confirm(`Are you sure you want to change password of ${props.username}?`) - ) { - //TODO: insert change password functionality - alert("Not implemented yet"); - setNewPassword(""); - } else { - alert("Password was not changed!"); - } + const nameChange: StrNameChange = { + prevName: props.username, + newName: newUsername.replace(/ /g, ""), + }; + ChangeUsername({ nameChange: nameChange }); }; return ( @@ -62,14 +38,14 @@ function UserInfoModal(props: { className="fixed inset-0 bg-black bg-opacity-30 backdrop-blur-sm flex justify-center items-center" > -
    +

    {props.username}

    - (Change Username or Password) + (Change Username)

    {showInput && (
    @@ -78,25 +54,14 @@ function UserInfoModal(props: { type={"text"} value={newUsername} onChange={function (e): void { + e.defaultPrevented; setNewUsername(e.target.value); }} - placeholder={"Username"} - /> -
    -