mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Implement index admin page for screens by machine.
This commit is contained in:
@@ -28,7 +28,6 @@
|
|||||||
// Copyright © 2003-2018 Natalia Portillo
|
// Copyright © 2003-2018 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System.ComponentModel;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Cicm.Database.Models
|
namespace Cicm.Database.Models
|
||||||
@@ -40,7 +39,6 @@ namespace Cicm.Database.Models
|
|||||||
[Remote("VerifyUnique", "ScreensByMachine", "Admin", AdditionalFields = nameof(ScreenId))]
|
[Remote("VerifyUnique", "ScreensByMachine", "Admin", AdditionalFields = nameof(ScreenId))]
|
||||||
public int MachineId { get; set; }
|
public int MachineId { get; set; }
|
||||||
|
|
||||||
[DisplayName("GPU")]
|
|
||||||
public virtual Screen Screen { get; set; }
|
public virtual Screen Screen { get; set; }
|
||||||
public virtual Machine Machine { get; set; }
|
public virtual Machine Machine { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,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;
|
||||||
@@ -25,7 +26,14 @@ namespace cicm_web.Areas.Admin.Controllers
|
|||||||
{
|
{
|
||||||
IIncludableQueryable<ScreensByMachine, Screen> cicmContext =
|
IIncludableQueryable<ScreensByMachine, Screen> cicmContext =
|
||||||
_context.ScreensByMachine.Include(s => s.Machine).Include(s => s.Screen);
|
_context.ScreensByMachine.Include(s => s.Machine).Include(s => s.Screen);
|
||||||
return View(await cicmContext.ToListAsync());
|
return View(await cicmContext.Select(s => new ScreensByMachineViewModel
|
||||||
|
{
|
||||||
|
Id = s.Id,
|
||||||
|
Screen = s.Screen.NativeResolution != null
|
||||||
|
? $"{s.Screen.Diagonal}\" {s.Screen.Type} with {s.Screen.NativeResolution}"
|
||||||
|
: $"{s.Screen.Diagonal}\" {s.Screen}",
|
||||||
|
Machine = $"{s.Machine.Company.Name} {s.Machine.Name}"
|
||||||
|
}).OrderBy(s => s.Machine).ThenBy(s => s.Screen).ToListAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: ScreensByMachine/Details/5
|
// GET: ScreensByMachine/Details/5
|
||||||
|
|||||||
38
cicm_web/Areas/Admin/Models/ScreensByMachineViewModel.cs
Normal file
38
cicm_web/Areas/Admin/Models/ScreensByMachineViewModel.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : GpusByMachine.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Junction betweeen GPU 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
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
namespace cicm_web.Areas.Admin.Models
|
||||||
|
{
|
||||||
|
public class ScreensByMachineViewModel : BaseViewModel<long>
|
||||||
|
{
|
||||||
|
public string Machine;
|
||||||
|
public string Screen;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,3 +44,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<a asp-action="Index">Back to List</a>
|
<a asp-action="Index">Back to List</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||||
|
}
|
||||||
@@ -52,3 +52,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<a asp-action="Index">Back to List</a>
|
<a asp-action="Index">Back to List</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||||
|
}
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
@using Cicm.Database.Models
|
@using cicm_web.Areas.Admin.Models
|
||||||
@model IEnumerable<Cicm.Database.Models.ScreensByMachine>
|
@model IEnumerable<cicm_web.Areas.Admin.Models.ScreensByMachineViewModel>
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Index";
|
ViewData["Title"] = "Index";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h1>Index</h1>
|
<h1>Screens by machine</h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a asp-action="Create">Create New</a>
|
<a asp-action="Create"
|
||||||
|
class="btn btn-primary">
|
||||||
|
Create New
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -23,26 +26,29 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach(ScreensByMachine item in Model)
|
@foreach(ScreensByMachineViewModel item in Model)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Screen.Type)
|
@Html.DisplayFor(modelItem => item.Screen)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Machine.Name)
|
@Html.DisplayFor(modelItem => item.Machine)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="Edit"
|
|
||||||
asp-route-id="@item.Id">
|
|
||||||
Edit
|
|
||||||
</a> |
|
|
||||||
<a asp-action="Details"
|
<a asp-action="Details"
|
||||||
asp-route-id="@item.Id">
|
asp-route-id="@item.Id"
|
||||||
|
class="btn btn-primary">
|
||||||
Details
|
Details
|
||||||
</a> |
|
</a>
|
||||||
|
<a asp-action="Edit"
|
||||||
|
asp-route-id="@item.Id"
|
||||||
|
class="btn btn-secondary">
|
||||||
|
Edit
|
||||||
|
</a>
|
||||||
<a asp-action="Delete"
|
<a asp-action="Delete"
|
||||||
asp-route-id="@item.Id">
|
asp-route-id="@item.Id"
|
||||||
|
class="btn btn-danger">
|
||||||
Delete
|
Delete
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -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.742</Version>
|
<Version>3.0.99.744</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>
|
||||||
|
|||||||
Reference in New Issue
Block a user