blob: d56e5508c0d14eef2ed69b4fcb32de4917edf5b3 [file] [log] [blame]
@page
@model BaSyx.Common.UI.Pages.AssetAdministrationShellRepositoryModel
@using BaSyx.API.Components;
@using BaSyx.Models.Core.AssetAdministrationShell.Generics;
@using BaSyx.Utils.Settings.Types;
@using Microsoft.AspNetCore.Hosting;
@using System.Security.Cryptography;
@using System.Text;
@using System.Text.RegularExpressions;
@{
IAssetAdministrationShellRepositoryServiceProvider sp = Model.ServiceProvider;
IEnumerable<IAssetAdministrationShellServiceProvider> shellServiceProviders = null;
var retrievedShellServiceProviders = sp.GetAssetAdministrationShellServiceProviders();
if (retrievedShellServiceProviders.Success && retrievedShellServiceProviders.Entity != null)
{
shellServiceProviders = retrievedShellServiceProviders.Entity;
}
IHostingEnvironment hostingEnvironment = Model.HostingEnvironment;
ServerSettings settings = Model.Settings;
string pathToCompanyLogo = settings.Miscellaneous.TryGetValue("CompanyLogo", out string path) ? path : string.Empty;
ViewData["Title"] = "Asset Administration Shell Repository";
ViewData["ApiRoot"] = "/shells";
ViewData["CompanyLogo"] = pathToCompanyLogo;
ViewData["ApiType"] = "AssetAdministrationShellRepository";
}
@functions
{
private static string GetHashString(string input)
{
SHA256 shaAlgorithm = SHA256.Create();
byte[] data = Encoding.UTF8.GetBytes(input);
byte[] bHash = shaAlgorithm.ComputeHash(data);
string hashString = string.Empty;
for (int i = 0; i < bHash.Length; i++)
{
hashString += bHash[i].ToString("x2");
}
var output = Regex.Replace(hashString, @"[\d-]", string.Empty);
return output;
}
}
<div class="starter-template">
<h1>Asset Administration Shell Repository UI</h1>
<p class="lead">Generic UI to display many Asset Administration Shells</p>
</div>
@if (shellServiceProviders?.Count() > 0)
{
foreach (var shellServiceProvider in shellServiceProviders)
{
IAssetAdministrationShell aas = shellServiceProvider.GetBinding();
<div class="card border-dark mb-3">
<div class="card-header bg-dark">
<h4>
<a class="text-white" data-toggle="collapse" href="#@GetHashString(aas.IdShort)">@aas.IdShort</a>
</h4>
</div>
<div id="@GetHashString(aas.IdShort)" class="collapse">
<ul class="list-group list-group-flush">
@await Html.PartialAsync("_IdShort", aas.IdShort)
@await Html.PartialAsync("_Identifier", aas.Identification)
@await Html.PartialAsync("_Description", aas.Description)
</ul>
<div class="card-body">
@await Html.PartialAsync("_Asset", aas.Asset)
@{
IEnumerable<ISubmodelServiceProvider> submodelServiceProviders = null;
var retrievedSubmodelServiceProvider = shellServiceProvider.SubmodelRegistry.GetSubmodelServiceProviders();
if (retrievedSubmodelServiceProvider.Success && retrievedSubmodelServiceProvider.Entity != null)
{
submodelServiceProviders = retrievedSubmodelServiceProvider.Entity;
}
}
@if (submodelServiceProviders?.Count() > 0)
{
foreach (var submodelServiceProvider in submodelServiceProviders)
{
ISubmodel submodel = submodelServiceProvider.GetBinding();
@await Html.PartialAsync("_Submodel", submodel, new ViewDataDictionary(ViewData) { {"aasId", aas.IdShort} })
}
}
</div>
</div>
</div>
}
}