|
23 | 23 | </div>
|
24 | 24 |
|
25 | 25 | <div class="row">
|
26 |
| - <div class="col-sm-6"> |
27 |
| - <h3>Queue Event:</h3> |
28 |
| - <label class="" for="sample-requests">Example Requests:</label> |
29 |
| - <select class="control" id="sample-requests" @bind="SelectedSampleRequestName"> |
30 |
| - <option id="@NO_SAMPLE_SELECTED_ID"> -- select a request -- </option> |
31 |
| - @if (@SampleRequests.ContainsKey(SampleRequestManager.SavedRequestGroup)) |
32 |
| - { |
33 |
| - <optgroup id="saved-select-request-group" label="@SampleRequestManager.SavedRequestGroup"> |
34 |
| - @foreach (var request in SampleRequests[SampleRequestManager.SavedRequestGroup]) |
35 |
| - { |
36 |
| - <option value="@request.Filename">@request.Name</option> |
37 |
| - } |
38 |
| - </optgroup> |
39 |
| - } |
40 |
| - @foreach (var group in SampleRequests.Keys) |
41 |
| - { |
42 |
| - @if (!string.Equals(group, SampleRequestManager.SavedRequestGroup)) |
| 26 | + <div class="col-sm-6 gap-2 d-flex flex-column"> |
| 27 | + <h4>Queue Event</h4> |
| 28 | + <div class="form-floating"> |
| 29 | + <select class="form-select" id="sample-requests" @bind="SelectedSampleRequestName"> |
| 30 | + <option value="@NoSampleSelectedId">Select a request</option> |
| 31 | + @if (@SampleRequests.ContainsKey(SampleRequestManager.SavedRequestGroup)) |
43 | 32 | {
|
44 |
| - <optgroup label="@group"> |
45 |
| - @foreach (var request in SampleRequests[group]) |
| 33 | + <optgroup id="saved-select-request-group" label="@SampleRequestManager.SavedRequestGroup"> |
| 34 | + @foreach (var request in SampleRequests[SampleRequestManager.SavedRequestGroup]) |
46 | 35 | {
|
47 | 36 | <option value="@request.Filename">@request.Name</option>
|
48 | 37 | }
|
49 | 38 | </optgroup>
|
50 | 39 | }
|
51 |
| - } |
52 |
| - </select> |
53 |
| - <label class="col-xs-3 control-label" for="function-payload">Function Input:</label> |
54 |
| - <textarea class="form-control" style="margin: 5px" rows="20" @bind="FunctionInput" placeholder="JSON document as input to Lambda Function. Plain strings must be wrapped in quotes."></textarea> |
55 |
| - <div class="col-sm form-group"> |
| 40 | + @foreach (var group in SampleRequests.Keys) |
| 41 | + { |
| 42 | + @if (!string.Equals(group, SampleRequestManager.SavedRequestGroup)) |
| 43 | + { |
| 44 | + <optgroup label="@group"> |
| 45 | + @foreach (var request in SampleRequests[group]) |
| 46 | + { |
| 47 | + <option value="@request.Filename">@request.Name</option> |
| 48 | + } |
| 49 | + </optgroup> |
| 50 | + } |
| 51 | + } |
| 52 | + </select> |
| 53 | + <label for="sample-requests">Example Requests</label> |
| 54 | + </div> |
| 55 | + <div class="mt-1"> |
| 56 | + <label class="form-label" for="function-payload">Function Input</label> |
| 57 | + <StandaloneCodeEditor @ref="_editor" ConstructionOptions="EditorConstructionOptions" CssClass="rounded-4 overflow-hidden border"/> |
| 58 | + </div> |
| 59 | + <div class="form-group"> |
56 | 60 | <button class="btn btn-primary btn-sm" @onclick="OnAddEventClick">Queue Event</button>
|
57 | 61 | </div>
|
58 | 62 | </div>
|
|
66 | 70 | {
|
67 | 71 | <div>
|
68 | 72 | <div style="cursor: pointer" @onclick="() => OnRequeue(RuntimeApiModel.ActiveEvent.AwsRequestId)">
|
69 |
| - @((MarkupString)REBOOT_ICON) |
| 73 | + @((MarkupString)RebootIcon) |
70 | 74 | </div>
|
71 | 75 | <p><b>Request ID:</b> @RuntimeApiModel.ActiveEvent.AwsRequestId</p>
|
72 | 76 | <p><b>Status:</b> <span style="@GetStatusStyle(RuntimeApiModel.ActiveEvent.EventStatus)">@RuntimeApiModel.ActiveEvent.EventStatus</span></p>
|
|
106 | 110 | <div class="event-label">Last Updated:</div><div class="event-value">@evnt.LastUpdated</div>
|
107 | 111 | </div>
|
108 | 112 | <div class="col-sm-1 " style="cursor: pointer" @onclick="() => OnDeleteEvent(evnt.AwsRequestId)">
|
109 |
| - @((MarkupString)CLOSE_ICON) |
| 113 | + @((MarkupString)CloseIcon) |
110 | 114 | </div>
|
111 | 115 | </div>
|
112 | 116 | <div class="row" style="padding: 2px">
|
|
124 | 128 | <div class="event-list-item">
|
125 | 129 | <div class="row" style="padding: 2px">
|
126 | 130 | <div class="col-sm-1 " style="cursor: pointer" @onclick="() => OnRequeue(evnt.AwsRequestId)">
|
127 |
| - @((MarkupString)REBOOT_ICON) |
| 131 | + @((MarkupString)RebootIcon) |
128 | 132 | </div>
|
129 | 133 | <div class="col-sm-10 row">
|
130 | 134 | <div class="event-label">Request ID:</div><div class="event-value"> @evnt.AwsRequestId</div>
|
131 | 135 | <div class="event-label">Status:</div><div class="event-value" style="@GetStatusStyle(evnt.EventStatus)">@evnt.EventStatus</div>
|
132 | 136 | <div class="event-label">Last Updated:</div><div class="event-value">@evnt.LastUpdated</div>
|
133 | 137 | </div>
|
134 | 138 | <div class="col-sm-1 " style="cursor: pointer" @onclick="() => OnDeleteEvent(evnt.AwsRequestId)">
|
135 |
| - @((MarkupString)CLOSE_ICON) |
| 139 | + @((MarkupString)CloseIcon) |
136 | 140 | </div>
|
137 | 141 | </div>
|
138 | 142 | <div class="row" style="padding: 2px">
|
|
163 | 167 |
|
164 | 168 |
|
165 | 169 | @code {
|
166 |
| - private const string REBOOT_ICON = @" |
| 170 | + private StandaloneCodeEditor _editor = null!; |
| 171 | + |
| 172 | + private const string RebootIcon = @" |
167 | 173 | <svg xmlns=""http://www.w3.org/2000/svg"" width=""16"" height=""16"" fill=""currentColor"" class=""bi bi-bootstrap-reboot"" viewBox=""0 0 16 16"">
|
168 | 174 | <path d=""M1.161 8a6.84 6.84 0 1 0 6.842-6.84.58.58 0 1 1 0-1.16 8 8 0 1 1-6.556 3.412l-.663-.577a.58.58 0 0 1 .227-.997l2.52-.69a.58.58 0 0 1 .728.633l-.332 2.592a.58.58 0 0 1-.956.364l-.643-.56A6.812 6.812 0 0 0 1.16 8z""/>
|
169 | 175 | </svg>
|
170 | 176 | ";
|
171 | 177 |
|
172 |
| - private const string CLOSE_ICON = @" |
| 178 | + private const string CloseIcon = @" |
173 | 179 | <svg xmlns=""http://www.w3.org/2000/svg"" width=""16"" height=""16"" fill=""currentColor"" class=""bi bi-x"" viewBox=""0 0 16 16"">
|
174 | 180 | <path d=""M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z""/>
|
175 | 181 | </svg>
|
176 | 182 | ";
|
177 | 183 |
|
178 | 184 | [CascadingParameter] public IModalService Modal { get; set; } = default!;
|
179 | 185 |
|
180 |
| - private const string NO_SAMPLE_SELECTED_ID = "void-select-request"; |
| 186 | + private const string NoSampleSelectedId = "void-select-request"; |
181 | 187 |
|
182 | 188 | private string FunctionInput { get; set; } = "";
|
183 | 189 |
|
|
186 | 192 | string? _selectedSampleRequestName;
|
187 | 193 | string? SelectedSampleRequestName
|
188 | 194 | {
|
189 |
| - get => this._selectedSampleRequestName; |
| 195 | + get => _selectedSampleRequestName; |
190 | 196 | set
|
191 | 197 | {
|
192 | 198 | if (SampleRequestManager == null)
|
193 | 199 | return;
|
194 | 200 |
|
195 |
| - this._selectedSampleRequestName = value; |
196 |
| - if (string.IsNullOrEmpty(this._selectedSampleRequestName)) |
| 201 | + _selectedSampleRequestName = value; |
| 202 | + if (string.IsNullOrEmpty(_selectedSampleRequestName) || |
| 203 | + string.Equals(value, NoSampleSelectedId)) |
197 | 204 | {
|
198 |
| - this.FunctionInput = string.Empty; |
| 205 | + FunctionInput = string.Empty; |
199 | 206 | }
|
200 |
| - else if (!string.Equals(value, NO_SAMPLE_SELECTED_ID)) |
| 207 | + else |
201 | 208 | {
|
202 |
| - this.FunctionInput = SampleRequestManager.GetRequest(this._selectedSampleRequestName); |
| 209 | + FunctionInput = SampleRequestManager.GetRequest(_selectedSampleRequestName); |
203 | 210 | }
|
204 |
| - this.StateHasChanged(); |
| 211 | + |
| 212 | + _editor.SetValue(FunctionInput); |
| 213 | + StateHasChanged(); |
205 | 214 | }
|
206 | 215 | }
|
207 | 216 |
|
|
210 | 219 | protected override void OnInitialized()
|
211 | 220 | {
|
212 | 221 | RuntimeApiModel.StateChange += RuntimeApiModelOnStateChange;
|
213 |
| - this.SampleRequestManager = new SampleRequestManager(DirectoryManager.GetCurrentDirectory()); |
214 |
| - this.SampleRequests = SampleRequestManager.GetSampleRequests(); |
| 222 | + SampleRequestManager = new SampleRequestManager(DirectoryManager.GetCurrentDirectory()); |
| 223 | + SampleRequests = SampleRequestManager.GetSampleRequests(); |
215 | 224 | }
|
216 | 225 |
|
217 | 226 | private void RuntimeApiModelOnStateChange(object? sender, EventArgs e)
|
218 | 227 | {
|
219 |
| - this.InvokeAsync(this.StateHasChanged); |
| 228 | + InvokeAsync(this.StateHasChanged); |
220 | 229 | }
|
221 | 230 |
|
222 | 231 | void OnAddEventClick()
|
223 | 232 | {
|
224 |
| - RuntimeApiModel.QueueEvent(this.FunctionInput); |
225 |
| - this.FunctionInput = ""; |
226 |
| - this.SelectedSampleRequestName = NO_SAMPLE_SELECTED_ID; |
227 |
| - this.StateHasChanged(); |
| 233 | + RuntimeApiModel.QueueEvent(FunctionInput); |
| 234 | + FunctionInput = ""; |
| 235 | + SelectedSampleRequestName = NoSampleSelectedId; |
| 236 | + StateHasChanged(); |
228 | 237 | }
|
229 | 238 |
|
230 | 239 | void OnClearQueued()
|
231 | 240 | {
|
232 |
| - this.RuntimeApiModel.ClearQueued(); |
233 |
| - this.StateHasChanged(); |
| 241 | + RuntimeApiModel.ClearQueued(); |
| 242 | + StateHasChanged(); |
234 | 243 | }
|
235 | 244 |
|
236 | 245 | void OnClearExecuted()
|
237 | 246 | {
|
238 |
| - this.RuntimeApiModel.ClearExecuted(); |
239 |
| - this.StateHasChanged(); |
| 247 | + RuntimeApiModel.ClearExecuted(); |
| 248 | + StateHasChanged(); |
240 | 249 | }
|
241 | 250 |
|
242 | 251 | void OnRequeue(string awsRequestId)
|
243 | 252 | {
|
244 | 253 | EventContainer? evnt = null;
|
245 |
| - if (string.Equals(this.RuntimeApiModel.ActiveEvent?.AwsRequestId, awsRequestId)) |
| 254 | + if (string.Equals(RuntimeApiModel.ActiveEvent?.AwsRequestId, awsRequestId)) |
246 | 255 | {
|
247 |
| - evnt = this.RuntimeApiModel.ActiveEvent; |
| 256 | + evnt = RuntimeApiModel.ActiveEvent; |
248 | 257 | }
|
249 | 258 | else
|
250 | 259 | {
|
251 |
| - evnt = this.RuntimeApiModel.ExecutedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); |
| 260 | + evnt = RuntimeApiModel.ExecutedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); |
252 | 261 | }
|
253 | 262 |
|
254 | 263 | if (evnt == null)
|
255 | 264 | return;
|
256 | 265 |
|
257 |
| - this.RuntimeApiModel.QueueEvent(evnt.EventJson); |
258 |
| - this.StateHasChanged(); |
| 266 | + RuntimeApiModel.QueueEvent(evnt.EventJson); |
| 267 | + StateHasChanged(); |
259 | 268 | }
|
260 | 269 |
|
261 | 270 | void OnDeleteEvent(string awsRequestId)
|
262 | 271 | {
|
263 |
| - this.RuntimeApiModel.DeleteEvent(awsRequestId); |
264 |
| - this.StateHasChanged(); |
| 272 | + RuntimeApiModel.DeleteEvent(awsRequestId); |
| 273 | + StateHasChanged(); |
265 | 274 | }
|
266 | 275 |
|
267 | 276 | string GetStatusStyle(EventContainer.Status status) => status switch
|
|
308 | 317 | parameters.Add(ExpandedTextDialog.PARAMETER_NAME_FULL_TEXT, text);
|
309 | 318 | Modal.Show<ExpandedTextDialog>(title, parameters);
|
310 | 319 | }
|
| 320 | + |
| 321 | + private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor) |
| 322 | + { |
| 323 | + return new StandaloneEditorConstructionOptions |
| 324 | + { |
| 325 | + Language = "json", |
| 326 | + GlyphMargin = true, |
| 327 | + Theme = "vs-dark" |
| 328 | + }; |
| 329 | + } |
311 | 330 | }
|
0 commit comments