First pass at adding CO2S query and display

This commit is contained in:
2020-07-02 21:29:40 -04:00
parent 3dedac5591
commit 0fae6c5118
4 changed files with 57 additions and 18 deletions
+8 -1
View File
@@ -35,7 +35,13 @@ namespace LeafWeb.WebCms.Models
[Display(Name = "Range")]
[RegularExpression(@"^([0-9]|[1-8][0-9]|9[0-9]|1[0-7][0-9]|180)$", ErrorMessage = "± longitude degrees")]
public string lonr { get; set; }
/// <summary>Sample CO2 concentration</summary>
//[ParseInfo(17, units: "umol/mol")]
[Display(Name = "CO2 response curves")]
[RegularExpression(@"^([0-9]*\.[0-9]+|[0-9]+)$", ErrorMessage = "Value is numeric")]
public string co2s { get; set; }
public bool HasExtendedParameters =>
!(
string.IsNullOrEmpty(siteid)
@@ -44,6 +50,7 @@ namespace LeafWeb.WebCms.Models
&& string.IsNullOrEmpty(latr)
&& string.IsNullOrEmpty(lon)
&& string.IsNullOrEmpty(lonr)
&& string.IsNullOrEmpty(co2s)
);
}
}
+15 -1
View File
@@ -58,7 +58,7 @@ namespace LeafWeb.WebCms.Utility
if (!string.IsNullOrEmpty(query.lon))
{
var longitude = Int32.Parse(query.lon);
var longitude = int.Parse(query.lon);
var range = 0;
if (!string.IsNullOrEmpty(query.lonr))
{
@@ -73,6 +73,20 @@ namespace LeafWeb.WebCms.Utility
select li;
}
if (!string.IsNullOrEmpty(query.co2s))
{
var co2s = double.Parse(query.co2s);
resultItems =
from li in resultItems
where co2s >=
li.LeafInputData.Max(lid =>
lid.Data.Max(d => d.CO2S) -
lid.Data.Min(d => d.CO2S)
)
select li;
}
return resultItems;
}
}
+8
View File
@@ -71,6 +71,14 @@
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col">
<div class="text-body">Curve Variation range minimum</div>
@Html.EditorFor(m => m.Q.co2s, new { size = "small", append = "umol/m" })
</div>
</div>
</div>
</div>
}
@@ -2,15 +2,30 @@
@{
//Layout = "~/Views/Shared/DisplayTemplates/_FieldLayout.cshtml";
}
<div class="row pb-lg-2 pb-sm-1">
<div class="col text-truncate border-right border-bottom font-weight-bold">
Leaf Input Data
</div>
</div>
@RendDistinctValues("Site Id", Model.Select(m => m.SiteName))
@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 + ": "
+ string.Join(", ",
m.Data?.Select(d => d.CO2S?.ToString())
)
)
)
@RendDistinctValues("CO2S Min", Model.Select(m => m.Data?.Min(d => d.CO2S).ToString()))
@RendDistinctValues("CO2S Average", Model.Select(m => m.Data?.Average(d => d.CO2S).ToString()))
@RendDistinctValues("CO2S Max", Model.Select(m => m.Data?.Max(d => d.CO2S).ToString()))
@Rend("Site Id", Model.Select(m => m.SiteName))
@Rend("Latitude [&deg;]", Model.Select(m => m.Site.Latitude?.ToString()))
@Rend("Longitude [&deg;]", Model.Select(m => m.Site.Longitude?.ToString()))
@Rend("Elevation [m]", Model.Select(m => m.Site.Elevation?.ToString()))
@helper Rend(string label, IEnumerable<string> values)
@helper RendValue(string label, string value)
{
var value = string.Join(", ", values.Distinct());
<div class="row pb-lg-2 pb-sm-1 @if (ViewData.Model == null){<text>d-none</text> }">
<div class="col-sm-3 text-truncate border-right border-bottom pl-4 pl-sm-5">
@Html.Raw(label)
@@ -21,13 +36,8 @@
</div>
}
@*@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" }
)*@
@helper RendDistinctValues(string label, IEnumerable<string> values)
{
var value = string.Join(", ", values.Distinct());
@RendValue(label, value)
}