﻿@model IEnumerable<RightpointLabs.Pourcast.Web.Areas.Admin.Models.TapModel>

@{
    ViewBag.Title = "Index";
}

<h2>Taps</h2>

@foreach (var tap in Model)
{
    <div class="col-lg-6">
        <h3>@tap.Name</h3>
        @if (null == tap.Keg)
        {
            <h4>No Keg On Tap</h4>
            <hr />
        }
        else
        {
            <h4>@tap.Keg.BeerName</h4>
            <p>
                Amount of Beer Remaining: @tap.Keg.AmountOfBeerRemaining <br />
                Percent Left: @tap.Keg.PercentRemaining <br />
            </p>
        }
        <p>
            @Html.ActionLink("Edit", "Edit", new {id = tap.Id})
        </p>
    </div>
}
<p>
     |
    @Html.ActionLink("Back to List", "Index")
</p>

﻿@model IEnumerable<RightpointLabs.Pourcast.Web.Areas.Admin.Models.TapModel>

@{
    ViewBag.Title = "Index";
}

<h2>Taps</h2>

@foreach (var tap in Model)
{
    <div class="col-lg-6">
        <h3>@tap.Name</h3>
        @if (null == tap.Keg)
        {
            <h4>No Keg On Tap</h4>
            <hr />
        }
        else
        {
            <h4>@tap.Keg.BeerName</h4>
            <p>
                Amount of Beer Remaining: @tap.Keg.AmountOfBeerRemaining <br />
                Percent Left: @tap.Keg.PercentRemaining <br />
            </p>
        }
        <p>
            @Html.ActionLink("Edit", "Edit", new {id = tap.Id}, new { @class = "btn"})
            @if (null != tap.Keg)
            {
                <a class="btn btn-pour" data-tap-id="@tap.Id" href="#">Pour</a>
            }
        </p>
    </div>
}
<p>
     |
    @Html.ActionLink("Back to List", "Index")
</p>



@section scripts {
    <script type="text/javascript">
        $(function () {
            $(".btn-pour").each(function() {
                var $t = $(this);
                var tapId = $t.attr("data-tap-id");
                var timer = null;
                var start = null;
                $t.mousedown(function () {
                    $.getJSON("/api/tap/" + tapId + "/StartPour");
                    start = new Date().getTime();
                    timer = setInterval(function () {
                        $.getJSON("/api/tap/" + tapId + "/Pouring?volume=" + ((new Date().getTime() - start) / 500));
                    }, 250);
                });
                $t.mouseup(function () {
                    clearInterval(timer);
                    $.getJSON("/api/tap/" + tapId + "/StopPour?volume=" + ((new Date().getTime() - start) / 500));
                });
            });
        });
    </script>
}
Add fake pour buttons in admin
Add fake pour buttons in admin

They follow the same API as the Netduino will: 1 StartPour when pressed,
0-N Pouring while button held down, 1 StopPour when button released.
