mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
155 lines
5.6 KiB
Plaintext
155 lines
5.6 KiB
Plaintext
@{
|
|
/******************************************************************************
|
|
// MARECHAI: Master repository of computing history artifacts information
|
|
// ----------------------------------------------------------------------------
|
|
//
|
|
// Filename : Index.razor
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
//
|
|
// --[ Description ] ----------------------------------------------------------
|
|
//
|
|
// Lists all companies or companies by country
|
|
//
|
|
// --[ 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 "/companies"
|
|
@page "/companies/country/{CountryId:int}"
|
|
@page "/companies/{StartingCharacter}"
|
|
@inherits OwningComponentBase<CompaniesService>
|
|
@inject IStringLocalizer<CompaniesService> L
|
|
@inject IWebHostEnvironment Host
|
|
|
|
@if (_companies is null)
|
|
{
|
|
<p align="center">@L["Loading..."]</p>
|
|
|
|
return;
|
|
}
|
|
|
|
<p align="center">
|
|
@if (CountryId.HasValue)
|
|
{
|
|
<b>@string.Format(L["Companies founded in {0}."], L[_countryName])</b>
|
|
if (File.Exists(System.IO.Path.Combine(Host.WebRootPath, "assets/flags/countries", CountryId + ".svg")))
|
|
{
|
|
<picture>
|
|
<source type="image/svg+xml" srcset="/assets/flags/countries/@(CountryId).svg">
|
|
<source type="image/webp" srcset="/assets/flags/countries/webp/1x/@(CountryId).webp,
|
|
/assets/flags/countries/webp/1x/@(CountryId).webp 2x,
|
|
/assets/flags/countries/webp/1x/@(CountryId).webp 3x">
|
|
<img srcset="/assets/flags/countries/png/1x/@(CountryId).png,
|
|
/assets/flags/countries/png/1x/@(CountryId).png 2x,
|
|
/assets/flags/countries/png/1x/@(CountryId).webp 3x" src="/assets/flags/countries/png/1x@(CountryId).png" alt="" height="32" />
|
|
</picture>
|
|
}
|
|
<br />
|
|
}
|
|
|
|
@if (_character.HasValue)
|
|
{
|
|
<b>@string.Format(L["Companies which name starts with {0}."], _character)</b>
|
|
<br />
|
|
}
|
|
|
|
@if (_companies.Any())
|
|
{
|
|
<p>
|
|
@string.Format(L["{0} companies found in the database."], _companies.Count())
|
|
<br />
|
|
@foreach (var company in _companies)
|
|
{
|
|
<a href="/companies/@company.Id">
|
|
@if (company.LastLogo != null &&
|
|
File.Exists(Path.Combine(Host.WebRootPath, "assets/logos", company.LastLogo + ".svg")))
|
|
{
|
|
<picture>
|
|
<source type="image/svg+xml" srcset="/assets/logos/@(company.LastLogo).svg">
|
|
<source type="image/webp" srcset="/assets/logos/thumbs/webp/1x/@(company.LastLogo).webp,
|
|
/assets/logos/thumbs/webp/2x/@(company.LastLogo).webp 2x,
|
|
/assets/logos/thumbs/webp/3x/@(company.LastLogo).webp 3x">
|
|
<img srcset="/assets/logos/thumbs/png/1x/@(company.LastLogo).png,
|
|
/assets/logos/thumbs/png/2x/@(company.LastLogo).png 2x,
|
|
/assets/logos/thumbs/png/3x/@(company.LastLogo).png 3x" src="/assets/logos/thumbs/png/1x@(company.LastLogo).png" alt="" height="auto" width="auto" style="max-height: 32px; max-width: 128px" />
|
|
</picture>
|
|
}
|
|
@company.Name
|
|
</a>
|
|
<br />
|
|
}
|
|
</p>
|
|
}
|
|
else
|
|
{
|
|
<p>@L["There are no companies in the database."]</p>
|
|
}
|
|
</p>
|
|
|
|
@code
|
|
{
|
|
[Parameter]
|
|
public int? CountryId { get; set; }
|
|
|
|
[Parameter]
|
|
public string StartingCharacter { get; set; }
|
|
|
|
List<CompanyViewModel> _companies;
|
|
string _countryName;
|
|
char? _character;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_character = null;
|
|
if (!string.IsNullOrWhiteSpace(StartingCharacter) &&
|
|
StartingCharacter.Length == 1)
|
|
{
|
|
_character = StartingCharacter[0];
|
|
|
|
// ToUpper()
|
|
if (_character >= 'a' &&
|
|
_character <= 'z')
|
|
_character -= (char)32;
|
|
|
|
|
|
// Check if not letter or number
|
|
if (_character < '0' ||
|
|
(_character > '9' && _character < 'A') ||
|
|
_character > 'Z')
|
|
_character = null;
|
|
}
|
|
|
|
if (_character.HasValue)
|
|
_companies = await Service.GetCompaniesByLetterAsync(_character.Value);
|
|
|
|
if (CountryId.HasValue && _companies is null)
|
|
{
|
|
_countryName = await Service.GetCountryNameAsync(CountryId.Value);
|
|
|
|
if (_countryName != null)
|
|
{
|
|
_companies = await Service.GetCompaniesByCountryAsync(CountryId.Value);
|
|
}
|
|
else
|
|
CountryId = null;
|
|
}
|
|
|
|
_companies ??= await Service.GetCompaniesAsync();
|
|
}
|
|
} |