mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
Compare commits
3 Commits
v0.14.0-be
...
58708cf35d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58708cf35d | ||
|
|
1d4e7100ab | ||
|
|
0dfe000148 |
@@ -115,8 +115,6 @@ export const CreateRepositoryForm = ({
|
|||||||
onChange={(e) => field.onChange(slugify(e.target.value))}
|
onChange={(e) => field.onChange(slugify(e.target.value))}
|
||||||
max={32}
|
max={32}
|
||||||
min={2}
|
min={2}
|
||||||
disabled={mode === "update"}
|
|
||||||
className={mode === "update" ? "bg-gray-50" : ""}
|
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormDescription>Unique identifier for the repository.</FormDescription>
|
<FormDescription>Unique identifier for the repository.</FormDescription>
|
||||||
|
|||||||
@@ -104,8 +104,6 @@ export const CreateVolumeForm = ({ onSubmit, mode = "create", initialValues, for
|
|||||||
onChange={(e) => field.onChange(slugify(e.target.value))}
|
onChange={(e) => field.onChange(slugify(e.target.value))}
|
||||||
max={32}
|
max={32}
|
||||||
min={1}
|
min={1}
|
||||||
disabled={mode === "update"}
|
|
||||||
className={mode === "update" ? "bg-gray-50" : ""}
|
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormDescription>Unique identifier for the volume.</FormDescription>
|
<FormDescription>Unique identifier for the volume.</FormDescription>
|
||||||
|
|||||||
@@ -114,8 +114,6 @@ export const CreateNotificationForm = ({ onSubmit, mode = "create", initialValue
|
|||||||
onChange={(e) => field.onChange(slugify(e.target.value))}
|
onChange={(e) => field.onChange(slugify(e.target.value))}
|
||||||
max={32}
|
max={32}
|
||||||
min={2}
|
min={2}
|
||||||
disabled={mode === "update"}
|
|
||||||
className={mode === "update" ? "bg-gray-50" : ""}
|
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormDescription>Unique identifier for this notification destination.</FormDescription>
|
<FormDescription>Unique identifier for this notification destination.</FormDescription>
|
||||||
|
|||||||
@@ -1,63 +1,170 @@
|
|||||||
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import { useNavigate } from "react-router";
|
||||||
import { Card } from "~/client/components/ui/card";
|
import { Card } from "~/client/components/ui/card";
|
||||||
|
import { Button } from "~/client/components/ui/button";
|
||||||
|
import { Input } from "~/client/components/ui/input";
|
||||||
|
import { Label } from "~/client/components/ui/label";
|
||||||
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "~/client/components/ui/select";
|
||||||
|
import {
|
||||||
|
AlertDialog,
|
||||||
|
AlertDialogAction,
|
||||||
|
AlertDialogCancel,
|
||||||
|
AlertDialogContent,
|
||||||
|
AlertDialogDescription,
|
||||||
|
AlertDialogFooter,
|
||||||
|
AlertDialogHeader,
|
||||||
|
AlertDialogTitle,
|
||||||
|
} from "~/client/components/ui/alert-dialog";
|
||||||
import type { Repository } from "~/client/lib/types";
|
import type { Repository } from "~/client/lib/types";
|
||||||
|
import { slugify } from "~/client/lib/utils";
|
||||||
|
import { updateRepositoryMutation } from "~/client/api-client/@tanstack/react-query.gen";
|
||||||
|
import type { UpdateRepositoryResponse } from "~/client/api-client/types.gen";
|
||||||
|
|
||||||
|
type CompressionMode = "off" | "auto" | "fastest" | "better" | "max";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
repository: Repository;
|
repository: Repository;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const RepositoryInfoTabContent = ({ repository }: Props) => {
|
export const RepositoryInfoTabContent = ({ repository }: Props) => {
|
||||||
return (
|
const navigate = useNavigate();
|
||||||
<Card className="p-6">
|
const [name, setName] = useState(repository.name);
|
||||||
<div className="space-y-6">
|
const [compressionMode, setCompressionMode] = useState<CompressionMode>(
|
||||||
<div>
|
(repository.compressionMode as CompressionMode) || "off",
|
||||||
<h3 className="text-lg font-semibold mb-4">Repository Information</h3>
|
);
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
||||||
<div>
|
|
||||||
<div className="text-sm font-medium text-muted-foreground">Name</div>
|
|
||||||
<p className="mt-1 text-sm">{repository.name}</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div className="text-sm font-medium text-muted-foreground">Backend</div>
|
|
||||||
<p className="mt-1 text-sm">{repository.type}</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div className="text-sm font-medium text-muted-foreground">Compression Mode</div>
|
|
||||||
<p className="mt-1 text-sm">{repository.compressionMode || "off"}</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div className="text-sm font-medium text-muted-foreground">Status</div>
|
|
||||||
<p className="mt-1 text-sm">{repository.status || "unknown"}</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div className="text-sm font-medium text-muted-foreground">Created At</div>
|
|
||||||
<p className="mt-1 text-sm">{new Date(repository.createdAt).toLocaleString()}</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div className="text-sm font-medium text-muted-foreground">Last Checked</div>
|
|
||||||
<p className="mt-1 text-sm">
|
|
||||||
{repository.lastChecked ? new Date(repository.lastChecked).toLocaleString() : "Never"}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{repository.lastError && (
|
|
||||||
<div>
|
|
||||||
<div className="flex items-center justify-between mb-4">
|
|
||||||
<h3 className="text-lg font-semibold text-red-500">Last Error</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="bg-red-500/10 border border-red-500/20 rounded-md p-4">
|
const updateMutation = useMutation({
|
||||||
<p className="text-sm text-red-500">{repository.lastError}</p>
|
...updateRepositoryMutation(),
|
||||||
|
onSuccess: (data: UpdateRepositoryResponse) => {
|
||||||
|
toast.success("Repository updated successfully");
|
||||||
|
setShowConfirmDialog(false);
|
||||||
|
|
||||||
|
if (data.name !== repository.name) {
|
||||||
|
navigate(`/repositories/${data.name}`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
toast.error("Failed to update repository", { description: error.message, richColors: true });
|
||||||
|
setShowConfirmDialog(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleSubmit = (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setShowConfirmDialog(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmUpdate = () => {
|
||||||
|
updateMutation.mutate({
|
||||||
|
path: { name: repository.name },
|
||||||
|
body: { name, compressionMode },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const hasChanges =
|
||||||
|
name !== repository.name || compressionMode !== ((repository.compressionMode as CompressionMode) || "off");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Card className="p-6">
|
||||||
|
<form onSubmit={handleSubmit} className="space-y-6">
|
||||||
|
<div>
|
||||||
|
<h3 className="text-lg font-semibold mb-4">Repository Settings</h3>
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="name">Name</Label>
|
||||||
|
<Input
|
||||||
|
id="name"
|
||||||
|
value={name}
|
||||||
|
onChange={(e) => setName(slugify(e.target.value))}
|
||||||
|
placeholder="Repository name"
|
||||||
|
maxLength={32}
|
||||||
|
minLength={2}
|
||||||
|
/>
|
||||||
|
<p className="text-sm text-muted-foreground">Unique identifier for the repository.</p>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="compressionMode">Compression Mode</Label>
|
||||||
|
<Select value={compressionMode} onValueChange={(val) => setCompressionMode(val as CompressionMode)}>
|
||||||
|
<SelectTrigger id="compressionMode">
|
||||||
|
<SelectValue placeholder="Select compression mode" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="off">Off</SelectItem>
|
||||||
|
<SelectItem value="auto">Auto</SelectItem>
|
||||||
|
<SelectItem value="max">Max</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<p className="text-sm text-muted-foreground">Compression level for new data.</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
<div>
|
<div>
|
||||||
<h3 className="text-lg font-semibold mb-4">Configuration</h3>
|
<h3 className="text-lg font-semibold mb-4">Repository Information</h3>
|
||||||
<div className="bg-muted/50 rounded-md p-4">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
<pre className="text-sm overflow-auto">{JSON.stringify(repository.config, null, 2)}</pre>
|
<div>
|
||||||
|
<div className="text-sm font-medium text-muted-foreground">Backend</div>
|
||||||
|
<p className="mt-1 text-sm">{repository.type}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-medium text-muted-foreground">Status</div>
|
||||||
|
<p className="mt-1 text-sm">{repository.status || "unknown"}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-medium text-muted-foreground">Created At</div>
|
||||||
|
<p className="mt-1 text-sm">{new Date(repository.createdAt * 1000).toLocaleString()}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-medium text-muted-foreground">Last Checked</div>
|
||||||
|
<p className="mt-1 text-sm">
|
||||||
|
{repository.lastChecked ? new Date(repository.lastChecked).toLocaleString() : "Never"}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
{repository.lastError && (
|
||||||
</Card>
|
<div>
|
||||||
|
<div className="flex items-center justify-between mb-4">
|
||||||
|
<h3 className="text-lg font-semibold text-red-500">Last Error</h3>
|
||||||
|
</div>
|
||||||
|
<div className="bg-red-500/10 border border-red-500/20 rounded-md p-4">
|
||||||
|
<p className="text-sm text-red-500">{repository.lastError}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3 className="text-lg font-semibold mb-4">Configuration</h3>
|
||||||
|
<div className="bg-muted/50 rounded-md p-4">
|
||||||
|
<pre className="text-sm overflow-auto">{JSON.stringify(repository.config, null, 2)}</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex justify-end pt-4 border-t">
|
||||||
|
<Button type="submit" disabled={!hasChanges || updateMutation.isPending} loading={updateMutation.isPending}>
|
||||||
|
Save Changes
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<AlertDialog open={showConfirmDialog} onOpenChange={setShowConfirmDialog}>
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>Update Repository</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription>Are you sure you want to update the repository settings?</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter>
|
||||||
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||||
|
<AlertDialogAction onClick={confirmUpdate}>Update</AlertDialogAction>
|
||||||
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { useNavigate } from "react-router";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { CreateVolumeForm, type FormValues } from "~/client/components/create-volume-form";
|
import { CreateVolumeForm, type FormValues } from "~/client/components/create-volume-form";
|
||||||
import {
|
import {
|
||||||
@@ -17,6 +18,7 @@ import type { StatFs, Volume } from "~/client/lib/types";
|
|||||||
import { HealthchecksCard } from "../components/healthchecks-card";
|
import { HealthchecksCard } from "../components/healthchecks-card";
|
||||||
import { StorageChart } from "../components/storage-chart";
|
import { StorageChart } from "../components/storage-chart";
|
||||||
import { updateVolumeMutation } from "~/client/api-client/@tanstack/react-query.gen";
|
import { updateVolumeMutation } from "~/client/api-client/@tanstack/react-query.gen";
|
||||||
|
import type { UpdateVolumeResponse } from "~/client/api-client/types.gen";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
volume: Volume;
|
volume: Volume;
|
||||||
@@ -24,12 +26,18 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const VolumeInfoTabContent = ({ volume, statfs }: Props) => {
|
export const VolumeInfoTabContent = ({ volume, statfs }: Props) => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
const updateMutation = useMutation({
|
||||||
...updateVolumeMutation(),
|
...updateVolumeMutation(),
|
||||||
onSuccess: (_) => {
|
onSuccess: (data: UpdateVolumeResponse) => {
|
||||||
toast.success("Volume updated successfully");
|
toast.success("Volume updated successfully");
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
setPendingValues(null);
|
setPendingValues(null);
|
||||||
|
|
||||||
|
if (data.name !== volume.name) {
|
||||||
|
navigate(`/volumes/${data.name}`);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
toast.error("Failed to update volume", { description: error.message });
|
toast.error("Failed to update volume", { description: error.message });
|
||||||
@@ -50,7 +58,7 @@ export const VolumeInfoTabContent = ({ volume, statfs }: Props) => {
|
|||||||
if (pendingValues) {
|
if (pendingValues) {
|
||||||
updateMutation.mutate({
|
updateMutation.mutate({
|
||||||
path: { name: volume.name },
|
path: { name: volume.name },
|
||||||
body: { config: pendingValues },
|
body: { name: pendingValues.name, config: pendingValues },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const startup = async () => {
|
|||||||
|
|
||||||
Scheduler.build(CleanupDanglingMountsJob).schedule("0 * * * *");
|
Scheduler.build(CleanupDanglingMountsJob).schedule("0 * * * *");
|
||||||
Scheduler.build(VolumeHealthCheckJob).schedule("*/30 * * * *");
|
Scheduler.build(VolumeHealthCheckJob).schedule("*/30 * * * *");
|
||||||
Scheduler.build(RepositoryHealthCheckJob).schedule("0 * * * *");
|
Scheduler.build(RepositoryHealthCheckJob).schedule("0 12 * * *");
|
||||||
Scheduler.build(BackupExecutionJob).schedule("* * * * *");
|
Scheduler.build(BackupExecutionJob).schedule("* * * * *");
|
||||||
Scheduler.build(CleanupSessionsJob).schedule("0 0 * * *");
|
Scheduler.build(CleanupSessionsJob).schedule("0 0 * * *");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ const checkHealth = async (repositoryId: string) => {
|
|||||||
throw new NotFoundError("Repository not found");
|
throw new NotFoundError("Repository not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
const { hasErrors, error } = await restic.check(repository.config, { readData: true });
|
const { hasErrors, error } = await restic.check(repository.config);
|
||||||
|
|
||||||
await db
|
await db
|
||||||
.update(repositoriesTable)
|
.update(repositoriesTable)
|
||||||
|
|||||||
Reference in New Issue
Block a user