Add LeafInputDataSite info to Queue Details

This commit is contained in:
2020-06-23 15:47:30 -04:00
parent a4db61509d
commit 95e7de2a9b
5 changed files with 138 additions and 9 deletions
+101
View File
@@ -0,0 +1,101 @@
using System.ComponentModel.DataAnnotations;
using AutoMapper;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Utility;
namespace LeafWeb.WebCms.Models
{
public class LeafInputDataSiteViewModel
{
/// <summary>Site identifier</summary>
/// <remarks>do not leave blank between letters</remarks>
[ParseInfo(1)]
[Display(Name = "Site Id")]
public string SiteId { get; set; }
/// <summary>Site latitude, northern hemisphere positive</summary>
[DisplayFormat(DataFormatString = "{0} &deg;")]
public double? Latitude { get; set; }
/// <summary>Site longitude, east positive</summary>
[DisplayFormat(DataFormatString = "{0} &deg;")]
public double? Longitude { get; set; }
/// <summary>site elevation</summary>
[DisplayFormat(DataFormatString = "{0} m")]
public double? Elevation { get; set; }
/// <summary>the year when the A/Ci data is taken</summary>
[DisplayFormat(DataFormatString = "{0} year")]
public int? SampleYear { get; set; }
/// <summary>the day of year (since 1 Jan) when the A/Ci data is taken</summary>
[ParseInfo(6, units: "day")]
public int? SampleDayOfYear { get; set; }
/// <summary>the approximate start day (since 1 Jan) of growing season</summary>
[ParseInfo(7, units: "day")]
public int? GrowSeasonStart { get; set; }
/// <summary>the approximate end day (since 1 Jan) of growing season</summary>
[ParseInfo(8, units: "day")]
public int? GrowSeasonEnd { get; set; }
/// <summary>stand age since the last disturbance</summary>
[ParseInfo(9, units: "year")]
public double? StandAge { get; set; }
/// <summary>the height of the canopy</summary>
[ParseInfo(10, units: "m")]
public double? CanopyHeight { get; set; }
/// <summary>the leaf area index in the middle of growing season</summary>
[ParseInfo(11, units: "m2/m2")]
public double? LeafAreaIndex { get; set; }
/// <summary>the species of the leaf sample</summary>
/// <remarks>don't leave blank between letters</remarks>
[ParseInfo(12, units: "dimensionless")]
public string SpeciesSampled { get; set; }
/// <summary>the average time interval between two consecutive A/Ci data points</summary>
[ParseInfo(13, alternateTitle: "AveTimeResolution", units: "minutes")]
public double? AverageTimeResolution { get; set; }
/// <summary>the height at which the leaf is located</summary>
[ParseInfo(14, units: "m")]
public double? SampleHeight { get; set; }
/// <summary>the age of the leaf</summary>
[ParseInfo(15, units: "day")]
public int? LeafAge { get; set; }
/// <summary>specific leaf area of the sample</summary>
[ParseInfo(16, units: "cm2/g")]
public double? SpecificLeafArea { get; set; }
/// <summary>dry leaf nitrogen content of the sample</summary>
[ParseInfo(17, units: "%")]
public double? LfNitrogenContent { get; set; }
/// <summary>dry leaf carbon content of the sample</summary>
[ParseInfo(18, units: "%")]
public double? LfCarbonContent { get; set; }
/// <summary>dry leaf phosphorus content of the sample</summary>
[ParseInfo(19, units: "%")]
public double? LfPhosphContent { get; set; }
static LeafInputDataSiteViewModel()
{
Mapper.CreateMap<LeafInputDataSite, LeafInputDataSiteViewModel>();
}
public LeafInputDataSiteViewModel() {}
public LeafInputDataSiteViewModel(LeafInputDataSite site)
{
Mapper.Map(site, this);
}
}
}
+14 -6
View File
@@ -9,7 +9,7 @@ using LeafWeb.Core.Utility;
namespace LeafWeb.WebCms.Models
{
public class LeafInputDetails
public class LeafInputDetails
{
[HiddenInput(DisplayValue = false)]
public int LeafInputId { get; set; }
@@ -52,7 +52,11 @@ namespace LeafWeb.WebCms.Models
[Display(Name = "Time In Progress")]
public TimeSpan TimeInProgress { get; set; }
[UIHint("LeafInputStatusViewModels")]
[UIHint("LeafInputDataSiteViewModels")]
public List<LeafInputDataSiteViewModel> Sites { get; set; }
[UIHint("LeafInputStatusViewModels")]
public List<LeafInputStatusViewModel> StatusHistory { get; set; }
[HiddenInput(DisplayValue = false)]
@@ -80,10 +84,14 @@ namespace LeafWeb.WebCms.Models
Mapper.CreateMap<LeafInputStatusType, string>().ConvertUsing(st => st.ToString());
Mapper.CreateMap<LeafInputStatusType, LeafInputStatus>().ConvertUsing(st => new LeafInputStatus());
Mapper.CreateMap<LeafInputStatus, LeafInputStatusViewModel>();
Mapper.CreateMap<LeafInput, LeafInputDetails>()
.ForMember(dest => dest.LeafInputId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.HasLeafChart, opt => opt.ResolveUsing(src => src.OutputFiles.Any(o => o.IsLeafChartFile)));
}
Mapper.CreateMap<LeafInputDataSite, LeafInputDataSiteViewModel>();
Mapper.CreateMap<LeafInput, LeafInputDetails>()
.ForMember(dest => dest.LeafInputId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.HasLeafChart,
opt => opt.ResolveUsing(src => src.OutputFiles.Any(o => o.IsLeafChartFile)))
.ForMember(dest => dest.Sites, opt =>
opt.ResolveUsing(li => li.LeafInputData.Select(d => d.Site)));
}
public LeafInputDetails(LeafInput leafInput)
{
+4 -3
View File
@@ -16,8 +16,9 @@
@using (Html.BeginUmbracoForm("Search", "Queue", null, new {@action = "/leaf-data/manage-queue/"}))
{
<div class="row">
<div class="col-lg-8">
Service description: @Model.ServerDescription<br/>
<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>
@@ -85,7 +86,7 @@
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)),
grid.Column("", format: item => Actions(item.Value), canSort: false)),
htmlAttributes: new {@class = "table table-sm table-striped table-bordered table-hover"}
)
@grid.BootstrapPager()
@@ -0,0 +1,17 @@
@model IEnumerable<LeafInputDataSiteViewModel>
@{
Layout = "~/Views/Shared/DisplayTemplates/_FieldLayout.cshtml";
var grid = new WebGrid(Model, rowsPerPage: 45)
{
};
}
@grid.GetHtml(columns:
grid.Columns(
grid.Column("SiteId"),
grid.Column("Latitude"),
grid.Column("Longitude"),
grid.Column("Elevation")
),
htmlAttributes: new { @class = "table table-sm table-striped table-bordered table-hover" }
)
+2
View File
@@ -1070,6 +1070,7 @@
<Content Include="Views\Membership\PasswordReset.cshtml" />
<Content Include="Views\MacroPartials\Membership\PasswordResetRequest.cshtml" />
<Content Include="Views\Membership\PasswordResetRequest.cshtml" />
<Content Include="Views\Shared\DisplayTemplates\LeafInputDataSiteViewModels.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
@@ -1109,6 +1110,7 @@
<Compile Include="EventHandlers\MemberEvents.cs" />
<Compile Include="Models\ChartViewModel.cs" />
<Compile Include="Models\LeafDataQuery.cs" />
<Compile Include="Models\LeafInputDataSiteViewModel.cs" />
<Compile Include="Models\PasswordResetForm.cs" />
<Compile Include="Models\PasswordResetRequestForm.cs" />
<Compile Include="Models\ContactForm.cs" />