From f4da58ab6ca2aabc8b4509f97a8dae87ae61dd1a Mon Sep 17 00:00:00 2001 From: SnippetsX Date: Tue, 12 Nov 2024 01:35:39 +0300 Subject: [PATCH] added dev login --- generatetoken.js | 10 ++ package.json | 4 +- src/App.js | 3 +- src/Configuration/ConfiugrationMain.js | 2 + src/Dashboard/DashboardMain.js | 2 +- src/Dashboard/DashboardUsers.js | 161 +++++++++++++++++++++++++ src/Login/LoginDev.js | 75 ++++++++++++ src/Settings/SettingsInfo.js | 15 +-- src/Terminal/TerminalPage.js | 12 -- src/metadata.json | 2 +- 10 files changed, 258 insertions(+), 28 deletions(-) create mode 100644 generatetoken.js create mode 100644 src/Configuration/ConfiugrationMain.js create mode 100644 src/Dashboard/DashboardUsers.js create mode 100644 src/Login/LoginDev.js diff --git a/generatetoken.js b/generatetoken.js new file mode 100644 index 0000000..12814b7 --- /dev/null +++ b/generatetoken.js @@ -0,0 +1,10 @@ +const fs = require('fs'); + +const filePath = 'authtoken.json'; + +if (!fs.existsSync(filePath)) { + const randomToken = (Math.random().toString(36).substring(2, 10)); + console.log("You're token is ", randomToken); + fs.writeFileSync(filePath, JSON.stringify({ token: randomToken }, null, 2)); +} + diff --git a/package.json b/package.json index f1dc36b..494fc6b 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "xterm": "^5.3.0" }, "scripts": { - "start": "node generate-buildno.js && react-scripts start", - "build": "node generate-buildno.js && react-scripts build", + "start": "node generatetoken.js && node generate-buildno.js && react-scripts start", + "build": "node generatetoken.js && node generate-buildno.js && react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, diff --git a/src/App.js b/src/App.js index 9f5e6df..409e01f 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 metadata from './metadata.json'; import './App.css' import useToken from './core/useToken'; @@ -13,7 +14,7 @@ import Terminal from './Terminal/TerminalPage' function App() { const { token, setToken } = useToken(); - if(!token){ + if(!token && !(['DEV', 'ALPHA', 'BETA'].includes(metadata.buildTag))){ return } diff --git a/src/Configuration/ConfiugrationMain.js b/src/Configuration/ConfiugrationMain.js new file mode 100644 index 0000000..e6fb461 --- /dev/null +++ b/src/Configuration/ConfiugrationMain.js @@ -0,0 +1,2 @@ +import React from "react"; + diff --git a/src/Dashboard/DashboardMain.js b/src/Dashboard/DashboardMain.js index 9ee0511..561e38d 100644 --- a/src/Dashboard/DashboardMain.js +++ b/src/Dashboard/DashboardMain.js @@ -26,7 +26,7 @@ import { ThemeProvider } from '@mui/material/styles'; import theme from '../theme'; import deleteToken from '../core/deleteToken'; import {SystemMon, WebsiteAvailability} from '../widgets/WidgetsStatistics' -import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView'; + const drawerWidth = 240; diff --git a/src/Dashboard/DashboardUsers.js b/src/Dashboard/DashboardUsers.js new file mode 100644 index 0000000..c4522e6 --- /dev/null +++ b/src/Dashboard/DashboardUsers.js @@ -0,0 +1,161 @@ +import React, { useState } 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; + +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'}> + + + + + + + + + + {/* Hi {localStorage.getItem('token')} */} + + + + + + + + + + + + + + + + + + + + + + + + ); +} \ No newline at end of file diff --git a/src/Login/LoginDev.js b/src/Login/LoginDev.js new file mode 100644 index 0000000..a45bb4c --- /dev/null +++ b/src/Login/LoginDev.js @@ -0,0 +1,75 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; +import { Button, Container, TextField, Typography, AppBar, Toolbar, Box } from '@mui/material'; +import { ThemeProvider } from '@mui/material/styles'; +import theme from '../theme'; +import {loginUser} from './LoginServerSend' +import './LoginPage.css' +import { sha256 } from 'js-sha256'; +import authtoken from '../authtoken.json'; + +export default function Login({ setToken }) { + const [token, setToken] = useState(''); + const [msg, setMsg] = useState(''); + + const handleSubmit = async e => { + e.preventDefault(); + + setMsg(true); + } + } + + return( + + + + + Admin Dashboard + + + + + + + + + Please Enter Developer Token + + + setPassword(e.target.value)} + /> + + + + + + ) +} \ No newline at end of file diff --git a/src/Settings/SettingsInfo.js b/src/Settings/SettingsInfo.js index 9e2b028..b821dfa 100644 --- a/src/Settings/SettingsInfo.js +++ b/src/Settings/SettingsInfo.js @@ -19,7 +19,6 @@ 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 MenuIcon from '@mui/icons-material/Menu'; import AccountCircleIcon from '@mui/icons-material/AccountCircleOutlined'; import { ThemeProvider } from '@mui/material/styles'; import theme from '../theme'; @@ -30,19 +29,9 @@ import { DashboardInfo } from '../widgets/WidgetStatic' const drawerWidth = 240; export default function SettingsInfo() { - const [open, setOpen] = useState(false); const [anchorEl, setAnchorEl] = useState(null); const openMenu = Boolean(anchorEl); - const handleDrawer = () => { - if(open === false){ - setOpen(true); - } - else{ - setOpen(false); - } - }; - const handleMenuClick = (event) => { setAnchorEl(event.currentTarget); @@ -128,6 +117,10 @@ export default function SettingsInfo() { + window.location.href = '/settings/info'}> + + + diff --git a/src/Terminal/TerminalPage.js b/src/Terminal/TerminalPage.js index 0d37e5c..b061275 100644 --- a/src/Terminal/TerminalPage.js +++ b/src/Terminal/TerminalPage.js @@ -21,7 +21,6 @@ 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 MenuIcon from '@mui/icons-material/Menu'; import AccountCircleIcon from '@mui/icons-material/AccountCircleOutlined'; import { ThemeProvider } from '@mui/material/styles'; import theme from '../theme'; @@ -33,20 +32,9 @@ import 'xterm/css/xterm.css'; const drawerWidth = 240; export default function TerminalPage() { - const [open, setOpen] = useState(false); const [anchorEl, setAnchorEl] = useState(null); const openMenu = Boolean(anchorEl); - const handleDrawer = () => { - if(open === false){ - setOpen(true); - } - else{ - setOpen(false); - } - }; - - const handleMenuClick = (event) => { setAnchorEl(event.currentTarget); }; diff --git a/src/metadata.json b/src/metadata.json index 51202ff..d4e0988 100644 --- a/src/metadata.json +++ b/src/metadata.json @@ -1 +1 @@ -{"buildMajor":1,"buildMinor":0,"buildRevision":2,"buildTag":"DEV"} \ No newline at end of file +{"buildMajor":1,"buildMinor":0,"buildRevision":5,"buildTag":"DEV"} \ No newline at end of file