NTP Analyzer  0.8.2
Analyze the operation of time servers
PeerGraphPageConfiguration.cs
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21 
22 using System;
23 using System.Collections.Generic;
27 using Ntp.Analyzer.Config.Table;
28 using Ntp.Analyzer.Objects;
29 using Ntp.Common.Process;
30 using Ntp.Common.Web;
31 
32 namespace Ntp.Analyzer.Config.Node.Page
33 {
35  {
37  string configName,
38  int? frequency,
39  bool? initialRun,
40  bool? fixedRun,
41  int? linkIndex,
43  DestinationCollection destinations,
44  Uri link)
45  : base(configName, destinations, link)
46  {
47  this.frequency = frequency;
48  this.initialRun = initialRun;
49  this.fixedRun = fixedRun;
50  this.linkIndex = linkIndex;
51  ConfigLink = link;
52  PageConfiguration = page;
53  }
54 
55  private readonly bool? fixedRun;
56  private readonly int? frequency;
57  private readonly bool? initialRun;
58  private readonly int? linkIndex;
59 
60  public override PageTheme Theme => PageTheme.Default;
61 
62  public override string Title => string.Empty;
63 
64  [NtpaIndex(10)]
65  [NtpaReference(Symbol.KeywordGraphPage)]
66  public PeerPageConfiguration PageConfiguration { get; }
67 
68  [NtpaIndex(11)]
69  [NtpaSetting(Symbol.KeywordLinkIndex, 1)]
70  public override int LinkIndex => linkIndex ?? 1;
71 
72  [NtpaIndex(20)]
73  [NtpaSetting(Symbol.KeywordLink)]
74  public Uri ConfigLink { get; }
75 
76  public override IEnumerable<GraphSetConfiguration> GraphSets => PageConfiguration.Graphs;
77 
78  [NtpaIndex(1)]
79  [NtpaSetting(Symbol.KeywordFrequency, 0)]
80  public int Frequency => frequency ?? 0;
81 
82  [NtpaIndex(2)]
83  [NtpaSetting(Symbol.KeywordInitialRun, true)]
84  public bool InitialRun => initialRun ?? true;
85 
86  [NtpaIndex(3)]
87  [NtpaSetting(Symbol.KeywordFixedRun, false)]
88  public bool FixedRun => fixedRun ?? false;
89 
90  public string GetFileName(Host host, string name, GraphSetConfiguration graphSet, GraphBaseConfiguration graph)
91  {
92  return GetGraphFileName(host, name, graphSet, graph);
93  }
94 
95  public Uri GetLink(Host host, string name, GraphSetConfiguration graphSet, GraphBaseConfiguration graph)
96  {
97  return WebPath.Append(Link, GetGraphFileName(host, name, graphSet, graph));
98  }
99 
100  internal override void Assemble()
101  {
102  base.Assemble();
103  PageConfiguration.AttachGraphPage(this);
104  }
105 
106  private string GetGraphFileName(Host host, string name, GraphSetConfiguration graphSet,
108  {
109  return
110  host.Name.Replace('.', '-') + "_" +
111  graph.GetAltName(graphSet, name).
112  Replace(".png", string.Empty).
113  Replace('.', '-')
114  + ".html";
115  }
116  }
117 }
string GetGraphFileName(Host host, string name, GraphSetConfiguration graphSet, GraphBaseConfiguration graph)
string GetFileName(Host host, string name, GraphSetConfiguration graphSet, GraphBaseConfiguration graph)
IEnumerable< GraphSetConfiguration > Graphs
Gets the graphs to be displayed on this page.
abstract string GetAltName(GraphSetConfiguration owner, string postfix)
Uri GetLink(Host host, string name, GraphSetConfiguration graphSet, GraphBaseConfiguration graph)
PeerGraphPageConfiguration(string configName, int?frequency, bool?initialRun, bool?fixedRun, int?linkIndex, PeerPageConfiguration page, DestinationCollection destinations, Uri link)