mirror of
https://github.com/bitwarden/server.git
synced 2025-05-22 20:11:04 -05:00
date range search on logs
This commit is contained in:
parent
b99f6cdbc1
commit
47fed7ab80
@ -27,7 +27,7 @@ namespace Bit.Admin.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> Index(string cursor = null, int count = 50,
|
public async Task<IActionResult> Index(string cursor = null, int count = 50,
|
||||||
LogEventLevel? level = null, string project = null)
|
LogEventLevel? level = null, string project = null, DateTime? start = null, DateTime? end = null)
|
||||||
{
|
{
|
||||||
var collectionLink = UriFactory.CreateDocumentCollectionUri(Database, Collection);
|
var collectionLink = UriFactory.CreateDocumentCollectionUri(Database, Collection);
|
||||||
using(var client = new DocumentClient(new Uri(_globalSettings.DocumentDb.Uri),
|
using(var client = new DocumentClient(new Uri(_globalSettings.DocumentDb.Uri),
|
||||||
@ -48,6 +48,14 @@ namespace Bit.Admin.Controllers
|
|||||||
{
|
{
|
||||||
query = query.Where(l => l.Properties != null && l.Properties["Project"] == (object)project);
|
query = query.Where(l => l.Properties != null && l.Properties["Project"] == (object)project);
|
||||||
}
|
}
|
||||||
|
if(start.HasValue)
|
||||||
|
{
|
||||||
|
query = query.Where(l => l.Timestamp >= start.Value);
|
||||||
|
}
|
||||||
|
if(end.HasValue)
|
||||||
|
{
|
||||||
|
query = query.Where(l => l.Timestamp <= end.Value);
|
||||||
|
}
|
||||||
|
|
||||||
var docQuery = query.OrderByDescending(l => l.Timestamp).AsDocumentQuery();
|
var docQuery = query.OrderByDescending(l => l.Timestamp).AsDocumentQuery();
|
||||||
var response = await docQuery.ExecuteNextAsync<LogModel>();
|
var response = await docQuery.ExecuteNextAsync<LogModel>();
|
||||||
@ -56,6 +64,8 @@ namespace Bit.Admin.Controllers
|
|||||||
{
|
{
|
||||||
Level = level,
|
Level = level,
|
||||||
Project = project,
|
Project = project,
|
||||||
|
Start = start,
|
||||||
|
End = end,
|
||||||
Items = response.ToList(),
|
Items = response.ToList(),
|
||||||
Count = count,
|
Count = count,
|
||||||
Cursor = cursor,
|
Cursor = cursor,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Serilog.Events;
|
using System;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace Bit.Admin.Models
|
namespace Bit.Admin.Models
|
||||||
{
|
{
|
||||||
@ -6,5 +7,7 @@ namespace Bit.Admin.Models
|
|||||||
{
|
{
|
||||||
public LogEventLevel? Level { get; set; }
|
public LogEventLevel? Level { get; set; }
|
||||||
public string Project { get; set; }
|
public string Project { get; set; }
|
||||||
|
public DateTime? Start { get; set; }
|
||||||
|
public DateTime? End { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
<option asp-selected="@(Model.Project == "Notifications")" value="Notifications">Notifications</option>
|
<option asp-selected="@(Model.Project == "Notifications")" value="Notifications">Notifications</option>
|
||||||
<option asp-selected="@(Model.Project == "Icons")" value="Icons">Icons</option>
|
<option asp-selected="@(Model.Project == "Icons")" value="Icons">Icons</option>
|
||||||
</select>
|
</select>
|
||||||
|
<input class="form-control mb-2 mr-2" type="datetime-local" asp-for="Start" name="start">
|
||||||
|
<input class="form-control mb-2 mr-2" type="datetime-local" asp-for="End" name="end">
|
||||||
<button type="submit" class="btn btn-primary mb-2" title="Search"><i class="fa fa-search"></i> Search</button>
|
<button type="submit" class="btn btn-primary mb-2" title="Search"><i class="fa fa-search"></i> Search</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user