Implement searching reports from device stats.

This commit is contained in:
2019-11-24 03:08:09 +00:00
parent 2074ad489a
commit ad0ce6344f
5 changed files with 146 additions and 5 deletions

View File

@@ -346,5 +346,17 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
Id = deviceId
});
}
public IActionResult Find(int id, string manufacturer, string model, string revision, string bus)
{
var found = new FindReportModel
{
Id = id, Manufacturer = manufacturer, Model = model, Revision = revision,
Bus = bus,
LikeDevices = _context.Devices.Where(r => r.Model.ToLower().Contains(model.ToLower())).ToList()
};
return View(found);
}
}
}

View File

@@ -1,4 +1,3 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.CommonTypes.Metadata;
@@ -171,9 +170,6 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
bool UploadedReportExists(int id) => _context.Reports.Any(e => e.Id == id);
public IActionResult Find(int id, string manufacturer, string model, string bus) =>
throw new NotImplementedException();
public IActionResult Promote(int? id)
{
if(id == null)

View File

@@ -74,7 +74,7 @@
@if (item.Report is null)
{
@("No")
<a asp-action="Find" asp-controller="Reports" asp-route-id="@item.Id" asp-route-manufacturer="@item.Manufacturer" asp-route-model="@item.Model" asp-route-revision="@item.Revision" asp-route-bus="@item.Bus" target="_blank">(Find)</a>
<a asp-action="Find" asp-controller="Devices" asp-route-id="@item.Id" asp-route-manufacturer="@item.Manufacturer" asp-route-model="@item.Model" asp-route-revision="@item.Revision" asp-route-bus="@item.Bus" target="_blank">(Find)</a>
}
else
{

View File

@@ -0,0 +1,119 @@
@model FindReportModel
@{
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
ViewBag.Title = "DiscImageChef";
}
@{
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Find.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : DiscImageChef Server.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2019 Natalia Portillo
// ****************************************************************************/
}
<div>
<h4>Found device reports with similar data</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Manufacturer)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Manufacturer)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Model)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Model)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Revision)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Revision)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Bus)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Bus)
</dd>
</dl>
</div>
@if (Model.LikeDevices.Count == 0)
{
<div>No device report with similar information has been found!</div>
}
else
{
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.LikeDevices[0].Manufacturer)
</th>
<th>
@Html.DisplayNameFor(model => model.LikeDevices[0].Model)
</th>
<th>
@Html.DisplayNameFor(model => model.LikeDevices[0].Revision)
</th>
<th>
@Html.DisplayNameFor(model => model.LikeDevices[0].CompactFlash)
</th>
<th>
@Html.DisplayNameFor(model => model.LikeDevices[0].Type)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.LikeDevices)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Manufacturer)
</td>
<td>
@Html.DisplayFor(modelItem => item.Model)
</td>
<td>
@Html.DisplayFor(modelItem => item.Revision)
</td>
<td>
@Html.DisplayFor(modelItem => item.CompactFlash)
</td>
<td>
@Html.DisplayFor(modelItem => item.Type)
</td>
<td>
<a asp-action="LinkReports" asp-route-statsId="@Model.Id" asp-route-deviceId="@item.Id" class="btn btn-secondary">Link</a>
</td>
</tr>
}
</tbody>
</table>
}

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace DiscImageChef.Server.Models
{
public class FindReportModel
{
public int Id { get; set; }
public string Manufacturer { get; set; }
public string Model { get; set; }
public string Revision { get; set; }
public string Bus { get; set; }
public List<Device> LikeDevices { get; set; }
}
}