204 files changed
+10550
-4971
No files matched your search
@@ -1,9 +1,14 @@
|
|||||||
## Describe your changes
|
## Describe your changes
|
||||||
|
|
||||||
## Issue Number if applicable
|
Provide a brief description of the changes you’ve made and their purpose.
|
||||||
|
|
||||||
## Checklist before requesting a review
|
## Issue number
|
||||||
|
|
||||||
- [ ] I have performed a self-review of my code
|
Mention the issue number(s) this PR addresses (e.g., #123).
|
||||||
- [ ] I have inlcuded the issue # in the PR if applicable
|
|
||||||
- [ ] I have labelled the PR correctly
|
## Please ensure all items are checked off before requesting a review:
|
||||||
|
|
||||||
|
- [ ] I have performed a self-review of my code.
|
||||||
|
- [ ] I have included the issue # in the PR.
|
||||||
|
- [ ] I have labelled the PR correctly.
|
||||||
|
- [ ] My PR is granular and targeted to one specific feature only.
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 90,
|
||||||
|
"useTabs": true,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"singleQuote": false,
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"proseWrap": "preserve",
|
||||||
|
"bracketSameLine": false,
|
||||||
|
"singleAttributePerLine": true,
|
||||||
|
"semi": true,
|
||||||
|
"jsxSingleQuote": false,
|
||||||
|
"quoteProps": "as-needed",
|
||||||
|
"arrowParens": "always",
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"htmlWhitespaceSensitivity": "css"
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in the **bluewave-uptime** project and community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community, especially during Hacktoberfest, where we encourage new contributors to join and feel supported.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our community include:
|
||||||
|
|
||||||
|
- Demonstrating empathy and kindness toward other people
|
||||||
|
- Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
- Giving and gracefully accepting constructive feedback
|
||||||
|
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
||||||
|
- Focusing on what is best not just for us as individuals, but for the overall community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
- The use of sexualized language or imagery, and sexual attention or advances of any kind
|
||||||
|
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
- Public or private harassment
|
||||||
|
- Publishing others' private information, such as a physical or email address, without their explicit permission
|
||||||
|
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this Code of Conduct, especially during Hacktoberfest to ensure a positive experience for all contributors.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all project spaces, and it also applies when an individual is officially representing the project or its community in public spaces. Examples of representing our project include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hello@bluewavelabs.ca. All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All project team members are obligated to respect the privacy and security of the reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Project maintainers will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
||||||
|
**Consequence**: A private, written warning from project maintainers, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
**Community Impact**: A violation through a single incident or series of actions.
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
By following this Code of Conduct, we can ensure a welcoming and inclusive environment, encouraging new contributors to engage with the project and the community. Thank you for helping make **bluewave-uptime** a positive space for all!
|
||||||
@@ -77,6 +77,7 @@ Once it's filed:
|
|||||||
This section guides you through submitting an enhancement suggestion for the application, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community understand your enhancements and find related suggestions.
|
This section guides you through submitting an enhancement suggestion for the application, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community understand your enhancements and find related suggestions.
|
||||||
|
|
||||||
- Make sure that you are using the latest version.
|
- Make sure that you are using the latest version.
|
||||||
|
- Make sure you run the code locally. The Uptime Manager [documentation](https://bluewavelabs.gitbook.io/uptime-manager) covers it.
|
||||||
- Find out if the functionality is already covered, maybe by an individual configuration.
|
- Find out if the functionality is already covered, maybe by an individual configuration.
|
||||||
- Perform a [search](/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
|
- Perform a [search](/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
|
||||||
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
|
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
VITE_APP_API_BASE_URL=UPTIME_APP_API_BASE_URL
|
||||||
+12
-14
@@ -2,20 +2,18 @@ module.exports = {
|
|||||||
root: true,
|
root: true,
|
||||||
env: { browser: true, es2020: true },
|
env: { browser: true, es2020: true },
|
||||||
extends: [
|
extends: [
|
||||||
'eslint:recommended',
|
"eslint:recommended",
|
||||||
'plugin:react/recommended',
|
"plugin:react/recommended",
|
||||||
'plugin:react/jsx-runtime',
|
"plugin:react/jsx-runtime",
|
||||||
'plugin:react-hooks/recommended',
|
"plugin:react-hooks/recommended",
|
||||||
],
|
],
|
||||||
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
ignorePatterns: ["dist", ".eslintrc.cjs"],
|
||||||
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
|
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
|
||||||
settings: { react: { version: '18.2' } },
|
settings: { react: { version: "18.2" } },
|
||||||
plugins: ['react-refresh'],
|
plugins: ["react-refresh"],
|
||||||
rules: {
|
rules: {
|
||||||
'react/jsx-no-target-blank': 'off',
|
"react/jsx-no-target-blank": "off",
|
||||||
'react-refresh/only-export-components': [
|
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
|
||||||
'warn',
|
"react/no-unescaped-entities": "off",
|
||||||
{ allowConstantExport: true },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
@@ -24,3 +24,5 @@ dist-ssr
|
|||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
.env
|
.env
|
||||||
|
|
||||||
|
!env.sh
|
||||||
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
for i in $(env | grep UPTIME_APP_)
|
||||||
|
do
|
||||||
|
key=$(echo $i | cut -d '=' -f 1)
|
||||||
|
value=$(echo $i | cut -d '=' -f 2-)
|
||||||
|
echo $key=$value
|
||||||
|
find /usr/share/nginx/html -type f \( -name '*.js' -o -name '*.css' \) -exec sed -i "s|${key}|${value}|g" '{}' +
|
||||||
|
done
|
||||||
+13
-4
@@ -1,14 +1,23 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" href="./bluewave_favicon.ico" />
|
<link
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
rel="icon"
|
||||||
|
href="./bluewave_favicon.ico"
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1.0"
|
||||||
|
/>
|
||||||
<title>BlueWave Uptime</title>
|
<title>BlueWave Uptime</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script type="module" src="/src/main.jsx"></script>
|
<script
|
||||||
|
type="module"
|
||||||
|
src="/src/main.jsx"
|
||||||
|
></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Generated
+462
-453
File diff suppressed because it is too large.
Load diff
+9
-7
@@ -6,6 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
|
"build-dev": "vite build --mode development",
|
||||||
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
|
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
@@ -17,13 +18,13 @@
|
|||||||
"@mui/lab": "^5.0.0-alpha.170",
|
"@mui/lab": "^5.0.0-alpha.170",
|
||||||
"@mui/material": "^5.15.16",
|
"@mui/material": "^5.15.16",
|
||||||
"@mui/x-charts": "^7.5.1",
|
"@mui/x-charts": "^7.5.1",
|
||||||
"@mui/x-data-grid": "7.3.2",
|
"@mui/x-data-grid": "7.22.0",
|
||||||
"@mui/x-date-pickers": "7.3.2",
|
"@mui/x-date-pickers": "7.22.0",
|
||||||
"@reduxjs/toolkit": "2.2.5",
|
"@reduxjs/toolkit": "2.3.0",
|
||||||
"axios": "^1.7.4",
|
"axios": "^1.7.4",
|
||||||
"chart.js": "^4.4.3",
|
"chart.js": "^4.4.3",
|
||||||
"dayjs": "1.11.11",
|
"dayjs": "1.11.13",
|
||||||
"joi": "17.13.1",
|
"joi": "17.13.3",
|
||||||
"jwt-decode": "^4.0.0",
|
"jwt-decode": "^4.0.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
@@ -31,7 +32,7 @@
|
|||||||
"react-router": "^6.23.0",
|
"react-router": "^6.23.0",
|
||||||
"react-router-dom": "^6.23.1",
|
"react-router-dom": "^6.23.1",
|
||||||
"react-toastify": "^10.0.5",
|
"react-toastify": "^10.0.5",
|
||||||
"recharts": "2.13.0-alpha.4",
|
"recharts": "2.13.1",
|
||||||
"redux-persist": "6.0.0",
|
"redux-persist": "6.0.0",
|
||||||
"vite-plugin-svgr": "^4.2.0"
|
"vite-plugin-svgr": "^4.2.0"
|
||||||
},
|
},
|
||||||
@@ -41,8 +42,9 @@
|
|||||||
"@vitejs/plugin-react": "^4.2.1",
|
"@vitejs/plugin-react": "^4.2.1",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-react": "^7.34.1",
|
"eslint-plugin-react": "^7.34.1",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^5.0.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.6",
|
"eslint-plugin-react-refresh": "^0.4.6",
|
||||||
|
"prettier": "^3.3.3",
|
||||||
"vite": "^5.2.0"
|
"vite": "^5.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+57
-18
@@ -36,7 +36,7 @@ import { useSelector } from "react-redux";
|
|||||||
import { CssBaseline } from "@mui/material";
|
import { CssBaseline } from "@mui/material";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { getAppSettings } from "./Features/Settings/settingsSlice";
|
import { getAppSettings, updateAppSettings } 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";
|
||||||
function App() {
|
function App() {
|
||||||
@@ -70,7 +70,11 @@ function App() {
|
|||||||
<ThemeProvider theme={mode === "light" ? lightTheme : darkTheme}>
|
<ThemeProvider theme={mode === "light" ? lightTheme : darkTheme}>
|
||||||
<CssBaseline />
|
<CssBaseline />
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route exact path="/" element={<HomeLayout />}>
|
<Route
|
||||||
|
exact
|
||||||
|
path="/"
|
||||||
|
element={<HomeLayout />}
|
||||||
|
>
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path="/"
|
path="/"
|
||||||
@@ -119,21 +123,34 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="advanced-settings"
|
path="advanced-settings"
|
||||||
element={
|
element={<ProtectedRoute Component={AdvancedSettingsWithAdminProp} />}
|
||||||
<ProtectedRoute Component={AdvancedSettingsWithAdminProp} />
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="account/profile"
|
path="account/profile"
|
||||||
element={<ProtectedRoute Component={Account} open="profile" />}
|
element={
|
||||||
|
<ProtectedRoute
|
||||||
|
Component={Account}
|
||||||
|
open="profile"
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="account/password"
|
path="account/password"
|
||||||
element={<ProtectedRoute Component={Account} open="password" />}
|
element={
|
||||||
|
<ProtectedRoute
|
||||||
|
Component={Account}
|
||||||
|
open="password"
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="account/team"
|
path="account/team"
|
||||||
element={<ProtectedRoute Component={Account} open="team" />}
|
element={
|
||||||
|
<ProtectedRoute
|
||||||
|
Component={Account}
|
||||||
|
open="team"
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="pagespeed"
|
path="pagespeed"
|
||||||
@@ -145,9 +162,7 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="pagespeed/:monitorId"
|
path="pagespeed/:monitorId"
|
||||||
element={
|
element={<ProtectedRoute Component={PageSpeedDetailsWithAdminProp} />}
|
||||||
<ProtectedRoute Component={PageSpeedDetailsWithAdminProp} />
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="pagespeed/configure/:monitorId"
|
path="pagespeed/configure/:monitorId"
|
||||||
@@ -155,15 +170,39 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<Route exact path="/login" element={<Login />} />
|
<Route
|
||||||
|
exact
|
||||||
|
path="/login"
|
||||||
|
element={<Login />}
|
||||||
|
/>
|
||||||
|
|
||||||
<Route exact path="/register" element={<AdminCheckedRegister />} />
|
<Route
|
||||||
<Route exact path="/register/:token" element={<Register />} />
|
exact
|
||||||
|
path="/register"
|
||||||
|
element={<AdminCheckedRegister />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
exact
|
||||||
|
path="/register/:token"
|
||||||
|
element={<Register />}
|
||||||
|
/>
|
||||||
{/* <Route path="/toast" element={<ToastComponent />} /> */}
|
{/* <Route path="/toast" element={<ToastComponent />} /> */}
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route
|
||||||
<Route path="/forgot-password" element={<ForgotPassword />} />
|
path="*"
|
||||||
<Route path="/check-email" element={<CheckEmail />} />
|
element={<NotFound />}
|
||||||
<Route path="/set-new-password/:token" element={<SetNewPassword />} />
|
/>
|
||||||
|
<Route
|
||||||
|
path="/forgot-password"
|
||||||
|
element={<ForgotPassword />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/check-email"
|
||||||
|
element={<CheckEmail />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/set-new-password/:token"
|
||||||
|
element={<SetNewPassword />}
|
||||||
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/new-password-confirmed"
|
path="/new-password-confirmed"
|
||||||
element={<NewPasswordConfirmed />}
|
element={<NewPasswordConfirmed />}
|
||||||
|
|||||||
@@ -42,25 +42,23 @@ const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => {
|
|||||||
className="alert row-stack"
|
className="alert row-stack"
|
||||||
gap={theme.spacing(8)}
|
gap={theme.spacing(8)}
|
||||||
sx={{
|
sx={{
|
||||||
padding: hasIcon
|
padding: hasIcon ? theme.spacing(8) : `${theme.spacing(4)} ${theme.spacing(8)}`,
|
||||||
? theme.spacing(8)
|
|
||||||
: `${theme.spacing(4)} ${theme.spacing(8)}`,
|
|
||||||
backgroundColor: bg,
|
backgroundColor: bg,
|
||||||
border: `solid 1px ${border}`,
|
border: `solid 1px ${border}`,
|
||||||
borderRadius: theme.shape.borderRadius,
|
borderRadius: theme.shape.borderRadius,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{hasIcon && <Box sx={{ color: text }}>{icon}</Box>}
|
{hasIcon && <Box sx={{ color: text }}>{icon}</Box>}
|
||||||
<Stack direction="column" gap="2px" sx={{ flex: 1 }}>
|
<Stack
|
||||||
|
direction="column"
|
||||||
|
gap="2px"
|
||||||
|
sx={{ flex: 1 }}
|
||||||
|
>
|
||||||
{title && (
|
{title && (
|
||||||
<Typography sx={{ fontWeight: "700", color: `${text}` }}>
|
<Typography sx={{ fontWeight: "700", color: `${text}` }}>{title}</Typography>
|
||||||
{title}
|
|
||||||
</Typography>
|
|
||||||
)}
|
)}
|
||||||
{body && (
|
{body && (
|
||||||
<Typography sx={{ fontWeight: "400", color: `${text}` }}>
|
<Typography sx={{ fontWeight: "400", color: `${text}` }}>{body}</Typography>
|
||||||
{body}
|
|
||||||
</Typography>
|
|
||||||
)}
|
)}
|
||||||
{hasIcon && isToast && (
|
{hasIcon && isToast && (
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ const Avatar = ({ src, small, sx }) => {
|
|||||||
return (
|
return (
|
||||||
<MuiAvatar
|
<MuiAvatar
|
||||||
alt={`${user?.firstName} ${user?.lastName}`}
|
alt={`${user?.firstName} ${user?.lastName}`}
|
||||||
src={
|
src={src ? src : user?.avatarImage ? image : "/static/images/avatar/2.jpg"}
|
||||||
src ? src : user?.avatarImage ? image : "/static/images/avatar/2.jpg"
|
|
||||||
}
|
|
||||||
sx={{
|
sx={{
|
||||||
fontSize: small ? "16px" : "22px",
|
fontSize: small ? "16px" : "22px",
|
||||||
color: "white",
|
color: "white",
|
||||||
|
|||||||
@@ -18,10 +18,7 @@
|
|||||||
.MuiPaper-root:has(table.MuiTable-root) {
|
.MuiPaper-root:has(table.MuiTable-root) {
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
.MuiTable-root
|
.MuiTable-root .MuiTableBody-root .MuiTableRow-root:last-child .MuiTableCell-root {
|
||||||
.MuiTableBody-root
|
|
||||||
.MuiTableRow-root:last-child
|
|
||||||
.MuiTableCell-root {
|
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +117,7 @@
|
|||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.monitors .MuiTable-root .MuiTableHead-root .MuiTableCell-root {
|
.table-container .MuiTable-root .MuiTableHead-root .MuiTableCell-root {
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
font-size: var(--env-var-font-size-small-plus);
|
font-size: var(--env-var-font-size-small-plus);
|
||||||
|
|||||||
@@ -243,7 +243,11 @@ const BasicTable = ({ data, paginated, reversed, table }) => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography px={theme.spacing(2)} fontSize={12} sx={{ opacity: 0.7 }}>
|
<Typography
|
||||||
|
px={theme.spacing(2)}
|
||||||
|
fontSize={12}
|
||||||
|
sx={{ opacity: 0.7 }}
|
||||||
|
>
|
||||||
Showing {getRange()} of {data.rows.length} monitor(s)
|
Showing {getRange()} of {data.rows.length} monitor(s)
|
||||||
</Typography>
|
</Typography>
|
||||||
<TablePagination
|
<TablePagination
|
||||||
@@ -257,10 +261,7 @@ const BasicTable = ({ data, paginated, reversed, table }) => {
|
|||||||
ActionsComponent={TablePaginationActions}
|
ActionsComponent={TablePaginationActions}
|
||||||
labelRowsPerPage="Rows per page"
|
labelRowsPerPage="Rows per page"
|
||||||
labelDisplayedRows={({ page, count }) =>
|
labelDisplayedRows={({ page, count }) =>
|
||||||
`Page ${page + 1} of ${Math.max(
|
`Page ${page + 1} of ${Math.max(0, Math.ceil(count / rowsPerPage))}`
|
||||||
0,
|
|
||||||
Math.ceil(count / rowsPerPage)
|
|
||||||
)}`
|
|
||||||
}
|
}
|
||||||
slotProps={{
|
slotProps={{
|
||||||
select: {
|
select: {
|
||||||
|
|||||||
@@ -65,9 +65,7 @@ const BarChart = ({ checks = [] }) => {
|
|||||||
width={theme.spacing(4)}
|
width={theme.spacing(4)}
|
||||||
height={theme.spacing(4)}
|
height={theme.spacing(4)}
|
||||||
backgroundColor={
|
backgroundColor={
|
||||||
check.status
|
check.status ? theme.palette.success.main : theme.palette.error.text
|
||||||
? theme.palette.success.main
|
|
||||||
: theme.palette.error.text
|
|
||||||
}
|
}
|
||||||
sx={{ borderRadius: "50%" }}
|
sx={{ borderRadius: "50%" }}
|
||||||
/>
|
/>
|
||||||
@@ -78,12 +76,18 @@ const BarChart = ({ checks = [] }) => {
|
|||||||
ml={theme.spacing(2)}
|
ml={theme.spacing(2)}
|
||||||
gap={theme.spacing(12)}
|
gap={theme.spacing(12)}
|
||||||
>
|
>
|
||||||
<Typography component="span" sx={{ opacity: 0.8 }}>
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{ opacity: 0.8 }}
|
||||||
|
>
|
||||||
Response Time
|
Response Time
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{check.originalResponseTime}
|
{check.originalResponseTime}
|
||||||
<Typography component="span" sx={{ opacity: 0.8 }}>
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{ opacity: 0.8 }}
|
||||||
|
>
|
||||||
{" "}
|
{" "}
|
||||||
ms
|
ms
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -149,9 +153,7 @@ const BarChart = ({ checks = [] }) => {
|
|||||||
width="100%"
|
width="100%"
|
||||||
height={`${animate ? check.responseTime : 0}%`}
|
height={`${animate ? check.responseTime : 0}%`}
|
||||||
backgroundColor={
|
backgroundColor={
|
||||||
check.status
|
check.status ? theme.palette.success.main : theme.palette.error.text
|
||||||
? theme.palette.success.main
|
|
||||||
: theme.palette.error.text
|
|
||||||
}
|
}
|
||||||
sx={{
|
sx={{
|
||||||
borderRadius: theme.spacing(1.5),
|
borderRadius: theme.spacing(1.5),
|
||||||
|
|||||||
@@ -62,12 +62,18 @@ const CustomToolTip = ({ active, payload, label }) => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography component="span" sx={{ opacity: 0.8 }}>
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{ opacity: 0.8 }}
|
||||||
|
>
|
||||||
Response Time
|
Response Time
|
||||||
</Typography>{" "}
|
</Typography>{" "}
|
||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{payload[0].payload.originalResponseTime}
|
{payload[0].payload.originalResponseTime}
|
||||||
<Typography component="span" sx={{ opacity: 0.8 }}>
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{ opacity: 0.8 }}
|
||||||
|
>
|
||||||
{" "}
|
{" "}
|
||||||
ms
|
ms
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -115,7 +121,11 @@ const MonitorDetailsAreaChart = ({ checks }) => {
|
|||||||
const [isHovered, setIsHovered] = useState(false);
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" minWidth={25} height={220}>
|
<ResponsiveContainer
|
||||||
|
width="100%"
|
||||||
|
minWidth={25}
|
||||||
|
height={220}
|
||||||
|
>
|
||||||
<AreaChart
|
<AreaChart
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
@@ -137,7 +147,13 @@ const MonitorDetailsAreaChart = ({ checks }) => {
|
|||||||
vertical={false}
|
vertical={false}
|
||||||
/>
|
/>
|
||||||
<defs>
|
<defs>
|
||||||
<linearGradient id="colorUv" x1="0" y1="0" x2="0" y2="1">
|
<linearGradient
|
||||||
|
id="colorUv"
|
||||||
|
x1="0"
|
||||||
|
y1="0"
|
||||||
|
x2="0"
|
||||||
|
y2="1"
|
||||||
|
>
|
||||||
<stop
|
<stop
|
||||||
offset="0%"
|
offset="0%"
|
||||||
stopColor={theme.palette.primary.main}
|
stopColor={theme.palette.primary.main}
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ const Check = ({ text, variant = "info", outlined = false }) => {
|
|||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
sx={{
|
sx={{
|
||||||
color:
|
color: variant === "info" ? theme.palette.text.tertiary : colors[variant],
|
||||||
variant === "info" ? theme.palette.text.tertiary : colors[variant],
|
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import { useId } from "react";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
import { Modal, Stack, Typography } from "@mui/material";
|
||||||
|
|
||||||
|
const GenericDialog = ({ title, description, open, onClose, theme, children }) => {
|
||||||
|
const titleId = useId();
|
||||||
|
const descriptionId = useId();
|
||||||
|
const ariaDescribedBy = description?.length > 0 ? descriptionId : "";
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
aria-labelledby={titleId}
|
||||||
|
aria-describedby={ariaDescribedBy}
|
||||||
|
open={open}
|
||||||
|
onClose={onClose}
|
||||||
|
onClick={(e)=>e.stopPropagation()}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
gap={theme.spacing(2)}
|
||||||
|
sx={{
|
||||||
|
position: "absolute",
|
||||||
|
top: "50%",
|
||||||
|
left: "50%",
|
||||||
|
transform: "translate(-50%, -50%)",
|
||||||
|
width: 400,
|
||||||
|
bgcolor: theme.palette.background.main,
|
||||||
|
border: 1,
|
||||||
|
borderColor: theme.palette.border.light,
|
||||||
|
borderRadius: theme.shape.borderRadius,
|
||||||
|
boxShadow: 24,
|
||||||
|
p: theme.spacing(15),
|
||||||
|
"&:focus": {
|
||||||
|
outline: "none",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
id={titleId}
|
||||||
|
component="h2"
|
||||||
|
fontSize={16}
|
||||||
|
color={theme.palette.text.primary}
|
||||||
|
fontWeight={600}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
{description && (
|
||||||
|
<Typography
|
||||||
|
id={descriptionId}
|
||||||
|
color={theme.palette.text.tertiary}
|
||||||
|
>
|
||||||
|
{description}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
{children}
|
||||||
|
</Stack>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GenericDialog.propTypes = {
|
||||||
|
title: PropTypes.string.isRequired,
|
||||||
|
description: PropTypes.string,
|
||||||
|
open: PropTypes.bool.isRequired,
|
||||||
|
onClose: PropTypes.func.isRequired,
|
||||||
|
theme: PropTypes.object.isRequired,
|
||||||
|
children: PropTypes.element.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export { GenericDialog };
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import PropTypes from "prop-types";
|
||||||
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
|
import { Button, Stack } from "@mui/material";
|
||||||
|
import { GenericDialog } from "./genericDialog";
|
||||||
|
|
||||||
|
const Dialog = ({
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
open,
|
||||||
|
theme,
|
||||||
|
onCancel,
|
||||||
|
confirmationButtonLabel,
|
||||||
|
onConfirm,
|
||||||
|
isLoading,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<GenericDialog
|
||||||
|
title={title}
|
||||||
|
description={description}
|
||||||
|
open={open}
|
||||||
|
onClose={onCancel}
|
||||||
|
theme={theme}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(4)}
|
||||||
|
mt={theme.spacing(12)}
|
||||||
|
justifyContent="flex-end"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="text"
|
||||||
|
color="info"
|
||||||
|
onClick={onCancel}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<LoadingButton
|
||||||
|
variant="contained"
|
||||||
|
color="error"
|
||||||
|
loading={isLoading}
|
||||||
|
onClick={onConfirm}
|
||||||
|
>
|
||||||
|
{confirmationButtonLabel}
|
||||||
|
</LoadingButton>
|
||||||
|
</Stack>
|
||||||
|
</GenericDialog>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Dialog.propTypes = {
|
||||||
|
title: PropTypes.string.isRequired,
|
||||||
|
description: PropTypes.string,
|
||||||
|
open: PropTypes.bool.isRequired,
|
||||||
|
onClose: PropTypes.func.isRequired,
|
||||||
|
theme: PropTypes.object.isRequired,
|
||||||
|
onCancel: PropTypes.func.isRequired,
|
||||||
|
confirmationButtonLabel: PropTypes.string.isRequired,
|
||||||
|
onConfirm: PropTypes.func.isRequired,
|
||||||
|
isLoading: PropTypes.bool.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Dialog;
|
||||||
@@ -46,7 +46,11 @@ const Fallback = ({ title, checks, link = "/", isAdmin }) => {
|
|||||||
>
|
>
|
||||||
<Background style={{ width: "100%" }} />
|
<Background style={{ width: "100%" }} />
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(4)} maxWidth={"275px"} zIndex={1}>
|
<Stack
|
||||||
|
gap={theme.spacing(4)}
|
||||||
|
maxWidth={"275px"}
|
||||||
|
zIndex={1}
|
||||||
|
>
|
||||||
<Typography
|
<Typography
|
||||||
component="h1"
|
component="h1"
|
||||||
marginY={theme.spacing(4)}
|
marginY={theme.spacing(4)}
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { forwardRef, useState } from "react";
|
import { forwardRef, useState } from "react";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import {
|
import { IconButton, InputAdornment, Stack, TextField, Typography } from "@mui/material";
|
||||||
IconButton,
|
|
||||||
InputAdornment,
|
|
||||||
Stack,
|
|
||||||
TextField,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import VisibilityOff from "@mui/icons-material/VisibilityOff";
|
import VisibilityOff from "@mui/icons-material/VisibilityOff";
|
||||||
import Visibility from "@mui/icons-material/Visibility";
|
import Visibility from "@mui/icons-material/Visibility";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
@@ -47,6 +41,7 @@ const Field = forwardRef(
|
|||||||
placeholder,
|
placeholder,
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
|
onBlur,
|
||||||
onInput,
|
onInput,
|
||||||
error,
|
error,
|
||||||
disabled,
|
disabled,
|
||||||
@@ -74,6 +69,7 @@ const Field = forwardRef(
|
|||||||
"&:has(.input-error) .MuiOutlinedInput-root fieldset": {
|
"&:has(.input-error) .MuiOutlinedInput-root fieldset": {
|
||||||
borderColor: theme.palette.error.text,
|
borderColor: theme.palette.error.text,
|
||||||
},
|
},
|
||||||
|
display: hidden ? "none" : "",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{label && (
|
{label && (
|
||||||
@@ -120,6 +116,7 @@ const Field = forwardRef(
|
|||||||
value={value}
|
value={value}
|
||||||
onInput={onInput}
|
onInput={onInput}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
onBlur={onBlur}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
inputRef={ref}
|
inputRef={ref}
|
||||||
inputProps={{
|
inputProps={{
|
||||||
@@ -141,9 +138,7 @@ const Field = forwardRef(
|
|||||||
borderBottomLeftRadius: theme.shape.borderRadius,
|
borderBottomLeftRadius: theme.shape.borderRadius,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: {
|
: {}
|
||||||
display: hidden ? "none" : "",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
InputProps={{
|
InputProps={{
|
||||||
startAdornment: type === "url" && (
|
startAdornment: type === "url" && (
|
||||||
@@ -211,14 +206,7 @@ const Field = forwardRef(
|
|||||||
Field.displayName = "Field";
|
Field.displayName = "Field";
|
||||||
|
|
||||||
Field.propTypes = {
|
Field.propTypes = {
|
||||||
type: PropTypes.oneOf([
|
type: PropTypes.oneOf(["text", "password", "url", "email", "description", "number"]),
|
||||||
"text",
|
|
||||||
"password",
|
|
||||||
"url",
|
|
||||||
"email",
|
|
||||||
"description",
|
|
||||||
"number",
|
|
||||||
]),
|
|
||||||
id: PropTypes.string.isRequired,
|
id: PropTypes.string.isRequired,
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
label: PropTypes.string,
|
label: PropTypes.string,
|
||||||
@@ -230,6 +218,7 @@ Field.propTypes = {
|
|||||||
placeholder: PropTypes.string,
|
placeholder: PropTypes.string,
|
||||||
value: PropTypes.string.isRequired,
|
value: PropTypes.string.isRequired,
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
|
onBlur: PropTypes.func,
|
||||||
onInput: PropTypes.func,
|
onInput: PropTypes.func,
|
||||||
error: PropTypes.string,
|
error: PropTypes.string,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
|
|||||||
@@ -92,7 +92,10 @@ const ImageField = ({ id, src, loading, onChange }) => {
|
|||||||
>
|
>
|
||||||
<CloudUploadIcon />
|
<CloudUploadIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Typography component="h2" color={theme.palette.text.tertiary}>
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
color={theme.palette.text.tertiary}
|
||||||
|
>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
fontSize="inherit"
|
fontSize="inherit"
|
||||||
@@ -121,7 +124,10 @@ const ImageField = ({ id, src, loading, onChange }) => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Stack direction="row" justifyContent="center">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="center"
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
width: "250px",
|
width: "250px",
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
@@ -1,12 +1,5 @@
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import {
|
import { Box, ListItem, Autocomplete, TextField, Stack, Typography } from "@mui/material";
|
||||||
Box,
|
|
||||||
ListItem,
|
|
||||||
Autocomplete,
|
|
||||||
TextField,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import SearchIcon from "../../../assets/icons/search.svg?react";
|
import SearchIcon from "../../../assets/icons/search.svg?react";
|
||||||
|
|
||||||
@@ -45,6 +38,7 @@ const SearchAdornment = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//TODO keep search state inside of component
|
||||||
const Search = ({
|
const Search = ({
|
||||||
id,
|
id,
|
||||||
options,
|
options,
|
||||||
@@ -141,8 +135,7 @@ const Search = ({
|
|||||||
: {}
|
: {}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{option[filteredBy] +
|
{option[filteredBy] + (secondaryLabel ? ` (${option[secondaryLabel]})` : "")}
|
||||||
(secondaryLabel ? ` (${option[secondaryLabel]})` : "")}
|
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import {
|
import { MenuItem, Select as MuiSelect, Stack, Typography } from "@mui/material";
|
||||||
MenuItem,
|
|
||||||
Select as MuiSelect,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
@@ -51,6 +46,7 @@ const Select = ({
|
|||||||
value,
|
value,
|
||||||
items,
|
items,
|
||||||
onChange,
|
onChange,
|
||||||
|
onBlur,
|
||||||
sx,
|
sx,
|
||||||
name = "",
|
name = "",
|
||||||
}) => {
|
}) => {
|
||||||
@@ -63,7 +59,10 @@ const Select = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap={theme.spacing(2)} className="select-wrapper">
|
<Stack
|
||||||
|
gap={theme.spacing(2)}
|
||||||
|
className="select-wrapper"
|
||||||
|
>
|
||||||
{label && (
|
{label && (
|
||||||
<Typography
|
<Typography
|
||||||
component="h3"
|
component="h3"
|
||||||
@@ -78,6 +77,7 @@ const Select = ({
|
|||||||
className="select-component"
|
className="select-component"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
onBlur={onBlur}
|
||||||
displayEmpty
|
displayEmpty
|
||||||
name={name}
|
name={name}
|
||||||
inputProps={{ id: id }}
|
inputProps={{ id: id }}
|
||||||
@@ -142,6 +142,7 @@ Select.propTypes = {
|
|||||||
})
|
})
|
||||||
).isRequired,
|
).isRequired,
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
|
onBlur: PropTypes.func,
|
||||||
sx: PropTypes.object,
|
sx: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -86,10 +86,7 @@ const lightenColor = (color, percent) => {
|
|||||||
const ColoredLabel = ({ label, color }) => {
|
const ColoredLabel = ({ label, color }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
// If an invalid color is passed, default to the labelGray color
|
// If an invalid color is passed, default to the labelGray color
|
||||||
if (
|
if (typeof color !== "string" || !/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(color)) {
|
||||||
typeof color !== "string" ||
|
|
||||||
!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(color)
|
|
||||||
) {
|
|
||||||
color = theme.palette.border.light;
|
color = theme.palette.border.light;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,13 +177,7 @@ const StatusLabel = ({ status, text, customStyles }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
StatusLabel.propTypes = {
|
StatusLabel.propTypes = {
|
||||||
status: PropTypes.oneOf([
|
status: PropTypes.oneOf(["up", "down", "paused", "pending", "cannot resolve"]),
|
||||||
"up",
|
|
||||||
"down",
|
|
||||||
"paused",
|
|
||||||
"pending",
|
|
||||||
"cannot resolve",
|
|
||||||
]),
|
|
||||||
text: PropTypes.string,
|
text: PropTypes.string,
|
||||||
customStyles: PropTypes.object,
|
customStyles: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import {
|
import { Box, IconButton, LinearProgress, Stack, Typography } from "@mui/material";
|
||||||
Box,
|
|
||||||
IconButton,
|
|
||||||
LinearProgress,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import CloseIcon from "@mui/icons-material/Close";
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
import ErrorOutlineOutlinedIcon from "@mui/icons-material/ErrorOutlineOutlined";
|
import ErrorOutlineOutlinedIcon from "@mui/icons-material/ErrorOutlineOutlined";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
@@ -23,14 +17,7 @@ import "./index.css";
|
|||||||
* @returns {JSX.Element} The rendered component.
|
* @returns {JSX.Element} The rendered component.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ProgressUpload = ({
|
const ProgressUpload = ({ icon, label, size, progress = 0, onClick, error }) => {
|
||||||
icon,
|
|
||||||
label,
|
|
||||||
size,
|
|
||||||
progress = 0,
|
|
||||||
onClick,
|
|
||||||
error,
|
|
||||||
}) => {
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -104,10 +91,16 @@ const ProgressUpload = ({
|
|||||||
</Typography>
|
</Typography>
|
||||||
) : (
|
) : (
|
||||||
<Box color={theme.palette.text.tertiary}>
|
<Box color={theme.palette.text.tertiary}>
|
||||||
<Typography component="h2" mb={theme.spacing(1.5)}>
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
mb={theme.spacing(1.5)}
|
||||||
|
>
|
||||||
{error ? error : label}
|
{error ? error : label}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography component="p" sx={{ opacity: 0.6 }}>
|
<Typography
|
||||||
|
component="p"
|
||||||
|
sx={{ opacity: 0.6 }}
|
||||||
|
>
|
||||||
{!error && size}
|
{!error && size}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -142,7 +135,10 @@ const ProgressUpload = ({
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
{!error ? (
|
{!error ? (
|
||||||
<Stack direction="row" alignItems="center">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
<Box sx={{ width: "100%", mr: theme.spacing(5) }}>
|
<Box sx={{ width: "100%", mr: theme.spacing(5) }}>
|
||||||
<LinearProgress
|
<LinearProgress
|
||||||
variant="determinate"
|
variant="determinate"
|
||||||
|
|||||||
@@ -27,11 +27,17 @@ CustomStepIcon.propTypes = {
|
|||||||
const ProgressStepper = ({ steps }) => {
|
const ProgressStepper = ({ steps }) => {
|
||||||
const [activeStep, setActiveStep] = React.useState(1);
|
const [activeStep, setActiveStep] = React.useState(1);
|
||||||
return (
|
return (
|
||||||
<Stepper activeStep={activeStep} alternativeLabel>
|
<Stepper
|
||||||
|
activeStep={activeStep}
|
||||||
|
alternativeLabel
|
||||||
|
>
|
||||||
{steps.map((step, index) => {
|
{steps.map((step, index) => {
|
||||||
const color = activeStep === index ? "primary" : "inherit";
|
const color = activeStep === index ? "primary" : "inherit";
|
||||||
return (
|
return (
|
||||||
<Step key={step.label} onClick={() => setActiveStep(index)}>
|
<Step
|
||||||
|
key={step.label}
|
||||||
|
onClick={() => setActiveStep(index)}
|
||||||
|
>
|
||||||
<StepLabel StepIconComponent={CustomStepIcon}>
|
<StepLabel StepIconComponent={CustomStepIcon}>
|
||||||
<Typography
|
<Typography
|
||||||
variant="body1"
|
variant="body1"
|
||||||
@@ -41,7 +47,10 @@ const ProgressStepper = ({ steps }) => {
|
|||||||
{step.label}
|
{step.label}
|
||||||
</Typography>
|
</Typography>
|
||||||
</StepLabel>
|
</StepLabel>
|
||||||
<Typography variant="body1" color={color}>
|
<Typography
|
||||||
|
variant="body1"
|
||||||
|
color={color}
|
||||||
|
>
|
||||||
{step.content}
|
{step.content}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Step>
|
</Step>
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ const ProtectedRoute = ({ Component, ...rest }) => {
|
|||||||
return authState.authToken ? (
|
return authState.authToken ? (
|
||||||
<Component {...rest} />
|
<Component {...rest} />
|
||||||
) : (
|
) : (
|
||||||
<Navigate to="/login" replace />
|
<Navigate
|
||||||
|
to="/login"
|
||||||
|
replace
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ import ArrowUp from "../../assets/icons/up-arrow.svg?react";
|
|||||||
import ArrowRight from "../../assets/icons/right-arrow.svg?react";
|
import ArrowRight from "../../assets/icons/right-arrow.svg?react";
|
||||||
import ArrowLeft from "../../assets/icons/left-arrow.svg?react";
|
import ArrowLeft from "../../assets/icons/left-arrow.svg?react";
|
||||||
import DotsVertical from "../../assets/icons/dots-vertical.svg?react";
|
import DotsVertical from "../../assets/icons/dots-vertical.svg?react";
|
||||||
|
import ChangeLog from "../../assets/icons/changeLog.svg?react";
|
||||||
|
import Docs from "../../assets/icons/docs.svg?react";
|
||||||
|
import Folder from "../../assets/icons/folder.svg?react";
|
||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
@@ -66,12 +69,30 @@ const menu = [
|
|||||||
{ name: "Team", path: "account/team", icon: <TeamSvg /> },
|
{ name: "Team", path: "account/team", icon: <TeamSvg /> },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Other",
|
||||||
|
icon: <Folder />,
|
||||||
|
nested: [
|
||||||
|
{ name: "Settings", path: "settings", icon: <Settings /> },
|
||||||
|
{ name: "Support", path: "support", icon: <Support /> },
|
||||||
|
{ name: "Docs", path: "docs", icon: <Docs /> },
|
||||||
|
{ name: "Changelog", path: "changelog", icon: <ChangeLog /> },
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const other = [
|
const URL_MAP = {
|
||||||
{ name: "Support", path: "support", icon: <Support /> },
|
support: "https://github.com/bluewave-labs/bluewave-uptime/issues",
|
||||||
{ name: "Settings", path: "settings", icon: <Settings /> },
|
docs: "https://bluewavelabs.gitbook.io/uptime-manager",
|
||||||
];
|
changelog: "https://github.com/bluewave-labs/bluewave-uptime/releases",
|
||||||
|
};
|
||||||
|
|
||||||
|
const PATH_MAP = {
|
||||||
|
monitors: "Dashboard",
|
||||||
|
pagespeed: "Dashboard",
|
||||||
|
account: "Account",
|
||||||
|
settings: "Other",
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @component
|
* @component
|
||||||
@@ -87,7 +108,7 @@ function Sidebar() {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const authState = useSelector((state) => state.auth);
|
const authState = useSelector((state) => state.auth);
|
||||||
const collapsed = useSelector((state) => state.ui.sidebar.collapsed);
|
const collapsed = useSelector((state) => state.ui.sidebar.collapsed);
|
||||||
const [open, setOpen] = useState({ Dashboard: false, Account: false });
|
const [open, setOpen] = useState({ Dashboard: false, Account: false, Other: false });
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
const [popup, setPopup] = useState();
|
const [popup, setPopup] = useState();
|
||||||
const { user } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
@@ -120,13 +141,13 @@ function Sidebar() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
const matchedKey = Object.keys(PATH_MAP).find((key) =>
|
||||||
location.pathname.includes("monitors") ||
|
location.pathname.includes(key)
|
||||||
location.pathname.includes("pagespeed")
|
);
|
||||||
)
|
|
||||||
setOpen((prev) => ({ ...prev, Dashboard: true }));
|
if (matchedKey) {
|
||||||
else if (location.pathname.includes("/account"))
|
setOpen((prev) => ({ ...prev, [PATH_MAP[matchedKey]]: true }));
|
||||||
setOpen((prev) => ({ ...prev, Account: true }));
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -151,8 +172,18 @@ function Sidebar() {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack pt={theme.spacing(6)} pb={theme.spacing(12)} pl={theme.spacing(8)}>
|
<Stack
|
||||||
<Stack direction="row" alignItems="center" gap={theme.spacing(4)}>
|
pt={theme.spacing(6)}
|
||||||
|
pb={theme.spacing(12)}
|
||||||
|
pl={theme.spacing(8)}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
gap={theme.spacing(4)}
|
||||||
|
onClick={() => window.open("https://github.com/bluewave-labs/bluewave-uptime", "_blank", "noreferrer")}
|
||||||
|
sx={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
<Stack
|
<Stack
|
||||||
justifyContent="center"
|
justifyContent="center"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
@@ -202,7 +233,9 @@ function Sidebar() {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setOpen({ Dashboard: false, Account: false });
|
setOpen((prev) =>
|
||||||
|
Object.fromEntries(Object.keys(prev).map((key) => [key, false]))
|
||||||
|
);
|
||||||
dispatch(toggleSidebar());
|
dispatch(toggleSidebar());
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -250,9 +283,7 @@ function Sidebar() {
|
|||||||
disableInteractive
|
disableInteractive
|
||||||
>
|
>
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
className={
|
className={location.pathname.includes(item.path) ? "selected-path" : ""}
|
||||||
location.pathname.includes(item.path) ? "selected-path" : ""
|
|
||||||
}
|
|
||||||
onClick={() => navigate(`/${item.path}`)}
|
onClick={() => navigate(`/${item.path}`)}
|
||||||
sx={{
|
sx={{
|
||||||
height: "37px",
|
height: "37px",
|
||||||
@@ -286,9 +317,7 @@ function Sidebar() {
|
|||||||
>
|
>
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
className={
|
className={
|
||||||
Boolean(anchorEl) && popup === item.name
|
Boolean(anchorEl) && popup === item.name ? "selected-path" : ""
|
||||||
? "selected-path"
|
|
||||||
: ""
|
|
||||||
}
|
}
|
||||||
onClick={(event) => openPopup(event, item.name)}
|
onClick={(event) => openPopup(event, item.name)}
|
||||||
sx={{
|
sx={{
|
||||||
@@ -340,13 +369,16 @@ function Sidebar() {
|
|||||||
return (
|
return (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
className={
|
className={
|
||||||
location.pathname.includes(child.path)
|
location.pathname.includes(child.path) ? "selected-path" : ""
|
||||||
? "selected-path"
|
|
||||||
: ""
|
|
||||||
}
|
}
|
||||||
key={child.path}
|
key={child.path}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
const url = URL_MAP[child.path];
|
||||||
|
if (url) {
|
||||||
|
window.open(url, "_blank", "noreferrer");
|
||||||
|
} else {
|
||||||
navigate(`/${child.path}`);
|
navigate(`/${child.path}`);
|
||||||
|
}
|
||||||
closePopup();
|
closePopup();
|
||||||
}}
|
}}
|
||||||
sx={{
|
sx={{
|
||||||
@@ -372,8 +404,8 @@ function Sidebar() {
|
|||||||
<ListItemButton
|
<ListItemButton
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setOpen((prev) => ({
|
setOpen((prev) => ({
|
||||||
...prev,
|
...Object.fromEntries(Object.keys(prev).map((key) => [key, false])),
|
||||||
[`${item.name}`]: !prev[`${item.name}`],
|
[item.name]: !prev[item.name],
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
sx={{
|
sx={{
|
||||||
@@ -386,7 +418,10 @@ function Sidebar() {
|
|||||||
<ListItemText>{item.name}</ListItemText>
|
<ListItemText>{item.name}</ListItemText>
|
||||||
{open[`${item.name}`] ? <ArrowUp /> : <ArrowDown />}
|
{open[`${item.name}`] ? <ArrowUp /> : <ArrowDown />}
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
<Collapse in={open[`${item.name}`]} timeout="auto">
|
<Collapse
|
||||||
|
in={open[`${item.name}`]}
|
||||||
|
timeout="auto"
|
||||||
|
>
|
||||||
<List
|
<List
|
||||||
component="div"
|
component="div"
|
||||||
disablePadding
|
disablePadding
|
||||||
@@ -404,12 +439,17 @@ function Sidebar() {
|
|||||||
return (
|
return (
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
className={
|
className={
|
||||||
location.pathname.includes(child.path)
|
location.pathname.includes(child.path) ? "selected-path" : ""
|
||||||
? "selected-path"
|
|
||||||
: ""
|
|
||||||
}
|
}
|
||||||
key={child.path}
|
key={child.path}
|
||||||
onClick={() => navigate(`/${child.path}`)}
|
onClick={() => {
|
||||||
|
const url = URL_MAP[child.path];
|
||||||
|
if (url) {
|
||||||
|
window.open(url, "_blank", "noreferrer");
|
||||||
|
} else {
|
||||||
|
navigate(`/${child.path}`);
|
||||||
|
}
|
||||||
|
}}
|
||||||
sx={{
|
sx={{
|
||||||
gap: theme.spacing(4),
|
gap: theme.spacing(4),
|
||||||
borderRadius: theme.shape.borderRadius,
|
borderRadius: theme.shape.borderRadius,
|
||||||
@@ -442,9 +482,7 @@ function Sidebar() {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ListItemIcon sx={{ minWidth: 0 }}>
|
<ListItemIcon sx={{ minWidth: 0 }}>{child.icon}</ListItemIcon>
|
||||||
{child.icon}
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText>{child.name}</ListItemText>
|
<ListItemText>{child.name}</ListItemText>
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
);
|
);
|
||||||
@@ -455,70 +493,6 @@ function Sidebar() {
|
|||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</List>
|
</List>
|
||||||
<Divider sx={{ my: theme.spacing(4) }} />
|
|
||||||
{/* other */}
|
|
||||||
<List
|
|
||||||
component="nav"
|
|
||||||
aria-labelledby="nested-other-subheader"
|
|
||||||
subheader={
|
|
||||||
<ListSubheader
|
|
||||||
component="div"
|
|
||||||
id="nested-other-subheader"
|
|
||||||
sx={{
|
|
||||||
pt: theme.spacing(4),
|
|
||||||
px: collapsed ? 0 : theme.spacing(4),
|
|
||||||
backgroundColor: "transparent",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Other
|
|
||||||
</ListSubheader>
|
|
||||||
}
|
|
||||||
sx={{ px: theme.spacing(6) }}
|
|
||||||
>
|
|
||||||
{other.map((item) => (
|
|
||||||
<Tooltip
|
|
||||||
key={item.path}
|
|
||||||
placement="right"
|
|
||||||
title={collapsed ? item.name : ""}
|
|
||||||
slotProps={{
|
|
||||||
popper: {
|
|
||||||
modifiers: [
|
|
||||||
{
|
|
||||||
name: "offset",
|
|
||||||
options: {
|
|
||||||
offset: [0, -16],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
disableInteractive
|
|
||||||
>
|
|
||||||
<ListItemButton
|
|
||||||
className={
|
|
||||||
location.pathname.includes(item.path) ? "selected-path" : ""
|
|
||||||
}
|
|
||||||
onClick={() =>
|
|
||||||
item.path === "support"
|
|
||||||
? window.open(
|
|
||||||
"https://github.com/bluewave-labs/bluewave-uptime/issues",
|
|
||||||
"_blank",
|
|
||||||
"noreferrer"
|
|
||||||
)
|
|
||||||
: navigate(`/${item.path}`)
|
|
||||||
}
|
|
||||||
sx={{
|
|
||||||
gap: theme.spacing(4),
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
px: theme.spacing(4),
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon sx={{ minWidth: 0 }}>{item.icon}</ListItemIcon>
|
|
||||||
<ListItemText>{item.name}</ListItemText>
|
|
||||||
</ListItemButton>
|
|
||||||
</Tooltip>
|
|
||||||
))}
|
|
||||||
</List>
|
|
||||||
<Divider sx={{ mt: "auto" }} />
|
<Divider sx={{ mt: "auto" }} />
|
||||||
|
|
||||||
<Stack
|
<Stack
|
||||||
@@ -560,14 +534,20 @@ function Sidebar() {
|
|||||||
<>
|
<>
|
||||||
<Avatar small={true} />
|
<Avatar small={true} />
|
||||||
<Box ml={theme.spacing(2)}>
|
<Box ml={theme.spacing(2)}>
|
||||||
<Typography component="span" fontWeight={500}>
|
<Typography
|
||||||
|
component="span"
|
||||||
|
fontWeight={500}
|
||||||
|
>
|
||||||
{authState.user?.firstName} {authState.user?.lastName}
|
{authState.user?.firstName} {authState.user?.lastName}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography sx={{ textTransform: "capitalize" }}>
|
<Typography sx={{ textTransform: "capitalize" }}>
|
||||||
{authState.user?.role}
|
{authState.user?.role}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Tooltip title="Controls" disableInteractive>
|
<Tooltip
|
||||||
|
title="Controls"
|
||||||
|
disableInteractive
|
||||||
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
sx={{
|
sx={{
|
||||||
ml: "auto",
|
ml: "auto",
|
||||||
@@ -622,7 +602,11 @@ function Sidebar() {
|
|||||||
{collapsed && (
|
{collapsed && (
|
||||||
<MenuItem sx={{ cursor: "default", minWidth: "150px" }}>
|
<MenuItem sx={{ cursor: "default", minWidth: "150px" }}>
|
||||||
<Box mb={theme.spacing(2)}>
|
<Box mb={theme.spacing(2)}>
|
||||||
<Typography component="span" fontWeight={500} fontSize={13}>
|
<Typography
|
||||||
|
component="span"
|
||||||
|
fontWeight={500}
|
||||||
|
fontSize={13}
|
||||||
|
>
|
||||||
{authState.user?.firstName} {authState.user?.lastName}
|
{authState.user?.firstName} {authState.user?.lastName}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography sx={{ textTransform: "capitalize", fontSize: 12 }}>
|
<Typography sx={{ textTransform: "capitalize", fontSize: 12 }}>
|
||||||
@@ -632,7 +616,7 @@ function Sidebar() {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
{collapsed && <Divider />}
|
{collapsed && <Divider />}
|
||||||
<MenuItem
|
{/* <MenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
dispatch(setMode("light"));
|
dispatch(setMode("light"));
|
||||||
closePopup();
|
closePopup();
|
||||||
@@ -647,7 +631,7 @@ function Sidebar() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Dark
|
Dark
|
||||||
</MenuItem>
|
</MenuItem> */}
|
||||||
<Divider />
|
<Divider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={logout}
|
onClick={logout}
|
||||||
|
|||||||
@@ -171,7 +171,10 @@ const PasswordPanel = () => {
|
|||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import TabPanel from "@mui/lab/TabPanel";
|
import TabPanel from "@mui/lab/TabPanel";
|
||||||
import { Box, Button, Divider, Modal, Stack, Typography } from "@mui/material";
|
import { Box, Button, Divider, Stack, Typography } from "@mui/material";
|
||||||
import Avatar from "../../Avatar";
|
import Avatar from "../../Avatar";
|
||||||
import Field from "../../Inputs/Field";
|
import Field from "../../Inputs/Field";
|
||||||
import ImageField from "../../Inputs/Image";
|
import ImageField from "../../Inputs/Image";
|
||||||
import { credentials, imageValidation } from "../../../Validation/validation";
|
import { credentials, imageValidation } from "../../../Validation/validation";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import {
|
import { clearAuthState, deleteUser, update } from "../../../Features/Auth/authSlice";
|
||||||
clearAuthState,
|
|
||||||
deleteUser,
|
|
||||||
update,
|
|
||||||
} from "../../../Features/Auth/authSlice";
|
|
||||||
import ImageIcon from "@mui/icons-material/Image";
|
import ImageIcon from "@mui/icons-material/Image";
|
||||||
import ProgressUpload from "../../ProgressBars";
|
import ProgressUpload from "../../ProgressBars";
|
||||||
import { formatBytes } from "../../../Utils/fileUtils";
|
import { formatBytes } from "../../../Utils/fileUtils";
|
||||||
@@ -19,6 +15,8 @@ import { clearUptimeMonitorState } from "../../../Features/UptimeMonitors/uptime
|
|||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import { logger } from "../../../Utils/Logger";
|
import { logger } from "../../../Utils/Logger";
|
||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
|
import { GenericDialog } from "../../Dialog/genericDialog";
|
||||||
|
import Dialog from "../../Dialog";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProfilePanel component displays a form for editing user profile information
|
* ProfilePanel component displays a form for editing user profile information
|
||||||
@@ -69,10 +67,7 @@ const ProfilePanel = () => {
|
|||||||
// Handles image file
|
// Handles image file
|
||||||
const handlePicture = (event) => {
|
const handlePicture = (event) => {
|
||||||
const pic = event.target.files[0];
|
const pic = event.target.files[0];
|
||||||
let error = validateField(
|
let error = validateField({ type: pic.type, size: pic.size }, imageValidation);
|
||||||
{ type: pic.type, size: pic.size },
|
|
||||||
imageValidation
|
|
||||||
);
|
|
||||||
if (error) return;
|
if (error) return;
|
||||||
|
|
||||||
setProgress((prev) => ({ ...prev, isLoading: true }));
|
setProgress((prev) => ({ ...prev, isLoading: true }));
|
||||||
@@ -259,7 +254,10 @@ const ProfilePanel = () => {
|
|||||||
<Stack direction="row">
|
<Stack direction="row">
|
||||||
<Stack flex={0.9}>
|
<Stack flex={0.9}>
|
||||||
<Typography component="h1">Email</Typography>
|
<Typography component="h1">Email</Typography>
|
||||||
<Typography component="p" sx={{ opacity: 0.6 }}>
|
<Typography
|
||||||
|
component="p"
|
||||||
|
sx={{ opacity: 0.6 }}
|
||||||
|
>
|
||||||
This is your current email address — it cannot be changed.
|
This is your current email address — it cannot be changed.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -276,11 +274,18 @@ const ProfilePanel = () => {
|
|||||||
<Stack direction="row">
|
<Stack direction="row">
|
||||||
<Stack flex={0.9}>
|
<Stack flex={0.9}>
|
||||||
<Typography component="h1">Your photo</Typography>
|
<Typography component="h1">Your photo</Typography>
|
||||||
<Typography component="p" sx={{ opacity: 0.6 }}>
|
<Typography
|
||||||
|
component="p"
|
||||||
|
sx={{ opacity: 0.6 }}
|
||||||
|
>
|
||||||
This photo will be displayed in your profile page.
|
This photo will be displayed in your profile page.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" alignItems="center" flex={1}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
flex={1}
|
||||||
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
src={
|
src={
|
||||||
localData?.deleteProfileImage
|
localData?.deleteProfileImage
|
||||||
@@ -291,10 +296,18 @@ const ProfilePanel = () => {
|
|||||||
}
|
}
|
||||||
sx={{ mr: "8px" }}
|
sx={{ mr: "8px" }}
|
||||||
/>
|
/>
|
||||||
<Button variant="text" color="info" onClick={handleDeletePicture}>
|
<Button
|
||||||
|
variant="text"
|
||||||
|
color="info"
|
||||||
|
onClick={handleDeletePicture}
|
||||||
|
>
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="text" color="primary" onClick={openPictureModal}>
|
<Button
|
||||||
|
variant="text"
|
||||||
|
color="primary"
|
||||||
|
onClick={openPictureModal}
|
||||||
|
>
|
||||||
Update
|
Update
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -306,7 +319,10 @@ const ProfilePanel = () => {
|
|||||||
marginY: theme.spacing(1),
|
marginY: theme.spacing(1),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
>
|
||||||
<Box width="fit-content">
|
<Box width="fit-content">
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
variant="contained"
|
variant="contained"
|
||||||
@@ -314,9 +330,7 @@ const ProfilePanel = () => {
|
|||||||
onClick={handleSaveProfile}
|
onClick={handleSaveProfile}
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
loadingIndicator="Saving..."
|
loadingIndicator="Saving..."
|
||||||
disabled={
|
disabled={Object.keys(errors).length !== 0 && !errors?.picture && true}
|
||||||
Object.keys(errors).length !== 0 && !errors?.picture && true
|
|
||||||
}
|
|
||||||
sx={{ px: theme.spacing(12) }}
|
sx={{ px: theme.spacing(12) }}
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
@@ -332,12 +346,19 @@ const ProfilePanel = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{!user.role.includes("demo") && (
|
{!user.role.includes("demo") && (
|
||||||
<Box component="form" noValidate spellCheck="false">
|
<Box
|
||||||
|
component="form"
|
||||||
|
noValidate
|
||||||
|
spellCheck="false"
|
||||||
|
>
|
||||||
<Box mb={theme.spacing(6)}>
|
<Box mb={theme.spacing(6)}>
|
||||||
<Typography component="h1">Delete account</Typography>
|
<Typography component="h1">Delete account</Typography>
|
||||||
<Typography component="p" sx={{ opacity: 0.6 }}>
|
<Typography
|
||||||
Note that deleting your account will remove all data from our
|
component="p"
|
||||||
system. This is permanent and non-recoverable.
|
sx={{ opacity: 0.6 }}
|
||||||
|
>
|
||||||
|
Note that deleting your account will remove all data from our system. This
|
||||||
|
is permanent and non-recoverable.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Button
|
<Button
|
||||||
@@ -350,91 +371,26 @@ const ProfilePanel = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
{/* TODO - Update ModalPopup Component with @mui for reusability */}
|
{/* TODO - Update ModalPopup Component with @mui for reusability */}
|
||||||
<Modal
|
|
||||||
aria-labelledby="modal-delete-account"
|
<Dialog
|
||||||
aria-describedby="delete-account-confirmation"
|
|
||||||
open={isModalOpen("delete")}
|
open={isModalOpen("delete")}
|
||||||
onClose={() => setIsOpen("")}
|
theme={theme}
|
||||||
disablePortal
|
title={"Really delete this account?"}
|
||||||
>
|
description={
|
||||||
<Stack
|
"If you delete your account, you will no longer be able to sign in, and all of your data will be deleted. Deleting your account is permanent and non-recoverable action."
|
||||||
gap={theme.spacing(5)}
|
}
|
||||||
sx={{
|
onCancel={() => setIsOpen("")}
|
||||||
position: "absolute",
|
confirmationButtonLabel={"Delete account"}
|
||||||
top: "50%",
|
onConfirm={handleDeleteAccount}
|
||||||
left: "50%",
|
isLoading={isLoading}
|
||||||
transform: "translate(-50%, -50%)",
|
/>
|
||||||
width: 500,
|
|
||||||
bgcolor: theme.palette.background.main,
|
<GenericDialog
|
||||||
border: 1,
|
title={"Upload Image"}
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
boxShadow: 24,
|
|
||||||
p: theme.spacing(15),
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography id="modal-delete-account" component="h1">
|
|
||||||
Really delete this account?
|
|
||||||
</Typography>
|
|
||||||
<Typography id="delete-account-confirmation" component="p">
|
|
||||||
If you delete your account, you will no longer be able to sign in,
|
|
||||||
and all of your data will be deleted. Deleting your account is
|
|
||||||
permanent and non-recoverable action.
|
|
||||||
</Typography>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
gap={theme.spacing(5)}
|
|
||||||
mt={theme.spacing(5)}
|
|
||||||
justifyContent="flex-end"
|
|
||||||
>
|
|
||||||
<Button variant="text" color="info" onClick={() => setIsOpen("")}>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<LoadingButton
|
|
||||||
variant="contained"
|
|
||||||
color="error"
|
|
||||||
onClick={handleDeleteAccount}
|
|
||||||
loading={isLoading}
|
|
||||||
>
|
|
||||||
Delete account
|
|
||||||
</LoadingButton>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
</Modal>
|
|
||||||
<Modal
|
|
||||||
aria-labelledby="modal-update-picture"
|
|
||||||
aria-describedby="update-profile-picture"
|
|
||||||
open={isModalOpen("picture")}
|
open={isModalOpen("picture")}
|
||||||
onClose={closePictureModal}
|
onClose={closePictureModal}
|
||||||
|
theme={theme}
|
||||||
>
|
>
|
||||||
<Stack
|
|
||||||
sx={{
|
|
||||||
position: "absolute",
|
|
||||||
top: "50%",
|
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
width: 475,
|
|
||||||
bgcolor: theme.palette.background.main,
|
|
||||||
border: 1,
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
boxShadow: theme.shape.boxShadow,
|
|
||||||
p: theme.spacing(15),
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
id="modal-update-picture"
|
|
||||||
component="h1"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
Upload Image
|
|
||||||
</Typography>
|
|
||||||
<ImageField
|
<ImageField
|
||||||
id="update-profile-picture"
|
id="update-profile-picture"
|
||||||
src={
|
src={
|
||||||
@@ -470,14 +426,10 @@ const ProfilePanel = () => {
|
|||||||
justifyContent="flex-end"
|
justifyContent="flex-end"
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="text"
|
||||||
color="secondary"
|
color="info"
|
||||||
disabled
|
onClick={removePicture}
|
||||||
sx={{ mr: "auto" }}
|
|
||||||
>
|
>
|
||||||
Edit
|
|
||||||
</Button>
|
|
||||||
<Button variant="text" color="info" onClick={removePicture}>
|
|
||||||
Remove
|
Remove
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
@@ -494,8 +446,7 @@ const ProfilePanel = () => {
|
|||||||
Update
|
Update
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</GenericDialog>
|
||||||
</Modal>
|
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import TabPanel from "@mui/lab/TabPanel";
|
import TabPanel from "@mui/lab/TabPanel";
|
||||||
import {
|
import { Button, ButtonGroup, Stack, Typography } from "@mui/material";
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
ButtonGroup,
|
|
||||||
Modal,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import Field from "../../Inputs/Field";
|
import Field from "../../Inputs/Field";
|
||||||
import { credentials } from "../../../Validation/validation";
|
import { credentials } from "../../../Validation/validation";
|
||||||
@@ -17,6 +10,7 @@ import { useSelector } from "react-redux";
|
|||||||
import BasicTable from "../../BasicTable";
|
import BasicTable from "../../BasicTable";
|
||||||
import Select from "../../Inputs/Select";
|
import Select from "../../Inputs/Select";
|
||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
|
import { GenericDialog } from "../../Dialog/genericDialog";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TeamPanel component manages the organization and team members,
|
* TeamPanel component manages the organization and team members,
|
||||||
@@ -38,10 +32,10 @@ const TeamPanel = () => {
|
|||||||
|
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
const { authToken, user } = useSelector((state) => state.auth);
|
||||||
//TODO
|
//TODO
|
||||||
const [orgStates, setOrgStates] = useState({
|
// const [orgStates, setOrgStates] = useState({
|
||||||
name: "Bluewave Labs",
|
// name: "Bluewave Labs",
|
||||||
isEdit: false,
|
// isEdit: false,
|
||||||
});
|
// });
|
||||||
const [toInvite, setToInvite] = useState({
|
const [toInvite, setToInvite] = useState({
|
||||||
email: "",
|
email: "",
|
||||||
role: ["0"],
|
role: ["0"],
|
||||||
@@ -49,6 +43,7 @@ const TeamPanel = () => {
|
|||||||
const [tableData, setTableData] = useState({});
|
const [tableData, setTableData] = useState({});
|
||||||
const [members, setMembers] = useState([]);
|
const [members, setMembers] = useState([]);
|
||||||
const [filter, setFilter] = useState("all");
|
const [filter, setFilter] = useState("all");
|
||||||
|
const [isDisabled, setIsDisabled] = useState(true);
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
const [isSendingInvite, setIsSendingInvite] = useState(false);
|
const [isSendingInvite, setIsSendingInvite] = useState(false);
|
||||||
|
|
||||||
@@ -74,9 +69,7 @@ const TeamPanel = () => {
|
|||||||
if (filter !== "all")
|
if (filter !== "all")
|
||||||
team = members.filter((member) => {
|
team = members.filter((member) => {
|
||||||
if (filter === "admin") {
|
if (filter === "admin") {
|
||||||
return (
|
return member.role.includes("admin") || member.role.includes("superadmin");
|
||||||
member.role.includes("admin") || member.role.includes("superadmin")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return member.role.includes(filter);
|
return member.role.includes(filter);
|
||||||
});
|
});
|
||||||
@@ -137,12 +130,15 @@ const TeamPanel = () => {
|
|||||||
|
|
||||||
setTableData(data);
|
setTableData(data);
|
||||||
}, [members, filter]);
|
}, [members, filter]);
|
||||||
|
useEffect(() => {
|
||||||
|
setIsDisabled(Object.keys(errors).length !== 0 || toInvite.email === "");
|
||||||
|
}, [errors, toInvite.email]);
|
||||||
|
|
||||||
// RENAME ORGANIZATION
|
// RENAME ORGANIZATION
|
||||||
const toggleEdit = () => {
|
// const toggleEdit = () => {
|
||||||
setOrgStates((prev) => ({ ...prev, isEdit: !prev.isEdit }));
|
// setOrgStates((prev) => ({ ...prev, isEdit: !prev.isEdit }));
|
||||||
};
|
// };
|
||||||
const handleRename = () => {};
|
// const handleRename = () => {};
|
||||||
|
|
||||||
// INVITE MEMBER
|
// INVITE MEMBER
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
@@ -154,10 +150,7 @@ const TeamPanel = () => {
|
|||||||
email: value,
|
email: value,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const validation = credentials.validate(
|
const validation = credentials.validate({ email: value }, { abortEarly: false });
|
||||||
{ email: value },
|
|
||||||
{ abortEarly: false }
|
|
||||||
);
|
|
||||||
|
|
||||||
setErrors((prev) => {
|
setErrors((prev) => {
|
||||||
const updatedErrors = { ...prev };
|
const updatedErrors = { ...prev };
|
||||||
@@ -172,6 +165,10 @@ const TeamPanel = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleInviteMember = async () => {
|
const handleInviteMember = async () => {
|
||||||
|
if (!toInvite.email) {
|
||||||
|
setErrors((prev) => ({ ...prev, email: "Email is required." }));
|
||||||
|
return;
|
||||||
|
}
|
||||||
setIsSendingInvite(true);
|
setIsSendingInvite(true);
|
||||||
if (!toInvite.role.includes("user") || !toInvite.role.includes("admin"))
|
if (!toInvite.role.includes("user") || !toInvite.role.includes("admin"))
|
||||||
setToInvite((prev) => ({ ...prev, role: ["user"] }));
|
setToInvite((prev) => ({ ...prev, role: ["user"] }));
|
||||||
@@ -215,6 +212,7 @@ const TeamPanel = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<TabPanel
|
<TabPanel
|
||||||
|
className="team-panel table-container"
|
||||||
value="team"
|
value="team"
|
||||||
sx={{
|
sx={{
|
||||||
"& h1": {
|
"& h1": {
|
||||||
@@ -280,7 +278,10 @@ const TeamPanel = () => {
|
|||||||
gap={theme.spacing(12)}
|
gap={theme.spacing(12)}
|
||||||
>
|
>
|
||||||
<Typography component="h1">Team members</Typography>
|
<Typography component="h1">Team members</Typography>
|
||||||
<Stack direction="row" justifyContent="space-between">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems="flex-end"
|
alignItems="flex-end"
|
||||||
@@ -327,51 +328,16 @@ const TeamPanel = () => {
|
|||||||
table={"team"}
|
table={"team"}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Modal
|
|
||||||
aria-labelledby="modal-invite-member"
|
<GenericDialog
|
||||||
aria-describedby="invite-member-to-team"
|
title={"Invite new team member"}
|
||||||
|
description={
|
||||||
|
"When you add a new team member, they will get access to all monitors."
|
||||||
|
}
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
onClose={closeInviteModal}
|
onClose={closeInviteModal}
|
||||||
|
theme={theme}
|
||||||
>
|
>
|
||||||
<Stack
|
|
||||||
gap={theme.spacing(5)}
|
|
||||||
sx={{
|
|
||||||
position: "absolute",
|
|
||||||
top: "50%",
|
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
width: 450,
|
|
||||||
bgcolor: theme.palette.background.main,
|
|
||||||
border: 1,
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
boxShadow: theme.shape.boxShadow,
|
|
||||||
p: theme.spacing(15),
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box>
|
|
||||||
<Typography
|
|
||||||
id="modal-invite-member"
|
|
||||||
component="h1"
|
|
||||||
fontWeight={600}
|
|
||||||
fontColor={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
Invite new team member
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
id="invite-member-to-team"
|
|
||||||
component="p"
|
|
||||||
fontSize={13}
|
|
||||||
color={theme.palette.text.accent}
|
|
||||||
sx={{ mt: theme.spacing(1), mb: theme.spacing(4) }}
|
|
||||||
>
|
|
||||||
When you add a new team member, they will get access to all
|
|
||||||
monitors.
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Field
|
<Field
|
||||||
type="email"
|
type="email"
|
||||||
id="input-team-member"
|
id="input-team-member"
|
||||||
@@ -415,13 +381,12 @@ const TeamPanel = () => {
|
|||||||
color="primary"
|
color="primary"
|
||||||
onClick={handleInviteMember}
|
onClick={handleInviteMember}
|
||||||
loading={isSendingInvite}
|
loading={isSendingInvite}
|
||||||
disabled={Object.keys(errors).length !== 0}
|
disabled={isDisabled}
|
||||||
>
|
>
|
||||||
Send invite
|
Send invite
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</GenericDialog>
|
||||||
</Modal>
|
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ const initialState = {
|
|||||||
msg: null,
|
msg: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const register = createAsyncThunk(
|
export const register = createAsyncThunk("auth/register", async (form, thunkApi) => {
|
||||||
"auth/register",
|
|
||||||
async (form, thunkApi) => {
|
|
||||||
try {
|
try {
|
||||||
const res = await networkService.registerUser(form);
|
const res = await networkService.registerUser(form);
|
||||||
return res.data;
|
return res.data;
|
||||||
@@ -27,8 +25,7 @@ export const register = createAsyncThunk(
|
|||||||
};
|
};
|
||||||
return thunkApi.rejectWithValue(payload);
|
return thunkApi.rejectWithValue(payload);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
|
export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
|
||||||
try {
|
try {
|
||||||
@@ -46,9 +43,7 @@ export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const update = createAsyncThunk(
|
export const update = createAsyncThunk("auth/update", async (data, thunkApi) => {
|
||||||
"auth/update",
|
|
||||||
async (data, thunkApi) => {
|
|
||||||
const { authToken: token, localData: form } = data;
|
const { authToken: token, localData: form } = data;
|
||||||
const user = jwtDecode(token);
|
const user = jwtDecode(token);
|
||||||
try {
|
try {
|
||||||
@@ -63,8 +58,7 @@ export const update = createAsyncThunk(
|
|||||||
});
|
});
|
||||||
fd.append("profileImage", imageResult.data);
|
fd.append("profileImage", imageResult.data);
|
||||||
}
|
}
|
||||||
form.deleteProfileImage &&
|
form.deleteProfileImage && fd.append("deleteProfileImage", form.deleteProfileImage);
|
||||||
fd.append("deleteProfileImage", form.deleteProfileImage);
|
|
||||||
|
|
||||||
const res = await networkService.updateUser({
|
const res = await networkService.updateUser({
|
||||||
authToken: token,
|
authToken: token,
|
||||||
@@ -82,12 +76,9 @@ export const update = createAsyncThunk(
|
|||||||
};
|
};
|
||||||
return thunkApi.rejectWithValue(payload);
|
return thunkApi.rejectWithValue(payload);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
export const deleteUser = createAsyncThunk(
|
export const deleteUser = createAsyncThunk("auth/delete", async (data, thunkApi) => {
|
||||||
"auth/delete",
|
|
||||||
async (data, thunkApi) => {
|
|
||||||
const user = jwtDecode(data);
|
const user = jwtDecode(data);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -106,8 +97,7 @@ export const deleteUser = createAsyncThunk(
|
|||||||
};
|
};
|
||||||
return thunkApi.rejectWithValue(payload);
|
return thunkApi.rejectWithValue(payload);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
export const forgotPassword = createAsyncThunk(
|
export const forgotPassword = createAsyncThunk(
|
||||||
"auth/forgotPassword",
|
"auth/forgotPassword",
|
||||||
@@ -162,9 +152,7 @@ const handleAuthFulfilled = (state, action) => {
|
|||||||
const handleAuthRejected = (state, action) => {
|
const handleAuthRejected = (state, action) => {
|
||||||
state.isLoading = false;
|
state.isLoading = false;
|
||||||
state.success = false;
|
state.success = false;
|
||||||
state.msg = action.payload
|
state.msg = action.payload ? action.payload.msg : "Failed to login or register";
|
||||||
? action.payload.msg
|
|
||||||
: "Failed to login or register";
|
|
||||||
};
|
};
|
||||||
const handleUpdateFulfilled = (state, action) => {
|
const handleUpdateFulfilled = (state, action) => {
|
||||||
state.isLoading = false;
|
state.isLoading = false;
|
||||||
@@ -175,9 +163,7 @@ const handleUpdateFulfilled = (state, action) => {
|
|||||||
const handleUpdateRejected = (state, action) => {
|
const handleUpdateRejected = (state, action) => {
|
||||||
state.isLoading = false;
|
state.isLoading = false;
|
||||||
state.success = false;
|
state.success = false;
|
||||||
state.msg = action.payload
|
state.msg = action.payload ? action.payload.msg : "Failed to update profile data.";
|
||||||
? action.payload.msg
|
|
||||||
: "Failed to update profile data.";
|
|
||||||
};
|
};
|
||||||
const handleDeleteFulfilled = (state, action) => {
|
const handleDeleteFulfilled = (state, action) => {
|
||||||
state.isLoading = false;
|
state.isLoading = false;
|
||||||
@@ -197,9 +183,7 @@ const handleForgotFulfilled = (state, action) => {
|
|||||||
const handleForgotRejected = (state, action) => {
|
const handleForgotRejected = (state, action) => {
|
||||||
state.isLoading = false;
|
state.isLoading = false;
|
||||||
state.success = false;
|
state.success = false;
|
||||||
state.msg = action.payload
|
state.msg = action.payload ? action.payload.msg : "Failed to send reset instructions.";
|
||||||
? action.payload.msg
|
|
||||||
: "Failed to send reset instructions.";
|
|
||||||
};
|
};
|
||||||
const handleNewPasswordRejected = (state, action) => {
|
const handleNewPasswordRejected = (state, action) => {
|
||||||
state.isLoading = false;
|
state.isLoading = false;
|
||||||
|
|||||||
@@ -31,6 +31,30 @@ export const createPageSpeed = createAsyncThunk(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const checkEndpointResolution = createAsyncThunk(
|
||||||
|
"monitors/checkEndpoint",
|
||||||
|
async (data, thunkApi) => {
|
||||||
|
try {
|
||||||
|
const { authToken, monitorURL } = data;
|
||||||
|
|
||||||
|
const res = await networkService.checkEndpointResolution({
|
||||||
|
authToken: authToken,
|
||||||
|
monitorURL: monitorURL,
|
||||||
|
})
|
||||||
|
return res.data;
|
||||||
|
} catch (error) {
|
||||||
|
if (error.response && error.response.data) {
|
||||||
|
return thunkApi.rejectWithValue(error.response.data);
|
||||||
|
}
|
||||||
|
const payload = {
|
||||||
|
status: false,
|
||||||
|
msg: error.message ? error.message : "Unknown error",
|
||||||
|
};
|
||||||
|
return thunkApi.rejectWithValue(payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
export const getPagespeedMonitorById = createAsyncThunk(
|
export const getPagespeedMonitorById = createAsyncThunk(
|
||||||
"monitors/getMonitorById",
|
"monitors/getMonitorById",
|
||||||
async (data, thunkApi) => {
|
async (data, thunkApi) => {
|
||||||
@@ -222,7 +246,24 @@ const pageSpeedMonitorSlice = createSlice({
|
|||||||
? action.payload.msg
|
? action.payload.msg
|
||||||
: "Failed to create page speed monitor";
|
: "Failed to create page speed monitor";
|
||||||
})
|
})
|
||||||
|
// *****************************************************
|
||||||
|
// Resolve Endpoint
|
||||||
|
// *****************************************************
|
||||||
|
.addCase(checkEndpointResolution.pending, (state) => {
|
||||||
|
state.isLoading = true;
|
||||||
|
})
|
||||||
|
.addCase(checkEndpointResolution.fulfilled, (state, action) => {
|
||||||
|
state.isLoading = false;
|
||||||
|
state.success = action.payload.success;
|
||||||
|
state.msg = action.payload.msg;
|
||||||
|
})
|
||||||
|
.addCase(checkEndpointResolution.rejected, (state, action) => {
|
||||||
|
state.isLoading = false;
|
||||||
|
state.success = false;
|
||||||
|
state.msg = action.payload
|
||||||
|
? action.payload.msg
|
||||||
|
: "Failed to check endpoint resolution";
|
||||||
|
})
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
// Update Monitor
|
// Update Monitor
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|||||||
@@ -89,9 +89,7 @@ const handleUpdateSettingsFulfilled = (state, action) => {
|
|||||||
const handleUpdateSettingsRejected = (state, action) => {
|
const handleUpdateSettingsRejected = (state, action) => {
|
||||||
state.isLoading = false;
|
state.isLoading = false;
|
||||||
state.success = false;
|
state.success = false;
|
||||||
state.msg = action.payload
|
state.msg = action.payload ? action.payload.msg : "Failed to update settings.";
|
||||||
? action.payload.msg
|
|
||||||
: "Failed to update settings.";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const settingsSlice = createSlice({
|
const settingsSlice = createSlice({
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { createSlice } from "@reduxjs/toolkit";
|
import { createSlice } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
|
const initialMode = window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches ? "dark" : "light";
|
||||||
|
|
||||||
// Initial state for UI settings.
|
// Initial state for UI settings.
|
||||||
// Add more settings as needed (e.g., theme preferences, user settings)
|
// Add more settings as needed (e.g., theme preferences, user settings)
|
||||||
const initialState = {
|
const initialState = {
|
||||||
@@ -15,7 +17,7 @@ const initialState = {
|
|||||||
sidebar: {
|
sidebar: {
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
},
|
},
|
||||||
mode: "light",
|
mode: initialMode,
|
||||||
greeting: { index: 0, lastUpdate: null },
|
greeting: { index: 0, lastUpdate: null },
|
||||||
timezone: "America/Toronto",
|
timezone: "America/Toronto",
|
||||||
};
|
};
|
||||||
@@ -47,10 +49,5 @@ const uiSlice = createSlice({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export default uiSlice.reducer;
|
export default uiSlice.reducer;
|
||||||
export const {
|
export const { setRowsPerPage, toggleSidebar, setMode, setGreeting, setTimezone } =
|
||||||
setRowsPerPage,
|
uiSlice.actions;
|
||||||
toggleSidebar,
|
|
||||||
setMode,
|
|
||||||
setGreeting,
|
|
||||||
setTimezone,
|
|
||||||
} = uiSlice.actions;
|
|
||||||
@@ -31,6 +31,30 @@ export const createUptimeMonitor = createAsyncThunk(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const checkEndpointResolution = createAsyncThunk(
|
||||||
|
"monitors/checkEndpoint",
|
||||||
|
async (data, thunkApi) => {
|
||||||
|
try {
|
||||||
|
const { authToken, monitorURL } = data;
|
||||||
|
|
||||||
|
const res = await networkService.checkEndpointResolution({
|
||||||
|
authToken: authToken,
|
||||||
|
monitorURL: monitorURL,
|
||||||
|
})
|
||||||
|
return res.data;
|
||||||
|
} catch (error) {
|
||||||
|
if (error.response && error.response.data) {
|
||||||
|
return thunkApi.rejectWithValue(error.response.data);
|
||||||
|
}
|
||||||
|
const payload = {
|
||||||
|
status: false,
|
||||||
|
msg: error.message ? error.message : "Unknown error",
|
||||||
|
};
|
||||||
|
return thunkApi.rejectWithValue(payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
export const getUptimeMonitorById = createAsyncThunk(
|
export const getUptimeMonitorById = createAsyncThunk(
|
||||||
"monitors/getMonitorById",
|
"monitors/getMonitorById",
|
||||||
async (data, thunkApi) => {
|
async (data, thunkApi) => {
|
||||||
@@ -271,6 +295,24 @@ const uptimeMonitorsSlice = createSlice({
|
|||||||
: "Failed to create uptime monitor";
|
: "Failed to create uptime monitor";
|
||||||
})
|
})
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
// Resolve Endpoint
|
||||||
|
// *****************************************************
|
||||||
|
.addCase(checkEndpointResolution.pending, (state) => {
|
||||||
|
state.isLoading = true;
|
||||||
|
})
|
||||||
|
.addCase(checkEndpointResolution.fulfilled, (state, action) => {
|
||||||
|
state.isLoading = false;
|
||||||
|
state.success = action.payload.success;
|
||||||
|
state.msg = action.payload.msg;
|
||||||
|
})
|
||||||
|
.addCase(checkEndpointResolution.rejected, (state, action) => {
|
||||||
|
state.isLoading = false;
|
||||||
|
state.success = false;
|
||||||
|
state.msg = action.payload
|
||||||
|
? action.payload.msg
|
||||||
|
: "Failed to check endpoint resolution";
|
||||||
|
})
|
||||||
|
// *****************************************************
|
||||||
// Get Monitor By Id
|
// Get Monitor By Id
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
.addCase(getUptimeMonitorById.pending, (state) => {
|
.addCase(getUptimeMonitorById.pending, (state) => {
|
||||||
@@ -284,9 +326,7 @@ const uptimeMonitorsSlice = createSlice({
|
|||||||
.addCase(getUptimeMonitorById.rejected, (state, action) => {
|
.addCase(getUptimeMonitorById.rejected, (state, action) => {
|
||||||
state.isLoading = false;
|
state.isLoading = false;
|
||||||
state.success = false;
|
state.success = false;
|
||||||
state.msg = action.payload
|
state.msg = action.payload ? action.payload.msg : "Failed to get uptime monitor";
|
||||||
? action.payload.msg
|
|
||||||
: "Failed to get uptime monitor";
|
|
||||||
})
|
})
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
// update Monitor
|
// update Monitor
|
||||||
@@ -393,14 +433,11 @@ const uptimeMonitorsSlice = createSlice({
|
|||||||
.addCase(deleteAllMonitors.rejected, (state, action) => {
|
.addCase(deleteAllMonitors.rejected, (state, action) => {
|
||||||
state.isLoading = false;
|
state.isLoading = false;
|
||||||
state.success = false;
|
state.success = false;
|
||||||
state.msg = action.payload
|
state.msg = action.payload ? action.payload.msg : "Failed to delete all monitors";
|
||||||
? action.payload.msg
|
|
||||||
: "Failed to delete all monitors";
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { setUptimeMonitors, clearUptimeMonitorState } =
|
export const { setUptimeMonitors, clearUptimeMonitorState } = uptimeMonitorsSlice.actions;
|
||||||
uptimeMonitorsSlice.actions;
|
|
||||||
|
|
||||||
export default uptimeMonitorsSlice.reducer;
|
export default uptimeMonitorsSlice.reducer;
|
||||||
@@ -20,7 +20,12 @@ const withAdminCheck = (WrappedComponent) => {
|
|||||||
logger.error(error);
|
logger.error(error);
|
||||||
});
|
});
|
||||||
}, [navigate]);
|
}, [navigate]);
|
||||||
return <WrappedComponent {...props} isSuperAdmin={true} />;
|
return (
|
||||||
|
<WrappedComponent
|
||||||
|
{...props}
|
||||||
|
isSuperAdmin={true}
|
||||||
|
/>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
const wrappedComponentName =
|
const wrappedComponentName =
|
||||||
WrappedComponent.displayName || WrappedComponent.name || "Component";
|
WrappedComponent.displayName || WrappedComponent.name || "Component";
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ const withAdminProp = (WrappedComponent) => {
|
|||||||
(user?.role?.includes("admin") ?? false) ||
|
(user?.role?.includes("admin") ?? false) ||
|
||||||
(user?.role?.includes("superadmin") ?? false);
|
(user?.role?.includes("superadmin") ?? false);
|
||||||
|
|
||||||
return <WrappedComponent {...props} isAdmin={isAdmin} />;
|
return (
|
||||||
|
<WrappedComponent
|
||||||
|
{...props}
|
||||||
|
isAdmin={isAdmin}
|
||||||
|
/>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const wrappedComponentName =
|
const wrappedComponentName =
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import "./index.css";
|
|||||||
|
|
||||||
const HomeLayout = () => {
|
const HomeLayout = () => {
|
||||||
return (
|
return (
|
||||||
<Stack className="home-layout" flexDirection="row" gap={14}>
|
<Stack
|
||||||
|
className="home-layout"
|
||||||
|
flexDirection="row"
|
||||||
|
gap={14}
|
||||||
|
>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -54,7 +54,10 @@ const Account = ({ open = "profile" }) => {
|
|||||||
"& .MuiTabs-root": { height: "fit-content", minHeight: "0" },
|
"& .MuiTabs-root": { height: "fit-content", minHeight: "0" },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TabList onChange={handleTabChange} aria-label="account tabs">
|
<TabList
|
||||||
|
onChange={handleTabChange}
|
||||||
|
aria-label="account tabs"
|
||||||
|
>
|
||||||
{tabList.map((label, index) => (
|
{tabList.map((label, index) => (
|
||||||
<Tab
|
<Tab
|
||||||
label={label}
|
label={label}
|
||||||
|
|||||||
@@ -9,12 +9,11 @@ import PropTypes from "prop-types";
|
|||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
import { ConfigBox } from "../Settings/styled";
|
import { ConfigBox } from "../Settings/styled";
|
||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
import {
|
import { getAppSettings, updateAppSettings } from "../../Features/Settings/settingsSlice";
|
||||||
getAppSettings,
|
|
||||||
updateAppSettings,
|
|
||||||
} from "../../Features/Settings/settingsSlice";
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import Select from "../../Components/Inputs/Select";
|
import Select from "../../Components/Inputs/Select";
|
||||||
|
import { advancedSettingsValidation } from "../../Validation/validation";
|
||||||
|
import { buildErrors, hasValidationErrors } from "../../Validation/error";
|
||||||
|
|
||||||
const AdvancedSettings = ({ isAdmin }) => {
|
const AdvancedSettings = ({ isAdmin }) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -24,7 +23,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
navigate("/");
|
navigate("/");
|
||||||
}
|
}
|
||||||
}, [navigate, isAdmin]);
|
}, [navigate, isAdmin]);
|
||||||
|
const [errors, setErrors] = useState({});
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -36,17 +35,30 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
systemEmailPort: "",
|
systemEmailPort: "",
|
||||||
systemEmailAddress: "",
|
systemEmailAddress: "",
|
||||||
systemEmailPassword: "",
|
systemEmailPassword: "",
|
||||||
jwtTTL: "",
|
jwtTTLNum: 99,
|
||||||
|
jwtTTLUnits: "days",
|
||||||
|
jwtTTL: "99d",
|
||||||
dbType: "",
|
dbType: "",
|
||||||
redisHost: "",
|
redisHost: "",
|
||||||
redisPort: "",
|
redisPort: "",
|
||||||
pagespeedApiKey: "",
|
pagespeedApiKey: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const parseJWTTTL = (data) => {
|
||||||
|
if (data.jwtTTL) {
|
||||||
|
const len = data.jwtTTL.length;
|
||||||
|
data.jwtTTLNum = data.jwtTTL.substring(0, len - 1);
|
||||||
|
data.jwtTTLUnits = unitItems.filter(
|
||||||
|
(itm) => itm._id == data.jwtTTL.substring(len - 1)
|
||||||
|
)[0].name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getSettings = async () => {
|
const getSettings = async () => {
|
||||||
const action = await dispatch(getAppSettings({ authToken }));
|
const action = await dispatch(getAppSettings({ authToken }));
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
|
parseJWTTTL(action.payload.data);
|
||||||
setLocalSettings(action.payload.data);
|
setLocalSettings(action.payload.data);
|
||||||
} else {
|
} else {
|
||||||
createToast({ body: "Failed to get settings" });
|
createToast({ body: "Failed to get settings" });
|
||||||
@@ -69,24 +81,56 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
warn: 4,
|
warn: 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const unitItemLookup = {
|
||||||
|
days: "d",
|
||||||
|
hours: "h",
|
||||||
|
};
|
||||||
|
const unitItems = Object.keys(unitItemLookup).map((key) => ({
|
||||||
|
_id: unitItemLookup[key],
|
||||||
|
name: key,
|
||||||
|
}));
|
||||||
|
|
||||||
const handleLogLevel = (e) => {
|
const handleLogLevel = (e) => {
|
||||||
const id = e.target.value;
|
const id = e.target.value;
|
||||||
const newLogLevel = logItems.find((item) => item._id === id).name;
|
const newLogLevel = logItems.find((item) => item._id === id).name;
|
||||||
setLocalSettings({ ...localSettings, logLevel: newLogLevel });
|
setLocalSettings({ ...localSettings, logLevel: newLogLevel });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleJWTTTLUnits = (e) => {
|
||||||
|
const id = e.target.value;
|
||||||
|
const newUnits = unitItems.find((item) => item._id === id).name;
|
||||||
|
setLocalSettings({ ...localSettings, jwtTTLUnits: newUnits });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBlur = (event) => {
|
||||||
|
const { value, id } = event.target;
|
||||||
|
const { error } = advancedSettingsValidation.validate(
|
||||||
|
{ [id]: value },
|
||||||
|
{
|
||||||
|
abortEarly: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setErrors((prev) => {
|
||||||
|
return buildErrors(prev, id, error);
|
||||||
|
});
|
||||||
|
};
|
||||||
const handleChange = (event) => {
|
const handleChange = (event) => {
|
||||||
const { value, id } = event.target;
|
const { value, id } = event.target;
|
||||||
setLocalSettings({ ...localSettings, [id]: value });
|
setLocalSettings({ ...localSettings, [id]: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
|
localSettings.jwtTTL =
|
||||||
|
localSettings.jwtTTLNum + unitItemLookup[localSettings.jwtTTLUnits];
|
||||||
|
if (hasValidationErrors(localSettings, advancedSettingsValidation, setErrors)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const action = await dispatch(
|
const action = await dispatch(
|
||||||
updateAppSettings({ settings: localSettings, authToken })
|
updateAppSettings({ settings: localSettings, authToken })
|
||||||
);
|
);
|
||||||
let body = "";
|
let body = "";
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
console.log(action.payload.data);
|
parseJWTTTL(action.payload.data);
|
||||||
setLocalSettings(action.payload.data);
|
setLocalSettings(action.payload.data);
|
||||||
body = "Settings saved successfully";
|
body = "Settings saved successfully";
|
||||||
} else {
|
} else {
|
||||||
@@ -121,6 +165,8 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
label="API URL Host"
|
label="API URL Host"
|
||||||
value={localSettings.apiBaseUrl}
|
value={localSettings.apiBaseUrl}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.apiBaseUrl}
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
id="logLevel"
|
id="logLevel"
|
||||||
@@ -129,6 +175,8 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
items={logItems}
|
items={logItems}
|
||||||
value={logItemLookup[localSettings.logLevel]}
|
value={logItemLookup[localSettings.logLevel]}
|
||||||
onChange={handleLogLevel}
|
onChange={handleLogLevel}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.logLevel}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
@@ -136,26 +184,30 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1">Email settings</Typography>
|
<Typography component="h1">Email settings</Typography>
|
||||||
<Typography sx={{ mt: theme.spacing(2) }}>
|
<Typography sx={{ mt: theme.spacing(2) }}>
|
||||||
Set your host email settings here. These settings are used for
|
Set your host email settings here. These settings are used for sending
|
||||||
sending system emails.
|
system emails.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(20)}>
|
<Stack gap={theme.spacing(20)}>
|
||||||
<Field
|
<Field
|
||||||
type="text"
|
type="text"
|
||||||
id="systemEmailHost"
|
id="systemEmailHost"
|
||||||
label="Email host"
|
label="System email host"
|
||||||
name="systemEmailHost"
|
name="systemEmailHost"
|
||||||
value={localSettings.systemEmailHost}
|
value={localSettings.systemEmailHost}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.systemEmailHost}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
type="number"
|
||||||
id="systemEmailPort"
|
id="systemEmailPort"
|
||||||
label="System email address"
|
label="System email port"
|
||||||
name="systemEmailPort"
|
name="systemEmailPort"
|
||||||
value={localSettings.systemEmailPort.toString()}
|
value={localSettings.systemEmailPort?.toString()}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.systemEmailPort}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
type="email"
|
type="email"
|
||||||
@@ -164,6 +216,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="systemEmailAddress"
|
name="systemEmailAddress"
|
||||||
value={localSettings.systemEmailAddress}
|
value={localSettings.systemEmailAddress}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
error={errors.systemEmailAddress}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
type="text"
|
type="text"
|
||||||
@@ -172,6 +225,8 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="systemEmailPassword"
|
name="systemEmailPassword"
|
||||||
value={localSettings.systemEmailPassword}
|
value={localSettings.systemEmailPassword}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.systemEmailPassword}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
@@ -183,14 +238,33 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(20)}>
|
<Stack gap={theme.spacing(20)}>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(10)}
|
||||||
|
>
|
||||||
<Field
|
<Field
|
||||||
type="text"
|
type="number"
|
||||||
id="jwtTTL"
|
id="jwtTTLNum"
|
||||||
label="JWT time to live"
|
label="JWT time to live"
|
||||||
name="jwtTTL"
|
name="jwtTTLNum"
|
||||||
value={localSettings.jwtTTL}
|
value={localSettings.jwtTTLNum.toString()}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.jwtTTLNum}
|
||||||
/>
|
/>
|
||||||
|
<Select
|
||||||
|
id="jwtTTLUnits"
|
||||||
|
label="JWT TTL Units"
|
||||||
|
name="jwtTTLUnits"
|
||||||
|
placeholder="Select time"
|
||||||
|
isHidden={true}
|
||||||
|
items={unitItems}
|
||||||
|
value={unitItemLookup[localSettings.jwtTTLUnits]}
|
||||||
|
onChange={handleJWTTTLUnits}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.jwtTTLUnits}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
<Field
|
<Field
|
||||||
type="text"
|
type="text"
|
||||||
id="dbType"
|
id="dbType"
|
||||||
@@ -198,6 +272,8 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="dbType"
|
name="dbType"
|
||||||
value={localSettings.dbType}
|
value={localSettings.dbType}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.dbType}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
type="text"
|
type="text"
|
||||||
@@ -206,14 +282,18 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="redisHost"
|
name="redisHost"
|
||||||
value={localSettings.redisHost}
|
value={localSettings.redisHost}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.redisHost}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
type="number"
|
||||||
id="redisPort"
|
id="redisPort"
|
||||||
label="Redis port"
|
label="Redis port"
|
||||||
name="redisPort"
|
name="redisPort"
|
||||||
value={localSettings.redisPort.toString()}
|
value={localSettings.redisPort?.toString()}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.redisPort}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
type="text"
|
type="text"
|
||||||
@@ -222,6 +302,8 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="pagespeedApiKey"
|
name="pagespeedApiKey"
|
||||||
value={localSettings.pagespeedApiKey}
|
value={localSettings.pagespeedApiKey}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
error={errors.pagespeedApiKey}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
@@ -231,9 +313,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2">BlueWave Uptime v1.0.0</Typography>
|
<Typography component="h2">BlueWave Uptime v1.0.0</Typography>
|
||||||
<Typography
|
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(6), opacity: 0.6 }}>
|
||||||
sx={{ mt: theme.spacing(2), mb: theme.spacing(6), opacity: 0.6 }}
|
|
||||||
>
|
|
||||||
Developed by Bluewave Labs.
|
Developed by Bluewave Labs.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Link
|
<Link
|
||||||
@@ -243,7 +323,10 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
loading={settings.isLoading || settings.authIsLoading}
|
loading={settings.isLoading || settings.authIsLoading}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|||||||
@@ -150,7 +150,10 @@ const CheckEmail = () => {
|
|||||||
<Typography component="h1">Check your email</Typography>
|
<Typography component="h1">Check your email</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
We sent a password reset link to{" "}
|
We sent a password reset link to{" "}
|
||||||
<Typography className="email-sent-to" component="span">
|
<Typography
|
||||||
|
className="email-sent-to"
|
||||||
|
component="span"
|
||||||
|
>
|
||||||
{email || "username@email.com"}
|
{email || "username@email.com"}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -184,7 +187,10 @@ const CheckEmail = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box textAlign="center" p={theme.spacing(12)}>
|
<Box
|
||||||
|
textAlign="center"
|
||||||
|
p={theme.spacing(12)}
|
||||||
|
>
|
||||||
<Typography display="inline-block">Go back to —</Typography>
|
<Typography display="inline-block">Go back to —</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
|
|||||||
@@ -73,10 +73,7 @@ const ForgotPassword = () => {
|
|||||||
const { value } = event.target;
|
const { value } = event.target;
|
||||||
setForm({ email: value });
|
setForm({ email: value });
|
||||||
|
|
||||||
const { error } = credentials.validate(
|
const { error } = credentials.validate({ email: value }, { abortEarly: false });
|
||||||
{ email: value },
|
|
||||||
{ abortEarly: false }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (error) setErrors({ email: error.details[0].message });
|
if (error) setErrors({ email: error.details[0].message });
|
||||||
else delete errors.email;
|
else delete errors.email;
|
||||||
@@ -153,9 +150,7 @@ const ForgotPassword = () => {
|
|||||||
<Key alt="password key icon" />
|
<Key alt="password key icon" />
|
||||||
</IconBox>
|
</IconBox>
|
||||||
<Typography component="h1">Forgot password?</Typography>
|
<Typography component="h1">Forgot password?</Typography>
|
||||||
<Typography>
|
<Typography>No worries, we'll send you reset instructions.</Typography>
|
||||||
No worries, we'll send you reset instructions.
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
component="form"
|
component="form"
|
||||||
@@ -191,7 +186,10 @@ const ForgotPassword = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box textAlign="center" p={theme.spacing(12)}>
|
<Box
|
||||||
|
textAlign="center"
|
||||||
|
p={theme.spacing(12)}
|
||||||
|
>
|
||||||
<Typography display="inline-block">Go back to —</Typography>
|
<Typography display="inline-block">Go back to —</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
|
|||||||
@@ -137,8 +137,15 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
<Typography component="h1">Log In</Typography>
|
<Typography component="h1">Log In</Typography>
|
||||||
<Typography>Enter your email address</Typography>
|
<Typography>Enter your email address</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box textAlign="left" mb={theme.spacing(5)}>
|
<Box
|
||||||
<form noValidate spellCheck={false} onSubmit={onSubmit}>
|
textAlign="left"
|
||||||
|
mb={theme.spacing(5)}
|
||||||
|
>
|
||||||
|
<form
|
||||||
|
noValidate
|
||||||
|
spellCheck={false}
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
>
|
||||||
<Field
|
<Field
|
||||||
type="email"
|
type="email"
|
||||||
id="login-email-input"
|
id="login-email-input"
|
||||||
@@ -154,7 +161,10 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack direction="row" justifyContent="space-between">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="info"
|
color="info"
|
||||||
@@ -233,8 +243,15 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
<Typography component="h1">Log In</Typography>
|
<Typography component="h1">Log In</Typography>
|
||||||
<Typography>Enter your password</Typography>
|
<Typography>Enter your password</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box textAlign="left" mb={theme.spacing(5)}>
|
<Box
|
||||||
<form noValidate spellCheck={false} onSubmit={onSubmit}>
|
textAlign="left"
|
||||||
|
mb={theme.spacing(5)}
|
||||||
|
>
|
||||||
|
<form
|
||||||
|
noValidate
|
||||||
|
spellCheck={false}
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
>
|
||||||
<Field
|
<Field
|
||||||
type="password"
|
type="password"
|
||||||
id="login-password-input"
|
id="login-password-input"
|
||||||
@@ -249,7 +266,10 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack direction="row" justifyContent="space-between">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="info"
|
color="info"
|
||||||
@@ -359,10 +379,7 @@ const Login = () => {
|
|||||||
[name]: value,
|
[name]: value,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { error } = credentials.validate(
|
const { error } = credentials.validate({ [name]: value }, { abortEarly: false });
|
||||||
{ [name]: value },
|
|
||||||
{ abortEarly: false }
|
|
||||||
);
|
|
||||||
|
|
||||||
setErrors((prev) => {
|
setErrors((prev) => {
|
||||||
const prevErrors = { ...prev };
|
const prevErrors = { ...prev };
|
||||||
@@ -413,8 +430,7 @@ const Login = () => {
|
|||||||
if (action.payload) {
|
if (action.payload) {
|
||||||
if (action.payload.msg === "Incorrect password")
|
if (action.payload.msg === "Incorrect password")
|
||||||
setErrors({
|
setErrors({
|
||||||
password:
|
password: "The password you provided does not match our records",
|
||||||
"The password you provided does not match our records",
|
|
||||||
});
|
});
|
||||||
// dispatch errors
|
// dispatch errors
|
||||||
createToast({
|
createToast({
|
||||||
@@ -507,10 +523,11 @@ const Login = () => {
|
|||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box textAlign="center" p={theme.spacing(12)}>
|
<Box
|
||||||
<Typography display="inline-block">
|
textAlign="center"
|
||||||
Don't have an account? —
|
p={theme.spacing(12)}
|
||||||
</Typography>
|
>
|
||||||
|
<Typography display="inline-block">Don't have an account? —</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
color={theme.palette.primary.main}
|
color={theme.palette.primary.main}
|
||||||
|
|||||||
@@ -85,8 +85,7 @@ const NewPasswordConfirmed = () => {
|
|||||||
</IconBox>
|
</IconBox>
|
||||||
<Typography component="h1">Password reset</Typography>
|
<Typography component="h1">Password reset</Typography>
|
||||||
<Typography mb={theme.spacing(2)}>
|
<Typography mb={theme.spacing(2)}>
|
||||||
Your password has been successfully reset. Click below to log in
|
Your password has been successfully reset. Click below to log in magically.
|
||||||
magically.
|
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Button
|
<Button
|
||||||
@@ -102,7 +101,10 @@ const NewPasswordConfirmed = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box textAlign="center" p={theme.spacing(12)}>
|
<Box
|
||||||
|
textAlign="center"
|
||||||
|
p={theme.spacing(12)}
|
||||||
|
>
|
||||||
<Typography display="inline-block">Go back to —</Typography>
|
<Typography display="inline-block">Go back to —</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ const LandingPage = ({ isSuperAdmin, onSignup }) => {
|
|||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1">Sign Up</Typography>
|
<Typography component="h1">Sign Up</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
Create your {isSuperAdmin ? "Super admin " : ""}account to get
|
Create your {isSuperAdmin ? "Super admin " : ""}account to get started.
|
||||||
started.
|
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box width="100%">
|
<Box width="100%">
|
||||||
@@ -181,7 +180,10 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack direction="row" justifyContent="space-between">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="info"
|
color="info"
|
||||||
@@ -274,7 +276,10 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack direction="row" justifyContent="space-between">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="info"
|
color="info"
|
||||||
@@ -396,8 +401,8 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
<Check
|
<Check
|
||||||
text={
|
text={
|
||||||
<>
|
<>
|
||||||
<Typography component="span">Must be at least</Typography> 8
|
<Typography component="span">Must be at least</Typography> 8 characters
|
||||||
characters long
|
long
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
variant={
|
variant={
|
||||||
@@ -413,8 +418,8 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
<Check
|
<Check
|
||||||
text={
|
text={
|
||||||
<>
|
<>
|
||||||
<Typography component="span">Must contain</Typography> one
|
<Typography component="span">Must contain</Typography> one special
|
||||||
special character and a number
|
character and a number
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
variant={
|
variant={
|
||||||
@@ -422,9 +427,7 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
? "error"
|
? "error"
|
||||||
: form.password === ""
|
: form.password === ""
|
||||||
? "info"
|
? "info"
|
||||||
: !/^(?=.*[!@#$%^&*(),.?":{}|])(?=.*\d).+$/.test(
|
: !/^(?=.*[!@#$%^&*(),.?":{}|])(?=.*\d).+$/.test(form.password)
|
||||||
form.password
|
|
||||||
)
|
|
||||||
? "error"
|
? "error"
|
||||||
: "success"
|
: "success"
|
||||||
}
|
}
|
||||||
@@ -432,10 +435,8 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
<Check
|
<Check
|
||||||
text={
|
text={
|
||||||
<>
|
<>
|
||||||
<Typography component="span">
|
<Typography component="span">Must contain at least</Typography> one
|
||||||
Must contain at least
|
upper and lower character
|
||||||
</Typography>{" "}
|
|
||||||
one upper and lower character
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
variant={
|
variant={
|
||||||
@@ -450,7 +451,10 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack direction="row" justifyContent="space-between">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="info"
|
color="info"
|
||||||
@@ -738,10 +742,11 @@ const Register = ({ isSuperAdmin }) => {
|
|||||||
""
|
""
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box textAlign="center" p={theme.spacing(12)}>
|
<Box
|
||||||
<Typography display="inline-block">
|
textAlign="center"
|
||||||
Already have an account? —
|
p={theme.spacing(12)}
|
||||||
</Typography>
|
>
|
||||||
|
<Typography display="inline-block">Already have an account? —</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
ml={theme.spacing(2)}
|
ml={theme.spacing(2)}
|
||||||
|
|||||||
@@ -59,9 +59,7 @@ const SetNewPassword = () => {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
delete passwordForm.confirm;
|
delete passwordForm.confirm;
|
||||||
const action = await dispatch(
|
const action = await dispatch(setNewPassword({ token: token, form: passwordForm }));
|
||||||
setNewPassword({ token: token, form: passwordForm })
|
|
||||||
);
|
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
navigate("/new-password-confirmed");
|
navigate("/new-password-confirmed");
|
||||||
createToast({
|
createToast({
|
||||||
@@ -217,7 +215,10 @@ const SetNewPassword = () => {
|
|||||||
error={errors.confirm}
|
error={errors.confirm}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(4)} mb={theme.spacing(12)}>
|
<Stack
|
||||||
|
gap={theme.spacing(4)}
|
||||||
|
mb={theme.spacing(12)}
|
||||||
|
>
|
||||||
<Check
|
<Check
|
||||||
text={
|
text={
|
||||||
<>
|
<>
|
||||||
@@ -238,8 +239,8 @@ const SetNewPassword = () => {
|
|||||||
<Check
|
<Check
|
||||||
text={
|
text={
|
||||||
<>
|
<>
|
||||||
<Typography component="span">Must contain</Typography> one
|
<Typography component="span">Must contain</Typography> one special
|
||||||
special character and a number
|
character and a number
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
variant={
|
variant={
|
||||||
@@ -247,9 +248,7 @@ const SetNewPassword = () => {
|
|||||||
? "error"
|
? "error"
|
||||||
: form.password === ""
|
: form.password === ""
|
||||||
? "info"
|
? "info"
|
||||||
: !/^(?=.*[!@#$%^&*(),.?":{}|])(?=.*\d).+$/.test(
|
: !/^(?=.*[!@#$%^&*(),.?":{}|])(?=.*\d).+$/.test(form.password)
|
||||||
form.password
|
|
||||||
)
|
|
||||||
? "error"
|
? "error"
|
||||||
: "success"
|
: "success"
|
||||||
}
|
}
|
||||||
@@ -257,10 +256,8 @@ const SetNewPassword = () => {
|
|||||||
<Check
|
<Check
|
||||||
text={
|
text={
|
||||||
<>
|
<>
|
||||||
<Typography component="span">
|
<Typography component="span">Must contain at least</Typography> one
|
||||||
Must contain at least
|
upper and lower character
|
||||||
</Typography>{" "}
|
|
||||||
one upper and lower character
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
variant={
|
variant={
|
||||||
@@ -287,7 +284,10 @@ const SetNewPassword = () => {
|
|||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box textAlign="center" p={theme.spacing(12)}>
|
<Box
|
||||||
|
textAlign="center"
|
||||||
|
p={theme.spacing(12)}
|
||||||
|
>
|
||||||
<Typography display="inline-block">Go back to —</Typography>
|
<Typography display="inline-block">Go back to —</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { useTheme } from "@emotion/react";
|
||||||
|
import PlaceholderLight from "../../../../assets/Images/data_placeholder.svg?react";
|
||||||
|
import PlaceholderDark from "../../../../assets/Images/data_placeholder_dark.svg?react";
|
||||||
|
import { Box, Typography } from "@mui/material";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
const Empty = ({ styles, mode }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
return (
|
||||||
|
<Box sx={{ ...styles }}>
|
||||||
|
<Box
|
||||||
|
textAlign="center"
|
||||||
|
pb={theme.spacing(20)}
|
||||||
|
>
|
||||||
|
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
||||||
|
</Box>
|
||||||
|
<Typography
|
||||||
|
textAlign="center"
|
||||||
|
color={theme.palette.text.secondary}
|
||||||
|
>
|
||||||
|
No incidents recorded yet.
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Empty.propTypes = {
|
||||||
|
styles: PropTypes.object,
|
||||||
|
mode: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export { Empty };
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Skeleton /* , Stack */ } from "@mui/material";
|
||||||
|
const IncidentSkeleton = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Skeleton
|
||||||
|
animation={"wave"}
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={300}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
animation={"wave"}
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={100}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { IncidentSkeleton };
|
||||||
@@ -24,6 +24,8 @@ import { useTheme } from "@emotion/react";
|
|||||||
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
||||||
import PlaceholderLight from "../../../assets/Images/data_placeholder.svg?react";
|
import PlaceholderLight from "../../../assets/Images/data_placeholder.svg?react";
|
||||||
import PlaceholderDark from "../../../assets/Images/data_placeholder_dark.svg?react";
|
import PlaceholderDark from "../../../assets/Images/data_placeholder_dark.svg?react";
|
||||||
|
import { Empty } from "./Empty/Empty";
|
||||||
|
import { IncidentSkeleton } from "./Skeleton/Skeleton";
|
||||||
|
|
||||||
const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
||||||
const uiTimezone = useSelector((state) => state.ui.timezone);
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
@@ -37,6 +39,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
page: 0,
|
page: 0,
|
||||||
rowsPerPage: 14,
|
rowsPerPage: 14,
|
||||||
});
|
});
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPaginationController((prevPaginationController) => ({
|
setPaginationController((prevPaginationController) => ({
|
||||||
@@ -51,6 +54,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
let res;
|
let res;
|
||||||
if (selectedMonitor === "0") {
|
if (selectedMonitor === "0") {
|
||||||
res = await networkService.getChecksByTeam({
|
res = await networkService.getChecksByTeam({
|
||||||
@@ -70,7 +74,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
sortOrder: "desc",
|
sortOrder: "desc",
|
||||||
limit: null,
|
limit: null,
|
||||||
dateRange: null,
|
dateRange: null,
|
||||||
sitler: filter,
|
filter: filter,
|
||||||
page: paginationController.page,
|
page: paginationController.page,
|
||||||
rowsPerPage: paginationController.rowsPerPage,
|
rowsPerPage: paginationController.rowsPerPage,
|
||||||
});
|
});
|
||||||
@@ -79,6 +83,8 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
setChecksCount(res.data.data.checksCount);
|
setChecksCount(res.data.data.checksCount);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchPage();
|
fetchPage();
|
||||||
@@ -129,23 +135,31 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
p: theme.spacing(30),
|
p: theme.spacing(30),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hasChecks = checks?.length === 0;
|
||||||
|
const noIncidentsRecordedYet = hasChecks && selectedMonitor === "0";
|
||||||
|
const noIncidentsForThatMonitor = hasChecks && selectedMonitor !== "0";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{checks?.length === 0 && selectedMonitor === "0" ? (
|
{isLoading ? (
|
||||||
|
<IncidentSkeleton />
|
||||||
|
) : noIncidentsRecordedYet ? (
|
||||||
|
<Empty
|
||||||
|
mode={mode}
|
||||||
|
styles={sharedStyles}
|
||||||
|
/>
|
||||||
|
) : noIncidentsForThatMonitor ? (
|
||||||
<Box sx={{ ...sharedStyles }}>
|
<Box sx={{ ...sharedStyles }}>
|
||||||
<Box textAlign="center" pb={theme.spacing(20)}>
|
<Box
|
||||||
|
textAlign="center"
|
||||||
|
pb={theme.spacing(20)}
|
||||||
|
>
|
||||||
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
||||||
</Box>
|
</Box>
|
||||||
<Typography textAlign="center" color={theme.palette.text.secondary}>
|
<Typography
|
||||||
No incidents recorded yet.
|
textAlign="center"
|
||||||
</Typography>
|
color={theme.palette.text.secondary}
|
||||||
</Box>
|
>
|
||||||
) : checks?.length === 0 ? (
|
|
||||||
<Box sx={{ ...sharedStyles }}>
|
|
||||||
<Box textAlign="center" pb={theme.spacing(20)}>
|
|
||||||
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
|
||||||
</Box>
|
|
||||||
<Typography textAlign="center" color={theme.palette.text.secondary}>
|
|
||||||
The monitor you have selected has no recorded incidents yet.
|
The monitor you have selected has no recorded incidents yet.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -182,9 +196,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{formattedDate}</TableCell>
|
<TableCell>{formattedDate}</TableCell>
|
||||||
<TableCell>
|
<TableCell>{check.statusCode ? check.statusCode : "N/A"}</TableCell>
|
||||||
{check.statusCode ? check.statusCode : "N/A"}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>{check.message}</TableCell>
|
<TableCell>{check.message}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,14 +17,15 @@ const Incidents = () => {
|
|||||||
|
|
||||||
const [monitors, setMonitors] = useState({});
|
const [monitors, setMonitors] = useState({});
|
||||||
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
||||||
const [loading, setLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
// TODO do something with these filters
|
// TODO do something with these filters
|
||||||
const [filter, setFilter] = useState("all");
|
const [filter, setFilter] = useState("all");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitors = async () => {
|
const fetchMonitors = async () => {
|
||||||
setLoading(true);
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
const res = await networkService.getMonitorsByTeamId({
|
const res = await networkService.getMonitorsByTeamId({
|
||||||
authToken: authState.authToken,
|
authToken: authState.authToken,
|
||||||
teamId: authState.user.teamId,
|
teamId: authState.user.teamId,
|
||||||
@@ -48,25 +49,38 @@ const Incidents = () => {
|
|||||||
setMonitors(monitorLookup);
|
setMonitors(monitorLookup);
|
||||||
monitorId !== undefined && setSelectedMonitor(monitorId);
|
monitorId !== undefined && setSelectedMonitor(monitorId);
|
||||||
}
|
}
|
||||||
setLoading(false);
|
} catch (error) {
|
||||||
|
console.info(error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [authState]);
|
}, [authState]);
|
||||||
|
|
||||||
useEffect(() => {}, []);
|
useEffect(() => {}, [monitors]);
|
||||||
|
|
||||||
const handleSelect = (event) => {
|
const handleSelect = (event) => {
|
||||||
setSelectedMonitor(event.target.value);
|
setSelectedMonitor(event.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isActuallyLoading = isLoading && Object.keys(monitors)?.length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="incidents" pt={theme.spacing(6)} gap={theme.spacing(12)}>
|
<Stack
|
||||||
{loading ? (
|
className="incidents"
|
||||||
|
pt={theme.spacing(6)}
|
||||||
|
gap={theme.spacing(12)}
|
||||||
|
>
|
||||||
|
{isActuallyLoading ? (
|
||||||
<SkeletonLayout />
|
<SkeletonLayout />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
gap={theme.spacing(6)}
|
||||||
|
>
|
||||||
<Typography
|
<Typography
|
||||||
display="inline-block"
|
display="inline-block"
|
||||||
component="h1"
|
component="h1"
|
||||||
|
|||||||
@@ -11,9 +11,21 @@ const SkeletonLayout = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}>
|
<Stack
|
||||||
<Skeleton variant="rounded" width={150} height={34} />
|
direction="row"
|
||||||
<Skeleton variant="rounded" width="15%" height={34} />
|
alignItems="center"
|
||||||
|
gap={theme.spacing(6)}
|
||||||
|
>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width={150}
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="15%"
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="rounded"
|
variant="rounded"
|
||||||
width="20%"
|
width="20%"
|
||||||
@@ -21,8 +33,16 @@ const SkeletonLayout = () => {
|
|||||||
sx={{ ml: "auto" }}
|
sx={{ ml: "auto" }}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Skeleton variant="rounded" width="100%" height={300} />
|
<Skeleton
|
||||||
<Skeleton variant="rounded" width="100%" height={100} />
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={300}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={100}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ const IntegrationsComponent = ({ icon, header, info, onClick }) => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid item lg={6} flexGrow={1}>
|
<Grid
|
||||||
|
item
|
||||||
|
lg={6}
|
||||||
|
flexGrow={1}
|
||||||
|
>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
@@ -34,7 +38,10 @@ const IntegrationsComponent = ({ icon, header, info, onClick }) => {
|
|||||||
backgroundColor={theme.palette.background.main}
|
backgroundColor={theme.palette.background.main}
|
||||||
>
|
>
|
||||||
{icon}
|
{icon}
|
||||||
<Stack gap={theme.spacing(2)} flex={1}>
|
<Stack
|
||||||
|
gap={theme.spacing(2)}
|
||||||
|
flex={1}
|
||||||
|
>
|
||||||
<Typography component="h1">{header}</Typography>
|
<Typography component="h1">{header}</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
@@ -127,7 +134,10 @@ const Integrations = () => {
|
|||||||
<Typography mb={theme.spacing(12)}>
|
<Typography mb={theme.spacing(12)}>
|
||||||
Connect BlueWave Uptime to your favorite service.
|
Connect BlueWave Uptime to your favorite service.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Grid container spacing={theme.spacing(12)}>
|
<Grid
|
||||||
|
container
|
||||||
|
spacing={theme.spacing(12)}
|
||||||
|
>
|
||||||
{integrations.map((integration, index) => (
|
{integrations.map((integration, index) => (
|
||||||
<IntegrationsComponent
|
<IntegrationsComponent
|
||||||
key={index}
|
key={index}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
MS_PER_WEEK,
|
MS_PER_WEEK,
|
||||||
} from "../../../Utils/timeUtils";
|
} from "../../../Utils/timeUtils";
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
import { buildErrors, hasValidationErrors } from "../../../Validation/error";
|
||||||
|
|
||||||
const getDurationAndUnit = (durationInMs) => {
|
const getDurationAndUnit = (durationInMs) => {
|
||||||
if (durationInMs % MS_PER_DAY === 0) {
|
if (durationInMs % MS_PER_DAY === 0) {
|
||||||
@@ -176,16 +177,6 @@ const CreateMaintenance = () => {
|
|||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [authToken, user]);
|
}, [authToken, user]);
|
||||||
|
|
||||||
const buildErrors = (prev, id, error) => {
|
|
||||||
const updatedErrors = { ...prev };
|
|
||||||
if (error) {
|
|
||||||
updatedErrors[id] = error.details[0].message;
|
|
||||||
} else {
|
|
||||||
delete updatedErrors[id];
|
|
||||||
}
|
|
||||||
return updatedErrors;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSearch = (value) => {
|
const handleSearch = (value) => {
|
||||||
setSearch(value);
|
setSearch(value);
|
||||||
};
|
};
|
||||||
@@ -224,20 +215,8 @@ const CreateMaintenance = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
const { error } = maintenanceWindowValidation.validate(form, {
|
if (hasValidationErrors(form, maintenanceWindowValidation, setErrors))
|
||||||
abortEarly: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// If errors, return early
|
|
||||||
if (error) {
|
|
||||||
const newErrors = {};
|
|
||||||
error.details.forEach((err) => {
|
|
||||||
newErrors[err.path[0]] = err.message;
|
|
||||||
});
|
|
||||||
setErrors(newErrors);
|
|
||||||
logger.error(error);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
// Build timestamp for maintenance window from startDate and startTime
|
// Build timestamp for maintenance window from startDate and startTime
|
||||||
const start = dayjs(form.startDate)
|
const start = dayjs(form.startDate)
|
||||||
.set("hour", form.startTime.hour())
|
.set("hour", form.startTime.hour())
|
||||||
@@ -310,8 +289,14 @@ const CreateMaintenance = () => {
|
|||||||
mt={theme.spacing(6)}
|
mt={theme.spacing(6)}
|
||||||
>
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1" variant="h1">
|
<Typography
|
||||||
<Typography component="span" fontSize="inherit">
|
component="h1"
|
||||||
|
variant="h1"
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
fontSize="inherit"
|
||||||
|
>
|
||||||
{`${maintenanceWindowId === undefined ? "Create a" : "Edit"}`}{" "}
|
{`${maintenanceWindowId === undefined ? "Create a" : "Edit"}`}{" "}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -322,16 +307,26 @@ const CreateMaintenance = () => {
|
|||||||
>
|
>
|
||||||
maintenance{" "}
|
maintenance{" "}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography component="span" fontSize="inherit">
|
<Typography
|
||||||
|
component="span"
|
||||||
|
fontSize="inherit"
|
||||||
|
>
|
||||||
window
|
window
|
||||||
</Typography>
|
</Typography>
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography component="h2" variant="body2" fontSize={14}>
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="body2"
|
||||||
|
fontSize={14}
|
||||||
|
>
|
||||||
Your pings won't be sent during this time frame
|
Your pings won't be sent during this time frame
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<ConfigBox direction="row">
|
<ConfigBox direction="row">
|
||||||
<Typography component="h2" variant="h2">
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
>
|
||||||
General Settings
|
General Settings
|
||||||
</Typography>
|
</Typography>
|
||||||
<Box
|
<Box
|
||||||
@@ -352,7 +347,10 @@ const CreateMaintenance = () => {
|
|||||||
}}
|
}}
|
||||||
items={repeatConfig}
|
items={repeatConfig}
|
||||||
/>
|
/>
|
||||||
<Stack gap={theme.spacing(2)} mt={theme.spacing(16)}>
|
<Stack
|
||||||
|
gap={theme.spacing(2)}
|
||||||
|
mt={theme.spacing(16)}
|
||||||
|
>
|
||||||
<Typography component="h3">Date</Typography>
|
<Typography component="h3">Date</Typography>
|
||||||
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
@@ -411,12 +409,13 @@ const CreateMaintenance = () => {
|
|||||||
<ConfigBox>
|
<ConfigBox>
|
||||||
<Stack direction="row">
|
<Stack direction="row">
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2" variant="h2">
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
>
|
||||||
Start time
|
Start time
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>All dates and times are in GMT+0 time zone.</Typography>
|
||||||
All dates and times are in GMT+0 time zone.
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
<Stack direction="row">
|
<Stack direction="row">
|
||||||
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||||
@@ -457,11 +456,17 @@ const CreateMaintenance = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row">
|
<Stack direction="row">
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2" variant="h2">
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
>
|
||||||
Duration
|
Duration
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack direction="row" spacing={theme.spacing(8)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={theme.spacing(8)}
|
||||||
|
>
|
||||||
<Field
|
<Field
|
||||||
type="number"
|
type="number"
|
||||||
id="duration"
|
id="duration"
|
||||||
@@ -498,7 +503,10 @@ const CreateMaintenance = () => {
|
|||||||
<ConfigBox>
|
<ConfigBox>
|
||||||
<Stack direction="row">
|
<Stack direction="row">
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2" variant="h2">
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
>
|
||||||
Friendly name
|
Friendly name
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -516,7 +524,10 @@ const CreateMaintenance = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row">
|
<Stack direction="row">
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2" variant="h2">
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
>
|
||||||
Add monitors
|
Add monitors
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -539,7 +550,10 @@ const CreateMaintenance = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
</Box>
|
</Box>
|
||||||
<Box ml="auto" display="inline-block">
|
<Box
|
||||||
|
ml="auto"
|
||||||
|
display="inline-block"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
|
|||||||
@@ -2,23 +2,16 @@ import { useState } from "react";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import {
|
import { IconButton, Menu, MenuItem } from "@mui/material";
|
||||||
Button,
|
|
||||||
IconButton,
|
|
||||||
Menu,
|
|
||||||
MenuItem,
|
|
||||||
Modal,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
|
||||||
import { logger } from "../../../../Utils/Logger";
|
import { logger } from "../../../../Utils/Logger";
|
||||||
import Settings from "../../../../assets/icons/settings-bold.svg?react";
|
import Settings from "../../../../assets/icons/settings-bold.svg?react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { networkService } from "../../../../main";
|
import { networkService } from "../../../../main";
|
||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
|
|
||||||
const ActionsMenu = ({ isAdmin, maintenanceWindow, updateCallback }) => {
|
import Dialog from "../../../../Components/Dialog";
|
||||||
|
|
||||||
|
const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
|
||||||
maintenanceWindow;
|
maintenanceWindow;
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
@@ -155,67 +148,21 @@ const ActionsMenu = ({ isAdmin, maintenanceWindow, updateCallback }) => {
|
|||||||
Remove
|
Remove
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Modal
|
<Dialog
|
||||||
aria-labelledby="modal-delete-monitor"
|
|
||||||
aria-describedby="delete-monitor-confirmation"
|
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
onClose={(e) => {
|
theme={theme}
|
||||||
|
title={"Do you really want to remove this maintenance window?"}
|
||||||
|
onCancel={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
confirmationButtonLabel={"Delete"}
|
||||||
<Stack
|
onConfirm={(e) => {
|
||||||
gap={theme.spacing(2)}
|
|
||||||
sx={{
|
|
||||||
position: "absolute",
|
|
||||||
top: "50%",
|
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
width: 400,
|
|
||||||
bgcolor: theme.palette.background.main,
|
|
||||||
border: 1,
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
boxShadow: 24,
|
|
||||||
p: theme.spacing(15),
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography id="modal-delete-maintenance" component="h2" variant="h2">
|
|
||||||
Do you really want to remove this maintenance window?
|
|
||||||
</Typography>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
gap={theme.spacing(4)}
|
|
||||||
mt={theme.spacing(12)}
|
|
||||||
justifyContent="flex-end"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
variant="text"
|
|
||||||
color="info"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
setIsOpen(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<LoadingButton
|
|
||||||
loading={isLoading}
|
|
||||||
variant="contained"
|
|
||||||
color="error"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation(e);
|
e.stopPropagation(e);
|
||||||
handleRemove(e);
|
handleRemove(e);
|
||||||
}}
|
}}
|
||||||
>
|
isLoading={isLoading}
|
||||||
Delete
|
/>
|
||||||
</LoadingButton>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
</Modal>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -169,10 +169,7 @@ const MaintenanceTable = ({
|
|||||||
*/
|
*/
|
||||||
const getRange = () => {
|
const getRange = () => {
|
||||||
let start = page * rowsPerPage + 1;
|
let start = page * rowsPerPage + 1;
|
||||||
let end = Math.min(
|
let end = Math.min(page * rowsPerPage + rowsPerPage, maintenanceWindowCount);
|
||||||
page * rowsPerPage + rowsPerPage,
|
|
||||||
maintenanceWindowCount
|
|
||||||
);
|
|
||||||
return `${start} - ${end}`;
|
return `${start} - ${end}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -221,8 +218,7 @@ const MaintenanceTable = ({
|
|||||||
Status
|
Status
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
visibility:
|
visibility: sort.field === "active" ? "visible" : "hidden",
|
||||||
sort.field === "active" ? "visible" : "hidden",
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{sort.order === "asc" ? (
|
{sort.order === "asc" ? (
|
||||||
@@ -282,7 +278,11 @@ const MaintenanceTable = ({
|
|||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
px={theme.spacing(4)}
|
px={theme.spacing(4)}
|
||||||
>
|
>
|
||||||
<Typography px={theme.spacing(2)} variant="body2" sx={{ opacity: 0.7 }}>
|
<Typography
|
||||||
|
px={theme.spacing(2)}
|
||||||
|
variant="body2"
|
||||||
|
sx={{ opacity: 0.7 }}
|
||||||
|
>
|
||||||
Showing {getRange()} of {maintenanceWindowCount} maintenance window(s)
|
Showing {getRange()} of {maintenanceWindowCount} maintenance window(s)
|
||||||
</Typography>
|
</Typography>
|
||||||
<TablePagination
|
<TablePagination
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ const Maintenance = ({ isAdmin }) => {
|
|||||||
page: page,
|
page: page,
|
||||||
rowsPerPage: rowsPerPage,
|
rowsPerPage: rowsPerPage,
|
||||||
});
|
});
|
||||||
const { maintenanceWindows, maintenanceWindowCount } =
|
const { maintenanceWindows, maintenanceWindowCount } = response.data.data;
|
||||||
response.data.data;
|
|
||||||
setMaintenanceWindows(maintenanceWindows);
|
setMaintenanceWindows(maintenanceWindows);
|
||||||
setMaintenanceWindowCount(maintenanceWindowCount);
|
setMaintenanceWindowCount(maintenanceWindowCount);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -46,7 +45,7 @@ const Maintenance = ({ isAdmin }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
className="maintenance"
|
className="maintenance table-container"
|
||||||
sx={{
|
sx={{
|
||||||
':has(> [class*="fallback__"])': {
|
':has(> [class*="fallback__"])': {
|
||||||
position: "relative",
|
position: "relative",
|
||||||
@@ -67,9 +66,7 @@ const Maintenance = ({ isAdmin }) => {
|
|||||||
alignItems="center"
|
alignItems="center"
|
||||||
mt={theme.spacing(5)}
|
mt={theme.spacing(5)}
|
||||||
>
|
>
|
||||||
<Breadcrumbs
|
<Breadcrumbs list={[{ name: "maintenance", path: "/maintenance" }]} />
|
||||||
list={[{ name: "maintenance", path: "/maintenance" }]}
|
|
||||||
/>
|
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useNavigate, useParams } 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 { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Box, Button, Modal, Stack, Tooltip, Typography } from "@mui/material";
|
import { Box, Stack, Tooltip, Typography } from "@mui/material";
|
||||||
import { monitorValidation } from "../../../Validation/validation";
|
import { monitorValidation } from "../../../Validation/validation";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import { logger } from "../../../Utils/Logger";
|
import { logger } from "../../../Utils/Logger";
|
||||||
@@ -24,6 +24,7 @@ import PulseDot from "../../../Components/Animated/PulseDot";
|
|||||||
import SkeletonLayout from "./skeleton";
|
import SkeletonLayout from "./skeleton";
|
||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
import Dialog from "../../../Components/Dialog";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a URL string and returns a URL object.
|
* Parses a URL string and returns a URL object.
|
||||||
@@ -64,9 +65,7 @@ const Configure = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(
|
const action = await dispatch(getUptimeMonitorById({ authToken, monitorId }));
|
||||||
getUptimeMonitorById({ authToken, monitorId })
|
|
||||||
);
|
|
||||||
|
|
||||||
if (getUptimeMonitorById.fulfilled.match(action)) {
|
if (getUptimeMonitorById.fulfilled.match(action)) {
|
||||||
const monitor = action.payload.data;
|
const monitor = action.payload.data;
|
||||||
@@ -128,8 +127,7 @@ const Configure = () => {
|
|||||||
setErrors((prev) => {
|
setErrors((prev) => {
|
||||||
const updatedErrors = { ...prev };
|
const updatedErrors = { ...prev };
|
||||||
|
|
||||||
if (validation.error)
|
if (validation.error) updatedErrors[name] = validation.error.details[0].message;
|
||||||
updatedErrors[name] = validation.error.details[0].message;
|
|
||||||
else delete updatedErrors[name];
|
else delete updatedErrors[name];
|
||||||
return updatedErrors;
|
return updatedErrors;
|
||||||
});
|
});
|
||||||
@@ -138,9 +136,7 @@ const Configure = () => {
|
|||||||
|
|
||||||
const handlePause = async () => {
|
const handlePause = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(
|
const action = await dispatch(pauseUptimeMonitor({ authToken, monitorId }));
|
||||||
pauseUptimeMonitor({ authToken, monitorId })
|
|
||||||
);
|
|
||||||
if (pauseUptimeMonitor.fulfilled.match(action)) {
|
if (pauseUptimeMonitor.fulfilled.match(action)) {
|
||||||
const monitor = action.payload.data;
|
const monitor = action.payload.data;
|
||||||
setMonitor(monitor);
|
setMonitor(monitor);
|
||||||
@@ -155,9 +151,7 @@ const Configure = () => {
|
|||||||
|
|
||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const action = await dispatch(
|
const action = await dispatch(updateUptimeMonitor({ authToken, monitor: monitor }));
|
||||||
updateUptimeMonitor({ authToken, monitor: monitor })
|
|
||||||
);
|
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
createToast({ body: "Monitor updated successfully!" });
|
createToast({ body: "Monitor updated successfully!" });
|
||||||
dispatch(getUptimeMonitorsByTeamId(authToken));
|
dispatch(getUptimeMonitorsByTeamId(authToken));
|
||||||
@@ -202,7 +196,10 @@ const Configure = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="configure-monitor" gap={theme.spacing(10)}>
|
<Stack
|
||||||
|
className="configure-monitor"
|
||||||
|
gap={theme.spacing(10)}
|
||||||
|
>
|
||||||
{Object.keys(monitor).length === 0 ? (
|
{Object.keys(monitor).length === 0 ? (
|
||||||
<SkeletonLayout />
|
<SkeletonLayout />
|
||||||
) : (
|
) : (
|
||||||
@@ -221,9 +218,15 @@ const Configure = () => {
|
|||||||
gap={theme.spacing(12)}
|
gap={theme.spacing(12)}
|
||||||
flex={1}
|
flex={1}
|
||||||
>
|
>
|
||||||
<Stack direction="row" gap={theme.spacing(2)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(2)}
|
||||||
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1" variant="h1">
|
<Typography
|
||||||
|
component="h1"
|
||||||
|
variant="h1"
|
||||||
|
>
|
||||||
{monitor.name}
|
{monitor.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -249,12 +252,13 @@ const Configure = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<PulseDot
|
<PulseDot color={statusColor[monitor?.status ?? undefined]} />
|
||||||
color={statusColor[monitor?.status ?? undefined]}
|
|
||||||
/>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Typography component="h2" variant="h2">
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
>
|
||||||
{monitor.url?.replace(/^https?:\/\//, "") || "..."}
|
{monitor.url?.replace(/^https?:\/\//, "") || "..."}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -334,8 +338,8 @@ const Configure = () => {
|
|||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2">General settings</Typography>
|
<Typography component="h2">General settings</Typography>
|
||||||
<Typography component="p">
|
<Typography component="p">
|
||||||
Here you can select the URL of the host, together with the
|
Here you can select the URL of the host, together with the type of
|
||||||
type of monitor.
|
monitor.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(20)}>
|
<Stack gap={theme.spacing(20)}>
|
||||||
@@ -369,9 +373,7 @@ const Configure = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(6)}>
|
<Stack gap={theme.spacing(6)}>
|
||||||
<Typography component="p">
|
<Typography component="p">When there is a new incident,</Typography>
|
||||||
When there is a new incident,
|
|
||||||
</Typography>
|
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="notify-sms"
|
id="notify-sms"
|
||||||
label="Notify via SMS (coming soon)"
|
label="Notify via SMS (coming soon)"
|
||||||
@@ -433,7 +435,11 @@ const Configure = () => {
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
<Stack direction="row" justifyContent="flex-end" mt="auto">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
mt="auto"
|
||||||
|
>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
@@ -447,71 +453,17 @@ const Configure = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Modal
|
|
||||||
aria-labelledby="modal-delete-monitor"
|
<Dialog
|
||||||
aria-describedby="delete-monitor-confirmation"
|
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
onClose={() => setIsOpen(false)}
|
theme={theme}
|
||||||
disablePortal
|
title="Do you really want to delete this monitor?"
|
||||||
>
|
description="Once deleted, this monitor cannot be retrieved."
|
||||||
<Stack
|
onCancel={() => setIsOpen(false)}
|
||||||
gap={theme.spacing(2)}
|
confirmationButtonLabel="Delete"
|
||||||
sx={{
|
onConfirm={handleRemove}
|
||||||
position: "absolute",
|
isLoading={isLoading}
|
||||||
top: "50%",
|
/>
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
width: 400,
|
|
||||||
bgcolor: theme.palette.background.main,
|
|
||||||
border: 1,
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
boxShadow: 24,
|
|
||||||
p: theme.spacing(15),
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
id="modal-delete-monitor"
|
|
||||||
component="h2"
|
|
||||||
fontSize={16}
|
|
||||||
color={theme.palette.text.primary}
|
|
||||||
fontWeight={600}
|
|
||||||
>
|
|
||||||
Do you really want to delete this monitor?
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
id="delete-monitor-confirmation"
|
|
||||||
color={theme.palette.text.tertiary}
|
|
||||||
>
|
|
||||||
Once deleted, this monitor cannot be retrieved.
|
|
||||||
</Typography>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
gap={theme.spacing(4)}
|
|
||||||
mt={theme.spacing(12)}
|
|
||||||
justifyContent="flex-end"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
variant="text"
|
|
||||||
color="info"
|
|
||||||
onClick={() => setIsOpen(false)}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<LoadingButton
|
|
||||||
variant="contained"
|
|
||||||
color="error"
|
|
||||||
loading={isLoading}
|
|
||||||
onClick={handleRemove}
|
|
||||||
>
|
|
||||||
Delete
|
|
||||||
</LoadingButton>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
</Modal>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,9 +11,20 @@ const SkeletonLayout = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Skeleton variant="rounded" width="15%" height={34} />
|
<Skeleton
|
||||||
<Stack gap={theme.spacing(20)} mt={theme.spacing(6)}>
|
variant="rounded"
|
||||||
<Stack direction="row" gap={theme.spacing(4)} mt={theme.spacing(4)}>
|
width="15%"
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
|
<Stack
|
||||||
|
gap={theme.spacing(20)}
|
||||||
|
mt={theme.spacing(6)}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(4)}
|
||||||
|
mt={theme.spacing(4)}
|
||||||
|
>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="circular"
|
variant="circular"
|
||||||
style={{ minWidth: 24, minHeight: 24 }}
|
style={{ minWidth: 24, minHeight: 24 }}
|
||||||
@@ -25,7 +36,11 @@ const SkeletonLayout = () => {
|
|||||||
height={24}
|
height={24}
|
||||||
sx={{ mb: theme.spacing(4) }}
|
sx={{ mb: theme.spacing(4) }}
|
||||||
/>
|
/>
|
||||||
<Skeleton variant="rounded" width="50%" height={18} />
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={18}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
@@ -35,14 +50,37 @@ const SkeletonLayout = () => {
|
|||||||
alignSelf: "flex-end",
|
alignSelf: "flex-end",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Skeleton variant="rounded" width={150} height={34} />
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width={150}
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Skeleton variant="rounded" width="100%" height={200} />
|
<Skeleton
|
||||||
<Skeleton variant="rounded" width="100%" height={200} />
|
variant="rounded"
|
||||||
<Skeleton variant="rounded" width="100%" height={200} />
|
width="100%"
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
height={200}
|
||||||
<Skeleton variant="rounded" width="15%" height={34} />
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={200}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={200}
|
||||||
|
/>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="15%"
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material";
|
import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material";
|
||||||
|
import LoadingButton from '@mui/lab/LoadingButton';
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { monitorValidation } from "../../../Validation/validation";
|
import { monitorValidation } from "../../../Validation/validation";
|
||||||
import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
||||||
|
import { checkEndpointResolution } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
@@ -19,7 +21,7 @@ import "./index.css";
|
|||||||
const CreateMonitor = () => {
|
const CreateMonitor = () => {
|
||||||
const MS_PER_MINUTE = 60000;
|
const MS_PER_MINUTE = 60000;
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user, authToken } = useSelector((state) => state.auth);
|
||||||
const { monitors } = useSelector((state) => state.uptimeMonitors);
|
const { monitors, isLoading } = useSelector((state) => state.uptimeMonitors);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -46,9 +48,7 @@ const CreateMonitor = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
if (monitorId) {
|
if (monitorId) {
|
||||||
const action = await dispatch(
|
const action = await dispatch(getUptimeMonitorById({ authToken, monitorId }));
|
||||||
getUptimeMonitorById({ authToken, monitorId })
|
|
||||||
);
|
|
||||||
|
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
const data = action.payload.data;
|
const data = action.payload.data;
|
||||||
@@ -148,6 +148,17 @@ const CreateMonitor = () => {
|
|||||||
setErrors(newErrors);
|
setErrors(newErrors);
|
||||||
createToast({ body: "Error validation data." });
|
createToast({ body: "Error validation data." });
|
||||||
} else {
|
} else {
|
||||||
|
if (monitor.type === "http") {
|
||||||
|
const checkEndpointAction = await dispatch(
|
||||||
|
checkEndpointResolution({ authToken, monitorURL: form.url })
|
||||||
|
)
|
||||||
|
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||||
|
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
|
||||||
|
setErrors({ url: "The entered URL is not reachable." });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
form = {
|
form = {
|
||||||
...form,
|
...form,
|
||||||
description: form.name,
|
description: form.name,
|
||||||
@@ -155,9 +166,7 @@ const CreateMonitor = () => {
|
|||||||
userId: user._id,
|
userId: user._id,
|
||||||
notifications: monitor.notifications,
|
notifications: monitor.notifications,
|
||||||
};
|
};
|
||||||
const action = await dispatch(
|
const action = await dispatch(createUptimeMonitor({ authToken, monitor: form }));
|
||||||
createUptimeMonitor({ authToken, monitor: form })
|
|
||||||
);
|
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
createToast({ body: "Monitor created successfully!" });
|
createToast({ body: "Monitor created successfully!" });
|
||||||
navigate("/monitors");
|
navigate("/monitors");
|
||||||
@@ -193,8 +202,14 @@ const CreateMonitor = () => {
|
|||||||
gap={theme.spacing(12)}
|
gap={theme.spacing(12)}
|
||||||
mt={theme.spacing(6)}
|
mt={theme.spacing(6)}
|
||||||
>
|
>
|
||||||
<Typography component="h1" variant="h1">
|
<Typography
|
||||||
<Typography component="span" fontSize="inherit">
|
component="h1"
|
||||||
|
variant="h1"
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
fontSize="inherit"
|
||||||
|
>
|
||||||
Create your{" "}
|
Create your{" "}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -210,8 +225,7 @@ const CreateMonitor = () => {
|
|||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2">General settings</Typography>
|
<Typography component="h2">General settings</Typography>
|
||||||
<Typography component="p">
|
<Typography component="p">
|
||||||
Here you can select the URL of the host, together with the type of
|
Here you can select the URL of the host, together with the type of monitor.
|
||||||
monitor.
|
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(15)}>
|
<Stack gap={theme.spacing(15)}>
|
||||||
@@ -368,15 +382,19 @@ const CreateMonitor = () => {
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
<Stack
|
||||||
<Button
|
direction="row"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
>
|
||||||
|
<LoadingButton
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={handleCreateMonitor}
|
onClick={handleCreateMonitor}
|
||||||
disabled={Object.keys(errors).length !== 0 && true}
|
disabled={Object.keys(errors).length !== 0 && true}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
Create monitor
|
Create monitor
|
||||||
</Button>
|
</LoadingButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -13,27 +13,28 @@ import { memo, useMemo, useState } from "react";
|
|||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { formatDateWithTz } from "../../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../../Utils/timeUtils";
|
||||||
|
|
||||||
const CustomLabels = ({
|
const CustomLabels = ({ x, width, height, firstDataPoint, lastDataPoint, type }) => {
|
||||||
x,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
firstDataPoint,
|
|
||||||
lastDataPoint,
|
|
||||||
type,
|
|
||||||
}) => {
|
|
||||||
const uiTimezone = useSelector((state) => state.ui.timezone);
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
const dateFormat = type === "day" ? "MMM D, h:mm A" : "MMM D";
|
const dateFormat = type === "day" ? "MMM D, h:mm A" : "MMM D";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<text x={x} y={height} dy={-3} textAnchor="start" fontSize={11}>
|
<text
|
||||||
{formatDateWithTz(
|
x={x}
|
||||||
new Date(firstDataPoint.time),
|
y={height}
|
||||||
dateFormat,
|
dy={-3}
|
||||||
uiTimezone
|
textAnchor="start"
|
||||||
)}
|
fontSize={11}
|
||||||
|
>
|
||||||
|
{formatDateWithTz(new Date(firstDataPoint.time), dateFormat, uiTimezone)}
|
||||||
</text>
|
</text>
|
||||||
<text x={width} y={height} dy={-3} textAnchor="end" fontSize={11}>
|
<text
|
||||||
|
x={width}
|
||||||
|
y={height}
|
||||||
|
dy={-3}
|
||||||
|
textAnchor="end"
|
||||||
|
fontSize={11}
|
||||||
|
>
|
||||||
{formatDateWithTz(new Date(lastDataPoint.time), dateFormat, uiTimezone)}
|
{formatDateWithTz(new Date(lastDataPoint.time), dateFormat, uiTimezone)}
|
||||||
</text>
|
</text>
|
||||||
</>
|
</>
|
||||||
@@ -67,7 +68,11 @@ const UpBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
const reversedData = useMemo(() => [...data].reverse(), [data]);
|
const reversedData = useMemo(() => [...data].reverse(), [data]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" minWidth={210} height={155}>
|
<ResponsiveContainer
|
||||||
|
width="100%"
|
||||||
|
minWidth={210}
|
||||||
|
height={155}
|
||||||
|
>
|
||||||
<BarChart
|
<BarChart
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
@@ -108,9 +113,7 @@ const UpBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
return (
|
return (
|
||||||
<Cell
|
<Cell
|
||||||
key={`cell-${entry.time}`}
|
key={`cell-${entry.time}`}
|
||||||
fill={
|
fill={hoveredBarIndex === index ? main : chartHovered ? light : main}
|
||||||
hoveredBarIndex === index ? main : chartHovered ? light : main
|
|
||||||
}
|
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
setHoveredBarIndex(index);
|
setHoveredBarIndex(index);
|
||||||
onBarHover(entry);
|
onBarHover(entry);
|
||||||
@@ -153,7 +156,11 @@ const DownBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
const reversedData = useMemo(() => [...data].reverse(), [data]);
|
const reversedData = useMemo(() => [...data].reverse(), [data]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" minWidth={250} height={155}>
|
<ResponsiveContainer
|
||||||
|
width="100%"
|
||||||
|
minWidth={250}
|
||||||
|
height={155}
|
||||||
|
>
|
||||||
<BarChart
|
<BarChart
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
@@ -260,7 +267,11 @@ const ResponseGaugeChart = ({ data }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" minWidth={210} height={155}>
|
<ResponsiveContainer
|
||||||
|
width="100%"
|
||||||
|
minWidth={210}
|
||||||
|
height={155}
|
||||||
|
>
|
||||||
<RadialBarChart
|
<RadialBarChart
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
@@ -271,10 +282,24 @@ const ResponseGaugeChart = ({ data }) => {
|
|||||||
innerRadius={100}
|
innerRadius={100}
|
||||||
outerRadius={150}
|
outerRadius={150}
|
||||||
>
|
>
|
||||||
<text x={0} y="100%" dx="5%" dy={-2} textAnchor="start" fontSize={11}>
|
<text
|
||||||
|
x={0}
|
||||||
|
y="100%"
|
||||||
|
dx="5%"
|
||||||
|
dy={-2}
|
||||||
|
textAnchor="start"
|
||||||
|
fontSize={11}
|
||||||
|
>
|
||||||
low
|
low
|
||||||
</text>
|
</text>
|
||||||
<text x="100%" y="100%" dx="-3%" dy={-2} textAnchor="end" fontSize={11}>
|
<text
|
||||||
|
x="100%"
|
||||||
|
y="100%"
|
||||||
|
dx="-3%"
|
||||||
|
dy={-2}
|
||||||
|
textAnchor="end"
|
||||||
|
fontSize={11}
|
||||||
|
>
|
||||||
high
|
high
|
||||||
</text>
|
</text>
|
||||||
<text
|
<text
|
||||||
@@ -294,8 +319,7 @@ const ResponseGaugeChart = ({ data }) => {
|
|||||||
dominantBaseline="hanging"
|
dominantBaseline="hanging"
|
||||||
fontSize={25}
|
fontSize={25}
|
||||||
>
|
>
|
||||||
<tspan fontWeight={600}>{responseTime}</tspan>{" "}
|
<tspan fontWeight={600}>{responseTime}</tspan> <tspan opacity={0.8}>ms</tspan>
|
||||||
<tspan opacity={0.8}>ms</tspan>
|
|
||||||
</text>
|
</text>
|
||||||
<RadialBar
|
<RadialBar
|
||||||
background={{ fill: responseProps.bg }}
|
background={{ fill: responseProps.bg }}
|
||||||
@@ -303,7 +327,11 @@ const ResponseGaugeChart = ({ data }) => {
|
|||||||
dataKey="response"
|
dataKey="response"
|
||||||
stroke="none"
|
stroke="none"
|
||||||
>
|
>
|
||||||
<Cell fill="transparent" background={false} barSize={0} />
|
<Cell
|
||||||
|
fill="transparent"
|
||||||
|
background={false}
|
||||||
|
barSize={0}
|
||||||
|
/>
|
||||||
<Cell fill={responseProps.main} />
|
<Cell fill={responseProps.main} />
|
||||||
</RadialBar>
|
</RadialBar>
|
||||||
</RadialBarChart>
|
</RadialBarChart>
|
||||||
|
|||||||
@@ -125,9 +125,7 @@ const PaginationTable = ({ monitorId, dateRange }) => {
|
|||||||
uiTimezone
|
uiTimezone
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>{check.statusCode ? check.statusCode : "N/A"}</TableCell>
|
||||||
{check.statusCode ? check.statusCode : "N/A"}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>{check.message}</TableCell>
|
<TableCell>{check.message}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
@@ -13,10 +13,7 @@ import { useSelector } from "react-redux";
|
|||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { networkService } from "../../../main";
|
import { networkService } from "../../../main";
|
||||||
import { logger } from "../../../Utils/Logger";
|
import { logger } from "../../../Utils/Logger";
|
||||||
import {
|
import { formatDurationRounded, formatDurationSplit } from "../../../Utils/timeUtils";
|
||||||
formatDurationRounded,
|
|
||||||
formatDurationSplit,
|
|
||||||
} from "../../../Utils/timeUtils";
|
|
||||||
import MonitorDetailsAreaChart from "../../../Components/Charts/MonitorDetailsAreaChart";
|
import MonitorDetailsAreaChart from "../../../Components/Charts/MonitorDetailsAreaChart";
|
||||||
import ButtonGroup from "@mui/material/ButtonGroup";
|
import ButtonGroup from "@mui/material/ButtonGroup";
|
||||||
import SettingsIcon from "../../../assets/icons/settings-bold.svg?react";
|
import SettingsIcon from "../../../assets/icons/settings-bold.svg?react";
|
||||||
@@ -93,16 +90,12 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
authToken: authToken,
|
authToken: authToken,
|
||||||
monitorId: monitorId,
|
monitorId: monitorId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res?.data?.data?.certificateDate) {
|
if (res?.data?.data?.certificateDate) {
|
||||||
let [month, day, year] = res.data.data.certificateDate.split("/");
|
const date = res.data.data.certificateDate;
|
||||||
const date = new Date(year, month - 1, day);
|
setCertificateExpiry(formatDateWithTz(date, dateFormat, uiTimezone) ?? "N/A");
|
||||||
|
|
||||||
setCertificateExpiry(
|
|
||||||
formatDateWithTz(date, dateFormat, uiTimezone) ?? "N/A"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
setCertificateExpiry("N/A");
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -136,10 +129,19 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
{ name: "details", path: `/monitors/${monitorId}` },
|
{ name: "details", path: `/monitors/${monitorId}` },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<Stack gap={theme.spacing(10)} mt={theme.spacing(10)}>
|
<Stack
|
||||||
<Stack direction="row" gap={theme.spacing(2)}>
|
gap={theme.spacing(10)}
|
||||||
|
mt={theme.spacing(10)}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(2)}
|
||||||
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1" variant="h1">
|
<Typography
|
||||||
|
component="h1"
|
||||||
|
variant="h1"
|
||||||
|
>
|
||||||
{monitor.name}
|
{monitor.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -168,7 +170,10 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
<PulseDot color={statusColor[determineState(monitor)]} />
|
<PulseDot color={statusColor[determineState(monitor)]} />
|
||||||
</Box>
|
</Box>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Typography component="h2" variant="h2">
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
>
|
||||||
{monitor.url?.replace(/^https?:\/\//, "") || "..."}
|
{monitor.url?.replace(/^https?:\/\//, "") || "..."}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -273,12 +278,13 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" gap={theme.spacing(8)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(8)}
|
||||||
|
>
|
||||||
<StatBox sx={statusStyles[determineState(monitor)]}>
|
<StatBox sx={statusStyles[determineState(monitor)]}>
|
||||||
<Typography component="h2">active for</Typography>
|
<Typography component="h2">active for</Typography>
|
||||||
<Typography>
|
<Typography>{splitDuration(monitor?.uptimeDuration)}</Typography>
|
||||||
{splitDuration(monitor?.uptimeDuration)}
|
|
||||||
</Typography>
|
|
||||||
</StatBox>
|
</StatBox>
|
||||||
<StatBox>
|
<StatBox>
|
||||||
<Typography component="h2">last check</Typography>
|
<Typography component="h2">last check</Typography>
|
||||||
@@ -336,7 +342,11 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" flexWrap="wrap" gap={theme.spacing(8)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
flexWrap="wrap"
|
||||||
|
gap={theme.spacing(8)}
|
||||||
|
>
|
||||||
<ChartBox>
|
<ChartBox>
|
||||||
<Stack>
|
<Stack>
|
||||||
<IconBox>
|
<IconBox>
|
||||||
@@ -352,8 +362,7 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
? hoveredUptimeData.totalChecks
|
? hoveredUptimeData.totalChecks
|
||||||
: monitor?.periodTotalChecks}
|
: monitor?.periodTotalChecks}
|
||||||
</Typography>
|
</Typography>
|
||||||
{hoveredUptimeData !== null &&
|
{hoveredUptimeData !== null && hoveredUptimeData.time !== null && (
|
||||||
hoveredUptimeData.time !== null && (
|
|
||||||
<Typography
|
<Typography
|
||||||
component="h5"
|
component="h5"
|
||||||
position="absolute"
|
position="absolute"
|
||||||
@@ -373,9 +382,7 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
<Typography>Uptime Percentage</Typography>
|
<Typography>Uptime Percentage</Typography>
|
||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{hoveredUptimeData !== null
|
{hoveredUptimeData !== null
|
||||||
? Math.floor(
|
? Math.floor(hoveredUptimeData.uptimePercentage * 10) / 10
|
||||||
hoveredUptimeData.uptimePercentage * 10
|
|
||||||
) / 10
|
|
||||||
: Math.floor(monitor?.periodUptime * 10) / 10}
|
: Math.floor(monitor?.periodUptime * 10) / 10}
|
||||||
<Typography component="span">%</Typography>
|
<Typography component="span">%</Typography>
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -429,24 +436,23 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
<IconBox>
|
<IconBox>
|
||||||
<AverageResponseIcon />
|
<AverageResponseIcon />
|
||||||
</IconBox>
|
</IconBox>
|
||||||
<Typography component="h2">
|
<Typography component="h2">Average Response Time</Typography>
|
||||||
Average Response Time
|
|
||||||
</Typography>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
<ResponseGaugeChart
|
<ResponseGaugeChart
|
||||||
data={[{ response: monitor?.periodAvgResponseTime }]}
|
data={[{ response: monitor?.periodAvgResponseTime }]}
|
||||||
/>
|
/>
|
||||||
</ChartBox>
|
</ChartBox>
|
||||||
<ChartBox sx={{ padding: 0 }}>
|
<ChartBox sx={{ padding: 0 }}>
|
||||||
<Stack pt={theme.spacing(8)} pl={theme.spacing(8)}>
|
<Stack
|
||||||
|
pt={theme.spacing(8)}
|
||||||
|
pl={theme.spacing(8)}
|
||||||
|
>
|
||||||
<IconBox>
|
<IconBox>
|
||||||
<ResponseTimeIcon />
|
<ResponseTimeIcon />
|
||||||
</IconBox>
|
</IconBox>
|
||||||
<Typography component="h2">Response Times</Typography>
|
<Typography component="h2">Response Times</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<MonitorDetailsAreaChart
|
<MonitorDetailsAreaChart checks={[...monitor.checks].reverse()} />
|
||||||
checks={[...monitor.checks].reverse()}
|
|
||||||
/>
|
|
||||||
</ChartBox>
|
</ChartBox>
|
||||||
<ChartBox
|
<ChartBox
|
||||||
gap={theme.spacing(8)}
|
gap={theme.spacing(8)}
|
||||||
|
|||||||
@@ -10,15 +10,30 @@ const SkeletonLayout = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Skeleton variant="rounded" width="20%" height={34} />
|
<Skeleton
|
||||||
<Stack gap={theme.spacing(20)} mt={theme.spacing(6)}>
|
variant="rounded"
|
||||||
<Stack direction="row" gap={theme.spacing(4)} mt={theme.spacing(4)}>
|
width="20%"
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
|
<Stack
|
||||||
|
gap={theme.spacing(20)}
|
||||||
|
mt={theme.spacing(6)}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(4)}
|
||||||
|
mt={theme.spacing(4)}
|
||||||
|
>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="circular"
|
variant="circular"
|
||||||
style={{ minWidth: 24, minHeight: 24 }}
|
style={{ minWidth: 24, minHeight: 24 }}
|
||||||
/>
|
/>
|
||||||
<Box width="80%">
|
<Box width="80%">
|
||||||
<Skeleton variant="rounded" width="50%" height={24} />
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={24}
|
||||||
|
/>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="rounded"
|
variant="rounded"
|
||||||
width="50%"
|
width="50%"
|
||||||
@@ -38,9 +53,21 @@ const SkeletonLayout = () => {
|
|||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
gap={theme.spacing(12)}
|
gap={theme.spacing(12)}
|
||||||
>
|
>
|
||||||
<Skeleton variant="rounded" width="100%" height={80} />
|
<Skeleton
|
||||||
<Skeleton variant="rounded" width="100%" height={80} />
|
variant="rounded"
|
||||||
<Skeleton variant="rounded" width="100%" height={80} />
|
width="100%"
|
||||||
|
height={80}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={80}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={80}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box>
|
<Box>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -54,16 +81,36 @@ const SkeletonLayout = () => {
|
|||||||
height={24}
|
height={24}
|
||||||
sx={{ alignSelf: "flex-end" }}
|
sx={{ alignSelf: "flex-end" }}
|
||||||
/>
|
/>
|
||||||
<Skeleton variant="rounded" width="20%" height={34} />
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="20%"
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box sx={{ height: "200px" }}>
|
<Box sx={{ height: "200px" }}>
|
||||||
<Skeleton variant="rounded" width="100%" height="100%" />
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(8)}>
|
<Stack gap={theme.spacing(8)}>
|
||||||
<Skeleton variant="rounded" width="20%" height={24} />
|
<Skeleton
|
||||||
<Skeleton variant="rounded" width="100%" height={200} />
|
variant="rounded"
|
||||||
<Skeleton variant="rounded" width="100%" height={50} />
|
width="20%"
|
||||||
|
height={24}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={200}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={50}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import { useTheme } from "@emotion/react";
|
||||||
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
|
import Search from "../../../../Components/Inputs/Search";
|
||||||
|
import MemoizedMonitorTable from "../MonitorTable";
|
||||||
|
import { useState } from "react";
|
||||||
|
import useDebounce from "../../../../Utils/debounce";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
const CurrentMonitoring = ({ totalMonitors, monitors, isAdmin }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const [search, setSearch] = useState("");
|
||||||
|
const [isSearching, setIsSearching] = useState(false);
|
||||||
|
const debouncedFilter = useDebounce(search, 500);
|
||||||
|
const handleSearch = (value) => {
|
||||||
|
setIsSearching(true);
|
||||||
|
setSearch(value);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
flex={1}
|
||||||
|
px={theme.spacing(10)}
|
||||||
|
py={theme.spacing(8)}
|
||||||
|
border={1}
|
||||||
|
borderColor={theme.palette.border.light}
|
||||||
|
borderRadius={theme.shape.borderRadius}
|
||||||
|
backgroundColor={theme.palette.background.main}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
mb={theme.spacing(8)}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
fontWeight={500}
|
||||||
|
letterSpacing={-0.2}
|
||||||
|
>
|
||||||
|
Actively monitoring
|
||||||
|
</Typography>
|
||||||
|
<Box
|
||||||
|
className="current-monitors-counter"
|
||||||
|
color={theme.palette.text.primary}
|
||||||
|
border={1}
|
||||||
|
borderColor={theme.palette.border.light}
|
||||||
|
backgroundColor={theme.palette.background.accent}
|
||||||
|
>
|
||||||
|
{totalMonitors}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
width="25%"
|
||||||
|
minWidth={150}
|
||||||
|
ml="auto"
|
||||||
|
>
|
||||||
|
<Search
|
||||||
|
options={monitors}
|
||||||
|
filteredBy="name"
|
||||||
|
inputValue={search}
|
||||||
|
handleInputChange={handleSearch}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
<MemoizedMonitorTable
|
||||||
|
isAdmin={isAdmin}
|
||||||
|
filter={debouncedFilter}
|
||||||
|
setIsSearching={setIsSearching}
|
||||||
|
isSearching={isSearching}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
CurrentMonitoring.propTypes = {
|
||||||
|
totalMonitors: PropTypes.number,
|
||||||
|
monitors: PropTypes.array,
|
||||||
|
isAdmin: PropTypes.bool,
|
||||||
|
};
|
||||||
|
|
||||||
|
export { CurrentMonitoring };
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { Skeleton, TableCell, TableRow } from "@mui/material";
|
||||||
|
const ROWS_NUMBER = 7;
|
||||||
|
const ROWS_ARRAY = Array.from({ length: ROWS_NUMBER }, (_, i) => i);
|
||||||
|
|
||||||
|
const TableBodySkeleton = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{ROWS_ARRAY.map((row) => (
|
||||||
|
<TableRow key={row}>
|
||||||
|
<TableCell>
|
||||||
|
<Skeleton />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Skeleton />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Skeleton />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Skeleton />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Skeleton />
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { TableBodySkeleton };
|
||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
Typography,
|
Typography,
|
||||||
Button,
|
Button,
|
||||||
|
CircularProgress,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded";
|
import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded";
|
||||||
import ArrowUpwardRoundedIcon from "@mui/icons-material/ArrowUpwardRounded";
|
import ArrowUpwardRoundedIcon from "@mui/icons-material/ArrowUpwardRounded";
|
||||||
@@ -34,6 +35,7 @@ import RightArrow from "../../../../assets/icons/right-arrow.svg?react";
|
|||||||
import SelectorVertical from "../../../../assets/icons/selector-vertical.svg?react";
|
import SelectorVertical from "../../../../assets/icons/selector-vertical.svg?react";
|
||||||
import ActionsMenu from "../actionsMenu";
|
import ActionsMenu from "../actionsMenu";
|
||||||
import useUtils from "../../utils";
|
import useUtils from "../../utils";
|
||||||
|
import { TableBodySkeleton } from "./Skeleton";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component for pagination actions (first, previous, next, last).
|
* Component for pagination actions (first, previous, next, last).
|
||||||
@@ -107,17 +109,17 @@ TablePaginationActions.propTypes = {
|
|||||||
onPageChange: PropTypes.func.isRequired,
|
onPageChange: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
const MonitorTable = ({ isAdmin, filter, setIsSearching, isSearching }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { determineState } = useUtils();
|
const { determineState } = useUtils();
|
||||||
|
|
||||||
const { rowsPerPage } = useSelector((state) => state.ui.monitors);
|
const { rowsPerPage } = useSelector((state) => state.ui.monitors);
|
||||||
|
const authState = useSelector((state) => state.auth);
|
||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
const [monitors, setMonitors] = useState([]);
|
const [monitors, setMonitors] = useState([]);
|
||||||
const [monitorCount, setMonitorCount] = useState(0);
|
const [monitorCount, setMonitorCount] = useState(0);
|
||||||
const authState = useSelector((state) => state.auth);
|
|
||||||
const [updateTrigger, setUpdateTrigger] = useState(false);
|
const [updateTrigger, setUpdateTrigger] = useState(false);
|
||||||
const [sort, setSort] = useState({});
|
const [sort, setSort] = useState({});
|
||||||
const prevFilter = useRef(filter);
|
const prevFilter = useRef(filter);
|
||||||
@@ -160,11 +162,12 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
|||||||
});
|
});
|
||||||
setMonitors(res?.data?.data?.monitors ?? []);
|
setMonitors(res?.data?.data?.monitors ?? []);
|
||||||
setMonitorCount(res?.data?.data?.monitorCount ?? 0);
|
setMonitorCount(res?.data?.data?.monitorCount ?? 0);
|
||||||
setLoading(false);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
|
} finally {
|
||||||
|
setIsSearching(false);
|
||||||
}
|
}
|
||||||
}, [authState, page, rowsPerPage, filter, sort, setLoading]);
|
}, [authState, page, rowsPerPage, filter, sort, setIsSearching]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchPage();
|
fetchPage();
|
||||||
@@ -175,7 +178,7 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
|||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
filter,
|
filter,
|
||||||
sort,
|
sort,
|
||||||
setLoading,
|
setIsSearching,
|
||||||
fetchPage,
|
fetchPage,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -229,7 +232,37 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<Box position="relative">
|
||||||
|
{isSearching && (
|
||||||
<>
|
<>
|
||||||
|
<Box
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
position="absolute"
|
||||||
|
sx={{
|
||||||
|
backgroundColor: theme.palette.background.main,
|
||||||
|
opacity: 0.8,
|
||||||
|
zIndex: 100,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Box
|
||||||
|
height="100%"
|
||||||
|
position="absolute"
|
||||||
|
top="20%"
|
||||||
|
left="50%"
|
||||||
|
sx={{
|
||||||
|
transform: "translateX(-50%)",
|
||||||
|
zIndex: 101,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CircularProgress
|
||||||
|
sx={{
|
||||||
|
color: theme.palette.other.icon,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<TableContainer component={Paper}>
|
<TableContainer component={Paper}>
|
||||||
<Table>
|
<Table>
|
||||||
<TableHead>
|
<TableHead>
|
||||||
@@ -263,8 +296,7 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
|||||||
Status
|
Status
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
visibility:
|
visibility: sort.field === "status" ? "visible" : "hidden",
|
||||||
sort.field === "status" ? "visible" : "hidden",
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{sort.order === "asc" ? (
|
{sort.order === "asc" ? (
|
||||||
@@ -281,7 +313,9 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{monitors.map((monitor) => {
|
{/* TODO add empty state. Check if is searching, and empty => skeleton. Is empty, not searching => skeleton */}
|
||||||
|
{monitors.length > 0 ? (
|
||||||
|
monitors.map((monitor) => {
|
||||||
let uptimePercentage = "";
|
let uptimePercentage = "";
|
||||||
let percentageColor = theme.palette.percentage.uptimeExcellent;
|
let percentageColor = theme.palette.percentage.uptimeExcellent;
|
||||||
|
|
||||||
@@ -324,7 +358,10 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Host key={monitor._id} params={params} />
|
<Host
|
||||||
|
key={monitor._id}
|
||||||
|
params={params}
|
||||||
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusLabel
|
<StatusLabel
|
||||||
@@ -337,9 +374,7 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
|||||||
<BarChart checks={monitor.checks.slice().reverse()} />
|
<BarChart checks={monitor.checks.slice().reverse()} />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<span style={{ textTransform: "uppercase" }}>
|
<span style={{ textTransform: "uppercase" }}>{monitor.type}</span>
|
||||||
{monitor.type}
|
|
||||||
</span>
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<ActionsMenu
|
<ActionsMenu
|
||||||
@@ -350,7 +385,10 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})
|
||||||
|
) : (
|
||||||
|
<TableBodySkeleton />
|
||||||
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
@@ -360,7 +398,11 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
|||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
px={theme.spacing(4)}
|
px={theme.spacing(4)}
|
||||||
>
|
>
|
||||||
<Typography px={theme.spacing(2)} variant="body2" sx={{ opacity: 0.7 }}>
|
<Typography
|
||||||
|
px={theme.spacing(2)}
|
||||||
|
variant="body2"
|
||||||
|
sx={{ opacity: 0.7 }}
|
||||||
|
>
|
||||||
Showing {getRange()} of {monitorCount} monitor(s)
|
Showing {getRange()} of {monitorCount} monitor(s)
|
||||||
</Typography>
|
</Typography>
|
||||||
<TablePagination
|
<TablePagination
|
||||||
@@ -420,14 +462,15 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
MonitorTable.propTypes = {
|
MonitorTable.propTypes = {
|
||||||
isAdmin: PropTypes.bool,
|
isAdmin: PropTypes.bool,
|
||||||
filter: PropTypes.string,
|
filter: PropTypes.string,
|
||||||
setLoading: PropTypes.func,
|
setIsSearching: PropTypes.func,
|
||||||
|
isSearching: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MemoizedMonitorTable = memo(MonitorTable);
|
const MemoizedMonitorTable = memo(MonitorTable);
|
||||||
|
|||||||
@@ -3,21 +3,16 @@ import { useSelector, useDispatch } from "react-redux";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import {
|
import { logger } from "../../../Utils/Logger";
|
||||||
Button,
|
import { IconButton, Menu, MenuItem } from "@mui/material";
|
||||||
IconButton,
|
|
||||||
Menu,
|
|
||||||
MenuItem,
|
|
||||||
Modal,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import {
|
import {
|
||||||
deleteUptimeMonitor,
|
deleteUptimeMonitor,
|
||||||
|
pauseUptimeMonitor,
|
||||||
getUptimeMonitorsByTeamId,
|
getUptimeMonitorsByTeamId,
|
||||||
} from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
} from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
||||||
import Settings from "../../../assets/icons/settings-bold.svg?react";
|
import Settings from "../../../assets/icons/settings-bold.svg?react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
import Dialog from "../../../Components/Dialog";
|
||||||
|
|
||||||
const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
|
const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
@@ -26,6 +21,8 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const authState = useSelector((state) => state.auth);
|
const authState = useSelector((state) => state.auth);
|
||||||
|
const authToken = authState.authToken;
|
||||||
|
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
||||||
|
|
||||||
const handleRemove = async (event) => {
|
const handleRemove = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -44,6 +41,24 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handlePause = async () => {
|
||||||
|
try {
|
||||||
|
const action = await dispatch(
|
||||||
|
pauseUptimeMonitor({ authToken, monitorId: monitor._id })
|
||||||
|
);
|
||||||
|
if (pauseUptimeMonitor.fulfilled.match(action)) {
|
||||||
|
updateCallback();
|
||||||
|
const state = action?.payload?.data.isActive === false ? "paused" : "resumed";
|
||||||
|
createToast({ body: `Monitor ${state} successfully.` });
|
||||||
|
} else {
|
||||||
|
throw new Error(action?.error?.message ?? "Failed to pause monitor.");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Error pausing monitor:", monitor._id, error);
|
||||||
|
createToast({ body: "Failed to pause monitor." });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const openMenu = (event, id, url) => {
|
const openMenu = (event, id, url) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -68,11 +83,7 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
|
|||||||
aria-label="monitor actions"
|
aria-label="monitor actions"
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
openMenu(
|
openMenu(event, monitor._id, monitor.type === "ping" ? null : monitor.url);
|
||||||
event,
|
|
||||||
monitor._id,
|
|
||||||
monitor.type === "ping" ? null : monitor.url
|
|
||||||
);
|
|
||||||
}}
|
}}
|
||||||
sx={{
|
sx={{
|
||||||
"&:focus": {
|
"&:focus": {
|
||||||
@@ -155,6 +166,16 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
|
|||||||
Clone
|
Clone
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
|
{isAdmin && (
|
||||||
|
<MenuItem
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
handlePause(e);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{monitor?.isActive === true ? "Pause" : "Resume"}
|
||||||
|
</MenuItem>
|
||||||
|
)}
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@@ -166,69 +187,26 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
</Menu>
|
</Menu>
|
||||||
<Modal
|
<Dialog
|
||||||
aria-labelledby="modal-delete-monitor"
|
|
||||||
aria-describedby="delete-monitor-confirmation"
|
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
onClose={(e) => {
|
theme={theme}
|
||||||
|
title="Do you really want to delete this monitor?"
|
||||||
|
description="Once deleted, this monitor cannot be retrieved."
|
||||||
|
/* Do we need stop propagation? */
|
||||||
|
onCancel={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
confirmationButtonLabel="Delete"
|
||||||
<Stack
|
/* Do we need stop propagation? */
|
||||||
gap={theme.spacing(2)}
|
onConfirm={(e) => {
|
||||||
sx={{
|
|
||||||
position: "absolute",
|
|
||||||
top: "50%",
|
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
width: 400,
|
|
||||||
bgcolor: theme.palette.background.main,
|
|
||||||
border: 1,
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
boxShadow: 24,
|
|
||||||
p: theme.spacing(15),
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography id="modal-delete-monitor" component="h2" variant="h2">
|
|
||||||
Do you really want to delete this monitor?
|
|
||||||
</Typography>
|
|
||||||
<Typography id="delete-monitor-confirmation" variant="body1">
|
|
||||||
Once deleted, this monitor cannot be retrieved.
|
|
||||||
</Typography>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
gap={theme.spacing(4)}
|
|
||||||
mt={theme.spacing(12)}
|
|
||||||
justifyContent="flex-end"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
variant="text"
|
|
||||||
color="info"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsOpen(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
color="error"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation(e);
|
|
||||||
handleRemove(e);
|
handleRemove(e);
|
||||||
}}
|
}}
|
||||||
>
|
isLoading={isLoading}
|
||||||
Delete
|
modelTitle="modal-delete-monitor"
|
||||||
</Button>
|
modelDescription="delete-monitor-confirmation"
|
||||||
</Stack>
|
/>
|
||||||
</Stack>
|
|
||||||
</Modal>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -238,6 +216,7 @@ ActionsMenu.propTypes = {
|
|||||||
_id: PropTypes.string,
|
_id: PropTypes.string,
|
||||||
url: PropTypes.string,
|
url: PropTypes.string,
|
||||||
type: PropTypes.string,
|
type: PropTypes.string,
|
||||||
|
isActive: PropTypes.bool,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
isAdmin: PropTypes.bool,
|
isAdmin: PropTypes.bool,
|
||||||
updateCallback: PropTypes.func,
|
updateCallback: PropTypes.func,
|
||||||
|
|||||||
@@ -26,7 +26,11 @@ const Fallback = ({ isAdmin }) => {
|
|||||||
<Box pb={theme.spacing(20)}>
|
<Box pb={theme.spacing(20)}>
|
||||||
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
||||||
</Box>
|
</Box>
|
||||||
<Typography component="h2" variant="h2" fontWeight={500}>
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
fontWeight={500}
|
||||||
|
>
|
||||||
No monitors found to display
|
No monitors found to display
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
|
|||||||
@@ -1,55 +1,44 @@
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect } from "react";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { getUptimeMonitorsByTeamId } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
import { getUptimeMonitorsByTeamId } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import {
|
import { Box, Button, Stack } from "@mui/material";
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
CircularProgress,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import SkeletonLayout from "./skeleton";
|
import SkeletonLayout from "./skeleton";
|
||||||
import Fallback from "./fallback";
|
import Fallback from "./fallback";
|
||||||
import StatusBox from "./StatusBox";
|
import StatusBox from "./StatusBox";
|
||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
import Greeting from "../../../Utils/greeting";
|
import Greeting from "../../../Utils/greeting";
|
||||||
import MonitorTable from "./MonitorTable";
|
import { CurrentMonitoring } from "./CurrentMonitoring";
|
||||||
import Search from "../../../Components/Inputs/Search";
|
|
||||||
import useDebounce from "../../../Utils/debounce";
|
|
||||||
|
|
||||||
const Monitors = ({ isAdmin }) => {
|
const Monitors = ({ isAdmin }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const monitorState = useSelector((state) => state.uptimeMonitors);
|
const monitorState = useSelector((state) => state.uptimeMonitors);
|
||||||
const authState = useSelector((state) => state.auth);
|
const authState = useSelector((state) => state.auth);
|
||||||
const [search, setSearch] = useState("");
|
|
||||||
const [isSearching, setIsSearching] = useState(false);
|
|
||||||
const dispatch = useDispatch({});
|
const dispatch = useDispatch({});
|
||||||
const debouncedFilter = useDebounce(search, 500);
|
|
||||||
|
|
||||||
const handleSearch = (value) => {
|
|
||||||
setIsSearching(true);
|
|
||||||
setSearch(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(getUptimeMonitorsByTeamId(authState.authToken));
|
dispatch(getUptimeMonitorsByTeamId(authState.authToken));
|
||||||
}, [authState.authToken, dispatch]);
|
}, [authState.authToken, dispatch]);
|
||||||
|
|
||||||
let loading =
|
//TODO bring fetching to this component, like on pageSpeed
|
||||||
monitorState?.isLoading &&
|
|
||||||
monitorState?.monitorsSummary?.monitors?.length === 0;
|
const loading = monitorState?.isLoading;
|
||||||
|
|
||||||
|
const totalMonitors = monitorState?.monitorsSummary?.monitorCounts?.total;
|
||||||
|
|
||||||
|
const hasMonitors = totalMonitors > 0;
|
||||||
|
const noMonitors = !hasMonitors;
|
||||||
|
const canAddMonitor = isAdmin && hasMonitors;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="monitors" gap={theme.spacing(8)}>
|
<Stack
|
||||||
{loading ? (
|
className="monitors"
|
||||||
<SkeletonLayout />
|
gap={theme.spacing(8)}
|
||||||
) : (
|
>
|
||||||
<>
|
|
||||||
<Box>
|
<Box>
|
||||||
<Breadcrumbs list={[{ name: `monitors`, path: "/monitors" }]} />
|
<Breadcrumbs list={[{ name: `monitors`, path: "/monitors" }]} />
|
||||||
<Stack
|
<Stack
|
||||||
@@ -57,10 +46,10 @@ const Monitors = ({ isAdmin }) => {
|
|||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
mt={theme.spacing(5)}
|
mt={theme.spacing(5)}
|
||||||
|
gap={theme.spacing(6)}
|
||||||
>
|
>
|
||||||
<Greeting type="uptime" />
|
<Greeting type="uptime" />
|
||||||
{isAdmin &&
|
{canAddMonitor && (
|
||||||
monitorState?.monitorsSummary?.monitors?.length !== 0 && (
|
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
@@ -74,11 +63,12 @@ const Monitors = ({ isAdmin }) => {
|
|||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
{isAdmin && monitorState?.monitorsSummary?.monitors?.length === 0 && (
|
{noMonitors && <Fallback isAdmin={isAdmin} />}
|
||||||
<Fallback isAdmin={isAdmin} />
|
{loading ? (
|
||||||
)}
|
<SkeletonLayout />
|
||||||
|
) : (
|
||||||
{monitorState?.monitorsSummary?.monitors?.length !== 0 && (
|
<>
|
||||||
|
{hasMonitors && (
|
||||||
<>
|
<>
|
||||||
<Stack
|
<Stack
|
||||||
gap={theme.spacing(8)}
|
gap={theme.spacing(8)}
|
||||||
@@ -91,95 +81,18 @@ const Monitors = ({ isAdmin }) => {
|
|||||||
/>
|
/>
|
||||||
<StatusBox
|
<StatusBox
|
||||||
title="down"
|
title="down"
|
||||||
value={
|
value={monitorState?.monitorsSummary?.monitorCounts?.down ?? 0}
|
||||||
monitorState?.monitorsSummary?.monitorCounts?.down ?? 0
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<StatusBox
|
<StatusBox
|
||||||
title="paused"
|
title="paused"
|
||||||
value={
|
value={monitorState?.monitorsSummary?.monitorCounts?.paused ?? 0}
|
||||||
monitorState?.monitorsSummary?.monitorCounts?.paused ?? 0
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box
|
<CurrentMonitoring
|
||||||
flex={1}
|
|
||||||
px={theme.spacing(10)}
|
|
||||||
py={theme.spacing(8)}
|
|
||||||
border={1}
|
|
||||||
borderColor={theme.palette.border.light}
|
|
||||||
borderRadius={theme.shape.borderRadius}
|
|
||||||
backgroundColor={theme.palette.background.main}
|
|
||||||
>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
alignItems="center"
|
|
||||||
mb={theme.spacing(8)}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
component="h2"
|
|
||||||
variant="h2"
|
|
||||||
fontWeight={500}
|
|
||||||
letterSpacing={-0.2}
|
|
||||||
>
|
|
||||||
Actively monitoring
|
|
||||||
</Typography>
|
|
||||||
<Box
|
|
||||||
className="current-monitors-counter"
|
|
||||||
color={theme.palette.text.primary}
|
|
||||||
border={1}
|
|
||||||
borderColor={theme.palette.border.light}
|
|
||||||
backgroundColor={theme.palette.background.accent}
|
|
||||||
>
|
|
||||||
{monitorState?.monitorsSummary?.monitorCounts?.total || 0}
|
|
||||||
</Box>
|
|
||||||
<Box width="25%" minWidth={150} ml="auto">
|
|
||||||
<Search
|
|
||||||
options={monitorState?.monitorsSummary?.monitors ?? []}
|
|
||||||
filteredBy="name"
|
|
||||||
inputValue={search}
|
|
||||||
handleInputChange={handleSearch}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</Stack>
|
|
||||||
<Box position="relative">
|
|
||||||
{isSearching && (
|
|
||||||
<>
|
|
||||||
<Box
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
position="absolute"
|
|
||||||
sx={{
|
|
||||||
backgroundColor: theme.palette.background.main,
|
|
||||||
opacity: 0.8,
|
|
||||||
zIndex: 100,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Box
|
|
||||||
height="100%"
|
|
||||||
position="absolute"
|
|
||||||
top="20%"
|
|
||||||
left="50%"
|
|
||||||
sx={{
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
zIndex: 101,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CircularProgress
|
|
||||||
sx={{
|
|
||||||
color: theme.palette.other.icon,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<MonitorTable
|
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
filter={debouncedFilter}
|
monitors={monitorState.monitorsSummary.monitors}
|
||||||
setLoading={setIsSearching}
|
totalMonitors={totalMonitors}
|
||||||
/>
|
/>
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -11,20 +11,49 @@ const SkeletonLayout = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
<Stack
|
||||||
<Skeleton variant="rounded" width="50%" height={36} />
|
direction="row"
|
||||||
<Skeleton variant="rounded" width="15%" height={36} />
|
justifyContent="space-between"
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={36}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="15%"
|
||||||
|
height={36}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
gap={theme.spacing(12)}
|
gap={theme.spacing(12)}
|
||||||
direction="row"
|
direction="row"
|
||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
>
|
>
|
||||||
<Skeleton variant="rounded" width="100%" height={100} />
|
<Skeleton
|
||||||
<Skeleton variant="rounded" width="100%" height={100} />
|
variant="rounded"
|
||||||
<Skeleton variant="rounded" width="100%" height={100} />
|
width="100%"
|
||||||
|
height={100}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={100}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={100}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Skeleton variant="rounded" width="100%" height="100%" flex={1} />
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
flex={1}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,10 +35,24 @@ const NotFound = ({ title = DefaultValue.title, desc = DefaultValue.desc }) => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack height="100vh" justifyContent="center">
|
<Stack
|
||||||
<Stack gap={theme.spacing(2)} alignItems="center">
|
height="100vh"
|
||||||
<img src={NotFoundSvg} alt="404" style={{ maxHeight: "25rem" }} />
|
justifyContent="center"
|
||||||
<Typography component="h1" variant="h1" fontSize={16}>
|
>
|
||||||
|
<Stack
|
||||||
|
gap={theme.spacing(2)}
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={NotFoundSvg}
|
||||||
|
alt="404"
|
||||||
|
style={{ maxHeight: "25rem" }}
|
||||||
|
/>
|
||||||
|
<Typography
|
||||||
|
component="h1"
|
||||||
|
variant="h1"
|
||||||
|
fontSize={16}
|
||||||
|
>
|
||||||
{title}
|
{title}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">{desc}</Typography>
|
<Typography variant="body1">{desc}</Typography>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { Box, Button, Modal, Stack, Tooltip, Typography } from "@mui/material";
|
import { Box, Stack, Tooltip, Typography } from "@mui/material";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { useNavigate, useParams } from "react-router";
|
import { useNavigate, useParams } from "react-router";
|
||||||
import {
|
import {
|
||||||
@@ -25,6 +25,7 @@ import PlayCircleOutlineRoundedIcon from "@mui/icons-material/PlayCircleOutlineR
|
|||||||
import SkeletonLayout from "./skeleton";
|
import SkeletonLayout from "./skeleton";
|
||||||
import useUtils from "../../Monitors/utils";
|
import useUtils from "../../Monitors/utils";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
import Dialog from "../../../Components/Dialog";
|
||||||
|
|
||||||
const PageSpeedConfigure = () => {
|
const PageSpeedConfigure = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -37,6 +38,7 @@ const PageSpeedConfigure = () => {
|
|||||||
const [monitor, setMonitor] = useState({});
|
const [monitor, setMonitor] = useState({});
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
const { statusColor, pagespeedStatusMsg, determineState } = useUtils();
|
const { statusColor, pagespeedStatusMsg, determineState } = useUtils();
|
||||||
|
const [buttonLoading, setButtonLoading] = useState(false);
|
||||||
const idMap = {
|
const idMap = {
|
||||||
"monitor-url": "url",
|
"monitor-url": "url",
|
||||||
"monitor-name": "name",
|
"monitor-name": "name",
|
||||||
@@ -58,9 +60,7 @@ const PageSpeedConfigure = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(
|
const action = await dispatch(getPagespeedMonitorById({ authToken, monitorId }));
|
||||||
getPagespeedMonitorById({ authToken, monitorId })
|
|
||||||
);
|
|
||||||
|
|
||||||
if (getPagespeedMonitorById.fulfilled.match(action)) {
|
if (getPagespeedMonitorById.fulfilled.match(action)) {
|
||||||
const monitor = action.payload.data;
|
const monitor = action.payload.data;
|
||||||
@@ -122,8 +122,7 @@ const PageSpeedConfigure = () => {
|
|||||||
setErrors((prev) => {
|
setErrors((prev) => {
|
||||||
const updatedErrors = { ...prev };
|
const updatedErrors = { ...prev };
|
||||||
|
|
||||||
if (validation.error)
|
if (validation.error) updatedErrors[name] = validation.error.details[0].message;
|
||||||
updatedErrors[name] = validation.error.details[0].message;
|
|
||||||
else delete updatedErrors[name];
|
else delete updatedErrors[name];
|
||||||
return updatedErrors;
|
return updatedErrors;
|
||||||
});
|
});
|
||||||
@@ -147,9 +146,7 @@ const PageSpeedConfigure = () => {
|
|||||||
|
|
||||||
const handleSave = async (event) => {
|
const handleSave = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const action = await dispatch(
|
const action = await dispatch(updatePageSpeed({ authToken, monitor: monitor }));
|
||||||
updatePageSpeed({ authToken, monitor: monitor })
|
|
||||||
);
|
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
createToast({ body: "Monitor updated successfully!" });
|
createToast({ body: "Monitor updated successfully!" });
|
||||||
dispatch(getPageSpeedByTeamId(authToken));
|
dispatch(getPageSpeedByTeamId(authToken));
|
||||||
@@ -161,16 +158,21 @@ const PageSpeedConfigure = () => {
|
|||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const handleRemove = async (event) => {
|
const handleRemove = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
setButtonLoading(true);
|
||||||
const action = await dispatch(deletePageSpeed({ authToken, monitor }));
|
const action = await dispatch(deletePageSpeed({ authToken, monitor }));
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
navigate("/pagespeed");
|
navigate("/pagespeed");
|
||||||
} else {
|
} else {
|
||||||
createToast({ body: "Failed to delete monitor." });
|
createToast({ body: "Failed to delete monitor." });
|
||||||
}
|
}
|
||||||
|
setButtonLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="configure-pagespeed" gap={theme.spacing(10)}>
|
<Stack
|
||||||
|
className="configure-pagespeed"
|
||||||
|
gap={theme.spacing(10)}
|
||||||
|
>
|
||||||
{Object.keys(monitor).length === 0 ? (
|
{Object.keys(monitor).length === 0 ? (
|
||||||
<SkeletonLayout />
|
<SkeletonLayout />
|
||||||
) : (
|
) : (
|
||||||
@@ -190,9 +192,15 @@ const PageSpeedConfigure = () => {
|
|||||||
flex={1}
|
flex={1}
|
||||||
gap={theme.spacing(10)}
|
gap={theme.spacing(10)}
|
||||||
>
|
>
|
||||||
<Stack direction="row" gap={theme.spacing(2)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(2)}
|
||||||
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1" variant="h1">
|
<Typography
|
||||||
|
component="h1"
|
||||||
|
variant="h1"
|
||||||
|
>
|
||||||
{monitor.name}
|
{monitor.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -221,7 +229,10 @@ const PageSpeedConfigure = () => {
|
|||||||
<PulseDot color={statusColor[determineState(monitor)]} />
|
<PulseDot color={statusColor[determineState(monitor)]} />
|
||||||
</Box>
|
</Box>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Typography component="h2" variant="h2">
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
>
|
||||||
{monitor.url?.replace(/^https?:\/\//, "") || "..."}
|
{monitor.url?.replace(/^https?:\/\//, "") || "..."}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -248,7 +259,10 @@ const PageSpeedConfigure = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
<Box alignSelf="flex-end" ml="auto">
|
<Box
|
||||||
|
alignSelf="flex-end"
|
||||||
|
ml="auto"
|
||||||
|
>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
onClick={handlePause}
|
onClick={handlePause}
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
@@ -295,8 +309,8 @@ const PageSpeedConfigure = () => {
|
|||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2">General settings</Typography>
|
<Typography component="h2">General settings</Typography>
|
||||||
<Typography component="p">
|
<Typography component="p">
|
||||||
Here you can select the URL of the host, together with the
|
Here you can select the URL of the host, together with the type of
|
||||||
type of monitor.
|
monitor.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -337,9 +351,7 @@ const PageSpeedConfigure = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(6)}>
|
<Stack gap={theme.spacing(6)}>
|
||||||
<Typography component="p">
|
<Typography component="p">When there is a new incident,</Typography>
|
||||||
When there is a new incident,
|
|
||||||
</Typography>
|
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="notify-sms"
|
id="notify-sms"
|
||||||
label="Notify via SMS (coming soon)"
|
label="Notify via SMS (coming soon)"
|
||||||
@@ -401,7 +413,11 @@ const PageSpeedConfigure = () => {
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
<Stack direction="row" justifyContent="flex-end" mt="auto">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
mt="auto"
|
||||||
|
>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
type="submit"
|
type="submit"
|
||||||
@@ -416,65 +432,16 @@ const PageSpeedConfigure = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Modal
|
<Dialog
|
||||||
aria-labelledby="modal-delete-pagespeed-monitor"
|
|
||||||
aria-describedby="delete-pagespeed-monitor-confirmation"
|
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
onClose={() => setIsOpen(false)}
|
theme={theme}
|
||||||
disablePortal
|
title={"Do you really want to delete this monitor?"}
|
||||||
>
|
description={"Once deleted, this monitor cannot be retrieved."}
|
||||||
<Stack
|
onCancel={() => setIsOpen(false)}
|
||||||
gap={theme.spacing(2)}
|
confirmationButtonLabel={"Delete"}
|
||||||
sx={{
|
onConfirm={handleRemove}
|
||||||
position: "absolute",
|
isLoading={buttonLoading}
|
||||||
top: "50%",
|
/>
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
width: 400,
|
|
||||||
bgcolor: theme.palette.background.main,
|
|
||||||
border: 1,
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
boxShadow: 24,
|
|
||||||
p: theme.spacing(15),
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
id="modal-delete-pagespeed-monitor"
|
|
||||||
component="h2"
|
|
||||||
variant="h2"
|
|
||||||
fontWeight={500}
|
|
||||||
>
|
|
||||||
Do you really want to delete this monitor?
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
id="delete-pagespeed-monitor-confirmation"
|
|
||||||
variant="body1"
|
|
||||||
>
|
|
||||||
Once deleted, this monitor cannot be retrieved.
|
|
||||||
</Typography>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
gap={theme.spacing(4)}
|
|
||||||
mt={theme.spacing(12)}
|
|
||||||
justifyContent="flex-end"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
variant="text"
|
|
||||||
color="info"
|
|
||||||
onClick={() => setIsOpen(false)}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<Button variant="contained" color="error" onClick={handleRemove}>
|
|
||||||
Delete
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
</Modal>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,9 +11,21 @@ const SkeletonLayout = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Skeleton variant="rounded" width="15%" height={34} />
|
<Skeleton
|
||||||
<Stack gap={theme.spacing(20)} mt={theme.spacing(6)} maxWidth="1000px">
|
variant="rounded"
|
||||||
<Stack direction="row" gap={theme.spacing(4)} mt={theme.spacing(4)}>
|
width="15%"
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
|
<Stack
|
||||||
|
gap={theme.spacing(20)}
|
||||||
|
mt={theme.spacing(6)}
|
||||||
|
maxWidth="1000px"
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(4)}
|
||||||
|
mt={theme.spacing(4)}
|
||||||
|
>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="circular"
|
variant="circular"
|
||||||
style={{ minWidth: 24, minHeight: 24 }}
|
style={{ minWidth: 24, minHeight: 24 }}
|
||||||
@@ -25,7 +37,11 @@ const SkeletonLayout = () => {
|
|||||||
height={24}
|
height={24}
|
||||||
sx={{ mb: theme.spacing(4) }}
|
sx={{ mb: theme.spacing(4) }}
|
||||||
/>
|
/>
|
||||||
<Skeleton variant="rounded" width="50%" height={18} />
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={18}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
@@ -35,13 +51,32 @@ const SkeletonLayout = () => {
|
|||||||
alignSelf: "flex-end",
|
alignSelf: "flex-end",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Skeleton variant="rounded" width={100} height={34} />
|
<Skeleton
|
||||||
<Skeleton variant="rounded" width={100} height={34} />
|
variant="rounded"
|
||||||
|
width={100}
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width={100}
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Skeleton variant="rounded" width="100%" height={500} />
|
<Skeleton
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
variant="rounded"
|
||||||
<Skeleton variant="rounded" width="15%" height={34} />
|
width="100%"
|
||||||
|
height={500}
|
||||||
|
/>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="15%"
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material";
|
import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material";
|
||||||
|
import LoadingButton from '@mui/lab/LoadingButton';
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { monitorValidation } from "../../../Validation/validation";
|
import { monitorValidation } from "../../../Validation/validation";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { createPageSpeed } from "../../../Features/PageSpeedMonitor/pageSpeedMonitorSlice";
|
import { createPageSpeed, checkEndpointResolution } from "../../../Features/PageSpeedMonitor/pageSpeedMonitorSlice";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import { logger } from "../../../Utils/Logger";
|
import { logger } from "../../../Utils/Logger";
|
||||||
import { ConfigBox } from "../../Monitors/styled";
|
import { ConfigBox } from "../../Monitors/styled";
|
||||||
@@ -18,6 +19,7 @@ import "./index.css";
|
|||||||
const CreatePageSpeed = () => {
|
const CreatePageSpeed = () => {
|
||||||
const MS_PER_MINUTE = 60000;
|
const MS_PER_MINUTE = 60000;
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user, authToken } = useSelector((state) => state.auth);
|
||||||
|
const { isLoading } = useSelector((state) => state.pageSpeedMonitors);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -111,6 +113,15 @@ const CreatePageSpeed = () => {
|
|||||||
setErrors(newErrors);
|
setErrors(newErrors);
|
||||||
createToast({ body: "Error validation data." });
|
createToast({ body: "Error validation data." });
|
||||||
} else {
|
} else {
|
||||||
|
const checkEndpointAction = await dispatch(
|
||||||
|
checkEndpointResolution({ authToken, monitorURL: form.url })
|
||||||
|
)
|
||||||
|
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||||
|
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
|
||||||
|
setErrors({ url: "The entered URL is not reachable." });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
form = {
|
form = {
|
||||||
...form,
|
...form,
|
||||||
description: form.name,
|
description: form.name,
|
||||||
@@ -327,14 +338,15 @@ const CreatePageSpeed = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
<Stack direction="row" justifyContent="flex-end">
|
||||||
<Button
|
<LoadingButton
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={handleCreateMonitor}
|
onClick={handleCreateMonitor}
|
||||||
disabled={Object.keys(errors).length !== 0 && true}
|
disabled={Object.keys(errors).length !== 0 && true}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
Create monitor
|
Create monitor
|
||||||
</Button>
|
</LoadingButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -105,9 +105,7 @@ const CustomToolTip = ({ active, payload, label, config }) => {
|
|||||||
>
|
>
|
||||||
{config[key].text}
|
{config[key].text}
|
||||||
</Typography>{" "}
|
</Typography>{" "}
|
||||||
<Typography component="span">
|
<Typography component="span">{payload[0].payload[key]}</Typography>
|
||||||
{payload[0].payload[key]}
|
|
||||||
</Typography>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -216,10 +214,7 @@ CustomTick.propTypes = {
|
|||||||
const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
|
const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [isHovered, setIsHovered] = useState(false);
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
const memoizedData = useMemo(
|
const memoizedData = useMemo(() => processDataWithGaps(data, interval), [data[0]]);
|
||||||
() => processDataWithGaps(data, interval),
|
|
||||||
[data[0]]
|
|
||||||
);
|
|
||||||
|
|
||||||
const filteredConfig = Object.keys(config).reduce((result, key) => {
|
const filteredConfig = Object.keys(config).reduce((result, key) => {
|
||||||
if (metrics[key]) {
|
if (metrics[key]) {
|
||||||
@@ -229,7 +224,11 @@ const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
|
|||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" minWidth={25} height={215}>
|
<ResponsiveContainer
|
||||||
|
width="100%"
|
||||||
|
minWidth={25}
|
||||||
|
height={215}
|
||||||
|
>
|
||||||
<AreaChart
|
<AreaChart
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
@@ -265,9 +264,24 @@ const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
|
|||||||
const endColor = theme.palette[color].light;
|
const endColor = theme.palette[color].light;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<linearGradient id={id} x1="0" y1="0" x2="0" y2="1" key={id}>
|
<linearGradient
|
||||||
<stop offset="0%" stopColor={startColor} stopOpacity={0.8} />
|
id={id}
|
||||||
<stop offset="100%" stopColor={endColor} stopOpacity={0} />
|
x1="0"
|
||||||
|
y1="0"
|
||||||
|
x2="0"
|
||||||
|
y2="1"
|
||||||
|
key={id}
|
||||||
|
>
|
||||||
|
<stop
|
||||||
|
offset="0%"
|
||||||
|
stopColor={startColor}
|
||||||
|
stopOpacity={0.8}
|
||||||
|
/>
|
||||||
|
<stop
|
||||||
|
offset="100%"
|
||||||
|
stopColor={endColor}
|
||||||
|
stopOpacity={0}
|
||||||
|
/>
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -299,12 +313,9 @@ PagespeedDetailsAreaChart.propTypes = {
|
|||||||
data: PropTypes.arrayOf(
|
data: PropTypes.arrayOf(
|
||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
createdAt: PropTypes.string.isRequired,
|
createdAt: PropTypes.string.isRequired,
|
||||||
accessibility: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
accessibility: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
||||||
.isRequired,
|
bestPractices: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
||||||
bestPractices: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
performance: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
||||||
.isRequired,
|
|
||||||
performance: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
||||||
.isRequired,
|
|
||||||
seo: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
seo: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
||||||
})
|
})
|
||||||
).isRequired,
|
).isRequired,
|
||||||
|
|||||||
@@ -20,7 +20,12 @@ const PieCenterLabel = ({ value, color, setExpand }) => {
|
|||||||
transform={`translate(${width / 2}, ${height / 2})`}
|
transform={`translate(${width / 2}, ${height / 2})`}
|
||||||
onMouseEnter={() => setExpand(true)}
|
onMouseEnter={() => setExpand(true)}
|
||||||
>
|
>
|
||||||
<circle cx={0} cy={0} r={width / 4} fill="transparent" />
|
<circle
|
||||||
|
cx={0}
|
||||||
|
cy={0}
|
||||||
|
r={width / 4}
|
||||||
|
fill="transparent"
|
||||||
|
/>
|
||||||
<text
|
<text
|
||||||
className="pie-label"
|
className="pie-label"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -1,20 +1,10 @@
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import {
|
import { Box, Button, Divider, Stack, Tooltip, Typography } from "@mui/material";
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
Divider,
|
|
||||||
Stack,
|
|
||||||
Tooltip,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import {
|
import { formatDurationRounded, formatDurationSplit } from "../../../Utils/timeUtils";
|
||||||
formatDurationRounded,
|
|
||||||
formatDurationSplit,
|
|
||||||
} from "../../../Utils/timeUtils";
|
|
||||||
import { ChartBox, IconBox, StatBox } from "./styled";
|
import { ChartBox, IconBox, StatBox } from "./styled";
|
||||||
import { logger } from "../../../Utils/Logger";
|
import { logger } from "../../../Utils/Logger";
|
||||||
import { networkService } from "../../../main";
|
import { networkService } from "../../../main";
|
||||||
@@ -88,7 +78,10 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="page-speed-details" gap={theme.spacing(10)}>
|
<Stack
|
||||||
|
className="page-speed-details"
|
||||||
|
gap={theme.spacing(10)}
|
||||||
|
>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<SkeletonLayout />
|
<SkeletonLayout />
|
||||||
) : (
|
) : (
|
||||||
@@ -99,9 +92,15 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
{ name: "details", path: `/pagespeed/${monitorId}` },
|
{ name: "details", path: `/pagespeed/${monitorId}` },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<Stack direction="row" gap={theme.spacing(2)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(2)}
|
||||||
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1" variant="h1">
|
<Typography
|
||||||
|
component="h1"
|
||||||
|
variant="h1"
|
||||||
|
>
|
||||||
{monitor.name}
|
{monitor.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -130,7 +129,10 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
<PulseDot color={statusColor[determineState(monitor)]} />
|
<PulseDot color={statusColor[determineState(monitor)]} />
|
||||||
</Box>
|
</Box>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Typography component="h2" variant="h2">
|
<Typography
|
||||||
|
component="h2"
|
||||||
|
variant="h2"
|
||||||
|
>
|
||||||
{monitor?.url}
|
{monitor?.url}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -179,7 +181,10 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" gap={theme.spacing(8)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.spacing(8)}
|
||||||
|
>
|
||||||
<StatBox>
|
<StatBox>
|
||||||
<Typography component="h2">checks since</Typography>
|
<Typography component="h2">checks since</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
@@ -196,11 +201,18 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
</StatBox>
|
</StatBox>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography variant="body2" my={theme.spacing(8)}>
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
my={theme.spacing(8)}
|
||||||
|
>
|
||||||
Showing statistics for past 24 hours.
|
Showing statistics for past 24 hours.
|
||||||
</Typography>
|
</Typography>
|
||||||
<ChartBox sx={{ gridTemplateColumns: "75% 25%" }}>
|
<ChartBox sx={{ gridTemplateColumns: "75% 25%" }}>
|
||||||
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
gap={theme.spacing(6)}
|
||||||
|
>
|
||||||
<IconBox>
|
<IconBox>
|
||||||
<ScoreIcon />
|
<ScoreIcon />
|
||||||
</IconBox>
|
</IconBox>
|
||||||
@@ -232,7 +244,10 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography fontSize={11} fontWeight={500}>
|
<Typography
|
||||||
|
fontSize={11}
|
||||||
|
fontWeight={500}
|
||||||
|
>
|
||||||
Shown
|
Shown
|
||||||
</Typography>
|
</Typography>
|
||||||
<Divider sx={{ mt: theme.spacing(2) }} />
|
<Divider sx={{ mt: theme.spacing(2) }} />
|
||||||
@@ -273,7 +288,11 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
flex={1}
|
flex={1}
|
||||||
sx={{ gridTemplateColumns: "50% 50%", gridTemplateRows: "15% 85%" }}
|
sx={{ gridTemplateColumns: "50% 50%", gridTemplateRows: "15% 85%" }}
|
||||||
>
|
>
|
||||||
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
gap={theme.spacing(6)}
|
||||||
|
>
|
||||||
<IconBox>
|
<IconBox>
|
||||||
<PerformanceIcon />
|
<PerformanceIcon />
|
||||||
</IconBox>
|
</IconBox>
|
||||||
@@ -288,7 +307,10 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
pb={theme.spacing(12)}
|
pb={theme.spacing(12)}
|
||||||
>
|
>
|
||||||
<PieChart audits={audits} />
|
<PieChart audits={audits} />
|
||||||
<Typography variant="body1" mt="auto">
|
<Typography
|
||||||
|
variant="body1"
|
||||||
|
mt="auto"
|
||||||
|
>
|
||||||
Values are estimated and may vary.{" "}
|
Values are estimated and may vary.{" "}
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
@@ -309,8 +331,16 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box px={theme.spacing(20)} py={theme.spacing(8)} height="100%">
|
<Box
|
||||||
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}>
|
px={theme.spacing(20)}
|
||||||
|
py={theme.spacing(8)}
|
||||||
|
height="100%"
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
gap={theme.spacing(6)}
|
||||||
|
>
|
||||||
<IconBox>
|
<IconBox>
|
||||||
<SpedometerIcon />
|
<SpedometerIcon />
|
||||||
</IconBox>
|
</IconBox>
|
||||||
@@ -336,9 +366,7 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
: theme.palette.unresolved.main;
|
: theme.palette.unresolved.main;
|
||||||
|
|
||||||
// Find the position where the number ends and the unit begins
|
// Find the position where the number ends and the unit begins
|
||||||
const match = audit.displayValue.match(
|
const match = audit.displayValue.match(/(\d+\.?\d*)\s*([a-zA-Z]+)/);
|
||||||
/(\d+\.?\d*)\s*([a-zA-Z]+)/
|
|
||||||
);
|
|
||||||
let value;
|
let value;
|
||||||
let unit;
|
let unit;
|
||||||
if (match) {
|
if (match) {
|
||||||
@@ -376,12 +404,20 @@ const PageSpeedDetails = ({ isAdmin }) => {
|
|||||||
color={theme.palette.text.primary}
|
color={theme.palette.text.primary}
|
||||||
>
|
>
|
||||||
{value}
|
{value}
|
||||||
<Typography component="span" variant="body2" ml={2}>
|
<Typography
|
||||||
|
component="span"
|
||||||
|
variant="body2"
|
||||||
|
ml={2}
|
||||||
|
>
|
||||||
{unit}
|
{unit}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box width={4} backgroundColor={bg} borderRadius={4} />
|
<Box
|
||||||
|
width={4}
|
||||||
|
backgroundColor={bg}
|
||||||
|
borderRadius={4}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -8,12 +8,31 @@ import { Box, Skeleton, Stack } from "@mui/material";
|
|||||||
const SkeletonLayout = () => {
|
const SkeletonLayout = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Skeleton variant="rounded" width="15%" height={34} />
|
<Skeleton
|
||||||
<Stack direction="row" gap={4}>
|
variant="rounded"
|
||||||
<Skeleton variant="circular" style={{ minWidth: 24, minHeight: 24 }} />
|
width="15%"
|
||||||
|
height={34}
|
||||||
|
/>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={4}
|
||||||
|
>
|
||||||
|
<Skeleton
|
||||||
|
variant="circular"
|
||||||
|
style={{ minWidth: 24, minHeight: 24 }}
|
||||||
|
/>
|
||||||
<Box width="85%">
|
<Box width="85%">
|
||||||
<Skeleton variant="rounded" width="50%" height={24} />
|
<Skeleton
|
||||||
<Skeleton variant="rounded" width="50%" height={18} sx={{ mt: 4 }} />
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={24}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={18}
|
||||||
|
sx={{ mt: 4 }}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="rounded"
|
variant="rounded"
|
||||||
@@ -28,14 +47,45 @@ const SkeletonLayout = () => {
|
|||||||
gap={20}
|
gap={20}
|
||||||
flexWrap="wrap"
|
flexWrap="wrap"
|
||||||
>
|
>
|
||||||
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} />
|
<Skeleton
|
||||||
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} />
|
variant="rounded"
|
||||||
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} />
|
width="30%"
|
||||||
|
height={90}
|
||||||
|
sx={{ flex: 1 }}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="30%"
|
||||||
|
height={90}
|
||||||
|
sx={{ flex: 1 }}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="30%"
|
||||||
|
height={90}
|
||||||
|
sx={{ flex: 1 }}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Skeleton variant="rounded" width="25%" height={24} />
|
<Skeleton
|
||||||
<Skeleton variant="rounded" width="100%" height={300} />
|
variant="rounded"
|
||||||
<Skeleton variant="rounded" width="25%" height={24} />
|
width="25%"
|
||||||
<Skeleton variant="rounded" width="100%" height={300} />
|
height={24}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={300}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="25%"
|
||||||
|
height={24}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={300}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,13 +5,7 @@ import { Box, Grid, Stack, Typography } from "@mui/material";
|
|||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { IconBox } from "./Details/styled";
|
import { IconBox } from "./Details/styled";
|
||||||
import {
|
import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip } from "recharts";
|
||||||
Area,
|
|
||||||
AreaChart,
|
|
||||||
CartesianGrid,
|
|
||||||
ResponsiveContainer,
|
|
||||||
Tooltip,
|
|
||||||
} from "recharts";
|
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { formatDateWithTz, formatDurationSplit } from "../../Utils/timeUtils";
|
import { formatDateWithTz, formatDurationSplit } from "../../Utils/timeUtils";
|
||||||
import useUtils from "../Monitors/utils";
|
import useUtils from "../Monitors/utils";
|
||||||
@@ -99,11 +93,7 @@ const processData = (data) => {
|
|||||||
|
|
||||||
const calculateScore = (entry) => {
|
const calculateScore = (entry) => {
|
||||||
return (
|
return (
|
||||||
(entry.accessibility +
|
(entry.accessibility + entry.bestPractices + entry.performance + entry.seo) / 4
|
||||||
entry.bestPractices +
|
|
||||||
entry.performance +
|
|
||||||
entry.seo) /
|
|
||||||
4
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -130,7 +120,11 @@ const PagespeedAreaChart = ({ data, status }) => {
|
|||||||
const formattedData = processData(data);
|
const formattedData = processData(data);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" minWidth={25} height={85}>
|
<ResponsiveContainer
|
||||||
|
width="100%"
|
||||||
|
minWidth={25}
|
||||||
|
height={85}
|
||||||
|
>
|
||||||
<AreaChart
|
<AreaChart
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
@@ -212,7 +206,11 @@ const Card = ({ monitor }) => {
|
|||||||
const monitorState = determineState(monitor);
|
const monitorState = determineState(monitor);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid item lg={6} flexGrow={1}>
|
<Grid
|
||||||
|
item
|
||||||
|
lg={6}
|
||||||
|
flexGrow={1}
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
position="relative"
|
position="relative"
|
||||||
p={theme.spacing(8)}
|
p={theme.spacing(8)}
|
||||||
@@ -269,7 +267,10 @@ const Card = ({ monitor }) => {
|
|||||||
mb={theme.spacing(-8)}
|
mb={theme.spacing(-8)}
|
||||||
sx={{ gridColumnStart: 1, gridColumnEnd: 4 }}
|
sx={{ gridColumnStart: 1, gridColumnEnd: 4 }}
|
||||||
>
|
>
|
||||||
<PagespeedAreaChart data={monitor.checks} status={monitorState} />
|
<PagespeedAreaChart
|
||||||
|
data={monitor.checks}
|
||||||
|
status={monitorState}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
position="absolute"
|
position="absolute"
|
||||||
@@ -287,7 +288,10 @@ const Card = ({ monitor }) => {
|
|||||||
borderBottomLeftRadius: 4,
|
borderBottomLeftRadius: 4,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography fontSize={11} color={theme.palette.text.accent}>
|
<Typography
|
||||||
|
fontSize={11}
|
||||||
|
color={theme.palette.text.accent}
|
||||||
|
>
|
||||||
Checking every{" "}
|
Checking every{" "}
|
||||||
{(() => {
|
{(() => {
|
||||||
const { time, format } = formatDurationSplit(monitor?.interval);
|
const { time, format } = formatDurationSplit(monitor?.interval);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const PageSpeed = ({ isAdmin }) => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user, authToken } = useSelector((state) => state.auth);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [monitors, setMonitors] = useState([]);
|
const [monitors, setMonitors] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(getPageSpeedByTeamId(authToken));
|
dispatch(getPageSpeedByTeamId(authToken));
|
||||||
@@ -99,9 +99,15 @@ const PageSpeed = ({ isAdmin }) => {
|
|||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
<Grid container spacing={theme.spacing(12)}>
|
<Grid
|
||||||
|
container
|
||||||
|
spacing={theme.spacing(12)}
|
||||||
|
>
|
||||||
{monitors?.map((monitor) => (
|
{monitors?.map((monitor) => (
|
||||||
<Card monitor={monitor} key={monitor._id} />
|
<Card
|
||||||
|
monitor={monitor}
|
||||||
|
key={monitor._id}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ const SkeletonLayout = () => {
|
|||||||
mb={theme.spacing(12)}
|
mb={theme.spacing(12)}
|
||||||
>
|
>
|
||||||
<Box width="80%">
|
<Box width="80%">
|
||||||
<Skeleton variant="rounded" width="25%" height={24} />
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="25%"
|
||||||
|
height={24}
|
||||||
|
/>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="rounded"
|
variant="rounded"
|
||||||
width="50%"
|
width="50%"
|
||||||
@@ -32,7 +36,11 @@ const SkeletonLayout = () => {
|
|||||||
sx={{ alignSelf: "flex-end" }}
|
sx={{ alignSelf: "flex-end" }}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" flexWrap="wrap" gap={theme.spacing(12)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
flexWrap="wrap"
|
||||||
|
gap={theme.spacing(12)}
|
||||||
|
>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="rounded"
|
variant="rounded"
|
||||||
width="100%"
|
width="100%"
|
||||||
|
|||||||
@@ -15,13 +15,14 @@ import {
|
|||||||
import { update } from "../../Features/Auth/authSlice";
|
import { update } from "../../Features/Auth/authSlice";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
import { setTimezone } from "../../Features/UI/uiSlice";
|
import { setTimezone, setMode } from "../../Features/UI/uiSlice";
|
||||||
import timezones from "../../Utils/timezones.json";
|
import timezones from "../../Utils/timezones.json";
|
||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { ConfigBox } from "./styled";
|
import { ConfigBox } from "./styled";
|
||||||
import { networkService } from "../../main";
|
import { networkService } from "../../main";
|
||||||
import { settingsValidation } from "../../Validation/validation";
|
import { settingsValidation } from "../../Validation/validation";
|
||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
|
import Dialog from "../../Components/Dialog";
|
||||||
|
|
||||||
const SECONDS_PER_DAY = 86400;
|
const SECONDS_PER_DAY = 86400;
|
||||||
|
|
||||||
@@ -32,14 +33,37 @@ const Settings = ({ isAdmin }) => {
|
|||||||
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
||||||
const { isLoading: authIsLoading } = useSelector((state) => state.auth);
|
const { isLoading: authIsLoading } = useSelector((state) => state.auth);
|
||||||
const { timezone } = useSelector((state) => state.ui);
|
const { timezone } = useSelector((state) => state.ui);
|
||||||
|
const { mode } = useSelector((state) => state.ui);
|
||||||
const [checksIsLoading, setChecksIsLoading] = useState(false);
|
const [checksIsLoading, setChecksIsLoading] = useState(false);
|
||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
ttl: checkTTL ? (checkTTL / SECONDS_PER_DAY).toString() : 0,
|
ttl: checkTTL ? (checkTTL / SECONDS_PER_DAY).toString() : 0,
|
||||||
});
|
});
|
||||||
|
const [version, setVersion] = useState("unknown");
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
|
const deleteStatsMonitorsInitState = { deleteMonitors: false, deleteStats: false };
|
||||||
|
const [isOpen, setIsOpen] = useState(deleteStatsMonitorsInitState);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
//Fetching latest release version from github
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchLatestVersion = async () => {
|
||||||
|
let version = "unknown";
|
||||||
|
try {
|
||||||
|
const response = await networkService.fetchGithubLatestRelease();
|
||||||
|
if (!response.status === 200) {
|
||||||
|
throw new Error("Failed to fetch latest version");
|
||||||
|
}
|
||||||
|
version = response.data.tag_name;
|
||||||
|
} catch (error) {
|
||||||
|
createToast({ body: error.message || "Error fetching latest version" }); // Set error message
|
||||||
|
} finally {
|
||||||
|
setVersion(version);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchLatestVersion();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleChange = (event) => {
|
const handleChange = (event) => {
|
||||||
const { value, id } = event.target;
|
const { value, id } = event.target;
|
||||||
const { error } = settingsValidation.validate(
|
const { error } = settingsValidation.validate(
|
||||||
@@ -76,9 +100,7 @@ const Settings = ({ isAdmin }) => {
|
|||||||
ttl: form.ttl,
|
ttl: form.ttl,
|
||||||
});
|
});
|
||||||
const updatedUser = { ...user, checkTTL: form.ttl };
|
const updatedUser = { ...user, checkTTL: form.ttl };
|
||||||
const action = await dispatch(
|
const action = await dispatch(update({ authToken, localData: updatedUser }));
|
||||||
update({ authToken, localData: updatedUser })
|
|
||||||
);
|
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
createToast({
|
createToast({
|
||||||
body: "Settings saved successfully",
|
body: "Settings saved successfully",
|
||||||
@@ -118,6 +140,8 @@ const Settings = ({ isAdmin }) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
createToast({ body: "Failed to clear stats" });
|
createToast({ body: "Failed to clear stats" });
|
||||||
|
} finally {
|
||||||
|
setIsOpen(deleteStatsMonitorsInitState);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -146,6 +170,8 @@ const Settings = ({ isAdmin }) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
createToast({ Body: "Failed to delete all monitors" });
|
createToast({ Body: "Failed to delete all monitors" });
|
||||||
|
} finally {
|
||||||
|
setIsOpen(deleteStatsMonitorsInitState);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -166,8 +192,8 @@ const Settings = ({ isAdmin }) => {
|
|||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1">General settings</Typography>
|
<Typography component="h1">General settings</Typography>
|
||||||
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(2) }}>
|
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(2) }}>
|
||||||
<Typography component="span">Display timezone</Typography>- The
|
<Typography component="span">Display timezone</Typography>- The timezone of
|
||||||
timezone of the dashboard you publicly display.
|
the dashboard you publicly display.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(20)}>
|
<Stack gap={theme.spacing(20)}>
|
||||||
@@ -182,13 +208,35 @@ const Settings = ({ isAdmin }) => {
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
|
<ConfigBox>
|
||||||
|
<Box>
|
||||||
|
<Typography component="h1">Appearance</Typography>
|
||||||
|
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(2) }}>
|
||||||
|
Switch between light and dark mode.
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Stack gap={theme.spacing(20)}>
|
||||||
|
<Select
|
||||||
|
id="theme-mode"
|
||||||
|
label="Theme Mode"
|
||||||
|
value={mode}
|
||||||
|
onChange={(e) => {
|
||||||
|
dispatch(setMode(e.target.value));
|
||||||
|
}}
|
||||||
|
items={[
|
||||||
|
{ _id: "light", name: "Light" },
|
||||||
|
{ _id: "dark", name: "Dark" },
|
||||||
|
]}
|
||||||
|
></Select>
|
||||||
|
</Stack>
|
||||||
|
</ConfigBox>
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<ConfigBox>
|
<ConfigBox>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1">History and monitoring</Typography>
|
<Typography component="h1">History and monitoring</Typography>
|
||||||
<Typography sx={{ mt: theme.spacing(2) }}>
|
<Typography sx={{ mt: theme.spacing(2) }}>
|
||||||
Define here for how long you want to keep the data. You can also
|
Define here for how long you want to keep the data. You can also remove
|
||||||
remove all past data.
|
all past data.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(20)}>
|
<Stack gap={theme.spacing(20)}>
|
||||||
@@ -202,17 +250,28 @@ const Settings = ({ isAdmin }) => {
|
|||||||
/>
|
/>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography>Clear all stats. This is irreversible.</Typography>
|
<Typography>Clear all stats. This is irreversible.</Typography>
|
||||||
<LoadingButton
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="error"
|
color="error"
|
||||||
loading={isLoading || authIsLoading || checksIsLoading}
|
onClick={() =>
|
||||||
onClick={handleClearStats}
|
setIsOpen({ ...deleteStatsMonitorsInitState, deleteStats: true })
|
||||||
|
}
|
||||||
sx={{ mt: theme.spacing(4) }}
|
sx={{ mt: theme.spacing(4) }}
|
||||||
>
|
>
|
||||||
Clear all stats
|
Clear all stats
|
||||||
</LoadingButton>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
<Dialog
|
||||||
|
open={isOpen.deleteStats}
|
||||||
|
theme={theme}
|
||||||
|
title="Do you want to clear all stats?"
|
||||||
|
description="Once deleted, this monitor cannot be retrieved."
|
||||||
|
onCancel={() => setIsOpen(deleteStatsMonitorsInitState)}
|
||||||
|
confirmationButtonLabel="Yes, clear all stats"
|
||||||
|
onConfirm={handleClearStats}
|
||||||
|
isLoading={isLoading || authIsLoading || checksIsLoading}
|
||||||
|
/>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
)}
|
)}
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
@@ -242,13 +301,24 @@ const Settings = ({ isAdmin }) => {
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
color="error"
|
color="error"
|
||||||
loading={isLoading || authIsLoading || checksIsLoading}
|
loading={isLoading || authIsLoading || checksIsLoading}
|
||||||
onClick={handleDeleteAllMonitors}
|
onClick={() =>
|
||||||
|
setIsOpen({ ...deleteStatsMonitorsInitState, deleteMonitors: true })
|
||||||
|
}
|
||||||
sx={{ mt: theme.spacing(4) }}
|
sx={{ mt: theme.spacing(4) }}
|
||||||
>
|
>
|
||||||
Remove all monitors
|
Remove all monitors
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
<Dialog
|
||||||
|
open={isOpen.deleteMonitors}
|
||||||
|
theme={theme}
|
||||||
|
title="Do you want to remove all monitors?"
|
||||||
|
onCancel={() => setIsOpen(deleteStatsMonitorsInitState)}
|
||||||
|
confirmationButtonLabel="Yes, clear all monitors"
|
||||||
|
onConfirm={handleDeleteAllMonitors}
|
||||||
|
isLoading={isLoading || authIsLoading || checksIsLoading}
|
||||||
|
/>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
)}
|
)}
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
@@ -278,20 +348,21 @@ const Settings = ({ isAdmin }) => {
|
|||||||
<Typography component="h1">About</Typography>
|
<Typography component="h1">About</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2">BlueWave Uptime v1.0.0</Typography>
|
<Typography component="h2">BlueWave Uptime {version}</Typography>
|
||||||
<Typography
|
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(6), opacity: 0.6 }}>
|
||||||
sx={{ mt: theme.spacing(2), mb: theme.spacing(6), opacity: 0.6 }}
|
|
||||||
>
|
|
||||||
Developed by Bluewave Labs.
|
Developed by Bluewave Labs.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Link
|
<Link
|
||||||
level="secondary"
|
level="secondary"
|
||||||
url="https://github.com/bluewave-labs"
|
url="https://github.com/bluewave-labs/bluewave-uptime"
|
||||||
label="https://github.com/bluewave-labs"
|
label="https://github.com/bluewave-labs/bluewave-uptime"
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
loading={isLoading || authIsLoading || checksIsLoading}
|
loading={isLoading || authIsLoading || checksIsLoading}
|
||||||
disabled={Object.keys(errors).length > 0}
|
disabled={Object.keys(errors).length > 0}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ const BASE_URL = import.meta.env.VITE_APP_API_BASE_URL;
|
|||||||
const FALLBACK_BASE_URL = "http://localhost:5000/api/v1";
|
const FALLBACK_BASE_URL = "http://localhost:5000/api/v1";
|
||||||
import { clearAuthState } from "../Features/Auth/authSlice";
|
import { clearAuthState } from "../Features/Auth/authSlice";
|
||||||
import { clearUptimeMonitorState } from "../Features/UptimeMonitors/uptimeMonitorsSlice";
|
import { clearUptimeMonitorState } from "../Features/UptimeMonitors/uptimeMonitorsSlice";
|
||||||
import { logger } from "./Logger";
|
|
||||||
class NetworkService {
|
class NetworkService {
|
||||||
constructor(store, dispatch, navigate) {
|
constructor(store, dispatch, navigate) {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
@@ -89,6 +88,32 @@ class NetworkService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* ************************************
|
||||||
|
* Check the endpoint resolution
|
||||||
|
* ************************************
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @param {Object} config - The configuration object.
|
||||||
|
* @param {string} config.authToken - The authorization token to be used in the request header.
|
||||||
|
* @param {Object} config.monitorURL - The monitor url to be sent in the request body.
|
||||||
|
* @returns {Promise<AxiosResponse>} The response from the axios POST request.
|
||||||
|
*/
|
||||||
|
async checkEndpointResolution(config) {
|
||||||
|
const { authToken, monitorURL } = config;
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
if (monitorURL) params.append("monitorURL", monitorURL);
|
||||||
|
|
||||||
|
return this.axiosInstance.get(`/monitors/resolution/url?${params.toString()}`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* ************************************
|
* ************************************
|
||||||
@@ -175,15 +200,12 @@ class NetworkService {
|
|||||||
if (field) params.append("field", field);
|
if (field) params.append("field", field);
|
||||||
if (order) params.append("order", order);
|
if (order) params.append("order", order);
|
||||||
|
|
||||||
return this.axiosInstance.get(
|
return this.axiosInstance.get(`/monitors/team/${teamId}?${params.toString()}`, {
|
||||||
`/monitors/team/${teamId}?${params.toString()}`,
|
|
||||||
{
|
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${authToken}`,
|
Authorization: `Bearer ${authToken}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,16 +255,12 @@ class NetworkService {
|
|||||||
* @returns {Promise<AxiosResponse>} The response from the axios PUT request.
|
* @returns {Promise<AxiosResponse>} The response from the axios PUT request.
|
||||||
*/
|
*/
|
||||||
async updateMonitor(config) {
|
async updateMonitor(config) {
|
||||||
return this.axiosInstance.put(
|
return this.axiosInstance.put(`/monitors/${config.monitorId}`, config.updatedFields, {
|
||||||
`/monitors/${config.monitorId}`,
|
|
||||||
config.updatedFields,
|
|
||||||
{
|
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${config.authToken}`,
|
Authorization: `Bearer ${config.authToken}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -582,12 +600,9 @@ class NetworkService {
|
|||||||
if (config.page) params.append("page", config.page);
|
if (config.page) params.append("page", config.page);
|
||||||
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
||||||
|
|
||||||
return this.axiosInstance.get(
|
return this.axiosInstance.get(`/checks/${config.monitorId}?${params.toString()}`, {
|
||||||
`/checks/${config.monitorId}?${params.toString()}`,
|
|
||||||
{
|
|
||||||
headers: { Authorization: `Bearer ${config.authToken}` },
|
headers: { Authorization: `Bearer ${config.authToken}` },
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -616,12 +631,9 @@ class NetworkService {
|
|||||||
if (config.filter) params.append("filter", config.filter);
|
if (config.filter) params.append("filter", config.filter);
|
||||||
if (config.page) params.append("page", config.page);
|
if (config.page) params.append("page", config.page);
|
||||||
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
||||||
return this.axiosInstance.get(
|
return this.axiosInstance.get(`/checks/team/${config.teamId}?${params.toString()}`, {
|
||||||
`/checks/team/${config.teamId}?${params.toString()}`,
|
|
||||||
{
|
|
||||||
headers: { Authorization: `Bearer ${config.authToken}` },
|
headers: { Authorization: `Bearer ${config.authToken}` },
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -705,16 +717,12 @@ class NetworkService {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
async createMaintenanceWindow(config) {
|
async createMaintenanceWindow(config) {
|
||||||
return this.axiosInstance.post(
|
return this.axiosInstance.post(`/maintenance-window`, config.maintenanceWindow, {
|
||||||
`/maintenance-window`,
|
|
||||||
config.maintenanceWindow,
|
|
||||||
{
|
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${config.authToken}`,
|
Authorization: `Bearer ${config.authToken}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -759,15 +767,12 @@ class NetworkService {
|
|||||||
|
|
||||||
async getMaintenanceWindowById(config) {
|
async getMaintenanceWindowById(config) {
|
||||||
const { authToken, maintenanceWindowId } = config;
|
const { authToken, maintenanceWindowId } = config;
|
||||||
return this.axiosInstance.get(
|
return this.axiosInstance.get(`/maintenance-window/${maintenanceWindowId}`, {
|
||||||
`/maintenance-window/${maintenanceWindowId}`,
|
|
||||||
{
|
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${authToken}`,
|
Authorization: `Bearer ${authToken}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -797,15 +802,12 @@ class NetworkService {
|
|||||||
if (field) params.append("field", field);
|
if (field) params.append("field", field);
|
||||||
if (order) params.append("order", order);
|
if (order) params.append("order", order);
|
||||||
|
|
||||||
return this.axiosInstance.get(
|
return this.axiosInstance.get(`/maintenance-window/team?${params.toString()}`, {
|
||||||
`/maintenance-window/team?${params.toString()}`,
|
|
||||||
{
|
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${authToken}`,
|
Authorization: `Bearer ${authToken}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* ************************************
|
* ************************************
|
||||||
@@ -822,14 +824,26 @@ class NetworkService {
|
|||||||
|
|
||||||
async deleteMaintenanceWindow(config) {
|
async deleteMaintenanceWindow(config) {
|
||||||
const { authToken, maintenanceWindowId } = config;
|
const { authToken, maintenanceWindowId } = config;
|
||||||
return this.axiosInstance.delete(
|
return this.axiosInstance.delete(`/maintenance-window/${maintenanceWindowId}`, {
|
||||||
`/maintenance-window/${maintenanceWindowId}`,
|
|
||||||
{
|
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${authToken}`,
|
Authorization: `Bearer ${authToken}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ************************************
|
||||||
|
* Fetcher github latest release version
|
||||||
|
* ************************************
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @returns {Promise<AxiosResponse>} The response from the axios GET request.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
async fetchGithubLatestRelease() {
|
||||||
|
return this.axiosInstance.get(
|
||||||
|
"https://api.github.com/repos/bluewave-labs/bluewave-uptime/releases/latest"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,8 +110,7 @@ const darkTheme = createTheme({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
props: (props) =>
|
props: (props) => props.variant === "group" && props.filled === "true",
|
||||||
props.variant === "group" && props.filled === "true",
|
|
||||||
style: {
|
style: {
|
||||||
backgroundColor: theme.palette.secondary.main,
|
backgroundColor: theme.palette.secondary.main,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -107,8 +107,7 @@ const lightTheme = createTheme({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
props: (props) =>
|
props: (props) => props.variant === "group" && props.filled === "true",
|
||||||
props.variant === "group" && props.filled === "true",
|
|
||||||
style: {
|
style: {
|
||||||
backgroundColor: theme.palette.secondary.main,
|
backgroundColor: theme.palette.secondary.main,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -155,8 +155,15 @@ const Greeting = ({ type = "" }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1" variant="h1" mb={theme.spacing(1)}>
|
<Typography
|
||||||
<Typography component="span" fontSize="inherit">
|
component="h1"
|
||||||
|
variant="h1"
|
||||||
|
mb={theme.spacing(1)}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
fontSize="inherit"
|
||||||
|
>
|
||||||
{prepend},{" "}
|
{prepend},{" "}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -168,7 +175,11 @@ const Greeting = ({ type = "" }) => {
|
|||||||
{firstName} {emoji}
|
{firstName} {emoji}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="h2" lineHeight={1} color={theme.palette.text.accent}>
|
<Typography
|
||||||
|
variant="h2"
|
||||||
|
lineHeight={1}
|
||||||
|
color={theme.palette.text.accent}
|
||||||
|
>
|
||||||
{append} — Here’s an overview of your {type} monitors.
|
{append} — Here’s an overview of your {type} monitors.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
const buildErrors = (prev, id, error) => {
|
||||||
|
const updatedErrors = { ...prev };
|
||||||
|
if (error) {
|
||||||
|
updatedErrors[id] = error.details[0].message?? "Validation error";
|
||||||
|
} else {
|
||||||
|
delete updatedErrors[id];
|
||||||
|
}
|
||||||
|
return updatedErrors;
|
||||||
|
};
|
||||||
|
|
||||||
|
const hasValidationErrors = (form, validation, setErrors) => {
|
||||||
|
const { error } = validation.validate(form, {
|
||||||
|
abortEarly: false,
|
||||||
|
});
|
||||||
|
if (error) {
|
||||||
|
const newErrors = {};
|
||||||
|
error.details.forEach((err) => {
|
||||||
|
if (
|
||||||
|
![
|
||||||
|
"clientHost",
|
||||||
|
"refreshTokenSecret",
|
||||||
|
"dbConnectionString",
|
||||||
|
"refreshTokenTTL",
|
||||||
|
"jwtTTL",
|
||||||
|
].includes(err.path[0])
|
||||||
|
) {
|
||||||
|
newErrors[err.path[0]] = err.message ?? "Validation error";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (Object.keys(newErrors).length > 0) {
|
||||||
|
setErrors(newErrors);
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
export { buildErrors, hasValidationErrors };
|
||||||
@@ -22,22 +22,16 @@ const passwordSchema = joi
|
|||||||
})
|
})
|
||||||
.custom((value, helpers) => {
|
.custom((value, helpers) => {
|
||||||
if (!/[A-Z]/.test(value)) {
|
if (!/[A-Z]/.test(value)) {
|
||||||
return helpers.message(
|
return helpers.message("Password must contain at least one uppercase letter");
|
||||||
"Password must contain at least one uppercase letter"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (!/[a-z]/.test(value)) {
|
if (!/[a-z]/.test(value)) {
|
||||||
return helpers.message(
|
return helpers.message("Password must contain at least one lowercase letter");
|
||||||
"Password must contain at least one lowercase letter"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (!/\d/.test(value)) {
|
if (!/\d/.test(value)) {
|
||||||
return helpers.message("Password must contain at least one number");
|
return helpers.message("Password must contain at least one number");
|
||||||
}
|
}
|
||||||
if (!/[!@#$%^&*]/.test(value)) {
|
if (!/[!@#$%^&*]/.test(value)) {
|
||||||
return helpers.message(
|
return helpers.message("Password must contain at least one special character");
|
||||||
"Password must contain at least one special character"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
@@ -89,10 +83,7 @@ const monitorValidation = joi.object({
|
|||||||
name: joi.string().trim().max(50).allow("").messages({
|
name: joi.string().trim().max(50).allow("").messages({
|
||||||
"string.max": "This field should not exceed the 50 characters limit.",
|
"string.max": "This field should not exceed the 50 characters limit.",
|
||||||
}),
|
}),
|
||||||
type: joi
|
type: joi.string().trim().messages({ "string.empty": "This field is required." }),
|
||||||
.string()
|
|
||||||
.trim()
|
|
||||||
.messages({ "string.empty": "This field is required." }),
|
|
||||||
interval: joi.number().messages({
|
interval: joi.number().messages({
|
||||||
"number.base": "Frequency must be a number.",
|
"number.base": "Frequency must be a number.",
|
||||||
"any.required": "Frequency is required.",
|
"any.required": "Frequency is required.",
|
||||||
@@ -131,16 +122,49 @@ const maintenanceWindowValidation = joi.object({
|
|||||||
repeat: joi.string(),
|
repeat: joi.string(),
|
||||||
startDate: joi.custom(dayjsValidator, "Day.js date validation"),
|
startDate: joi.custom(dayjsValidator, "Day.js date validation"),
|
||||||
startTime: joi.custom(dayjsValidator, "Day.js date validation"),
|
startTime: joi.custom(dayjsValidator, "Day.js date validation"),
|
||||||
duration: joi.number(),
|
duration: joi.number().integer().min(0),
|
||||||
durationUnit: joi.string(),
|
durationUnit: joi.string(),
|
||||||
name: joi.string(),
|
name: joi.string(),
|
||||||
monitors: joi.array().min(1),
|
monitors: joi.array().min(1),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const advancedSettingsValidation = joi.object({
|
||||||
|
apiBaseUrl: joi.string().uri({ allowRelative: true }).trim().messages({
|
||||||
|
"string.empty": "API base url is required.",
|
||||||
|
"string.uri": "The URL you provided is not valid.",
|
||||||
|
}),
|
||||||
|
logLevel: joi.string().valid("debug", "none", "error", "warn").allow(""),
|
||||||
|
systemEmailHost: joi.string().allow(""),
|
||||||
|
systemEmailPort: joi.number().allow(null, ""),
|
||||||
|
systemEmailAddress: joi.string().allow(""),
|
||||||
|
systemEmailPassword: joi.string().allow(""),
|
||||||
|
jwtTTLNum: joi.number().messages({
|
||||||
|
"number.base": "JWT TTL is required.",
|
||||||
|
}),
|
||||||
|
jwtTTLUnits: joi
|
||||||
|
.string()
|
||||||
|
.trim()
|
||||||
|
.custom((value, helpers) => {
|
||||||
|
if (!["days", "hours"].includes(value)) {
|
||||||
|
return helpers.message("JWT TTL unit is required.");
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}),
|
||||||
|
dbType: joi.string().trim().messages({
|
||||||
|
"string.empty": "DB type is required.",
|
||||||
|
}),
|
||||||
|
redisHost: joi.string().trim().messages({
|
||||||
|
"string.empty": "Redis host is required.",
|
||||||
|
}),
|
||||||
|
redisPort: joi.number().allow(null, ""),
|
||||||
|
pagespeedApiKey: joi.string().allow(""),
|
||||||
|
});
|
||||||
|
|
||||||
export {
|
export {
|
||||||
credentials,
|
credentials,
|
||||||
imageValidation,
|
imageValidation,
|
||||||
monitorValidation,
|
monitorValidation,
|
||||||
settingsValidation,
|
settingsValidation,
|
||||||
maintenanceWindowValidation,
|
maintenanceWindowValidation,
|
||||||
|
advancedSettingsValidation
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M17 17L22 12L17 7M7 7L2 12L7 17M14 3L10 21" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 237 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M14 11H8M10 15H8M16 7H8M20 6.8V17.2C20 18.8802 20 19.7202 19.673 20.362C19.3854 20.9265 18.9265 21.3854 18.362 21.673C17.7202 22 16.8802 22 15.2 22H8.8C7.11984 22 6.27976 22 5.63803 21.673C5.07354 21.3854 4.6146 20.9265 4.32698 20.362C4 19.7202 4 18.8802 4 17.2V6.8C4 5.11984 4 4.27976 4.32698 3.63803C4.6146 3.07354 5.07354 2.6146 5.63803 2.32698C6.27976 2 7.11984 2 8.8 2H15.2C16.8802 2 17.7202 2 18.362 2.32698C18.9265 2.6146 19.3854 3.07354 19.673 3.63803C20 4.27976 20 5.11984 20 6.8Z" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 684 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M3 8.2C3 7.07989 3 6.51984 3.21799 6.09202C3.40973 5.71569 3.71569 5.40973 4.09202 5.21799C4.51984 5 5.0799 5 6.2 5H9.67452C10.1637 5 10.4083 5 10.6385 5.05526C10.8425 5.10425 11.0376 5.18506 11.2166 5.29472C11.4184 5.4184 11.5914 5.59135 11.9373 5.93726L12.0627 6.06274C12.4086 6.40865 12.5816 6.5816 12.7834 6.70528C12.9624 6.81494 13.1575 6.89575 13.3615 6.94474C13.5917 7 13.8363 7 14.3255 7H17.8C18.9201 7 19.4802 7 19.908 7.21799C20.2843 7.40973 20.5903 7.71569 20.782 8.09202C21 8.51984 21 9.0799 21 10.2V15.8C21 16.9201 21 17.4802 20.782 17.908C20.5903 18.2843 20.2843 18.5903 19.908 18.782C19.4802 19 18.9201 19 17.8 19H6.2C5.07989 19 4.51984 19 4.09202 18.782C3.71569 18.5903 3.40973 18.2843 3.21799 17.908C3 17.4802 3 16.9201 3 15.8V8.2Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.0 KiB |
+4
-1
@@ -11,7 +11,10 @@ export { networkService };
|
|||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById("root")).render(
|
ReactDOM.createRoot(document.getElementById("root")).render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<PersistGate loading={null} persistor={persistor}>
|
<PersistGate
|
||||||
|
loading={null}
|
||||||
|
persistor={persistor}
|
||||||
|
>
|
||||||
<Router>
|
<Router>
|
||||||
<NetworkServiceProvider>
|
<NetworkServiceProvider>
|
||||||
<App />
|
<App />
|
||||||
|
|||||||
+1
-5
@@ -41,11 +41,7 @@ export const store = configureStore({
|
|||||||
middleware: (getDefaultMiddleware) =>
|
middleware: (getDefaultMiddleware) =>
|
||||||
getDefaultMiddleware({
|
getDefaultMiddleware({
|
||||||
serializableCheck: {
|
serializableCheck: {
|
||||||
ignoredActions: [
|
ignoredActions: ["persist/PERSIST", "persist/REHYDRATE", "persist/REGISTER"],
|
||||||
"persist/PERSIST",
|
|
||||||
"persist/REHYDRATE",
|
|
||||||
"persist/REGISTER",
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
Loaded 100 of 204 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user