From 95e7de2a9b1ef43e245b00c08a1ad580623453c6 Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Tue, 23 Jun 2020 15:47:30 -0400 Subject: [PATCH] Add LeafInputDataSite info to Queue Details --- WebCms/Models/LeafInputDataSiteViewModel.cs | 101 ++++++++++++++++++ WebCms/Models/LeafInputDetails.cs | 20 ++-- WebCms/Views/Queue/Index.cshtml | 7 +- .../LeafInputDataSiteViewModels.cshtml | 17 +++ WebCms/WebCms.csproj | 2 + 5 files changed, 138 insertions(+), 9 deletions(-) create mode 100644 WebCms/Models/LeafInputDataSiteViewModel.cs create mode 100644 WebCms/Views/Shared/DisplayTemplates/LeafInputDataSiteViewModels.cshtml diff --git a/WebCms/Models/LeafInputDataSiteViewModel.cs b/WebCms/Models/LeafInputDataSiteViewModel.cs new file mode 100644 index 0000000..507da2b --- /dev/null +++ b/WebCms/Models/LeafInputDataSiteViewModel.cs @@ -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 + { + /// Site identifier + /// do not leave blank between letters + [ParseInfo(1)] + [Display(Name = "Site Id")] + public string SiteId { get; set; } + + /// Site latitude, northern hemisphere positive + [DisplayFormat(DataFormatString = "{0} °")] + public double? Latitude { get; set; } + + /// Site longitude, east positive + [DisplayFormat(DataFormatString = "{0} °")] + public double? Longitude { get; set; } + + /// site elevation + [DisplayFormat(DataFormatString = "{0} m")] + public double? Elevation { get; set; } + + /// the year when the A/Ci data is taken + [DisplayFormat(DataFormatString = "{0} year")] + public int? SampleYear { get; set; } + + /// the day of year (since 1 Jan) when the A/Ci data is taken + [ParseInfo(6, units: "day")] + public int? SampleDayOfYear { get; set; } + + /// the approximate start day (since 1 Jan) of growing season + [ParseInfo(7, units: "day")] + public int? GrowSeasonStart { get; set; } + + /// the approximate end day (since 1 Jan) of growing season + [ParseInfo(8, units: "day")] + public int? GrowSeasonEnd { get; set; } + + /// stand age since the last disturbance + [ParseInfo(9, units: "year")] + public double? StandAge { get; set; } + + /// the height of the canopy + [ParseInfo(10, units: "m")] + public double? CanopyHeight { get; set; } + + /// the leaf area index in the middle of growing season + [ParseInfo(11, units: "m2/m2")] + public double? LeafAreaIndex { get; set; } + + /// the species of the leaf sample + /// don't leave blank between letters + [ParseInfo(12, units: "dimensionless")] + public string SpeciesSampled { get; set; } + + /// the average time interval between two consecutive A/Ci data points + [ParseInfo(13, alternateTitle: "AveTimeResolution", units: "minutes")] + public double? AverageTimeResolution { get; set; } + + /// the height at which the leaf is located + [ParseInfo(14, units: "m")] + public double? SampleHeight { get; set; } + + /// the age of the leaf + [ParseInfo(15, units: "day")] + public int? LeafAge { get; set; } + + /// specific leaf area of the sample + [ParseInfo(16, units: "cm2/g")] + public double? SpecificLeafArea { get; set; } + + /// dry leaf nitrogen content of the sample + [ParseInfo(17, units: "%")] + public double? LfNitrogenContent { get; set; } + + /// dry leaf carbon content of the sample + [ParseInfo(18, units: "%")] + public double? LfCarbonContent { get; set; } + + /// dry leaf phosphorus content of the sample + [ParseInfo(19, units: "%")] + public double? LfPhosphContent { get; set; } + + static LeafInputDataSiteViewModel() + { + Mapper.CreateMap(); + } + + public LeafInputDataSiteViewModel() {} + + public LeafInputDataSiteViewModel(LeafInputDataSite site) + { + Mapper.Map(site, this); + } + } +} \ No newline at end of file diff --git a/WebCms/Models/LeafInputDetails.cs b/WebCms/Models/LeafInputDetails.cs index 600d6c1..7314603 100644 --- a/WebCms/Models/LeafInputDetails.cs +++ b/WebCms/Models/LeafInputDetails.cs @@ -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 Sites { get; set; } + + + [UIHint("LeafInputStatusViewModels")] public List StatusHistory { get; set; } [HiddenInput(DisplayValue = false)] @@ -80,10 +84,14 @@ namespace LeafWeb.WebCms.Models Mapper.CreateMap().ConvertUsing(st => st.ToString()); Mapper.CreateMap().ConvertUsing(st => new LeafInputStatus()); Mapper.CreateMap(); - Mapper.CreateMap() - .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(); + Mapper.CreateMap() + .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) { diff --git a/WebCms/Views/Queue/Index.cshtml b/WebCms/Views/Queue/Index.cshtml index fb0cc90..6e820e7 100644 --- a/WebCms/Views/Queue/Index.cshtml +++ b/WebCms/Views/Queue/Index.cshtml @@ -16,8 +16,9 @@ @using (Html.BeginUmbracoForm("Search", "Queue", null, new {@action = "/leaf-data/manage-queue/"})) {
-
- Service description: @Model.ServerDescription
+
+ @Model.Items.Count() results
+ Service description: @Model.ServerDescription @*Est. processing time by LeafInput size - 1: @Model.TimeInProgressEstimater.EstimateTimeInProgress(1).ToRoundedReadableString() 10: @Model.TimeInProgressEstimater.EstimateTimeInProgress(10).ToRoundedReadableString() @@ -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() diff --git a/WebCms/Views/Shared/DisplayTemplates/LeafInputDataSiteViewModels.cshtml b/WebCms/Views/Shared/DisplayTemplates/LeafInputDataSiteViewModels.cshtml new file mode 100644 index 0000000..de5bd91 --- /dev/null +++ b/WebCms/Views/Shared/DisplayTemplates/LeafInputDataSiteViewModels.cshtml @@ -0,0 +1,17 @@ +@model IEnumerable +@{ + 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" } + ) diff --git a/WebCms/WebCms.csproj b/WebCms/WebCms.csproj index 7f9787c..baa5e7b 100644 --- a/WebCms/WebCms.csproj +++ b/WebCms/WebCms.csproj @@ -1070,6 +1070,7 @@ + Web.config @@ -1109,6 +1110,7 @@ +