Skip to content

Commit 9b33ba5

Browse files
committed
Send start and end date params to middlware.
1 parent 44a8585 commit 9b33ba5

File tree

6 files changed

+47
-29
lines changed

6 files changed

+47
-29
lines changed

src/Serilog.Ui.Web/SerilogUiMiddleware.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,13 @@ private async Task<string> FetchLogsAsync(HttpContext httpContext)
147147

148148
int.TryParse(pageStr, out var currentPage);
149149
int.TryParse(countStr, out var count);
150+
150151
DateTime.TryParse(startDateStar, out var startDate);
151152
DateTime.TryParse(endDateStar, out var endDate);
152153

154+
if (endDate != default)
155+
endDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59);
156+
153157
currentPage = currentPage == default ? 1 : currentPage;
154158
count = count == default ? 10 : count;
155159

src/Serilog.Ui.Web/wwwroot/dist/main.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,14 @@ a[data-toggle="collapse"] {
380380

381381
.modal-body.wrapped pre {
382382
white-space: pre-wrap;
383+
}
384+
385+
#searchArea .col {
386+
padding-left: 5px;
387+
padding-right: 5px;
388+
}
389+
390+
#submit {
391+
cursor: pointer;
392+
vertical-align: text-top;
383393
}

src/Serilog.Ui.Web/wwwroot/dist/main.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,7 @@
3131
fetchData();
3232
});
3333

34-
$("#search").on("keypress", function (e) {
35-
if (e.which === 13) {
36-
$("#page").val("1");
37-
fetchData();
38-
}
39-
});
40-
41-
$("#search").on("input", function () {
42-
if ($(this).val() !== "") {
43-
return;
44-
}
45-
34+
$("#submit").on("click", function () {
4635
$("#page").val("1");
4736
fetchData();
4837
});
@@ -123,8 +112,20 @@ const fetchData = () => {
123112
const page = $("#page").val();
124113
const count = $("#count").children("option:selected").val();
125114
const level = $("#level").children("option:selected").val();
115+
const startDate = $("#startDate").val();
116+
const endDate = $("#endDate").val();
117+
118+
if (startDate && endDate !== null) {
119+
const start = Date.parse(startDate);
120+
const end = Date.parse(endDate);
121+
if (start > end) {
122+
alert("Start date cannot be greater than end date");
123+
return;
124+
}
125+
}
126+
126127
const searchTerm = escape($("#search").val());
127-
const url = `${location.pathname.replace("/index.html", "")}/api/logs?page=${page}&count=${count}&level=${level}&search=${searchTerm}`;
128+
const url = `${location.pathname.replace("/index.html", "")}/api/logs?page=${page}&count=${count}&level=${level}&search=${searchTerm}&startDate=${startDate}&endDate=${endDate}`;
128129
const token = sessionStorage.getItem("serilogui_token");
129130
let xf = null;
130131
if (authType !== "Windows")

src/Serilog.Ui.Web/wwwroot/dist/main.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)