Skip to content

Commit 35933a9

Browse files
Merge pull request #145 from BalaVigneshRaviChandran/ES-970775-UmlSequenceDiagram
970775: Uml sequence diagram for blog
2 parents 6a00988 + 8ad1a01 commit 35933a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2914
-0
lines changed

Samples/UMLFromMermaid/App.razor

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@namespace UMLFromMermaid
2+
<Router AppAssembly="@typeof(App).Assembly">
3+
<Found Context="routeData">
4+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
5+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
6+
</Found>
7+
<NotFound>
8+
<PageTitle>Not found</PageTitle>
9+
<LayoutView Layout="@typeof(MainLayout)">
10+
<p role="alert">Sorry, there's nothing at this address.</p>
11+
</LayoutView>
12+
</NotFound>
13+
</Router>
14+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Microsoft.JSInterop;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace UMLFromMermaid.Pages
8+
{
9+
10+
#pragma warning disable CA1052 // Static holder types should be Static or NotInheritable
11+
public class FileUtil
12+
#pragma warning restore CA1052 // Static holder types should be Static or NotInheritable
13+
{
14+
public async static Task SaveAs(IJSRuntime js, string data, string fileName)
15+
{
16+
await js.InvokeAsync<object>(
17+
"saveDiagram",
18+
#pragma warning disable CA1305 // Specify IFormatProvider
19+
Convert.ToString(data), fileName).ConfigureAwait(true);
20+
#pragma warning restore CA1305 // Specify IFormatProvider
21+
}
22+
public async static Task Click(IJSRuntime js)
23+
{
24+
await js.InvokeAsync<object>(
25+
"click").ConfigureAwait(true);
26+
}
27+
public async static Task<string> LoadFile(IJSRuntime js, object data)
28+
{
29+
return await js.InvokeAsync<string>(
30+
"loadFile", data).ConfigureAwait(true);
31+
}
32+
public async static Task StartMovingDash(IJSRuntime js,string id)
33+
{
34+
await js.InvokeAsync<string>(
35+
"applyMovingDash", id).ConfigureAwait(true);
36+
37+
}
38+
39+
public async static Task StopMovingDash(IJSRuntime js,string id)
40+
{
41+
await js.InvokeAsync<string>(
42+
"removeMovingDash", id).ConfigureAwait(true);
43+
}
44+
45+
public async static Task RemoveConnectorDash(IJSRuntime js, string id)
46+
{
47+
await js.InvokeAsync<string>(
48+
"removeConnectorDash", id).ConfigureAwait(true);
49+
50+
}
51+
//public async static Task SetGradient(IJSRuntime js, int level)
52+
//{
53+
// await js.InvokeAsync<object>("setWaterLevel", level).ConfigureAwait(true);
54+
//}
55+
}
56+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
@page "/"
2+
3+
@using Syncfusion.Blazor.Diagram
4+
5+
<div style="display: flex; height: 800px;">
6+
7+
<div style="width: 75%; padding-right: 1rem;">
8+
<SfDiagramComponent @ref="@diagramComponent" ID="diagram" Height="100%" Model="@umlModel">
9+
</SfDiagramComponent>
10+
</div>
11+
12+
13+
<div style="width: 25%; display: flex; flex-direction: column;">
14+
<textarea style="flex: 1; resize: none;" placeholder="Mermaid data goes here...">@mermaidData</textarea>
15+
<div style="margin-top: 1rem;">
16+
<button @onclick="save" style="margin-bottom: 0.5rem; width: 100%;">Save</button>
17+
<button @onclick="LoadFromMermaid" style="width: 100%;margin-bottom: 0.5rem;">Load from mermaid</button>
18+
<button @onclick="ClearDiagram" style="width: 100%;">Clear</button>
19+
</div>
20+
</div>
21+
</div>
22+
23+
@code {
24+
UmlSequenceDiagramModel umlModel;
25+
SfDiagramComponent diagramComponent;
26+
string mermaidData = "";
27+
28+
private void save()
29+
{
30+
mermaidData = diagramComponent.SaveDiagramAsMermaid();
31+
StateHasChanged();
32+
}
33+
34+
private async Task LoadFromMermaid()
35+
{
36+
await diagramComponent.LoadDiagramFromMermaidAsync(mermaidData);
37+
}
38+
39+
private void ClearDiagram()
40+
{
41+
diagramComponent.Clear();
42+
}
43+
44+
protected override void OnInitialized()
45+
{
46+
umlModel = new UmlSequenceDiagramModel()
47+
{
48+
// Participants Collection
49+
Participants = new List<UmlSequenceParticipant>
50+
{
51+
new UmlSequenceParticipant { ID = "User", Content = "User", IsActor = false, },
52+
new UmlSequenceParticipant { ID = "Application", Content = "Application", IsActor = false, },
53+
new UmlSequenceParticipant { ID = "Database", Content = "Database", IsActor = false, ShowDestructionMarker = true}
54+
},
55+
56+
// Sequence Messages
57+
Messages = new List<UmlSequenceMessage>
58+
{
59+
new UmlSequenceMessage { ID = "MSG1", Content = "Database initiates delete process.", FromParticipantID = "Database", ToParticipantID = "Application"},
60+
new UmlSequenceMessage { ID = "MSG2", Content = "Application deletes User.", FromParticipantID = "Application", ToParticipantID = "User", MessageType = UmlSequenceMessageType.Delete },
61+
new UmlSequenceMessage { ID = "MSG3", Content = "Database deletes Application.", FromParticipantID = "Database", ToParticipantID = "Application", MessageType = UmlSequenceMessageType.Delete },
62+
63+
}
64+
};
65+
}
66+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page "/"
2+
@namespace UMLFromMermaid.Pages
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
@{
5+
Layout = "_Layout";
6+
}
7+
8+
<component type="typeof(App)" render-mode="ServerPrerendered" />
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@using Microsoft.AspNetCore.Components.Web
2+
@namespace UMLFromMermaid.Pages
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
5+
<!DOCTYPE html>
6+
<html lang="en">
7+
<head>
8+
<meta charset="utf-8" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
10+
<base href="~/" />
11+
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
12+
<link href="css/site.css" rel="stylesheet" />
13+
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
14+
<script src="~/interop.js"></script>
15+
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
16+
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
17+
</head>
18+
<body>
19+
@RenderBody()
20+
21+
22+
23+
<script src="_framework/blazor.server.js"></script>
24+
</body>
25+
</html>

Samples/UMLFromMermaid/Program.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
using Microsoft.AspNetCore.Components;
3+
using Microsoft.AspNetCore.Components.Web;
4+
using Syncfusion.Blazor;
5+
6+
var builder = WebApplication.CreateBuilder(args);
7+
8+
// Add services to the container.
9+
builder.Services.AddRazorPages();
10+
builder.Services.AddServerSideBlazor();
11+
builder.Services.AddSyncfusionBlazor();
12+
builder.Services.AddServerSideBlazor().AddHubOptions(o => { o.MaximumReceiveMessageSize = 102400000; });
13+
var app = builder.Build();
14+
15+
// Configure the HTTP request pipeline.
16+
if (!app.Environment.IsDevelopment())
17+
{
18+
app.UseExceptionHandler("/Error");
19+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
20+
app.UseHsts();
21+
}
22+
23+
app.UseHttpsRedirection();
24+
25+
app.UseStaticFiles();
26+
27+
app.UseRouting();
28+
29+
app.MapBlazorHub();
30+
app.MapFallbackToPage("/_Host");
31+
32+
app.Run();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:11920",
7+
"sslPort": 44341
8+
}
9+
},
10+
"profiles": {
11+
"UMLFromMermaid": {
12+
"commandName": "Project",
13+
"dotnetRunMessages": true,
14+
"launchBrowser": true,
15+
"applicationUrl": "https://localhost:7204;http://localhost:5236",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"IIS Express": {
21+
"commandName": "IISExpress",
22+
"launchBrowser": true,
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
}
26+
}
27+
}
28+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@namespace UMLFromMermaid.Shared
2+
@inherits LayoutComponentBase
3+
4+
<PageTitle>UMLFromMermaid</PageTitle>
5+
6+
<div class="page">
7+
<div class="sidebar">
8+
<NavMenu />
9+
</div>
10+
11+
12+
<main>
13+
14+
<article class="content px-4">
15+
@Body
16+
</article>
17+
</main>
18+
</div>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
.page {
2+
position: relative;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
main {
8+
flex: 1;
9+
}
10+
11+
.sidebar {
12+
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
13+
}
14+
15+
.top-row {
16+
background-color: #f7f7f7;
17+
border-bottom: 1px solid #d6d5d5;
18+
justify-content: flex-end;
19+
height: 3.5rem;
20+
display: flex;
21+
align-items: center;
22+
}
23+
24+
.top-row ::deep a, .top-row .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
}
28+
29+
.top-row a:first-child {
30+
overflow: hidden;
31+
text-overflow: ellipsis;
32+
}
33+
34+
@media (max-width: 640.98px) {
35+
.top-row:not(.auth) {
36+
display: none;
37+
}
38+
39+
.top-row.auth {
40+
justify-content: space-between;
41+
}
42+
43+
.top-row a, .top-row .btn-link {
44+
margin-left: 0;
45+
}
46+
}
47+
48+
@media (min-width: 641px) {
49+
.page {
50+
flex-direction: row;
51+
}
52+
53+
.sidebar {
54+
width: 250px;
55+
height: 100vh;
56+
position: sticky;
57+
top: 0;
58+
}
59+
60+
.top-row {
61+
position: sticky;
62+
top: 0;
63+
z-index: 1;
64+
}
65+
66+
.top-row, article {
67+
padding-left: 2rem !important;
68+
padding-right: 1.5rem !important;
69+
}
70+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk.Web">
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<PackageReference Include="Syncfusion.Blazor.Diagram" Version="*" />
10+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="*" />
11+
</ItemGroup>
12+
<ItemGroup>
13+
<Folder Include="wwwroot\" />
14+
</ItemGroup>
15+
</Project>

0 commit comments

Comments
 (0)