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:
2026-07-06 22:29:39 -04:00
parent 03e9368a91
commit 155b5a4b21
4 changed files with 37 additions and 7 deletions
+1 -1
View File
@@ -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
+2
View File
@@ -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
+18 -3
View File
@@ -150,9 +150,24 @@ 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>
<button className="btn-primary" onClick={openNew}>
Nuevo export
</button>
<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">
+16 -3
View File
@@ -133,9 +133,22 @@ 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-primary" onClick={() => openEditor(null)}>
Nuevo share
</button>
<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>
</div>
<div className="card overflow-x-auto p-0">