mirror of
https://github.com/hubHarmony/servii-frontend.git
synced 2024-11-18 05:40:31 +00:00
final newdetails
This commit is contained in:
parent
e25dcbcf6a
commit
fcdbf628d8
@ -35,7 +35,6 @@ const Navbar = ({ user }) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('User data:', user);
|
|
||||||
}, [user]);
|
}, [user]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -9,6 +9,7 @@ import PropTypes from "prop-types";
|
|||||||
|
|
||||||
const ServerCard = ({ status, version, name, framework, onRunClick, onStopClick, onDeleteClick , countPlayers , maxPlayers}) => {
|
const ServerCard = ({ status, version, name, framework, onRunClick, onStopClick, onDeleteClick , countPlayers , maxPlayers}) => {
|
||||||
|
|
||||||
|
|
||||||
const getFrameworkSource = () => {
|
const getFrameworkSource = () => {
|
||||||
switch (framework) {
|
switch (framework) {
|
||||||
case "bukkit":
|
case "bukkit":
|
||||||
@ -50,7 +51,10 @@ const ServerCard = ({ status, version, name, framework, onRunClick, onStopClick,
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link to={`/server/${name}/options`} className={styles.serverCard}>
|
<Link
|
||||||
|
to={`/server/${name}/options`}
|
||||||
|
className={styles.serverCard}
|
||||||
|
state={{ status }}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<div className={styles.serverInfo}>
|
<div className={styles.serverInfo}>
|
||||||
<img src={getFrameworkSource()} alt={`${name} Icon`} className={styles.frameworkIcon} />
|
<img src={getFrameworkSource()} alt={`${name} Icon`} className={styles.frameworkIcon} />
|
||||||
|
@ -88,9 +88,7 @@ const DashboardPage = ({ user }) => {
|
|||||||
const handleCopyAddress = () => {
|
const handleCopyAddress = () => {
|
||||||
const address = `${subdomain}.servii.fr`;
|
const address = `${subdomain}.servii.fr`;
|
||||||
navigator.clipboard.writeText(address)
|
navigator.clipboard.writeText(address)
|
||||||
.then(() => {
|
|
||||||
console.log('Address copied to clipboard');
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { useEffect, useState, useRef } from 'react';
|
import { useEffect, useState, useRef } from 'react';
|
||||||
import { useParams, useNavigate } from 'react-router-dom';
|
import { useParams, useNavigate, useLocation } from 'react-router-dom';
|
||||||
|
import { FaExclamationCircle } from 'react-icons/fa';
|
||||||
import styles from './ServerConsole.module.scss';
|
import styles from './ServerConsole.module.scss';
|
||||||
import serviiApi from "../../service/api.tsx";
|
import serviiApi from "../../service/api.tsx";
|
||||||
import Loading from '../Loading/loading.jsx';
|
import Loading from '../Loading/loading.jsx';
|
||||||
@ -12,6 +13,8 @@ const ServerConsole = ({ user }) => {
|
|||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
const [logs, setLogs] = useState('');
|
const [logs, setLogs] = useState('');
|
||||||
const [message, setMessage] = useState('');
|
const [message, setMessage] = useState('');
|
||||||
|
const location = useLocation();
|
||||||
|
const status = location.state?.status;
|
||||||
|
|
||||||
const logsEndRef = useRef(null);
|
const logsEndRef = useRef(null);
|
||||||
|
|
||||||
@ -20,7 +23,6 @@ const ServerConsole = ({ user }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const fetchServerLogs = async () => {
|
const fetchServerLogs = async () => {
|
||||||
setLoading(true);
|
|
||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -41,7 +43,6 @@ const ServerConsole = ({ user }) => {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(`Erreur: ${err.message}`);
|
setError(`Erreur: ${err.message}`);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -53,14 +54,20 @@ const ServerConsole = ({ user }) => {
|
|||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
}, [logs]);
|
}, [logs]);
|
||||||
|
|
||||||
const handleSendMessage = () => {
|
const handleSendMessage = async () => {
|
||||||
if (message.trim()) {
|
if (message.trim() === "") {
|
||||||
console.log(`Message envoyé: ${message}`);
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const response = await serviiApi.command(message, serverName);
|
||||||
setMessage('');
|
setMessage('');
|
||||||
fetchServerLogs();
|
fetchServerLogs();
|
||||||
|
} catch (err) {
|
||||||
|
setError(`Erreur lors de l'envoi de la commande : ${err.message}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
}
|
}
|
||||||
@ -79,12 +86,23 @@ const ServerConsole = ({ user }) => {
|
|||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<div className={styles.containerConsole}>
|
<div className={styles.containerConsole}>
|
||||||
<div className={styles.header}>Console</div>
|
<div className={styles.header}>
|
||||||
|
Console {status ? '(En marche)' : '(Arrêté)'}
|
||||||
|
</div>
|
||||||
<div className={styles.logContainer}>
|
<div className={styles.logContainer}>
|
||||||
|
{status ? (
|
||||||
|
<>
|
||||||
<pre className={styles.logs}>
|
<pre className={styles.logs}>
|
||||||
{logs}
|
{logs}
|
||||||
</pre>
|
</pre>
|
||||||
<div ref={logsEndRef} />
|
<div ref={logsEndRef} />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div className={styles.offline}>
|
||||||
|
<FaExclamationCircle style={{ marginRight: '.6rem' }} />
|
||||||
|
<span>Serveur hors ligne</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.chatInputContainer}>
|
<div className={styles.chatInputContainer}>
|
||||||
<input
|
<input
|
||||||
@ -101,6 +119,7 @@ const ServerConsole = ({ user }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ServerConsole.propTypes = {
|
ServerConsole.propTypes = {
|
||||||
|
@ -33,15 +33,15 @@
|
|||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-bottom: .1rem solid #343947;
|
border-bottom: .1rem solid #343947;
|
||||||
padding-left: 1rem; /* Ajoutez du padding à l'intérieur */
|
padding-left: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logContainer {
|
.logContainer {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100% - 6rem); /* Prend en compte la hauteur de la barre d'en-tête et de la barre de chat */
|
height: calc(100% - 6rem);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: 1rem; /* Ajoutez du padding pour éviter que le texte touche les bords */
|
padding: 1rem;
|
||||||
box-sizing: border-box; /* Inclut le padding dans la taille totale */
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logs {
|
.logs {
|
||||||
@ -50,7 +50,7 @@
|
|||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
margin: 0; /* Supprimez les marges par défaut de <pre> */
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chatInputContainer {
|
.chatInputContainer {
|
||||||
@ -87,3 +87,13 @@
|
|||||||
.sendButton:hover {
|
.sendButton:hover {
|
||||||
background-color: #5A567E;
|
background-color: #5A567E;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.offline {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
@ -12,15 +12,20 @@ import PropTypes from "prop-types";
|
|||||||
import { FaServer, FaCogs, FaUserFriends, FaGlobe, FaHistory, FaClipboardList, FaSave, FaLock } from 'react-icons/fa';
|
import { FaServer, FaCogs, FaUserFriends, FaGlobe, FaHistory, FaClipboardList, FaSave, FaLock } from 'react-icons/fa';
|
||||||
import NotFoundPage from '../NotFoundPage/NotFoundPage';
|
import NotFoundPage from '../NotFoundPage/NotFoundPage';
|
||||||
import { NavLink } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
|
import { useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
|
|
||||||
const ServerDetails = ({ user }) => {
|
const ServerDetails = ({ user }) => {
|
||||||
const { serverName } = useParams();
|
const { serverName } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
const status = location.state?.status;
|
||||||
|
|
||||||
const handleQuit = () => {
|
const handleQuit = () => {
|
||||||
navigate('/dashboard');
|
navigate('/dashboard');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Navbar user={user} />
|
<Navbar user={user} />
|
||||||
@ -39,6 +44,7 @@ const ServerDetails = ({ user }) => {
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
|
|
||||||
<NavLink
|
<NavLink
|
||||||
|
state={{ status }}
|
||||||
to={`/server/${serverName}/console`}
|
to={`/server/${serverName}/console`}
|
||||||
className={({ isActive }) => isActive ? `${styles.menuItem} ${styles.active}` : styles.menuItem}>
|
className={({ isActive }) => isActive ? `${styles.menuItem} ${styles.active}` : styles.menuItem}>
|
||||||
<FaClipboardList /> Console
|
<FaClipboardList /> Console
|
||||||
@ -74,11 +80,12 @@ const ServerDetails = ({ user }) => {
|
|||||||
<FaLock /> Accès
|
<FaLock /> Accès
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
|
<button className={styles.BackButton} onClick={handleQuit}>Retour</button>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.serverDetailsContainer}>
|
<div className={styles.serverDetailsContainer}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="options" element={<ServerProperties user={user} />} />
|
<Route path="options" element={<ServerProperties user={user} status={status} />} />
|
||||||
<Route path="console" element={<ServerConsole user={user} />} />
|
<Route path="console" element={<ServerConsole user={user} status={status} />} />
|
||||||
<Route path="history" element={<h2>Cette fonctionnalité sera prochainement disponible.</h2>} />
|
<Route path="history" element={<h2>Cette fonctionnalité sera prochainement disponible.</h2>} />
|
||||||
<Route path="players" element={<h2>Cette fonctionnalité sera prochainement disponible.</h2>} />
|
<Route path="players" element={<h2>Cette fonctionnalité sera prochainement disponible.</h2>} />
|
||||||
<Route path="worlds" element={<h2>Cette fonctionnalité sera prochainement disponible.</h2>} />
|
<Route path="worlds" element={<h2>Cette fonctionnalité sera prochainement disponible.</h2>} />
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
&.active {
|
&.active {
|
||||||
background-color: red;
|
background-color: #1D1836;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,19 +66,17 @@
|
|||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logoutButton {
|
.BackButton {
|
||||||
margin-top: 2rem;
|
margin-top: 1rem;
|
||||||
padding: 0.75rem 1.5rem;
|
padding: 0.70rem 1.5rem;
|
||||||
background-color: #EF4444;
|
background-color: #1D1836;
|
||||||
border: none;
|
border: none;
|
||||||
color: white;
|
color: white;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 100%;
|
width: 20rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
font-size: 1.25rem;
|
||||||
|
|
||||||
.logoutButton:hover {
|
|
||||||
background-color: #DC2626;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.serverDetailsContainer {
|
.serverDetailsContainer {
|
||||||
|
Loading…
Reference in New Issue
Block a user