Merge branch 'develop' into 915-be-add-new-endpoint-for-refreshing-access-token

This commit is contained in:
Rushi Gandhi committed 2024-10-22 10:26:49 +05:30
commit af685f3c8b
142 files changed
+4063 -1619

No files matched your search

@@ -1,9 +1,14 @@
## Describe your changes ## Describe your changes
## Issue Number if applicable Provide a brief description of the changes you’ve made and their purpose.
## Checklist before requesting a review ## Issue number
- [ ] I have performed a self-review of my code Mention the issue number(s) this PR addresses (e.g., #123).
- [ ] I have inlcuded the issue # in the PR if applicable
- [ ] I have labelled the PR correctly ## Please ensure all items are checked off before requesting a review:
- [ ] I have performed a self-review of my code.
- [ ] I have included the issue # in the PR.
- [ ] I have labelled the PR correctly.
- [ ] My PR is granular and targeted to one specific feature only.
+1 -1
View File
@@ -8,7 +8,7 @@
"bracketSameLine": false, "bracketSameLine": false,
"singleAttributePerLine": true, "singleAttributePerLine": true,
"semi": true, "semi": true,
"jsx-single-quote": false, "jsxSingleQuote": false,
"quoteProps": "as-needed", "quoteProps": "as-needed",
"arrowParens": "always", "arrowParens": "always",
"trailingComma": "es5", "trailingComma": "es5",
+11 -14
View File
@@ -2,20 +2,17 @@ module.exports = {
root: true, root: true,
env: { browser: true, es2020: true }, env: { browser: true, es2020: true },
extends: [ extends: [
'eslint:recommended', "eslint:recommended",
'plugin:react/recommended', "plugin:react/recommended",
'plugin:react/jsx-runtime', "plugin:react/jsx-runtime",
'plugin:react-hooks/recommended', "plugin:react-hooks/recommended",
], ],
ignorePatterns: ['dist', '.eslintrc.cjs'], ignorePatterns: ["dist", ".eslintrc.cjs"],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, parserOptions: { ecmaVersion: "latest", sourceType: "module" },
settings: { react: { version: '18.2' } }, settings: { react: { version: "18.2" } },
plugins: ['react-refresh'], plugins: ["react-refresh"],
rules: { rules: {
'react/jsx-no-target-blank': 'off', "react/jsx-no-target-blank": "off",
'react-refresh/only-export-components': [ "react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
'warn',
{ allowConstantExport: true },
],
}, },
} };
+13 -4
View File
@@ -1,14 +1,23 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" href="./bluewave_favicon.ico" /> <link
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> rel="icon"
href="./bluewave_favicon.ico"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<title>BlueWave Uptime</title> <title>BlueWave Uptime</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/src/main.jsx"></script> <script
type="module"
src="/src/main.jsx"
></script>
</body> </body>
</html> </html>
+140 -189
View File
@@ -59,12 +59,12 @@
} }
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
"version": "7.24.7", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.25.7.tgz",
"integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", "integrity": "sha512-0xZJFNE5XMpENsgfHYTw8FbX4kv53mFLn2i3XPoq69LyhYSCBJtitaHx9QnsVTrsogI4Z3+HtEfZ2/GFPOtf5g==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/highlight": "^7.24.7", "@babel/highlight": "^7.25.7",
"picocolors": "^1.0.0" "picocolors": "^1.0.0"
}, },
"engines": { "engines": {
@@ -72,30 +72,30 @@
} }
}, },
"node_modules/@babel/compat-data": { "node_modules/@babel/compat-data": {
"version": "7.24.9", "version": "7.25.8",
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.9.tgz", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.8.tgz",
"integrity": "sha512-e701mcfApCJqMMueQI0Fb68Amflj83+dvAvHawoBpAz+GDjCIyGHzNwnefjsWJ3xiYAqqiQFoWbspGYBdb2/ng==", "integrity": "sha512-ZsysZyXY4Tlx+Q53XdnOFmqwfB9QDTHYxaZYajWRoBLuLEAwI2UIbtxOjWh/cFaa9IKUlcB+DDuoskLuKu56JA==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/core": { "node_modules/@babel/core": {
"version": "7.24.9", "version": "7.25.8",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.9.tgz", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.8.tgz",
"integrity": "sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==", "integrity": "sha512-Oixnb+DzmRT30qu9d3tJSQkxuygWm32DFykT4bRoORPa9hZ/L4KhVB/XiRm6KG+roIEM7DBQlmg27kw2HZkdZg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@ampproject/remapping": "^2.2.0", "@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^7.24.7", "@babel/code-frame": "^7.25.7",
"@babel/generator": "^7.24.9", "@babel/generator": "^7.25.7",
"@babel/helper-compilation-targets": "^7.24.8", "@babel/helper-compilation-targets": "^7.25.7",
"@babel/helper-module-transforms": "^7.24.9", "@babel/helper-module-transforms": "^7.25.7",
"@babel/helpers": "^7.24.8", "@babel/helpers": "^7.25.7",
"@babel/parser": "^7.24.8", "@babel/parser": "^7.25.8",
"@babel/template": "^7.24.7", "@babel/template": "^7.25.7",
"@babel/traverse": "^7.24.8", "@babel/traverse": "^7.25.7",
"@babel/types": "^7.24.9", "@babel/types": "^7.25.8",
"convert-source-map": "^2.0.0", "convert-source-map": "^2.0.0",
"debug": "^4.1.0", "debug": "^4.1.0",
"gensync": "^1.0.0-beta.2", "gensync": "^1.0.0-beta.2",
@@ -117,29 +117,29 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@babel/generator": { "node_modules/@babel/generator": {
"version": "7.24.10", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.10.tgz", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.7.tgz",
"integrity": "sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==", "integrity": "sha512-5Dqpl5fyV9pIAD62yK9P7fcA768uVPUyrQmqpqstHWgMma4feF1x/oFysBCVZLY5wJ2GkMUCdsNDnGZrPoR6rA==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/types": "^7.24.9", "@babel/types": "^7.25.7",
"@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/gen-mapping": "^0.3.5",
"@jridgewell/trace-mapping": "^0.3.25", "@jridgewell/trace-mapping": "^0.3.25",
"jsesc": "^2.5.1" "jsesc": "^3.0.2"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/helper-compilation-targets": { "node_modules/@babel/helper-compilation-targets": {
"version": "7.24.8", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.24.8.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.7.tgz",
"integrity": "sha512-oU+UoqCHdp+nWVDkpldqIQL/i/bvAv53tRqLG/s+cOXxe66zOYLU7ar/Xs3LdmBihrUMEUhwu6dMZwbNOYDwvw==", "integrity": "sha512-DniTEax0sv6isaw6qSQSfV4gVRNtw2rte8HHM45t9ZR0xILaufBRNkpMifCRiAPyvL4ACD6v0gfCwCmtOQaV4A==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/compat-data": "^7.24.8", "@babel/compat-data": "^7.25.7",
"@babel/helper-validator-option": "^7.24.8", "@babel/helper-validator-option": "^7.25.7",
"browserslist": "^4.23.1", "browserslist": "^4.24.0",
"lru-cache": "^5.1.1", "lru-cache": "^5.1.1",
"semver": "^6.3.1" "semver": "^6.3.1"
}, },
@@ -147,67 +147,29 @@
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/helper-environment-visitor": {
"version": "7.24.7",
"resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz",
"integrity": "sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==",
"license": "MIT",
"dependencies": {
"@babel/types": "^7.24.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-function-name": {
"version": "7.24.7",
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.24.7.tgz",
"integrity": "sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==",
"license": "MIT",
"dependencies": {
"@babel/template": "^7.24.7",
"@babel/types": "^7.24.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-hoist-variables": {
"version": "7.24.7",
"resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz",
"integrity": "sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==",
"license": "MIT",
"dependencies": {
"@babel/types": "^7.24.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-module-imports": { "node_modules/@babel/helper-module-imports": {
"version": "7.24.7", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.24.7.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.7.tgz",
"integrity": "sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==", "integrity": "sha512-o0xCgpNmRohmnoWKQ0Ij8IdddjyBFE4T2kagL/x6M3+4zUgc+4qTOUBoNe4XxDskt1HPKO007ZPiMgLDq2s7Kw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/traverse": "^7.24.7", "@babel/traverse": "^7.25.7",
"@babel/types": "^7.24.7" "@babel/types": "^7.25.7"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/helper-module-transforms": { "node_modules/@babel/helper-module-transforms": {
"version": "7.24.9", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.24.9.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.7.tgz",
"integrity": "sha512-oYbh+rtFKj/HwBQkFlUzvcybzklmVdVV3UU+mN7n2t/q3yGHbuVdNxyFvSBO1tfvjyArpHNcWMAzsSPdyI46hw==", "integrity": "sha512-k/6f8dKG3yDz/qCwSM+RKovjMix563SLxQFo0UhRNo239SP6n9u5/eLtKD6EAjwta2JHJ49CsD8pms2HdNiMMQ==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/helper-environment-visitor": "^7.24.7", "@babel/helper-module-imports": "^7.25.7",
"@babel/helper-module-imports": "^7.24.7", "@babel/helper-simple-access": "^7.25.7",
"@babel/helper-simple-access": "^7.24.7", "@babel/helper-validator-identifier": "^7.25.7",
"@babel/helper-split-export-declaration": "^7.24.7", "@babel/traverse": "^7.25.7"
"@babel/helper-validator-identifier": "^7.24.7"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
@@ -227,77 +189,65 @@
} }
}, },
"node_modules/@babel/helper-simple-access": { "node_modules/@babel/helper-simple-access": {
"version": "7.24.7", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.24.7.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.25.7.tgz",
"integrity": "sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==", "integrity": "sha512-FPGAkJmyoChQeM+ruBGIDyrT2tKfZJO8NcxdC+CWNJi7N8/rZpSxK7yvBJ5O/nF1gfu5KzN7VKG3YVSLFfRSxQ==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/traverse": "^7.24.7", "@babel/traverse": "^7.25.7",
"@babel/types": "^7.24.7" "@babel/types": "^7.25.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-split-export-declaration": {
"version": "7.24.7",
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.24.7.tgz",
"integrity": "sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==",
"license": "MIT",
"dependencies": {
"@babel/types": "^7.24.7"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/helper-string-parser": { "node_modules/@babel/helper-string-parser": {
"version": "7.24.8", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.8.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz",
"integrity": "sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==", "integrity": "sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/helper-validator-identifier": { "node_modules/@babel/helper-validator-identifier": {
"version": "7.24.7", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz",
"integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", "integrity": "sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/helper-validator-option": { "node_modules/@babel/helper-validator-option": {
"version": "7.24.8", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.24.8.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.7.tgz",
"integrity": "sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==", "integrity": "sha512-ytbPLsm+GjArDYXJ8Ydr1c/KJuutjF2besPNbIZnZ6MKUxi/uTA22t2ymmA4WFjZFpjiAMO0xuuJPqK2nvDVfQ==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/helpers": { "node_modules/@babel/helpers": {
"version": "7.24.8", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.8.tgz", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.7.tgz",
"integrity": "sha512-gV2265Nkcz7weJJfvDoAEVzC1e2OTDpkGbEsebse8koXUJUXPsCMi7sRo/+SPMuMZ9MtUPnGwITTnQnU5YjyaQ==", "integrity": "sha512-Sv6pASx7Esm38KQpF/U/OXLwPPrdGHNKoeblRxgZRLXnAtnkEe4ptJPDtAZM7fBLadbc1Q07kQpSiGQ0Jg6tRA==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/template": "^7.24.7", "@babel/template": "^7.25.7",
"@babel/types": "^7.24.8" "@babel/types": "^7.25.7"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/highlight": { "node_modules/@babel/highlight": {
"version": "7.24.7", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.25.7.tgz",
"integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", "integrity": "sha512-iYyACpW3iW8Fw+ZybQK+drQre+ns/tKpXbNESfrhNnPLIklLbXr7MYJ6gPEd0iETGLOK+SxMjVvKb/ffmk+FEw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/helper-validator-identifier": "^7.24.7", "@babel/helper-validator-identifier": "^7.25.7",
"chalk": "^2.4.2", "chalk": "^2.4.2",
"js-tokens": "^4.0.0", "js-tokens": "^4.0.0",
"picocolors": "^1.0.0" "picocolors": "^1.0.0"
@@ -307,10 +257,13 @@
} }
}, },
"node_modules/@babel/parser": { "node_modules/@babel/parser": {
"version": "7.24.8", "version": "7.25.8",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.8.tgz", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.8.tgz",
"integrity": "sha512-WzfbgXOkGzZiXXCqk43kKwZjzwx4oulxZi3nq2TYL9mOjQv6kYwul9mz6ID36njuL7Xkp6nJEfok848Zj10j/w==", "integrity": "sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ==",
"license": "MIT", "license": "MIT",
"dependencies": {
"@babel/types": "^7.25.8"
},
"bin": { "bin": {
"parser": "bin/babel-parser.js" "parser": "bin/babel-parser.js"
}, },
@@ -363,33 +316,30 @@
} }
}, },
"node_modules/@babel/template": { "node_modules/@babel/template": {
"version": "7.24.7", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.24.7.tgz", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.7.tgz",
"integrity": "sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==", "integrity": "sha512-wRwtAgI3bAS+JGU2upWNL9lSlDcRCqD05BZ1n3X2ONLH1WilFP6O1otQjeMK/1g0pvYcXC7b/qVUB1keofjtZA==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.24.7", "@babel/code-frame": "^7.25.7",
"@babel/parser": "^7.24.7", "@babel/parser": "^7.25.7",
"@babel/types": "^7.24.7" "@babel/types": "^7.25.7"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/traverse": { "node_modules/@babel/traverse": {
"version": "7.24.8", "version": "7.25.7",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.24.8.tgz", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.7.tgz",
"integrity": "sha512-t0P1xxAPzEDcEPmjprAQq19NWum4K0EQPjMwZQZbHt+GiZqvjCHjj755Weq1YRPVzBI+3zSfvScfpnuIecVFJQ==", "integrity": "sha512-jatJPT1Zjqvh/1FyJs6qAHL+Dzb7sTb+xr7Q+gM1b+1oBsMsQQ4FkVKb6dFlJvLlVssqkRzV05Jzervt9yhnzg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.24.7", "@babel/code-frame": "^7.25.7",
"@babel/generator": "^7.24.8", "@babel/generator": "^7.25.7",
"@babel/helper-environment-visitor": "^7.24.7", "@babel/parser": "^7.25.7",
"@babel/helper-function-name": "^7.24.7", "@babel/template": "^7.25.7",
"@babel/helper-hoist-variables": "^7.24.7", "@babel/types": "^7.25.7",
"@babel/helper-split-export-declaration": "^7.24.7",
"@babel/parser": "^7.24.8",
"@babel/types": "^7.24.8",
"debug": "^4.3.1", "debug": "^4.3.1",
"globals": "^11.1.0" "globals": "^11.1.0"
}, },
@@ -398,13 +348,13 @@
} }
}, },
"node_modules/@babel/types": { "node_modules/@babel/types": {
"version": "7.24.9", "version": "7.25.8",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.9.tgz", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.8.tgz",
"integrity": "sha512-xm8XrMKz0IlUdocVbYJe0Z9xEgidU7msskG8BbhnTPK/HZ2z/7FP7ykqPgrUH+C+r414mNfNWam1f2vqOjqjYQ==", "integrity": "sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/helper-string-parser": "^7.24.8", "@babel/helper-string-parser": "^7.25.7",
"@babel/helper-validator-identifier": "^7.24.7", "@babel/helper-validator-identifier": "^7.25.7",
"to-fast-properties": "^2.0.0" "to-fast-properties": "^2.0.0"
}, },
"engines": { "engines": {
@@ -992,9 +942,9 @@
} }
}, },
"node_modules/@eslint/js": { "node_modules/@eslint/js": {
"version": "8.57.0", "version": "8.57.1",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz",
"integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@@ -1061,14 +1011,14 @@
} }
}, },
"node_modules/@humanwhocodes/config-array": { "node_modules/@humanwhocodes/config-array": {
"version": "0.11.14", "version": "0.13.0",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz",
"integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==",
"deprecated": "Use @eslint/config-array instead", "deprecated": "Use @eslint/config-array instead",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@humanwhocodes/object-schema": "^2.0.2", "@humanwhocodes/object-schema": "^2.0.3",
"debug": "^4.3.1", "debug": "^4.3.1",
"minimatch": "^3.0.5" "minimatch": "^3.0.5"
}, },
@@ -2396,15 +2346,15 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/@vitejs/plugin-react": { "node_modules/@vitejs/plugin-react": {
"version": "4.3.1", "version": "4.3.3",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.3.1.tgz", "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.3.3.tgz",
"integrity": "sha512-m/V2syj5CuVnaxcUJOQRel/Wr31FFXRFlnOoq1TVtkCxsY5veGMTEmpWHndrhB2U8ScHtCQB1e+4hWYExQc6Lg==", "integrity": "sha512-NooDe9GpHGqNns1i8XDERg0Vsg5SSYRhRxxyTGogUdkdNt47jal+fbuYi+Yfq6pzRCKXyoPcWisfxE6RIM3GKA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/core": "^7.24.5", "@babel/core": "^7.25.2",
"@babel/plugin-transform-react-jsx-self": "^7.24.5", "@babel/plugin-transform-react-jsx-self": "^7.24.7",
"@babel/plugin-transform-react-jsx-source": "^7.24.1", "@babel/plugin-transform-react-jsx-source": "^7.24.7",
"@types/babel__core": "^7.20.5", "@types/babel__core": "^7.20.5",
"react-refresh": "^0.14.2" "react-refresh": "^0.14.2"
}, },
@@ -2700,9 +2650,9 @@
} }
}, },
"node_modules/browserslist": { "node_modules/browserslist": {
"version": "4.23.2", "version": "4.24.2",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.2.tgz", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz",
"integrity": "sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==", "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@@ -2719,10 +2669,10 @@
], ],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"caniuse-lite": "^1.0.30001640", "caniuse-lite": "^1.0.30001669",
"electron-to-chromium": "^1.4.820", "electron-to-chromium": "^1.5.41",
"node-releases": "^2.0.14", "node-releases": "^2.0.18",
"update-browserslist-db": "^1.1.0" "update-browserslist-db": "^1.1.1"
}, },
"bin": { "bin": {
"browserslist": "cli.js" "browserslist": "cli.js"
@@ -2773,9 +2723,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001642", "version": "1.0.30001669",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001642.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz",
"integrity": "sha512-3XQ0DoRgLijXJErLSl+bLnJ+Et4KqV1PY6JJBGAFlsNsz31zeAIncyeZfLCabHK/jtSh+671RM9YMldxjUPZtA==", "integrity": "sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@@ -3224,9 +3174,9 @@
} }
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.4.829", "version": "1.5.41",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.829.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.41.tgz",
"integrity": "sha512-5qp1N2POAfW0u1qGAxXEtz6P7bO1m6gpZr5hdf5ve6lxpLM7MpiM4jIPz7xcrNlClQMafbyUDDWjlIQZ1Mw0Rw==", "integrity": "sha512-dfdv/2xNjX0P8Vzme4cfzHqnPm5xsZXwsolTYr0eyW18IUmNyG08vL+fttvinTfhKfIKdRoqkDIC9e9iWQCNYQ==",
"license": "ISC" "license": "ISC"
}, },
"node_modules/entities": { "node_modules/entities": {
@@ -3455,9 +3405,9 @@
} }
}, },
"node_modules/escalade": { "node_modules/escalade": {
"version": "3.1.2", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
"integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=6" "node": ">=6"
@@ -3476,17 +3426,18 @@
} }
}, },
"node_modules/eslint": { "node_modules/eslint": {
"version": "8.57.0", "version": "8.57.1",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz",
"integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==",
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1", "@eslint-community/regexpp": "^4.6.1",
"@eslint/eslintrc": "^2.1.4", "@eslint/eslintrc": "^2.1.4",
"@eslint/js": "8.57.0", "@eslint/js": "8.57.1",
"@humanwhocodes/config-array": "^0.11.14", "@humanwhocodes/config-array": "^0.13.0",
"@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8", "@nodelib/fs.walk": "^1.2.8",
"@ungap/structured-clone": "^1.2.0", "@ungap/structured-clone": "^1.2.0",
@@ -3579,9 +3530,9 @@
} }
}, },
"node_modules/eslint-plugin-react-refresh": { "node_modules/eslint-plugin-react-refresh": {
"version": "0.4.8", "version": "0.4.13",
"resolved": "https://registry.npmjs.org/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.8.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.13.tgz",
"integrity": "sha512-MIKAclwaDFIiYtVBLzDdm16E+Ty4GwhB6wZlCAG1R3Ur+F9Qbo6PRxpA5DK7XtDgm+WlCoAY2WxAwqhmIDHg6Q==", "integrity": "sha512-f1EppwrpJRWmqDTyvAyomFVDYRtrS7iTEqv3nokETnMiMzs2SSTmKRTACce4O2p4jYyowiSMvpdwC/RLcMFhuQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peerDependencies": { "peerDependencies": {
@@ -4766,15 +4717,15 @@
} }
}, },
"node_modules/jsesc": { "node_modules/jsesc": {
"version": "2.5.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz",
"integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==",
"license": "MIT", "license": "MIT",
"bin": { "bin": {
"jsesc": "bin/jsesc" "jsesc": "bin/jsesc"
}, },
"engines": { "engines": {
"node": ">=4" "node": ">=6"
} }
}, },
"node_modules/json-buffer": { "node_modules/json-buffer": {
@@ -5006,9 +4957,9 @@
} }
}, },
"node_modules/node-releases": { "node_modules/node-releases": {
"version": "2.0.17", "version": "2.0.18",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.17.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz",
"integrity": "sha512-Ww6ZlOiEQfPfXM45v17oabk77Z7mg5bOt7AjDyzy7RjK9OrLrLC8dyZQoAPEOtFX9SaNf1Tdvr5gRJWdTJj7GA==", "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/object-assign": { "node_modules/object-assign": {
@@ -6212,9 +6163,9 @@
} }
}, },
"node_modules/update-browserslist-db": { "node_modules/update-browserslist-db": {
"version": "1.1.0", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz",
"integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@@ -6231,8 +6182,8 @@
], ],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"escalade": "^3.1.2", "escalade": "^3.2.0",
"picocolors": "^1.0.1" "picocolors": "^1.1.0"
}, },
"bin": { "bin": {
"update-browserslist-db": "cli.js" "update-browserslist-db": "cli.js"
+8 -10
View File
@@ -42,25 +42,23 @@ const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => {
className="alert row-stack" className="alert row-stack"
gap={theme.spacing(8)} gap={theme.spacing(8)}
sx={{ sx={{
padding: hasIcon padding: hasIcon ? theme.spacing(8) : `${theme.spacing(4)} ${theme.spacing(8)}`,
? theme.spacing(8)
: `${theme.spacing(4)} ${theme.spacing(8)}`,
backgroundColor: bg, backgroundColor: bg,
border: `solid 1px ${border}`, border: `solid 1px ${border}`,
borderRadius: theme.shape.borderRadius, borderRadius: theme.shape.borderRadius,
}} }}
> >
{hasIcon && <Box sx={{ color: text }}>{icon}</Box>} {hasIcon && <Box sx={{ color: text }}>{icon}</Box>}
<Stack direction="column" gap="2px" sx={{ flex: 1 }}> <Stack
direction="column"
gap="2px"
sx={{ flex: 1 }}
>
{title && ( {title && (
<Typography sx={{ fontWeight: "700", color: `${text}` }}> <Typography sx={{ fontWeight: "700", color: `${text}` }}>{title}</Typography>
{title}
</Typography>
)} )}
{body && ( {body && (
<Typography sx={{ fontWeight: "400", color: `${text}` }}> <Typography sx={{ fontWeight: "400", color: `${text}` }}>{body}</Typography>
{body}
</Typography>
)} )}
{hasIcon && isToast && ( {hasIcon && isToast && (
<Button <Button
+1 -3
View File
@@ -52,9 +52,7 @@ const Avatar = ({ src, small, sx }) => {
return ( return (
<MuiAvatar <MuiAvatar
alt={`${user?.firstName} ${user?.lastName}`} alt={`${user?.firstName} ${user?.lastName}`}
src={ src={src ? src : user?.avatarImage ? image : "/static/images/avatar/2.jpg"}
src ? src : user?.avatarImage ? image : "/static/images/avatar/2.jpg"
}
sx={{ sx={{
fontSize: small ? "16px" : "22px", fontSize: small ? "16px" : "22px",
color: "white", color: "white",
+1 -4
View File
@@ -18,10 +18,7 @@
.MuiPaper-root:has(table.MuiTable-root) { .MuiPaper-root:has(table.MuiTable-root) {
box-shadow: none; box-shadow: none;
} }
.MuiTable-root .MuiTable-root .MuiTableBody-root .MuiTableRow-root:last-child .MuiTableCell-root {
.MuiTableBody-root
.MuiTableRow-root:last-child
.MuiTableCell-root {
border: none; border: none;
} }
+6 -5
View File
@@ -243,7 +243,11 @@ const BasicTable = ({ data, paginated, reversed, table }) => {
}, },
}} }}
> >
<Typography px={theme.spacing(2)} fontSize={12} sx={{ opacity: 0.7 }}> <Typography
px={theme.spacing(2)}
fontSize={12}
sx={{ opacity: 0.7 }}
>
Showing {getRange()} of {data.rows.length} monitor(s) Showing {getRange()} of {data.rows.length} monitor(s)
</Typography> </Typography>
<TablePagination <TablePagination
@@ -257,10 +261,7 @@ const BasicTable = ({ data, paginated, reversed, table }) => {
ActionsComponent={TablePaginationActions} ActionsComponent={TablePaginationActions}
labelRowsPerPage="Rows per page" labelRowsPerPage="Rows per page"
labelDisplayedRows={({ page, count }) => labelDisplayedRows={({ page, count }) =>
`Page ${page + 1} of ${Math.max( `Page ${page + 1} of ${Math.max(0, Math.ceil(count / rowsPerPage))}`
0,
Math.ceil(count / rowsPerPage)
)}`
} }
slotProps={{ slotProps={{
select: { select: {
@@ -65,9 +65,7 @@ const BarChart = ({ checks = [] }) => {
width={theme.spacing(4)} width={theme.spacing(4)}
height={theme.spacing(4)} height={theme.spacing(4)}
backgroundColor={ backgroundColor={
check.status check.status ? theme.palette.success.main : theme.palette.error.text
? theme.palette.success.main
: theme.palette.error.text
} }
sx={{ borderRadius: "50%" }} sx={{ borderRadius: "50%" }}
/> />
@@ -78,12 +76,18 @@ const BarChart = ({ checks = [] }) => {
ml={theme.spacing(2)} ml={theme.spacing(2)}
gap={theme.spacing(12)} gap={theme.spacing(12)}
> >
<Typography component="span" sx={{ opacity: 0.8 }}> <Typography
component="span"
sx={{ opacity: 0.8 }}
>
Response Time Response Time
</Typography> </Typography>
<Typography component="span"> <Typography component="span">
{check.originalResponseTime} {check.originalResponseTime}
<Typography component="span" sx={{ opacity: 0.8 }}> <Typography
component="span"
sx={{ opacity: 0.8 }}
>
{" "} {" "}
ms ms
</Typography> </Typography>
@@ -149,9 +153,7 @@ const BarChart = ({ checks = [] }) => {
width="100%" width="100%"
height={`${animate ? check.responseTime : 0}%`} height={`${animate ? check.responseTime : 0}%`}
backgroundColor={ backgroundColor={
check.status check.status ? theme.palette.success.main : theme.palette.error.text
? theme.palette.success.main
: theme.palette.error.text
} }
sx={{ sx={{
borderRadius: theme.spacing(1.5), borderRadius: theme.spacing(1.5),
@@ -62,12 +62,18 @@ const CustomToolTip = ({ active, payload, label }) => {
}, },
}} }}
> >
<Typography component="span" sx={{ opacity: 0.8 }}> <Typography
component="span"
sx={{ opacity: 0.8 }}
>
Response Time Response Time
</Typography>{" "} </Typography>{" "}
<Typography component="span"> <Typography component="span">
{payload[0].payload.originalResponseTime} {payload[0].payload.originalResponseTime}
<Typography component="span" sx={{ opacity: 0.8 }}> <Typography
component="span"
sx={{ opacity: 0.8 }}
>
{" "} {" "}
ms ms
</Typography> </Typography>
@@ -115,7 +121,11 @@ const MonitorDetailsAreaChart = ({ checks }) => {
const [isHovered, setIsHovered] = useState(false); const [isHovered, setIsHovered] = useState(false);
return ( return (
<ResponsiveContainer width="100%" minWidth={25} height={220}> <ResponsiveContainer
width="100%"
minWidth={25}
height={220}
>
<AreaChart <AreaChart
width="100%" width="100%"
height="100%" height="100%"
@@ -137,7 +147,13 @@ const MonitorDetailsAreaChart = ({ checks }) => {
vertical={false} vertical={false}
/> />
<defs> <defs>
<linearGradient id="colorUv" x1="0" y1="0" x2="0" y2="1"> <linearGradient
id="colorUv"
x1="0"
y1="0"
x2="0"
y2="1"
>
<stop <stop
offset="0%" offset="0%"
stopColor={theme.palette.primary.main} stopColor={theme.palette.primary.main}
+1 -2
View File
@@ -50,8 +50,7 @@ const Check = ({ text, variant = "info", outlined = false }) => {
<Typography <Typography
component="span" component="span"
sx={{ sx={{
color: color: variant === "info" ? theme.palette.text.tertiary : colors[variant],
variant === "info" ? theme.palette.text.tertiary : colors[variant],
opacity: 0.8, opacity: 0.8,
}} }}
> >
-1
View File
@@ -1 +0,0 @@
+36 -13
View File
@@ -1,13 +1,27 @@
import LoadingButton from "@mui/lab/LoadingButton"; import LoadingButton from "@mui/lab/LoadingButton";
import { Button, Modal, Stack, Typography } from "@mui/material"; import { Button, Modal, Stack, Typography } from "@mui/material";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
const Dialog = ({ modelTitle, modelDescription, const Dialog = ({
open, onClose, title, confirmationBtnLbl, confirmationBtnOnClick, cancelBtnLbl, cancelBtnOnClick, theme, isLoading, description }) => { modelTitle,
return <Modal modelDescription,
open,
onClose,
title,
confirmationBtnLbl,
confirmationBtnOnClick,
cancelBtnLbl,
cancelBtnOnClick,
theme,
isLoading,
description,
}) => {
return (
<Modal
aria-labelledby={modelTitle} aria-labelledby={modelTitle}
aria-describedby={modelDescription} aria-describedby={modelDescription}
open={open} open={open}
onClose={onClose} > onClose={onClose}
>
<Stack <Stack
gap={theme.spacing(2)} gap={theme.spacing(2)}
sx={{ sx={{
@@ -27,15 +41,23 @@ const Dialog = ({ modelTitle, modelDescription,
}, },
}} }}
> >
<Typography id={modelTitle} component="h2" <Typography
id={modelTitle}
component="h2"
fontSize={16} fontSize={16}
color={theme.palette.text.primary} color={theme.palette.text.primary}
fontWeight={600}> fontWeight={600}
>
{title} {title}
</Typography> </Typography>
{description && <Typography id={modelDescription} color={theme.palette.text.tertiary}> {description && (
<Typography
id={modelDescription}
color={theme.palette.text.tertiary}
>
{description} {description}
</Typography>} </Typography>
)}
<Stack <Stack
direction="row" direction="row"
gap={theme.spacing(4)} gap={theme.spacing(4)}
@@ -52,7 +74,7 @@ const Dialog = ({ modelTitle, modelDescription,
<LoadingButton <LoadingButton
variant="contained" variant="contained"
color="error" color="error"
loading= {isLoading} loading={isLoading}
onClick={confirmationBtnOnClick} onClick={confirmationBtnOnClick}
> >
{confirmationBtnLbl} {confirmationBtnLbl}
@@ -60,7 +82,8 @@ const Dialog = ({ modelTitle, modelDescription,
</Stack> </Stack>
</Stack> </Stack>
</Modal> </Modal>
} );
};
Dialog.propTypes = { Dialog.propTypes = {
modelTitle: PropTypes.string.isRequired, modelTitle: PropTypes.string.isRequired,
@@ -74,7 +97,7 @@ Dialog.propTypes = {
cancelBtnOnClick: PropTypes.func.isRequired, cancelBtnOnClick: PropTypes.func.isRequired,
theme: PropTypes.object.isRequired, theme: PropTypes.object.isRequired,
isLoading: PropTypes.bool.isRequired, isLoading: PropTypes.bool.isRequired,
description: PropTypes.string description: PropTypes.string,
} };
export default Dialog export default Dialog;
+5 -1
View File
@@ -46,7 +46,11 @@ const Fallback = ({ title, checks, link = "/", isAdmin }) => {
> >
<Background style={{ width: "100%" }} /> <Background style={{ width: "100%" }} />
</Box> </Box>
<Stack gap={theme.spacing(4)} maxWidth={"275px"} zIndex={1}> <Stack
gap={theme.spacing(4)}
maxWidth={"275px"}
zIndex={1}
>
<Typography <Typography
component="h1" component="h1"
marginY={theme.spacing(4)} marginY={theme.spacing(4)}
+3 -18
View File
@@ -1,13 +1,7 @@
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { forwardRef, useState } from "react"; import { forwardRef, useState } from "react";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { import { IconButton, InputAdornment, Stack, TextField, Typography } from "@mui/material";
IconButton,
InputAdornment,
Stack,
TextField,
Typography,
} from "@mui/material";
import VisibilityOff from "@mui/icons-material/VisibilityOff"; import VisibilityOff from "@mui/icons-material/VisibilityOff";
import Visibility from "@mui/icons-material/Visibility"; import Visibility from "@mui/icons-material/Visibility";
import "./index.css"; import "./index.css";
@@ -142,9 +136,7 @@ const Field = forwardRef(
borderBottomLeftRadius: theme.shape.borderRadius, borderBottomLeftRadius: theme.shape.borderRadius,
}, },
} }
: { : {}
}
} }
InputProps={{ InputProps={{
startAdornment: type === "url" && ( startAdornment: type === "url" && (
@@ -212,14 +204,7 @@ const Field = forwardRef(
Field.displayName = "Field"; Field.displayName = "Field";
Field.propTypes = { Field.propTypes = {
type: PropTypes.oneOf([ type: PropTypes.oneOf(["text", "password", "url", "email", "description", "number"]),
"text",
"password",
"url",
"email",
"description",
"number",
]),
id: PropTypes.string.isRequired, id: PropTypes.string.isRequired,
name: PropTypes.string, name: PropTypes.string,
label: PropTypes.string, label: PropTypes.string,
+8 -2
View File
@@ -92,7 +92,10 @@ const ImageField = ({ id, src, loading, onChange }) => {
> >
<CloudUploadIcon /> <CloudUploadIcon />
</IconButton> </IconButton>
<Typography component="h2" color={theme.palette.text.tertiary}> <Typography
component="h2"
color={theme.palette.text.tertiary}
>
<Typography <Typography
component="span" component="span"
fontSize="inherit" fontSize="inherit"
@@ -121,7 +124,10 @@ const ImageField = ({ id, src, loading, onChange }) => {
</Typography> </Typography>
</> </>
) : ( ) : (
<Stack direction="row" justifyContent="center"> <Stack
direction="row"
justifyContent="center"
>
<Box <Box
sx={{ sx={{
width: "250px", width: "250px",
@@ -1 +0,0 @@
+3 -10
View File
@@ -1,12 +1,5 @@
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { import { Box, ListItem, Autocomplete, TextField, Stack, Typography } from "@mui/material";
Box,
ListItem,
Autocomplete,
TextField,
Stack,
Typography,
} from "@mui/material";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import SearchIcon from "../../../assets/icons/search.svg?react"; import SearchIcon from "../../../assets/icons/search.svg?react";
@@ -45,6 +38,7 @@ const SearchAdornment = () => {
); );
}; };
//TODO keep search state inside of component
const Search = ({ const Search = ({
id, id,
options, options,
@@ -141,8 +135,7 @@ const Search = ({
: {} : {}
} }
> >
{option[filteredBy] + {option[filteredBy] + (secondaryLabel ? ` (${option[secondaryLabel]})` : "")}
(secondaryLabel ? ` (${option[secondaryLabel]})` : "")}
</ListItem> </ListItem>
); );
}} }}
@@ -1,11 +1,6 @@
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { import { MenuItem, Select as MuiSelect, Stack, Typography } from "@mui/material";
MenuItem,
Select as MuiSelect,
Stack,
Typography,
} from "@mui/material";
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
import "./index.css"; import "./index.css";
@@ -63,7 +58,10 @@ const Select = ({
}; };
return ( return (
<Stack gap={theme.spacing(2)} className="select-wrapper"> <Stack
gap={theme.spacing(2)}
className="select-wrapper"
>
{label && ( {label && (
<Typography <Typography
component="h3" component="h3"
+2 -11
View File
@@ -86,10 +86,7 @@ const lightenColor = (color, percent) => {
const ColoredLabel = ({ label, color }) => { const ColoredLabel = ({ label, color }) => {
const theme = useTheme(); const theme = useTheme();
// If an invalid color is passed, default to the labelGray color // If an invalid color is passed, default to the labelGray color
if ( if (typeof color !== "string" || !/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(color)) {
typeof color !== "string" ||
!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(color)
) {
color = theme.palette.border.light; color = theme.palette.border.light;
} }
@@ -180,13 +177,7 @@ const StatusLabel = ({ status, text, customStyles }) => {
}; };
StatusLabel.propTypes = { StatusLabel.propTypes = {
status: PropTypes.oneOf([ status: PropTypes.oneOf(["up", "down", "paused", "pending", "cannot resolve"]),
"up",
"down",
"paused",
"pending",
"cannot resolve",
]),
text: PropTypes.string, text: PropTypes.string,
customStyles: PropTypes.object, customStyles: PropTypes.object,
}; };
+14 -18
View File
@@ -1,13 +1,7 @@
import React from "react"; import React from "react";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { import { Box, IconButton, LinearProgress, Stack, Typography } from "@mui/material";
Box,
IconButton,
LinearProgress,
Stack,
Typography,
} from "@mui/material";
import CloseIcon from "@mui/icons-material/Close"; import CloseIcon from "@mui/icons-material/Close";
import ErrorOutlineOutlinedIcon from "@mui/icons-material/ErrorOutlineOutlined"; import ErrorOutlineOutlinedIcon from "@mui/icons-material/ErrorOutlineOutlined";
import "./index.css"; import "./index.css";
@@ -23,14 +17,7 @@ import "./index.css";
* @returns {JSX.Element} The rendered component. * @returns {JSX.Element} The rendered component.
*/ */
const ProgressUpload = ({ const ProgressUpload = ({ icon, label, size, progress = 0, onClick, error }) => {
icon,
label,
size,
progress = 0,
onClick,
error,
}) => {
const theme = useTheme(); const theme = useTheme();
return ( return (
@@ -104,10 +91,16 @@ const ProgressUpload = ({
</Typography> </Typography>
) : ( ) : (
<Box color={theme.palette.text.tertiary}> <Box color={theme.palette.text.tertiary}>
<Typography component="h2" mb={theme.spacing(1.5)}> <Typography
component="h2"
mb={theme.spacing(1.5)}
>
{error ? error : label} {error ? error : label}
</Typography> </Typography>
<Typography component="p" sx={{ opacity: 0.6 }}> <Typography
component="p"
sx={{ opacity: 0.6 }}
>
{!error && size} {!error && size}
</Typography> </Typography>
</Box> </Box>
@@ -142,7 +135,10 @@ const ProgressUpload = ({
</IconButton> </IconButton>
</Stack> </Stack>
{!error ? ( {!error ? (
<Stack direction="row" alignItems="center"> <Stack
direction="row"
alignItems="center"
>
<Box sx={{ width: "100%", mr: theme.spacing(5) }}> <Box sx={{ width: "100%", mr: theme.spacing(5) }}>
<LinearProgress <LinearProgress
variant="determinate" variant="determinate"
@@ -27,11 +27,17 @@ CustomStepIcon.propTypes = {
const ProgressStepper = ({ steps }) => { const ProgressStepper = ({ steps }) => {
const [activeStep, setActiveStep] = React.useState(1); const [activeStep, setActiveStep] = React.useState(1);
return ( return (
<Stepper activeStep={activeStep} alternativeLabel> <Stepper
activeStep={activeStep}
alternativeLabel
>
{steps.map((step, index) => { {steps.map((step, index) => {
const color = activeStep === index ? "primary" : "inherit"; const color = activeStep === index ? "primary" : "inherit";
return ( return (
<Step key={step.label} onClick={() => setActiveStep(index)}> <Step
key={step.label}
onClick={() => setActiveStep(index)}
>
<StepLabel StepIconComponent={CustomStepIcon}> <StepLabel StepIconComponent={CustomStepIcon}>
<Typography <Typography
variant="body1" variant="body1"
@@ -41,7 +47,10 @@ const ProgressStepper = ({ steps }) => {
{step.label} {step.label}
</Typography> </Typography>
</StepLabel> </StepLabel>
<Typography variant="body1" color={color}> <Typography
variant="body1"
color={color}
>
{step.content} {step.content}
</Typography> </Typography>
</Step> </Step>
@@ -19,7 +19,10 @@ const ProtectedRoute = ({ Component, ...rest }) => {
return authState.authToken ? ( return authState.authToken ? (
<Component {...rest} /> <Component {...rest} />
) : ( ) : (
<Navigate to="/login" replace /> <Navigate
to="/login"
replace
/>
); );
}; };
+37 -26
View File
@@ -172,8 +172,16 @@ function Sidebar() {
}, },
}} }}
> >
<Stack pt={theme.spacing(6)} pb={theme.spacing(12)} pl={theme.spacing(8)}> <Stack
<Stack direction="row" alignItems="center" gap={theme.spacing(4)}> pt={theme.spacing(6)}
pb={theme.spacing(12)}
pl={theme.spacing(8)}
>
<Stack
direction="row"
alignItems="center"
gap={theme.spacing(4)}
>
<Stack <Stack
justifyContent="center" justifyContent="center"
alignItems="center" alignItems="center"
@@ -223,9 +231,9 @@ function Sidebar() {
}, },
}} }}
onClick={() => { onClick={() => {
setOpen(prev => setOpen((prev) =>
Object.fromEntries(Object.keys(prev).map(key => [key, false])) Object.fromEntries(Object.keys(prev).map((key) => [key, false]))
) );
dispatch(toggleSidebar()); dispatch(toggleSidebar());
}} }}
> >
@@ -273,9 +281,7 @@ function Sidebar() {
disableInteractive disableInteractive
> >
<ListItemButton <ListItemButton
className={ className={location.pathname.includes(item.path) ? "selected-path" : ""}
location.pathname.includes(item.path) ? "selected-path" : ""
}
onClick={() => navigate(`/${item.path}`)} onClick={() => navigate(`/${item.path}`)}
sx={{ sx={{
height: "37px", height: "37px",
@@ -309,9 +315,7 @@ function Sidebar() {
> >
<ListItemButton <ListItemButton
className={ className={
Boolean(anchorEl) && popup === item.name Boolean(anchorEl) && popup === item.name ? "selected-path" : ""
? "selected-path"
: ""
} }
onClick={(event) => openPopup(event, item.name)} onClick={(event) => openPopup(event, item.name)}
sx={{ sx={{
@@ -363,9 +367,7 @@ function Sidebar() {
return ( return (
<MenuItem <MenuItem
className={ className={
location.pathname.includes(child.path) location.pathname.includes(child.path) ? "selected-path" : ""
? "selected-path"
: ""
} }
key={child.path} key={child.path}
onClick={() => { onClick={() => {
@@ -400,8 +402,8 @@ function Sidebar() {
<ListItemButton <ListItemButton
onClick={() => onClick={() =>
setOpen((prev) => ({ setOpen((prev) => ({
...Object.fromEntries(Object.keys(prev).map(key => [key, false])), ...Object.fromEntries(Object.keys(prev).map((key) => [key, false])),
[item.name]: !prev[item.name] [item.name]: !prev[item.name],
})) }))
} }
sx={{ sx={{
@@ -414,7 +416,10 @@ function Sidebar() {
<ListItemText>{item.name}</ListItemText> <ListItemText>{item.name}</ListItemText>
{open[`${item.name}`] ? <ArrowUp /> : <ArrowDown />} {open[`${item.name}`] ? <ArrowUp /> : <ArrowDown />}
</ListItemButton> </ListItemButton>
<Collapse in={open[`${item.name}`]} timeout="auto"> <Collapse
in={open[`${item.name}`]}
timeout="auto"
>
<List <List
component="div" component="div"
disablePadding disablePadding
@@ -432,9 +437,7 @@ function Sidebar() {
return ( return (
<ListItemButton <ListItemButton
className={ className={
location.pathname.includes(child.path) location.pathname.includes(child.path) ? "selected-path" : ""
? "selected-path"
: ""
} }
key={child.path} key={child.path}
onClick={() => { onClick={() => {
@@ -477,9 +480,7 @@ function Sidebar() {
}, },
}} }}
> >
<ListItemIcon sx={{ minWidth: 0 }}> <ListItemIcon sx={{ minWidth: 0 }}>{child.icon}</ListItemIcon>
{child.icon}
</ListItemIcon>
<ListItemText>{child.name}</ListItemText> <ListItemText>{child.name}</ListItemText>
</ListItemButton> </ListItemButton>
); );
@@ -531,14 +532,20 @@ function Sidebar() {
<> <>
<Avatar small={true} /> <Avatar small={true} />
<Box ml={theme.spacing(2)}> <Box ml={theme.spacing(2)}>
<Typography component="span" fontWeight={500}> <Typography
component="span"
fontWeight={500}
>
{authState.user?.firstName} {authState.user?.lastName} {authState.user?.firstName} {authState.user?.lastName}
</Typography> </Typography>
<Typography sx={{ textTransform: "capitalize" }}> <Typography sx={{ textTransform: "capitalize" }}>
{authState.user?.role} {authState.user?.role}
</Typography> </Typography>
</Box> </Box>
<Tooltip title="Controls" disableInteractive> <Tooltip
title="Controls"
disableInteractive
>
<IconButton <IconButton
sx={{ sx={{
ml: "auto", ml: "auto",
@@ -593,7 +600,11 @@ function Sidebar() {
{collapsed && ( {collapsed && (
<MenuItem sx={{ cursor: "default", minWidth: "150px" }}> <MenuItem sx={{ cursor: "default", minWidth: "150px" }}>
<Box mb={theme.spacing(2)}> <Box mb={theme.spacing(2)}>
<Typography component="span" fontWeight={500} fontSize={13}> <Typography
component="span"
fontWeight={500}
fontSize={13}
>
{authState.user?.firstName} {authState.user?.lastName} {authState.user?.firstName} {authState.user?.lastName}
</Typography> </Typography>
<Typography sx={{ textTransform: "capitalize", fontSize: 12 }}> <Typography sx={{ textTransform: "capitalize", fontSize: 12 }}>
@@ -171,7 +171,10 @@ const PasswordPanel = () => {
/> />
</Box> </Box>
</Stack> </Stack>
<Stack direction="row" justifyContent="flex-end"> <Stack
direction="row"
justifyContent="flex-end"
>
<LoadingButton <LoadingButton
variant="contained" variant="contained"
color="primary" color="primary"
@@ -7,11 +7,7 @@ import Field from "../../Inputs/Field";
import ImageField from "../../Inputs/Image"; import ImageField from "../../Inputs/Image";
import { credentials, imageValidation } from "../../../Validation/validation"; import { credentials, imageValidation } from "../../../Validation/validation";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { import { clearAuthState, deleteUser, update } from "../../../Features/Auth/authSlice";
clearAuthState,
deleteUser,
update,
} from "../../../Features/Auth/authSlice";
import ImageIcon from "@mui/icons-material/Image"; import ImageIcon from "@mui/icons-material/Image";
import ProgressUpload from "../../ProgressBars"; import ProgressUpload from "../../ProgressBars";
import { formatBytes } from "../../../Utils/fileUtils"; import { formatBytes } from "../../../Utils/fileUtils";
@@ -69,10 +65,7 @@ const ProfilePanel = () => {
// Handles image file // Handles image file
const handlePicture = (event) => { const handlePicture = (event) => {
const pic = event.target.files[0]; const pic = event.target.files[0];
let error = validateField( let error = validateField({ type: pic.type, size: pic.size }, imageValidation);
{ type: pic.type, size: pic.size },
imageValidation
);
if (error) return; if (error) return;
setProgress((prev) => ({ ...prev, isLoading: true })); setProgress((prev) => ({ ...prev, isLoading: true }));
@@ -259,7 +252,10 @@ const ProfilePanel = () => {
<Stack direction="row"> <Stack direction="row">
<Stack flex={0.9}> <Stack flex={0.9}>
<Typography component="h1">Email</Typography> <Typography component="h1">Email</Typography>
<Typography component="p" sx={{ opacity: 0.6 }}> <Typography
component="p"
sx={{ opacity: 0.6 }}
>
This is your current email address — it cannot be changed. This is your current email address — it cannot be changed.
</Typography> </Typography>
</Stack> </Stack>
@@ -276,11 +272,18 @@ const ProfilePanel = () => {
<Stack direction="row"> <Stack direction="row">
<Stack flex={0.9}> <Stack flex={0.9}>
<Typography component="h1">Your photo</Typography> <Typography component="h1">Your photo</Typography>
<Typography component="p" sx={{ opacity: 0.6 }}> <Typography
component="p"
sx={{ opacity: 0.6 }}
>
This photo will be displayed in your profile page. This photo will be displayed in your profile page.
</Typography> </Typography>
</Stack> </Stack>
<Stack direction="row" alignItems="center" flex={1}> <Stack
direction="row"
alignItems="center"
flex={1}
>
<Avatar <Avatar
src={ src={
localData?.deleteProfileImage localData?.deleteProfileImage
@@ -291,10 +294,18 @@ const ProfilePanel = () => {
} }
sx={{ mr: "8px" }} sx={{ mr: "8px" }}
/> />
<Button variant="text" color="info" onClick={handleDeletePicture}> <Button
variant="text"
color="info"
onClick={handleDeletePicture}
>
Delete Delete
</Button> </Button>
<Button variant="text" color="primary" onClick={openPictureModal}> <Button
variant="text"
color="primary"
onClick={openPictureModal}
>
Update Update
</Button> </Button>
</Stack> </Stack>
@@ -306,7 +317,10 @@ const ProfilePanel = () => {
marginY: theme.spacing(1), marginY: theme.spacing(1),
}} }}
/> />
<Stack direction="row" justifyContent="flex-end"> <Stack
direction="row"
justifyContent="flex-end"
>
<Box width="fit-content"> <Box width="fit-content">
<LoadingButton <LoadingButton
variant="contained" variant="contained"
@@ -314,9 +328,7 @@ const ProfilePanel = () => {
onClick={handleSaveProfile} onClick={handleSaveProfile}
loading={isLoading} loading={isLoading}
loadingIndicator="Saving..." loadingIndicator="Saving..."
disabled={ disabled={Object.keys(errors).length !== 0 && !errors?.picture && true}
Object.keys(errors).length !== 0 && !errors?.picture && true
}
sx={{ px: theme.spacing(12) }} sx={{ px: theme.spacing(12) }}
> >
Save Save
@@ -332,12 +344,19 @@ const ProfilePanel = () => {
}} }}
/> />
{!user.role.includes("demo") && ( {!user.role.includes("demo") && (
<Box component="form" noValidate spellCheck="false"> <Box
component="form"
noValidate
spellCheck="false"
>
<Box mb={theme.spacing(6)}> <Box mb={theme.spacing(6)}>
<Typography component="h1">Delete account</Typography> <Typography component="h1">Delete account</Typography>
<Typography component="p" sx={{ opacity: 0.6 }}> <Typography
Note that deleting your account will remove all data from our component="p"
system. This is permanent and non-recoverable. sx={{ opacity: 0.6 }}
>
Note that deleting your account will remove all data from our system. This
is permanent and non-recoverable.
</Typography> </Typography>
</Box> </Box>
<Button <Button
@@ -376,13 +395,19 @@ const ProfilePanel = () => {
}, },
}} }}
> >
<Typography id="modal-delete-account" component="h1"> <Typography
id="modal-delete-account"
component="h1"
>
Really delete this account? Really delete this account?
</Typography> </Typography>
<Typography id="delete-account-confirmation" component="p"> <Typography
If you delete your account, you will no longer be able to sign in, id="delete-account-confirmation"
and all of your data will be deleted. Deleting your account is component="p"
permanent and non-recoverable action. >
If you delete your account, you will no longer be able to sign in, and all of
your data will be deleted. Deleting your account is permanent and
non-recoverable action.
</Typography> </Typography>
<Stack <Stack
direction="row" direction="row"
@@ -390,7 +415,11 @@ const ProfilePanel = () => {
mt={theme.spacing(5)} mt={theme.spacing(5)}
justifyContent="flex-end" justifyContent="flex-end"
> >
<Button variant="text" color="info" onClick={() => setIsOpen("")}> <Button
variant="text"
color="info"
onClick={() => setIsOpen("")}
>
Cancel Cancel
</Button> </Button>
<LoadingButton <LoadingButton
@@ -469,7 +498,11 @@ const ProfilePanel = () => {
gap={theme.spacing(5)} gap={theme.spacing(5)}
justifyContent="flex-end" justifyContent="flex-end"
> >
<Button variant="text" color="info" onClick={removePicture}> <Button
variant="text"
color="info"
onClick={removePicture}
>
Remove Remove
</Button> </Button>
<Button <Button
@@ -1,13 +1,6 @@
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import TabPanel from "@mui/lab/TabPanel"; import TabPanel from "@mui/lab/TabPanel";
import { import { Box, Button, ButtonGroup, Modal, Stack, Typography } from "@mui/material";
Box,
Button,
ButtonGroup,
Modal,
Stack,
Typography,
} from "@mui/material";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import Field from "../../Inputs/Field"; import Field from "../../Inputs/Field";
import { credentials } from "../../../Validation/validation"; import { credentials } from "../../../Validation/validation";
@@ -75,9 +68,7 @@ const TeamPanel = () => {
if (filter !== "all") if (filter !== "all")
team = members.filter((member) => { team = members.filter((member) => {
if (filter === "admin") { if (filter === "admin") {
return ( return member.role.includes("admin") || member.role.includes("superadmin");
member.role.includes("admin") || member.role.includes("superadmin")
);
} }
return member.role.includes(filter); return member.role.includes(filter);
}); });
@@ -158,10 +149,7 @@ const TeamPanel = () => {
email: value, email: value,
})); }));
const validation = credentials.validate( const validation = credentials.validate({ email: value }, { abortEarly: false });
{ email: value },
{ abortEarly: false }
);
setErrors((prev) => { setErrors((prev) => {
const updatedErrors = { ...prev }; const updatedErrors = { ...prev };
@@ -289,7 +277,10 @@ const TeamPanel = () => {
gap={theme.spacing(12)} gap={theme.spacing(12)}
> >
<Typography component="h1">Team members</Typography> <Typography component="h1">Team members</Typography>
<Stack direction="row" justifyContent="space-between"> <Stack
direction="row"
justifyContent="space-between"
>
<Stack <Stack
direction="row" direction="row"
alignItems="flex-end" alignItems="flex-end"
@@ -377,8 +368,7 @@ const TeamPanel = () => {
color={theme.palette.text.accent} color={theme.palette.text.accent}
sx={{ mt: theme.spacing(1), mb: theme.spacing(4) }} sx={{ mt: theme.spacing(1), mb: theme.spacing(4) }}
> >
When you add a new team member, they will get access to all When you add a new team member, they will get access to all monitors.
monitors.
</Typography> </Typography>
</Box> </Box>
<Field <Field
+10 -26
View File
@@ -11,9 +11,7 @@ const initialState = {
msg: null, msg: null,
}; };
export const register = createAsyncThunk( export const register = createAsyncThunk("auth/register", async (form, thunkApi) => {
"auth/register",
async (form, thunkApi) => {
try { try {
const res = await networkService.registerUser(form); const res = await networkService.registerUser(form);
return res.data; return res.data;
@@ -27,8 +25,7 @@ export const register = createAsyncThunk(
}; };
return thunkApi.rejectWithValue(payload); return thunkApi.rejectWithValue(payload);
} }
} });
);
export const login = createAsyncThunk("auth/login", async (form, thunkApi) => { export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
try { try {
@@ -46,9 +43,7 @@ export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
} }
}); });
export const update = createAsyncThunk( export const update = createAsyncThunk("auth/update", async (data, thunkApi) => {
"auth/update",
async (data, thunkApi) => {
const { authToken: token, localData: form } = data; const { authToken: token, localData: form } = data;
const user = jwtDecode(token); const user = jwtDecode(token);
try { try {
@@ -63,8 +58,7 @@ export const update = createAsyncThunk(
}); });
fd.append("profileImage", imageResult.data); fd.append("profileImage", imageResult.data);
} }
form.deleteProfileImage && form.deleteProfileImage && fd.append("deleteProfileImage", form.deleteProfileImage);
fd.append("deleteProfileImage", form.deleteProfileImage);
const res = await networkService.updateUser({ const res = await networkService.updateUser({
authToken: token, authToken: token,
@@ -82,12 +76,9 @@ export const update = createAsyncThunk(
}; };
return thunkApi.rejectWithValue(payload); return thunkApi.rejectWithValue(payload);
} }
} });
);
export const deleteUser = createAsyncThunk( export const deleteUser = createAsyncThunk("auth/delete", async (data, thunkApi) => {
"auth/delete",
async (data, thunkApi) => {
const user = jwtDecode(data); const user = jwtDecode(data);
try { try {
@@ -106,8 +97,7 @@ export const deleteUser = createAsyncThunk(
}; };
return thunkApi.rejectWithValue(payload); return thunkApi.rejectWithValue(payload);
} }
} });
);
export const forgotPassword = createAsyncThunk( export const forgotPassword = createAsyncThunk(
"auth/forgotPassword", "auth/forgotPassword",
@@ -162,9 +152,7 @@ const handleAuthFulfilled = (state, action) => {
const handleAuthRejected = (state, action) => { const handleAuthRejected = (state, action) => {
state.isLoading = false; state.isLoading = false;
state.success = false; state.success = false;
state.msg = action.payload state.msg = action.payload ? action.payload.msg : "Failed to login or register";
? action.payload.msg
: "Failed to login or register";
}; };
const handleUpdateFulfilled = (state, action) => { const handleUpdateFulfilled = (state, action) => {
state.isLoading = false; state.isLoading = false;
@@ -175,9 +163,7 @@ const handleUpdateFulfilled = (state, action) => {
const handleUpdateRejected = (state, action) => { const handleUpdateRejected = (state, action) => {
state.isLoading = false; state.isLoading = false;
state.success = false; state.success = false;
state.msg = action.payload state.msg = action.payload ? action.payload.msg : "Failed to update profile data.";
? action.payload.msg
: "Failed to update profile data.";
}; };
const handleDeleteFulfilled = (state, action) => { const handleDeleteFulfilled = (state, action) => {
state.isLoading = false; state.isLoading = false;
@@ -197,9 +183,7 @@ const handleForgotFulfilled = (state, action) => {
const handleForgotRejected = (state, action) => { const handleForgotRejected = (state, action) => {
state.isLoading = false; state.isLoading = false;
state.success = false; state.success = false;
state.msg = action.payload state.msg = action.payload ? action.payload.msg : "Failed to send reset instructions.";
? action.payload.msg
: "Failed to send reset instructions.";
}; };
const handleNewPasswordRejected = (state, action) => { const handleNewPasswordRejected = (state, action) => {
state.isLoading = false; state.isLoading = false;
@@ -31,6 +31,30 @@ export const createPageSpeed = createAsyncThunk(
} }
); );
export const checkEndpointResolution = createAsyncThunk(
"monitors/checkEndpoint",
async (data, thunkApi) => {
try {
const { authToken, monitorURL } = data;
const res = await networkService.checkEndpointResolution({
authToken: authToken,
monitorURL: monitorURL,
})
return res.data;
} catch (error) {
if (error.response && error.response.data) {
return thunkApi.rejectWithValue(error.response.data);
}
const payload = {
status: false,
msg: error.message ? error.message : "Unknown error",
};
return thunkApi.rejectWithValue(payload);
}
}
)
export const getPagespeedMonitorById = createAsyncThunk( export const getPagespeedMonitorById = createAsyncThunk(
"monitors/getMonitorById", "monitors/getMonitorById",
async (data, thunkApi) => { async (data, thunkApi) => {
@@ -222,7 +246,24 @@ const pageSpeedMonitorSlice = createSlice({
? action.payload.msg ? action.payload.msg
: "Failed to create page speed monitor"; : "Failed to create page speed monitor";
}) })
// *****************************************************
// Resolve Endpoint
// *****************************************************
.addCase(checkEndpointResolution.pending, (state) => {
state.isLoading = true;
})
.addCase(checkEndpointResolution.fulfilled, (state, action) => {
state.isLoading = false;
state.success = action.payload.success;
state.msg = action.payload.msg;
})
.addCase(checkEndpointResolution.rejected, (state, action) => {
state.isLoading = false;
state.success = false;
state.msg = action.payload
? action.payload.msg
: "Failed to check endpoint resolution";
})
// ***************************************************** // *****************************************************
// Update Monitor // Update Monitor
// ***************************************************** // *****************************************************
@@ -89,9 +89,7 @@ const handleUpdateSettingsFulfilled = (state, action) => {
const handleUpdateSettingsRejected = (state, action) => { const handleUpdateSettingsRejected = (state, action) => {
state.isLoading = false; state.isLoading = false;
state.success = false; state.success = false;
state.msg = action.payload state.msg = action.payload ? action.payload.msg : "Failed to update settings.";
? action.payload.msg
: "Failed to update settings.";
}; };
const settingsSlice = createSlice({ const settingsSlice = createSlice({
+2 -7
View File
@@ -47,10 +47,5 @@ const uiSlice = createSlice({
}); });
export default uiSlice.reducer; export default uiSlice.reducer;
export const { export const { setRowsPerPage, toggleSidebar, setMode, setGreeting, setTimezone } =
setRowsPerPage, uiSlice.actions;
toggleSidebar,
setMode,
setGreeting,
setTimezone,
} = uiSlice.actions;
@@ -31,6 +31,30 @@ export const createUptimeMonitor = createAsyncThunk(
} }
); );
export const checkEndpointResolution = createAsyncThunk(
"monitors/checkEndpoint",
async (data, thunkApi) => {
try {
const { authToken, monitorURL } = data;
const res = await networkService.checkEndpointResolution({
authToken: authToken,
monitorURL: monitorURL,
})
return res.data;
} catch (error) {
if (error.response && error.response.data) {
return thunkApi.rejectWithValue(error.response.data);
}
const payload = {
status: false,
msg: error.message ? error.message : "Unknown error",
};
return thunkApi.rejectWithValue(payload);
}
}
)
export const getUptimeMonitorById = createAsyncThunk( export const getUptimeMonitorById = createAsyncThunk(
"monitors/getMonitorById", "monitors/getMonitorById",
async (data, thunkApi) => { async (data, thunkApi) => {
@@ -271,6 +295,24 @@ const uptimeMonitorsSlice = createSlice({
: "Failed to create uptime monitor"; : "Failed to create uptime monitor";
}) })
// ***************************************************** // *****************************************************
// Resolve Endpoint
// *****************************************************
.addCase(checkEndpointResolution.pending, (state) => {
state.isLoading = true;
})
.addCase(checkEndpointResolution.fulfilled, (state, action) => {
state.isLoading = false;
state.success = action.payload.success;
state.msg = action.payload.msg;
})
.addCase(checkEndpointResolution.rejected, (state, action) => {
state.isLoading = false;
state.success = false;
state.msg = action.payload
? action.payload.msg
: "Failed to check endpoint resolution";
})
// *****************************************************
// Get Monitor By Id // Get Monitor By Id
// ***************************************************** // *****************************************************
.addCase(getUptimeMonitorById.pending, (state) => { .addCase(getUptimeMonitorById.pending, (state) => {
@@ -284,9 +326,7 @@ const uptimeMonitorsSlice = createSlice({
.addCase(getUptimeMonitorById.rejected, (state, action) => { .addCase(getUptimeMonitorById.rejected, (state, action) => {
state.isLoading = false; state.isLoading = false;
state.success = false; state.success = false;
state.msg = action.payload state.msg = action.payload ? action.payload.msg : "Failed to get uptime monitor";
? action.payload.msg
: "Failed to get uptime monitor";
}) })
// ***************************************************** // *****************************************************
// update Monitor // update Monitor
@@ -393,14 +433,11 @@ const uptimeMonitorsSlice = createSlice({
.addCase(deleteAllMonitors.rejected, (state, action) => { .addCase(deleteAllMonitors.rejected, (state, action) => {
state.isLoading = false; state.isLoading = false;
state.success = false; state.success = false;
state.msg = action.payload state.msg = action.payload ? action.payload.msg : "Failed to delete all monitors";
? action.payload.msg
: "Failed to delete all monitors";
}); });
}, },
}); });
export const { setUptimeMonitors, clearUptimeMonitorState } = export const { setUptimeMonitors, clearUptimeMonitorState } = uptimeMonitorsSlice.actions;
uptimeMonitorsSlice.actions;
export default uptimeMonitorsSlice.reducer; export default uptimeMonitorsSlice.reducer;
+6 -1
View File
@@ -20,7 +20,12 @@ const withAdminCheck = (WrappedComponent) => {
logger.error(error); logger.error(error);
}); });
}, [navigate]); }, [navigate]);
return <WrappedComponent {...props} isSuperAdmin={true} />; return (
<WrappedComponent
{...props}
isSuperAdmin={true}
/>
);
}; };
const wrappedComponentName = const wrappedComponentName =
WrappedComponent.displayName || WrappedComponent.name || "Component"; WrappedComponent.displayName || WrappedComponent.name || "Component";
+6 -1
View File
@@ -7,7 +7,12 @@ const withAdminProp = (WrappedComponent) => {
(user?.role?.includes("admin") ?? false) || (user?.role?.includes("admin") ?? false) ||
(user?.role?.includes("superadmin") ?? false); (user?.role?.includes("superadmin") ?? false);
return <WrappedComponent {...props} isAdmin={isAdmin} />; return (
<WrappedComponent
{...props}
isAdmin={isAdmin}
/>
);
}; };
const wrappedComponentName = const wrappedComponentName =
+5 -1
View File
@@ -6,7 +6,11 @@ import "./index.css";
const HomeLayout = () => { const HomeLayout = () => {
return ( return (
<Stack className="home-layout" flexDirection="row" gap={14}> <Stack
className="home-layout"
flexDirection="row"
gap={14}
>
<Sidebar /> <Sidebar />
<Outlet /> <Outlet />
</Stack> </Stack>
+4 -1
View File
@@ -54,7 +54,10 @@ const Account = ({ open = "profile" }) => {
"& .MuiTabs-root": { height: "fit-content", minHeight: "0" }, "& .MuiTabs-root": { height: "fit-content", minHeight: "0" },
}} }}
> >
<TabList onChange={handleTabChange} aria-label="account tabs"> <TabList
onChange={handleTabChange}
aria-label="account tabs"
>
{tabList.map((label, index) => ( {tabList.map((label, index) => (
<Tab <Tab
label={label} label={label}
+27 -6
View File
@@ -9,16 +9,14 @@ import PropTypes from "prop-types";
import LoadingButton from "@mui/lab/LoadingButton"; import LoadingButton from "@mui/lab/LoadingButton";
import { ConfigBox } from "../Settings/styled"; import { ConfigBox } from "../Settings/styled";
import { useNavigate } from "react-router"; import { useNavigate } from "react-router";
import { import { getAppSettings, updateAppSettings } from "../../Features/Settings/settingsSlice";
getAppSettings,
updateAppSettings,
} from "../../Features/Settings/settingsSlice";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import Select from "../../Components/Inputs/Select"; import Select from "../../Components/Inputs/Select";
import { advancedSettingsValidation } from "../../Validation/validation";
import { buildErrors, hasValidationErrors } from "../../Validation/error";
const AdvancedSettings = ({ isAdmin }) => { const AdvancedSettings = ({ isAdmin }) => {
const navigate = useNavigate(); const navigate = useNavigate();
useEffect(() => { useEffect(() => {
if (!isAdmin) { if (!isAdmin) {
navigate("/"); navigate("/");
@@ -42,11 +40,12 @@ const AdvancedSettings = ({ isAdmin }) => {
redisPort: "", redisPort: "",
pagespeedApiKey: "", pagespeedApiKey: "",
}); });
const [errors, setErrors] = useState({});
useEffect(() => { useEffect(() => {
const getSettings = async () => { const getSettings = async () => {
const action = await dispatch(getAppSettings({ authToken })); const action = await dispatch(getAppSettings({ authToken }));
if (action.payload.success) { if (action.payload?.success) {
setLocalSettings(action.payload.data); setLocalSettings(action.payload.data);
} else { } else {
createToast({ body: "Failed to get settings" }); createToast({ body: "Failed to get settings" });
@@ -78,9 +77,20 @@ const AdvancedSettings = ({ isAdmin }) => {
const handleChange = (event) => { const handleChange = (event) => {
const { value, id } = event.target; const { value, id } = event.target;
setLocalSettings({ ...localSettings, [id]: value }); setLocalSettings({ ...localSettings, [id]: value });
const { error } = advancedSettingsValidation.validate(
{ [id]: value },
{
abortEarly: false,
}
);
setErrors((prev) => {
return buildErrors(prev, id, error);
});
}; };
const handleSave = async () => { const handleSave = async () => {
if (hasValidationErrors(localSettings, advancedSettingsValidation, setErrors))
return;
const action = await dispatch( const action = await dispatch(
updateAppSettings({ settings: localSettings, authToken }) updateAppSettings({ settings: localSettings, authToken })
); );
@@ -121,6 +131,7 @@ const AdvancedSettings = ({ isAdmin }) => {
label="API URL Host" label="API URL Host"
value={localSettings.apiBaseUrl} value={localSettings.apiBaseUrl}
onChange={handleChange} onChange={handleChange}
error={errors.apiBaseUrl}
/> />
<Select <Select
id="logLevel" id="logLevel"
@@ -129,6 +140,7 @@ const AdvancedSettings = ({ isAdmin }) => {
items={logItems} items={logItems}
value={logItemLookup[localSettings.logLevel]} value={logItemLookup[localSettings.logLevel]}
onChange={handleLogLevel} onChange={handleLogLevel}
error={errors.logLevel}
/> />
</Stack> </Stack>
</ConfigBox> </ConfigBox>
@@ -148,6 +160,7 @@ const AdvancedSettings = ({ isAdmin }) => {
name="systemEmailHost" name="systemEmailHost"
value={localSettings.systemEmailHost} value={localSettings.systemEmailHost}
onChange={handleChange} onChange={handleChange}
error={errors.systemEmailHost}
/> />
<Field <Field
type="number" type="number"
@@ -156,6 +169,7 @@ const AdvancedSettings = ({ isAdmin }) => {
name="systemEmailPort" name="systemEmailPort"
value={localSettings.systemEmailPort.toString()} value={localSettings.systemEmailPort.toString()}
onChange={handleChange} onChange={handleChange}
error={errors.systemEmailPort}
/> />
<Field <Field
type="email" type="email"
@@ -164,6 +178,7 @@ const AdvancedSettings = ({ isAdmin }) => {
name="systemEmailAddress" name="systemEmailAddress"
value={localSettings.systemEmailAddress} value={localSettings.systemEmailAddress}
onChange={handleChange} onChange={handleChange}
error={errors.systemEmailAddress}
/> />
<Field <Field
type="text" type="text"
@@ -172,6 +187,7 @@ const AdvancedSettings = ({ isAdmin }) => {
name="systemEmailPassword" name="systemEmailPassword"
value={localSettings.systemEmailPassword} value={localSettings.systemEmailPassword}
onChange={handleChange} onChange={handleChange}
error={errors.systemEmailPassword}
/> />
</Stack> </Stack>
</ConfigBox> </ConfigBox>
@@ -190,6 +206,7 @@ const AdvancedSettings = ({ isAdmin }) => {
name="jwtTTL" name="jwtTTL"
value={localSettings.jwtTTL} value={localSettings.jwtTTL}
onChange={handleChange} onChange={handleChange}
error={errors.jwtTTL}
/> />
<Field <Field
type="text" type="text"
@@ -198,6 +215,7 @@ const AdvancedSettings = ({ isAdmin }) => {
name="dbType" name="dbType"
value={localSettings.dbType} value={localSettings.dbType}
onChange={handleChange} onChange={handleChange}
error={errors.dbType}
/> />
<Field <Field
type="text" type="text"
@@ -206,6 +224,7 @@ const AdvancedSettings = ({ isAdmin }) => {
name="redisHost" name="redisHost"
value={localSettings.redisHost} value={localSettings.redisHost}
onChange={handleChange} onChange={handleChange}
error={errors.redisHost}
/> />
<Field <Field
type="number" type="number"
@@ -214,6 +233,7 @@ const AdvancedSettings = ({ isAdmin }) => {
name="redisPort" name="redisPort"
value={localSettings.redisPort.toString()} value={localSettings.redisPort.toString()}
onChange={handleChange} onChange={handleChange}
error={errors.redisPort}
/> />
<Field <Field
type="text" type="text"
@@ -222,6 +242,7 @@ const AdvancedSettings = ({ isAdmin }) => {
name="pagespeedApiKey" name="pagespeedApiKey"
value={localSettings.pagespeedApiKey} value={localSettings.pagespeedApiKey}
onChange={handleChange} onChange={handleChange}
error={errors.pagespeedApiKey}
/> />
</Stack> </Stack>
</ConfigBox> </ConfigBox>
+8 -2
View File
@@ -150,7 +150,10 @@ const CheckEmail = () => {
<Typography component="h1">Check your email</Typography> <Typography component="h1">Check your email</Typography>
<Typography> <Typography>
We sent a password reset link to{" "} We sent a password reset link to{" "}
<Typography className="email-sent-to" component="span"> <Typography
className="email-sent-to"
component="span"
>
{email || "username@email.com"} {email || "username@email.com"}
</Typography> </Typography>
</Typography> </Typography>
@@ -184,7 +187,10 @@ const CheckEmail = () => {
</Typography> </Typography>
</Stack> </Stack>
</Stack> </Stack>
<Box textAlign="center" p={theme.spacing(12)}> <Box
textAlign="center"
p={theme.spacing(12)}
>
<Typography display="inline-block">Go back to —</Typography> <Typography display="inline-block">Go back to —</Typography>
<Typography <Typography
component="span" component="span"
+6 -8
View File
@@ -73,10 +73,7 @@ const ForgotPassword = () => {
const { value } = event.target; const { value } = event.target;
setForm({ email: value }); setForm({ email: value });
const { error } = credentials.validate( const { error } = credentials.validate({ email: value }, { abortEarly: false });
{ email: value },
{ abortEarly: false }
);
if (error) setErrors({ email: error.details[0].message }); if (error) setErrors({ email: error.details[0].message });
else delete errors.email; else delete errors.email;
@@ -153,9 +150,7 @@ const ForgotPassword = () => {
<Key alt="password key icon" /> <Key alt="password key icon" />
</IconBox> </IconBox>
<Typography component="h1">Forgot password?</Typography> <Typography component="h1">Forgot password?</Typography>
<Typography> <Typography>No worries, we&apos;ll send you reset instructions.</Typography>
No worries, we&apos;ll send you reset instructions.
</Typography>
</Box> </Box>
<Box <Box
component="form" component="form"
@@ -191,7 +186,10 @@ const ForgotPassword = () => {
</Box> </Box>
</Stack> </Stack>
</Stack> </Stack>
<Box textAlign="center" p={theme.spacing(12)}> <Box
textAlign="center"
p={theme.spacing(12)}
>
<Typography display="inline-block">Go back to —</Typography> <Typography display="inline-block">Go back to —</Typography>
<Typography <Typography
component="span" component="span"
+33 -16
View File
@@ -137,8 +137,15 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
<Typography component="h1">Log In</Typography> <Typography component="h1">Log In</Typography>
<Typography>Enter your email address</Typography> <Typography>Enter your email address</Typography>
</Box> </Box>
<Box textAlign="left" mb={theme.spacing(5)}> <Box
<form noValidate spellCheck={false} onSubmit={onSubmit}> textAlign="left"
mb={theme.spacing(5)}
>
<form
noValidate
spellCheck={false}
onSubmit={onSubmit}
>
<Field <Field
type="email" type="email"
id="login-email-input" id="login-email-input"
@@ -154,7 +161,10 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
/> />
</form> </form>
</Box> </Box>
<Stack direction="row" justifyContent="space-between"> <Stack
direction="row"
justifyContent="space-between"
>
<Button <Button
variant="outlined" variant="outlined"
color="info" color="info"
@@ -233,8 +243,15 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
<Typography component="h1">Log In</Typography> <Typography component="h1">Log In</Typography>
<Typography>Enter your password</Typography> <Typography>Enter your password</Typography>
</Box> </Box>
<Box textAlign="left" mb={theme.spacing(5)}> <Box
<form noValidate spellCheck={false} onSubmit={onSubmit}> textAlign="left"
mb={theme.spacing(5)}
>
<form
noValidate
spellCheck={false}
onSubmit={onSubmit}
>
<Field <Field
type="password" type="password"
id="login-password-input" id="login-password-input"
@@ -249,7 +266,10 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
/> />
</form> </form>
</Box> </Box>
<Stack direction="row" justifyContent="space-between"> <Stack
direction="row"
justifyContent="space-between"
>
<Button <Button
variant="outlined" variant="outlined"
color="info" color="info"
@@ -359,10 +379,7 @@ const Login = () => {
[name]: value, [name]: value,
})); }));
const { error } = credentials.validate( const { error } = credentials.validate({ [name]: value }, { abortEarly: false });
{ [name]: value },
{ abortEarly: false }
);
setErrors((prev) => { setErrors((prev) => {
const prevErrors = { ...prev }; const prevErrors = { ...prev };
@@ -413,8 +430,7 @@ const Login = () => {
if (action.payload) { if (action.payload) {
if (action.payload.msg === "Incorrect password") if (action.payload.msg === "Incorrect password")
setErrors({ setErrors({
password: password: "The password you provided does not match our records",
"The password you provided does not match our records",
}); });
// dispatch errors // dispatch errors
createToast({ createToast({
@@ -507,10 +523,11 @@ const Login = () => {
) )
)} )}
</Stack> </Stack>
<Box textAlign="center" p={theme.spacing(12)}> <Box
<Typography display="inline-block"> textAlign="center"
Don&apos;t have an account? — p={theme.spacing(12)}
</Typography> >
<Typography display="inline-block">Don&apos;t have an account? —</Typography>
<Typography <Typography
component="span" component="span"
color={theme.palette.primary.main} color={theme.palette.primary.main}
@@ -85,8 +85,7 @@ const NewPasswordConfirmed = () => {
</IconBox> </IconBox>
<Typography component="h1">Password reset</Typography> <Typography component="h1">Password reset</Typography>
<Typography mb={theme.spacing(2)}> <Typography mb={theme.spacing(2)}>
Your password has been successfully reset. Click below to log in Your password has been successfully reset. Click below to log in magically.
magically.
</Typography> </Typography>
</Box> </Box>
<Button <Button
@@ -102,7 +101,10 @@ const NewPasswordConfirmed = () => {
</Button> </Button>
</Stack> </Stack>
</Stack> </Stack>
<Box textAlign="center" p={theme.spacing(12)}> <Box
textAlign="center"
p={theme.spacing(12)}
>
<Typography display="inline-block">Go back to —</Typography> <Typography display="inline-block">Go back to —</Typography>
<Typography <Typography
component="span" component="span"
+25 -20
View File
@@ -38,8 +38,7 @@ const LandingPage = ({ isSuperAdmin, onSignup }) => {
<Box> <Box>
<Typography component="h1">Sign Up</Typography> <Typography component="h1">Sign Up</Typography>
<Typography> <Typography>
Create your {isSuperAdmin ? "Super admin " : ""}account to get Create your {isSuperAdmin ? "Super admin " : ""}account to get started.
started.
</Typography> </Typography>
</Box> </Box>
<Box width="100%"> <Box width="100%">
@@ -181,7 +180,10 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
/> />
</Box> </Box>
</Box> </Box>
<Stack direction="row" justifyContent="space-between"> <Stack
direction="row"
justifyContent="space-between"
>
<Button <Button
variant="outlined" variant="outlined"
color="info" color="info"
@@ -274,7 +276,10 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
/> />
</Box> </Box>
</Box> </Box>
<Stack direction="row" justifyContent="space-between"> <Stack
direction="row"
justifyContent="space-between"
>
<Button <Button
variant="outlined" variant="outlined"
color="info" color="info"
@@ -396,8 +401,8 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
<Check <Check
text={ text={
<> <>
<Typography component="span">Must be at least</Typography> 8 <Typography component="span">Must be at least</Typography> 8 characters
characters long long
</> </>
} }
variant={ variant={
@@ -413,8 +418,8 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
<Check <Check
text={ text={
<> <>
<Typography component="span">Must contain</Typography> one <Typography component="span">Must contain</Typography> one special
special character and a number character and a number
</> </>
} }
variant={ variant={
@@ -422,9 +427,7 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
? "error" ? "error"
: form.password === "" : form.password === ""
? "info" ? "info"
: !/^(?=.*[!@#$%^&*(),.?":{}|])(?=.*\d).+$/.test( : !/^(?=.*[!@#$%^&*(),.?":{}|])(?=.*\d).+$/.test(form.password)
form.password
)
? "error" ? "error"
: "success" : "success"
} }
@@ -432,10 +435,8 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
<Check <Check
text={ text={
<> <>
<Typography component="span"> <Typography component="span">Must contain at least</Typography> one
Must contain at least upper and lower character
</Typography>{" "}
one upper and lower character
</> </>
} }
variant={ variant={
@@ -450,7 +451,10 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
/> />
</Stack> </Stack>
</Box> </Box>
<Stack direction="row" justifyContent="space-between"> <Stack
direction="row"
justifyContent="space-between"
>
<Button <Button
variant="outlined" variant="outlined"
color="info" color="info"
@@ -738,10 +742,11 @@ const Register = ({ isSuperAdmin }) => {
"" ""
)} )}
</Stack> </Stack>
<Box textAlign="center" p={theme.spacing(12)}> <Box
<Typography display="inline-block"> textAlign="center"
Already have an account? — p={theme.spacing(12)}
</Typography> >
<Typography display="inline-block">Already have an account? —</Typography>
<Typography <Typography
component="span" component="span"
ml={theme.spacing(2)} ml={theme.spacing(2)}
+14 -14
View File
@@ -59,9 +59,7 @@ const SetNewPassword = () => {
}); });
} else { } else {
delete passwordForm.confirm; delete passwordForm.confirm;
const action = await dispatch( const action = await dispatch(setNewPassword({ token: token, form: passwordForm }));
setNewPassword({ token: token, form: passwordForm })
);
if (action.payload.success) { if (action.payload.success) {
navigate("/new-password-confirmed"); navigate("/new-password-confirmed");
createToast({ createToast({
@@ -217,7 +215,10 @@ const SetNewPassword = () => {
error={errors.confirm} error={errors.confirm}
/> />
</Box> </Box>
<Stack gap={theme.spacing(4)} mb={theme.spacing(12)}> <Stack
gap={theme.spacing(4)}
mb={theme.spacing(12)}
>
<Check <Check
text={ text={
<> <>
@@ -238,8 +239,8 @@ const SetNewPassword = () => {
<Check <Check
text={ text={
<> <>
<Typography component="span">Must contain</Typography> one <Typography component="span">Must contain</Typography> one special
special character and a number character and a number
</> </>
} }
variant={ variant={
@@ -247,9 +248,7 @@ const SetNewPassword = () => {
? "error" ? "error"
: form.password === "" : form.password === ""
? "info" ? "info"
: !/^(?=.*[!@#$%^&*(),.?":{}|])(?=.*\d).+$/.test( : !/^(?=.*[!@#$%^&*(),.?":{}|])(?=.*\d).+$/.test(form.password)
form.password
)
? "error" ? "error"
: "success" : "success"
} }
@@ -257,10 +256,8 @@ const SetNewPassword = () => {
<Check <Check
text={ text={
<> <>
<Typography component="span"> <Typography component="span">Must contain at least</Typography> one
Must contain at least upper and lower character
</Typography>{" "}
one upper and lower character
</> </>
} }
variant={ variant={
@@ -287,7 +284,10 @@ const SetNewPassword = () => {
</LoadingButton> </LoadingButton>
</Stack> </Stack>
</Stack> </Stack>
<Box textAlign="center" p={theme.spacing(12)}> <Box
textAlign="center"
p={theme.spacing(12)}
>
<Typography display="inline-block">Go back to —</Typography> <Typography display="inline-block">Go back to —</Typography>
<Typography <Typography
component="span" component="span"
@@ -0,0 +1,32 @@
import { useTheme } from "@emotion/react";
import PlaceholderLight from "../../../../assets/Images/data_placeholder.svg?react";
import PlaceholderDark from "../../../../assets/Images/data_placeholder_dark.svg?react";
import { Box, Typography } from "@mui/material";
import PropTypes from "prop-types";
const Empty = ({ styles, mode }) => {
const theme = useTheme();
return (
<Box sx={{ ...styles }}>
<Box
textAlign="center"
pb={theme.spacing(20)}
>
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
</Box>
<Typography
textAlign="center"
color={theme.palette.text.secondary}
>
No incidents recorded yet.
</Typography>
</Box>
);
};
Empty.propTypes = {
styles: PropTypes.object,
mode: PropTypes.string,
};
export { Empty };
@@ -0,0 +1,21 @@
import { Skeleton /* , Stack */ } from "@mui/material";
const IncidentSkeleton = () => {
return (
<>
<Skeleton
animation={"wave"}
variant="rounded"
width="100%"
height={300}
/>
<Skeleton
animation={"wave"}
variant="rounded"
width="100%"
height={100}
/>
</>
);
};
export { IncidentSkeleton };
@@ -24,6 +24,8 @@ import { useTheme } from "@emotion/react";
import { formatDateWithTz } from "../../../Utils/timeUtils"; import { formatDateWithTz } from "../../../Utils/timeUtils";
import PlaceholderLight from "../../../assets/Images/data_placeholder.svg?react"; import PlaceholderLight from "../../../assets/Images/data_placeholder.svg?react";
import PlaceholderDark from "../../../assets/Images/data_placeholder_dark.svg?react"; import PlaceholderDark from "../../../assets/Images/data_placeholder_dark.svg?react";
import { Empty } from "./Empty/Empty";
import { IncidentSkeleton } from "./Skeleton/Skeleton";
const IncidentTable = ({ monitors, selectedMonitor, filter }) => { const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
const uiTimezone = useSelector((state) => state.ui.timezone); const uiTimezone = useSelector((state) => state.ui.timezone);
@@ -37,6 +39,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
page: 0, page: 0,
rowsPerPage: 14, rowsPerPage: 14,
}); });
const [isLoading, setIsLoading] = useState(true);
useEffect(() => { useEffect(() => {
setPaginationController((prevPaginationController) => ({ setPaginationController((prevPaginationController) => ({
@@ -51,6 +54,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
return; return;
} }
try { try {
setIsLoading(true);
let res; let res;
if (selectedMonitor === "0") { if (selectedMonitor === "0") {
res = await networkService.getChecksByTeam({ res = await networkService.getChecksByTeam({
@@ -79,6 +83,8 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
setChecksCount(res.data.data.checksCount); setChecksCount(res.data.data.checksCount);
} catch (error) { } catch (error) {
logger.error(error); logger.error(error);
} finally {
setIsLoading(false);
} }
}; };
fetchPage(); fetchPage();
@@ -129,23 +135,31 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
p: theme.spacing(30), p: theme.spacing(30),
}; };
const hasChecks = checks?.length === 0;
const noIncidentsRecordedYet = hasChecks && selectedMonitor === "0";
const noIncidentsForThatMonitor = hasChecks && selectedMonitor !== "0";
return ( return (
<> <>
{checks?.length === 0 && selectedMonitor === "0" ? ( {isLoading ? (
<IncidentSkeleton />
) : noIncidentsRecordedYet ? (
<Empty
mode={mode}
styles={sharedStyles}
/>
) : noIncidentsForThatMonitor ? (
<Box sx={{ ...sharedStyles }}> <Box sx={{ ...sharedStyles }}>
<Box textAlign="center" pb={theme.spacing(20)}> <Box
textAlign="center"
pb={theme.spacing(20)}
>
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />} {mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
</Box> </Box>
<Typography textAlign="center" color={theme.palette.text.secondary}> <Typography
No incidents recorded yet. textAlign="center"
</Typography> color={theme.palette.text.secondary}
</Box> >
) : checks?.length === 0 ? (
<Box sx={{ ...sharedStyles }}>
<Box textAlign="center" pb={theme.spacing(20)}>
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
</Box>
<Typography textAlign="center" color={theme.palette.text.secondary}>
The monitor you have selected has no recorded incidents yet. The monitor you have selected has no recorded incidents yet.
</Typography> </Typography>
</Box> </Box>
@@ -182,9 +196,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
/> />
</TableCell> </TableCell>
<TableCell>{formattedDate}</TableCell> <TableCell>{formattedDate}</TableCell>
<TableCell> <TableCell>{check.statusCode ? check.statusCode : "N/A"}</TableCell>
{check.statusCode ? check.statusCode : "N/A"}
</TableCell>
<TableCell>{check.message}</TableCell> <TableCell>{check.message}</TableCell>
</TableRow> </TableRow>
); );
+22 -8
View File
@@ -17,14 +17,15 @@ const Incidents = () => {
const [monitors, setMonitors] = useState({}); const [monitors, setMonitors] = useState({});
const [selectedMonitor, setSelectedMonitor] = useState("0"); const [selectedMonitor, setSelectedMonitor] = useState("0");
const [loading, setLoading] = useState(false); const [isLoading, setIsLoading] = useState(true);
// TODO do something with these filters // TODO do something with these filters
const [filter, setFilter] = useState("all"); const [filter, setFilter] = useState("all");
useEffect(() => { useEffect(() => {
const fetchMonitors = async () => { const fetchMonitors = async () => {
setLoading(true); try {
setIsLoading(true);
const res = await networkService.getMonitorsByTeamId({ const res = await networkService.getMonitorsByTeamId({
authToken: authState.authToken, authToken: authState.authToken,
teamId: authState.user.teamId, teamId: authState.user.teamId,
@@ -48,25 +49,38 @@ const Incidents = () => {
setMonitors(monitorLookup); setMonitors(monitorLookup);
monitorId !== undefined && setSelectedMonitor(monitorId); monitorId !== undefined && setSelectedMonitor(monitorId);
} }
setLoading(false); } catch (error) {
console.info(error);
} finally {
setIsLoading(false);
}
}; };
fetchMonitors(); fetchMonitors();
}, [authState]); }, [authState]);
useEffect(() => {}, []); useEffect(() => {}, [monitors]);
const handleSelect = (event) => { const handleSelect = (event) => {
setSelectedMonitor(event.target.value); setSelectedMonitor(event.target.value);
}; };
const isActuallyLoading = isLoading && Object.keys(monitors)?.length === 0;
return ( return (
<Stack className="incidents table-container" pt={theme.spacing(6)} gap={theme.spacing(12)}> <Stack
{loading ? ( className="incidents"
pt={theme.spacing(6)}
gap={theme.spacing(12)}
>
{isActuallyLoading ? (
<SkeletonLayout /> <SkeletonLayout />
) : ( ) : (
<> <>
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}> <Stack
direction="row"
alignItems="center"
gap={theme.spacing(6)}
>
<Typography <Typography
display="inline-block" display="inline-block"
component="h1" component="h1"
+25 -5
View File
@@ -11,9 +11,21 @@ const SkeletonLayout = () => {
return ( return (
<> <>
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}> <Stack
<Skeleton variant="rounded" width={150} height={34} /> direction="row"
<Skeleton variant="rounded" width="15%" height={34} /> alignItems="center"
gap={theme.spacing(6)}
>
<Skeleton
variant="rounded"
width={150}
height={34}
/>
<Skeleton
variant="rounded"
width="15%"
height={34}
/>
<Skeleton <Skeleton
variant="rounded" variant="rounded"
width="20%" width="20%"
@@ -21,8 +33,16 @@ const SkeletonLayout = () => {
sx={{ ml: "auto" }} sx={{ ml: "auto" }}
/> />
</Stack> </Stack>
<Skeleton variant="rounded" width="100%" height={300} /> <Skeleton
<Skeleton variant="rounded" width="100%" height={100} /> variant="rounded"
width="100%"
height={300}
/>
<Skeleton
variant="rounded"
width="100%"
height={100}
/>
</> </>
); );
}; };
+13 -3
View File
@@ -20,7 +20,11 @@ const IntegrationsComponent = ({ icon, header, info, onClick }) => {
const theme = useTheme(); const theme = useTheme();
return ( return (
<Grid item lg={6} flexGrow={1}> <Grid
item
lg={6}
flexGrow={1}
>
<Stack <Stack
direction="row" direction="row"
justifyContent="space-between" justifyContent="space-between"
@@ -34,7 +38,10 @@ const IntegrationsComponent = ({ icon, header, info, onClick }) => {
backgroundColor={theme.palette.background.main} backgroundColor={theme.palette.background.main}
> >
{icon} {icon}
<Stack gap={theme.spacing(2)} flex={1}> <Stack
gap={theme.spacing(2)}
flex={1}
>
<Typography component="h1">{header}</Typography> <Typography component="h1">{header}</Typography>
<Typography <Typography
sx={{ sx={{
@@ -127,7 +134,10 @@ const Integrations = () => {
<Typography mb={theme.spacing(12)}> <Typography mb={theme.spacing(12)}>
Connect BlueWave Uptime to your favorite service. Connect BlueWave Uptime to your favorite service.
</Typography> </Typography>
<Grid container spacing={theme.spacing(12)}> <Grid
container
spacing={theme.spacing(12)}
>
{integrations.map((integration, index) => ( {integrations.map((integration, index) => (
<IntegrationsComponent <IntegrationsComponent
key={index} key={index}
@@ -28,6 +28,7 @@ import {
MS_PER_WEEK, MS_PER_WEEK,
} from "../../../Utils/timeUtils"; } from "../../../Utils/timeUtils";
import { useNavigate, useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import { buildErrors, hasValidationErrors } from "../../../Validation/error";
const getDurationAndUnit = (durationInMs) => { const getDurationAndUnit = (durationInMs) => {
if (durationInMs % MS_PER_DAY === 0) { if (durationInMs % MS_PER_DAY === 0) {
@@ -176,16 +177,6 @@ const CreateMaintenance = () => {
fetchMonitors(); fetchMonitors();
}, [authToken, user]); }, [authToken, user]);
const buildErrors = (prev, id, error) => {
const updatedErrors = { ...prev };
if (error) {
updatedErrors[id] = error.details[0].message;
} else {
delete updatedErrors[id];
}
return updatedErrors;
};
const handleSearch = (value) => { const handleSearch = (value) => {
setSearch(value); setSearch(value);
}; };
@@ -224,20 +215,8 @@ const CreateMaintenance = () => {
}; };
const handleSubmit = async () => { const handleSubmit = async () => {
const { error } = maintenanceWindowValidation.validate(form, { if(hasValidationErrors(form, maintenanceWindowValidation, setErrors))
abortEarly: false,
});
// If errors, return early
if (error) {
const newErrors = {};
error.details.forEach((err) => {
newErrors[err.path[0]] = err.message;
});
setErrors(newErrors);
logger.error(error);
return; return;
}
// Build timestamp for maintenance window from startDate and startTime // Build timestamp for maintenance window from startDate and startTime
const start = dayjs(form.startDate) const start = dayjs(form.startDate)
.set("hour", form.startTime.hour()) .set("hour", form.startTime.hour())
@@ -310,8 +289,14 @@ const CreateMaintenance = () => {
mt={theme.spacing(6)} mt={theme.spacing(6)}
> >
<Box> <Box>
<Typography component="h1" variant="h1"> <Typography
<Typography component="span" fontSize="inherit"> component="h1"
variant="h1"
>
<Typography
component="span"
fontSize="inherit"
>
{`${maintenanceWindowId === undefined ? "Create a" : "Edit"}`}{" "} {`${maintenanceWindowId === undefined ? "Create a" : "Edit"}`}{" "}
</Typography> </Typography>
<Typography <Typography
@@ -322,16 +307,26 @@ const CreateMaintenance = () => {
> >
maintenance{" "} maintenance{" "}
</Typography> </Typography>
<Typography component="span" fontSize="inherit"> <Typography
component="span"
fontSize="inherit"
>
window window
</Typography> </Typography>
</Typography> </Typography>
<Typography component="h2" variant="body2" fontSize={14}> <Typography
component="h2"
variant="body2"
fontSize={14}
>
Your pings won&apos;t be sent during this time frame Your pings won&apos;t be sent during this time frame
</Typography> </Typography>
</Box> </Box>
<ConfigBox direction="row"> <ConfigBox direction="row">
<Typography component="h2" variant="h2"> <Typography
component="h2"
variant="h2"
>
General Settings General Settings
</Typography> </Typography>
<Box <Box
@@ -352,7 +347,10 @@ const CreateMaintenance = () => {
}} }}
items={repeatConfig} items={repeatConfig}
/> />
<Stack gap={theme.spacing(2)} mt={theme.spacing(16)}> <Stack
gap={theme.spacing(2)}
mt={theme.spacing(16)}
>
<Typography component="h3">Date</Typography> <Typography component="h3">Date</Typography>
<LocalizationProvider dateAdapter={AdapterDayjs}> <LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker <DatePicker
@@ -411,12 +409,13 @@ const CreateMaintenance = () => {
<ConfigBox> <ConfigBox>
<Stack direction="row"> <Stack direction="row">
<Box> <Box>
<Typography component="h2" variant="h2"> <Typography
component="h2"
variant="h2"
>
Start time Start time
</Typography> </Typography>
<Typography> <Typography>All dates and times are in GMT+0 time zone.</Typography>
All dates and times are in GMT+0 time zone.
</Typography>
</Box> </Box>
<Stack direction="row"> <Stack direction="row">
<LocalizationProvider dateAdapter={AdapterDayjs}> <LocalizationProvider dateAdapter={AdapterDayjs}>
@@ -457,11 +456,17 @@ const CreateMaintenance = () => {
</Stack> </Stack>
<Stack direction="row"> <Stack direction="row">
<Box> <Box>
<Typography component="h2" variant="h2"> <Typography
component="h2"
variant="h2"
>
Duration Duration
</Typography> </Typography>
</Box> </Box>
<Stack direction="row" spacing={theme.spacing(8)}> <Stack
direction="row"
spacing={theme.spacing(8)}
>
<Field <Field
type="number" type="number"
id="duration" id="duration"
@@ -498,7 +503,10 @@ const CreateMaintenance = () => {
<ConfigBox> <ConfigBox>
<Stack direction="row"> <Stack direction="row">
<Box> <Box>
<Typography component="h2" variant="h2"> <Typography
component="h2"
variant="h2"
>
Friendly name Friendly name
</Typography> </Typography>
</Box> </Box>
@@ -516,7 +524,10 @@ const CreateMaintenance = () => {
</Stack> </Stack>
<Stack direction="row"> <Stack direction="row">
<Box> <Box>
<Typography component="h2" variant="h2"> <Typography
component="h2"
variant="h2"
>
Add monitors Add monitors
</Typography> </Typography>
</Box> </Box>
@@ -539,7 +550,10 @@ const CreateMaintenance = () => {
</Stack> </Stack>
</ConfigBox> </ConfigBox>
</Box> </Box>
<Box ml="auto" display="inline-block"> <Box
ml="auto"
display="inline-block"
>
<Button <Button
variant="contained" variant="contained"
color="secondary" color="secondary"
@@ -183,7 +183,11 @@ const ActionsMenu = ({ isAdmin, maintenanceWindow, updateCallback }) => {
}, },
}} }}
> >
<Typography id="modal-delete-maintenance" component="h2" variant="h2"> <Typography
id="modal-delete-maintenance"
component="h2"
variant="h2"
>
Do you really want to remove this maintenance window? Do you really want to remove this maintenance window?
</Typography> </Typography>
<Stack <Stack
@@ -169,10 +169,7 @@ const MaintenanceTable = ({
*/ */
const getRange = () => { const getRange = () => {
let start = page * rowsPerPage + 1; let start = page * rowsPerPage + 1;
let end = Math.min( let end = Math.min(page * rowsPerPage + rowsPerPage, maintenanceWindowCount);
page * rowsPerPage + rowsPerPage,
maintenanceWindowCount
);
return `${start} - ${end}`; return `${start} - ${end}`;
}; };
@@ -221,8 +218,7 @@ const MaintenanceTable = ({
Status Status
<span <span
style={{ style={{
visibility: visibility: sort.field === "active" ? "visible" : "hidden",
sort.field === "active" ? "visible" : "hidden",
}} }}
> >
{sort.order === "asc" ? ( {sort.order === "asc" ? (
@@ -282,7 +278,11 @@ const MaintenanceTable = ({
justifyContent="space-between" justifyContent="space-between"
px={theme.spacing(4)} px={theme.spacing(4)}
> >
<Typography px={theme.spacing(2)} variant="body2" sx={{ opacity: 0.7 }}> <Typography
px={theme.spacing(2)}
variant="body2"
sx={{ opacity: 0.7 }}
>
Showing {getRange()} of {maintenanceWindowCount} maintenance window(s) Showing {getRange()} of {maintenanceWindowCount} maintenance window(s)
</Typography> </Typography>
<TablePagination <TablePagination
+2 -5
View File
@@ -33,8 +33,7 @@ const Maintenance = ({ isAdmin }) => {
page: page, page: page,
rowsPerPage: rowsPerPage, rowsPerPage: rowsPerPage,
}); });
const { maintenanceWindows, maintenanceWindowCount } = const { maintenanceWindows, maintenanceWindowCount } = response.data.data;
response.data.data;
setMaintenanceWindows(maintenanceWindows); setMaintenanceWindows(maintenanceWindows);
setMaintenanceWindowCount(maintenanceWindowCount); setMaintenanceWindowCount(maintenanceWindowCount);
} catch (error) { } catch (error) {
@@ -67,9 +66,7 @@ const Maintenance = ({ isAdmin }) => {
alignItems="center" alignItems="center"
mt={theme.spacing(5)} mt={theme.spacing(5)}
> >
<Breadcrumbs <Breadcrumbs list={[{ name: "maintenance", path: "/maintenance" }]} />
list={[{ name: "maintenance", path: "/maintenance" }]}
/>
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"
+30 -26
View File
@@ -65,9 +65,7 @@ const Configure = () => {
useEffect(() => { useEffect(() => {
const fetchMonitor = async () => { const fetchMonitor = async () => {
try { try {
const action = await dispatch( const action = await dispatch(getUptimeMonitorById({ authToken, monitorId }));
getUptimeMonitorById({ authToken, monitorId })
);
if (getUptimeMonitorById.fulfilled.match(action)) { if (getUptimeMonitorById.fulfilled.match(action)) {
const monitor = action.payload.data; const monitor = action.payload.data;
@@ -129,8 +127,7 @@ const Configure = () => {
setErrors((prev) => { setErrors((prev) => {
const updatedErrors = { ...prev }; const updatedErrors = { ...prev };
if (validation.error) if (validation.error) updatedErrors[name] = validation.error.details[0].message;
updatedErrors[name] = validation.error.details[0].message;
else delete updatedErrors[name]; else delete updatedErrors[name];
return updatedErrors; return updatedErrors;
}); });
@@ -139,9 +136,7 @@ const Configure = () => {
const handlePause = async () => { const handlePause = async () => {
try { try {
const action = await dispatch( const action = await dispatch(pauseUptimeMonitor({ authToken, monitorId }));
pauseUptimeMonitor({ authToken, monitorId })
);
if (pauseUptimeMonitor.fulfilled.match(action)) { if (pauseUptimeMonitor.fulfilled.match(action)) {
const monitor = action.payload.data; const monitor = action.payload.data;
setMonitor(monitor); setMonitor(monitor);
@@ -156,9 +151,7 @@ const Configure = () => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
event.preventDefault(); event.preventDefault();
const action = await dispatch( const action = await dispatch(updateUptimeMonitor({ authToken, monitor: monitor }));
updateUptimeMonitor({ authToken, monitor: monitor })
);
if (action.meta.requestStatus === "fulfilled") { if (action.meta.requestStatus === "fulfilled") {
createToast({ body: "Monitor updated successfully!" }); createToast({ body: "Monitor updated successfully!" });
dispatch(getUptimeMonitorsByTeamId(authToken)); dispatch(getUptimeMonitorsByTeamId(authToken));
@@ -203,7 +196,10 @@ const Configure = () => {
}; };
return ( return (
<Stack className="configure-monitor" gap={theme.spacing(10)}> <Stack
className="configure-monitor"
gap={theme.spacing(10)}
>
{Object.keys(monitor).length === 0 ? ( {Object.keys(monitor).length === 0 ? (
<SkeletonLayout /> <SkeletonLayout />
) : ( ) : (
@@ -222,9 +218,15 @@ const Configure = () => {
gap={theme.spacing(12)} gap={theme.spacing(12)}
flex={1} flex={1}
> >
<Stack direction="row" gap={theme.spacing(2)}> <Stack
direction="row"
gap={theme.spacing(2)}
>
<Box> <Box>
<Typography component="h1" variant="h1"> <Typography
component="h1"
variant="h1"
>
{monitor.name} {monitor.name}
</Typography> </Typography>
<Stack <Stack
@@ -250,12 +252,13 @@ const Configure = () => {
}} }}
> >
<Box> <Box>
<PulseDot <PulseDot color={statusColor[monitor?.status ?? undefined]} />
color={statusColor[monitor?.status ?? undefined]}
/>
</Box> </Box>
</Tooltip> </Tooltip>
<Typography component="h2" variant="h2"> <Typography
component="h2"
variant="h2"
>
{monitor.url?.replace(/^https?:\/\//, "") || "..."} {monitor.url?.replace(/^https?:\/\//, "") || "..."}
</Typography> </Typography>
<Typography <Typography
@@ -335,8 +338,8 @@ const Configure = () => {
<Box> <Box>
<Typography component="h2">General settings</Typography> <Typography component="h2">General settings</Typography>
<Typography component="p"> <Typography component="p">
Here you can select the URL of the host, together with the Here you can select the URL of the host, together with the type of
type of monitor. monitor.
</Typography> </Typography>
</Box> </Box>
<Stack gap={theme.spacing(20)}> <Stack gap={theme.spacing(20)}>
@@ -370,9 +373,7 @@ const Configure = () => {
</Typography> </Typography>
</Box> </Box>
<Stack gap={theme.spacing(6)}> <Stack gap={theme.spacing(6)}>
<Typography component="p"> <Typography component="p">When there is a new incident,</Typography>
When there is a new incident,
</Typography>
<Checkbox <Checkbox
id="notify-sms" id="notify-sms"
label="Notify via SMS (coming soon)" label="Notify via SMS (coming soon)"
@@ -434,7 +435,11 @@ const Configure = () => {
/> />
</Stack> </Stack>
</ConfigBox> </ConfigBox>
<Stack direction="row" justifyContent="flex-end" mt="auto"> <Stack
direction="row"
justifyContent="flex-end"
mt="auto"
>
<LoadingButton <LoadingButton
variant="contained" variant="contained"
color="primary" color="primary"
@@ -461,8 +466,7 @@ const Configure = () => {
theme={theme} theme={theme}
isLoading={isLoading} isLoading={isLoading}
description="Once deleted, this monitor cannot be retrieved." description="Once deleted, this monitor cannot be retrieved."
> ></Dialog>
</Dialog>
</Stack> </Stack>
); );
}; };
@@ -11,9 +11,20 @@ const SkeletonLayout = () => {
return ( return (
<> <>
<Skeleton variant="rounded" width="15%" height={34} /> <Skeleton
<Stack gap={theme.spacing(20)} mt={theme.spacing(6)}> variant="rounded"
<Stack direction="row" gap={theme.spacing(4)} mt={theme.spacing(4)}> width="15%"
height={34}
/>
<Stack
gap={theme.spacing(20)}
mt={theme.spacing(6)}
>
<Stack
direction="row"
gap={theme.spacing(4)}
mt={theme.spacing(4)}
>
<Skeleton <Skeleton
variant="circular" variant="circular"
style={{ minWidth: 24, minHeight: 24 }} style={{ minWidth: 24, minHeight: 24 }}
@@ -25,7 +36,11 @@ const SkeletonLayout = () => {
height={24} height={24}
sx={{ mb: theme.spacing(4) }} sx={{ mb: theme.spacing(4) }}
/> />
<Skeleton variant="rounded" width="50%" height={18} /> <Skeleton
variant="rounded"
width="50%"
height={18}
/>
</Box> </Box>
<Stack <Stack
direction="row" direction="row"
@@ -35,14 +50,37 @@ const SkeletonLayout = () => {
alignSelf: "flex-end", alignSelf: "flex-end",
}} }}
> >
<Skeleton variant="rounded" width={150} height={34} /> <Skeleton
variant="rounded"
width={150}
height={34}
/>
</Stack> </Stack>
</Stack> </Stack>
<Skeleton variant="rounded" width="100%" height={200} /> <Skeleton
<Skeleton variant="rounded" width="100%" height={200} /> variant="rounded"
<Skeleton variant="rounded" width="100%" height={200} /> width="100%"
<Stack direction="row" justifyContent="flex-end"> height={200}
<Skeleton variant="rounded" width="15%" height={34} /> />
<Skeleton
variant="rounded"
width="100%"
height={200}
/>
<Skeleton
variant="rounded"
width="100%"
height={200}
/>
<Stack
direction="row"
justifyContent="flex-end"
>
<Skeleton
variant="rounded"
width="15%"
height={34}
/>
</Stack> </Stack>
</Stack> </Stack>
</> </>
@@ -1,8 +1,10 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material"; import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material";
import LoadingButton from '@mui/lab/LoadingButton';
import { useSelector, useDispatch } from "react-redux"; import { useSelector, useDispatch } from "react-redux";
import { monitorValidation } from "../../../Validation/validation"; import { monitorValidation } from "../../../Validation/validation";
import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"; import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import { checkEndpointResolution } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"
import { useNavigate, useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { createToast } from "../../../Utils/toastUtils"; import { createToast } from "../../../Utils/toastUtils";
@@ -19,7 +21,7 @@ import "./index.css";
const CreateMonitor = () => { const CreateMonitor = () => {
const MS_PER_MINUTE = 60000; const MS_PER_MINUTE = 60000;
const { user, authToken } = useSelector((state) => state.auth); const { user, authToken } = useSelector((state) => state.auth);
const { monitors } = useSelector((state) => state.uptimeMonitors); const { monitors, isLoading } = useSelector((state) => state.uptimeMonitors);
const dispatch = useDispatch(); const dispatch = useDispatch();
const navigate = useNavigate(); const navigate = useNavigate();
const theme = useTheme(); const theme = useTheme();
@@ -46,9 +48,7 @@ const CreateMonitor = () => {
useEffect(() => { useEffect(() => {
const fetchMonitor = async () => { const fetchMonitor = async () => {
if (monitorId) { if (monitorId) {
const action = await dispatch( const action = await dispatch(getUptimeMonitorById({ authToken, monitorId }));
getUptimeMonitorById({ authToken, monitorId })
);
if (action.payload.success) { if (action.payload.success) {
const data = action.payload.data; const data = action.payload.data;
@@ -148,6 +148,17 @@ const CreateMonitor = () => {
setErrors(newErrors); setErrors(newErrors);
createToast({ body: "Error validation data." }); createToast({ body: "Error validation data." });
} else { } else {
if (monitor.type === "http") {
const checkEndpointAction = await dispatch(
checkEndpointResolution({ authToken, monitorURL: form.url })
)
if (checkEndpointAction.meta.requestStatus === "rejected") {
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
setErrors({ url: "The entered URL is not reachable." });
return;
}
}
form = { form = {
...form, ...form,
description: form.name, description: form.name,
@@ -155,9 +166,7 @@ const CreateMonitor = () => {
userId: user._id, userId: user._id,
notifications: monitor.notifications, notifications: monitor.notifications,
}; };
const action = await dispatch( const action = await dispatch(createUptimeMonitor({ authToken, monitor: form }));
createUptimeMonitor({ authToken, monitor: form })
);
if (action.meta.requestStatus === "fulfilled") { if (action.meta.requestStatus === "fulfilled") {
createToast({ body: "Monitor created successfully!" }); createToast({ body: "Monitor created successfully!" });
navigate("/monitors"); navigate("/monitors");
@@ -193,8 +202,14 @@ const CreateMonitor = () => {
gap={theme.spacing(12)} gap={theme.spacing(12)}
mt={theme.spacing(6)} mt={theme.spacing(6)}
> >
<Typography component="h1" variant="h1"> <Typography
<Typography component="span" fontSize="inherit"> component="h1"
variant="h1"
>
<Typography
component="span"
fontSize="inherit"
>
Create your{" "} Create your{" "}
</Typography> </Typography>
<Typography <Typography
@@ -210,8 +225,7 @@ const CreateMonitor = () => {
<Box> <Box>
<Typography component="h2">General settings</Typography> <Typography component="h2">General settings</Typography>
<Typography component="p"> <Typography component="p">
Here you can select the URL of the host, together with the type of Here you can select the URL of the host, together with the type of monitor.
monitor.
</Typography> </Typography>
</Box> </Box>
<Stack gap={theme.spacing(15)}> <Stack gap={theme.spacing(15)}>
@@ -368,15 +382,19 @@ const CreateMonitor = () => {
/> />
</Stack> </Stack>
</ConfigBox> </ConfigBox>
<Stack direction="row" justifyContent="flex-end"> <Stack
<Button direction="row"
justifyContent="flex-end"
>
<LoadingButton
variant="contained" variant="contained"
color="primary" color="primary"
onClick={handleCreateMonitor} onClick={handleCreateMonitor}
disabled={Object.keys(errors).length !== 0 && true} disabled={Object.keys(errors).length !== 0 && true}
loading={isLoading}
> >
Create monitor Create monitor
</Button> </LoadingButton>
</Stack> </Stack>
</Stack> </Stack>
</Box> </Box>
@@ -13,27 +13,28 @@ import { memo, useMemo, useState } from "react";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { formatDateWithTz } from "../../../../Utils/timeUtils"; import { formatDateWithTz } from "../../../../Utils/timeUtils";
const CustomLabels = ({ const CustomLabels = ({ x, width, height, firstDataPoint, lastDataPoint, type }) => {
x,
width,
height,
firstDataPoint,
lastDataPoint,
type,
}) => {
const uiTimezone = useSelector((state) => state.ui.timezone); const uiTimezone = useSelector((state) => state.ui.timezone);
const dateFormat = type === "day" ? "MMM D, h:mm A" : "MMM D"; const dateFormat = type === "day" ? "MMM D, h:mm A" : "MMM D";
return ( return (
<> <>
<text x={x} y={height} dy={-3} textAnchor="start" fontSize={11}> <text
{formatDateWithTz( x={x}
new Date(firstDataPoint.time), y={height}
dateFormat, dy={-3}
uiTimezone textAnchor="start"
)} fontSize={11}
>
{formatDateWithTz(new Date(firstDataPoint.time), dateFormat, uiTimezone)}
</text> </text>
<text x={width} y={height} dy={-3} textAnchor="end" fontSize={11}> <text
x={width}
y={height}
dy={-3}
textAnchor="end"
fontSize={11}
>
{formatDateWithTz(new Date(lastDataPoint.time), dateFormat, uiTimezone)} {formatDateWithTz(new Date(lastDataPoint.time), dateFormat, uiTimezone)}
</text> </text>
</> </>
@@ -67,7 +68,11 @@ const UpBarChart = memo(({ data, type, onBarHover }) => {
const reversedData = useMemo(() => [...data].reverse(), [data]); const reversedData = useMemo(() => [...data].reverse(), [data]);
return ( return (
<ResponsiveContainer width="100%" minWidth={210} height={155}> <ResponsiveContainer
width="100%"
minWidth={210}
height={155}
>
<BarChart <BarChart
width="100%" width="100%"
height="100%" height="100%"
@@ -108,9 +113,7 @@ const UpBarChart = memo(({ data, type, onBarHover }) => {
return ( return (
<Cell <Cell
key={`cell-${entry.time}`} key={`cell-${entry.time}`}
fill={ fill={hoveredBarIndex === index ? main : chartHovered ? light : main}
hoveredBarIndex === index ? main : chartHovered ? light : main
}
onMouseEnter={() => { onMouseEnter={() => {
setHoveredBarIndex(index); setHoveredBarIndex(index);
onBarHover(entry); onBarHover(entry);
@@ -153,7 +156,11 @@ const DownBarChart = memo(({ data, type, onBarHover }) => {
const reversedData = useMemo(() => [...data].reverse(), [data]); const reversedData = useMemo(() => [...data].reverse(), [data]);
return ( return (
<ResponsiveContainer width="100%" minWidth={250} height={155}> <ResponsiveContainer
width="100%"
minWidth={250}
height={155}
>
<BarChart <BarChart
width="100%" width="100%"
height="100%" height="100%"
@@ -260,7 +267,11 @@ const ResponseGaugeChart = ({ data }) => {
}; };
return ( return (
<ResponsiveContainer width="100%" minWidth={210} height={155}> <ResponsiveContainer
width="100%"
minWidth={210}
height={155}
>
<RadialBarChart <RadialBarChart
width="100%" width="100%"
height="100%" height="100%"
@@ -271,10 +282,24 @@ const ResponseGaugeChart = ({ data }) => {
innerRadius={100} innerRadius={100}
outerRadius={150} outerRadius={150}
> >
<text x={0} y="100%" dx="5%" dy={-2} textAnchor="start" fontSize={11}> <text
x={0}
y="100%"
dx="5%"
dy={-2}
textAnchor="start"
fontSize={11}
>
low low
</text> </text>
<text x="100%" y="100%" dx="-3%" dy={-2} textAnchor="end" fontSize={11}> <text
x="100%"
y="100%"
dx="-3%"
dy={-2}
textAnchor="end"
fontSize={11}
>
high high
</text> </text>
<text <text
@@ -294,8 +319,7 @@ const ResponseGaugeChart = ({ data }) => {
dominantBaseline="hanging" dominantBaseline="hanging"
fontSize={25} fontSize={25}
> >
<tspan fontWeight={600}>{responseTime}</tspan>{" "} <tspan fontWeight={600}>{responseTime}</tspan> <tspan opacity={0.8}>ms</tspan>
<tspan opacity={0.8}>ms</tspan>
</text> </text>
<RadialBar <RadialBar
background={{ fill: responseProps.bg }} background={{ fill: responseProps.bg }}
@@ -303,7 +327,11 @@ const ResponseGaugeChart = ({ data }) => {
dataKey="response" dataKey="response"
stroke="none" stroke="none"
> >
<Cell fill="transparent" background={false} barSize={0} /> <Cell
fill="transparent"
background={false}
barSize={0}
/>
<Cell fill={responseProps.main} /> <Cell fill={responseProps.main} />
</RadialBar> </RadialBar>
</RadialBarChart> </RadialBarChart>
@@ -125,9 +125,7 @@ const PaginationTable = ({ monitorId, dateRange }) => {
uiTimezone uiTimezone
)} )}
</TableCell> </TableCell>
<TableCell> <TableCell>{check.statusCode ? check.statusCode : "N/A"}</TableCell>
{check.statusCode ? check.statusCode : "N/A"}
</TableCell>
<TableCell>{check.message}</TableCell> <TableCell>{check.message}</TableCell>
</TableRow> </TableRow>
); );
@@ -1 +0,0 @@
+59 -12
View File
@@ -10,15 +10,30 @@ const SkeletonLayout = () => {
return ( return (
<> <>
<Skeleton variant="rounded" width="20%" height={34} /> <Skeleton
<Stack gap={theme.spacing(20)} mt={theme.spacing(6)}> variant="rounded"
<Stack direction="row" gap={theme.spacing(4)} mt={theme.spacing(4)}> width="20%"
height={34}
/>
<Stack
gap={theme.spacing(20)}
mt={theme.spacing(6)}
>
<Stack
direction="row"
gap={theme.spacing(4)}
mt={theme.spacing(4)}
>
<Skeleton <Skeleton
variant="circular" variant="circular"
style={{ minWidth: 24, minHeight: 24 }} style={{ minWidth: 24, minHeight: 24 }}
/> />
<Box width="80%"> <Box width="80%">
<Skeleton variant="rounded" width="50%" height={24} /> <Skeleton
variant="rounded"
width="50%"
height={24}
/>
<Skeleton <Skeleton
variant="rounded" variant="rounded"
width="50%" width="50%"
@@ -38,9 +53,21 @@ const SkeletonLayout = () => {
justifyContent="space-between" justifyContent="space-between"
gap={theme.spacing(12)} gap={theme.spacing(12)}
> >
<Skeleton variant="rounded" width="100%" height={80} /> <Skeleton
<Skeleton variant="rounded" width="100%" height={80} /> variant="rounded"
<Skeleton variant="rounded" width="100%" height={80} /> width="100%"
height={80}
/>
<Skeleton
variant="rounded"
width="100%"
height={80}
/>
<Skeleton
variant="rounded"
width="100%"
height={80}
/>
</Stack> </Stack>
<Box> <Box>
<Stack <Stack
@@ -54,16 +81,36 @@ const SkeletonLayout = () => {
height={24} height={24}
sx={{ alignSelf: "flex-end" }} sx={{ alignSelf: "flex-end" }}
/> />
<Skeleton variant="rounded" width="20%" height={34} /> <Skeleton
variant="rounded"
width="20%"
height={34}
/>
</Stack> </Stack>
<Box sx={{ height: "200px" }}> <Box sx={{ height: "200px" }}>
<Skeleton variant="rounded" width="100%" height="100%" /> <Skeleton
variant="rounded"
width="100%"
height="100%"
/>
</Box> </Box>
</Box> </Box>
<Stack gap={theme.spacing(8)}> <Stack gap={theme.spacing(8)}>
<Skeleton variant="rounded" width="20%" height={24} /> <Skeleton
<Skeleton variant="rounded" width="100%" height={200} /> variant="rounded"
<Skeleton variant="rounded" width="100%" height={50} /> width="20%"
height={24}
/>
<Skeleton
variant="rounded"
width="100%"
height={200}
/>
<Skeleton
variant="rounded"
width="100%"
height={50}
/>
</Stack> </Stack>
</Stack> </Stack>
</> </>
@@ -0,0 +1,79 @@
import { useTheme } from "@emotion/react";
import { Box, Stack, Typography } from "@mui/material";
import Search from "../../../../Components/Inputs/Search";
import MemoizedMonitorTable from "../MonitorTable";
import { useState } from "react";
import useDebounce from "../../../../Utils/debounce";
import PropTypes from "prop-types";
const CurrentMonitoring = ({ totalMonitors, monitors, isAdmin }) => {
const theme = useTheme();
const [search, setSearch] = useState("");
const [isSearching, setIsSearching] = useState(false);
const debouncedFilter = useDebounce(search, 500);
const handleSearch = (value) => {
setIsSearching(true);
setSearch(value);
};
return (
<Box
flex={1}
px={theme.spacing(10)}
py={theme.spacing(8)}
border={1}
borderColor={theme.palette.border.light}
borderRadius={theme.shape.borderRadius}
backgroundColor={theme.palette.background.main}
>
<Stack
direction="row"
alignItems="center"
mb={theme.spacing(8)}
>
<Typography
component="h2"
variant="h2"
fontWeight={500}
letterSpacing={-0.2}
>
Actively monitoring
</Typography>
<Box
className="current-monitors-counter"
color={theme.palette.text.primary}
border={1}
borderColor={theme.palette.border.light}
backgroundColor={theme.palette.background.accent}
>
{totalMonitors}
</Box>
<Box
width="25%"
minWidth={150}
ml="auto"
>
<Search
options={monitors}
filteredBy="name"
inputValue={search}
handleInputChange={handleSearch}
/>
</Box>
</Stack>
<MemoizedMonitorTable
isAdmin={isAdmin}
filter={debouncedFilter}
setIsSearching={setIsSearching}
isSearching={isSearching}
/>
</Box>
);
};
CurrentMonitoring.propTypes = {
totalMonitors: PropTypes.number,
monitors: PropTypes.array,
isAdmin: PropTypes.bool,
};
export { CurrentMonitoring };
@@ -0,0 +1,31 @@
import { Skeleton, TableCell, TableRow } from "@mui/material";
const ROWS_NUMBER = 7;
const ROWS_ARRAY = Array.from({ length: ROWS_NUMBER }, (_, i) => i);
const TableBodySkeleton = () => {
return (
<>
{ROWS_ARRAY.map((row) => (
<TableRow key={row}>
<TableCell>
<Skeleton />
</TableCell>
<TableCell>
<Skeleton />
</TableCell>
<TableCell>
<Skeleton />
</TableCell>
<TableCell>
<Skeleton />
</TableCell>
<TableCell>
<Skeleton />
</TableCell>
</TableRow>
))}
</>
);
};
export { TableBodySkeleton };
@@ -12,6 +12,7 @@ import {
Stack, Stack,
Typography, Typography,
Button, Button,
CircularProgress,
} from "@mui/material"; } from "@mui/material";
import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded"; import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded";
import ArrowUpwardRoundedIcon from "@mui/icons-material/ArrowUpwardRounded"; import ArrowUpwardRoundedIcon from "@mui/icons-material/ArrowUpwardRounded";
@@ -34,6 +35,7 @@ import RightArrow from "../../../../assets/icons/right-arrow.svg?react";
import SelectorVertical from "../../../../assets/icons/selector-vertical.svg?react"; import SelectorVertical from "../../../../assets/icons/selector-vertical.svg?react";
import ActionsMenu from "../actionsMenu"; import ActionsMenu from "../actionsMenu";
import useUtils from "../../utils"; import useUtils from "../../utils";
import { TableBodySkeleton } from "./Skeleton";
/** /**
* Component for pagination actions (first, previous, next, last). * Component for pagination actions (first, previous, next, last).
@@ -107,17 +109,17 @@ TablePaginationActions.propTypes = {
onPageChange: PropTypes.func.isRequired, onPageChange: PropTypes.func.isRequired,
}; };
const MonitorTable = ({ isAdmin, filter, setLoading }) => { const MonitorTable = ({ isAdmin, filter, setIsSearching, isSearching }) => {
const theme = useTheme(); const theme = useTheme();
const navigate = useNavigate(); const navigate = useNavigate();
const dispatch = useDispatch(); const dispatch = useDispatch();
const { determineState } = useUtils(); const { determineState } = useUtils();
const { rowsPerPage } = useSelector((state) => state.ui.monitors); const { rowsPerPage } = useSelector((state) => state.ui.monitors);
const authState = useSelector((state) => state.auth);
const [page, setPage] = useState(0); const [page, setPage] = useState(0);
const [monitors, setMonitors] = useState([]); const [monitors, setMonitors] = useState([]);
const [monitorCount, setMonitorCount] = useState(0); const [monitorCount, setMonitorCount] = useState(0);
const authState = useSelector((state) => state.auth);
const [updateTrigger, setUpdateTrigger] = useState(false); const [updateTrigger, setUpdateTrigger] = useState(false);
const [sort, setSort] = useState({}); const [sort, setSort] = useState({});
const prevFilter = useRef(filter); const prevFilter = useRef(filter);
@@ -160,11 +162,12 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
}); });
setMonitors(res?.data?.data?.monitors ?? []); setMonitors(res?.data?.data?.monitors ?? []);
setMonitorCount(res?.data?.data?.monitorCount ?? 0); setMonitorCount(res?.data?.data?.monitorCount ?? 0);
setLoading(false);
} catch (error) { } catch (error) {
logger.error(error); logger.error(error);
} finally {
setIsSearching(false);
} }
}, [authState, page, rowsPerPage, filter, sort, setLoading]); }, [authState, page, rowsPerPage, filter, sort, setIsSearching]);
useEffect(() => { useEffect(() => {
fetchPage(); fetchPage();
@@ -175,7 +178,7 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
rowsPerPage, rowsPerPage,
filter, filter,
sort, sort,
setLoading, setIsSearching,
fetchPage, fetchPage,
]); ]);
@@ -229,7 +232,37 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
}; };
return ( return (
<Box position="relative">
{isSearching && (
<> <>
<Box
width="100%"
height="100%"
position="absolute"
sx={{
backgroundColor: theme.palette.background.main,
opacity: 0.8,
zIndex: 100,
}}
/>
<Box
height="100%"
position="absolute"
top="20%"
left="50%"
sx={{
transform: "translateX(-50%)",
zIndex: 101,
}}
>
<CircularProgress
sx={{
color: theme.palette.other.icon,
}}
/>
</Box>
</>
)}
<TableContainer component={Paper}> <TableContainer component={Paper}>
<Table> <Table>
<TableHead> <TableHead>
@@ -263,8 +296,7 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
Status Status
<span <span
style={{ style={{
visibility: visibility: sort.field === "status" ? "visible" : "hidden",
sort.field === "status" ? "visible" : "hidden",
}} }}
> >
{sort.order === "asc" ? ( {sort.order === "asc" ? (
@@ -281,7 +313,9 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{monitors.map((monitor) => { {/* TODO add empty state. Check if is searching, and empty => skeleton. Is empty, not searching => skeleton */}
{monitors.length > 0 ? (
monitors.map((monitor) => {
let uptimePercentage = ""; let uptimePercentage = "";
let percentageColor = theme.palette.percentage.uptimeExcellent; let percentageColor = theme.palette.percentage.uptimeExcellent;
@@ -324,7 +358,10 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
}} }}
> >
<TableCell> <TableCell>
<Host key={monitor._id} params={params} /> <Host
key={monitor._id}
params={params}
/>
</TableCell> </TableCell>
<TableCell> <TableCell>
<StatusLabel <StatusLabel
@@ -337,9 +374,7 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
<BarChart checks={monitor.checks.slice().reverse()} /> <BarChart checks={monitor.checks.slice().reverse()} />
</TableCell> </TableCell>
<TableCell> <TableCell>
<span style={{ textTransform: "uppercase" }}> <span style={{ textTransform: "uppercase" }}>{monitor.type}</span>
{monitor.type}
</span>
</TableCell> </TableCell>
<TableCell> <TableCell>
<ActionsMenu <ActionsMenu
@@ -350,7 +385,10 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
</TableCell> </TableCell>
</TableRow> </TableRow>
); );
})} })
) : (
<TableBodySkeleton />
)}
</TableBody> </TableBody>
</Table> </Table>
</TableContainer> </TableContainer>
@@ -360,7 +398,11 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
justifyContent="space-between" justifyContent="space-between"
px={theme.spacing(4)} px={theme.spacing(4)}
> >
<Typography px={theme.spacing(2)} variant="body2" sx={{ opacity: 0.7 }}> <Typography
px={theme.spacing(2)}
variant="body2"
sx={{ opacity: 0.7 }}
>
Showing {getRange()} of {monitorCount} monitor(s) Showing {getRange()} of {monitorCount} monitor(s)
</Typography> </Typography>
<TablePagination <TablePagination
@@ -420,14 +462,15 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
}} }}
/> />
</Stack> </Stack>
</> </Box>
); );
}; };
MonitorTable.propTypes = { MonitorTable.propTypes = {
isAdmin: PropTypes.bool, isAdmin: PropTypes.bool,
filter: PropTypes.string, filter: PropTypes.string,
setLoading: PropTypes.func, setIsSearching: PropTypes.func,
isSearching: PropTypes.bool,
}; };
const MemoizedMonitorTable = memo(MonitorTable); const MemoizedMonitorTable = memo(MonitorTable);
+12 -16
View File
@@ -4,11 +4,7 @@ import { useTheme } from "@emotion/react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { createToast } from "../../../Utils/toastUtils"; import { createToast } from "../../../Utils/toastUtils";
import { logger } from "../../../Utils/Logger"; import { logger } from "../../../Utils/Logger";
import { import { IconButton, Menu, MenuItem } from "@mui/material";
IconButton,
Menu,
MenuItem
} from "@mui/material";
import { import {
deleteUptimeMonitor, deleteUptimeMonitor,
pauseUptimeMonitor, pauseUptimeMonitor,
@@ -16,7 +12,7 @@ import {
} from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"; } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import Settings from "../../../assets/icons/settings-bold.svg?react"; import Settings from "../../../assets/icons/settings-bold.svg?react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import Dialog from "../../../Components/Dialog" import Dialog from "../../../Components/Dialog";
const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => { const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
const [anchorEl, setAnchorEl] = useState(null); const [anchorEl, setAnchorEl] = useState(null);
@@ -87,11 +83,7 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
aria-label="monitor actions" aria-label="monitor actions"
onClick={(event) => { onClick={(event) => {
event.stopPropagation(); event.stopPropagation();
openMenu( openMenu(event, monitor._id, monitor.type === "ping" ? null : monitor.url);
event,
monitor._id,
monitor.type === "ping" ? null : monitor.url
);
}} }}
sx={{ sx={{
"&:focus": { "&:focus": {
@@ -182,7 +174,6 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
}} }}
> >
{monitor?.isActive === true ? "Pause" : "Resume"} {monitor?.isActive === true ? "Pause" : "Resume"}
</MenuItem> </MenuItem>
)} )}
{isAdmin && ( {isAdmin && (
@@ -203,14 +194,19 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
onClose={() => setIsOpen(false)} onClose={() => setIsOpen(false)}
title="Do you really want to delete this monitor?" title="Do you really want to delete this monitor?"
confirmationBtnLbl="Delete" confirmationBtnLbl="Delete"
confirmationBtnOnClick={e => { e.stopPropagation(); handleRemove(e) }} confirmationBtnOnClick={(e) => {
e.stopPropagation();
handleRemove(e);
}}
cancelBtnLbl="Cancel" cancelBtnLbl="Cancel"
cancelBtnOnClick={e => { e.stopPropagation(); setIsOpen(false) }} cancelBtnOnClick={(e) => {
e.stopPropagation();
setIsOpen(false);
}}
theme={theme} theme={theme}
isLoading={isLoading} isLoading={isLoading}
description="Once deleted, this monitor cannot be retrieved." description="Once deleted, this monitor cannot be retrieved."
> ></Dialog>
</Dialog>
</> </>
); );
}; };
+5 -1
View File
@@ -26,7 +26,11 @@ const Fallback = ({ isAdmin }) => {
<Box pb={theme.spacing(20)}> <Box pb={theme.spacing(20)}>
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />} {mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
</Box> </Box>
<Typography component="h2" variant="h2" fontWeight={500}> <Typography
component="h2"
variant="h2"
fontWeight={500}
>
No monitors found to display No monitors found to display
</Typography> </Typography>
<Typography variant="body1"> <Typography variant="body1">
+29 -116
View File
@@ -1,55 +1,44 @@
import "./index.css"; import "./index.css";
import { useEffect, useState } from "react"; import { useEffect } from "react";
import { useSelector, useDispatch } from "react-redux"; import { useSelector, useDispatch } from "react-redux";
import { getUptimeMonitorsByTeamId } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"; import { getUptimeMonitorsByTeamId } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { import { Box, Button, Stack } from "@mui/material";
Box,
Button,
CircularProgress,
Stack,
Typography,
} from "@mui/material";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import SkeletonLayout from "./skeleton"; import SkeletonLayout from "./skeleton";
import Fallback from "./fallback"; import Fallback from "./fallback";
import StatusBox from "./StatusBox"; import StatusBox from "./StatusBox";
import Breadcrumbs from "../../../Components/Breadcrumbs"; import Breadcrumbs from "../../../Components/Breadcrumbs";
import Greeting from "../../../Utils/greeting"; import Greeting from "../../../Utils/greeting";
import MonitorTable from "./MonitorTable"; import { CurrentMonitoring } from "./CurrentMonitoring";
import Search from "../../../Components/Inputs/Search";
import useDebounce from "../../../Utils/debounce";
const Monitors = ({ isAdmin }) => { const Monitors = ({ isAdmin }) => {
const theme = useTheme(); const theme = useTheme();
const navigate = useNavigate(); const navigate = useNavigate();
const monitorState = useSelector((state) => state.uptimeMonitors); const monitorState = useSelector((state) => state.uptimeMonitors);
const authState = useSelector((state) => state.auth); const authState = useSelector((state) => state.auth);
const [search, setSearch] = useState("");
const [isSearching, setIsSearching] = useState(false);
const dispatch = useDispatch({}); const dispatch = useDispatch({});
const debouncedFilter = useDebounce(search, 500);
const handleSearch = (value) => {
setIsSearching(true);
setSearch(value);
};
useEffect(() => { useEffect(() => {
dispatch(getUptimeMonitorsByTeamId(authState.authToken)); dispatch(getUptimeMonitorsByTeamId(authState.authToken));
}, [authState.authToken, dispatch]); }, [authState.authToken, dispatch]);
let loading = //TODO bring fetching to this component, like on pageSpeed
monitorState?.isLoading &&
monitorState?.monitorsSummary?.monitors?.length === 0; const loading = monitorState?.isLoading;
const totalMonitors = monitorState?.monitorsSummary?.monitorCounts?.total;
const hasMonitors = totalMonitors > 0;
const noMonitors = !hasMonitors;
const canAddMonitor = isAdmin && hasMonitors;
return ( return (
<Stack className="monitors table-container" gap={theme.spacing(8)}> <Stack
{loading ? ( className="monitors"
<SkeletonLayout /> gap={theme.spacing(8)}
) : ( >
<>
<Box> <Box>
<Breadcrumbs list={[{ name: `monitors`, path: "/monitors" }]} /> <Breadcrumbs list={[{ name: `monitors`, path: "/monitors" }]} />
<Stack <Stack
@@ -57,10 +46,10 @@ const Monitors = ({ isAdmin }) => {
justifyContent="space-between" justifyContent="space-between"
alignItems="center" alignItems="center"
mt={theme.spacing(5)} mt={theme.spacing(5)}
gap={theme.spacing(6)}
> >
<Greeting type="uptime" /> <Greeting type="uptime" />
{isAdmin && {canAddMonitor && (
monitorState?.monitorsSummary?.monitors?.length !== 0 && (
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"
@@ -74,11 +63,12 @@ const Monitors = ({ isAdmin }) => {
)} )}
</Stack> </Stack>
</Box> </Box>
{isAdmin && monitorState?.monitorsSummary?.monitors?.length === 0 && ( {noMonitors && <Fallback isAdmin={isAdmin} />}
<Fallback isAdmin={isAdmin} /> {loading ? (
)} <SkeletonLayout />
) : (
{monitorState?.monitorsSummary?.monitors?.length !== 0 && ( <>
{hasMonitors && (
<> <>
<Stack <Stack
gap={theme.spacing(8)} gap={theme.spacing(8)}
@@ -91,95 +81,18 @@ const Monitors = ({ isAdmin }) => {
/> />
<StatusBox <StatusBox
title="down" title="down"
value={ value={monitorState?.monitorsSummary?.monitorCounts?.down ?? 0}
monitorState?.monitorsSummary?.monitorCounts?.down ?? 0
}
/> />
<StatusBox <StatusBox
title="paused" title="paused"
value={ value={monitorState?.monitorsSummary?.monitorCounts?.paused ?? 0}
monitorState?.monitorsSummary?.monitorCounts?.paused ?? 0
}
/> />
</Stack> </Stack>
<Box <CurrentMonitoring
flex={1}
px={theme.spacing(10)}
py={theme.spacing(8)}
border={1}
borderColor={theme.palette.border.light}
borderRadius={theme.shape.borderRadius}
backgroundColor={theme.palette.background.main}
>
<Stack
direction="row"
alignItems="center"
mb={theme.spacing(8)}
>
<Typography
component="h2"
variant="h2"
fontWeight={500}
letterSpacing={-0.2}
>
Actively monitoring
</Typography>
<Box
className="current-monitors-counter"
color={theme.palette.text.primary}
border={1}
borderColor={theme.palette.border.light}
backgroundColor={theme.palette.background.accent}
>
{monitorState?.monitorsSummary?.monitorCounts?.total || 0}
</Box>
<Box width="25%" minWidth={150} ml="auto">
<Search
options={monitorState?.monitorsSummary?.monitors ?? []}
filteredBy="name"
inputValue={search}
handleInputChange={handleSearch}
/>
</Box>
</Stack>
<Box position="relative">
{isSearching && (
<>
<Box
width="100%"
height="100%"
position="absolute"
sx={{
backgroundColor: theme.palette.background.main,
opacity: 0.8,
zIndex: 100,
}}
/>
<Box
height="100%"
position="absolute"
top="20%"
left="50%"
sx={{
transform: "translateX(-50%)",
zIndex: 101,
}}
>
<CircularProgress
sx={{
color: theme.palette.other.icon,
}}
/>
</Box>
</>
)}
<MonitorTable
isAdmin={isAdmin} isAdmin={isAdmin}
filter={debouncedFilter} monitors={monitorState.monitorsSummary.monitors}
setLoading={setIsSearching} totalMonitors={totalMonitors}
/> />
</Box>
</Box>
</> </>
)} )}
</> </>
+36 -7
View File
@@ -11,20 +11,49 @@ const SkeletonLayout = () => {
return ( return (
<> <>
<Stack direction="row" justifyContent="space-between" alignItems="center"> <Stack
<Skeleton variant="rounded" width="50%" height={36} /> direction="row"
<Skeleton variant="rounded" width="15%" height={36} /> justifyContent="space-between"
alignItems="center"
>
<Skeleton
variant="rounded"
width="50%"
height={36}
/>
<Skeleton
variant="rounded"
width="15%"
height={36}
/>
</Stack> </Stack>
<Stack <Stack
gap={theme.spacing(12)} gap={theme.spacing(12)}
direction="row" direction="row"
justifyContent="space-between" justifyContent="space-between"
> >
<Skeleton variant="rounded" width="100%" height={100} /> <Skeleton
<Skeleton variant="rounded" width="100%" height={100} /> variant="rounded"
<Skeleton variant="rounded" width="100%" height={100} /> width="100%"
height={100}
/>
<Skeleton
variant="rounded"
width="100%"
height={100}
/>
<Skeleton
variant="rounded"
width="100%"
height={100}
/>
</Stack> </Stack>
<Skeleton variant="rounded" width="100%" height="100%" flex={1} /> <Skeleton
variant="rounded"
width="100%"
height="100%"
flex={1}
/>
</> </>
); );
}; };
+18 -4
View File
@@ -35,10 +35,24 @@ const NotFound = ({ title = DefaultValue.title, desc = DefaultValue.desc }) => {
const theme = useTheme(); const theme = useTheme();
return ( return (
<Stack height="100vh" justifyContent="center"> <Stack
<Stack gap={theme.spacing(2)} alignItems="center"> height="100vh"
<img src={NotFoundSvg} alt="404" style={{ maxHeight: "25rem" }} /> justifyContent="center"
<Typography component="h1" variant="h1" fontSize={16}> >
<Stack
gap={theme.spacing(2)}
alignItems="center"
>
<img
src={NotFoundSvg}
alt="404"
style={{ maxHeight: "25rem" }}
/>
<Typography
component="h1"
variant="h1"
fontSize={16}
>
{title} {title}
</Typography> </Typography>
<Typography variant="body1">{desc}</Typography> <Typography variant="body1">{desc}</Typography>
+36 -20
View File
@@ -58,9 +58,7 @@ const PageSpeedConfigure = () => {
useEffect(() => { useEffect(() => {
const fetchMonitor = async () => { const fetchMonitor = async () => {
try { try {
const action = await dispatch( const action = await dispatch(getPagespeedMonitorById({ authToken, monitorId }));
getPagespeedMonitorById({ authToken, monitorId })
);
if (getPagespeedMonitorById.fulfilled.match(action)) { if (getPagespeedMonitorById.fulfilled.match(action)) {
const monitor = action.payload.data; const monitor = action.payload.data;
@@ -122,8 +120,7 @@ const PageSpeedConfigure = () => {
setErrors((prev) => { setErrors((prev) => {
const updatedErrors = { ...prev }; const updatedErrors = { ...prev };
if (validation.error) if (validation.error) updatedErrors[name] = validation.error.details[0].message;
updatedErrors[name] = validation.error.details[0].message;
else delete updatedErrors[name]; else delete updatedErrors[name];
return updatedErrors; return updatedErrors;
}); });
@@ -147,9 +144,7 @@ const PageSpeedConfigure = () => {
const handleSave = async (event) => { const handleSave = async (event) => {
event.preventDefault(); event.preventDefault();
const action = await dispatch( const action = await dispatch(updatePageSpeed({ authToken, monitor: monitor }));
updatePageSpeed({ authToken, monitor: monitor })
);
if (action.meta.requestStatus === "fulfilled") { if (action.meta.requestStatus === "fulfilled") {
createToast({ body: "Monitor updated successfully!" }); createToast({ body: "Monitor updated successfully!" });
dispatch(getPageSpeedByTeamId(authToken)); dispatch(getPageSpeedByTeamId(authToken));
@@ -170,7 +165,10 @@ const PageSpeedConfigure = () => {
}; };
return ( return (
<Stack className="configure-pagespeed" gap={theme.spacing(10)}> <Stack
className="configure-pagespeed"
gap={theme.spacing(10)}
>
{Object.keys(monitor).length === 0 ? ( {Object.keys(monitor).length === 0 ? (
<SkeletonLayout /> <SkeletonLayout />
) : ( ) : (
@@ -190,9 +188,15 @@ const PageSpeedConfigure = () => {
flex={1} flex={1}
gap={theme.spacing(10)} gap={theme.spacing(10)}
> >
<Stack direction="row" gap={theme.spacing(2)}> <Stack
direction="row"
gap={theme.spacing(2)}
>
<Box> <Box>
<Typography component="h1" variant="h1"> <Typography
component="h1"
variant="h1"
>
{monitor.name} {monitor.name}
</Typography> </Typography>
<Stack <Stack
@@ -221,7 +225,10 @@ const PageSpeedConfigure = () => {
<PulseDot color={statusColor[determineState(monitor)]} /> <PulseDot color={statusColor[determineState(monitor)]} />
</Box> </Box>
</Tooltip> </Tooltip>
<Typography component="h2" variant="h2"> <Typography
component="h2"
variant="h2"
>
{monitor.url?.replace(/^https?:\/\//, "") || "..."} {monitor.url?.replace(/^https?:\/\//, "") || "..."}
</Typography> </Typography>
<Typography <Typography
@@ -248,7 +255,10 @@ const PageSpeedConfigure = () => {
</Typography> </Typography>
</Stack> </Stack>
</Box> </Box>
<Box alignSelf="flex-end" ml="auto"> <Box
alignSelf="flex-end"
ml="auto"
>
<LoadingButton <LoadingButton
onClick={handlePause} onClick={handlePause}
loading={isLoading} loading={isLoading}
@@ -295,8 +305,8 @@ const PageSpeedConfigure = () => {
<Box> <Box>
<Typography component="h2">General settings</Typography> <Typography component="h2">General settings</Typography>
<Typography component="p"> <Typography component="p">
Here you can select the URL of the host, together with the Here you can select the URL of the host, together with the type of
type of monitor. monitor.
</Typography> </Typography>
</Box> </Box>
<Stack <Stack
@@ -337,9 +347,7 @@ const PageSpeedConfigure = () => {
</Typography> </Typography>
</Box> </Box>
<Stack gap={theme.spacing(6)}> <Stack gap={theme.spacing(6)}>
<Typography component="p"> <Typography component="p">When there is a new incident,</Typography>
When there is a new incident,
</Typography>
<Checkbox <Checkbox
id="notify-sms" id="notify-sms"
label="Notify via SMS (coming soon)" label="Notify via SMS (coming soon)"
@@ -401,7 +409,11 @@ const PageSpeedConfigure = () => {
/> />
</Stack> </Stack>
</ConfigBox> </ConfigBox>
<Stack direction="row" justifyContent="flex-end" mt="auto"> <Stack
direction="row"
justifyContent="flex-end"
mt="auto"
>
<LoadingButton <LoadingButton
loading={isLoading} loading={isLoading}
type="submit" type="submit"
@@ -469,7 +481,11 @@ const PageSpeedConfigure = () => {
> >
Cancel Cancel
</Button> </Button>
<Button variant="contained" color="error" onClick={handleRemove}> <Button
variant="contained"
color="error"
onClick={handleRemove}
>
Delete Delete
</Button> </Button>
</Stack> </Stack>
@@ -11,9 +11,21 @@ const SkeletonLayout = () => {
return ( return (
<> <>
<Skeleton variant="rounded" width="15%" height={34} /> <Skeleton
<Stack gap={theme.spacing(20)} mt={theme.spacing(6)} maxWidth="1000px"> variant="rounded"
<Stack direction="row" gap={theme.spacing(4)} mt={theme.spacing(4)}> width="15%"
height={34}
/>
<Stack
gap={theme.spacing(20)}
mt={theme.spacing(6)}
maxWidth="1000px"
>
<Stack
direction="row"
gap={theme.spacing(4)}
mt={theme.spacing(4)}
>
<Skeleton <Skeleton
variant="circular" variant="circular"
style={{ minWidth: 24, minHeight: 24 }} style={{ minWidth: 24, minHeight: 24 }}
@@ -25,7 +37,11 @@ const SkeletonLayout = () => {
height={24} height={24}
sx={{ mb: theme.spacing(4) }} sx={{ mb: theme.spacing(4) }}
/> />
<Skeleton variant="rounded" width="50%" height={18} /> <Skeleton
variant="rounded"
width="50%"
height={18}
/>
</Box> </Box>
<Stack <Stack
direction="row" direction="row"
@@ -35,13 +51,32 @@ const SkeletonLayout = () => {
alignSelf: "flex-end", alignSelf: "flex-end",
}} }}
> >
<Skeleton variant="rounded" width={100} height={34} /> <Skeleton
<Skeleton variant="rounded" width={100} height={34} /> variant="rounded"
width={100}
height={34}
/>
<Skeleton
variant="rounded"
width={100}
height={34}
/>
</Stack> </Stack>
</Stack> </Stack>
<Skeleton variant="rounded" width="100%" height={500} /> <Skeleton
<Stack direction="row" justifyContent="flex-end"> variant="rounded"
<Skeleton variant="rounded" width="15%" height={34} /> width="100%"
height={500}
/>
<Stack
direction="row"
justifyContent="flex-end"
>
<Skeleton
variant="rounded"
width="15%"
height={34}
/>
</Stack> </Stack>
</Stack> </Stack>
</> </>
@@ -1,10 +1,11 @@
import { useState } from "react"; import { useState } from "react";
import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material"; import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material";
import LoadingButton from '@mui/lab/LoadingButton';
import { useSelector, useDispatch } from "react-redux"; import { useSelector, useDispatch } from "react-redux";
import { monitorValidation } from "../../../Validation/validation"; import { monitorValidation } from "../../../Validation/validation";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { createPageSpeed } from "../../../Features/PageSpeedMonitor/pageSpeedMonitorSlice"; import { createPageSpeed, checkEndpointResolution } from "../../../Features/PageSpeedMonitor/pageSpeedMonitorSlice";
import { createToast } from "../../../Utils/toastUtils"; import { createToast } from "../../../Utils/toastUtils";
import { logger } from "../../../Utils/Logger"; import { logger } from "../../../Utils/Logger";
import { ConfigBox } from "../../Monitors/styled"; import { ConfigBox } from "../../Monitors/styled";
@@ -18,6 +19,7 @@ import "./index.css";
const CreatePageSpeed = () => { const CreatePageSpeed = () => {
const MS_PER_MINUTE = 60000; const MS_PER_MINUTE = 60000;
const { user, authToken } = useSelector((state) => state.auth); const { user, authToken } = useSelector((state) => state.auth);
const { isLoading } = useSelector((state) => state.pageSpeedMonitors);
const dispatch = useDispatch(); const dispatch = useDispatch();
const navigate = useNavigate(); const navigate = useNavigate();
const theme = useTheme(); const theme = useTheme();
@@ -111,6 +113,15 @@ const CreatePageSpeed = () => {
setErrors(newErrors); setErrors(newErrors);
createToast({ body: "Error validation data." }); createToast({ body: "Error validation data." });
} else { } else {
const checkEndpointAction = await dispatch(
checkEndpointResolution({ authToken, monitorURL: form.url })
)
if (checkEndpointAction.meta.requestStatus === "rejected") {
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
setErrors({ url: "The entered URL is not reachable." });
return;
}
form = { form = {
...form, ...form,
description: form.name, description: form.name,
@@ -327,14 +338,15 @@ const CreatePageSpeed = () => {
</Stack> </Stack>
</ConfigBox> </ConfigBox>
<Stack direction="row" justifyContent="flex-end"> <Stack direction="row" justifyContent="flex-end">
<Button <LoadingButton
variant="contained" variant="contained"
color="primary" color="primary"
onClick={handleCreateMonitor} onClick={handleCreateMonitor}
disabled={Object.keys(errors).length !== 0 && true} disabled={Object.keys(errors).length !== 0 && true}
loading={isLoading}
> >
Create monitor Create monitor
</Button> </LoadingButton>
</Stack> </Stack>
</Stack> </Stack>
</Box> </Box>
@@ -105,9 +105,7 @@ const CustomToolTip = ({ active, payload, label, config }) => {
> >
{config[key].text} {config[key].text}
</Typography>{" "} </Typography>{" "}
<Typography component="span"> <Typography component="span">{payload[0].payload[key]}</Typography>
{payload[0].payload[key]}
</Typography>
</Stack> </Stack>
); );
})} })}
@@ -216,10 +214,7 @@ CustomTick.propTypes = {
const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => { const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
const theme = useTheme(); const theme = useTheme();
const [isHovered, setIsHovered] = useState(false); const [isHovered, setIsHovered] = useState(false);
const memoizedData = useMemo( const memoizedData = useMemo(() => processDataWithGaps(data, interval), [data[0]]);
() => processDataWithGaps(data, interval),
[data[0]]
);
const filteredConfig = Object.keys(config).reduce((result, key) => { const filteredConfig = Object.keys(config).reduce((result, key) => {
if (metrics[key]) { if (metrics[key]) {
@@ -229,7 +224,11 @@ const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
}, {}); }, {});
return ( return (
<ResponsiveContainer width="100%" minWidth={25} height={215}> <ResponsiveContainer
width="100%"
minWidth={25}
height={215}
>
<AreaChart <AreaChart
width="100%" width="100%"
height="100%" height="100%"
@@ -265,9 +264,24 @@ const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
const endColor = theme.palette[color].light; const endColor = theme.palette[color].light;
return ( return (
<linearGradient id={id} x1="0" y1="0" x2="0" y2="1" key={id}> <linearGradient
<stop offset="0%" stopColor={startColor} stopOpacity={0.8} /> id={id}
<stop offset="100%" stopColor={endColor} stopOpacity={0} /> x1="0"
y1="0"
x2="0"
y2="1"
key={id}
>
<stop
offset="0%"
stopColor={startColor}
stopOpacity={0.8}
/>
<stop
offset="100%"
stopColor={endColor}
stopOpacity={0}
/>
</linearGradient> </linearGradient>
); );
})} })}
@@ -299,12 +313,9 @@ PagespeedDetailsAreaChart.propTypes = {
data: PropTypes.arrayOf( data: PropTypes.arrayOf(
PropTypes.shape({ PropTypes.shape({
createdAt: PropTypes.string.isRequired, createdAt: PropTypes.string.isRequired,
accessibility: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) accessibility: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
.isRequired, bestPractices: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
bestPractices: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) performance: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
.isRequired,
performance: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,
seo: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, seo: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
}) })
).isRequired, ).isRequired,
@@ -20,7 +20,12 @@ const PieCenterLabel = ({ value, color, setExpand }) => {
transform={`translate(${width / 2}, ${height / 2})`} transform={`translate(${width / 2}, ${height / 2})`}
onMouseEnter={() => setExpand(true)} onMouseEnter={() => setExpand(true)}
> >
<circle cx={0} cy={0} r={width / 4} fill="transparent" /> <circle
cx={0}
cy={0}
r={width / 4}
fill="transparent"
/>
<text <text
className="pie-label" className="pie-label"
style={{ style={{
+65 -29
View File
@@ -1,20 +1,10 @@
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { import { Box, Button, Divider, Stack, Tooltip, Typography } from "@mui/material";
Box,
Button,
Divider,
Stack,
Tooltip,
Typography,
} from "@mui/material";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { useNavigate, useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { import { formatDurationRounded, formatDurationSplit } from "../../../Utils/timeUtils";
formatDurationRounded,
formatDurationSplit,
} from "../../../Utils/timeUtils";
import { ChartBox, IconBox, StatBox } from "./styled"; import { ChartBox, IconBox, StatBox } from "./styled";
import { logger } from "../../../Utils/Logger"; import { logger } from "../../../Utils/Logger";
import { networkService } from "../../../main"; import { networkService } from "../../../main";
@@ -88,7 +78,10 @@ const PageSpeedDetails = ({ isAdmin }) => {
}; };
return ( return (
<Stack className="page-speed-details" gap={theme.spacing(10)}> <Stack
className="page-speed-details"
gap={theme.spacing(10)}
>
{loading ? ( {loading ? (
<SkeletonLayout /> <SkeletonLayout />
) : ( ) : (
@@ -99,9 +92,15 @@ const PageSpeedDetails = ({ isAdmin }) => {
{ name: "details", path: `/pagespeed/${monitorId}` }, { name: "details", path: `/pagespeed/${monitorId}` },
]} ]}
/> />
<Stack direction="row" gap={theme.spacing(2)}> <Stack
direction="row"
gap={theme.spacing(2)}
>
<Box> <Box>
<Typography component="h1" variant="h1"> <Typography
component="h1"
variant="h1"
>
{monitor.name} {monitor.name}
</Typography> </Typography>
<Stack <Stack
@@ -130,7 +129,10 @@ const PageSpeedDetails = ({ isAdmin }) => {
<PulseDot color={statusColor[determineState(monitor)]} /> <PulseDot color={statusColor[determineState(monitor)]} />
</Box> </Box>
</Tooltip> </Tooltip>
<Typography component="h2" variant="h2"> <Typography
component="h2"
variant="h2"
>
{monitor?.url} {monitor?.url}
</Typography> </Typography>
<Typography <Typography
@@ -179,7 +181,10 @@ const PageSpeedDetails = ({ isAdmin }) => {
</Button> </Button>
)} )}
</Stack> </Stack>
<Stack direction="row" gap={theme.spacing(8)}> <Stack
direction="row"
gap={theme.spacing(8)}
>
<StatBox> <StatBox>
<Typography component="h2">checks since</Typography> <Typography component="h2">checks since</Typography>
<Typography> <Typography>
@@ -196,11 +201,18 @@ const PageSpeedDetails = ({ isAdmin }) => {
</StatBox> </StatBox>
</Stack> </Stack>
<Box> <Box>
<Typography variant="body2" my={theme.spacing(8)}> <Typography
variant="body2"
my={theme.spacing(8)}
>
Showing statistics for past 24 hours. Showing statistics for past 24 hours.
</Typography> </Typography>
<ChartBox sx={{ gridTemplateColumns: "75% 25%" }}> <ChartBox sx={{ gridTemplateColumns: "75% 25%" }}>
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}> <Stack
direction="row"
alignItems="center"
gap={theme.spacing(6)}
>
<IconBox> <IconBox>
<ScoreIcon /> <ScoreIcon />
</IconBox> </IconBox>
@@ -232,7 +244,10 @@ const PageSpeedDetails = ({ isAdmin }) => {
}} }}
> >
<Box> <Box>
<Typography fontSize={11} fontWeight={500}> <Typography
fontSize={11}
fontWeight={500}
>
Shown Shown
</Typography> </Typography>
<Divider sx={{ mt: theme.spacing(2) }} /> <Divider sx={{ mt: theme.spacing(2) }} />
@@ -273,7 +288,11 @@ const PageSpeedDetails = ({ isAdmin }) => {
flex={1} flex={1}
sx={{ gridTemplateColumns: "50% 50%", gridTemplateRows: "15% 85%" }} sx={{ gridTemplateColumns: "50% 50%", gridTemplateRows: "15% 85%" }}
> >
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}> <Stack
direction="row"
alignItems="center"
gap={theme.spacing(6)}
>
<IconBox> <IconBox>
<PerformanceIcon /> <PerformanceIcon />
</IconBox> </IconBox>
@@ -288,7 +307,10 @@ const PageSpeedDetails = ({ isAdmin }) => {
pb={theme.spacing(12)} pb={theme.spacing(12)}
> >
<PieChart audits={audits} /> <PieChart audits={audits} />
<Typography variant="body1" mt="auto"> <Typography
variant="body1"
mt="auto"
>
Values are estimated and may vary.{" "} Values are estimated and may vary.{" "}
<Typography <Typography
component="span" component="span"
@@ -309,8 +331,16 @@ const PageSpeedDetails = ({ isAdmin }) => {
</Typography> </Typography>
</Typography> </Typography>
</Stack> </Stack>
<Box px={theme.spacing(20)} py={theme.spacing(8)} height="100%"> <Box
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}> px={theme.spacing(20)}
py={theme.spacing(8)}
height="100%"
>
<Stack
direction="row"
alignItems="center"
gap={theme.spacing(6)}
>
<IconBox> <IconBox>
<SpedometerIcon /> <SpedometerIcon />
</IconBox> </IconBox>
@@ -336,9 +366,7 @@ const PageSpeedDetails = ({ isAdmin }) => {
: theme.palette.unresolved.main; : theme.palette.unresolved.main;
// Find the position where the number ends and the unit begins // Find the position where the number ends and the unit begins
const match = audit.displayValue.match( const match = audit.displayValue.match(/(\d+\.?\d*)\s*([a-zA-Z]+)/);
/(\d+\.?\d*)\s*([a-zA-Z]+)/
);
let value; let value;
let unit; let unit;
if (match) { if (match) {
@@ -376,12 +404,20 @@ const PageSpeedDetails = ({ isAdmin }) => {
color={theme.palette.text.primary} color={theme.palette.text.primary}
> >
{value} {value}
<Typography component="span" variant="body2" ml={2}> <Typography
component="span"
variant="body2"
ml={2}
>
{unit} {unit}
</Typography> </Typography>
</Typography> </Typography>
</Box> </Box>
<Box width={4} backgroundColor={bg} borderRadius={4} /> <Box
width={4}
backgroundColor={bg}
borderRadius={4}
/>
</Stack> </Stack>
); );
})} })}
+62 -12
View File
@@ -8,12 +8,31 @@ import { Box, Skeleton, Stack } from "@mui/material";
const SkeletonLayout = () => { const SkeletonLayout = () => {
return ( return (
<> <>
<Skeleton variant="rounded" width="15%" height={34} /> <Skeleton
<Stack direction="row" gap={4}> variant="rounded"
<Skeleton variant="circular" style={{ minWidth: 24, minHeight: 24 }} /> width="15%"
height={34}
/>
<Stack
direction="row"
gap={4}
>
<Skeleton
variant="circular"
style={{ minWidth: 24, minHeight: 24 }}
/>
<Box width="85%"> <Box width="85%">
<Skeleton variant="rounded" width="50%" height={24} /> <Skeleton
<Skeleton variant="rounded" width="50%" height={18} sx={{ mt: 4 }} /> variant="rounded"
width="50%"
height={24}
/>
<Skeleton
variant="rounded"
width="50%"
height={18}
sx={{ mt: 4 }}
/>
</Box> </Box>
<Skeleton <Skeleton
variant="rounded" variant="rounded"
@@ -28,14 +47,45 @@ const SkeletonLayout = () => {
gap={20} gap={20}
flexWrap="wrap" flexWrap="wrap"
> >
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} /> <Skeleton
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} /> variant="rounded"
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} /> width="30%"
height={90}
sx={{ flex: 1 }}
/>
<Skeleton
variant="rounded"
width="30%"
height={90}
sx={{ flex: 1 }}
/>
<Skeleton
variant="rounded"
width="30%"
height={90}
sx={{ flex: 1 }}
/>
</Stack> </Stack>
<Skeleton variant="rounded" width="25%" height={24} /> <Skeleton
<Skeleton variant="rounded" width="100%" height={300} /> variant="rounded"
<Skeleton variant="rounded" width="25%" height={24} /> width="25%"
<Skeleton variant="rounded" width="100%" height={300} /> height={24}
/>
<Skeleton
variant="rounded"
width="100%"
height={300}
/>
<Skeleton
variant="rounded"
width="25%"
height={24}
/>
<Skeleton
variant="rounded"
width="100%"
height={300}
/>
</> </>
); );
}; };
+20 -16
View File
@@ -5,13 +5,7 @@ import { Box, Grid, Stack, Typography } from "@mui/material";
import { useNavigate } from "react-router"; import { useNavigate } from "react-router";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { IconBox } from "./Details/styled"; import { IconBox } from "./Details/styled";
import { import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip } from "recharts";
Area,
AreaChart,
CartesianGrid,
ResponsiveContainer,
Tooltip,
} from "recharts";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { formatDateWithTz, formatDurationSplit } from "../../Utils/timeUtils"; import { formatDateWithTz, formatDurationSplit } from "../../Utils/timeUtils";
import useUtils from "../Monitors/utils"; import useUtils from "../Monitors/utils";
@@ -99,11 +93,7 @@ const processData = (data) => {
const calculateScore = (entry) => { const calculateScore = (entry) => {
return ( return (
(entry.accessibility + (entry.accessibility + entry.bestPractices + entry.performance + entry.seo) / 4
entry.bestPractices +
entry.performance +
entry.seo) /
4
); );
}; };
@@ -130,7 +120,11 @@ const PagespeedAreaChart = ({ data, status }) => {
const formattedData = processData(data); const formattedData = processData(data);
return ( return (
<ResponsiveContainer width="100%" minWidth={25} height={85}> <ResponsiveContainer
width="100%"
minWidth={25}
height={85}
>
<AreaChart <AreaChart
width="100%" width="100%"
height="100%" height="100%"
@@ -212,7 +206,11 @@ const Card = ({ monitor }) => {
const monitorState = determineState(monitor); const monitorState = determineState(monitor);
return ( return (
<Grid item lg={6} flexGrow={1}> <Grid
item
lg={6}
flexGrow={1}
>
<Box <Box
position="relative" position="relative"
p={theme.spacing(8)} p={theme.spacing(8)}
@@ -269,7 +267,10 @@ const Card = ({ monitor }) => {
mb={theme.spacing(-8)} mb={theme.spacing(-8)}
sx={{ gridColumnStart: 1, gridColumnEnd: 4 }} sx={{ gridColumnStart: 1, gridColumnEnd: 4 }}
> >
<PagespeedAreaChart data={monitor.checks} status={monitorState} /> <PagespeedAreaChart
data={monitor.checks}
status={monitorState}
/>
</Box> </Box>
<Box <Box
position="absolute" position="absolute"
@@ -287,7 +288,10 @@ const Card = ({ monitor }) => {
borderBottomLeftRadius: 4, borderBottomLeftRadius: 4,
}} }}
> >
<Typography fontSize={11} color={theme.palette.text.accent}> <Typography
fontSize={11}
color={theme.palette.text.accent}
>
Checking every{" "} Checking every{" "}
{(() => { {(() => {
const { time, format } = formatDurationSplit(monitor?.interval); const { time, format } = formatDurationSplit(monitor?.interval);
+9 -3
View File
@@ -19,7 +19,7 @@ const PageSpeed = ({ isAdmin }) => {
const navigate = useNavigate(); const navigate = useNavigate();
const { user, authToken } = useSelector((state) => state.auth); const { user, authToken } = useSelector((state) => state.auth);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(true);
const [monitors, setMonitors] = useState([]); const [monitors, setMonitors] = useState([]);
useEffect(() => { useEffect(() => {
dispatch(getPageSpeedByTeamId(authToken)); dispatch(getPageSpeedByTeamId(authToken));
@@ -99,9 +99,15 @@ const PageSpeed = ({ isAdmin }) => {
)} )}
</Stack> </Stack>
</Box> </Box>
<Grid container spacing={theme.spacing(12)}> <Grid
container
spacing={theme.spacing(12)}
>
{monitors?.map((monitor) => ( {monitors?.map((monitor) => (
<Card monitor={monitor} key={monitor._id} /> <Card
monitor={monitor}
key={monitor._id}
/>
))} ))}
</Grid> </Grid>
</Box> </Box>
+10 -2
View File
@@ -17,7 +17,11 @@ const SkeletonLayout = () => {
mb={theme.spacing(12)} mb={theme.spacing(12)}
> >
<Box width="80%"> <Box width="80%">
<Skeleton variant="rounded" width="25%" height={24} /> <Skeleton
variant="rounded"
width="25%"
height={24}
/>
<Skeleton <Skeleton
variant="rounded" variant="rounded"
width="50%" width="50%"
@@ -32,7 +36,11 @@ const SkeletonLayout = () => {
sx={{ alignSelf: "flex-end" }} sx={{ alignSelf: "flex-end" }}
/> />
</Stack> </Stack>
<Stack direction="row" flexWrap="wrap" gap={theme.spacing(12)}> <Stack
direction="row"
flexWrap="wrap"
gap={theme.spacing(12)}
>
<Skeleton <Skeleton
variant="rounded" variant="rounded"
width="100%" width="100%"
+34 -31
View File
@@ -17,12 +17,12 @@ import PropTypes from "prop-types";
import LoadingButton from "@mui/lab/LoadingButton"; import LoadingButton from "@mui/lab/LoadingButton";
import { setTimezone, setMode } from "../../Features/UI/uiSlice"; import { setTimezone, setMode } from "../../Features/UI/uiSlice";
import timezones from "../../Utils/timezones.json"; import timezones from "../../Utils/timezones.json";
import { useState,useEffect } from "react"; import { useState, useEffect } from "react";
import { ConfigBox } from "./styled"; import { ConfigBox } from "./styled";
import { networkService } from "../../main"; import { networkService } from "../../main";
import { settingsValidation } from "../../Validation/validation"; import { settingsValidation } from "../../Validation/validation";
import { useNavigate } from "react-router"; import { useNavigate } from "react-router";
import Dialog from "../../Components/Dialog" import Dialog from "../../Components/Dialog";
const SECONDS_PER_DAY = 86400; const SECONDS_PER_DAY = 86400;
@@ -33,12 +33,12 @@ const Settings = ({ isAdmin }) => {
const { isLoading } = useSelector((state) => state.uptimeMonitors); const { isLoading } = useSelector((state) => state.uptimeMonitors);
const { isLoading: authIsLoading } = useSelector((state) => state.auth); const { isLoading: authIsLoading } = useSelector((state) => state.auth);
const { timezone } = useSelector((state) => state.ui); const { timezone } = useSelector((state) => state.ui);
const {mode} = useSelector((state) => state.ui); const { mode } = useSelector((state) => state.ui);
const [checksIsLoading, setChecksIsLoading] = useState(false); const [checksIsLoading, setChecksIsLoading] = useState(false);
const [form, setForm] = useState({ const [form, setForm] = useState({
ttl: checkTTL ? (checkTTL / SECONDS_PER_DAY).toString() : 0, ttl: checkTTL ? (checkTTL / SECONDS_PER_DAY).toString() : 0,
}); });
const [version,setVersion]=useState("unknown"); const [version, setVersion] = useState("unknown");
const [errors, setErrors] = useState({}); const [errors, setErrors] = useState({});
const deleteStatsMonitorsInitState = { deleteMonitors: false, deleteStats: false }; const deleteStatsMonitorsInitState = { deleteMonitors: false, deleteStats: false };
const [isOpen, setIsOpen] = useState(deleteStatsMonitorsInitState); const [isOpen, setIsOpen] = useState(deleteStatsMonitorsInitState);
@@ -48,21 +48,21 @@ const Settings = ({ isAdmin }) => {
//Fetching latest release version from github //Fetching latest release version from github
useEffect(() => { useEffect(() => {
const fetchLatestVersion = async () => { const fetchLatestVersion = async () => {
let version="unknown"; let version = "unknown";
try { try {
const response = await networkService.fetchGithubLatestRelease(); const response = await networkService.fetchGithubLatestRelease();
if (!response.status===200) { if (!response.status === 200) {
throw new Error("Failed to fetch latest version"); throw new Error("Failed to fetch latest version");
} }
version=response.data.tag_name; version = response.data.tag_name;
} catch (error) { } catch (error) {
createToast({ body: error.message || "Error fetching latest version" }); // Set error message createToast({ body: error.message || "Error fetching latest version" }); // Set error message
} finally{ } finally {
setVersion(version); setVersion(version);
} }
}; };
fetchLatestVersion(); fetchLatestVersion();
},[]); }, []);
const handleChange = (event) => { const handleChange = (event) => {
const { value, id } = event.target; const { value, id } = event.target;
@@ -100,9 +100,7 @@ const Settings = ({ isAdmin }) => {
ttl: form.ttl, ttl: form.ttl,
}); });
const updatedUser = { ...user, checkTTL: form.ttl }; const updatedUser = { ...user, checkTTL: form.ttl };
const action = await dispatch( const action = await dispatch(update({ authToken, localData: updatedUser }));
update({ authToken, localData: updatedUser })
);
if (action.payload.success) { if (action.payload.success) {
createToast({ createToast({
body: "Settings saved successfully", body: "Settings saved successfully",
@@ -143,7 +141,7 @@ const Settings = ({ isAdmin }) => {
logger.error(error); logger.error(error);
createToast({ body: "Failed to clear stats" }); createToast({ body: "Failed to clear stats" });
} finally { } finally {
setIsOpen(deleteStatsMonitorsInitState) setIsOpen(deleteStatsMonitorsInitState);
} }
}; };
@@ -173,7 +171,7 @@ const Settings = ({ isAdmin }) => {
logger.error(error); logger.error(error);
createToast({ Body: "Failed to delete all monitors" }); createToast({ Body: "Failed to delete all monitors" });
} finally { } finally {
setIsOpen(deleteStatsMonitorsInitState) setIsOpen(deleteStatsMonitorsInitState);
} }
}; };
@@ -194,8 +192,8 @@ const Settings = ({ isAdmin }) => {
<Box> <Box>
<Typography component="h1">General settings</Typography> <Typography component="h1">General settings</Typography>
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(2) }}> <Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(2) }}>
<Typography component="span">Display timezone</Typography>- The <Typography component="span">Display timezone</Typography>- The timezone of
timezone of the dashboard you publicly display. the dashboard you publicly display.
</Typography> </Typography>
</Box> </Box>
<Stack gap={theme.spacing(20)}> <Stack gap={theme.spacing(20)}>
@@ -225,9 +223,11 @@ const Settings = ({ isAdmin }) => {
onChange={(e) => { onChange={(e) => {
dispatch(setMode(e.target.value)); dispatch(setMode(e.target.value));
}} }}
items={[{_id:'light', name:'Light'},{_id:'dark', name:'Dark'}]} items={[
> { _id: "light", name: "Light" },
</Select> { _id: "dark", name: "Dark" },
]}
></Select>
</Stack> </Stack>
</ConfigBox> </ConfigBox>
{isAdmin && ( {isAdmin && (
@@ -235,8 +235,8 @@ const Settings = ({ isAdmin }) => {
<Box> <Box>
<Typography component="h1">History and monitoring</Typography> <Typography component="h1">History and monitoring</Typography>
<Typography sx={{ mt: theme.spacing(2) }}> <Typography sx={{ mt: theme.spacing(2) }}>
Define here for how long you want to keep the data. You can also Define here for how long you want to keep the data. You can also remove
remove all past data. all past data.
</Typography> </Typography>
</Box> </Box>
<Stack gap={theme.spacing(20)}> <Stack gap={theme.spacing(20)}>
@@ -253,7 +253,9 @@ const Settings = ({ isAdmin }) => {
<Button <Button
variant="contained" variant="contained"
color="error" color="error"
onClick={()=>setIsOpen({...deleteStatsMonitorsInitState, deleteStats: true})} onClick={() =>
setIsOpen({ ...deleteStatsMonitorsInitState, deleteStats: true })
}
sx={{ mt: theme.spacing(4) }} sx={{ mt: theme.spacing(4) }}
> >
Clear all stats Clear all stats
@@ -272,8 +274,7 @@ const Settings = ({ isAdmin }) => {
cancelBtnOnClick={() => setIsOpen(deleteStatsMonitorsInitState)} cancelBtnOnClick={() => setIsOpen(deleteStatsMonitorsInitState)}
theme={theme} theme={theme}
isLoading={isLoading || authIsLoading || checksIsLoading} isLoading={isLoading || authIsLoading || checksIsLoading}
> ></Dialog>
</Dialog>
</ConfigBox> </ConfigBox>
)} )}
{isAdmin && ( {isAdmin && (
@@ -303,7 +304,9 @@ const Settings = ({ isAdmin }) => {
variant="contained" variant="contained"
color="error" color="error"
loading={isLoading || authIsLoading || checksIsLoading} loading={isLoading || authIsLoading || checksIsLoading}
onClick={()=>setIsOpen({...deleteStatsMonitorsInitState, deleteMonitors: true})} onClick={() =>
setIsOpen({ ...deleteStatsMonitorsInitState, deleteMonitors: true })
}
sx={{ mt: theme.spacing(4) }} sx={{ mt: theme.spacing(4) }}
> >
Remove all monitors Remove all monitors
@@ -322,8 +325,7 @@ const Settings = ({ isAdmin }) => {
cancelBtnOnClick={() => setIsOpen(deleteStatsMonitorsInitState)} cancelBtnOnClick={() => setIsOpen(deleteStatsMonitorsInitState)}
theme={theme} theme={theme}
isLoading={isLoading || authIsLoading || checksIsLoading} isLoading={isLoading || authIsLoading || checksIsLoading}
> ></Dialog>
</Dialog>
</ConfigBox> </ConfigBox>
)} )}
{isAdmin && ( {isAdmin && (
@@ -354,9 +356,7 @@ const Settings = ({ isAdmin }) => {
</Box> </Box>
<Box> <Box>
<Typography component="h2">BlueWave Uptime {version}</Typography> <Typography component="h2">BlueWave Uptime {version}</Typography>
<Typography <Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(6), opacity: 0.6 }}>
sx={{ mt: theme.spacing(2), mb: theme.spacing(6), opacity: 0.6 }}
>
Developed by Bluewave Labs. Developed by Bluewave Labs.
</Typography> </Typography>
<Link <Link
@@ -366,7 +366,10 @@ const Settings = ({ isAdmin }) => {
/> />
</Box> </Box>
</ConfigBox> </ConfigBox>
<Stack direction="row" justifyContent="flex-end"> <Stack
direction="row"
justifyContent="flex-end"
>
<LoadingButton <LoadingButton
loading={isLoading || authIsLoading || checksIsLoading} loading={isLoading || authIsLoading || checksIsLoading}
disabled={Object.keys(errors).length > 0} disabled={Object.keys(errors).length > 0}
+45 -45
View File
@@ -3,7 +3,6 @@ const BASE_URL = import.meta.env.VITE_APP_API_BASE_URL;
const FALLBACK_BASE_URL = "http://localhost:5000/api/v1"; const FALLBACK_BASE_URL = "http://localhost:5000/api/v1";
import { clearAuthState } from "../Features/Auth/authSlice"; import { clearAuthState } from "../Features/Auth/authSlice";
import { clearUptimeMonitorState } from "../Features/UptimeMonitors/uptimeMonitorsSlice"; import { clearUptimeMonitorState } from "../Features/UptimeMonitors/uptimeMonitorsSlice";
import { logger } from "./Logger";
class NetworkService { class NetworkService {
constructor(store, dispatch, navigate) { constructor(store, dispatch, navigate) {
this.store = store; this.store = store;
@@ -89,6 +88,32 @@ class NetworkService {
}); });
} }
/**
*
* ************************************
* Check the endpoint resolution
* ************************************
*
* @async
* @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {Object} config.monitorURL - The monitor url to be sent in the request body.
* @returns {Promise<AxiosResponse>} The response from the axios POST request.
*/
async checkEndpointResolution(config) {
const { authToken, monitorURL } = config;
const params = new URLSearchParams();
if (monitorURL) params.append("monitorURL", monitorURL);
return this.axiosInstance.get(`/monitors/resolution/url?${params.toString()}`, {
headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json",
}
})
}
/** /**
* *
* ************************************ * ************************************
@@ -175,15 +200,12 @@ class NetworkService {
if (field) params.append("field", field); if (field) params.append("field", field);
if (order) params.append("order", order); if (order) params.append("order", order);
return this.axiosInstance.get( return this.axiosInstance.get(`/monitors/team/${teamId}?${params.toString()}`, {
`/monitors/team/${teamId}?${params.toString()}`,
{
headers: { headers: {
Authorization: `Bearer ${authToken}`, Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} });
);
} }
/** /**
@@ -233,16 +255,12 @@ class NetworkService {
* @returns {Promise<AxiosResponse>} The response from the axios PUT request. * @returns {Promise<AxiosResponse>} The response from the axios PUT request.
*/ */
async updateMonitor(config) { async updateMonitor(config) {
return this.axiosInstance.put( return this.axiosInstance.put(`/monitors/${config.monitorId}`, config.updatedFields, {
`/monitors/${config.monitorId}`,
config.updatedFields,
{
headers: { headers: {
Authorization: `Bearer ${config.authToken}`, Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} });
);
} }
/** /**
@@ -582,12 +600,9 @@ class NetworkService {
if (config.page) params.append("page", config.page); if (config.page) params.append("page", config.page);
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage); if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
return this.axiosInstance.get( return this.axiosInstance.get(`/checks/${config.monitorId}?${params.toString()}`, {
`/checks/${config.monitorId}?${params.toString()}`,
{
headers: { Authorization: `Bearer ${config.authToken}` }, headers: { Authorization: `Bearer ${config.authToken}` },
} });
);
} }
/** /**
@@ -616,12 +631,9 @@ class NetworkService {
if (config.filter) params.append("filter", config.filter); if (config.filter) params.append("filter", config.filter);
if (config.page) params.append("page", config.page); if (config.page) params.append("page", config.page);
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage); if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
return this.axiosInstance.get( return this.axiosInstance.get(`/checks/team/${config.teamId}?${params.toString()}`, {
`/checks/team/${config.teamId}?${params.toString()}`,
{
headers: { Authorization: `Bearer ${config.authToken}` }, headers: { Authorization: `Bearer ${config.authToken}` },
} });
);
} }
/** /**
@@ -705,16 +717,12 @@ class NetworkService {
*/ */
async createMaintenanceWindow(config) { async createMaintenanceWindow(config) {
return this.axiosInstance.post( return this.axiosInstance.post(`/maintenance-window`, config.maintenanceWindow, {
`/maintenance-window`,
config.maintenanceWindow,
{
headers: { headers: {
Authorization: `Bearer ${config.authToken}`, Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} });
);
} }
/** /**
@@ -759,15 +767,12 @@ class NetworkService {
async getMaintenanceWindowById(config) { async getMaintenanceWindowById(config) {
const { authToken, maintenanceWindowId } = config; const { authToken, maintenanceWindowId } = config;
return this.axiosInstance.get( return this.axiosInstance.get(`/maintenance-window/${maintenanceWindowId}`, {
`/maintenance-window/${maintenanceWindowId}`,
{
headers: { headers: {
Authorization: `Bearer ${authToken}`, Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} });
);
} }
/** /**
@@ -797,15 +802,12 @@ class NetworkService {
if (field) params.append("field", field); if (field) params.append("field", field);
if (order) params.append("order", order); if (order) params.append("order", order);
return this.axiosInstance.get( return this.axiosInstance.get(`/maintenance-window/team?${params.toString()}`, {
`/maintenance-window/team?${params.toString()}`,
{
headers: { headers: {
Authorization: `Bearer ${authToken}`, Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} });
);
} }
/** /**
* ************************************ * ************************************
@@ -822,15 +824,12 @@ class NetworkService {
async deleteMaintenanceWindow(config) { async deleteMaintenanceWindow(config) {
const { authToken, maintenanceWindowId } = config; const { authToken, maintenanceWindowId } = config;
return this.axiosInstance.delete( return this.axiosInstance.delete(`/maintenance-window/${maintenanceWindowId}`, {
`/maintenance-window/${maintenanceWindowId}`,
{
headers: { headers: {
Authorization: `Bearer ${authToken}`, Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} });
);
} }
/** /**
@@ -843,9 +842,10 @@ class NetworkService {
* *
*/ */
async fetchGithubLatestRelease() { async fetchGithubLatestRelease() {
return this.axiosInstance.get('https://api.github.com/repos/bluewave-labs/bluewave-uptime/releases/latest'); return this.axiosInstance.get(
"https://api.github.com/repos/bluewave-labs/bluewave-uptime/releases/latest"
);
} }
} }
export default NetworkService; export default NetworkService;
+1 -2
View File
@@ -110,8 +110,7 @@ const darkTheme = createTheme({
}, },
}, },
{ {
props: (props) => props: (props) => props.variant === "group" && props.filled === "true",
props.variant === "group" && props.filled === "true",
style: { style: {
backgroundColor: theme.palette.secondary.main, backgroundColor: theme.palette.secondary.main,
}, },
+1 -2
View File
@@ -107,8 +107,7 @@ const lightTheme = createTheme({
}, },
}, },
{ {
props: (props) => props: (props) => props.variant === "group" && props.filled === "true",
props.variant === "group" && props.filled === "true",
style: { style: {
backgroundColor: theme.palette.secondary.main, backgroundColor: theme.palette.secondary.main,
}, },
+14 -3
View File
@@ -155,8 +155,15 @@ const Greeting = ({ type = "" }) => {
return ( return (
<Box> <Box>
<Typography component="h1" variant="h1" mb={theme.spacing(1)}> <Typography
<Typography component="span" fontSize="inherit"> component="h1"
variant="h1"
mb={theme.spacing(1)}
>
<Typography
component="span"
fontSize="inherit"
>
{prepend},{" "} {prepend},{" "}
</Typography> </Typography>
<Typography <Typography
@@ -168,7 +175,11 @@ const Greeting = ({ type = "" }) => {
{firstName} {emoji} {firstName} {emoji}
</Typography> </Typography>
</Typography> </Typography>
<Typography variant="h2" lineHeight={1} color={theme.palette.text.accent}> <Typography
variant="h2"
lineHeight={1}
color={theme.palette.text.accent}
>
{append} — Here’s an overview of your {type} monitors. {append} — Here’s an overview of your {type} monitors.
</Typography> </Typography>
</Box> </Box>
+25
View File
@@ -0,0 +1,25 @@
const buildErrors = (prev, id, error) => {
const updatedErrors = { ...prev };
if (error) {
updatedErrors[id] = error.details[0].message?? "Validation error";
} else {
delete updatedErrors[id];
}
return updatedErrors;
};
const hasValidationErrors = (form, validation, setErrors) => {
const { error } = validation.validate(form, {
abortEarly: false,
});
if (error) {
const newErrors = {};
error.details.forEach((err) => {
newErrors[err.path[0]] = err.message?? "Validation error";
});
setErrors(newErrors);
return true;
}
return false;
};
export { buildErrors, hasValidationErrors };
+37 -13
View File
@@ -22,22 +22,16 @@ const passwordSchema = joi
}) })
.custom((value, helpers) => { .custom((value, helpers) => {
if (!/[A-Z]/.test(value)) { if (!/[A-Z]/.test(value)) {
return helpers.message( return helpers.message("Password must contain at least one uppercase letter");
"Password must contain at least one uppercase letter"
);
} }
if (!/[a-z]/.test(value)) { if (!/[a-z]/.test(value)) {
return helpers.message( return helpers.message("Password must contain at least one lowercase letter");
"Password must contain at least one lowercase letter"
);
} }
if (!/\d/.test(value)) { if (!/\d/.test(value)) {
return helpers.message("Password must contain at least one number"); return helpers.message("Password must contain at least one number");
} }
if (!/[!@#$%^&*]/.test(value)) { if (!/[!@#$%^&*]/.test(value)) {
return helpers.message( return helpers.message("Password must contain at least one special character");
"Password must contain at least one special character"
);
} }
return value; return value;
@@ -89,10 +83,7 @@ const monitorValidation = joi.object({
name: joi.string().trim().max(50).allow("").messages({ name: joi.string().trim().max(50).allow("").messages({
"string.max": "This field should not exceed the 50 characters limit.", "string.max": "This field should not exceed the 50 characters limit.",
}), }),
type: joi type: joi.string().trim().messages({ "string.empty": "This field is required." }),
.string()
.trim()
.messages({ "string.empty": "This field is required." }),
interval: joi.number().messages({ interval: joi.number().messages({
"number.base": "Frequency must be a number.", "number.base": "Frequency must be a number.",
"any.required": "Frequency is required.", "any.required": "Frequency is required.",
@@ -137,10 +128,43 @@ const maintenanceWindowValidation = joi.object({
monitors: joi.array().min(1), monitors: joi.array().min(1),
}); });
const advancedSettingsValidation = joi.object({
apiBaseUrl: joi.string().uri({ allowRelative: true }).trim().messages({
"string.empty": "API base url is required.",
"string.uri": "The URL you provided is not valid.",
}),
logLevel: joi.string().valid("debug", "none", "error", "warn").allow(""),
systemEmailHost: joi.string().allow(''),
systemEmailPort: joi.string().allow(''),
systemEmailAddress: joi
.string().allow(''),
systemEmailPassword: joi.string().allow(''),
jwtTTL: joi
.string()
.trim()
.messages({
"string.empty": "JWT TTL is required."
}),
dbType: joi.string().trim().messages({
"string.empty": "DB type is required",
}),
redisHost: joi.string().trim().messages({
"string.empty": "Redis host is required",
}),
redisPort: joi.string().allow('').custom((value, helpers) => {
if(value && isNaN(parseInt(value))){
return helpers.message("Redit port must be a number")
}
return value
}),
pagespeedApiKey: joi.string().allow('')
});
export { export {
credentials, credentials,
imageValidation, imageValidation,
monitorValidation, monitorValidation,
settingsValidation, settingsValidation,
maintenanceWindowValidation, maintenanceWindowValidation,
advancedSettingsValidation,
}; };
+4 -1
View File
@@ -11,7 +11,10 @@ export { networkService };
ReactDOM.createRoot(document.getElementById("root")).render( ReactDOM.createRoot(document.getElementById("root")).render(
<Provider store={store}> <Provider store={store}>
<PersistGate loading={null} persistor={persistor}> <PersistGate
loading={null}
persistor={persistor}
>
<Router> <Router>
<NetworkServiceProvider> <NetworkServiceProvider>
<App /> <App />
+1 -5
View File
@@ -41,11 +41,7 @@ export const store = configureStore({
middleware: (getDefaultMiddleware) => middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({ getDefaultMiddleware({
serializableCheck: { serializableCheck: {
ignoredActions: [ ignoredActions: ["persist/PERSIST", "persist/REHYDRATE", "persist/REGISTER"],
"persist/PERSIST",
"persist/REHYDRATE",
"persist/REGISTER",
],
}, },
}), }),
}); });
+5 -5
View File
@@ -1,11 +1,11 @@
import { defineConfig } from 'vite' import { defineConfig } from "vite";
import react from '@vitejs/plugin-react' import react from "@vitejs/plugin-react";
import svgr from 'vite-plugin-svgr'; import svgr from "vite-plugin-svgr";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [svgr(), react()], plugins: [svgr(), react()],
optimizeDeps: { optimizeDeps: {
include: ['@mui/material/Tooltip', '@emotion/styled'], include: ["@mui/material/Tooltip", "@emotion/styled"],
}, },
}) });
+18 -16
View File
@@ -1,24 +1,26 @@
#!/bin/bash #!/bin/bash
# Change directory to root Server directory for correct Docker Context # Change directory to root Server directory for correct Docker Context
cd "$(dirname "$0")"
cd ../.. cd ../..
#Client # Define an array of services and their Dockerfiles
client="./Docker/dev/client.Dockerfile" declare -A services=(
["uptime_client"]="./Docker/dev/client.Dockerfile"
["uptime_database_mongo"]="./Docker/dev/mongoDB.Dockerfile"
["uptime_redis"]="./Docker/dev/redis.Dockerfile"
["uptime_server"]="./Docker/dev/server.Dockerfile"
)
# MongoDB # Loop through each service and build the corresponding image
mongoDB="./Docker/dev/mongoDB.Dockerfile" for service in "${!services[@]}"; do
docker build -f "${services[$service]}" -t "$service" .
# Redis ## Check if the build succeeded
redis="./Docker/dev/redis.Dockerfile" if [ $? -ne 0 ]; then
echo "Error building $service image. Exiting..."
exit 1
fi
done
# Server echo "All images built successfully"
server="./Docker/dev/server.Dockerfile"
docker build -f $client -t uptime_client .
docker build -f $mongoDB -t uptime_database_mongo .
docker build -f $redis -t uptime_redis .
docker build -f $server -t uptime_server .
echo "All images built"
+18 -16
View File
@@ -1,24 +1,26 @@
#!/bin/bash #!/bin/bash
# Change directory to root Server directory for correct Docker Context # Change directory to root Server directory for correct Docker Context
cd "$(dirname "$0")"
cd ../.. cd ../..
#Client # Define an array of services and their Dockerfiles
client="./Docker/dist/client.Dockerfile" declare -A services=(
["bluewave/uptime_client"]="./Docker/dist/client.Dockerfile"
["bluewave/database_mongo"]="./Docker/dist/mongoDB.Dockerfile"
["bluewave/uptime_redis"]="./Docker/dist/redis.Dockerfile"
["bluewave/uptime_server"]="./Docker/dist/server.Dockerfile"
)
# MongoDB # Loop through each service and build the corresponding image
mongoDB="./Docker/dist/mongoDB.Dockerfile" for service in "${!services[@]}"; do
docker build -f "${services[$service]}" -t "$service" .
# Redis # Check if the build succeeded
redis="./Docker/dist/redis.Dockerfile" if [ $? -ne 0 ]; then
echo "Error building $service image. Exiting..."
exit 1
fi
done
# Server echo "All images built successfully"
server="./Docker/dist/server.Dockerfile"
docker build -f $client -t dist_uptime_client .
docker build -f $mongoDB -t dist_uptime_database_mongo .
docker build -f $redis -t dist_uptime_redis .
docker build -f $server -t dist_uptime_server .
echo "All images built"
+18 -16
View File
@@ -1,24 +1,26 @@
#!/bin/bash #!/bin/bash
# Change directory to root directory for correct Docker Context # Change directory to root directory for correct Docker Context
cd "$(dirname "$0")"
cd ../.. cd ../..
#Client # Define an array of services and their Dockerfiles
client="./Docker/prod/client.Dockerfile" declare -A services=(
["uptime_client"]="./Docker/prod/client.Dockerfile"
["uptime_database_mongo"]="./Docker/prod/mongoDB.Dockerfile"
["uptime_redis"]="./Docker/prod/redis.Dockerfile"
["uptime_server"]="./Docker/prod/server.Dockerfile"
)
# MongoDB # Loop through each service and build the corresponding image
mongoDB="./Docker/prod/mongoDB.Dockerfile" for service in "${!services[@]}"; do
docker build -f "${services[$service]}" -t "$service" .
# Redis # Check if the build succeeded
redis="./Docker/prod/redis.Dockerfile" if [ $? -ne 0 ]; then
echo "Error building $service image. Exiting..."
exit 1
fi
done
# Server echo "All images built successfully"
server="./Docker/prod/server.Dockerfile"
docker build -f $client -t uptime_client .
docker build -f $mongoDB -t uptime_database_mongo .
docker build -f $redis -t uptime_redis .
docker build -f $server -t uptime_server .
echo "All images built"
+4 -5
View File
@@ -44,14 +44,13 @@ We've just launched our [Discussions](https://github.com/bluewave-labs/bluewave-
**Roadmap (short term):** **Roadmap (short term):**
- [ ] Memory, disk and CPU monitoring We are actively developing **infrastructure monitoring** features for Uptime Manager, which will include comprehensive monitoring of memory, disk usage, and CPU performance. Our goal is to build a lightweight agent that runs on Linux servers, continuously collecting and transmitting health metrics to Uptime Manager, where the data will be visualized for real-time insights.
- [ ] 3rd party integrations
- [ ] DNS monitoring
- [ ] SSL monitoring
**Roadmap (long term):** **Roadmap (long term):**
- [ ] Status pages - DNS monitoring
- SSL monitoring
- Status pages
## Tech stack ## Tech stack
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"all": true, "all": true,
"include": ["controllers/*.js", "utils/*.js"], "include": ["controllers/*.js", "utils/*.js", "service/*.js"],
"exclude": ["**/*.test.js"], "exclude": ["**/*.test.js"],
"reporter": ["html", "text", "lcov"], "reporter": ["html", "text", "lcov"],
"sourceMap": false, "sourceMap": false,
+5 -22
View File
@@ -12,32 +12,15 @@ const handleError = (error, serviceName, method, status = 500) => {
return error; return error;
}; };
const fetchMonitorCertificate = async (tls, monitor) => { const fetchMonitorCertificate = async (sslChecker, monitor) => {
return new Promise((resolve, reject) => { try {
const monitorUrl = new URL(monitor.url); const monitorUrl = new URL(monitor.url);
const hostname = monitorUrl.hostname; const hostname = monitorUrl.hostname;
try { const cert = await sslChecker(hostname);
let socket = tls.connect( return cert;
{
port: 443,
host: hostname,
servername: hostname, // this is required in case the server enabled SNI
},
() => {
try {
let x509Certificate = socket.getPeerX509Certificate();
resolve(x509Certificate);
} catch (error) { } catch (error) {
reject(error); throw error;
} finally {
socket.end();
} }
}
);
} catch (error) {
reject(error);
}
});
}; };
export { handleValidationError, handleError, fetchMonitorCertificate }; export { handleValidationError, handleError, fetchMonitorCertificate };
+2 -6
View File
@@ -59,9 +59,7 @@ const issueInvitation = async (req, res, next) => {
}); });
}); });
return res return res.status(200).json({ success: true, msg: "Invite sent", data: inviteToken });
.status(200)
.json({ success: true, msg: "Invite sent", data: inviteToken });
} catch (error) { } catch (error) {
next(handleError(error, SERVICE_NAME, "inviteController")); next(handleError(error, SERVICE_NAME, "inviteController"));
} }
@@ -77,9 +75,7 @@ const inviteVerifyController = async (req, res, next) => {
try { try {
const invite = await req.db.getInviteToken(req.body.token); const invite = await req.db.getInviteToken(req.body.token);
res res.status(200).json({ status: "success", msg: "Invite verified", data: invite });
.status(200)
.json({ status: "success", msg: "Invite verified", data: invite });
} catch (error) { } catch (error) {
next(handleError(error, SERVICE_NAME, "inviteVerifyController")); next(handleError(error, SERVICE_NAME, "inviteVerifyController"));
} }
@@ -55,9 +55,7 @@ const getMaintenanceWindowById = async (req, res, next) => {
return; return;
} }
try { try {
const maintenanceWindow = await req.db.getMaintenanceWindowById( const maintenanceWindow = await req.db.getMaintenanceWindowById(req.params.id);
req.params.id
);
return res.status(200).json({ return res.status(200).json({
success: true, success: true,
msg: successMessages.MAINTENANCE_WINDOW_GET_BY_ID, msg: successMessages.MAINTENANCE_WINDOW_GET_BY_ID,
@@ -97,9 +95,7 @@ const getMaintenanceWindowsByTeamId = async (req, res, next) => {
const getMaintenanceWindowsByMonitorId = async (req, res, next) => { const getMaintenanceWindowsByMonitorId = async (req, res, next) => {
try { try {
await getMaintenanceWindowsByMonitorIdParamValidation.validateAsync( await getMaintenanceWindowsByMonitorIdParamValidation.validateAsync(req.params);
req.params
);
} catch (error) { } catch (error) {
next(handleValidationError(error, SERVICE_NAME)); next(handleValidationError(error, SERVICE_NAME));
return; return;
+46 -9
View File
@@ -3,6 +3,7 @@ import {
getMonitorByIdQueryValidation, getMonitorByIdQueryValidation,
getMonitorsByTeamIdValidation, getMonitorsByTeamIdValidation,
createMonitorBodyValidation, createMonitorBodyValidation,
getMonitorURLByQueryValidation,
editMonitorBodyValidation, editMonitorBodyValidation,
getMonitorsAndSummaryByTeamIdParamValidation, getMonitorsAndSummaryByTeamIdParamValidation,
getMonitorsAndSummaryByTeamIdQueryValidation, getMonitorsAndSummaryByTeamIdQueryValidation,
@@ -12,18 +13,15 @@ import {
getMonitorStatsByIdQueryValidation, getMonitorStatsByIdQueryValidation,
getCertificateParamValidation, getCertificateParamValidation,
} from "../validation/joi.js"; } from "../validation/joi.js";
import * as tls from "tls"; import sslChecker from "ssl-checker";
const SERVICE_NAME = "monitorController";
import { errorMessages, successMessages } from "../utils/messages.js"; import { errorMessages, successMessages } from "../utils/messages.js";
import jwt from "jsonwebtoken"; import jwt from "jsonwebtoken";
import { getTokenFromHeaders } from "../utils/utils.js"; import { getTokenFromHeaders } from "../utils/utils.js";
import logger from "../utils/logger.js"; import logger from "../utils/logger.js";
import { import { handleError, handleValidationError } from "./controllerUtils.js";
handleError, import dns from "dns";
handleValidationError,
fetchMonitorCertificate, const SERVICE_NAME = "monitorController";
} from "./controllerUtils.js";
/** /**
* Returns all monitors * Returns all monitors
@@ -87,7 +85,7 @@ const getMonitorCertificate = async (req, res, next, fetchMonitorCertificate) =>
try { try {
const { monitorId } = req.params; const { monitorId } = req.params;
const monitor = await req.db.getMonitorById(monitorId); const monitor = await req.db.getMonitorById(monitorId);
const certificate = await fetchMonitorCertificate(tls, monitor); const certificate = await fetchMonitorCertificate(sslChecker, monitor);
if (certificate && certificate.validTo) { if (certificate && certificate.validTo) {
return res.status(200).json({ return res.status(200).json({
success: true, success: true,
@@ -261,6 +259,44 @@ const createMonitor = async (req, res, next) => {
} }
}; };
/**
* Checks if the endpoint can be resolved
* @async
* @param {Object} req - The Express request object.
* @property {Object} req.query - The query parameters of the request.
* @param {Object} res - The Express response object.
* @param {function} next - The next middleware function.
* @returns {Object} The response object with a success status, a message, and the resolution result.
* @throws {Error} If there is an error during the process, especially if there is a validation error (422).
*/
const checkEndpointResolution = async (req, res, next) => {
try {
await getMonitorURLByQueryValidation.validateAsync(req.query);
} catch (error) {
next(handleValidationError(error, SERVICE_NAME));
return;
}
try {
let { monitorURL } = req.query;
monitorURL = new URL(monitorURL);
await new Promise((resolve, reject) => {
dns.resolve(monitorURL.hostname, (error) => {
if (error) {
reject(error);
}
resolve();
});
});
return res.status(200).json({
success: true,
msg: `URL resolved successfully`,
});
} catch (error) {
next(handleError(error, SERVICE_NAME, "checkEndpointResolution"));
}
}
/** /**
* Deletes a monitor by its ID and also deletes associated checks, alerts, and notifications. * Deletes a monitor by its ID and also deletes associated checks, alerts, and notifications.
* @async * @async
@@ -481,6 +517,7 @@ export {
getMonitorsAndSummaryByTeamId, getMonitorsAndSummaryByTeamId,
getMonitorsByTeamId, getMonitorsByTeamId,
createMonitor, createMonitor,
checkEndpointResolution,
deleteMonitor, deleteMonitor,
deleteAllMonitors, deleteAllMonitors,
editMonitor, editMonitor,
+1 -3
View File
@@ -47,9 +47,7 @@ const addJob = async (req, res, next) => {
const obliterateQueue = async (req, res, next) => { const obliterateQueue = async (req, res, next) => {
try { try {
await req.jobQueue.obliterate(); await req.jobQueue.obliterate();
return res return res.status(200).json({ success: true, msg: successMessages.QUEUE_OBLITERATE });
.status(200)
.json({ success: true, msg: successMessages.QUEUE_OBLITERATE });
} catch (error) { } catch (error) {
next(handleError(error, SERVICE_NAME, "obliterateQueue")); next(handleError(error, SERVICE_NAME, "obliterateQueue"));
return; return;
+60
View File
@@ -0,0 +1,60 @@
import mongoose from "mongoose";
const cpuSchema = mongoose.Schema({
physical_core: { type: Number, default: 0 },
logical_core: { type: Number, default: 0 },
frequency: { type: Number, default: 0 },
temperature: { type: Number, default: 0 },
free_percent: { type: Number, default: 0 },
usage_percent: { type: Number, default: 0 },
});
const memorySchema = mongoose.Schema({
total_bytes: { type: Number, default: 0 },
available_bytes: { type: Number, default: 0 },
used_bytes: { type: Number, default: 0 },
usage_percent: { type: Number, default: 0 },
});
const discSchema = mongoose.Schema({
read_speed_bytes: { type: Number, default: 0 },
write_speed_bytes: { type: Number, default: 0 },
total_bytes: { type: Number, default: 0 },
free_bytes: { type: Number, default: 0 },
usage_percent: { type: Number, default: 0 },
});
const hostSchema = mongoose.Schema({
os: { type: String, default: "" },
platform: { type: String, default: "" },
kernel_version: { type: String, default: "" },
});
const HardwareCheckSchema = mongoose.Schema(
{
monitorId: {
type: mongoose.Schema.Types.ObjectId,
ref: "Monitor",
immutable: true,
},
cpu: {
type: cpuSchema,
default: () => ({}),
},
memory: {
type: memorySchema,
default: () => ({}),
},
disk: {
type: [discSchema],
default: () => [],
},
host: {
type: hostSchema,
default: () => ({}),
},
},
{ timestamps: true }
);
export default mongoose.model("HardwareCheck", HardwareCheckSchema);
Loaded 100 of 142 files, more files were not shown because too many files have changed in this diff. Show more