Optimize view of memory by machine admin page.

This commit is contained in:
2019-05-19 23:56:50 +01:00
parent d1cbec9eef
commit b3865f515b
4 changed files with 63 additions and 6 deletions

View File

@@ -31,6 +31,7 @@
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Cicm.Database.Models; using Cicm.Database.Models;
using cicm_web.Areas.Admin.Models;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
@@ -56,7 +57,16 @@ namespace cicm_web.Areas.Admin.Controllers
IIncludableQueryable<MemoryByMachine, Machine> cicmContext = IIncludableQueryable<MemoryByMachine, Machine> cicmContext =
_context.MemoryByMachine.Include(m => m.Machine); _context.MemoryByMachine.Include(m => m.Machine);
return View(await cicmContext.OrderBy(m => m.Machine.Name).ThenBy(m => m.Usage).ThenBy(m => m.Size) return View(await cicmContext.OrderBy(m => m.Machine.Name).ThenBy(m => m.Usage).ThenBy(m => m.Size)
.ThenBy(m => m.Type).ToListAsync()); .ThenBy(m => m.Type)
.Select(m => new MemoryByMachineViewModel
{
Id = m.Id,
Machine = m.Machine.Name,
Size = m.Size,
Speed = m.Speed,
Type = m.Type,
Usage = m.Usage
}).ToListAsync());
} }
// GET: Admin/MemoryByMachines/Details/5 // GET: Admin/MemoryByMachines/Details/5

View File

@@ -0,0 +1,47 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : MemoryByMachine.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Junction between memory and machine.
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/
using System.ComponentModel;
using Cicm.Database;
namespace cicm_web.Areas.Admin.Models
{
public class MemoryByMachineViewModel
{
public long Id;
public MemoryType Type { get; set; }
public MemoryUsage Usage { get; set; }
public long? Size { get; set; }
[DisplayName("Speed (Hz)")]
public double? Speed { get; set; }
public string Machine { get; set; }
}
}

View File

@@ -29,8 +29,8 @@
// Copyright © 2003-2018 Natalia Portillo // Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
} }
@using Cicm.Database.Models @using cicm_web.Areas.Admin.Models
@model IEnumerable<Cicm.Database.Models.MemoryByMachine> @model IEnumerable<cicm_web.Areas.Admin.Models.MemoryByMachineViewModel>
@{ @{
ViewData["Title"] = "Memory by machines (Admin)"; ViewData["Title"] = "Memory by machines (Admin)";
@@ -66,11 +66,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach(MemoryByMachine item in Model) @foreach(MemoryByMachineViewModel item in Model)
{ {
<tr> <tr>
<td> <td>
@Html.DisplayFor(modelItem => item.Machine.Name) @Html.DisplayFor(modelItem => item.Machine)
</td> </td>
<td> <td>
@Html.DisplayFor(modelItem => item.Usage) @Html.DisplayFor(modelItem => item.Usage)

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp2.2</TargetFramework>
<Version>3.0.99.538</Version> <Version>3.0.99.539</Version>
<Company>Canary Islands Computer Museum</Company> <Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright> <Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product> <Product>Canary Islands Computer Museum Website</Product>