diff --git a/Client/package-lock.json b/Client/package-lock.json index 76f31993f..df6c6da70 100644 --- a/Client/package-lock.json +++ b/Client/package-lock.json @@ -30,7 +30,8 @@ "react-router-dom": "^6.23.1", "react-toastify": "^10.0.5", "recharts": "2.12.7", - "redux-persist": "6.0.0" + "redux-persist": "6.0.0", + "vite-plugin-svgr": "^4.2.0" }, "devDependencies": { "@types/react": "^18.2.66", @@ -47,7 +48,6 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", - "dev": true, "license": "Apache-2.0", "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", @@ -74,7 +74,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.7.tgz", "integrity": "sha512-qJzAIcv03PyaWqxRgO4mSU3lihncDT296vnyuE2O8uA4w3UHWI4S3hgeZd1L8W1Bft40w9JxJ2b412iDUFFRhw==", - "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -84,7 +83,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.7.tgz", "integrity": "sha512-nykK+LEK86ahTkX/3TgauT0ikKoNCfKHEaZYTUVupJdTLzGNvrblu4u6fa7DhZONAltdf8e662t/abY8idrd/g==", - "dev": true, "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.2.0", @@ -115,7 +113,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true, "license": "MIT" }, "node_modules/@babel/generator": { @@ -137,7 +134,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.24.7.tgz", "integrity": "sha512-ctSdRHBi20qWOfy27RUb4Fhp07KSJ3sXcuSvTrXrc4aG8NSYDo1ici3Vhg9bg69y5bj0Mr1lh0aeEgTvc12rMg==", - "dev": true, "license": "MIT", "dependencies": { "@babel/compat-data": "^7.24.7", @@ -204,7 +200,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.24.7.tgz", "integrity": "sha512-1fuJEwIrp+97rM4RWdO+qrRsZlAeL1lQJoPqtCYWv0NL115XM93hIH4CSRln2w52SqvmY5hqdtauB6QFCDiZNQ==", - "dev": true, "license": "MIT", "dependencies": { "@babel/helper-environment-visitor": "^7.24.7", @@ -234,7 +229,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.24.7.tgz", "integrity": "sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==", - "dev": true, "license": "MIT", "dependencies": { "@babel/traverse": "^7.24.7", @@ -278,7 +272,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.24.7.tgz", "integrity": "sha512-yy1/KvjhV/ZCL+SM7hBrvnZJ3ZuT9OuZgIJAGpPEToANvc3iM6iDvBnRjtElWibHU6n8/LPR/EjX9EtIEYO3pw==", - "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -288,7 +281,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.7.tgz", "integrity": "sha512-NlmJJtvcw72yRJRcnCmGvSi+3jDEg8qFu3z0AFoymmzLx5ERVWyzd9kVXr7Th9/8yIJi2Zc6av4Tqz3wFs8QWg==", - "dev": true, "license": "MIT", "dependencies": { "@babel/template": "^7.24.7", @@ -571,7 +563,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -588,7 +579,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -605,7 +595,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -622,7 +611,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -639,7 +627,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -656,7 +643,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -673,7 +659,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -690,7 +675,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -707,7 +691,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -724,7 +707,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -741,7 +723,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -758,7 +739,6 @@ "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -775,7 +755,6 @@ "cpu": [ "mips64el" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -792,7 +771,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -809,7 +787,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -826,7 +803,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -843,7 +819,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -860,7 +835,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -877,7 +851,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -894,7 +867,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -911,7 +883,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -928,7 +899,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -945,7 +915,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1766,6 +1735,27 @@ "node": ">=14.0.0" } }, + "node_modules/@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.18.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.0.tgz", @@ -1773,7 +1763,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1787,7 +1776,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1801,7 +1789,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1815,7 +1802,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1829,7 +1815,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1843,7 +1828,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1857,7 +1841,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1871,7 +1854,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1885,7 +1867,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1899,7 +1880,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1913,7 +1893,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1927,7 +1906,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1941,7 +1919,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1955,7 +1932,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1969,7 +1945,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1983,7 +1958,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -2011,6 +1985,232 @@ "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==", "license": "BSD-3-Clause" }, + "node_modules/@svgr/babel-plugin-add-jsx-attribute": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-8.0.0.tgz", + "integrity": "sha512-b9MIk7yhdS1pMCZM8VeNfUlSKVRhsHZNMl5O9SfaX0l0t5wjdgu4IDzGB8bpnGBBOjGST3rRFVsaaEtI4W6f7g==", + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@svgr/babel-plugin-remove-jsx-attribute": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-remove-jsx-attribute/-/babel-plugin-remove-jsx-attribute-8.0.0.tgz", + "integrity": "sha512-BcCkm/STipKvbCl6b7QFrMh/vx00vIP63k2eM66MfHJzPr6O2U0jYEViXkHJWqXqQYjdeA9cuCl5KWmlwjDvbA==", + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@svgr/babel-plugin-remove-jsx-empty-expression": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-remove-jsx-empty-expression/-/babel-plugin-remove-jsx-empty-expression-8.0.0.tgz", + "integrity": "sha512-5BcGCBfBxB5+XSDSWnhTThfI9jcO5f0Ai2V24gZpG+wXF14BzwxxdDb4g6trdOux0rhibGs385BeFMSmxtS3uA==", + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@svgr/babel-plugin-replace-jsx-attribute-value": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-replace-jsx-attribute-value/-/babel-plugin-replace-jsx-attribute-value-8.0.0.tgz", + "integrity": "sha512-KVQ+PtIjb1BuYT3ht8M5KbzWBhdAjjUPdlMtpuw/VjT8coTrItWX6Qafl9+ji831JaJcu6PJNKCV0bp01lBNzQ==", + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@svgr/babel-plugin-svg-dynamic-title": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-svg-dynamic-title/-/babel-plugin-svg-dynamic-title-8.0.0.tgz", + "integrity": "sha512-omNiKqwjNmOQJ2v6ge4SErBbkooV2aAWwaPFs2vUY7p7GhVkzRkJ00kILXQvRhA6miHnNpXv7MRnnSjdRjK8og==", + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@svgr/babel-plugin-svg-em-dimensions": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-svg-em-dimensions/-/babel-plugin-svg-em-dimensions-8.0.0.tgz", + "integrity": "sha512-mURHYnu6Iw3UBTbhGwE/vsngtCIbHE43xCRK7kCw4t01xyGqb2Pd+WXekRRoFOBIY29ZoOhUCTEweDMdrjfi9g==", + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@svgr/babel-plugin-transform-react-native-svg": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-transform-react-native-svg/-/babel-plugin-transform-react-native-svg-8.1.0.tgz", + "integrity": "sha512-Tx8T58CHo+7nwJ+EhUwx3LfdNSG9R2OKfaIXXs5soiy5HtgoAEkDay9LIimLOcG8dJQH1wPZp/cnAv6S9CrR1Q==", + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@svgr/babel-plugin-transform-svg-component": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-transform-svg-component/-/babel-plugin-transform-svg-component-8.0.0.tgz", + "integrity": "sha512-DFx8xa3cZXTdb/k3kfPeaixecQLgKh5NVBMwD0AQxOzcZawK4oo1Jh9LbrcACUivsCA7TLG8eeWgrDXjTMhRmw==", + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@svgr/babel-preset": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@svgr/babel-preset/-/babel-preset-8.1.0.tgz", + "integrity": "sha512-7EYDbHE7MxHpv4sxvnVPngw5fuR6pw79SkcrILHJ/iMpuKySNCl5W1qcwPEpU+LgyRXOaAFgH0KhwD18wwg6ug==", + "dependencies": { + "@svgr/babel-plugin-add-jsx-attribute": "8.0.0", + "@svgr/babel-plugin-remove-jsx-attribute": "8.0.0", + "@svgr/babel-plugin-remove-jsx-empty-expression": "8.0.0", + "@svgr/babel-plugin-replace-jsx-attribute-value": "8.0.0", + "@svgr/babel-plugin-svg-dynamic-title": "8.0.0", + "@svgr/babel-plugin-svg-em-dimensions": "8.0.0", + "@svgr/babel-plugin-transform-react-native-svg": "8.1.0", + "@svgr/babel-plugin-transform-svg-component": "8.0.0" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@svgr/core": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@svgr/core/-/core-8.1.0.tgz", + "integrity": "sha512-8QqtOQT5ACVlmsvKOJNEaWmRPmcojMOzCz4Hs2BGG/toAp/K38LcsMRyLp349glq5AzJbCEeimEoxaX6v/fLrA==", + "dependencies": { + "@babel/core": "^7.21.3", + "@svgr/babel-preset": "8.1.0", + "camelcase": "^6.2.0", + "cosmiconfig": "^8.1.3", + "snake-case": "^3.0.4" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + } + }, + "node_modules/@svgr/core/node_modules/cosmiconfig": { + "version": "8.3.6", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz", + "integrity": "sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==", + "dependencies": { + "import-fresh": "^3.3.0", + "js-yaml": "^4.1.0", + "parse-json": "^5.2.0", + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/d-fischer" + }, + "peerDependencies": { + "typescript": ">=4.9.5" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@svgr/hast-util-to-babel-ast": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@svgr/hast-util-to-babel-ast/-/hast-util-to-babel-ast-8.0.0.tgz", + "integrity": "sha512-EbDKwO9GpfWP4jN9sGdYwPBU0kdomaPIL2Eu4YwmgP+sJeXT+L7bMwJUBnhzfH8Q2qMBqZ4fJwpCyYsAN3mt2Q==", + "dependencies": { + "@babel/types": "^7.21.3", + "entities": "^4.4.0" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + } + }, + "node_modules/@svgr/plugin-jsx": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@svgr/plugin-jsx/-/plugin-jsx-8.1.0.tgz", + "integrity": "sha512-0xiIyBsLlr8quN+WyuxooNW9RJ0Dpr8uOnH/xrCVO8GLUcwHISwj1AG0k+LFzteTkAA0GbX0kj9q6Dk70PTiPA==", + "dependencies": { + "@babel/core": "^7.21.3", + "@svgr/babel-preset": "8.1.0", + "@svgr/hast-util-to-babel-ast": "8.0.0", + "svg-parser": "^2.0.4" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + }, + "peerDependencies": { + "@svgr/core": "*" + } + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -2123,7 +2323,6 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "dev": true, "license": "MIT" }, "node_modules/@types/parse-json": { @@ -2266,7 +2465,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true, "license": "Python-2.0" }, "node_modules/array-buffer-byte-length": { @@ -2489,7 +2687,6 @@ "version": "4.23.1", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.1.tgz", "integrity": "sha512-TUfofFo/KsK/bWZ9TWQ5O26tsWW4Uhmt8IYklbnUa70udB6P2wA7w7o4PY4muaEPBQaAX+CEnmmIA41NVHtPVw==", - "dev": true, "funding": [ { "type": "opencollective", @@ -2547,11 +2744,21 @@ "node": ">=6" } }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/caniuse-lite": { "version": "1.0.30001636", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz", "integrity": "sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg==", - "dev": true, "funding": [ { "type": "opencollective", @@ -2989,13 +3196,32 @@ "csstype": "^3.0.2" } }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/electron-to-chromium": { "version": "1.4.810", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.810.tgz", "integrity": "sha512-Kaxhu4T7SJGpRQx99tq216gCq2nMxJo+uuT6uzz9l8TVN2stL7M06MIIXAtr9jsrLs2Glflgf2vMQRepxawOdQ==", - "dev": true, "license": "ISC" }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -3175,7 +3401,6 @@ "version": "0.21.5", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", - "dev": true, "hasInstallScript": true, "license": "MIT", "bin": { @@ -3214,7 +3439,6 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", - "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -3551,6 +3775,11 @@ "node": ">=4.0" } }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -3720,7 +3949,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -3773,7 +4001,6 @@ "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -4509,7 +4736,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -4561,7 +4787,6 @@ "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, "license": "MIT", "bin": { "json5": "lib/cli.js" @@ -4666,11 +4891,18 @@ "loose-envify": "cli.js" } }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dependencies": { + "tslib": "^2.0.3" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, "license": "ISC", "dependencies": { "yallist": "^3.0.2" @@ -4720,7 +4952,6 @@ "version": "3.3.7", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", - "dev": true, "funding": [ { "type": "github", @@ -4742,11 +4973,19 @@ "dev": true, "license": "MIT" }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, "node_modules/node-releases": { "version": "2.0.14", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", - "dev": true, "license": "MIT" }, "node_modules/object-assign": { @@ -5011,6 +5250,17 @@ "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==", "license": "ISC" }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/possible-typed-array-names": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", @@ -5025,7 +5275,6 @@ "version": "8.4.38", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", - "dev": true, "funding": [ { "type": "opencollective", @@ -5433,7 +5682,6 @@ "version": "4.18.0", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.18.0.tgz", "integrity": "sha512-QmJz14PX3rzbJCN1SG4Xe/bAAX2a6NpCP8ab2vfu2GiUr8AQcr2nCV/oEO3yneFarB67zk8ShlIyWb2LGTb3Sg==", - "dev": true, "license": "MIT", "dependencies": { "@types/estree": "1.0.5" @@ -5539,7 +5787,6 @@ "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -5621,6 +5868,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/snake-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", + "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -5634,7 +5890,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", - "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" @@ -5775,6 +6030,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/svg-parser": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/svg-parser/-/svg-parser-2.0.4.tgz", + "integrity": "sha512-e4hG1hRwoOdRb37cIMSgzNsxyzKfayW6VOflrwvR+/bzrkyxY/31WkbgnQpgtrNp1SdpJvpUAGTa/ZoiPNDuRQ==" + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -5797,6 +6057,11 @@ "node": ">=4" } }, + "node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -5920,7 +6185,6 @@ "version": "1.0.16", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz", "integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==", - "dev": true, "funding": [ { "type": "opencollective", @@ -5992,7 +6256,6 @@ "version": "5.3.1", "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.1.tgz", "integrity": "sha512-XBmSKRLXLxiaPYamLv3/hnP/KXDai1NDexN0FpkTaZXTfycHvkRHoenpgl/fvuK/kPbB6xAgoyiryAhQNxYmAQ==", - "dev": true, "license": "MIT", "dependencies": { "esbuild": "^0.21.3", @@ -6044,6 +6307,19 @@ } } }, + "node_modules/vite-plugin-svgr": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/vite-plugin-svgr/-/vite-plugin-svgr-4.2.0.tgz", + "integrity": "sha512-SC7+FfVtNQk7So0XMjrrtLAbEC8qjFPifyD7+fs/E6aaNdVde6umlVVh0QuwDLdOMu7vp5RiGFsB70nj5yo0XA==", + "dependencies": { + "@rollup/pluginutils": "^5.0.5", + "@svgr/core": "^8.1.0", + "@svgr/plugin-jsx": "^8.1.0" + }, + "peerDependencies": { + "vite": "^2.6.0 || 3 || 4 || 5" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -6164,7 +6440,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true, "license": "ISC" }, "node_modules/yaml": { diff --git a/Client/package.json b/Client/package.json index 9c54daf7f..f711bff9a 100644 --- a/Client/package.json +++ b/Client/package.json @@ -32,7 +32,8 @@ "react-router-dom": "^6.23.1", "react-toastify": "^10.0.5", "recharts": "2.12.7", - "redux-persist": "6.0.0" + "redux-persist": "6.0.0", + "vite-plugin-svgr": "^4.2.0" }, "devDependencies": { "@types/react": "^18.2.66", diff --git a/Client/src/App.jsx b/Client/src/App.jsx index a38084b7f..fd2f62eda 100644 --- a/Client/src/App.jsx +++ b/Client/src/App.jsx @@ -18,7 +18,11 @@ import CheckEmail from "./Pages/CheckEmail"; import SetNewPassword from "./Pages/SetNewPassword"; import NewPasswordConfirmed from "./Pages/NewPasswordConfirmed"; import ProtectedRoute from "./Components/ProtectedRoute"; +<<<<<<< HEAD import Details from "./Pages/Details"; +======= +import Maintenance from "./Pages/Maintenance"; +>>>>>>> upstream/master function App() { return ( @@ -54,6 +58,10 @@ function App() { path="integrations" element={} /> + } + /> } diff --git a/Client/src/Components/Avatar/index.jsx b/Client/src/Components/Avatar/index.jsx index c7805aac9..151914061 100644 --- a/Client/src/Components/Avatar/index.jsx +++ b/Client/src/Components/Avatar/index.jsx @@ -1,12 +1,12 @@ import { Avatar as MuiAvatar } from "@mui/material"; import PropTypes from "prop-types"; +import { useSelector } from "react-redux"; +import { useEffect, useState } from "react"; /** * @component * @param {Object} props * @param {string} props.src - Path to image for avatar - * @param {string} props.firstName - The users first name - * @param {string} props.lastName - The users last name * @param {boolean} props.small - Specifies if avatar should be large * @param {Object} [props.sx] - Additional styles to apply to the button. * @returns {JSX.Element} @@ -15,29 +15,49 @@ import PropTypes from "prop-types"; * */ -const Avatar = ({ src, firstName, lastName, small, sx }) => { - const borderColor = "#F0F2F4"; - const smallStyle = small ? { width: 32, height: 32 } : {}; +const Avatar = ({ src, small, sx }) => { + const { user } = useSelector((state) => state.auth); + + const style = small ? { width: 25, height: 25 } : { width: 64, height: 64 }; + const border = small ? 1 : 3; + + const [image, setImage] = useState(); + useEffect(() => { + if (user.avatarImage) { + setImage(`data:image/png;base64,${user.avatarImage}`); + } + }, [user?.avatarImage]); + return ( - {src === undefined ? `${firstName[0]}${lastName[0]}` : null} + {user.firstname?.charAt(0)}{user.lastname?.charAt(0)} ); }; Avatar.propTypes = { src: PropTypes.string, - firstName: PropTypes.string.isRequired, - lastName: PropTypes.string.isRequired, small: PropTypes.bool, sx: PropTypes.object, }; diff --git a/Client/src/Components/Charts/Servers/serverStatus.css b/Client/src/Components/Charts/Servers/serverStatus.css index 541019107..97a4fec3f 100644 --- a/Client/src/Components/Charts/Servers/serverStatus.css +++ b/Client/src/Components/Charts/Servers/serverStatus.css @@ -12,7 +12,7 @@ } .server-status-tile { - min-width: 310px; + min-width: 250px; width: calc(100% - 310px); padding: var(--spacing-general-1); border: 1px solid var(--color-border-0); diff --git a/Client/src/Components/DashboardMenu/index.jsx b/Client/src/Components/DashboardMenu/index.jsx index 2363352c1..a88274c5d 100644 --- a/Client/src/Components/DashboardMenu/index.jsx +++ b/Client/src/Components/DashboardMenu/index.jsx @@ -5,6 +5,7 @@ import Monitors from "../../assets/Images/Icon-monitor-gray.png"; import Incidents from "../../assets/Images/Icon-warning-gray.png"; import SensorsIcon from "../../assets/Images/Icon-signal-gray.png"; import AllInclusiveIcon from "../../assets/Images/Icon-link-gray.png"; +import MaintenanceIcon from "../../assets/Images/Icon-maintenance-gray.png"; import SettingsIcon from "../../assets/Images/Icon-setting-gray.png"; import React, { useState, useEffect } from "react"; import { useNavigate, useLocation } from "react-router-dom"; @@ -62,6 +63,13 @@ function DashboardMenu() { activeButton === "/integrations", () => handleClick(pathMap["/integrations"], "/integrations") )} + {DashboardMenuButton( + MaintenanceIcon, + "Maintenance", + "/maintenance", + activeButton === "/maintenance", + () => handleClick(pathMap["/maintenance"], "/maintenance") + )} {DashboardMenuButton( SettingsIcon, "Settings", diff --git a/Client/src/Components/MonitorTable/index.css b/Client/src/Components/MonitorTable/index.css new file mode 100644 index 000000000..360526fc4 --- /dev/null +++ b/Client/src/Components/MonitorTable/index.css @@ -0,0 +1,135 @@ +.host-row { + display: flex; + align-items: center; +} + +.host-row a { + width: var(--env-var-img-width-2); + height: var(--env-var-img-width-2); + color: var(--env-var-color-5); + margin-right: 10px; + margin-bottom: 2px; +} +.host-row a svg { + width: var(--env-var-font-size-large); + height: var(--env-var-font-size-large); +} +.host-row .host-percentage { + font-size: var(--env-var-font-size-small); +} + +.host-name { + width: fit-content; + margin-right: 10px; + font-weight: 700; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; +} + +.host-status { + width: fit-content; +} + +.host-status-details { + display: flex; + align-items: center; + border: 1px solid var(--env-var-color-4); + border-radius: var(--env-var-radius-2); + padding: calc(var(--env-var-spacing-1) / 2); +} + +.host-status-text { + font-size: var(--env-var-font-size-medium); + line-height: var(--env-var-font-size-medium); +} +.host-status-dot { + width: 6px; + height: 6px; + border-radius: 50%; + margin-right: calc(var(--env-var-spacing-1) / 2); +} + +.monitors .MuiPaper-root:has(table.MuiTable-root) { + box-shadow: none; + border: solid 1px var(--env-var-color-16); + border-radius: var(--env-var-radius-1); +} +.monitors .MuiTableBody-root .MuiTableRow-root:last-child .MuiTableCell-root { + border: none; +} +.monitors .MuiTableHead-root, +.monitors .MuiTableRow-root:hover { + background-color: var(--env-var-color-13); +} +.monitors .MuiTableHead-root .MuiTableCell-root, +.monitors .MuiTableBody-root .MuiTableCell-root { + font-size: var(--env-var-font-size-medium); +} +.monitors .MuiTableHead-root .MuiTableCell-root { + padding: var(--env-var-spacing-1) var(--env-var-spacing-2); + font-weight: 500; + color: var(--env-var-color-2); +} +.monitors .MuiTableHead-root span { + display: inline-block; + height: 17px; + width: 20px; + overflow: hidden; + margin-bottom: -2px; + margin-left: 2px; +} +.monitors .MuiTableHead-root span svg { + width: 20px; + height: 20px; +} +.monitors .MuiTableBody-root .MuiTableCell-root { + color: var(--env-var-color-5); + padding: 6px var(--env-var-spacing-2); +} + +.monitors .MuiPagination-root { + flex: 1; + margin-top: 35px; + border: solid 1px var(--env-var-color-16); + border-radius: var(--env-var-radius-1); + padding: var(--env-var-spacing-1-plus) var(--env-var-spacing-2); +} +.monitors .MuiPagination-root ul { + justify-content: center; +} +.monitors .MuiPagination-root ul li button { + font-size: var(--env-var-font-size-medium); + color: var(--env-var-color-5); + font-weight: 500; +} +.monitors .MuiPagination-root ul li:first-child { + margin-right: auto; +} +.monitors .MuiPagination-root ul li:last-child { + margin-left: auto; +} +.monitors .MuiPagination-root ul li:first-child button, +.monitors .MuiPagination-root ul li:last-child button { + border: solid 1px var(--env-var-color-16); + border-radius: var(--env-var-radius-1); +} +.monitors .MuiPagination-root ul li:first-child button { + padding: 0 var(--env-var-spacing-1) 0 var(--env-var-spacing-1-plus); +} +.monitors .MuiPagination-root ul li:last-child button { + padding: 0 var(--env-var-spacing-1-plus) 0 var(--env-var-spacing-1); +} +.monitors .MuiPagination-root ul li:first-child button::after, +.monitors .MuiPagination-root ul li:last-child button::before { + position: relative; + display: inline-block; +} +.monitors .MuiPagination-root ul li:first-child button::after { + content: "Previous"; + margin-left: 15px; +} +.monitors .MuiPagination-root ul li:last-child button::before { + content: "Next"; + margin-right: 15px; +} diff --git a/Client/src/Components/MonitorTable/index.jsx b/Client/src/Components/MonitorTable/index.jsx new file mode 100644 index 000000000..977c6e918 --- /dev/null +++ b/Client/src/Components/MonitorTable/index.jsx @@ -0,0 +1,193 @@ +import "./index.css"; +import { useState } from "react"; +import PropTypes from "prop-types"; +import ResponseTimeChart from "../Charts/ResponseTimeChart"; +import { + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Paper, + Pagination, + PaginationItem, +} from "@mui/material"; +import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded"; +import OpenInNewPage from "../../assets/icons/open-in-new-page.svg?react"; +import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded"; +import ArrowForwardRoundedIcon from "@mui/icons-material/ArrowForwardRounded"; + +/** + * Host component. + * This subcomponent receives a params object and displays the host details. + * + * @component + * @param {Object} params - An object containing the following properties: + * @param {string} params.url - The URL of the host. + * @param {string} params.title - The name of the host. + * @param {string} params.percentageColor - The color of the percentage text. + * @param {number} params.precentage - The percentage to display. + * @returns {React.ElementType} Returns a div element with the host details. + */ +const Host = ({ params }) => { + return ( +
+ + + +
{params.title}
+
+ {params.precentage}% +
+
+ ); +}; + +/** + * Status component. + * This subcomponent receives a params object and displays the status details of a monitor. + * + * @component + * @param {Object} params - An object containing the following properties: + * @param {string} params.backgroundColor - The background color of the status box. + * @param {string} params.statusDotColor - The color of the status dot. + * @param {string} params.status - The status text to display. + * @returns {React.ElementType} Returns a div element with the host status. + */ +const Status = ({ params }) => { + return ( +
+
+
+ + {params.status} + +
+
+ ); +}; + +/** + * MonitorTable component. + * Takes an array of monitor objects and displays them in a table. + * Each row in the table represents a monitor and includes the host, status, response time, and action. + * + * @component + * @param {Object[]} monitors - An array of monitor objects. Each object should have the following properties: + * @param {string} monitors[].url - The URL of the monitor. + * @param {string} monitors[].name - The name of the monitor. + * @param {boolean} monitors[].status - The status of the monitor. True if the monitor is up, false otherwise. + * @param {Object[]} monitors[].checks - An array of check objects for the response time chart. + * @returns {React.Component} Returns a table with the monitor data. + */ +const MonitorTable = ({ monitors = [] }) => { + const [page, setPage] = useState(0); + const rowsPerPage = 5; + + const handleChangePage = (event, newPage) => { + setPage(newPage); + }; + + const mappedRows = monitors + .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) + .map((monitor) => { + const params = { + url: monitor.url, + title: monitor.name, + precentage: 100, + percentageColor: + monitor.status === true + ? "var(--env-var-color-17)" + : "var(--env-var-color-19)", + status: monitor.status === true ? "up" : "down", + backgroundColor: + monitor.status === true + ? "var(--env-var-color-20)" + : "var(--env-var-color-21)", + statusDotColor: + monitor.status === true + ? "var(--env-var-color-17)" + : "var(--env-var-color-19)", + }; + + return ( + + + + + + + + + + + TODO Add Actions + + ); + }); + + return ( + <> + + + + + Host + + Status + + + + + Response Time + Actions + + + {mappedRows} +
+
+ handleChangePage(event, value - 1)} + shape="rounded" + renderItem={(item) => ( + + )} + /> + + ); +}; + +MonitorTable.propTypes = { + monitors: PropTypes.arrayOf(PropTypes.object).isRequired, +}; + +Status.propTypes = { params: PropTypes.object.isRequired }; +Host.propTypes = { params: PropTypes.object.isRequired }; + +export default MonitorTable; diff --git a/Client/src/Components/NavBar/index.css b/Client/src/Components/NavBar/index.css index b4a9a07ba..d412c0a20 100644 --- a/Client/src/Components/NavBar/index.css +++ b/Client/src/Components/NavBar/index.css @@ -5,12 +5,6 @@ justify-content: center; } -.icon-button-avatar { - width: 25px; - height: 25px; - margin-right: var(--env-var-spacing-1); -} - .icon-button-toggle-title { font-size: var(--env-var-font-size-medium); color: var(--env-var-color-5); @@ -30,3 +24,9 @@ box-shadow: none; background-color: transparent; } + +#menu-appbar svg { + width: 16px; + height: 16px; + color: var(--env-var-color-25); +} diff --git a/Client/src/Components/NavBar/index.jsx b/Client/src/Components/NavBar/index.jsx index 1e28f0aff..524c0a179 100644 --- a/Client/src/Components/NavBar/index.jsx +++ b/Client/src/Components/NavBar/index.jsx @@ -8,7 +8,7 @@ import Typography from "@mui/material/Typography"; import Menu from "@mui/material/Menu"; import MenuIcon from "@mui/icons-material/Menu"; import Container from "@mui/material/Container"; -import Avatar from "@mui/material/Avatar"; +import Avatar from "../Avatar"; import Tooltip from "@mui/material/Tooltip"; import MenuItem from "@mui/material/MenuItem"; import { useTheme } from "@mui/material/styles"; @@ -18,8 +18,18 @@ import { clearMonitorState } from "../../Features/Monitors/monitorsSlice"; import { useDispatch, useSelector } from "react-redux"; import { useNavigate } from "react-router-dom"; +import LockSvg from "../../assets/icons/lock.svg?react"; +import UserSvg from "../../assets/icons/user.svg?react"; +import TeamSvg from "../../assets/icons/user-two.svg?react"; +import LogoutSvg from "../../assets/icons/logout.svg?react"; -const settings = ["Profile", "Team", "Invite Colleagues", "Logout"]; +const settings = ["Profile", "Password", "Team", "Logout"]; +const icons = { + Profile: , + Team: , + Password: , + Logout: , +}; /** * NavBar component @@ -71,8 +81,8 @@ function NavBar() { case "Team": navigate("/account/team"); break; - case "Invite Colleagues": - console.log("Invite Colleagues"); + case "Password": + navigate("/account/password"); break; case "Logout": logout(); @@ -151,12 +161,7 @@ function NavBar() { sx={{ p: 0 }} >
- +
{authState.user.firstname} {authState.user.lastname}
@@ -189,10 +194,13 @@ function NavBar() { id="menu-item" key={setting} onClick={() => handleCloseUserMenu(setting)} + sx={{ width: "150px" }} > + {icons[setting]} {setting} diff --git a/Client/src/Components/ProgressBars/index.css b/Client/src/Components/ProgressBars/index.css index 8bd3fc966..5ba1939da 100644 --- a/Client/src/Components/ProgressBars/index.css +++ b/Client/src/Components/ProgressBars/index.css @@ -17,7 +17,8 @@ padding-left: 2px; } .progress-bar-container:has(p.input-error){ - border-color: var(--env-var-color-24); + border-color: var(--env-var-color-19); + background-color: var(--env-var-color-21); padding: 8px var(--env-var-spacing-1-plus); } .progress-bar-container p.input-error{ diff --git a/Client/src/Components/ProgressBars/index.jsx b/Client/src/Components/ProgressBars/index.jsx index 2d60683ef..40e1a5a2c 100644 --- a/Client/src/Components/ProgressBars/index.jsx +++ b/Client/src/Components/ProgressBars/index.jsx @@ -94,6 +94,9 @@ const ProgressUpload = ({ } : { ml: "auto", + "&:focus": { + outline: "none", + }, } } > diff --git a/Client/src/Components/TabPanels/Account/ProfilePanel.jsx b/Client/src/Components/TabPanels/Account/ProfilePanel.jsx index 2208fd646..a56b65919 100644 --- a/Client/src/Components/TabPanels/Account/ProfilePanel.jsx +++ b/Client/src/Components/TabPanels/Account/ProfilePanel.jsx @@ -1,5 +1,5 @@ import { useTheme } from "@emotion/react"; -import { useState } from "react"; +import { useRef, useState } from "react"; import TabPanel from "@mui/lab/TabPanel"; import { Box, Divider, Modal, Stack, Typography } from "@mui/material"; import ButtonSpinner from "../../ButtonSpinner"; @@ -16,6 +16,7 @@ import { update } from "../../../Features/Auth/authSlice"; import ImageField from "../../TextFields/Image"; import ImageIcon from "@mui/icons-material/Image"; import ProgressUpload from "../../ProgressBars"; +import { formatBytes } from "../../../Utils/fileUtils"; /** * ProfilePanel component displays a form for editing user profile information @@ -29,26 +30,28 @@ const ProfilePanel = () => { const theme = useTheme(); const dispatch = useDispatch(); + //redux state const { user, authToken, isLoading } = useSelector((state) => state.auth); + const idToName = { "edit-first-name": "firstname", "edit-last-name": "lastname", - //Disabled for now, will revisit in the future + // Disabled for now, will revisit in the future // "edit-email": "email", }; + + // Local state for form data, errors, and file handling const [localData, setLocalData] = useState({ firstname: user.firstname, lastname: user.lastname, - //Disabled for now, will revisit in the future - // email: user.email, - //TODO - upload picture - profilePicUrl: "placeholder", + // email: user.email, // Disabled for now }); const [errors, setErrors] = useState({}); - const [isOpen, setIsOpen] = useState(""); - const isModalOpen = (name) => isOpen === name; - const [loading, setLoading] = useState(false); + const [file, setFile] = useState(); + const intervalRef = useRef(null); + const [progress, setProgress] = useState({ value: 0, isLoading: false }); + // Handles input field changes and performs validation const handleChange = (event) => { const { value, id } = event.target; const name = idToName[id]; @@ -57,71 +60,51 @@ const ProfilePanel = () => { [name]: value, })); - const validation = editProfileValidation.validate( - { [name]: value }, - { abortEarly: false } - ); - - setErrors((prev) => { - const updatedErrors = { ...prev }; - - if (validation.error) { - updatedErrors[name] = validation.error.details[0].message; - } else { - delete updatedErrors[name]; - } - return updatedErrors; - }); + validateField({ [name]: value }, editProfileValidation, name); }; - //TODO - add setPicture state to localData - const [picture, setPicture] = useState(); - const [uploadProgress, setUploadProgress] = useState(0); - const [isUploading, setIsUploading] = useState(false); + // Handles image file const handlePicture = (event) => { - clearError("picture"); const pic = event.target.files[0]; - console.log(pic); - //TODO - add setPicture state to localData - setPicture({ name: pic.name, type: pic.type, size: formatBytes(pic.size) }); - setIsUploading(true); - - const { error } = imageValidation.validate( - { - type: pic.type, - size: pic.size, - }, - { abortEarly: false } + let error = validateField( + { type: pic.type, size: pic.size }, + imageValidation ); + if (error) return; - if (error) { - setErrors((prev) => { - const updatedErrors = { ...prev }; - updatedErrors["picture"] = error.details[0].message; - return updatedErrors; + setProgress((prev) => ({ ...prev, isLoading: true })); + setFile({ + src: URL.createObjectURL(pic), + name: pic.name, + size: formatBytes(pic.size), + }); + + //TODO - potentitally remove once image compression functions are implemented + intervalRef.current = setInterval(() => { + const buffer = 12; + setProgress((prev) => { + if (prev.value + buffer >= 100) { + clearInterval(intervalRef.current); + return { value: 100, isLoading: false }; + } + return { ...prev, value: prev.value + buffer }; }); - return; - } - - setTimeout(() => { - //TODO - add setPicture state to localData - setPicture((prev) => ({ ...prev, src: URL.createObjectURL(pic) })); - }, 1500); - - let progress = 0; - const interval = setInterval(() => { - progress += 10; - setUploadProgress(progress); - if (progress >= 100) { - clearInterval(interval); - } - }, 150); + }, 120); }; - const formatBytes = (bytes) => { - if (bytes === 0) return "0 Bytes"; - const megabytes = bytes / (1024 * 1024); - return megabytes.toFixed(2) + " MB"; + + // Validates input against provided schema and updates error state + const validateField = (toValidate, schema, name = "picture") => { + const { error } = schema.validate(toValidate, { abortEarly: false }); + setErrors((prev) => { + const prevErrors = { ...prev }; + if (error) prevErrors[name] = error.details[0].message; + else delete prevErrors[name]; + return prevErrors; + }); + if (error) return true; }; + + // Clears specific error from errors state const clearError = (err) => { setErrors((prev) => { const updatedErrors = { ...prev }; @@ -129,53 +112,59 @@ const ProfilePanel = () => { return updatedErrors; }); }; - const handleCancelUpload = () => { - //TODO - add setPicture state to localData - setPicture(); - setUploadProgress(0); - setIsUploading(false); - clearError("picture"); - }; - const handleClosePictureModal = () => { - setIsOpen(""); - setUploadProgress(0); - setIsUploading(false); - clearError("picture"); + + // Resets picture-related states and clears interval + const removePicture = () => { + errors["picture"] && clearError("picture"); + clearInterval(intervalRef.current); // interrupt interval if image upload is canceled prior to completing the process + setProgress({ value: 0, isLoading: false }); }; - //TODO - revisit once localData is set up properly - const handleDeletePicture = () => { - setLoading(true); - setTimeout(() => { - //TODO - add setPicture state to localData - setPicture(null); - setLoading(false); - }, 2000); - }; - //TODO - implement update profile function - const handleUpdatePicture = () => { + // Closes the picture update modal and resets related states + const closePictureModal = () => { + removePicture(); setIsOpen(""); - setUploadProgress(0); - setIsUploading(false); }; - //TODO - implement delete account function - const handleDeleteAccount = () => {}; - //TODO - implement save profile function + + // Updates profile image displayed on UI + const handleUpdatePicture = () => { + setProgress({ value: 0, isLoading: false }); + setLocalData((prev) => ({ + ...prev, + file: file.src, + })); + setIsOpen(""); + }; + + // Handles form submission to update user profile const handleSaveProfile = (event) => { event.preventDefault(); - if ( - localData.firstname === user.firstname && - localData.lastname === user.lastname && - localData.profilePicUrl === user.profilePicUrl - ) { - //TODO - add toast(profile data is unchanged) and maybe disable button - return; - } + // if ( + // localData.firstname === user.firstname && + // localData.lastname === user.lastname + // ) { + // // TODO: Add toast/notification for unchanged profile data + // return; + // } dispatch(update({ authToken, localData })); - //TODO - add toast confirmation + // TODO: Add toast/notification for profile update success }; + // Removes current profile image from UI + const handleDeletePicture = () => { + // TODO - implement delete picture function + }; + + // Initiates the account deletion process + const handleDeleteAccount = () => { + //TODO - implement delete account function + }; + + // Modal state and control functions + const [isOpen, setIsOpen] = useState(""); + const isModalOpen = (name) => isOpen === name; + return (
@@ -260,22 +249,11 @@ const ProfilePanel = () => { - - + +
+ ); +}; + +export default Maintenance; diff --git a/Client/src/Pages/Monitors/index.css b/Client/src/Pages/Monitors/index.css index 987bbd7cd..a21a3e125 100644 --- a/Client/src/Pages/Monitors/index.css +++ b/Client/src/Pages/Monitors/index.css @@ -1,7 +1,6 @@ .monitors, .new-monitor { width: 70vw; - padding: 4vw; } .monitors { @@ -9,13 +8,13 @@ } .monitors-bar { - margin-top: calc(2 * var(--env-var-spacing-2)); display: flex; justify-content: space-between; align-items: center; } .monitors-bar-title { + color: var(--env-var-color-1); font-size: 24px; font-weight: 700; } diff --git a/Client/src/Pages/Monitors/index.jsx b/Client/src/Pages/Monitors/index.jsx index 4c6d18606..a8f30623f 100644 --- a/Client/src/Pages/Monitors/index.jsx +++ b/Client/src/Pages/Monitors/index.jsx @@ -7,10 +7,11 @@ import { useNavigate } from "react-router-dom"; import Button from "../../Components/Button"; import ServerStatus from "../../Components/Charts/Servers/ServerStatus"; import SearchTextField from "../../Components/TextFields/Search/SearchTextField"; -import HostsTable from "../../Components/HostsTable"; -import Pagination from "../../Components/Pagination"; +import MonitorTable from "../../Components/MonitorTable"; +import { useTheme } from "@emotion/react"; const Monitors = () => { + const theme = useTheme(); const navigate = useNavigate(); const monitorState = useSelector((state) => state.monitors); const authState = useSelector((state) => state.auth); @@ -25,9 +26,13 @@ const Monitors = () => { }, 0); const down = monitorState.monitors.length - up; - return ( -
+
Hello, {authState.user.firstname} @@ -38,7 +43,7 @@ const Monitors = () => { onClick={() => { navigate("/monitors/create"); }} - sx={{ padding: "10px 20px", fontSize: "13px" }} + sx={{ padding: "6px 25px", fontSize: "13px" }} />
@@ -60,10 +65,8 @@ const Monitors = () => {
-
- -
- +
+
); diff --git a/Client/src/Pages/Monitors/monitors.css b/Client/src/Pages/Monitors/monitors.css index c2ed8532f..05ae79709 100644 --- a/Client/src/Pages/Monitors/monitors.css +++ b/Client/src/Pages/Monitors/monitors.css @@ -7,6 +7,7 @@ .current-monitors-title-holder { display: flex; + align-items: center; } .current-monitors-bar { @@ -18,16 +19,22 @@ font-size: 1rem; font-weight: bold; margin-right: var(--env-var-spacing-1); + color: var(--env-var-color-1); } .current-monitors-counter { - width: var(--env-var-spacing-2); - height: var(--env-var-spacing-2); + display: inline-flex; + justify-content: center; + align-items: center; + padding: 2px; + min-width: 22px; + min-height: 22px; background-color: var(--env-var-color-15); border: 1px solid var(--env-var-color-6); border-radius: 50%; - text-align: center; - align-items: center; + font-size: var(--env-var-font-size-medium); + font-weight: 500; + color: var(--env-var-color-5); } .monitors-v-gaping { @@ -66,24 +73,6 @@ font-size: var(--env-var-font-size-medium); } -.host-list-item { - display: flex; - align-items: center; - cursor: pointer; -} - -.host-list-item-open { - width: var(--env-var-img-width-2); - height: var(--env-var-img-width-2); - margin-right: 8px; -} - -.host-list-item-name { - font-size: var(--env-var-font-size-medium); - font-weight: bold; - margin-right: var(--env-var-spacing-1); -} - .host-list-item-precentage { font-size: var(--env-var-font-size-medium); } @@ -101,13 +90,6 @@ padding: calc(var(--env-var-spacing-1) / 2); } -.host-status-box-circle { - width: 6px; - height: 6px; - border-radius: 50%; - margin-right: calc(var(--env-var-spacing-1) / 2); -} - .host-actions { margin: auto; cursor: pointer; diff --git a/Client/src/Pages/Register/index.jsx b/Client/src/Pages/Register/index.jsx index 1760a5be2..617e04edd 100644 --- a/Client/src/Pages/Register/index.jsx +++ b/Client/src/Pages/Register/index.jsx @@ -11,12 +11,9 @@ import Check from "../../Components/Check/Check"; import Button from "../../Components/Button"; import Google from "../../assets/Images/Google.png"; import { registerValidation } from "../../Validation/validation"; - +import axiosInstance from "../../Utils/axiosConfig"; import { useDispatch } from "react-redux"; import { register } from "../../Features/Auth/authSlice"; -import axios from "axios"; - -const BASE_URL = import.meta.env.VITE_APP_API_BASE_URL; const Register = () => { const dispatch = useDispatch(); @@ -41,8 +38,8 @@ const Register = () => { }); useEffect(() => { - axios - .get(BASE_URL + "/auth/users/admin") + axiosInstance + .get("/auth/users/admin") .then((response) => { if (response.data.data === true) { navigate("/login"); diff --git a/Client/src/Pages/SetNewPassword/index.jsx b/Client/src/Pages/SetNewPassword/index.jsx index d2360c7c5..d0b4242ee 100644 --- a/Client/src/Pages/SetNewPassword/index.jsx +++ b/Client/src/Pages/SetNewPassword/index.jsx @@ -8,8 +8,7 @@ import LeftArrow from "../../assets/Images/arrow-left.png"; import { useParams } from "react-router-dom"; import { useState, useEffect } from "react"; import { newPasswordValidation } from "../../Validation/validation"; -import axios from "axios"; -const BASE_URL = import.meta.env.VITE_APP_API_BASE_URL; +import axiosInstance from "../../Utils/axiosConfig"; import { useNavigate } from "react-router-dom"; const SetNewPassword = () => { @@ -33,10 +32,10 @@ const SetNewPassword = () => { // TODO show loading spinner setIsLoading(true); try { - await axios.post(`${BASE_URL}/auth/recovery/validate`, { + await axiosInstance.post("/auth/recovery/validate", { recoveryToken: token, }); - await axios.post(`${BASE_URL}/auth/recovery/reset`, { + await axiosInstance.post("/auth/recovery/reset", { ...form, recoveryToken: token, }); diff --git a/Client/src/Pages/Status/index.jsx b/Client/src/Pages/Status/index.jsx index 33729f7e1..f0cf82b60 100644 --- a/Client/src/Pages/Status/index.jsx +++ b/Client/src/Pages/Status/index.jsx @@ -1,9 +1,7 @@ -import React from 'react' +import React from "react"; const Status = () => { - return ( -
Status
- ) -} + return
Status
; +}; -export default Status \ No newline at end of file +export default Status; diff --git a/Client/src/Utils/PathMap.js b/Client/src/Utils/PathMap.js index 2a86c17f7..a14aafe63 100644 --- a/Client/src/Utils/PathMap.js +++ b/Client/src/Utils/PathMap.js @@ -1,9 +1,10 @@ const pathMap = { - "/monitors": "Monitors", - "/incidents": "Incidents", - "/status" : "Status Pages", - "/integrations": "Integrations", - "/settings" : "Settings" -} + "/monitors": "Monitors", + "/incidents": "Incidents", + "/status": "Status Pages", + "/integrations": "Integrations", + "/maintenance": "maintenance", + "/settings": "Settings", +}; -export default pathMap; \ No newline at end of file +export default pathMap; diff --git a/Client/src/Utils/axiosConfig.js b/Client/src/Utils/axiosConfig.js new file mode 100644 index 000000000..8d3040028 --- /dev/null +++ b/Client/src/Utils/axiosConfig.js @@ -0,0 +1,27 @@ +import axios from "axios"; +import { clearAuthState } from "../Features/Auth/authSlice"; +const BASE_URL = import.meta.env.VITE_APP_API_BASE_URL; + +let store; + +export const injectStore = (s) => { + store = s; +}; + +const axiosInstance = axios.create({ + baseURL: BASE_URL, +}); + +axiosInstance.interceptors.response.use( + (response) => response, + (error) => { + console.error(error); + if (error.response && error.response.status === 401) { + console.log("Invalid token revoked"); + store.dispatch(clearAuthState()); + } + return Promise.reject(error); + } +); + +export default axiosInstance; diff --git a/Client/src/Utils/fileUtils.js b/Client/src/Utils/fileUtils.js new file mode 100644 index 000000000..699832b47 --- /dev/null +++ b/Client/src/Utils/fileUtils.js @@ -0,0 +1,11 @@ +export const formatBytes = (bytes) => { + if (bytes === 0) return "0 Bytes"; + const megabytes = bytes / (1024 * 1024); + return megabytes.toFixed(2) + " MB"; +}; + +export const checkImage = (url) => { + const img = new Image(); + img.src = url; + return img.naturalWidth !== 0; +}; \ No newline at end of file diff --git a/Client/src/assets/Images/Icon-maintenance-gray.png b/Client/src/assets/Images/Icon-maintenance-gray.png new file mode 100644 index 000000000..c2c203d76 Binary files /dev/null and b/Client/src/assets/Images/Icon-maintenance-gray.png differ diff --git a/Client/src/assets/Images/maintenance_window_frame.svg b/Client/src/assets/Images/maintenance_window_frame.svg new file mode 100644 index 000000000..51fd317fe --- /dev/null +++ b/Client/src/assets/Images/maintenance_window_frame.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Client/src/assets/icons/lock.svg b/Client/src/assets/icons/lock.svg new file mode 100644 index 000000000..38e8e1df0 --- /dev/null +++ b/Client/src/assets/icons/lock.svg @@ -0,0 +1,3 @@ + + + diff --git a/Client/src/assets/icons/logout.svg b/Client/src/assets/icons/logout.svg new file mode 100644 index 000000000..bf4183d73 --- /dev/null +++ b/Client/src/assets/icons/logout.svg @@ -0,0 +1,3 @@ + + + diff --git a/Client/src/assets/icons/open-in-new-page.svg b/Client/src/assets/icons/open-in-new-page.svg new file mode 100644 index 000000000..2bcb21c43 --- /dev/null +++ b/Client/src/assets/icons/open-in-new-page.svg @@ -0,0 +1,3 @@ + + + diff --git a/Client/src/assets/icons/search.svg b/Client/src/assets/icons/search.svg new file mode 100644 index 000000000..a1bc74224 --- /dev/null +++ b/Client/src/assets/icons/search.svg @@ -0,0 +1,3 @@ + + + diff --git a/Client/src/assets/icons/user-two.svg b/Client/src/assets/icons/user-two.svg new file mode 100644 index 000000000..8e40622c3 --- /dev/null +++ b/Client/src/assets/icons/user-two.svg @@ -0,0 +1,3 @@ + + + diff --git a/Client/src/assets/icons/user.svg b/Client/src/assets/icons/user.svg new file mode 100644 index 000000000..51e0e7b11 --- /dev/null +++ b/Client/src/assets/icons/user.svg @@ -0,0 +1,3 @@ + + + diff --git a/Client/src/main.jsx b/Client/src/main.jsx index 601dab68d..09754147d 100644 --- a/Client/src/main.jsx +++ b/Client/src/main.jsx @@ -8,6 +8,9 @@ import { ThemeProvider } from "@mui/material"; import { Provider } from "react-redux"; import { persistor, store } from "./store"; import { PersistGate } from "redux-persist/integration/react"; +import { injectStore } from "./Utils/axiosConfig.js"; + +injectStore(store); ReactDOM.createRoot(document.getElementById("root")).render( diff --git a/Client/vite.config.js b/Client/vite.config.js index d697e594d..9a3ca3842 100644 --- a/Client/vite.config.js +++ b/Client/vite.config.js @@ -1,9 +1,10 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +import svgr from 'vite-plugin-svgr'; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()], + plugins: [svgr(), react()], optimizeDeps: { include: ['@mui/material/Tooltip', '@emotion/styled'], }, diff --git a/Server/controllers/authController.js b/Server/controllers/authController.js index 757d8f78b..e06c58eb9 100644 --- a/Server/controllers/authController.js +++ b/Server/controllers/authController.js @@ -7,7 +7,7 @@ const { recoveryValidation, recoveryTokenValidation, newPasswordValidation, - deleteUserParamValidation + deleteUserParamValidation, } = require("../validation/joi"); const logger = require("../utils/logger"); require("dotenv").config(); @@ -59,6 +59,7 @@ const registerController = async (req, res, next) => { const userForToken = { ...newUser._doc }; delete userForToken.profileImage; + delete userForToken.avatarImage; const token = issueToken(userForToken); @@ -107,9 +108,13 @@ const loginController = async (req, res, next) => { // Remove password from user object. Should this be abstracted to DB layer? const userWithoutPassword = { ...user._doc }; delete userWithoutPassword.password; + delete userWithoutPassword.avatarImage; // Happy path, return token const token = issueToken(userWithoutPassword); + // reset avatar image + userWithoutPassword.avatarImage = user.avatarImage; + return res.status(200).json({ success: true, msg: successMessages.AUTH_LOGIN_USER, @@ -134,6 +139,7 @@ const userEditController = async (req, res, next) => { return; } + // TODO is this neccessary any longer? Verify ownership middleware should handle this if (req.params.userId !== req.user._id.toString()) { const error = new Error(errorMessages.AUTH_UNAUTHORIZED); error.status = 401; @@ -274,21 +280,23 @@ const resetPasswordController = async (req, res, next) => { */ const deleteUserController = async (req, res, next) => { try { - const token = req.headers.authorization.split(' ')[1]; - const decodedToken = jwt.decode(token) + const token = req.headers.authorization.split(" ")[1]; + const decodedToken = jwt.decode(token); const { _id, email } = decodedToken; const decodedTokenCastedAsRequest = { params: { - userId: _id + userId: _id, }, body: { - email - } - } + email, + }, + }; // Validate user - await deleteUserParamValidation.validateAsync(decodedTokenCastedAsRequest.body); + await deleteUserParamValidation.validateAsync( + decodedTokenCastedAsRequest.body + ); // Check if the user exists const user = await req.db.getUserByEmail(decodedTokenCastedAsRequest); @@ -297,45 +305,42 @@ const deleteUserController = async (req, res, next) => { } // 1. Find all the monitors associated with the user id - const monitors = await req.db.getMonitorsByUserId(decodedTokenCastedAsRequest); - + const monitors = await req.db.getMonitorsByUserId( + decodedTokenCastedAsRequest + ); + if (monitors) { // 2. Delete jobs associated with each monitor for (const monitor of monitors) { await req.jobQueue.deleteJob(monitor); } - + // 3. Delete all checks associated with each monitor for (const monitor of monitors) { await req.db.deleteChecks(monitor._id); } - + // 4. Delete all alerts associated with each monitor for (const monitor of monitors) { await req.db.deleteAlertByMonitorId(monitor._id); } - + // 5. Delete each monitor await req.db.deleteMonitorsByUserId(user._id); - + // 6. Delete the user by id await req.db.deleteUser(decodedTokenCastedAsRequest); - return res.status(200).json({ success: true, msg: successMessages.AUTH_DELETE_USER, }); - } else { - return res.status(404).json({ success: false, msg: errorMessages.MONITOR_GET_BY_USER_ID, }); - } - } catch (error) { error.service = SERVICE_NAME; next(error); diff --git a/Server/db/MongoDB.js b/Server/db/MongoDB.js index 738708696..4c9e19095 100644 --- a/Server/db/MongoDB.js +++ b/Server/db/MongoDB.js @@ -7,7 +7,8 @@ const RecoveryToken = require("../models/RecoveryToken"); const crypto = require("crypto"); const DUPLICATE_KEY_CODE = 11000; // MongoDB error code for duplicate key const { errorMessages, successMessages } = require("../utils/messages"); -const { error } = require("console"); +const { GenerateAvatarImage } = require("../utils/imageProcessing"); +const { ParseBoolean } = require("../utils/utils"); const connect = async () => { try { await mongoose.connect(process.env.DB_CONNECTION_STRING); @@ -33,12 +34,16 @@ const connect = async () => { const insertUser = async (req, res) => { try { const userData = { ...req.body }; - console.log(req.file); if (req.file) { + // 1. Save the full size image userData.profileImage = { data: req.file.buffer, contentType: req.file.mimetype, }; + + // 2. Get the avatar sized image + const avatar = await GenerateAvatarImage(req.file); + userData.avatarImage = avatar; } const newUser = new UserModel(userData); await newUser.save(); @@ -95,13 +100,29 @@ const updateUser = async (req, res) => { try { const candidateUser = { ...req.body }; - if (req.file) { + // ****************************************** + // Handle profile image + // ****************************************** + + if (ParseBoolean(candidateUser.deleteProfileImage) === true) { + candidateUser.profileImage = null; + candidateUser.avatarImage = null; + } else if (req.file) { + // 1. Save the full size image candidateUser.profileImage = { data: req.file.buffer, contentType: req.file.mimetype, }; + + // 2. Get the avaatar sized image + const avatar = await GenerateAvatarImage(req.file); + candidateUser.avatarImage = avatar; } + // ****************************************** + // End handling profile image + // ****************************************** + const updatedUser = await UserModel.findByIdAndUpdate( candidateUserId, candidateUser, @@ -115,7 +136,6 @@ const updateUser = async (req, res) => { } }; - /** * Delete a user by ID * @async @@ -600,5 +620,5 @@ module.exports = { editAlert, deleteAlert, deleteAlertByMonitorId, - deleteMonitorsByUserId + deleteMonitorsByUserId, }; diff --git a/Server/models/user.js b/Server/models/user.js index 3ad3daad7..1a8135e33 100644 --- a/Server/models/user.js +++ b/Server/models/user.js @@ -20,6 +20,9 @@ const UserSchema = mongoose.Schema( type: String, required: true, }, + avatarImage: { + type: String, + }, profileImage: { data: Buffer, contentType: String, diff --git a/Server/package-lock.json b/Server/package-lock.json index ad6637c18..bf83f62ca 100644 --- a/Server/package-lock.json +++ b/Server/package-lock.json @@ -23,6 +23,7 @@ "mongoose": "^8.3.3", "multer": "1.4.5-lts.1", "ping": "0.4.4", + "sharp": "0.33.4", "winston": "^3.13.0" }, "devDependencies": { @@ -47,6 +48,16 @@ "kuler": "^2.0.0" } }, + "node_modules/@emnapi/runtime": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.2.0.tgz", + "integrity": "sha512-bV21/9LQmcQeCPEg3BDFtvwL6cwiTMksYNWQQ4KOxCZikEGalWtenoZ0wCiukJINlGCIi2KXx01g4FoH/LxpzQ==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@hapi/hoek": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz", @@ -60,6 +71,456 @@ "@hapi/hoek": "^9.0.0" } }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.4.tgz", + "integrity": "sha512-p0suNqXufJs9t3RqLBO6vvrgr5OhgbWp76s5gTRvdmxmuv9E1rcaqGUsl3l4mKVmXPkTkTErXediAui4x+8PSA==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.0.2" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.4.tgz", + "integrity": "sha512-0l7yRObwtTi82Z6ebVI2PnHT8EB2NxBgpK2MiKJZJ7cz32R4lxd001ecMhzzsZig3Yv9oclvqqdV93jo9hy+Dw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.0.2" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.2.tgz", + "integrity": "sha512-tcK/41Rq8IKlSaKRCCAuuY3lDJjQnYIW1UXU1kxcEKrfL8WR7N6+rzNoOxoQRJWTAECuKwgAHnPvqXGN8XfkHA==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "macos": ">=11", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.2.tgz", + "integrity": "sha512-Ofw+7oaWa0HiiMiKWqqaZbaYV3/UGL2wAPeLuJTx+9cXpCRdvQhCLG0IH8YGwM0yGWGLpsF4Su9vM1o6aer+Fw==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "macos": ">=10.13", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.2.tgz", + "integrity": "sha512-iLWCvrKgeFoglQxdEwzu1eQV04o8YeYGFXtfWU26Zr2wWT3q3MTzC+QTCO3ZQfWd3doKHT4Pm2kRmLbupT+sZw==", + "cpu": [ + "arm" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.2.tgz", + "integrity": "sha512-x7kCt3N00ofFmmkkdshwj3vGPCnmiDh7Gwnd4nUwZln2YjqPxV1NlTyZOvoDWdKQVDL911487HOueBvrpflagw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.2.tgz", + "integrity": "sha512-cmhQ1J4qVhfmS6szYW7RT+gLJq9dH2i4maq+qyXayUSn9/3iY2ZeWpbAgSpSVbV2E1JUL2Gg7pwnYQ1h8rQIog==", + "cpu": [ + "s390x" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.2.tgz", + "integrity": "sha512-E441q4Qdb+7yuyiADVi5J+44x8ctlrqn8XgkDTwr4qPJzWkaHwD489iZ4nGDgcuya4iMN3ULV6NwbhRZJ9Z7SQ==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.2.tgz", + "integrity": "sha512-3CAkndNpYUrlDqkCM5qhksfE+qSIREVpyoeHIU6jd48SJZViAmznoQQLAv4hVXF7xyUB9zf+G++e2v1ABjCbEQ==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.2.tgz", + "integrity": "sha512-VI94Q6khIHqHWNOh6LLdm9s2Ry4zdjWJwH56WoiJU7NTeDwyApdZZ8c+SADC8OH98KWNQXnE01UdJ9CSfZvwZw==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.4.tgz", + "integrity": "sha512-RUgBD1c0+gCYZGCCe6mMdTiOFS0Zc/XrN0fYd6hISIKcDUbAW5NtSQW9g/powkrXYm6Vzwd6y+fqmExDuCdHNQ==", + "cpu": [ + "arm" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.0.2" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.4.tgz", + "integrity": "sha512-2800clwVg1ZQtxwSoTlHvtm9ObgAax7V6MTAB/hDT945Tfyy3hVkmiHpeLPCKYqYR1Gcmv1uDZ3a4OFwkdBL7Q==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.0.2" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.4.tgz", + "integrity": "sha512-h3RAL3siQoyzSoH36tUeS0PDmb5wINKGYzcLB5C6DIiAn2F3udeFAum+gj8IbA/82+8RGCTn7XW8WTFnqag4tQ==", + "cpu": [ + "s390x" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.31", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.0.2" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.4.tgz", + "integrity": "sha512-GoR++s0XW9DGVi8SUGQ/U4AeIzLdNjHka6jidVwapQ/JebGVQIpi52OdyxCNVRE++n1FCLzjDovJNozif7w/Aw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.0.2" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.4.tgz", + "integrity": "sha512-nhr1yC3BlVrKDTl6cO12gTpXMl4ITBUZieehFvMntlCXFzH2bvKG76tBL2Y/OqhupZt81pR7R+Q5YhJxW0rGgQ==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.0.2" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.4.tgz", + "integrity": "sha512-uCPTku0zwqDmZEOi4ILyGdmW76tH7dm8kKlOIV1XC5cLyJ71ENAAqarOHQh0RLfpIpbV5KOpXzdU6XkJtS0daw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.0.2" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.4.tgz", + "integrity": "sha512-Bmmauh4sXUsUqkleQahpdNXKvo+wa1V9KhT2pDA4VJGKwnKMJXiSTGphn0gnJrlooda0QxCtXc6RX1XAU6hMnQ==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.1.1" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.4.tgz", + "integrity": "sha512-99SJ91XzUhYHbx7uhK3+9Lf7+LjwMGQZMDlO/E/YVJ7Nc3lyDFZPGhjwiYdctoH2BOzW9+TnfqcaMKt0jHLdqw==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.4.tgz", + "integrity": "sha512-3QLocdTRVIrFNye5YocZl+KKpYKP+fksi1QhmOArgx7GyhIbQp/WrJRu176jm8IxromS7RIkzMiMINVdBtC8Aw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, "node_modules/@ioredis/commands": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz", @@ -2385,6 +2846,77 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, + "node_modules/sharp": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.4.tgz", + "integrity": "sha512-7i/dt5kGl7qR4gwPRD2biwD2/SvBn3O04J77XKFgL2OnZtQw+AG9wnuS/csmu80nPRHLYE9E41fyEiG8nhH6/Q==", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "color": "^4.2.3", + "detect-libc": "^2.0.3", + "semver": "^7.6.0" + }, + "engines": { + "libvips": ">=8.15.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.33.4", + "@img/sharp-darwin-x64": "0.33.4", + "@img/sharp-libvips-darwin-arm64": "1.0.2", + "@img/sharp-libvips-darwin-x64": "1.0.2", + "@img/sharp-libvips-linux-arm": "1.0.2", + "@img/sharp-libvips-linux-arm64": "1.0.2", + "@img/sharp-libvips-linux-s390x": "1.0.2", + "@img/sharp-libvips-linux-x64": "1.0.2", + "@img/sharp-libvips-linuxmusl-arm64": "1.0.2", + "@img/sharp-libvips-linuxmusl-x64": "1.0.2", + "@img/sharp-linux-arm": "0.33.4", + "@img/sharp-linux-arm64": "0.33.4", + "@img/sharp-linux-s390x": "0.33.4", + "@img/sharp-linux-x64": "0.33.4", + "@img/sharp-linuxmusl-arm64": "0.33.4", + "@img/sharp-linuxmusl-x64": "0.33.4", + "@img/sharp-wasm32": "0.33.4", + "@img/sharp-win32-ia32": "0.33.4", + "@img/sharp-win32-x64": "0.33.4" + } + }, + "node_modules/sharp/node_modules/color": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + }, + "engines": { + "node": ">=12.5.0" + } + }, + "node_modules/sharp/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/sharp/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT" + }, "node_modules/side-channel": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", diff --git a/Server/package.json b/Server/package.json index 2133afd4d..778a89acf 100644 --- a/Server/package.json +++ b/Server/package.json @@ -25,6 +25,7 @@ "mongoose": "^8.3.3", "multer": "1.4.5-lts.1", "ping": "0.4.4", + "sharp": "0.33.4", "winston": "^3.13.0" }, "devDependencies": { diff --git a/Server/utils/imageProcessing.js b/Server/utils/imageProcessing.js new file mode 100644 index 000000000..59793004f --- /dev/null +++ b/Server/utils/imageProcessing.js @@ -0,0 +1,27 @@ +const sharp = require("sharp"); +/** + * Generates a 64 * 64 pixel image from a given image + * @param {} file + */ +const GenerateAvatarImage = async (file) => { + try { + // Resize to target 64 * 64 + let resizedImageBuffer = await sharp(file.buffer) + .resize({ + width: 64, + height: 64, + fit: "cover", + }) + .toBuffer(); + + //Get b64 string + const base64Image = resizedImageBuffer.toString("base64"); + return base64Image; + } catch (error) { + throw error; + } +}; + +module.exports = { + GenerateAvatarImage, +}; diff --git a/Server/utils/utils.js b/Server/utils/utils.js new file mode 100644 index 000000000..934c99492 --- /dev/null +++ b/Server/utils/utils.js @@ -0,0 +1,21 @@ +/** + * Converts a request body parameter to a boolean. + * @param {string | boolean} value + * @returns {boolean} + */ +const ParseBoolean = (value) => { + if (value === true || value === "true") { + return true; + } else if ( + value === false || + value === "false" || + value === null || + value === undefined + ) { + return false; + } +}; + +module.exports = { + ParseBoolean, +}; diff --git a/Server/validation/joi.js b/Server/validation/joi.js index 8864fb8bd..28973f2cf 100644 --- a/Server/validation/joi.js +++ b/Server/validation/joi.js @@ -26,6 +26,7 @@ const editUserBodyValidation = joi.object({ firstname: joi.string(), lastname: joi.string(), profileImage: joi.any(), + deleteProfileImage: joi.boolean(), role: joi.string(), }); @@ -165,5 +166,5 @@ module.exports = { createCheckBodyValidation, getChecksParamValidation, deleteChecksParamValidation, - deleteUserParamValidation + deleteUserParamValidation, };