@using ConstructorAppUI.ViewModels
@model DashboardIndexViewModel
@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/AdminLayout/Index.cshtml";
}


@section Scripts {
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
    <script src="~/lib/microsoft/signalr/dist/browser/signalr.min.js"></script>
    <script type="text/javascript">

        $(document).ready(() => {
            var signalRHubBaseUrl = '@ViewBag.SignalRHubBaseUrl';
            var connection = new signalR.HubConnectionBuilder().withUrl(`${signalRHubBaseUrl}/signalrhub`).build();


             connection.on("ReceiveContactUsCountAll", (value) => {
                $("#receivecontactuscountall").text(value);
            });

             connection.on("ReceiveProjectCountAll", (value) => {
                $("#receiveprojectcountall").text(value);
            });

             connection.on("ReceiveReferenceCountAll", (value) => {
                $("#receivereferencecountall").text(value);
            });

             connection.on("ReceiveTestimonialCountAll", (value) => {
                $("#receivetestimonialcountall").text(value);
            });


                connection.start().then(() => {
                $("#connstatus").text("Bağlı"); // Bağlantı sağlandığında durumu "Connected" olarak ayarla

                setInterval(() => {
                    connection.invoke("SendContactUs").catch((err) => console.error(err));
                    connection.invoke("SendProject").catch((err) => console.error(err));
                    connection.invoke("SendReference").catch((err) => console.error(err));
                    connection.invoke("SendTestimonial").catch((err) => console.error(err));
                }, 1000);

            }).catch((err) => {
                console.error(err);
            });
        });
    </script>
}


<!-- Ionicons -->
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<body class="hold-transition sidebar-mini layout-fixed">
    <div class="wrapper">
        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-3 col-6">
                        <!-- small box -->
                        <div class="small-box bg-info">
                            <div class="inner">
                                <h3 id="receivecontactuscountall"><sup style="font-size: 20px"></sup></h3>
                                <p>İletişim Talepleri</p>
                            </div>
                            <div class="icon">
                                <i class="far fa-envelope"></i>
                            </div>
                            <a href="ContactUs/Index/" class="small-box-footer">Daha Fazla <i class="fas fa-arrow-circle-right"></i></a>
                        </div>
                    </div>
                    <div class="col-lg-3 col-6">
                        <!-- small box -->
                        <div class="small-box bg-warning">
                            <div class="inner">
                                <h3 id="receiveprojectcountall"><sup style="font-size: 20px"></sup></h3>
                                <p>Gösterimdeki Projeler</p>
                            </div>
                            <div class="icon">
                                <i class="ion ion-person-add"></i>
                            </div>
                            <a href="#" class="small-box-footer">Daha Fazla <i class="fas fa-arrow-circle-right"></i></a>
                        </div>
                    </div>
                    <div class="col-lg-3 col-6">
                        <!-- small box -->
                        <div class="small-box bg-gradient-indigo">
                            <div class="inner">
                                <h3 id="receivereferencecountall"><sup style="font-size: 20px"></sup></h3>
                                <p>Referanslar</p>
                            </div>
                            <div class="icon">
                                <i class="ion ion-person-add"></i>
                            </div>
                            <a href="#" class="small-box-footer">Daha Fazla <i class="fas fa-arrow-circle-right"></i></a>
                        </div>
                    </div>
                    <div class="col-lg-3 col-6">
                        <!-- small box -->
                        <div class="small-box bg-success">
                            <div class="inner">
                                <h3 id="receivetestimonialcountall"><sup style="font-size: 20px"></sup></h3>
                                <p>Gelen Youmlar</p>
                            </div>
                            <div class="icon">
                                <i class="ion ion-person-add"></i>
                            </div>
                            <a href="#" class="small-box-footer">Daha Fazla <i class="fas fa-arrow-circle-right"></i></a>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
</body>



