Skip to content

Commit

Permalink
feat: add multiple function support
Browse files Browse the repository at this point in the history
  • Loading branch information
philasmar committed Dec 24, 2024
1 parent a3b3f85 commit 95b992e
Show file tree
Hide file tree
Showing 13 changed files with 648 additions and 484 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<PackageReference Include="Spectre.Console" Version="0.49.1" />
<PackageReference Include="Spectre.Console.Cli" Version="0.49.1" />
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.1" />
<PackageReference Include="Blazored.Modal" Version="7.3.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.11" />
<PackageReference Include="BlazorMonaco" Version="3.2.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,26 @@
</ul>

<ul class="navbar-nav flex-row flex-wrap ms-md-auto">
<li class="nav-item col-6 col-lg-auto">
<a class="nav-link py-2 px-0 px-lg-2" href="@Constants.LinkGithubTestTool" target="_blank" rel="noopener">
<i class="bi bi-github"></i>
<small class="d-lg-none ms-2">GitHub</small>
</a>
</li>
<li class="nav-item py-2 py-lg-1 col-12 col-lg-auto">
<div class="vr d-none d-lg-flex h-100 mx-lg-2"></div>
<hr class="d-lg-none my-2 text-white-50">
</li>
<li class="nav-item dropdown">
<button class="nav-link py-2 px-0 px-lg-2 dropdown-toggle d-flex align-items-center show" id="bd-theme" type="button" aria-expanded="true" data-bs-toggle="dropdown" data-bs-display="static" aria-label="Toggle theme (light)">
<i class="bi bi-palette-fill"></i>
@if (ThemeService.CurrentTheme.Equals("dark"))
{
<i class="bi bi-moon-stars-fill"></i>
}
else
{
<i class="bi bi-sun-fill"></i>
}
<span class="d-lg-none ms-2" id="bd-theme-text">Toggle theme</span>
</button>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="bd-theme-text" data-bs-popper="static">
Expand All @@ -61,12 +78,9 @@
</div>
</div>
</nav>
<div class="page flex-grow-1">
<main>
<article class="content px-4">
@Body
</article>
</main>

<div class="container-fluid content d-flex flex-column flex-grow-1 px-3">
@Body
</div>

<footer class="footer text-muted p-3 mt-4">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@using Amazon.Lambda.TestTool.Models

<div class="modal fade" id="eventModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<div class="d-flex align-items-center gap-2">
<div><b>Request ID:</b> @_eventContainer?.AwsRequestId</div>
<span class="badge @GetStatusBadgeStyle(_eventContainer?.EventStatus)">@_eventContainer?.EventStatus</span>
</div>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<nav class="navbar navbar-expand-md bd-navbar pt-0">
<ul class="navbar-nav nav-underline nav-fill flex-row" id="eventsModalTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="active-tab" data-bs-toggle="tab" data-bs-target="#request-tab-pane" type="button" role="tab" aria-controls="request-tab-pane" aria-selected="true" @onclick="ShowRequestTab">
<i class="bi bi-file-earmark"></i>
Request
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="queued-tab" data-bs-toggle="tab" data-bs-target="#response-tab-pane" type="button" role="tab" aria-controls="response-tab-pane" aria-selected="false" @onclick="ShowResponseTab">
<i class="bi bi-file-earmark-fill"></i>
Response
</button>
</li>
</ul>
</nav>
<div class="tab-content d-flex flex-column flex-grow-1 flex-fill" id="eventsModalTabContent">
<div class="tab-pane fade flex-fill active show" id="request-tab-pane" role="tabpanel" aria-labelledby="request-tab" tabindex="0">
<StandaloneCodeEditor Id="request-body" @ref="_requestEditor" ConstructionOptions="EditorConstructionOptions" CssClass="monaco-modal-editor rounded-4 overflow-hidden border"/>
</div>
<div class="tab-pane fade flex-fill flex-column gap-2" id="response-tab-pane" role="tabpanel" aria-labelledby="response-tab" tabindex="1">
<div class="flex-grow-1">
<div class="d-flex bg-body-tertiary p-2 align-items-start gap-2 rounded-4 rounded-bottom-0 border border-bottom-0">
<div class="d-flex flex-column gap-2">
<div><b>Last Updated:</b> @_eventContainer?.LastUpdated</div>
@if (_eventContainer?.EventStatus == EventContainer.Status.Failure)
{
<div><b>Error Type:</b> @_eventContainer?.ErrorType</div>
}
</div>
</div>
@if (_eventContainer?.EventStatus == EventContainer.Status.Failure)
{
<StandaloneCodeEditor Id="response-error-body" @ref="_responseErrorEditor" ConstructionOptions="EditorConstructionOptions" CssClass="monaco-editor-container monaco-modal-editor rounded-4 rounded-top-0 border border-top-0 overflow-hidden"/>
}
else
{
<StandaloneCodeEditor Id="response-body" @ref="_responseEditor" ConstructionOptions="EditorConstructionOptions" CssClass="monaco-editor-container monaco-modal-editor rounded-4 rounded-top-0 border border-top-0 overflow-hidden"/>
}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

using Amazon.Lambda.TestTool.Models;
using Amazon.Lambda.TestTool.Services;
using BlazorMonaco.Editor;
using Microsoft.AspNetCore.Components;

namespace Amazon.Lambda.TestTool.Components.Pages;

public partial class EventDialog : ComponentBase
{
[Inject] public required IThemeService ThemeService { get; set; }

private EventContainer? _eventContainer;
private StandaloneCodeEditor? _requestEditor;
private StandaloneCodeEditor? _responseErrorEditor;
private StandaloneCodeEditor? _responseEditor;

public void ShowDialog(EventContainer eventContainer)
{
_eventContainer = eventContainer;
_requestEditor?.SetValue(_eventContainer.EventJson);
_responseErrorEditor?.SetValue(_eventContainer.ErrorResponse);
_responseEditor?.SetValue(_eventContainer.Response);
StateHasChanged();
}

private void ShowRequestTab()
{
_requestEditor?.SetValue(_eventContainer?.EventJson);
StateHasChanged();
}

private void ShowResponseTab()
{
_responseErrorEditor?.SetValue(_eventContainer?.ErrorResponse);
_responseEditor?.SetValue(_eventContainer?.Response);
StateHasChanged();
}

private string GetStatusBadgeStyle(EventContainer.Status? status) => status switch
{
EventContainer.Status.Success => "text-bg-success",
EventContainer.Status.Failure => "text-bg-danger",
_ => "text-bg-secondary"
};

private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor)
{
return new StandaloneEditorConstructionOptions
{
Language = "json",
GlyphMargin = false,
Theme = ThemeService.CurrentTheme.Equals("dark") ? "vs-dark" : "vs",
FontSize = 12,
AutomaticLayout = true,
ScrollBeyondLastLine = false,
ReadOnly = true,
Minimap = new EditorMinimapOptions
{
Enabled = false
}
};
}
}
Loading

0 comments on commit 95b992e

Please sign in to comment.