Skip to content

Commit f5138d8

Browse files
committed
PCF Showcase Remove /shell-descriptors appendix for communication wit IFrane code
1 parent 04304eb commit f5138d8

3 files changed

Lines changed: 81 additions & 67 deletions

File tree

src/AasxServerBlazor/Pages/Pcf2.razor

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@
363363
{
364364
var ad = aasDescriptors.FirstOrDefault(ad => ad.Id == node.aas.Id);
365365
var registryURL = ad.Extensions[0].Value;
366+
if (registryURL.EndsWith("/shell-descriptors"))
367+
{
368+
registryURL = registryURL.Substring(0, registryURL.Length - "/shell-descriptors".Length);
369+
}
366370

367371
if (AasxCredentials.get(AasxTaskService, cs.credentials, registryURL, out queryPara, out userPW, out urlEdcWrapper, out replace, true))
368372
{

src/AasxServerBlazor/Shared/MainLayout.razor

Lines changed: 64 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -263,69 +263,74 @@
263263
}
264264
</div>
265265

266-
@code{
267-
268-
static List<string> roleList = new()
266+
@code{
267+
268+
static List<string> roleList = new()
269269
{
270270
"Anonym", "Isabelle", "Steven", "Albert"
271271
};
272272

273-
static string _role = roleList[ 0 ];
274-
static string _input = string.Empty;
275-
static string _watchText = string.Empty;
276-
static string _path = string.Empty;
277-
static bool _loading;
278-
static bool _edit;
279-
280-
//TODO: code duplication with Pcf2.razor
281-
static string getAasLink(IIdentifiable aas)
282-
{
283-
string endpoint = null;
284-
var idEncoded = Base64UrlEncoder.Encode(aas.Id);
285-
if (aas.Extensions != null)
286-
{
287-
endpoint = aas.Extensions[ 0 ].Value;
288-
}
289-
else
290-
{
291-
endpoint = Program.externalBlazor + "/shells/" + idEncoded;
292-
}
293-
294-
return endpoint;
295-
}
296-
297-
string getIframePath()
298-
{
299-
var link = "";
300-
//get the admin shell of the cabinet
301-
foreach (var env in AasxServer.Program.env)
302-
{
303-
if (env != null)
304-
{
305-
var queryPara = "";
306-
var userPW = "";
307-
var urlEdcWrapper = "";
308-
string replace = "";
309-
310-
var aas = env.AasEnv.AssetAdministrationShells[ 0 ];
311-
if (aas.IdShort != "ZveiControlCabinetAas - EXTERNAL")
312-
continue;
313-
314-
link = getAasLink(aas);
315-
316-
var registry = AasRegistryService.GetRegistryList();
317-
if (registry != null && registry.Count != 0)
318-
{
319-
string registryURL = registry[ 0 ];
320-
321-
if (AasxCredentials.get(AasxTaskService, cs.credentials, registryURL, out queryPara, out userPW, out urlEdcWrapper, out replace, true))
322-
{
323-
if (replace != "")
324-
registryURL = replace;
325-
}
326-
327-
link += "&registryURL=" + registryURL;
328-
}
273+
static string _role = roleList[ 0 ];
274+
static string _input = string.Empty;
275+
static string _watchText = string.Empty;
276+
static string _path = string.Empty;
277+
static bool _loading;
278+
static bool _edit;
279+
280+
//TODO: code duplication with Pcf2.razor
281+
static string getAasLink(IIdentifiable aas)
282+
{
283+
string endpoint = null;
284+
var idEncoded = Base64UrlEncoder.Encode(aas.Id);
285+
if (aas.Extensions != null)
286+
{
287+
endpoint = aas.Extensions[ 0 ].Value;
288+
}
289+
else
290+
{
291+
endpoint = Program.externalBlazor + "/shells/" + idEncoded;
292+
}
293+
294+
return endpoint;
295+
}
296+
297+
string getIframePath()
298+
{
299+
var link = "";
300+
//get the admin shell of the cabinet
301+
foreach (var env in AasxServer.Program.env)
302+
{
303+
if (env != null)
304+
{
305+
var queryPara = "";
306+
var userPW = "";
307+
var urlEdcWrapper = "";
308+
string replace = "";
309+
310+
var aas = env.AasEnv.AssetAdministrationShells[ 0 ];
311+
if (aas.IdShort != "ZveiControlCabinetAas - EXTERNAL")
312+
continue;
313+
314+
link = getAasLink(aas);
315+
316+
var registry = AasRegistryService.GetRegistryList();
317+
if (registry != null && registry.Count != 0)
318+
{
319+
string registryURL = registry[0];
320+
321+
if (registryURL.EndsWith("/shell-descriptors"))
322+
{
323+
registryURL = registryURL.Substring(0, registryURL.Length - "/shell-descriptors".Length);
324+
}
325+
326+
if (AasxCredentials.get(AasxTaskService, cs.credentials, registryURL, out queryPara, out userPW, out urlEdcWrapper, out replace, true))
327+
{
328+
if (replace != "")
329+
registryURL = replace;
330+
}
331+
332+
link += "&registryURL=" + registryURL;
333+
}
329334

330335
queryPara = "";
331336
userPW = "";

src/IO.Swagger.Registry.Lib.V3/Services/RegistryInitializerService.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace IO.Swagger.Registry.Lib.V3.Services;
3838
using System.Globalization;
3939
using AasxServerDB;
4040
using AdminShellNS;
41-
41+
4242
public class RegistryInitializerService : IRegistryInitializerService
4343
{
4444
private const string AasxFilesChainPfx = "/aasx/files/Andreas_Orzelski_Chain.pfx";
@@ -184,7 +184,7 @@ public async Task InitRegistry(List<AasxCredentialsEntry> cList, DateTime timest
184184
getRegistry.Add(registryURL);
185185
}
186186
}
187-
}
187+
}
188188

189189
if (p.IdShort?.ToLower(CultureInfo.InvariantCulture) == "getregistryofregistry")
190190
{
@@ -422,8 +422,12 @@ public async Task InitRegistry(List<AasxCredentialsEntry> cList, DateTime timest
422422
submodelRegistryUrl = submodelRegistryUrl.Replace("\r", "");
423423
submodelRegistryUrl = submodelRegistryUrl.Replace("\n", "");
424424

425-
// basyx with Submodel Registry: read submodel descriptors
426-
requestPathGetReg = $"{submodelRegistryUrl}/submodel-descriptors";
425+
// basyx with Submodel Registry: read submodel descriptors
426+
if (!submodelRegistryUrl.EndsWith("submodel-descriptors"))
427+
{
428+
requestPathGetReg = $"{submodelRegistryUrl}/submodel-descriptors";
429+
430+
}
427431

428432
if (AasxCredentials.get(_aasxTaskService, cs.credentials, requestPathGetReg, out _, out _, out _, out var replace) && !string.IsNullOrEmpty(replace))
429433
{
@@ -810,7 +814,7 @@ public async Task InitRegistry(List<AasxCredentialsEntry> cList, DateTime timest
810814
}
811815

812816
if (sm != null)
813-
{
817+
{
814818
sm.Extensions = new List<IExtension>
815819
{
816820
new Extension("endpoint", value: sd.Endpoints?[0].ProtocolInformation?.Href),
@@ -887,8 +891,8 @@ public async Task InitRegistry(List<AasxCredentialsEntry> cList, DateTime timest
887891
{
888892
if (external)
889893
sm.IdShort = $"{sd.IdShort} - EXTERNAL";
890-
}
891-
894+
}
895+
892896
sm.Extensions = new List<IExtension>
893897
{
894898
new Extension("endpoint", value: sd.Endpoints?[0].ProtocolInformation.Href),
@@ -1098,7 +1102,8 @@ private void transmitDescriptor(AssetAdministrationShellDescriptor? ad, Submodel
10981102
{
10991103
if (sd != null)
11001104
{
1101-
if (!requestPath.Contains("?", StringComparison.InvariantCulture))
1105+
if (!requestPath.Contains("?", StringComparison.InvariantCulture)
1106+
&& !requestPath.EndsWith("/submodel-descriptors"))
11021107
{
11031108
requestPath += "/submodel-descriptors";
11041109
}

0 commit comments

Comments
 (0)