Reformating charting, add DataError message

This commit is contained in:
2016-05-09 11:46:32 -04:00
parent 1ba8f24b10
commit aca7157663
11 changed files with 616 additions and 24 deletions
@@ -10,12 +10,14 @@ using System.Web.UI.WebControls;
using LeafWeb.Core.Charter;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Parsers;
using LeafWeb.Core.Utility;
using LeafWeb.Web.Services;
using LeafWeb.Web.ViewModels.LeafCharter;
using LeafWeb.Web.ViewModels.Chart;
using NLog;
namespace LeafWeb.Web.Controllers
{
public class LeafCharterController : ControllerBase
public class ChartController : ControllerBase
{
public ActionResult Index(int leafInputId)
{
@@ -28,16 +30,30 @@ namespace LeafWeb.Web.Controllers
if (leafOutputFile == null)
throw new ArgumentOutOfRangeException(); // TODO: break
var curveData = GetCurveData(leafOutputFile.Contents);
try
{
var curveData = GetCurveData(leafOutputFile.Contents);
var curveIds = curveData.Select(c => c.CurveId).ToList();
var curveIds = curveData.Select(c => c.CurveId).ToList();
var viewModel = new LeafCharterViewModel {AvailableCurveId = curveIds, LeafInputId = leafInputId};
var viewModel = new ChartViewModel
{
AvailableCurveId = curveIds,
LeafInputId = leafInputId,
LeafInputIdentifier = leafOutputFile.LeafInput.Identifier
};
return View(viewModel);
return View(viewModel);
}
catch (ParseException parseException)
{
var logger = LogManager.GetCurrentClassLogger();
logger.Warn(parseException);
return View("DataError", model: parseException.Message);
}
}
public ActionResult LeafCharts(int leafInputId, string curveId)
public ActionResult ChartCurve(int leafInputId, string curveId)
{
var leafOutputFile =
DataService
@@ -53,7 +69,7 @@ namespace LeafWeb.Web.Controllers
var curveIdData = curveData.FirstOrDefault(c => c.CurveId == curveId);
if (curveIdData == null)
return File("/Content/favicon/apple-icon-57x57.png", "image/png");
return File("/Content/favicon/apple-icon-57x57.png", "image/png"); // TODO: different image ?
var charts = GetChartBitmaps(curveIdData).ToList();
@@ -65,7 +81,7 @@ namespace LeafWeb.Web.Controllers
{
combinedChart.Save(ms, ImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
return File(ms.ToArray(), "image/png", curveId + ".png");
return File(ms.ToArray(), "image/png", curveId.FilterValidFilename() + ".png");
}
}
@@ -1,15 +1,16 @@
using System.Collections.Generic;
namespace LeafWeb.Web.ViewModels.LeafCharter
namespace LeafWeb.Web.ViewModels.Chart
{
public class LeafCharterViewModel
public class ChartViewModel
{
public int LeafInputId { get; set; }
public string CurveId { get; set; }
public IEnumerable<string> AvailableCurveId { get; set; }
public string LeafInputIdentifier { get; set; }
}
public class LeafCharterQueryViewModel
public class ChartQueryViewModel
{
public int LeafInputId { get; set; }
public string CurveId { get; set; }
+9
View File
@@ -0,0 +1,9 @@
@model string
@{
ViewBag.Title = "Chart - Data Error";
}
<h1>@ViewBag.Title</h1>
<p>There was an issue generating a chart for the selected data.</p>
<p>@Model</p>
@@ -1,4 +1,9 @@
@model LeafWeb.Web.ViewModels.LeafCharter.LeafCharterViewModel
@model LeafWeb.Web.ViewModels.Chart.ChartViewModel
@{
ViewBag.Title = "Chart";
}
<h1>@ViewBag.Title</h1>
<h3>Identifier: <strong>@Model.LeafInputIdentifier</strong></h3>
@Html.DropDownList("CurveId", new SelectList(Model.AvailableCurveId, Model.CurveId), "Select CurveId")
@@ -15,7 +20,7 @@
$chart.attr('src', "");
var curveId = $("option:selected", this).text();
var url =
"@Html.Raw(Url.Action("LeafCharts", new {leafInputId = Model.LeafInputId, curveId="curveId"}))";
"@Html.Raw(Url.Action("ChartCurve", new {leafInputId = Model.LeafInputId, curveId="curveId"}))";
url = url.replace("=curveId", "=" + curveId);
$chart.attr('src', url)
.load(function() {
+1 -1
View File
@@ -11,7 +11,7 @@
@Html.Partial("_StatusMessage")
<h1>Submitting Data and Retrieving EDO Results</h1>
<h1>@ViewBag.Title</h1>
<p>
There is no limit on the number of files you may submit for analysis.
Keep selecting files and hitting the Add button until all of the files you need to upload are shown in the list.
+4 -4
View File
@@ -5,7 +5,7 @@
var grid = new WebGrid(Model, rowsPerPage: 45);
}
<h1>Result Status</h1>
<h1>@ViewBag.Title</h1>
@grid.GetHtml(columns:
grid.Columns(
@@ -15,8 +15,8 @@
grid.Column("CurrentStatus", "Status"),
grid.Column("Chart", "Chart", item =>
item.HasLeafChart
? Html.ActionLink("Chart", "Index", "LeafCharter", new {leafInputId = item.LeafInputId}, new {})
: Html.Raw(""))
),
? Html.ActionLink("Chart", "Index", "Chart", new {leafInputId = item.LeafInputId}, new {})
: Html.Raw(""))
),
htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed" }
)
+4 -3
View File
@@ -964,7 +964,7 @@
<Compile Include="Services\LeafGasCharter.cs" />
<Compile Include="Controllers\ControllerBase.cs" />
<Compile Include="Controllers\FluxnetSiteController.cs" />
<Compile Include="Controllers\LeafCharterController.cs" />
<Compile Include="Controllers\ChartController.cs" />
<Compile Include="Controllers\LeafInputController.cs" />
<Compile Include="Controllers\ResultsController.cs" />
<Compile Include="Controllers\PagesController.cs" />
@@ -983,7 +983,7 @@
<Compile Include="Services\PiscalQueue\StartPending.cs" />
<Compile Include="Utility\MarkdownHelper.cs" />
<Compile Include="Utility\Validation.cs" />
<Compile Include="ViewModels\LeafCharter\LeafCharterViewModel.cs" />
<Compile Include="ViewModels\Chart\ChartViewModel.cs" />
<Compile Include="ViewModels\LeafInput\ConfirmViewModel.cs" />
<Compile Include="ViewModels\LeafInput\CreateViewModel.cs" />
<Compile Include="ViewModels\Results\ResultStatusViewModel.cs" />
@@ -996,7 +996,7 @@
<Content Include="Views\Shared\_Layout.cshtml" />
<Content Include="Views\_ViewStart.cshtml" />
<Content Include="Scripts\jquery-1.9.1.min.map" />
<Content Include="Views\LeafCharter\Index.cshtml" />
<Content Include="Views\Chart\Index.cshtml" />
<Content Include="Views\LeafInput\Index.cshtml" />
<Content Include="Views\Shared\_ValidationSummary.cshtml" />
<Content Include="Views\Shared\EditorTemplates\_FieldLayout.cshtml" />
@@ -1022,6 +1022,7 @@
<Content Include="Views\Results\Index.cshtml" />
<Content Include="Views\Pages\Information.cshtml" />
<Content Include="Views\Results\DownloadNotFound.cshtml" />
<Content Include="Views\Chart\DataError.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>