Merge pull request #2263 from bluewave-labs/develop

develop->demo
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-05-13 13:35:45 -07:00
commit 881fbdeeb4
55 files changed
+1444 -666

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ Fixes #123
const { t } = useTranslation(); const { t } = useTranslation();
<div>{t('add')}</div> <div>{t('add')}</div>
``` ```
- [ ] The issue I am working on is assigned to me. - [ ] I have **not** included any files that are not related to my pull request, including package-lock and package-json if dependencies have not changed
- [ ] I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application). - [ ] I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
- [ ] I made sure font sizes, color choices etc are all referenced from the theme. I have no hardcoded dimensions. - [ ] I made sure font sizes, color choices etc are all referenced from the theme. I have no hardcoded dimensions.
- [ ] My PR is granular and targeted to one specific feature. - [ ] My PR is granular and targeted to one specific feature.
+9
View File
@@ -123,9 +123,15 @@ If one or more of these are missing, we may ask you to update your pull request
## Branching model ## Branching model
- Code contributions should go to the `develop` branch. - Code contributions should go to the `develop` branch.
- `master` is used for stable releases. - `master` is used for stable releases.
- Use descriptive branch names, like `fix/login-error` or `feat/add-alerts`. - Use descriptive branch names, like `fix/login-error` or `feat/add-alerts`.
- Make sure that you are using the latest version.
- Make sure you run the code locally. The Checkmate [documentation](https://docs.checkmate.so) covers it.
- 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.
- 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.
--- ---
@@ -133,8 +139,11 @@ If one or more of these are missing, we may ask you to update your pull request
Thanks for making Checkmate better. We mean it. Whether it’s your first pull request or your 50th, we’re excited to build with you. Thanks for making Checkmate better. We mean it. Whether it’s your first pull request or your 50th, we’re excited to build with you.
PS: feel free to introduce yourself on [Discord](https://discord.gg/YOUR-DISCORD-LINK) and say hi. PS: feel free to introduce yourself on [Discord](https://discord.gg/YOUR-DISCORD-LINK) and say hi.
-- Checkmate team -- Checkmate team
Also make sure you read the [document about how to make a good pull request](/PULLREQUESTS.md).
+1
View File
@@ -8,6 +8,7 @@
![](https://img.shields.io/github/issues/bluewave-labs/checkmate) ![](https://img.shields.io/github/issues/bluewave-labs/checkmate)
![](https://img.shields.io/github/issues-pr/bluewave-labs/checkmate) ![](https://img.shields.io/github/issues-pr/bluewave-labs/checkmate)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9901/badge)](https://www.bestpractices.dev/projects/9901) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9901/badge)](https://www.bestpractices.dev/projects/9901)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/bluewave-labs/checkmate)
<h1 align="center"><a href="https://bluewavelabs.ca" target="_blank">Checkmate</a></h1> <h1 align="center"><a href="https://bluewavelabs.ca" target="_blank">Checkmate</a></h1>
+1 -1
View File
@@ -111,7 +111,7 @@ const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => {
Alert.propTypes = { Alert.propTypes = {
variant: PropTypes.oneOf(["info", "error", "warning"]).isRequired, variant: PropTypes.oneOf(["info", "error", "warning"]).isRequired,
title: PropTypes.string, title: PropTypes.string,
body: PropTypes.string, body: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
isToast: PropTypes.bool, isToast: PropTypes.bool,
hasIcon: PropTypes.bool, hasIcon: PropTypes.bool,
onClick: function (props, propName, componentName) { onClick: function (props, propName, componentName) {
+3 -1
View File
@@ -2,6 +2,7 @@ import PropTypes from "prop-types";
import { Button, Stack } from "@mui/material"; import { Button, Stack } from "@mui/material";
import { GenericDialog } from "./genericDialog"; import { GenericDialog } from "./genericDialog";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { useTranslation } from "react-i18next";
const Dialog = ({ const Dialog = ({
title, title,
@@ -13,6 +14,7 @@ const Dialog = ({
isLoading, isLoading,
}) => { }) => {
const theme = useTheme(); const theme = useTheme();
const { t } = useTranslation();
return ( return (
<GenericDialog <GenericDialog
@@ -33,7 +35,7 @@ const Dialog = ({
color="secondary" color="secondary"
onClick={onCancel} onClick={onCancel}
> >
Cancel {t("cancel", "Cancel")}
</Button> </Button>
<Button <Button
variant="contained" variant="contained"
+30 -16
View File
@@ -11,7 +11,8 @@ import { useSelector } from "react-redux";
import Alert from "../Alert"; import Alert from "../Alert";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import "./index.css"; import "./index.css";
import { useFetchSettings } from "../../Hooks/useFetchSettings";
import { useState } from "react";
/** /**
* Fallback component to display a fallback UI with a title, a list of checks, and a navigation button. * Fallback component to display a fallback UI with a title, a list of checks, and a navigation button.
* *
@@ -24,17 +25,26 @@ import "./index.css";
* @returns {JSX.Element} The rendered fallback UI. * @returns {JSX.Element} The rendered fallback UI.
*/ */
const Fallback = ({ title, checks, link = "/", isAdmin, vowelStart = false, showPageSpeedWarning = false }) => { const Fallback = ({
title,
checks,
link = "/",
isAdmin,
vowelStart = false,
showPageSpeedWarning = false,
}) => {
const theme = useTheme(); const theme = useTheme();
const navigate = useNavigate(); const navigate = useNavigate();
const mode = useSelector((state) => state.ui.mode); const mode = useSelector((state) => state.ui.mode);
const { t } = useTranslation(); const { t } = useTranslation();
const [settingsData, setSettingsData] = useState(undefined);
const [isLoading, error] = useFetchSettings({ setSettingsData });
// Custom warning message with clickable link // Custom warning message with clickable link
const renderWarningMessage = () => { const renderWarningMessage = () => {
return ( return (
<> <>
{t("pageSpeedWarning")} {" "} {t("pageSpeedWarning")}{" "}
<Link <Link
component={RouterLink} component={RouterLink}
to="/settings" to="/settings"
@@ -44,12 +54,12 @@ const Fallback = ({ title, checks, link = "/", isAdmin, vowelStart = false, show
fontWeight: "inherit", fontWeight: "inherit",
"&:hover": { "&:hover": {
textDecoration: "underline", textDecoration: "underline",
} },
}} }}
> >
{t("pageSpeedLearnMoreLink")} {t("pageSpeedLearnMoreLink")}
</Link> </Link>{" "}
{" "}{t("pageSpeedAddApiKey")} {t("pageSpeedAddApiKey")}
</> </>
); );
}; };
@@ -131,25 +141,29 @@ const Fallback = ({ title, checks, link = "/", isAdmin, vowelStart = false, show
)} )}
{/* Warning box for PageSpeed monitor */} {/* Warning box for PageSpeed monitor */}
{(title === "pagespeed monitor" && showPageSpeedWarning) && ( {title === "pagespeed monitor" && showPageSpeedWarning && (
<Box sx={{ width: "80%", maxWidth: "600px", zIndex: 1 }}> <Box sx={{ width: "80%", maxWidth: "600px", zIndex: 1 }}>
<Box sx={{ <Box
'& .alert.row-stack': { sx={{
"& .alert.row-stack": {
backgroundColor: theme.palette.warningSecondary.main, backgroundColor: theme.palette.warningSecondary.main,
borderColor: theme.palette.warningSecondary.lowContrast, borderColor: theme.palette.warningSecondary.lowContrast,
'& .MuiTypography-root': { "& .MuiTypography-root": {
color: theme.palette.warningSecondary.contrastText color: theme.palette.warningSecondary.contrastText,
}, },
'& .MuiBox-root > svg': { "& .MuiBox-root > svg": {
color: theme.palette.warningSecondary.contrastText color: theme.palette.warningSecondary.contrastText,
} },
} },
}}> }}
>
{settingsData?.pagespeedKeySet === false && (
<Alert <Alert
variant="warning" variant="warning"
hasIcon={true} hasIcon={true}
body={renderWarningMessage()} body={renderWarningMessage()}
/> />
)}
</Box> </Box>
</Box> </Box>
)} )}
@@ -156,7 +156,7 @@ const Select = ({
}; };
Select.propTypes = { Select.propTypes = {
id: PropTypes.string.isRequired, id: PropTypes.string,
name: PropTypes.string, name: PropTypes.string,
label: PropTypes.string, label: PropTypes.string,
placeholder: PropTypes.string, placeholder: PropTypes.string,
@@ -141,9 +141,9 @@ TextInput.displayName = "TextInput";
TextInput.propTypes = { TextInput.propTypes = {
type: PropTypes.string, type: PropTypes.string,
id: PropTypes.string.isRequired, id: PropTypes.string,
name: PropTypes.string, name: PropTypes.string,
value: PropTypes.string, value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
placeholder: PropTypes.string, placeholder: PropTypes.string,
isRequired: PropTypes.bool, isRequired: PropTypes.bool,
isOptional: PropTypes.bool, isOptional: PropTypes.bool,
@@ -6,7 +6,7 @@ import { useTheme } from "@emotion/react";
const CreateMonitorHeader = ({ const CreateMonitorHeader = ({
isAdmin, isAdmin,
label = "Create new", label,
isLoading = true, isLoading = true,
path, path,
bulkPath, bulkPath,
@@ -15,6 +15,8 @@ const CreateMonitorHeader = ({
const { t } = useTranslation(); const { t } = useTranslation();
const theme = useTheme(); const theme = useTheme();
// Use the provided label or fall back to the translated default
if (!isAdmin) return null; if (!isAdmin) return null;
return ( return (
@@ -30,7 +32,7 @@ const CreateMonitorHeader = ({
color="accent" color="accent"
onClick={() => navigate(path)} onClick={() => navigate(path)}
> >
{label} {label || t("createNew")}
</Button> </Button>
{bulkPath && ( {bulkPath && (
<Button <Button
+32 -22
View File
@@ -47,46 +47,47 @@ import "./index.css";
import { useLocation, useNavigate } from "react-router"; import { useLocation, useNavigate } from "react-router";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { useTranslation } from "react-i18next";
import { clearAuthState } from "../../Features/Auth/authSlice"; import { clearAuthState } from "../../Features/Auth/authSlice";
import { toggleSidebar } from "../../Features/UI/uiSlice"; import { toggleSidebar } from "../../Features/UI/uiSlice";
import { clearUptimeMonitorState } from "../../Features/UptimeMonitors/uptimeMonitorsSlice"; import { clearUptimeMonitorState } from "../../Features/UptimeMonitors/uptimeMonitorsSlice";
const menu = [ const getMenu = (t) => [
{ name: "Uptime", path: "uptime", icon: <Monitors /> }, { name: t("menu.uptime"), path: "uptime", icon: <Monitors /> },
{ name: "Pagespeed", path: "pagespeed", icon: <PageSpeed /> }, { name: t("menu.pagespeed"), path: "pagespeed", icon: <PageSpeed /> },
{ name: "Infrastructure", path: "infrastructure", icon: <Integrations /> }, { name: t("menu.infrastructure"), path: "infrastructure", icon: <Integrations /> },
{ {
name: "Distributed uptime", name: t("menu.distributedUptime"),
path: "distributed-uptime", path: "distributed-uptime",
icon: <DistributedUptimeIcon />, icon: <DistributedUptimeIcon />,
}, },
{ name: "Incidents", path: "incidents", icon: <Incidents /> }, { name: t("menu.incidents"), path: "incidents", icon: <Incidents /> },
{ name: "Status pages", path: "status", icon: <StatusPages /> }, { name: t("menu.statusPages"), path: "status", icon: <StatusPages /> },
{ name: "Maintenance", path: "maintenance", icon: <Maintenance /> }, { name: t("menu.maintenance"), path: "maintenance", icon: <Maintenance /> },
// { name: "Integrations", path: "integrations", icon: <Integrations /> }, // { name: t("menu.integrations"), path: "integrations", icon: <Integrations /> },
{ {
name: "Settings", name: t("menu.settings"),
icon: <Settings />, icon: <Settings />,
path: "settings", path: "settings",
}, },
]; ];
const otherMenuItems = [ const getOtherMenuItems = (t) => [
{ name: "Support", path: "support", icon: <Support /> }, { name: t("menu.support"), path: "support", icon: <Support /> },
{ {
name: "Discussions", name: t("menu.discussions"),
path: "discussions", path: "discussions",
icon: <Discussions />, icon: <Discussions />,
}, },
{ name: "Docs", path: "docs", icon: <Docs /> }, { name: t("menu.docs"), path: "docs", icon: <Docs /> },
{ name: "Changelog", path: "changelog", icon: <ChangeLog /> }, { name: t("menu.changelog"), path: "changelog", icon: <ChangeLog /> },
]; ];
const accountMenuItems = [ const getAccountMenuItems = (t) => [
{ name: "Profile", path: "account/profile", icon: <UserSvg /> }, { name: t("menu.profile"), path: "account/profile", icon: <UserSvg /> },
{ name: "Password", path: "account/password", icon: <LockSvg /> }, { name: t("menu.password"), path: "account/password", icon: <LockSvg /> },
{ name: "Team", path: "account/team", icon: <TeamSvg /> }, { name: t("menu.team"), path: "account/team", icon: <TeamSvg /> },
]; ];
/* TODO this could be a key in nested Path would be the link */ /* TODO this could be a key in nested Path would be the link */
@@ -118,7 +119,12 @@ function Sidebar() {
const navigate = useNavigate(); const navigate = useNavigate();
const location = useLocation(); const location = useLocation();
const dispatch = useDispatch(); const dispatch = useDispatch();
const { t } = useTranslation();
const authState = useSelector((state) => state.auth); const authState = useSelector((state) => state.auth);
const menu = getMenu(t);
const otherMenuItems = getOtherMenuItems(t);
const accountMenuItems = getAccountMenuItems(t);
const collapsed = useSelector((state) => state.ui.sidebar.collapsed); const collapsed = useSelector((state) => state.ui.sidebar.collapsed);
const [open, setOpen] = useState({ Dashboard: false, Account: false, Other: false }); const [open, setOpen] = useState({ Dashboard: false, Account: false, Other: false });
const [anchorEl, setAnchorEl] = useState(null); const [anchorEl, setAnchorEl] = useState(null);
@@ -726,7 +732,11 @@ function Sidebar() {
{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?.includes("superadmin") ? t("roles.superAdmin") :
authState.user?.role?.includes("admin") ? t("roles.admin") :
authState.user?.role?.includes("user") ? t("roles.teamMember") :
authState.user?.role?.includes("demo") ? t("roles.demoUser") :
authState.user?.role}
</Typography> </Typography>
</Box> </Box>
<Stack <Stack
@@ -737,7 +747,7 @@ function Sidebar() {
> >
<ThemeSwitch color={iconColor} /> <ThemeSwitch color={iconColor} />
<Tooltip <Tooltip
title="Controls" title={t("navControls")}
disableInteractive disableInteractive
> >
<IconButton <IconButton
@@ -851,7 +861,7 @@ function Sidebar() {
}} }}
> >
<LogoutSvg /> <LogoutSvg />
Log out {t("menu.logOut", "Log out")}
</MenuItem> </MenuItem>
</Menu> </Menu>
</Stack> </Stack>
@@ -94,7 +94,7 @@ const PasswordPanel = () => {
const action = await dispatch(update({ localData })); const action = await dispatch(update({ localData }));
if (action.payload.success) { if (action.payload.success) {
createToast({ createToast({
body: "Your password was changed successfully.", body: t("passwordPanel.passwordChangedSuccess", "Your password was changed successfully."),
}); });
setLocalData({ setLocalData({
password: "", password: "",
@@ -104,7 +104,7 @@ const PasswordPanel = () => {
} else { } else {
// TODO: Check for other errors? // TODO: Check for other errors?
createToast({ createToast({
body: "Your password input was incorrect.", body: t("passwordPanel.passwordInputIncorrect", "Your password input was incorrect."),
}); });
setErrors({ password: "*" + action.payload.msg + "." }); setErrors({ password: "*" + action.payload.msg + "." });
} }
@@ -148,12 +148,12 @@ const PasswordPanel = () => {
component="h1" component="h1"
width="20ch" width="20ch"
> >
Current password {t("passwordPanel.currentPassword", "Current password")}
</Typography> </Typography>
<TextInput <TextInput
type="password" type="password"
id="edit-current-password" id="edit-current-password"
placeholder="Enter your current password" placeholder={t("passwordPanel.enterCurrentPassword", "Enter your current password")}
autoComplete="current-password" autoComplete="current-password"
value={localData.password} value={localData.password}
onChange={handleChange} onChange={handleChange}
@@ -173,13 +173,13 @@ const PasswordPanel = () => {
component="h1" component="h1"
width="20ch" width="20ch"
> >
New password {t("passwordPanel.newPassword", "New password")}
</Typography> </Typography>
<TextInput <TextInput
type="password" type="password"
id="edit-new-password" id="edit-new-password"
placeholder="Enter your new password" placeholder={t("passwordPanel.enterNewPassword", "Enter your new password")}
autoComplete="new-password" autoComplete="new-password"
value={localData.newPassword} value={localData.newPassword}
onChange={handleChange} onChange={handleChange}
@@ -199,13 +199,13 @@ const PasswordPanel = () => {
component="h1" component="h1"
width="20ch" width="20ch"
> >
Confirm new password {t("passwordPanel.confirmNewPassword", "Confirm new password")}
</Typography> </Typography>
<TextInput <TextInput
type="password" type="password"
id="edit-confirm-password" id="edit-confirm-password"
placeholder={t("confirmPassword")} placeholder={t("confirmPassword", "Confirm password")}
autoComplete="new-password" autoComplete="new-password"
value={localData.confirm} value={localData.confirm}
onChange={handleChange} onChange={handleChange}
@@ -219,7 +219,7 @@ const PasswordPanel = () => {
<Box sx={{ maxWidth: "70ch" }}> <Box sx={{ maxWidth: "70ch" }}>
<Alert <Alert
variant="warning" variant="warning"
body="New password must contain at least 8 characters and must have at least one uppercase letter, one lowercase letter, one number and one special character." body={t("passwordPanel.passwordRequirements", "New password must contain at least 8 characters and must have at least one uppercase letter, one lowercase letter, one number and one special character.")}
/> />
</Box> </Box>
)} )}
@@ -232,7 +232,7 @@ const PasswordPanel = () => {
color="accent" color="accent"
type="submit" type="submit"
loading={isLoading} loading={isLoading}
loadingIndicator="Saving..." loadingIndicator={t("commonSaving", "Saving...")}
disabled={ disabled={
Object.keys(errors).length > 0 || Object.keys(errors).length > 0 ||
Object.values(localData).filter((value) => value === "").length > 0 Object.values(localData).filter((value) => value === "").length > 0
@@ -242,7 +242,7 @@ const PasswordPanel = () => {
mt: theme.spacing(20), mt: theme.spacing(20),
}} }}
> >
Save {t("commonSave", "Save")}
</Button> </Button>
</Stack> </Stack>
</Stack> </Stack>
@@ -2,11 +2,11 @@ import { useTheme } from "@emotion/react";
import TabPanel from "@mui/lab/TabPanel"; import TabPanel from "@mui/lab/TabPanel";
import { Button, ButtonGroup, Stack, Typography } from "@mui/material"; import { Button, ButtonGroup, Stack, Typography } from "@mui/material";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import TextInput from "../../Inputs/TextInput"; import TextInput from "../../Inputs/TextInput";
import { credentials } from "../../../Validation/validation"; import { credentials } from "../../../Validation/validation";
import { networkService } from "../../../main"; import { networkService } from "../../../main";
import { createToast } from "../../../Utils/toastUtils"; import { createToast } from "../../../Utils/toastUtils";
import { useSelector } from "react-redux";
import Select from "../../Inputs/Select"; import Select from "../../Inputs/Select";
import { GenericDialog } from "../../Dialog/genericDialog"; import { GenericDialog } from "../../Dialog/genericDialog";
import DataTable from "../../Table/"; import DataTable from "../../Table/";
@@ -21,6 +21,7 @@ import { useGetInviteToken } from "../../../Hooks/inviteHooks";
const TeamPanel = () => { const TeamPanel = () => {
const theme = useTheme(); const theme = useTheme();
const { t } = useTranslation();
const SPACING_GAP = theme.spacing(12); const SPACING_GAP = theme.spacing(12);
const [toInvite, setToInvite] = useState({ const [toInvite, setToInvite] = useState({
@@ -39,7 +40,7 @@ const TeamPanel = () => {
const headers = [ const headers = [
{ {
id: "name", id: "name",
content: "Name", content: t("teamPanel.table.name"),
render: (row) => { render: (row) => {
return ( return (
<Stack> <Stack>
@@ -47,16 +48,16 @@ const TeamPanel = () => {
{row.firstName + " " + row.lastName} {row.firstName + " " + row.lastName}
</Typography> </Typography>
<Typography> <Typography>
Created {new Date(row.createdAt).toLocaleDateString()} {t("teamPanel.table.created")} {new Date(row.createdAt).toLocaleDateString()}
</Typography> </Typography>
</Stack> </Stack>
); );
}, },
}, },
{ id: "email", content: "Email", render: (row) => row.email }, { id: "email", content: t("teamPanel.table.email"), render: (row) => row.email },
{ {
id: "role", id: "role",
content: "Role", content: t("teamPanel.table.role"),
render: (row) => row.role, render: (row) => row.role,
}, },
]; ];
@@ -78,10 +79,10 @@ const TeamPanel = () => {
useEffect(() => { useEffect(() => {
const ROLE_MAP = { const ROLE_MAP = {
superadmin: "Super admin", superadmin: t("roles.superAdmin"),
admin: "Admin", admin: t("roles.admin"),
user: "Team member", user: t("roles.teamMember"),
demo: "Demo User", demo: t("roles.demoUser"),
}; };
let team = members; let team = members;
if (filter !== "all") if (filter !== "all")
@@ -98,7 +99,7 @@ const TeamPanel = () => {
role: member.role.map((role) => ROLE_MAP[role]).join(","), role: member.role.map((role) => ROLE_MAP[role]).join(","),
})); }));
setData(team); setData(team);
}, [filter, members]); }, [members, filter, t]);
useEffect(() => { useEffect(() => {
setIsDisabled(Object.keys(errors).length !== 0 || toInvite.email === ""); setIsDisabled(Object.keys(errors).length !== 0 || toInvite.email === "");
@@ -197,7 +198,7 @@ const TeamPanel = () => {
spellCheck="false" spellCheck="false"
gap={SPACING_GAP} gap={SPACING_GAP}
> >
<Typography component="h1">Team members</Typography> <Typography component="h1">{t("teamPanel.teamMembers")}</Typography>
<Stack <Stack
direction="row" direction="row"
justifyContent="space-between" justifyContent="space-between"
@@ -214,21 +215,21 @@ const TeamPanel = () => {
filled={(filter === "all").toString()} filled={(filter === "all").toString()}
onClick={() => setFilter("all")} onClick={() => setFilter("all")}
> >
All {t("teamPanel.filter.all")}
</Button> </Button>
<Button <Button
variant="group" variant="group"
filled={(filter === "admin").toString()} filled={(filter === "admin").toString()}
onClick={() => setFilter("admin")} onClick={() => setFilter("admin")}
> >
Super admin {t("roles.superAdmin")}
</Button> </Button>
<Button <Button
variant="group" variant="group"
filled={(filter === "user").toString()} filled={(filter === "user").toString()}
onClick={() => setFilter("user")} onClick={() => setFilter("user")}
> >
Member {t("teamPanel.filter.member")}
</Button> </Button>
</ButtonGroup> </ButtonGroup>
</Stack> </Stack>
@@ -237,22 +238,20 @@ const TeamPanel = () => {
color="accent" color="accent"
onClick={() => setIsOpen(true)} onClick={() => setIsOpen(true)}
> >
Invite a team member {t("teamPanel.inviteTeamMember")}
</Button> </Button>
</Stack> </Stack>
<DataTable <DataTable
headers={headers} headers={headers}
data={data} data={data}
config={{ emptyView: "There are no team members with this role" }} config={{ emptyView: t("teamPanel.noMembers") }}
/> />
</Stack> </Stack>
<GenericDialog <GenericDialog
title={"Invite new team member"} title={t("teamPanel.inviteNewTeamMember")}
description={ description={t("teamPanel.inviteDescription")}
"When you add a new team member, they will get access to all monitors."
}
open={isOpen} open={isOpen}
onClose={closeInviteModal} onClose={closeInviteModal}
theme={theme} theme={theme}
@@ -261,7 +260,7 @@ const TeamPanel = () => {
marginBottom={SPACING_GAP} marginBottom={SPACING_GAP}
type="email" type="email"
id="input-team-member" id="input-team-member"
placeholder="Email" placeholder={t("teamPanel.email")}
value={toInvite.email} value={toInvite.email}
onChange={handleChange} onChange={handleChange}
error={errors.email ? true : false} error={errors.email ? true : false}
@@ -269,7 +268,7 @@ const TeamPanel = () => {
/> />
<Select <Select
id="team-member-role" id="team-member-role"
placeholder="Select role" placeholder={t("teamPanel.selectRole")}
isHidden={true} isHidden={true}
value={toInvite.role[0]} value={toInvite.role[0]}
onChange={(event) => onChange={(event) =>
@@ -279,11 +278,11 @@ const TeamPanel = () => {
})) }))
} }
items={[ items={[
{ _id: "admin", name: "Admin" }, { _id: "admin", name: t("roles.admin") },
{ _id: "user", name: "User" }, { _id: "user", name: t("roles.teamMember") },
]} ]}
/> />
{token && <Typography>Invite link</Typography>} {token && <Typography>{t("teamPanel.inviteLink")}</Typography>}
{token && ( {token && (
<TextInput <TextInput
id="invite-token" id="invite-token"
@@ -302,7 +301,7 @@ const TeamPanel = () => {
color="error" color="error"
onClick={closeInviteModal} onClick={closeInviteModal}
> >
Cancel {t("teamPanel.cancel")}
</Button> </Button>
<Button <Button
variant="contained" variant="contained"
@@ -311,7 +310,7 @@ const TeamPanel = () => {
loading={isSendingInvite} loading={isSendingInvite}
disabled={isDisabled} disabled={isDisabled}
> >
Get token {t("teamPanel.getToken")}
</Button> </Button>
<Button <Button
variant="contained" variant="contained"
@@ -320,7 +319,7 @@ const TeamPanel = () => {
loading={isSendingInvite} loading={isSendingInvite}
disabled={isDisabled} disabled={isDisabled}
> >
E-mail token {t("teamPanel.emailToken")}
</Button> </Button>
</Stack> </Stack>
</GenericDialog> </GenericDialog>
-1
View File
@@ -65,7 +65,6 @@ const DataTable = ({
backgroundColor: theme.palette.secondary.main, backgroundColor: theme.palette.secondary.main,
color: theme.palette.secondary.contrastText, color: theme.palette.secondary.contrastText,
fontWeight: 600, fontWeight: 600,
fontSize: "13px",
}, },
"& :is(td)": { "& :is(td)": {
backgroundColor: theme.palette.primary.main, backgroundColor: theme.palette.primary.main,
+24
View File
@@ -0,0 +1,24 @@
import { useState } from "react";
import { networkService } from "../main";
import { createToast } from "../Utils/toastUtils";
import { useTranslation } from "react-i18next";
const UseDeleteMonitorStats = () => {
const { t } = useTranslation();
const [isLoading, setIsLoading] = useState(false);
const deleteMonitorStats = async ({ teamId }) => {
setIsLoading(true);
try {
const res = await networkService.deleteChecksByTeamId({ teamId });
createToast({ body: t("settingsStatsCleared") });
} catch (error) {
createToast({ body: t("settingsFailedToClearStats") });
} finally {
setIsLoading(false);
}
};
return [deleteMonitorStats, isLoading];
};
export { UseDeleteMonitorStats };
+55
View File
@@ -0,0 +1,55 @@
import { useState, useEffect } from "react";
import { networkService } from "../main";
import { createToast } from "../Utils/toastUtils";
import { useTranslation } from "react-i18next";
const useFetchSettings = ({ setSettingsData }) => {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(undefined);
useEffect(() => {
const fetchSettings = async () => {
setIsLoading(true);
try {
const response = await networkService.getAppSettings();
setSettingsData(response?.data?.data);
} catch (error) {
createToast({ body: "Failed to fetch settings" });
setError(error);
} finally {
setIsLoading(false);
}
};
fetchSettings();
}, []);
return [isLoading, error];
};
const useSaveSettings = () => {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(undefined);
const { t } = useTranslation();
const saveSettings = async (settings) => {
setIsLoading(true);
try {
await networkService.updateAppSettings({ settings });
if (settings.checkTTL) {
await networkService.updateChecksTTL({
ttl: settings.checkTTL,
});
}
createToast({ body: t("settingsSuccessSaved") });
} catch (error) {
createToast({ body: t("settingsFailedToSave") });
setError(error);
} finally {
setIsLoading(false);
}
};
return [isLoading, error, saveSettings];
};
export { useFetchSettings, useSaveSettings };
+33
View File
@@ -0,0 +1,33 @@
import { useState } from "react";
import { networkService } from "../main";
import { useSelector } from "react-redux";
import { createToast } from "../Utils/toastUtils";
const useSendTestEmail = () => {
const [isSending, setIsSending] = useState(false);
const [error, setError] = useState(null);
const user = useSelector((state) => state.auth.user);
const sendTestEmail = async () => {
try {
setIsSending(true);
setError(null);
const response = await networkService.sendTestEmail({ to: user.email });
if (typeof response?.data?.data?.messageId !== "undefined") {
createToast({
body: "Test email sent successfully",
});
} else {
throw new Error("Failed to send test email");
}
} catch (error) {
setError(error);
} finally {
setIsSending(false);
}
};
return [isSending, error, sendTestEmail];
};
export { useSendTestEmail };
+20 -9
View File
@@ -8,6 +8,7 @@ import TabContext from "@mui/lab/TabContext";
import ProfilePanel from "../../Components/TabPanels/Account/ProfilePanel"; import ProfilePanel from "../../Components/TabPanels/Account/ProfilePanel";
import PasswordPanel from "../../Components/TabPanels/Account/PasswordPanel"; import PasswordPanel from "../../Components/TabPanels/Account/PasswordPanel";
import TeamPanel from "../../Components/TabPanels/Account/TeamPanel"; import TeamPanel from "../../Components/TabPanels/Account/TeamPanel";
import { useTranslation } from "react-i18next";
import "./index.css"; import "./index.css";
/** /**
@@ -24,24 +25,34 @@ const Account = ({ open = "profile" }) => {
navigate(`/account/${newTab}`); navigate(`/account/${newTab}`);
}; };
const { user } = useSelector((state) => state.auth); const { user } = useSelector((state) => state.auth);
const { t } = useTranslation();
const requiredRoles = ["superadmin", "admin"]; const requiredRoles = ["superadmin", "admin"];
let tabList = ["Profile", "Password", "Team"]; let tabList = [
{ name: t("menu.profile"), value: "profile" },
{ name: t("menu.password"), value: "password" },
{ name: t("menu.team"), value: "team" }
];
const hideTeams = !requiredRoles.some((role) => user.role.includes(role)); const hideTeams = !requiredRoles.some((role) => user.role.includes(role));
if (hideTeams) { if (hideTeams) {
tabList = ["Profile", "Password"]; tabList = [
{ name: t("menu.profile"), value: "profile" },
{ name: t("menu.password"), value: "password" }
];
} }
// Remove password for demo // Remove password for demo
if (user.role.includes("demo")) { if (user.role.includes("demo")) {
tabList = ["Profile"]; tabList = [
{ name: t("menu.profile"), value: "profile" }
];
} }
const handleKeyDown = (event) => { const handleKeyDown = (event) => {
const currentIndex = tabList.findIndex((label) => label.toLowerCase() === tab); const currentIndex = tabList.findIndex((item) => item.value === tab);
if (event.key === "Tab") { if (event.key === "Tab") {
const nextIndex = (currentIndex + 1) % tabList.length; const nextIndex = (currentIndex + 1) % tabList.length;
setFocusedTab(tabList[nextIndex].toLowerCase()); setFocusedTab(tabList[nextIndex].value);
} else if (event.key === "Enter") { } else if (event.key === "Enter") {
event.preventDefault(); event.preventDefault();
navigate(`/account/${focusedTab}`); navigate(`/account/${focusedTab}`);
@@ -60,13 +71,13 @@ const Account = ({ open = "profile" }) => {
> >
<TabContext value={tab}> <TabContext value={tab}>
<CustomTabList value={tab} onChange={handleTabChange} aria-label="account tabs"> <CustomTabList value={tab} onChange={handleTabChange} aria-label="account tabs">
{tabList.map((label, index) => ( {tabList.map((item, index) => (
<Tab <Tab
label={label} label={item.name}
key={index} key={index}
value={label.toLowerCase()} value={item.value}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
onFocus={() => handleFocus(label.toLowerCase())} onFocus={() => handleFocus(item.value)}
tabIndex={index} tabIndex={index}
/> />
))} ))}
+4 -4
View File
@@ -166,7 +166,7 @@ const ForgotPassword = () => {
</IconBox> </IconBox>
</Stack> </Stack>
<Typography component="h1">{t("authForgotPasswordTitle")}</Typography> <Typography component="h1">{t("authForgotPasswordTitle")}</Typography>
<Typography>No worries, we&apos;ll send you reset instructions.</Typography> <Typography>{t("authForgotPasswordInstructions")}</Typography>
</Box> </Box>
<Box <Box
component="form" component="form"
@@ -179,13 +179,13 @@ const ForgotPassword = () => {
<TextInput <TextInput
type="email" type="email"
id="forgot-password-email-input" id="forgot-password-email-input"
label="Email" label={t("email")}
isRequired={true} isRequired={true}
placeholder="Enter your email" placeholder={t("enterEmail")}
value={form.email} value={form.email}
onChange={handleChange} onChange={handleChange}
error={errors.email ? true : false} error={errors.email ? true : false}
helperText={errors.email} helperText={t(errors.email)}
/> />
<Button <Button
variant="contained" variant="contained"
@@ -71,7 +71,7 @@ function StepTwo({ form, errors, onSubmit, onChange, onBack }) {
helperText={errors.email && ( helperText={errors.email && (
errors.email.includes("required") ? t("authRegisterEmailRequired") : errors.email.includes("required") ? t("authRegisterEmailRequired") :
errors.email.includes("valid email") ? t("authRegisterEmailInvalid") : errors.email.includes("valid email") ? t("authRegisterEmailInvalid") :
errors.email t(errors.email)
)} )}
ref={inputRef} ref={inputRef}
/> />
+4 -1
View File
@@ -11,12 +11,15 @@ import { useState } from "react";
import IncidentTable from "./Components/IncidentTable"; import IncidentTable from "./Components/IncidentTable";
import GenericFallback from "../../Components/GenericFallback"; import GenericFallback from "../../Components/GenericFallback";
import NetworkError from "../../Components/GenericFallback/NetworkError"; import NetworkError from "../../Components/GenericFallback/NetworkError";
import { useTranslation } from "react-i18next";
//Constants //Constants
const BREADCRUMBS = [{ name: `Incidents`, path: "/incidents" }];
const Incidents = () => { const Incidents = () => {
// Redux state // Redux state
const { user } = useSelector((state) => state.auth); const { user } = useSelector((state) => state.auth);
const { t } = useTranslation();
const BREADCRUMBS = [{ name: t("incidentsPageTitle", "Incidents"), path: "/incidents" }];
// Local state // Local state
const [selectedMonitor, setSelectedMonitor] = useState("0"); const [selectedMonitor, setSelectedMonitor] = useState("0");
@@ -68,8 +68,16 @@ const MonitorsTable = ({ shouldRender, monitors, isAdmin, handleActionMenuDelete
), ),
}, },
{ id: "cpu", content: t("cpu"), render: (row) => <CustomGauge progress={row.cpu} /> }, { id: "cpu", content: t("cpu"), render: (row) => <CustomGauge progress={row.cpu} /> },
{ id: "memory", content: t("memory"), render: (row) => <CustomGauge progress={row.mem} /> }, {
{ id: "disk", content: t("disk"), render: (row) => <CustomGauge progress={row.disk} /> }, id: "memory",
content: t("memory"),
render: (row) => <CustomGauge progress={row.mem} />,
},
{
id: "disk",
content: t("disk"),
render: (row) => <CustomGauge progress={row.disk} />,
},
{ {
id: "actions", id: "actions",
content: t("actions"), content: t("actions"),
@@ -129,6 +137,7 @@ const MonitorsTable = ({ shouldRender, monitors, isAdmin, handleActionMenuDelete
}, },
}, },
onRowClick: (row) => openDetails(row.id), onRowClick: (row) => openDetails(row.id),
emptyView: "No monitors found",
}} }}
/> />
); );
@@ -73,7 +73,7 @@ const InfrastructureMonitors = () => {
); );
} }
if (!isLoading && monitors?.length === 0) { if (!isLoading && typeof summary?.totalMonitors === "undefined" ) {
return ( return (
<Fallback <Fallback
vowelStart={true} vowelStart={true}
@@ -0,0 +1,32 @@
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import ConfigBox from "../../Components/ConfigBox";
// Utils
import { useTheme } from "@emotion/react";
import { useTranslation } from "react-i18next";
import Link from "../../Components/Link";
const SettingsAbout = () => {
const theme = useTheme();
const { t } = useTranslation();
return (
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsAbout")}</Typography>
</Box>
<Box>
<Typography component="h2">Checkmate {2.1}</Typography>
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(6), opacity: 0.6 }}>
{t("settingsDevelopedBy")}
</Typography>
<Link
level="secondary"
url="https://github.com/bluewave-labs/checkmate"
label="https://github.com/bluewave-labs/checkmate"
/>
</Box>
</ConfigBox>
);
};
export default SettingsAbout;
@@ -0,0 +1,96 @@
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import ConfigBox from "../../Components/ConfigBox";
// Utils
import { useTheme } from "@emotion/react";
import { PropTypes } from "prop-types";
import { useTranslation } from "react-i18next";
import Dialog from "../../Components/Dialog";
import { useState } from "react";
const SettingsDemoMonitors = ({ isAdmin, HEADER_SX, handleChange, isLoading }) => {
const { t } = useTranslation();
const theme = useTheme();
// Local state
const [isOpen, setIsOpen] = useState(false);
if (!isAdmin) {
return null;
}
return (
<>
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsDemoMonitors")}</Typography>
<Typography sx={HEADER_SX}>{t("settingsDemoMonitorsDescription")}</Typography>
</Box>
<Box>
<Typography>{t("settingsAddDemoMonitors")}</Typography>
<Button
variant="contained"
color="accent"
loading={isLoading}
onClick={() => {
const syntheticEvent = {
target: {
name: "demo",
},
};
handleChange(syntheticEvent);
}}
sx={{ mt: theme.spacing(4) }}
>
{t("settingsAddDemoMonitorsButton")}
</Button>
</Box>
</ConfigBox>
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsSystemReset")}</Typography>
<Typography sx={{ mt: theme.spacing(2) }}>
{t("settingsSystemResetDescription")}
</Typography>
</Box>
<Box>
<Typography>{t("settingsRemoveAllMonitors")}</Typography>
<Button
variant="contained"
color="error"
loading={isLoading}
onClick={() => setIsOpen(true)}
sx={{ mt: theme.spacing(4) }}
>
{t("settingsRemoveAllMonitorsButton")}
</Button>
</Box>
<Dialog
open={isOpen}
theme={theme}
title={t("settingsRemoveAllMonitorsDialogTitle")}
onCancel={() => setIsOpen(false)}
confirmationButtonLabel={t("settingsRemoveAllMonitorsDialogConfirm")}
onConfirm={() => {
const syntheticEvent = {
target: {
name: "deleteMonitors",
},
};
handleChange(syntheticEvent);
setIsOpen(false);
}}
isLoading={isLoading}
/>
</ConfigBox>
</>
);
};
SettingsDemoMonitors.propTypes = {
isAdmin: PropTypes.bool,
handleChange: PropTypes.func,
HEADER_SX: PropTypes.object,
};
export default SettingsDemoMonitors;
+150
View File
@@ -0,0 +1,150 @@
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import ConfigBox from "../../Components/ConfigBox";
import TextInput from "../../Components/Inputs/TextInput";
import Button from "@mui/material/Button";
import Stack from "@mui/material/Stack";
// Utils
import { useTheme } from "@emotion/react";
import { PropTypes } from "prop-types";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { PasswordEndAdornment } from "../../Components/Inputs/TextInput/Adornments";
import { useSendTestEmail } from "../../Hooks/useSendTestEmail";
const SettingsEmail = ({
isAdmin,
HEADER_SX,
handleChange,
settingsData,
setSettingsData,
isPasswordSet,
}) => {
// Setup
const { t } = useTranslation();
const theme = useTheme();
// Local state
const [password, setPassword] = useState("");
const [hasBeenReset, setHasBeenReset] = useState(false);
// Network
const [isSending, error, sendTestEmail] = useSendTestEmail();
// Handlers
const handlePasswordChange = (e) => {
setPassword(e.target.value);
setSettingsData({
...settingsData,
settings: { ...settingsData.settings, systemEmailPassword: e.target.value },
});
};
if (!isAdmin) {
return null;
}
return (
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsEmail")}</Typography>
<Typography sx={HEADER_SX}>{t("settingsEmailDescription")}</Typography>
</Box>
<Box>
<Stack gap={theme.spacing(10)}>
<Box>
<Typography>{t("settingsEmailHost")}</Typography>
<TextInput
name="systemEmailHost"
placeholder="smtp.gmail.com"
value={settingsData?.settings?.systemEmailHost ?? ""}
onChange={handleChange}
/>
</Box>
<Box>
<Typography>{t("settingsEmailPort")}</Typography>
<TextInput
name="systemEmailPort"
placeholder="425"
type="number"
value={settingsData?.settings?.systemEmailPort ?? ""}
onChange={handleChange}
/>
</Box>
<Box>
<Typography>{t("settingsEmailUser")}</Typography>
<TextInput
name="systemEmailUser"
placeholder="Leave empty if not required"
value={settingsData?.settings?.systemEmailUser ?? ""}
onChange={handleChange}
/>
</Box>
<Box>
<Typography>{t("settingsEmailAddress")}</Typography>
<TextInput
name="systemEmailAddress"
placeholder="uptime@bluewavelabs.ca"
value={settingsData?.settings?.systemEmailAddress ?? ""}
onChange={handleChange}
/>
</Box>
{(isPasswordSet === false || hasBeenReset === true) && (
<Box>
<Typography>{t("settingsEmailPassword")}</Typography>
<TextInput
name="systemEmailPassword"
type="password"
placeholder="123 456 789 101112"
value={password}
onChange={handlePasswordChange}
endAdornment={<PasswordEndAdornment />}
/>
</Box>
)}
{isPasswordSet === true && hasBeenReset === false && (
<Box>
<Typography>{t("settingsEmailFieldResetLabel")}</Typography>
<Button
onClick={() => {
setPassword("");
setSettingsData({
...settingsData,
settings: { ...settingsData.settings, systemEmailPassword: "" },
});
setHasBeenReset(true);
}}
variant="contained"
color="error"
sx={{ mt: theme.spacing(4) }}
>
{t("reset")}
</Button>
</Box>
)}
<Box>
<Button
variant="contained"
color="accent"
loading={isSending}
onClick={sendTestEmail}
>
Send test e-mail
</Button>
</Box>
</Stack>
</Box>
</ConfigBox>
);
};
SettingsEmail.propTypes = {
isAdmin: PropTypes.bool,
settingsData: PropTypes.object,
setSettingsData: PropTypes.func,
handleChange: PropTypes.func,
HEADER_SX: PropTypes.object,
isPasswordSet: PropTypes.bool,
};
export default SettingsEmail;
@@ -0,0 +1,93 @@
import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import ConfigBox from "../../Components/ConfigBox";
import TextInput from "../../Components/Inputs/TextInput";
import { PasswordEndAdornment } from "../../Components/Inputs/TextInput/Adornments";
// Utils
import { useTheme } from "@emotion/react";
import { PropTypes } from "prop-types";
import { useState, useEffect } from "react";
import { useTranslation } from "react-i18next";
const SettingsPagespeed = ({
isAdmin,
HEADING_SX,
settingsData,
setSettingsData,
isApiKeySet,
}) => {
const { t } = useTranslation();
const theme = useTheme();
// Local state
const [apiKey, setApiKey] = useState("");
const [hasBeenReset, setHasBeenReset] = useState(false);
// Handler
const handleChange = (e) => {
setApiKey(e.target.value);
setSettingsData({
...settingsData,
settings: { ...settingsData.settings, pagespeedApiKey: e.target.value },
});
};
if (!isAdmin) {
return null;
}
return (
<ConfigBox>
<Box>
<Typography component="h1">{t("pageSpeedApiKeyFieldTitle")}</Typography>
<Typography sx={HEADING_SX}>{t("pageSpeedApiKeyFieldDescription")}</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
{(isApiKeySet === false || hasBeenReset === true) && (
<TextInput
name="pagespeedApiKey"
label={t("pageSpeedApiKeyFieldLabel")}
value={apiKey}
type={"password"}
onChange={handleChange}
optionalLabel="(Optional)"
endAdornment={<PasswordEndAdornment />}
/>
)}
{isApiKeySet === true && hasBeenReset === false && (
<Box>
<Typography>{t("pageSpeedApiKeyFieldResetLabel")}</Typography>
<Button
onClick={() => {
setApiKey("");
setSettingsData({
...settingsData,
settings: { ...settingsData.settings, pagespeedApiKey: "" },
});
setHasBeenReset(true);
}}
variant="contained"
color="error"
sx={{ mt: theme.spacing(4) }}
>
{t("reset")}
</Button>
</Box>
)}
</Stack>
</ConfigBox>
);
};
SettingsPagespeed.propTypes = {
isAdmin: PropTypes.bool,
HEADING_SX: PropTypes.object,
settingsData: PropTypes.object,
setSettingsData: PropTypes.func,
isApiKeySet: PropTypes.bool,
};
export default SettingsPagespeed;
@@ -0,0 +1,90 @@
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import Stack from "@mui/material/Stack";
import ConfigBox from "../../Components/ConfigBox";
import TextInput from "../../Components/Inputs/TextInput";
import Dialog from "../../Components/Dialog";
// Utils
import { useTheme } from "@emotion/react";
import { PropTypes } from "prop-types";
import { useTranslation } from "react-i18next";
import { useState } from "react";
const SettingsStats = ({ isAdmin, HEADING_SX, handleChange, settingsData, errors }) => {
const theme = useTheme();
const { t } = useTranslation();
const [isOpen, setIsOpen] = useState(false);
if (!isAdmin) {
return null;
}
return (
<ConfigBox>
<Box>
<Typography
component="h1"
sx={HEADING_SX}
>
{t("settingsHistoryAndMonitoring")}
</Typography>
<Typography sx={{ mt: theme.spacing(2) }}>
{t("settingsHistoryAndMonitoringDescription")}
</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
<TextInput
name="checkTTL"
label={t("settingsTTLLabel")}
optionalLabel={t("settingsTTLOptionalLabel")}
value={settingsData?.settings?.checkTTL ?? ""}
onChange={handleChange}
type="number"
error={errors.checkTTL ? true : false}
helperText={errors.checkTTL}
/>
<Box>
<Typography>{t("settingsClearAllStats")}</Typography>
<Button
variant="contained"
color="error"
onClick={() => setIsOpen(true)}
sx={{ mt: theme.spacing(4) }}
>
{t("settingsClearAllStatsButton")}
</Button>
</Box>
</Stack>
<Dialog
open={isOpen}
theme={theme}
title={t("settingsClearAllStatsDialogTitle")}
description={t("settingsClearAllStatsDialogDescription")}
onCancel={() => setIsOpen(false)}
confirmationButtonLabel={t("settingsClearAllStatsDialogConfirm")}
onConfirm={() => {
const syntheticEvent = {
target: {
name: "deleteStats",
},
};
handleChange(syntheticEvent);
setIsOpen(false);
}}
isLoading={false}
/>
</ConfigBox>
);
};
SettingsStats.propTypes = {
isAdmin: PropTypes.bool,
HEADING_SX: PropTypes.object,
handleChange: PropTypes.func,
settingsData: PropTypes.object,
errors: PropTypes.object,
};
export default SettingsStats;
@@ -0,0 +1,43 @@
import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import ConfigBox from "../../Components/ConfigBox";
import Select from "../../Components/Inputs/Select";
import timezones from "../../Utils/timezones.json";
// Utils
import { useTheme } from "@emotion/react";
import { PropTypes } from "prop-types";
import { useTranslation } from "react-i18next";
const SettingsTimeZone = ({ HEADING_SX, handleChange, timezone }) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsGeneralSettings")}</Typography>
<Typography sx={HEADING_SX}>
<Typography component="span">{t("settingsDisplayTimezone")}</Typography>-{" "}
{t("settingsDisplayTimezoneDescription")}
</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
<Select
label={t("settingsDisplayTimezone")}
name="timezone"
value={timezone}
onChange={handleChange}
items={timezones}
/>
</Stack>
</ConfigBox>
);
};
SettingsTimeZone.propTypes = {
HEADING_SX: PropTypes.object,
handleChange: PropTypes.func,
timezone: PropTypes.string,
};
export default SettingsTimeZone;
+52
View File
@@ -0,0 +1,52 @@
import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import ConfigBox from "../../Components/ConfigBox";
import Select from "../../Components/Inputs/Select";
// Utils
import { useTheme } from "@emotion/react";
import { PropTypes } from "prop-types";
import { useTranslation } from "react-i18next";
const SettingsUI = ({ HEADING_SX, handleChange, mode, language }) => {
const { t, i18n } = useTranslation();
const theme = useTheme();
const languages = Object.keys(i18n.options.resources || {});
return (
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsAppearance")}</Typography>
<Typography sx={HEADING_SX}>{t("settingsAppearanceDescription")}</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
<Select
name="mode"
label={t("settingsThemeMode")}
value={mode}
onChange={handleChange}
items={[
{ _id: "light", name: "Light" },
{ _id: "dark", name: "Dark" },
]}
></Select>
<Select
name="language"
label={t("settingsLanguage")}
value={language}
onChange={handleChange}
items={languages.map((lang) => ({ _id: lang, name: lang.toUpperCase() }))}
></Select>
</Stack>
</ConfigBox>
);
};
SettingsUI.propTypes = {
HEADING_SX: PropTypes.object,
handleChange: PropTypes.func,
mode: PropTypes.string,
language: PropTypes.string,
};
export default SettingsUI;
+128 -435
View File
@@ -1,116 +1,72 @@
// Components import Stack from "@mui/material/Stack";
import { Box, Stack, Typography, Button } from "@mui/material"; import Typography from "@mui/material/Typography";
import TextInput from "../../Components/Inputs/TextInput"; import Breadcrumbs from "../../Components/Breadcrumbs";
import Link from "../../Components/Link"; import SettingsTimeZone from "./SettingsTimeZone";
import Select from "../../Components/Inputs/Select"; import SettingsUI from "./SettingsUI";
import { useIsAdmin } from "../../Hooks/useIsAdmin"; import SettingsPagespeed from "./SettingsPagespeed";
import Dialog from "../../Components/Dialog"; import SettingsDemoMonitors from "./SettingsDemoMonitors";
import ConfigBox from "../../Components/ConfigBox"; import SettingsAbout from "./SettingsAbout";
import { PasswordEndAdornment } from "../../Components/Inputs/TextInput/Adornments"; import SettingsEmail from "./SettingsEmail";
import { getAppSettings } from "../../Features/Settings/settingsSlice"; import Button from "@mui/material/Button";
// import { // Utils
// WalletMultiButton, import { settingsValidation } from "../../Validation/validation";
// WalletDisconnectButton,
// } from "@solana/wallet-adapter-react-ui";
//Utils
import { useTheme } from "@emotion/react";
import { logger } from "../../Utils/Logger";
import { useDispatch, useSelector } from "react-redux";
import { createToast } from "../../Utils/toastUtils"; import { createToast } from "../../Utils/toastUtils";
import { useState } from "react";
import { useTheme } from "@emotion/react";
import { useTranslation } from "react-i18next";
import { useSelector, useDispatch } from "react-redux";
import { setTimezone, setMode, setLanguage } from "../../Features/UI/uiSlice";
import SettingsStats from "./SettingsStats";
import { import {
deleteMonitorChecksByTeamId, deleteMonitorChecksByTeamId,
addDemoMonitors, addDemoMonitors,
deleteAllMonitors, deleteAllMonitors,
} from "../../Features/UptimeMonitors/uptimeMonitorsSlice"; } from "../../Features/UptimeMonitors/uptimeMonitorsSlice";
import { update } from "../../Features/Auth/authSlice"; import { useFetchSettings, useSaveSettings } from "../../Hooks/useFetchSettings";
import PropTypes from "prop-types"; import { UseDeleteMonitorStats } from "../../Hooks/useDeleteMonitorStats";
import { setTimezone, setMode, setLanguage } from "../../Features/UI/uiSlice"; import { useIsAdmin } from "../../Hooks/useIsAdmin";
import timezones from "../../Utils/timezones.json";
import { useState, useEffect } from "react";
import { networkService } from "../../main";
import { settingsValidation } from "../../Validation/validation";
import { updateAppSettings } from "../../Features/Settings/settingsSlice";
import { useTranslation } from "react-i18next";
// Constants // Constants
const SECONDS_PER_DAY = 86400; const BREADCRUMBS = [{ name: `Settings`, path: "/settings" }];
const Settings = () => { const Settings = () => {
const theme = useTheme(); // Redux state
const { t, i18n } = useTranslation(); const { mode, language, timezone } = useSelector((state) => state.ui);
const isAdmin = useIsAdmin();
const { user } = useSelector((state) => state.auth); const { user } = useSelector((state) => state.auth);
const { language } = useSelector((state) => state.ui);
const { checkTTL } = user; // Local state
const { isLoading } = useSelector((state) => state.uptimeMonitors); const [settingsData, setSettingsData] = useState({});
const { isLoading: authIsLoading } = useSelector((state) => state.auth); const [errors, setErrors] = useState({});
const { timezone, distributedUptimeEnabled } = useSelector((state) => state.ui);
const { mode } = useSelector((state) => state.ui); // Network
const { pagespeedApiKey } = useSelector((state) => state.settings); const [isSettingsLoading, settingsError] = useFetchSettings({
const [checksIsLoading, setChecksIsLoading] = useState(false); setSettingsData,
const [form, setForm] = useState({
enableDistributedUptime: distributedUptimeEnabled,
ttl: checkTTL ? (checkTTL / SECONDS_PER_DAY).toString() : 0,
pagespeedApiKey: pagespeedApiKey,
}); });
const [version, setVersion] = useState("unknown"); const [isSaving, saveError, saveSettings] = useSaveSettings();
const [apiKeyFieldType, setApiKeyFieldType] = useState("password"); const [deleteMonitorStats, isDeletingMonitorStats] = UseDeleteMonitorStats();
const [isApiKeySet, setIsApiKeySet] = useState(pagespeedApiKey ? true : false);
const [tempPSKey, setTempPSKey] = useState(""); // Setup
const [errors, setErrors] = useState({}); const isAdmin = useIsAdmin();
const deleteStatsMonitorsInitState = { deleteMonitors: false, deleteStats: false }; const theme = useTheme();
const [isOpen, setIsOpen] = useState(deleteStatsMonitorsInitState); const HEADING_SX = { mt: theme.spacing(2), mb: theme.spacing(2) };
const { t, i18n } = useTranslation();
const dispatch = useDispatch(); const dispatch = useDispatch();
//Fetching latest release version from github // Handlers
useEffect(() => { const handleChange = async (e) => {
const fetchLatestVersion = async () => { const { name, value } = e.target;
let version = "unknown";
try { // Build next state early
const response = await networkService.fetchGithubLatestRelease(); const newSettingsData = {
if (!response.status === 200) { ...settingsData,
throw new Error("Failed to fetch latest version"); settings: { ...settingsData.settings, [name]: value },
}
version = response.data.tag_name;
} catch (error) {
createToast({ body: error.message || "Error fetching latest version" }); // Set error message
} finally {
setVersion(version);
}
}; };
fetchLatestVersion();
}, []);
useEffect(() => {
dispatch(getAppSettings());
}, [dispatch]);
const handleChange = (event) => {
const { type, checked, value, id } = event.target;
if (type === "checkbox") {
setForm((prev) => ({
...prev,
[id]: checked,
}));
return;
}
if (id === "pagespeedApiKey") {
setTempPSKey(value);
return;
}
let inputValue = value;
if (id === "ttl") {
inputValue = value.replace(/[^0-9]/g, "");
}
const updatedForm = { ...form, [id]: inputValue };
const { error } = settingsValidation.validate(updatedForm, { abortEarly: false });
// Validate
const { error } = settingsValidation.validate(newSettingsData.settings, {
abortEarly: false,
});
if (!error || error.details.length === 0) { if (!error || error.details.length === 0) {
setErrors({}); setErrors({});
} else { } else {
@@ -119,62 +75,27 @@ const Settings = () => {
newErrors[err.path[0]] = err.message; newErrors[err.path[0]] = err.message;
}); });
setErrors(newErrors); setErrors(newErrors);
logger.error("Validation errors:", error.details);
} }
setForm(updatedForm); if (name === "timezone") {
}; dispatch(setTimezone({ timezone: value }));
// TODO Handle saving
const handleSave = async () => {
try {
setChecksIsLoading(true);
await networkService.updateChecksTTL({
ttl: form.ttl,
});
const updatedUser = { ...user, checkTTL: form.ttl };
const [userAction, settingsAction] = await Promise.all([
dispatch(update({ localData: updatedUser })),
dispatch(
updateAppSettings({
settings: {
language: language,
pagespeedApiKey: tempPSKey ? tempPSKey : form.pagespeedApiKey,
},
})
),
]);
if (userAction.payload.success && settingsAction.payload.success) {
createToast({ body: t("settingsSuccessSaved") });
} else {
throw new Error("Failed to save settings");
} }
} catch (error) {
createToast({ body: t("settingsFailedToSave") });
} finally {
setChecksIsLoading(false);
}
};
const handleClearStats = async () => { if (name === "mode") {
try { dispatch(setMode(value));
const action = await dispatch(deleteMonitorChecksByTeamId({ teamId: user.teamId }));
if (deleteMonitorChecksByTeamId.fulfilled.match(action)) {
createToast({ body: t("settingsStatsCleared") });
} else {
createToast({ body: t("settingsFailedToClearStats") });
} }
} catch (error) {
logger.error(error);
createToast({ body: t("settingsFailedToClearStats") });
} finally {
setIsOpen(deleteStatsMonitorsInitState);
}
};
const handleInsertDemoMonitors = async () => { if (name === "language") {
dispatch(setLanguage(value));
i18n.changeLanguage(value);
}
if (name === "deleteStats") {
await deleteMonitorStats({ teamId: user.teamId });
return;
}
if (name === "demo") {
try { try {
const action = await dispatch(addDemoMonitors()); const action = await dispatch(addDemoMonitors());
if (addDemoMonitors.fulfilled.match(action)) { if (addDemoMonitors.fulfilled.match(action)) {
@@ -183,12 +104,12 @@ const Settings = () => {
createToast({ body: t("settingsFailedToAddDemoMonitors") }); createToast({ body: t("settingsFailedToAddDemoMonitors") });
} }
} catch (error) { } catch (error) {
logger.error(error); createToast({ body: t("settingsFailedToAddDemoMonitors") });
createToast({ Body: t("settingsFailedToAddDemoMonitors") }); }
return;
} }
};
const handleDeleteAllMonitors = async () => { if (name === "deleteMonitors") {
try { try {
const action = await dispatch(deleteAllMonitors()); const action = await dispatch(deleteAllMonitors());
if (deleteAllMonitors.fulfilled.match(action)) { if (deleteAllMonitors.fulfilled.match(action)) {
@@ -197,304 +118,80 @@ const Settings = () => {
createToast({ body: t("settingsFailedToDeleteMonitors") }); createToast({ body: t("settingsFailedToDeleteMonitors") });
} }
} catch (error) { } catch (error) {
logger.error(error); createToast({ body: t("settingsFailedToDeleteMonitors") });
createToast({ Body: t("settingsFailedToDeleteMonitors") });
} finally {
setIsOpen(deleteStatsMonitorsInitState);
} }
return;
}
setSettingsData(newSettingsData);
}; };
const handleResetApiKey = () => { const handleSave = () => {
setIsApiKeySet(false); const { error } = settingsValidation.validate(settingsData.settings, {
setForm((prev) => ({ abortEarly: false,
...prev, });
pagespeedApiKey: "", if (!error || error.details.length === 0) {
})); setErrors({});
} else {
const newErrors = {};
error.details.forEach((err) => {
newErrors[err.path[0]] = err.message;
});
setErrors(newErrors);
}
saveSettings(settingsData?.settings);
}; };
const languages = Object.keys(i18n.options.resources || {});
return ( return (
<Box <Stack gap={theme.spacing(10)}>
className="settings" <Breadcrumbs list={BREADCRUMBS} />
style={{ <Typography variant="h1">Settings</Typography>
paddingBottom: 0, <SettingsTimeZone
}} HEADING_SX={HEADING_SX}
> handleChange={handleChange}
<Stack timezone={timezone}
component="form"
gap={theme.spacing(12)}
noValidate
spellCheck="false"
>
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsGeneralSettings")}</Typography>
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(2) }}>
<Typography component="span">{t("settingsDisplayTimezone")}</Typography>-{" "}
{t("settingsDisplayTimezoneDescription")}
</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
<Select
id="display-timezones"
label={t("settingsDisplayTimezone")}
value={timezone}
onChange={(e) => {
dispatch(setTimezone({ timezone: e.target.value }));
}}
items={timezones}
/> />
</Stack> <SettingsUI
</ConfigBox> HEADING_SX={HEADING_SX}
<ConfigBox> handleChange={handleChange}
<Box> mode={mode}
<Typography component="h1">{t("settingsAppearance")}</Typography> language={language}
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(2) }}>
{t("settingsAppearanceDescription")}
</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
<Select
id="theme-mode"
label={t("settingsThemeMode")}
value={mode}
onChange={(e) => {
dispatch(setMode(e.target.value));
}}
items={[
{ _id: "light", name: "Light" },
{ _id: "dark", name: "Dark" },
]}
></Select>
<Select
id="language"
label={t("settingsLanguage")}
value={language}
onChange={(e) => {
dispatch(setLanguage(e.target.value));
i18n.changeLanguage(e.target.value);
}}
items={languages.map((lang) => ({ _id: lang, name: lang.toUpperCase() }))}
></Select>
</Stack>
</ConfigBox>
{/* {isAdmin && (
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsDistributedUptime")}</Typography>
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(2) }}>
{t("settingsDistributedUptimeDescription")}
</Typography>
</Box>
<Box>
<Switch
id="enableDistributedUptime"
color="accent"
checked={distributedUptimeEnabled}
onChange={(e) => {
dispatch(setDistributedUptimeEnabled(e.target.checked));
}}
/> />
{distributedUptimeEnabled === true <SettingsPagespeed
? t("settingsEnabled") isAdmin={isAdmin}
: t("settingsDisabled")} HEADING_SX={HEADING_SX}
</Box> settingsData={settingsData}
</ConfigBox> setSettingsData={setSettingsData}
)} */} isApiKeySet={settingsData?.pagespeedKeySet ?? false}
<ConfigBox>
<Box>
<Typography component="h1">{t("pageSpeedApiKeyFieldTitle")}</Typography>
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(2) }}>
{t("pageSpeedApiKeyFieldDescription")}
</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
<TextInput
id="pagespeedApiKey"
label={t("pageSpeedApiKeyFieldLabel")}
value={form.pagespeedApiKey ? form.pagespeedApiKey : tempPSKey}
type={apiKeyFieldType}
onChange={handleChange}
disabled={isApiKeySet}
optionalLabel="(Optional)"
error={!!errors.pagespeedApiKey}
helperText={errors.pagespeedApiKey}
endAdornment={
!isApiKeySet && (
<PasswordEndAdornment
fieldType={apiKeyFieldType}
setFieldType={setApiKeyFieldType}
/> />
) <SettingsStats
} isAdmin={isAdmin}
HEADING_SX={HEADING_SX}
settingsData={settingsData}
handleChange={handleChange}
errors={errors}
/> />
{isApiKeySet && ( <SettingsDemoMonitors
<Box> isAdmin={isAdmin}
<Typography>{t("pageSpeedApiKeyFieldResetLabel")}</Typography> HEADER_SX={HEADING_SX}
<Button handleChange={handleChange}
onClick={handleResetApiKey} isLoading={isSettingsLoading || isSaving || isDeletingMonitorStats}
variant="contained"
color="error"
sx={{ mt: theme.spacing(4) }}
>
{t("reset")}
</Button>
</Box>
)}
</Stack>
</ConfigBox>
{/* {isAdmin && (
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsWallet")}</Typography>
<Typography sx={{ mt: theme.spacing(2) }}>
{t("settingsWalletDescription")}
</Typography>
</Box>
<Box
sx={{
display: "flex",
flexWrap: "wrap",
justifyContent: "flex-start",
gap: 2,
}}
>
<Stack
direction="row"
spacing={2}
>
<WalletMultiButton />
<WalletDisconnectButton />
</Stack>
</Box>
</ConfigBox>
)} */}
{isAdmin && (
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsHistoryAndMonitoring")}</Typography>
<Typography sx={{ mt: theme.spacing(2) }}>
{t("settingsHistoryAndMonitoringDescription")}
</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
<TextInput
id="ttl"
label={t("settingsTTLLabel")}
optionalLabel={t("settingsTTLOptionalLabel")}
value={form.ttl}
onChange={handleChange}
error={errors.ttl ? true : false}
helperText={errors.ttl}
/> />
<Box> <SettingsEmail
<Typography>{t("settingsClearAllStats")}</Typography> isAdmin={isAdmin}
<Button HEADER_SX={HEADING_SX}
variant="contained" handleChange={handleChange}
color="error" settingsData={settingsData}
onClick={() => setSettingsData={setSettingsData}
setIsOpen({ ...deleteStatsMonitorsInitState, deleteStats: true }) isPasswordSet={settingsData?.emailPasswordSet ?? false}
}
sx={{ mt: theme.spacing(4) }}
>
{t("settingsClearAllStatsButton")}
</Button>
</Box>
</Stack>
<Dialog
open={isOpen.deleteStats}
theme={theme}
title={t("settingsClearAllStatsDialogTitle")}
description={t("settingsClearAllStatsDialogDescription")}
onCancel={() => setIsOpen(deleteStatsMonitorsInitState)}
confirmationButtonLabel={t("settingsClearAllStatsDialogConfirm")}
onConfirm={handleClearStats}
isLoading={isLoading || authIsLoading || checksIsLoading}
/> />
</ConfigBox> <SettingsAbout />
)}
{isAdmin && (
<>
{/* Demo Monitors Section */}
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsDemoMonitors")}</Typography>
<Typography sx={{ mt: theme.spacing(2) }}>
{t("settingsDemoMonitorsDescription")}
</Typography>
</Box>
<Box>
<Typography>{t("settingsAddDemoMonitors")}</Typography>
<Button
variant="contained"
color="accent"
loading={isLoading || authIsLoading || checksIsLoading}
onClick={handleInsertDemoMonitors}
sx={{ mt: theme.spacing(4) }}
>
{t("settingsAddDemoMonitorsButton")}
</Button>
</Box>
</ConfigBox>
{/* System Reset Section */}
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsSystemReset")}</Typography>
<Typography sx={{ mt: theme.spacing(2) }}>
{t("settingsSystemResetDescription")}
</Typography>
</Box>
<Box>
<Typography>{t("settingsRemoveAllMonitors")}</Typography>
<Button
variant="contained"
color="error"
loading={isLoading || authIsLoading || checksIsLoading}
onClick={() =>
setIsOpen({ ...deleteStatsMonitorsInitState, deleteMonitors: true })
}
sx={{ mt: theme.spacing(4) }}
>
{t("settingsRemoveAllMonitorsButton")}
</Button>
</Box>
<Dialog
open={isOpen.deleteMonitors}
theme={theme}
title={t("settingsRemoveAllMonitorsDialogTitle")}
onCancel={() => setIsOpen(deleteStatsMonitorsInitState)}
confirmationButtonLabel={t("settingsRemoveAllMonitorsDialogConfirm")}
onConfirm={handleDeleteAllMonitors}
isLoading={isLoading || authIsLoading || checksIsLoading}
/>
</ConfigBox>
</>
)}
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsAbout")}</Typography>
</Box>
<Box>
<Typography component="h2">Checkmate {version}</Typography>
<Typography sx={{ mt: theme.spacing(2), mb: theme.spacing(6), opacity: 0.6 }}>
{t("settingsDevelopedBy")}
</Typography>
<Link
level="secondary"
url="https://github.com/bluewave-labs/checkmate"
label="https://github.com/bluewave-labs/checkmate"
/>
</Box>
</ConfigBox>
<Stack <Stack
direction="row" direction="row"
justifyContent="flex-end" justifyContent="flex-end"
> >
<Button <Button
loading={isLoading || authIsLoading || checksIsLoading} loading={isSaving || isDeletingMonitorStats || isSettingsLoading}
disabled={Object.keys(errors).length > 0} disabled={Object.keys(errors).length > 0}
variant="contained" variant="contained"
color="accent" color="accent"
@@ -505,11 +202,7 @@ const Settings = () => {
</Button> </Button>
</Stack> </Stack>
</Stack> </Stack>
</Box>
); );
}; };
Settings.propTypes = {
isAdmin: PropTypes.bool,
};
export default Settings; export default Settings;
+4 -1
View File
@@ -420,7 +420,9 @@ const Configure = () => {
</ConfigBox> </ConfigBox>
<ConfigBox> <ConfigBox>
<Box> <Box>
<Typography component="h2">{t("distributedUptimeCreateIncidentNotification")}</Typography> <Typography component="h2">
{t("distributedUptimeCreateIncidentNotification")}
</Typography>
<Typography component="p"> <Typography component="p">
{t("distributedUptimeCreateIncidentDescription")} {t("distributedUptimeCreateIncidentDescription")}
</Typography> </Typography>
@@ -491,6 +493,7 @@ const Configure = () => {
</Box> </Box>
<Stack> <Stack>
<FormControlLabel <FormControlLabel
sx={{ marginLeft: 0 }}
control={ control={
<Switch <Switch
name="ignore-error" name="ignore-error"
+1
View File
@@ -422,6 +422,7 @@ const CreateMonitor = () => {
</Box> </Box>
<Stack> <Stack>
<FormControlLabel <FormControlLabel
sx={{ marginLeft: 0 }}
control={ control={
<Switch <Switch
name="ignore-error" name="ignore-error"
@@ -27,22 +27,14 @@ import { useTranslation } from "react-i18next";
* @returns {JSX.Element} The rendered Filter component. * @returns {JSX.Element} The rendered Filter component.
*/ */
const typeOptions = [ const getTypeOptions = () => [
{ value: "http", label: "HTTP(S)" }, { value: "http", label: "HTTP(S)" },
{ value: "ping", label: "Ping" }, { value: "ping", label: "Ping" },
{ value: "docker", label: "Docker" }, { value: "docker", label: "Docker" },
{ value: "port", label: "Port" }, { value: "port", label: "Port" },
]; ];
const statusOptions = [ // These functions were moved inline to ensure translations are applied correctly
{ value: "Up", label: "Up" },
{ value: "Down", label: "Down" },
];
const stateOptions = [
{ value: "Active", label: "Active" },
{ value: "Paused", label: "Paused" },
];
const Filter = ({ const Filter = ({
selectedTypes, selectedTypes,
@@ -58,6 +50,18 @@ const Filter = ({
const theme = useTheme(); const theme = useTheme();
const { t } = useTranslation(); const { t } = useTranslation();
const typeOptions = getTypeOptions();
// Create status options with translations
const statusOptions = [
{ value: "Up", label: t("monitorStatus.up") },
{ value: "Down", label: t("monitorStatus.down") },
];
// Create state options with translations
const stateOptions = [
{ value: "Active", label: t("monitorState.active") },
{ value: "Paused", label: t("monitorState.paused") },
];
const handleTypeChange = (event) => { const handleTypeChange = (event) => {
const selectedValues = event.target.value; const selectedValues = event.target.value;
setSelectedTypes(selectedValues.length > 0 ? selectedValues : undefined); setSelectedTypes(selectedValues.length > 0 ? selectedValues : undefined);
@@ -2,10 +2,12 @@ import PropTypes from "prop-types";
import { Stack } from "@mui/material"; import { Stack } from "@mui/material";
import StatusBox from "./statusBox"; import StatusBox from "./statusBox";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { useTranslation } from "react-i18next";
import SkeletonLayout from "./skeleton"; import SkeletonLayout from "./skeleton";
const StatusBoxes = ({ shouldRender, monitorsSummary }) => { const StatusBoxes = ({ shouldRender, monitorsSummary }) => {
const theme = useTheme(); const theme = useTheme();
const { t } = useTranslation();
if (!shouldRender) return <SkeletonLayout shouldRender={shouldRender} />; if (!shouldRender) return <SkeletonLayout shouldRender={shouldRender} />;
return ( return (
<Stack <Stack
@@ -14,15 +16,15 @@ const StatusBoxes = ({ shouldRender, monitorsSummary }) => {
justifyContent="space-between" justifyContent="space-between"
> >
<StatusBox <StatusBox
title="up" title={t("monitorStatus.up")}
value={monitorsSummary?.upMonitors ?? 0} value={monitorsSummary?.upMonitors ?? 0}
/> />
<StatusBox <StatusBox
title="down" title={t("monitorStatus.down")}
value={monitorsSummary?.downMonitors ?? 0} value={monitorsSummary?.downMonitors ?? 0}
/> />
<StatusBox <StatusBox
title="paused" title={t("monitorStatus.paused")}
value={monitorsSummary?.pausedMonitors ?? 0} value={monitorsSummary?.pausedMonitors ?? 0}
/> />
</Stack> </Stack>
@@ -31,6 +33,7 @@ const StatusBoxes = ({ shouldRender, monitorsSummary }) => {
StatusBoxes.propTypes = { StatusBoxes.propTypes = {
monitorsSummary: PropTypes.object, monitorsSummary: PropTypes.object,
shouldRender: PropTypes.bool,
}; };
export default StatusBoxes; export default StatusBoxes;
+5 -2
View File
@@ -31,11 +31,11 @@ import PropTypes from "prop-types";
import useFetchMonitorsWithSummary from "../../../Hooks/useFetchMonitorsWithSummary"; import useFetchMonitorsWithSummary from "../../../Hooks/useFetchMonitorsWithSummary";
import useFetchMonitorsWithChecks from "../../../Hooks/useFetchMonitorsWithChecks"; import useFetchMonitorsWithChecks from "../../../Hooks/useFetchMonitorsWithChecks";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
const BREADCRUMBS = [{ name: `Uptime`, path: "/uptime" }];
const TYPES = ["http", "ping", "docker", "port"]; const TYPES = ["http", "ping", "docker", "port"];
const CreateMonitorButton = ({ shouldRender }) => { const CreateMonitorButton = ({ shouldRender }) => {
// Utils // Utils
const navigate = useNavigate(); const navigate = useNavigate();
const { t } = useTranslation();
if (shouldRender === false) { if (shouldRender === false) {
return; return;
} }
@@ -49,7 +49,7 @@ const CreateMonitorButton = ({ shouldRender }) => {
navigate("/uptime/create"); navigate("/uptime/create");
}} }}
> >
Create new {t("createNew")}
</Button> </Button>
</Box> </Box>
); );
@@ -78,10 +78,13 @@ const UptimeMonitors = () => {
// Utils // Utils
const theme = useTheme(); const theme = useTheme();
const navigate = useNavigate();
const isAdmin = useIsAdmin(); const isAdmin = useIsAdmin();
const dispatch = useDispatch(); const dispatch = useDispatch();
const { t } = useTranslation(); const { t } = useTranslation();
const BREADCRUMBS = [{ name: t("menu.uptime"), path: "/uptime" }];
// Handlers // Handlers
const handleChangePage = (event, newPage) => { const handleChangePage = (event, newPage) => {
setPage(newPage); setPage(newPage);
+8
View File
@@ -1152,6 +1152,14 @@ class NetworkService {
} }
); );
} }
// ************************************
// Send tes t email
// ************************************
async sendTestEmail(config) {
const { to } = config;
return this.axiosInstance.post(`/monitors/test-email`, { to });
}
} }
export default NetworkService; export default NetworkService;
+2 -2
View File
@@ -9,7 +9,7 @@ const shadow =
const baseTheme = (palette) => ({ const baseTheme = (palette) => ({
typography: { typography: {
fontFamily: fontFamilyPrimary, fontFamily: fontFamilyPrimary,
fontSize: 14, fontSize: typographyLevels.base,
h1: { h1: {
fontSize: typographyLevels.xl, fontSize: typographyLevels.xl,
color: palette.primary.contrastText, color: palette.primary.contrastText,
@@ -253,6 +253,7 @@ const baseTheme = (palette) => ({
MuiTableCell: { MuiTableCell: {
styleOverrides: { styleOverrides: {
root: ({ theme }) => ({ root: ({ theme }) => ({
fontSize: typographyLevels.base,
borderBottomColor: theme.palette.primary.lowContrast, borderBottomColor: theme.palette.primary.lowContrast,
}), }),
}, },
@@ -376,7 +377,6 @@ const baseTheme = (palette) => ({
MuiTab: { MuiTab: {
styleOverrides: { styleOverrides: {
root: ({ theme }) => ({ root: ({ theme }) => ({
fontSize: theme.typography.fontSize - 1,
color: theme.palette.tertiary.contrastText, color: theme.palette.tertiary.contrastText,
height: "34px", height: "34px",
minHeight: "34px", minHeight: "34px",
+5 -3
View File
@@ -3,6 +3,7 @@ import { useTheme } from "@emotion/react";
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { useEffect } from "react"; import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { setGreeting } from "../Features/UI/uiSlice"; import { setGreeting } from "../Features/UI/uiSlice";
const early = [ const early = [
@@ -133,6 +134,7 @@ const evening = [
const Greeting = ({ type = "" }) => { const Greeting = ({ type = "" }) => {
const theme = useTheme(); const theme = useTheme();
const dispatch = useDispatch(); const dispatch = useDispatch();
const { t } = useTranslation();
const { firstName } = useSelector((state) => state.auth.user); const { firstName } = useSelector((state) => state.auth.user);
const index = useSelector((state) => state.ui.greeting.index); const index = useSelector((state) => state.ui.greeting.index);
const lastUpdate = useSelector((state) => state.ui.greeting.lastUpdate); const lastUpdate = useSelector((state) => state.ui.greeting.lastUpdate);
@@ -147,7 +149,7 @@ const Greeting = ({ type = "" }) => {
let random = Math.floor(Math.random() * 5); let random = Math.floor(Math.random() * 5);
dispatch(setGreeting({ index: random, lastUpdate: hour })); dispatch(setGreeting({ index: random, lastUpdate: hour }));
} }
}, [dispatch, hour]); }, [dispatch, hour, lastUpdate]);
let greetingArray = let greetingArray =
hour < 6 ? early : hour < 12 ? morning : hour < 18 ? afternoon : evening; hour < 6 ? early : hour < 12 ? morning : hour < 18 ? afternoon : evening;
@@ -165,7 +167,7 @@ const Greeting = ({ type = "" }) => {
fontSize="inherit" fontSize="inherit"
color={theme.palette.primary.contrastTextTertiary} color={theme.palette.primary.contrastTextTertiary}
> >
{prepend},{" "} {t("greeting.prepend", { defaultValue: prepend })}, {" "}
</Typography> </Typography>
<Typography <Typography
component="span" component="span"
@@ -181,7 +183,7 @@ const Greeting = ({ type = "" }) => {
lineHeight={1} lineHeight={1}
color={theme.palette.primary.contrastTextTertiary} color={theme.palette.primary.contrastTextTertiary}
> >
{append} — Here’s an overview of your {type} monitors. {t("greeting.append", { defaultValue: append })} — {t("greeting.overview", { type: t(`menu.${type}`) })}
</Typography> </Typography>
</Box> </Box>
); );
+31 -10
View File
@@ -11,7 +11,19 @@ const nameSchema = joi
.messages({ .messages({
"string.empty": "Name is required", "string.empty": "Name is required",
"string.max": "Name must be less than 50 characters", "string.max": "Name must be less than 50 characters",
"string.pattern.base": "Name must contain only letters, spaces, apostrophes, or hyphens" "string.pattern.base":
"Name must contain only letters, spaces, apostrophes, or hyphens",
});
const lastnameSchema = joi
.string()
.max(50)
.trim()
.pattern(/^[\p{L}\p{M}''\- ]+$/u)
.messages({
"string.empty": "Surname is required",
"string.max": "Surname must be less than 50 characters",
"string.pattern.base": "Surname must contain only letters, spaces, apostrophes, or hyphens"
}); });
const passwordSchema = joi const passwordSchema = joi
@@ -53,7 +65,7 @@ const passwordSchema = joi
const credentials = joi.object({ const credentials = joi.object({
firstName: nameSchema, firstName: nameSchema,
lastName: nameSchema, lastName: lastnameSchema,
email: joi email: joi
.string() .string()
.trim() .trim()
@@ -152,7 +164,8 @@ const monitorValidation = joi.object({
"string.invalidUrl": "Please enter a valid URL with optional port", "string.invalidUrl": "Please enter a valid URL with optional port",
"string.pattern.base": "Please enter a valid container ID.", "string.pattern.base": "Please enter a valid container ID.",
}), }),
port: joi.number() port: joi
.number()
.integer() .integer()
.min(1) .min(1)
.max(65535) .max(65535)
@@ -253,14 +266,19 @@ const statusPageValidation = joi.object({
showCharts: joi.boolean(), showCharts: joi.boolean(),
}); });
const settingsValidation = joi.object({ const settingsValidation = joi.object({
ttl: joi.number().required().messages({ checkTTL: joi.number().required().messages({
"string.empty": "Please enter a value", "string.empty": "Please enter a value",
"number.base": "Please enter a valid number", "number.base": "Please enter a valid number",
"any.required": "Please enter a value" "any.required": "Please enter a value",
}), }),
pagespeedApiKey: joi.string().allow("").optional(), pagespeedApiKey: joi.string().allow("").optional(),
}) language: joi.string().required(),
.unknown(true); systemEmailHost: joi.string().allow(""),
systemEmailPort: joi.number().allow(null, ""),
systemEmailAddress: joi.string().allow(""),
systemEmailPassword: joi.string().allow(""),
systemEmailUser: joi.string().allow(""),
});
const dayjsValidator = (value, helpers) => { const dayjsValidator = (value, helpers) => {
if (!dayjs(value).isValid()) { if (!dayjs(value).isValid()) {
@@ -363,9 +381,12 @@ const infrastructureMonitorValidation = joi.object({
notifications: joi.array().items( notifications: joi.array().items(
joi.object({ joi.object({
type: joi.string().valid("email").required(), type: joi.string().valid("email").required(),
address: joi.string().email({ tlds: { allow: false } }).required(), address: joi
.string()
.email({ tlds: { allow: false } })
.required(),
}) })
) ),
}); });
export { export {
@@ -377,5 +398,5 @@ export {
advancedSettingsValidation, advancedSettingsValidation,
infrastructureMonitorValidation, infrastructureMonitorValidation,
statusPageValidation, statusPageValidation,
logoImageValidation logoImageValidation,
}; };
+98 -3
View File
@@ -16,6 +16,7 @@
"commonBack": "Back", "commonBack": "Back",
"authForgotPasswordTitle": "Forgot password?", "authForgotPasswordTitle": "Forgot password?",
"authForgotPasswordResetPassword": "Reset password", "authForgotPasswordResetPassword": "Reset password",
"authForgotPasswordInstructions": "No worries, we'll send you reset instructions.",
"createPassword": "Create your password", "createPassword": "Create your password",
"createAPassword": "Password", "createAPassword": "Password",
"authRegisterAlreadyHaveAccount": "Already have an account?", "authRegisterAlreadyHaveAccount": "Already have an account?",
@@ -71,6 +72,8 @@
"settingsAppearance": "Appearance", "settingsAppearance": "Appearance",
"settingsAppearanceDescription": "Switch between light and dark mode, or change user interface language", "settingsAppearanceDescription": "Switch between light and dark mode, or change user interface language",
"settingsThemeMode": "Theme Mode", "settingsThemeMode": "Theme Mode",
"settingsThemeModeLight": "Light",
"settingsThemeModeDark": "Dark",
"settingsLanguage": "Language", "settingsLanguage": "Language",
"settingsDistributedUptime": "Distributed uptime", "settingsDistributedUptime": "Distributed uptime",
"settingsDistributedUptimeDescription": "Enable/disable distributed uptime monitoring.", "settingsDistributedUptimeDescription": "Enable/disable distributed uptime monitoring.",
@@ -85,6 +88,7 @@
"settingsClearAllStatsDialogTitle": "Do you want to clear all stats?", "settingsClearAllStatsDialogTitle": "Do you want to clear all stats?",
"settingsClearAllStatsDialogDescription": "Once removed, the monitoring history and stats cannot be retrieved.", "settingsClearAllStatsDialogDescription": "Once removed, the monitoring history and stats cannot be retrieved.",
"settingsClearAllStatsDialogConfirm": "Yes, clear all stats", "settingsClearAllStatsDialogConfirm": "Yes, clear all stats",
"settingsClearAllStatsDialogCancel": "Cancel",
"settingsDemoMonitors": "Demo monitors", "settingsDemoMonitors": "Demo monitors",
"settingsDemoMonitorsDescription": "Add sample monitors for demonstration purposes.", "settingsDemoMonitorsDescription": "Add sample monitors for demonstration purposes.",
"settingsAddDemoMonitors": "Adding demo monitors", "settingsAddDemoMonitors": "Adding demo monitors",
@@ -108,6 +112,14 @@
"settingsFailedToAddDemoMonitors": "Failed to add demo monitors", "settingsFailedToAddDemoMonitors": "Failed to add demo monitors",
"settingsMonitorsDeleted": "Successfully deleted all monitors", "settingsMonitorsDeleted": "Successfully deleted all monitors",
"settingsFailedToDeleteMonitors": "Failed to delete all monitors", "settingsFailedToDeleteMonitors": "Failed to delete all monitors",
"settingsEmail": "Email settings",
"settingsEmailDescription": "Configure email settings",
"settingsEmailHost": "Email host",
"settingsEmailPort": "Email port",
"settingsEmailAddress": "Email address",
"settingsEmailPassword": "Email password",
"settingsEmailUser": "Email user",
"settingsEmailFieldResetLabel": "Password is set. Click Reset to change it.",
"backendUnreachable": "Server Connection Error", "backendUnreachable": "Server Connection Error",
"backendUnreachableMessage": "We're unable to connect to the server. Please check your internet connection or verify your deployment configuration if the problem persists.", "backendUnreachableMessage": "We're unable to connect to the server. Please check your internet connection or verify your deployment configuration if the problem persists.",
"backendUnreachableError": "Cannot connect to the server. Please try again later.", "backendUnreachableError": "Cannot connect to the server. Please try again later.",
@@ -122,7 +134,7 @@
"http": "HTTP", "http": "HTTP",
"monitor": "monitor", "monitor": "monitor",
"aboutus": "About Us", "aboutus": "About Us",
"state": "State",
"now": "Now", "now": "Now",
"delete": "Delete", "delete": "Delete",
"configure": "Configure", "configure": "Configure",
@@ -291,6 +303,7 @@
"integrationsZapier": "Zapier", "integrationsZapier": "Zapier",
"integrationsZapierInfo": "Send all incidents to Zapier, and then see them everywhere", "integrationsZapierInfo": "Send all incidents to Zapier, and then see them everywhere",
"commonSave": "Save", "commonSave": "Save",
"commonSaving": "Saving...",
"createYour": "Create your", "createYour": "Create your",
"createMonitor": "Create monitor", "createMonitor": "Create monitor",
"pause": "Pause", "pause": "Pause",
@@ -379,6 +392,8 @@
"statusPageStatusNotPublic": "This status page is not public.", "statusPageStatusNotPublic": "This status page is not public.",
"statusPageStatusNoPage": "There's no status page here.", "statusPageStatusNoPage": "There's no status page here.",
"statusPageStatusServiceStatus": "Service status", "statusPageStatusServiceStatus": "Service status",
"statusBreadCrumbsStatusPages": "Status Pages",
"statusBreadCrumbsDetails": "Details",
"deleteStatusPage": "Do you want to delete this status page?", "deleteStatusPage": "Do you want to delete this status page?",
"deleteStatusPageConfirm": "Yes, delete status page", "deleteStatusPageConfirm": "Yes, delete status page",
"deleteStatusPageDescription": "Once deleted, your status page cannot be retrieved.", "deleteStatusPageDescription": "Once deleted, your status page cannot be retrieved.",
@@ -439,6 +454,86 @@
"pageSpeedApiKeyFieldLabel": "PageSpeed API key", "pageSpeedApiKeyFieldLabel": "PageSpeed API key",
"pageSpeedApiKeyFieldDescription": "Enter your Google PageSpeed API key to enable pagespeed monitoring. Click Reset to update the key.", "pageSpeedApiKeyFieldDescription": "Enter your Google PageSpeed API key to enable pagespeed monitoring. Click Reset to update the key.",
"pageSpeedApiKeyFieldResetLabel": "API key is set. Click Reset to change it.", "pageSpeedApiKeyFieldResetLabel": "API key is set. Click Reset to change it.",
"reset": "Reset"
}
"reset": "Reset",
"createNew": "Create new",
"greeting": {
"prepend": "Hey there",
"append": "The afternoon is your playground—let's make it epic!",
"overview": "Here's an overview of your {{type}} monitors."
},
"monitorStatus": {
"up": "up",
"down": "down",
"paused": "paused"
},
"roles": {
"superAdmin": "Super admin",
"admin": "Admin",
"teamMember": "Team member",
"demoUser": "Demo user"
},
"teamPanel": {
"teamMembers": "Team members",
"filter": {
"all": "All",
"member": "Member"
},
"inviteTeamMember": "Invite a team member",
"inviteNewTeamMember": "Invite new team member",
"inviteDescription": "When you add a new team member, they will get access to all monitors.",
"email": "Email",
"selectRole": "Select role",
"inviteLink": "Invite link",
"cancel": "Cancel",
"noMembers": "There are no team members with this role",
"getToken": "Get token",
"emailToken": "E-mail token",
"table": {
"name": "Name",
"email": "Email",
"role": "Role",
"created": "Created"
}
},
"monitorState": {
"paused": "Paused",
"resumed": "Resumed",
"active": "Active"
},
"menu": {
"uptime": "Uptime",
"pagespeed": "Pagespeed",
"infrastructure": "Infrastructure",
"distributedUptime": "Distributed Uptime",
"incidents": "Incidents",
"statusPages": "Status pages",
"maintenance": "Maintenance",
"integrations": "Integrations",
"settings": "Settings",
"support": "Support",
"discussions": "Discussions",
"docs": "Docs",
"changelog": "Changelog",
"profile": "Profile",
"password": "Password",
"team": "Team",
"logOut": "Log out"
},
"navControls": "Controls",
"statusBreadCrumbsStatusPages": "Status Pages",
"statusBreadCrumbsDetails": "Details",
"incidentsPageTitle": "Incidents",
"passwordPanel": {
"passwordChangedSuccess": "Your password was changed successfully.",
"passwordInputIncorrect": "Your password input was incorrect.",
"currentPassword": "Current password",
"enterCurrentPassword": "Enter your current password",
"newPassword": "New password",
"enterNewPassword": "Enter your new password",
"confirmNewPassword": "Confirm new password",
"passwordRequirements": "New password must contain at least 8 characters and must have at least one uppercase letter, one lowercase letter, one number and one special character.",
"saving": "Saving..."
},
"uptimeCreateSelectURL": "Enter the URL or IP to monitor (e.g., https://example.com/ or 192.168.1.100) and add a clear display name that appears on the dashboard."
}
+99 -16
View File
@@ -16,6 +16,7 @@
"commonBack": "Назад", "commonBack": "Назад",
"authForgotPasswordTitle": "Забыли пароль?", "authForgotPasswordTitle": "Забыли пароль?",
"authForgotPasswordResetPassword": "Сбросить пароль", "authForgotPasswordResetPassword": "Сбросить пароль",
"authForgotPasswordInstructions": "Не волнуйтесь, мы отправим вам инструкции по сбросу.",
"createPassword": "Создайте свой пароль", "createPassword": "Создайте свой пароль",
"createAPassword": "Пароль", "createAPassword": "Пароль",
"authRegisterAlreadyHaveAccount": "Уже есть аккаунт?", "authRegisterAlreadyHaveAccount": "Уже есть аккаунт?",
@@ -65,7 +66,18 @@
"authRegisterLastName": "Фамилия", "authRegisterLastName": "Фамилия",
"authRegisterEmail": "Эл. почта", "authRegisterEmail": "Эл. почта",
"authRegisterEmailRequired": "Чтобы продолжить, пожалуйста, введите ваш адрес электронной почты", "authRegisterEmailRequired": "Чтобы продолжить, пожалуйста, введите ваш адрес электронной почты",
"authRegisterEmailInvalid": "Пожалуйста, введите корректный адрес электронной почты", "authRegisterEmailInvalid": "Пожалуйста, введите действительный адрес электронной почты",
"bulkImport": {
"title": "Массовый импорт",
"selectFileTips": "Выберите CSV-файл для загрузки",
"selectFileDescription": "Вы можете скачать наш <template>шаблон</template> или <sample>пример</sample>",
"selectFile": "Выбрать файл",
"parsingFailed": "Ошибка анализа",
"uploadSuccess": "Мониторы успешно созданы!",
"validationFailed": "Ошибка проверки",
"noFileSelected": "Файл не выбран",
"fallbackPage": "Импортируйте файл для загрузки списка серверов"
},
"distributedStatusHeaderText": "Охват реального времени и реального устройства", "distributedStatusHeaderText": "Охват реального времени и реального устройства",
"distributedStatusSubHeaderText": "Работает на миллионах устройств по всему миру, просматривайте производительность системы по глобальному региону, стране или городу", "distributedStatusSubHeaderText": "Работает на миллионах устройств по всему миру, просматривайте производительность системы по глобальному региону, стране или городу",
"settingsGeneralSettings": "Общие настройки", "settingsGeneralSettings": "Общие настройки",
@@ -74,6 +86,8 @@
"settingsAppearance": "Внешний вид", "settingsAppearance": "Внешний вид",
"settingsAppearanceDescription": "Переключение между светлым и темным режимом или изменение языка пользовательского интерфейса", "settingsAppearanceDescription": "Переключение между светлым и темным режимом или изменение языка пользовательского интерфейса",
"settingsThemeMode": "Тема", "settingsThemeMode": "Тема",
"settingsThemeModeLight": "Светлая",
"settingsThemeModeDark": "Тёмная",
"settingsLanguage": "Язык", "settingsLanguage": "Язык",
"settingsDistributedUptime": "Distributed uptime", "settingsDistributedUptime": "Distributed uptime",
"settingsDistributedUptimeDescription": "Включить/выключить distributed uptime monitoring.", "settingsDistributedUptimeDescription": "Включить/выключить distributed uptime monitoring.",
@@ -88,6 +102,7 @@
"settingsClearAllStatsDialogTitle": "Хотите очистить всю статистику?", "settingsClearAllStatsDialogTitle": "Хотите очистить всю статистику?",
"settingsClearAllStatsDialogDescription": "После удаления история мониторинга и статистика не могут быть восстановлены.", "settingsClearAllStatsDialogDescription": "После удаления история мониторинга и статистика не могут быть восстановлены.",
"settingsClearAllStatsDialogConfirm": "Да, очистить всю статистику", "settingsClearAllStatsDialogConfirm": "Да, очистить всю статистику",
"settingsClearAllStatsDialogCancel": "Отмена",
"settingsDemoMonitors": "Демо мониторы", "settingsDemoMonitors": "Демо мониторы",
"settingsDemoMonitorsDescription": "Добавьте примеры мониторов для демонстрации.", "settingsDemoMonitorsDescription": "Добавьте примеры мониторов для демонстрации.",
"settingsAddDemoMonitors": "Добавление демонстрационных мониторов", "settingsAddDemoMonitors": "Добавление демонстрационных мониторов",
@@ -103,6 +118,8 @@
"settingsAbout": "О", "settingsAbout": "О",
"settingsDevelopedBy": "Developed by Bluewave Labs.", "settingsDevelopedBy": "Developed by Bluewave Labs.",
"settingsSave": "Сохранить", "settingsSave": "Сохранить",
"commonSave": "Сохранить",
"commonSaving": "Сохранение...",
"settingsSuccessSaved": "Настройки успешно сохранены", "settingsSuccessSaved": "Настройки успешно сохранены",
"settingsFailedToSave": "Не удалось сохранить настройки", "settingsFailedToSave": "Не удалось сохранить настройки",
"settingsStatsCleared": "Статистика успешно очищена", "settingsStatsCleared": "Статистика успешно очищена",
@@ -295,7 +312,6 @@
"integrationsDiscordInfo": "Подключитесь к Discord и просматривайте инциденты прямо в канале", "integrationsDiscordInfo": "Подключитесь к Discord и просматривайте инциденты прямо в канале",
"integrationsZapier": "Zapier", "integrationsZapier": "Zapier",
"integrationsZapierInfo": "Отправляйте все инциденты в Zapier, и тогда вы сможете видеть их везде", "integrationsZapierInfo": "Отправляйте все инциденты в Zapier, и тогда вы сможете видеть их везде",
"commonSave": "",
"createYour": "", "createYour": "",
"createMonitor": "", "createMonitor": "",
"pause": "", "pause": "",
@@ -315,19 +331,6 @@
"pingMonitoring": "", "pingMonitoring": "",
"pingMonitoringDescription": "", "pingMonitoringDescription": "",
"dockerContainerMonitoring": "", "dockerContainerMonitoring": "",
"dockerContainerMonitoringDescription": "",
"portMonitoring": "",
"portMonitoringDescription": "",
"createMaintenanceWindow": "",
"createMaintenance": "",
"editMaintenance": "",
"maintenanceWindowName": "",
"friendlyNameInput": "",
"friendlyNamePlaceholder": "",
"maintenanceRepeat": "",
"maintenance": "",
"duration": "",
"addMonitors": "",
"window": "", "window": "",
"cancel": "", "cancel": "",
"message": "", "message": "",
@@ -391,7 +394,87 @@
"uptimeCreateJsonPath": "", "uptimeCreateJsonPath": "",
"uptimeCreateJsonPathQuery": "", "uptimeCreateJsonPathQuery": "",
"maintenanceTableActionMenuDialogTitle": "", "maintenanceTableActionMenuDialogTitle": "",
"incidentsPageTitle": "Инциденты",
"passwordPanel": {
"passwordChangedSuccess": "Ваш пароль был успешно изменен.",
"passwordInputIncorrect": "Ваш пароль введен неверно.",
"currentPassword": "Текущий пароль",
"enterCurrentPassword": "Введите ваш текущий пароль",
"newPassword": "Новый пароль",
"enterNewPassword": "Введите ваш новый пароль",
"confirmNewPassword": "Подтвердите новый пароль",
"passwordRequirements": "Новый пароль должен содержать не менее 8 символов и должен иметь как минимум одну заглавную букву, одну строчную букву, одну цифру и один специальный символ.",
"saving": "Сохранение..."
},
"pageSpeedWarning": "Предупреждение: Вы не добавили ключ API Google PageSpeed. Без него монитор PageSpeed не будет работать.", "pageSpeedWarning": "Предупреждение: Вы не добавили ключ API Google PageSpeed. Без него монитор PageSpeed не будет работать.",
"pageSpeedLearnMoreLink": "Нажмите здесь, чтобы узнать", "pageSpeedLearnMoreLink": "Нажмите здесь, чтобы узнать",
"pageSpeedAddApiKey": "как добавить ваш ключ API." "pageSpeedAddApiKey": "как добавить ваш ключ API.",
"createNew": "Создать новый",
"greeting": {
"prepend": "Привет",
"append": "День прекрасен для новых достижений!",
"overview": "Вот обзор ваших мониторов {{type}}."
},
"monitorStatus": {
"up": "работает",
"down": "не работает",
"paused": "приостановлен"
},
"roles": {
"superAdmin": "Суперадминистратор",
"admin": "Администратор",
"teamMember": "Член команды",
"demoUser": "Демо-пользователь"
},
"teamPanel": {
"teamMembers": "Члены команды",
"filter": {
"all": "Все",
"member": "Член"
},
"inviteTeamMember": "Пригласить члена команды",
"inviteNewTeamMember": "Пригласить нового члена команды",
"inviteDescription": "Когда вы добавляете нового члена команды, он получит доступ ко всем мониторам.",
"email": "Эл. почта",
"selectRole": "Выберите роль",
"inviteLink": "Ссылка для приглашения",
"cancel": "Отмена",
"noMembers": "Нет членов команды с этой ролью",
"getToken": "Получить токен",
"emailToken": "Отправить токен по эл. почте",
"table": {
"name": "Имя",
"email": "Эл. почта",
"role": "Роль",
"created": "Создан"
}
},
"monitorState": {
"paused": "приостановлен",
"resumed": "возобновлен",
"active": "активный"
},
"menu": {
"uptime": "Аптайм",
"pagespeed": "Скорость страницы",
"infrastructure": "Инфраструктура",
"distributedUptime": "Распределенный Аптайм",
"incidents": "Инциденты",
"statusPages": "Страницы статуса",
"maintenance": "Обслуживание",
"integrations": "Интеграции",
"settings": "Настройки",
"support": "Поддержка",
"profile": "Профиль",
"password": "Пароль",
"team": "Команда",
"logOut": "Выйти",
"discussions": "Обсуждения",
"docs": "Документация",
"changelog": "История изменений"
},
"navControls": "Управление",
"statusBreadCrumbsStatusPages": "Страницы статуса",
"statusBreadCrumbsDetails": "Подробности",
"uptimeCreateSelectURL": "Введите URL или IP для мониторинга (например, https://example.com/ или 192.168.1.100) и добавьте понятное отображаемое имя, которое будет показано на панели управления."
} }
+100 -15
View File
@@ -16,6 +16,7 @@
"commonBack": "Geri", "commonBack": "Geri",
"authForgotPasswordTitle": "Parolanızı mı unuttunuz?", "authForgotPasswordTitle": "Parolanızı mı unuttunuz?",
"authForgotPasswordResetPassword": "Parola sıfırla", "authForgotPasswordResetPassword": "Parola sıfırla",
"authForgotPasswordInstructions": "Endişelenmeyin, size sıfırlama talimatlarını göndereceğiz.",
"createPassword": "Parolanızı oluşturun", "createPassword": "Parolanızı oluşturun",
"createAPassword": "Parola", "createAPassword": "Parola",
"authRegisterAlreadyHaveAccount": "Zaten hesabınız var mı?", "authRegisterAlreadyHaveAccount": "Zaten hesabınız var mı?",
@@ -69,6 +70,8 @@
"settingsAppearance": "Görünüm", "settingsAppearance": "Görünüm",
"settingsAppearanceDescription": "Açık ve koyu mod arasında geçiş yapın veya kullanıcı arayüzü dilini değiştirin", "settingsAppearanceDescription": "Açık ve koyu mod arasında geçiş yapın veya kullanıcı arayüzü dilini değiştirin",
"settingsThemeMode": "Tema", "settingsThemeMode": "Tema",
"settingsThemeModeLight": "Açık",
"settingsThemeModeDark": "Koyu",
"settingsLanguage": "Dil", "settingsLanguage": "Dil",
"settingsDistributedUptime": "Dağıtılmış çalışma süresi", "settingsDistributedUptime": "Dağıtılmış çalışma süresi",
"settingsDistributedUptimeDescription": "Dağıtılmış çalışma süresi izlemeyi etkinleştirin/devre dışı bırakın.", "settingsDistributedUptimeDescription": "Dağıtılmış çalışma süresi izlemeyi etkinleştirin/devre dışı bırakın.",
@@ -83,6 +86,7 @@
"settingsClearAllStatsDialogTitle": "Tüm istatistikleri temizlemek istiyor musunuz?", "settingsClearAllStatsDialogTitle": "Tüm istatistikleri temizlemek istiyor musunuz?",
"settingsClearAllStatsDialogDescription": "Kaldırıldıktan sonra, izleme geçmişi ve istatistikleri geri alınamaz.", "settingsClearAllStatsDialogDescription": "Kaldırıldıktan sonra, izleme geçmişi ve istatistikleri geri alınamaz.",
"settingsClearAllStatsDialogConfirm": "Evet, tüm istatistikleri temizle", "settingsClearAllStatsDialogConfirm": "Evet, tüm istatistikleri temizle",
"settingsClearAllStatsDialogCancel": "İptal",
"settingsDemoMonitors": "Demo monitörler", "settingsDemoMonitors": "Demo monitörler",
"settingsDemoMonitorsDescription": "Gösterim amaçlı örnek monitörler ekleyin.", "settingsDemoMonitorsDescription": "Gösterim amaçlı örnek monitörler ekleyin.",
"settingsAddDemoMonitors": "Demo monitörler ekleniyor", "settingsAddDemoMonitors": "Demo monitörler ekleniyor",
@@ -289,6 +293,7 @@
"integrationsZapier": "Zapier", "integrationsZapier": "Zapier",
"integrationsZapierInfo": "", "integrationsZapierInfo": "",
"commonSave": "Kaydet", "commonSave": "Kaydet",
"commonSaving": "Kaydediliyor...",
"createYour": "", "createYour": "",
"createMonitor": "Monitör oluştur", "createMonitor": "Monitör oluştur",
"pause": "Beklet", "pause": "Beklet",
@@ -389,12 +394,12 @@
"infrastructureMonitorCreated": "", "infrastructureMonitorCreated": "",
"infrastructureMonitorUpdated": "", "infrastructureMonitorUpdated": "",
"errorInvalidTypeId": "", "errorInvalidTypeId": "",
"errorInvalidFieldId": "", "pageSpeedWarning": "Uyarı: Google PageSpeed API anahtarı eklemediniz. Bu olmadan, PageSpeed monitörü çalışmayacaktır.",
"inviteNoTokenFound": "", "pageSpeedLearnMoreLink": "Daha fazla bilgi için tıklayın",
"pageSpeedWarning": "", "pageSpeedAddApiKey": "API anahtarınızı nasıl ekleyeceğinizi öğrenin.",
"pageSpeedLearnMoreLink": "", "pageSpeedApiKeyFieldDescription": "Sayfa hızı izlemeyi etkinleştirmek için Google PageSpeed API anahtarınızı girin. Anahtarı güncellemek için Sıfırla'ya tıklayın.",
"pageSpeedAddApiKey": "", "pageSpeedApiKeyFieldResetLabel": "API anahtarı ayarlandı. Değiştirmek için Sıfırla'ya tıklayın.",
"update": "", "reset": "Sıfırla",
"invalidFileFormat": "", "invalidFileFormat": "",
"invalidFileSize": "", "invalidFileSize": "",
"ClickUpload": "", "ClickUpload": "",
@@ -418,14 +423,94 @@
"authRegisterEmailRequired": "Devam etmek için lütfen e-posta adresinizi girin", "authRegisterEmailRequired": "Devam etmek için lütfen e-posta adresinizi girin",
"authRegisterEmailInvalid": "Lütfen geçerli bir e-posta adresi girin", "authRegisterEmailInvalid": "Lütfen geçerli bir e-posta adresi girin",
"bulkImport": { "bulkImport": {
"title": "", "title": "Toplu İçe Aktar",
"selectFileTips": "", "selectFileTips": "Yüklemek için CSV dosyası seçin",
"selectFileDescription": "", "selectFileDescription": "<template>Şablonumuzu</template> veya <sample>örneğimizi</sample> indirebilirsiniz",
"selectFile": "", "selectFile": "Dosya Seç",
"parsingFailed": "", "parsingFailed": "Ayrıştırma başarısız oldu",
"uploadSuccess": "", "uploadSuccess": "Monitörler başarıyla oluşturuldu!",
"validationFailed": "", "validationFailed": "Doğrulama başarısız oldu",
"noFileSelected": "", "noFileSelected": "Dosya seçilmedi",
"fallbackPage": "" "fallbackPage": "Sunucuların listesini toplu olarak yüklemek için bir dosya içe aktarın"
},
"createNew": "Yeni oluştur",
"greeting": {
"prepend": "Merhaba",
"append": "Öğleden sonra senin oyun alanın—hadi onu muhteşem yapalım!",
"overview": "İşte {{type}} monitörlerinizin genel görünümü."
},
"monitorStatus": {
"up": "aktif",
"down": "devre dışı",
"paused": "duraklatıldı"
},
"roles": {
"superAdmin": "Süper yönetici",
"admin": "Yönetici",
"teamMember": "Takım üyesi",
"demoUser": "Demo kullanıcı"
},
"teamPanel": {
"teamMembers": "Takım üyeleri",
"filter": {
"all": "Tümü",
"member": "Üye"
},
"inviteTeamMember": "Takım üyesi davet et",
"inviteNewTeamMember": "Yeni takım üyesi davet et",
"inviteDescription": "Yeni bir takım üyesi eklediğinizde, tüm monitörlere erişim hakkı alacaktır.",
"email": "E-posta",
"selectRole": "Rol seçin",
"inviteLink": "Davet bağlantısı",
"cancel": "İptal",
"noMembers": "Bu role sahip takım üyesi bulunmamaktadır",
"getToken": "Token al",
"emailToken": "Token e-posta ile gönder",
"table": {
"name": "Ad",
"email": "E-posta",
"role": "Rol",
"created": "Oluşturuldu"
} }
},
"monitorState": {
"paused": "duraklatıldı",
"resumed": "devam ettirildi",
"active": "aktif"
},
"menu": {
"uptime": "Çalışma Süresi",
"pagespeed": "Sayfa Hızı",
"infrastructure": "Altyapı",
"distributedUptime": "Dağıtılmış Çalışma Süresi",
"incidents": "Olaylar",
"statusPages": "Durum Sayfaları",
"maintenance": "Bakım",
"integrations": "Entegrasyonlar",
"settings": "Ayarlar",
"support": "Destek",
"discussions": "Tartışmalar",
"docs": "Belgeler",
"changelog": "Değişiklik Günlüğü",
"profile": "Profil",
"password": "Şifre",
"team": "Takım",
"logOut": "Çıkış"
},
"navControls": "Kontroller",
"statusBreadCrumbsStatusPages": "Durum Sayfaları",
"statusBreadCrumbsDetails": "Detaylar",
"incidentsPageTitle": "Olaylar",
"passwordPanel": {
"passwordChangedSuccess": "Şifreniz başarıyla değiştirildi.",
"passwordInputIncorrect": "Şifre girişiniz yanlış.",
"currentPassword": "Mevcut şifre",
"enterCurrentPassword": "Mevcut şifrenizi girin",
"newPassword": "Yeni şifre",
"enterNewPassword": "Yeni şifrenizi girin",
"confirmNewPassword": "Yeni şifreyi onaylayın",
"passwordRequirements": "Yeni şifre en az 8 karakter içermeli ve en az bir büyük harf, bir küçük harf, bir rakam ve bir özel karakter içermelidir.",
"saving": "Kaydediliyor..."
},
"uptimeCreateSelectURL": "İzlenecek URL veya IP adresini girin (örn. https://example.com/ veya 192.168.1.100) ve kontrol panelinde görünecek net bir görüntü adı ekleyin."
} }
-4
View File
@@ -24,8 +24,6 @@ services:
redis: redis:
image: uptime_redis:latest image: uptime_redis:latest
restart: always restart: always
ports:
- "6379:6379"
volumes: volumes:
- ./redis/data:/data - ./redis/data:/data
healthcheck: healthcheck:
@@ -38,8 +36,6 @@ services:
image: uptime_mongo:latest image: uptime_mongo:latest
restart: always restart: always
command: ["mongod", "--quiet", "--replSet", "rs0", "--bind_ip_all"] command: ["mongod", "--quiet", "--replSet", "rs0", "--bind_ip_all"]
ports:
- "27017:27017"
volumes: volumes:
- ./mongo/data:/data/db - ./mongo/data:/data/db
healthcheck: healthcheck:
+3 -6
View File
@@ -3,7 +3,7 @@ services:
image: ghcr.io/bluewave-labs/checkmate:frontend-dist image: ghcr.io/bluewave-labs/checkmate:frontend-dist
restart: always restart: always
environment: environment:
UPTIME_APP_API_BASE_URL: "http://localhost:5000/api/v1" UPTIME_APP_API_BASE_URL: "http://localhost:52345/api/v1"
UPTIME_APP_CLIENT_HOST: "http://localhost" UPTIME_APP_CLIENT_HOST: "http://localhost"
ports: ports:
- "80:80" - "80:80"
@@ -14,7 +14,7 @@ services:
image: ghcr.io/bluewave-labs/checkmate:backend-dist image: ghcr.io/bluewave-labs/checkmate:backend-dist
restart: always restart: always
ports: ports:
- "5000:5000" - "52345:52345"
depends_on: depends_on:
- redis - redis
- mongodb - mongodb
@@ -22,13 +22,12 @@ services:
- DB_CONNECTION_STRING=mongodb://mongodb:27017/uptime_db?replicaSet=rs0 - DB_CONNECTION_STRING=mongodb://mongodb:27017/uptime_db?replicaSet=rs0
- REDIS_URL=redis://redis:6379 - REDIS_URL=redis://redis:6379
- CLIENT_HOST=http://localhost - CLIENT_HOST=http://localhost
- JWT_SECRET=my_secret
# volumes: # volumes:
# - /var/run/docker.sock:/var/run/docker.sock:ro # - /var/run/docker.sock:/var/run/docker.sock:ro
redis: redis:
image: ghcr.io/bluewave-labs/checkmate:redis-dist image: ghcr.io/bluewave-labs/checkmate:redis-dist
restart: always restart: always
ports:
- "6379:6379"
volumes: volumes:
- ./redis/data:/data - ./redis/data:/data
healthcheck: healthcheck:
@@ -43,8 +42,6 @@ services:
volumes: volumes:
- ./mongo/data:/data/db - ./mongo/data:/data/db
command: ["mongod", "--quiet", "--replSet", "rs0", "--bind_ip_all"] command: ["mongod", "--quiet", "--replSet", "rs0", "--bind_ip_all"]
ports:
- "27017:27017"
healthcheck: healthcheck:
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'mongodb:27017'}]}) }" | mongosh --port 27017 --quiet test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'mongodb:27017'}]}) }" | mongosh --port 27017 --quiet
interval: 5s interval: 5s
-4
View File
@@ -36,8 +36,6 @@ services:
redis: redis:
image: ghcr.io/bluewave-labs/checkmate:redis-demo image: ghcr.io/bluewave-labs/checkmate:redis-demo
restart: always restart: always
ports:
- "6379:6379"
volumes: volumes:
- ./redis/data:/data - ./redis/data:/data
healthcheck: healthcheck:
@@ -50,8 +48,6 @@ services:
image: ghcr.io/bluewave-labs/checkmate:mongo-demo image: ghcr.io/bluewave-labs/checkmate:mongo-demo
restart: always restart: always
command: ["mongod", "--quiet", "--replSet", "rs0", "--bind_ip_all"] command: ["mongod", "--quiet", "--replSet", "rs0", "--bind_ip_all"]
ports:
- "27017:27017"
volumes: volumes:
- ./mongo/data:/data/db - ./mongo/data:/data/db
# - ./mongo/init/init.js:/docker-entrypoint-initdb.d/init.js // No longer needed # - ./mongo/init/init.js:/docker-entrypoint-initdb.d/init.js // No longer needed
+7 -4
View File
@@ -582,14 +582,18 @@ class MonitorController {
} }
try { try {
const monitor = await Monitor.findOneAndUpdate({ _id: req.params.monitorId }, [ const monitor = await Monitor.findOneAndUpdate(
{ _id: req.params.monitorId },
[
{ {
$set: { $set: {
isActive: { $not: "$isActive" }, isActive: { $not: "$isActive" },
status: "$$REMOVE", status: "$$REMOVE",
}, },
}, },
]); ],
{ new: true }
);
monitor.isActive === true monitor.isActive === true
? await this.jobQueue.deleteJob(monitor) ? await this.jobQueue.deleteJob(monitor)
: await this.jobQueue.addJob(monitor._id, monitor); : await this.jobQueue.addJob(monitor._id, monitor);
@@ -649,9 +653,8 @@ class MonitorController {
sendTestEmail = async (req, res, next) => { sendTestEmail = async (req, res, next) => {
try { try {
const { to } = req.body; const { to } = req.body;
if (!to || typeof to !== "string") { if (!to || typeof to !== "string") {
return res.error({ msg: this.stringService.errorForValidEmailAddress }); throw new Error(this.stringService.errorForValidEmailAddress);
} }
const subject = this.stringService.testEmailSubject; const subject = this.stringService.testEmailSubject;
+15 -2
View File
@@ -13,12 +13,25 @@ class SettingsController {
getAppSettings = async (req, res, next) => { getAppSettings = async (req, res, next) => {
const dbSettings = await this.settingsService.getDBSettings(); const dbSettings = await this.settingsService.getDBSettings();
const sanitizedSettings = { ...dbSettings }; const sanitizedSettings = { ...dbSettings };
const returnSettings = {
pagespeedKeySet: false,
emailPasswordSet: false,
};
if (typeof sanitizedSettings.pagespeedApiKey !== "undefined") { if (typeof sanitizedSettings.pagespeedApiKey !== "undefined") {
sanitizedSettings.pagespeedApiKey = "********"; returnSettings.pagespeedKeySet = true;
delete sanitizedSettings.pagespeedApiKey;
} }
if (typeof sanitizedSettings.systemEmailPassword !== "undefined") {
returnSettings.emailPasswordSet = true;
delete sanitizedSettings.systemEmailPassword;
}
returnSettings.settings = sanitizedSettings;
return res.success({ return res.success({
msg: this.stringService.getAppSettings, msg: this.stringService.getAppSettings,
data: sanitizedSettings, data: returnSettings,
}); });
}; };
+11 -1
View File
@@ -2,13 +2,16 @@ import mongoose from "mongoose";
const AppSettingsSchema = mongoose.Schema( const AppSettingsSchema = mongoose.Schema(
{ {
checkTTL: {
type: Number,
default: 30,
},
language: { language: {
type: String, type: String,
default: "gb", default: "gb",
}, },
pagespeedApiKey: { pagespeedApiKey: {
type: String, type: String,
default: "",
}, },
systemEmailHost: { systemEmailHost: {
type: String, type: String,
@@ -22,12 +25,19 @@ const AppSettingsSchema = mongoose.Schema(
systemEmailPassword: { systemEmailPassword: {
type: String, type: String,
}, },
systemEmailUser: {
type: String,
},
singleton: { singleton: {
type: Boolean, type: Boolean,
required: true, required: true,
unique: true, unique: true,
default: true, default: true,
}, },
version: {
type: Number,
default: 1,
},
}, },
{ {
timestamps: true, timestamps: true,
+16 -6
View File
@@ -14,12 +14,22 @@ const getAppSettings = async () => {
const updateAppSettings = async (newSettings) => { const updateAppSettings = async (newSettings) => {
try { try {
console.log(newSettings); const update = { $set: { ...newSettings } };
const settings = await AppSettings.findOneAndUpdate(
{}, if (newSettings.pagespeedApiKey === "") {
{ $set: newSettings }, update.$unset = { pagespeedApiKey: "" };
{ new: true, upsert: true } delete update.$set.pagespeedApiKey;
); }
if (newSettings.systemEmailPassword === "") {
update.$unset = { systemEmailPassword: "" };
delete update.$set.systemEmailPassword;
}
const settings = await AppSettings.findOneAndUpdate({}, update, {
new: true,
upsert: true,
});
return settings; return settings;
} catch (error) { } catch (error) {
error.service = SERVICE_NAME; error.service = SERVICE_NAME;
+1 -1
View File
@@ -161,5 +161,5 @@
"monitorDownAlert": "Downtime Alert: One of your monitors went offline.\n📌 Monitor: {monitorName}\n📅 Time: {time}\n⚠️ Status: DOWN\n📟 Status Code: {code}\n\u200B\n", "monitorDownAlert": "Downtime Alert: One of your monitors went offline.\n📌 Monitor: {monitorName}\n📅 Time: {time}\n⚠️ Status: DOWN\n📟 Status Code: {code}\n\u200B\n",
"sendTestEmail": "Test email sent successfully", "sendTestEmail": "Test email sent successfully",
"errorForValidEmailAddress": "A valid recipient email address is required.", "errorForValidEmailAddress": "A valid recipient email address is required.",
"testEmailSubject": "Test Email from Monitoring System" "testEmailSubject": "Test E-mail from Checkmate"
} }
+27 -21
View File
@@ -29,7 +29,10 @@ class EmailService {
this.mjml2html = mjml2html; this.mjml2html = mjml2html;
this.nodemailer = nodemailer; this.nodemailer = nodemailer;
this.logger = logger; this.logger = logger;
this.init();
}
init = async () => {
/** /**
* Loads an email template from the filesystem. * Loads an email template from the filesystem.
* *
@@ -67,35 +70,15 @@ class EmailService {
serverIsUpTemplate: this.loadTemplate("serverIsUp"), serverIsUpTemplate: this.loadTemplate("serverIsUp"),
passwordResetTemplate: this.loadTemplate("passwordReset"), passwordResetTemplate: this.loadTemplate("passwordReset"),
hardwareIncidentTemplate: this.loadTemplate("hardwareIncident"), hardwareIncidentTemplate: this.loadTemplate("hardwareIncident"),
testEmailTemplate: this.loadTemplate("testEmailTemplate") testEmailTemplate: this.loadTemplate("testEmailTemplate"),
}; };
/** /**
* The email transporter used to send emails. * The email transporter used to send emails.
* @type {Object} * @type {Object}
*/ */
const {
systemEmailHost,
systemEmailPort,
systemEmailUser,
systemEmailAddress,
systemEmailPassword,
} = this.settingsService.getSettings();
const emailConfig = {
host: systemEmailHost,
port: systemEmailPort,
secure: true,
auth: {
user: systemEmailUser || systemEmailAddress,
pass: systemEmailPassword,
},
}; };
this.transporter = this.nodemailer.createTransport(emailConfig);
}
/** /**
* Asynchronously builds and sends an email using a specified template and context. * Asynchronously builds and sends an email using a specified template and context.
* *
@@ -106,6 +89,28 @@ class EmailService {
* @returns {Promise<string>} A promise that resolves to the messageId of the sent email. * @returns {Promise<string>} A promise that resolves to the messageId of the sent email.
*/ */
buildAndSendEmail = async (template, context, to, subject) => { buildAndSendEmail = async (template, context, to, subject) => {
// TODO - Consider an update transporter method so this only needs to be recreated when smtp settings change
const {
systemEmailHost,
systemEmailPort,
systemEmailUser,
systemEmailAddress,
systemEmailPassword,
} = await this.settingsService.getDBSettings();
const emailConfig = {
host: systemEmailHost,
port: systemEmailPort,
secure: true,
auth: {
user: systemEmailUser || systemEmailAddress,
pass: systemEmailPassword,
},
connectionTimeout: 5000,
};
this.transporter = this.nodemailer.createTransport(emailConfig);
const buildHtml = async (template, context) => { const buildHtml = async (template, context) => {
try { try {
const mjml = this.templateLookup[template](context); const mjml = this.templateLookup[template](context);
@@ -125,6 +130,7 @@ class EmailService {
try { try {
const info = await this.transporter.sendMail({ const info = await this.transporter.sendMail({
to: to, to: to,
from: systemEmailAddress,
subject: subject, subject: subject,
html: html, html: html,
}); });
+12 -3
View File
@@ -36,7 +36,6 @@ class NetworkService {
this.net = net; this.net = net;
this.stringService = stringService; this.stringService = stringService;
this.settingsService = settingsService; this.settingsService = settingsService;
this.settings = settingsService.getSettings();
} }
/** /**
@@ -254,8 +253,18 @@ class NetworkService {
const url = job.data.url; const url = job.data.url;
const updatedJob = { ...job }; const updatedJob = { ...job };
let pagespeedUrl = `https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&category=seo&category=accessibility&category=best-practices&category=performance`; let pagespeedUrl = `https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?url=${url}&category=seo&category=accessibility&category=best-practices&category=performance`;
if (this.settings?.pagespeedApiKey) {
pagespeedUrl += `&key=${this.settings.pagespeedApiKey}`; const dbSettings = await this.settingsService.getDBSettings();
if (dbSettings?.pagespeedApiKey) {
pagespeedUrl += `&key=${dbSettings.pagespeedApiKey}`;
} else {
this.logger.info({
message: "Pagespeed API key not found",
service: this.SERVICE_NAME,
method: "requestPagespeed",
details: { url },
});
return;
} }
updatedJob.data.url = pagespeedUrl; updatedJob.data.url = pagespeedUrl;
return await this.requestHttp(updatedJob); return await this.requestHttp(updatedJob);
+14 -1
View File
@@ -59,7 +59,20 @@ class SettingsService {
} }
async getDBSettings() { async getDBSettings() {
const settings = await this.appSettings.findOne({ singleton: true }).lean(); // Remove any old settings
await this.appSettings.deleteMany({ version: { $exists: false } });
let settings = await this.appSettings
.findOne({ singleton: true })
.select("-__v -_id -createdAt -updatedAt -singleton")
.lean();
if (settings === null) {
await this.appSettings.create({});
settings = await this.appSettings
.findOne({ singleton: true })
.select("-__v -_id -createdAt -updatedAt -singleton")
.lean();
}
return settings; return settings;
} }
} }
+4
View File
@@ -428,6 +428,10 @@ class StringService {
get dbUserExists() { get dbUserExists() {
return this.translationService.getTranslation("dbUserExists"); return this.translationService.getTranslation("dbUserExists");
} }
get testEmailSubject() {
return this.translationService.getTranslation("testEmailSubject");
}
} }
export default StringService; export default StringService;
+2 -9
View File
@@ -424,21 +424,14 @@ const editMaintenanceByIdWindowBodyValidation = joi.object({
// SettingsValidation // SettingsValidation
//**************************************** //****************************************
const updateAppSettingsBodyValidation = joi.object({ const updateAppSettingsBodyValidation = joi.object({
apiBaseUrl: joi.string().allow(""), checkTTL: joi.number().allow(""),
logLevel: joi.string().valid("debug", "none", "error", "warn").allow(""),
clientHost: joi.string().allow(""),
dbType: joi.string().allow(""),
dbConnectionString: joi.string().allow(""),
redisHost: joi.string().allow(""),
redisPort: joi.number().allow(null, ""),
redisUrl: joi.string().allow(""),
jwtTTL: joi.string().allow(""),
pagespeedApiKey: joi.string().allow(""), pagespeedApiKey: joi.string().allow(""),
language: joi.string().allow(""), language: joi.string().allow(""),
systemEmailHost: joi.string().allow(""), systemEmailHost: joi.string().allow(""),
systemEmailPort: joi.number().allow(""), systemEmailPort: joi.number().allow(""),
systemEmailAddress: joi.string().allow(""), systemEmailAddress: joi.string().allow(""),
systemEmailPassword: joi.string().allow(""), systemEmailPassword: joi.string().allow(""),
systemEmailUser: joi.string().allow(""),
}); });
//**************************************** //****************************************