Add resolutions to admin view.

This commit is contained in:
2020-05-30 04:36:31 +01:00
parent ae2007cae0
commit 8ce6361b26
41 changed files with 1518 additions and 1450 deletions

View File

@@ -1,206 +0,0 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin"), Authorize]
public class ResolutionsByGpuController : Controller
{
readonly MarechaiContext _context;
public ResolutionsByGpuController(MarechaiContext context) => _context = context;
// GET: ResolutionsByGpu
public async Task<IActionResult> Index()
{
IIncludableQueryable<ResolutionsByGpu, Resolution> marechaiContext =
_context.ResolutionsByGpu.Include(r => r.Gpu).Include(r => r.Resolution);
return View(await marechaiContext.OrderBy(r => r.Gpu.Company.Name).ThenBy(r => r.Gpu.Name).
ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Width).
ThenBy(r => r.Resolution.Height).ThenBy(r => r.Resolution.Colors).
Select(r => new ResolutionsByGpuViewModel
{
Gpu = r.Gpu.Name, GpuCompany = r.Gpu.Company.Name, Id = r.Id,
Resolution = r.Resolution
}).ToListAsync());
}
// GET: ResolutionsByGpu/Details/5
public async Task<IActionResult> Details(long? id)
{
if(id == null)
return NotFound();
ResolutionsByGpu resolutionsByGpu = await _context.
ResolutionsByGpu.Include(r => r.Gpu).Include(r => r.Resolution).
FirstOrDefaultAsync(m => m.Id == id);
if(resolutionsByGpu == null)
return NotFound();
return View(resolutionsByGpu);
}
// GET: ResolutionsByGpu/Create
public IActionResult Create()
{
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(r => r.Company.Name).ThenBy(r => r.Name).
Select(g => new
{
g.Id, Name = $"{g.Company.Name} {g.Name}"
}), "Id", "Name");
ViewData["ResolutionId"] = new SelectList(_context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).
ThenBy(r => r.Height).ThenBy(r => r.Colors).
Select(r => new
{
r.Id, Name = r.ToString()
}), "Id", "Name");
return View();
}
// POST: ResolutionsByGpu/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("GpuId,ResolutionId,Id")] ResolutionsByGpu resolutionsByGpu)
{
if(ModelState.IsValid)
{
_context.Add(resolutionsByGpu);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(r => r.Company.Name).ThenBy(r => r.Name).
Select(g => new
{
g.Id, Name = $"{g.Company.Name} {g.Name}"
}), "Id", "Name", resolutionsByGpu.GpuId);
ViewData["ResolutionId"] = new SelectList(_context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).
ThenBy(r => r.Height).ThenBy(r => r.Colors).
Select(r => new
{
r.Id, Name = r.ToString()
}), "Id", "Name", resolutionsByGpu.ResolutionId);
return View(resolutionsByGpu);
}
// GET: ResolutionsByGpu/Edit/5
public async Task<IActionResult> Edit(long? id)
{
if(id == null)
return NotFound();
ResolutionsByGpu resolutionsByGpu = await _context.ResolutionsByGpu.FindAsync(id);
if(resolutionsByGpu == null)
return NotFound();
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(r => r.Company.Name).ThenBy(r => r.Name).
Select(g => new
{
g.Id, Name = $"{g.Company.Name} {g.Name}"
}), "Id", "Name", resolutionsByGpu.GpuId);
ViewData["ResolutionId"] = new SelectList(_context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).
ThenBy(r => r.Height).ThenBy(r => r.Colors).
Select(r => new
{
r.Id, Name = r.ToString()
}), "Id", "Name", resolutionsByGpu.ResolutionId);
return View(resolutionsByGpu);
}
// POST: ResolutionsByGpu/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
long id, [Bind("GpuId,ResolutionId,Id")] ResolutionsByGpu resolutionsByGpu)
{
if(id != resolutionsByGpu.Id)
return NotFound();
if(ModelState.IsValid)
{
try
{
_context.Update(resolutionsByGpu);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!ResolutionsByGpuExists(resolutionsByGpu.Id))
return NotFound();
throw;
}
return RedirectToAction(nameof(Index));
}
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(r => r.Company.Name).ThenBy(r => r.Name).
Select(g => new
{
g.Id, Name = $"{g.Company.Name} {g.Name}"
}), "Id", "Name", resolutionsByGpu.GpuId);
ViewData["ResolutionId"] = new SelectList(_context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).
ThenBy(r => r.Height).ThenBy(r => r.Colors).
Select(r => new
{
r.Id, Name = r.ToString()
}), "Id", "Name", resolutionsByGpu.ResolutionId);
return View(resolutionsByGpu);
}
// GET: ResolutionsByGpu/Delete/5
public async Task<IActionResult> Delete(long? id)
{
if(id == null)
return NotFound();
ResolutionsByGpu resolutionsByGpu = await _context.
ResolutionsByGpu.Include(r => r.Gpu).Include(r => r.Resolution).
FirstOrDefaultAsync(m => m.Id == id);
if(resolutionsByGpu == null)
return NotFound();
return View(resolutionsByGpu);
}
// POST: ResolutionsByGpu/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(long id)
{
ResolutionsByGpu resolutionsByGpu = await _context.ResolutionsByGpu.FindAsync(id);
_context.ResolutionsByGpu.Remove(resolutionsByGpu);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool ResolutionsByGpuExists(long id) => _context.ResolutionsByGpu.Any(e => e.Id == id);
[AcceptVerbs("Get", "Post")]
public async Task<IActionResult> VerifyUnique(int gpuId, int resolutionId) =>
await _context.ResolutionsByGpu.FirstOrDefaultAsync(i => i.GpuId == gpuId && i.ResolutionId == resolutionId)
is null ? Json(true) : Json("The selected GPU already has the selected resolution.");
}
}

View File

@@ -1,197 +0,0 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin"), Authorize]
public class ResolutionsByScreenController : Controller
{
readonly MarechaiContext _context;
public ResolutionsByScreenController(MarechaiContext context) => _context = context;
// GET: ResolutionsByScreen
public async Task<IActionResult> Index()
{
IIncludableQueryable<ResolutionsByScreen, Screen> marechaiContext =
_context.ResolutionsByScreen.Include(r => r.Resolution).Include(r => r.Screen);
return View(await marechaiContext.OrderBy(r => r.Screen.ToString()).ThenBy(r => r.Resolution.ToString()).
ToListAsync());
}
// GET: ResolutionsByScreen/Details/5
public async Task<IActionResult> Details(long? id)
{
if(id == null)
return NotFound();
ResolutionsByScreen resolutionsByScreen =
await _context.ResolutionsByScreen.Include(r => r.Resolution).Include(r => r.Screen).
FirstOrDefaultAsync(m => m.Id == id);
if(resolutionsByScreen == null)
return NotFound();
return View(resolutionsByScreen);
}
// GET: ResolutionsByScreen/Create
public IActionResult Create()
{
ViewData["ResolutionId"] = new SelectList(_context.Resolutions.Select(r => new
{
r.Id, Name = r.ToString()
}).OrderBy(r => r.Name), "Id", "Name");
ViewData["ScreenId"] = new SelectList(_context.Screens.Select(s => new
{
s.Id,
Name = s.NativeResolution != null ? $"{s.Diagonal}\" {s.Type} with {s.NativeResolution}"
: $"{s.Diagonal}\" {s.Type}"
}).OrderBy(s => s.Name), "Id", "Name");
return View();
}
// POST: ResolutionsByScreen/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create(
[Bind("ScreenId,ResolutionId,Id")] ResolutionsByScreen resolutionsByScreen)
{
if(ModelState.IsValid)
{
_context.Add(resolutionsByScreen);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["ResolutionId"] = new SelectList(_context.Resolutions.Select(r => new
{
r.Id, Name = r.ToString()
}).OrderBy(r => r.Name), "Id", "Name", resolutionsByScreen.ResolutionId);
ViewData["ScreenId"] = new SelectList(_context.Screens.Select(s => new
{
s.Id,
Name = s.NativeResolution != null ? $"{s.Diagonal}\" {s.Type} with {s.NativeResolution}"
: $"{s.Diagonal}\" {s.Type}"
}).OrderBy(s => s.Name), "Id", "Name", resolutionsByScreen.ScreenId);
return View(resolutionsByScreen);
}
// GET: ResolutionsByScreen/Edit/5
public async Task<IActionResult> Edit(long? id)
{
if(id == null)
return NotFound();
ResolutionsByScreen resolutionsByScreen = await _context.ResolutionsByScreen.FindAsync(id);
if(resolutionsByScreen == null)
return NotFound();
ViewData["ResolutionId"] = new SelectList(_context.Resolutions.Select(r => new
{
r.Id, Name = r.ToString()
}).OrderBy(r => r.Name), "Id", "Name", resolutionsByScreen.ResolutionId);
ViewData["ScreenId"] = new SelectList(_context.Screens.Select(s => new
{
s.Id,
Name = s.NativeResolution != null ? $"{s.Diagonal}\" {s.Type} with {s.NativeResolution}"
: $"{s.Diagonal}\" {s.Type}"
}).OrderBy(s => s.Name), "Id", "Name", resolutionsByScreen.ScreenId);
return View(resolutionsByScreen);
}
// POST: ResolutionsByScreen/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
long id, [Bind("ScreenId,ResolutionId,Id")] ResolutionsByScreen resolutionsByScreen)
{
if(id != resolutionsByScreen.Id)
return NotFound();
if(ModelState.IsValid)
{
try
{
_context.Update(resolutionsByScreen);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!ResolutionsByScreenExists(resolutionsByScreen.Id))
return NotFound();
throw;
}
return RedirectToAction(nameof(Index));
}
ViewData["ResolutionId"] = new SelectList(_context.Resolutions.Select(r => new
{
r.Id, Name = r.ToString()
}).OrderBy(r => r.Name), "Id", "Name", resolutionsByScreen.ResolutionId);
ViewData["ScreenId"] = new SelectList(_context.Screens.Select(s => new
{
s.Id,
Name = s.NativeResolution != null ? $"{s.Diagonal}\" {s.Type} with {s.NativeResolution}"
: $"{s.Diagonal}\" {s.Type}"
}).OrderBy(s => s.Name), "Id", "Name", resolutionsByScreen.ScreenId);
return View(resolutionsByScreen);
}
// GET: ResolutionsByScreen/Delete/5
public async Task<IActionResult> Delete(long? id)
{
if(id == null)
return NotFound();
ResolutionsByScreen resolutionsByScreen =
await _context.ResolutionsByScreen.Include(r => r.Resolution).Include(r => r.Screen).
FirstOrDefaultAsync(m => m.Id == id);
if(resolutionsByScreen == null)
return NotFound();
return View(resolutionsByScreen);
}
// POST: ResolutionsByScreen/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(long id)
{
ResolutionsByScreen resolutionsByScreen = await _context.ResolutionsByScreen.FindAsync(id);
_context.ResolutionsByScreen.Remove(resolutionsByScreen);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool ResolutionsByScreenExists(long id) => _context.ResolutionsByScreen.Any(e => e.Id == id);
[AcceptVerbs("Get", "Post")]
public async Task<IActionResult> VerifyUnique(int screenId, int resolutionId) =>
await _context.ResolutionsByScreen.FirstOrDefaultAsync(i => i.ScreenId == screenId &&
i.ResolutionId == resolutionId) is null
? Json(true) : Json("The selected screen already has the selected resolution.");
}
}

View File

@@ -1,159 +0,0 @@
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : ResolutionsController.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Resolutions admin controller
//
// --[ 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-2020 Natalia Portillo
*******************************************************************************/
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin"), Authorize]
public class ResolutionsController : Controller
{
readonly MarechaiContext _context;
public ResolutionsController(MarechaiContext context) => _context = context;
// GET: Admin/Resolutions
public async Task<IActionResult> Index() =>
View(await _context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).ThenBy(r => r.Height).
ThenBy(r => r.Colors).ThenBy(r => r.Grayscale).ToListAsync());
// GET: Admin/Resolutions/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
return NotFound();
Resolution resolution = await _context.Resolutions.FirstOrDefaultAsync(m => m.Id == id);
if(resolution == null)
return NotFound();
return View(resolution);
}
// GET: Admin/Resolutions/Create
public IActionResult Create() => View();
// POST: Admin/Resolutions/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,Width,Height,Colors,Palette,Chars,Grayscale")]
Resolution resolution)
{
if(ModelState.IsValid)
{
_context.Add(resolution);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(resolution);
}
// GET: Admin/Resolutions/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
return NotFound();
Resolution resolution = await _context.Resolutions.FindAsync(id);
if(resolution == null)
return NotFound();
return View(resolution);
}
// POST: Admin/Resolutions/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Width,Height,Colors,Palette,Chars,Grayscale")]
Resolution resolution)
{
if(id != resolution.Id)
return NotFound();
if(ModelState.IsValid)
{
try
{
_context.Update(resolution);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!ResolutionExists(resolution.Id))
return NotFound();
throw;
}
return RedirectToAction(nameof(Index));
}
return View(resolution);
}
// GET: Admin/Resolutions/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
return NotFound();
Resolution resolution = await _context.Resolutions.FirstOrDefaultAsync(m => m.Id == id);
if(resolution == null)
return NotFound();
return View(resolution);
}
// POST: Admin/Resolutions/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Resolution resolution = await _context.Resolutions.FindAsync(id);
_context.Resolutions.Remove(resolution);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool ResolutionExists(int id) => _context.Resolutions.Any(e => e.Id == id);
}
}

View File

@@ -1,99 +0,0 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Create.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Admin view create
//
// --[ 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-2020 Natalia Portillo
*******************************************************************************/
}
@model Marechai.Database.Models.Resolution
@{
ViewData["Title"] = "Create";
}
<h2>Create</h2>
<h4>Resolution</h4>
<hr />
<div class="row">
<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="Width" class="control-label">
</label>
<input asp-for="Width" class="form-control" />
<span asp-validation-for="Width" class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Height" class="control-label">
</label>
<input asp-for="Height" class="form-control" />
<span asp-validation-for="Height" class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Colors" class="control-label">
</label>
<input asp-for="Colors" class="form-control" />
<span asp-validation-for="Colors" class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Palette" class="control-label">
</label>
<input asp-for="Palette" class="form-control" />
<span asp-validation-for="Palette" class="text-danger">
</span>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input asp-for="Chars" /> @Html.DisplayNameFor(model => model.Chars)
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input asp-for="Grayscale" /> @Html.DisplayNameFor(model => model.Grayscale)
</label>
</div>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" value="Create" />
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</div>
</form>
</div>
</div>
@section Scripts {
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@@ -1,87 +0,0 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Delete.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Admin view delete
//
// --[ 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-2020 Natalia Portillo
*******************************************************************************/
}
@model Marechai.Database.Models.Resolution
@{
ViewData["Title"] = "Delete";
}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Resolution</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Width)
</dt>
<dd>
@Html.DisplayFor(model => model.Width)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Height)
</dt>
<dd>
@Html.DisplayFor(model => model.Height)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Colors)
</dt>
<dd>
@Html.DisplayFor(model => model.Colors)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Palette)
</dt>
<dd>
@Html.DisplayFor(model => model.Palette)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Chars)
</dt>
<dd>
@Html.DisplayFor(model => model.Chars)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Grayscale)
</dt>
<dd>
@Html.DisplayFor(model => model.Grayscale)
</dd>
</dl>
<form asp-action="Delete">
<input type="hidden" asp-for="Id" />
<input class="btn btn-danger" type="submit" value="Delete" />
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</form>
</div>

View File

@@ -1,87 +0,0 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Details.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Admin view details
//
// --[ 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-2020 Natalia Portillo
*******************************************************************************/
}
@model Marechai.Database.Models.Resolution
@{
ViewData["Title"] = "Details";
}
<h2>Details</h2>
<div>
<h4>Resolution</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Width)
</dt>
<dd>
@Html.DisplayFor(model => model.Width)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Height)
</dt>
<dd>
@Html.DisplayFor(model => model.Height)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Colors)
</dt>
<dd>
@Html.DisplayFor(model => model.Colors)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Palette)
</dt>
<dd>
@Html.DisplayFor(model => model.Palette)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Chars)
</dt>
<dd>
@Html.DisplayFor(model => model.Chars)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Grayscale)
</dt>
<dd>
@Html.DisplayFor(model => model.Grayscale)
</dd>
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">
Edit
</a>
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</div>

View File

@@ -1,100 +0,0 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Edit.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Admin view edit
//
// --[ 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-2020 Natalia Portillo
*******************************************************************************/
}
@model Marechai.Database.Models.Resolution
@{
ViewData["Title"] = "Edit";
}
<h2>Edit</h2>
<h4>Resolution</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger">
</div>
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="Width" class="control-label">
</label>
<input asp-for="Width" class="form-control" />
<span asp-validation-for="Width" class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Height" class="control-label">
</label>
<input asp-for="Height" class="form-control" />
<span asp-validation-for="Height" class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Colors" class="control-label">
</label>
<input asp-for="Colors" class="form-control" />
<span asp-validation-for="Colors" class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Palette" class="control-label">
</label>
<input asp-for="Palette" class="form-control" />
<span asp-validation-for="Palette" class="text-danger">
</span>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input asp-for="Chars" /> @Html.DisplayNameFor(model => model.Chars)
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input asp-for="Grayscale" /> @Html.DisplayNameFor(model => model.Grayscale)
</label>
</div>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" value="Save" />
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</div>
</form>
</div>
</div>
@section Scripts {
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@@ -1,73 +0,0 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Index.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Admin view index
//
// --[ 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-2020 Natalia Portillo
*******************************************************************************/
}
@model IEnumerable<Marechai.Database.Models.Resolution>
@{
ViewData["Title"] = "Resolutions (Admin)";
}
<h2>Resolutions</h2>
<p>
<a asp-action="Create" class="btn btn-primary">
Create new
</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Resolution
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@item.ToString()
</td>
<td>
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-primary">
Details
</a>
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-secondary">
Edit
</a>
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">
Delete
</a>
</td>
</tr>
}
</tbody>
</table>

View File

@@ -1,38 +0,0 @@
@model Marechai.Database.Models.ResolutionsByGpu
@{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>Resolutions by GPU</h4>
<hr />
<div class="row">
<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>
<span asp-validation-for="GpuId" class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Resolution" class="control-label">
</label>
<select asp-for="ResolutionId" class="form-control" asp-items="ViewBag.ResolutionId">
</select>
<span asp-validation-for="ResolutionId" class="text-danger">
</span>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" value="Create" />
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</div>
</form>
</div>
</div>

View File

@@ -1,32 +0,0 @@
@model Marechai.Database.Models.ResolutionsByGpu
@{
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Resolution by GPU</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.Resolution)
</dt>
<dd class="col-sm-10">
@Model.Resolution.ToString()
</dd>
</dl>
<form asp-action="Delete">
<input type="hidden" asp-for="Id" />
<input class="btn btn-danger" type="submit" value="Delete" />
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</form>
</div>

View File

@@ -1,32 +0,0 @@
@model Marechai.Database.Models.ResolutionsByGpu
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>Resolution by GPU</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.Resolution)
</dt>
<dd class="col-sm-10">
@Model.Resolution.ToString()
</dd>
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">
Edit
</a>
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</div>

View File

@@ -1,39 +0,0 @@
@model Marechai.Database.Models.ResolutionsByGpu
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>Resolution by GPU</h4>
<hr />
<div class="row">
<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="GpuId" 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="ResolutionId" class="control-label">
</label>
<select asp-for="ResolutionId" class="form-control" asp-items="ViewBag.ResolutionId">
</select>
<span asp-validation-for="ResolutionId" class="text-danger">
</span>
</div>
<input type="hidden" asp-for="Id" />
<div class="form-group">
<input class="btn btn-primary" type="submit" value="Save" />
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</div>
</form>
</div>
</div>

View File

@@ -1,49 +0,0 @@
@model IEnumerable<Marechai.Areas.Admin.Models.ResolutionsByGpuViewModel>
@{
ViewData["Title"] = "Index";
}
<h1>Resolutions by GPU</h1>
<p>
<a asp-action="Create" class="btn btn-primary">
Create new
</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Gpu)
</th>
<th>
@Html.DisplayNameFor(model => model.Resolution)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.GpuCompany)
@Html.DisplayFor(modelItem => item.Gpu)
</td>
<td>
@item.Resolution
</td>
<td>
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-primary">
Details
</a>
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-secondary">
Edit
</a>
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">
Delete
</a>
</td>
</tr>
}
</tbody>
</table>

View File

@@ -1,42 +0,0 @@
@model Marechai.Database.Models.ResolutionsByScreen
@{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>Resolutions by screen</h4>
<hr />
<div class="row">
<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="Screen" class="control-label">
</label>
<select asp-for="ScreenId" class="form-control" asp-items="ViewBag.ScreenId">
</select>
<span asp-validation-for="ScreenId" class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Resolution" class="control-label">
</label>
<select asp-for="ResolutionId" class="form-control" asp-items="ViewBag.ResolutionId">
</select>
<span asp-validation-for="ResolutionId" class="text-danger">
</span>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" value="Create" />
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</div>
</form>
</div>
</div>
@section Scripts {
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@@ -1,39 +0,0 @@
@model Marechai.Database.Models.ResolutionsByScreen
@{
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Resolutions by screen</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Screen)
</dt>
<dd class="col-sm-10">
@if (Model.Screen.NativeResolution != null)
{
@($"{Model.Screen.Diagonal}\" {Model.Screen.Type} with {Model.Screen.NativeResolution}")
}
else
{
@($"{Model.Screen.Diagonal}\" {Model.Screen.Type}")
}
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Resolution)
</dt>
<dd class="col-sm-10">
@Model.Resolution.ToString()
</dd>
</dl>
<form asp-action="Delete">
<input type="hidden" asp-for="Id" />
<input class="btn btn-danger" type="submit" value="Delete" />
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</form>
</div>

View File

@@ -1,39 +0,0 @@
@model Marechai.Database.Models.ResolutionsByScreen
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>Resolutions by screen</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Screen)
</dt>
<dd class="col-sm-10">
@if (Model.Screen.NativeResolution != null)
{
@($"{Model.Screen.Diagonal}\" {Model.Screen.Type} with {Model.Screen.NativeResolution}")
}
else
{
@($"{Model.Screen.Diagonal}\" {Model.Screen.Type}")
}
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Resolution)
</dt>
<dd class="col-sm-10">
@Model.Resolution.ToString()
</dd>
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">
Edit
</a>
<a asp-action="Index" class="btn btn-secondary">
Back to List
</a>
</div>

View File

@@ -1,41 +0,0 @@
@model Marechai.Database.Models.ResolutionsByScreen
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>Resolutions by screen</h4>
<hr />
<div class="row">
<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="Screen" class="control-label">
</label>
<select asp-for="ScreenId" class="form-control" asp-items="ViewBag.ScreenId">
</select>
<span asp-validation-for="ScreenId" class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Resolution" class="control-label">
</label>
<select asp-for="ResolutionId" class="form-control" asp-items="ViewBag.ResolutionId">
</select>
<span asp-validation-for="ResolutionId" class="text-danger">
</span>
</div>
<input type="hidden" asp-for="Id" />
<div class="form-group">
<input class="btn btn-primary" type="submit" value="Save" />
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
</div>
</form>
</div>
</div>
@section Scripts {
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@@ -1,55 +0,0 @@
@model IEnumerable<Marechai.Database.Models.ResolutionsByScreen>
@{
ViewData["Title"] = "Index";
}
<h1>Resolutions by screen</h1>
<p>
<a asp-action="Create" class="btn btn-primary">
Create new
</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Screen)
</th>
<th>
@Html.DisplayNameFor(model => model.Resolution)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@if (item.Screen.NativeResolution != null)
{
@($"{item.Screen.Diagonal}\" {item.Screen.Type} with {item.Screen.NativeResolution}")
}
else
{
@($"{item.Screen.Diagonal}\" {item.Screen.Type}")
}
</td>
<td>
@item.Resolution.ToString()
</td>
<td>
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-primary">
Details
</a>
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-secondary">
Edit
</a>
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">
Delete
</a>
</td>
</tr>
}
</tbody>
</table>

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>3.0.99.1399</Version>
<Version>3.0.99.1404</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>
@@ -122,6 +122,12 @@
<Content Update="Pages\Admin\Details\SoundSynth.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<Content Update="Pages\Admin\Resolutions.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<Content Update="Pages\Admin\Details\Resolution.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" />
@@ -179,5 +185,20 @@
<_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Details.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Edit.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Index.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\Resolutions\Create.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\Resolutions\Delete.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\Resolutions\Details.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\Resolutions\Edit.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\Resolutions\Index.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByGpu\Create.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByGpu\Delete.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByGpu\Details.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByGpu\Edit.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByGpu\Index.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByScreen\Create.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByScreen\Delete.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByScreen\Details.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByScreen\Edit.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByScreen\Index.cshtml" />
</ItemGroup>
</Project>

View File

@@ -37,6 +37,8 @@
@inject IStringLocalizer<GpusService> L
@inject CompaniesService CompaniesService
@inject NavigationManager NavigationManager
@inject ResolutionsService ResolutionsService
@inject ResolutionsByGpuService ResolutionsByGpuService
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Graphical processing unit details"]</h3>
<hr />
@@ -240,3 +242,103 @@
}
<a href="/admin/gpus" class="btn btn-secondary">@L["Back to list"]</a>
</div>
@if (!_editing)
{
<hr />
<h3>@L["Resolutions supported by this graphical processing unit"]</h3>
<Button Color="Color.Success" Clicked="OnAddResolutionClick" Disabled="_addingResolution">@L["Add new (resolution by gpu)"]</Button>
@if (_addingResolution)
{
<div>
<Field>
<FieldLabel>@L["Resolutions"]</FieldLabel>
<Select Disabled="_savingResolution" TValue="int?" @bind-SelectedValue="@_addingResolutionId">
@foreach (var resolution in _resolutions)
{
@if (_gpuResolutions.All(r => r.ResolutionId != resolution.Id))
{
<SelectItem TValue="int?" Value="@resolution.Id">@resolution</SelectItem>
}
}
</Select>
<Button Color="Color.Primary" Clicked="@CancelAddResolution" Disabled="@_savingResolution">@L["Cancel"]</Button>
<Button Color="Color.Success" Clicked="@ConfirmAddResolution" Disabled="@_savingResolution">@L["Add"]</Button>
</Field>
</div>
}
@if (_gpuResolutions?.Count > 0)
{
<div>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Width"]
</th>
<th>
@L["Height"]
</th>
<th>
@L["Colors"]
</th>
<th>
@L["Palette"]
</th>
<th>
@L["Chars"]
</th>
<th>
@L["Grayscale"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _gpuResolutions)
{
<tr>
<td>
@item.Resolution.Width
</td>
<td>
@item.Resolution.Height
</td>
<td>
@item.Resolution.Colors
</td>
<td>
@item.Resolution.Palette
</td>
<td>
@item.Resolution.Chars
</td>
<td>
@item.Resolution.Grayscale
</td>
<td>
<Button Color="Color.Danger" Clicked="() => {ShowResolutionDeleteModal(item.Id);}" Disabled="@_addingResolution">@L["Delete"]</Button>
</td>
</tr>
}
</tbody>
</table>
</div>
}
<Modal @ref="_frmDelete" IsCentered="true" Closing="@ModalClosing">
<ModalBackdrop />
<ModalContent Centered="true">
<ModalHeader>
<ModalTitle>@_deleteTitle</ModalTitle>
<CloseButton Clicked="@HideModal" />
</ModalHeader>
<ModalBody>
<Text>@_deleteText</Text>
</ModalBody>
<ModalFooter>
<Button Color="Color.Primary" Clicked="@HideModal" Disabled="@_deleteInProgress">@L["Cancel"]</Button>
<Button Color="Color.Danger" Clicked="@ConfirmDelete" Disabled="@_deleteInProgress">@L["Delete"]</Button>
</ModalFooter>
</ModalContent>
</Modal>
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.Shared;
@@ -10,12 +11,22 @@ namespace Marechai.Pages.Admin.Details
{
public partial class Gpu
{
bool _addingResolution;
int? _addingResolutionId;
List<CompanyViewModel> _companies;
bool _creating;
ResolutionByGpuViewModel _currentResolution;
bool _deleteInProgress;
string _deleteText;
string _deleteTitle;
bool _editing;
Modal _frmDelete;
List<ResolutionByGpuViewModel> _gpuResolutions;
bool _loaded;
GpuViewModel _model;
bool _prototype;
List<ResolutionViewModel> _resolutions;
bool _savingResolution;
bool _unknownCompany;
bool _unknownDieSize;
bool _unknownIntroduced;
@@ -43,6 +54,8 @@ namespace Marechai.Pages.Admin.Details
_companies = await CompaniesService.GetAsync();
_model = _creating ? new GpuViewModel() : await Service.GetAsync(Id);
_resolutions = await ResolutionsService.GetAsync();
_gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id);
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/gpus/edit/", StringComparison.InvariantCulture);
@@ -162,5 +175,91 @@ namespace Marechai.Pages.Admin.Details
void ValidateProcess(ValidatorEventArgs e) =>
Validators.ValidateString(e, L["Process must be 45 characters or less."], 45);
void ShowResolutionDeleteModal(long itemId)
{
_currentResolution = _gpuResolutions.FirstOrDefault(n => n.Id == itemId);
_deleteTitle = L["Delete resolution from this graphical processing unit"];
_deleteText =
string.Format(L["Are you sure you want to delete the resolution {0} from this graphical processing unit?"],
_currentResolution);
_frmDelete.Show();
}
void HideModal() => _frmDelete.Hide();
async void ConfirmDelete()
{
if(_currentResolution is null)
return;
_deleteInProgress = true;
// Yield thread to let UI to update
await Task.Yield();
await ResolutionsByGpuService.DeleteAsync(_currentResolution.Id);
_gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id);
_deleteInProgress = false;
_frmDelete.Hide();
// Yield thread to let UI to update
await Task.Yield();
// Tell we finished loading
StateHasChanged();
}
void ModalClosing(ModalClosingEventArgs obj)
{
_deleteInProgress = false;
_currentResolution = null;
}
void OnAddResolutionClick()
{
_addingResolution = true;
_savingResolution = false;
_addingResolutionId = _resolutions.First().Id;
}
void CancelAddResolution()
{
_addingResolution = false;
_savingResolution = false;
_addingResolutionId = null;
}
async Task ConfirmAddResolution()
{
if(_addingResolutionId is null ||
_addingResolutionId <= 0)
{
CancelAddResolution();
return;
}
_savingResolution = true;
// Yield thread to let UI to update
await Task.Yield();
await ResolutionsByGpuService.CreateAsync(_addingResolutionId.Value, Id);
_gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id);
_addingResolution = false;
_savingResolution = false;
_addingResolutionId = null;
// Yield thread to let UI to update
await Task.Yield();
// Tell we finished loading
StateHasChanged();
}
}
}

View File

@@ -0,0 +1,131 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Details.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Admin view details
//
// --[ 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-2020 Natalia Portillo
*******************************************************************************/
}
@page "/admin/resolutions/details/{Id:int}"
@page "/admin/resolutions/edit/{Id:int}"
@page "/admin/resolutions/create"
@inherits OwningComponentBase<ResolutionsService>
@inject IStringLocalizer<ResolutionsService> L
@inject NavigationManager NavigationManager
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Resolution details"]</h3>
<hr />
@if (!_loaded)
{
<p align="center">@L["Loading..."]</p>
return;
}
<div>
<Field>
<FieldLabel>@L["Width (pixels or characters)"]</FieldLabel>
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="int" @bind-Value="@_model.Width" >
<Feedback>
<ValidationError>@L["Please enter a valid width in pixels or characters."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
</Field>
<Field>
<FieldLabel>@L["Height (pixels or characters)"]</FieldLabel>
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="int" @bind-Value="@_model.Height" >
<Feedback>
<ValidationError>@L["Please enter a valid height in pixels or characters."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
</Field>
@if (_editing || _model.Colors.HasValue)
{
<Field>
<FieldLabel>@L["Colors"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownColors">@L["Unknown (colors)"]</Check>
}
@if (!_editing ||
!_unknownColors)
{
<Validation Validator="@ValidateLongBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="long?" Decimals="0" @bind-Value="@_model.Colors" >
<Feedback>
<ValidationError>@L["Please enter a valid number of colors."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.Palette.HasValue)
{
<Field>
<FieldLabel>@L["Colors in palette"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownPalette">@L["Unknown (colors in palette)"]</Check>
}
@if (!_editing ||
!_unknownPalette)
{
<Validation Validator="@ValidateLongBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="long?" Decimals="0" @bind-Value="@_model.Palette" >
<Feedback>
<ValidationError>@L["Please enter a valid number of colors in palette."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
<Field>
<Check Disabled="!_editing" TValue="bool" @bind-Checked="@_model.Chars">@L["Resolution is character based (text only)."]</Check>
</Field>
<Field>
<Check Disabled="!_editing" TValue="bool" @bind-Checked="@_model.Grayscale">@L["Resolution only has gray colors."]</Check>
</Field>
</div>
<div>
@if (!_editing)
{
<Button Color="Color.Primary" Clicked="@OnEditClicked">@L["Edit"]</Button>
}
else
{
<Button Color="Color.Success" Clicked="@OnSaveClicked">@L["Save"]</Button>
<Button Color="Color.Danger" Clicked="@OnCancelClicked">@L["Cancel"]</Button>
}
<a href="/admin/resolutions" class="btn btn-secondary">@L["Back to list"]</a>
</div>

View File

@@ -0,0 +1,104 @@
using System;
using System.Threading.Tasks;
using Blazorise;
using Marechai.Shared;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
namespace Marechai.Pages.Admin.Details
{
public partial class Resolution
{
bool _creating;
bool _editing;
bool _loaded;
ResolutionViewModel _model;
bool _unknownColors;
bool _unknownPalette;
[Parameter]
public int Id { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(_loaded)
return;
_loaded = true;
_creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/resolutions/create", StringComparison.InvariantCulture);
if(Id <= 0 &&
!_creating)
return;
_model = _creating ? new ResolutionViewModel() : await Service.GetAsync(Id);
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/resolutions/edit/",
StringComparison.InvariantCulture);
if(_editing)
SetCheckboxes();
StateHasChanged();
}
void SetCheckboxes()
{
_unknownColors = !_model.Colors.HasValue;
_unknownPalette = !_model.Colors.HasValue;
}
void OnEditClicked()
{
_editing = true;
SetCheckboxes();
StateHasChanged();
}
async void OnCancelClicked()
{
_editing = false;
if(_creating)
{
NavigationManager.ToBaseRelativePath("admin/resolutions");
return;
}
_model = await Service.GetAsync(Id);
SetCheckboxes();
StateHasChanged();
}
async void OnSaveClicked()
{
if(_unknownColors)
_model.Colors = null;
else if(_model.Colors <= 0)
return;
if(_unknownPalette)
_model.Palette = null;
else if(_model.Palette <= 0)
return;
if(_creating)
Id = await Service.CreateAsync(_model);
else
await Service.UpdateAsync(_model);
_editing = false;
_creating = false;
_model = await Service.GetAsync(Id);
SetCheckboxes();
StateHasChanged();
}
void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateInteger(e, 1);
void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e, 2);
}
}

View File

@@ -37,6 +37,8 @@
@inject IStringLocalizer<ScreensService> L
@inject ResolutionsService ResolutionsService
@inject NavigationManager NavigationManager
@inject ResolutionsByScreenService ResolutionsByScreenService
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Screen details"]</h3>
<hr />
@@ -89,7 +91,6 @@
</NumericEdit>
</Validation>
}
<NumericEdit Disabled="!_editing" TValue="double?" Decimals="2" @bind-Value="@_model.Height"/>
</Field>
}
<Field>
@@ -166,3 +167,104 @@
}
<a href="/admin/screens" class="btn btn-secondary">@L["Back to list"]</a>
</div>
@if (!_editing)
{
<hr />
<h3>@L["Resolutions supported by this screen"]</h3>
<Button Color="Color.Success" Clicked="OnAddResolutionClick" Disabled="_addingResolution">@L["Add new (resolution by screen)"]</Button>
@if (_addingResolution)
{
<div>
<Field>
<FieldLabel>@L["Resolutions"]</FieldLabel>
<Select Disabled="_savingResolution" TValue="int?" @bind-SelectedValue="@_addingResolutionId">
@foreach (var resolution in _resolutions)
{
@if (resolution.Id != _model.NativeResolutionId &&
_screenResolutions.All(r => r.ResolutionId != resolution.Id))
{
<SelectItem TValue="int?" Value="@resolution.Id">@resolution</SelectItem>
}
}
</Select>
<Button Color="Color.Primary" Clicked="@CancelAddResolution" Disabled="@_savingResolution">@L["Cancel"]</Button>
<Button Color="Color.Success" Clicked="@ConfirmAddResolution" Disabled="@_savingResolution">@L["Add"]</Button>
</Field>
</div>
}
@if (_screenResolutions?.Count > 0)
{
<div>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Width"]
</th>
<th>
@L["Height"]
</th>
<th>
@L["Colors"]
</th>
<th>
@L["Palette"]
</th>
<th>
@L["Chars"]
</th>
<th>
@L["Grayscale"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _screenResolutions)
{
<tr>
<td>
@item.Resolution.Width
</td>
<td>
@item.Resolution.Height
</td>
<td>
@item.Resolution.Colors
</td>
<td>
@item.Resolution.Palette
</td>
<td>
@item.Resolution.Chars
</td>
<td>
@item.Resolution.Grayscale
</td>
<td>
<Button Color="Color.Danger" Clicked="() => {ShowResolutionDeleteModal(item.Id);}" Disabled="@_addingResolution">@L["Delete"]</Button>
</td>
</tr>
}
</tbody>
</table>
</div>
}
<Modal @ref="_frmDelete" IsCentered="true" Closing="@ModalClosing">
<ModalBackdrop />
<ModalContent Centered="true">
<ModalHeader>
<ModalTitle>@_deleteTitle</ModalTitle>
<CloseButton Clicked="@HideModal" />
</ModalHeader>
<ModalBody>
<Text>@_deleteText</Text>
</ModalBody>
<ModalFooter>
<Button Color="Color.Primary" Clicked="@HideModal" Disabled="@_deleteInProgress">@L["Cancel"]</Button>
<Button Color="Color.Danger" Clicked="@ConfirmDelete" Disabled="@_deleteInProgress">@L["Delete"]</Button>
</ModalFooter>
</ModalContent>
</Modal>
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.Shared;
@@ -10,11 +11,20 @@ namespace Marechai.Pages.Admin.Details
{
public partial class Screen
{
bool _addingResolution;
int? _addingResolutionId;
bool _creating;
ResolutionByScreenViewModel _currentResolution;
bool _deleteInProgress;
string _deleteText;
string _deleteTitle;
bool _editing;
Modal _frmDelete;
bool _loaded;
ScreenViewModel _model;
List<ResolutionViewModel> _resolutions;
bool _savingResolution;
List<ResolutionByScreenViewModel> _screenResolutions;
bool _unknownColors;
bool _unknownHeight;
bool _unknownType;
@@ -38,6 +48,7 @@ namespace Marechai.Pages.Admin.Details
_resolutions = await ResolutionsService.GetAsync();
_model = _creating ? new ScreenViewModel() : await Service.GetAsync(Id);
_screenResolutions = await ResolutionsByScreenService.GetByScreen(Id);
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
StartsWith("admin/screens/edit/",
@@ -120,5 +131,90 @@ namespace Marechai.Pages.Admin.Details
void ValidateType(ValidatorEventArgs e) =>
Validators.ValidateString(e, L["Screen type cannot be bigger than 256 characters."], 256);
void ShowResolutionDeleteModal(long itemId)
{
_currentResolution = _screenResolutions.FirstOrDefault(n => n.Id == itemId);
_deleteTitle = L["Delete resolution from this screen"];
_deleteText = string.Format(L["Are you sure you want to delete the resolution {0} from this screen?"],
_currentResolution);
_frmDelete.Show();
}
void HideModal() => _frmDelete.Hide();
async void ConfirmDelete()
{
if(_currentResolution is null)
return;
_deleteInProgress = true;
// Yield thread to let UI to update
await Task.Yield();
await ResolutionsByScreenService.DeleteAsync(_currentResolution.Id);
_screenResolutions = await ResolutionsByScreenService.GetByScreen(Id);
_deleteInProgress = false;
_frmDelete.Hide();
// Yield thread to let UI to update
await Task.Yield();
// Tell we finished loading
StateHasChanged();
}
void ModalClosing(ModalClosingEventArgs obj)
{
_deleteInProgress = false;
_currentResolution = null;
}
void OnAddResolutionClick()
{
_addingResolution = true;
_savingResolution = false;
_addingResolutionId = _resolutions.First().Id;
}
void CancelAddResolution()
{
_addingResolution = false;
_savingResolution = false;
_addingResolutionId = null;
}
async Task ConfirmAddResolution()
{
if(_addingResolutionId is null ||
_addingResolutionId <= 0)
{
CancelAddResolution();
return;
}
_savingResolution = true;
// Yield thread to let UI to update
await Task.Yield();
await ResolutionsByScreenService.CreateAsync(_addingResolutionId.Value, Id);
_screenResolutions = await ResolutionsByScreenService.GetByScreen(Id);
_addingResolution = false;
_savingResolution = false;
_addingResolutionId = null;
// Yield thread to let UI to update
await Task.Yield();
// Tell we finished loading
StateHasChanged();
}
}
}

View File

@@ -80,6 +80,9 @@
<li>
<a href="/admin/sound_synths">@L["Sound synthesizers"]</a>
</li>
<li>
<a href="/admin/resolutions">@L["Resolutions"]</a>
</li>
</ul>
</div>
<div class="content">

View File

@@ -0,0 +1,118 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Resolutions.razor
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// List of resolutions
//
// --[ 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-2020 Natalia Portillo
*******************************************************************************/
}
@page "/admin/resolutions"
@inherits OwningComponentBase<ResolutionsService>
@inject IStringLocalizer<ResolutionsService> L
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Resolutions"]</h3>
@if (_resolutions is null)
{
<p>@L["Loading..."]</p>
return;
}
<p>
<a class="btn btn-primary" href="/admin/resolutions/create">@L["Create new"]</a>
</p>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Width"]
</th>
<th>
@L["Height"]
</th>
<th>
@L["Colors"]
</th>
<th>
@L["Palette"]
</th>
<th>
@L["Chars"]
</th>
<th>
@L["Grayscale"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _resolutions)
{
<tr>
<td>
@item.Width
</td>
<td>
@item.Height
</td>
<td>
@item.Colors
</td>
<td>
@item.Palette
</td>
<td>
@item.Chars
</td>
<td>
@item.Grayscale
</td>
<td>
<a class="btn btn-primary" href="/admin/resolutions/details/@item.Id">@L["Details"]</a>
<a class="btn btn-secondary" href="/admin/resolutions/edit/@item.Id">@L["Edit"]</a>
<Button Color="Color.Danger" Clicked="() => {ShowModal(item.Id);}">@L["Delete"]</Button>
</td>
</tr>
}
</tbody>
</table>
<Modal @ref="_frmDelete" IsCentered="true" Closing="@ModalClosing">
<ModalBackdrop/>
<ModalContent Centered="true">
<ModalHeader>
<ModalTitle>@L["Delete resolution"]</ModalTitle>
<CloseButton Clicked="@HideModal"/>
</ModalHeader>
<ModalBody>
<Text>@string.Format(L["Are you sure you want to delete resolution {0}?"], _resolution)</Text>
</ModalBody>
<ModalFooter>
<Button Color="Color.Primary" Clicked="@HideModal" Disabled="@_deleteInProgress">@L["Cancel"]</Button>
<Button Color="Color.Danger" Clicked="@ConfirmDelete" Disabled="@_deleteInProgress">@L["Delete"]</Button>
</ModalFooter>
</ModalContent>
</Modal>

View File

@@ -0,0 +1,52 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Marechai.ViewModels;
namespace Marechai.Pages.Admin
{
public partial class Resolutions
{
bool _deleteInProgress;
Modal _frmDelete;
ResolutionViewModel _resolution;
List<ResolutionViewModel> _resolutions;
void ShowModal(int itemId)
{
_resolution = _resolutions.FirstOrDefault(n => n.Id == itemId);
_frmDelete.Show();
}
void HideModal() => _frmDelete.Hide();
async void ConfirmDelete()
{
if(_resolution is null)
return;
_deleteInProgress = true;
_resolutions = null;
// Yield thread to let UI to update
await Task.Yield();
await Service.DeleteAsync(_resolution.Id);
_resolutions = await Service.GetAsync();
_deleteInProgress = false;
_frmDelete.Hide();
// Yield thread to let UI to update
await Task.Yield();
// Tell we finished loading
StateHasChanged();
}
void ModalClosing(ModalClosingEventArgs obj) => _resolution = null;
protected override async Task OnInitializedAsync() => _resolutions = await Service.GetAsync();
}
}

View File

@@ -206,4 +206,8 @@
<value>Sintetizadores de sonido</value>
<comment>Sound synthesizers.</comment>
</data>
<data name="Resolutions" xml:space="preserve">
<value>Resoluciones</value>
<comment>Resolutions.</comment>
</data>
</root>

View File

@@ -150,4 +150,8 @@
<value>Unknown</value>
<comment>Unknown, referring to the number of transistors</comment>
</data>
<data name="Add new (resolution by gpu)" xml:space="preserve">
<value>Add new</value>
<comment>Add new, referring to resolutions supported by this gpu</comment>
</data>
</root>

View File

@@ -270,4 +270,52 @@
<value>Por favor introduce un número válido de transistores.</value>
<comment>Please enter a valid number of transistors.</comment>
</data>
<data name="Add new (resolution by gpu)" xml:space="preserve">
<value>Añadir nueva</value>
<comment>Add new, referring to resolutions supported by this gpu</comment>
</data>
<data name="Resolutions supported by this graphical processing unit" xml:space="preserve">
<value>Prototipo</value>
<comment>Resolutions supported by this graphical processing unit</comment>
</data>
<data name="Resolutions" xml:space="preserve">
<value>Resoluciones</value>
<comment>Resolutions</comment>
</data>
<data name="Add" xml:space="preserve">
<value>Añadir</value>
<comment>Add</comment>
</data>
<data name="Width" xml:space="preserve">
<value>Ancho</value>
<comment>Width</comment>
</data>
<data name="Height" xml:space="preserve">
<value>Alto</value>
<comment>Height</comment>
</data>
<data name="Colors" xml:space="preserve">
<value>Colores</value>
<comment>Colors</comment>
</data>
<data name="Palette" xml:space="preserve">
<value>Paleta</value>
<comment>Palette</comment>
</data>
<data name="Chars" xml:space="preserve">
<value>Caracteres</value>
<comment>Chars</comment>
</data>
<data name="Grayscale" xml:space="preserve">
<value>Escala de grises</value>
<comment>Grayscale</comment>
</data>
<data name="Delete resolution from this graphical processing unit" xml:space="preserve">
<value>Eliminar resolución de esta unidad de proceso de gráficos</value>
<comment>Delete resolution from this graphical processing unit</comment>
</data>
<data name="Are you sure you want to delete the resolution {0} from this graphical processing unit?" xml:space="preserve">
<value>¿Estás seguro de eliminar la resolución {0} de esta unidad de proceso de gráficos?</value>
<comment>Are you sure you want to delete the resolution {0} from this graphical processing unit?</comment>
</data>
</root>

View File

@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ReSharper disable MarkupTextTypo -->
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Unknown (colors)" xml:space="preserve">
<value>Unknown</value>
<comment>Unknown, referring to colors in resolution</comment>
</data>
<data name="Unknown (colors in palette)" xml:space="preserve">
<value>Unknown</value>
<comment>Unknown, referring to colors in palette resolution</comment>
</data>
</root>

View File

@@ -0,0 +1,237 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ReSharper disable MarkupTextTypo -->
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Unknown (colors)" xml:space="preserve">
<value>Desconocidos</value>
<comment>Unknown, referring to colors in resolution</comment>
</data>
<data name="Unknown (colors in palette)" xml:space="preserve">
<value>Desconocidos</value>
<comment>Unknown, referring to colors in palette resolution</comment>
</data>
<data name="Resolutions" xml:space="preserve">
<value>Resoluciones</value>
<comment>Resolutions</comment>
</data>
<data name="Create new" xml:space="preserve">
<value>Crear nueva</value>
<comment>Create new</comment>
</data>
<data name="Width" xml:space="preserve">
<value>Ancho</value>
<comment>Width</comment>
</data>
<data name="Height" xml:space="preserve">
<value>Alto</value>
<comment>Height</comment>
</data>
<data name="Colors" xml:space="preserve">
<value>Colores</value>
<comment>Colors</comment>
</data>
<data name="Palette" xml:space="preserve">
<value>Paleta</value>
<comment>Palette</comment>
</data>
<data name="Chars" xml:space="preserve">
<value>Caracteres</value>
<comment>Chars</comment>
</data>
<data name="Grayscale" xml:space="preserve">
<value>Escala de grises</value>
<comment>Grayscale</comment>
</data>
<data name="Details" xml:space="preserve">
<value>Detalles</value>
<comment>Details</comment>
</data>
<data name="Edit" xml:space="preserve">
<value>Editar</value>
<comment>Edit</comment>
</data>
<data name="Delete" xml:space="preserve">
<value>Eliminar</value>
<comment>Delete</comment>
</data>
<data name="Delete resolution" xml:space="preserve">
<value>Eliminar resolución</value>
<comment>Delete resolution</comment>
</data>
<data name="Are you sure you want to delete resolution {0}?" xml:space="preserve">
<value>¿Estás seguro de eliminar la resolución {0}?</value>
<comment>Are you sure you want to delete resolution {0}?</comment>
</data>
<data name="Resolution details" xml:space="preserve">
<value>Detalles de resolución</value>
<comment>Resolution details</comment>
</data>
<data name="Loading..." xml:space="preserve">
<value>Cargando...</value>
<comment>Loading...</comment>
</data>
<data name="Width (pixels or characters)" xml:space="preserve">
<value>Ancho (píxeles o caracteres)</value>
<comment>Width (pixels or characters)</comment>
</data>
<data name="Please enter a valid width in pixels or characters." xml:space="preserve">
<value>Por favor introduce un ancho válido en píxeles o caracteres.</value>
<comment>Please enter a valid width in pixels or characters.</comment>
</data>
<data name="Height (pixels or characters)" xml:space="preserve">
<value>Alto (píxeles o caracteres)</value>
<comment>Height (pixels or characters)</comment>
</data>
<data name="Please enter a valid height in pixels or characters." xml:space="preserve">
<value>Por favor introduce un alto válido en píxeles o caracteres.</value>
<comment>Please enter a valid height in pixels or characters.</comment>
</data>
<data name="Please enter a valid number of colors." xml:space="preserve">
<value>Por favor introduce un número de colores válido.</value>
<comment>Please enter a valid number of colors.</comment>
</data>
<data name="Colors in palette" xml:space="preserve">
<value>Colores en paleta</value>
<comment>Colors in palette</comment>
</data>
<data name="Please enter a valid number of colors in palette." xml:space="preserve">
<value>Por favor introduce un número de colores en paleta válido.</value>
<comment>Please enter a valid number of colors in palette.</comment>
</data>
<data name="Resolution is character based (text only)." xml:space="preserve">
<value>La resolución es basada en caracteres (sólo texto).</value>
<comment>Resolution is character based (text only).</comment>
</data>
<data name="Resolution only has gray colors." xml:space="preserve">
<value>La resolución sólo tiene grises.</value>
<comment>Resolution only has gray colors.</comment>
</data>
<data name="Save" xml:space="preserve">
<value>Guardar</value>
<comment>Save</comment>
</data>
<data name="Cancel" xml:space="preserve">
<value>Cancelar</value>
<comment>Cancel</comment>
</data>
<data name="Back to list" xml:space="preserve">
<value>Volver a la lista</value>
<comment>Back to list</comment>
</data>
</root>

View File

@@ -134,4 +134,8 @@
<value>Unknown</value>
<comment>Unknown, referring to a screen type</comment>
</data>
<data name="Add new (resolution by screen)" xml:space="preserve">
<value>Add new</value>
<comment>Add new, referring to resolutions supported by this screen</comment>
</data>
</root>

View File

@@ -238,4 +238,52 @@
<value>El tipo de pantalla no puede tener más de 256 caracteres.</value>
<comment>Screen type cannot be bigger than 256 characters.</comment>
</data>
<data name="Add new (resolution by screen)" xml:space="preserve">
<value>Añadir nueva</value>
<comment>Add new, referring to resolutions supported by this screen</comment>
</data>
<data name="Resolutions supported by this screen" xml:space="preserve">
<value>Resoluciones soportadas por esta pantalla</value>
<comment>Resolutions supported by this screen</comment>
</data>
<data name="Resolutions" xml:space="preserve">
<value>Resoluciones</value>
<comment>Resolutions</comment>
</data>
<data name="Add" xml:space="preserve">
<value>Añadir</value>
<comment>Add</comment>
</data>
<data name="Width" xml:space="preserve">
<value>Ancho</value>
<comment>Width</comment>
</data>
<data name="Height" xml:space="preserve">
<value>Alto</value>
<comment>Height</comment>
</data>
<data name="Colors" xml:space="preserve">
<value>Colores</value>
<comment>Colors</comment>
</data>
<data name="Palette" xml:space="preserve">
<value>Paleta</value>
<comment>Palette</comment>
</data>
<data name="Chars" xml:space="preserve">
<value>Caracteres</value>
<comment>Chars</comment>
</data>
<data name="Grayscale" xml:space="preserve">
<value>Escala de grises</value>
<comment>Grayscale</comment>
</data>
<data name="Delete resolution from this screen" xml:space="preserve">
<value>Eliminar resolución de esta pantalla</value>
<comment>Delete resolution from this screen</comment>
</data>
<data name="Are you sure you want to delete the resolution {0} from this screen?" xml:space="preserve">
<value>¿Estás seguro de eliminar la resolución {0} de esta pantalla?</value>
<comment>Are you sure you want to delete the resolution {0} from this screen?</comment>
</data>
</root>

View File

@@ -68,6 +68,9 @@ namespace Marechai.Services
services.AddScoped<MemoriesByMachineService>();
services.AddScoped<StorageByMachineService>();
services.AddScoped<ScreensByMachineService>();
services.AddScoped<ResolutionsService>();
services.AddScoped<ResolutionsByScreenService>();
services.AddScoped<ResolutionsByGpuService>();
}
}
}

View File

@@ -0,0 +1,56 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.ViewModels;
using Microsoft.EntityFrameworkCore;
namespace Marechai.Services
{
public class ResolutionsByGpuService
{
readonly MarechaiContext _context;
public ResolutionsByGpuService(MarechaiContext context) => _context = context;
public async Task<List<ResolutionByGpuViewModel>> GetByGpu(int resolutionId) =>
await _context.ResolutionsByGpu.Where(r => r.ResolutionId == resolutionId).
Select(r => new ResolutionByGpuViewModel
{
Id = r.Id, GpuId = r.GpuId, Resolution = new ResolutionViewModel
{
Id = r.Resolution.Id, Width = r.Resolution.Width, Height = r.Resolution.Height,
Colors = r.Resolution.Colors, Palette = r.Resolution.Palette,
Chars = r.Resolution.Chars, Grayscale = r.Resolution.Grayscale
},
ResolutionId = r.ResolutionId
}).OrderBy(r => r.Resolution.Width).ThenBy(r => r.Resolution.Height).
ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Grayscale).
ThenBy(r => r.Resolution.Colors).ThenBy(r => r.Resolution.Palette).ToListAsync();
public async Task DeleteAsync(long id)
{
ResolutionsByGpu item = await _context.ResolutionsByGpu.FindAsync(id);
if(item is null)
return;
_context.ResolutionsByGpu.Remove(item);
await _context.SaveChangesAsync();
}
public async Task<long> CreateAsync(int resolutionId, int gpuId)
{
var item = new ResolutionsByGpu
{
GpuId = gpuId, ResolutionId = resolutionId
};
await _context.ResolutionsByGpu.AddAsync(item);
await _context.SaveChangesAsync();
return item.Id;
}
}
}

View File

@@ -0,0 +1,56 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.ViewModels;
using Microsoft.EntityFrameworkCore;
namespace Marechai.Services
{
public class ResolutionsByScreenService
{
readonly MarechaiContext _context;
public ResolutionsByScreenService(MarechaiContext context) => _context = context;
public async Task<List<ResolutionByScreenViewModel>> GetByScreen(int resolutionId) =>
await _context.ResolutionsByScreen.Where(r => r.ResolutionId == resolutionId).
Select(r => new ResolutionByScreenViewModel
{
Id = r.Id, ScreenId = r.ScreenId, Resolution = new ResolutionViewModel
{
Id = r.Resolution.Id, Width = r.Resolution.Width, Height = r.Resolution.Height,
Colors = r.Resolution.Colors, Palette = r.Resolution.Palette,
Chars = r.Resolution.Chars, Grayscale = r.Resolution.Grayscale
},
ResolutionId = r.ResolutionId
}).OrderBy(r => r.Resolution.Width).ThenBy(r => r.Resolution.Height).
ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Grayscale).
ThenBy(r => r.Resolution.Colors).ThenBy(r => r.Resolution.Palette).ToListAsync();
public async Task DeleteAsync(long id)
{
ResolutionsByScreen item = await _context.ResolutionsByScreen.FindAsync(id);
if(item is null)
return;
_context.ResolutionsByScreen.Remove(item);
await _context.SaveChangesAsync();
}
public async Task<long> CreateAsync(int resolutionId, int screenId)
{
var item = new ResolutionsByScreen
{
ScreenId = screenId, ResolutionId = resolutionId
};
await _context.ResolutionsByScreen.AddAsync(item);
await _context.SaveChangesAsync();
return item.Id;
}
}
}

View File

@@ -13,15 +13,62 @@ namespace Marechai.Services
public ResolutionsService(MarechaiContext context) => _context = context;
public async Task<List<ResolutionViewModel>> GetAsync()
{
List<ResolutionViewModel> list = await _context.Resolutions.Select(r => new ResolutionViewModel
public async Task<List<ResolutionViewModel>> GetAsync() =>
await _context.Resolutions.Select(r => new ResolutionViewModel
{
Id = r.Id, Width = r.Width, Height = r.Height, Colors = r.Colors,
Palette = r.Palette, Chars = r.Chars, Grayscale = r.Grayscale
}).ToListAsync();
}).OrderBy(r => r.Width).ThenBy(r => r.Height).ThenBy(r => r.Chars).ThenBy(r => r.Grayscale).
ThenBy(r => r.Colors).ThenBy(r => r.Palette).ToListAsync();
return list.OrderBy(r => r.ToString()).ToList();
public async Task<ResolutionViewModel> GetAsync(int id) =>
await _context.Resolutions.Where(r => r.Id == id).Select(r => new ResolutionViewModel
{
Id = r.Id, Width = r.Width, Height = r.Height, Colors = r.Colors,
Palette = r.Palette, Chars = r.Chars, Grayscale = r.Grayscale
}).FirstOrDefaultAsync();
public async Task UpdateAsync(ResolutionViewModel viewModel)
{
Resolution model = await _context.Resolutions.FindAsync(viewModel.Id);
if(model is null)
return;
model.Chars = viewModel.Chars;
model.Colors = viewModel.Colors;
model.Grayscale = viewModel.Grayscale;
model.Height = viewModel.Height;
model.Palette = viewModel.Palette;
model.Width = viewModel.Width;
await _context.SaveChangesAsync();
}
public async Task<int> CreateAsync(ResolutionViewModel viewModel)
{
var model = new Resolution
{
Chars = viewModel.Chars, Colors = viewModel.Colors, Grayscale = viewModel.Grayscale,
Height = viewModel.Height, Palette = viewModel.Palette, Width = viewModel.Width
};
await _context.Resolutions.AddAsync(model);
await _context.SaveChangesAsync();
return model.Id;
}
public async Task DeleteAsync(int id)
{
Resolution item = await _context.Resolutions.FindAsync(id);
if(item is null)
return;
_context.Resolutions.Remove(item);
await _context.SaveChangesAsync();
}
}
}

View File

@@ -0,0 +1,9 @@
namespace Marechai.ViewModels
{
public class ResolutionByGpuViewModel : BaseViewModel<long>
{
public int ResolutionId { get; set; }
public int GpuId { get; set; }
public ResolutionViewModel Resolution { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace Marechai.ViewModels
{
public class ResolutionByScreenViewModel : BaseViewModel<long>
{
public int ResolutionId { get; set; }
public int ScreenId { get; set; }
public ResolutionViewModel Resolution { get; set; }
}
}