[FEATURE] Initial Extra Ports
This commit is contained in:
parent
69018292b7
commit
2884709bb1
7 changed files with 81 additions and 7 deletions
|
@ -8,8 +8,9 @@ RUN npm i
|
|||
COPY public public
|
||||
COPY dist dist
|
||||
COPY src src
|
||||
COPY lib lib
|
||||
COPY index.html .
|
||||
COPY vite.config.js .
|
||||
RUN npm run build:react
|
||||
# Copy Backend resources over
|
||||
COPY lib lib
|
||||
CMD ["npm","start"]
|
||||
|
|
|
@ -24,6 +24,14 @@ function payloadFilter(req, res) {
|
|||
if (!version) return res.status(400).send("Server version is required!");
|
||||
if (!serverType) return res.status(400).send("Server type is required!");
|
||||
if (!memory) return res.status(400).send("Memory is required!");
|
||||
if (
|
||||
!!extraPorts &&
|
||||
(!Array.isArray(extraPorts) ||
|
||||
extraPorts.find((e) => typeof e !== "string" || e.length > 5))
|
||||
)
|
||||
return res
|
||||
.status(400)
|
||||
.send("Extra ports must be a list of strings with length of 5!");
|
||||
// TODO: Impliment non creation time backups
|
||||
if (
|
||||
!!backupHost ||
|
||||
|
|
|
@ -13,6 +13,7 @@ CREATE TABLE servers (
|
|||
backup_id varchar(255) DEFAULT NULL,
|
||||
backup_key varchar(255) DEFAULT NULL,
|
||||
backup_interval varchar(255) DEFAULT NULL,
|
||||
extra_ports varchar(7)[] DEFAULT NULL,
|
||||
CONSTRAINT unique_host UNIQUE(host)
|
||||
);
|
||||
ALTER SEQUENCE servers_id_seq OWNED BY servers.id;
|
23
lib/k8s/configs/extra-svc.yml
Normal file
23
lib/k8s/configs/extra-svc.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
minecluster.dunemask.net/id: changeme-server-id
|
||||
labels:
|
||||
app: changeme-app
|
||||
name: changeme-extra
|
||||
namespace: changeme-namespace
|
||||
spec:
|
||||
internalTrafficPolicy: Cluster
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
ipFamilyPolicy: SingleStack
|
||||
ports:
|
||||
- name: port-name
|
||||
port: 1234
|
||||
protocol: TCP
|
||||
targetPort: port-name
|
||||
selector:
|
||||
app: changeme-app
|
||||
sessionAffinity: None
|
||||
type: ClusterIP
|
|
@ -22,7 +22,6 @@ export function useFilePreview(isOpen = false) {
|
|||
return [open, dialogToggle];
|
||||
}
|
||||
|
||||
|
||||
export default function FilePreview(props) {
|
||||
const [fileText, setFileText] = useState();
|
||||
const theme = useTheme();
|
||||
|
@ -33,16 +32,14 @@ export default function FilePreview(props) {
|
|||
const ext = name ? name.split(".").pop() : null;
|
||||
const isTextFile = textFileTypes.includes(ext);
|
||||
|
||||
|
||||
const buildDelta = (text) => {
|
||||
if (!text) return;
|
||||
console.log("building delta");
|
||||
return { ops: text.split("\n").map((l) => ({ insert: `${l}\n` })) };
|
||||
};
|
||||
|
||||
|
||||
async function onEditorChange(content, delta, source, editor) {
|
||||
console.log(editor.getText());
|
||||
console.log(editor.getText());
|
||||
}
|
||||
|
||||
async function onPreviewChange() {
|
||||
|
@ -79,7 +76,11 @@ export default function FilePreview(props) {
|
|||
<Toolbar sx={{ display: { sm: "none" } }} />
|
||||
<DialogTitle>{name}</DialogTitle>
|
||||
<DialogContent>
|
||||
<ReactQuill theme="snow" value={buildDelta(fileText)} onChange={onEditorChange} />
|
||||
<ReactQuill
|
||||
theme="snow"
|
||||
value={buildDelta(fileText)}
|
||||
onChange={onEditorChange}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button autoFocus onClick={dialogToggle}>
|
||||
|
|
38
src/components/server-options/ExtraPortsOption.jsx
Normal file
38
src/components/server-options/ExtraPortsOption.jsx
Normal file
|
@ -0,0 +1,38 @@
|
|||
import TextField from "@mui/material/TextField";
|
||||
import Autocomplete from "@mui/material/Autocomplete";
|
||||
import Chip from "@mui/material/Chip";
|
||||
|
||||
const validatePort = (p) => p !== "25565" && p !== "25575" && p.length < 6;
|
||||
|
||||
export default function ExtraPortsOption(props) {
|
||||
const { value: ports, onChange } = props;
|
||||
|
||||
function modifyPorts(e, val) {
|
||||
if (!validatePort(val))
|
||||
return alert("That port cannot be added/removed as an extra port!");
|
||||
}
|
||||
function portChange(e, val, optionType, changedValue) {
|
||||
if (!validatePort(changedValue.option))
|
||||
return alert("That port cannot be added/removed as an extra port!");
|
||||
|
||||
onChange("extraPorts", val);
|
||||
}
|
||||
|
||||
return (
|
||||
<Autocomplete
|
||||
multiple
|
||||
id="extra-ports-autocomplete"
|
||||
options={[]}
|
||||
onChange={portChange}
|
||||
freeSolo
|
||||
renderInput={(p) => <TextField {...p} label="Extra Ports" />}
|
||||
onInputChange={modifyPorts}
|
||||
renderTags={(value, getTagProps) =>
|
||||
value.map((option, index) => {
|
||||
const defaultChipProps = getTagProps({ index });
|
||||
return <Chip label={option} {...defaultChipProps} />;
|
||||
})
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
|
@ -21,6 +21,7 @@ import CpuOption, {
|
|||
import MemoryOption, {
|
||||
memoryOptions,
|
||||
} from "@mcl/components/server-options/MemoryOption.jsx";
|
||||
import ExtraPortsOption from "@mcl/components/server-options/ExtraPortsOption.jsx";
|
||||
|
||||
import BackupHostOption from "@mcl/components/server-options/BackupHostOption.jsx";
|
||||
import BackupBucketOption from "@mcl/components/server-options/BackupBucketOption.jsx";
|
||||
|
@ -35,6 +36,7 @@ const defaultServer = {
|
|||
serverType: serverTypeOptions[0],
|
||||
cpu: cpuOptions[0],
|
||||
memory: memoryOptions[2], // 1.5GB
|
||||
extraPorts: [],
|
||||
};
|
||||
|
||||
export default function CreateCoreOptions() {
|
||||
|
@ -79,7 +81,6 @@ export default function CreateCoreOptions() {
|
|||
).toLowerCase()}`);
|
||||
} else for (var k in s) if (k.startsWith("backup")) delete s[k];
|
||||
setSpec(s);
|
||||
console.log(s);
|
||||
setBackupEnabled(!backupEnabled);
|
||||
};
|
||||
|
||||
|
@ -98,6 +99,7 @@ export default function CreateCoreOptions() {
|
|||
/>
|
||||
<CpuOption value={spec.cpu} onChange={coreUpdate("cpu")} />
|
||||
<MemoryOption value={spec.memory} onChange={coreUpdate("memory")} />
|
||||
<ExtraPortsOption value={spec.extraPorts} onChange={updateSpec} />
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Switch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue