{{define "content"}}
<div class="page-header">
  <div>
    <h1 class="page-title">Module</h1>
    <p class="page-sub">Scanner-Module aktivieren, deaktivieren und konfigurieren.</p>
  </div>
</div>

<div class="card">
  {{range .Modules}}
  <div class="module-row">
    <div class="module-icon">
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round">
        <path d="M22 12h-4l-3 9L9 3l-3 9H2"/>
      </svg>
    </div>

    <div class="module-info">
      <div class="module-name">{{.DisplayName}}</div>
      <div class="module-desc">{{.Description}} · alle {{.Interval}}</div>
    </div>

    <div class="module-status">
      {{if .LastRun}}
      <span style="font-size:12px;color:var(--text-3);">Letzter Lauf: {{.LastRun}}</span>
      {{end}}
      {{if .Enabled}}
      <span class="badge badge-green">Aktiv</span>
      {{else}}
      <span class="badge badge-gray">Inaktiv</span>
      {{end}}
      <form method="POST" action="/modules/{{.Name}}/toggle" style="display:inline;">
        <label class="toggle" title="{{if .Enabled}}Deaktivieren{{else}}Aktivieren{{end}}">
          <input type="checkbox"{{if .Enabled}} checked{{end}} onchange="this.form.submit()">
          <span class="toggle-track"></span>
        </label>
      </form>
    </div>
  </div>
  {{else}}
  <div style="padding:48px;text-align:center;color:var(--text-3);">
    Keine Module registriert. Konfiguriere Module in config.yaml.
  </div>
  {{end}}
</div>

<div class="card" style="margin-top:16px;">
  <div class="card-header">
    <span class="card-title">ARP-Discovery Konfiguration</span>
  </div>
  <form method="POST" action="/modules/arp_discovery/config" class="setting-body full">
    <div class="form-group">
      <label class="input-label">Subnetz (CIDR)</label>
      {{range .ARPSubnets}}
      <input class="input mb-3" type="text" name="subnet" value="{{.}}" placeholder="192.168.0.0/24">
      {{else}}
      <input class="input mb-3" type="text" name="subnet" value="" placeholder="192.168.0.0/24">
      {{end}}
    </div>
    <div class="form-group">
      <label class="input-label">Netzwerk-Interface</label>
      <input class="input" type="text" name="interface" value="{{.ARPInterface}}" placeholder="eth0">
    </div>
    <div>
      <button type="submit" class="btn btn-primary">Speichern</button>
    </div>
  </form>
</div>
{{end}}
