This commit is contained in:
AntoninoP 2024-07-04 11:54:23 +02:00
commit c1e6cd4829
5 changed files with 9 additions and 17 deletions

1
package-lock.json generated
View File

@ -9760,6 +9760,7 @@
"version": "10.0.5",
"resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-10.0.5.tgz",
"integrity": "sha512-mNKt2jBXJg4O7pSdbNUfDdTsK9FIdikfsIE/yUCxbAEXl4HMyJaivrVFcn3Elvt5xvCQYhUZm+hqTIu1UXM3Pw==",
"license": "MIT",
"dependencies": {
"clsx": "^2.1.0"
},

View File

@ -5,12 +5,8 @@ const ServerCard = ({ color, status, version, link, name, onRunClick, onStopClic
const getStatusColor = () => {
switch (status) {
case 'En cours':
case true:
return 'green';
case 'Démarrage':
return 'orange';
case 'Hors ligne':
return 'gray';
default:
return 'gray';
}
@ -49,12 +45,11 @@ const ServerCard = ({ color, status, version, link, name, onRunClick, onStopClic
</span>
<div className={styles.name}>{name}</div>
</div>
<div className={styles.statusText}>{status}</div>
<div className={styles.buttonContainer}>
{status === 'Hors ligne' && (
{status && (
<button className={styles.runButton} onClick={handleRun}>Démarrer</button>
)}
{status === 'En cours' && (
{!status && (
<button className={styles.stopButton} onClick={handleStop}>Arrêter</button>
)}
</div>

View File

@ -37,11 +37,6 @@
font-size: 1.5rem;
}
.statusText {
font-size: 1rem;
margin-top: 0.5rem;
}
.version {
font-size: 1.5rem;
margin-left: auto;

View File

@ -43,6 +43,7 @@ const DashboardPage = ({ user }) => {
const handleRunServer = async (serverName) => {
try {
await serviiApi.serverRun(serverName);
await loadServers();
} catch (error) {
console.error('Error starting server:', error);
}
@ -51,6 +52,7 @@ const DashboardPage = ({ user }) => {
const handleStopServer = async (serverName) => {
try {
await serviiApi.serverStop(serverName);
await loadServers();
} catch (error) {
console.error('Error stopping server:', error);
}
@ -59,7 +61,7 @@ const DashboardPage = ({ user }) => {
const handleDeleteServer = async (serverName) => {
try {
await serviiApi.serverDelete(serverName);
loadServers();
await loadServers();
} catch (error) {
console.error('Error deleting server:', error);
}
@ -79,10 +81,9 @@ const DashboardPage = ({ user }) => {
<ServerCard
key={index}
color="#f0f0f0"
status={server.running ? 'En cours' : 'Hors ligne'}
status={server.running}
version={server.version}
name={server.name}
link="#"
onRunClick={() => handleRunServer(server.name)}
onStopClick={() => handleStopServer(server.name)}
onDeleteClick={() => handleDeleteServer(server.name)}

View File

@ -1,7 +1,7 @@
// src/services/serverService.ts
import {getAuth} from 'firebase/auth';
const apiUrl: string = 'http://176.165.62.226:3000';
const apiUrl: string = 'https://www.servii.fr/api';
interface ApiResponse {
return_code: number;