@php
$nodes = $nodes ?? config('nas-file-manager.schema', []);
$canEdit = $canEdit ?? (config('nas-file-manager.edit_gate') === null || \Illuminate\Support\Facades\Gate::allows(config('nas-file-manager.edit_gate')));
$title = $title ?? 'Folder Structure & File Manager';
// Build connections — DB rows take priority, then config, then legacy key
$rawConns = \P7H\NasFileManager\Models\NasConnection::allAsConfig()
?? config('nas-file-manager.connections', []);
if (empty($rawConns)) {
$lc = config('nas-file-manager.connection', []);
$rawConns = [[
'name' => 'Primary NAS',
'enabled' => true,
'protocol' => $lc['protocol'] ?? 'sftp',
'host' => $lc['host'] ?? '',
'port' => (int)($lc['port'] ?? 22),
'username' => $lc['username'] ?? '',
'password' => $lc['password'] ?? '',
'share' => $lc['smb_share'] ?? '',
'smb_domain' => $lc['smb_domain'] ?? '',
'subdirectory' => $lc['path'] ?? '/media',
]];
}
$connectionsJs = collect($rawConns)->values()->map(fn($c, $i) => [
'_id' => $c['db_id'] ?? ($i + 1),
'db_id' => $c['db_id'] ?? null,
'name' => $c['name'] ?? ('Connection ' . ($i + 1)),
'enabled' => (bool)($c['enabled'] ?? true),
'expanded' => $i === 0,
'protocol' => $c['protocol'] ?? 'sftp',
'host' => $c['host'] ?? '',
'port' => (int)($c['port'] ?? 22),
'username' => $c['username'] ?? '',
'password' => '',
'has_password' => !empty($c['password']),
'share' => $c['share'] ?? ($c['smb_share'] ?? ''),
'smb_domain' => $c['smb_domain'] ?? '',
'subdirectory' => $c['subdirectory'] ?? ($c['path'] ?? '/media'),
'testStatus' => null,
'testMessage' => '',
'saveStatus' => null,
'saveMessage' => '',
'pickerOpen' => false,
'pickerItems' => [],
'pickerPath' => '',
'pickerSegments' => [],
'pickerLoading' => false,
'pickerError' => '',
'shares' => [],
'sharesLoading' => false,
])->all();
$hasConnection = collect($rawConns)->contains(fn($c) => !empty($c['host']));
@endphp
{{-- ── Accordion header ── --}}
{{-- ── Accordion body ── --}}
{{-- ── Tab bar ── --}}
{{-- ══════════════════════════════════════════════════════════════ --}}
{{-- SCHEMA TAB --}}
{{-- ══════════════════════════════════════════════════════════════ --}}
{{-- Live NAS tree --}}
{{-- Loading --}}
Loading…
{{-- Error --}}
{{-- Live tree --}}
{{-- No connection configured --}}
Configure a NAS connection to browse the live folder structure.
{{-- ══════════════════════════════════════════════════════════════ --}}
{{-- BROWSER TAB --}}
{{-- ══════════════════════════════════════════════════════════════ --}}
@if($canEdit)
@endif
{{-- ══════════════════════════════════════════════════════════════ --}}
{{-- CONNECTION TAB --}}
{{-- ══════════════════════════════════════════════════════════════ --}}
@if(!$hasConnection)
NAS connection not configured
Fill in the fields below, click Test to verify, then Save to DB.
@endif
{{-- ── Connection cards ── --}}
{{-- Card header --}}
{{-- Card body --}}
{{-- Protocol --}}
{{-- Subdirectory + inline picker --}}
Starting directory on the NAS.
{{-- Inline picker --}}
No subdirectories found
{{-- Test status --}}
{{-- Save status --}}
{{-- Card actions --}}
{{-- Test button --}}
{{-- Split save button --}}
{{-- /split button --}}
{{-- /card body --}}
{{-- /card --}}
{{-- Add connection --}}
{{-- /connection tab --}}
{{-- /accordion body --}}
@if($canEdit)
{{-- ── Rename dialog ── --}}
{{-- ── Delete dialog ── --}}
Delete ? This cannot be undone.
@endif
{{-- /nas-fm x-data --}}