Example #1
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "a";
            output.Attributes.SetAttribute("href", "#");
            output.Attributes.SetAttribute("class", "pull-right hover-pulsate js-reload-link");
            if (NodeType.HasValue())
            {
                output.Attributes.SetAttribute("data-type", NodeType);
                output.Attributes.SetAttribute("data-uk", "all");
            }
            else if (Node != null)
            {
                output.Attributes.SetAttribute("data-type", Node.NodeType);
                output.Attributes.SetAttribute("data-uk", Node.UniqueKey);
                output.Attributes.SetAttribute("title", "Updated " + Node.LastPoll?.ToZuluTime());

                if (Cache != null)
                {
                    output.Attributes.SetAttribute("data-guid", Cache.UniqueId.ToString());
                }
                else if (Caches != null)
                {
                    output.Attributes.SetAttribute("data-guid", JsonSerializer.Serialize(Caches.Select(i => i.UniqueId)));
                }
            }
            else if (Nodes != null)
            {
                output.Attributes.SetAttribute("data-type", Nodes.FirstOrDefault()?.NodeType);
                output.Attributes.SetAttribute("data-uk", JsonSerializer.Serialize(Nodes.Where(n => n != null).Select(n => n.UniqueKey)));
            }

            output.Content.SetContent(Icon.Refresh + @" <span class=""js-text"">Poll Now</span>");

            //<a href="#" class="pull-right hover-pulsate js-reload-link" data-type="@n.NodeType" data-uk="@n.UniqueKey" data-guid="@(c?.UniqueId.ToString())" title="Updated @(n.LastPoll?.ToZuluTime())"></a>

//@helper PollNow(params LightweightCache[] caches)
//{
//    if (caches != null)
//    {
//        <a data-type="@Opserver.Data.Cache.TimedCacheKey" data-uk="@Json.Encode(caches.Where(i => i != null).Select(i => i.Key))"></a>
//    }
//}
//@helper PollNow(LightweightCache cache)
//{
//    <a data-type="@Opserver.Data.Cache.TimedCacheKey" data-uk="@cache.Key"></a>
//}
        }