From 6b94f31e04cdf288d25aebbceebc16db71c6e7f9 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sat, 6 Jan 2024 15:47:24 +0800 Subject: [PATCH 01/12] Fix additional entry in transaction report pdf --- .../TransactionReportPDF/TransactionReportPDF.tsx | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/Components/TransactionReportPDF/TransactionReportPDF.tsx b/src/Components/TransactionReportPDF/TransactionReportPDF.tsx index f18627f..2c6889c 100644 --- a/src/Components/TransactionReportPDF/TransactionReportPDF.tsx +++ b/src/Components/TransactionReportPDF/TransactionReportPDF.tsx @@ -72,20 +72,6 @@ export default function TransactionReportPDF(props: props) { ).length } - - Rejected Transactions:{" "} - { - transactions_today.filter( - (transaction) => transaction.transaction_status == "Rejected" - ).length - } - Date: Sat, 6 Jan 2024 15:51:48 +0800 Subject: [PATCH 02/12] update woodpecker.yml to only run on master branch --- .woodpecker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.woodpecker.yml b/.woodpecker.yml index 62a9d7b..82bee88 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -12,4 +12,6 @@ steps: - npm run build - ssh root@10.0.10.4 'rm -rf /mnt/sda1/files/projects/borrowing_tracker_frontend/*' - scp -r dist/* root@10.0.10.4:/mnt/sda1/files/projects/borrowing_tracker_frontend + when: + - branch: master secrets: [SSH_KEY] From 433207f8e4ef8a45947ab334dcf90aa6085b000c Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sat, 6 Jan 2024 20:47:26 +0800 Subject: [PATCH 03/12] Fix search bar in equipment instance list page --- package-lock.json | 13 ++ package.json | 1 + .../EquipmentInstancesListPage.tsx | 130 +++++++++--------- 3 files changed, 77 insertions(+), 67 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5d37b69..a2b5e18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "react-redux": "^8.1.3", "react-router-dom": "^6.18.0", "react-toastify": "^9.1.3", + "react-virtuoso": "^4.6.2", "reactjs-popup": "^2.0.6", "styled-components": "^6.1.1" }, @@ -3895,6 +3896,18 @@ "react-dom": ">=16.6.0" } }, + "node_modules/react-virtuoso": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/react-virtuoso/-/react-virtuoso-4.6.2.tgz", + "integrity": "sha512-vvlqvzPif+MvBrJ09+hJJrVY0xJK9yran+A+/1iwY78k0YCVKsyoNPqoLxOxzYPggspNBNXqUXEcvckN29OxyQ==", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": ">=16 || >=17 || >= 18", + "react-dom": ">=16 || >=17 || >= 18" + } + }, "node_modules/reactjs-popup": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/reactjs-popup/-/reactjs-popup-2.0.6.tgz", diff --git a/package.json b/package.json index 389aa1a..2bd2909 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "react-redux": "^8.1.3", "react-router-dom": "^6.18.0", "react-toastify": "^9.1.3", + "react-virtuoso": "^4.6.2", "reactjs-popup": "^2.0.6", "styled-components": "^6.1.1" }, diff --git a/src/Pages/EquipmentInstancesListPage/EquipmentInstancesListPage.tsx b/src/Pages/EquipmentInstancesListPage/EquipmentInstancesListPage.tsx index 432b58a..b333d71 100644 --- a/src/Pages/EquipmentInstancesListPage/EquipmentInstancesListPage.tsx +++ b/src/Pages/EquipmentInstancesListPage/EquipmentInstancesListPage.tsx @@ -65,79 +65,75 @@ export default function EquipmentInstancesListPage() { width: "100%", minHeight: "100%", minWidth: "100%", - flexWrap: "wrap", }} > -
-
+ + + theme.palette.getContrastText(theme.palette.background.paper), + }, + }} + value={filter} + onChange={(_event, newValue) => { + setFilter(newValue); + }} + freeSolo + id="custom-input-demo" + options={["Available", "Broken", "Glassware", "Miscellaneous"]} + renderInput={(params) => ( +
+ +
+ )} + /> +

- - - theme.palette.getContrastText( - theme.palette.background.paper - ), - }, - }} - value={filter} - onChange={(_event, newValue) => { - setFilter(newValue); - }} - freeSolo - id="custom-input-demo" - options={["Available", "Broken", "Glassware", "Miscellaneous"]} - renderInput={(params) => ( -

- -
- )} - /> -

- Results Found:{" "} - { - equipment_instances?.data?.filter((equipment) => - filter !== null - ? // If filter is not null, we filter if it matches any criteria - equipment.equipment_name - .toLowerCase() - .includes(filter.toLowerCase()) || - equipment.category - .toLowerCase() - .includes(filter.toLowerCase()) || - equipment.last_updated - .toLowerCase() - .includes(filter?.toLowerCase()) || - equipment.status.toLowerCase() == filter.toLowerCase() - : // If filter keyword is null then we just pass through everything as if we did not filter at all - true - ).length - } -

-
+ Results Found:{" "} + { + equipment_instances?.data?.filter((equipment) => + filter !== null + ? // If filter is not null, we filter if it matches any criteria + equipment.equipment_name + .toLowerCase() + .includes(filter.toLowerCase()) || + equipment.category + .toLowerCase() + .includes(filter.toLowerCase()) || + equipment.last_updated + .toLowerCase() + .includes(filter?.toLowerCase()) || + equipment.status.toLowerCase() == filter.toLowerCase() + : // If filter keyword is null then we just pass through everything as if we did not filter at all + true + ).length + } +

+
Date: Sun, 7 Jan 2024 10:52:53 +0800 Subject: [PATCH 04/12] Update dropdown menu for new transaction --- package-lock.json | 32 ++++++ package.json | 2 + src/CountTransactionEquipments/test | 0 .../AddTransactionPage/AddTransactionPage.tsx | 97 ++++++++++++++----- 4 files changed, 107 insertions(+), 24 deletions(-) delete mode 100644 src/CountTransactionEquipments/test diff --git a/package-lock.json b/package-lock.json index a2b5e18..97891f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,12 +24,14 @@ "react-router-dom": "^6.18.0", "react-toastify": "^9.1.3", "react-virtuoso": "^4.6.2", + "react-window": "^1.8.10", "reactjs-popup": "^2.0.6", "styled-components": "^6.1.1" }, "devDependencies": { "@types/react": "^18.2.15", "@types/react-dom": "^18.2.7", + "@types/react-window": "^1.8.8", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "@vitejs/plugin-react": "^4.0.3", @@ -1762,6 +1764,15 @@ "@types/react": "*" } }, + "node_modules/@types/react-window": { + "version": "1.8.8", + "resolved": "https://registry.npmjs.org/@types/react-window/-/react-window-1.8.8.tgz", + "integrity": "sha512-8Ls660bHR1AUA2kuRvVG9D/4XpRC6wjAaPT9dil7Ckc76eP9TKWZwwmgfq8Q1LANX3QNDnoU4Zp48A3w+zK69Q==", + "dev": true, + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/scheduler": { "version": "0.16.5", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.5.tgz", @@ -3373,6 +3384,11 @@ "resolved": "https://registry.npmjs.org/media-engine/-/media-engine-1.0.3.tgz", "integrity": "sha512-aa5tG6sDoK+k70B9iEX1NeyfT8ObCKhNDs6lJVpwF6r8vhUfuKMslIcirq6HIUYuuUYLefcEQOn9bSBOvawtwg==" }, + "node_modules/memoize-one": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz", + "integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==" + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -3908,6 +3924,22 @@ "react-dom": ">=16 || >=17 || >= 18" } }, + "node_modules/react-window": { + "version": "1.8.10", + "resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.10.tgz", + "integrity": "sha512-Y0Cx+dnU6NLa5/EvoHukUD0BklJ8qITCtVEPY1C/nL8wwoZ0b5aEw8Ff1dOVHw7fCzMt55XfJDd8S8W8LCaUCg==", + "dependencies": { + "@babel/runtime": "^7.0.0", + "memoize-one": ">=3.1.1 <6" + }, + "engines": { + "node": ">8.0.0" + }, + "peerDependencies": { + "react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/reactjs-popup": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/reactjs-popup/-/reactjs-popup-2.0.6.tgz", diff --git a/package.json b/package.json index 2bd2909..a1000f4 100644 --- a/package.json +++ b/package.json @@ -26,12 +26,14 @@ "react-router-dom": "^6.18.0", "react-toastify": "^9.1.3", "react-virtuoso": "^4.6.2", + "react-window": "^1.8.10", "reactjs-popup": "^2.0.6", "styled-components": "^6.1.1" }, "devDependencies": { "@types/react": "^18.2.15", "@types/react-dom": "^18.2.7", + "@types/react-window": "^1.8.8", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "@vitejs/plugin-react": "^4.0.3", diff --git a/src/CountTransactionEquipments/test b/src/CountTransactionEquipments/test deleted file mode 100644 index e69de29..0000000 diff --git a/src/Pages/AddTransactionPage/AddTransactionPage.tsx b/src/Pages/AddTransactionPage/AddTransactionPage.tsx index d088a53..0ea14c3 100644 --- a/src/Pages/AddTransactionPage/AddTransactionPage.tsx +++ b/src/Pages/AddTransactionPage/AddTransactionPage.tsx @@ -20,6 +20,7 @@ import { CircularProgress, MenuItem, OutlinedInput, + Autocomplete, } from "@mui/material"; import React from "react"; import Header from "../../Components/Header/Header"; @@ -126,29 +127,50 @@ export default function AddTransactionPage() {
- Items Requested - + equipments: newValue.map((item) => item.id), + }); + }} + renderInput={(params) => ( + + )} + /> - Assigned Teacher + + Assigned Teacher + - Subject + + Subject + ) => { @@ -181,7 +209,14 @@ export default function AddTransactionPage() { /> - Remarks + + Remarks + - Consumables + + Consumables + - Additional Members + + Additional Members + Date: Sun, 7 Jan 2024 10:56:28 +0800 Subject: [PATCH 05/12] Remove redundant labels --- src/Pages/AddTransactionPage/AddTransactionPage.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Pages/AddTransactionPage/AddTransactionPage.tsx b/src/Pages/AddTransactionPage/AddTransactionPage.tsx index 0ea14c3..f9c69e1 100644 --- a/src/Pages/AddTransactionPage/AddTransactionPage.tsx +++ b/src/Pages/AddTransactionPage/AddTransactionPage.tsx @@ -33,10 +33,10 @@ export default function AddTransactionPage() { equipments: [] as number[], teacher: 0, subject: "", - remarks: " ", + remarks: "", transaction_status: "Pending Approval", - consumables: " ", - additional_members: " ", + consumables: "", + additional_members: "", borrower: 0, }); /* @@ -147,7 +147,7 @@ export default function AddTransactionPage() { transaction.equipments.includes(equipment.id) ) || [] } - onChange={(event, newValue) => { + onChange={(_event, newValue) => { SetTransaction({ ...transaction, equipments: newValue.map((item) => item.id), @@ -203,7 +203,6 @@ export default function AddTransactionPage() { SetTransaction({ ...transaction, subject: e.target.value }); setError(""); }} - label={"Subject"} value={transaction.subject} placeholder={"The subject requiring the equipments"} /> @@ -224,7 +223,6 @@ export default function AddTransactionPage() { SetTransaction({ ...transaction, remarks: e.target.value }); setError(""); }} - label={"Remarks"} value={transaction.remarks} placeholder={"Optionally add a brief description of the request"} /> @@ -245,7 +243,6 @@ export default function AddTransactionPage() { SetTransaction({ ...transaction, consumables: e.target.value }); setError(""); }} - label={"Consumables"} value={transaction.consumables} placeholder={"Write down any consumables here"} /> @@ -269,7 +266,6 @@ export default function AddTransactionPage() { }); setError(""); }} - label={"Additional Members"} value={transaction.additional_members} placeholder={ "Write down any additional members borrowing on behalf of this transaction" From c1c092080cb564fe2903f6b83805b473638e3660 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sun, 7 Jan 2024 11:04:37 +0800 Subject: [PATCH 06/12] Refresh available equipments on transaction create --- src/Pages/AddTransactionPage/AddTransactionPage.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Pages/AddTransactionPage/AddTransactionPage.tsx b/src/Pages/AddTransactionPage/AddTransactionPage.tsx index f9c69e1..07d027c 100644 --- a/src/Pages/AddTransactionPage/AddTransactionPage.tsx +++ b/src/Pages/AddTransactionPage/AddTransactionPage.tsx @@ -309,6 +309,9 @@ export default function AddTransactionPage() { queryClient.invalidateQueries({ queryKey: ["equipment_instances"], }); + queryClient.invalidateQueries({ + queryKey: ["equipment_instances_available"], + }); queryClient.invalidateQueries({ queryKey: ["transactions"], }); From a685e3fcb51f5065e211c84ae6bb5bf13203ed71 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sun, 7 Jan 2024 12:12:05 +0800 Subject: [PATCH 07/12] Update debug backend url --- src/Components/API/API.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/API/API.tsx b/src/Components/API/API.tsx index 10984e0..2d6f26f 100644 --- a/src/Components/API/API.tsx +++ b/src/Components/API/API.tsx @@ -23,11 +23,11 @@ import { TransactionCreateType, } from "../Types/Types"; -const debug = false; +const debug = true; let backendURL; if (debug) { - backendURL = "http://localhost:8000/"; + backendURL = "http://localhost:8092/"; } else { backendURL = "https://csm-backend.keannu1.duckdns.org/"; } From 8810daa26caa9d1eccb9c1b7116711e5a0be6adc Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sun, 7 Jan 2024 12:20:22 +0800 Subject: [PATCH 08/12] Sort available equipments by id in ascending order --- src/Pages/AddTransactionPage/AddTransactionPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pages/AddTransactionPage/AddTransactionPage.tsx b/src/Pages/AddTransactionPage/AddTransactionPage.tsx index 07d027c..098b3eb 100644 --- a/src/Pages/AddTransactionPage/AddTransactionPage.tsx +++ b/src/Pages/AddTransactionPage/AddTransactionPage.tsx @@ -138,7 +138,7 @@ export default function AddTransactionPage() { a.id - b.id) || []} getOptionLabel={(option) => `${option.equipment_name} (ID:${option.id})` } From b5f4fc73260b3b3d597f3c2f26e273f059028d7f Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sun, 7 Jan 2024 12:20:41 +0800 Subject: [PATCH 09/12] Turn off debug flag --- src/Components/API/API.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/API/API.tsx b/src/Components/API/API.tsx index 2d6f26f..4c43e72 100644 --- a/src/Components/API/API.tsx +++ b/src/Components/API/API.tsx @@ -23,7 +23,7 @@ import { TransactionCreateType, } from "../Types/Types"; -const debug = true; +const debug = false; let backendURL; if (debug) { From e589588d8ce016b36b5956b2af0d77a6a1e96c2e Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sun, 7 Jan 2024 12:28:06 +0800 Subject: [PATCH 10/12] Fix equipment tally page --- .../Technician/TechnicianWidgets.tsx | 6 +- .../EquipmentTallyPage/EquipmentTallyPage.tsx | 130 +++++++++--------- 2 files changed, 67 insertions(+), 69 deletions(-) diff --git a/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx b/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx index 188ea7d..65726b0 100644 --- a/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx +++ b/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx @@ -38,14 +38,16 @@ export default function TechnicianWidgets() { if (isLoading) { return ( <> - +

- Loading + Loading widgets...

); diff --git a/src/Pages/EquipmentTallyPage/EquipmentTallyPage.tsx b/src/Pages/EquipmentTallyPage/EquipmentTallyPage.tsx index 6e703ab..51101bc 100644 --- a/src/Pages/EquipmentTallyPage/EquipmentTallyPage.tsx +++ b/src/Pages/EquipmentTallyPage/EquipmentTallyPage.tsx @@ -65,79 +65,75 @@ export default function EquipmentTallyPage() { width: "100%", minHeight: "100%", minWidth: "100%", - flexWrap: "wrap", }} > -
-
+ + + theme.palette.getContrastText(theme.palette.background.paper), + }, + }} + value={filter} + onChange={(_event, newValue) => { + setFilter(newValue); + }} + freeSolo + id="custom-input-demo" + options={["Glassware", "Miscellaneous"]} + renderInput={(params) => ( +
+ +
+ )} + /> +

- - - theme.palette.getContrastText( - theme.palette.background.paper - ), - }, - }} - value={filter} - onChange={(_event, newValue) => { - setFilter(newValue); - }} - freeSolo - id="custom-input-demo" - options={["Glassware", "Miscellaneous"]} - renderInput={(params) => ( -

- -
- )} - /> -

- Results Found:{" "} - { - equipments?.data?.filter((equipment) => - filter !== null - ? // If filter is not null, we filter if it matches any criteria - equipment.name - .toLowerCase() - .includes(filter.toLowerCase()) || - equipment.category - .toLowerCase() - .includes(filter.toLowerCase()) || - equipment.last_updated - .toLowerCase() - .includes(filter?.toLowerCase()) || - equipment.category.toLowerCase() == filter.toLowerCase() - : // If filter keyword is null then we just pass through everything as if we did not filter at all - true - ).length - } -

-
+ Results Found:{" "} + { + equipment_instances?.data?.filter((equipment) => + filter !== null + ? // If filter is not null, we filter if it matches any criteria + equipment.equipment_name + .toLowerCase() + .includes(filter.toLowerCase()) || + equipment.category + .toLowerCase() + .includes(filter.toLowerCase()) || + equipment.last_updated + .toLowerCase() + .includes(filter?.toLowerCase()) || + equipment.status.toLowerCase() == filter.toLowerCase() + : // If filter keyword is null then we just pass through everything as if we did not filter at all + true + ).length + } +

+
Date: Sun, 7 Jan 2024 12:30:34 +0800 Subject: [PATCH 11/12] Improve technician widgets loading --- .../Technician/TechnicianWidgets.tsx | 31 ++++--------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx b/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx index 65726b0..b412176 100644 --- a/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx +++ b/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx @@ -6,7 +6,6 @@ import { UserAPI, TransactionsAPI, } from "../../API/API"; -import CircularProgress from "@mui/material/CircularProgress"; import moment from "moment"; export default function TechnicianWidgets() { @@ -34,24 +33,6 @@ export default function TechnicianWidgets() { }, ], }); - const isLoading = queries.some((result) => result.isLoading); - if (isLoading) { - return ( - <> - -

- Loading widgets... -

- - ); - } return (
{queries[1].data?.filter( (equipment) => equipment.status == "Pending" - ).length || 0} + ).length || "Loading..."}

- {queries[1].data?.length || 0} + {queries[1].data?.length || "Loading..."}

@@ -169,7 +150,7 @@ export default function TechnicianWidgets() { > {queries[1].data?.filter( (equipment) => equipment.status == "Available" - ).length || 0} + ).length || "Loading..."}

{queries[1].data?.filter( (equipment) => equipment.status == "Broken" - ).length || 0} + ).length || "Loading..."}

@@ -249,7 +230,7 @@ export default function TechnicianWidgets() { todayStartOfDay, todayEndOfDay ) - ).length || 0} + ).length || "Loading..."}

From b4ab7ae2e42035cb23f3f807c52bae84b35ae4d6 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sun, 7 Jan 2024 12:47:23 +0800 Subject: [PATCH 12/12] Change site name --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 6010514..cd834f8 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - CITC Equipment Tracker + CSM Equipment Tracker