diff --git a/Client/src/Components/Sidebar/index.jsx b/Client/src/Components/Sidebar/index.jsx index c372f8c66..27fb35329 100644 --- a/Client/src/Components/Sidebar/index.jsx +++ b/Client/src/Components/Sidebar/index.jsx @@ -90,6 +90,14 @@ function Sidebar() { const [open, setOpen] = useState({ Dashboard: false, Account: false }); const [anchorEl, setAnchorEl] = useState(null); const [popup, setPopup] = useState(); + const { user } = useSelector((state) => state.auth); + + // Remove demo password if demo + if (user.role.includes("demo")) { + menu[3].nested = menu[3].nested.filter((item) => { + return item.name !== "Password"; + }); + } const openPopup = (event, id) => { setAnchorEl(event.currentTarget); diff --git a/Client/src/Components/TabPanels/Account/ProfilePanel.jsx b/Client/src/Components/TabPanels/Account/ProfilePanel.jsx index fb782da92..36441c53c 100644 --- a/Client/src/Components/TabPanels/Account/ProfilePanel.jsx +++ b/Client/src/Components/TabPanels/Account/ProfilePanel.jsx @@ -331,22 +331,24 @@ const ProfilePanel = () => { borderColor: theme.palette.border.light, }} /> - - - Delete account - - Note that deleting your account will remove all data from our - system. This is permanent and non-recoverable. - + {!user.role.includes("demo") && ( + + + Delete account + + Note that deleting your account will remove all data from our + system. This is permanent and non-recoverable. + + + - - + )} {/* TODO - Update ModalPopup Component with @mui for reusability */} { superadmin: "Super admin", admin: "Admin", user: "Team member", + demo: "Demo User", }; const theme = useTheme(); diff --git a/Client/src/Pages/Account/index.jsx b/Client/src/Pages/Account/index.jsx index fe7b19655..4f5b0c440 100644 --- a/Client/src/Pages/Account/index.jsx +++ b/Client/src/Pages/Account/index.jsx @@ -22,15 +22,20 @@ const Account = ({ open = "profile" }) => { const handleTabChange = (event, newTab) => { navigate(`/account/${newTab}`); }; - - let tabList = ["Profile", "Password", "Team"]; const { user } = useSelector((state) => state.auth); + const requiredRoles = ["superadmin", "admin"]; + let tabList = ["Profile", "Team", "Password"]; const hideTeams = !requiredRoles.some((role) => user.role.includes(role)); if (hideTeams) { tabList = ["Profile", "Password"]; } + // Remove password for demo + if (user.role.includes("demo")) { + tabList = ["Profile"]; + } + return ( { - + {user.role.includes("superadmin") && } {!hideTeams && } diff --git a/Client/src/Pages/Auth/Login.jsx b/Client/src/Pages/Auth/Login.jsx index 565419f09..b4566da2f 100644 --- a/Client/src/Pages/Auth/Login.jsx +++ b/Client/src/Pages/Auth/Login.jsx @@ -15,6 +15,7 @@ import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded"; import PropTypes from "prop-types"; import { logger } from "../../Utils/Logger"; import "./index.css"; +const DEMO = import.meta.env.VITE_APP_DEMO; /** * Displays the initial landing page. @@ -327,8 +328,8 @@ const Login = () => { }; const [form, setForm] = useState({ - email: "", - password: "", + email: DEMO !== undefined ? "uptimedemo@demo.com" : "", + password: DEMO !== undefined ? "Demouser1!" : "", }); const [errors, setErrors] = useState({}); const [step, setStep] = useState(0); diff --git a/README.md b/README.md index e050b221e..d396ae397 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,9 @@

An open source server monitoring application

- ![Dashboard-dark](https://github.com/user-attachments/assets/db875138-164f-453c-a75e-889f88747578) (yes, we have a light theme as well, but this looks better on readme.md) - BlueWave Uptime is an open source server monitoring application used to track the operational status and performance of servers and websites. It regularly checks whether a server/website is accessible and performs optimally, providing real-time alerts and reports on the monitored services' availability, downtime, and response time. ## Features @@ -214,10 +212,11 @@ That's it, the application is ready to use on port 80. ##### Environmental Variables -| ENV Variable Name | Required/Optional | Type | Description | Accepted Values | -| --------------------- | ----------------- | -------- | ------------------ | ---------------------------------- | -| VITE_APP_API_BASE_URL | Required | `string` | Base URL of server | {host}/api/v1 | -| VITE_APP_LOG_LEVEL | Optional | `string` | Log level | `"none"`\|`"error"` \| `"warn"` \| | +| ENV Variable Name | Required/Optional | Type | Description | Accepted Values | +| --------------------- | ----------------- | --------- | ------------------ | ---------------------------------- | +| VITE_APP_API_BASE_URL | Required | `string` | Base URL of server | {host}/api/v1 | +| VITE_APP_LOG_LEVEL | Optional | `string` | Log level | `"none"`\|`"error"` \| `"warn"` \| | +| VITE_APP_DEMO | Optional | `boolean` | Demo server or not | `true`\|`false` \| |
diff --git a/Server/models/user.js b/Server/models/user.js index 829129b4d..888bfd7eb 100644 --- a/Server/models/user.js +++ b/Server/models/user.js @@ -38,7 +38,7 @@ const UserSchema = mongoose.Schema( role: { type: [String], default: "user", - enum: ["user", "admin", "superadmin"], + enum: ["user", "admin", "superadmin", "demo"], }, teamId: { type: mongoose.Schema.Types.ObjectId, diff --git a/Server/validation/joi.js b/Server/validation/joi.js index 417965b95..918400c21 100644 --- a/Server/validation/joi.js +++ b/Server/validation/joi.js @@ -70,7 +70,7 @@ const registrationBodyValidation = joi.object({ profileImage: joi.any(), role: joi .array() - .items(joi.string().valid("superadmin", "admin", "user")) + .items(joi.string().valid("superadmin", "admin", "user", "demo")) .min(1) .required(), teamId: joi.string().allow("").required(),