From 610eff06a2f504fdd0c3ba2c6808f3610d32840f Mon Sep 17 00:00:00 2001 From: "sam.gerene" Date: Wed, 8 Dec 2021 13:00:05 +0100 Subject: [PATCH] [Add] menu implementation --- README.md | 4 +- .../ReqifViewer.Infrastructure.csproj | 2 +- .../Services/IReqIFLoaderService.cs | 7 ++- .../Services/ReqIFLoaderService.cs | 13 ++++- reqifviewer/Shared/MainLayout.razor | 8 ++- reqifviewer/Shared/SideMenu.razor | 56 ++++++++++++++++++- reqifviewer/reqifviewer.csproj | 2 +- 7 files changed, 80 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 21e1f76..9cc7f8d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The reqifviewer is a web application to inspect and navigate [ReqIF](https://www.omg.org/spec/ReqIF/1.2/About-ReqIF/) files. The web application is developed using Blazor and depends on [ReqIFSharp](https://reqifsharp.org) for [ReqIF](https://www.omg.org/spec/ReqIF/1.2/About-ReqIF/) processing. -> Visit https://reqifviewer.reqifsharp.org to see the application in action. +> Visit https://viewer.reqifsharp.org to see the application in action. ## Build and Deploy using Docker @@ -23,4 +23,4 @@ $ ./solutionfolder# docker push rheagroup/reqifviewer:latest ## Autodeployment -reqifviewer is dockerized and pushed to [dockerhub](https://hub.docker.com/repository/docker/rheagroup/reqifviewer) using a GitHub action that is triggered by pushing a **tag** that has the following naming convention `web-app-x.y.z`, where x.y.z is the version numbr following [SEMVER](https://semver.org/). The server where the docker container is hosted automatically pulls latest using [watchtower](https://github.com/containrrr/watchtower), find it at https://reqifviewer.reqifsharp.org. \ No newline at end of file +reqifviewer is dockerized and pushed to [dockerhub](https://hub.docker.com/repository/docker/rheagroup/reqifviewer) using a GitHub action that is triggered by pushing a **tag** that has the following naming convention `web-app-x.y.z`, where x.y.z is the version numbr following [SEMVER](https://semver.org/). The server where the docker container is hosted automatically pulls latest using [watchtower](https://github.com/containrrr/watchtower), find it at https://viewer.reqifsharp.org. \ No newline at end of file diff --git a/ReqifViewer.Infrastructure/ReqifViewer.Infrastructure.csproj b/ReqifViewer.Infrastructure/ReqifViewer.Infrastructure.csproj index faa2f40..81d88a1 100644 --- a/ReqifViewer.Infrastructure/ReqifViewer.Infrastructure.csproj +++ b/ReqifViewer.Infrastructure/ReqifViewer.Infrastructure.csproj @@ -4,7 +4,7 @@ net5.0 RHEA System S.A. ReqifViewer.Infrastructure - 0.0.1 + 0.1.0 Shared Infrastructure Copyright © RHEA System S.A. Sam Gerené diff --git a/ReqifViewer.Infrastructure/Services/IReqIFLoaderService.cs b/ReqifViewer.Infrastructure/Services/IReqIFLoaderService.cs index a36c0c6..fd01de6 100644 --- a/ReqifViewer.Infrastructure/Services/IReqIFLoaderService.cs +++ b/ReqifViewer.Infrastructure/Services/IReqIFLoaderService.cs @@ -20,9 +20,9 @@ namespace ReqifViewer.Infrastructure.Services { + using System; using System.IO; using System.Collections.Generic; - using System.Threading; using System.Threading.Tasks; using ReqIFSharp; @@ -60,5 +60,10 @@ public interface IReqIFLoaderService /// /// void Reset(); + + /// + /// Event Handler that is invoked when the has either loaded data or has been reset + /// + event EventHandler> ReqIfChanged; } } diff --git a/ReqifViewer.Infrastructure/Services/ReqIFLoaderService.cs b/ReqifViewer.Infrastructure/Services/ReqIFLoaderService.cs index 1e40fe7..d226730 100644 --- a/ReqifViewer.Infrastructure/Services/ReqIFLoaderService.cs +++ b/ReqifViewer.Infrastructure/Services/ReqIFLoaderService.cs @@ -20,9 +20,9 @@ namespace ReqifViewer.Infrastructure.Services { + using System; using System.Collections.Generic; using System.IO; - using System.Threading; using System.Threading.Tasks; using ReqIFSharp; @@ -66,8 +66,10 @@ public async Task Load(Stream reqIFStream) var reqIfDeserializer = new ReqIFDeserializer(); result = reqIfDeserializer.Deserialize(this.SourceStream); - + this.ReqIFData = result; + + ReqIfChanged?.Invoke(this, this.ReqIFData); } /// @@ -78,6 +80,13 @@ public void Reset() { this.SourceStream = null; this.ReqIFData = null; + + ReqIfChanged?.Invoke(this, null); } + + /// + /// Event Handler that is invoked when the has either loaded data or has been reset + /// + public event EventHandler> ReqIfChanged; } } diff --git a/reqifviewer/Shared/MainLayout.razor b/reqifviewer/Shared/MainLayout.razor index 18aac02..aad3c7f 100644 --- a/reqifviewer/Shared/MainLayout.razor +++ b/reqifviewer/Shared/MainLayout.razor @@ -73,9 +73,11 @@ @code { - bool sidebarExpanded = false; - bool bodyExpanded = true; - string version = string.Empty; + private bool sidebarExpanded = false; + + private bool bodyExpanded = true; + + private string version = string.Empty; /// /// Method invoked when the component is ready to start, having received its diff --git a/reqifviewer/Shared/SideMenu.razor b/reqifviewer/Shared/SideMenu.razor index 59cad30..f21e0d5 100644 --- a/reqifviewer/Shared/SideMenu.razor +++ b/reqifviewer/Shared/SideMenu.razor @@ -14,12 +14,42 @@ limitations under the License. -------------------------------------------------------------------------------> +@using ReqifViewer.Infrastructure.Services +@using ReqIFSharp + +@inject IReqIFLoaderService reqIfLoaderService + -
-
+
+ + @if (this.reqifLoaded) + { + @foreach (var reqif in this.reqIfLoaderService.ReqIFData) + { + + + + @foreach (var specification in reqif.CoreContent.Specifications) + { + + } + + + + + + + + + + + + } + } +
@@ -38,4 +68,26 @@ ///
[Parameter] public EventCallback ExpandedChanged { get; set; } + + private bool reqifLoaded = false; + + protected override void OnInitialized() + { + this.reqIfLoaderService.ReqIfChanged += ReqIfLoaderServiceOnReqIfChanged; + } + + private void ReqIfLoaderServiceOnReqIfChanged(object sender, IEnumerable reqIfs) + { + if (reqIfs == null || !reqIfs.Any()) + { + this.reqifLoaded = false; + } + else + { + this.reqifLoaded = true; + } + + this.StateHasChanged(); + } + } \ No newline at end of file diff --git a/reqifviewer/reqifviewer.csproj b/reqifviewer/reqifviewer.csproj index 9a271d9..4b84d90 100644 --- a/reqifviewer/reqifviewer.csproj +++ b/reqifviewer/reqifviewer.csproj @@ -4,7 +4,7 @@ net5.0 RHEA System S.A. reqifviewer - 0.0.2 + 0.1.0 Web Application to inspect ReqIF files Copyright © RHEA System S.A. Sam Gerené