[FEATURE] Mutable Servers & Edit UI (#8)
Co-authored-by: Dunemask <dunemask@gmail.com> Reviewed-on: https://gitea.dunemask.dev/elysium/minecluster/pulls/8
This commit is contained in:
parent
23efaafe1d
commit
3d73f69678
19 changed files with 291 additions and 35 deletions
|
@ -1,5 +1,10 @@
|
|||
import pg from "../postgres.js";
|
||||
import { deleteQuery, insertQuery, selectWhereQuery } from "../pg-query.js";
|
||||
import {
|
||||
deleteQuery,
|
||||
insertQuery,
|
||||
selectWhereQuery,
|
||||
updateWhereAllQuery,
|
||||
} from "../pg-query.js";
|
||||
import ExpressClientError from "../../util/ExpressClientError.js";
|
||||
const table = "servers";
|
||||
|
||||
|
@ -30,7 +35,7 @@ export async function createServerEntry(serverSpec) {
|
|||
server_type,
|
||||
memory,
|
||||
extra_ports,
|
||||
backup_enabled: !!backup_interval, // We already verified the payload, so any backup key will work
|
||||
backup_enabled: !!backup_interval ? true : null, // We already verified the payload, so any backup key will work
|
||||
backup_host,
|
||||
backup_bucket_path,
|
||||
backup_id,
|
||||
|
@ -128,6 +133,45 @@ export async function getServerEntry(serverId) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function modifyServerEntry(serverSpec) {
|
||||
const {
|
||||
id,
|
||||
name,
|
||||
host,
|
||||
version,
|
||||
serverType: server_type,
|
||||
memory,
|
||||
extraPorts: extra_ports,
|
||||
backupEnabled: backup_enabled,
|
||||
backupHost: backup_host,
|
||||
backupBucket: backup_bucket_path,
|
||||
backupId: backup_id,
|
||||
backupKey: backup_key,
|
||||
backupInterval: backup_interval,
|
||||
} = serverSpec;
|
||||
|
||||
const q = updateWhereAllQuery(
|
||||
table,
|
||||
{
|
||||
name,
|
||||
host,
|
||||
version,
|
||||
server_type,
|
||||
memory,
|
||||
extra_ports,
|
||||
backup_enabled,
|
||||
backup_host,
|
||||
backup_bucket_path,
|
||||
backup_id,
|
||||
backup_key,
|
||||
backup_interval,
|
||||
},
|
||||
{ id },
|
||||
);
|
||||
|
||||
return pg.query(q);
|
||||
}
|
||||
|
||||
export async function getServerEntries() {
|
||||
const q = `SELECT * FROM ${table}`;
|
||||
return pg.query(q);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue