diff --git a/src/pages/DashboardPage/DashboardPage.jsx b/src/pages/DashboardPage/DashboardPage.jsx
index 965bd52..adde911 100644
--- a/src/pages/DashboardPage/DashboardPage.jsx
+++ b/src/pages/DashboardPage/DashboardPage.jsx
@@ -88,9 +88,7 @@ const DashboardPage = ({ user }) => {
const handleCopyAddress = () => {
const address = `${subdomain}.servii.fr`;
navigator.clipboard.writeText(address)
- .then(() => {
- console.log('Address copied to clipboard');
- })
+
};
if (loading) {
diff --git a/src/pages/ServerConsole/ServerConsole.jsx b/src/pages/ServerConsole/ServerConsole.jsx
index b782339..f4f8efa 100644
--- a/src/pages/ServerConsole/ServerConsole.jsx
+++ b/src/pages/ServerConsole/ServerConsole.jsx
@@ -1,5 +1,6 @@
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 serviiApi from "../../service/api.tsx";
import Loading from '../Loading/loading.jsx';
@@ -12,6 +13,8 @@ const ServerConsole = ({ user }) => {
const [error, setError] = useState(null);
const [logs, setLogs] = useState('');
const [message, setMessage] = useState('');
+ const location = useLocation();
+ const status = location.state?.status;
const logsEndRef = useRef(null);
@@ -20,7 +23,6 @@ const ServerConsole = ({ user }) => {
};
const fetchServerLogs = async () => {
- setLoading(true);
setError(null);
try {
@@ -41,7 +43,6 @@ const ServerConsole = ({ user }) => {
} catch (err) {
setError(`Erreur: ${err.message}`);
} finally {
- setLoading(false);
}
};
@@ -53,13 +54,19 @@ const ServerConsole = ({ user }) => {
scrollToBottom();
}, [logs]);
- const handleSendMessage = () => {
- if (message.trim()) {
- console.log(`Message envoyé: ${message}`);
- setMessage('');
+ const handleSendMessage = async () => {
+ if (message.trim() === "") {
+ return;
+ }
+ try {
+ const response = await serviiApi.command(message, serverName);
+ setMessage('');
fetchServerLogs();
+ } catch (err) {
+ setError(`Erreur lors de l'envoi de la commande : ${err.message}`);
}
};
+
if (loading) {
return
;
@@ -79,12 +86,23 @@ const ServerConsole = ({ user }) => {
return (
-
Console
+
+ Console {status ? '(En marche)' : '(Arrêté)'}
+
-
- {logs}
-
-
+ {status ? (
+ <>
+
+ {logs}
+
+
+ >
+ ) : (
+
+
+ Serveur hors ligne
+
+ )}
{
);
+
};
ServerConsole.propTypes = {
diff --git a/src/pages/ServerConsole/ServerConsole.module.scss b/src/pages/ServerConsole/ServerConsole.module.scss
index 1a4fd57..3e0808b 100644
--- a/src/pages/ServerConsole/ServerConsole.module.scss
+++ b/src/pages/ServerConsole/ServerConsole.module.scss
@@ -33,15 +33,15 @@
font-size: 1rem;
font-weight: 500;
border-bottom: .1rem solid #343947;
- padding-left: 1rem; /* Ajoutez du padding à l'intérieur */
+ padding-left: 1rem;
}
.logContainer {
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;
- padding: 1rem; /* Ajoutez du padding pour éviter que le texte touche les bords */
- box-sizing: border-box; /* Inclut le padding dans la taille totale */
+ padding: 1rem;
+ box-sizing: border-box;
}
.logs {
@@ -50,7 +50,7 @@
color: #ffffff;
white-space: pre-wrap;
line-height: 1.5;
- margin: 0; /* Supprimez les marges par défaut de
*/
+ margin: 0;
}
.chatInputContainer {
@@ -87,3 +87,13 @@
.sendButton:hover {
background-color: #5A567E;
}
+
+
+.offline {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ width: 100%;
+ height: 100%;
+ font-size: 1.5rem;
+}
\ No newline at end of file
diff --git a/src/pages/ServerDetails/ServerDetails.jsx b/src/pages/ServerDetails/ServerDetails.jsx
index 33575b2..033a4d5 100644
--- a/src/pages/ServerDetails/ServerDetails.jsx
+++ b/src/pages/ServerDetails/ServerDetails.jsx
@@ -12,15 +12,20 @@ import PropTypes from "prop-types";
import { FaServer, FaCogs, FaUserFriends, FaGlobe, FaHistory, FaClipboardList, FaSave, FaLock } from 'react-icons/fa';
import NotFoundPage from '../NotFoundPage/NotFoundPage';
import { NavLink } from 'react-router-dom';
+import { useLocation } from 'react-router-dom';
-const ServerDetails = ({ user }) => {
+
+const ServerDetails = ({ user }) => {
const { serverName } = useParams();
const navigate = useNavigate();
+ const location = useLocation();
+ const status = location.state?.status;
const handleQuit = () => {
navigate('/dashboard');
};
+
return (
<>
@@ -39,6 +44,7 @@ const ServerDetails = ({ user }) => {
isActive ? `${styles.menuItem} ${styles.active}` : styles.menuItem}>
Console
@@ -74,18 +80,19 @@ const ServerDetails = ({ user }) => {
Accès
+
Retour