diff --git a/Core/Entities/LeafInputDataSite.cs b/Core/Entities/LeafInputDataSite.cs index 027140a..b189c27 100644 --- a/Core/Entities/LeafInputDataSite.cs +++ b/Core/Entities/LeafInputDataSite.cs @@ -18,7 +18,7 @@ namespace LeafWeb.Core.Entities [ParseInfo(1)] public string SiteId { get; set; } - /// Site latitude, northern hermisphere positive + /// Site latitude, northern hemisphere positive [ParseInfo(2, units:"degrees")] public double? Latitude { get; set; } diff --git a/WebCms/Controllers/QueueController.cs b/WebCms/Controllers/QueueController.cs index a56169a..a26fcae 100644 --- a/WebCms/Controllers/QueueController.cs +++ b/WebCms/Controllers/QueueController.cs @@ -19,15 +19,15 @@ namespace LeafWeb.WebCms.Controllers { private const int TimeSamples = 40; - public ActionResult Index(string query) + public ActionResult Index(LeafDataQuery query) { var resultItems = - DataService.GetLeafInputsOrdered() ; + DataService.GetLeafInputsOrdered(); // search functionality - if (!string.IsNullOrEmpty(query)) + if (!string.IsNullOrEmpty(query.Query)) { - foreach (var piece in query.Split(' ').Select(p => p.Trim())) + foreach (var piece in query.Query.Split(' ').Select(p => p.Trim())) { resultItems = from li in resultItems @@ -44,7 +44,12 @@ namespace LeafWeb.WebCms.Controllers var queueViewModel = new QueueViewModel { - Items = resultItems, ServerDescription = serviceDescription, Query = query, + Items = resultItems, + ServerDescription = serviceDescription, + Query = new LeafDataQuery + { + Query = query.Query + }, TimeInProgressEstimater = timeInProgressEstimater }; @@ -53,6 +58,8 @@ namespace LeafWeb.WebCms.Controllers private TimeInProgressEstimater TimeInProgressEstimater() { + + // TODO: move this to a background process var estimater = HttpRuntime.Cache["TimeInProgressEstimater"]; if (estimater == null) { @@ -73,11 +80,12 @@ namespace LeafWeb.WebCms.Controllers return Content(string.Join("
", data)); } - public ActionResult Search(string query) - { - var nameValueCollection = new NameValueCollection {{"query", query}}; - return RedirectToUmbracoPage(LeafWebPageIds.ManageQueue, nameValueCollection); - } + [HttpPost] + public ActionResult Search(LeafDataQuery query) + { + var collection = new NameValueCollection() {{"Query.Query", query.Query}}; + return RedirectToCurrentUmbracoPage(collection); + } private static string ServiceDescription() { diff --git a/WebCms/Models/LeafDataQuery.cs b/WebCms/Models/LeafDataQuery.cs new file mode 100644 index 0000000..48c0855 --- /dev/null +++ b/WebCms/Models/LeafDataQuery.cs @@ -0,0 +1,47 @@ +using System.ComponentModel.DataAnnotations; +using AutoMapper; +using LeafWeb.Core.DAL; +using LeafWeb.Core.Entities; +using LeafWeb.WebCms.Controllers; + +namespace LeafWeb.WebCms.Models +{ + public class LeafDataQuery + { + [Display(Name = "Search", Description = "General query")] + public string Query { get; set; } + + [Display(Name = "Site ID", Description = "The site's name/Fluxnet ID, if known")] + public string SiteId { get; set; } + + [Display(Name = "Species Name")] + public string SpeciesName { get; set; } + + /// Site latitude, northern hemisphere positive + [RegularExpression(@"\d{0,2}", ErrorMessage = "Site latitude, northern hemisphere positive")] + public int Latitude { get; set; } + + [Display(Name = "Range")] + public string LatitudeRange { get; set; } + + /// Site longitude, east positive + [RegularExpression(@"\d{0,2}", ErrorMessage = "Site longitude, east positive")] + public string Longitude { get; set; } + + [Display(Name = "Range")] + public string LongitudeRange { get; set; } + + static LeafDataQuery() + { + //Mapper.CreateMap() + // .ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore()); + //Mapper.CreateMap() + // .ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore()); + } + + public LeafDataQuery() + { + //PhotosynthesisType = new SelectListViewModel(); + } + } +} \ No newline at end of file diff --git a/WebCms/Models/QueueViewModel.cs b/WebCms/Models/QueueViewModel.cs index d4ce771..b530d4c 100644 --- a/WebCms/Models/QueueViewModel.cs +++ b/WebCms/Models/QueueViewModel.cs @@ -10,7 +10,7 @@ namespace LeafWeb.WebCms.Models public string ServerDescription { get; set; } public string ServerStatus { get; set; } public IEnumerable Items { get; set; } - public string Query { get; set; } + public LeafDataQuery Query { get; set; } public TimeInProgressEstimater TimeInProgressEstimater { get; set; } } } \ No newline at end of file diff --git a/WebCms/Views/MacroPartials/Membership/Register.cshtml b/WebCms/Views/MacroPartials/Membership/Register.cshtml index 15a9a47..321b521 100644 --- a/WebCms/Views/MacroPartials/Membership/Register.cshtml +++ b/WebCms/Views/MacroPartials/Membership/Register.cshtml @@ -23,6 +23,7 @@
+ @* ReSharper disable once UnknownCssClass *@ @if (success || (!user?.IsApproved ?? false)) {

@@ -40,6 +41,20 @@ else new {id="register-member"})) { @Html.ValidationSummary(true) +
    + @foreach (var ms in ViewData.ModelState) + { +
  • @ms.Key +
      +
    • @ms.Value.Value.AttemptedValue
    • + @foreach (var valueError in ms.Value.Errors) + { +
    • @valueError.ErrorMessage
    • + } +
    +
  • + } +
@Html.EditorFor(m => registerModel.Name) @Html.EditorFor(m => registerModel.Email, new { type = "email"}) diff --git a/WebCms/Views/Queue/Index.cshtml b/WebCms/Views/Queue/Index.cshtml index 3ce608f..b77ec93 100644 --- a/WebCms/Views/Queue/Index.cshtml +++ b/WebCms/Views/Queue/Index.cshtml @@ -9,30 +9,71 @@ var grid = new WebGrid(Model.Items, rowsPerPage: 45); } -
-
- Service description: @Model.ServerDescription
- @*Est. processing time by LeafInput size - +@using (Html.BeginUmbracoForm("Search", FormMethod.Post)) +{ +
+
+ Service description: @Model.ServerDescription
+ @*Est. processing time by LeafInput size - 1: @Model.TimeInProgressEstimater.EstimateTimeInProgress(1).ToRoundedReadableString() 10: @Model.TimeInProgressEstimater.EstimateTimeInProgress(10).ToRoundedReadableString() 100: @Model.TimeInProgressEstimater.EstimateTimeInProgress(100).ToRoundedReadableString()*@ -
-
- @using (Html.BeginUmbracoForm("Search", FormMethod.Post)) - { +
+
- - - + + + +
- } +
-
+
+ +
+
+
+ @Html.EditorFor(m => m.Query.SiteId) +
+
+ @Html.EditorFor(m => m.Query.SpeciesName) +
+
+
+
+
+
+
+ @Html.EditorFor(m => m.Query.Latitude, new {size = "small", append = "°"}) +
+
+ @Html.EditorFor(m => m.Query.LatitudeRange, new {size = "small", prepend = "±", append = "°"}) +
+
+
+
+
+
+ @Html.EditorFor(m => m.Query.Longitude, new {size = "small", append = "°"}) +
+
+ @Html.EditorFor(m => m.Query.LongitudeRange, new {size = "small", prepend = "±", append = "°"}) +
+
+
+
+
+
+} + @if (Model.Items.Any()) { -
+
@grid.Table(columns: grid.Columns( grid.Column("Identifier", "Identifier"), diff --git a/WebCms/Views/Shared/EditorTemplates/String.cshtml b/WebCms/Views/Shared/EditorTemplates/String.cshtml index be50dd5..45d1e0c 100644 --- a/WebCms/Views/Shared/EditorTemplates/String.cshtml +++ b/WebCms/Views/Shared/EditorTemplates/String.cshtml @@ -28,6 +28,34 @@ controlClass = string.Concat(controlClass, " ", "is-invalid"); } htmlAttributes.Add("class", controlClass); + + + var inputGroupClass = ""; + if (!string.IsNullOrEmpty(ViewBag.size)) + { + if (ViewBag.size == "small") + { + inputGroupClass = "input-group-sm"; + } + else if (ViewBag.size == "large") + { + inputGroupClass = "input-group-lg"; + } + } } -@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, htmlAttributes) \ No newline at end of file +
+ @if (!string.IsNullOrEmpty(ViewBag.prepend)) + { +
+ @Html.Raw(ViewBag.prepend) +
+ } + @Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, htmlAttributes) + @if (!string.IsNullOrEmpty(ViewBag.append)) + { +
+ @Html.Raw(ViewBag.append) +
+ } +
diff --git a/WebCms/WebCms.csproj b/WebCms/WebCms.csproj index 90befbb..e86e2b0 100644 --- a/WebCms/WebCms.csproj +++ b/WebCms/WebCms.csproj @@ -1108,6 +1108,7 @@ + diff --git a/WebCms/scripts/Queue.js b/WebCms/scripts/Queue.js index 08f0baf..8abfb7e 100644 --- a/WebCms/scripts/Queue.js +++ b/WebCms/scripts/Queue.js @@ -1,7 +1,7 @@ -$(function () { +$(function() { + // responsive column hide for results $("#queue th:nth-child(4)").addClass("d-none d-md-table-cell"); $("#queue td:nth-child(4)").addClass("d-none d-md-table-cell"); $("#queue th:nth-child(3)").addClass("d-none d-sm-table-cell"); $("#queue td:nth-child(3)").addClass("d-none d-sm-table-cell"); - }); \ No newline at end of file