Show similar device and uploaded reports in uploaded report details.

This commit is contained in:
2019-11-23 19:24:03 +00:00
parent 9d96795ab1
commit 37a2ee0b37
3 changed files with 178 additions and 19 deletions

View File

@@ -28,14 +28,39 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
return NotFound();
}
UploadedReport uploadedReport = await _context.Reports.FirstOrDefaultAsync(m => m.Id == id);
var model = new UploadedReportDetails
{
Report = await _context.Reports.FirstOrDefaultAsync(m => m.Id == id)
};
if(uploadedReport == null)
if(model.Report is null)
{
return NotFound();
}
return View(uploadedReport);
model.ReportAll = _context.
Devices.Where(d => d.Manufacturer == model.Report.Manufacturer &&
d.Model == model.Report.Model &&
d.Revision == model.Report.Revision).
Select(d => d.Id).ToList();
model.ReportButManufacturer = _context.
Devices.Where(d => d.Model == model.Report.Model &&
d.Revision == model.Report.Revision).Select(d => d.Id).
Where(d => model.ReportAll.All(r => r != d)).ToList();
model.SameAll = _context.
Reports.Where(d => d.Manufacturer == model.Report.Manufacturer &&
d.Model == model.Report.Model &&
d.Revision == model.Report.Revision &&
d.Id != id).Select(d => d.Id).ToList();
model.SameButManufacturer = _context.
Reports.Where(d => d.Model == model.Report.Model &&
d.Revision == model.Report.Revision && d.Id != id).
Select(d => d.Id).Where(d => model.SameAll.All(r => r != d)).ToList();
return View(model);
}
// GET: Admin/Reports/Edit/5

View File

@@ -1,52 +1,173 @@
@model UploadedReport
@model UploadedReportDetails
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>UploadedReport</h4>
<h4>Uploaded report</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.UploadedWhen)
@Html.DisplayNameFor(model => model.Report.UploadedWhen)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.UploadedWhen)
@Html.DisplayFor(model => model.Report.UploadedWhen)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.CompactFlash)
@Html.DisplayNameFor(model => model.Report.Manufacturer)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.CompactFlash)
@Html.DisplayFor(model => model.Report.Manufacturer)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Manufacturer)
@Html.DisplayNameFor(model => model.Report.Model)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Manufacturer)
@Html.DisplayFor(model => model.Report.Model)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Model)
@Html.DisplayNameFor(model => model.Report.Revision)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Model)
@Html.DisplayFor(model => model.Report.Revision)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Revision)
@Html.DisplayNameFor(model => model.Report.CompactFlash)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Revision)
@Html.DisplayFor(model => model.Report.CompactFlash)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Type)
@Html.DisplayNameFor(model => model.Report.Type)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Type)
@Html.DisplayFor(model => model.Report.Type)
</dd>
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">Edit</a>
<a asp-action="Edit" asp-route-id="@Model.Report.Id" class="btn btn-primary">Edit</a>
<a asp-action="Promote" asp-route-id="@Model.Report.Id" class="btn btn-secondary">Promote</a>
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
</div>
</div>
@if (Model.SameAll.Count > 0)
{
<div>
<h4>Other uploaded reports with same manufacturer, model and revision:</h4>
<table class="table">
<thead>
<tr>
<th>
Id
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.SameAll)
{
<tr>
<td>
@item
</td>
<td>
<a asp-action="Details" asp-route-id="@item" class="btn btn-primary" target="_blank">Details</a>
<a asp-action="Merge" asp-route-slave="@item" asp-route-master="@Model.Report.Id" class="btn btn-secondary">Merge</a>
</td>
</tr>
}
</tbody>
</table>
</div>
}
@if (Model.SameButManufacturer.Count > 0)
{
<div>
<h4>Other uploaded reports with same model and revision:</h4>
<table class="table">
<thead>
<tr>
<th>
Id
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.SameButManufacturer)
{
<tr>
<td>
@item
</td>
<td>
<a asp-action="Details" asp-route-id="@item" class="btn btn-primary" target="_blank">Details</a>
<a asp-action="Merge" asp-route-slave="@item" asp-route-master="@Model.Report.Id" class="btn btn-secondary">Merge</a>
</td>
</tr>
}
</tbody>
</table>
</div>
}
@if (Model.ReportAll.Count > 0)
{
<div>
<h4>Device reports with same manufacturer, model and revision:</h4>
<table class="table">
<thead>
<tr>
<th>
Id
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.ReportAll)
{
<tr>
<td>
@item
</td>
<td>
<a asp-controller="Devices" asp-action="Details" asp-route-id="@item" class="btn btn-primary" target="_blank">Details</a>
<a asp-controller="Devices" asp-action="MergeReports" asp-route-deviceId="@item" asp-route-reportId="@Model.Report.Id" class="btn btn-secondary">Merge</a>
</td>
</tr>
}
</tbody>
</table>
</div>
}
@if (Model.ReportButManufacturer.Count > 0)
{
<div>
<h4>Device reports with same model and revision:</h4>
<table class="table">
<thead>
<tr>
<th>
Id
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.ReportButManufacturer)
{
<tr>
<td>
@item
</td>
<td>
<a asp-controller="Devices" asp-action="Details" asp-route-id="@item" class="btn btn-primary" target="_blank">Details</a>
<a asp-controller="Devices" asp-action="MergeReports" asp-route-deviceId="@item" asp-route-reportId="@Model.Report.Id" class="btn btn-secondary">Merge</a>
</td>
</tr>
}
</tbody>
</table>
</div>
}

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace DiscImageChef.Server.Models
{
public class UploadedReportDetails
{
public UploadedReport Report { get; set; }
public List<int> SameAll { get; set; }
public List<int> SameButManufacturer { get; set; }
public List<int> ReportAll { get; set; }
public List<int> ReportButManufacturer { get; set; }
}
}