Skip to content

Commit

Permalink
* upload of attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
festo-i40 committed Dec 29, 2024
1 parent ef938db commit 5f94093
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/AasxCsharpLibrary/AdminShellUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ public static string FilterFriendlyName(string src,
if (pascalCase && src.Length > 0)
src = char.ToUpper(src[0]) + src.Substring(1);

var regex = regexForFilter ?? @"[^a-zA-Z0-9\-_]";
var regex = regexForFilter ?? @"[^a-zA-Z0-9_]";
src = Regex.Replace(src, regex, "_");

if (fixMoreBlanks)
Expand Down
2 changes: 1 addition & 1 deletion src/AasxPackageExplorer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@
</Grid>

<Label x:Name="Message"
Margin="2,3,2,2" Padding="0, 2, 0, 0"
Margin="2,3,2,2" Padding="2, 2, 0, 0"
Content="Ready"
VerticalContentAlignment="Center"/>
</DockPanel>
Expand Down
45 changes: 27 additions & 18 deletions src/AasxPackageExplorer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public PackageCentral PackageCentral

public AasxMenuWpf MainMenu = new AasxMenuWpf();

private Aas.ISubmodelElement _showContentElement = null;
private VisualElementGeneric _showContentElement = null;
private VisualElementGeneric currentEntityForUpdate = null;
private IFlyoutControl currentFlyoutControl = null;

Expand Down Expand Up @@ -714,18 +714,11 @@ public void PrepareDispEditEntity(
// some entities require special handling
if (entities?.ExactlyOne == true && entities.First() is VisualElementSubmodelElement sme)
{
if (sme?.theWrapper is Aas.IFile file)
if (sme?.theWrapper is Aas.IFile || sme?.theWrapper is Aas.IBlob)
{
ShowContent.IsEnabled = true;
_showContentElement = file;
DragSource.Foreground = Brushes.Black;
}

if (sme?.theWrapper is Aas.IBlob blb)
{
ShowContent.IsEnabled = true;
this._showContentElement = blb;
DragSource.Foreground = Brushes.Black;
_showContentElement = entities.First();
}
}

Expand Down Expand Up @@ -3103,7 +3096,15 @@ public void LogShow()
{
// show only if not present
if (_messageReportWindow != null)
{
// this is ridiculous, but this seems to make the trick
// https://stackoverflow.com/questions/257587/bring-a-window-to-the-front-in-wpf
_messageReportWindow.Activate();
_messageReportWindow.Topmost = true; // important
_messageReportWindow.Topmost = false; // important
_messageReportWindow.Focus(); // important
return;
}

// Collect all the stored log prints
IEnumerable<StoredPrint> Prints()
Expand Down Expand Up @@ -3364,15 +3365,18 @@ private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
}
}

private void ShowContent_Click(object sender, RoutedEventArgs e)
private async void ShowContent_Click(object sender, RoutedEventArgs e)
{
if (sender == ShowContent && _showContentElement != null && PackageCentral.MainAvailable)
await Task.Yield();

if (sender == ShowContent && _showContentElement != null && PackageCentral.MainAvailable
&& _showContentElement is VisualElementSubmodelElement veSme)
{
//
// Text edit of BLOB?
//

if (this._showContentElement is Aas.IBlob blb
if (veSme?.theWrapper is Aas.IBlob blb
&& MainMenu?.IsChecked("EditMenu") == true
&& AdminShellUtil.CheckForTextContentType(blb.ContentType))
{
Expand All @@ -3399,7 +3403,7 @@ private void ShowContent_Click(object sender, RoutedEventArgs e)
return;
}

if (this._showContentElement is Aas.IFile file
if (veSme?.theWrapper is Aas.IFile file
&& MainMenu?.IsChecked("EditMenu") == true
&& AdminShellUtil.CheckForTextContentType(file.ContentType))
{
Expand All @@ -3419,9 +3423,9 @@ private void ShowContent_Click(object sender, RoutedEventArgs e)
//

Tuple<object, string> contentFound = null;
if (_showContentElement is Aas.IFile scFile)
if (veSme?.theWrapper is Aas.IFile scFile)
contentFound = new Tuple<object, string>(scFile.Value, scFile.ContentType);
if (_showContentElement is Aas.IBlob scBlob && MainMenu?.IsChecked("EditMenu") == false)
if (veSme?.theWrapper is Aas.IBlob scBlob && MainMenu?.IsChecked("EditMenu") == false)
contentFound = new Tuple<object, string>(scBlob.Value, scBlob.ContentType);

if (contentFound != null)
Expand All @@ -3435,8 +3439,13 @@ private void ShowContent_Click(object sender, RoutedEventArgs e)
if (!contentUri.ToLower().Trim().StartsWith("http://")
&& !contentUri.ToLower().Trim().StartsWith("https://"))
{
// make it as file
contentUri = PackageCentral.Main.MakePackageFileAvailableAsTempFile(contentUri);
// make it a file?
// more info for Registry/ Repo available?
var x = veSme.FindAasSubmodelIdShortPath();
contentUri = await PackageCentral.Main.MakePackageFileAvailableAsTempFileAsync(contentUri,
aasId: x?.Item1?.Id,
smId: x?.Item2?.Id,
idShortPath: x?.Item3);
}

BrowserDisplayLocalFile(contentUri, contentFound.Item2);
Expand Down
4 changes: 2 additions & 2 deletions src/AasxPackageExplorer/debug.MIHO.script
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
// Tool("exportsmtasciidoc", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\new.zip", "AntoraStyle", "true");
Tool("editkey");
// Tool("createrepofromapi", "BaseAddress", "http://localhost:5001/api/v3.0/", "BaseType", "Repository");
Tool("connectextended", "BaseAddress", "http://smt-repo.admin-shell-io.com/api/v3.0", "BaseType", "Repository", "GetAllAas", "false", "GetSingleAas", "true", "AasId", "https://admin-shell.io/idta/aas/DigitalNameplate/3/0", "AutoLoadOnDemand", "false", "AutoLoadCds", "true", "ParallelReads", "10");
// Tool("connectextended", "BaseAddress", "http://smt-repo.admin-shell-io.com/api/v3.0", "BaseType", "Repository", "GetAllAas", "false", "GetSingleAas", "true", "AasId", "https://admin-shell.io/idta/aas/DigitalNameplate/3/0", "AutoLoadOnDemand", "false", "AutoLoadCds", "true", "ParallelReads", "10");
// Tool("connectextended", "BaseAddress", "http://smt-repo.admin-shell-io.com/api/v3.0", "BaseType", "Repository", "GetSingleAas", "false", "GetAllAas", "true", "PageLimit", "4", "AutoLoadOnDemand", "false", "AutoLoadCds", "true");
// Tool("connectextended", "BaseAddress", "http://localhost:5001/api/v3.0/", "BaseType", "Repository", "GetSingleAas", "false", "GetAllAas", "true", "PageLimit", "99", "AutoLoadOnDemand", "false");
// Tool("connectextended", "BaseAddress", "http://localhost:5001/api/v3.0/", "BaseType", "Repository", "GetSingleAas", "true", "AasId", "http://smart.festo.com/id/demo-box/aas/instance/99920202206560529000071817", "AutoLoadOnDemand", "false");
// Tool("connectextended", "BaseAddress", "https://eis-data.aas-voyager.com/", "BaseType", "Repository", "GetSingleAas", "true", "PageLimit", "2", "AutoLoadOnDemand", "false", "AasId", "https://new.abb.com/products/de/2CSF204101R1400/aas");
// Tool("connectextended", "BaseAddress", "https://techday2-registry.admin-shell-io.com/", "BaseType", "Registry", "GetSingleAas", "false", "GetAasByAssetLink", "true", "PageLimit", "2", "AutoLoadOnDemand", "false", "AssetId", "https://pk.harting.com/?.20P=ZSN1");
// Select("AAS", "First");
// Tool("apiuploadassistant");
Tool("apiuploadassistant", "BaseAddress", "http://localhost:5001/api/v3.0/", "IncludeSubmodels", true, "IncludeCDs", true, "IncludeSupplFiles", true, "OverwriteIfExist", true);
// Select("Submodel", "First");
// Select("Submodel", "Next");
// Tool("exportsmtasciidoc", "File", "C:\Users\homi0002\Desktop\tmp\new.zip", "ExportHtml", "true", "ExportPdf", "false", "AntoraStyle", "false", "ViewResult", "true");
Expand Down
3 changes: 2 additions & 1 deletion src/AasxPackageExplorer/options-debug.MIHO.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx",
// "AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\test-data\\MTP\\test-data-SMT_MTP.aasx",
"AasxToLoad": "C:\\Users\\Micha\\Desktop\\Demo\\AASX\\8001203_SPAU-P10R-T-R18M-L-PNLK-PNVBA-M8D_060ff64f-9fd2-422d-81ce-b17e49f007c5_work.aasx",
// "AasxToLoad": "C:\\Users\\Micha\\Desktop\\Demo\\AASX\\8001203_SPAU-P10R-T-R18M-L-PNLK-PNVBA-M8D_060ff64f-9fd2-422d-81ce-b17e49f007c5_work.aasx",
"AasxToLoad": "C:\\Users\\Micha\\Desktop\\t3\\dnp-t30.aasx",
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\00_FestoDemoBox-Module-2-Kopie.aasx",
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\8001203_SPAU-P10R-T-R18M-L-PNLK-PNVBA-M8D_060ff64f-9fd2-422d-81ce-b17e49f007c5_work_spiel.aasx",
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\1449600_NEBM-SM12G8-E-1.5-Q5-LE6_511946fb-00c1-4aa8-9877-9ba23d86146e.aasx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public override async Task<byte[]> GetBytesFromPackageOrExternalAsync(
return absBytes;

// ok, try to load from the server
if (aasId?.HasContent() != true || idShortPath?.HasContent() != true
if (aasId?.HasContent() != true || smId?.HasContent() != true || idShortPath?.HasContent() != true
|| _defaultRepoBaseUri == null)
return null;

Expand Down
Loading

0 comments on commit 5f94093

Please sign in to comment.