diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs index 9eec26583b..020f7193e7 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs @@ -36,7 +36,13 @@ namespace Microsoft.AspNet.Diagnostics.Elm return; } - var options = ParseParams(context); + var t = await ParseParams(context); + var options = t.Item1; + var redirect = t.Item2; + if (redirect) + { + return; + } if (context.Request.Path == _options.Path) { RenderMainLogPage(options, context); @@ -81,27 +87,38 @@ namespace Microsoft.AspNet.Diagnostics.Elm await requestPage.ExecuteAsync(context); } - private ViewOptions ParseParams(HttpContext context) + private async Task> ParseParams(HttpContext context) { var options = new ViewOptions() { MinLevel = LogLevel.Verbose, NamePrefix = string.Empty }; - if (context.Request.Query.ContainsKey("level")) + var isRedirect = false; + var form = await context.Request.GetFormAsync(); + if (form.ContainsKey("clear")) { - var minLevel = options.MinLevel; - if (Enum.TryParse(context.Request.Query["level"], out minLevel)) + _store.Clear(); + context.Response.Redirect(context.Request.PathBase.Add(_options.Path).ToString()); + isRedirect = true; + } + else + { + if (context.Request.Query.ContainsKey("level")) { - options.MinLevel = minLevel; + var minLevel = options.MinLevel; + if (Enum.TryParse(context.Request.Query["level"], out minLevel)) + { + options.MinLevel = minLevel; + } + } + if (context.Request.Query.ContainsKey("name")) + { + var namePrefix = context.Request.Query.GetValues("name")[0]; + options.NamePrefix = namePrefix; } } - if (context.Request.Query.ContainsKey("name")) - { - var namePrefix = context.Request.Query.GetValues("name")[0]; - options.NamePrefix = namePrefix; - } - return options; + return Tuple.Create(options, isRedirect); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/ElmStore.cs b/src/Microsoft.AspNet.Diagnostics.Elm/ElmStore.cs index b328d80ed4..e2c0982996 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/ElmStore.cs +++ b/src/Microsoft.AspNet.Diagnostics.Elm/ElmStore.cs @@ -48,6 +48,14 @@ namespace Microsoft.AspNet.Diagnostics.Elm } } + /// + /// Removes all activity contexts that have been stored. + /// + public void Clear() + { + Activities.Clear(); + } + /// /// Returns the total number of logs in all activities in the store /// diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs index 9f62571070..3433f135dd 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs +++ b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs @@ -318,6 +318,10 @@ col:nth-child(2) { background-color: #FAFAFA; } +form { + display: inline-block; +} + h1 { margin-left: 25px; } @@ -501,6 +505,9 @@ tr:nth-child(2n) { WriteLiteral(@" /> +
+ +
@@ -518,13 +525,13 @@ tr:nth-child(2n) { "); -#line 136 "LogPage.cshtml" +#line 139 "LogPage.cshtml" #line default #line hidden -#line 136 "LogPage.cshtml" +#line 139 "LogPage.cshtml" foreach (var activity in Model.Activities.Reverse()) { @@ -532,13 +539,13 @@ tr:nth-child(2n) { #line hidden WriteLiteral(" \r\n \r\n"); -#line 140 "LogPage.cshtml" +#line 143 "LogPage.cshtml" #line default #line hidden -#line 140 "LogPage.cshtml" +#line 143 "LogPage.cshtml" if (activity.HttpInfo != null) { @@ -548,30 +555,30 @@ tr:nth-child(2n) { #line hidden WriteLiteral(" \r\n \r\n \r\n"); -#line 147 "LogPage.cshtml" +#line 150 "LogPage.cshtml" } else { @@ -580,13 +587,13 @@ tr:nth-child(2n) { #line hidden WriteLiteral(" \r\n"); -#line 151 "LogPage.cshtml" +#line 154 "LogPage.cshtml" } @@ -608,13 +615,13 @@ tr:nth-child(2n) { "); -#line 166 "LogPage.cshtml" +#line 169 "LogPage.cshtml" #line default #line hidden -#line 166 "LogPage.cshtml" +#line 169 "LogPage.cshtml" if (activity.Id.Equals(Guid.Empty)) { // message not within a scope @@ -623,12 +630,12 @@ tr:nth-child(2n) { #line default #line hidden -#line 169 "LogPage.cshtml" +#line 172 "LogPage.cshtml" Write(LogRow(activity.Root.Messages.FirstOrDefault(), 0)); #line default #line hidden -#line 169 "LogPage.cshtml" +#line 172 "LogPage.cshtml" } else @@ -638,12 +645,12 @@ tr:nth-child(2n) { #line default #line hidden -#line 173 "LogPage.cshtml" +#line 176 "LogPage.cshtml" Write(Traverse(activity.Root, 0)); #line default #line hidden -#line 173 "LogPage.cshtml" +#line 176 "LogPage.cshtml" } @@ -652,7 +659,7 @@ tr:nth-child(2n) { WriteLiteral(" \r\n
(requestPath, 4407), false)); - WriteAttribute("title", Tuple.Create(" title=\"", 4420), Tuple.Create("\"", 4451), - Tuple.Create(Tuple.Create("", 4428), Tuple.Create(activity.HttpInfo.Path, 4428), false)); + WriteAttribute("href", Tuple.Create(" href=\"", 4534), Tuple.Create("\"", 4553), + Tuple.Create(Tuple.Create("", 4541), Tuple.Create(requestPath, 4541), false)); + WriteAttribute("title", Tuple.Create(" title=\"", 4554), Tuple.Create("\"", 4585), + Tuple.Create(Tuple.Create("", 4562), Tuple.Create(activity.HttpInfo.Path, 4562), false)); WriteLiteral(">"); -#line 144 "LogPage.cshtml" +#line 147 "LogPage.cshtml" Write(activity.HttpInfo.Path); #line default #line hidden WriteLiteral(""); -#line 145 "LogPage.cshtml" +#line 148 "LogPage.cshtml" Write(activity.HttpInfo.Host); #line default #line hidden WriteLiteral(""); -#line 146 "LogPage.cshtml" +#line 149 "LogPage.cshtml" Write(activity.HttpInfo.StatusCode); #line default #line hidden WriteLiteral(""); -#line 150 "LogPage.cshtml" +#line 153 "LogPage.cshtml" Write(activity.Root.State); #line default #line hidden WriteLiteral("
\r\n " + " \r\n \r\n \r\n"); -#line 180 "LogPage.cshtml" +#line 183 "LogPage.cshtml" } #line default diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cshtml b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cshtml index da02a19745..0b6aa0ea42 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cshtml +++ b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cshtml @@ -117,6 +117,9 @@ +
+ +
diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.css b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.css index ff0aa8ef29..ff305ecf60 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.css +++ b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.css @@ -8,6 +8,10 @@ col:nth-child(2) { background-color: #FAFAFA; } +form { + display: inline-block; +} + h1 { margin-left: 25px; }