﻿@model ExampleApp.Web.Models.QueueInformationViewModel

<div id="QueueInformation">

    @Html.LabelFor(m => m.QueueName)                    <span id="QueueInformation_QueueName">@Model.QueueName</span>
    @Html.LabelFor(m => m.CurrentQueueSizeMegabytes)    <span id="QueueInformation_CurrentQueueSize">@Model.CurrentQueueSizeMegabytes</span> MB
    @Html.LabelFor(m => m.MaxQueueSizeMegabytes)        <span id="QueueInformation_MaxQueueSize">@Model.MaxQueueSizeMegabytes</span> MB

    <div id="QueueInformationAjaxStatus"></div>

    <script type="text/javascript">
        function updateQueueInformation() {
            var ajaxRequest = $.get('@Url.HttpRouteUrl("GetQueue", new {queueName = Model.QueueName})')
                .done(function (data) {
                    $('#QueueInformation_QueueName').text(data.QueueName);
                    $('#QueueInformation_CurrentQueueSize').text(data.CurrentQueueSizeMegabytes);
                    $('#QueueInformation_MaxQueueSize').text(data.MaxQueueSizeMegabytes);
                })
                .always(function () {
                    setTimeout(updateQueueInformation, 2000);
                });

            ajax.indicate(ajaxRequest, $('#QueueInformationAjaxStatus'), false);
        }

        updateQueueInformation();
    </script>
</div>