Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using AXSharp.Connector;
using System;

namespace AXSharp.Abstractions.Dialogs.ActionDialog
{
public interface IsDialog : ITwinObject
{
string DialogId { get; set; }
void Initialize(Action dialogAction);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using AXSharp.Abstractions.Dialogs.AlertDialog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Timers;

namespace AXSharp.Abstractions.Dialogs.AlertDialog
{
public class AlertDialogServiceBase : IAlertDialogService
{
public event EventHandler AlertDialogChanged;

public void AddToast(string type, string title, string message, int time)
{
throw new NotImplementedException();
}

public void AddAlertDialog(string type, string title, string message, int time)
{
throw new NotImplementedException();
}

public void AddAlertDialog(IAlertDialog toast)
{
throw new NotImplementedException();
}

public List<IAlertDialog> GetAlertDialogs()
{
throw new NotImplementedException();
}

public void RemoveAlertDialog(IAlertDialog toast)
{
throw new NotImplementedException();
}

public void RemoveAllAlertDialogs()
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace AXSharp.Abstractions.Dialogs.AlertDialog
{
public interface IAlertDialog
{
public Guid Id { get; set; }
public string Type { get; set; }
public string Title { get; set; }
public string Message { get; set; }
public DateTimeOffset TimeToBurn { get; set; }
public DateTimeOffset Posted { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;


namespace AXSharp.Abstractions.Dialogs.AlertDialog
{
public interface IAlertDialogService
{
public event EventHandler? AlertDialogChanged;
public void AddAlertDialog(string type, string title, string message, int time);
public void AddAlertDialog(IAlertDialog toast);
public List<IAlertDialog> GetAlertDialogs();
public void RemoveAlertDialog(IAlertDialog toast);
public void RemoveAllAlertDialogs();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.10" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client.Core" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using AXSharp.Presentation.Blazor.Interfaces;
using AXSharp.Connector.ValueTypes.Online;
using System.Xml.Linq;
using AXSharp.Abstractions.Dialogs.AlertDialog;

namespace AXSharp.Presentation.Blazor.Controls.RenderableContent
{
Expand All @@ -26,6 +27,10 @@ public partial class RenderableComponentBase : ComponentBase, IRenderableCompone
{
[Parameter] public int PollingInterval { get; set; }

[CascadingParameter]
public IAlertDialogService AlertDialogService { get; set; }


///<inheritdoc/>
public virtual void Dispose()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Reflection;
using System.ComponentModel;
using AXSharp.Connector.ValueTypes;
using AXSharp.Abstractions.Dialogs.AlertDialog;

namespace AXSharp.Presentation.Blazor.Controls.RenderableContent
{
Expand Down Expand Up @@ -84,6 +85,20 @@ public string Presentation
private Type _groupContainer { get; set; }
public Type MainLayoutType { get; set; }


private IAlertDialogService _alertDialogService;

[Parameter]
public IAlertDialogService AlertDialogService {
get
{
if(_alertDialogService == null)
_alertDialogService = new AlertDialogServiceBase();
return _alertDialogService;
}
set => _alertDialogService = value;
}

private ITwinElement _context { get; set; }
protected override void OnInitialized()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@*This class is view part of RenderableContentControl. It contains UI generation pipeline.*@

@*Call rendering method over context object*@
@*Call rendering method over context object*@
<CascadingValue Value="@AlertDialogService">
<div name="@_context.Symbol.Replace(".","-")" class="@Class">
@RenderComponent(_context)
</div>
</CascadingValue>



Expand All @@ -24,17 +26,18 @@
var component = ViewLocatorBuilder(twinType, twin, Presentation);
if (component != null)
{
@CreateComplexComponent(twin, component);
@CreateComplexComponent(twin, component)
;
}
else
{
var groupName = String.IsNullOrEmpty(twin.AttributeName) ? twin.GetSymbolTail() : twin.AttributeName;
//otherwise render children and set MainLayout
<GroupContainerAttributeSetter GroupType="_groupContainer" GroupName="@groupName">
<MainLayoutSetter LayoutType="@MainLayoutType" GroupBoxName="@groupName" LayoutClass="@LayoutClass">
@RenderChildren(twin, MainLayoutType)
</MainLayoutSetter>
</GroupContainerAttributeSetter>
<GroupContainerAttributeSetter GroupType="_groupContainer" GroupName="@groupName">
<MainLayoutSetter LayoutType="@MainLayoutType" GroupBoxName="@groupName" LayoutClass="@LayoutClass">
@RenderChildren(twin, MainLayoutType)
</MainLayoutSetter>
</GroupContainerAttributeSetter>
}
};

Expand Down Expand Up @@ -62,13 +65,13 @@
@Generator(child, parentLayout)
}
else
{
{
var name = String.IsNullOrEmpty(child.AttributeName) ? child.GetSymbolTail() : child.AttributeName;
//otherwise is value tag or has mainLayout set, add children layout and continue
<ChildrenLayoutPropSetter ChildName="@name"
ChildrenLayout="@parentLayout"
ChildContent="@Generator(child,null)"
Class="@LayoutChildrenClass"/>
ChildrenLayout="@parentLayout"
ChildContent="@Generator(child,null)"
Class="@LayoutChildrenClass" />
}
canEnumerate = enumerator.MoveNext();
}
Expand All @@ -79,11 +82,11 @@
var groupContainer = TryLoadGroupTypeFromProperty(child);

<GroupLayoutSetter ParentLayout="@parentLayout"
GroupLayout="@groupLayout"
GroupContainer="@groupContainer"
GroupName="@group.GroupName"
LayoutClass="@LayoutClass">
@RenderGroup(group, groupLayout)
GroupLayout="@groupLayout"
GroupContainer="@groupContainer"
GroupName="@group.GroupName"
LayoutClass="@LayoutClass">
@RenderGroup(group, groupLayout)
</GroupLayoutSetter>

}
Expand All @@ -96,27 +99,27 @@
{
foreach (var child in group.GroupElements)
{

//if child is complex, we can again call recursively and generate it's groups
if (child is ITwinObject complex)
{
@Generator(complex, group.GroupLayout)
}
else
{
var name = String.IsNullOrEmpty(child.AttributeName) ? child.GetSymbolTail() : child.AttributeName;
<ChildrenLayoutPropSetter ChildName="@name"
ChildrenLayout="@groupLayout"
ChildContent="@Generator(child, groupLayout)"
Class="@LayoutChildrenClass" />
var name = String.IsNullOrEmpty(child.AttributeName) ? child.GetSymbolTail() : child.AttributeName;
<ChildrenLayoutPropSetter ChildName="@name"
ChildrenLayout="@groupLayout"
ChildContent="@Generator(child, groupLayout)"
Class="@LayoutChildrenClass" />
}
}

};

private RenderFragment Generator(ITwinElement kid, Type layout) => __builder =>
{

if (IsEnumerator(kid))
{
var enumDiscriminatorAttribute = AttributesHandler.GetEnumeratorDiscriminatorAttribute(kid);
Expand All @@ -138,23 +141,23 @@
private RenderFragment GenerateComplex(ITwinObject twin, Type layout) => __builder =>
{
Type mainLayout = null;

var component = ViewLocatorBuilder(twin.GetType(), twin, Presentation);
if (component != null)
{
var name = String.IsNullOrEmpty(twin.AttributeName) ? twin.GetSymbolTail() : twin.AttributeName;
<ChildrenLayoutPropSetter ChildName="@name"
ChildrenLayout="layout"
ChildContent="@CreateComplexComponent(twin, component)"
Class="@LayoutChildrenClass" />
ChildrenLayout="layout"
ChildContent="@CreateComplexComponent(twin, component)"
Class="@LayoutChildrenClass" />
}
else
{
if(TryLoadLayoutTypeFromProperty(twin) == null)
if (TryLoadLayoutTypeFromProperty(twin) == null)
{
mainLayout = TryLoadLayoutType(twin);
}

<ArrayBorderSetter IsArray="@CheckForArray(twin)" Name="@twin.GetSymbolTail()">
@if (mainLayout != null)
{
Expand Down Expand Up @@ -191,7 +194,7 @@
var enumKidType = kid.GetType()?.BaseType ?? kid.GetType();
var component = ViewEnumLocatorBuilder(enumKidType, presentationType);
@CreateEnumComponent(enumDiscriminatorAttribute, kid, component)
};
};

private RenderFragment GenerateValueTag(ITwinElement element) => __builder =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace AXSharp.Presentation.Blazor.Controls.RenderableContent

private TwinContainerObject _twinContainer;



[Parameter]
public TwinContainerObject TwinContainer
{
Expand Down