mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-08-25 10:26:35 +00:00
fix: better defaults in add repo / add plan views
This commit is contained in:
+1
-1
@@ -104,5 +104,5 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Logs are available at /tmp/backrest.log"
|
||||
echo "Logs are available at ~/.local/share/backrest/processlogs/backrest.log"
|
||||
echo "Access backrest WebUI at http://localhost:9898"
|
||||
|
||||
@@ -15,7 +15,11 @@ import {
|
||||
} from "antd";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useShowModal } from "../components/ModalManager";
|
||||
import { Plan, RetentionPolicy } from "../../gen/ts/v1/config_pb";
|
||||
import {
|
||||
Plan,
|
||||
RetentionPolicy,
|
||||
Schedule_Clock,
|
||||
} from "../../gen/ts/v1/config_pb";
|
||||
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
||||
import { URIAutocomplete } from "../components/URIAutocomplete";
|
||||
import { formatErrorAlert, useAlertApi } from "../components/Alerts";
|
||||
@@ -32,6 +36,26 @@ import {
|
||||
ScheduleFormItem,
|
||||
} from "../components/ScheduleFormItem";
|
||||
|
||||
const planDefaults = new Plan({
|
||||
schedule: {
|
||||
schedule: {
|
||||
case: "cron",
|
||||
value: "0 * * * *", // every hour
|
||||
},
|
||||
clock: Schedule_Clock.LOCAL,
|
||||
},
|
||||
retention: {
|
||||
policy: {
|
||||
case: "policyTimeBucketed",
|
||||
value: {
|
||||
hourly: 24,
|
||||
daily: 30,
|
||||
monthly: 12,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const AddPlanModal = ({ template }: { template: Plan | null }) => {
|
||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||
const showModal = useShowModal();
|
||||
@@ -39,7 +63,11 @@ export const AddPlanModal = ({ template }: { template: Plan | null }) => {
|
||||
const [config, setConfig] = useConfig();
|
||||
const [form] = Form.useForm();
|
||||
useEffect(() => {
|
||||
form.setFieldsValue(template ? JSON.parse(template.toJsonString()) : {});
|
||||
form.setFieldsValue(
|
||||
template
|
||||
? JSON.parse(template.toJsonString())
|
||||
: JSON.parse(planDefaults.toJsonString())
|
||||
);
|
||||
}, [template]);
|
||||
|
||||
if (!config) {
|
||||
|
||||
@@ -23,6 +23,8 @@ import {
|
||||
CommandPrefix_IONiceLevel,
|
||||
Hook,
|
||||
Repo,
|
||||
Schedule,
|
||||
Schedule_Clock,
|
||||
} from "../../gen/ts/v1/config_pb";
|
||||
import { URIAutocomplete } from "../components/URIAutocomplete";
|
||||
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
||||
@@ -45,6 +47,28 @@ import {
|
||||
import { proto3 } from "@bufbuild/protobuf";
|
||||
import { isWindows } from "../state/buildcfg";
|
||||
|
||||
const repoDefaults = new Repo({
|
||||
prunePolicy: {
|
||||
maxUnusedPercent: 10,
|
||||
schedule: {
|
||||
schedule: {
|
||||
case: "cron",
|
||||
value: "0 0 1 * *", // 1st of the month,
|
||||
},
|
||||
clock: Schedule_Clock.LAST_RUN_TIME,
|
||||
},
|
||||
},
|
||||
checkPolicy: {
|
||||
schedule: {
|
||||
schedule: {
|
||||
case: "cron",
|
||||
value: "0 0 1 * *", // 1st of the month,
|
||||
},
|
||||
clock: Schedule_Clock.LAST_RUN_TIME,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const AddRepoModal = ({ template }: { template: Repo | null }) => {
|
||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||
const showModal = useShowModal();
|
||||
@@ -52,7 +76,11 @@ export const AddRepoModal = ({ template }: { template: Repo | null }) => {
|
||||
const [config, setConfig] = useConfig();
|
||||
const [form] = Form.useForm();
|
||||
useEffect(() => {
|
||||
form.setFieldsValue(template ? JSON.parse(template.toJsonString()) : {});
|
||||
form.setFieldsValue(
|
||||
template
|
||||
? JSON.parse(template.toJsonString())
|
||||
: JSON.parse(repoDefaults.toJsonString())
|
||||
);
|
||||
}, [template]);
|
||||
|
||||
if (!config) {
|
||||
|
||||
Reference in New Issue
Block a user