-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from gnmyt/features/pve-integration
Proxmox Integration
- Loading branch information
Showing
37 changed files
with
1,095 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
client/src/pages/Servers/components/ProxmoxDialog/ProxmoxDialog.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { DialogProvider } from "@/common/components/Dialog"; | ||
import "./styles.sass"; | ||
import { useContext, useEffect, useState } from "react"; | ||
import { ServerContext } from "@/common/contexts/ServerContext.jsx"; | ||
import IconInput from "@/common/components/IconInput"; | ||
import { mdiAccountCircleOutline, mdiFormTextbox, mdiIp, mdiLockOutline } from "@mdi/js"; | ||
import Button from "@/common/components/Button"; | ||
import Input from "@/common/components/IconInput/index.js"; | ||
import { getRequest, patchRequest, postRequest, putRequest } from "@/common/utils/RequestUtil.js"; | ||
|
||
export const ProxmoxDialog = ({ open, onClose, currentFolderId, editServerId }) => { | ||
|
||
const [name, setName] = useState(""); | ||
const [ip, setIp] = useState(""); | ||
const [port, setPort] = useState("8006"); | ||
const [username, setUsername] = useState(""); | ||
const [password, setPassword] = useState(""); | ||
|
||
const create = () => { | ||
putRequest("pve-servers", { | ||
name, folderId: currentFolderId, ip, port, username, password, | ||
}).then(async () => { | ||
onClose(); | ||
loadServers(); | ||
await postRequest("pve-servers/refresh"); | ||
}).catch(err => console.error(err)); | ||
}; | ||
|
||
const edit = () => { | ||
patchRequest(`pve-servers/${editServerId.split("-")[1]}`, { | ||
name, ip, port, username, password: password === "********" ? undefined : password, | ||
}).then(async () => { | ||
onClose(); | ||
await postRequest("pve-servers/refresh"); | ||
loadServers(); | ||
}).catch(err => console.error(err)); | ||
} | ||
|
||
useEffect(() => { | ||
if (editServerId) { | ||
getRequest(`pve-servers/${editServerId.split("-")[1]}`).then(server => { | ||
setName(server.name); | ||
setIp(server.ip); | ||
setPort(server.port); | ||
setUsername(server.username); | ||
setPassword("********"); | ||
}).catch(err => console.error(err)); | ||
} else { | ||
setName(""); | ||
setIp(""); | ||
setPort("8006"); | ||
setUsername(""); | ||
setPassword(""); | ||
} | ||
}, [editServerId, open]); | ||
|
||
const { loadServers } = useContext(ServerContext); | ||
|
||
return ( | ||
<DialogProvider open={open} onClose={onClose}> | ||
<div className="proxmox-dialog"> | ||
<h2>{editServerId ? "Edit" : "Import"} Proxmox VE</h2> | ||
<div className="form-group"> | ||
<label htmlFor="name">Name</label> | ||
<IconInput icon={mdiFormTextbox} value={name} setValue={setName} placeholder="Name" id="name" /> | ||
</div> | ||
|
||
<div className="ip-row"> | ||
|
||
<div className="form-group"> | ||
<label htmlFor="ip">Server-IP</label> | ||
<Input icon={mdiIp} type="text" placeholder="Server-IP" id="ip" | ||
autoComplete="off" value={ip} setValue={setIp} /> | ||
</div> | ||
|
||
<div className="form-group"> | ||
<label htmlFor="port">Port</label> | ||
<input type="text" placeholder="Port" value={port} | ||
onChange={(event) => setPort(event.target.value)} | ||
className="small-input" id="port" /> | ||
</div> | ||
</div> | ||
|
||
<div className="form-group"> | ||
<label htmlFor="username">Username</label> | ||
<IconInput icon={mdiAccountCircleOutline} value={username} setValue={setUsername} | ||
placeholder="Username (e.g. root@pam)" id="username" /> | ||
</div> | ||
|
||
<div className="form-group"> | ||
<label htmlFor="password">Password</label> | ||
<IconInput icon={mdiLockOutline} value={password} setValue={setPassword} placeholder="Password" | ||
type="password" id="password" /> | ||
</div> | ||
|
||
<Button onClick={editServerId ? edit : create} text={editServerId ? "Edit" : "Import"} /> | ||
|
||
</div> | ||
</DialogProvider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {ProxmoxDialog as default} from "./ProxmoxDialog.jsx"; |
44 changes: 44 additions & 0 deletions
44
client/src/pages/Servers/components/ProxmoxDialog/styles.sass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
@import "@/common/styles/colors" | ||
|
||
.proxmox-dialog | ||
display: flex | ||
flex-direction: column | ||
gap: 1rem | ||
width: 20rem | ||
|
||
h2, p | ||
margin: 0 | ||
|
||
p | ||
font-weight: 600 | ||
font-size: 0.9rem | ||
|
||
.error | ||
border: 1px solid $error | ||
|
||
.form-group | ||
display: flex | ||
flex-direction: column | ||
gap: 0.3rem | ||
|
||
label | ||
color: $subtext | ||
font-weight: 600 | ||
|
||
.ip-row | ||
display: flex | ||
gap: 1rem | ||
|
||
.small-input | ||
padding: 0.8rem | ||
border: 1px solid $gray | ||
width: 3rem | ||
background-color: $dark-gray | ||
color: $light-gray | ||
border-radius: 0.5rem | ||
font-size: 14pt | ||
outline: none | ||
|
||
&:focus | ||
border: 1px solid $primary | ||
background-color: $gray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.