fixed issue with timeline history!

This commit is contained in:
RaidMax 2015-04-27 12:40:57 -05:00
parent c9889f0792
commit 8e7622c64e
8 changed files with 114 additions and 20 deletions

View File

@ -450,6 +450,9 @@ namespace IW4MAdmin
//Update stat information of specified player
public void updatePlayer(Player P)
{
if (P.stats == null)
return;
Dictionary<String, object> updatedPlayer = new Dictionary<String, object>();
updatedPlayer.Add("KILLS", P.stats.Kills);

18
Admin/Helpers.cs Normal file
View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IW4MAdmin
{
class pHistory
{
public pHistory(DateTime w, int cNum)
{
When = w;
Players = cNum;
}
public DateTime When { get; private set; }
public int Players { get; private set; }
}
}

View File

@ -97,6 +97,7 @@
<Compile Include="Event.cs" />
<Compile Include="File.cs" />
<Compile Include="Heartbeat.cs" />
<Compile Include="Helpers.cs" />
<Compile Include="Log.cs" />
<Compile Include="Main.cs" />
<Compile Include="Maps.cs" />
@ -130,6 +131,9 @@
<Content Include="webfront\footer.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="webfront\graph.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="webfront\header.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
@ -146,7 +150,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="config\messages.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="config\rules.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View File

@ -39,7 +39,7 @@ namespace IW4MAdmin
Skills = new Moserware.TrueSkill();
statusPlayers = new Dictionary<string, Player>();
chatHistory = new List<Chat>();
playerHistory = new Queue<int>();
playerHistory = new Queue<pHistory>();
lastWebChat = DateTime.Now;
nextMessage = 0;
initCommands();
@ -529,9 +529,15 @@ namespace IW4MAdmin
isRunning = true;
#if DEBUG
// Random rnd = new Random();
// while (playerHistory.Count < 144)
// playerHistory.Enqueue(rnd.Next(0, 18));
/* Random rnd = new Random();
DateTime testTOD = DateTime.Now;
while (playerHistory.Count < 144)
{
playerHistory.Enqueue(new pHistory(testTOD, rnd.Next(14, 19)));
testTOD = testTOD.AddMinutes(5);
}
Console.WriteLine("There are " + playerHistory.Count + " player counts");*/
#endif
//Handles new rcon requests in a fashionable manner
@ -579,9 +585,9 @@ namespace IW4MAdmin
if ((lastCount - playerCountStart).TotalMinutes > 4)
{
while (playerHistory.Count > 144 )
while (playerHistory.Count > 144 ) // 12 times a minute for 12 hours
playerHistory.Dequeue();
playerHistory.Enqueue(clientnum);
playerHistory.Enqueue(new pHistory(lastCount, clientnum));
playerCountStart = DateTime.Now;
}
@ -1406,7 +1412,7 @@ namespace IW4MAdmin
public int totalKills = 0;
public List<Report> Reports;
public List<Chat> chatHistory;
public Queue<int> playerHistory;
public Queue<pHistory> playerHistory;
//Info

View File

@ -463,19 +463,20 @@ namespace IW4MAdmin_Web
test.Append("<script type='text/javascript' src='//www.google.com/jsapi'></script><div id='chart_div'></div>");
test.Append("<script> var players = [");
int count = 1;
DateTime prev = DateTime.Now;
foreach (int i in IW4MAdmin.Program.Servers[server].playerHistory.ToArray())
List<IW4MAdmin.pHistory> run = IW4MAdmin.Program.Servers[server].playerHistory.ToList();
foreach (IW4MAdmin.pHistory i in run) //need to reverse for proper timeline
{
test.AppendFormat("[[{0},{1},{2}], {3}]", prev.Hour, prev.Minute, prev.Second, i);
prev = prev.AddMinutes(-5);
test.AppendFormat("[new Date({0}, {1}, {2}, {3}, {4}), {5}]", i.When.Year, i.When.Month - 1, i.When.Day, i.When.Hour, i.When.Minute, i.Players);
if (count < IW4MAdmin.Program.Servers[server].playerHistory.Count)
test.Append(',');
test.Append(",\n");
count++;
}
test.Append("];\n");
test.Append("</script>");
test.Append("<script>function drawBasic(){var a=new google.visualization.DataTable;a.addColumn('timeofday','Time'),a.addColumn('number','Players'),a.addRows(players);var e={ hAxis:{title:'Time', gridlines: {count:10}}, vAxis:{title:'Players'}, vAxis: {viewWindow: {max:18}, gridlines: {count:7}}},i=new google.visualization.LineChart(document.getElementById('chart_div'));i.draw(a,e)}google.load('visualization','1',{ callback: drawBasic, packages:['corechart','line']});</script>");
body = test.ToString();
IW4MAdmin.file Graph = new IW4MAdmin.file("webfront\\graph.html");
var graph = Graph.getLines();
Graph.Close();
body = test.ToString() + graph ;
}
else if (request.QueryString == "player")
@ -500,8 +501,8 @@ namespace IW4MAdmin_Web
IW4MAdmin.Player P = IW4MAdmin.Program.Servers[server].clientDB.getPlayer(IP);
if (P == null)
P = new IW4MAdmin.Player("Guest", "Guest", 0, 0);
if (P.getLevel() > IW4MAdmin.Player.Permission.Flagged)
Console.WriteLine(P.getName() + " is authenticated");
// if (P.getLevel() > IW4MAdmin.Player.Permission.Flagged)
// Console.WriteLine(P.getName() + " is authenticate");
Client toSend = new Client(WebFront.Page.player, page, request.Headers, Data, P);
body = Macro.findMacros(header + player + footer, toSend, server);

View File

@ -1,4 +1,8 @@
VERSION: 0.9
VERSION: 0.9.1
CHANGELOG:
fixed issue with `history` timelime
VERSION: 0.9
CHANGELOG:
-webfront now displays player info and link to repz account
-webfront shows ips for authed admin ( determined by ip )

View File

@ -9,8 +9,8 @@
$("#history_dialog").dialog({
autoOpen: false,
modal: true,
width: 1000,
height: 350,
width: 1100,
height: 450,
buttons: {
"Dismiss": function () {
$(this).dialog("close");

58
Admin/webfront/graph.html Normal file
View File

@ -0,0 +1,58 @@
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script>
google.load('visualization', '1', { callback: drawChart, packages: ['corechart'] });
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Time');
data.addColumn('number', 'Players');
data.addRows(players);
var options = {
//curveType: 'function',
//width: 900,
height: 300,
legend: {position: 'none'},
enableInteractivity: true,
chartArea: {
width: '93%'
},
vAxis: {
title: 'Players',
gridlines: { count: 7 },
viewWindowMode: 'explicit',
viewWindow: {
min: 0,
max: 18
},
},
hAxis: {
viewWindow: {
//min: players[0][0],
//max: players[players.length-1][0]
},
gridlines: {
count: 12,
units: {
days: {format: ["MMM dd"]},
hours: {format: ["HH:mm", "ha"]},
}
},
minorGridlines: {
count: 5,
units: {
hours: {format: ["hh:mm:ss a", "ha"]},
minutes: {format: ["HH:mm a Z", ":mm"]}
}
}
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>