Files
marechai/Marechai/Pages/Admin/Details/SoftwareVariant.razor

404 lines
16 KiB
Plaintext

@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ 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/software_variants/details/{Id:long}"
@page "/admin/software_variants/edit/{Id:long}"
@page "/admin/software_variants/create"
@using Marechai.Database
@using Marechai.Database.Models
@inherits OwningComponentBase<SoftwareVariantsService>
@inject IStringLocalizer<SoftwareVariantsService> L
@inject SoftwareVersionsService SoftwareVersionsService
@inject LicensesService LicensesService
@inject CompaniesService CompaniesService
@inject DocumentRolesService DocumentRolesService
@inject CompaniesBySoftwareVariantService CompaniesBySoftwareVariantService
@inject NavigationManager NavigationManager
@inject IWebHostEnvironment Host
@inject IJSRuntime JSRuntime
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Software variant details"]</h3>
<hr />
@if (!_loaded)
{
<p align="center">@L["Loading..."]</p>
return;
}
<div>
<Field>
<FieldLabel>@L["Software version"]</FieldLabel>
<Select Disabled="!_editing" TValue="ulong" @bind-SelectedValue="@_model.SoftwareVersionId">
@foreach (var version in _softwareVersions)
{
<SelectItem TValue="ulong" Value="@version.Id">@version.Name ?? @version.Version</SelectItem>
}
</Select>
</Field>
@if (_editing || _model.Name != null)
{
<Field>
<FieldLabel>@L["Name, if different from software version name"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownName">@L["Unknown (name)"]</Check>
}
@if (!_editing ||
!_unknownName)
{
<Validation Validator="@ValidateName">
<TextEdit Disabled="!_editing" @bind-Text="@_model.Name">
<Feedback>
<ValidationError>@L["Please enter a valid name."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.Version != null)
{
<Field>
<FieldLabel>@L["Version, if different from software version's"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownVersion">@L["Unknown (version)"]</Check>
}
@if (!_editing ||
!_unknownVersion)
{
<Validation Validator="@ValidateVersion">
<TextEdit Disabled="!_editing" @bind-Text="@_model.Version">
<Feedback>
<ValidationError>@L["Please enter a valid version."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.Introduced != null)
{
<Field>
<FieldLabel>@L["Introduced"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownIntroduced">@L["Unknown (introduction date)"]</Check>
}
@if (!_editing || !_unknownIntroduced)
{
<Validation Validator="@ValidateIntroduced">
<DateEdit TValue="DateTime?" ReadOnly="!_editing" @bind-Date="@_model.Introduced" >
<Feedback>
<ValidationError>@L["Please enter a valid introduction date."]</ValidationError>
</Feedback>
</DateEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.ParentId != null)
{
<Field>
<FieldLabel>@L["Parent"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownParent">@L["Unknown or none (parent variant)"]</Check>
}
@if (!_editing ||
!_unknownParent)
{
<Select Disabled="!_editing" TValue="ulong?" @bind-SelectedValue="@_model.ParentId">
@foreach (var variant in _softwareVariants)
{
<SelectItem TValue="ulong?" Value="@variant.Id">@variant.Name ?? @variant.Version</SelectItem>
}
</Select>
}
</Field>
}
@if (_editing || _model.MinimumMemory.HasValue)
{
<Field>
<FieldLabel>@L["Minimum memory (bytes)"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownMinimumMemory">@L["Unknown (minimum memory)"]</Check>
}
@if (!_editing ||
!_unknownMinimumMemory)
{
<Validation Validator="@ValidateUnsignedLongBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="ulong?" Decimals="0" @bind-Value="@_model.MinimumMemory">
<Feedback>
<ValidationError>@L["Please enter the minimum memory size in bytes."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.RecommendedMemory.HasValue)
{
<Field>
<FieldLabel>@L["Recommended memory (bytes)"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownRecommendedMemory">@L["Unknown (recommended memory)"]</Check>
}
@if (!_editing ||
!_unknownRecommendedMemory)
{
<Validation Validator="@ValidateUnsignedLongBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="ulong?" Decimals="0" @bind-Value="@_model.RecommendedMemory">
<Feedback>
<ValidationError>@L["Please enter the recommended memory size in bytes."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.RequiredStorage.HasValue)
{
<Field>
<FieldLabel>@L["Required storage (bytes)"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownRequiredStorage">@L["Unknown (required storage)"]</Check>
}
@if (!_editing ||
!_unknownRequiredStorage)
{
<Validation Validator="@ValidateUnsignedLongBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="ulong?" Decimals="0" @bind-Value="@_model.RequiredStorage">
<Feedback>
<ValidationError>@L["Please enter the required storage size in bytes."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.PartNumber != null)
{
<Field>
<FieldLabel>@L["Part number"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownPartNumber">@L["Unknown (part number)"]</Check>
}
@if (!_editing ||
!_unknownPartNumber)
{
<Validation Validator="@ValidatePartNumber">
<TextEdit Disabled="!_editing" @bind-Text="@_model.PartNumber">
<Feedback>
<ValidationError>@L["Please enter a valid part number."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.SerialNumber != null)
{
<Field>
<FieldLabel>@L["Serial number"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownSerialNumber">@L["Unknown (serial number)"]</Check>
}
@if(_editing)
{
@L["Serial number is NOT the serial number used to install the software, but a serial number some software manufacturers use as SKU."]
}
@if (!_editing ||
!_unknownSerialNumber)
{
<Validation Validator="@ValidateSerialNumber">
<TextEdit Disabled="!_editing" @bind-Text="@_model.SerialNumber">
<Feedback>
<ValidationError>@L["Please enter a valid serial number."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.ProductCode != null)
{
<Field>
<FieldLabel>@L["Product code"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownProductCode">@L["Unknown (product code)"]</Check>
}
@if (!_editing ||
!_unknownProductCode)
{
<Validation Validator="@ValidateProductCode">
<TextEdit Disabled="!_editing" @bind-Text="@_model.ProductCode">
<Feedback>
<ValidationError>@L["Please enter a valid product code."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.CatalogueNumber != null)
{
<Field>
<FieldLabel>@L["Catalogue number"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownCatalogueNumber">@L["Unknown (catalogue number)"]</Check>
}
@if (!_editing ||
!_unknownCatalogueNumber)
{
<Validation Validator="@ValidateCatalogueNumber">
<TextEdit Disabled="!_editing" @bind-Text="@_model.CatalogueNumber">
<Feedback>
<ValidationError>@L["Please enter a valid catalogue number."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
}
</Field>
}
<Field>
<FieldLabel>@L["Distribution mode"]</FieldLabel>
<Select Disabled="!_editing" TValue="uint" @bind-SelectedValue="@Distribution">
@foreach (uint mode in Enum.GetValues(typeof(DistributionMode)))
{
<SelectItem TValue="uint" Value="@mode">@(((DistributionMode)mode).ToString())</SelectItem>
}
</Select>
</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/software_variants" class="btn btn-secondary">@L["Back to list"]</a>
</div>
@if (!_editing)
{
<hr />
<h3>@L["Companies involved in this software variant"]</h3>
<Button Color="Color.Success" Clicked="OnAddCompanyClick" Disabled="_addingCompany">@L["Add new (company)"]</Button>
@if (_addingCompany)
{
<div>
<Field>
<FieldLabel>@L["Company"]</FieldLabel>
<Select Disabled="_savingCompany" TValue="int?" @bind-SelectedValue="@_addingCompanyId">
@foreach (var company in _companies)
{
<SelectItem TValue="int?" Value="@company.Id">@company.Name</SelectItem>
}
</Select>
</Field>
<Field>
<FieldLabel>@L["Role"]</FieldLabel>
<Select Disabled="!_editing" TValue="string" @bind-SelectedValue="@_addingCompanyRoleId">
@foreach (var role in _roles)
{
<SelectItem TValue="string" Value="@role.Id">@role.Name</SelectItem>
}
</Select>
</Field>
<Button Color="Color.Primary" Clicked="@CancelAddCompany" Disabled="@_savingCompany">@L["Cancel"]</Button>
<Button Color="Color.Success" Clicked="@ConfirmAddCompany" Disabled="@_savingCompany">@L["Add"]</Button>
</div>
}
@if (_softwareVariantCompanies?.Count > 0)
{
<div>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Company"]
</th>
<th>
@L["Role"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _softwareVariantCompanies)
{
<tr>
<td>
@item.Company
</td>
<td>
@item.Role
</td>
<td>
<Button Color="Color.Danger" Clicked="() => {ShowCompanyDeleteModal(item.Id);}" Disabled="@_addingCompany">@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>
}