Add object for results details

This commit is contained in:
2020-07-18 21:39:18 -04:00
parent 1e7fa1bb1d
commit 28377cfce8
14 changed files with 156 additions and 33 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ namespace LeafWeb.WebCms.Tests.Models
public void CanConstructFromLeafInputFile()
{
var leafInput = GetLeafInput;
var viewModel = new LeafInputDetails(leafInput);
var viewModel = new LeafInputDetails_Admin(leafInput);
//Assert.That(viewModel.CurrentStatus, Is.EqualTo(leafInput.CurrentStatus.ToString()));
Assert.That(viewModel.StatusHistory, Has.Count.EqualTo(5));
+1 -1
View File
@@ -21,7 +21,7 @@ namespace LeafWeb.WebCms.App_Start
Mapper.CreateMap<LeafOutputFile, string>().ConvertUsing(file => file?.FileContents.Contents.GetString());
Mapper.CreateMap<LeafInputStatusType, string>().ConvertUsing(st => st.ToString());
Mapper.CreateMap<LeafInputStatusType, LeafInputStatus>().ConvertUsing(st => new LeafInputStatus());
Mapper.CreateMap<LeafInput, LeafInputDetails>()
Mapper.CreateMap<LeafInput, LeafInputDetails_Admin>()
.ForMember(dest => dest.LeafInputId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.HasLeafChart,
opt => opt.ResolveUsing(src => src.OutputFiles.Any(o => o.IsLeafChartFile)));
+3 -1
View File
@@ -5,7 +5,9 @@ namespace LeafWeb.WebCms.Controllers
{
public const int ManageQueue = 1107;
public const int Chart = 1100;
public const int Details = 1111;
// ReSharper disable once InconsistentNaming
public const int Details_Admin = 1111;
public const int Details_Results = 0;
public const int PasswordResetRequest = 1164;
}
+1 -1
View File
@@ -103,7 +103,7 @@ namespace LeafWeb.WebCms.Controllers
RedirectToUmbracoPage(LeafWebPageIds.ManageQueue);
}
var viewModel = new LeafInputDetails(leafInput);
var viewModel = new LeafInputDetails_Admin(leafInput);
return View(viewModel);
}
+17 -2
View File
@@ -11,7 +11,7 @@ namespace LeafWeb.WebCms.Controllers
{
public class ResultsController : BaseController
{
//[MemberAuthorize(AllowGroup = "Authenticated")]
[MemberAuthorize(AllowGroup = "Authenticated")]
public ActionResult Index(LeafDataQuery query)
{
var resultItems =
@@ -29,7 +29,7 @@ namespace LeafWeb.WebCms.Controllers
}
//[MemberAuthorize(AllowGroup = "Authenticated")]
[MemberAuthorize(AllowGroup = "Authenticated")]
[HttpPost]
public ActionResult Search(LeafDataQuery query)
{
@@ -41,6 +41,21 @@ namespace LeafWeb.WebCms.Controllers
return RedirectToCurrentUmbracoPage(query.GetNameValueCollection());
}
public ActionResult Details(int id)
{
var leafInput = DataService.GetLeafInput(id);
if (leafInput == null)
{
SetStatusMessage($"LeafInput '${id}' not found, may have been deleted?");
RedirectToUmbracoPage(LeafWebPageIds.ManageQueue);
}
var viewModel = new LeafInputDetails_Admin(leafInput);
return View(viewModel);
}
public ActionResult Recent()
{
var dateThreshold = DateTime.Today.Subtract(TimeSpan.FromDays(90));
+11 -15
View File
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web.Mvc;
using AutoMapper;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Utility;
namespace LeafWeb.WebCms.Models
{
@@ -14,24 +12,24 @@ namespace LeafWeb.WebCms.Models
[HiddenInput(DisplayValue = false)]
public int LeafInputId { get; set; }
[Display(Name = "Identifier")]
[Display(Name = "Identifier", Order = 0)]
[Required(ErrorMessage = "A unique identifier is required")]
public string Identifier { get; set; }
[Display(Name = "Site Id")]
[Display(Name = "Site Id", Order = 0)]
[Required(ErrorMessage = "The site's name is required")]
public string SiteId { get; set; }
[Display(Name = "Photosyn. Pathway")]
[Display(Name = "Photosyn. Pathway", Order = 0)]
[Required(ErrorMessage = "A Photosynthetic pathway must be chosen")]
public string PhotosynthesisType { get; set; }
[Display(Name = "Name")]
[Display(Name = "Name", Order = 0)]
[Required(ErrorMessage = "Name required")]
[RegularExpression(@"[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Please provide full name")]
public string Name { get; set; }
[Display(Name = "Email address")]
[Display(Name = "Email address", Order = 0)]
[Required(ErrorMessage = "An email address is required")]
[DataType(DataType.EmailAddress)]
[RegularExpression(@"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}", ErrorMessage = "Must be an email address")]
@@ -39,19 +37,17 @@ namespace LeafWeb.WebCms.Models
[DataType(DataType.Date)]
[Required]
[Display(Order = 0)]
public DateTime Added { get; set; }
[Display(Name = "Piscal Error")]
[Display(Name = "Piscal Error", Order = 0)]
[UIHint("PreReadMore")]
public string OutputErrorMessage { get; set; }
[Display(Name = "Piscal Warning")]
[Display(Name = "Piscal Warning", Order = 0)]
[UIHint("PreReadMore")]
public string OutputWarningMessage { get; set; }
[Display(Name = "Time In Progress")]
public TimeSpan TimeInProgress { get; set; }
[HiddenInput(DisplayValue = false)]
public bool HasLeafChart { get; set; }
@@ -71,12 +67,12 @@ namespace LeafWeb.WebCms.Models
public bool IsCancellable { get; set; }
[UIHint("LeafInputDataViewModels")]
[Display(Order = 0)]
public List<LeafInputDataViewModel> LeafInputData { get; set; }
[UIHint("LeafInputStatusViewModels")]
public List<LeafInputStatusViewModel> StatusHistory { get; set; }
public LeafInputDetails(){}
public LeafInputDetails(LeafInput leafInput)
public LeafInputDetails(LeafInput leafInput)
{
Mapper.Map(leafInput, this);
}
+23
View File
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using AutoMapper;
using LeafWeb.Core.Entities;
namespace LeafWeb.WebCms.Models
{
public class LeafInputDetails_Admin : LeafInputDetails
{
[Display(Name = "Time In Progress", Order = 2)]
public TimeSpan TimeInProgress { get; set; }
[UIHint("LeafInputStatusViewModels")]
[Display(Order = 2)]
public List<LeafInputStatusViewModel> StatusHistory { get; set; }
public LeafInputDetails_Admin(LeafInput leafInput)
{
Mapper.Map(leafInput, this);
}
}
}
+3 -3
View File
@@ -1,6 +1,6 @@
@using LeafWeb.WebCms.Controllers
@using LeafWeb.WebCms.Utility
@model LeafInputDetails
@model LeafInputDetails_Admin
<div class="row pb-3">
@@ -78,7 +78,7 @@
@Html.Partial("DisplayTemplates/_ChartLink", (int)item.LeafInputId, cssClass)
}
@helper DeleteLink(LeafInputDetails item)
@helper DeleteLink(LeafInputDetails_Admin item)
{
var cssClass
= CssClassUtil.CreateCssClassDataDictionary("btn", "btn-outline-secondary");
@@ -90,7 +90,7 @@
@Html.Partial("DisplayTemplates/_DeleteForm", Tuple.Create(item.LeafInputId, item.Identifier), cssClass)
}
@helper CancelLink(LeafInputDetails item)
@helper CancelLink(LeafInputDetails_Admin item)
{
var cssClass
= CssClassUtil.CreateCssClassDataDictionary("btn", "btn-outline-secondary");
+61
View File
@@ -0,0 +1,61 @@
@using LeafWeb.WebCms.Utility
@model LeafInputDetails_Admin
<div class="row pb-3">
@ChartLink(Model)
<div class="dropdown pl-3">
<button class="btn btn-outline-secondary dropdown-toggle" id="downloadButton"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="fa fa-download"></span> Download
</button>
<div class="dropdown-menu" aria-labelledby="downloadButton">
<a href="@Url.Action("DownloadInput", "Queue", new {id = Model.LeafInputId})"
class="dropdown-item">
Input
</a>
<a href="@Url.Action("DownloadOutputToUser", "Queue", new {id = Model.LeafInputId})"
class="dropdown-item @if (!Model.HasOutputFiles) {<text> disabled</text>}">
ToUser
</a>
</div>
</div>
@if (Model.IsCancellable)
{
<div class="pl-3">
@CancelLink(Model)
</div>
}
</div>
<div class="row">
<div class="container">
@Html.DisplayForModel()
</div>
</div>
@helper ChartLink(dynamic item)
{
var cssClass
= CssClassUtil.CreateCssClassDataDictionary("btn", "btn-outline-secondary");
if (!item.HasLeafChart)
{
cssClass.SetCssDisabled();
}
@Html.Partial("DisplayTemplates/_ChartLink", (int)item.LeafInputId, cssClass)
}
@helper CancelLink(LeafInputDetails_Admin item)
{
var cssClass
= CssClassUtil.CreateCssClassDataDictionary("btn", "btn-outline-secondary");
if (!item.IsCancellable)
{
cssClass.SetCssDisabled();
}
@Html.Partial("DisplayTemplates/_CancelForm", Tuple.Create(item.LeafInputId, item.Identifier), cssClass)
}
@@ -1,7 +1,7 @@
@using LeafWeb.WebCms.Controllers
@model int
@{
var url = UmbracoContext.Current.UrlProvider.GetUrl(LeafWebPageIds.Details);
var url = UmbracoContext.Current.UrlProvider.GetUrl(LeafWebPageIds.Details_Admin);
}
<a href="@url?id=@Model" @Html.Partial("DisplayTemplates/_ViewDataCssClass")>
@@ -0,0 +1,9 @@
@using LeafWeb.WebCms.Controllers
@model int
@{
var url = UmbracoContext.Current.UrlProvider.GetUrl(LeafWebPageIds.Details_Results);
}
<a href="@url?id=@Model" @Html.Partial("DisplayTemplates/_ViewDataCssClass")>
<span class="fa fa-edit"></span> Details
</a>
+3 -3
View File
@@ -6,9 +6,9 @@
Html.RequiresJs("~/scripts/jquery.validate.custom.js", 2);
Html.RequiresJs("~/scripts/jquery.validate.unobtrusive.bootstrap.js", 2);
string actionName = string.Empty;// = "Search";
string controllerName = string.Empty;// = "Queue";
string htmlFormAction = string.Empty;// = "/admin/manage-queue/";
var actionName = string.Empty;
var controllerName = string.Empty;
var htmlFormAction = string.Empty;
if (ViewData.ContainsKey("actionName"))
{
+17 -3
View File
@@ -12,7 +12,14 @@
<span class="d-none d-sm-inline">Actions</span>
</button>
<div class="dropdown-menu" aria-labelledby="actions(@Model.Id)">
@DetailsLink(Model)
@if (admin)
{
@Details_AdminLink(Model)
}
else
{
@Details_ResultsLink(Model)
}
@ChartLink(Model)
@if (admin && Model.IsPending)
{
@@ -40,11 +47,18 @@
</div>
</div>
@helper DetailsLink(dynamic item)
@helper Details_AdminLink(dynamic item)
{
var cssClass = CssClassUtil.CreateCssClassDataDictionary("dropdown-item");
@Html.Partial("DisplayTemplates/_DetailsLink", (int)item.Id, cssClass)
@Html.Partial("DisplayTemplates/_Details_AdminLink", (int)item.Id, cssClass)
}
@helper Details_ResultsLink(dynamic item)
{
var cssClass = CssClassUtil.CreateCssClassDataDictionary("dropdown-item");
@Html.Partial("DisplayTemplates/_Details_ResultsLink", (int)item.Id, cssClass)
}
@helper ChartLink(dynamic item)
+5 -2
View File
@@ -1024,7 +1024,7 @@
<Content Include="Views\Shared\DisplayTemplates\LeafInputStatusViewModels.cshtml" />
<Content Include="Views\Shared\DisplayTemplates\_ChartLink.cshtml" />
<Content Include="Views\Shared\DisplayTemplates\_Status.cshtml" />
<Content Include="Views\Shared\DisplayTemplates\_DetailsLink.cshtml" />
<Content Include="Views\Shared\DisplayTemplates\_Details_AdminLink.cshtml" />
<Content Include="Views\Shared\DisplayTemplates\_ChartButton.cshtml" />
<Content Include="Views\EmptyPage.cshtml" />
<Content Include="Views\Shared\EditorTemplates\TermsOfService.cshtml" />
@@ -1072,6 +1072,8 @@
<Content Include="Views\Results\Recent.cshtml" />
<Content Include="Views\MacroPartials\Search.cshtml" />
<Content Include="Views\Shared\_LeafInputActions.cshtml" />
<Content Include="Views\Shared\DisplayTemplates\_Details_ResultsLink.cshtml" />
<Content Include="Views\Results\Details.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
@@ -1115,10 +1117,11 @@
<Compile Include="Models\LeafInputDataCurveViewModel.cs" />
<Compile Include="Models\LeafInputDataSiteViewModel.cs" />
<Compile Include="Models\LeafInputDataViewModel.cs" />
<Compile Include="Models\LeafInputDetails.cs" />
<Compile Include="Models\PasswordResetForm.cs" />
<Compile Include="Models\PasswordResetRequestForm.cs" />
<Compile Include="Models\ContactForm.cs" />
<Compile Include="Models\LeafInputDetails.cs" />
<Compile Include="Models\LeafInputDetails_Admin.cs" />
<Compile Include="Models\LeafInputCreate.cs" />
<Compile Include="Models\LeafInputStatusViewModel.cs" />
<Compile Include="Models\SearchViewModel.cs" />