mirror of
https://github.com/hubHarmony/servii-frontend.git
synced 2024-11-18 05:40:31 +00:00
ajout bouton création serveurs
This commit is contained in:
parent
00f306045f
commit
1fd5224fe6
@ -9,6 +9,7 @@
|
|||||||
align-items: center;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status {
|
.status {
|
||||||
|
@ -11,8 +11,8 @@ html {
|
|||||||
--profile-pic-size: 3rem;
|
--profile-pic-size: 3rem;
|
||||||
--logout-button-bg: #ff4b4b;
|
--logout-button-bg: #ff4b4b;
|
||||||
--logout-button-bg-hover: #ff1a1a;
|
--logout-button-bg-hover: #ff1a1a;
|
||||||
--card-width: 100%;
|
--card-width: 80%;
|
||||||
--card-padding: 4rem;
|
--card-padding: 3.5rem;
|
||||||
--card-border-color: #343947;
|
--card-border-color: #343947;
|
||||||
--card-bg-color: #1D1836;
|
--card-bg-color: #1D1836;
|
||||||
--main-bg-color: #050816;
|
--main-bg-color: #050816;
|
||||||
|
@ -6,11 +6,13 @@ import NoServer from '../NoServer/NoServer';
|
|||||||
import { getUserSubdomain } from "../../service/firebase";
|
import { getUserSubdomain } from "../../service/firebase";
|
||||||
import serviiApi from "../../service/api.tsx";
|
import serviiApi from "../../service/api.tsx";
|
||||||
import Loading from '../Loading/loading';
|
import Loading from '../Loading/loading';
|
||||||
|
import CreateServer from '../../components/CreateServer/CreateServer';
|
||||||
|
|
||||||
const DashboardPage = ({ user }) => {
|
const DashboardPage = ({ user }) => {
|
||||||
const [servers, setServers] = useState([]);
|
const [servers, setServers] = useState([]);
|
||||||
const [subdomain, setSubdomain] = useState("");
|
const [subdomain, setSubdomain] = useState("");
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [showCreateServer, setShowCreateServer] = useState(false);
|
||||||
|
|
||||||
const loadServers = async () => {
|
const loadServers = async () => {
|
||||||
try {
|
try {
|
||||||
@ -38,11 +40,16 @@ const DashboardPage = ({ user }) => {
|
|||||||
if (!serverName || !serverVersion) return;
|
if (!serverName || !serverVersion) return;
|
||||||
await serviiApi.serverCreate(serverName, serverVersion, "paper");
|
await serviiApi.serverCreate(serverName, serverVersion, "paper");
|
||||||
await loadServers();
|
await loadServers();
|
||||||
|
setShowCreateServer(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating server:', error);
|
console.error('Error creating server:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCreateServerPage = () => {
|
||||||
|
setShowCreateServer(true);
|
||||||
|
};
|
||||||
|
|
||||||
const handleRunServer = async (serverName) => {
|
const handleRunServer = async (serverName) => {
|
||||||
try {
|
try {
|
||||||
await serviiApi.serverRun(serverName);
|
await serviiApi.serverRun(serverName);
|
||||||
@ -70,20 +77,33 @@ const DashboardPage = ({ user }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (showCreateServer) {
|
||||||
|
return <CreateServer user={user} onCreateServer={handleCreateServer} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.dashboardContainer}>
|
<div className={styles.dashboardContainer}>
|
||||||
<Navbar user={user} />
|
<Navbar user={user} />
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<Loading />
|
<Loading />
|
||||||
) :
|
) : (
|
||||||
<div className={styles.cardsContainer}>
|
<div className={styles.cardsContainer}>
|
||||||
<div className={styles.iptitle}>Adresse de connexion à vos serveurs : <span>{subdomain}.servii.fr</span></div>
|
|
||||||
{servers.length === 0 ? (
|
{servers.length === 0 ? (
|
||||||
<NoServer user={user} onCreateServer={handleCreateServer} />
|
<NoServer user={user} onCreateServer={handleCreateServer} />
|
||||||
) : (
|
) : (
|
||||||
servers.map((server, index) => (
|
<div>
|
||||||
|
<div className={styles.iptitle}>
|
||||||
|
Adresse de connexion à vos serveurs : <span>{subdomain}.servii.fr</span>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
className={styles.btncreate}
|
||||||
|
onClick={handleCreateServerPage}
|
||||||
|
>
|
||||||
|
Créer un nouveau serveur
|
||||||
|
</button>
|
||||||
|
{servers.map((server) => (
|
||||||
<ServerCard
|
<ServerCard
|
||||||
key={index}
|
key={server.id}
|
||||||
status={server.running}
|
status={server.running}
|
||||||
version={server.version}
|
version={server.version}
|
||||||
name={server.name}
|
name={server.name}
|
||||||
@ -93,11 +113,11 @@ const DashboardPage = ({ user }) => {
|
|||||||
onDeleteClick={() => handleDeleteServer(server.name)}
|
onDeleteClick={() => handleDeleteServer(server.name)}
|
||||||
subdomain={subdomain}
|
subdomain={subdomain}
|
||||||
/>
|
/>
|
||||||
)
|
))}
|
||||||
)
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -37,3 +37,19 @@ html, body {
|
|||||||
.iptitle span {
|
.iptitle span {
|
||||||
color: violet;
|
color: violet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btncreate{
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
background-color: #1D1836;
|
||||||
|
width: 40rem;
|
||||||
|
height: 5rem;
|
||||||
|
color: white;
|
||||||
|
border: solid 0.1rem #090325;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 2rem;
|
||||||
|
font-weight: 900;
|
||||||
|
border-radius: 1rem;
|
||||||
|
margin-bottom: 3rem;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user