|
1 |
| -@page "/" |
| 1 | +@page "/" |
2 | 2 |
|
3 | 3 | @using Amazon.Lambda.TestTool.Commands
|
4 | 4 | @using Amazon.Lambda.TestTool.Services
|
|
9 | 9 | @using Microsoft.AspNetCore.Http;
|
10 | 10 |
|
11 | 11 | @inject IHttpContextAccessor HttpContextAccessor
|
12 |
| -@inject IRuntimeApiDataStore RuntimeApiModel |
| 12 | +@inject IRuntimeApiDataStoreManager DataStoreManager |
13 | 13 | @inject IDirectoryManager DirectoryManager
|
14 | 14 |
|
15 | 15 | <PageTitle>Lambda Function Tester</PageTitle>
|
|
62 | 62 | </div>
|
63 | 63 | <div class="col-sm-6">
|
64 | 64 | <h3>Active Event:</h3>
|
65 |
| - @if (RuntimeApiModel.ActiveEvent == null) |
| 65 | + @if (DataStore.ActiveEvent == null) |
66 | 66 | {
|
67 | 67 | <h2>No active event</h2>
|
68 | 68 | }
|
69 | 69 | else
|
70 | 70 | {
|
71 | 71 | <div>
|
72 |
| - <div style="cursor: pointer" @onclick="() => OnRequeue(RuntimeApiModel.ActiveEvent.AwsRequestId)"> |
| 72 | + <div style="cursor: pointer" @onclick="() => OnRequeue(DataStore.ActiveEvent.AwsRequestId)"> |
73 | 73 | @((MarkupString)RebootIcon)
|
74 | 74 | </div>
|
75 |
| - <p><b>Request ID:</b> @RuntimeApiModel.ActiveEvent.AwsRequestId</p> |
76 |
| - <p><b>Status:</b> <span style="@GetStatusStyle(RuntimeApiModel.ActiveEvent.EventStatus)">@RuntimeApiModel.ActiveEvent.EventStatus</span></p> |
77 |
| - <p><b>Last Updated:</b> @RuntimeApiModel.ActiveEvent.LastUpdated</p> |
78 |
| - <p><b>Event JSON:</b><span class="event-value"><span class="fake-link" @onclick="() => ShowEventJson(RuntimeApiModel.ActiveEvent)">@CreateSnippet(RuntimeApiModel.ActiveEvent.EventJson)</span></span></p> |
79 |
| - @if (RuntimeApiModel.ActiveEvent.EventStatus == EventContainer.Status.Failure) |
| 75 | + <p><b>Request ID:</b> @DataStore.ActiveEvent.AwsRequestId</p> |
| 76 | + <p><b>Status:</b> <span style="@GetStatusStyle(DataStore.ActiveEvent.EventStatus)">@DataStore.ActiveEvent.EventStatus</span></p> |
| 77 | + <p><b>Last Updated:</b> @DataStore.ActiveEvent.LastUpdated</p> |
| 78 | + <p><b>Event JSON:</b><span class="event-value"><span class="fake-link" @onclick="() => ShowEventJson(DataStore.ActiveEvent)">@CreateSnippet(DataStore.ActiveEvent.EventJson)</span></span></p> |
| 79 | + @if (DataStore.ActiveEvent.EventStatus == EventContainer.Status.Failure) |
80 | 80 | {
|
81 |
| - <p><b>Error Type:</b> @RuntimeApiModel.ActiveEvent.ErrorType</p> |
| 81 | + <p><b>Error Type:</b> @DataStore.ActiveEvent.ErrorType</p> |
82 | 82 | <p>
|
83 | 83 | <b>Error Response:</b>
|
84 |
| - <pre class="form-control" style="@Constants.ResponseErrorStyleSizeConstraint">@RuntimeApiModel.ActiveEvent.ErrorResponse</pre> |
| 84 | + <pre class="form-control" style="@Constants.ResponseErrorStyleSizeConstraint">@DataStore.ActiveEvent.ErrorResponse</pre> |
85 | 85 | </p>
|
86 | 86 | }
|
87 | 87 | else
|
88 | 88 | {
|
89 | 89 | <p>
|
90 | 90 | <b>Response:</b>
|
91 |
| - <pre class="form-control" style="@Constants.ResponseSuccessStyleSizeConstraint">@Utils.TryPrettyPrintJson(RuntimeApiModel.ActiveEvent.Response)</pre> |
| 91 | + <pre class="form-control" style="@Constants.ResponseSuccessStyleSizeConstraint">@Utils.TryPrettyPrintJson(DataStore.ActiveEvent.Response)</pre> |
92 | 92 | </p>
|
93 | 93 | }
|
94 | 94 | </div>
|
|
101 | 101 | <div class="col-sm-6">
|
102 | 102 | <h3>Queued Events: <button class="btn btn-secondary btn-sm" @onclick="OnClearQueued">Clear</button></h3>
|
103 | 103 | <div class="col-xs-5 event-list">
|
104 |
| - @foreach (var evnt in @RuntimeApiModel.QueuedEvents) |
| 104 | + @foreach (var evnt in @DataStore.QueuedEvents) |
105 | 105 | {
|
106 | 106 | <div class="event-list-item">
|
107 | 107 | <div class="row" style="padding: 2px">
|
|
123 | 123 | <div class="col-sm-6">
|
124 | 124 | <h3>Executed Events: <button class="btn btn-secondary btn-sm" @onclick="OnClearExecuted">Clear</button></h3>
|
125 | 125 | <div class="col-xs-5 event-list">
|
126 |
| - @foreach (var evnt in @RuntimeApiModel.ExecutedEvents.OrderByDescending(x => x.LastUpdated)) |
| 126 | + @foreach (var evnt in @DataStore.ExecutedEvents.OrderByDescending(x => x.LastUpdated)) |
127 | 127 | {
|
128 | 128 | <div class="event-list-item">
|
129 | 129 | <div class="row" style="padding: 2px">
|
|
189 | 189 |
|
190 | 190 | private IDictionary<string, IList<LambdaRequest>> SampleRequests { get; set; } = new Dictionary<string, IList<LambdaRequest>>();
|
191 | 191 |
|
| 192 | + private IRuntimeApiDataStore DataStore => DataStoreManager.GetLambdaRuntimeDataStore(LambdaRuntimeApi.DefaultFunctionName); |
| 193 | + |
192 | 194 | string? _selectedSampleRequestName;
|
193 | 195 | string? SelectedSampleRequestName
|
194 | 196 | {
|
|
218 | 220 |
|
219 | 221 | protected override void OnInitialized()
|
220 | 222 | {
|
221 |
| - RuntimeApiModel.StateChange += RuntimeApiModelOnStateChange; |
| 223 | + DataStore.StateChange += DataStoreOnStateChange; |
222 | 224 | SampleRequestManager = new SampleRequestManager(DirectoryManager.GetCurrentDirectory());
|
223 | 225 | SampleRequests = SampleRequestManager.GetSampleRequests();
|
224 | 226 | }
|
225 | 227 |
|
226 |
| - private void RuntimeApiModelOnStateChange(object? sender, EventArgs e) |
| 228 | + private void DataStoreOnStateChange(object? sender, EventArgs e) |
227 | 229 | {
|
228 | 230 | InvokeAsync(this.StateHasChanged);
|
229 | 231 | }
|
230 | 232 |
|
231 | 233 | void OnAddEventClick()
|
232 | 234 | {
|
233 |
| - RuntimeApiModel.QueueEvent(FunctionInput); |
| 235 | + DataStore.QueueEvent(FunctionInput, false); |
234 | 236 | FunctionInput = "";
|
235 | 237 | SelectedSampleRequestName = NoSampleSelectedId;
|
236 | 238 | StateHasChanged();
|
237 | 239 | }
|
238 | 240 |
|
239 | 241 | void OnClearQueued()
|
240 | 242 | {
|
241 |
| - RuntimeApiModel.ClearQueued(); |
| 243 | + DataStore.ClearQueued(); |
242 | 244 | StateHasChanged();
|
243 | 245 | }
|
244 | 246 |
|
245 | 247 | void OnClearExecuted()
|
246 | 248 | {
|
247 |
| - RuntimeApiModel.ClearExecuted(); |
| 249 | + DataStore.ClearExecuted(); |
248 | 250 | StateHasChanged();
|
249 | 251 | }
|
250 | 252 |
|
251 | 253 | void OnRequeue(string awsRequestId)
|
252 | 254 | {
|
253 | 255 | EventContainer? evnt = null;
|
254 |
| - if (string.Equals(RuntimeApiModel.ActiveEvent?.AwsRequestId, awsRequestId)) |
| 256 | + if (string.Equals(DataStore.ActiveEvent?.AwsRequestId, awsRequestId)) |
255 | 257 | {
|
256 |
| - evnt = RuntimeApiModel.ActiveEvent; |
| 258 | + evnt = DataStore.ActiveEvent; |
257 | 259 | }
|
258 | 260 | else
|
259 | 261 | {
|
260 |
| - evnt = RuntimeApiModel.ExecutedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); |
| 262 | + evnt = DataStore.ExecutedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); |
261 | 263 | }
|
262 | 264 |
|
263 | 265 | if (evnt == null)
|
264 | 266 | return;
|
265 | 267 |
|
266 |
| - RuntimeApiModel.QueueEvent(evnt.EventJson); |
| 268 | + DataStore.QueueEvent(evnt.EventJson, false); |
267 | 269 | StateHasChanged();
|
268 | 270 | }
|
269 | 271 |
|
270 | 272 | void OnDeleteEvent(string awsRequestId)
|
271 | 273 | {
|
272 |
| - RuntimeApiModel.DeleteEvent(awsRequestId); |
| 274 | + DataStore.DeleteEvent(awsRequestId); |
273 | 275 | StateHasChanged();
|
274 | 276 | }
|
275 | 277 |
|
|
0 commit comments