mirror of
https://bitbucket.org/anguist/ntpa
synced 2026-10-14 09:29:48 +00:00
Allow peers without org id
This commit is contained in:
@@ -74,7 +74,7 @@ namespace Ntp.Analyzer.Objects
|
||||
/// </returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString() + String.Format("[Peer: Name={0}, Ip={1}, OrgId={2}]", Name, Ip, OrgId);
|
||||
return base.ToString() + String.Format("[Peer: Name={0}, Ip={1}, OrgId={2}]", Name, Ip, OrgId ?? Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,9 @@ namespace Ntp.Analyzer.Process.Description
|
||||
Peer peer = peers.Single();
|
||||
|
||||
PeerGraph graph = new PeerGraph(config, host, peer);
|
||||
string file = peer.Server.Name.Replace('.', '-') + ".png";
|
||||
|
||||
string name = peer.Server != null ? peer.Server.Name : peer.Name;
|
||||
string file = name.Replace('.', '-') + ".png";
|
||||
|
||||
SaveStream(graph, file);
|
||||
}
|
||||
|
||||
@@ -92,8 +92,9 @@ namespace Ntp.Analyzer.Process.Description
|
||||
|
||||
Peer peer = peers.Single();
|
||||
|
||||
GraphPageBuilder builder = new GraphPageBuilder(config, peer, peer.Server.Name, graphSet, graph);
|
||||
string file = config.GetFileName(host, peer.Server, graphSet, graph);
|
||||
string name = peer.Server != null ? peer.Server.Name : peer.Name;
|
||||
GraphPageBuilder builder = new GraphPageBuilder(config, peer, name, graphSet, graph);
|
||||
string file = config.GetFileName(host, name, graphSet, graph);
|
||||
|
||||
SaveStream(builder, file);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,9 @@ namespace Ntp.Analyzer.Process.Description
|
||||
else
|
||||
peerPageBuilder = new DefaultPeerPageBuilder(peer, page);
|
||||
|
||||
SaveStream(peerPageBuilder, peer.OrgId.Value.ToString(CultureInfo.InvariantCulture) + ".html");
|
||||
string name = peer.OrgId.HasValue ?
|
||||
peer.OrgId.Value.ToString (CultureInfo.InvariantCulture) : peer.Name;
|
||||
SaveStream(peerPageBuilder, name + ".html");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,10 +103,10 @@ namespace Ntp.Analyzer.Config.Page
|
||||
}
|
||||
}
|
||||
|
||||
public string GetFileName (Host host, TimeServer peer, GraphSetConfiguration graphSet, GraphBaseConfiguration graph)
|
||||
public string GetFileName (Host host, string name, GraphSetConfiguration graphSet, GraphBaseConfiguration graph)
|
||||
{
|
||||
return host.Name.Replace ('.', '-') + "_" +
|
||||
graph.GetAltName (graphSet, peer.Name).
|
||||
graph.GetAltName (graphSet, name).
|
||||
Replace (".png", String.Empty).
|
||||
Replace ('.', '-')
|
||||
+ ".html";
|
||||
|
||||
@@ -109,14 +109,17 @@ namespace Ntp.Analyzer.Render.Summery
|
||||
// TODO: Add links for images.
|
||||
foreach (GraphBaseConfiguration graph in graphSet.Graphs)
|
||||
{
|
||||
int id = peer.OrgId ?? peer.Id;
|
||||
string name = peer.Server != null ? peer.Server.Name : peer.Name;
|
||||
|
||||
builder.Append(@" <div class=""container theme-graph2"">");
|
||||
builder.Append(@"<a href=""");
|
||||
builder.Append(page.GetPeerLink(peer.OrgId.Value));
|
||||
builder.Append(page.GetPeerLink(id));
|
||||
builder.Append(@""">");
|
||||
builder.Append(@"<img class=""img-responsive"" src=""");
|
||||
builder.Append(graph.GetLink(graphSet, peer.Server.Name));
|
||||
builder.Append(graph.GetLink(graphSet, name));
|
||||
builder.Append(@""" alt=""");
|
||||
builder.Append(graph.GetAltName(graphSet, peer.Server.Name));
|
||||
builder.Append(graph.GetAltName(graphSet, name));
|
||||
builder.Append(@""">");
|
||||
builder.AppendLine(@"</a></div>");
|
||||
}
|
||||
|
||||
@@ -77,13 +77,16 @@ namespace Ntp.Analyzer.Render.Summery
|
||||
{
|
||||
foreach (GraphBaseConfiguration graph in graphSet.Graphs)
|
||||
{
|
||||
int id = peer.OrgId ?? peer.Id;
|
||||
string name = peer.Server != null ? peer.Server.Name : peer.Name;
|
||||
|
||||
builder.Append(@"<a href=""");
|
||||
builder.Append(page.GetPeerLink(peer.OrgId.Value));
|
||||
builder.Append(page.GetPeerLink(id));
|
||||
builder.Append(@""">");
|
||||
builder.Append(@"<img src=""");
|
||||
builder.Append(graph.GetLink(graphSet, peer.Server.Name));
|
||||
builder.Append(graph.GetLink(graphSet, name));
|
||||
builder.Append(@""" alt=""");
|
||||
builder.Append(graph.GetAltName(graphSet, peer.Server.Name));
|
||||
builder.Append(graph.GetAltName(graphSet, name));
|
||||
builder.Append(@""">");
|
||||
builder.AppendLine(@"</a>");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user