Commit f6ca2cc4 authored by yangxiaodong's avatar yangxiaodong

cleanup.

parent 7930e82c
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
......
...@@ -135,7 +135,6 @@ namespace DotNetCore.CAP.Dashboard ...@@ -135,7 +135,6 @@ namespace DotNetCore.CAP.Dashboard
IntValue = page.Statistics.ReceivedSucceeded IntValue = page.Statistics.ReceivedSucceeded
}); });
//---------------------------------------------------- //----------------------------------------------------
public static readonly DashboardMetric PublishedFailedCount = new DashboardMetric( public static readonly DashboardMetric PublishedFailedCount = new DashboardMetric(
...@@ -147,6 +146,7 @@ namespace DotNetCore.CAP.Dashboard ...@@ -147,6 +146,7 @@ namespace DotNetCore.CAP.Dashboard
Style = page.Statistics.PublishedFailed > 0 ? MetricStyle.Danger : MetricStyle.Default, Style = page.Statistics.PublishedFailed > 0 ? MetricStyle.Danger : MetricStyle.Default,
Highlighted = page.Statistics.PublishedFailed > 0 Highlighted = page.Statistics.PublishedFailed > 0
}); });
public static readonly DashboardMetric ReceivedFailedCount = new DashboardMetric( public static readonly DashboardMetric ReceivedFailedCount = new DashboardMetric(
"received_failed:count", "received_failed:count",
"Metrics_FailedJobs", "Metrics_FailedJobs",
......
...@@ -15,6 +15,7 @@ namespace DotNetCore.CAP.Dashboard ...@@ -15,6 +15,7 @@ namespace DotNetCore.CAP.Dashboard
public abstract string RemoteIpAddress { get; } public abstract string RemoteIpAddress { get; }
public abstract string GetQuery(string key); public abstract string GetQuery(string key);
public abstract Task<IList<string>> GetFormValuesAsync(string key); public abstract Task<IList<string>> GetFormValuesAsync(string key);
} }
...@@ -33,7 +34,9 @@ namespace DotNetCore.CAP.Dashboard ...@@ -33,7 +34,9 @@ namespace DotNetCore.CAP.Dashboard
public override string PathBase => _context.Request.PathBase.Value; public override string PathBase => _context.Request.PathBase.Value;
public override string LocalIpAddress => _context.Connection.LocalIpAddress.ToString(); public override string LocalIpAddress => _context.Connection.LocalIpAddress.ToString();
public override string RemoteIpAddress => _context.Connection.RemoteIpAddress.ToString(); public override string RemoteIpAddress => _context.Connection.RemoteIpAddress.ToString();
public override string GetQuery(string key) => _context.Request.Query[key]; public override string GetQuery(string key) => _context.Request.Query[key];
public override async Task<IList<string>> GetFormValuesAsync(string key) public override async Task<IList<string>> GetFormValuesAsync(string key)
{ {
var form = await _context.Request.ReadFormAsync(); var form = await _context.Request.ReadFormAsync();
......
...@@ -14,6 +14,7 @@ namespace DotNetCore.CAP.Dashboard ...@@ -14,6 +14,7 @@ namespace DotNetCore.CAP.Dashboard
public abstract Stream Body { get; } public abstract Stream Body { get; }
public abstract void SetExpire(DateTimeOffset? value); public abstract void SetExpire(DateTimeOffset? value);
public abstract Task WriteAsync(string text); public abstract Task WriteAsync(string text);
} }
...@@ -21,7 +22,7 @@ namespace DotNetCore.CAP.Dashboard ...@@ -21,7 +22,7 @@ namespace DotNetCore.CAP.Dashboard
{ {
private readonly HttpContext _context; private readonly HttpContext _context;
public CapDashboardResponse( HttpContext context) public CapDashboardResponse(HttpContext context)
{ {
if (context == null) throw new ArgumentNullException(nameof(context)); if (context == null) throw new ArgumentNullException(nameof(context));
_context = context; _context = context;
......
...@@ -72,11 +72,10 @@ namespace DotNetCore.CAP.Dashboard ...@@ -72,11 +72,10 @@ namespace DotNetCore.CAP.Dashboard
GetExecutingAssembly(), GetExecutingAssembly(),
GetContentResourceName("fonts", "glyphicons-halflings-regular.woff2"))); GetContentResourceName("fonts", "glyphicons-halflings-regular.woff2")));
#endregion #endregion Embedded static content
#region Razor pages and commands #region Razor pages and commands
Routes.AddJsonResult("/published/message/(?<Id>.+)", x => Routes.AddJsonResult("/published/message/(?<Id>.+)", x =>
{ {
var id = int.Parse(x.UriMatch.Groups["Id"].Value); var id = int.Parse(x.UriMatch.Groups["Id"].Value);
...@@ -186,7 +185,7 @@ namespace DotNetCore.CAP.Dashboard ...@@ -186,7 +185,7 @@ namespace DotNetCore.CAP.Dashboard
//Routes.AddRazorPage("/servers", x => new ServersPage()); //Routes.AddRazorPage("/servers", x => new ServersPage());
//Routes.AddRazorPage("/retries", x => new RetriesPage()); //Routes.AddRazorPage("/retries", x => new RetriesPage());
#endregion #endregion Razor pages and commands
} }
public static RouteCollection Routes { get; } public static RouteCollection Routes { get; }
......
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text;
using System.ComponentModel;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using DotNetCore.CAP.Dashboard.Resources;
using DotNetCore.CAP.Dashboard.Pages; using DotNetCore.CAP.Dashboard.Pages;
using DotNetCore.CAP.Dashboard.Resources;
using DotNetCore.CAP.Infrastructure; using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models; using DotNetCore.CAP.Models;
using Microsoft.Extensions.Internal; using Microsoft.Extensions.Internal;
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
{ {
public interface IDashboardAuthorizationFilter public interface IDashboardAuthorizationFilter
{ {
bool Authorize( DashboardContext context); bool Authorize(DashboardContext context);
} }
} }
\ No newline at end of file
using System; using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace DotNetCore.CAP.Dashboard namespace DotNetCore.CAP.Dashboard
{ {
......
...@@ -11,16 +11,23 @@ namespace DotNetCore.CAP.Dashboard ...@@ -11,16 +11,23 @@ namespace DotNetCore.CAP.Dashboard
IList<MessageDto> Messages(MessageQueryDto queryDto); IList<MessageDto> Messages(MessageQueryDto queryDto);
int PublishedFailedCount(); int PublishedFailedCount();
int PublishedProcessingCount(); int PublishedProcessingCount();
int PublishedSucceededCount(); int PublishedSucceededCount();
int ReceivedFailedCount(); int ReceivedFailedCount();
int ReceivedProcessingCount(); int ReceivedProcessingCount();
int ReceivedSucceededCount(); int ReceivedSucceededCount();
IDictionary<DateTime, int> SucceededByDatesCount(); IDictionary<DateTime, int> SucceededByDatesCount();
IDictionary<DateTime, int> FailedByDatesCount(); IDictionary<DateTime, int> FailedByDatesCount();
IDictionary<DateTime, int> HourlySucceededJobs(); IDictionary<DateTime, int> HourlySucceededJobs();
IDictionary<DateTime, int> HourlyFailedJobs(); IDictionary<DateTime, int> HourlyFailedJobs();
} }
} }
\ No newline at end of file
...@@ -14,6 +14,7 @@ namespace DotNetCore.CAP.Dashboard ...@@ -14,6 +14,7 @@ namespace DotNetCore.CAP.Dashboard
private static readonly IDictionary<string, string> BackgroundStateColors private static readonly IDictionary<string, string> BackgroundStateColors
= new Dictionary<string, string>(); = new Dictionary<string, string>();
private static readonly IDictionary<string, string> ForegroundStateColors private static readonly IDictionary<string, string> ForegroundStateColors
= new Dictionary<string, string>(); = new Dictionary<string, string>();
...@@ -144,7 +145,6 @@ namespace DotNetCore.CAP.Dashboard ...@@ -144,7 +145,6 @@ namespace DotNetCore.CAP.Dashboard
itemsAdded = true; itemsAdded = true;
} }
if (stateData.ContainsKey("Result") && !String.IsNullOrWhiteSpace(stateData["Result"])) if (stateData.ContainsKey("Result") && !String.IsNullOrWhiteSpace(stateData["Result"]))
{ {
var result = stateData["Result"]; var result = stateData["Result"];
......
using System; using System;
using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
......
...@@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard ...@@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard
var settings = new JsonSerializerSettings var settings = new JsonSerializerSettings
{ {
ContractResolver = new CamelCasePropertyNamesContractResolver(), ContractResolver = new CamelCasePropertyNamesContractResolver(),
Converters = new JsonConverter[]{ new StringEnumConverter { CamelCaseText = true } } Converters = new JsonConverter[] { new StringEnumConverter { CamelCaseText = true } }
}; };
var serialized = JsonConvert.SerializeObject(result, settings); var serialized = JsonConvert.SerializeObject(result, settings);
......
using System; using System;
using System.Collections.Generic;
using System.Text;
namespace DotNetCore.CAP.Dashboard namespace DotNetCore.CAP.Dashboard
{ {
......
...@@ -51,7 +51,6 @@ namespace DotNetCore.CAP.Dashboard ...@@ -51,7 +51,6 @@ namespace DotNetCore.CAP.Dashboard
Active = page.RequestPath.StartsWith("/received/failed"), Active = page.RequestPath.StartsWith("/received/failed"),
Metric = DashboardMetrics.ReceivedFailedCount Metric = DashboardMetrics.ReceivedFailedCount
}); });
} }
} }
} }
\ No newline at end of file
 namespace DotNetCore.CAP.Dashboard
namespace DotNetCore.CAP.Dashboard
{ {
public class Metric public class Metric
{ {
......
using System; using System;
namespace DotNetCore.CAP.Dashboard.Monitoring namespace DotNetCore.CAP.Dashboard.Monitoring
{ {
public class MessageDto public class MessageDto
......
using System; using DotNetCore.CAP.Models;
using System.Collections.Generic;
using System.Text;
using DotNetCore.CAP.Models;
namespace DotNetCore.CAP.Dashboard.Monitoring namespace DotNetCore.CAP.Dashboard.Monitoring
{ {
......
using System; namespace DotNetCore.CAP.Dashboard.Monitoring
using System.Collections.Generic;
namespace DotNetCore.CAP.Dashboard.Monitoring
{ {
public class SubscriberDto public class SubscriberDto
{ {
......
...@@ -13,7 +13,7 @@ namespace DotNetCore.CAP.Dashboard ...@@ -13,7 +13,7 @@ namespace DotNetCore.CAP.Dashboard
Items.Add(page => new MenuItem(Strings.NavigationMenu_Published, page.Url.LinkToPublished()) Items.Add(page => new MenuItem(Strings.NavigationMenu_Published, page.Url.LinkToPublished())
{ {
Active = page.RequestPath.StartsWith("/published"), Active = page.RequestPath.StartsWith("/published"),
Metrics = new [] Metrics = new[]
{ {
DashboardMetrics.PublishedSucceededCount, DashboardMetrics.PublishedSucceededCount,
DashboardMetrics.PublishedFailedCountOrNull DashboardMetrics.PublishedFailedCountOrNull
......
using System; using System;
using System.Collections.Generic;
using System.Text;
using DotNetCore.CAP.Processor.States; using DotNetCore.CAP.Processor.States;
namespace DotNetCore.CAP.Dashboard.Pages namespace DotNetCore.CAP.Dashboard.Pages
......
using System; using System;
using System.Collections.Generic;
using System.Text;
using DotNetCore.CAP.Processor.States; using DotNetCore.CAP.Processor.States;
namespace DotNetCore.CAP.Dashboard.Pages namespace DotNetCore.CAP.Dashboard.Pages
......
...@@ -5,7 +5,7 @@ namespace DotNetCore.CAP.Dashboard.Pages ...@@ -5,7 +5,7 @@ namespace DotNetCore.CAP.Dashboard.Pages
{ {
partial class SidebarMenu partial class SidebarMenu
{ {
public SidebarMenu( IEnumerable<Func<RazorPage, MenuItem>> items) public SidebarMenu(IEnumerable<Func<RazorPage, MenuItem>> items)
{ {
if (items == null) throw new ArgumentNullException(nameof(items)); if (items == null) throw new ArgumentNullException(nameof(items));
Items = items; Items = items;
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Threading.Tasks;
using DotNetCore.CAP.Dashboard.Monitoring; using DotNetCore.CAP.Dashboard.Monitoring;
namespace DotNetCore.CAP.Dashboard namespace DotNetCore.CAP.Dashboard
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace DotNetCore.CAP.Dashboard namespace DotNetCore.CAP.Dashboard
......
using System; using System;
using System.Collections.Generic;
namespace DotNetCore.CAP.Dashboard namespace DotNetCore.CAP.Dashboard
{ {
public class UrlHelper public class UrlHelper
{ {
private readonly DashboardContext _context; private readonly DashboardContext _context;
public UrlHelper( DashboardContext context) public UrlHelper(DashboardContext context)
{ {
if (context == null) throw new ArgumentNullException(nameof(context)); if (context == null) throw new ArgumentNullException(nameof(context));
_context = context; _context = context;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment