Can export entire server configuration
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-06-17 21:17:25 +02:00
parent 1080ab5cb2
commit ab16bd7bcf
9 changed files with 369 additions and 3 deletions

View File

@ -232,4 +232,16 @@ export class ServerApi {
})
).data;
}
/**
* Export all server configs
*/
static async ExportServerConfigs(): Promise<Blob> {
return (
await APIClient.exec({
method: "GET",
uri: "/server/export_configs",
})
).data;
}
}

View File

@ -9,18 +9,21 @@ import {
import Icon from "@mdi/react";
import {
Box,
IconButton,
LinearProgress,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
Tooltip,
Typography,
} from "@mui/material";
import Grid from "@mui/material/Grid";
import { PieChart } from "@mui/x-charts";
import { filesize } from "filesize";
import humanizeDuration from "humanize-duration";
import IosShareIcon from "@mui/icons-material/IosShare";
import React from "react";
import {
DiskInfo,
@ -31,6 +34,8 @@ import {
import { AsyncWidget } from "../widgets/AsyncWidget";
import { VirtWebPaper } from "../widgets/VirtWebPaper";
import { VirtWebRouteContainer } from "../widgets/VirtWebRouteContainer";
import { useLoadingMessage } from "../hooks/providers/LoadingMessageProvider";
import { useAlert } from "../hooks/providers/AlertDialogProvider";
export function SysInfoRoute(): React.ReactElement {
const [info, setInfo] = React.useState<ServerSystemInfo>();
@ -52,6 +57,23 @@ export function SysInfoRoute(): React.ReactElement {
export function SysInfoRouteInner(p: {
info: ServerSystemInfo;
}): React.ReactElement {
const alert = useAlert();
const loadingMessage = useLoadingMessage();
const downloadAllConfig = async () => {
try {
loadingMessage.show("Downloading server config...");
const res = await ServerApi.ExportServerConfigs();
const url = URL.createObjectURL(res);
window.location.href = url;
} catch (e) {
console.error("Failed to download server config!", e);
alert(`Failed to download server config! ${e}`);
} finally {
loadingMessage.hide();
}
};
const sumDiskUsage = p.info.disks.reduce(
(prev, disk) => {
return {
@ -63,7 +85,16 @@ export function SysInfoRouteInner(p: {
);
return (
<VirtWebRouteContainer label="Sysinfo">
<VirtWebRouteContainer
label="Sysinfo"
actions={
<Tooltip title="Export all server configs">
<IconButton onClick={downloadAllConfig}>
<IosShareIcon />
</IconButton>
</Tooltip>
}
>
<Grid container spacing={2}>
{/* Memory */}
<Grid size={{ xs: 4 }}>

View File

@ -799,6 +799,11 @@ export function TokenRightsEditor(p: {
right={{ verb: "GET", path: "/api/server/bridges" }}
label="Get list of network bridges"
/>
<RouteRight
{...p}
right={{ verb: "GET", path: "/api/server/export_configs" }}
label="Export all configurations"
/>
</RightsSection>
</>
);