Improve Samba Global Configuration display in WebUI
Backend: - Parse global config into structured key-value pairs - Return parameters array instead of raw text - Better handling of comments and empty lines Frontend: - Add 'Samba Config' tab to shares page - Display config parameters in readable table format - Color-code parameter names for clarity - Add getSambaConfig() method to API client Co-Authored-By: Patrick <patrick@perlbach24.de>
This commit is contained in:
@@ -13,9 +13,10 @@ import DeleteConfirmDialog from "@/components/shares/DeleteConfirmDialog"
|
||||
|
||||
export default function SharesPage() {
|
||||
const router = useRouter()
|
||||
const [activeTab, setActiveTab] = useState<"samba" | "nfs">("samba")
|
||||
const [activeTab, setActiveTab] = useState<"samba" | "nfs" | "config">("samba")
|
||||
const [sambaShares, setSambaShares] = useState<any[]>([])
|
||||
const [nfsShares, setNfsShares] = useState<any[]>([])
|
||||
const [sambaConfig, setSambaConfig] = useState<any[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [showSambaDialog, setShowSambaDialog] = useState(false)
|
||||
@@ -37,13 +38,15 @@ export default function SharesPage() {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
|
||||
const [samba, nfs] = await Promise.all([
|
||||
const [samba, nfs, config] = await Promise.all([
|
||||
api.getSambaShares().catch(() => []),
|
||||
api.getNfsShares().catch(() => []),
|
||||
api.getSambaConfig().catch(() => ({ parameters: [] })),
|
||||
])
|
||||
|
||||
setSambaShares(samba)
|
||||
setNfsShares(nfs)
|
||||
setSambaConfig(config.parameters || [])
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Failed to load shares")
|
||||
} finally {
|
||||
@@ -138,6 +141,16 @@ export default function SharesPage() {
|
||||
>
|
||||
NFS
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab("config")}
|
||||
className={`px-4 py-2 font-medium transition-colors ${
|
||||
activeTab === "config"
|
||||
? "border-b-2 border-primary text-primary"
|
||||
: "text-muted-foreground hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
Samba Config
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -254,6 +267,41 @@ export default function SharesPage() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* SAMBA CONFIG TAB */}
|
||||
{activeTab === "config" && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Samba Global Configuration</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{sambaConfig.length === 0 ? (
|
||||
<p className="text-muted-foreground text-center py-12">
|
||||
No global configuration parameters found.
|
||||
</p>
|
||||
) : (
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="border-b border-border bg-muted/30">
|
||||
<tr>
|
||||
<th className="text-left py-3 px-4 font-medium w-40">Parameter</th>
|
||||
<th className="text-left py-3 px-4 font-medium">Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{sambaConfig.map((param, idx) => (
|
||||
<tr key={idx} className="border-b border-border/50 hover:bg-muted/30">
|
||||
<td className="py-3 px-4 font-mono text-xs font-medium text-blue-600">{param.key}</td>
|
||||
<td className="py-3 px-4 text-xs font-mono break-all">{param.value}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</main>
|
||||
|
||||
{/* Dialogs */}
|
||||
|
||||
Reference in New Issue
Block a user