Add details for search

This commit is contained in:
2020-07-23 21:16:26 -04:00
parent 25b5d8ebc6
commit 733ed01100
7 changed files with 45 additions and 16 deletions
+31 -1
View File
@@ -134,7 +134,7 @@ namespace LeafWeb.WebCms.Tests.Models
}
[Test]
public void CanConstructFromLeafInputFile()
public void CanConstructAdminFromLeafInputFile()
{
var leafInput = GetLeafInput;
var viewModel = new LeafInputDetails_Admin(leafInput);
@@ -167,5 +167,35 @@ namespace LeafWeb.WebCms.Tests.Models
//Assert.That(viewModel.LeafInputData[0].Id, Is.EqualTo(123));
}
[Test]
public void CanConstructFromLeafInputFile()
{
var leafInput = GetLeafInput;
var viewModel = new LeafInputDetails(leafInput);
//Assert.That(viewModel.CurrentStatus, Is.EqualTo(leafInput.CurrentStatus.ToString()));
//Assert.That(viewModel., Is.EqualTo(leafInput.Id));
//Assert.That(viewModel.LeafOutputFilenames, Has.Length.EqualTo(1));
//Assert.That(viewModel., Is.EqualTo(leafInput.Identifier));
Assert.That(viewModel.SiteId, Is.EqualTo(leafInput.SiteId));
//Assert.That(viewModel.LeafInputPhotosynthesisType, Is.EqualTo(leafInput.PhotosynthesisType.Name));
Assert.That(viewModel.LeafInputData, Has.Count.EqualTo(1));
Assert.That(viewModel.LeafInputData[0].SiteName, Is.EqualTo("MySite"));
Assert.That(viewModel.LeafInputData[0].Id, Is.EqualTo(123));
Assert.That(viewModel.LeafInputData[0].Site, Is.Not.Null);
Assert.That(viewModel.LeafInputData[0].Site.SiteId, Is.EqualTo("MySiteId"));
Assert.That(viewModel.LeafInputData[0].Site.Latitude, Is.EqualTo(10));
Assert.That(viewModel.LeafInputData[0].Site.Longitude, Is.EqualTo(20));
Assert.That(viewModel.LeafInputData[0].Site.Elevation, Is.Null);
Assert.That(viewModel.LeafInputData[0].Data, Is.Not.Null);
Assert.That(viewModel.LeafInputData[0].Data, Has.Count.GreaterThan(0));
Assert.That(viewModel.LeafInputData[0].Data[0].CO2S, Is.EqualTo(3.1));
//Assert.That(viewModel.LeafInputData[0].Id, Is.EqualTo(123));
}
}
}
+4 -1
View File
@@ -21,11 +21,14 @@ namespace LeafWeb.WebCms.App_Start
Mapper.CreateMap<LeafOutputFile, string>().ConvertUsing(file => file?.FileContents.Contents.GetString());
Mapper.CreateMap<LeafInputStatusType, string>().ConvertUsing(st => st.ToString());
Mapper.CreateMap<LeafInputStatusType, LeafInputStatus>().ConvertUsing(st => new LeafInputStatus());
Mapper.CreateMap<LeafInput, LeafInputDetails_Admin>()
Mapper.CreateMap<LeafInput, LeafInputDetails>()
.Include<LeafInput, LeafInputDetails_Admin>()
.ForMember(dest => dest.LeafInputId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.HasLeafChart,
opt => opt.ResolveUsing(src => src.OutputFiles.Any(o => o.IsLeafChartFile)));
Mapper.CreateMap<LeafInput, LeafInputDetails_Admin>();
// LeafInputData
Mapper.CreateMap<LeafInputData, LeafInputDataViewModel>()
.ForMember(dest => dest.Filename, opt => opt.MapFrom(src => src.LeafOutputFile.Filename));
+1 -1
View File
@@ -7,7 +7,7 @@ namespace LeafWeb.WebCms.Controllers
public const int Chart = 1100;
// ReSharper disable once InconsistentNaming
public const int Details_Admin = 1111;
public const int Details_Results = 0;
public const int Details_Results = 1183;
public const int PasswordResetRequest = 1164;
}
+2 -5
View File
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Utility;
using LeafWeb.WebCms.Models;
using LeafWeb.WebCms.Utility;
using Umbraco.Web.Mvc;
@@ -33,7 +30,6 @@ namespace LeafWeb.WebCms.Controllers
return View(searchViewModel);
}
[MemberAuthorize(AllowGroup = "Authenticated")]
[HttpPost]
public ActionResult Search(LeafDataQuery query)
@@ -48,6 +44,7 @@ namespace LeafWeb.WebCms.Controllers
return RedirectToCurrentUmbracoPage(query.GetNameValueCollection());
}
[MemberAuthorize(AllowGroup = "Authenticated")]
public ActionResult Details(int id)
{
var leafInput = DataService.GetLeafInput(id);
@@ -58,7 +55,7 @@ namespace LeafWeb.WebCms.Controllers
RedirectToUmbracoPage(LeafWebPageIds.ManageQueue);
}
var viewModel = new LeafInputDetails_Admin(leafInput);
var viewModel = new LeafInputDetails(leafInput);
return View(viewModel);
}
@@ -0,0 +1,5 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
Html.RenderAction("Details", "Results");
}
+1 -8
View File
@@ -1,5 +1,5 @@
@using LeafWeb.WebCms.Utility
@model LeafInputDetails_Admin
@model LeafInputDetails
<div class="row pb-3">
@@ -22,13 +22,6 @@
</div>
</div>
@if (Model.IsCancellable)
{
<div class="pl-3">
@CancelLink(Model)
</div>
}
</div>
<div class="row">
<div class="container">
+1
View File
@@ -1074,6 +1074,7 @@
<Content Include="Views\Shared\_LeafInputActions.cshtml" />
<Content Include="Views\Shared\DisplayTemplates\_Details_ResultsLink.cshtml" />
<Content Include="Views\Results\Details.cshtml" />
<Content Include="Views\MacroPartials\ResultsDetails.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>