Merge pull request #17 from hubHarmony/frameworkChoicePage

Framework choice page
This commit is contained in:
Antoninop 2024-08-11 23:48:55 +02:00 committed by GitHub
commit 7f4ce95c13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 199 additions and 90 deletions

View File

@ -13,8 +13,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: npm ci - run: npm ci && npm run build
- run: build
- uses: FirebaseExtended/action-hosting-deploy@v0 - uses: FirebaseExtended/action-hosting-deploy@v0
with: with:
repoToken: ${{ secrets.GITHUB_TOKEN }} repoToken: ${{ secrets.GITHUB_TOKEN }}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -3,12 +3,50 @@ import styles from './CreateServer.module.scss';
import { getUserSubdomain } from "../../service/firebase"; import { getUserSubdomain } from "../../service/firebase";
import serviiApi from "../../service/api.tsx"; import serviiApi from "../../service/api.tsx";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import vanillaLogo from '../../assets/frameworks/vanilla.png';
import bukkitLogo from '../../assets/frameworks/bukkit.png';
import paperLogo from '../../assets/frameworks/paper.png';
import spigotLogo from '../../assets/frameworks/spigot.png';
const frameworks = [
{ name: 'vanilla', logo: vanillaLogo },
{ name: 'bukkit', logo: bukkitLogo },
{ name: 'spigot', logo: spigotLogo },
{ name: 'paper', logo: paperLogo },
];
const versions = {
vanilla: ['1.21', '1.20', '1.19'],
bukkit: [
'1.15.0', '1.15.1', '1.15.2', '1.15.3', '1.15.4', '1.15.5',
'1.16.0', '1.16.1', '1.16.2', '1.16.3', '1.16.4', '1.16.5',
'1.17.0', '1.17.1', '1.17.2', '1.17.3', '1.17.4', '1.17.5',
'1.18.1', '1.18.2',
'1.19.1', '1.19.2', '1.19.3', '1.19.4',
'1.20.1', '1.20.2', '1.20.4', '1.20.6'
],
spigot: ['1.21', '1.20'],
paper: [
'1.13.1', '1.13.2',
'1.14.1', '1.14.2', '1.14.3', '1.14.4',
'1.15.1', '1.15.2',
'1.16.1', '1.16.2', '1.16.3', '1.16.4', '1.16.5',
'1.17.1',
'1.18.1', '1.18.2',
'1.19.1', '1.19.2', '1.19.3', '1.19.4',
'1.20.1', '1.20.2', '1.20.4', '1.20.5', '1.20.6'
],
};
const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noServers }) => { const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noServers }) => {
const [subdomain, setSubdomain] = useState(null); const [subdomain, setSubdomain] = useState(null);
const [subdomainInput, setSubdomainInput] = useState(''); const [subdomainInput, setSubdomainInput] = useState('');
const [serverName, setServerName] = useState(''); const [serverName, setServerName] = useState('');
const [serverVersion, setServerVersion] = useState(''); const [serverVersion, setServerVersion] = useState();
const [selectedFramework, setSelectedFramework] = useState("vanilla");
const loadSubdomain = async () => { const loadSubdomain = async () => {
try { try {
@ -40,7 +78,7 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer
const handleCreateServer = async () => { const handleCreateServer = async () => {
try { try {
await onCreateServer(serverName, serverVersion); await onCreateServer(serverName, serverVersion , selectedFramework);
} catch (error) { } catch (error) {
console.error('Error creating server:', error); console.error('Error creating server:', error);
} }
@ -92,16 +130,40 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer
value={serverName} value={serverName}
onChange={(e) => setServerName(validateInput(e.target.value))} onChange={(e) => setServerName(validateInput(e.target.value))}
/> />
<div className={styles.subtitle}>Sélection du framework</div>
<div className={styles.carreContainer}>
{frameworks.map((framework, index) => (
<img
key={index}
className={`${styles.carre} ${selectedFramework === framework.name ? styles.selected : ''}`}
src={framework.logo.toLowerCase()}
alt={`${framework.name} Logo`}
onClick={() => {
setSelectedFramework(framework.name);
setServerVersion('');
}}
/>
))}
</div>
<div className={styles.subtitle}>Sélection de la version</div>
<select <select
className={styles.select} className={styles.select}
name="version" name="version"
id="version-select" id="version-select"
value={serverVersion} value={serverVersion}
onChange={(e) => setServerVersion(e.target.value)} onChange={(e) => setServerVersion(e.target.value)}
disabled={!selectedFramework}
> >
<option>Version</option> <option>Version</option>
<option value="1.21">1.21</option> {selectedFramework && versions[selectedFramework].map((version, index) => (
<option key={index} value={version}>{version}</option>
))}
</select> </select>
<div className={styles.buttonContainer}> <div className={styles.buttonContainer}>
<button className={styles.btnServCreate} onClick={handleCreateServer}> <button className={styles.btnServCreate} onClick={handleCreateServer}>
Créer Créer
@ -129,7 +191,7 @@ CreateServer.propTypes = {
]), ]),
onCreateServer: PropTypes.func.isRequired, onCreateServer: PropTypes.func.isRequired,
onSubdomainUpdate: PropTypes.func.isRequired, onSubdomainUpdate: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired, onCancel: PropTypes.func,
noServers: PropTypes.any noServers: PropTypes.any
}; };

View File

@ -25,7 +25,6 @@
.input, .select { .input, .select {
width: 60rem; width: 60rem;
padding: 1rem; padding: 1rem;
margin-top: 1rem;
background-color: #090325; background-color: #090325;
border: none; border: none;
border-radius: 0.5rem; border-radius: 0.5rem;
@ -118,7 +117,9 @@
color: #AAA6C3; color: #AAA6C3;
font-weight: 600; font-weight: 600;
text-align: start; text-align: start;
margin-bottom: 2rem; margin-bottom: 1.5rem;
margin-top: 2rem;
} }
.inputsubdomain { .inputsubdomain {
@ -132,6 +133,37 @@
font-size: 1rem; font-size: 1rem;
} }
.carreContainer {
display: flex;
justify-content: space-around;
align-items: center;
width: 100%;
height: 5rem;
}
.carre {
width: 5rem;
height: 5rem;
object-fit: cover;
display: block;
border: 1px solid black;
cursor: pointer;
transition: transform 0.2s;
}
.carre:hover {
transform: scale(1.1);
}
.selected {
border: 2px solid #fff;
transform: scale(1.2);
}
@media (max-width: 800px) { @media (max-width: 800px) {
.buttonContainer{ .buttonContainer{

View File

@ -1,14 +1,13 @@
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import styles from './serverCard.module.scss'; import styles from './serverCard.module.scss';
import paper from '../../assets/frameworks/paper_mc.png'; import paper from '../../assets/frameworks/paper.png';
import spigot from '../../assets/frameworks/spigot.png'; import spigot from '../../assets/frameworks/spigot.png';
import bukkit from '../../assets/frameworks/bukkit.png'; import bukkit from '../../assets/frameworks/bukkit.png';
import vanilla from '../../assets/frameworks/vanilla.png'; import vanilla from '../../assets/frameworks/vanilla.png';
import delete_button from '../../assets/frameworks/delete.png';
import PropTypes from "prop-types"; import PropTypes from "prop-types";
const ServerCard = ({ status, version, name, framework, onRunClick, onStopClick, onDeleteClick }) => { const ServerCard = ({ status, version, name, framework, onRunClick, onStopClick, onDeleteClick , countPlayers , maxPlayers}) => {
const getFrameworkSource = () => { const getFrameworkSource = () => {
switch (framework) { switch (framework) {
@ -52,25 +51,31 @@ const ServerCard = ({ status, version, name, framework, onRunClick, onStopClick,
return ( return (
<Link to={`/server/${name}`} className={styles.serverCard}> <Link to={`/server/${name}`} className={styles.serverCard}>
<div className={styles.leftCard}> <div className={styles.header}>
<div className={styles.status}> <div className={styles.serverInfo}>
<div className={styles.name}>{name}</div>
<img src={getFrameworkSource()} alt={`${name} Icon`} className={styles.frameworkIcon} /> <img src={getFrameworkSource()} alt={`${name} Icon`} className={styles.frameworkIcon} />
<div className="tooltip"></div> <div>
</div> <div className={styles.serverName}>{name}</div>
<div className={styles.buttonContainer}>
{status === false && (
<button className={styles.stoppedButton} onClick={handleRun}> Démarrer</button>
)}
{status === true && (
<button className={styles.runningButton} onClick={handleStop}> Arrêter</button>
)}
</div>
</div>
<div className={styles.version}>Version: {version}</div> <div className={styles.version}>Version: {version}</div>
<button className={styles.runningButton} onClick={handleDelete}><img src={delete_button} className={styles.deleteButton} /></button> </div>
</div>
<div className={styles.status}>
{status === false ? " " : countPlayers + "/" + maxPlayers + " joueurs"}
</div>
</div>
<div className={styles.actions}>
<div>
{status === false ? (
<button className={`${styles.startStopButton} ${styles.stoppedButton}`} onClick={handleRun}> Démarrer</button>
) : (
<button className={`${styles.startStopButton} ${styles.runningButton}`} onClick={handleStop}> Arrêter</button>
)}
</div>
<button className={styles.deleteButton} onClick={handleDelete}>🗑 Supprimer</button>
</div>
</Link> </Link>
); );
}; };
ServerCard.propTypes = { ServerCard.propTypes = {
@ -82,6 +87,7 @@ ServerCard.propTypes = {
onRunClick: PropTypes.func.isRequired, onRunClick: PropTypes.func.isRequired,
onStopClick: PropTypes.func.isRequired, onStopClick: PropTypes.func.isRequired,
onDeleteClick: PropTypes.func.isRequired, onDeleteClick: PropTypes.func.isRequired,
countPlayers: PropTypes.number,
subdomain: PropTypes.string, subdomain: PropTypes.string,
}; };

View File

@ -1,88 +1,95 @@
.serverCard { .serverCard {
width: var(--card-width); display: flex;
padding: var(--card-padding); flex-direction: column;
justify-content: space-between;
align-items: flex-start;
width: 35.5rem;
padding: 2rem;
border: 0.2rem solid var(--card-border-color); border: 0.2rem solid var(--card-border-color);
border-radius: 0.8rem; border-radius: 0.8rem;
text-decoration: none;
display: flex;
flex-direction: row;
align-items: center;
background-color: var(--card-bg-color); background-color: var(--card-bg-color);
color: var(--text-color); color: var(--text-color);
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
cursor: pointer; cursor: pointer;
text-decoration: none;
} }
.header {
display: flex;
justify-content: space-between;
width: 100%;
}
.serverInfo {
.status {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.frameworkIcon { .frameworkIcon {
width: 2rem; width: 2.5rem;
height: 2rem; height: 2.5rem;
pointer-events: none; margin-right: 0.8rem;
}
.serverName {
font-size: 1.6rem;
font-weight: bold;
}
.version {
font-size: 1.2rem;
color: var(--text-secondary-color);
margin-top: 0.5rem;
}
.status {
font-size: 1.2rem;
font-weight: bold;
color: var(--status-color);
}
.actions {
display: flex;
justify-content: space-between;
width: 100%;
margin-top: 1rem;
}
.startStopButton {
padding: 1rem 1.8rem;
border-radius: 0.6rem;
border: none;
color: white;
cursor: pointer;
transition: background-color 0.3s ease;
} }
.stoppedButton { .stoppedButton {
background-color: #008d5f; background-color: #008d5f;
color: white;
border: none;
padding: 1rem 1.6rem;
border-radius: 0.6rem;
outline: none;
cursor: pointer;
transition: background-color 0.3s ease;
margin-top: 1rem;
} }
.runningButton { .runningButton {
background-color: #8d213e; background-color: #8d213e;
color: white;
border: none;
padding: 1rem 1.6rem;
border-radius: 0.6rem;
outline: none;
cursor: pointer;
transition: background-color 0.3s ease;
margin-top: 1rem;
}
.runningButton:hover{
background-color: #8d213ec1;
} }
.stoppedButton:hover { .stoppedButton:hover {
background-color: #008d5fc1; background-color: #008d5fc1;
} }
.runningButton:hover {
background-color: #8d213ec1;
}
.deleteButton { .deleteButton {
width: 20px; background-color: #d9534f;
height: 20px; color: white;
user-select: none; border: none;
pointer-events: none; border-radius: 0.6rem;
-webkit-user-select: none; /* Safari */ padding: 0.6rem 1rem;
-moz-user-select: none; /* Firefox */ cursor: pointer;
-ms-user-select: none; /* IE/Edge */ transition: background-color 0.3s ease;
} }
.name { .deleteButton:hover {
font-size: 1.5rem; background-color: #c9302c;
font-weight: bold;
padding-right: 0.5rem;
}
.version {
font-size: 1.5rem;
margin-left: auto;
margin-right: 2rem;
}
.leftCard {
display: flex;
flex-direction: column;
align-items: start;
justify-content: center;
} }

View File

@ -39,10 +39,10 @@ const DashboardPage = ({ user }) => {
loadServers(); loadServers();
}, []); }, []);
const handleCreateServer = async (serverName, serverVersion) => { const handleCreateServer = async (serverName, serverVersion , framework) => {
try { try {
if (!serverName || !serverVersion) return; if (!serverName || !serverVersion) return;
await serviiApi.serverCreate(serverName, serverVersion, "spigot"); await serviiApi.serverCreate(serverName, serverVersion, framework);
await loadServers(); await loadServers();
setShowCreateServer(false); setShowCreateServer(false);
} catch (error) { } catch (error) {
@ -118,6 +118,7 @@ const DashboardPage = ({ user }) => {
<CreateServer <CreateServer
user={user} user={user}
onCreateServer={handleCreateServerPage} onCreateServer={handleCreateServerPage}
onCancel={handleCancelCreateServer}
noServers noServers
/> />
) : ( ) : (
@ -141,6 +142,8 @@ const DashboardPage = ({ user }) => {
version={server.version} version={server.version}
name={server.name} name={server.name}
framework={server.framework} framework={server.framework}
maxPlayers={server.maxPlayers}
countPlayers={server.onlinePlayers}
onRunClick={() => handleRunServer(server.name)} onRunClick={() => handleRunServer(server.name)}
onStopClick={() => handleStopServer(server.name)} onStopClick={() => handleStopServer(server.name)}
onDeleteClick={() => handleDeleteServer(server.name)} onDeleteClick={() => handleDeleteServer(server.name)}