First Pass at LeafDataQuery for Queue

This commit is contained in:
2020-06-17 15:26:31 -04:00
parent 5ac9291518
commit d09f84b47d
9 changed files with 169 additions and 29 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ namespace LeafWeb.Core.Entities
[ParseInfo(1)]
public string SiteId { get; set; }
/// <summary>Site latitude, northern hermisphere positive</summary>
/// <summary>Site latitude, northern hemisphere positive</summary>
[ParseInfo(2, units:"degrees")]
public double? Latitude { get; set; }
+18 -10
View File
@@ -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("<br />", 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()
{
+47
View File
@@ -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; }
/// <summary>Site latitude, northern hemisphere positive</summary>
[RegularExpression(@"\d{0,2}", ErrorMessage = "Site latitude, northern hemisphere positive")]
public int Latitude { get; set; }
[Display(Name = "Range")]
public string LatitudeRange { get; set; }
/// <summary>Site longitude, east positive</summary>
[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<LeafInputCreate, LeafInput>()
// .ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
//Mapper.CreateMap<LeafInput, LeafInputCreate>()
// .ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
}
public LeafDataQuery()
{
//PhotosynthesisType = new SelectListViewModel();
}
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ namespace LeafWeb.WebCms.Models
public string ServerDescription { get; set; }
public string ServerStatus { get; set; }
public IEnumerable<LeafInput> Items { get; set; }
public string Query { get; set; }
public LeafDataQuery Query { get; set; }
public TimeInProgressEstimater TimeInProgressEstimater { get; set; }
}
}
@@ -23,6 +23,7 @@
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-lg-6 card card-body bg-light">
@* ReSharper disable once UnknownCssClass *@
@if (success || (!user?.IsApproved ?? false))
{
<h2 class="text-center"><span class="fa fa-check text-primary"></span> </h2>
@@ -40,6 +41,20 @@ else
new {id="register-member"}))
{
@Html.ValidationSummary(true)
<ul class="d-none">
@foreach (var ms in ViewData.ModelState)
{
<li>@ms.Key
<ul>
<li>@ms.Value.Value.AttemptedValue</li>
@foreach (var valueError in ms.Value.Errors)
{
<li>@valueError.ErrorMessage</li>
}
</ul>
</li>
}
</ul>
@Html.EditorFor(m => registerModel.Name)
@Html.EditorFor(m => registerModel.Email, new { type = "email"})
+55 -14
View File
@@ -9,30 +9,71 @@
var grid = new WebGrid(Model.Items, rowsPerPage: 45);
}
<div class="row">
<div class="col-lg-8">
Service description: @Model.ServerDescription<br/>
@*Est. processing time by LeafInput size -
@using (Html.BeginUmbracoForm<QueueController>("Search", FormMethod.Post))
{
<div class="row">
<div class="col-lg-8">
Service description: @Model.ServerDescription<br/>
@*Est. processing time by LeafInput size -
<i class="fa fa-file-o"></i> 1: <strong>@Model.TimeInProgressEstimater.EstimateTimeInProgress(1).ToRoundedReadableString()</strong>
<i class="fa fa-file-o"></i> 10: <strong>@Model.TimeInProgressEstimater.EstimateTimeInProgress(10).ToRoundedReadableString()</strong>
<i class="fa fa-file-o"></i> 100: <strong>@Model.TimeInProgressEstimater.EstimateTimeInProgress(100).ToRoundedReadableString()</strong>*@
</div>
<div class="col-lg-4">
@using (Html.BeginUmbracoForm<QueueController>("Search", FormMethod.Post))
{
</div>
<div class="col-lg-4">
<div class="input-group">
<input name="query" type="text" class="form-control" placeholder="Search for..." value="@Model.Query">
<span class="input-group-btn">
<button class="btn btn-outline-secondary" type="button">Search</button>
<input name="Query.Query" type="text" class="form-control" placeholder="Search for..." value="@Model.Query.Query">
<span class="input-group-append">
<button class="btn btn-outline-secondary" type="submit">Search</button>
<button class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split" type="button"
data-toggle="collapse" data-target="#additionalSearch" aria-haspopup="true" aria-expanded="false"
title="Additional Search Options">
</button>
</span>
</div><!-- /input-group -->
}
</div>
</div>
</div>
<div class="row collapse ml-1 mr-1" id="additionalSearch">
<div class="col-lg-8 offset-lg-4 card card-body">
<div class="row">
<div class="col-md-6">
@Html.EditorFor(m => m.Query.SiteId)
</div>
<div class="col-md-6">
@Html.EditorFor(m => m.Query.SpeciesName)
</div>
</div>
<hr/>
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-sm-7">
@Html.EditorFor(m => m.Query.Latitude, new {size = "small", append = "&deg;"})
</div>
<div class="col-sm-5">
@Html.EditorFor(m => m.Query.LatitudeRange, new {size = "small", prepend = "&plusmn;", append = "&deg;"})
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-sm-7">
@Html.EditorFor(m => m.Query.Longitude, new {size = "small", append = "&deg;"})
</div>
<div class="col-sm-5">
@Html.EditorFor(m => m.Query.LongitudeRange, new {size = "small", prepend = "&plusmn;", append = "&deg;"})
</div>
</div>
</div>
</div>
</div>
</div>
}
@if (Model.Items.Any())
{
<div id="queue" class="table-responsive">
<div id="queue" class="table-responsive mt-3">
@grid.Table(columns:
grid.Columns(
grid.Column("Identifier", "Identifier"),
@@ -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)
<div class="input-group @inputGroupClass">
@if (!string.IsNullOrEmpty(ViewBag.prepend))
{
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon2">@Html.Raw(ViewBag.prepend)</span>
</div>
}
@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, htmlAttributes)
@if (!string.IsNullOrEmpty(ViewBag.append))
{
<div class="input-group-append">
<span class="input-group-text" id="basic-addon2">@Html.Raw(ViewBag.append)</span>
</div>
}
</div>
+1
View File
@@ -1108,6 +1108,7 @@
<Compile Include="Controllers\ResultsController.cs" />
<Compile Include="EventHandlers\MemberEvents.cs" />
<Compile Include="Models\ChartViewModel.cs" />
<Compile Include="Models\LeafDataQuery.cs" />
<Compile Include="Models\PasswordResetForm.cs" />
<Compile Include="Models\PasswordResetRequestForm.cs" />
<Compile Include="Models\ContactForm.cs" />
+2 -2
View File
@@ -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");
});