Merge branch 'develop' into 1067-fe-hardware-monitoring-create-hardware-monitor
This commit is contained in:
commit
aa6e881c1a
61 files changed
+2549
-1047
No files matched your search
Generated
+13
-13
@@ -8,12 +8,12 @@
|
|||||||
"name": "client",
|
"name": "client",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.11.4",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.11.5",
|
"@emotion/styled": "^11.13.0",
|
||||||
"@fontsource/roboto": "^5.0.13",
|
"@fontsource/roboto": "^5.0.13",
|
||||||
"@mui/icons-material": "^5.15.17",
|
"@mui/icons-material": "^5.15.17",
|
||||||
"@mui/lab": "^5.0.0-alpha.170",
|
"@mui/lab": "^5.0.0-alpha.170",
|
||||||
"@mui/material": "^5.15.16",
|
"@mui/material": "^5.16.7",
|
||||||
"@mui/x-charts": "^7.5.1",
|
"@mui/x-charts": "^7.5.1",
|
||||||
"@mui/x-data-grid": "7.22.2",
|
"@mui/x-data-grid": "7.22.2",
|
||||||
"@mui/x-date-pickers": "7.22.2",
|
"@mui/x-date-pickers": "7.22.2",
|
||||||
@@ -304,9 +304,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/runtime": {
|
"node_modules/@babel/runtime": {
|
||||||
"version": "7.25.9",
|
"version": "7.26.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.9.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.0.tgz",
|
||||||
"integrity": "sha512-4zpTHZ9Cm6L9L+uIqghQX8ZXg8HKFcjYO3qHoO8zTmRm6HQUJ8SSJ+KRvbMBZn0EGVlT4DRYeQ/6hjlyXBh+Kg==",
|
"integrity": "sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"regenerator-runtime": "^0.14.0"
|
"regenerator-runtime": "^0.14.0"
|
||||||
@@ -1356,12 +1356,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mui/types": {
|
"node_modules/@mui/types": {
|
||||||
"version": "7.2.15",
|
"version": "7.2.19",
|
||||||
"resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.15.tgz",
|
"resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.19.tgz",
|
||||||
"integrity": "sha512-nbo7yPhtKJkdf9kcVOF8JZHPZTmqXjJ/tI0bdWgHg5tp9AnIN4Y7f7wm9T+0SyGYJk76+GYZ8Q5XaTYAsUHN0Q==",
|
"integrity": "sha512-6XpZEM/Q3epK9RN8ENoXuygnqUQxE+siN/6rGRi2iwJPgBUR25mphYQ9ZI87plGh58YoZ5pp40bFvKYOCDJ3tA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@types/react": "^17.0.0 || ^18.0.0"
|
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@types/react": {
|
"@types/react": {
|
||||||
@@ -2350,9 +2350,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/prop-types": {
|
"node_modules/@types/prop-types": {
|
||||||
"version": "15.7.12",
|
"version": "15.7.13",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz",
|
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.13.tgz",
|
||||||
"integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==",
|
"integrity": "sha512-hCZTSvwbzWGvhqxp/RqVqwU999pBf2vp7hzIjiYOsl8wqOmUxkQ6ddw1cV3l8811+kdUFus/q4d1Y3E3SyEifA==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/react": {
|
"node_modules/@types/react": {
|
||||||
|
|||||||
+3
-3
@@ -11,12 +11,12 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.11.4",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.11.5",
|
"@emotion/styled": "^11.13.0",
|
||||||
"@fontsource/roboto": "^5.0.13",
|
"@fontsource/roboto": "^5.0.13",
|
||||||
"@mui/icons-material": "^5.15.17",
|
"@mui/icons-material": "^5.15.17",
|
||||||
"@mui/lab": "^5.0.0-alpha.170",
|
"@mui/lab": "^5.0.0-alpha.170",
|
||||||
"@mui/material": "^5.15.16",
|
"@mui/material": "^5.16.7",
|
||||||
"@mui/x-charts": "^7.5.1",
|
"@mui/x-charts": "^7.5.1",
|
||||||
"@mui/x-data-grid": "7.22.2",
|
"@mui/x-data-grid": "7.22.2",
|
||||||
"@mui/x-date-pickers": "7.22.2",
|
"@mui/x-date-pickers": "7.22.2",
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
.card {
|
|
||||||
padding: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.read-the-docs {
|
|
||||||
color: #888;
|
|
||||||
}
|
|
||||||
+39
-23
@@ -1,14 +1,12 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { Routes, Route } from "react-router-dom";
|
import { Routes, Route, Navigate } from "react-router-dom";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
// import "./App.css";
|
|
||||||
import "react-toastify/dist/ReactToastify.css";
|
import "react-toastify/dist/ReactToastify.css";
|
||||||
import { ToastContainer } from "react-toastify";
|
import { ToastContainer } from "react-toastify";
|
||||||
import NotFound from "./Pages/NotFound";
|
import NotFound from "./Pages/NotFound";
|
||||||
import Login from "./Pages/Auth/Login";
|
import Login from "./Pages/Auth/Login";
|
||||||
import Register from "./Pages/Auth/Register/Register";
|
import Register from "./Pages/Auth/Register/Register";
|
||||||
import HomeLayout from "./Layouts/HomeLayout";
|
|
||||||
import Account from "./Pages/Account";
|
import Account from "./Pages/Account";
|
||||||
import Monitors from "./Pages/Monitors/Home";
|
import Monitors from "./Pages/Monitors/Home";
|
||||||
import CreateMonitor from "./Pages/Monitors/CreateMonitor";
|
import CreateMonitor from "./Pages/Monitors/CreateMonitor";
|
||||||
@@ -30,15 +28,17 @@ import CreatePageSpeed from "./Pages/PageSpeed/CreatePageSpeed";
|
|||||||
import CreateNewMaintenanceWindow from "./Pages/Maintenance/CreateMaintenance";
|
import CreateNewMaintenanceWindow from "./Pages/Maintenance/CreateMaintenance";
|
||||||
import PageSpeedDetails from "./Pages/PageSpeed/Details";
|
import PageSpeedDetails from "./Pages/PageSpeed/Details";
|
||||||
import PageSpeedConfigure from "./Pages/PageSpeed/Configure";
|
import PageSpeedConfigure from "./Pages/PageSpeed/Configure";
|
||||||
import withAdminCheck from "./HOC/withAdminCheck";
|
import HomeLayout from "./Components/Layouts/HomeLayout";
|
||||||
import withAdminProp from "./HOC/withAdminProp";
|
import withAdminCheck from "./Components/HOC/withAdminCheck";
|
||||||
|
import withAdminProp from "./Components/HOC/withAdminProp";
|
||||||
import { ThemeProvider } from "@emotion/react";
|
import { ThemeProvider } from "@emotion/react";
|
||||||
import lightTheme from "./Utils/Theme/lightTheme";
|
import lightTheme from "./Utils/Theme/lightTheme";
|
||||||
import darkTheme from "./Utils/Theme/darkTheme";
|
import darkTheme from "./Utils/Theme/darkTheme";
|
||||||
import { CssBaseline } from "@mui/material";
|
import { CssBaseline, GlobalStyles } from "@mui/material";
|
||||||
import { getAppSettings } from "./Features/Settings/settingsSlice";
|
import { getAppSettings } from "./Features/Settings/settingsSlice";
|
||||||
import { logger } from "./Utils/Logger"; // Import the logger
|
import { logger } from "./Utils/Logger"; // Import the logger
|
||||||
import { networkService } from "./main";
|
import { networkService } from "./main";
|
||||||
|
import { Infrastructure } from "./Pages/Infrastructure";
|
||||||
function App() {
|
function App() {
|
||||||
const AdminCheckedRegister = withAdminCheck(Register);
|
const AdminCheckedRegister = withAdminCheck(Register);
|
||||||
const MonitorsWithAdminProp = withAdminProp(Monitors);
|
const MonitorsWithAdminProp = withAdminProp(Monitors);
|
||||||
@@ -67,8 +67,19 @@ function App() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
/* Extract Themeprovider, baseline and global styles to Styles */
|
||||||
<ThemeProvider theme={mode === "light" ? lightTheme : darkTheme}>
|
<ThemeProvider theme={mode === "light" ? lightTheme : darkTheme}>
|
||||||
<CssBaseline />
|
<CssBaseline />
|
||||||
|
<GlobalStyles
|
||||||
|
styles={({ palette }) => {
|
||||||
|
return {
|
||||||
|
body: {
|
||||||
|
backgroundImage: `radial-gradient(circle, ${palette.gradient.color1}, ${palette.gradient.color2}, ${palette.gradient.color3}, ${palette.gradient.color4}, ${palette.gradient.color5})`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/* Extract Routes to Routes */}
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
@@ -78,7 +89,7 @@ function App() {
|
|||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path="/"
|
path="/"
|
||||||
element={<ProtectedRoute Component={MonitorsWithAdminProp} />}
|
element={<Navigate to="/monitors" />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/monitors"
|
path="/monitors"
|
||||||
@@ -96,6 +107,27 @@ function App() {
|
|||||||
path="/monitors/configure/:monitorId/"
|
path="/monitors/configure/:monitorId/"
|
||||||
element={<ProtectedRoute Component={Configure} />}
|
element={<ProtectedRoute Component={Configure} />}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path="pagespeed"
|
||||||
|
element={<ProtectedRoute Component={PageSpeedWithAdminProp} />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="pagespeed/create"
|
||||||
|
element={<ProtectedRoute Component={CreatePageSpeed} />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="pagespeed/:monitorId"
|
||||||
|
element={<ProtectedRoute Component={PageSpeedDetailsWithAdminProp} />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="pagespeed/configure/:monitorId"
|
||||||
|
element={<ProtectedRoute Component={PageSpeedConfigure} />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="infrastructure"
|
||||||
|
element={<ProtectedRoute Component={Infrastructure} />}
|
||||||
|
/>
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
path="incidents/:monitorId?"
|
path="incidents/:monitorId?"
|
||||||
element={<ProtectedRoute Component={Incidents} />}
|
element={<ProtectedRoute Component={Incidents} />}
|
||||||
@@ -152,22 +184,6 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
|
||||||
path="pagespeed"
|
|
||||||
element={<ProtectedRoute Component={PageSpeedWithAdminProp} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="pagespeed/create"
|
|
||||||
element={<ProtectedRoute Component={CreatePageSpeed} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="pagespeed/:monitorId"
|
|
||||||
element={<ProtectedRoute Component={PageSpeedDetailsWithAdminProp} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="pagespeed/configure/:monitorId"
|
|
||||||
element={<ProtectedRoute Component={PageSpeedConfigure} />}
|
|
||||||
/>
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ const icons = {
|
|||||||
|
|
||||||
const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => {
|
const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
/* TODO
|
||||||
|
This needs fixing. text bg and border not necessarilly exist. Probably text becomes contrastText. border becomes contrastText. bg becomes dark.
|
||||||
|
Check possible variants, see implementation in light and dark theme, and adjust */
|
||||||
const { text, bg, border } = theme.palette[variant];
|
const { text, bg, border } = theme.palette[variant];
|
||||||
const icon = icons[variant];
|
const icon = icons[variant];
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
|
/* TODO add prop validation and jsdocs */
|
||||||
const BarChart = ({ checks = [] }) => {
|
const BarChart = ({ checks = [] }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [animate, setAnimate] = useState(false);
|
const [animate, setAnimate] = useState(false);
|
||||||
@@ -65,7 +66,9 @@ const BarChart = ({ checks = [] }) => {
|
|||||||
width={theme.spacing(4)}
|
width={theme.spacing(4)}
|
||||||
height={theme.spacing(4)}
|
height={theme.spacing(4)}
|
||||||
backgroundColor={
|
backgroundColor={
|
||||||
check.status ? theme.palette.success.main : theme.palette.error.text
|
check.status
|
||||||
|
? theme.palette.success.main
|
||||||
|
: theme.palette.error.contrastText
|
||||||
}
|
}
|
||||||
sx={{ borderRadius: "50%" }}
|
sx={{ borderRadius: "50%" }}
|
||||||
/>
|
/>
|
||||||
@@ -111,7 +114,7 @@ const BarChart = ({ checks = [] }) => {
|
|||||||
],
|
],
|
||||||
sx: {
|
sx: {
|
||||||
"& .MuiTooltip-tooltip": {
|
"& .MuiTooltip-tooltip": {
|
||||||
backgroundColor: theme.palette.background.main,
|
backgroundColor: theme.palette.secondary.main,
|
||||||
border: 1,
|
border: 1,
|
||||||
borderColor: theme.palette.border.dark,
|
borderColor: theme.palette.border.dark,
|
||||||
borderRadius: theme.shape.borderRadius,
|
borderRadius: theme.shape.borderRadius,
|
||||||
@@ -138,7 +141,9 @@ const BarChart = ({ checks = [] }) => {
|
|||||||
width="9px"
|
width="9px"
|
||||||
height="100%"
|
height="100%"
|
||||||
backgroundColor={
|
backgroundColor={
|
||||||
check.status ? theme.palette.success.bg : theme.palette.error.bg
|
check.status
|
||||||
|
? theme.palette.success.contrastText
|
||||||
|
: theme.palette.error.dark
|
||||||
}
|
}
|
||||||
sx={{
|
sx={{
|
||||||
borderRadius: theme.spacing(1.5),
|
borderRadius: theme.spacing(1.5),
|
||||||
@@ -153,7 +158,9 @@ const BarChart = ({ checks = [] }) => {
|
|||||||
width="100%"
|
width="100%"
|
||||||
height={`${animate ? check.responseTime : 0}%`}
|
height={`${animate ? check.responseTime : 0}%`}
|
||||||
backgroundColor={
|
backgroundColor={
|
||||||
check.status ? theme.palette.success.main : theme.palette.error.text
|
check.status
|
||||||
|
? theme.palette.success.main
|
||||||
|
: theme.palette.error.contrastText
|
||||||
}
|
}
|
||||||
sx={{
|
sx={{
|
||||||
borderRadius: theme.spacing(1.5),
|
borderRadius: theme.spacing(1.5),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const Check = ({ text, noHighlightText, variant = "info", outlined = false }) =>
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const colors = {
|
const colors = {
|
||||||
success: theme.palette.success.main,
|
success: theme.palette.success.main,
|
||||||
error: theme.palette.error.text,
|
error: theme.palette.error.contrastText,
|
||||||
info: theme.palette.info.border,
|
info: theme.palette.info.border,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import React, { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { logger } from "../Utils/Logger";
|
import { logger } from "../../Utils/Logger";
|
||||||
import { networkService } from "../main";
|
import { networkService } from "../../main";
|
||||||
|
|
||||||
const withAdminCheck = (WrappedComponent) => {
|
const withAdminCheck = (WrappedComponent) => {
|
||||||
const WithAdminCheck = (props) => {
|
const WithAdminCheck = (props) => {
|
||||||
File renamed without changes.
@@ -0,0 +1,29 @@
|
|||||||
|
import { Typography } from "@mui/material";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A heading component that renders text with a specific heading level.
|
||||||
|
*
|
||||||
|
* @param {Object} props - The properties passed to the Heading component.
|
||||||
|
* @param {('h1'|'h2'|'h3')} props.component - The heading level for the component.
|
||||||
|
* @param {string} props.children - The content to display inside the heading.
|
||||||
|
* @returns {JSX.Element} The Typography component with specified heading properties.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Heading({ component, children }) {
|
||||||
|
return (
|
||||||
|
<Typography
|
||||||
|
component={component}
|
||||||
|
variant="h2"
|
||||||
|
fontWeight={600}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Heading.propTypes = {
|
||||||
|
component: PropTypes.oneOf(["h1", "h2", "h3"]).isRequired,
|
||||||
|
children: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
export { Heading };
|
||||||
@@ -68,7 +68,7 @@ const Field = forwardRef(
|
|||||||
borderColor: theme.palette.border.dark,
|
borderColor: theme.palette.border.dark,
|
||||||
},
|
},
|
||||||
"&:has(.input-error) .MuiOutlinedInput-root fieldset": {
|
"&:has(.input-error) .MuiOutlinedInput-root fieldset": {
|
||||||
borderColor: theme.palette.error.text,
|
borderColor: theme.palette.error.contrastText,
|
||||||
},
|
},
|
||||||
display: hidden ? "none" : "",
|
display: hidden ? "none" : "",
|
||||||
}}
|
}}
|
||||||
@@ -84,7 +84,7 @@ const Field = forwardRef(
|
|||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
ml={theme.spacing(1)}
|
ml={theme.spacing(1)}
|
||||||
color={theme.palette.error.text}
|
color={theme.palette.error.contrastText}
|
||||||
>
|
>
|
||||||
*
|
*
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -191,7 +191,7 @@ const Field = forwardRef(
|
|||||||
component="span"
|
component="span"
|
||||||
className="input-error"
|
className="input-error"
|
||||||
hidden={className? true: false}
|
hidden={className? true: false}
|
||||||
color={theme.palette.error.text}
|
color={theme.palette.error.contrastText}
|
||||||
mt={theme.spacing(2)}
|
mt={theme.spacing(2)}
|
||||||
sx={{
|
sx={{
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const Radio = (props) => {
|
|||||||
color: "transparent",
|
color: "transparent",
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 16,
|
||||||
boxShadow: "inset 0 0 0 1px #656a74",
|
boxShadow: `inset 0 0 0 1px ${theme.palette.secondary.main}`,
|
||||||
mt: theme.spacing(0.5),
|
mt: theme.spacing(0.5),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ const Search = ({
|
|||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
className="input-error"
|
className="input-error"
|
||||||
color={theme.palette.error.text}
|
color={theme.palette.error.contrastText}
|
||||||
mt={theme.spacing(2)}
|
mt={theme.spacing(2)}
|
||||||
sx={{
|
sx={{
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
.label {
|
.label {
|
||||||
border: 1px solid #000;
|
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const BaseLabel = ({ label, styles, children }) => {
|
|||||||
className="label"
|
className="label"
|
||||||
sx={{
|
sx={{
|
||||||
borderRadius: borderRadius,
|
borderRadius: borderRadius,
|
||||||
borderColor: theme.palette.text.tertiary,
|
border: `1px solid ${theme.palette.text.tertiary}`,
|
||||||
color: theme.palette.text.tertiary,
|
color: theme.palette.text.tertiary,
|
||||||
padding: padding,
|
padding: padding,
|
||||||
...styles,
|
...styles,
|
||||||
@@ -127,22 +127,22 @@ const StatusLabel = ({ status, text, customStyles }) => {
|
|||||||
const colors = {
|
const colors = {
|
||||||
up: {
|
up: {
|
||||||
dotColor: theme.palette.success.main,
|
dotColor: theme.palette.success.main,
|
||||||
bgColor: theme.palette.success.bg,
|
bgColor: theme.palette.success./* dark */ contrastText,
|
||||||
borderColor: theme.palette.success.light,
|
borderColor: theme.palette.success.main /* light */,
|
||||||
},
|
},
|
||||||
down: {
|
down: {
|
||||||
dotColor: theme.palette.error.text,
|
dotColor: theme.palette.error.contrastText,
|
||||||
bgColor: theme.palette.error.bg,
|
bgColor: theme.palette.error.dark,
|
||||||
borderColor: theme.palette.error.light,
|
borderColor: theme.palette.error.light,
|
||||||
},
|
},
|
||||||
paused: {
|
paused: {
|
||||||
dotColor: theme.palette.warning.main,
|
dotColor: theme.palette.warning.main,
|
||||||
bgColor: theme.palette.warning.bg,
|
bgColor: theme.palette.warning.dark,
|
||||||
borderColor: theme.palette.warning.light,
|
borderColor: theme.palette.warning.light,
|
||||||
},
|
},
|
||||||
pending: {
|
pending: {
|
||||||
dotColor: theme.palette.warning.main,
|
dotColor: theme.palette.warning.main,
|
||||||
bgColor: theme.palette.warning.bg,
|
bgColor: theme.palette.warning.dark,
|
||||||
borderColor: theme.palette.warning.light,
|
borderColor: theme.palette.warning.light,
|
||||||
},
|
},
|
||||||
"cannot resolve": {
|
"cannot resolve": {
|
||||||
|
|||||||
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import Sidebar from "../../Components/Sidebar";
|
import Sidebar from "../../Sidebar";
|
||||||
import { Outlet } from "react-router";
|
import { Outlet } from "react-router";
|
||||||
import { Stack } from "@mui/material";
|
import { Stack } from "@mui/material";
|
||||||
|
|
||||||
@@ -34,11 +34,11 @@ const ProgressUpload = ({ icon, label, size, progress = 0, onClick, error }) =>
|
|||||||
backgroundColor: theme.palette.background.fill,
|
backgroundColor: theme.palette.background.fill,
|
||||||
"&:has(.input-error)": {
|
"&:has(.input-error)": {
|
||||||
borderColor: theme.palette.error.main,
|
borderColor: theme.palette.error.main,
|
||||||
backgroundColor: theme.palette.error.bg,
|
backgroundColor: theme.palette.error.dark,
|
||||||
py: theme.spacing(4),
|
py: theme.spacing(4),
|
||||||
px: theme.spacing(8),
|
px: theme.spacing(8),
|
||||||
"& > .MuiStack-root > svg": {
|
"& > .MuiStack-root > svg": {
|
||||||
fill: theme.palette.error.text,
|
fill: theme.palette.error.contrastText,
|
||||||
width: "20px",
|
width: "20px",
|
||||||
height: "20px",
|
height: "20px",
|
||||||
},
|
},
|
||||||
@@ -85,7 +85,7 @@ const ProgressUpload = ({ icon, label, size, progress = 0, onClick, error }) =>
|
|||||||
<Typography
|
<Typography
|
||||||
component="p"
|
component="p"
|
||||||
className="input-error"
|
className="input-error"
|
||||||
color={theme.palette.error.text}
|
color={theme.palette.error.contrastText}
|
||||||
>
|
>
|
||||||
{error}
|
{error}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { useLocation, useNavigate } from "react-router";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { clearAuthState } from "../../Features/Auth/authSlice";
|
import { clearAuthState } from "../../Features/Auth/authSlice";
|
||||||
import { setMode, toggleSidebar } from "../../Features/UI/uiSlice";
|
import { toggleSidebar } from "../../Features/UI/uiSlice";
|
||||||
import { clearUptimeMonitorState } from "../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
import { clearUptimeMonitorState } from "../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
||||||
import Avatar from "../Avatar";
|
import Avatar from "../Avatar";
|
||||||
import LockSvg from "../../assets/icons/lock.svg?react";
|
import LockSvg from "../../assets/icons/lock.svg?react";
|
||||||
@@ -29,7 +29,6 @@ import LogoutSvg from "../../assets/icons/logout.svg?react";
|
|||||||
import Support from "../../assets/icons/support.svg?react";
|
import Support from "../../assets/icons/support.svg?react";
|
||||||
import Dashboard from "../../assets/icons/dashboard.svg?react";
|
import Dashboard from "../../assets/icons/dashboard.svg?react";
|
||||||
import Account from "../../assets/icons/user-edit.svg?react";
|
import Account from "../../assets/icons/user-edit.svg?react";
|
||||||
import StatusPages from "../../assets/icons/status-pages.svg?react";
|
|
||||||
import Maintenance from "../../assets/icons/maintenance.svg?react";
|
import Maintenance from "../../assets/icons/maintenance.svg?react";
|
||||||
import Monitors from "../../assets/icons/monitors.svg?react";
|
import Monitors from "../../assets/icons/monitors.svg?react";
|
||||||
import Incidents from "../../assets/icons/incidents.svg?react";
|
import Incidents from "../../assets/icons/incidents.svg?react";
|
||||||
@@ -54,6 +53,7 @@ const menu = [
|
|||||||
nested: [
|
nested: [
|
||||||
{ name: "Monitors", path: "monitors", icon: <Monitors /> },
|
{ name: "Monitors", path: "monitors", icon: <Monitors /> },
|
||||||
{ name: "Pagespeed", path: "pagespeed", icon: <PageSpeed /> },
|
{ name: "Pagespeed", path: "pagespeed", icon: <PageSpeed /> },
|
||||||
|
{ name: "Infrastructure", path: "infrastructure", icon: <Integrations /> },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ name: "Incidents", path: "incidents", icon: <Incidents /> },
|
{ name: "Incidents", path: "incidents", icon: <Incidents /> },
|
||||||
@@ -113,7 +113,6 @@ function Sidebar() {
|
|||||||
const [popup, setPopup] = useState();
|
const [popup, setPopup] = useState();
|
||||||
const { user } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
// Remove demo password if demo
|
|
||||||
const accountMenuItem = menu.find((item) => item.name === "Account");
|
const accountMenuItem = menu.find((item) => item.name === "Account");
|
||||||
if (user.role?.includes("demo") && accountMenuItem) {
|
if (user.role?.includes("demo") && accountMenuItem) {
|
||||||
accountMenuItem.nested = accountMenuItem.nested.filter((item) => {
|
accountMenuItem.nested = accountMenuItem.nested.filter((item) => {
|
||||||
@@ -148,7 +147,9 @@ function Sidebar() {
|
|||||||
if (matchedKey) {
|
if (matchedKey) {
|
||||||
setOpen((prev) => ({ ...prev, [PATH_MAP[matchedKey]]: true }));
|
setOpen((prev) => ({ ...prev, [PATH_MAP[matchedKey]]: true }));
|
||||||
}
|
}
|
||||||
}, []);
|
}, [location]);
|
||||||
|
|
||||||
|
/* TODO refactor this, there are a some ternaries and comments in the return */
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
@@ -181,7 +182,13 @@ function Sidebar() {
|
|||||||
direction="row"
|
direction="row"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
gap={theme.spacing(4)}
|
gap={theme.spacing(4)}
|
||||||
onClick={() => window.open("https://github.com/bluewave-labs/bluewave-uptime", "_blank", "noreferrer")}
|
onClick={() =>
|
||||||
|
window.open(
|
||||||
|
"https://github.com/bluewave-labs/bluewave-uptime",
|
||||||
|
"_blank",
|
||||||
|
"noreferrer"
|
||||||
|
)
|
||||||
|
}
|
||||||
sx={{ cursor: "pointer" }}
|
sx={{ cursor: "pointer" }}
|
||||||
>
|
>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -297,6 +304,7 @@ function Sidebar() {
|
|||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
) : collapsed ? (
|
) : collapsed ? (
|
||||||
|
/* TODO Do we ever get here? */
|
||||||
<React.Fragment key={item.name}>
|
<React.Fragment key={item.name}>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
placement="right"
|
placement="right"
|
||||||
@@ -616,22 +624,6 @@ function Sidebar() {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
{collapsed && <Divider />}
|
{collapsed && <Divider />}
|
||||||
{/* <MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
dispatch(setMode("light"));
|
|
||||||
closePopup();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Light
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
dispatch(setMode("dark"));
|
|
||||||
closePopup();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Dark
|
|
||||||
</MenuItem> */}
|
|
||||||
<Divider />
|
<Divider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={logout}
|
onClick={logout}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export const checkEndpointResolution = createAsyncThunk(
|
|||||||
const res = await networkService.checkEndpointResolution({
|
const res = await networkService.checkEndpointResolution({
|
||||||
authToken: authToken,
|
authToken: authToken,
|
||||||
monitorURL: monitorURL,
|
monitorURL: monitorURL,
|
||||||
})
|
});
|
||||||
return res.data;
|
return res.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) {
|
if (error.response && error.response.data) {
|
||||||
@@ -53,7 +53,7 @@ export const checkEndpointResolution = createAsyncThunk(
|
|||||||
return thunkApi.rejectWithValue(payload);
|
return thunkApi.rejectWithValue(payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
|
|
||||||
export const getUptimeMonitorById = createAsyncThunk(
|
export const getUptimeMonitorById = createAsyncThunk(
|
||||||
"monitors/getMonitorById",
|
"monitors/getMonitorById",
|
||||||
@@ -86,7 +86,7 @@ export const getUptimeMonitorsByTeamId = createAsyncThunk(
|
|||||||
const res = await networkService.getMonitorsAndSummaryByTeamId({
|
const res = await networkService.getMonitorsAndSummaryByTeamId({
|
||||||
authToken: token,
|
authToken: token,
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
types: ["http", "ping"],
|
types: ["http", "ping", "docker"],
|
||||||
});
|
});
|
||||||
return res.data;
|
return res.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { Box, Button } from "@mui/material";
|
||||||
|
import { Heading } from "../../Components/Heading";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Infrastructure monitoring page. This is a work in progress
|
||||||
|
*
|
||||||
|
* @param - Define params.
|
||||||
|
* @returns {JSX.Element} The infrastructure monitoring page.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Infrastructure() {
|
||||||
|
return (
|
||||||
|
<Box component="main">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() => {
|
||||||
|
// navigate("/monitors/create");
|
||||||
|
}}
|
||||||
|
sx={{ fontWeight: 500 }}
|
||||||
|
>
|
||||||
|
Create monitor
|
||||||
|
</Button>
|
||||||
|
<Heading component="h2">Infrastructure monitors</Heading>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Infrastructure };
|
||||||
@@ -114,7 +114,7 @@ const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
|
|||||||
"& ul": { p: theme.spacing(2.5) },
|
"& ul": { p: theme.spacing(2.5) },
|
||||||
"& li": { m: 0 },
|
"& li": { m: 0 },
|
||||||
"& li:last-of-type": {
|
"& li:last-of-type": {
|
||||||
color: theme.palette.error.text,
|
color: theme.palette.error.contrastText,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,10 +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 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 { 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,21 +19,40 @@ import { getUptimeMonitorById } from "../../../Features/UptimeMonitors/uptimeMon
|
|||||||
import "./index.css";
|
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, isLoading } = 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();
|
||||||
|
|
||||||
const idMap = {
|
const idMap = {
|
||||||
"monitor-url": "url",
|
"monitor-url": "url",
|
||||||
"monitor-name": "name",
|
"monitor-name": "name",
|
||||||
"monitor-checks-http": "type",
|
"monitor-checks-http": "type",
|
||||||
"monitor-checks-ping": "type",
|
"monitor-checks-ping": "type",
|
||||||
|
"monitor-checks-docker": "type",
|
||||||
"notify-email-default": "notification-email",
|
"notify-email-default": "notification-email",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const monitorTypeMaps = {
|
||||||
|
http: {
|
||||||
|
label: "URL to monitor",
|
||||||
|
placeholder: "google.com",
|
||||||
|
namePlaceholder: "Google",
|
||||||
|
},
|
||||||
|
ping: {
|
||||||
|
label: "IP address to monitor",
|
||||||
|
placeholder: "1.1.1.1",
|
||||||
|
namePlaceholder: "Google",
|
||||||
|
},
|
||||||
|
docker: {
|
||||||
|
label: "Container ID",
|
||||||
|
placeholder: "abc123",
|
||||||
|
namePlaceholder: "My Container",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const { monitorId } = useParams();
|
const { monitorId } = useParams();
|
||||||
const [monitor, setMonitor] = useState({
|
const [monitor, setMonitor] = useState({
|
||||||
url: "",
|
url: "",
|
||||||
@@ -112,7 +131,6 @@ const CreateMonitor = () => {
|
|||||||
{ [name]: value },
|
{ [name]: value },
|
||||||
{ abortEarly: false }
|
{ abortEarly: false }
|
||||||
);
|
);
|
||||||
console.log(error);
|
|
||||||
setErrors((prev) => {
|
setErrors((prev) => {
|
||||||
const updatedErrors = { ...prev };
|
const updatedErrors = { ...prev };
|
||||||
if (error) updatedErrors[name] = error.details[0].message;
|
if (error) updatedErrors[name] = error.details[0].message;
|
||||||
@@ -148,16 +166,18 @@ const CreateMonitor = () => {
|
|||||||
setErrors(newErrors);
|
setErrors(newErrors);
|
||||||
createToast({ body: "Error validation data." });
|
createToast({ body: "Error validation data." });
|
||||||
} else {
|
} else {
|
||||||
if (monitor.type === "http") {
|
if (monitor.type === "http") {
|
||||||
const checkEndpointAction = await dispatch(
|
const checkEndpointAction = await dispatch(
|
||||||
checkEndpointResolution({ authToken, monitorURL: form.url })
|
checkEndpointResolution({ authToken, monitorURL: form.url })
|
||||||
)
|
);
|
||||||
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||||
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
|
createToast({
|
||||||
setErrors({ url: "The entered URL is not reachable." });
|
body: "The endpoint you entered doesn't resolve. Check the URL again.",
|
||||||
return;
|
});
|
||||||
}
|
setErrors({ url: "The entered URL is not reachable." });
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
form = {
|
form = {
|
||||||
...form,
|
...form,
|
||||||
@@ -232,9 +252,9 @@ const CreateMonitor = () => {
|
|||||||
<Field
|
<Field
|
||||||
type={monitor.type === "http" ? "url" : "text"}
|
type={monitor.type === "http" ? "url" : "text"}
|
||||||
id="monitor-url"
|
id="monitor-url"
|
||||||
label="URL to monitor"
|
label={monitorTypeMaps[monitor.type].label || "URL to monitor"}
|
||||||
https={https}
|
https={https}
|
||||||
placeholder="google.com"
|
placeholder={monitorTypeMaps[monitor.type].placeholder || ""}
|
||||||
value={monitor.url}
|
value={monitor.url}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
error={errors["url"]}
|
error={errors["url"]}
|
||||||
@@ -244,7 +264,7 @@ const CreateMonitor = () => {
|
|||||||
id="monitor-name"
|
id="monitor-name"
|
||||||
label="Display name"
|
label="Display name"
|
||||||
isOptional={true}
|
isOptional={true}
|
||||||
placeholder="Google"
|
placeholder={monitorTypeMaps[monitor.type].namePlaceholder || ""}
|
||||||
value={monitor.name}
|
value={monitor.name}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
error={errors["name"]}
|
error={errors["name"]}
|
||||||
@@ -299,12 +319,21 @@ const CreateMonitor = () => {
|
|||||||
checked={monitor.type === "ping"}
|
checked={monitor.type === "ping"}
|
||||||
onChange={(event) => handleChange(event)}
|
onChange={(event) => handleChange(event)}
|
||||||
/>
|
/>
|
||||||
|
<Radio
|
||||||
|
id="monitor-checks-docker"
|
||||||
|
title="Docker container monitoring"
|
||||||
|
desc="Check whether your container is running or not."
|
||||||
|
size="small"
|
||||||
|
value="docker"
|
||||||
|
checked={monitor.type === "docker"}
|
||||||
|
onChange={(event) => handleChange(event)}
|
||||||
|
/>
|
||||||
{errors["type"] ? (
|
{errors["type"] ? (
|
||||||
<Box className="error-container">
|
<Box className="error-container">
|
||||||
<Typography
|
<Typography
|
||||||
component="p"
|
component="p"
|
||||||
className="input-error"
|
className="input-error"
|
||||||
color={theme.palette.error.text}
|
color={theme.palette.error.contrastText}
|
||||||
>
|
>
|
||||||
{errors["type"]}
|
{errors["type"]}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -387,14 +416,14 @@ const CreateMonitor = () => {
|
|||||||
justifyContent="flex-end"
|
justifyContent="flex-end"
|
||||||
>
|
>
|
||||||
<LoadingButton
|
<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}
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
Create monitor
|
Create monitor
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ const UpBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
? { main: theme.palette.success.main, light: theme.palette.success.light }
|
? { main: theme.palette.success.main, light: theme.palette.success.light }
|
||||||
: uptime > 50
|
: uptime > 50
|
||||||
? { main: theme.palette.warning.main, light: theme.palette.warning.light }
|
? { main: theme.palette.warning.main, light: theme.palette.warning.light }
|
||||||
: { main: theme.palette.error.text, light: theme.palette.error.light };
|
: { main: theme.palette.error.contrastText, light: theme.palette.error.light };
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO - REMOVE THIS LATER
|
// TODO - REMOVE THIS LATER
|
||||||
@@ -201,10 +201,10 @@ const DownBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
key={`cell-${entry.time}`}
|
key={`cell-${entry.time}`}
|
||||||
fill={
|
fill={
|
||||||
hoveredBarIndex === index
|
hoveredBarIndex === index
|
||||||
? theme.palette.error.text
|
? theme.palette.error.contrastText
|
||||||
: chartHovered
|
: chartHovered
|
||||||
? theme.palette.error.light
|
? theme.palette.error.light
|
||||||
: theme.palette.error.text
|
: theme.palette.error.contrastText
|
||||||
}
|
}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
setHoveredBarIndex(index);
|
setHoveredBarIndex(index);
|
||||||
@@ -246,24 +246,24 @@ const ResponseGaugeChart = ({ data }) => {
|
|||||||
? {
|
? {
|
||||||
category: "Excellent",
|
category: "Excellent",
|
||||||
main: theme.palette.success.main,
|
main: theme.palette.success.main,
|
||||||
bg: theme.palette.success.bg,
|
bg: theme.palette.success.dark,
|
||||||
}
|
}
|
||||||
: responseTime <= 500
|
: responseTime <= 500
|
||||||
? {
|
? {
|
||||||
category: "Fair",
|
category: "Fair",
|
||||||
main: theme.palette.success.main,
|
main: theme.palette.success.main,
|
||||||
bg: theme.palette.success.bg,
|
bg: theme.palette.success.dark,
|
||||||
}
|
}
|
||||||
: responseTime <= 600
|
: responseTime <= 600
|
||||||
? {
|
? {
|
||||||
category: "Acceptable",
|
category: "Acceptable",
|
||||||
main: theme.palette.warning.main,
|
main: theme.palette.warning.main,
|
||||||
bg: theme.palette.warning.bg,
|
bg: theme.palette.warning.dark,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
category: "Poor",
|
category: "Poor",
|
||||||
main: theme.palette.error.text,
|
main: theme.palette.error.contrastText,
|
||||||
bg: theme.palette.error.bg,
|
bg: theme.palette.error.dark,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Stack } from "@mui/material";
|
||||||
import Search from "../../../../Components/Inputs/Search";
|
import Search from "../../../../Components/Inputs/Search";
|
||||||
import MemoizedMonitorTable from "../MonitorTable";
|
import MemoizedMonitorTable from "../MonitorTable";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import useDebounce from "../../../../Utils/debounce";
|
import useDebounce from "../../../../Utils/debounce";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
import { Heading } from "../../../../Components/Heading";
|
||||||
|
|
||||||
const CurrentMonitoring = ({ totalMonitors, monitors, isAdmin }) => {
|
const CurrentMonitoring = ({ totalMonitors, monitors, isAdmin }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -18,26 +19,15 @@ const CurrentMonitoring = ({ totalMonitors, monitors, isAdmin }) => {
|
|||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
flex={1}
|
flex={1}
|
||||||
px={theme.spacing(10)}
|
|
||||||
py={theme.spacing(8)}
|
py={theme.spacing(8)}
|
||||||
border={1}
|
|
||||||
borderColor={theme.palette.border.light}
|
|
||||||
borderRadius={theme.shape.borderRadius}
|
|
||||||
backgroundColor={theme.palette.background.main}
|
|
||||||
>
|
>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
mb={theme.spacing(8)}
|
mb={theme.spacing(8)}
|
||||||
>
|
>
|
||||||
<Typography
|
<Heading component="h2">Actively monitoring</Heading>
|
||||||
component="h2"
|
|
||||||
variant="h2"
|
|
||||||
fontWeight={500}
|
|
||||||
letterSpacing={-0.2}
|
|
||||||
>
|
|
||||||
Actively monitoring
|
|
||||||
</Typography>
|
|
||||||
<Box
|
<Box
|
||||||
className="current-monitors-counter"
|
className="current-monitors-counter"
|
||||||
color={theme.palette.text.primary}
|
color={theme.palette.text.primary}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ const MonitorTable = ({ isAdmin, filter, setIsSearching, isSearching }) => {
|
|||||||
authToken,
|
authToken,
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
limit: 25,
|
limit: 25,
|
||||||
types: ["http", "ping"],
|
types: ["http", "ping", "docker"],
|
||||||
status: null,
|
status: null,
|
||||||
checkOrder: "desc",
|
checkOrder: "desc",
|
||||||
normalize: true,
|
normalize: true,
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const StatusBox = ({ title, value }) => {
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
} else if (title === "down") {
|
} else if (title === "down") {
|
||||||
color = theme.palette.error.text;
|
color = theme.palette.error.main;
|
||||||
icon = (
|
icon = (
|
||||||
<Box sx={{ ...sharedStyles, transform: "rotate(180deg)", top: 5 }}>
|
<Box sx={{ ...sharedStyles, transform: "rotate(180deg)", top: 5 }}>
|
||||||
<Arrow />
|
<Arrow />
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
|
|||||||
"& ul": { p: theme.spacing(2.5) },
|
"& ul": { p: theme.spacing(2.5) },
|
||||||
"& li": { m: 0 },
|
"& li": { m: 0 },
|
||||||
"& li:last-of-type": {
|
"& li:last-of-type": {
|
||||||
color: theme.palette.error.text,
|
color: theme.palette.error.contrastText,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* TODO take these from here and declare using emotion. Plus, the values should live in the theme */
|
||||||
.monitors .MuiStack-root > button:not(.MuiIconButton-root) {
|
.monitors .MuiStack-root > button:not(.MuiIconButton-root) {
|
||||||
font-size: var(--env-var-font-size-medium);
|
font-size: var(--env-var-font-size-medium);
|
||||||
height: var(--env-var-height-2);
|
height: var(--env-var-height-2);
|
||||||
|
|||||||
@@ -28,20 +28,20 @@ const useUtils = () => {
|
|||||||
};
|
};
|
||||||
const statusStyles = {
|
const statusStyles = {
|
||||||
up: {
|
up: {
|
||||||
backgroundColor: theme.palette.success.bg,
|
backgroundColor: theme.palette.success.dark,
|
||||||
background: `linear-gradient(340deg, ${theme.palette.success.light} -60%, ${theme.palette.success.bg} 35%)`,
|
background: `linear-gradient(340deg, ${theme.palette.success.light} -60%, ${theme.palette.success.dark} 35%)`,
|
||||||
borderColor: theme.palette.success.light,
|
borderColor: theme.palette.success.light,
|
||||||
"& h2": { color: theme.palette.success.main },
|
"& h2": { color: theme.palette.success.main },
|
||||||
},
|
},
|
||||||
down: {
|
down: {
|
||||||
backgroundColor: theme.palette.error.bg,
|
backgroundColor: theme.palette.error.dark,
|
||||||
background: `linear-gradient(340deg, ${theme.palette.error.light} -60%, ${theme.palette.error.bg} 35%)`,
|
background: `linear-gradient(340deg, ${theme.palette.error.light} -60%, ${theme.palette.error.dark} 35%)`,
|
||||||
borderColor: theme.palette.error.light,
|
borderColor: theme.palette.error.light,
|
||||||
"& h2": { color: theme.palette.error.main },
|
"& h2": { color: theme.palette.error.main },
|
||||||
},
|
},
|
||||||
paused: {
|
paused: {
|
||||||
backgroundColor: theme.palette.warning.bg,
|
backgroundColor: theme.palette.warning.dark,
|
||||||
background: `linear-gradient(340deg, ${theme.palette.warning.light} -60%, ${theme.palette.warning.bg} 35%)`,
|
background: `linear-gradient(340deg, ${theme.palette.warning.light} -60%, ${theme.palette.warning.dark} 35%)`,
|
||||||
borderColor: theme.palette.warning.light,
|
borderColor: theme.palette.warning.light,
|
||||||
"& h2": { color: theme.palette.warning.main },
|
"& h2": { color: theme.palette.warning.main },
|
||||||
},
|
},
|
||||||
@@ -54,22 +54,22 @@ const useUtils = () => {
|
|||||||
};
|
};
|
||||||
const pagespeedStyles = {
|
const pagespeedStyles = {
|
||||||
up: {
|
up: {
|
||||||
bg: theme.palette.success.bg,
|
bg: theme.palette.success.dark,
|
||||||
light: theme.palette.success.light,
|
light: theme.palette.success.light,
|
||||||
stroke: theme.palette.success.main,
|
stroke: theme.palette.success.main,
|
||||||
},
|
},
|
||||||
down: {
|
down: {
|
||||||
bg: theme.palette.error.bg,
|
bg: theme.palette.error.dark,
|
||||||
light: theme.palette.error.light,
|
light: theme.palette.error.light,
|
||||||
stroke: theme.palette.error.main,
|
stroke: theme.palette.error.main,
|
||||||
},
|
},
|
||||||
paused: {
|
paused: {
|
||||||
bg: theme.palette.warning.bg,
|
bg: theme.palette.warning.dark,
|
||||||
light: theme.palette.warning.light,
|
light: theme.palette.warning.light,
|
||||||
stroke: theme.palette.warning.main,
|
stroke: theme.palette.warning.main,
|
||||||
},
|
},
|
||||||
pending: {
|
pending: {
|
||||||
bg: theme.palette.warning.bg,
|
bg: theme.palette.warning.dark,
|
||||||
light: theme.palette.warning.light,
|
light: theme.palette.warning.light,
|
||||||
stroke: theme.palette.warning.main,
|
stroke: theme.palette.warning.main,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
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 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, checkEndpointResolution } 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";
|
||||||
@@ -17,12 +20,12 @@ import Breadcrumbs from "../../../Components/Breadcrumbs";
|
|||||||
import "./index.css";
|
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 { isLoading } = useSelector((state) => state.pageSpeedMonitors);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
const idMap = {
|
const idMap = {
|
||||||
"monitor-url": "url",
|
"monitor-url": "url",
|
||||||
@@ -105,252 +108,260 @@ const CreatePageSpeed = () => {
|
|||||||
abortEarly: false,
|
abortEarly: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
const newErrors = {};
|
const newErrors = {};
|
||||||
error.details.forEach((err) => {
|
error.details.forEach((err) => {
|
||||||
newErrors[err.path[0]] = err.message;
|
newErrors[err.path[0]] = err.message;
|
||||||
});
|
});
|
||||||
setErrors(newErrors);
|
setErrors(newErrors);
|
||||||
createToast({ body: "Error validation data." });
|
createToast({ body: "Error validation data." });
|
||||||
} else {
|
} else {
|
||||||
const checkEndpointAction = await dispatch(
|
const checkEndpointAction = await dispatch(
|
||||||
checkEndpointResolution({ authToken, monitorURL: form.url })
|
checkEndpointResolution({ authToken, monitorURL: form.url })
|
||||||
)
|
);
|
||||||
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||||
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
|
createToast({
|
||||||
setErrors({ url: "The entered URL is not reachable." });
|
body: "The endpoint you entered doesn't resolve. Check the URL again.",
|
||||||
return;
|
});
|
||||||
}
|
setErrors({ url: "The entered URL is not reachable." });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
form = {
|
form = {
|
||||||
...form,
|
...form,
|
||||||
description: form.name,
|
description: form.name,
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
userId: user._id,
|
userId: user._id,
|
||||||
notifications: monitor.notifications,
|
notifications: monitor.notifications,
|
||||||
};
|
};
|
||||||
const action = await dispatch(
|
const action = await dispatch(createPageSpeed({ authToken, monitor: form }));
|
||||||
createPageSpeed({ authToken, monitor: form })
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
);
|
createToast({ body: "Monitor created successfully!" });
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
navigate("/pagespeed");
|
||||||
createToast({ body: "Monitor created successfully!" });
|
} else {
|
||||||
navigate("/pagespeed");
|
createToast({ body: "Failed to create monitor." });
|
||||||
} else {
|
}
|
||||||
createToast({ body: "Failed to create monitor." });
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//select values
|
//select values
|
||||||
const frequencies = [
|
const frequencies = [
|
||||||
{ _id: 3, name: "3 minutes" },
|
{ _id: 3, name: "3 minutes" },
|
||||||
{ _id: 5, name: "5 minutes" },
|
{ _id: 5, name: "5 minutes" },
|
||||||
{ _id: 10, name: "10 minutes" },
|
{ _id: 10, name: "10 minutes" },
|
||||||
{ _id: 20, name: "20 minutes" },
|
{ _id: 20, name: "20 minutes" },
|
||||||
{ _id: 60, name: "1 hour" },
|
{ _id: 60, name: "1 hour" },
|
||||||
{ _id: 1440, name: "1 day" },
|
{ _id: 1440, name: "1 day" },
|
||||||
{ _id: 10080, name: "1 week" },
|
{ _id: 10080, name: "1 week" },
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
className="create-monitor"
|
className="create-monitor"
|
||||||
sx={{
|
sx={{
|
||||||
"& h1": {
|
"& h1": {
|
||||||
color: theme.palette.text.primary,
|
color: theme.palette.text.primary,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Breadcrumbs
|
<Breadcrumbs
|
||||||
list={[
|
list={[
|
||||||
{ name: "pagespeed", path: "/pagespeed" },
|
{ name: "pagespeed", path: "/pagespeed" },
|
||||||
{ name: "create", path: `/pagespeed/create` },
|
{ name: "create", path: `/pagespeed/create` },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<Stack
|
<Stack
|
||||||
component="form"
|
component="form"
|
||||||
className="create-monitor-form"
|
className="create-monitor-form"
|
||||||
onSubmit={handleCreateMonitor}
|
onSubmit={handleCreateMonitor}
|
||||||
noValidate
|
noValidate
|
||||||
spellCheck="false"
|
spellCheck="false"
|
||||||
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"
|
||||||
Create your{" "}
|
variant="h1"
|
||||||
</Typography>
|
>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
fontSize="inherit"
|
fontSize="inherit"
|
||||||
fontWeight="inherit"
|
>
|
||||||
color={theme.palette.text.secondary}
|
Create your{" "}
|
||||||
>
|
</Typography>
|
||||||
pagespeed monitor
|
<Typography
|
||||||
</Typography>
|
component="span"
|
||||||
</Typography>
|
fontSize="inherit"
|
||||||
<ConfigBox>
|
fontWeight="inherit"
|
||||||
<Box>
|
color={theme.palette.text.secondary}
|
||||||
<Typography component="h2">General settings</Typography>
|
>
|
||||||
<Typography component="p">
|
pagespeed monitor
|
||||||
Here you can select the URL of the host, together with the type of
|
</Typography>
|
||||||
monitor.
|
</Typography>
|
||||||
</Typography>
|
<ConfigBox>
|
||||||
</Box>
|
<Box>
|
||||||
<Stack gap={theme.spacing(15)}>
|
<Typography component="h2">General settings</Typography>
|
||||||
<Field
|
<Typography component="p">
|
||||||
type={"url"}
|
Here you can select the URL of the host, together with the type of monitor.
|
||||||
id="monitor-url"
|
</Typography>
|
||||||
label="URL to monitor"
|
</Box>
|
||||||
https={https}
|
<Stack gap={theme.spacing(15)}>
|
||||||
placeholder="google.com"
|
<Field
|
||||||
value={monitor.url}
|
type={"url"}
|
||||||
onChange={handleChange}
|
id="monitor-url"
|
||||||
error={errors["url"]}
|
label="URL to monitor"
|
||||||
/>
|
https={https}
|
||||||
<Field
|
placeholder="google.com"
|
||||||
type="text"
|
value={monitor.url}
|
||||||
id="monitor-name"
|
onChange={handleChange}
|
||||||
label="Display name"
|
error={errors["url"]}
|
||||||
isOptional={true}
|
/>
|
||||||
placeholder="Google"
|
<Field
|
||||||
value={monitor.name}
|
type="text"
|
||||||
onChange={handleChange}
|
id="monitor-name"
|
||||||
error={errors["name"]}
|
label="Display name"
|
||||||
/>
|
isOptional={true}
|
||||||
</Stack>
|
placeholder="Google"
|
||||||
</ConfigBox>
|
value={monitor.name}
|
||||||
<ConfigBox>
|
onChange={handleChange}
|
||||||
<Box>
|
error={errors["name"]}
|
||||||
<Typography component="h2">Checks to perform</Typography>
|
/>
|
||||||
<Typography component="p">
|
</Stack>
|
||||||
You can always add or remove checks after adding your site.
|
</ConfigBox>
|
||||||
</Typography>
|
<ConfigBox>
|
||||||
</Box>
|
<Box>
|
||||||
<Stack gap={theme.spacing(12)}>
|
<Typography component="h2">Checks to perform</Typography>
|
||||||
<Stack gap={theme.spacing(6)}>
|
<Typography component="p">
|
||||||
<Radio
|
You can always add or remove checks after adding your site.
|
||||||
id="monitor-checks-http"
|
</Typography>
|
||||||
title="Website monitoring"
|
</Box>
|
||||||
desc="Use HTTP(s) to monitor your website or API endpoint."
|
<Stack gap={theme.spacing(12)}>
|
||||||
size="small"
|
<Stack gap={theme.spacing(6)}>
|
||||||
value="http"
|
<Radio
|
||||||
checked={monitor.type === "pagespeed"}
|
id="monitor-checks-http"
|
||||||
onChange={(event) => handleChange(event)}
|
title="Website monitoring"
|
||||||
/>
|
desc="Use HTTP(s) to monitor your website or API endpoint."
|
||||||
<ButtonGroup sx={{ ml: "32px" }}>
|
size="small"
|
||||||
<Button
|
value="http"
|
||||||
variant="group"
|
checked={monitor.type === "pagespeed"}
|
||||||
filled={https.toString()}
|
onChange={(event) => handleChange(event)}
|
||||||
onClick={() => setHttps(true)}
|
/>
|
||||||
>
|
<ButtonGroup sx={{ ml: "32px" }}>
|
||||||
HTTPS
|
<Button
|
||||||
</Button>
|
variant="group"
|
||||||
<Button
|
filled={https.toString()}
|
||||||
variant="group"
|
onClick={() => setHttps(true)}
|
||||||
filled={(!https).toString()}
|
>
|
||||||
onClick={() => setHttps(false)}
|
HTTPS
|
||||||
>
|
</Button>
|
||||||
HTTP
|
<Button
|
||||||
</Button>
|
variant="group"
|
||||||
</ButtonGroup>
|
filled={(!https).toString()}
|
||||||
</Stack>
|
onClick={() => setHttps(false)}
|
||||||
{errors["type"] ? (
|
>
|
||||||
<Box className="error-container">
|
HTTP
|
||||||
<Typography
|
</Button>
|
||||||
component="p"
|
</ButtonGroup>
|
||||||
className="input-error"
|
</Stack>
|
||||||
color={theme.palette.error.text}
|
{errors["type"] ? (
|
||||||
>
|
<Box className="error-container">
|
||||||
{errors["type"]}
|
<Typography
|
||||||
</Typography>
|
component="p"
|
||||||
</Box>
|
className="input-error"
|
||||||
) : (
|
color={theme.palette.error.contrastText}
|
||||||
""
|
>
|
||||||
)}
|
{errors["type"]}
|
||||||
</Stack>
|
</Typography>
|
||||||
</ConfigBox>
|
</Box>
|
||||||
<ConfigBox>
|
) : (
|
||||||
<Box>
|
""
|
||||||
<Typography component="h2">Incident notifications</Typography>
|
)}
|
||||||
<Typography component="p">
|
</Stack>
|
||||||
When there is an incident, notify users.
|
</ConfigBox>
|
||||||
</Typography>
|
<ConfigBox>
|
||||||
</Box>
|
<Box>
|
||||||
<Stack gap={theme.spacing(6)}>
|
<Typography component="h2">Incident notifications</Typography>
|
||||||
<Typography component="p">When there is a new incident,</Typography>
|
<Typography component="p">
|
||||||
<Checkbox
|
When there is an incident, notify users.
|
||||||
id="notify-sms"
|
</Typography>
|
||||||
label="Notify via SMS (coming soon)"
|
</Box>
|
||||||
isChecked={false}
|
<Stack gap={theme.spacing(6)}>
|
||||||
value=""
|
<Typography component="p">When there is a new incident,</Typography>
|
||||||
onChange={() => logger.warn("disabled")}
|
<Checkbox
|
||||||
isDisabled={true}
|
id="notify-sms"
|
||||||
/>
|
label="Notify via SMS (coming soon)"
|
||||||
<Checkbox
|
isChecked={false}
|
||||||
id="notify-email-default"
|
value=""
|
||||||
label={`Notify via email (to ${user.email})`}
|
onChange={() => logger.warn("disabled")}
|
||||||
isChecked={monitor.notifications.some(
|
isDisabled={true}
|
||||||
(notification) => notification.type === "email"
|
/>
|
||||||
)}
|
<Checkbox
|
||||||
value={user?.email}
|
id="notify-email-default"
|
||||||
onChange={(event) => handleChange(event)}
|
label={`Notify via email (to ${user.email})`}
|
||||||
/>
|
isChecked={monitor.notifications.some(
|
||||||
<Checkbox
|
(notification) => notification.type === "email"
|
||||||
id="notify-email"
|
)}
|
||||||
label="Also notify via email to multiple addresses (coming soon)"
|
value={user?.email}
|
||||||
isChecked={false}
|
onChange={(event) => handleChange(event)}
|
||||||
value=""
|
/>
|
||||||
onChange={() => logger.warn("disabled")}
|
<Checkbox
|
||||||
isDisabled={true}
|
id="notify-email"
|
||||||
/>
|
label="Also notify via email to multiple addresses (coming soon)"
|
||||||
{monitor.notifications.some(
|
isChecked={false}
|
||||||
(notification) => notification.type === "emails"
|
value=""
|
||||||
) ? (
|
onChange={() => logger.warn("disabled")}
|
||||||
<Box mx={theme.spacing(16)}>
|
isDisabled={true}
|
||||||
<Field
|
/>
|
||||||
id="notify-email-list"
|
{monitor.notifications.some(
|
||||||
type="text"
|
(notification) => notification.type === "emails"
|
||||||
placeholder="name@gmail.com"
|
) ? (
|
||||||
value=""
|
<Box mx={theme.spacing(16)}>
|
||||||
onChange={() => logger.warn("disabled")}
|
<Field
|
||||||
/>
|
id="notify-email-list"
|
||||||
<Typography mt={theme.spacing(4)}>
|
type="text"
|
||||||
You can separate multiple emails with a comma
|
placeholder="name@gmail.com"
|
||||||
</Typography>
|
value=""
|
||||||
</Box>
|
onChange={() => logger.warn("disabled")}
|
||||||
) : (
|
/>
|
||||||
""
|
<Typography mt={theme.spacing(4)}>
|
||||||
)}
|
You can separate multiple emails with a comma
|
||||||
</Stack>
|
</Typography>
|
||||||
</ConfigBox>
|
</Box>
|
||||||
<ConfigBox>
|
) : (
|
||||||
<Box>
|
""
|
||||||
<Typography component="h2">Advanced settings</Typography>
|
)}
|
||||||
</Box>
|
</Stack>
|
||||||
<Stack gap={theme.spacing(12)}>
|
</ConfigBox>
|
||||||
<Select
|
<ConfigBox>
|
||||||
id="monitor-interval"
|
<Box>
|
||||||
label="Check frequency"
|
<Typography component="h2">Advanced settings</Typography>
|
||||||
value={monitor.interval || 3}
|
</Box>
|
||||||
onChange={(event) => handleChange(event, "interval")}
|
<Stack gap={theme.spacing(12)}>
|
||||||
items={frequencies}
|
<Select
|
||||||
/>
|
id="monitor-interval"
|
||||||
</Stack>
|
label="Check frequency"
|
||||||
</ConfigBox>
|
value={monitor.interval || 3}
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
onChange={(event) => handleChange(event, "interval")}
|
||||||
<LoadingButton
|
items={frequencies}
|
||||||
variant="contained"
|
/>
|
||||||
color="primary"
|
</Stack>
|
||||||
onClick={handleCreateMonitor}
|
</ConfigBox>
|
||||||
disabled={Object.keys(errors).length !== 0 && true}
|
<Stack
|
||||||
loading={isLoading}
|
direction="row"
|
||||||
>
|
justifyContent="flex-end"
|
||||||
Create monitor
|
>
|
||||||
</LoadingButton>
|
<LoadingButton
|
||||||
</Stack>
|
variant="contained"
|
||||||
</Stack>
|
color="primary"
|
||||||
</Box>
|
onClick={handleCreateMonitor}
|
||||||
);
|
disabled={Object.keys(errors).length !== 0 && true}
|
||||||
|
loading={isLoading}
|
||||||
|
>
|
||||||
|
Create monitor
|
||||||
|
</LoadingButton>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CreatePageSpeed;
|
export default CreatePageSpeed;
|
||||||
@@ -127,22 +127,22 @@ const PieChart = ({ audits }) => {
|
|||||||
return {
|
return {
|
||||||
stroke: theme.palette.success.main,
|
stroke: theme.palette.success.main,
|
||||||
strokeBg: theme.palette.success.light,
|
strokeBg: theme.palette.success.light,
|
||||||
text: theme.palette.success.text,
|
text: theme.palette.success.contrastText,
|
||||||
bg: theme.palette.success.bg,
|
bg: theme.palette.success.dark,
|
||||||
};
|
};
|
||||||
else if (value >= 50 && value < 90)
|
else if (value >= 50 && value < 90)
|
||||||
return {
|
return {
|
||||||
stroke: theme.palette.warning.main,
|
stroke: theme.palette.warning.main,
|
||||||
strokeBg: theme.palette.warning.light,
|
strokeBg: theme.palette.warning.light,
|
||||||
text: theme.palette.warning.text,
|
text: theme.palette.warning.contrastText,
|
||||||
bg: theme.palette.warning.bg,
|
bg: theme.palette.warning.dark,
|
||||||
};
|
};
|
||||||
else if (value >= 0 && value < 50)
|
else if (value >= 0 && value < 50)
|
||||||
return {
|
return {
|
||||||
stroke: theme.palette.error.text,
|
stroke: theme.palette.error.contrastText,
|
||||||
strokeBg: theme.palette.error.light,
|
strokeBg: theme.palette.error.light,
|
||||||
text: theme.palette.error.text,
|
text: theme.palette.error.contrastText,
|
||||||
bg: theme.palette.error.bg,
|
bg: theme.palette.error.dark,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
stroke: theme.palette.unresolved.main,
|
stroke: theme.palette.unresolved.main,
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
: score >= 50
|
: score >= 50
|
||||||
? theme.palette.warning.main
|
? theme.palette.warning.main
|
||||||
: score >= 0
|
: score >= 0
|
||||||
? theme.palette.error.text
|
? theme.palette.error.contrastText
|
||||||
: 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
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
#Pages Folder
|
|
||||||
@@ -0,0 +1,244 @@
|
|||||||
|
const typographyBase = 14;
|
||||||
|
|
||||||
|
/* TODO
|
||||||
|
Check for px in codebase. All font sizes should be in REM and should live here.
|
||||||
|
Rest should be checked on each case
|
||||||
|
*/
|
||||||
|
const typographyLevels = {
|
||||||
|
base: typographyBase,
|
||||||
|
xs: `${(typographyBase - 4) / 16}rem`,
|
||||||
|
s: `${(typographyBase - 2) / 16}rem`,
|
||||||
|
m: `${typographyBase / 16}rem`,
|
||||||
|
l: `${(typographyBase + 2) / 16}rem`,
|
||||||
|
xl: `${(typographyBase + 10) / 16}rem`,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* TODO Review color palette and semantic colors */
|
||||||
|
const paletteColors = {
|
||||||
|
white: "#FFFFFF",
|
||||||
|
gray50: "#FEFEFE",
|
||||||
|
gray60: "#FEFDFE",
|
||||||
|
gray70: "#FDFDFD",
|
||||||
|
gray80: "#FDFCFD",
|
||||||
|
gray90: "#FCFCFD",
|
||||||
|
gray100: "#F4F4F4",
|
||||||
|
gray200: "#E3E3E3",
|
||||||
|
gray300: "#A2A3A3",
|
||||||
|
gray500: "#838C99",
|
||||||
|
gray600: "#454546",
|
||||||
|
gray750: "#36363E",
|
||||||
|
gray800: "#2D2D33",
|
||||||
|
gray850: "#131315",
|
||||||
|
gray860: "#111113",
|
||||||
|
gray870: "#0F0F11",
|
||||||
|
gray880: "#0C0C0E",
|
||||||
|
gray890: "#09090B",
|
||||||
|
blueGray20: "#E8F0FE",
|
||||||
|
blueGray150: "#667085",
|
||||||
|
blueGray200: "#475467",
|
||||||
|
blueGray400: "#344054",
|
||||||
|
blueGray900: "#1c2130",
|
||||||
|
blueBlueWave: "#1570EF",
|
||||||
|
blue700: "#4E5BA6",
|
||||||
|
purple300: "#664EFF",
|
||||||
|
purple400: "#3A1BFF",
|
||||||
|
green50: "#D4F4E1",
|
||||||
|
green150: "#45BB7A",
|
||||||
|
green400: "#079455",
|
||||||
|
green800: "#1C4428",
|
||||||
|
green900: "#12261E",
|
||||||
|
red50: "#F9ECED",
|
||||||
|
red100: "#FBD1D1",
|
||||||
|
red200: "#F04438",
|
||||||
|
red300: "#D32F2F",
|
||||||
|
red700: "#542426",
|
||||||
|
red800: "#301A1F",
|
||||||
|
orange50: "#FEF8EA",
|
||||||
|
orange100: "#FFECBC",
|
||||||
|
orange300: "#FDB022",
|
||||||
|
orange400: "#FF9F00",
|
||||||
|
orange500: "#E88C30",
|
||||||
|
orange600: "#DC6803",
|
||||||
|
orange800: "#624711",
|
||||||
|
};
|
||||||
|
|
||||||
|
const semanticColors = {
|
||||||
|
primary: {
|
||||||
|
main: {
|
||||||
|
light: paletteColors.blueBlueWave,
|
||||||
|
dark: paletteColors.blueBlueWave,
|
||||||
|
},
|
||||||
|
// TODO we dont have primary light, dark or contrast text
|
||||||
|
},
|
||||||
|
secondary: {
|
||||||
|
main: {
|
||||||
|
light: paletteColors.gray100,
|
||||||
|
dark: paletteColors.gray800,
|
||||||
|
},
|
||||||
|
contrastText: {
|
||||||
|
light: paletteColors.blueGray200,
|
||||||
|
dark: paletteColors.blueGray200,
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
light: paletteColors.gray200,
|
||||||
|
dark: paletteColors.gray200,
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
light: paletteColors.gray200,
|
||||||
|
dark: paletteColors.gray200,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
success: {
|
||||||
|
main: {
|
||||||
|
light: paletteColors.green400,
|
||||||
|
dark: paletteColors.green400,
|
||||||
|
},
|
||||||
|
contrastText: {
|
||||||
|
light: paletteColors.green50,
|
||||||
|
dark: paletteColors.green900,
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
light: paletteColors.green50,
|
||||||
|
dark: paletteColors.green150,
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
light: paletteColors.green800,
|
||||||
|
dark: paletteColors.green900,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
main: {
|
||||||
|
light: paletteColors.red300,
|
||||||
|
dark: paletteColors.red300,
|
||||||
|
},
|
||||||
|
contrastText: {
|
||||||
|
light: paletteColors.gray50,
|
||||||
|
dark: paletteColors.gray50,
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
light: paletteColors.red100,
|
||||||
|
dark: paletteColors.red700,
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
light: paletteColors.red50,
|
||||||
|
dark: paletteColors.red800,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
warning: {
|
||||||
|
main: {
|
||||||
|
light: paletteColors.orange300,
|
||||||
|
dark: paletteColors.orange400,
|
||||||
|
},
|
||||||
|
contrastText: {
|
||||||
|
light: paletteColors.orange600,
|
||||||
|
dark: paletteColors.orange500,
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
light: paletteColors.orange100,
|
||||||
|
dark: paletteColors.orange800,
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
light: paletteColors.orange50,
|
||||||
|
dark: paletteColors.gray800,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
/* From this part on, try to create semantic structure, not feature based structure */
|
||||||
|
gradient: {
|
||||||
|
color1: {
|
||||||
|
light: paletteColors.gray90,
|
||||||
|
dark: paletteColors.gray890,
|
||||||
|
},
|
||||||
|
color2: {
|
||||||
|
light: paletteColors.gray80,
|
||||||
|
dark: paletteColors.gray880,
|
||||||
|
},
|
||||||
|
color3: {
|
||||||
|
light: paletteColors.gray70,
|
||||||
|
dark: paletteColors.gray870,
|
||||||
|
},
|
||||||
|
color4: {
|
||||||
|
light: paletteColors.gray60,
|
||||||
|
dark: paletteColors.gray860,
|
||||||
|
},
|
||||||
|
color5: {
|
||||||
|
light: paletteColors.gray50,
|
||||||
|
dark: paletteColors.gray850,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
background: {
|
||||||
|
main: {
|
||||||
|
light: paletteColors.white,
|
||||||
|
dark: paletteColors.gray850,
|
||||||
|
},
|
||||||
|
alt: {
|
||||||
|
light: paletteColors.gray90,
|
||||||
|
dark: paletteColors.gray890,
|
||||||
|
},
|
||||||
|
fill: {
|
||||||
|
light: paletteColors.gray100,
|
||||||
|
dark: paletteColors.gray800,
|
||||||
|
},
|
||||||
|
accent: {
|
||||||
|
light: paletteColors.gray100,
|
||||||
|
dark: paletteColors.gray850,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
primary: {
|
||||||
|
light: paletteColors.blueGray900,
|
||||||
|
dark: paletteColors.gray100,
|
||||||
|
},
|
||||||
|
secondary: {
|
||||||
|
light: paletteColors.blueGray400,
|
||||||
|
dark: paletteColors.gray200,
|
||||||
|
},
|
||||||
|
tertiary: {
|
||||||
|
light: paletteColors.blueGray200,
|
||||||
|
dark: paletteColors.gray300,
|
||||||
|
},
|
||||||
|
accent: {
|
||||||
|
light: paletteColors.gray500,
|
||||||
|
dark: paletteColors.gray500,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
light: {
|
||||||
|
light: paletteColors.gray200,
|
||||||
|
dark: paletteColors.gray800,
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
light: paletteColors.gray200,
|
||||||
|
dark: paletteColors.gray750,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
unresolved: {
|
||||||
|
main: {
|
||||||
|
light: paletteColors.blue700,
|
||||||
|
dark: paletteColors.purple300,
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
light: paletteColors.blueGray20,
|
||||||
|
dark: paletteColors.purple400,
|
||||||
|
},
|
||||||
|
bg: {
|
||||||
|
light: paletteColors.gray100,
|
||||||
|
dark: paletteColors.gray100,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
other: {
|
||||||
|
icon: {
|
||||||
|
light: paletteColors.blueGray150,
|
||||||
|
},
|
||||||
|
line: {
|
||||||
|
light: paletteColors.gray200,
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
light: paletteColors.gray300,
|
||||||
|
dark: paletteColors.gray600,
|
||||||
|
},
|
||||||
|
autofill: {
|
||||||
|
light: paletteColors.blueGray20,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export { typographyLevels, semanticColors as colors };
|
||||||
+100
-259
@@ -1,267 +1,108 @@
|
|||||||
import { createTheme } from "@mui/material";
|
import { createTheme } from "@mui/material";
|
||||||
|
import { baseTheme } from "./globalTheme";
|
||||||
|
import { colors } from "./constants";
|
||||||
|
|
||||||
const text = {
|
const {
|
||||||
primary: "#fafafa",
|
primary,
|
||||||
secondary: "#e6e6e6",
|
secondary,
|
||||||
tertiary: "#a1a1aa",
|
success,
|
||||||
accent: "#8e8e8f",
|
error,
|
||||||
disabled: "rgba(172, 172, 172, 0.3)",
|
warning,
|
||||||
};
|
gradient: {
|
||||||
const background = {
|
color1: { dark: color1 },
|
||||||
main: "#151518",
|
color2: { dark: color2 },
|
||||||
alt: "#09090b",
|
color3: { dark: color3 },
|
||||||
fill: "#2D2D33",
|
color4: { dark: color4 },
|
||||||
accent: "#18181a",
|
color5: { dark: color5 },
|
||||||
};
|
},
|
||||||
const border = { light: "#27272a", dark: "#36363e" };
|
background,
|
||||||
|
text,
|
||||||
|
border,
|
||||||
|
unresolved,
|
||||||
|
other,
|
||||||
|
} = colors;
|
||||||
|
|
||||||
const fontFamilyDefault =
|
const palette = {
|
||||||
'"Inter","system-ui", "Avenir", "Helvetica", "Arial", sans-serif';
|
primary: { main: primary.main.dark },
|
||||||
const shadow =
|
secondary: {
|
||||||
"0px 4px 24px -4px rgba(255, 255, 255, 0.03), 0px 3px 3px -3px rgba(255, 255, 255, 0.01)";
|
main: secondary.main.dark,
|
||||||
|
contrastText: secondary.contrastText.dark,
|
||||||
|
light: secondary.dark.dark,
|
||||||
|
dark: secondary.dark.dark,
|
||||||
|
},
|
||||||
|
success: {
|
||||||
|
main: success.main.dark,
|
||||||
|
contrastText: success.contrastText.dark,
|
||||||
|
light: success.light.dark,
|
||||||
|
dark: success.dark.dark,
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
main: error.main.dark,
|
||||||
|
contrastText: error.contrastText.dark,
|
||||||
|
light: error.light.dark,
|
||||||
|
dark: error.dark.dark,
|
||||||
|
},
|
||||||
|
warning: {
|
||||||
|
main: warning.main.dark,
|
||||||
|
light: warning.light.dark,
|
||||||
|
contrastText: warning.contrastText.dark,
|
||||||
|
dark: warning.dark.dark,
|
||||||
|
},
|
||||||
|
/* From this part on, try to create semantic structure, not feature based structure */
|
||||||
|
percentage: {
|
||||||
|
uptimePoor: error.main.dark,
|
||||||
|
uptimeFair: warning.contrastText.dark,
|
||||||
|
uptimeGood: warning.main.dark /* Change for a success color? ?*/,
|
||||||
|
uptimeExcellent: success.main.dark,
|
||||||
|
},
|
||||||
|
unresolved: {
|
||||||
|
main: unresolved.main.dark,
|
||||||
|
light: unresolved.light.dark,
|
||||||
|
bg: unresolved.bg.dark,
|
||||||
|
},
|
||||||
|
divider: border.light.dark,
|
||||||
|
other: {
|
||||||
|
icon: text.secondary.dark,
|
||||||
|
line: border.light.dark,
|
||||||
|
fill: background.accent.dark,
|
||||||
|
grid: other.grid.dark,
|
||||||
|
autofill: secondary.main.dark,
|
||||||
|
},
|
||||||
|
gradient: {
|
||||||
|
color1,
|
||||||
|
color2,
|
||||||
|
color3,
|
||||||
|
color4,
|
||||||
|
color5,
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
primary: text.primary.dark,
|
||||||
|
secondary: text.secondary.dark,
|
||||||
|
tertiary: text.tertiary.dark,
|
||||||
|
accent: text.accent.dark,
|
||||||
|
},
|
||||||
|
background: {
|
||||||
|
main: background.main.dark,
|
||||||
|
alt: background.alt.dark,
|
||||||
|
fill: background.fill.dark,
|
||||||
|
accent: background.accent.dark,
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
light: border.light.dark,
|
||||||
|
dark: border.dark.dark,
|
||||||
|
},
|
||||||
|
info: {
|
||||||
|
text: text.primary.dark,
|
||||||
|
main: text.secondary.dark,
|
||||||
|
bg: background.main.dark,
|
||||||
|
light: background.main.dark,
|
||||||
|
border: border.light.dark,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const darkTheme = createTheme({
|
const darkTheme = createTheme({
|
||||||
typography: {
|
palette,
|
||||||
fontFamily: fontFamilyDefault,
|
...baseTheme(palette),
|
||||||
fontSize: 13,
|
|
||||||
h1: { fontSize: 22, color: text.primary, fontWeight: 500 },
|
|
||||||
h2: { fontSize: 14.5, color: text.secondary, fontWeight: 400 },
|
|
||||||
body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
|
|
||||||
body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
|
|
||||||
},
|
|
||||||
chart: {
|
|
||||||
header: {
|
|
||||||
fontWeight: 400,
|
|
||||||
fill: text.tertiary,
|
|
||||||
fontSize: 11,
|
|
||||||
},
|
|
||||||
subheader: {
|
|
||||||
fontWeight: 400,
|
|
||||||
fill: text.tertiary,
|
|
||||||
fontSize: 9,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
palette: {
|
|
||||||
mode: "dark",
|
|
||||||
primary: { main: "#1570ef" },
|
|
||||||
secondary: { main: "#2D2D33" },
|
|
||||||
text: text,
|
|
||||||
background: background,
|
|
||||||
border: border,
|
|
||||||
info: {
|
|
||||||
text: text.primary,
|
|
||||||
main: text.secondary,
|
|
||||||
bg: background.main,
|
|
||||||
light: background.main,
|
|
||||||
border: border.light,
|
|
||||||
},
|
|
||||||
success: {
|
|
||||||
text: "#079455",
|
|
||||||
main: "#45bb7a",
|
|
||||||
light: "#1c4428",
|
|
||||||
bg: "#12261e",
|
|
||||||
},
|
|
||||||
error: {
|
|
||||||
text: "#f04438",
|
|
||||||
main: "#d32f2f",
|
|
||||||
light: "#542426",
|
|
||||||
bg: "#301a1f",
|
|
||||||
dark: "#932020",
|
|
||||||
border: "#f04438",
|
|
||||||
},
|
|
||||||
warning: {
|
|
||||||
text: "#e88c30",
|
|
||||||
main: "#FF9F00",
|
|
||||||
light: "#624711",
|
|
||||||
bg: "#262115",
|
|
||||||
border: "#e88c30",
|
|
||||||
},
|
|
||||||
percentage: {
|
|
||||||
uptimePoor: "#d32f2f",
|
|
||||||
uptimeFair: "#e88c30",
|
|
||||||
uptimeGood: "#ffd600",
|
|
||||||
uptimeExcellent: "#079455",
|
|
||||||
},
|
|
||||||
unresolved: { main: "#664eff", light: "#3a1bff", bg: "#f2f4f7" },
|
|
||||||
divider: border.light,
|
|
||||||
other: {
|
|
||||||
icon: "#e6e6e6",
|
|
||||||
line: "#27272a",
|
|
||||||
fill: "#18181a",
|
|
||||||
grid: "#454546",
|
|
||||||
autofill: "#2d2d33",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
spacing: 2,
|
|
||||||
components: {
|
|
||||||
MuiCssBaseline: {
|
|
||||||
styleOverrides: {
|
|
||||||
body: {
|
|
||||||
backgroundImage:
|
|
||||||
"radial-gradient(circle, #09090b, #0c0c0e, #0f0f11, #111113, #131315, #131315, #131315, #131315, #111113, #0f0f11, #0c0c0e, #09090b)",
|
|
||||||
lineHeight: "inherit",
|
|
||||||
paddingLeft: "calc(100vw - 100%)",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiButton: {
|
|
||||||
defaultProps: {
|
|
||||||
disableRipple: true,
|
|
||||||
},
|
|
||||||
styleOverrides: {
|
|
||||||
root: ({ theme }) => ({
|
|
||||||
variants: [
|
|
||||||
{
|
|
||||||
props: (props) => props.variant === "group",
|
|
||||||
style: {
|
|
||||||
color: theme.palette.secondary.contrastText,
|
|
||||||
backgroundColor: theme.palette.background.main,
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
props: (props) => props.variant === "group" && props.filled === "true",
|
|
||||||
style: {
|
|
||||||
backgroundColor: theme.palette.secondary.main,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
props: (props) =>
|
|
||||||
props.variant === "contained" && props.color === "secondary",
|
|
||||||
style: {
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: theme.palette.border.dark,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
fontWeight: 400,
|
|
||||||
borderRadius: 4,
|
|
||||||
boxShadow: "none",
|
|
||||||
textTransform: "none",
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
"&:hover": {
|
|
||||||
boxShadow: "none",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiIconButton: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
padding: 4,
|
|
||||||
transition: "none",
|
|
||||||
"&:hover": {
|
|
||||||
backgroundColor: border.light,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiPaper: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
marginTop: 4,
|
|
||||||
padding: 0,
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: border.light,
|
|
||||||
borderRadius: 4,
|
|
||||||
boxShadow: shadow,
|
|
||||||
backgroundColor: background.main,
|
|
||||||
backgroundImage: "none",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiList: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
padding: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiListItemButton: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
transition: "none",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiMenuItem: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
borderRadius: 4,
|
|
||||||
backgroundColor: "inherit",
|
|
||||||
padding: "4px 6px",
|
|
||||||
color: text.secondary,
|
|
||||||
fontSize: 13,
|
|
||||||
margin: 2,
|
|
||||||
minWidth: 100,
|
|
||||||
"&:hover, &.Mui-selected, &.Mui-selected:hover, &.Mui-selected.Mui-focusVisible":
|
|
||||||
{
|
|
||||||
backgroundColor: background.fill,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiTableCell: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
borderBottomColor: border.light,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiTableHead: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
backgroundColor: background.accent,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiPagination: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
backgroundColor: background.main,
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: border.light,
|
|
||||||
"& button": {
|
|
||||||
color: text.tertiary,
|
|
||||||
borderRadius: 4,
|
|
||||||
},
|
|
||||||
"& li:first-of-type button, & li:last-of-type button": {
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: border.light,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiPaginationItem: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
"&:not(.MuiPaginationItem-ellipsis):hover, &.Mui-selected": {
|
|
||||||
backgroundColor: background.fill,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiSkeleton: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
backgroundColor: "#151518",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shape: {
|
|
||||||
borderRadius: 2,
|
|
||||||
borderThick: 2,
|
|
||||||
boxShadow: shadow,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default darkTheme;
|
export default darkTheme;
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
import { typographyLevels } from "./constants";
|
||||||
|
|
||||||
|
const fontFamilyPrimary = '"Inter" , sans-serif';
|
||||||
|
// const fontFamilySecondary = '"Avenir", sans-serif';
|
||||||
|
|
||||||
|
/* TODO take the color out from here */
|
||||||
|
const shadow =
|
||||||
|
"0px 4px 24px -4px rgba(16, 24, 40, 0.08), 0px 3px 3px -3px rgba(16, 24, 40, 0.03)";
|
||||||
|
|
||||||
|
const baseTheme = (palette) => ({
|
||||||
|
typography: {
|
||||||
|
fontFamily: fontFamilyPrimary,
|
||||||
|
fontSize: 14,
|
||||||
|
h1: {
|
||||||
|
fontSize: typographyLevels.xl,
|
||||||
|
color: palette.text.primary,
|
||||||
|
fontWeight: 500,
|
||||||
|
},
|
||||||
|
h2: {
|
||||||
|
fontSize: typographyLevels.l,
|
||||||
|
color: palette.text.secondary,
|
||||||
|
fontWeight: 400,
|
||||||
|
},
|
||||||
|
body1: {
|
||||||
|
fontSize: typographyLevels.m,
|
||||||
|
color: palette.text.tertiary,
|
||||||
|
fontWeight: 400,
|
||||||
|
},
|
||||||
|
body2: {
|
||||||
|
fontSize: typographyLevels.s,
|
||||||
|
color: palette.text.tertiary,
|
||||||
|
fontWeight: 400,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
/* TODO take chart from here, it should live inside of the gauge, and get info from the theme */
|
||||||
|
chart: {
|
||||||
|
header: {
|
||||||
|
fontWeight: 400,
|
||||||
|
fill: palette.text.tertiary,
|
||||||
|
fontSize: typographyLevels.m,
|
||||||
|
},
|
||||||
|
subheader: {
|
||||||
|
fontWeight: 400,
|
||||||
|
fill: palette.text.tertiary,
|
||||||
|
fontSize: typographyLevels.xs,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
spacing: 2,
|
||||||
|
/* TODO All these should live inside of a component*/
|
||||||
|
components: {
|
||||||
|
MuiButton: {
|
||||||
|
defaultProps: {
|
||||||
|
disableRipple: true,
|
||||||
|
},
|
||||||
|
styleOverrides: {
|
||||||
|
root: ({ theme }) => ({
|
||||||
|
variants: [
|
||||||
|
{
|
||||||
|
props: (props) => props.variant === "group",
|
||||||
|
style: {
|
||||||
|
color: theme.palette.secondary.contrastText,
|
||||||
|
backgroundColor: theme.palette.background.main,
|
||||||
|
border: 1,
|
||||||
|
borderStyle: "solid",
|
||||||
|
borderColor: theme.palette.border.light,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
props: (props) => props.variant === "group" && props.filled === "true",
|
||||||
|
style: {
|
||||||
|
backgroundColor: theme.palette.secondary.main,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
props: (props) =>
|
||||||
|
props.variant === "contained" && props.color === "secondary",
|
||||||
|
style: {
|
||||||
|
border: 1,
|
||||||
|
borderStyle: "solid",
|
||||||
|
borderColor: theme.palette.border.light,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
props: (props) => props.variant === "contained" && props.disabled,
|
||||||
|
style: {
|
||||||
|
backgroundColor: `${theme.palette.secondary.main} !important`,
|
||||||
|
color: `${theme.palette.secondary.contrastText} !important`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fontWeight: 400,
|
||||||
|
borderRadius: 4,
|
||||||
|
boxShadow: "none",
|
||||||
|
textTransform: "none",
|
||||||
|
"&:focus": {
|
||||||
|
outline: "none",
|
||||||
|
},
|
||||||
|
"&:hover": {
|
||||||
|
boxShadow: "none",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MuiIconButton: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: ({ theme }) => ({
|
||||||
|
padding: 4,
|
||||||
|
transition: "none",
|
||||||
|
"&:hover": {
|
||||||
|
backgroundColor: theme.palette.background.fill,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MuiPaper: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: ({ theme }) => {
|
||||||
|
return {
|
||||||
|
marginTop: 4,
|
||||||
|
padding: 0,
|
||||||
|
border: 1,
|
||||||
|
borderStyle: "solid",
|
||||||
|
borderColor: theme.palette.border.light,
|
||||||
|
borderRadius: 4,
|
||||||
|
boxShadow: shadow,
|
||||||
|
backgroundColor: theme.palette.background.main,
|
||||||
|
backgroundImage: "none",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MuiList: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: {
|
||||||
|
padding: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MuiListItemButton: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: {
|
||||||
|
transition: "none",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MuiMenuItem: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: ({ theme }) => ({
|
||||||
|
borderRadius: 4,
|
||||||
|
backgroundColor: "inherit",
|
||||||
|
padding: "4px 6px",
|
||||||
|
color: theme.palette.text.secondary,
|
||||||
|
fontSize: 13,
|
||||||
|
margin: 2,
|
||||||
|
minWidth: 100,
|
||||||
|
"&:hover, &.Mui-selected, &.Mui-selected:hover, &.Mui-selected.Mui-focusVisible":
|
||||||
|
{
|
||||||
|
backgroundColor: theme.palette.background.fill,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MuiTableCell: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: ({ theme }) => ({
|
||||||
|
borderBottomColor: theme.palette.border.light,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MuiTableHead: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: ({ theme }) => ({
|
||||||
|
backgroundColor: theme.palette.background.accent,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MuiPagination: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: ({ theme }) => ({
|
||||||
|
backgroundColor: theme.palette.background.main,
|
||||||
|
border: 1,
|
||||||
|
borderStyle: "solid",
|
||||||
|
borderColor: theme.palette.border.light,
|
||||||
|
"& button": {
|
||||||
|
color: theme.palette.text.tertiary,
|
||||||
|
borderRadius: 4,
|
||||||
|
},
|
||||||
|
"& li:first-of-type button, & li:last-of-type button": {
|
||||||
|
border: 1,
|
||||||
|
borderStyle: "solid",
|
||||||
|
borderColor: theme.palette.border.light,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MuiPaginationItem: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: ({ theme }) => ({
|
||||||
|
"&:not(.MuiPaginationItem-ellipsis):hover, &.Mui-selected": {
|
||||||
|
backgroundColor: theme.palette.background.fill,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
MuiSkeleton: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: ({ theme }) => ({
|
||||||
|
backgroundColor: theme.palette.unresolved.bg,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shape: {
|
||||||
|
borderRadius: 2,
|
||||||
|
borderThick: 2,
|
||||||
|
boxShadow: shadow,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export { baseTheme };
|
||||||
@@ -1,265 +1,114 @@
|
|||||||
import { createTheme } from "@mui/material";
|
import { createTheme } from "@mui/material";
|
||||||
|
import { baseTheme } from "./globalTheme";
|
||||||
|
import { colors } from "./constants";
|
||||||
|
|
||||||
const text = {
|
/*
|
||||||
primary: "#1c2130",
|
TODO
|
||||||
secondary: "#344054",
|
Next step: check if all keys here are being used in the codebase. e.g.: Search codebase for palette.primary; also check for destructuring palette ('= theme.palette')
|
||||||
tertiary: "#475467",
|
*/
|
||||||
accent: "#838c99",
|
|
||||||
};
|
const {
|
||||||
const background = {
|
primary,
|
||||||
main: "#FFFFFF",
|
secondary,
|
||||||
alt: "#FCFCFD",
|
success,
|
||||||
fill: "#F4F4F4",
|
error,
|
||||||
accent: "#f9fafb",
|
warning,
|
||||||
|
gradient: {
|
||||||
|
color1: { light: color1 },
|
||||||
|
color2: { light: color2 },
|
||||||
|
color3: { light: color3 },
|
||||||
|
color4: { light: color4 },
|
||||||
|
color5: { light: color5 },
|
||||||
|
},
|
||||||
|
background,
|
||||||
|
text,
|
||||||
|
border,
|
||||||
|
unresolved,
|
||||||
|
other,
|
||||||
|
} = colors;
|
||||||
|
|
||||||
|
const palette = {
|
||||||
|
primary: { main: primary.main.light },
|
||||||
|
secondary: {
|
||||||
|
main: secondary.main.light,
|
||||||
|
contrastText: secondary.contrastText.light,
|
||||||
|
light: secondary.dark.light,
|
||||||
|
dark: secondary.dark.light,
|
||||||
|
},
|
||||||
|
success: {
|
||||||
|
main: success.main.light,
|
||||||
|
contrastText: success.contrastText.light,
|
||||||
|
light: success.light.light,
|
||||||
|
dark: success.dark.light,
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
main: error.main.light,
|
||||||
|
contrastText: error.contrastText.light,
|
||||||
|
light: error.light.light,
|
||||||
|
dark: error.dark.light,
|
||||||
|
},
|
||||||
|
warning: {
|
||||||
|
main: warning.main.light,
|
||||||
|
light: warning.light.light,
|
||||||
|
contrastText: warning.contrastText.light,
|
||||||
|
dark: warning.dark.light,
|
||||||
|
},
|
||||||
|
/* From this part on, try to create semantic structure, not feature based structure */
|
||||||
|
percentage: {
|
||||||
|
uptimePoor: error.main.light,
|
||||||
|
uptimeFair: warning.contrastText.light,
|
||||||
|
uptimeGood: warning.main.light /* Change for a success color? */,
|
||||||
|
uptimeExcellent: success.main.light,
|
||||||
|
},
|
||||||
|
unresolved: {
|
||||||
|
main: unresolved.main.light,
|
||||||
|
light: unresolved.light.light,
|
||||||
|
bg: unresolved.bg.light,
|
||||||
|
},
|
||||||
|
divider: border.light.light,
|
||||||
|
other: {
|
||||||
|
icon: other.icon.light,
|
||||||
|
line: other.line.light,
|
||||||
|
fill: secondary.dark.light,
|
||||||
|
grid: other.grid.light,
|
||||||
|
autofill: other.autofill.light,
|
||||||
|
},
|
||||||
|
gradient: {
|
||||||
|
color1,
|
||||||
|
color2,
|
||||||
|
color3,
|
||||||
|
color4,
|
||||||
|
color5,
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
primary: text.primary.light,
|
||||||
|
secondary: text.secondary.light,
|
||||||
|
tertiary: text.tertiary.light,
|
||||||
|
accent: text.accent.light,
|
||||||
|
},
|
||||||
|
background: {
|
||||||
|
main: background.main.light,
|
||||||
|
alt: background.alt.light,
|
||||||
|
fill: background.fill.light,
|
||||||
|
accent: background.accent.light,
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
light: border.light.light,
|
||||||
|
dark: border.dark.light,
|
||||||
|
},
|
||||||
|
info: {
|
||||||
|
text: text.primary.light,
|
||||||
|
main: text.tertiary.light,
|
||||||
|
bg: background.main.light,
|
||||||
|
light: background.main.light,
|
||||||
|
border: border.dark.light,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const border = { light: "#eaecf0", dark: "#d0d5dd" };
|
/* TODO I figured out we could have just one theme by passing mode as parameter for theme function. Implement later */
|
||||||
|
|
||||||
const fontFamilyDefault =
|
|
||||||
'"Inter","system-ui", "Avenir", "Helvetica", "Arial", sans-serif';
|
|
||||||
const shadow =
|
|
||||||
"0px 4px 24px -4px rgba(16, 24, 40, 0.08), 0px 3px 3px -3px rgba(16, 24, 40, 0.03)";
|
|
||||||
|
|
||||||
const lightTheme = createTheme({
|
const lightTheme = createTheme({
|
||||||
typography: {
|
palette,
|
||||||
fontFamily: fontFamilyDefault,
|
...baseTheme(palette),
|
||||||
fontSize: 13,
|
|
||||||
h1: { fontSize: 22, color: text.primary, fontWeight: 500 },
|
|
||||||
h2: { fontSize: 14.5, color: text.secondary, fontWeight: 400 },
|
|
||||||
body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
|
|
||||||
body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
|
|
||||||
},
|
|
||||||
chart: {
|
|
||||||
header: {
|
|
||||||
fontWeight: 400,
|
|
||||||
fill: text.tertiary,
|
|
||||||
fontSize: 11,
|
|
||||||
},
|
|
||||||
subheader: {
|
|
||||||
fontWeight: 400,
|
|
||||||
fill: text.tertiary,
|
|
||||||
fontSize: 9,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
palette: {
|
|
||||||
primary: { main: "#1570EF" },
|
|
||||||
secondary: { main: "#F4F4F4", dark: "#e3e3e3", contrastText: "#475467" },
|
|
||||||
text: text,
|
|
||||||
background: background,
|
|
||||||
border: border,
|
|
||||||
info: {
|
|
||||||
text: text.primary,
|
|
||||||
main: text.tertiary,
|
|
||||||
bg: background.main,
|
|
||||||
light: background.main,
|
|
||||||
border: border.dark,
|
|
||||||
},
|
|
||||||
success: {
|
|
||||||
text: "#079455",
|
|
||||||
main: "#17b26a",
|
|
||||||
light: "#d4f4e1",
|
|
||||||
bg: "#ecfdf3",
|
|
||||||
},
|
|
||||||
error: {
|
|
||||||
text: "#f04438",
|
|
||||||
main: "#d32f2f",
|
|
||||||
light: "#fbd1d1",
|
|
||||||
bg: "#f9eced",
|
|
||||||
border: "#f04438",
|
|
||||||
},
|
|
||||||
warning: {
|
|
||||||
text: "#DC6803",
|
|
||||||
main: "#fdb022",
|
|
||||||
light: "#ffecbc",
|
|
||||||
bg: "#fef8ea",
|
|
||||||
border: "#fec84b",
|
|
||||||
},
|
|
||||||
percentage: {
|
|
||||||
uptimePoor: "#d32f2f",
|
|
||||||
uptimeFair: "#ec8013",
|
|
||||||
uptimeGood: "#ffb800",
|
|
||||||
uptimeExcellent: "#079455",
|
|
||||||
},
|
|
||||||
unresolved: { main: "#4e5ba6", light: "#e2eaf7", bg: "#f2f4f7" },
|
|
||||||
divider: border.light,
|
|
||||||
other: {
|
|
||||||
icon: "#667085",
|
|
||||||
line: "#d6d9dd",
|
|
||||||
fill: "#e3e3e3",
|
|
||||||
grid: "#a2a3a3",
|
|
||||||
autofill: "#e8f0fe",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
spacing: 2,
|
|
||||||
components: {
|
|
||||||
MuiCssBaseline: {
|
|
||||||
styleOverrides: {
|
|
||||||
body: {
|
|
||||||
backgroundImage:
|
|
||||||
"radial-gradient(circle, #fcfcfd, #fdfcfd, #fdfdfd, #fefdfe, #fefefe, #fefefe, #fefefe, #fefefe, #fefdfe, #fdfdfd, #fdfcfd, #fcfcfd)",
|
|
||||||
lineHeight: "inherit",
|
|
||||||
paddingLeft: "calc(100vw - 100%)",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiButton: {
|
|
||||||
defaultProps: {
|
|
||||||
disableRipple: true,
|
|
||||||
},
|
|
||||||
styleOverrides: {
|
|
||||||
root: ({ theme }) => ({
|
|
||||||
variants: [
|
|
||||||
{
|
|
||||||
props: (props) => props.variant === "group",
|
|
||||||
style: {
|
|
||||||
color: theme.palette.secondary.contrastText,
|
|
||||||
backgroundColor: theme.palette.background.main,
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
props: (props) => props.variant === "group" && props.filled === "true",
|
|
||||||
style: {
|
|
||||||
backgroundColor: theme.palette.secondary.main,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
props: (props) =>
|
|
||||||
props.variant === "contained" && props.color === "secondary",
|
|
||||||
style: {
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
fontWeight: 400,
|
|
||||||
borderRadius: 4,
|
|
||||||
boxShadow: "none",
|
|
||||||
textTransform: "none",
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
"&:hover": {
|
|
||||||
boxShadow: "none",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiIconButton: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
padding: 4,
|
|
||||||
transition: "none",
|
|
||||||
"&:hover": {
|
|
||||||
backgroundColor: background.fill,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiPaper: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
marginTop: 4,
|
|
||||||
padding: 0,
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: border.light,
|
|
||||||
borderRadius: 4,
|
|
||||||
boxShadow: shadow,
|
|
||||||
backgroundColor: background.main,
|
|
||||||
backgroundImage: "none",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiList: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
padding: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiListItemButton: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
transition: "none",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiMenuItem: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
borderRadius: 4,
|
|
||||||
backgroundColor: "inherit",
|
|
||||||
padding: "4px 6px",
|
|
||||||
color: text.secondary,
|
|
||||||
fontSize: 13,
|
|
||||||
margin: 2,
|
|
||||||
minWidth: 100,
|
|
||||||
"&:hover, &.Mui-selected, &.Mui-selected:hover, &.Mui-selected.Mui-focusVisible":
|
|
||||||
{
|
|
||||||
backgroundColor: background.fill,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiTableCell: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
borderBottomColor: border.light,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiTableHead: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
backgroundColor: background.accent,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiPagination: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
backgroundColor: background.main,
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: border.light,
|
|
||||||
"& button": {
|
|
||||||
color: text.tertiary,
|
|
||||||
borderRadius: 4,
|
|
||||||
},
|
|
||||||
"& li:first-of-type button, & li:last-of-type button": {
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: border.light,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiPaginationItem: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
"&:not(.MuiPaginationItem-ellipsis):hover, &.Mui-selected": {
|
|
||||||
backgroundColor: background.fill,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MuiSkeleton: {
|
|
||||||
styleOverrides: {
|
|
||||||
root: {
|
|
||||||
backgroundColor: "#f2f4f7",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shape: {
|
|
||||||
borderRadius: 2,
|
|
||||||
borderThick: 2,
|
|
||||||
boxShadow: shadow,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default lightTheme;
|
export default lightTheme;
|
||||||
@@ -46,6 +46,8 @@ We've just launched our [Discussions](https://github.com/bluewave-labs/bluewave-
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
Additionally, we will introduce **Docker monitoring** to track the performance and health of containerized environments.
|
||||||
|
|
||||||
**Roadmap (long term):**
|
**Roadmap (long term):**
|
||||||
|
|
||||||
- DNS monitoring
|
- DNS monitoring
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const MonitorSchema = mongoose.Schema(
|
|||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
enum: ["http", "ping", "pagespeed", "hardware"],
|
enum: ["http", "ping", "pagespeed", "hardware", "docker"],
|
||||||
},
|
},
|
||||||
url: {
|
url: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
createPageSpeedCheck,
|
createPageSpeedCheck,
|
||||||
getPageSpeedChecks,
|
|
||||||
deletePageSpeedChecksByMonitorId,
|
deletePageSpeedChecksByMonitorId,
|
||||||
} from "./modules/pageSpeedCheckModule.js";
|
} from "./modules/pageSpeedCheckModule.js";
|
||||||
|
|
||||||
@@ -212,7 +211,6 @@ export default {
|
|||||||
updateChecksTTL,
|
updateChecksTTL,
|
||||||
deleteMonitorsByUserId,
|
deleteMonitorsByUserId,
|
||||||
createPageSpeedCheck,
|
createPageSpeedCheck,
|
||||||
getPageSpeedChecks,
|
|
||||||
deletePageSpeedChecksByMonitorId,
|
deletePageSpeedChecksByMonitorId,
|
||||||
createHardwareCheck,
|
createHardwareCheck,
|
||||||
createMaintenanceWindow,
|
createMaintenanceWindow,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const SERVICE_NAME = "monitorModule";
|
|||||||
const CHECK_MODEL_LOOKUP = {
|
const CHECK_MODEL_LOOKUP = {
|
||||||
http: Check,
|
http: Check,
|
||||||
ping: Check,
|
ping: Check,
|
||||||
|
docker: Check,
|
||||||
pagespeed: PageSpeedCheck,
|
pagespeed: PageSpeedCheck,
|
||||||
hardware: HardwareCheck,
|
hardware: HardwareCheck,
|
||||||
};
|
};
|
||||||
@@ -349,7 +350,7 @@ const getMonitorStatsById = async (req) => {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (monitor.type === "http" || monitor.type === "ping") {
|
if (monitor.type === "http" || monitor.type === "ping" || monitor.type === "docker") {
|
||||||
// HTTP/PING Specific stats
|
// HTTP/PING Specific stats
|
||||||
monitorStats.periodAvgResponseTime = getAverageResponseTime(checksForDateRange);
|
monitorStats.periodAvgResponseTime = getAverageResponseTime(checksForDateRange);
|
||||||
monitorStats.periodUptime = getUptimePercentage(checksForDateRange);
|
monitorStats.periodUptime = getUptimePercentage(checksForDateRange);
|
||||||
|
|||||||
@@ -25,25 +25,6 @@ const createPageSpeedCheck = async (pageSpeedCheckData) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all PageSpeed checks for a monitor
|
|
||||||
* @async
|
|
||||||
* @param {string} monitorId
|
|
||||||
* @returns {Promise<Array<PageSpeedCheck>>}
|
|
||||||
* @throws {Error}
|
|
||||||
*/
|
|
||||||
|
|
||||||
const getPageSpeedChecks = async (monitorId) => {
|
|
||||||
try {
|
|
||||||
const pageSpeedChecks = await PageSpeedCheck.find({ monitorId });
|
|
||||||
return pageSpeedChecks;
|
|
||||||
} catch (error) {
|
|
||||||
error.service = SERVICE_NAME;
|
|
||||||
error.method = "getPageSpeedChecks";
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all PageSpeed checks for a monitor
|
* Delete all PageSpeed checks for a monitor
|
||||||
* @async
|
* @async
|
||||||
@@ -63,4 +44,4 @@ const deletePageSpeedChecksByMonitorId = async (monitorId) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export { createPageSpeedCheck, getPageSpeedChecks, deletePageSpeedChecksByMonitorId };
|
export { createPageSpeedCheck, deletePageSpeedChecksByMonitorId };
|
||||||
@@ -15,7 +15,11 @@ const SERVICE_NAME = "userModule";
|
|||||||
* @returns {Promise<UserModel>}
|
* @returns {Promise<UserModel>}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
const insertUser = async (userData, imageFile) => {
|
const insertUser = async (
|
||||||
|
userData,
|
||||||
|
imageFile,
|
||||||
|
generateAvatarImage = GenerateAvatarImage
|
||||||
|
) => {
|
||||||
try {
|
try {
|
||||||
if (imageFile) {
|
if (imageFile) {
|
||||||
// 1. Save the full size image
|
// 1. Save the full size image
|
||||||
@@ -25,7 +29,7 @@ const insertUser = async (userData, imageFile) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 2. Get the avatar sized image
|
// 2. Get the avatar sized image
|
||||||
const avatar = await GenerateAvatarImage(imageFile);
|
const avatar = await generateAvatarImage(imageFile);
|
||||||
userData.avatarImage = avatar;
|
userData.avatarImage = avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +94,12 @@ const getUserByEmail = async (email) => {
|
|||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const updateUser = async (req, res) => {
|
const updateUser = async (
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
parseBoolean = ParseBoolean,
|
||||||
|
generateAvatarImage = GenerateAvatarImage
|
||||||
|
) => {
|
||||||
const candidateUserId = req.params.userId;
|
const candidateUserId = req.params.userId;
|
||||||
try {
|
try {
|
||||||
const candidateUser = { ...req.body };
|
const candidateUser = { ...req.body };
|
||||||
@@ -98,7 +107,7 @@ const updateUser = async (req, res) => {
|
|||||||
// Handle profile image
|
// Handle profile image
|
||||||
// ******************************************
|
// ******************************************
|
||||||
|
|
||||||
if (ParseBoolean(candidateUser.deleteProfileImage) === true) {
|
if (parseBoolean(candidateUser.deleteProfileImage) === true) {
|
||||||
candidateUser.profileImage = null;
|
candidateUser.profileImage = null;
|
||||||
candidateUser.avatarImage = null;
|
candidateUser.avatarImage = null;
|
||||||
} else if (req.file) {
|
} else if (req.file) {
|
||||||
@@ -108,8 +117,8 @@ const updateUser = async (req, res) => {
|
|||||||
contentType: req.file.mimetype,
|
contentType: req.file.mimetype,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 2. Get the avaatar sized image
|
// 2. Get the avatar sized image
|
||||||
const avatar = await GenerateAvatarImage(req.file);
|
const avatar = await generateAvatarImage(req.file);
|
||||||
candidateUser.avatarImage = avatar;
|
candidateUser.avatarImage = avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +173,7 @@ const deleteUser = async (userId) => {
|
|||||||
const deleteTeam = async (teamId) => {
|
const deleteTeam = async (teamId) => {
|
||||||
try {
|
try {
|
||||||
await TeamModel.findByIdAndDelete(teamId);
|
await TeamModel.findByIdAndDelete(teamId);
|
||||||
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
error.method = "deleteTeam";
|
error.method = "deleteTeam";
|
||||||
@@ -174,6 +184,7 @@ const deleteTeam = async (teamId) => {
|
|||||||
const deleteAllOtherUsers = async () => {
|
const deleteAllOtherUsers = async () => {
|
||||||
try {
|
try {
|
||||||
await UserModel.deleteMany({ role: { $ne: "superadmin" } });
|
await UserModel.deleteMany({ role: { $ne: "superadmin" } });
|
||||||
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
error.method = "deleteAllOtherUsers";
|
error.method = "deleteAllOtherUsers";
|
||||||
|
|||||||
+3
-2
@@ -28,6 +28,7 @@ import NetworkService from "./service/networkService.js";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import ping from "ping";
|
import ping from "ping";
|
||||||
import http from "http";
|
import http from "http";
|
||||||
|
import Docker from "dockerode";
|
||||||
|
|
||||||
// Email service and dependencies
|
// Email service and dependencies
|
||||||
import EmailService from "./service/emailService.js";
|
import EmailService from "./service/emailService.js";
|
||||||
@@ -45,7 +46,7 @@ import NotificationService from "./service/notificationService.js";
|
|||||||
|
|
||||||
import db from "./db/mongo/MongoDB.js";
|
import db from "./db/mongo/MongoDB.js";
|
||||||
const SERVICE_NAME = "Server";
|
const SERVICE_NAME = "Server";
|
||||||
const SHUTDOWN_TIMEOUT = 0;
|
const SHUTDOWN_TIMEOUT = 1000;
|
||||||
|
|
||||||
let isShuttingDown = false;
|
let isShuttingDown = false;
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
@@ -130,7 +131,7 @@ const startApp = async () => {
|
|||||||
nodemailer,
|
nodemailer,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
const networkService = new NetworkService(axios, ping, logger, http);
|
const networkService = new NetworkService(axios, ping, logger, http, Docker);
|
||||||
const statusService = new StatusService(db, logger);
|
const statusService = new StatusService(db, logger);
|
||||||
const notificationService = new NotificationService(emailService, db, logger);
|
const notificationService = new NotificationService(emailService, db, logger);
|
||||||
const jobQueue = await JobQueue.createJobQueue(
|
const jobQueue = await JobQueue.createJobQueue(
|
||||||
|
|||||||
Generated
+276
@@ -14,6 +14,7 @@
|
|||||||
"bcrypt": "^5.1.1",
|
"bcrypt": "^5.1.1",
|
||||||
"bullmq": "5.25.6",
|
"bullmq": "5.25.6",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
"dockerode": "4.0.2",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"express": "^4.19.2",
|
"express": "^4.19.2",
|
||||||
"handlebars": "^4.7.8",
|
"handlebars": "^4.7.8",
|
||||||
@@ -89,6 +90,12 @@
|
|||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@balena/dockerignore": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@balena/dockerignore/-/dockerignore-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q==",
|
||||||
|
"license": "Apache-2.0"
|
||||||
|
},
|
||||||
"node_modules/@bcoe/v8-coverage": {
|
"node_modules/@bcoe/v8-coverage": {
|
||||||
"version": "0.2.3",
|
"version": "0.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
|
||||||
@@ -996,6 +1003,15 @@
|
|||||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||||
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
|
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
|
||||||
},
|
},
|
||||||
|
"node_modules/asn1": {
|
||||||
|
"version": "0.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz",
|
||||||
|
"integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"safer-buffer": "~2.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/assertion-error": {
|
"node_modules/assertion-error": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
|
||||||
@@ -1032,6 +1048,26 @@
|
|||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
|
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
|
||||||
},
|
},
|
||||||
|
"node_modules/base64-js": {
|
||||||
|
"version": "1.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||||
|
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/bcrypt": {
|
"node_modules/bcrypt": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.1.tgz",
|
||||||
@@ -1045,6 +1081,15 @@
|
|||||||
"node": ">= 10.0.0"
|
"node": ">= 10.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/bcrypt-pbkdf": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"tweetnacl": "^0.14.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/binary-extensions": {
|
"node_modules/binary-extensions": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
|
||||||
@@ -1056,6 +1101,17 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/bl": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"buffer": "^5.5.0",
|
||||||
|
"inherits": "^2.0.4",
|
||||||
|
"readable-stream": "^3.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/body-parser": {
|
"node_modules/body-parser": {
|
||||||
"version": "1.20.3",
|
"version": "1.20.3",
|
||||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
|
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
|
||||||
@@ -1152,6 +1208,30 @@
|
|||||||
"node": ">=16.20.1"
|
"node": ">=16.20.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/buffer": {
|
||||||
|
"version": "5.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
||||||
|
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"base64-js": "^1.3.1",
|
||||||
|
"ieee754": "^1.1.13"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/buffer-equal-constant-time": {
|
"node_modules/buffer-equal-constant-time": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
|
||||||
@@ -1163,6 +1243,15 @@
|
|||||||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/buildcheck": {
|
||||||
|
"version": "0.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/buildcheck/-/buildcheck-0.0.6.tgz",
|
||||||
|
"integrity": "sha512-8f9ZJCUXyT1M35Jx7MkBgmBMo3oHTTBIPLiY9xyL0pl3T5RwcPEY8cUHr5LBNfu/fk6c2T4DJZuVM/8ZZT2D2A==",
|
||||||
|
"optional": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/bullmq": {
|
"node_modules/bullmq": {
|
||||||
"version": "5.25.6",
|
"version": "5.25.6",
|
||||||
"resolved": "https://registry.npmjs.org/bullmq/-/bullmq-5.25.6.tgz",
|
"resolved": "https://registry.npmjs.org/bullmq/-/bullmq-5.25.6.tgz",
|
||||||
@@ -1708,6 +1797,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/cpu-features": {
|
||||||
|
"version": "0.0.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/cpu-features/-/cpu-features-0.0.10.tgz",
|
||||||
|
"integrity": "sha512-9IkYqtX3YHPCzoVg1Py+o9057a3i0fp7S530UWokCSaFVTc7CwXPRiOjRjBQQ18ZCNafx78YfnG+HALxtVmOGA==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"optional": true,
|
||||||
|
"dependencies": {
|
||||||
|
"buildcheck": "~0.0.6",
|
||||||
|
"nan": "^2.19.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/cron-parser": {
|
"node_modules/cron-parser": {
|
||||||
"version": "4.9.0",
|
"version": "4.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-4.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-4.9.0.tgz",
|
||||||
@@ -2014,6 +2117,58 @@
|
|||||||
"node": ">=0.3.1"
|
"node": ">=0.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/docker-modem": {
|
||||||
|
"version": "5.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/docker-modem/-/docker-modem-5.0.3.tgz",
|
||||||
|
"integrity": "sha512-89zhop5YVhcPEt5FpUFGr3cDyceGhq/F9J+ZndQ4KfqNvfbJpPMfgeixFgUj5OjCYAboElqODxY5Z1EBsSa6sg==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"debug": "^4.1.1",
|
||||||
|
"readable-stream": "^3.5.0",
|
||||||
|
"split-ca": "^1.0.1",
|
||||||
|
"ssh2": "^1.15.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/docker-modem/node_modules/debug": {
|
||||||
|
"version": "4.3.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
|
||||||
|
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"ms": "^2.1.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"supports-color": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/docker-modem/node_modules/ms": {
|
||||||
|
"version": "2.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||||
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/dockerode": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/dockerode/-/dockerode-4.0.2.tgz",
|
||||||
|
"integrity": "sha512-9wM1BVpVMFr2Pw3eJNXrYYt6DT9k0xMcsSCjtPvyQ+xa1iPg/Mo3T/gUcwI0B2cczqCeCYRPF8yFYDwtFXT0+w==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@balena/dockerignore": "^1.0.2",
|
||||||
|
"docker-modem": "^5.0.3",
|
||||||
|
"tar-fs": "~2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/dom-serializer": {
|
"node_modules/dom-serializer": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
|
||||||
@@ -2145,6 +2300,15 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/end-of-stream": {
|
||||||
|
"version": "1.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
|
||||||
|
"integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"once": "^1.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/entities": {
|
"node_modules/entities": {
|
||||||
"version": "4.5.0",
|
"version": "4.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||||
@@ -2439,6 +2603,12 @@
|
|||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fs-constants": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/fs-minipass": {
|
"node_modules/fs-minipass": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
|
||||||
@@ -2822,6 +2992,26 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/ieee754": {
|
||||||
|
"version": "1.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||||
|
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "BSD-3-Clause"
|
||||||
|
},
|
||||||
"node_modules/ignore-by-default": {
|
"node_modules/ignore-by-default": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
|
||||||
@@ -4129,6 +4319,12 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/mkdirp-classic": {
|
||||||
|
"version": "0.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
|
||||||
|
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/mocha": {
|
"node_modules/mocha": {
|
||||||
"version": "10.8.2",
|
"version": "10.8.2",
|
||||||
"resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz",
|
"resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz",
|
||||||
@@ -4503,6 +4699,13 @@
|
|||||||
"mkdirp": "bin/cmd.js"
|
"mkdirp": "bin/cmd.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/nan": {
|
||||||
|
"version": "2.22.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/nan/-/nan-2.22.0.tgz",
|
||||||
|
"integrity": "sha512-nbajikzWTMwsW+eSsNm3QwlOs7het9gGJU5dDZzRTQGk03vyBOauxgI4VakDzE0PtsGTmXPsXTbbjVhRwR5mpw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"node_modules/nanoid": {
|
"node_modules/nanoid": {
|
||||||
"version": "3.3.7",
|
"version": "3.3.7",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
|
||||||
@@ -5553,6 +5756,16 @@
|
|||||||
"integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
|
"integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/pump": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"end-of-stream": "^1.1.0",
|
||||||
|
"once": "^1.3.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/punycode": {
|
"node_modules/punycode": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||||
@@ -6046,6 +6259,29 @@
|
|||||||
"memory-pager": "^1.0.2"
|
"memory-pager": "^1.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/split-ca": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/split-ca/-/split-ca-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-Q5thBSxp5t8WPTTJQS59LrGqOZqOsrhDGDVm8azCqIBjSBd7nd9o2PM+mDulQQkh8h//4U6hFZnc/mul8t5pWQ==",
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
|
"node_modules/ssh2": {
|
||||||
|
"version": "1.16.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ssh2/-/ssh2-1.16.0.tgz",
|
||||||
|
"integrity": "sha512-r1X4KsBGedJqo7h8F5c4Ybpcr5RjyP+aWIG007uBPRjmdQWfEiVLzSK71Zji1B9sKxwaCvD8y8cwSkYrlLiRRg==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"dependencies": {
|
||||||
|
"asn1": "^0.2.6",
|
||||||
|
"bcrypt-pbkdf": "^1.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.16.0"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"cpu-features": "~0.0.10",
|
||||||
|
"nan": "^2.20.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/ssl-checker": {
|
"node_modules/ssl-checker": {
|
||||||
"version": "2.0.10",
|
"version": "2.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/ssl-checker/-/ssl-checker-2.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/ssl-checker/-/ssl-checker-2.0.10.tgz",
|
||||||
@@ -6248,6 +6484,40 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tar-fs": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-6tzWDMeroL87uF/+lin46k+Q+46rAJ0SyPGz7OW7wTgblI273hsBqk2C1j0/xNadNLKDTUL9BukSjB7cwgmlPA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"chownr": "^1.1.1",
|
||||||
|
"mkdirp-classic": "^0.5.2",
|
||||||
|
"pump": "^3.0.0",
|
||||||
|
"tar-stream": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tar-fs/node_modules/chownr": {
|
||||||
|
"version": "1.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
|
||||||
|
"integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==",
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
|
"node_modules/tar-stream": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"bl": "^4.0.3",
|
||||||
|
"end-of-stream": "^1.4.1",
|
||||||
|
"fs-constants": "^1.0.0",
|
||||||
|
"inherits": "^2.0.3",
|
||||||
|
"readable-stream": "^3.1.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/text-hex": {
|
"node_modules/text-hex": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
|
||||||
@@ -6311,6 +6581,12 @@
|
|||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz",
|
||||||
"integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ=="
|
"integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ=="
|
||||||
},
|
},
|
||||||
|
"node_modules/tweetnacl": {
|
||||||
|
"version": "0.14.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
|
||||||
|
"integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==",
|
||||||
|
"license": "Unlicense"
|
||||||
|
},
|
||||||
"node_modules/type-detect": {
|
"node_modules/type-detect": {
|
||||||
"version": "4.0.8",
|
"version": "4.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"bcrypt": "^5.1.1",
|
"bcrypt": "^5.1.1",
|
||||||
"bullmq": "5.25.6",
|
"bullmq": "5.25.6",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
"dockerode": "4.0.2",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"express": "^4.19.2",
|
"express": "^4.19.2",
|
||||||
"handlebars": "^4.7.8",
|
"handlebars": "^4.7.8",
|
||||||
|
|||||||
@@ -180,8 +180,8 @@ class JobQueue {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error({
|
this.logger.error({
|
||||||
message: error.message,
|
message: error.message,
|
||||||
service: SERVICE_NAME,
|
service: error.service ?? SERVICE_NAME,
|
||||||
method: "createWorker",
|
method: error.method ?? "createJobHandler",
|
||||||
details: `Error processing job ${job.id}: ${error.message}`,
|
details: `Error processing job ${job.id}: ${error.message}`,
|
||||||
stack: error.stack,
|
stack: error.stack,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ import { errorMessages, successMessages } from "../utils/messages.js";
|
|||||||
* @param {Object} http - The HTTP utility for network operations.
|
* @param {Object} http - The HTTP utility for network operations.
|
||||||
*/
|
*/
|
||||||
class NetworkService {
|
class NetworkService {
|
||||||
constructor(axios, ping, logger, http) {
|
constructor(axios, ping, logger, http, Docker) {
|
||||||
this.TYPE_PING = "ping";
|
this.TYPE_PING = "ping";
|
||||||
this.TYPE_HTTP = "http";
|
this.TYPE_HTTP = "http";
|
||||||
this.TYPE_PAGESPEED = "pagespeed";
|
this.TYPE_PAGESPEED = "pagespeed";
|
||||||
this.TYPE_HARDWARE = "hardware";
|
this.TYPE_HARDWARE = "hardware";
|
||||||
|
this.TYPE_DOCKER = "docker";
|
||||||
this.SERVICE_NAME = "NetworkService";
|
this.SERVICE_NAME = "NetworkService";
|
||||||
this.NETWORK_ERROR = 5000;
|
this.NETWORK_ERROR = 5000;
|
||||||
this.PING_ERROR = 5001;
|
this.PING_ERROR = 5001;
|
||||||
@@ -20,6 +21,7 @@ class NetworkService {
|
|||||||
this.ping = ping;
|
this.ping = ping;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.http = http;
|
this.http = http;
|
||||||
|
this.Docker = Docker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,28 +64,34 @@ class NetworkService {
|
|||||||
* @property {string} message - The message indicating the result of the ping request.
|
* @property {string} message - The message indicating the result of the ping request.
|
||||||
*/
|
*/
|
||||||
async requestPing(job) {
|
async requestPing(job) {
|
||||||
const url = job.data.url;
|
try {
|
||||||
const { response, responseTime, error } = await this.timeRequest(() =>
|
const url = job.data.url;
|
||||||
this.ping.promise.probe(url)
|
const { response, responseTime, error } = await this.timeRequest(() =>
|
||||||
);
|
this.ping.promise.probe(url)
|
||||||
|
);
|
||||||
|
|
||||||
const pingResponse = {
|
const pingResponse = {
|
||||||
monitorId: job.data._id,
|
monitorId: job.data._id,
|
||||||
type: "ping",
|
type: "ping",
|
||||||
responseTime,
|
responseTime,
|
||||||
payload: response,
|
payload: response,
|
||||||
};
|
};
|
||||||
if (error) {
|
if (error) {
|
||||||
pingResponse.status = false;
|
pingResponse.status = false;
|
||||||
pingResponse.code = this.PING_ERROR;
|
pingResponse.code = this.PING_ERROR;
|
||||||
pingResponse.message = errorMessages.PING_CANNOT_RESOLVE;
|
pingResponse.message = errorMessages.PING_CANNOT_RESOLVE;
|
||||||
|
return pingResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
pingResponse.code = 200;
|
||||||
|
pingResponse.status = response.alive;
|
||||||
|
pingResponse.message = successMessages.PING_SUCCESS;
|
||||||
return pingResponse;
|
return pingResponse;
|
||||||
|
} catch (error) {
|
||||||
|
error.service = this.SERVICE_NAME;
|
||||||
|
error.method = "requestPing";
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pingResponse.code = 200;
|
|
||||||
pingResponse.status = response.alive;
|
|
||||||
pingResponse.message = successMessages.PING_SUCCESS;
|
|
||||||
return pingResponse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,34 +112,40 @@ class NetworkService {
|
|||||||
* @property {string} message - The message indicating the result of the HTTP request.
|
* @property {string} message - The message indicating the result of the HTTP request.
|
||||||
*/
|
*/
|
||||||
async requestHttp(job) {
|
async requestHttp(job) {
|
||||||
const url = job.data.url;
|
try {
|
||||||
const config = {};
|
const url = job.data.url;
|
||||||
|
const config = {};
|
||||||
|
|
||||||
job.data.secret !== undefined &&
|
job.data.secret !== undefined &&
|
||||||
(config.headers = { Authorization: `Bearer ${job.data.secret}` });
|
(config.headers = { Authorization: `Bearer ${job.data.secret}` });
|
||||||
|
|
||||||
const { response, responseTime, error } = await this.timeRequest(() =>
|
const { response, responseTime, error } = await this.timeRequest(() =>
|
||||||
this.axios.get(url, config)
|
this.axios.get(url, config)
|
||||||
);
|
);
|
||||||
|
|
||||||
const httpResponse = {
|
const httpResponse = {
|
||||||
monitorId: job.data._id,
|
monitorId: job.data._id,
|
||||||
type: job.data.type,
|
type: job.data.type,
|
||||||
responseTime,
|
responseTime,
|
||||||
payload: response?.data,
|
payload: response?.data,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
const code = error.response?.status || this.NETWORK_ERROR;
|
const code = error.response?.status || this.NETWORK_ERROR;
|
||||||
httpResponse.code = code;
|
httpResponse.code = code;
|
||||||
httpResponse.status = false;
|
httpResponse.status = false;
|
||||||
httpResponse.message = this.http.STATUS_CODES[code] || "Network Error";
|
httpResponse.message = this.http.STATUS_CODES[code] || "Network Error";
|
||||||
|
return httpResponse;
|
||||||
|
}
|
||||||
|
httpResponse.status = true;
|
||||||
|
httpResponse.code = response.status;
|
||||||
|
httpResponse.message = this.http.STATUS_CODES[response.status];
|
||||||
return httpResponse;
|
return httpResponse;
|
||||||
|
} catch (error) {
|
||||||
|
error.service = this.SERVICE_NAME;
|
||||||
|
error.method = "requestHttp";
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
httpResponse.status = true;
|
|
||||||
httpResponse.code = response.status;
|
|
||||||
httpResponse.message = this.http.STATUS_CODES[response.status];
|
|
||||||
return httpResponse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,15 +165,114 @@ class NetworkService {
|
|||||||
* @property {string} message - The message indicating the result of the PageSpeed request.
|
* @property {string} message - The message indicating the result of the PageSpeed request.
|
||||||
*/
|
*/
|
||||||
async requestPagespeed(job) {
|
async requestPagespeed(job) {
|
||||||
const url = job.data.url;
|
try {
|
||||||
const updatedJob = { ...job };
|
const url = job.data.url;
|
||||||
const pagespeedUrl = `https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&category=seo&category=accessibility&category=best-practices&category=performance`;
|
const updatedJob = { ...job };
|
||||||
updatedJob.data.url = pagespeedUrl;
|
const pagespeedUrl = `https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&category=seo&category=accessibility&category=best-practices&category=performance`;
|
||||||
return this.requestHttp(updatedJob);
|
updatedJob.data.url = pagespeedUrl;
|
||||||
|
return await this.requestHttp(updatedJob);
|
||||||
|
} catch (error) {
|
||||||
|
error.service = this.SERVICE_NAME;
|
||||||
|
error.method = "requestPagespeed";
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an HTTP request to check hardware status and returns the response.
|
||||||
|
*
|
||||||
|
* @param {Object} job - The job object containing the data for the hardware request.
|
||||||
|
* @param {Object} job.data - The data object within the job.
|
||||||
|
* @param {string} job.data.url - The URL to send the hardware status request to.
|
||||||
|
* @param {string} job.data._id - The monitor ID for the hardware request.
|
||||||
|
* @param {string} job.data.type - The type of request, which is "hardware".
|
||||||
|
* @returns {Promise<Object>} An object containing the hardware status response details.
|
||||||
|
* @property {string} monitorId - The monitor ID for the hardware request.
|
||||||
|
* @property {string} type - The type of request ("hardware").
|
||||||
|
* @property {number} responseTime - The time taken for the request to complete, in milliseconds.
|
||||||
|
* @property {Object} payload - The response payload from the hardware status request.
|
||||||
|
* @property {boolean} status - The status of the request (true if successful, false otherwise).
|
||||||
|
* @property {number} code - The response code (200 if successful, error code otherwise).
|
||||||
|
* @property {string} message - The message indicating the result of the hardware status request.
|
||||||
|
*/
|
||||||
async requestHardware(job) {
|
async requestHardware(job) {
|
||||||
return this.requestHttp(job);
|
try {
|
||||||
|
return await this.requestHttp(job);
|
||||||
|
} catch (error) {
|
||||||
|
error.service = this.SERVICE_NAME;
|
||||||
|
error.method = "requestHardware";
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a request to inspect a Docker container and returns its status.
|
||||||
|
*
|
||||||
|
* @param {Object} job - The job object containing the data for the Docker request.
|
||||||
|
* @param {Object} job.data - The data object within the job.
|
||||||
|
* @param {string} job.data.url - The container ID or name to inspect.
|
||||||
|
* @param {string} job.data._id - The monitor ID for the Docker request.
|
||||||
|
* @param {string} job.data.type - The type of request, which is "docker".
|
||||||
|
* @returns {Promise<Object>} An object containing the Docker container status details.
|
||||||
|
* @property {string} monitorId - The monitor ID for the Docker request.
|
||||||
|
* @property {string} type - The type of request ("docker").
|
||||||
|
* @property {number} responseTime - The time taken for the Docker inspection to complete, in milliseconds.
|
||||||
|
* @property {boolean} status - The status of the container (true if running, false otherwise).
|
||||||
|
* @property {number} code - The response code (200 if successful, error code otherwise).
|
||||||
|
* @property {string} message - The message indicating the result of the Docker inspection.
|
||||||
|
*/
|
||||||
|
async requestDocker(job) {
|
||||||
|
try {
|
||||||
|
const docker = new this.Docker({
|
||||||
|
socketPath: "/var/run/docker.sock",
|
||||||
|
handleError: true, // Enable error handling
|
||||||
|
});
|
||||||
|
|
||||||
|
const containers = await docker.listContainers({ all: true });
|
||||||
|
const containerExists = containers.some((c) => c.Id.startsWith(job.data.url));
|
||||||
|
if (!containerExists) {
|
||||||
|
throw new Error(errorMessages.DOCKER_NOT_FOUND);
|
||||||
|
}
|
||||||
|
const container = docker.getContainer(job.data.url);
|
||||||
|
|
||||||
|
const { response, responseTime, error } = await this.timeRequest(() =>
|
||||||
|
container.inspect()
|
||||||
|
);
|
||||||
|
|
||||||
|
const dockerResponse = {
|
||||||
|
monitorId: job.data._id,
|
||||||
|
type: job.data.type,
|
||||||
|
responseTime,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
dockerResponse.status = false;
|
||||||
|
dockerResponse.code = error.statusCode || this.NETWORK_ERROR;
|
||||||
|
dockerResponse.message = error.reason || errorMessages.DOCKER_FAIL;
|
||||||
|
return dockerResponse;
|
||||||
|
}
|
||||||
|
dockerResponse.status = response?.State?.Status === "running" ? true : false;
|
||||||
|
dockerResponse.code = 200;
|
||||||
|
dockerResponse.message = successMessages.DOCKER_SUCCESS;
|
||||||
|
return dockerResponse;
|
||||||
|
} catch (error) {
|
||||||
|
error.service = this.SERVICE_NAME;
|
||||||
|
error.method = "requestDocker";
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles unsupported job types by throwing an error with details.
|
||||||
|
*
|
||||||
|
* @param {string} type - The unsupported job type that was provided
|
||||||
|
* @throws {Error} An error with service name, method name and unsupported type message
|
||||||
|
*/
|
||||||
|
handleUnsupportedType(type) {
|
||||||
|
const err = new Error(`Unsupported type: ${type}`);
|
||||||
|
err.service = this.SERVICE_NAME;
|
||||||
|
err.method = "getStatus";
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,7 +285,8 @@ class NetworkService {
|
|||||||
* @throws {Error} Throws an error if the job type is unsupported.
|
* @throws {Error} Throws an error if the job type is unsupported.
|
||||||
*/
|
*/
|
||||||
async getStatus(job) {
|
async getStatus(job) {
|
||||||
switch (job.data.type) {
|
const type = job?.data?.type ?? "unknown";
|
||||||
|
switch (type) {
|
||||||
case this.TYPE_PING:
|
case this.TYPE_PING:
|
||||||
return await this.requestPing(job);
|
return await this.requestPing(job);
|
||||||
case this.TYPE_HTTP:
|
case this.TYPE_HTTP:
|
||||||
@@ -181,13 +295,10 @@ class NetworkService {
|
|||||||
return await this.requestPagespeed(job);
|
return await this.requestPagespeed(job);
|
||||||
case this.TYPE_HARDWARE:
|
case this.TYPE_HARDWARE:
|
||||||
return await this.requestHardware(job);
|
return await this.requestHardware(job);
|
||||||
|
case this.TYPE_DOCKER:
|
||||||
|
return await this.requestDocker(job);
|
||||||
default:
|
default:
|
||||||
this.logger.error({
|
return this.handleUnsupportedType(type);
|
||||||
message: `Unsupported type: ${job.data.type}`,
|
|
||||||
service: this.SERVICE_NAME,
|
|
||||||
method: "getStatus",
|
|
||||||
});
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ class StatusService {
|
|||||||
ping: this.db.createCheck,
|
ping: this.db.createCheck,
|
||||||
pagespeed: this.db.createPageSpeedCheck,
|
pagespeed: this.db.createPageSpeedCheck,
|
||||||
hardware: this.db.createHardwareCheck,
|
hardware: this.db.createHardwareCheck,
|
||||||
|
docker: this.db.createCheck,
|
||||||
};
|
};
|
||||||
const operation = operationMap[networkResponse.type];
|
const operation = operationMap[networkResponse.type];
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import sinon from "sinon";
|
||||||
|
import HardwareCheck from "../../db/models/HardwareCheck.js";
|
||||||
|
import { createHardwareCheck } from "../../db/mongo/modules/hardwareCheckModule.js";
|
||||||
|
|
||||||
|
const mockHardwareCheck = {
|
||||||
|
data: {
|
||||||
|
cpu: {
|
||||||
|
physical_core: 4,
|
||||||
|
logical_core: 8,
|
||||||
|
frequency: 4800,
|
||||||
|
current_frequency: 1411,
|
||||||
|
temperature: [45, 50, 46, 47, 45, 50, 46, 47],
|
||||||
|
free_percent: 0.8552990910595134,
|
||||||
|
usage_percent: 0.14470090894048657,
|
||||||
|
},
|
||||||
|
memory: {
|
||||||
|
total_bytes: 16467628032,
|
||||||
|
available_bytes: 7895044096,
|
||||||
|
used_bytes: 6599561216,
|
||||||
|
usage_percent: 0.4008,
|
||||||
|
},
|
||||||
|
disk: [
|
||||||
|
{
|
||||||
|
read_speed_bytes: null,
|
||||||
|
write_speed_bytes: null,
|
||||||
|
total_bytes: 931258499072,
|
||||||
|
free_bytes: 737097256960,
|
||||||
|
usage_percent: 0.1661,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
host: {
|
||||||
|
os: "linux",
|
||||||
|
platform: "ubuntu",
|
||||||
|
kernel_version: "6.8.0-48-generic",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
metric: ["cpu.temperature"],
|
||||||
|
err: "unable to read CPU temperature",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("HardwareCheckModule", () => {
|
||||||
|
let hardwareCheckSaveStub;
|
||||||
|
beforeEach(() => {
|
||||||
|
hardwareCheckSaveStub = sinon.stub(HardwareCheck.prototype, "save");
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("createHardwareCheck", () => {
|
||||||
|
it("should return a hardware check", async () => {
|
||||||
|
hardwareCheckSaveStub.resolves(mockHardwareCheck);
|
||||||
|
const hardwareCheck = await createHardwareCheck({});
|
||||||
|
expect(hardwareCheck).to.exist;
|
||||||
|
expect(hardwareCheck).to.deep.equal(mockHardwareCheck);
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
hardwareCheckSaveStub.rejects(err);
|
||||||
|
try {
|
||||||
|
await createHardwareCheck({});
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import sinon from "sinon";
|
||||||
|
import PageSpeedCheck from "../../db/models/PageSpeedCheck.js";
|
||||||
|
import {
|
||||||
|
createPageSpeedCheck,
|
||||||
|
deletePageSpeedChecksByMonitorId,
|
||||||
|
} from "../../db/mongo/modules/pageSpeedCheckModule.js";
|
||||||
|
|
||||||
|
const mockPageSpeedCheck = {
|
||||||
|
monitorId: "monitorId",
|
||||||
|
bestPractices: 1,
|
||||||
|
seo: 1,
|
||||||
|
performance: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockDeletedResult = { deletedCount: 1 };
|
||||||
|
|
||||||
|
describe("pageSpeedCheckModule", () => {
|
||||||
|
let pageSpeedCheckSaveStub, pageSpeedCheckDeleteManyStub;
|
||||||
|
beforeEach(() => {
|
||||||
|
pageSpeedCheckSaveStub = sinon.stub(PageSpeedCheck.prototype, "save");
|
||||||
|
pageSpeedCheckDeleteManyStub = sinon.stub(PageSpeedCheck, "deleteMany");
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("createPageSpeedCheck", () => {
|
||||||
|
it("should return a page speed check", async () => {
|
||||||
|
pageSpeedCheckSaveStub.resolves(mockPageSpeedCheck);
|
||||||
|
const pageSpeedCheck = await createPageSpeedCheck(mockPageSpeedCheck);
|
||||||
|
expect(pageSpeedCheck).to.deep.equal(mockPageSpeedCheck);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
pageSpeedCheckSaveStub.rejects(err);
|
||||||
|
try {
|
||||||
|
await expect(createPageSpeedCheck(mockPageSpeedCheck));
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("deletePageSpeedChecksByMonitorId", () => {
|
||||||
|
it("should return the number of deleted checks", async () => {
|
||||||
|
pageSpeedCheckDeleteManyStub.resolves(mockDeletedResult);
|
||||||
|
const result = await deletePageSpeedChecksByMonitorId("monitorId");
|
||||||
|
expect(result).to.deep.equal(mockDeletedResult.deletedCount);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
pageSpeedCheckDeleteManyStub.rejects(err);
|
||||||
|
try {
|
||||||
|
await expect(deletePageSpeedChecksByMonitorId("monitorId"));
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
import sinon from "sinon";
|
||||||
|
import RecoveryToken from "../../db/models/RecoveryToken.js";
|
||||||
|
import User from "../../db/models/User.js";
|
||||||
|
import {
|
||||||
|
requestRecoveryToken,
|
||||||
|
validateRecoveryToken,
|
||||||
|
resetPassword,
|
||||||
|
} from "../../db/mongo/modules/recoveryModule.js";
|
||||||
|
import { errorMessages } from "../../utils/messages.js";
|
||||||
|
|
||||||
|
const mockRecoveryToken = {
|
||||||
|
email: "test@test.com",
|
||||||
|
token: "1234567890",
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockUser = {
|
||||||
|
email: "test@test.com",
|
||||||
|
password: "oldPassword",
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockUserWithoutPassword = {
|
||||||
|
email: "test@test.com",
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create a query builder that logs
|
||||||
|
const createQueryChain = (finalResult, comparePasswordResult = false) => ({
|
||||||
|
select: () => ({
|
||||||
|
select: async () => {
|
||||||
|
if (finalResult === mockUser) {
|
||||||
|
// Return a new object with all required methods
|
||||||
|
return {
|
||||||
|
email: "test@test.com",
|
||||||
|
password: "oldPassword",
|
||||||
|
comparePassword: sinon.stub().resolves(comparePasswordResult),
|
||||||
|
save: sinon.stub().resolves(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return finalResult;
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
// Add methods to the top level too
|
||||||
|
comparePassword: sinon.stub().resolves(comparePasswordResult),
|
||||||
|
save: sinon.stub().resolves(),
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("recoveryModule", () => {
|
||||||
|
let deleteManyStub,
|
||||||
|
saveStub,
|
||||||
|
findOneStub,
|
||||||
|
userCompareStub,
|
||||||
|
userSaveStub,
|
||||||
|
userFindOneStub;
|
||||||
|
let req, res;
|
||||||
|
beforeEach(() => {
|
||||||
|
req = {
|
||||||
|
body: { email: "test@test.com" },
|
||||||
|
};
|
||||||
|
deleteManyStub = sinon.stub(RecoveryToken, "deleteMany");
|
||||||
|
saveStub = sinon.stub(RecoveryToken.prototype, "save");
|
||||||
|
findOneStub = sinon.stub(RecoveryToken, "findOne");
|
||||||
|
userCompareStub = sinon.stub(User.prototype, "comparePassword");
|
||||||
|
userSaveStub = sinon.stub(User.prototype, "save");
|
||||||
|
userFindOneStub = sinon.stub().resolves();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("requestRecoveryToken", () => {
|
||||||
|
it("should return a recovery token", async () => {
|
||||||
|
deleteManyStub.resolves();
|
||||||
|
saveStub.resolves(mockRecoveryToken);
|
||||||
|
const result = await requestRecoveryToken(req, res);
|
||||||
|
expect(result.email).to.equal(mockRecoveryToken.email);
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("Test error");
|
||||||
|
deleteManyStub.rejects(err);
|
||||||
|
try {
|
||||||
|
await requestRecoveryToken(req, res);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("validateRecoveryToken", () => {
|
||||||
|
it("should return a recovery token if found", async () => {
|
||||||
|
findOneStub.resolves(mockRecoveryToken);
|
||||||
|
const result = await validateRecoveryToken(req, res);
|
||||||
|
expect(result).to.deep.equal(mockRecoveryToken);
|
||||||
|
});
|
||||||
|
it("should thrown an error if a token is not found", async () => {
|
||||||
|
findOneStub.resolves(null);
|
||||||
|
try {
|
||||||
|
await validateRecoveryToken(req, res);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.message).to.equal(errorMessages.DB_TOKEN_NOT_FOUND);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("should handle DB errors", async () => {
|
||||||
|
const err = new Error("Test error");
|
||||||
|
findOneStub.rejects(err);
|
||||||
|
try {
|
||||||
|
await validateRecoveryToken(req, res);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("resetPassword", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
req.body = {
|
||||||
|
password: "test",
|
||||||
|
newPassword: "test1",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should thrown an error if a recovery token is not found", async () => {
|
||||||
|
findOneStub.resolves(null);
|
||||||
|
try {
|
||||||
|
await resetPassword(req, res);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.message).to.equal(errorMessages.DB_TOKEN_NOT_FOUND);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("should throw an error if a user is not found", async () => {
|
||||||
|
findOneStub.resolves(mockRecoveryToken);
|
||||||
|
userFindOneStub = sinon.stub(User, "findOne").resolves(null);
|
||||||
|
try {
|
||||||
|
await resetPassword(req, res);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.message).to.equal(errorMessages.DB_USER_NOT_FOUND);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("should throw an error if the passwords match", async () => {
|
||||||
|
findOneStub.resolves(mockRecoveryToken);
|
||||||
|
saveStub.resolves();
|
||||||
|
userFindOneStub = sinon
|
||||||
|
.stub(User, "findOne")
|
||||||
|
.returns(createQueryChain(mockUser, true));
|
||||||
|
try {
|
||||||
|
await resetPassword(req, res);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.message).to.equal(errorMessages.DB_RESET_PASSWORD_BAD_MATCH);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("should return a user without password if successful", async () => {
|
||||||
|
findOneStub.resolves(mockRecoveryToken);
|
||||||
|
saveStub.resolves();
|
||||||
|
userFindOneStub = sinon
|
||||||
|
.stub(User, "findOne")
|
||||||
|
.returns(createQueryChain(mockUser)) // First call will resolve to mockUser
|
||||||
|
.onSecondCall()
|
||||||
|
.returns(createQueryChain(mockUserWithoutPassword));
|
||||||
|
const result = await resetPassword(req, res);
|
||||||
|
expect(result).to.deep.equal(mockUserWithoutPassword);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import sinon from "sinon";
|
||||||
|
import {
|
||||||
|
getAppSettings,
|
||||||
|
updateAppSettings,
|
||||||
|
} from "../../db/mongo/modules/settingsModule.js";
|
||||||
|
import AppSettings from "../../db/models/AppSettings.js";
|
||||||
|
|
||||||
|
const mockAppSettings = {
|
||||||
|
appName: "Test App",
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("SettingsModule", () => {
|
||||||
|
let appSettingsFindOneStub, appSettingsFindOneAndUpdateStub;
|
||||||
|
beforeEach(() => {
|
||||||
|
appSettingsFindOneStub = sinon.stub(AppSettings, "findOne");
|
||||||
|
appSettingsFindOneAndUpdateStub = sinon.stub(AppSettings, "findOneAndUpdate");
|
||||||
|
});
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("getAppSettings", () => {
|
||||||
|
it("should return app settings", async () => {
|
||||||
|
appSettingsFindOneStub.resolves(mockAppSettings);
|
||||||
|
const result = await getAppSettings();
|
||||||
|
expect(result).to.deep.equal(mockAppSettings);
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("Test error");
|
||||||
|
appSettingsFindOneStub.throws(err);
|
||||||
|
try {
|
||||||
|
await getAppSettings();
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("updateAppSettings", () => {
|
||||||
|
it("should update app settings", async () => {
|
||||||
|
appSettingsFindOneAndUpdateStub.resolves(mockAppSettings);
|
||||||
|
const result = await updateAppSettings(mockAppSettings);
|
||||||
|
expect(result).to.deep.equal(mockAppSettings);
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("Test error");
|
||||||
|
appSettingsFindOneAndUpdateStub.throws(err);
|
||||||
|
try {
|
||||||
|
await updateAppSettings(mockAppSettings);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,286 @@
|
|||||||
|
import sinon from "sinon";
|
||||||
|
import UserModel from "../../db/models/User.js";
|
||||||
|
import TeamModel from "../../db/models/Team.js";
|
||||||
|
import {
|
||||||
|
insertUser,
|
||||||
|
getUserByEmail,
|
||||||
|
updateUser,
|
||||||
|
deleteUser,
|
||||||
|
deleteTeam,
|
||||||
|
deleteAllOtherUsers,
|
||||||
|
getAllUsers,
|
||||||
|
logoutUser,
|
||||||
|
} from "../../db/mongo/modules/userModule.js";
|
||||||
|
import { errorMessages } from "../../utils/messages.js";
|
||||||
|
|
||||||
|
const mockUser = {
|
||||||
|
email: "test@test.com",
|
||||||
|
password: "password",
|
||||||
|
role: ["user"],
|
||||||
|
};
|
||||||
|
const mockSuperUser = {
|
||||||
|
email: "test@test.com",
|
||||||
|
password: "password",
|
||||||
|
role: ["superadmin"],
|
||||||
|
};
|
||||||
|
const imageFile = {
|
||||||
|
image: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("userModule", () => {
|
||||||
|
let teamSaveStub,
|
||||||
|
teamFindByIdAndDeleteStub,
|
||||||
|
userSaveStub,
|
||||||
|
userFindStub,
|
||||||
|
userFindOneStub,
|
||||||
|
userFindByIdAndUpdateStub,
|
||||||
|
userFindByIdAndDeleteStub,
|
||||||
|
userDeleteManyStub,
|
||||||
|
userUpdateOneStub,
|
||||||
|
generateAvatarImageStub,
|
||||||
|
parseBooleanStub;
|
||||||
|
beforeEach(() => {
|
||||||
|
teamSaveStub = sinon.stub(TeamModel.prototype, "save");
|
||||||
|
teamFindByIdAndDeleteStub = sinon.stub(TeamModel, "findByIdAndDelete");
|
||||||
|
userSaveStub = sinon.stub(UserModel.prototype, "save");
|
||||||
|
userFindStub = sinon.stub(UserModel, "find");
|
||||||
|
userFindOneStub = sinon.stub(UserModel, "findOne");
|
||||||
|
userFindByIdAndUpdateStub = sinon.stub(UserModel, "findByIdAndUpdate");
|
||||||
|
userFindByIdAndDeleteStub = sinon.stub(UserModel, "findByIdAndDelete");
|
||||||
|
userDeleteManyStub = sinon.stub(UserModel, "deleteMany");
|
||||||
|
userUpdateOneStub = sinon.stub(UserModel, "updateOne");
|
||||||
|
generateAvatarImageStub = sinon.stub().resolves({ image: 2 });
|
||||||
|
parseBooleanStub = sinon.stub().returns(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("insertUser", () => {
|
||||||
|
it("should insert a regular user", async () => {
|
||||||
|
userSaveStub.resolves(mockUser);
|
||||||
|
userFindOneStub.returns({
|
||||||
|
select: sinon.stub().returns({
|
||||||
|
select: sinon.stub().resolves(mockUser),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const result = await insertUser(mockUser, imageFile, generateAvatarImageStub);
|
||||||
|
expect(result).to.deep.equal(mockUser);
|
||||||
|
});
|
||||||
|
it("should insert a superadmin user", async () => {
|
||||||
|
userSaveStub.resolves(mockSuperUser);
|
||||||
|
userFindOneStub.returns({
|
||||||
|
select: sinon.stub().returns({
|
||||||
|
select: sinon.stub().resolves(mockSuperUser),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const result = await insertUser(mockSuperUser, imageFile, generateAvatarImageStub);
|
||||||
|
expect(result).to.deep.equal(mockSuperUser);
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
userSaveStub.rejects(err);
|
||||||
|
try {
|
||||||
|
await insertUser(mockUser, imageFile, generateAvatarImageStub);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("should handle a duplicate key error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
err.code = 11000;
|
||||||
|
userSaveStub.rejects(err);
|
||||||
|
try {
|
||||||
|
await insertUser(mockUser, imageFile, generateAvatarImageStub);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("getUserByEmail", () => {
|
||||||
|
it("should return a user", async () => {
|
||||||
|
userFindOneStub.returns({
|
||||||
|
select: sinon.stub().resolves(mockUser),
|
||||||
|
});
|
||||||
|
const result = await getUserByEmail(mockUser.email);
|
||||||
|
expect(result).to.deep.equal(mockUser);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("getUserByEmail", () => {
|
||||||
|
it("throw an error if a user is not found", async () => {
|
||||||
|
userFindOneStub.returns({
|
||||||
|
select: sinon.stub().resolves(null),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await getUserByEmail(mockUser.email);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.message).to.equal(errorMessages.DB_USER_NOT_FOUND);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("updateUser", () => {
|
||||||
|
let req, res;
|
||||||
|
beforeEach(() => {
|
||||||
|
req = {
|
||||||
|
params: {
|
||||||
|
userId: "testId",
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
deleteProfileImage: "false",
|
||||||
|
email: "test@test.com",
|
||||||
|
},
|
||||||
|
file: {
|
||||||
|
buffer: "test",
|
||||||
|
mimetype: "test",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
res = {};
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {});
|
||||||
|
it("should update a user", async () => {
|
||||||
|
parseBooleanStub.returns(false);
|
||||||
|
userFindByIdAndUpdateStub.returns({
|
||||||
|
select: sinon.stub().returns({
|
||||||
|
select: sinon.stub().resolves(mockUser),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const result = await updateUser(
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
parseBooleanStub,
|
||||||
|
generateAvatarImageStub
|
||||||
|
);
|
||||||
|
expect(result).to.deep.equal(mockUser);
|
||||||
|
});
|
||||||
|
it("should delete a user profile image", async () => {
|
||||||
|
req.body.deleteProfileImage = "true";
|
||||||
|
userFindByIdAndUpdateStub.returns({
|
||||||
|
select: sinon.stub().returns({
|
||||||
|
select: sinon.stub().resolves(mockUser),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const result = await updateUser(
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
parseBooleanStub,
|
||||||
|
generateAvatarImageStub
|
||||||
|
);
|
||||||
|
expect(result).to.deep.equal(mockUser);
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
userFindByIdAndUpdateStub.throws(err);
|
||||||
|
try {
|
||||||
|
await updateUser(req, res, parseBooleanStub, generateAvatarImageStub);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("deleteUser", async () => {
|
||||||
|
it("should return a deleted user", async () => {
|
||||||
|
userFindByIdAndDeleteStub.resolves(mockUser);
|
||||||
|
const result = await deleteUser("testId");
|
||||||
|
expect(result).to.deep.equal(mockUser);
|
||||||
|
});
|
||||||
|
it("should throw an error if a user is not found", async () => {
|
||||||
|
try {
|
||||||
|
await deleteUser("testId");
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.message).to.equal(errorMessages.DB_USER_NOT_FOUND);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
userFindByIdAndDeleteStub.throws(err);
|
||||||
|
try {
|
||||||
|
await deleteUser("testId");
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("deleteTeam", () => {
|
||||||
|
it("should return true if team deleted", async () => {
|
||||||
|
teamFindByIdAndDeleteStub.resolves();
|
||||||
|
const result = await deleteTeam("testId");
|
||||||
|
expect(result).to.equal(true);
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
teamFindByIdAndDeleteStub.throws(err);
|
||||||
|
try {
|
||||||
|
await deleteTeam("testId");
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("deleteAllOtherUsers", () => {
|
||||||
|
it("should return true if all other users deleted", async () => {
|
||||||
|
userDeleteManyStub.resolves(true);
|
||||||
|
const result = await deleteAllOtherUsers();
|
||||||
|
expect(result).to.equal(true);
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
userDeleteManyStub.throws(err);
|
||||||
|
try {
|
||||||
|
await deleteAllOtherUsers();
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("getAllUsers", () => {
|
||||||
|
it("should return all users", async () => {
|
||||||
|
userFindStub.returns({
|
||||||
|
select: sinon.stub().returns({
|
||||||
|
select: sinon.stub().resolves([mockUser]),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const result = await getAllUsers();
|
||||||
|
expect(result).to.deep.equal([mockUser]);
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
userFindStub.throws(err);
|
||||||
|
try {
|
||||||
|
await getAllUsers();
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("logoutUser", async () => {
|
||||||
|
it("should return true if user logged out", async () => {
|
||||||
|
userUpdateOneStub.resolves(true);
|
||||||
|
const result = await logoutUser("testId");
|
||||||
|
expect(result).to.equal(true);
|
||||||
|
});
|
||||||
|
it("should handle an error", async () => {
|
||||||
|
const err = new Error("test error");
|
||||||
|
userUpdateOneStub.throws(err);
|
||||||
|
try {
|
||||||
|
await logoutUser("testId");
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error).to.deep.equal(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -30,6 +30,14 @@ class QueueStub {
|
|||||||
async getJobs() {
|
async getJobs() {
|
||||||
return this.jobs;
|
return this.jobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async pause() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async obliterate() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkerStub {
|
class WorkerStub {
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import sinon from "sinon";
|
|||||||
import NetworkService from "../../service/networkService.js";
|
import NetworkService from "../../service/networkService.js";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import http from "http";
|
import http from "http";
|
||||||
|
import { errorMessages } from "../../utils/messages.js";
|
||||||
describe("Network Service", () => {
|
describe("Network Service", () => {
|
||||||
let axios, ping, logger, networkService;
|
let axios, ping, Docker, logger, networkService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
axios = {
|
axios = {
|
||||||
@@ -12,6 +13,17 @@ describe("Network Service", () => {
|
|||||||
status: 200,
|
status: 200,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
Docker = class {
|
||||||
|
listContainers = sinon.stub().resolves([
|
||||||
|
{
|
||||||
|
Names: ["http://test.com"],
|
||||||
|
Id: "http://test.com",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
getContainer = sinon.stub().returns({
|
||||||
|
inspect: sinon.stub().resolves({ State: { Status: "running" } }),
|
||||||
|
});
|
||||||
|
};
|
||||||
ping = {
|
ping = {
|
||||||
promise: {
|
promise: {
|
||||||
probe: sinon
|
probe: sinon
|
||||||
@@ -20,7 +32,7 @@ describe("Network Service", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
logger = { error: sinon.stub() };
|
logger = { error: sinon.stub() };
|
||||||
networkService = new NetworkService(axios, ping, logger, http);
|
networkService = new NetworkService(axios, ping, logger, http, Docker);
|
||||||
});
|
});
|
||||||
describe("constructor", () => {
|
describe("constructor", () => {
|
||||||
it("should create a new NetworkService instance", () => {
|
it("should create a new NetworkService instance", () => {
|
||||||
@@ -70,6 +82,18 @@ describe("Network Service", () => {
|
|||||||
expect(pingResult.status).to.be.false;
|
expect(pingResult.status).to.be.false;
|
||||||
expect(pingResult.code).to.equal(networkService.PING_ERROR);
|
expect(pingResult.code).to.equal(networkService.PING_ERROR);
|
||||||
});
|
});
|
||||||
|
it("should throw an error if ping cannot resolve", async () => {
|
||||||
|
const error = new Error("test error");
|
||||||
|
networkService.timeRequest = sinon.stub().throws(error);
|
||||||
|
try {
|
||||||
|
await networkService.requestPing({
|
||||||
|
data: { url: "http://test.com", _id: "123" },
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.method).to.equal("requestPing");
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe("requestHttp", () => {
|
describe("requestHttp", () => {
|
||||||
it("should return a response object if http successful", async () => {
|
it("should return a response object if http successful", async () => {
|
||||||
@@ -108,6 +132,18 @@ describe("Network Service", () => {
|
|||||||
expect(httpResult.status).to.be.false;
|
expect(httpResult.status).to.be.false;
|
||||||
expect(httpResult.code).to.equal(networkService.NETWORK_ERROR);
|
expect(httpResult.code).to.equal(networkService.NETWORK_ERROR);
|
||||||
});
|
});
|
||||||
|
it("should throw an error if an error occurs", async () => {
|
||||||
|
const error = new Error("test error");
|
||||||
|
networkService.timeRequest = sinon.stub().throws(error);
|
||||||
|
try {
|
||||||
|
await networkService.requestHttp({
|
||||||
|
data: { url: "http://test.com", _id: "123" },
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.method).to.equal("requestHttp");
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("requestPagespeed", () => {
|
describe("requestPagespeed", () => {
|
||||||
@@ -147,6 +183,18 @@ describe("Network Service", () => {
|
|||||||
expect(pagespeedResult.status).to.be.false;
|
expect(pagespeedResult.status).to.be.false;
|
||||||
expect(pagespeedResult.code).to.equal(networkService.NETWORK_ERROR);
|
expect(pagespeedResult.code).to.equal(networkService.NETWORK_ERROR);
|
||||||
});
|
});
|
||||||
|
it("should throw an error if pagespeed cannot resolve", async () => {
|
||||||
|
const error = new Error("test error");
|
||||||
|
networkService.timeRequest = sinon.stub().throws(error);
|
||||||
|
try {
|
||||||
|
await networkService.requestPagespeed({
|
||||||
|
data: { url: "http://test.com", _id: "123" },
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.method).to.equal("requestPagespeed");
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("requestHardware", () => {
|
describe("requestHardware", () => {
|
||||||
@@ -201,6 +249,99 @@ describe("Network Service", () => {
|
|||||||
expect(httpResult.status).to.be.false;
|
expect(httpResult.status).to.be.false;
|
||||||
expect(httpResult.code).to.equal(networkService.NETWORK_ERROR);
|
expect(httpResult.code).to.equal(networkService.NETWORK_ERROR);
|
||||||
});
|
});
|
||||||
|
it("should throw an error if hardware cannot resolve", async () => {
|
||||||
|
const error = new Error("test error");
|
||||||
|
networkService.timeRequest = sinon.stub().throws(error);
|
||||||
|
try {
|
||||||
|
await networkService.requestHardware({
|
||||||
|
data: { url: "http://test.com", _id: "123" },
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.method).to.equal("requestHardware");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("requestDocker", () => {
|
||||||
|
it("should return a response object if docker successful", async () => {
|
||||||
|
const job = { data: { url: "http://test.com", _id: "123", type: "docker" } };
|
||||||
|
const dockerResult = await networkService.requestDocker(job);
|
||||||
|
expect(dockerResult.monitorId).to.equal("123");
|
||||||
|
expect(dockerResult.type).to.equal("docker");
|
||||||
|
expect(dockerResult.responseTime).to.be.a("number");
|
||||||
|
expect(dockerResult.status).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return a response object with status false if container not running", async () => {
|
||||||
|
Docker = class {
|
||||||
|
listContainers = sinon.stub().resolves([
|
||||||
|
{
|
||||||
|
Names: ["/my_container"],
|
||||||
|
Id: "abc123",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
getContainer = sinon.stub().returns({
|
||||||
|
inspect: sinon.stub().resolves({ State: { Status: "stopped" } }),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
networkService = new NetworkService(axios, ping, logger, http, Docker);
|
||||||
|
const job = { data: { url: "abc123", _id: "123", type: "docker" } };
|
||||||
|
const dockerResult = await networkService.requestDocker(job);
|
||||||
|
expect(dockerResult.status).to.be.false;
|
||||||
|
expect(dockerResult.code).to.equal(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle an error when fetching the container", async () => {
|
||||||
|
Docker = class {
|
||||||
|
listContainers = sinon.stub().resolves([
|
||||||
|
{
|
||||||
|
Names: ["/my_container"],
|
||||||
|
Id: "abc123",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
getContainer = sinon.stub().returns({
|
||||||
|
inspect: sinon.stub().throws(new Error("test error")),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
networkService = new NetworkService(axios, ping, logger, http, Docker);
|
||||||
|
const job = { data: { url: "abc123", _id: "123", type: "docker" } };
|
||||||
|
const dockerResult = await networkService.requestDocker(job);
|
||||||
|
expect(dockerResult.status).to.be.false;
|
||||||
|
expect(dockerResult.code).to.equal(networkService.NETWORK_ERROR);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should throw an error if operations fail", async () => {
|
||||||
|
Docker = class {
|
||||||
|
listContainers = sinon.stub().resolves([
|
||||||
|
{
|
||||||
|
Names: ["/my_container"],
|
||||||
|
Id: "abc123",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
getContainer = sinon.stub().throws(new Error("test error"));
|
||||||
|
};
|
||||||
|
networkService = new NetworkService(axios, ping, logger, http, Docker);
|
||||||
|
const job = { data: { url: "abc123", _id: "123", type: "docker" } };
|
||||||
|
try {
|
||||||
|
await networkService.requestDocker(job);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.message).to.equal("test error");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("should throw an error if no matching images found", async () => {
|
||||||
|
Docker = class {
|
||||||
|
listContainers = sinon.stub().resolves([]);
|
||||||
|
getContainer = sinon.stub().throws(new Error("test error"));
|
||||||
|
};
|
||||||
|
networkService = new NetworkService(axios, ping, logger, http, Docker);
|
||||||
|
const job = { data: { url: "abc123", _id: "123", type: "docker" } };
|
||||||
|
try {
|
||||||
|
await networkService.requestDocker(job);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.message).to.equal(errorMessages.DOCKER_NOT_FOUND);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getStatus", () => {
|
describe("getStatus", () => {
|
||||||
@@ -209,39 +350,81 @@ describe("Network Service", () => {
|
|||||||
networkService.requestHttp = sinon.stub();
|
networkService.requestHttp = sinon.stub();
|
||||||
networkService.requestPagespeed = sinon.stub();
|
networkService.requestPagespeed = sinon.stub();
|
||||||
networkService.requestHardware = sinon.stub();
|
networkService.requestHardware = sinon.stub();
|
||||||
|
networkService.requestDocker = sinon.stub();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
sinon.restore();
|
sinon.restore();
|
||||||
});
|
});
|
||||||
it("should call requestPing if type is ping", () => {
|
it("should call requestPing if type is ping", async () => {
|
||||||
networkService.getStatus({ data: { type: "ping" } });
|
await networkService.getStatus({ data: { type: "ping" } });
|
||||||
expect(networkService.requestPing.calledOnce).to.be.true;
|
expect(networkService.requestPing.calledOnce).to.be.true;
|
||||||
|
expect(networkService.requestDocker.notCalled).to.be.true;
|
||||||
expect(networkService.requestHttp.notCalled).to.be.true;
|
expect(networkService.requestHttp.notCalled).to.be.true;
|
||||||
expect(networkService.requestPagespeed.notCalled).to.be.true;
|
expect(networkService.requestPagespeed.notCalled).to.be.true;
|
||||||
});
|
});
|
||||||
it("should call requestHttp if type is http", () => {
|
it("should call requestHttp if type is http", async () => {
|
||||||
networkService.getStatus({ data: { type: "http" } });
|
await networkService.getStatus({ data: { type: "http" } });
|
||||||
expect(networkService.requestPing.notCalled).to.be.true;
|
expect(networkService.requestPing.notCalled).to.be.true;
|
||||||
|
expect(networkService.requestDocker.notCalled).to.be.true;
|
||||||
expect(networkService.requestHttp.calledOnce).to.be.true;
|
expect(networkService.requestHttp.calledOnce).to.be.true;
|
||||||
expect(networkService.requestPagespeed.notCalled).to.be.true;
|
expect(networkService.requestPagespeed.notCalled).to.be.true;
|
||||||
});
|
});
|
||||||
it("should call requestPagespeed if type is pagespeed", () => {
|
it("should call requestPagespeed if type is pagespeed", async () => {
|
||||||
networkService.getStatus({ data: { type: "pagespeed" } });
|
await networkService.getStatus({ data: { type: "pagespeed" } });
|
||||||
expect(networkService.requestPing.notCalled).to.be.true;
|
expect(networkService.requestPing.notCalled).to.be.true;
|
||||||
|
expect(networkService.requestDocker.notCalled).to.be.true;
|
||||||
expect(networkService.requestHttp.notCalled).to.be.true;
|
expect(networkService.requestHttp.notCalled).to.be.true;
|
||||||
expect(networkService.requestPagespeed.calledOnce).to.be.true;
|
expect(networkService.requestPagespeed.calledOnce).to.be.true;
|
||||||
});
|
});
|
||||||
it("should call requestHardware if type is hardware", () => {
|
it("should call requestHardware if type is hardware", async () => {
|
||||||
networkService.getStatus({ data: { type: "hardware" } });
|
await networkService.getStatus({ data: { type: "hardware" } });
|
||||||
expect(networkService.requestHardware.calledOnce).to.be.true;
|
expect(networkService.requestHardware.calledOnce).to.be.true;
|
||||||
|
expect(networkService.requestDocker.notCalled).to.be.true;
|
||||||
expect(networkService.requestPing.notCalled).to.be.true;
|
expect(networkService.requestPing.notCalled).to.be.true;
|
||||||
expect(networkService.requestPagespeed.notCalled).to.be.true;
|
expect(networkService.requestPagespeed.notCalled).to.be.true;
|
||||||
});
|
});
|
||||||
it("should log an error if an unknown type is provided", () => {
|
it("should call requestDocker if type is Docker", async () => {
|
||||||
networkService.getStatus({ data: { type: "unknown" } });
|
await networkService.getStatus({ data: { type: "docker" } });
|
||||||
expect(logger.error.calledOnce).to.be.true;
|
expect(networkService.requestDocker.calledOnce).to.be.true;
|
||||||
expect(logger.error.args[0][0].message).to.equal("Unsupported type: unknown");
|
expect(networkService.requestHardware.notCalled).to.be.true;
|
||||||
|
expect(networkService.requestPing.notCalled).to.be.true;
|
||||||
|
expect(networkService.requestPagespeed.notCalled).to.be.true;
|
||||||
|
});
|
||||||
|
it("should throw an error if an unknown type is provided", async () => {
|
||||||
|
try {
|
||||||
|
await networkService.getStatus({ data: { type: "unknown" } });
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.service).to.equal("NetworkService");
|
||||||
|
expect(error.method).to.equal("getStatus");
|
||||||
|
expect(error.message).to.equal("Unsupported type: unknown");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("should throw an error if job type is undefined", async () => {
|
||||||
|
try {
|
||||||
|
await networkService.getStatus({ data: { type: undefined } });
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.service).to.equal("NetworkService");
|
||||||
|
expect(error.method).to.equal("getStatus");
|
||||||
|
expect(error.message).to.equal("Unsupported type: unknown");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("should throw an error if job is empty", async () => {
|
||||||
|
try {
|
||||||
|
await networkService.getStatus({});
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.method).to.equal("getStatus");
|
||||||
|
expect(error.message).to.equal("Unsupported type: unknown");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("should throw an error if job is null", async () => {
|
||||||
|
try {
|
||||||
|
await networkService.getStatus(null);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.service).to.equal("NetworkService");
|
||||||
|
expect(error.method).to.equal("getStatus");
|
||||||
|
expect(error.message).to.equal("Unsupported type: unknown");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -182,7 +182,7 @@ describe("StatusService", () => {
|
|||||||
responseTime: 100,
|
responseTime: 100,
|
||||||
code: 200,
|
code: 200,
|
||||||
message: "Test message",
|
message: "Test message",
|
||||||
payload: { cpu: "cpu", memory: "memory", disk: "disk", host: "host" },
|
payload: { data: { cpu: "cpu", memory: "memory", disk: "disk", host: "host" } },
|
||||||
});
|
});
|
||||||
expect(check.monitorId).to.equal("test");
|
expect(check.monitorId).to.equal("test");
|
||||||
expect(check.status).to.be.true;
|
expect(check.status).to.be.true;
|
||||||
|
|||||||
@@ -46,6 +46,26 @@ describe("Logger", () => {
|
|||||||
const logger = new Logger();
|
const logger = new Logger();
|
||||||
logger.logger.info(logMessage);
|
logger.logger.info(logMessage);
|
||||||
});
|
});
|
||||||
|
it("should convert details to JSON string if it is an object", function () {
|
||||||
|
const logDetails = { key: "value" };
|
||||||
|
const expectedDetails = JSON.stringify(logDetails, null, 2); // Removed .s
|
||||||
|
|
||||||
|
createLoggerStub.callsFake((config) => {
|
||||||
|
const consoleTransport = config.transports[0];
|
||||||
|
const logEntry = {
|
||||||
|
level: "info",
|
||||||
|
message: "", // Add empty message since it's required
|
||||||
|
details: logDetails,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
const formattedMessage = consoleTransport.format.transform(logEntry);
|
||||||
|
expect(formattedMessage).to.include(expectedDetails);
|
||||||
|
return { info: sinon.spy() }; // Changed to return info method
|
||||||
|
});
|
||||||
|
|
||||||
|
const logger = new Logger();
|
||||||
|
logger.logger.info("", { details: logDetails }); // Updated to pass details properly
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("info", () => {
|
describe("info", () => {
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ const errorMessages = {
|
|||||||
// Status Page Errors
|
// Status Page Errors
|
||||||
STATUS_PAGE_NOT_FOUND: "Status page not found",
|
STATUS_PAGE_NOT_FOUND: "Status page not found",
|
||||||
STATUS_PAGE_URL_NOT_UNIQUE: "Status page url must be unique",
|
STATUS_PAGE_URL_NOT_UNIQUE: "Status page url must be unique",
|
||||||
|
|
||||||
|
// Docker
|
||||||
|
DOCKER_FAIL: "Failed to fetch Docker container information",
|
||||||
|
DOCKER_NOT_FOUND: "Docker container not found",
|
||||||
};
|
};
|
||||||
|
|
||||||
const successMessages = {
|
const successMessages = {
|
||||||
@@ -123,6 +127,9 @@ const successMessages = {
|
|||||||
// Status Page
|
// Status Page
|
||||||
STATUS_PAGE_BY_URL: "Got status page by url successfully",
|
STATUS_PAGE_BY_URL: "Got status page by url successfully",
|
||||||
STATUS_PAGE_CREATE: "Status page created successfully",
|
STATUS_PAGE_CREATE: "Status page created successfully",
|
||||||
|
|
||||||
|
// Docker
|
||||||
|
DOCKER_SUCCESS: "Docker container status fetched successfully",
|
||||||
};
|
};
|
||||||
|
|
||||||
export { errorMessages, successMessages };
|
export { errorMessages, successMessages };
|
||||||
@@ -144,8 +144,8 @@ const getMonitorsAndSummaryByTeamIdQueryValidation = joi.object({
|
|||||||
type: joi
|
type: joi
|
||||||
.alternatives()
|
.alternatives()
|
||||||
.try(
|
.try(
|
||||||
joi.string().valid("http", "ping", "pagespeed"),
|
joi.string().valid("http", "ping", "pagespeed", "docker"),
|
||||||
joi.array().items(joi.string().valid("http", "ping", "pagespeed"))
|
joi.array().items(joi.string().valid("http", "ping", "pagespeed", "docker"))
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -161,8 +161,8 @@ const getMonitorsByTeamIdQueryValidation = joi.object({
|
|||||||
type: joi
|
type: joi
|
||||||
.alternatives()
|
.alternatives()
|
||||||
.try(
|
.try(
|
||||||
joi.string().valid("http", "ping", "pagespeed"),
|
joi.string().valid("http", "ping", "pagespeed", "docker"),
|
||||||
joi.array().items(joi.string().valid("http", "ping", "pagespeed"))
|
joi.array().items(joi.string().valid("http", "ping", "pagespeed", "docker"))
|
||||||
),
|
),
|
||||||
page: joi.number(),
|
page: joi.number(),
|
||||||
rowsPerPage: joi.number(),
|
rowsPerPage: joi.number(),
|
||||||
|
|||||||
Reference in new issue
Block a user