From 65e8404592b054dc79fd9c80d178062c8679bc4e Mon Sep 17 00:00:00 2001 From: SnippetsX Date: Fri, 22 Nov 2024 22:20:29 +0300 Subject: [PATCH] Refactored all pages available right now for more readability Added Sidebar.js where stored all sidebars for this project Added AppBar.js where stored all appbars for this project --- src/App.js | 3 +- src/Dashboard/DashboardMain.js | 122 ++------------------------ src/Dashboard/DashboardUsers.js | 146 ++----------------------------- src/Settings/SettingsInfo.js | 123 ++------------------------ src/Settings/SettingsMain.js | 123 ++------------------------ src/Terminal/TerminalPage.js | 119 ++----------------------- src/metadata.json | 2 +- src/widgets/AppBar.js | 90 +++++++++++++++++++ src/widgets/ProgressBar.js | 10 +-- src/widgets/Sidebar.js | 107 ++++++++++++++++++++++ src/widgets/WidgetsStatistics.js | 10 ++- 11 files changed, 242 insertions(+), 613 deletions(-) create mode 100644 src/widgets/AppBar.js create mode 100644 src/widgets/Sidebar.js diff --git a/src/App.js b/src/App.js index fb4b9e0..f51a1d5 100644 --- a/src/App.js +++ b/src/App.js @@ -4,6 +4,7 @@ import { BrowserRouter as Router, Route, Routes, Navigate} from 'react-router-do import SettingsMain from './Settings/SettingsMain' import SettingsInfo from './Settings/SettingsInfo' import Dashboard from './Dashboard/DashboardMain' +import DashboardUsers from './Dashboard/DashboardUsers' import ProgressBar from './widgets/ProgressBar' import metadata from './metadata.json'; @@ -24,8 +25,8 @@ function App() { } /> } /> + } /> {/* } /> - } /> } /> */} } /> } /> diff --git a/src/Dashboard/DashboardMain.js b/src/Dashboard/DashboardMain.js index 561e38d..a06d488 100644 --- a/src/Dashboard/DashboardMain.js +++ b/src/Dashboard/DashboardMain.js @@ -1,134 +1,22 @@ -import React, { useState } from 'react'; +import React from 'react'; import { Box, - ListItem, - ListItemText, - List, - Drawer, - IconButton, - Divider, CssBaseline, - AppBar, Toolbar, - Typography, - Menu, - MenuItem, } from '@mui/material'; -import PeopleIcon from '@mui/icons-material/PeopleOutline'; -import DashboardIcon from '@mui/icons-material/DashboardOutlined'; -import BarChartIcon from '@mui/icons-material/BarChartOutlined'; -import ConstructionOutlinedIcon from '@mui/icons-material/ConstructionOutlined'; -import SettingsIcon from '@mui/icons-material/SettingsOutlined'; -import TerminalOutlinedIcon from '@mui/icons-material/TerminalOutlined'; -import LogoutIcon from '@mui/icons-material/LogoutOutlined'; -import AccountCircleIcon from '@mui/icons-material/AccountCircleOutlined'; import { ThemeProvider } from '@mui/material/styles'; import theme from '../theme'; -import deleteToken from '../core/deleteToken'; import {SystemMon, WebsiteAvailability} from '../widgets/WidgetsStatistics' - - -const drawerWidth = 240; +import { SidebarMain } from '../widgets/Sidebar'; +import { AppBarFull } from '../widgets/AppBar'; export default function DashboardMain() { - const [anchorEl, setAnchorEl] = useState(null); - const openMenu = Boolean(anchorEl); - - const handleMenuClick = (event) => { - setAnchorEl(event.currentTarget); - }; - - const handleMenuClose = () => { - setAnchorEl(null); - }; - return ( - - - - Admin Dashboard - - - - - - { handleMenuClose(); window.location.href = '/dashboard'; }}> - - Dashboard - - - - Profile - - - - My account - - { handleMenuClose(); window.location.href = '/settings'; }}> - - Settings - - { - handleMenuClose(); - deleteToken(); - window.location.reload(); - }}> - - Logout - - - - - - - - window.location.href = '/dashboard'}> - - - - - - - - - - - - - - - - window.location.href = '/dashboard/console'}> - - - - - - - + + { - setAnchorEl(event.currentTarget); - }; - - const handleMenuClose = () => { - setAnchorEl(null); - }; +export default function DashboardUsers() { return ( - - - - Admin Dashboard - - - - - - { handleMenuClose(); window.location.href = '/dashboard'; }}> - - Dashboard - - - - Profile - - - - My account - - { handleMenuClose(); window.location.href = '/settings'; }}> - - Settings - - { - handleMenuClose(); - deleteToken(); - window.location.reload(); - }}> - - Logout - - - - - - - - window.location.href = '/dashboard'}> - - - - - - - - - - - - - - - - window.location.href = '/dashboard/console'}> - - - - - - - + + - {/* Hi {localStorage.getItem('token')} */} - - - - - - - - - - - - - - - - - - - - + + Users Demo Page + diff --git a/src/Settings/SettingsInfo.js b/src/Settings/SettingsInfo.js index b821dfa..9c420bf 100644 --- a/src/Settings/SettingsInfo.js +++ b/src/Settings/SettingsInfo.js @@ -1,138 +1,33 @@ -import React, { useState } from 'react'; +import React from 'react'; import { Box, - ListItem, - ListItemText, - List, - Drawer, - IconButton, - Divider, CssBaseline, - AppBar, Toolbar, Typography, - Menu, - MenuItem, } from '@mui/material'; -import PeopleIcon from '@mui/icons-material/PeopleOutline'; -import DashboardIcon from '@mui/icons-material/DashboardOutlined'; -import BarChartIcon from '@mui/icons-material/BarChartOutlined'; -import SettingsIcon from '@mui/icons-material/SettingsOutlined'; -import LogoutIcon from '@mui/icons-material/LogoutOutlined'; -import AccountCircleIcon from '@mui/icons-material/AccountCircleOutlined'; import { ThemeProvider } from '@mui/material/styles'; import theme from '../theme'; -import deleteToken from '../core/deleteToken'; import '../metadata.json' import { DashboardInfo } from '../widgets/WidgetStatic' - -const drawerWidth = 240; +import { SidebarSettings } from '../widgets/Sidebar'; +import { AppBarFull } from '../widgets/AppBar'; export default function SettingsInfo() { - const [anchorEl, setAnchorEl] = useState(null); - const openMenu = Boolean(anchorEl); - - - const handleMenuClick = (event) => { - setAnchorEl(event.currentTarget); - }; - - const handleMenuClose = () => { - setAnchorEl(null); - }; - return ( - - - - Admin Dashboard - - - - - - { handleMenuClose(); window.location.href = '/dashboard'; }}> - - Dashboard - - - - Profile - - - - My account - - { handleMenuClose(); window.location.href = '/settings'; }}> - - Settings - - { - handleMenuClose(); - deleteToken(); - window.location.reload(); - }}> - - Logout - - - - - - - - - - - - - - - - - - - - window.location.href = '/settings/info'}> - - - - - - + + - - System Information - - + + System Information + + diff --git a/src/Settings/SettingsMain.js b/src/Settings/SettingsMain.js index 8ad025d..46a3ba7 100644 --- a/src/Settings/SettingsMain.js +++ b/src/Settings/SettingsMain.js @@ -1,51 +1,21 @@ import React, { useState } from 'react'; import { Box, - ListItem, - ListItemText, - List, - Drawer, - IconButton, - Divider, CssBaseline, - AppBar, Toolbar, Typography, - Menu, - MenuItem, Switch, FormControlLabel - } from '@mui/material'; -import PeopleIcon from '@mui/icons-material/PeopleOutline'; -import DashboardIcon from '@mui/icons-material/DashboardOutlined'; -import BarChartIcon from '@mui/icons-material/BarChartOutlined'; -import SettingsIcon from '@mui/icons-material/SettingsOutlined'; -import LogoutIcon from '@mui/icons-material/LogoutOutlined'; -import AccountCircleIcon from '@mui/icons-material/AccountCircleOutlined'; -import InfoIcon from '@mui/icons-material/InfoOutlined'; -import UpdateIcon from '@mui/icons-material/SystemUpdateAltOutlined'; import { ThemeProvider } from '@mui/material/styles'; import theme from '../theme'; -import deleteToken from '../core/deleteToken'; - - +import { SidebarSettings } from '../widgets/Sidebar'; +import { AppBarFull } from '../widgets/AppBar'; import {toggleDeveloperMode, getDeveloperMode } from '../core/configEdit'; -const drawerWidth = 240; export default function SettingsMain() { - const [anchorEl, setAnchorEl] = useState(null); - const openMenu = Boolean(anchorEl); - let [developerMode, setDeveloperMode] = useState(getDeveloperMode()); - - const handleMenuClick = (event) => { - setAnchorEl(event.currentTarget); - }; - - const handleMenuClose = () => { - setAnchorEl(null); - }; + const [developerMode, setDeveloperMode] = useState(getDeveloperMode()); const handleDeveloperModeChange = (e) => { setDeveloperMode(!developerMode); @@ -56,91 +26,8 @@ export default function SettingsMain() { - - - - Admin Dashboard - - - - - - { handleMenuClose(); window.location.href = '/dashboard'; }}> - - Dashboard - - - - Profile - - - - My account - - { handleMenuClose(); window.location.href = '/settings'; }}> - - Settings - - { - handleMenuClose(); - deleteToken(); - window.location.reload(); - }}> - - Logout - - - - - - - - - - - - - - - - - - - - - - { window.location.href = '/settings/info'; }}/> - - {getDeveloperMode() && ( - - - - - )} - - - + + { - setAnchorEl(event.currentTarget); - }; - - const handleMenuClose = () => { - setAnchorEl(null); - }; - return ( - - - - Admin Dashboard - - - - - - - - Profile - - - - My account - - { handleMenuClose(); window.location.href = '/settings'; }}> - - Settings - - { - handleMenuClose(); - deleteToken(); - window.location.reload(); - }}> - - Logout - - - - - - - - window.location.href = '/dashboard'}> - - - - - - - - - - - - - - - - window.location.href = '/dashboard/console'}> - - - - - - - + + { + return ( + + + + + Admin Dashboard + + + + + ) +} + +export const AppBarFull = () => { + const [anchorEl, setAnchorEl] = useState(null); + const openMenu = Boolean(anchorEl); + + const handleMenuClick = (event) => { + setAnchorEl(event.currentTarget); + }; + + const handleMenuClose = () => { + setAnchorEl(null); + }; + + return ( + + + + + Admin Dashboard + + + + + + { handleMenuClose(); window.location.href = '/dashboard'; }}> + + Dashboard + + + + Profile + + + + My account + + { handleMenuClose(); window.location.href = '/settings'; }}> + + Settings + + { + handleMenuClose(); + deleteToken(); + window.location.reload(); + }}> + + Logout + + + + + + + ) +} diff --git a/src/widgets/ProgressBar.js b/src/widgets/ProgressBar.js index f61c68f..3102945 100644 --- a/src/widgets/ProgressBar.js +++ b/src/widgets/ProgressBar.js @@ -1,8 +1,8 @@ import React, { useState, useEffect } from 'react'; import { Box, LinearProgress, Typography, Container } from '@mui/material'; import theme from '../theme'; -import { AppBar, Toolbar } from '@mui/material'; import { ThemeProvider } from '@mui/material/styles'; +import { AppBarFull } from './AppBar'; const ProgressBar = () => { const [progress, setProgress] = useState(0); @@ -25,13 +25,7 @@ const ProgressBar = () => { return ( - - - - Admin Dashboard - - - + { + return ( + + + + + + + + + + + + + + + + + + + { window.location.href = '/settings/info'; }}/> + + {getDeveloperMode() && ( + + + + + )} + + + + + ) +} + +export const SidebarMain = () => { + return ( + + + + + window.location.href = '/dashboard'}> + + + + + + + + + + + + + + + + window.location.href = '/dashboard/console'}> + + + + + + + + + ) +} diff --git a/src/widgets/WidgetsStatistics.js b/src/widgets/WidgetsStatistics.js index 0be4918..f22bb90 100644 --- a/src/widgets/WidgetsStatistics.js +++ b/src/widgets/WidgetsStatistics.js @@ -32,7 +32,7 @@ export const SystemMon = () => { return ( - { bgcolor: 'background.paper', borderRadius: 2, boxShadow: 3, - width: '500px' + minWidth: '260px', + maxWidth: '500px', + width: '100%' }}> System Monitor @@ -121,7 +123,9 @@ export const WebsiteAvailability = () => { bgcolor: 'background.paper', borderRadius: 2, boxShadow: 3, - width: '500px' + minWidth: '260px', + maxWidth: '500px', + width: '100%' }}> Services Avability