Add Only my data to

This commit is contained in:
2020-07-21 07:38:56 -04:00
parent 28377cfce8
commit cd6bd2d0e5
8 changed files with 97 additions and 67 deletions
+4 -2
View File
@@ -25,7 +25,8 @@ namespace LeafWeb.WebCms.Controllers
var resultItems = var resultItems =
DataService.GetLeafInputsOrdered(); DataService.GetLeafInputsOrdered();
resultItems = QueryFilter.Search(resultItems, query); resultItems
= QueryFilter.Search(resultItems, query, Members.GetCurrentLoginStatus()?.Email);
var timeInProgressEstimater = TimeInProgressEstimater(); var timeInProgressEstimater = TimeInProgressEstimater();
@@ -170,7 +171,8 @@ namespace LeafWeb.WebCms.Controllers
var resultItems = var resultItems =
DataService.GetLeafInputsOrdered(); DataService.GetLeafInputsOrdered();
resultItems = QueryFilter.Search(resultItems, query); resultItems
= QueryFilter.Search(resultItems, query, Members.GetCurrentLoginStatus()?.Email);
if (resultItems == null) if (resultItems == null)
return View("DownloadNotFound"); return View("DownloadNotFound");
+2 -1
View File
@@ -17,7 +17,8 @@ namespace LeafWeb.WebCms.Controllers
var resultItems = var resultItems =
DataService.GetLeafInputsOrdered(); DataService.GetLeafInputsOrdered();
resultItems = QueryFilter.Search(resultItems, query); resultItems =
QueryFilter.Search(resultItems, query, Members.GetCurrentLoginStatus()?.Email);
var searchViewModel = new SearchViewModel var searchViewModel = new SearchViewModel
{ {
+3
View File
@@ -59,6 +59,9 @@ namespace LeafWeb.WebCms.Models
[Display(Name = "Show Only Successfully Completed")] [Display(Name = "Show Only Successfully Completed")]
public bool compl { get; set; } public bool compl { get; set; }
[Display(Name = "Only my data")]
public bool usr { get; set; }
public bool HasExtendedParameters => public bool HasExtendedParameters =>
!( !(
string.IsNullOrEmpty(siteid) string.IsNullOrEmpty(siteid)
+10 -1
View File
@@ -7,7 +7,7 @@ namespace LeafWeb.WebCms.Utility
{ {
internal static class QueryFilter internal static class QueryFilter
{ {
public static IQueryable<LeafInput> Search(IQueryable<LeafInput> resultItems, LeafDataQuery query) public static IQueryable<LeafInput> Search(IQueryable<LeafInput> resultItems, LeafDataQuery query, string currentUserEmail)
{ {
// search functionality // search functionality
if (!string.IsNullOrEmpty(query.q)) if (!string.IsNullOrEmpty(query.q))
@@ -154,6 +154,15 @@ namespace LeafWeb.WebCms.Utility
select li; select li;
} }
if (query.usr && !string.IsNullOrEmpty(currentUserEmail))
{
resultItems =
from li in resultItems
where
li.Email.Equals(currentUserEmail, StringComparison.OrdinalIgnoreCase)
select li;
}
return resultItems; return resultItems;
} }
} }
+2 -2
View File
@@ -13,7 +13,7 @@
Service description: @Model.ServerDescription Service description: @Model.ServerDescription
</div> </div>
</div> </div>
<div class="row align-items-end"> <div class="row align-items-end mb-3">
<div class="col-3 order-last order-sm-first font-italic font-weight-light "> <div class="col-3 order-last order-sm-first font-italic font-weight-light ">
<strong>@Model.Items.Count()</strong> results <strong>@Model.Items.Count()</strong> results
@*Est. processing time by LeafInput size - @*Est. processing time by LeafInput size -
@@ -32,7 +32,7 @@
@if (Model.Items.Any()) @if (Model.Items.Any())
{ {
<div id="queue" class="table-responsive mt-3"> <div id="queue" class="table-responsive">
@grid.Table(columns: @grid.Table(columns:
grid.Columns( grid.Columns(
grid.Column("Identifier", "Identifier"), grid.Column("Identifier", "Identifier"),
+1 -1
View File
@@ -5,7 +5,7 @@
var grid = new WebGrid(Model.Items, rowsPerPage: 45); var grid = new WebGrid(Model.Items, rowsPerPage: 45);
} }
<div class="row align-items-end"> <div class="row align-items-end mb-3">
<div class="col-3 order-last order-sm-first font-italic font-weight-light "> <div class="col-3 order-last order-sm-first font-italic font-weight-light ">
<strong>@Model.Items.Count()</strong> results <strong>@Model.Items.Count()</strong> results
</div> </div>
@@ -3,8 +3,15 @@
@{ @{
Layout = null; Layout = null;
var lowerPropertyName = StringExtensions.LowercaseFirst(ViewData.ModelMetadata.PropertyName); var lowerPropertyName = StringExtensions.LowercaseFirst(ViewData.ModelMetadata.PropertyName);
var groupClass = $"form-group {lowerPropertyName}";
if (ViewBag.groupClass != null)
{
groupClass = string.Concat(groupClass, " ", ViewBag.groupClass);
}
} }
<div class="form-group @lowerPropertyName"> <div class="@groupClass">
@Html.LabelForModel() @Html.LabelForModel()
@RenderBody() @RenderBody()
@Html.ValidationMessage(string.Empty, new { @class = "text-danger"}) @Html.ValidationMessage(string.Empty, new { @class = "text-danger"})
+67 -59
View File
@@ -23,76 +23,84 @@
htmlFormAction = (string)ViewData["htmlFormAction"]; htmlFormAction = (string)ViewData["htmlFormAction"];
} }
} }
@using (Html.BeginUmbracoForm(actionName, controllerName, null, new {action = htmlFormAction})) @using (Html.BeginUmbracoForm(actionName, controllerName, null, new { action = htmlFormAction }))
{ {
<div class="input-group pl-5"> <div class="row justify-content-end">
<input name="q" type="text" class="form-control" placeholder="Search for..." value="@Model.q"> <div class="col text-right pt-2">
<span class="input-group-append"> @Html.EditorFor(m => m.usr, new ViewDataDictionary{{"groupClass", "mb-0"}})
<button class="btn btn-outline-secondary" type="submit">Search</button> </div>
<button class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split" type="button" <div class="col">
data-toggle="collapse" data-target="#additionalSearch" aria-haspopup="true" aria-expanded="false" <div class="input-group">
title="Additional Search Options"> <input name="q" type="text" class="form-control" placeholder="Search for..." value="@Model.q">
</button> <span class="input-group-append">
</span> <button class="btn btn-outline-secondary" type="submit">Search</button>
</div> <button class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split" type="button"
<!-- /input-group --> data-toggle="collapse" data-target="#additionalSearch" aria-haspopup="true" aria-expanded="false"
<div class="container"> title="Additional Search Options">
</button>
</span>
</div>
</div>
</div>
<!-- /input-group -->
<div class="row @if (Model.HasExtendedParameters) {<text>show</text>} collapse" id="additionalSearch"> <div class="row @if (Model.HasExtendedParameters) {<text>show</text>} collapse" id="additionalSearch">
<div class="col card card-body"> <div class="col">
<div class="row"> <div class="card card-body">
<div class="col-md-6"> <div class="row">
@Html.EditorFor(m => m.siteid) <div class="col-md-6">
@Html.EditorFor(m => m.siteid)
</div>
<div class="col-md-6">
@Html.EditorFor(m => m.species)
</div>
</div> </div>
<div class="col-md-6"> <hr/>
@Html.EditorFor(m => m.species) <div class="row">
</div> <div class="col-md-6">
</div> <div class="row">
<hr/> <div class="col-7">
<div class="row"> @Html.EditorFor(m => m.lat, new {size = "small", append = "&deg;"})
<div class="col-md-6"> </div>
<div class="row"> <div class="col-5">
<div class="col-7"> @Html.EditorFor(m => m.latr, new {size = "small", prepend = "&plusmn;", append = "&deg;"})
@Html.EditorFor(m => m.lat, new {size = "small", append = "&deg;"}) </div>
</div> </div>
<div class="col-5"> </div>
@Html.EditorFor(m => m.latr, new {size = "small", prepend = "&plusmn;", append = "&deg;"}) <div class="col-md-6 border-left">
<div class="row">
<div class="col-7">
@Html.EditorFor(m => m.lon, new {size = "small", append = "&deg;"})
</div>
<div class="col-5">
@Html.EditorFor(m => m.lonr, new {size = "small", prepend = "&plusmn;", append = "&deg;"})
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6 border-left"> <hr/>
<div class="row"> <div class="text-body font-weight-bold pb-3">Curve Variation range minimum</div>
<div class="col-7"> <div class="row align-items-end">
@Html.EditorFor(m => m.lon, new {size = "small", append = "&deg;"}) <div class="col-md-6">
</div> @Html.EditorFor(m => m.co2s, new {size = "small", prepend = ">", append = "umol/m"})
<div class="col-5"> </div>
@Html.EditorFor(m => m.lonr, new {size = "small", prepend = "&plusmn;", append = "&deg;"}) <div class="col-md-6">
</div> @Html.EditorFor(m => m.pari, new {size = "small", prepend = ">", append = "umol/m2/s"})
</div>
<div class="col-md-6">
@Html.EditorFor(m => m.tleaf, new {size = "small", prepend = ">", append = "oC"})
</div>
<div class="col-md-6">
@Html.EditorFor(m => m.phips2, new {size = "small", prepend = ">"})
</div> </div>
</div> </div>
</div> <hr/>
<hr/> <div class="row">
<div class="text-body font-weight-bold pb-3">Curve Variation range minimum</div> <div class="col">
<div class="row align-items-end"> @Html.EditorFor(m => m.compl)
<div class="col-md-6"> </div>
@Html.EditorFor(m => m.co2s, new {size = "small", prepend = ">", append = "umol/m"})
</div>
<div class="col-md-6">
@Html.EditorFor(m => m.pari, new {size = "small", prepend = ">", append = "umol/m2/s"})
</div>
<div class="col-md-6">
@Html.EditorFor(m => m.tleaf, new {size = "small", prepend = ">", append = "oC"})
</div>
<div class="col-md-6">
@Html.EditorFor(m => m.phips2, new {size = "small", prepend = ">"})
</div>
</div>
<hr/>
<div class="row">
<div class="col">
@Html.EditorFor(m => m.compl)
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
} }