@{
    ViewData["Title"] = "Settings";
    var pictureUrl = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value ?? "";
    var preferredUsername = User.Claims.FirstOrDefault(c => c.Type == "preferred_username")?.Value ?? "admin";
    var DbEngine = ViewBag.DbProvider;
    var mail = ViewBag.mail;
    var ServerVersion = ViewBag.ServerVersion;
}

<head>
    <link rel="stylesheet" href="~/css/site.css" />
    <link rel="stylesheet" href="~/css/settings.css" />
</head>

<div class="Settingscontainer">
    
    <div class="card shadow mt-5 p-4" style="width: 55%; margin: auto;">
        <h4><i class="bi bi-pencil-square me-2"></i>Systemeinformationen</h4>

        <br>

        <h5>Watcher Version: @ServerVersion</h5>

        <hr class="my-4" />

        <h5>Authentifizierungsmethode: <strong>@(ViewBag.IdentityProvider ?? "nicht gefunden")</strong></h5>
        

        <hr class="my-4" />

        <h5>Datenbank-Engine: <strong>@(DbEngine ?? "nicht gefunden")</strong></h5>
        

        <!-- Falls Sqlite verwendet wird können Backups erstellt werden -->
        @if (DbEngine == "Microsoft.EntityFrameworkCore.Sqlite")
        {
            <div class="d-flex gap-2">
                <form asp-action="CreateSqlDump" method="post" asp-controller="Database">
                    <button type="submit" class="btn btn-db">
                        <i class="bi bi-save me-1"></i> Backup erstellen
                    </button>
                </form>

                <form asp-action="ManageSqlDumps" method="post" asp-controller="Database">
                    <button type="submit" class="btn btn-db">
                        <i class="bi bi-save me-1"></i> Backups verwalten
                    </button>
                </form>
            </div>
            
        }
        else if (DbEngine == "Microsoft.EntityFrameworkCore.MySQL")
        {
            <p> MySQL Dump aktuell nicht möglich </p>
        }

        <!-- Status für Erstellung eines Backups -->
        @if (TempData["DumpMessage"] != null)
        {
            <div class="alert alert-success">
                <i class="bi bi-check-circle me-1"></i>@TempData["DumpMessage"]
            </div>
        }
        @if (TempData["DumpError"] != null)
        {
            <div class="alert alert-danger">
                <i class="bi bi-exclamation-circle me-1"></i>@TempData["DumpError"]
            </div>
        }

    </div>

    <div class="card shadow mt-5 p-4" style="width: 55%; margin: auto;">
        <h4><i class="bi bi-pencil-square me-2"></i>Benachrichtungen</h4>

        <p>Registrierte E-Mail Adresse: <strong>@(ViewBag.mail ?? "nicht gefunden")</strong></p>

        <!-- action="/Notification/UpdateSettings" existiert noch nicht-->
        <form method="post" action="#">
            <div class="card p-4 shadow-sm" style="max-width: 500px;">
                <h5 class="card-title mb-3">
                    <i class="bi bi-bell me-2"></i>Benachrichtigungseinstellungen
                </h5>

                <div class="form-check form-switch mb-3">
                    <input class="form-check-input" type="checkbox" id="notifyOffline" name="NotifyOffline" checked>
                    <label class="form-check-label" for="notifyOffline">Benachrichtigung bei Server-Offline</label>
                </div>

                <div class="form-check form-switch mb-3">
                    <input class="form-check-input" type="checkbox" id="notifyUpdates" name="NotifyUpdates">
                    <label class="form-check-label" for="notifyUpdates">Benachrichtigung bei neuen Updates</label>
                </div>

                <div class="form-check form-switch mb-3">
                    <input class="form-check-input" type="checkbox" id="notifyUser" name="NotifyUser">
                    <label class="form-check-label" for="notifyUser">Benachrichtigung bei neuen Benutzern</label>
                </div>

                <div class="form-check form-switch mb-3">
                    <input class="form-check-input" type="checkbox" id="notifyMaintenance" name="NotifyMaintenance">
                    <label class="form-check-label" for="notifyMaintenance">Wartungsinformationen erhalten</label>
                </div>

                <button type="submit" class="btn btn-db mt-3">
                    <i class="bi bi-save me-1"></i>Speichern
                </button>
            </div>
        </form>

        <hr class="my-4" />

    </div>
</div>
