diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 2cabd15..e126726 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -13,8 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: npm ci - - run: build + - run: npm ci && npm run build - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/assets/frameworks/bukkit.png b/src/assets/frameworks/bukkit.png index 5d5475b..d304f06 100644 Binary files a/src/assets/frameworks/bukkit.png and b/src/assets/frameworks/bukkit.png differ diff --git a/src/assets/frameworks/delete.png b/src/assets/frameworks/delete.png deleted file mode 100644 index 1f49fd9..0000000 Binary files a/src/assets/frameworks/delete.png and /dev/null differ diff --git a/src/assets/frameworks/paper.png b/src/assets/frameworks/paper.png new file mode 100644 index 0000000..d44c259 Binary files /dev/null and b/src/assets/frameworks/paper.png differ diff --git a/src/assets/frameworks/paper_mc.png b/src/assets/frameworks/paper_mc.png deleted file mode 100644 index 2e6b769..0000000 Binary files a/src/assets/frameworks/paper_mc.png and /dev/null differ diff --git a/src/assets/frameworks/spigot.png b/src/assets/frameworks/spigot.png index 65f99c9..385baa9 100644 Binary files a/src/assets/frameworks/spigot.png and b/src/assets/frameworks/spigot.png differ diff --git a/src/assets/frameworks/vanilla.png b/src/assets/frameworks/vanilla.png index 8480c89..38f5041 100644 Binary files a/src/assets/frameworks/vanilla.png and b/src/assets/frameworks/vanilla.png differ diff --git a/src/components/CreateServer/CreateServer.jsx b/src/components/CreateServer/CreateServer.jsx index 3337443..7cc7f3d 100644 --- a/src/components/CreateServer/CreateServer.jsx +++ b/src/components/CreateServer/CreateServer.jsx @@ -3,12 +3,50 @@ import styles from './CreateServer.module.scss'; import { getUserSubdomain } from "../../service/firebase"; import serviiApi from "../../service/api.tsx"; 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 [subdomain, setSubdomain] = useState(null); const [subdomainInput, setSubdomainInput] = useState(''); const [serverName, setServerName] = useState(''); - const [serverVersion, setServerVersion] = useState(''); + const [serverVersion, setServerVersion] = useState(); + const [selectedFramework, setSelectedFramework] = useState("vanilla"); const loadSubdomain = async () => { try { @@ -40,7 +78,7 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer const handleCreateServer = async () => { try { - await onCreateServer(serverName, serverVersion); + await onCreateServer(serverName, serverVersion , selectedFramework); } catch (error) { console.error('Error creating server:', error); } @@ -92,16 +130,40 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel, noSer value={serverName} onChange={(e) => setServerName(validateInput(e.target.value))} /> + +
Sélection du framework
+
+ + {frameworks.map((framework, index) => ( + {`${framework.name} { + setSelectedFramework(framework.name); + setServerVersion(''); + }} + /> + ))} +
+ +
Sélection de la version
+ +
- )} - {status === true && ( - - )} +
+ {status === false ? " " : countPlayers + "/" + maxPlayers + " joueurs"}
-
Version: {version}
- +
+
+ {status === false ? ( + + ) : ( + + )} +
+ +
); + }; ServerCard.propTypes = { @@ -82,6 +87,7 @@ ServerCard.propTypes = { onRunClick: PropTypes.func.isRequired, onStopClick: PropTypes.func.isRequired, onDeleteClick: PropTypes.func.isRequired, + countPlayers: PropTypes.number, subdomain: PropTypes.string, }; diff --git a/src/components/serverCard/serverCard.module.scss b/src/components/serverCard/serverCard.module.scss index a35a962..1889809 100644 --- a/src/components/serverCard/serverCard.module.scss +++ b/src/components/serverCard/serverCard.module.scss @@ -1,88 +1,95 @@ .serverCard { - width: var(--card-width); - padding: var(--card-padding); + display: flex; + 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-radius: 0.8rem; - text-decoration: none; - display: flex; - flex-direction: row; - align-items: center; background-color: var(--card-bg-color); color: var(--text-color); margin-bottom: 1.5rem; cursor: pointer; + text-decoration: none; } +.header { + display: flex; + justify-content: space-between; + width: 100%; +} - -.status { +.serverInfo { display: flex; align-items: center; } .frameworkIcon { - width: 2rem; - height: 2rem; - pointer-events: none; + width: 2.5rem; + height: 2.5rem; + margin-right: 0.8rem; } -.stoppedButton{ - 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{ - 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{ - background-color: #008d5fc1; -} - -.deleteButton{ - width: 20px; - height: 20px; - user-select: none; - pointer-events: none; - -webkit-user-select: none; /* Safari */ - -moz-user-select: none; /* Firefox */ - -ms-user-select: none; /* IE/Edge */ -} - -.name { - font-size: 1.5rem; +.serverName { + font-size: 1.6rem; font-weight: bold; - padding-right: 0.5rem; } .version { - font-size: 1.5rem; - margin-left: auto; - margin-right: 2rem; + font-size: 1.2rem; + color: var(--text-secondary-color); + margin-top: 0.5rem; } -.leftCard { - display: flex; - flex-direction: column; - align-items: start; - justify-content: center; +.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 { + background-color: #008d5f; +} + +.runningButton { + background-color: #8d213e; +} + +.stoppedButton:hover { + background-color: #008d5fc1; +} + +.runningButton:hover { + background-color: #8d213ec1; +} + +.deleteButton { + background-color: #d9534f; + color: white; + border: none; + border-radius: 0.6rem; + padding: 0.6rem 1rem; + cursor: pointer; + transition: background-color 0.3s ease; +} + +.deleteButton:hover { + background-color: #c9302c; } diff --git a/src/pages/DashboardPage/DashboardPage.jsx b/src/pages/DashboardPage/DashboardPage.jsx index cb5a64b..965bd52 100644 --- a/src/pages/DashboardPage/DashboardPage.jsx +++ b/src/pages/DashboardPage/DashboardPage.jsx @@ -39,10 +39,10 @@ const DashboardPage = ({ user }) => { loadServers(); }, []); - const handleCreateServer = async (serverName, serverVersion) => { + const handleCreateServer = async (serverName, serverVersion , framework) => { try { if (!serverName || !serverVersion) return; - await serviiApi.serverCreate(serverName, serverVersion, "spigot"); + await serviiApi.serverCreate(serverName, serverVersion, framework); await loadServers(); setShowCreateServer(false); } catch (error) { @@ -118,6 +118,7 @@ const DashboardPage = ({ user }) => { ) : ( @@ -141,6 +142,8 @@ const DashboardPage = ({ user }) => { version={server.version} name={server.name} framework={server.framework} + maxPlayers={server.maxPlayers} + countPlayers={server.onlinePlayers} onRunClick={() => handleRunServer(server.name)} onStopClick={() => handleStopServer(server.name)} onDeleteClick={() => handleDeleteServer(server.name)}