|
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>Lambd Function Tester</PageTitle>
|
|
58 | 58 | </div>
|
59 | 59 | <div class="col-sm-6">
|
60 | 60 | <h3>Active Event:</h3>
|
61 |
| - @if (RuntimeApiModel.ActiveEvent == null) |
| 61 | + @if (DataStore.ActiveEvent == null) |
62 | 62 | {
|
63 | 63 | <h2>No active event</h2>
|
64 | 64 | }
|
65 | 65 | else
|
66 | 66 | {
|
67 | 67 | <div>
|
68 |
| - <div style="cursor: pointer" @onclick="() => OnRequeue(RuntimeApiModel.ActiveEvent.AwsRequestId)"> |
| 68 | + <div style="cursor: pointer" @onclick="() => OnRequeue(DataStore.ActiveEvent.AwsRequestId)"> |
69 | 69 | @((MarkupString)REBOOT_ICON)
|
70 | 70 | </div>
|
71 |
| - <p><b>Request ID:</b> @RuntimeApiModel.ActiveEvent.AwsRequestId</p> |
72 |
| - <p><b>Status:</b> <span style="@GetStatusStyle(RuntimeApiModel.ActiveEvent.EventStatus)">@RuntimeApiModel.ActiveEvent.EventStatus</span></p> |
73 |
| - <p><b>Last Updated:</b> @RuntimeApiModel.ActiveEvent.LastUpdated</p> |
74 |
| - <p><b>Event JSON:</b><span class="event-value"><span class="fake-link" @onclick="() => ShowEventJson(RuntimeApiModel.ActiveEvent)">@CreateSnippet(RuntimeApiModel.ActiveEvent.EventJson)</span></span></p> |
75 |
| - @if (RuntimeApiModel.ActiveEvent.EventStatus == EventContainer.Status.Failure) |
| 71 | + <p><b>Request ID:</b> @DataStore.ActiveEvent.AwsRequestId</p> |
| 72 | + <p><b>Status:</b> <span style="@GetStatusStyle(DataStore.ActiveEvent.EventStatus)">@DataStore.ActiveEvent.EventStatus</span></p> |
| 73 | + <p><b>Last Updated:</b> @DataStore.ActiveEvent.LastUpdated</p> |
| 74 | + <p><b>Event JSON:</b><span class="event-value"><span class="fake-link" @onclick="() => ShowEventJson(DataStore.ActiveEvent)">@CreateSnippet(DataStore.ActiveEvent.EventJson)</span></span></p> |
| 75 | + @if (DataStore.ActiveEvent.EventStatus == EventContainer.Status.Failure) |
76 | 76 | {
|
77 |
| - <p><b>Error Type:</b> @RuntimeApiModel.ActiveEvent.ErrorType</p> |
| 77 | + <p><b>Error Type:</b> @DataStore.ActiveEvent.ErrorType</p> |
78 | 78 | <p>
|
79 | 79 | <b>Error Response:</b>
|
80 |
| - <pre class="form-control" style="@Constants.ResponseErrorStyleSizeConstraint">@RuntimeApiModel.ActiveEvent.ErrorResponse</pre> |
| 80 | + <pre class="form-control" style="@Constants.ResponseErrorStyleSizeConstraint">@DataStore.ActiveEvent.ErrorResponse</pre> |
81 | 81 | </p>
|
82 | 82 | }
|
83 | 83 | else
|
84 | 84 | {
|
85 | 85 | <p>
|
86 | 86 | <b>Response:</b>
|
87 |
| - <pre class="form-control" style="@Constants.ResponseSuccessStyleSizeConstraint">@Utils.TryPrettyPrintJson(RuntimeApiModel.ActiveEvent.Response)</pre> |
| 87 | + <pre class="form-control" style="@Constants.ResponseSuccessStyleSizeConstraint">@Utils.TryPrettyPrintJson(DataStore.ActiveEvent.Response)</pre> |
88 | 88 | </p>
|
89 | 89 | }
|
90 | 90 | </div>
|
|
97 | 97 | <div class="col-sm-6">
|
98 | 98 | <h3>Queued Events: <button class="btn btn-secondary btn-sm" @onclick="OnClearQueued">Clear</button></h3>
|
99 | 99 | <div class="col-xs-5 event-list">
|
100 |
| - @foreach (var evnt in @RuntimeApiModel.QueuedEvents) |
| 100 | + @foreach (var evnt in @DataStore.QueuedEvents) |
101 | 101 | {
|
102 | 102 | <div class="event-list-item">
|
103 | 103 | <div class="row" style="padding: 2px">
|
|
119 | 119 | <div class="col-sm-6">
|
120 | 120 | <h3>Executed Events: <button class="btn btn-secondary btn-sm" @onclick="OnClearExecuted">Clear</button></h3>
|
121 | 121 | <div class="col-xs-5 event-list">
|
122 |
| - @foreach (var evnt in @RuntimeApiModel.ExecutedEvents.OrderByDescending(x => x.LastUpdated)) |
| 122 | + @foreach (var evnt in @DataStore.ExecutedEvents.OrderByDescending(x => x.LastUpdated)) |
123 | 123 | {
|
124 | 124 | <div class="event-list-item">
|
125 | 125 | <div class="row" style="padding: 2px">
|
|
183 | 183 |
|
184 | 184 | private IDictionary<string, IList<LambdaRequest>> SampleRequests { get; set; } = new Dictionary<string, IList<LambdaRequest>>();
|
185 | 185 |
|
| 186 | + private IRuntimeApiDataStore DataStore => DataStoreManager.GetLambdaRuntimeDataStore(LambdaRuntimeApi.DefaultFunctionName); |
| 187 | + |
186 | 188 | string? _selectedSampleRequestName;
|
187 | 189 | string? SelectedSampleRequestName
|
188 | 190 | {
|
|
209 | 211 |
|
210 | 212 | protected override void OnInitialized()
|
211 | 213 | {
|
212 |
| - RuntimeApiModel.StateChange += RuntimeApiModelOnStateChange; |
| 214 | + DataStore.StateChange += RuntimeApiModelOnStateChange; |
213 | 215 | this.SampleRequestManager = new SampleRequestManager(DirectoryManager.GetCurrentDirectory());
|
214 | 216 | this.SampleRequests = SampleRequestManager.GetSampleRequests();
|
215 | 217 | }
|
|
221 | 223 |
|
222 | 224 | void OnAddEventClick()
|
223 | 225 | {
|
224 |
| - RuntimeApiModel.QueueEvent(this.FunctionInput); |
| 226 | + DataStore.QueueEvent(this.FunctionInput, false); |
225 | 227 | this.FunctionInput = "";
|
226 | 228 | this.SelectedSampleRequestName = NO_SAMPLE_SELECTED_ID;
|
227 | 229 | this.StateHasChanged();
|
228 | 230 | }
|
229 | 231 |
|
230 | 232 | void OnClearQueued()
|
231 | 233 | {
|
232 |
| - this.RuntimeApiModel.ClearQueued(); |
| 234 | + this.DataStore.ClearQueued(); |
233 | 235 | this.StateHasChanged();
|
234 | 236 | }
|
235 | 237 |
|
236 | 238 | void OnClearExecuted()
|
237 | 239 | {
|
238 |
| - this.RuntimeApiModel.ClearExecuted(); |
| 240 | + this.DataStore.ClearExecuted(); |
239 | 241 | this.StateHasChanged();
|
240 | 242 | }
|
241 | 243 |
|
242 | 244 | void OnRequeue(string awsRequestId)
|
243 | 245 | {
|
244 | 246 | EventContainer? evnt = null;
|
245 |
| - if (string.Equals(this.RuntimeApiModel.ActiveEvent?.AwsRequestId, awsRequestId)) |
| 247 | + if (string.Equals(this.DataStore.ActiveEvent?.AwsRequestId, awsRequestId)) |
246 | 248 | {
|
247 |
| - evnt = this.RuntimeApiModel.ActiveEvent; |
| 249 | + evnt = this.DataStore.ActiveEvent; |
248 | 250 | }
|
249 | 251 | else
|
250 | 252 | {
|
251 |
| - evnt = this.RuntimeApiModel.ExecutedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); |
| 253 | + evnt = this.DataStore.ExecutedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); |
252 | 254 | }
|
253 | 255 |
|
254 | 256 | if (evnt == null)
|
255 | 257 | return;
|
256 | 258 |
|
257 |
| - this.RuntimeApiModel.QueueEvent(evnt.EventJson); |
| 259 | + this.DataStore.QueueEvent(evnt.EventJson, false); |
258 | 260 | this.StateHasChanged();
|
259 | 261 | }
|
260 | 262 |
|
261 | 263 | void OnDeleteEvent(string awsRequestId)
|
262 | 264 | {
|
263 |
| - this.RuntimeApiModel.DeleteEvent(awsRequestId); |
| 265 | + this.DataStore.DeleteEvent(awsRequestId); |
264 | 266 | this.StateHasChanged();
|
265 | 267 | }
|
266 | 268 |
|
|
0 commit comments