feat: add re-import from system buttons for Samba and NFS
Add 'Re-importar del sistema' buttons to the Samba and NFS pages,
mirroring the existing user import flow. Both buttons show a confirm
dialog before calling the respective /api/import/{samba,nfs} endpoints
which replace the DB table with the current system config.
Version bump: 0.6.0 → 0.6.1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
BINARY=nasctl
|
||||
VERSION?=0.6.0
|
||||
VERSION?=0.6.1
|
||||
GO?=go
|
||||
LDFLAGS=-s -w -X github.com/darroyo/nasctl/internal/web.Version=$(VERSION) -X github.com/darroyo/nasctl/internal/web.Commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||
BUILD_FLAGS=CGO_ENABLED=0
|
||||
|
||||
@@ -215,6 +215,8 @@ export const api = {
|
||||
deleteWatchedMount: (id: number) => request<void>("DELETE", `/system/watched-mounts/${id}`),
|
||||
|
||||
// import
|
||||
importSamba: () => request<{ imported: number; message?: string }>("POST", "/import/samba"),
|
||||
importNfs: () => request<{ imported: number; message?: string }>("POST", "/import/nfs"),
|
||||
importUsers: () => request<{ imported: number; message?: string }>("POST", "/import/users"),
|
||||
|
||||
// files
|
||||
|
||||
@@ -150,10 +150,25 @@ export default function Nfs() {
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-bold text-white">Exports NFS</h1>
|
||||
<div className="flex gap-2">
|
||||
<button className="btn-ghost" onClick={async () => {
|
||||
if (!confirm("Esto reemplazará todos los exports configurados con el contenido actual de /etc/exports. ¿Continuar?")) return;
|
||||
try {
|
||||
const res = await api.importNfs();
|
||||
await load();
|
||||
await refresh();
|
||||
alert(`Importados ${res.imported} exports desde /etc/exports. Revisa y aplica los cambios.`);
|
||||
} catch (err) {
|
||||
alert(err instanceof Error ? err.message : "Error al importar");
|
||||
}
|
||||
}}>
|
||||
Re-importar del sistema
|
||||
</button>
|
||||
<button className="btn-primary" onClick={openNew}>
|
||||
Nuevo export
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="card overflow-x-auto p-0">
|
||||
<table className="w-full text-left text-sm">
|
||||
|
||||
@@ -133,6 +133,19 @@ export default function Samba() {
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-bold text-white">Shares SMB / Samba</h1>
|
||||
<button className="btn-ghost" onClick={async () => {
|
||||
if (!confirm("Esto reemplazará todos los shares configurados con el contenido actual de smb.conf. ¿Continuar?")) return;
|
||||
try {
|
||||
const res = await api.importSamba();
|
||||
await load();
|
||||
await refresh();
|
||||
alert(`Importados ${res.imported} shares desde smb.conf. Revisa y aplica los cambios.`);
|
||||
} catch (err) {
|
||||
alert(err instanceof Error ? err.message : "Error al importar");
|
||||
}
|
||||
}}>
|
||||
Re-importar del sistema
|
||||
</button>
|
||||
<button className="btn-primary" onClick={() => openEditor(null)}>
|
||||
Nuevo share
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user