Update Charting to use fancybox
This commit is contained in:
@@ -1 +1 @@
|
||||
C:\Users\poprhythm\AppData\Local\Temp\Temporary ASP.NET Files\vs\f80e29bb\faae20bf\App_Web_all.generated.cs.8f9494c4.pdoxzkxo.dll
|
||||
C:\Users\poprhythm\AppData\Local\Temp\Temporary ASP.NET Files\vs\f80e29bb\faae20bf\App_Web_all.generated.cs.8f9494c4.ulmxez9s.dll
|
||||
+1
File diff suppressed because one or more lines are too long
@@ -25,6 +25,9 @@ namespace LeafWeb.WebCms.Controllers
|
||||
if (!leafInputId.HasValue)
|
||||
return View("DataError", model: "Must specify LeafInputId");
|
||||
|
||||
//if (leafInputId == 2147483647)
|
||||
// return View(GetTestChartViewModel());
|
||||
|
||||
var leafOutputFile = DataService.GetLeafOutput_ChartFile(leafInputId.Value);
|
||||
|
||||
if (leafOutputFile == null)
|
||||
@@ -57,14 +60,28 @@ namespace LeafWeb.WebCms.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult ChartCurve(int leafInputId, string curveId)
|
||||
//private ChartViewModel GetTestChartViewModel()
|
||||
//{
|
||||
// return new ChartViewModel
|
||||
// {
|
||||
// AvailableCurveId = new []{"Valid", "Test"},
|
||||
// LeafInputId = 2147483647,
|
||||
// LeafInputIdentifier = "Chart Tests"
|
||||
// };
|
||||
//}
|
||||
|
||||
public ActionResult ChartCurve(int leafInputId, string curveId, bool base64 = false)
|
||||
{
|
||||
var leafOutputFile = DataService.GetLeafOutput_ChartFile(leafInputId);
|
||||
|
||||
if (leafOutputFile == null)
|
||||
throw new ArgumentOutOfRangeException(); // TODO: break
|
||||
if (leafOutputFile == null)
|
||||
{
|
||||
var logger = LogManager.GetLogger(GetType());
|
||||
logger.Warn($"Invalid LeafInputID {leafInputId}");
|
||||
return new HttpStatusCodeResult(HttpStatusCode.NotFound, $"Invalid LeafInputId {leafInputId}.");
|
||||
}
|
||||
|
||||
CurveData curveData;
|
||||
CurveData curveData;
|
||||
try
|
||||
{
|
||||
curveData = GetCurveData(leafOutputFile.FileContents.Contents, curveId);
|
||||
@@ -75,7 +92,7 @@ namespace LeafWeb.WebCms.Controllers
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return new HttpStatusCodeResult(HttpStatusCode.NotFound, $"Unhandled exception thrown wihle parsing {leafOutputFile.Filename}.");
|
||||
return new HttpStatusCodeResult(HttpStatusCode.NotFound, $"Unhandled exception thrown while parsing {leafOutputFile.Filename}.");
|
||||
}
|
||||
|
||||
if (curveData == null || curveData.ParamSets.Count == 0)
|
||||
@@ -88,12 +105,14 @@ namespace LeafWeb.WebCms.Controllers
|
||||
foreach (var chart in charts) chart.Dispose(); // cleanup
|
||||
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
combinedChart.Save(ms, ImageFormat.Png);
|
||||
{
|
||||
combinedChart.Save(ms, ImageFormat.Png);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
var base64String = Convert.ToBase64String(ms.ToArray());
|
||||
return Content(base64String, "image/png");
|
||||
//return File(ms.ToArray(), "image/png", curveId.FilterValidFilename() + ".png");
|
||||
if (base64)
|
||||
return Content(base64String, "image/png");
|
||||
else
|
||||
return File(ms.ToArray(), "image/png", curveId.FilterValidFilename() + ".png");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,42 @@
|
||||
@using ClientDependency.Core.Mvc
|
||||
@model LeafWeb.WebCms.Models.ChartViewModel
|
||||
@{
|
||||
var selectText = "Select CurveId";
|
||||
Html.RequiresCss("~/Content/glyphicon_animate.css");
|
||||
Html.RequiresJs("~/scripts/Chart.js");
|
||||
}
|
||||
|
||||
Html.RequiresCss("~/Content/jquery.fancybox.min.css");
|
||||
Html.RequiresJs("~/scripts/jquery.fancybox.min.js");
|
||||
}
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div>Identifier: <strong>@Model.LeafInputIdentifier</strong>
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
Identifier: <strong>@Model.LeafInputIdentifier</strong>
|
||||
</div>
|
||||
<div class="panel text-center">
|
||||
@foreach (var cId in Model.AvailableCurveId)
|
||||
{
|
||||
<p>
|
||||
<a href="@Url.Action("ChartCurve", new {leafInputId = Model.LeafInputId, curveId = cId})"
|
||||
data-fancybox
|
||||
data-options='{"buttons" : ["zoom", "download", "close"]}'
|
||||
class="btn btn-default">
|
||||
<i class="glyphicon glyphicon-picture"></i>
|
||||
@cId Chart
|
||||
</a>
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<span>CurveId:</span>
|
||||
@Html.DropDownList("CurveId", new SelectList(Model.AvailableCurveId, Model.CurveId), selectText)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<img id="chart"/>
|
||||
@section Scripts {
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
}
|
||||
|
||||
@*<img id="chart" />
|
||||
<span class="help-block">
|
||||
<span id="chart-error"></span>
|
||||
</span>
|
||||
</span>*@
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
<div class="row panel">
|
||||
<div class="col-lg-8">
|
||||
Service description: @Model.ServerDescription<br/>
|
||||
Est. processing time by LeafInput size -
|
||||
@*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>
|
||||
<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))
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<UseGlobalApplicationHostFile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<Use64BitIISExpress />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -663,6 +664,7 @@
|
||||
<Content Include="Content\font-awesome.css" />
|
||||
<Content Include="Content\font-awesome.min.css" />
|
||||
<Content Include="Content\glyphicon_animate.css" />
|
||||
<Content Include="Content\jquery.fancybox.min.css" />
|
||||
<Content Include="Content\style.css">
|
||||
<DependentUpon>style.scss</DependentUpon>
|
||||
</Content>
|
||||
@@ -796,6 +798,7 @@
|
||||
<Content Include="scripts\jquery.autocomplete.min.js" />
|
||||
<Content Include="scripts\jquery-1.12.4.min.map" />
|
||||
<None Include="scripts\jquery.validate-vsdoc.js" />
|
||||
<Content Include="scripts\jquery.fancybox.min.js" />
|
||||
<Content Include="scripts\jquery.validate.js" />
|
||||
<Content Include="scripts\jquery.validate.min.js" />
|
||||
<Content Include="scripts\jquery.validate.unobtrusive.bootstrap.js" />
|
||||
@@ -909,7 +912,9 @@
|
||||
<Content Include="Content\site.css" />
|
||||
<Content Include="Content\rte.css" />
|
||||
<Content Include="scripts\site.js" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_Start\HangfireStartup.cs" />
|
||||
|
||||
Vendored
+1
-65
@@ -1,67 +1,3 @@
|
||||
$(function () {
|
||||
|
||||
var baseUrl = "/umbraco/surface/Chart/ChartCurve";
|
||||
var $chart = $("#chart");
|
||||
var $chartError = $('#chart-error');
|
||||
var $curveIdElem = $('#CurveId');
|
||||
|
||||
var getUrlParameter = function (sParam) {
|
||||
var sPageUrl = decodeURIComponent(window.location.search.substring(1)),
|
||||
sUrlVariables = sPageUrl.split('&'),
|
||||
sParameterName,
|
||||
i;
|
||||
|
||||
for (i = 0; i < sUrlVariables.length; i++) {
|
||||
sParameterName = sUrlVariables[i].split('=');
|
||||
|
||||
if (sParameterName[0] === sParam) {
|
||||
return sParameterName[1] === undefined ? true : sParameterName[1];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var addSpinner = function () {
|
||||
$chart.after('<span class="glyphicon glyphicon-refresh gly-spin" style="font-size: 3em"></span>');
|
||||
}
|
||||
|
||||
var removeSpinner = function () {
|
||||
$chart.next('span.gly-spin').remove(); // remove spinner
|
||||
};
|
||||
|
||||
var curveIdChangeAjax = function () {
|
||||
$chartError.html('');
|
||||
|
||||
// this is the "Select CurveId" instruction
|
||||
if (this.selectedIndex === 0) {
|
||||
$chart.removeAttr('src');
|
||||
return;
|
||||
}
|
||||
var curveId = $("option:selected", this).text();
|
||||
|
||||
addSpinner();
|
||||
|
||||
var leafInputId = getUrlParameter("leafInputId");
|
||||
var url = baseUrl + "?leafInputId=" + leafInputId + "&curveId=" + curveId;
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
contentType: "image/png",
|
||||
success: function (data) {
|
||||
$chart.attr('src', "data:image/png;base64," + data);
|
||||
removeSpinner();
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
removeSpinner();
|
||||
$chart.removeAttr('src');
|
||||
var html = '<h3 class="text-danger">A problem was encountered loading this chart.</h3>';
|
||||
if (errorThrown != undefined) {
|
||||
html += "<h4>Detail:</h4><pre>" + errorThrown + "</pre>";
|
||||
}
|
||||
$chartError.html(html);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$curveIdElem.change(curveIdChangeAjax);
|
||||
$.fancybox.defaults.errorTpl = '<div class="fancybox-error"><p>Sorry, a problem was encountered loading this chart.</p></div>';
|
||||
});
|
||||
+13
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user