-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from bobbahbrown/v1.2.0
Version 1.2.0
- Loading branch information
Showing
23 changed files
with
570 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using CentCom.API.Models; | ||
using CentCom.API.Services; | ||
using CentCom.Common; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace CentCom.API.Controllers | ||
{ | ||
public class ViewerController : Controller | ||
{ | ||
private readonly ILogger<ViewerController> _logger; | ||
private readonly IBanService _banService; | ||
private readonly IBanSourceService _banSourceService; | ||
|
||
public ViewerController(ILogger<ViewerController> logger, IBanService banService, IBanSourceService banSourceService) | ||
{ | ||
_logger = logger; | ||
_banService = banService; | ||
_banSourceService = banSourceService; | ||
} | ||
|
||
[HttpGet] | ||
public async Task<IActionResult> Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
[HttpGet("viewer/search/{key}")] | ||
public async Task<IActionResult> SearchBans(string key) | ||
{ | ||
var ckey = KeyUtilities.GetCanonicalKey(key); | ||
if (string.IsNullOrWhiteSpace(ckey) || ckey.Length < 3) | ||
{ | ||
return View("badsearch", new BanSearchViewModel() { CKey = ckey }); | ||
} | ||
|
||
var searchResults = await _banService.SearchSummariesForKeyAsync(key); | ||
|
||
// If there is only one result, just view it | ||
if (searchResults.Count() == 1) | ||
{ | ||
return RedirectToAction("ViewBans", new { key = searchResults.First().CKey }); | ||
} | ||
|
||
return View(new BanSearchViewModel() { CKey = ckey, Data = searchResults }); | ||
} | ||
|
||
[HttpGet("viewer/view/{key}")] | ||
public async Task<IActionResult> ViewBans(string key, bool onlyActive = false) | ||
{ | ||
var bans = await _banService.GetBansForKeyAsync(key, null, onlyActive); | ||
|
||
return View(new BanViewViewModel() { CKey = KeyUtilities.GetCanonicalKey(key), Bans = bans, OnlyActive = onlyActive }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using CentCom.Common.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace CentCom.API.Models | ||
{ | ||
public class BanSearchViewModel | ||
{ | ||
public string CKey { get; set; } | ||
public IEnumerable<KeySummary> Data { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace CentCom.API.Models | ||
{ | ||
public class BanViewViewModel | ||
{ | ||
public string CKey { get; set; } | ||
public bool OnlyActive { get; set; } | ||
public IEnumerable<BanData> Bans { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>@ViewData["Title"]</title> | ||
|
||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous"> | ||
<environment include="Development"> | ||
<link rel="stylesheet" href="~/css/site.css" /> | ||
</environment> | ||
<environment exclude="Development"> | ||
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" /> | ||
</environment> | ||
|
||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" | ||
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" | ||
crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" | ||
crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | ||
@if (IsSectionDefined("AddToHead")) | ||
{ | ||
@RenderSection("AddToHead", required: false) | ||
} | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow"> | ||
<a class="navbar-brand col-md-3 col-lg-2 mr-0 px-3" href="/">CentCom</a> | ||
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-toggle="collapse" | ||
data-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<input id="ckey-search" class="form-control form-control-dark w-100" type="text" placeholder="Search ckey" aria-label="Search"> | ||
</nav> | ||
<div class="container-fluid"> | ||
<div class="row"> | ||
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse"> | ||
<div class="sidebar-sticky pt-3"> | ||
<ul class="nav flex-column"> | ||
<li class="nav-item"> | ||
<a asp-controller="Viewer" asp-action="Index" class="nav-link active"> | ||
<i data-feather="home"></i> | ||
Viewer | ||
</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="/swagger"> | ||
<span data-feather="file"></span> | ||
API Documentation | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</nav> | ||
|
||
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4 pt-3"> | ||
<div class="container body-content"> | ||
@RenderBody() | ||
</div> | ||
<hr /> | ||
<footer> | ||
<center> | ||
<p> | ||
<small> | ||
All content is provided without any guarantee, explicit or implied, of accuracy or permanent access. | ||
</small> | ||
</p> | ||
</center> | ||
</footer> | ||
</main> | ||
</div> | ||
</div> | ||
<script> | ||
feather.replace() | ||
function submitSearch() { | ||
var text = $('#ckey-search').val(); | ||
if ($.trim(text) != '') { | ||
window.location.href = window.location.origin + "/viewer/search/" + text; | ||
} | ||
} | ||
$('#ckey-search').submit(function (e) { | ||
submitSearch(); | ||
e.preventDefault(); | ||
}); | ||
$('#ckey-search').keypress(function (e) { | ||
if (e.which == '13') { | ||
submitSearch(); | ||
} | ||
}); | ||
</script> | ||
@RenderSection("Scripts", required: false) | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@model BanSearchViewModel | ||
@{ | ||
ViewBag.Title = "CentCom | Search Bans"; | ||
} | ||
<h2 class="mb-3">Search Results for '@Model.CKey'</h2> | ||
|
||
<div class="pl-1 pr-1"> | ||
<div> | ||
<p> | ||
Uh oh! Looks like the search request you tried was too short, or an invalid string. Try again with something longer! | ||
</p> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@{ | ||
ViewBag.Title = "CentCom"; | ||
} | ||
<h2 class="mb-3">CentCom Viewer</h2> | ||
<p> | ||
You can use this simple application to search through bans that are stored within CentCom. Type a ckey into the search box above to begin a query. | ||
<br /><br /> | ||
To view information on the API for CentCom, and how to use it, go to the <a href="/swagger">API Documentation</a>. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
@model BanSearchViewModel | ||
@{ | ||
ViewBag.Title = "CentCom | Search Bans"; | ||
} | ||
<h2 class="mb-3">Search Results for '@Model.CKey'</h2> | ||
|
||
<div class="pl-1 pr-1"> | ||
@if (Model.Data.Count() == 0) | ||
{ | ||
<div> | ||
<p> | ||
Found no bans for the searched key, perhaps that's a good thing! | ||
</p> | ||
</div> | ||
} | ||
else | ||
{ | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th scope="col">CKey</th> | ||
<th scope="col">Server Bans</th> | ||
<th scope="col">Job Bans</th> | ||
<th scope="col">Latest Ban</th> | ||
<th scope="col"></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@{ | ||
foreach (var b in Model.Data) | ||
{ | ||
<tr> | ||
<td>@b.CKey</td> | ||
<td>@b.ServerBans</td> | ||
<td>@b.JobBans</td> | ||
<td>@b.LatestBan</td> | ||
<td><a asp-controller="Viewer" asp-action="ViewBans" asp-route-key="@b.CKey" class="btn btn-outline-primary">View</a></td> | ||
</tr> | ||
} | ||
} | ||
</tbody> | ||
</table> | ||
} | ||
</div> |
Oops, something went wrong.