Import from internal git
This commit is contained in:
35
WebServer/Components/App.razor
Normal file
35
WebServer/Components/App.razor
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<base href="/"/>
|
||||
<link rel="stylesheet" href="bootstrap/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" href="app.css"/>
|
||||
<link rel="stylesheet" href="WebServer.styles.css"/>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
|
||||
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||
|
||||
<HeadOutlet/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<Routes/>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/yaml.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/css.min.js"></script>
|
||||
|
||||
<script>
|
||||
window.highlightSnippet = function(){
|
||||
document.querySelectorAll('pre code').forEach((el)=>{
|
||||
hljs.highlightBlock(el);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="_framework/blazor.web.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
22
WebServer/Components/Layout/MainLayout.razor
Normal file
22
WebServer/Components/Layout/MainLayout.razor
Normal file
@@ -0,0 +1,22 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<div class="page">
|
||||
<div class="sidebar">
|
||||
<NavMenu/>
|
||||
</div>
|
||||
|
||||
<main>
|
||||
<div class="top-row px-4">
|
||||
</div>
|
||||
|
||||
<article class="content px-4">
|
||||
@Body
|
||||
</article>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
An unhandled error has occurred.
|
||||
<a href="" class="reload">Reload</a>
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
96
WebServer/Components/Layout/MainLayout.razor.css
Normal file
96
WebServer/Components/Layout/MainLayout.razor.css
Normal file
@@ -0,0 +1,96 @@
|
||||
.page {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
main {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background-image: linear-gradient(180deg, rgb(90, 81, 161) 0%, #996CAFFF 70%);
|
||||
}
|
||||
|
||||
.top-row {
|
||||
background-color: #f7f7f7;
|
||||
border-bottom: 1px solid #d6d5d5;
|
||||
justify-content: flex-end;
|
||||
height: 3.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||
white-space: nowrap;
|
||||
margin-left: 1.5rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.top-row ::deep a:first-child {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
@media (max-width: 640.98px) {
|
||||
.top-row {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 641px) {
|
||||
.page {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 250px;
|
||||
height: 100vh;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.top-row {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.top-row.auth ::deep a:first-child {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.top-row, article {
|
||||
padding-left: 2rem !important;
|
||||
padding-right: 1.5rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
#blazor-error-ui {
|
||||
background: lightyellow;
|
||||
bottom: 0;
|
||||
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
|
||||
display: none;
|
||||
left: 0;
|
||||
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#blazor-error-ui .dismiss {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
right: 0.75rem;
|
||||
top: 0.5rem;
|
||||
}
|
||||
25
WebServer/Components/Layout/NavMenu.razor
Normal file
25
WebServer/Components/Layout/NavMenu.razor
Normal file
@@ -0,0 +1,25 @@
|
||||
<div class="top-row ps-3 navbar navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="">WebServer</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="checkbox" title="Navigation menu" class="navbar-toggler"/>
|
||||
|
||||
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
|
||||
|
||||
<nav class="flex-column">
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
|
||||
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="specifications">
|
||||
<span class="bi bi-file-earmark-text" aria-hidden="true"></span> Specifications
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
83
WebServer/Components/Layout/NavMenu.razor.css
Normal file
83
WebServer/Components/Layout/NavMenu.razor.css
Normal file
@@ -0,0 +1,83 @@
|
||||
.navbar-toggler {
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
width: 3.5rem;
|
||||
height: 2.5rem;
|
||||
color: white;
|
||||
position: absolute;
|
||||
top: 0.5rem;
|
||||
right: 1rem;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.navbar-toggler:checked {
|
||||
background-color: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
.top-row {
|
||||
height: 3.5rem;
|
||||
background-color: rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
font-size: 0.9rem;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.nav-item:first-of-type {
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.nav-item:last-of-type {
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
||||
.nav-item ::deep .nav-link {
|
||||
color: #d7d7d7;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
height: 3rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 3rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-item ::deep a.active {
|
||||
background-color: rgba(255,255,255,0.37);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.nav-item ::deep .nav-link:hover {
|
||||
background-color: rgba(255,255,255,0.1);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.nav-scrollable {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.navbar-toggler:checked ~ .nav-scrollable {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@media (min-width: 641px) {
|
||||
.navbar-toggler {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-scrollable {
|
||||
/* Never collapse the sidebar for wide screens */
|
||||
display: block;
|
||||
|
||||
/* Allow sidebar to scroll for tall menus */
|
||||
height: calc(100vh - 3.5rem);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
35
WebServer/Components/Molecule/ActionCard.razor
Normal file
35
WebServer/Components/Molecule/ActionCard.razor
Normal file
@@ -0,0 +1,35 @@
|
||||
<div class="action-box" @onclick="AsyncInvocation">
|
||||
@ChildContent
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Action? Action { get; set; }
|
||||
|
||||
private async void AsyncInvocation()
|
||||
{
|
||||
if (Action == null) return;
|
||||
await Task.Run(Action);
|
||||
}
|
||||
}
|
||||
|
||||
<style>
|
||||
|
||||
.action-box
|
||||
{
|
||||
padding: 5px;
|
||||
text-align: center;
|
||||
background: rgb(143,134,191);
|
||||
color: #d7d7d7;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.action-box:hover {
|
||||
box-shadow: 0 0 15px #736d6d;
|
||||
color: white;
|
||||
}
|
||||
|
||||
</style>
|
||||
36
WebServer/Components/Molecule/NavigationCard.razor
Normal file
36
WebServer/Components/Molecule/NavigationCard.razor
Normal file
@@ -0,0 +1,36 @@
|
||||
<a href="@Link">
|
||||
<div class="spec-box">
|
||||
<p>@DisplayName</p>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string? DisplayName { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Link { get; set; }
|
||||
}
|
||||
|
||||
<style>
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.spec-box
|
||||
{
|
||||
padding: 5px;
|
||||
width: 205px;
|
||||
height: 150px;
|
||||
text-align: center;
|
||||
background: rgb(143,134,191);
|
||||
color: #d7d7d7;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.spec-box:hover {
|
||||
box-shadow: 0 0 15px #736d6d;
|
||||
color: white;
|
||||
}
|
||||
|
||||
</style>
|
||||
24
WebServer/Components/Organism/ContentViewer.razor
Normal file
24
WebServer/Components/Organism/ContentViewer.razor
Normal file
@@ -0,0 +1,24 @@
|
||||
<pre>
|
||||
<code class="@Language">
|
||||
@ChildContent
|
||||
</code>
|
||||
</pre>
|
||||
|
||||
|
||||
@code{
|
||||
[Inject] private IJSRuntime _js { get; set; }
|
||||
[Parameter] public RenderFragment ChildContent { get; set; }
|
||||
[Parameter] public string Language { get; set; } = "yaml";
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
=> await _js.InvokeVoidAsync("highlightSnippet");
|
||||
}
|
||||
|
||||
<style>
|
||||
|
||||
pre{
|
||||
width: 750px;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
</style>
|
||||
32
WebServer/Components/Organism/SpecList.razor
Normal file
32
WebServer/Components/Organism/SpecList.razor
Normal file
@@ -0,0 +1,32 @@
|
||||
@using WebServer.Components.Molecule
|
||||
@using Core
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<input class="filter" @onchange=Filter/>
|
||||
<div class="specs d-flex flex-row flex-wrap justify-content-start">
|
||||
@foreach(var i in _specs.Count == 0 ? Data : _specs)
|
||||
{
|
||||
<div class="m-2">
|
||||
<NavigationCard DisplayName=@i.GetFileName() Link=@($"/details/{i.GetFolder()}/{i.GetFileName()}") />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public List<Location> Data { get; set; }
|
||||
private List<Location> _specs = [];
|
||||
|
||||
private void Filter(ChangeEventArgs e)
|
||||
{
|
||||
string filter = e.Value?.ToString() ?? string.Empty;
|
||||
_specs = Data.Where(s => s.Path.Contains(filter)).ToList();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
<style>
|
||||
.filter{
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
101
WebServer/Components/Pages/Details.razor
Normal file
101
WebServer/Components/Pages/Details.razor
Normal file
@@ -0,0 +1,101 @@
|
||||
@page "/details/{folder}/{specName}"
|
||||
@using Generator.Controllers
|
||||
@using WebServer.Components.Molecule
|
||||
@using WebServer.Components.Organism
|
||||
@using Core.SpecConfig
|
||||
@using Core.Events
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<PageTitle>Details</PageTitle>
|
||||
|
||||
<h3>Details</h3>
|
||||
<p>@SpecName</p>
|
||||
@if (CanBeGenerated())
|
||||
{
|
||||
<div class="d-flex flex-row flex-wrap">
|
||||
|
||||
<div class="generation-box m-2">
|
||||
<ActionCard Action="Generate">
|
||||
<div class="bi bi-gear-fill"></div>
|
||||
</ActionCard>
|
||||
</div>
|
||||
|
||||
<div class="publish-box m-2">
|
||||
<ActionCard Action="Publish">
|
||||
<div class="bi bi-upload"></div>
|
||||
</ActionCard>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="d-flex flex-row">
|
||||
|
||||
<ContentViewer Language="yaml">
|
||||
@GetSpecText()
|
||||
</ContentViewer>
|
||||
|
||||
<div class="action-status">
|
||||
@_actionState
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Inject] private AnalyzeController AnalyzeController { get; set; } = null!;
|
||||
[Inject] private GenerationController GenerationController { get; set; } = null!;
|
||||
[Inject] private PreGenerationController PreGenController { get; set; } = null!;
|
||||
[Parameter] public string Folder{ get; set; } = null!;
|
||||
[Parameter] public string SpecName{ get; set; } = null!;
|
||||
|
||||
private string? _actionState;
|
||||
private DisplayEmitter _emitter = null!;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_emitter = GenerationController.Emitter;
|
||||
_emitter.OnSay += DisplayState;
|
||||
_emitter.OnWarn += DisplayState;
|
||||
}
|
||||
|
||||
private async void DisplayState(object? sender, DisplayEventArgs e)
|
||||
{
|
||||
_actionState = e.Content;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async void Generate()
|
||||
{
|
||||
_emitter.Say(this, "Starting generation..");
|
||||
var process = PreGenController.ComputeGeneration(
|
||||
$"{Folder}/{SpecName}", null, PublishType.No
|
||||
);
|
||||
|
||||
await GenerationController.Launch(process);
|
||||
_emitter.Say(this,"Generation completed");
|
||||
|
||||
}
|
||||
|
||||
private void Publish()
|
||||
{
|
||||
_emitter.Say(this, "Publishing not available at the moment");
|
||||
}
|
||||
|
||||
private string GetSpecText() => AnalyzeController.GetSpecText(Folder, SpecName);
|
||||
|
||||
private bool CanBeGenerated() => AnalyzeController.CanBeGenerated(Folder, SpecName);
|
||||
}
|
||||
|
||||
<style>
|
||||
|
||||
.action-status{
|
||||
width: 300px;
|
||||
height: 250px;
|
||||
border: solid black;
|
||||
border-radius: 4px;
|
||||
word-wrap: break-word;
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
36
WebServer/Components/Pages/Error.razor
Normal file
36
WebServer/Components/Pages/Error.razor
Normal file
@@ -0,0 +1,36 @@
|
||||
@page "/Error"
|
||||
@using System.Diagnostics
|
||||
|
||||
<PageTitle>Error</PageTitle>
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
||||
@if (ShowRequestId)
|
||||
{
|
||||
<p>
|
||||
<strong>Request ID:</strong> <code>@RequestId</code>
|
||||
</p>
|
||||
}
|
||||
|
||||
<h3>Development Mode</h3>
|
||||
<p>
|
||||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||
</p>
|
||||
<p>
|
||||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||
It can result in displaying sensitive information from exceptions to end users.
|
||||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||
and restarting the app.
|
||||
</p>
|
||||
|
||||
@code{
|
||||
[CascadingParameter] private HttpContext? HttpContext { get; set; }
|
||||
|
||||
private string? RequestId { get; set; }
|
||||
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
|
||||
protected override void OnInitialized() =>
|
||||
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
|
||||
|
||||
}
|
||||
7
WebServer/Components/Pages/Home.razor
Normal file
7
WebServer/Components/Pages/Home.razor
Normal file
@@ -0,0 +1,7 @@
|
||||
@page "/"
|
||||
|
||||
<PageTitle>Home</PageTitle>
|
||||
|
||||
<h1>Hello, world!</h1>
|
||||
|
||||
Welcome to your new app.
|
||||
14
WebServer/Components/Pages/Specifications.razor
Normal file
14
WebServer/Components/Pages/Specifications.razor
Normal file
@@ -0,0 +1,14 @@
|
||||
@page "/specifications"
|
||||
@using WebServer.Components.Organism
|
||||
@using Generator.Controllers
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<PageTitle>Specifications</PageTitle>
|
||||
|
||||
<h3>Specifications</h3>
|
||||
|
||||
<SpecList Data=Controller.ListSpecs().ToList()></SpecList>
|
||||
|
||||
@code {
|
||||
[Inject] private AnalyzeController Controller { get; set; }
|
||||
}
|
||||
6
WebServer/Components/Routes.razor
Normal file
6
WebServer/Components/Routes.razor
Normal file
@@ -0,0 +1,6 @@
|
||||
<Router AppAssembly="typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)"/>
|
||||
<FocusOnNavigate RouteData="routeData" Selector="h1"/>
|
||||
</Found>
|
||||
</Router>
|
||||
10
WebServer/Components/_Imports.razor
Normal file
10
WebServer/Components/_Imports.razor
Normal file
@@ -0,0 +1,10 @@
|
||||
@using System.Net.Http
|
||||
@using System.Net.Http.Json
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||
@using Microsoft.JSInterop
|
||||
@using WebServer
|
||||
@using WebServer.Components
|
||||
Reference in New Issue
Block a user