Helium Pressure Report

This commit is contained in:
Stoyan Zlatev
2023-04-06 17:02:58 +02:00
parent 220308088f
commit c4b9933eb0
24 changed files with 736 additions and 44 deletions
@@ -125,4 +125,20 @@ table.table table.table {
.bg-whitesmoke {
background-color: whitesmoke !important
}
}
.bi-bold:before {
font-weight: bolder !important;
}
.table-responsive::-webkit-scrollbar:horizontal {
position: fixed;
bottom: 0;
}
.cursor-pointer:hover {
cursor: pointer !important;
text-decoration: underline !important;
}
@@ -3,7 +3,10 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Security.Claims;
using System.Security.Principal;
using System.Web.Mvc;
@@ -54,5 +57,25 @@
{
return default(T);
}
public static string Display<T>(this T model, Expression<Func<T, object>> expression)
{
if (expression.Body is MemberExpression memberExpression)
{
return memberExpression
.Member
.GetCustomAttribute<DisplayAttribute>()
.GetName();
}
else if (expression.Body is UnaryExpression unaryExpression && unaryExpression.Operand is MemberExpression operandExpression)
{
return operandExpression
.Member
.GetCustomAttribute<DisplayAttribute>()
.GetName();
}
return default(string);
}
}
}
@@ -0,0 +1,38 @@
namespace LaaProductionWeb.Controllers
{
using LaaProductionWeb.Services.Interfaces;
using LaaProductionWeb.Services.Models;
using System.Web.Mvc;
public class ReportController : Controller
{
private readonly IReportService reportService;
public ReportController(IReportService reportService)
=> this.reportService = reportService;
[HttpGet]
public ActionResult Index()
{
var model = this.reportService.LoadHeliumPressureReport();
return this.View(model);
}
[HttpPost]
public ActionResult Index(HeliumReportModel model)
{
model = this.reportService.LoadHeliumPressureReport(model);
return this.View(model);
}
public ActionResult Results(int testId = 0)
{
var results = this.reportService.LoadHeliumPressureResults(testId);
return this.PartialView(results);
}
}
}
@@ -145,6 +145,7 @@
<Compile Include="Controllers\AccountController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\ProtocolController.cs" />
<Compile Include="Controllers\ReportController.cs" />
<Compile Include="Controllers\SearchController.cs" />
<Compile Include="Controllers\ShipmentsController.cs" />
<Compile Include="Global.asax.cs">
@@ -176,6 +177,9 @@
<Content Include="Views\Account\Authorize.cshtml" />
<Content Include="Views\Account\UserRole.cshtml" />
<Content Include="Views\Account\Permissions.cshtml" />
<Content Include="Views\Report\Index.cshtml" />
<Content Include="Views\Report\Filter.cshtml" />
<Content Include="Views\Report\Results.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Content\font\fonts\bootstrap-icons.woff" />
@@ -15,17 +15,17 @@
enables a clean separation of concerns and gives you full control over markup
for enjoyable, agile development.
</p>
<p><a class="btn btn-default" >Learn more &raquo;</a></p>
<p><a class="btn btn-default">Learn more &raquo;</a></p>
</div>
<div class="col-md-4">
<h2>Get more libraries</h2>
<p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
<p><a class="btn btn-default" >Learn more &raquo;</a></p>
<p><a class="btn btn-default">Learn more &raquo;</a></p>
</div>
<div class="col-md-4">
<h2>Web Hosting</h2>
<p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p>
<p><a class="btn btn-default" >Learn more &raquo;</a></p>
<p><a class="btn btn-default">Learn more &raquo;</a></p>
</div>
</div>
</div>
@@ -2,19 +2,21 @@
@using LaaProductionWeb.Services.Models
<form action="/Protocol/DeleteFile" method="post" class="nav justify-content-end bg-whitesmoke">
@this.Html.AntiForgeryToken()
@this.Html.HiddenFor(x => x.FileId)
@this.Html.HiddenFor(x => x.OrderId)
<button class="btn btn-link text-danger nav-link">
<i class="bi bi-trash"></i> Delete
</button>
</form>
<div class="d-flex flex-column h-100">
<form action="/Protocol/DeleteFile" method="post" class="nav justify-content-end bg-whitesmoke">
@this.Html.AntiForgeryToken()
@this.Html.HiddenFor(x => x.FileId)
@this.Html.HiddenFor(x => x.OrderId)
<button class="btn btn-link text-danger nav-link">
<i class="bi bi-trash"></i> Delete
</button>
</form>
<div class="container-fluid h-100 p-0">
<div class="row h-100">
<div class="position-relative h-100">
<iframe class="position-absolute align-top align-left w-100 h-100" src="@this.Model.FileContent" frameborder="0" allowfullscreen />
<div class="container-fluid h-100 p-0">
<div class="row h-100">
<div class="position-relative h-100">
<iframe class="position-absolute align-top align-left w-100 h-100" src="@this.Model.FileContent" frameborder="0" allowfullscreen />
</div>
</div>
</div>
</div>
@@ -53,11 +53,10 @@
@this.Html.HiddenFor(x => x.ClientId)
@this.Html.HiddenFor(x => x.ClientName)
@this.Html.HiddenFor(x => x.Positions)
<input name="FilePDF" id="FilePDF" type="file" class="d-none" accept="application/pdf" />
<input name="FilePDF" id="FilePDF" type="file" class="d-none" accept="application/pdf" onchange="javascript: this.form.submit();" />
<div class="input-group flex-nowrap mt-3">
<a class="btn btn-light white-space-nowrap" href="/Protocol/Print?orderId=@this.Model.OrderId" target="_blank"><i class="bi bi-printer me-2"></i> Vorschau</a>
<label for="FilePDF" class="btn btn-outline-light border text-dark white-space-nowrap"><i class="bi bi-filetype-pdf"></i> Auswählen</label>
<button type="submit" class="btn btn-success white-space-nowrap"><i class="bi bi-upload"></i> Hochladen</button>
<a class="btn btn-light white-space-nowrap w-100" href="/Protocol/Print?orderId=@this.Model.OrderId" target="_blank"><i class="bi bi-printer me-2"></i> Vorschau</a>
<label for="FilePDF" class="btn btn-outline-light border text-dark white-space-nowrap w-100"><i class="bi bi-filetype-pdf"></i> Auswählen</label>
</div>
@if (this.TempData.TryGetValue(ProtocolController.FilePDF, out object errorMessage))
{
@@ -0,0 +1,25 @@
@model LaaProductionWeb.Services.Models.HeliumReportFilterProperty
@{
Func<bool, string> isChecked = x => x ? "checked" : string.Empty;
Func<bool, string> bgColor = x => !x ? "bg-light" : string.Empty;
}
<input type="hidden" name="@this.Model.IndexName" value="@this.Model.Index" />
<input type="hidden" name="@this.Model.ColumnName" value="@this.Model.Column" />
<input type="hidden" name="@this.Model.PropertyName" value="@this.Model.Property" />
<input name="@this.Model.LikeName" class="form-control form-control-sm mb-1" autocomplete="off" value="@this.Model.Like" />
<div class="input-group flex-nowrap justify-content-center">
<input id="@(this.Model.OrderById)_1" name="@this.Model.OrderByName" type="radio" value="1" @isChecked(this.Model.OrderBy == 1) class="d-none" />
<label for="@(this.Model.OrderById)_1" class="form-control form-control-sm text-center text-secondary border-light @bgColor(this.Model.OrderBy == 1) cursor-pointer">
<i class="bi bi-chevron-up"></i>
</label>
<input id="@(this.Model.OrderById)_0" name="@this.Model.OrderByName" type="radio" value="0" @isChecked(this.Model.OrderBy == 0) class="d-none" />
<label for="@(this.Model.OrderById)_0" class="form-control form-control-sm text-center text-secondary border-light @bgColor(this.Model.OrderBy == 0) cursor-pointer">
<i class="bi bi-dash"></i>
</label>
<input id="@(this.Model.OrderById)__1" name="@this.Model.OrderByName" type="radio" value="-1" @isChecked(this.Model.OrderBy == -1) class="d-none" />
<label for="@(this.Model.OrderById)__1" class="form-control form-control-sm text-center text-secondary border-light @bgColor(this.Model.OrderBy == -1) cursor-pointer">
<i class="bi bi-chevron-down"></i>
</label>
</div>
@@ -0,0 +1,120 @@
@model LaaProductionWeb.Services.Models.HeliumReportModel
<form action="/Report" method="post" autocomplete="off" class="h-100" id="he_report">
<div class="table-responsive mh-100">
<table class="table table-sm table-bordered mb-0">
<thead class="bg-light">
<tr>
<th class="text-nowrap p-2">@this.Model.Display(x => x.AuftragNr)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.FertigungNr)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.PositionNr)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.SerialNr)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.IdentNr)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.HeId)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.HeTestId)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.PcbId)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Nennweite)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Baulaenge)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Typ)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Druck)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Temperatur)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.HeLakeRate)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.HeTestPressure)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.IsValid)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.TestDate)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Tester)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Text)</th>
</tr>
<tr>
@foreach (var filter in this.Model.Filter)
{
<td>@this.Html.Partial("Filter", filter)</td>
}
</tr>
</thead>
<tbody>
@foreach (var item in this.Model.Items)
{
<tr>
<td class="text-nowrap p-2">@item.AuftragNr</td>
<td class="text-nowrap p-2">@item.FertigungNr</td>
<td class="text-nowrap p-2">@item.PositionNr</td>
<td class="text-nowrap p-2">@item.SerialNr</td>
<td class="text-nowrap p-2">@item.IdentNr</td>
<td class="text-nowrap p-2">@item.HeId</td>
<td class="text-nowrap p-2">
<a class="text-decoration-none cursor-pointer" href="#@item.HeTestId">
@item.HeTestId
</a>
</td>
<td class="text-nowrap p-2">@item.PcbId</td>
<td class="text-nowrap p-2">@item.Nennweite</td>
<td class="text-nowrap p-2">@item.Baulaenge</td>
<td class="text-nowrap p-2">@item.Typ</td>
<td class="text-nowrap p-2">@item.Druck</td>
<td class="text-nowrap p-2">@item.Temperatur</td>
<td class="text-nowrap p-2">@item.HeLakeRate</td>
<td class="text-nowrap p-2">@item.HeTestPressure</td>
<td class="text-nowrap p-2"><i class="bi bi-bold @(@item.IsValid ? "bi-check text-success" : "bi-x text-danger")"></i></td>
<td class="text-nowrap p-2">@($"{item.TestDate:dd.MM.yyyy}")</td>
<td class="text-nowrap p-2">@item.Tester</td>
<td class="text-nowrap p-2">@item.Text</td>
</tr>
}
</tbody>
</table>
</div>
</form>
<button id="modal_btn" class="d-none" data-bs-toggle="modal" data-bs-target="#modal"></button>
<!-- Modal -->
<div class="modal fade" id="modal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Testergebnisse</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table table-sm table-bordered">
<thead>
<tr>
<th>Test Id</th>
<th>Pint Nr</th>
<th>Result</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
</div>
</div>
</div>
</div>
@section scripts {
<script>
let form = document.getElementById('he_report');
let inputFields = form
.querySelectorAll('input')
.forEach(x => x.onchange = () => form.submit());
let tbody = this.document.getElementById('tbody');
let modalBtn = this.document.getElementById('modal_btn');
window.addEventListener('hashchange', function () {
tbody.innerHTML = null;
if (location.hash) {
let testId = location.hash.substring(1);
if (testId) {
fetch(`/Report/Results?testId=${testId}`)
.then(response => response.text())
.then(function (html) {
tbody.innerHTML = html;
modalBtn.click();
})
.catch(x => console.log(x));
}
}
});
</script>
}
@@ -0,0 +1,10 @@
@model IEnumerable<LaaProductionWeb.Services.Models.HeliumPressurePoint>
@foreach (var item in this.Model)
{
<tr>
<td>@item.TestId</td>
<td>@item.PointNr</td>
<td>@item.Result</td>
</tr>
}
@@ -33,6 +33,9 @@
<li class="nav-item">
<a class="nav-link text-smallcaps" href="/Protocol">Prüfprotokoll</a>
</li>
<li class="nav-item">
<a class="nav-link text-smallcaps" href="/Report">[He] Report</a>
</li>
</ul>
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item">