Update button rendering, move css classes to viewdata

This commit is contained in:
2020-06-26 21:40:20 -04:00
parent 7e88de5041
commit 55f59ddd7a
11 changed files with 208 additions and 112 deletions
+52 -30
View File
@@ -1,6 +1,6 @@
@using ClientDependency.Core.Mvc
@using LeafWeb.Core.Entities
@using LeafWeb.WebCms.Controllers
@using LeafWeb.WebCms.Utility
@model QueueViewModel
@{
@@ -13,16 +13,16 @@
var grid = new WebGrid(Model.Items, rowsPerPage: 45);
}
@using (Html.BeginUmbracoForm("Search", "Queue", null, new {@action = "/leaf-data/manage-queue/"}))
@using (Html.BeginUmbracoForm("Search", "Queue", null, new { @action = "/leaf-data/manage-queue/" }))
{
<div class="row">
<div class="col-lg-8 font-italic font-weight-light">
@Model.Items.Count() results<br />
Service description: @Model.ServerDescription
@*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>*@
<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">
<div class="input-group">
@@ -48,31 +48,31 @@
@Html.EditorFor(m => m.Q.species)
</div>
</div>
<hr/>
<hr />
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-sm-7">
@Html.EditorFor(m => m.Q.lat, new {size = "small", append = "&deg;"})
@Html.EditorFor(m => m.Q.lat, new { size = "small", append = "&deg;" })
</div>
<div class="col-sm-5">
@Html.EditorFor(m => m.Q.latr, new {size = "small", prepend = "&plusmn;", append = "&deg;"})
@Html.EditorFor(m => m.Q.latr, new { size = "small", prepend = "&plusmn;", append = "&deg;" })
</div>
</div>
</div>
<div class="col-md-6 border-left">
<div class="row">
<div class="col-sm-7">
@Html.EditorFor(m => m.Q.lon, new {size = "small", append = "&deg;"})
@Html.EditorFor(m => m.Q.lon, new { size = "small", append = "&deg;" })
</div>
<div class="col-sm-5">
@Html.EditorFor(m => m.Q.lonr, new {size = "small", prepend = "&plusmn;", append = "&deg;"})
@Html.EditorFor(m => m.Q.lonr, new { size = "small", prepend = "&plusmn;", append = "&deg;" })
</div>
</div>
</div>
</div>
</div>
</div>
</div>
}
@@ -83,11 +83,11 @@
grid.Columns(
grid.Column("Identifier", "Identifier"),
grid.Column("SiteId", "Site Id"),
grid.Column("Name", "Submitted By" ),
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("", format: item => Actions(item.Value), canSort: false)),
htmlAttributes: new {@class = "table table-sm table-striped table-bordered table-hover"}
htmlAttributes: new { @class = "table table-sm table-striped table-bordered table-hover" }
)
@grid.BootstrapPager()
</div>
@@ -106,7 +106,7 @@ else
{
<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"
<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>
@@ -129,9 +129,9 @@ else
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">Download</h6>
@DownloadInput(item)
<button class="dropdown-item @DisableItem(!item.HasOutputFiles)">@DownloadOutputToUser(item)</button>
@DownloadOutputToUser(item)
<div class="dropdown-divider"></div>
<button class="dropdown-item @DisableItem(!item.IsDeletable)">@DeleteLink(item)</button>
@DeleteLink(item)
</div>
</div>
</div>
@@ -139,17 +139,20 @@ else
@helper DetailsLink(dynamic item)
{
@Html.Partial("DisplayTemplates/_DetailsLink", (int)item.Id, new ViewDataDictionary {{"cssClass", new[]{"dropdown-item"}}})
var cssClass= CssClassUtil.CreateCssClassDataDictionary("dropdown-item");
@Html.Partial("DisplayTemplates/_DetailsLink", (int)item.Id, cssClass)
}
@helper ChartLink(dynamic item)
{
var classes = new[]{"dropdown-item"};
var cssClass= CssClassUtil.CreateCssClassDataDictionary("dropdown-item");
if (!item.HasLeafChart)
{
classes = classes.Concat(new[] {"disabled"}).ToArray();
cssClass.SetButtonDisabled();
}
@Html.Partial("DisplayTemplates/_ChartLink", (int)item.Id, new ViewDataDictionary {{"cssClass", classes}})
@Html.Partial("DisplayTemplates/_ChartLink", (int)item.Id, cssClass)
}
@helper DownloadInput(dynamic item)
@@ -160,7 +163,7 @@ else
}
@helper DownloadOutputToUser(dynamic item)
{
<a href="@Url.Action("DownloadOutputToUser", "Queue", new {id = item.Id})" class="dropdown-item">
<a href="@Url.Action("DownloadOutputToUser", "Queue", new {id = item.Id})" class="dropdown-item @DisableItem(!item.HasOutputFiles)">
<span class="fa fa-download"></span> ToUser
</a>
}
@@ -177,45 +180,64 @@ else
}
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>}
<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()
<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.
<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
<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), new ViewDataDictionary {{"cssClass", new[]{"dropdown-item"}}})
var cssClass
= CssClassUtil.CreateCssClassDataDictionary("dropdown-item");
if (!item.IsDeletable)
{
cssClass.SetButtonDisabled();
}
@Html.Partial("DisplayTemplates/_DeleteForm", Tuple.Create(item.Id, item.Identifier), cssClass)
}
@helper CancelLink(LeafInput item)
{
@Html.Partial("DisplayTemplates/_CancelForm", Tuple.Create(item.Id, item.Identifier, true), new ViewDataDictionary {{"cssClass", new[]{"dropdown-item"}}})
var cssClass
= CssClassUtil.CreateCssClassDataDictionary("dropdown-item");
if (!item.IsCancellable)
{
cssClass.SetButtonDisabled();
}
@Html.Partial("DisplayTemplates/_CancelForm", Tuple.Create(item.Id, item.Identifier), cssClass)
}
@helper PriorityForm(LeafInput item, Priority priority)
{
@Html.Partial("DisplayTemplates/_PriorityForm", Tuple.Create(item.Id, item.PendingPriority, priority), new ViewDataDictionary {{"cssClass", new[]{"dropdown-item"}}})
var cssClass
= CssClassUtil.CreateCssClassDataDictionary("dropdown-item");
@Html.Partial("DisplayTemplates/_PriorityForm", Tuple.Create(item.Id, item.PendingPriority, priority), cssClass)
}
@helper DisableItem(bool disabled)
{
if (disabled){<text>disabled</text>}
if (disabled)
{<text>disabled</text>}
}