@model Disco.Web.Models.Job.ShowModel
@{
    ViewBag.Title = Html.ToBreadcrumb("Jobs", MVC.Job.Index(), string.Format("Job: {0}", Model.Job.Id.ToString()));

    Html.BundleDeferred("~/ClientScripts/Modules/jQueryUI-TimePicker");

    Authorization.Require(Claims.Job.Show);
}
<div id="Job_Show">
    <div id="Job_Show_Status">
        @{ var jobStatusInfo = Model.Job.Status();}
        <i class="fa fa-square jobStatus @(jobStatusInfo.Item1)"></i>&nbsp;@jobStatusInfo.Item2 @if (Model.LongRunning.HasValue)
                                                                                                {<span class="smallMessage">(Long Running: @Model.LongRunning.Value.Humanize(false))</span>}
    </div>
    <div id="Job_Show_QueueStatus">
        @foreach (var jq in Model.Job.JobQueues.Where(q => !q.RemovedDate.HasValue).Select(q => Disco.Services.Jobs.JobQueues.JobQueueService.GetQueue(q.JobQueueId)))
        {
            <i class="fa fa-@(jq.JobQueue.Icon) fa-fw fa-lg d-@(jq.JobQueue.IconColour)" title="@(jq.JobQueue.Name)"></i>
        }
    </div>
    <script type="text/javascript">
        $(function () {
            $('#Job_Show_Status').appendTo('#layout_PageHeading');
            $('#Job_Show_QueueStatus').appendTo('#layout_PageHeading');
        });
    </script>
    @Html.Partial(MVC.Job.Views.JobParts._Subject, Model)
    <script type="text/javascript">
        $(function () {
            var $tabs = $('#jobDetailTabs');
            if ($tabs.children().length > 1) {
                $tabs.tabs({
                    activate: function (event, ui) {
                        window.setTimeout(function () {
                            var $window = $(window);
                            var tabHeight = $tabs.height();
                            var tabOffset = $tabs.offset();
                            var windowScrollTop = $window.scrollTop();
                            var windowHeight = $window.height();

                            var tabTopNotShown = windowScrollTop - tabOffset.top;
                            if (tabTopNotShown > 0) {
                                $('html').animate({ scrollTop: tabOffset.top }, 125);
                            } else {
                                var tabBottomNotShown = ((windowScrollTop + windowHeight) - (tabHeight + tabOffset.top)) * -1;
                                if (tabBottomNotShown > 0) {
                                    if (tabHeight > windowHeight)
                                        $('html').animate({ scrollTop: tabOffset.top }, 125);
                                    else
                                        $('html').animate({ scrollTop: windowScrollTop + tabBottomNotShown }, 125);
                                }
                            }
                        }, 1);
                    }
                });
            } else {
                $tabs.hide();
            }
        });
    </script>
    <div id="jobDetailTabs">
        <ul id="jobDetailTabItems">
            @if (Authorization.HasAll(Claims.Job.ShowLogs, Claims.Job.ShowAttachments))
            {
                <li><a id="jobDetailTab-ResourcesLink" href="#jobDetailTab-Resources">Log and Attachments [@(Model.Job.JobAttachments.Count)]</a></li>
            }
            else if (Authorization.Has(Claims.Job.ShowLogs))
            {
                <li><a id="jobDetailTab-ResourcesLink" href="#jobDetailTab-Resources">Log</a></li>
            }
            else if (Authorization.Has(Claims.Job.ShowAttachments))
            {
                <li><a id="jobDetailTab-ResourcesLink" href="#jobDetailTab-Resources">Attachments [@(Model.Job.JobAttachments.Count)]</a></li>
            }
            @if (Authorization.Has(Claims.Job.ShowJobsQueues))
            {
                <li><a id="jobDetailTab-QueuesLink" href="#jobDetailTab-Queues">Queues [@(Model.Job.JobQueues.Count(jq => !jq.RemovedDate.HasValue))]</a></li>
            }
        </ul>
        @if (Authorization.HasAny(Claims.Job.ShowLogs, Claims.Job.ShowAttachments))
        {
            <div id="jobDetailTab-Resources" class="jobPart">
                @Html.Partial(MVC.Job.Views.JobParts.Resources, Model)
            </div>
        }
        @if (Authorization.Has(Claims.Job.ShowJobsQueues))
        {
            <div id="jobDetailTab-Queues" class="jobPart">
                @Html.Partial(MVC.Job.Views.JobParts.Queues, Model)
            </div>
        }
        @Html.Partial(MVC.Job.Views.JobParts.JobMetaAdditions, Model)
    </div>
</div>
