mirror of
https://github.com/hubHarmony/servii-frontend.git
synced 2024-11-18 05:40:31 +00:00
[~] Fixed poor optimisation.
This commit is contained in:
parent
02405669f3
commit
74d05691ca
@ -5,12 +5,8 @@ const ServerCard = ({ color, status, version, link, name, onRunClick, onStopClic
|
|||||||
|
|
||||||
const getStatusColor = () => {
|
const getStatusColor = () => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 'En cours':
|
case true:
|
||||||
return 'green';
|
return 'green';
|
||||||
case 'Démarrage':
|
|
||||||
return 'orange';
|
|
||||||
case 'Hors ligne':
|
|
||||||
return 'gray';
|
|
||||||
default:
|
default:
|
||||||
return 'gray';
|
return 'gray';
|
||||||
}
|
}
|
||||||
@ -49,12 +45,11 @@ const ServerCard = ({ color, status, version, link, name, onRunClick, onStopClic
|
|||||||
</span>
|
</span>
|
||||||
<div className={styles.name}>{name}</div>
|
<div className={styles.name}>{name}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.statusText}>{status}</div>
|
|
||||||
<div className={styles.buttonContainer}>
|
<div className={styles.buttonContainer}>
|
||||||
{status === 'Hors ligne' && (
|
{status && (
|
||||||
<button className={styles.runButton} onClick={handleRun}>Démarrer</button>
|
<button className={styles.runButton} onClick={handleRun}>Démarrer</button>
|
||||||
)}
|
)}
|
||||||
{status === 'En cours' && (
|
{!status && (
|
||||||
<button className={styles.stopButton} onClick={handleStop}>Arrêter</button>
|
<button className={styles.stopButton} onClick={handleStop}>Arrêter</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -37,11 +37,6 @@
|
|||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.statusText {
|
|
||||||
font-size: 1rem;
|
|
||||||
margin-top: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.version {
|
.version {
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
|
@ -43,6 +43,7 @@ const DashboardPage = ({ user }) => {
|
|||||||
const handleRunServer = async (serverName) => {
|
const handleRunServer = async (serverName) => {
|
||||||
try {
|
try {
|
||||||
await serviiApi.serverRun(serverName);
|
await serviiApi.serverRun(serverName);
|
||||||
|
await loadServers();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error starting server:', error);
|
console.error('Error starting server:', error);
|
||||||
}
|
}
|
||||||
@ -51,6 +52,7 @@ const DashboardPage = ({ user }) => {
|
|||||||
const handleStopServer = async (serverName) => {
|
const handleStopServer = async (serverName) => {
|
||||||
try {
|
try {
|
||||||
await serviiApi.serverStop(serverName);
|
await serviiApi.serverStop(serverName);
|
||||||
|
await loadServers();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error stopping server:', error);
|
console.error('Error stopping server:', error);
|
||||||
}
|
}
|
||||||
@ -59,7 +61,7 @@ const DashboardPage = ({ user }) => {
|
|||||||
const handleDeleteServer = async (serverName) => {
|
const handleDeleteServer = async (serverName) => {
|
||||||
try {
|
try {
|
||||||
await serviiApi.serverDelete(serverName);
|
await serviiApi.serverDelete(serverName);
|
||||||
loadServers();
|
await loadServers();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting server:', error);
|
console.error('Error deleting server:', error);
|
||||||
}
|
}
|
||||||
@ -79,10 +81,9 @@ const DashboardPage = ({ user }) => {
|
|||||||
<ServerCard
|
<ServerCard
|
||||||
key={index}
|
key={index}
|
||||||
color="#f0f0f0"
|
color="#f0f0f0"
|
||||||
status={server.running ? 'En cours' : 'Hors ligne'}
|
status={server.running}
|
||||||
version={server.version}
|
version={server.version}
|
||||||
name={server.name}
|
name={server.name}
|
||||||
link="#"
|
|
||||||
onRunClick={() => handleRunServer(server.name)}
|
onRunClick={() => handleRunServer(server.name)}
|
||||||
onStopClick={() => handleStopServer(server.name)}
|
onStopClick={() => handleStopServer(server.name)}
|
||||||
onDeleteClick={() => handleDeleteServer(server.name)}
|
onDeleteClick={() => handleDeleteServer(server.name)}
|
||||||
|
Loading…
Reference in New Issue
Block a user