mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Sort in GPUs by machine admin pages.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Cicm.Database.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
|
||||
namespace cicm_web.Areas.Admin.Controllers
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
[Authorize]
|
||||
public class GpusByMachineController : Controller
|
||||
{
|
||||
private readonly cicmContext _context;
|
||||
readonly cicmContext _context;
|
||||
|
||||
public GpusByMachineController(cicmContext context)
|
||||
{
|
||||
@@ -23,26 +23,20 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
// GET: GpusByMachine
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var cicmContext = _context.GpusByMachine.Include(g => g.Gpu).Include(g => g.Machine);
|
||||
IIncludableQueryable<GpusByMachine, Machine> cicmContext =
|
||||
_context.GpusByMachine.Include(g => g.Gpu).Include(g => g.Machine);
|
||||
return View(await cicmContext.OrderBy(g => g.Machine.Name).ThenBy(g => g.Gpu.Name).ToListAsync());
|
||||
}
|
||||
|
||||
// GET: GpusByMachine/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
if(id == null) return NotFound();
|
||||
|
||||
var gpusByMachine = await _context.GpusByMachine
|
||||
.Include(g => g.Gpu)
|
||||
.Include(g => g.Machine)
|
||||
GpusByMachine gpusByMachine = await _context.GpusByMachine
|
||||
.Include(g => g.Gpu).Include(g => g.Machine)
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
if (gpusByMachine == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
if(gpusByMachine == null) return NotFound();
|
||||
|
||||
return View(gpusByMachine);
|
||||
}
|
||||
@@ -50,8 +44,8 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
// GET: GpusByMachine/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewData["GpuId"] = new SelectList(_context.Gpus, "Id", "Name");
|
||||
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name");
|
||||
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name");
|
||||
ViewData["MachineId"] = new SelectList(_context.Machines.OrderBy(m => m.Name), "Id", "Name");
|
||||
return View();
|
||||
}
|
||||
|
||||
@@ -68,26 +62,24 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
ViewData["GpuId"] = new SelectList(_context.Gpus, "Id", "Name", gpusByMachine.GpuId);
|
||||
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", gpusByMachine.MachineId);
|
||||
|
||||
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name", gpusByMachine.GpuId);
|
||||
ViewData["MachineId"] =
|
||||
new SelectList(_context.Machines.OrderBy(m => m.Name), "Id", "Name", gpusByMachine.MachineId);
|
||||
return View(gpusByMachine);
|
||||
}
|
||||
|
||||
// GET: GpusByMachine/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
if(id == null) return NotFound();
|
||||
|
||||
var gpusByMachine = await _context.GpusByMachine.FindAsync(id);
|
||||
if (gpusByMachine == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["GpuId"] = new SelectList(_context.Gpus, "Id", "Name", gpusByMachine.GpuId);
|
||||
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", gpusByMachine.MachineId);
|
||||
GpusByMachine gpusByMachine = await _context.GpusByMachine.FindAsync(id);
|
||||
if(gpusByMachine == null) return NotFound();
|
||||
|
||||
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name", gpusByMachine.GpuId);
|
||||
ViewData["MachineId"] =
|
||||
new SelectList(_context.Machines.OrderBy(m => m.Name), "Id", "Name", gpusByMachine.MachineId);
|
||||
return View(gpusByMachine);
|
||||
}
|
||||
|
||||
@@ -98,10 +90,7 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(long id, [Bind("GpuId,MachineId,Id")] GpusByMachine gpusByMachine)
|
||||
{
|
||||
if (id != gpusByMachine.Id)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
if(id != gpusByMachine.Id) return NotFound();
|
||||
|
||||
if(ModelState.IsValid)
|
||||
{
|
||||
@@ -112,54 +101,46 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
}
|
||||
catch(DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!GpusByMachineExists(gpusByMachine.Id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!GpusByMachineExists(gpusByMachine.Id)) return NotFound();
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
ViewData["GpuId"] = new SelectList(_context.Gpus, "Id", "Name", gpusByMachine.GpuId);
|
||||
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", gpusByMachine.MachineId);
|
||||
|
||||
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name", gpusByMachine.GpuId);
|
||||
ViewData["MachineId"] =
|
||||
new SelectList(_context.Machines.OrderBy(m => m.Name), "Id", "Name", gpusByMachine.MachineId);
|
||||
return View(gpusByMachine);
|
||||
}
|
||||
|
||||
// GET: GpusByMachine/Delete/5
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
if(id == null) return NotFound();
|
||||
|
||||
var gpusByMachine = await _context.GpusByMachine
|
||||
.Include(g => g.Gpu)
|
||||
.Include(g => g.Machine)
|
||||
GpusByMachine gpusByMachine = await _context.GpusByMachine
|
||||
.Include(g => g.Gpu).Include(g => g.Machine)
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
if (gpusByMachine == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
if(gpusByMachine == null) return NotFound();
|
||||
|
||||
return View(gpusByMachine);
|
||||
}
|
||||
|
||||
// POST: GpusByMachine/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[HttpPost]
|
||||
[ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
var gpusByMachine = await _context.GpusByMachine.FindAsync(id);
|
||||
GpusByMachine gpusByMachine = await _context.GpusByMachine.FindAsync(id);
|
||||
_context.GpusByMachine.Remove(gpusByMachine);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
private bool GpusByMachineExists(long id)
|
||||
bool GpusByMachineExists(long id)
|
||||
{
|
||||
return _context.GpusByMachine.Any(e => e.Id == id);
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Create">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Gpu" class="control-label"></label>
|
||||
<select asp-for="GpuId" class ="form-control" asp-items="ViewBag.GpuId"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Machine" class="control-label"></label>
|
||||
<select asp-for="MachineId" class ="form-control" asp-items="ViewBag.MachineId"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Gpu" class="control-label"></label>
|
||||
<select asp-for="GpuId" class ="form-control" asp-items="ViewBag.GpuId"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Create" class="btn btn-primary" />
|
||||
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
|
||||
|
||||
@@ -11,18 +11,18 @@
|
||||
<h4>GPU by machine</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Gpu)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Gpu.Name)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Machine)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Machine.Name)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Gpu)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Gpu.Name)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
|
||||
@@ -10,18 +10,18 @@
|
||||
<h4>GPU by machine</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Gpu)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Gpu.Name)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Machine)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Machine.Name)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Gpu)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Gpu.Name)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -12,16 +12,16 @@
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Edit">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Gpu" class="control-label"></label>
|
||||
<select asp-for="GpuId" class="form-control" asp-items="ViewBag.GpuId"></select>
|
||||
<span asp-validation-for="GpuId" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Machine" class="control-label"></label>
|
||||
<select asp-for="MachineId" class="form-control" asp-items="ViewBag.MachineId"></select>
|
||||
<span asp-validation-for="MachineId" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Gpu" class="control-label"></label>
|
||||
<select asp-for="GpuId" class="form-control" asp-items="ViewBag.GpuId"></select>
|
||||
<span asp-validation-for="GpuId" class="text-danger"></span>
|
||||
</div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Gpu)
|
||||
@Html.DisplayNameFor(model => model.Machine)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Machine)
|
||||
@Html.DisplayNameFor(model => model.Gpu)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@@ -25,10 +25,10 @@
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Gpu.Name)
|
||||
@Html.DisplayFor(modelItem => item.Machine.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Machine.Name)
|
||||
@Html.DisplayFor(modelItem => item.Gpu.Name)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-primary">Details</a>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.517</Version>
|
||||
<Version>3.0.99.518</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
Reference in New Issue
Block a user