Add screen details in admin view.

This commit is contained in:
2020-05-26 04:36:42 +01:00
parent 3d2f0b7183
commit a10fbda825
7 changed files with 151 additions and 55 deletions

View File

@@ -0,0 +1,94 @@
@{
/******************************************************************************
// 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/screens/details/{Id:int}"
@inherits OwningComponentBase<ScreensService>
@inject IStringLocalizer<ScreensService> L
@inject ResolutionsService ResolutionsService
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Screen details"]</h3>
<hr />
@if (!_loaded)
{
<p align="center">@L["Loading..."]</p>
return;
}
<div>
@if (_editable || _model.Width.HasValue)
{
<Field>
<FieldLabel>@L["Width (mm)"]</FieldLabel>
<NumericEdit Disabled="!_editable" TValue="double?" Decimals="2" @bind-Value="@_model.Width"/>
</Field>
}
@if (_editable || _model.Height.HasValue)
{
<Field>
<FieldLabel>@L["Height (mm)"]</FieldLabel>
<NumericEdit Disabled="!_editable" TValue="double?" Decimals="0" @bind-Value="@_model.Height"/>
</Field>
}
<Field>
<FieldLabel>@L["Diagonal (inches)"]</FieldLabel>
<NumericEdit Disabled="!_editable" TValue="double" Decimals="2" @bind-Value="@_model.Diagonal"/>
</Field>
@if (_editable || _model.EffectiveColors.HasValue)
{
<Field>
<FieldLabel>@L["Effective colors"]</FieldLabel>
<NumericEdit Disabled="!_editable" TValue="long?" Decimals="0" @bind-Value="@_model.EffectiveColors"/>
</Field>
}
@if (_editable || _model.Type != null)
{
<Field>
<FieldLabel>@L["Type"]</FieldLabel>
<TextEdit ReadOnly="!_editable" @bind-Text="@_model.Type" />
</Field>
}
<Field>
<FieldLabel>@L["Native resolution"]</FieldLabel>
<Select Disabled="!_editable" TValue="int" @bind-SelectedValue="@_model.NativeResolutionId">
@foreach (var resolution in _resolutions)
{
<SelectItem TValue="int" Value="@resolution.Id">@resolution.ToString()</SelectItem>
}
</Select>
</Field>
</div>
<div>
<span class="btn btn-primary">@L["Edit"]</span>
<a href="/admin/screens" class="btn btn-secondary">@L["Back to list"]</a>
</div>

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
namespace Marechai.Pages.Admin.Details
{
public partial class Screen
{
bool _editable;
bool _loaded;
Database.Models.Screen _model;
List<ResolutionViewModel> _resolutions;
[Parameter]
public int Id { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(_loaded)
return;
_loaded = true;
if(Id <= 0)
return;
_resolutions = await ResolutionsService.GetAsync();
_model = await Service.GetAsync(Id);
StateHasChanged();
}
}
}

View File

@@ -31,7 +31,6 @@
}
@page "/admin/screens"
@using Marechai.Database.Models
@inherits OwningComponentBase<ScreensService>
@inject IStringLocalizer<ScreensService> L
@attribute [Authorize(Roles = "UberAdmin, Admin")]
@@ -82,9 +81,7 @@
@item.Type
</td>
<td>
<span class="btn btn-primary">
@L["Details"]
</span>
<a class="btn btn-primary" href="/admin/screens/details/@item.Id">@L["Details"]</a>
<span class="btn btn-secondary">
@L["Edit"]
</span>