|
| 1 | +@page |
| 2 | +@model SampleWebApplication.Pages.LogsModel |
| 3 | +@{ |
| 4 | + ViewData["Title"] = "Logs"; |
| 5 | +} |
| 6 | + |
| 7 | +<form id="log-search-form" |
| 8 | + name="log-search-form" |
| 9 | + role="form" |
| 10 | + method="get"> |
| 11 | + |
| 12 | + <div class="card mb-5"> |
| 13 | + <div class="card-header"> |
| 14 | + <div class="row no-gutters"> |
| 15 | + <div class="col"> |
| 16 | + <i class="fa-solid fa-file-lines mr-2"></i> Logs |
| 17 | + </div> |
| 18 | + <div class="col-sm-2"> |
| 19 | + <select class="form-select form-select-sm" |
| 20 | + name="l" |
| 21 | + asp-for="Level" |
| 22 | + onchange="this.form.submit()"> |
| 23 | + <option value="">- Level -</option> |
| 24 | + <option value="Trace">Trace</option> |
| 25 | + <option value="Debug">Debug</option> |
| 26 | + <option value="Information">Information</option> |
| 27 | + <option value="Warning">Warning</option> |
| 28 | + <option value="Error">Error</option> |
| 29 | + <option value="Critical">Critical</option> |
| 30 | + </select> |
| 31 | + </div> |
| 32 | + <div class="col-sm-3"> |
| 33 | + <div class="input-group input-group-sm mr-2"> |
| 34 | + <div class="input-group-prepend"> |
| 35 | + <button class="btn btn-sm btn-outline-secondary" |
| 36 | + type="button" |
| 37 | + title="Previous Date" |
| 38 | + onclick="previousDate()"> |
| 39 | + <i class="fa-solid fa-chevron-left"></i> |
| 40 | + </button> |
| 41 | + </div> |
| 42 | + <input type="date" |
| 43 | + name="d" |
| 44 | + asp-for="Date" |
| 45 | + class="form-control form-control-sm" |
| 46 | + placeholder="Date" /> |
| 47 | + <div class="input-group-append"> |
| 48 | + <button class="btn btn-sm btn-outline-secondary" |
| 49 | + type="button" |
| 50 | + title="Next Date" |
| 51 | + onclick="nextDate()"> |
| 52 | + <i class="fa-solid fa-chevron-right"></i> |
| 53 | + </button> |
| 54 | + <button class="btn btn-sm btn-outline-secondary" |
| 55 | + type="submit"> |
| 56 | + <i class="fa-solid fa-magnifying-glass"></i> |
| 57 | + </button> |
| 58 | + </div> |
| 59 | + </div> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + </div> |
| 63 | + |
| 64 | + <div class="card-body p-0"> |
| 65 | + <table class="table table-bordered table-sm"> |
| 66 | + <colgroup> |
| 67 | + <col style="width: 30px" /> |
| 68 | + <col style="width: 30px" /> |
| 69 | + <col style="width: 200px" /> |
| 70 | + <col style="width: 120px" /> |
| 71 | + <col style="" /> |
| 72 | + </colgroup> |
| 73 | + <thead> |
| 74 | + <tr> |
| 75 | + <th scope="col"></th> |
| 76 | + <th scope="col"></th> |
| 77 | + <th scope="col">Date</th> |
| 78 | + <th scope="col">Level</th> |
| 79 | + <th scope="col">Message</th> |
| 80 | + </tr> |
| 81 | + </thead> |
| 82 | + <tbody> |
| 83 | + @foreach (var log in Model.Logs) |
| 84 | + { |
| 85 | + <tr> |
| 86 | + <td style="text-align: center;"> |
| 87 | + <a class="caret-toggle d-block collapsed" |
| 88 | + data-bs-toggle="collapse" |
| 89 | + |
| 90 | + role="button" |
| 91 | + aria-expanded="false" |
| 92 | + aria-controls= "[email protected]"> |
| 93 | + <i class="fa-solid fa-caret-down text-body"></i> |
| 94 | + </a> |
| 95 | + </td> |
| 96 | + <td style="text-align: center;"> |
| 97 | + @switch (log.Level) |
| 98 | + { |
| 99 | + case "Warning": |
| 100 | + <i class="fa-solid fa-triangle-exclamation text-warning"></i> |
| 101 | + break; |
| 102 | + case "Error": |
| 103 | + case "Critical": |
| 104 | + <i class="fa-solid fa-circle-xmark text-danger"></i> |
| 105 | + break; |
| 106 | + case "Information": |
| 107 | + <i class="fa-solid fa-circle-info text-primary"></i> |
| 108 | + break; |
| 109 | + default: |
| 110 | + <i class="fa-solid fa-circle-info text-secondary"></i> |
| 111 | + break; |
| 112 | + } |
| 113 | + </td> |
| 114 | + <td>@log.Timestamp?.ToString("g")</td> |
| 115 | + <td>@log.Level</td> |
| 116 | + <td>@log.RenderedMessage</td> |
| 117 | + </tr> |
| 118 | + < tr class= "collapse" id= "[email protected]" style= "background-color: #f9f9f9;"> |
| 119 | + <td colspan="5"> |
| 120 | + <div class="tab-container"> |
| 121 | + < ul class= "nav nav-tabs" id= "[email protected]" role= "tablist"> |
| 122 | + <li class="nav-item" role="presentation"> |
| 123 | + <a class="nav-link active" |
| 124 | + |
| 125 | + |
| 126 | + data-toggle="tab" |
| 127 | + |
| 128 | + aria-selected="true" |
| 129 | + role="tab">Properties</a> |
| 130 | + </li> |
| 131 | + @if (!string.IsNullOrWhiteSpace(log.Exception)) |
| 132 | + { |
| 133 | + <li class="nav-item" role="presentation"> |
| 134 | + <a class="nav-link" |
| 135 | + |
| 136 | + |
| 137 | + data-toggle="tab" |
| 138 | + |
| 139 | + role="tab">Exception</a> |
| 140 | + </li> |
| 141 | + } |
| 142 | + </ul> |
| 143 | + <div class="tab-content" id="myTabContent"> |
| 144 | + <div class="tab-pane fade show active" |
| 145 | + |
| 146 | + aria-labelledby= "[email protected]" |
| 147 | + role="tabpanel"> |
| 148 | + <json-display>@log.Data</json-display> |
| 149 | + </div> |
| 150 | + @if (!string.IsNullOrWhiteSpace(log.Exception)) |
| 151 | + { |
| 152 | + <div class="tab-pane fade" |
| 153 | + |
| 154 | + aria-labelledby= "[email protected]" |
| 155 | + role="tabpanel"> |
| 156 | + <pre style="overflow: auto; max-height: 400px; font-family: Courier New">@log.Exception</pre> |
| 157 | + </div> |
| 158 | + } |
| 159 | + </div> |
| 160 | + </div> |
| 161 | + </td> |
| 162 | + </tr> |
| 163 | + } |
| 164 | + </tbody> |
| 165 | + </table> |
| 166 | + </div> |
| 167 | + |
| 168 | + <div class="card-footer p-0"> |
| 169 | + |
| 170 | + <div class="row"> |
| 171 | + <div class="col-md-6"></div> |
| 172 | + <div class="col-md-6"> |
| 173 | + <nav aria-label="Log Pagination"> |
| 174 | + <ul class="justify-content-md-end m-3 pagination"> |
| 175 | + @if (!string.IsNullOrWhiteSpace(Model.ContinuationToken)) |
| 176 | + { |
| 177 | + <li class="page-item"> |
| 178 | + <a class="page-link" |
| 179 | + asp-page="/Logs" |
| 180 | + asp-route-z="@Model.PageSize" |
| 181 | + asp-route-l="@Model.Level" |
| 182 | + asp-route-d="@Model.Date.Date" |
| 183 | + asp-route-t="">First</a> |
| 184 | + </li> |
| 185 | + } |
| 186 | + else |
| 187 | + { |
| 188 | + <li class="page-item disabled"> |
| 189 | + <span class="page-link">First</span> |
| 190 | + </li> |
| 191 | + } |
| 192 | + @if (!string.IsNullOrWhiteSpace(Model.NextToken)) |
| 193 | + { |
| 194 | + <li class="page-item"> |
| 195 | + <a class="page-link" |
| 196 | + asp-page="/Logs" |
| 197 | + asp-route-z="@Model.PageSize" |
| 198 | + asp-route-l="@Model.Level" |
| 199 | + asp-route-d="@Model.Date.Date" |
| 200 | + asp-route-t="@Model.NextToken">Next</a> |
| 201 | + </li> |
| 202 | + } |
| 203 | + else |
| 204 | + { |
| 205 | + <li class="page-item disabled"> |
| 206 | + <span class="page-link">Next</span> |
| 207 | + </li> |
| 208 | + } |
| 209 | + </ul> |
| 210 | + </nav> |
| 211 | + </div> |
| 212 | + </div> |
| 213 | + </div> |
| 214 | + </div> |
| 215 | +</form> |
| 216 | + |
| 217 | +@section Scripts { |
| 218 | + <script> |
| 219 | + function previousDate() { |
| 220 | + $('#@Html.IdFor(p => p.Date)').val('@Model.Date.AddDays(-1).ToString("yyyy-MM-dd")'); |
| 221 | + $('#log-search-form').submit(); |
| 222 | + } |
| 223 | + function nextDate() { |
| 224 | + $('#@Html.IdFor(p => p.Date)').val('@Model.Date.AddDays(1).ToString("yyyy-MM-dd")'); |
| 225 | + $('#log-search-form').submit(); |
| 226 | + } |
| 227 | + </script> |
| 228 | +} |
0 commit comments