From f1691f3d53013d2873b1c28d258ab27de5d7183a Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Sat, 11 Jul 2020 21:07:43 -0400 Subject: [PATCH] Add "show only completed" to query --- WebCms/Models/LeafDataQuery.cs | 8 +++-- WebCms/Utility/NameValueCollectionUtil.cs | 17 ++++++---- WebCms/Utility/QueryFilter.cs | 9 +++++ WebCms/Views/Queue/Index.cshtml | 41 +++++++++++++---------- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/WebCms/Models/LeafDataQuery.cs b/WebCms/Models/LeafDataQuery.cs index 0099725..712e585 100644 --- a/WebCms/Models/LeafDataQuery.cs +++ b/WebCms/Models/LeafDataQuery.cs @@ -1,6 +1,4 @@ -using System.Collections.Specialized; -using System.ComponentModel.DataAnnotations; -using System.Runtime.CompilerServices; +using System.ComponentModel.DataAnnotations; namespace LeafWeb.WebCms.Models { @@ -58,6 +56,9 @@ namespace LeafWeb.WebCms.Models [RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")] public string phips2 { get; set; } + [Display(Name = "Show Only Successfully Completed")] + public bool completed { get; set; } + public bool HasExtendedParameters => !( string.IsNullOrEmpty(siteid) @@ -70,6 +71,7 @@ namespace LeafWeb.WebCms.Models && string.IsNullOrEmpty(pari) && string.IsNullOrEmpty(tleaf) && string.IsNullOrEmpty(phips2) + && !completed ); } } \ No newline at end of file diff --git a/WebCms/Utility/NameValueCollectionUtil.cs b/WebCms/Utility/NameValueCollectionUtil.cs index b808bd2..9f6505f 100644 --- a/WebCms/Utility/NameValueCollectionUtil.cs +++ b/WebCms/Utility/NameValueCollectionUtil.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; +using System.Collections.Specialized; using System.Linq; -using System.Web; using System.Web.Routing; namespace LeafWeb.WebCms.Utility @@ -21,9 +18,15 @@ namespace LeafWeb.WebCms.Utility foreach (var pi in obj.GetType().GetProperties().Where(p => p.CanWrite)) { var value = pi.GetValue(obj, null); - if (value == null) - continue; - nvs.Add(prefix + pi.Name, value.ToString()); + switch (value) + { + case null: + case bool b when b == false: + continue; + default: + nvs.Add(prefix + pi.Name, value.ToString()); + break; + } } return nvs; diff --git a/WebCms/Utility/QueryFilter.cs b/WebCms/Utility/QueryFilter.cs index 74d22e3..45571df 100644 --- a/WebCms/Utility/QueryFilter.cs +++ b/WebCms/Utility/QueryFilter.cs @@ -143,6 +143,15 @@ namespace LeafWeb.WebCms.Utility select li; } + if (query.completed) + { + resultItems = + from li in resultItems + where + li.CurrentStatus == LeafInputStatusType.Complete + select li; + } + return resultItems; } } diff --git a/WebCms/Views/Queue/Index.cshtml b/WebCms/Views/Queue/Index.cshtml index 136c888..d2ad47b 100644 --- a/WebCms/Views/Queue/Index.cshtml +++ b/WebCms/Views/Queue/Index.cshtml @@ -15,7 +15,7 @@ @using (Html.BeginUmbracoForm("Search", "Queue", null, new { @action = "/leaf-data/manage-queue/" })) { -
+
@Model.Items.Count() results
Service description: @Model.ServerDescription @@ -24,10 +24,6 @@ 10: @Model.TimeInProgressEstimater.EstimateTimeInProgress(10).ToRoundedReadableString() 100: @Model.TimeInProgressEstimater.EstimateTimeInProgress(100).ToRoundedReadableString()*@
-
- @DownloadResultsInput() - @DownloadResultsOutput_ToUser() -
@@ -77,7 +73,7 @@

Curve Variation range minimum
-
+
@Html.EditorFor(m => m.Q.co2s, new { size = "small", append = "umol/m", prepend = ">" })
@@ -91,6 +87,12 @@ @Html.EditorFor(m => m.Q.phips2, new { size = "small", prepend = ">" })
+
+
+
+ @Html.EditorFor(m => m.Q.completed) +
+
} @@ -109,8 +111,14 @@ grid.Column("", format: item => Actions(item.Value), canSort: false)), htmlAttributes: new { @class = "table table-sm table-striped table-bordered table-hover" } ) - @grid.PagerList()
+
+
@grid.PagerList()
+
+ Download Results + @DownloadResults() +
+
} else { @@ -263,16 +271,15 @@ else } -@helper DownloadResultsInput() +@helper DownloadResults() { - - Input - +
+ + Input + + + Output + +
} -@helper DownloadResultsOutput_ToUser() -{ - - Output - -} \ No newline at end of file