From 12e04037248c49beb2d90945842dd11b79176c01 Mon Sep 17 00:00:00 2001 From: yangxiaodong Date: Fri, 1 Sep 2017 18:33:23 +0800 Subject: [PATCH] add pages. --- .../Dashboard/DashboardRoutes.cs | 4 +- src/DotNetCore.CAP/Dashboard/HtmlHelper.cs | 28 +- .../Dashboard/Pages/QueuesPage.cshtml | 122 ++++ .../Dashboard/Pages/QueuesPage.generated.cs | 574 ++++++++++++++++++ .../Dashboard/Pages/_Breadcrumbs.generated.cs | 105 ++++ .../Dashboard/Pages/_SidebarMenu.generated.cs | 139 +++++ 6 files changed, 956 insertions(+), 16 deletions(-) create mode 100644 src/DotNetCore.CAP/Dashboard/Pages/QueuesPage.cshtml create mode 100644 src/DotNetCore.CAP/Dashboard/Pages/QueuesPage.generated.cs create mode 100644 src/DotNetCore.CAP/Dashboard/Pages/_Breadcrumbs.generated.cs create mode 100644 src/DotNetCore.CAP/Dashboard/Pages/_SidebarMenu.generated.cs diff --git a/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs b/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs index 7ab21d9..f08f01d 100644 --- a/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs +++ b/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs @@ -74,10 +74,10 @@ namespace DotNetCore.CAP.Dashboard #region Razor pages and commands - //Routes.AddRazorPage("/jobs/enqueued", x => new QueuesPage()); + Routes.AddRazorPage("/jobs/enqueued", x => new QueuesPage()); //Routes.AddRazorPage( // "/jobs/enqueued/fetched/(?.+)", - // x => new FetchedJobsPage(x.Groups["Queue"].Value)); + // x => new FetchedJobsPage(x.Groups["Queue"].Value)); //Routes.AddClientBatchCommand("/jobs/enqueued/delete", (client, jobId) => client.ChangeState(jobId, CreateDeletedState())); //Routes.AddClientBatchCommand("/jobs/enqueued/requeue", (client, jobId) => client.ChangeState(jobId, CreateEnqueuedState())); diff --git a/src/DotNetCore.CAP/Dashboard/HtmlHelper.cs b/src/DotNetCore.CAP/Dashboard/HtmlHelper.cs index fa4e52f..d3c83cb 100644 --- a/src/DotNetCore.CAP/Dashboard/HtmlHelper.cs +++ b/src/DotNetCore.CAP/Dashboard/HtmlHelper.cs @@ -23,22 +23,22 @@ namespace DotNetCore.CAP.Dashboard _page = page; } - //public NonEscapedString Breadcrumbs(string title, IDictionary items) - //{ - // if (items == null) throw new ArgumentNullException(nameof(items)); - // return RenderPartial(new Breadcrumbs(title, items)); - //} + public NonEscapedString Breadcrumbs(string title, IDictionary items) + { + if (items == null) throw new ArgumentNullException(nameof(items)); + return RenderPartial(new Breadcrumbs(title, items)); + } - //public NonEscapedString JobsSidebar() - //{ - // return RenderPartial(new SidebarMenu(JobsSidebarMenu.Items)); - //} + public NonEscapedString JobsSidebar() + { + return RenderPartial(new SidebarMenu(JobsSidebarMenu.Items)); + } - //public NonEscapedString SidebarMenu(IEnumerable> items) - //{ - // if (items == null) throw new ArgumentNullException(nameof(items)); - // return RenderPartial(new SidebarMenu(items)); - //} + public NonEscapedString SidebarMenu(IEnumerable> items) + { + if (items == null) throw new ArgumentNullException(nameof(items)); + return RenderPartial(new SidebarMenu(items)); + } public NonEscapedString BlockMetric(DashboardMetric metric) { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/QueuesPage.cshtml b/src/DotNetCore.CAP/Dashboard/Pages/QueuesPage.cshtml new file mode 100644 index 0000000..f449a84 --- /dev/null +++ b/src/DotNetCore.CAP/Dashboard/Pages/QueuesPage.cshtml @@ -0,0 +1,122 @@ +@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True *@ +@using System.Linq +@using DotNetCore.CAP.Dashboard +@using DotNetCore.CAP.Dashboard.Pages +@using DotNetCore.CAP.Dashboard.Resources +@inherits RazorPage +@{ + Layout = new LayoutPage(Strings.QueuesPage_Title); + + var monitor = Storage.GetMonitoringApi(); + var queues = monitor.Queues(); +} + +
+
+ @Html.JobsSidebar() +
+
+

@Strings.QueuesPage_Title

+ + @if (queues.Count == 0) + { +
+ @Strings.QueuesPage_NoQueues +
+ } + else + { +
+ + + + + + + + + + + @foreach (var queue in queues) + { + + + + + + + } + +
@Strings.QueuesPage_Table_Queue@Strings.QueuesPage_Table_Length@Strings.Common_Fetched@Strings.QueuesPage_Table_NextsJobs
@Html.QueueLabel(queue.Name)@queue.Length + @if (queue.Fetched.HasValue) + { + + @queue.Fetched + + } + else + { + @Strings.Common_NotAvailable + } + + @if (queue.FirstJobs.Count == 0) + { + + @Strings.QueuesPage_NoJobs + + } + else + { + + + + + + + + + + + @foreach (var job in queue.FirstJobs) + { + + + @if (job.Value == null) + { + + } + else + { + + + + } + + } + +
@Strings.Common_Id@Strings.Common_State@Strings.Common_Job@Strings.Common_Enqueued
+ @Html.JobIdLink(job.Key) + @if (job.Value != null && !job.Value.InEnqueuedState) + { + + } + @Strings.Common_JobExpired + @Html.StateLabel(job.Value.State) + + @Html.JobNameLink(job.Key, job.Value.Message) + + @if (job.Value.EnqueuedAt.HasValue) + { + @Html.RelativeTime(job.Value.EnqueuedAt.Value) + } + else + { + @Strings.Common_NotAvailable + } +
+ } +
+
+ } +
+
\ No newline at end of file diff --git a/src/DotNetCore.CAP/Dashboard/Pages/QueuesPage.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/QueuesPage.generated.cs new file mode 100644 index 0000000..31379c2 --- /dev/null +++ b/src/DotNetCore.CAP/Dashboard/Pages/QueuesPage.generated.cs @@ -0,0 +1,574 @@ +#pragma warning disable 1591 +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DotNetCore.CAP.Dashboard.Pages +{ + using System; + using System.Collections.Generic; + + #line 2 "..\..\Dashboard\Pages\QueuesPage.cshtml" + using System.Linq; + + #line default + #line hidden + using System.Text; + + #line 3 "..\..\Dashboard\Pages\QueuesPage.cshtml" + using DotNetCore.CAP.Dashboard; + + #line default + #line hidden + + #line 4 "..\..\Dashboard\Pages\QueuesPage.cshtml" + using DotNetCore.CAP.Dashboard.Pages; + + #line default + #line hidden + + #line 5 "..\..\Dashboard\Pages\QueuesPage.cshtml" + using DotNetCore.CAP.Dashboard.Resources; + + #line default + #line hidden + + [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] + internal partial class QueuesPage : RazorPage + { +#line hidden + + public override void Execute() + { + + +WriteLiteral("\r\n"); + + + + + + + + + #line 7 "..\..\Dashboard\Pages\QueuesPage.cshtml" + + Layout = new LayoutPage(Strings.QueuesPage_Title); + + var monitor = Storage.GetMonitoringApi(); + var queues = monitor.Queues(); + + + + #line default + #line hidden +WriteLiteral("\r\n
\r\n
\r\n "); + + + + #line 16 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Html.JobsSidebar()); + + + #line default + #line hidden +WriteLiteral("\r\n
\r\n
\r\n

"); + + + + #line 19 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.QueuesPage_Title); + + + #line default + #line hidden +WriteLiteral("

\r\n\r\n"); + + + + #line 21 "..\..\Dashboard\Pages\QueuesPage.cshtml" + if (queues.Count == 0) + { + + + #line default + #line hidden +WriteLiteral("
\r\n "); + + + + #line 24 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.QueuesPage_NoQueues); + + + #line default + #line hidden +WriteLiteral("\r\n
\r\n"); + + + + #line 26 "..\..\Dashboard\Pages\QueuesPage.cshtml" + } + else + { + + + #line default + #line hidden +WriteLiteral("
\r\n \r\n \r\n \r\n " + +" \r\n \r\n \r\n \r\n \r\n \r\n " + +" \r\n"); + + + + #line 40 "..\..\Dashboard\Pages\QueuesPage.cshtml" + foreach (var queue in queues) + { + + + #line default + #line hidden +WriteLiteral(" \r\n \r\n \r\n \r\n \r\n \r\n"); + + + + #line 116 "..\..\Dashboard\Pages\QueuesPage.cshtml" + } + + + #line default + #line hidden +WriteLiteral(" \r\n
"); + + + + #line 33 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.QueuesPage_Table_Queue); + + + #line default + #line hidden +WriteLiteral(""); + + + + #line 34 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.QueuesPage_Table_Length); + + + #line default + #line hidden +WriteLiteral(""); + + + + #line 35 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.Common_Fetched); + + + #line default + #line hidden +WriteLiteral(""); + + + + #line 36 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.QueuesPage_Table_NextsJobs); + + + #line default + #line hidden +WriteLiteral("
"); + + + + #line 43 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Html.QueueLabel(queue.Name)); + + + #line default + #line hidden +WriteLiteral(""); + + + + #line 44 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(queue.Length); + + + #line default + #line hidden +WriteLiteral("\r\n"); + + + + #line 46 "..\..\Dashboard\Pages\QueuesPage.cshtml" + if (queue.Fetched.HasValue) + { + + + #line default + #line hidden +WriteLiteral(" \r\n"); + + + + #line 51 "..\..\Dashboard\Pages\QueuesPage.cshtml" + } + else + { + + + #line default + #line hidden +WriteLiteral(" "); + + + + #line 54 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.Common_NotAvailable); + + + #line default + #line hidden +WriteLiteral("\r\n"); + + + + #line 55 "..\..\Dashboard\Pages\QueuesPage.cshtml" + } + + + #line default + #line hidden +WriteLiteral(" \r\n"); + + + + #line 58 "..\..\Dashboard\Pages\QueuesPage.cshtml" + if (queue.FirstJobs.Count == 0) + { + + + #line default + #line hidden +WriteLiteral(" \r\n " + +" "); + + + + #line 61 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.QueuesPage_NoJobs); + + + #line default + #line hidden +WriteLiteral("\r\n \r\n"); + + + + #line 63 "..\..\Dashboard\Pages\QueuesPage.cshtml" + } + else + { + + + #line default + #line hidden +WriteLiteral(@" + + + \r\n \r\n \r\n \r\n \r\n " + +" \r\n <" + +"tbody>\r\n"); + + + + #line 76 "..\..\Dashboard\Pages\QueuesPage.cshtml" + foreach (var job in queue.FirstJobs) + { + + + #line default + #line hidden +WriteLiteral(" \r\n \r\n"); + + + + #line 86 "..\..\Dashboard\Pages\QueuesPage.cshtml" + if (job.Value == null) + { + + + #line default + #line hidden +WriteLiteral(" \r\n"); + + + + #line 89 "..\..\Dashboard\Pages\QueuesPage.cshtml" + } + else + { + + + #line default + #line hidden +WriteLiteral(" \r\n"); + + + +WriteLiteral(" \r\n"); + + + +WriteLiteral(" \r\n"); + + + + #line 108 "..\..\Dashboard\Pages\QueuesPage.cshtml" + } + + + #line default + #line hidden +WriteLiteral(" \r\n"); + + + + #line 110 "..\..\Dashboard\Pages\QueuesPage.cshtml" + } + + + #line default + #line hidden +WriteLiteral(" \r\n " + +"
"); + + + + #line 69 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.Common_Id); + + + #line default + #line hidden +WriteLiteral("" + +""); + + + + #line 70 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.Common_State); + + + #line default + #line hidden +WriteLiteral(""); + + + + #line 71 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.Common_Job); + + + #line default + #line hidden +WriteLiteral(""); + + + + #line 72 "..\..\Dashboard\Pages\QueuesPage.cshtml" + Write(Strings.Common_Enqueued); + + + #line default + #line hidden +WriteLiteral("
\r\n"); + + + + #line 113 "..\..\Dashboard\Pages\QueuesPage.cshtml" + } + + + #line default + #line hidden +WriteLiteral("
\r\n
\r\n"); + + + + #line 120 "..\..\Dashboard\Pages\QueuesPage.cshtml" + } + + + #line default + #line hidden +WriteLiteral("
\r\n
"); + + + } + } +} +#pragma warning restore 1591 diff --git a/src/DotNetCore.CAP/Dashboard/Pages/_Breadcrumbs.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/_Breadcrumbs.generated.cs new file mode 100644 index 0000000..8e10a8a --- /dev/null +++ b/src/DotNetCore.CAP/Dashboard/Pages/_Breadcrumbs.generated.cs @@ -0,0 +1,105 @@ +#pragma warning disable 1591 +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DotNetCore.CAP.Dashboard.Pages +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + + #line 2 "..\..\Dashboard\Pages\_Breadcrumbs.cshtml" + using DotNetCore.CAP.Dashboard; + + #line default + #line hidden + + [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] + internal partial class Breadcrumbs : RazorPage + { +#line hidden + + public override void Execute() + { + + +WriteLiteral("\r\n"); + + + +WriteLiteral("\r\n
    \r\n
  1. \r\n"); + + + + #line 7 "..\..\Dashboard\Pages\_Breadcrumbs.cshtml" + foreach (var item in Items) + { + + + #line default + #line hidden +WriteLiteral("
  2. \r\n"); + + + + #line 10 "..\..\Dashboard\Pages\_Breadcrumbs.cshtml" + } + + + #line default + #line hidden +WriteLiteral("
  3. "); + + + + #line 11 "..\..\Dashboard\Pages\_Breadcrumbs.cshtml" + Write(Title); + + + #line default + #line hidden +WriteLiteral("
  4. \r\n
"); + + + } + } +} +#pragma warning restore 1591 diff --git a/src/DotNetCore.CAP/Dashboard/Pages/_SidebarMenu.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/_SidebarMenu.generated.cs new file mode 100644 index 0000000..98cd08f --- /dev/null +++ b/src/DotNetCore.CAP/Dashboard/Pages/_SidebarMenu.generated.cs @@ -0,0 +1,139 @@ +#pragma warning disable 1591 +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DotNetCore.CAP.Dashboard.Pages +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + + #line 2 "..\..\Dashboard\Pages\_SidebarMenu.cshtml" + using DotNetCore.CAP.Dashboard; + + #line default + #line hidden + + [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] + internal partial class SidebarMenu : RazorPage + { +#line hidden + + public override void Execute() + { + + +WriteLiteral("\r\n"); + + + + + + #line 4 "..\..\Dashboard\Pages\_SidebarMenu.cshtml" + if (Items.Any()) +{ + + + #line default + #line hidden +WriteLiteral(" \r\n"); + + + + #line 21 "..\..\Dashboard\Pages\_SidebarMenu.cshtml" +} + + + #line default + #line hidden + + } + } +} +#pragma warning restore 1591