Merge branch 'dev'
All checks were successful
Testing Example / build-and-test (push) Successful in 2m6s

This commit is contained in:
SnippetsX 2024-11-30 01:35:43 +03:00
commit f4b48eaaad
14 changed files with 122 additions and 17 deletions

View File

@ -3,6 +3,7 @@ on:
push:
branches:
- master
- dev
jobs:
build-and-test:
@ -82,6 +83,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ env.VERSION }}
name: Release v${{ env.VERSION }}
files: |
release-artifacts/admin_dashboard-${{ env.VERSION }}.zip
draft: false

4
.gitignore vendored
View File

@ -14,6 +14,10 @@
/build
*/build
/src/authtoken.json
<<<<<<< HEAD
=======
>>>>>>> dev
# misc
.DS_Store
.env.local

View File

@ -1,10 +1,11 @@
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
token VARCHAR(255) NOT NULL,
username VARCHAR(50) NOT NULL UNIQUE,
password_hash VARCHAR(255) NOT NULL,
perms VARCHAR(255) NOT NULL
);
-- Test user with admin permissions
INSERT INTO users (username, password_hash, perms)
VALUES ('admin', 'ecd71870d1963316a97e3ac3408c9835ad8cf0f3c1bc703527c30265534f75ae', 'admin');
INSERT INTO users (token, username, password_hash, perms)
VALUES ('be01e88cc202593292d503e4ed9e51e9eb217093662efbb145030ba51b97c22a','admin', 'ecd71870d1963316a97e3ac3408c9835ad8cf0f3c1bc703527c30265534f75ae', 'admin');

View File

@ -1,6 +1,6 @@
const fs = require('fs');
const filePath = 'authtoken.json';
const filePath = 'src/authtoken.json';
if (!fs.existsSync(filePath)) {
const randomToken = (Math.random().toString(36).substring(2, 10));

View File

@ -1,3 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
Disallow: /

View File

@ -11,6 +11,7 @@ import metadata from './metadata.json';
import './App.css'
import useToken from './core/useToken';
import Terminal from './Terminal/TerminalPage'
import DashboardReports from './Dashboard/DashboardReports';
function App() {
@ -26,8 +27,8 @@ function App() {
<Route path='/' element={<Navigate to='/dashboard' />} />
<Route path="/dashboard" element={<Dashboard/>} />
<Route path="/dashboard/users" element={<DashboardUsers />} />
{/* <Route path="/dashboard/configuration" element={<Settings />} />
<Route path="/dashboard/reports" element={<Reports />} /> */}
{/* <Route path="/dashboard/configuration" element={<Settings />} /> */}
<Route path="/dashboard/reports" element={<DashboardReports />} />
<Route path="/dashboard/console" element={<Terminal/>} />
<Route path="/settings" element={<SettingsMain/>} />
<Route path="/settings/info" element={<SettingsInfo/>} />

View File

@ -0,0 +1,33 @@
import React from 'react';
import {
Box,
CssBaseline,
Toolbar,
} from '@mui/material';
import { ThemeProvider } from '@mui/material/styles';
import theme from '../theme';
import { SidebarMain } from '../widgets/Sidebar';
import { AppBarFull } from '../widgets/AppBar';
import WidgetReport from '../widgets/WidgetReport';
export default function DashboardReports() {
return (
<ThemeProvider theme={theme}>
<Box sx={{ display: 'flex' }}>
<CssBaseline />
<AppBarFull />
<SidebarMain />
<Box
component="main"
sx={{ flexGrow: 1, bgcolor: 'background.default', p: 3 }}
>
<Toolbar />
{/* <Typography variant="h4">Hi {localStorage.getItem('token')}</Typography> */}
<Box sx={{ display: 'flex', gap: 3 }}>
<WidgetReport />
</Box>
</Box>
</Box>
</ThemeProvider>
);
}

View File

View File

@ -0,0 +1,28 @@
import React from "react";
import { ThemeProvider, Box, Typography } from "@mui/material";
import { theme } from "../theme";
const SettingsDatabaseConfig = () => {
return (
<ThemeProvider theme={theme}>
<Box sx={{ display: 'flex' }}>
<CssBaseline />
<AppBarFull />
<SidebarSettings />
<Box
component="main"
sx={{ flexGrow: 1, bgcolor: 'background.default', p: 3 }}
>
<Toolbar />
<Typography variant="h5" sx={{ mb: 3, color: 'primary.main' }}>
Database Configuration
</Typography>
</Box>
</Box>
</ThemeProvider>
);
};
export default SettingsDatabaseConfig;

View File

@ -65,3 +65,9 @@ export function getDeveloperMode() {
throw error;
});
}
export function getDatabaseConfig() {
return getConfig().then(config => config.database);
}

View File

@ -1 +1 @@
{"buildMajor":1,"buildMinor":0,"buildRevision":16,"buildTag":"DEV"}
{"buildMajor":1,"buildMinor":0,"buildRevision":21,"buildTag":"DEV"}

View File

@ -9,6 +9,7 @@ import DashboardIcon from '@mui/icons-material/DashboardOutlined';
import SettingsIcon from '@mui/icons-material/SettingsOutlined';
import LogoutIcon from '@mui/icons-material/LogoutOutlined';
import deleteToken from "../core/deleteToken";
import metadata from "../metadata.json";
const drawerWidth = 240;
@ -43,7 +44,10 @@ export const AppBarFull = () => {
<AppBar position="fixed" sx={{ width: `calc(100% - ${drawerWidth}px)`, ml: `${drawerWidth}px` }}>
<Toolbar>
<Typography variant="h6" noWrap sx={{ flexGrow: 1 }}>
Admin Dashboard
{['DEV', 'ALPHA', 'BETA'].includes(metadata.buildTag) ?
`Admin Dashboard ${metadata.buildTag}` :
'Admin Dashboard'
}
</Typography>
<IconButton
color="inherit"

View File

@ -31,24 +31,28 @@ export const SidebarSettings = () => {
>
<Divider />
<List>
<ListItem button key="Database Configuration" selected={window.location.pathname === '/settings'}>
<ListItem button key="Main Settings" onClick={() => window.location.href = '/settings'}>
<DashboardIcon sx={{ marginRight: 2, color: '#FFFFFF'}}/>
<ListItemText primary="Main Settings" sx={{ color: '#FFFFFF' }} />
</ListItem>
<ListItem button key="Database Configuration" onClick={() => window.location.href = '/settings/database'}>
<DashboardIcon sx={{ marginRight: 2, color: '#FFFFFF'}}/>
<ListItemText primary="Database Configuration" sx={{ color: '#FFFFFF' }} />
</ListItem>
<ListItem button key="Access lists" selected={window.location.pathname === '/settings/access'}>
<ListItem button key="Access lists" onClick={() => window.location.href = '/settings/access'}>
<PeopleIcon sx={{ marginRight: 2, color: '#FFFFFF' }}/>
<ListItemText primary="Access lists" sx={{ color: '#FFFFFF' }} />
</ListItem>
<ListItem button key="Update" selected={window.location.pathname === '/settings/update'}>
<ListItem button key="Update" onClick={() => window.location.href = '/settings/update'}>
<UpdateIcon sx={{ marginRight: 2, color: '#FFFFFF' }}/>
<ListItemText primary="Update" sx={{ color: '#FFFFFF' }} />
</ListItem>
<ListItem button key="Info" selected={window.location.pathname === '/settings/info'}>
<ListItem button key="Info" onClick={() => window.location.href = '/settings/info'}>
<InfoIcon sx={{ marginRight: 2, color: '#FFFFFF' }}/>
<ListItemText primary="Info" sx={{ color: '#FFFFFF' }} onClick={() => { window.location.href = '/settings/info'; }}/>
<ListItemText primary="Info" sx={{ color: '#FFFFFF' }} />
</ListItem>
{getDeveloperMode() && (
<ListItem button key="Debug" selected={window.location.pathname === '/settings/debug'}>
<ListItem button key="Debug" onClick={() => window.location.href = '/settings/debug'}>
<BarChartIcon sx={{ marginRight: 2, color: '#FFFFFF' }}/>
<ListItemText primary="Debug" sx={{ color: '#FFFFFF' }} />
</ListItem>
@ -82,15 +86,15 @@ export const SidebarMain = () => {
<DashboardIcon sx={{ marginRight: 2, color: '#FFFFFF'}}/>
<ListItemText primary="Dashboard" sx={{ color: '#FFFFFF' }} />
</ListItem>
<ListItem button key="Users">
<ListItem button key="Users" onClick={() => window.location.href = '/dashboard/users'}>
<PeopleIcon sx={{ marginRight: 2, color: '#FFFFFF' }}/>
<ListItemText primary="Users" sx={{ color: '#FFFFFF' }} />
</ListItem>
<ListItem button key="Reports">
<ListItem button key="Reports" onClick={() => window.location.href = '/dashboard/reports'}>
<BarChartIcon sx={{ marginRight: 2, color: '#FFFFFF' }}/>
<ListItemText primary="Reports" sx={{ color: '#FFFFFF' }} />
</ListItem>
<ListItem button key="Server Configuration">
<ListItem button key="Server Configuration" onClick={() => window.location.href = '/dashboard/configuration'}>
<ConstructionOutlinedIcon sx={{ marginRight: 2, color: '#FFFFFF' }}/>
<ListItemText primary="Server Configuration" sx={{ color: '#FFFFFF' }} />
</ListItem>

View File

@ -0,0 +1,22 @@
import React from "react";
import { Box, CssBaseline, Toolbar } from "@mui/material";
import { ThemeProvider } from "@mui/material/styles";
import theme from "../theme";
export default function WidgetReport() {
return (
<ThemeProvider theme={theme}>
<Box sx={{ display: "flex" }}>
<CssBaseline />
<Box
component="main"
sx={{ flexGrow: 1, bgcolor: "background.default", p: 3 }}
>
<Toolbar />
</Box>
</Box>
</ThemeProvider>
);
}