Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
0.0.4.2
Browse files Browse the repository at this point in the history
Closes #93 Maps that get deleted in the workshop now also get deleted in the database and as selected map. Takes after after saving game.ini
Closes #97 Could not crawl oculus profiles on steam! fix is not try to do that.
Closes #104 All hidden maps do now show a random mode. You need to change them to hide from hand
Closes #105 leaderboard now get the data via ajax
* Did a lot of css fixes. its now a lot more better on phones etc.
  • Loading branch information
devinSpitz authored Feb 26, 2022
2 parents 782a7cc + 4d02430 commit 0018006
Show file tree
Hide file tree
Showing 16 changed files with 474 additions and 276 deletions.
24 changes: 19 additions & 5 deletions PavlovRconWebserver/Controllers/LeaderBoardController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,30 @@ public async Task<IActionResult> Server(int server)
{
if(server==0) return RedirectToAction("Index");
var servers = (await _pavlovServerService.FindAll()).Where(x=>x.ServerType==ServerType.Community).ToList();

if(!servers.Select(x=>x.Id).Contains(server)) return RedirectToAction("Index");
var steamIdentityStats = (await _steamIdentityStatsServerService.FindAll()).Where(x=>x.ServerId==server);
var tmp = new LeaderBoardViewModel()
{
server = servers.First(x=>x.Id==server).Id,
AllServers = servers.Prepend(new PavlovServer()
{
Id = 0,
Name = "--Please select--"
}).ToList(),
list = steamIdentityStats.Select(x => new SteamIdentityStatsServerViewModel
}).ToList()
};
return View("Index", tmp);
}

[HttpGet("[controller]/Index/Server/Api/{server}")]
public async Task<IActionResult> ServerApi(int server)
{
if(server==0) return new ObjectResult("you need to set a serverId or no server found!");
var servers = (await _pavlovServerService.FindAll()).Where(x=>x.ServerType==ServerType.Community).ToList();

if(!servers.Select(x=>x.Id).Contains(server)) return new ObjectResult("you need to set a serverId or no server found!");
var steamIdentityStats = (await _steamIdentityStatsServerService.FindAll()).Where(x=>x.ServerId==server);
var tmp = new
{
model = steamIdentityStats.Select(x => new SteamIdentityStatsServerViewModel
{
SteamId = x.SteamId,
SteamName = x.SteamName,
Expand All @@ -66,9 +78,11 @@ public async Task<IActionResult> Server(int server)
UpTime = x.UpTime,
})
};
return View("Index", tmp);
return new ObjectResult(tmp);
}



[HttpGet("[controller]/Index/User/{steamId}")]
public async Task<IActionResult> User(string steamId)
{
Expand Down
8 changes: 4 additions & 4 deletions PavlovRconWebserver/Extensions/Staticscs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class Statics
{
public static string[] Models =
{
"none", "clown", "prisoner", "naked", "farmer", "russian", "nato", "us", "soviet", "german", "cop","infinitum","hidden"
"none", "clown", "prisoner", "naked", "farmer", "russian", "nato", "us", "soviet", "german", "cop","infinitum","hidden","aurora","kevin"
};

public static IDictionary<string, TimeSpan> BanList { get; } = new Dictionary<string, TimeSpan>
Expand Down Expand Up @@ -40,7 +40,7 @@ public static class GameModes
{"TTT", true},
{"OITC", false},
{"PUSH", true},
{"HIDDEN", true},
{"HIDE", true},
{"INFECTION", true},
{"PH", true}
};
Expand All @@ -58,14 +58,14 @@ public static class GameModes
{"TTT", false},
{"OITC", true},
{"PUSH", false},
{"HIDDEN", false},
{"HIDE", false},
{"INFECTION", false},
{"PH", false}
};

public static string[] ModesString =
{
"SND", "TDM", "DM", "GUN", "ZWV", "WW2GUN", "TANKTDM", "KOTH", "TTT", "OITC", "PUSH", "HIDDEN", "PH", "INFECTION"
"SND", "TDM", "DM", "GUN", "ZWV", "WW2GUN", "TANKTDM", "KOTH", "TTT", "OITC", "PUSH", "HIDE", "PH", "INFECTION"
};
}
}
2 changes: 1 addition & 1 deletion PavlovRconWebserver/PavlovRconWebserver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageVersion>0.0.4</PackageVersion>
<Title>PavlovRconWebserver</Title>
<Authors>Devin Spitz</Authors>
<AssemblyVersion>0.0.4.1</AssemblyVersion>
<AssemblyVersion>0.0.4.2</AssemblyVersion>
<LangVersion>9</LangVersion>
</PropertyGroup>
<ItemGroup>
Expand Down
14 changes: 14 additions & 0 deletions PavlovRconWebserver/Services/ServerSelectedMapService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ public async Task<ServerSelectedMap[]> FindAllFrom(PavlovServer pavlovServer)
.Include(x => x.Map)
.Include(x => x.PavlovServer)
.FindAsync(x => x.Map != null && x.PavlovServer.Id == pavlovServer.Id)).ToArray();
}
public async Task<ServerSelectedMap[]> GetAllWithMapId(string mapId)
{
return (await _liteDb.LiteDatabaseAsync.GetCollection<ServerSelectedMap>("ServerSelectedMap")
.Include(x => x.Map)
.Include(x => x.PavlovServer)
.FindAsync(x => x.Map != null && x.Map.Id == mapId)).ToArray();
}
public async Task<ServerSelectedMap[]> GetAllWithNoMoreMap()
{
return (await _liteDb.LiteDatabaseAsync.GetCollection<ServerSelectedMap>("ServerSelectedMap")
.Include(x => x.Map)
.Include(x => x.PavlovServer)
.FindAsync(x => x.Map==null)).ToArray();
}

public async Task<int> Insert(ServerSelectedMap serverSelectedMap)
Expand Down
16 changes: 14 additions & 2 deletions PavlovRconWebserver/Services/SteamService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,21 @@ await client.GetAsync(
var tmp = tmpRconMaps.FirstOrDefault(x => x.Id == map.Id);
var isNumeric = int.TryParse(map.Id, out _);
if (tmp == null && isNumeric)
{
foreach (var selected in await _serverSelectedMapService.GetAllWithMapId(map.Id))
await _serverSelectedMapService.Delete(selected.Id);

await _mapsService.Delete(map.Id);
}
// i should my here delete them from the serverSelectedMaps as well

}

//Clean maps that not exist anymore:
foreach (var invalidSelected in await _serverSelectedMapService.GetAllWithNoMoreMap())
await _serverSelectedMapService.Delete(invalidSelected.Id);

//Todo: Add a message to the server so the admin knows that he needs to save the Game.ini to get rid of the ghost maps.

return true;
}
Expand Down Expand Up @@ -233,9 +245,9 @@ public async Task<bool> CrawlSteamProfile()


var client = new HttpClient();
var allSteamIdentityStats = await _steamIdentityStatsServerService.FindAll();
var allSteamIdentityStats = (await _steamIdentityStatsServerService.FindAll()).Where(x=>!string.IsNullOrWhiteSpace(x.SteamId)).ToArray();

var steamIdentities = allSteamIdentityStats.GroupBy(x => x.SteamId).Select(x => x.Key);
var steamIdentities = allSteamIdentityStats.GroupBy(x =>x.SteamId).Select(x => x.Key);
foreach (var single in steamIdentities)
{
if(string.IsNullOrEmpty(single)) continue;
Expand Down
147 changes: 109 additions & 38 deletions PavlovRconWebserver/Views/LeaderBoard/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,67 +1,138 @@
@model LeaderBoardViewModel

<div class="container-fluid col-12 ">
<div class="container-fluid col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 col-xxl-12 ">

<form asp-controller="LeaderBoard" asp-action="Server" method="get">
@Html.LabelFor(x => x.server)
@Html.DropDownListFor(m => m.server, new SelectList(Model.AllServers, "Id", "Name", Model.server), new {@class = "form-control form-control-sm form-select ", onchange="submit()"})
</form>

<table id="leaderBoard" class="table table-responsive-sm col-12 ">
<table id="leaderBoard" class="table table-responsive-sm col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 col-xxl-12 ">
<thead>
<tr>
<th>ServerName</th>
<th>SteamId</th>
<th>SteamName</th>
<th>SteamPicture</th>
<th>Kills</th>
<th>Deaths</th>
<th>Assists</th>
<th>Expirence</th>
<th>UpTime</th>
<th name="serverName" class="serverName">ServerName</th>
<th name="steamId" class="steamId">SteamId</th>
<th name="steamName" class="steamName">SteamName</th>
<th name="steamPicture" class="steamPicture">SteamPicture</th>
<th name="kills" class="kills">Kills</th>
<th name="deaths" class="deaths">Deaths</th>
<th name="assists" class="assists">Assists</th>
<th name="expirence" class="expirence">Expirence</th>
<th name="upTime" class="upTime">UpTime</th>
</tr>
</thead>
<tbody>
@if (Model != null)
{
foreach (var steamIdentity in Model.list)
{
<tr>
<td>@steamIdentity.serverName</td>
<td>@steamIdentity.SteamId</td>
<td>@steamIdentity.SteamName</td>
@if (string.IsNullOrEmpty(@steamIdentity.SteamPicture))
{
<td><img src="~/images/noImg.png" height="150px" width="150px"/></td>
}
else
{
<td><img src="@steamIdentity.SteamPicture" height="150px" width="150px"/></td>
}
<td>@steamIdentity.Kills</td>
<td>@steamIdentity.Deaths</td>
<td>@steamIdentity.Assists</td>
<td>@steamIdentity.Exp</td>
<td>@steamIdentity.UpTime</td>
</tr>
}
}
@* gets autofilled *@
</tbody>
</table>

</div>

<link rel="stylesheet" type="text/css" href="~/lib/dataTables/datatables.min.css"/>
<script src="~/lib/dataTables/datatables.min.js" asp-append-version="true"></script>
<script>
function cleanOutput(data, defaultAnswer = "-")
{
if (typeof data !== "undefined" && data && (data.length >0||$.isNumeric( data )))
{
return data.toString()
}
return defaultAnswer;
}
//Will be called on document ready
function init(){
$.fn.dataTable.moment('DD-MMM-Y HH:mm:ss');
let columnDefs = [];
columnDefs.push({
"defaultContent": "-",
"targets": "_all"
});
columnDefs.push({
targets: "serverName",
"render":
function( data, type, row, meta){
return cleanOutput(row.serverName);
}
});
columnDefs.push({
targets: "steamId",
"render":
function( data, type, row, meta){
return cleanOutput(row.steamId);
}
});
columnDefs.push({
targets: "steamName",
"render":
function( data, type, row, meta){
return cleanOutput(row.steamName);
}
});
columnDefs.push({
targets: "steamPicture",
"render":
function( data, type, row, meta){
return "<img src='"+cleanOutput(row.steamPicture,"/images/noImg.png")+"' height='150px' width='150px'/>";
}
});
columnDefs.push({
targets: "kills",
"render":
function( data, type, row, meta){
return cleanOutput(row.kills);
}
});
columnDefs.push({
targets: "deaths",
"render":
function( data, type, row, meta){
return cleanOutput(row.deaths);
}
});
columnDefs.push({
targets: "assists",
"render":
function( data, type, row, meta){
return cleanOutput(row.assists);
}
});
columnDefs.push({
targets: "expirence",
"render":
function( data, type, row, meta){
return cleanOutput(row.exp);
}
});
columnDefs.push({
targets: "upTime",
type: 'datetime-moment',
orderDataType: 'datetime-moment',
"render":
function( data, type, row, meta){
if (typeof row.upTime === "undefined" || row.upTime === null)
return "-";
let thisDate = moment(row.upTime).format("HH:mm");
return thisDate+"h";
}
});
let serverId = $("#server").val()
if (serverId>0)
$('#leaderBoard').DataTable({
"lengthMenu": [[10, 25, 50,100, -1], [10, 25, 50,100, "All"]],
"order": [[ 7, "desc" ]],
"pageLength": 50,
"oSearch": {"sSearch": "@ViewBag.filter"}
columnDefs: columnDefs,
"oSearch": {"sSearch": "@ViewBag.filter"},
responsive: true,
"autoWidth": false,
ajax: {
url: `/LeaderBoard/Index/Server/Api/`+serverId,
dataSrc: function (json) {
return json['model'];
},
cache: true
},
});
}
Expand Down
Loading

0 comments on commit 0018006

Please sign in to comment.