diff --git a/src/pages/ServerConsole/ServerConsole.jsx b/src/pages/ServerConsole/ServerConsole.jsx
index a3eefd2..a658bb9 100644
--- a/src/pages/ServerConsole/ServerConsole.jsx
+++ b/src/pages/ServerConsole/ServerConsole.jsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from 'react';
+import { useEffect, useState, useRef } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import styles from './ServerConsole.module.scss';
import serviiApi from "../../service/api.tsx";
@@ -11,6 +11,13 @@ const ServerConsole = ({ user }) => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const [logs, setLogs] = useState('');
+ const [message, setMessage] = useState('');
+
+ const logsEndRef = useRef(null);
+
+ const scrollToBottom = () => {
+ logsEndRef.current?.scrollIntoView({ behavior: "smooth" });
+ };
useEffect(() => {
const fetchServerLogs = async () => {
@@ -20,11 +27,10 @@ const ServerConsole = ({ user }) => {
try {
const response = await serviiApi.fetchLogs(serverName);
if (response.return_code === 200) {
- // Nettoyer la chaîne de caractères en supprimant les [ ] et en remplaçant les \\n
let logString = response.message;
- logString = logString.slice(1, -1); // Supprime les crochets [ ] au début et à la fin
- logString = logString.replace(/\\n/g, '\n'); // Remplace les \\n par de véritables sauts de ligne
- logString = logString.replace(/\\\"/g, '"'); // Supprime les échappements de guillemets
+ logString = logString.slice(1, -1);
+ logString = logString.replace(/\\n/g, '\n');
+ logString = logString.replace(/\\\"/g, '"');
setLogs(logString);
} else {
setError(`Erreur lors de la récupération des logs: ${response.message}`);
@@ -39,6 +45,17 @@ const ServerConsole = ({ user }) => {
fetchServerLogs();
}, [serverName]);
+ useEffect(() => {
+ scrollToBottom();
+ }, [logs]);
+
+ const handleSendMessage = () => {
+ if (message.trim()) {
+ console.log(`Message envoyé: ${message}`);
+ setMessage('');
+ }
+ };
+
if (loading) {
return
{logs}+ +
*/ } -.sidebar { - overflow: hidden; -} - -.logContainer { +.chatInputContainer { + display: flex; width: 100%; - height: calc(100% - 3rem); - overflow-y: auto; + padding: 0.5rem; + background-color: #1D1836; + border-top: .1rem solid #343947; + border-left: .1rem solid #343947; + border-right: .1rem solid #343947; +} + +.chatInput { + flex: 1; + padding: 0.5rem; + border: .1rem solid #343947; + background-color: #2C2A3E; + color: #ffffff; + font-size: 0.9rem; + box-sizing: border-box; +} + +.sendButton { + margin-left: 0.5rem; + padding: 0.5rem 1rem; + background-color: #3E3B59; + color: #ffffff; + border: none; + cursor: pointer; + font-size: 0.9rem; + transition: background-color 0.3s; +} + +.sendButton:hover { + background-color: #5A567E; } diff --git a/src/pages/ServerDetails/ServerDetails.module.scss b/src/pages/ServerDetails/ServerDetails.module.scss index 6e4e973..1642042 100644 --- a/src/pages/ServerDetails/ServerDetails.module.scss +++ b/src/pages/ServerDetails/ServerDetails.module.scss @@ -1,7 +1,6 @@ .container { display: flex; - min-height: 100vh; - margin-top: var(--navbar-height); + min-height: calc(100vh - var(--navbar-height)); } .sidebar { @@ -83,17 +82,20 @@ } .serverDetailsContainer { + margin-top: var(--navbar-height); flex: 1; - margin-left: 20rem; - padding-top: 2rem; + margin-left: 20rem; + padding-top: 1rem; background-color: var(--main-bg-color); display: flex; flex-direction: column; align-items: center; color: var(--text-color); box-sizing: border-box; + overflow-y: auto; } + .navbar { position: fixed; top: 0;