@page
@model ManagementPage.Pages.UserHomeModel
@{
    ViewData["Title"] = "UserPage";
}

<h3>Hi @Model.name</h3>
<hr></hr>
<div class="card-deck row row-cols-1 row-cols-md-3 g-4">
    @foreach (var item in @Model.data)
    {
        <div class="card" style="width: 18rem;">
            <div class="card-body">
                <h5 class="card-title">@item.Name</h5>
                <p class="card-text">
                    <h4>Current conditions:</h4>
                    <div>Temperature @Model.currentEnvironment[@item.ApiID].Temperature</div>
                    <div>Humidity @Model.currentEnvironment[@item.ApiID].Humidity</div>
                </p>
                <a class="btn btn-primary" asp-area="" asp-page="/DevicePage" asp-route-id="@((UInt64)item.ApiID)">Details</a>
            </div>
        </div>
    }

    <div class="card text-center" style="width: 18rem;">
        <div class="card-body ">
            <h5 class="card-title">New Item</h5>
            <p class="card-text">Register a new device</p>
            <button type="button" class="btn btn-primary oi oi-plus" data-bs-toggle="modal" data-bs-target="#devicemodal"></button>
        </div>
    </div>
</div>

<div class="modal fade" id="devicemodal" tabindex="-1" aria-labelledby="deviceModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="deviceModalLabel">Add a new device</h5>
                <button type="button" id="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form role="form" method="POST" action="">
                    <div class="form-group">
                        <label asp-for="NewDevice.Name" class="control-label"></label>
                        <input asp-for="NewDevice.Name" class="form-control" />
                    </div>
                    <div class="form-group">
                        <label asp-for="NewDevice.Passcode" class="control-label"></label>
                        <input type="password" asp-for="NewDevice.Passcode" class="form-control" />
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-success">Create</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


