Add filename for LeafInputData details

This commit is contained in:
2020-07-04 21:14:10 -04:00
parent 7ad10d6ddc
commit e4e753c64a
3 changed files with 26 additions and 41 deletions
+5 -1
View File
@@ -27,7 +27,9 @@ namespace LeafWeb.WebCms.App_Start
opt => opt.ResolveUsing(src => src.OutputFiles.Any(o => o.IsLeafChartFile)));
// LeafInputData
Mapper.CreateMap<LeafInputData, LeafInputDataViewModel>();
Mapper.CreateMap<LeafInputData, LeafInputDataViewModel>()
.ForMember(dest => dest.Filename, opt => opt.MapFrom(src => src.LeafOutputFile.Filename));
//.ForMember(dest => dest.Filename, opt => opt.ResolveUsing(src => src.LeafOutputFile.Filename));
// LeafInputDataCurveViewModel
Mapper.CreateMap<LeafInputDataCurve, LeafInputDataCurveViewModel>();
@@ -39,6 +41,8 @@ namespace LeafWeb.WebCms.App_Start
Mapper.CreateMap<LeafInputStatus, LeafInputStatusViewModel>()
.ForMember(dest => dest.Status, opt => opt.MapFrom(li => li.Status.ToString()));
// VERY WEIRD. This next part "fixes" some map configuration issue with LeafInputDataCurve
//AutoMapper.AutoMapperMappingException {"Missing type map configuration or unsupported mapping.
//
//Mapping types:
+9
View File
@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using AutoMapper;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Utility;
@@ -11,11 +13,18 @@ namespace LeafWeb.WebCms.Models
/// </summary>
public class LeafInputDataViewModel
{
private static readonly Regex FilenamePrefixLength = new Regex(@"^(\d{14}clean)(.*)$") ;
public int Id { get; set; }
[ParseInfo(3, alternateTitle: "Site name in full", exampleValue: "Your site's identifier / name")]
public string SiteName { get; set; }
public string Filename { get; set; }
public string FilenameDatePrefix => FilenamePrefixLength.IsMatch(Filename) ? FilenamePrefixLength.Replace(Filename, "$1") : string.Empty;
public string FilenameOriginal => FilenamePrefixLength.IsMatch(Filename) ? FilenamePrefixLength.Replace(Filename, "$2") : Filename;
public LeafInputDataSiteViewModel Site { get; set; }
public List<LeafInputDataCurveViewModel> Data { get; set; }
@@ -11,56 +11,28 @@
@RendDistinctValues("Latitude [&deg;]", Model.Select(m => m.Site.Latitude?.ToString()))
@RendDistinctValues("Longitude [&deg;]", Model.Select(m => m.Site.Longitude?.ToString()))
@RendDistinctValues("Elevation [m]", Model.Select(m => m.Site.Elevation?.ToString()))
@*@RendDistinctValues("CO2S",
Model.Select(m =>
m.SiteName + " (" + m.Id + "): " +
string.Join(", ",
m.Data?.Select(d => d.CO2S?.ToString())
)
), "<br />"
)
@RendDistinctValues("CO2S Min", Model.Select(m =>
m.SiteName + " (" + m.Id + "): " +
m.Data?.Min(d => d.CO2S).ToString()), "<br />")
@RendDistinctValues("CO2S Average", Model.Select(m =>
m.SiteName + " (" + m.Id + "): " +
m.Data?.Average(d => d.CO2S).ToString()), "<br />")
@RendDistinctValues("CO2S Max", Model.Select(m =>
m.SiteName + " (" + m.Id + "): " +
m.Data?.Max(d => d.CO2S).ToString()), "<br />")
@RendDistinctValues("CO2S Range", Model.Select(m =>
m.SiteName + " (" + m.Id + "): " +
(m.Data?.Max(d => d.CO2S)
- m.Data?.Min(d => d.CO2S))), "<br />")
@RendValue("CO2S Min Range", Model.Min(m =>
m.Data?.Max(d => d.CO2S)
- m.Data?.Min(d => d.CO2S))?.ToString())*@
@RendValue("CO2 response curves (CO2S) Max range", Model.Max(m =>
m.Data?.Max(d => d.CO2S)
- m.Data?.Min(d => d.CO2S))?.ToString())
@RendValueRange("CO2 response curves (CO2S) range [umol/mol]", curveData => curveData.CO2S)
@RendValueRange("Light response curves (PARi) range [umol/m2/s]", curveData => curveData.PARi)
@RendValueRange("Temperature response curves (Tleaf) range [oC]", curveData => curveData.Tleaf)
@RendValueRange("Fluorometry measurements (PhiPS2) range", curveData => curveData.PhiPS2)
@RendValue("Light response curves (PARi) Max range", Model.Max(m =>
m.Data?.Max(d => d.PARi)
- m.Data?.Min(d => d.PARi))?.ToString())
@RendValue("Temperature response curves (Tleaf) Max Range", Model.Max(m =>
m.Data?.Max(d => d.Tleaf)
- m.Data?.Min(d => d.Tleaf))?.ToString())
@RendValue("Fluorometry measurements (PhiPS2) Max Range", Model.Max(m =>
m.Data?.Max(d => d.PhiPS2)
- m.Data?.Min(d => d.PhiPS2))?.ToString())
@helper RendValueRange(string label, Func<LeafInputDataCurveViewModel, double?> getVar)
{
@RendDistinctValues(label, Model.Select(m =>
m.FilenameOriginal + ": " +
(m.Data?.Max(getVar) - m.Data?.Min(getVar))), "<br />")
}
@helper RendValue(string label, string value)
{
<div class="row pb-lg-2 pb-sm-1 @if (ViewData.Model == null || string.IsNullOrEmpty(value)){<text>d-none</text> }">
<div class="col-sm-5 text-truncate border-right border-bottom pl-4 pl-sm-5">
<div class="col-sm-5 border-right border-bottom pl-4 pl-sm-5">
@Html.Raw(label)
</div>
<div class="col-sm-7 border-bottom pl-5 pl-sm-2">
@Html.Raw(@value)
@Html.Raw(value)
</div>
</div>
}