Files
LeafWeb/WebCms/Views/Queue/Index.cshtml
T
2020-02-25 11:08:27 -05:00

170 lines
6.6 KiB
Plaintext

@using ClientDependency.Core.Mvc
@using LeafWeb.Core.Entities
@using LeafWeb.WebCms.Controllers
@model QueueViewModel
@{
Html.RequiresJs("~/scripts/Queue.js");
var grid = new WebGrid(Model.Items, rowsPerPage: 45);
}
<div class="row">
<div class="col-lg-8">
Service description: @Model.ServerDescription<br/>
@*Est. processing time by LeafInput size -
<i class="fa fa-file-o"></i> 1: <strong>@Model.TimeInProgressEstimater.EstimateTimeInProgress(1).ToRoundedReadableString()</strong>
<i class="fa fa-file-o"></i> 10: <strong>@Model.TimeInProgressEstimater.EstimateTimeInProgress(10).ToRoundedReadableString()</strong>
<i class="fa fa-file-o"></i> 100: <strong>@Model.TimeInProgressEstimater.EstimateTimeInProgress(100).ToRoundedReadableString()</strong>*@
</div>
<div class="col-lg-4">
@using (Html.BeginUmbracoForm<QueueController>("Search", FormMethod.Post))
{
<div class="input-group">
<input name="query" type="text" class="form-control" placeholder="Search for..." value="@Model.Query">
<span class="input-group-btn">
<button class="btn btn-outline-secondary" type="button">Search</button>
</span>
</div><!-- /input-group -->
}
</div>
</div>
@if (Model.Items.Any())
{
<div id="queue" class="table-responsive">
@grid.Table(columns:
grid.Columns(
grid.Column("Identifier", "Identifier"),
grid.Column("SiteId", "Site Id"),
grid.Column("Name", "Submitted By" ),
grid.Column("TimeInProgress", "Statistics", item => Statistics(item.Value), canSort: false),
grid.Column("CurrentStatus", "Status", item => Status(item.Value), canSort: false),
grid.Column("Total Results: " + Model.Items.Count(), format: item => Actions(item.Value), canSort: false)),
htmlAttributes: new {@class = "table table-sm table-striped table-bordered table-hover"}
)
@grid.BootstrapPager()
</div>
}
else
{
<p>No results.</p>
}
@helper Status(LeafInput leafInput)
{
@Html.Partial("DisplayTemplates/_LeafInputStatus", leafInput)
}
@helper Actions(LeafInput item)
{
<div class="btn-group text-nowrap" role="group">
<div class="btn-group" role="group">
<button id="actions(@item.Id)" type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Actions">
<span class="d-none d-sm-inline">Actions</span>
</button>
<div class="dropdown-menu" aria-labelledby="actions(@item.Id)">
<button class="dropdown-item">@DetailsLink(item)</button>
<button class="dropdown-item @DisableItem(!item.HasLeafChart)">@ChartLink(item)</button>
@if (item.IsPending)
{
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">Priority</h6>
<button class="dropdown-item @DisableItem(item.PendingPriority == Priority.High)">@PriorityForm(item, Priority.High)</button>
<button class="dropdown-item @DisableItem(item.PendingPriority == Priority.Normal)">@PriorityForm(item, Priority.Normal)</button>
<button class="dropdown-item @DisableItem(item.PendingPriority == Priority.Low)">@PriorityForm(item, Priority.Low)</button>
}
@if (item.IsCancellable)
{
<div class="dropdown-divider"></div>
<button class="dropdown-item">@CancelLink(item)</button>
}
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">Download</h6>
<button class="dropdown-item">@DownloadInput(item)</button>
<button class="dropdown-item @DisableItem(!item.HasOutputFiles)">@DownloadOutputToUser(item)</button>
<div class="dropdown-divider"></div>
<button class="dropdown-item @DisableItem(!item.IsDeletable)">@DeleteLink(item)</button>
</div>
</div>
</div>
}
@helper DetailsLink(dynamic item)
{
@Html.Partial("DisplayTemplates/_DetailsLink", (int)item.Id)
}
@helper ChartLink(dynamic item)
{
@Html.Partial("DisplayTemplates/_ChartLink", (int)item.Id)
}
@helper DownloadInput(dynamic item)
{
<a href="@Url.Action("DownloadInput", "Queue", new {id = item.Id})">
<span class="fa fa-download"></span> Input
</a>
}
@helper DownloadOutputToUser(dynamic item)
{
<a href="@Url.Action("DownloadOutputToUser", "Queue", new {id = item.Id})">
<span class="fa fa-download"></span> ToUser
</a>
}
@helper Statistics(LeafInput leafInput)
{
var summary = new List<string> { "Added Time: " + leafInput.Added };
if (leafInput.StartTime.HasValue)
{
summary.Add("Start Time: " + leafInput.StartTime.Value);
}
if (leafInput.EndTime.HasValue)
{
summary.Add("End Time: " + leafInput.EndTime.Value);
}
var summaryText = string.Join(Environment.NewLine, summary);
<span class="text-nowrap" title="@summaryText">
<i class="fa fa-file-o"></i> @leafInput.InputFiles.Count @if(leafInput.InputFiles.Count > 1) {<text>inputs</text>} else { <text>input</text>}
<br />
@if (leafInput.TimeInProgress > TimeSpan.Zero)
{
<text>
<i class="fa fa-clock-o"></i> @leafInput.TimeInProgress.ToRoundedReadableString()
</text>
}
else if (leafInput.IsPending)
{
<text>
<i class="fa fa-hourglass-start"></i> @Html.Partial("DisplayTemplates/_TimeRemaining", Tuple.Create(leafInput, Model.TimeInProgressEstimater)) est.
</text>
}
@if (leafInput.IsRunning)
{
<text>
<br />
<i class="fa fa-hourglass-half"></i> @Html.Partial("DisplayTemplates/_TimeRemaining", Tuple.Create(leafInput, Model.TimeInProgressEstimater)) left
</text>
}
</span>
}
@helper DeleteLink(LeafInput item)
{
@Html.Partial("DisplayTemplates/_DeleteForm", Tuple.Create(item.Id, item.Identifier, item.IsDeletable, true))
}
@helper CancelLink(LeafInput item)
{
@Html.Partial("DisplayTemplates/_CancelForm", Tuple.Create(item.Id, item.Identifier, true))
}
@helper PriorityForm(LeafInput item, Priority priority)
{
@Html.Partial("DisplayTemplates/_PriorityForm", Tuple.Create(item.Id, item.PendingPriority, priority))
}
@helper DisableItem(bool disabled)
{
if (disabled){<text>disabled</text>}
}