186 lines
6 KiB
Text
186 lines
6 KiB
Text
@using JD.Core
|
|
@using TeaBox.AssetValidation
|
|
@using TeaBox.MapValidation
|
|
@{
|
|
Layout = "DefaultLayout.cshtml";
|
|
|
|
PageData["Title"] = "Maps Report";
|
|
PageData["currentPage"] = "MapsReport";
|
|
|
|
var mapsReportModel = new MapsReportModel();
|
|
}
|
|
|
|
@GenerateMapReports(mapsReportModel)
|
|
|
|
@helper GenerateMapReports(MapsReportModel model)
|
|
{
|
|
<h2>Maps</h2>
|
|
@GenerateSearchBar(model)
|
|
@GenerateBatchGroupedMapTable(model)
|
|
@GenerateValidationFullLog(model)
|
|
}
|
|
|
|
@helper GenerateSearchBar(MapsReportModel model)
|
|
{
|
|
<div class="btn-toolbar" role="toolbar">
|
|
<div class="btn-group" role="group" data-toggle="buttons" style="margin-bottom: 10px;">
|
|
@foreach (var version in model.Versions)
|
|
{
|
|
var isSelected = (model.CurrentVersion == version);
|
|
var isActiveClass = isSelected ? "active" : null;
|
|
|
|
<label class="btn btn-default @isActiveClass">
|
|
<input name="versionFilter" type="radio" class="btn btn-default" value="@version.FilterString" checked="@isSelected">@version.DisplayName
|
|
</label>
|
|
}
|
|
</div>
|
|
</div>
|
|
<input type="text" id="searchControl" class="form-control" placeholder="Search map...">
|
|
}
|
|
|
|
@helper GenerateBatchGroupedMapTable(MapsReportModel model)
|
|
{
|
|
<div class="page-header">
|
|
<h2></h2>
|
|
|
|
<table class="table Batch Grouped Maps">
|
|
@GenerateMapValidationHeadRow(model)
|
|
@GenerateReportValidationResultRows(model)
|
|
</table>
|
|
</div>
|
|
}
|
|
|
|
@helper GenerateMapValidationHeadRow(MapsReportModel model)
|
|
{
|
|
<tr>
|
|
<td>Map</td>
|
|
|
|
@foreach (var category in model.Categories)
|
|
{
|
|
var icon = @model.GetValidationCategoryIcon(category);
|
|
<td><i class="@icon"></i> @category</td>
|
|
}
|
|
</tr>
|
|
}
|
|
|
|
@helper GenerateReportValidationResultRows(MapsReportModel model)
|
|
{
|
|
foreach (var mapReport in model.MapReports)
|
|
{
|
|
var reportClass = mapReport.Failed ? "danger" : mapReport.Warning ? "warning" : "success";
|
|
|
|
<tr class="reportRow" mapName="@mapReport.Asset.Name" mapVersion="@mapReport.Asset.OriginalJdVersion.ShortName">
|
|
<td class="@reportClass">@mapReport.Asset.Name</td>
|
|
|
|
|
|
@foreach (var result in mapReport.Results.OrderBy(x => x.Validation.Category).GroupBy(x => x.Validation.Category))
|
|
{
|
|
var allErrors = result.Sum(x => x.Log.Errors.Count);
|
|
var allWarnings = result.Sum(x => x.Log.Warnings.Count);
|
|
var glyph = allErrors > 0
|
|
? "glyphicon-remove-sign"
|
|
: allWarnings > 0 ? "glyphicon-warning-sign" : "glyphicon-ok-sign";
|
|
var tdClass = allErrors > 0 ? "danger" : allWarnings > 0 ? "warning" : "success";
|
|
var hashCode = result.FirstOrDefault(x => x.Log.Errors.Any() || x.Log.Warnings.Any())?.GetHashCode();
|
|
<td class="@tdClass"><a href="#@hashCode"><span class="glyphicon @glyph text-@tdClass"></span></a></td>
|
|
}
|
|
</tr>
|
|
}
|
|
}
|
|
|
|
|
|
@helper GenerateValidationFullLog(MapsReportModel model)
|
|
{
|
|
foreach (var mapReport in model.MapReports)
|
|
{
|
|
if (mapReport.Results.All(r => r.Log.Errors.Count == 0 && r.Log.Warnings.Count == 0))
|
|
{
|
|
continue;
|
|
}
|
|
<div class="reportFullLog" mapName="@mapReport.Asset.Name" mapVersion="@mapReport.Asset.OriginalJdVersion.ShortName">
|
|
<div class="page-header">
|
|
<h1>
|
|
@mapReport.Asset.Name.ToString()
|
|
<p>
|
|
<small>@mapReport.Summary</small>
|
|
</p>
|
|
</h1>
|
|
</div>
|
|
@foreach (var result in mapReport.Results.Where(r => r.Log.Errors.Count > 0 || r.Log.Warnings.Count > 0))
|
|
{
|
|
@GenerateValidationResult(result)
|
|
}
|
|
</div>
|
|
}
|
|
}
|
|
|
|
@helper GenerateValidationResult(AssetReport<Map>.AssetValidationResult result)
|
|
{
|
|
var reportClass = result.Log.Errors.Count > 0 ? "alert-danger" : result.Log.Warnings.Count > 0 ? "alert-warning" : "alert-success";
|
|
var glyph = result.Log.Errors.Count > 0 ? "glyphicon-remove-sign" : result.Log.Warnings.Count > 0 ? "glyphicon-warning-sign" : "glyphicon-ok-sign";
|
|
var name = result.Log.Errors.Count > 0 ? result.Validation.FailureName : result.Log.Warnings.Count > 0 ? "Warning in validation \"" + result.Validation.Name + "\"" : result.Validation.Name;
|
|
|
|
<div id="@result.GetHashCode()" class="alert @reportClass">
|
|
|
|
<h4>
|
|
<span class="glyphicon @glyph"></span>
|
|
@name
|
|
</h4>
|
|
@foreach (var log in result.Log.FullLog)
|
|
{
|
|
<p>@log.Message</p>
|
|
}
|
|
</div>
|
|
}
|
|
|
|
@section Head
|
|
{
|
|
<style>
|
|
:target {
|
|
border: dashed #000 2px;
|
|
}
|
|
</style>
|
|
}
|
|
|
|
@section BodyEndScripts
|
|
{
|
|
<script>
|
|
|
|
$('#searchControl').on('input',
|
|
function (e) {
|
|
updateView();
|
|
});
|
|
|
|
$('input:radio').change(
|
|
function () {
|
|
updateView();
|
|
});
|
|
|
|
function updateView() {
|
|
var mapFilter = $('#searchControl').val();
|
|
var versionFilter = $("input[name='versionFilter']:checked").val();
|
|
|
|
$(".reportRow").each(function (i, obj) { filter(obj, mapFilter, versionFilter); });
|
|
$(".reportFullLog").each(function (i, obj) { filter(obj, mapFilter, versionFilter); });
|
|
}
|
|
|
|
function filter(element, mapFilter, versionFilter) {
|
|
var mapName = $(element).attr("mapName");
|
|
var mapVersion = $(element).attr("mapVersion");
|
|
var visible = (mapName.toLowerCase().indexOf(mapFilter.toLowerCase()) !== -1);
|
|
if (versionFilter !== "all") {
|
|
if (mapVersion !== versionFilter) {
|
|
visible = false;
|
|
}
|
|
}
|
|
|
|
if (visible) {
|
|
$(element).show();
|
|
} else {
|
|
$(element).hide();
|
|
}
|
|
}
|
|
|
|
</script>
|
|
}
|
|
|